import{o as r}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as e,ki as n}from"./vendor-frame-CwiylG4Y.js";import{ph as o}from"./shared-1-3-6x7RKF.js";import{Ao as s}from"./shared-6-Cf_fMhRZ.js";import{x as t}from"./shared-3-D-Ux4aGn.js";import{in as a,wn as i}from"./shared-8-C1HP2d2B.js";import{t as c}from"./cb9398eea-DNrEzJ-2.js";var l=r(e());function u(r){return"string"==typeof r?r:void 0}function d(r){if(!r||"object"!=typeof r)return null;const e=r,n=u(e.name);return n?{name:n,price:u(e.price),blurb:u(e.blurb),url:u(e.url)}:null}var m=n(),f=(0,l.memo)(function({data:r,disableAnalytics:e,onLearnMore:n,onDomainClick:o,onSourcesInfoOpen:s}){const{products:t}=r;return(0,m.jsx)("div",{className:"@container flex w-full flex-col gap-md font-ui",children:(0,m.jsx)("div",{className:"grid grid-cols-1 gap-md "+(1===t.length?"":"@[480px]:grid-cols-2"),children:t.map((r,t)=>(0,m.jsx)(c,{product:r,widgetType:"featured_card",disableAnalytics:e,onLearnMore:n,onDomainClick:o,onSourcesInfoOpen:s},`${r.name}-${t}`))})})}),p=(0,l.memo)(function(){return(0,m.jsx)("div",{className:"grid grid-cols-2 gap-md font-ui",children:Array.from({length:2},(r,e)=>(0,m.jsxs)("div",{className:"flex flex-col gap-3 bg-surface-2 p-lg",style:{borderRadius:i},children:[(0,m.jsx)(a,{width:"70%",height:22}),(0,m.jsx)(a,{width:"40%",height:14}),(0,m.jsx)(a,{width:"100%",height:48})]},e))})}),h=(0,l.memo)(function({input:r,isStreaming:e,partialJson:n,conversationUuid:a,disableAnalytics:i}){const{shownRef:c,trackClick:h,trackRender:g}=s("featured_card",a,i),j=t(),y=(0,l.useMemo)(()=>{const e=function(r){let e;if("string"==typeof r)try{e=o(r)}catch{return null}else{if(!r||"object"!=typeof r)return null;e=r}if(!e||"object"!=typeof e)return null;const n=e,s=[],t=[];if(Array.isArray(n.products))for(let o=0;o<n.products.length&&s.length<6;o++){const r=d(n.products[o]);r&&(s.push(r),t.push(o))}return 0===s.length?null:{products:s,sourceIndices:t,summary:u(n.summary)}}(n??r);if(!e)return null;const s=r&&"object"==typeof r?r.products:void 0,t=e.products.map((r,n)=>{const o=s?.[e.sourceIndices[n]];return Array.isArray(o?.images)?{...r,images:o.images}:r});return{...e,products:t}},[n,r]);(0,l.useEffect)(()=>{e||g(y?"rendered":"blank")},[e,y,g]);const b=(0,l.useCallback)(()=>h("learn_more"),[h]),x=(0,l.useCallback)(()=>h("sources_info_open"),[h]),k=(0,l.useCallback)(r=>j(r.telemetry),[j]);return y?(0,m.jsx)("div",{ref:c,children:(0,m.jsx)(f,{data:y,disableAnalytics:i,onLearnMore:b,onDomainClick:k,onSourcesInfoOpen:x})}):e?(0,m.jsx)(p,{}):null});export{h as default};