import{r as e,j as r}from"./vendor-react-Dp9pL_Wn.js";import{a0 as s,a6 as t,a9 as o,_ as a,a1 as n}from"./index-DhMXk6CR.js";import{u as i}from"./vendor-intl-D2wGIp4M.js";import{I as l}from"./vendor-ant-cds-bBedrtIN.js";import{Q as c}from"./c6eedc03a-CsEFTfjy.js";import"./vendor-infra-DayZK7Ds.js";import"./vendor-zod-0xcuG3aM.js";import"./vendor-router-qG5OCEmI.js";import"./vendor-query-BwvgHhJ1.js";import"./vendor-zustand-BeF8W8xk.js";import"./caf7c7e06-DJYXCm3T.js";import"./vendor-base-ui-DNypCIlh.js";import"./vendor-radix-Ch96tRrt.js";import"./vendor-base-5_f7mmWg.js";import"./vendor-lodash-BvMLws5K.js";import"./vendor-icons-CokWnmlw.js";import"./vendor-motion-EDlUw66k.js";import"./c5669b8e4-DFSq88jr.js";import"./vendor-luxon-CZxT8ieM.js";import"./c5f4e1303-CiyIFgnl.js";import"./cbaad2c48-DaP34LG2.js";import"./vendor-virtual-DRz8lJfQ.js";import"./vendor-growthbook-C66YtMMX.js";import"./vendor-zod-v3-CZy0YPWu.js";const d={"--row-hover":"hsl(from var(--cds-neutral-900) h s l / 2.5%)"},m=e.memo(function({value:e}){const s=i();if("string"==typeof e)return r.jsx("span",{className:"text-body text-primary",children:e});const t=e?s.formatMessage({defaultMessage:"Yes",id:"a5msuh5ORp"}):s.formatMessage({defaultMessage:"No",id:"oUWADlOjJt"});return r.jsxs("span",{className:"inline-flex items-center",children:[r.jsx(l,{name:e?"Check":"X",size:"md","aria-hidden":!0,className:e?"text-success":"text-danger"}),r.jsx("span",{className:"sr-only",children:t})]})}),u=e.memo(function({data:e}){const{products:a}=e,n={gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`,...d,borderRadius:s},i=a.reduce((e,r)=>Math.max(e,r.attributes.length),0);return r.jsxs("div",{className:"relative grid overflow-hidden bg-surface-2 font-ui",style:n,children:[a.map((e,s)=>r.jsxs("div",{className:"flex min-w-0 flex-col gap-xs px-lg pb-md pt-lg",children:[r.jsx("span",{className:t,children:e.name}),e.price&&r.jsx("span",{className:"text-body text-primary",children:e.price})]},`hd-${e.name}-${s}`)),r.jsx("div",{className:"group/rows contents",children:Array.from({length:i},(e,s)=>r.jsx("div",{className:"group/row contents",children:a.map((e,t)=>{const o=e.attributes[s],a=s===i-1;return r.jsx("div",{className:"min-w-0 border-t px-lg pt-md group-hover/row:bg-[var(--row-hover)] "+(a?"pb-lg":"pb-md"),children:r.jsx("div",{className:"flex flex-col gap-xs group-hover/rows:opacity-50 group-hover/row:!opacity-100",children:o&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-footnote text-secondary",children:o.label}),r.jsx(m,{value:o.value})]})})},`a-${s}-${t}`)})},`r-${s}`))}),r.jsx(o,{})]})});function p(e){return"string"==typeof e?e:void 0}function f(e){if(!e||"object"!=typeof e)return null;const r=e,s=p(r.label),t="boolean"==typeof r.value?r.value:p(r.value);return s&&void 0!==t&&""!==t?{label:s,value:t}:null}function j(e){if(!e||"object"!=typeof e)return null;const r=e,s=p(r.name);if(!s)return null;const t=Array.isArray(r.attributes)?r.attributes.map(f).filter(e=>null!==e).slice(0,8):[];return{name:s,price:p(r.price),attributes:t,url:p(r.url)}}const h=e.memo(function(){return r.jsx("div",{className:"grid grid-cols-3 gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:s},children:Array.from({length:3},(e,s)=>r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(n,{width:"80%",height:22}),r.jsx(n,{width:"50%",height:14}),r.jsx(n,{width:"100%",height:56}),r.jsx(n,{width:"100%",height:56})]},s))})}),x=e.memo(function({input:s,isStreaming:t,partialJson:o,conversationUuid:n,disableAnalytics:i}){const{shownRef:l,trackRender:d}=a("comparison_card",n,i),m=e.useMemo(()=>function(e){let r;if("string"==typeof e)try{r=c(e)}catch{return null}else{if(!e||"object"!=typeof e)return null;r=e}if(!r||"object"!=typeof r)return null;const s=r,t=Array.isArray(s.products)?s.products.map(j).filter(e=>null!==e).slice(0,3):[];return 0===t.length?null:{products:t,summary:p(s.summary)}}(o??s),[o,s]);return e.useEffect(()=>{t||d(m?"rendered":"blank")},[t,m,d]),m?r.jsx("div",{ref:l,children:r.jsx(u,{data:m})}):t?r.jsx(h,{}):null});export{x as default};
