@dori-ai/dori-side-widget 1.13.199 → 1.13.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MarkdownContent-ZQGRMI3l.js","./provider-CTqPyzps.js","../widget.js","./store-font-B5B6CNk6.js","./link-7TSqfFm_.js"])))=>i.map(i=>d[i]);
2
+ import{l as e,h as t,i as n,o as r,n as o,a,t as i,b as s,c as l,g as c,d,e as u,j as p,k as h,m as f,_ as g,s as m,q as b,r as x,u as y,v as w,w as v,x as k,y as S,z as j,B as C,C as z,D as A,E,F as T,G as R,H as W,I,J as B,K as M,L as _,M as F,N as L,O as D}from"../widget.js";import{r as P,a as H,u as q,g as O,b as Y,c as N,d as U,m as V,j as K,e as Q,f as Z,h as G,i as X,k as J,l as $,n as ee,o as te,B as ne,I as re,H as oe,p as ae,q as ie,T as se,C as le,E as ce,s as de,R as ue,t as pe,v as he,V as fe,w as ge,S as me,x as be,A as xe,y as ye,z as we,D as ve,F as ke,G as Se,J as je,K as Ce,L as ze,M as Ae,N as Ee,O as Te,P as Re,Q as We,U as Ie,W as Be,X as Me,Y as _e,Z as Fe,_ as Le,$ as De,a0 as Pe,a1 as He,a2 as qe,a3 as Oe,a4 as Ye,a5 as Ne,a6 as Ue,a7 as Ve,a8 as Ke,a9 as Qe,aa as Ze,ab as Ge,ac as Xe,ad as Je,ae as $e,af as et,ag as tt,ah as nt,ai as rt,aj as ot,ak as at,al as it,am as st,an as lt,ao as ct,ap as dt,aq as ut,ar as pt,as as ht,at as ft,au as gt,av as mt,aw as bt,ax as xt,ay as yt,az as wt,aA as vt,aB as kt,aC as St,aD as jt,aE as Ct,aF as zt,aG as At,aH as Et,aI as Tt,aJ as Rt,aK as Wt,aL as It,aM as Bt,aN as Mt,aO as _t,aP as Ft,aQ as Lt,aR as Dt,aS as Pt,aT as Ht,aU as qt,aV as Ot,aW as Yt,aX as Nt,aY as Ut,aZ as Vt,a_ as Kt,a$ as Qt,b0 as Zt,b1 as Gt,b2 as Xt,b3 as Jt,b4 as $t,b5 as en,b6 as tn,b7 as nn,b8 as rn,b9 as on,ba as an,bb as sn,bc as ln,bd as cn,be as dn,bf as un,bg as pn,bh as hn,bi as fn,bj as gn,bk as mn,bl as bn}from"./provider-CTqPyzps.js";import{U as xn,w as yn}from"./store-font-B5B6CNk6.js";import{L as wn}from"./link-7TSqfFm_.js";import{d as vn,s as kn}from"./report-BHr6U1PB.js";var Sn=P();function jn(e,t){const n=q().normalizeValue(e),r=function(e={}){e.fallback||(e.fallback="base");const t=q();let n=!1;const r=t.breakpoints.values.map(({min:t,name:r})=>{const o={breakpoint:r,query:`(min-width: ${t})`,fallback:!n};return r===e.fallback&&(n=!0),o}).filter(({breakpoint:t})=>!!e.breakpoints?.includes(t)),o=r.map(({fallback:e})=>e),a=function(e,t={}){const{fallback:n=[],ssr:r=!0,getWindow:o}=t,a=function(e,t=[]){const n=H.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return H.useInsertionEffect(()=>{n.current=e}),H.useCallback((...e)=>n.current?.(...e),t)}(o),i=Array.isArray(e)?e:[e],s=n?.filter(e=>null!=e),[l,c]=H.useState(()=>i.map((e,t)=>{if(!r){const{media:t,matches:n}=(o?.()??window).matchMedia(e);return{media:t,matches:n}}return{media:e,matches:!!s[t]}}));return H.useEffect(()=>{const e=a()??window;c(t=>{const n=i.map(t=>{const{media:n,matches:r}=e.matchMedia(t);return{media:n,matches:r}});return t.every((e,t)=>e.matches===n[t].matches&&e.media===n[t].media)?t:n});const t=i.map(t=>e.matchMedia(t)),n=e=>{c(t=>t.slice().map(t=>t.media===e.media?{...t,matches:e.matches}:t))},r=t.map(e=>function(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}(e,n));return()=>r.forEach(e=>e())},[a]),l.map(e=>e.matches)}(r.map(e=>e.query),{fallback:o,ssr:e.ssr}).lastIndexOf(!0);return r[a]?.breakpoint??e.fallback}({breakpoints:Object.keys(n),...t});return n[r]}var Cn=e=>{if(!e)return;const t=O(e),n=Y(e),r=N(e),o=()=>{requestAnimationFrame(()=>{let n;e.style.height="auto",n="content-box"===t.boxSizing?e.scrollHeight-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):e.scrollHeight+parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),"none"!==t.maxHeight&&n>parseFloat(t.maxHeight)?("hidden"===t.overflowY&&(e.style.overflowY="scroll"),n=parseFloat(t.maxHeight)):"hidden"!==t.overflowY&&(e.style.overflowY="hidden"),e.style.height=`${n}px`})};e.addEventListener("input",o),e.form?.addEventListener("reset",o);const a=Object.getPrototypeOf(e),i=Object.getOwnPropertyDescriptor(a,"value");Object.defineProperty(e,"value",{...i,set(){i?.set?.apply(this,arguments),o()}});const s=new n.ResizeObserver(()=>{requestAnimationFrame(()=>o())});s.observe(e);const l=new n.MutationObserver(()=>o());return l.observe(e,{attributes:!0,attributeFilter:["rows","placeholder"]}),r.fonts?.addEventListener("loadingdone",o),()=>{e.removeEventListener("input",o),e.form?.removeEventListener("reset",o),r.fonts?.removeEventListener("loadingdone",o),s.disconnect(),l.disconnect()}};const zn=H.forwardRef((e,t)=>{const{autoresize:n,...r}=e,o=H.useRef(null),a=U(),i=V(a?.getTextareaProps(),{style:{resize:n?"none":void 0}},r);return H.useEffect(()=>{if(n)return Cn(o.current)},[n]),K.jsx(Q.textarea,{...i,ref:Z(t,o)})});zn.displayName="FieldTextarea";const An=H.forwardRef(function(e,t){const{direction:n,align:r,justify:o,wrap:a,basis:i,grow:s,shrink:l,inline:c,...d}=e;return K.jsx(G.div,{ref:t,...d,css:{display:c?"inline-flex":"flex",flexDirection:n,alignItems:r,justifyContent:o,flexWrap:a,flexBasis:i,flexGrow:s,flexShrink:l,...e.css}})}),{withContext:En}=X({key:"textarea"}),Tn=En(zn),Rn=""+new URL("dori.ico",import.meta.url).href,Wn=({onClose:e,isMobile:t=!1,isExpanded:a=!1,onToggleExpand:i,fullPageHref:s,onReload:l})=>{const{botData:c,cartItemCount:d,shortlistEnabled:u,shortlist:p,setShortlistOpen:h}=J(),f=$(),{t:g}=ee(),m=n(c)&&d>0,b=u&&p.length>0,x=c?.bot_image?c.bot_image:Rn,y=te(x),w=he(y.ratio),[v,k]=H.useState(!1),S=H.useRef(p.length);H.useEffect(()=>{if(p.length===S.current)return;S.current=p.length,k(!0);const e=setTimeout(()=>k(!1),250);return()=>clearTimeout(e)},[p.length]);const j=H.useRef(null),[C,z]=H.useState(!1),A=g(s?"aiPageOpenFull":a?"minimize":"showFullScreen");H.useLayoutEffect(()=>{const e=j.current;if(!e)return;const t=()=>{e.setAttribute("data-fit-measure","");const t=e.scrollWidth>e.clientWidth+1;e.removeAttribute("data-fit-measure"),z(t)};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[A,m,d,b,p.length,t,y.ratio,f]);const E=K.jsx(ne,{as:"span",css:{display:C?"none":void 0,"[data-fit-measure] &":{display:"inline"}},children:A}),T=`calc(${f.font(13)} * 1.5 + 2 * ${f.length(5)})`;return K.jsxs(An,{ref:j,justify:"space-between",align:"center",gap:f.space(3),flexShrink:0,children:[c?.feature_flags?.hide_header_logo?K.jsx(ne,{h:f.length(40)}):K.jsx(re,{src:x,alt:"",role:"presentation",onLoad:y.onLoad,h:f.length(40),w:w?"auto":f.length(40),maxW:w?f.length(140):void 0,objectFit:w?"contain":"cover",borderRadius:w?f.radius(6):"50%",flexShrink:w?1:0,minW:0,css:{"[data-fit-measure] &":{flexShrink:0}}}),K.jsxs(oe,{gap:f.space(3),flexShrink:0,children:[b&&K.jsxs(ae,{variant:"outline",size:"sm",borderRadius:f.radius(4),px:f.space(2),height:"auto",lineHeight:"1.5",border:"none",color:"text",bgColor:"lightBackground",_hover:{bgColor:"veryLightBackground"},padding:`${f.length(5)} ${f.length(9)}`,transform:v?"scale(1.12)":"scale(1)",transition:"transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1)",onClick:()=>h(!0),"aria-label":g("savedProducts"),fontFamily:xn,children:[K.jsx(ie,{boxSize:f.length(15),color:"primary"}),K.jsx(se,{fontSize:f.font(13),fontWeight:"500",color:"text",children:p.length})]}),m&&K.jsxs(ae,{variant:"outline",size:"sm",borderRadius:f.radius(4),px:f.space(2),height:"auto",lineHeight:"1.5",border:"none",color:"text",bgColor:"lightBackground",_hover:{bgColor:"veryLightBackground"},padding:`${f.length(5)} ${f.length(9)}`,onClick:()=>{if(!r()){const e=`${o()}cart`;window.open(e,"_blank","noopener,noreferrer")||(window.location.href=e)}},fontFamily:xn,children:[K.jsx(le,{boxSize:f.length(16),color:"text"}),K.jsx(se,{fontSize:f.font(13),fontWeight:"500",color:"text",children:d})]}),s?K.jsx(ae,{asChild:!0,variant:"outline",size:"sm",borderRadius:f.radius(4),px:f.space(3),height:"auto",lineHeight:"1.5",border:"none",color:"text",bgColor:"lightBackground",_hover:{bgColor:"veryLightBackground"},padding:`${f.length(5)} ${f.length(9)}`,minH:T,fontFamily:xn,children:K.jsxs("a",{href:s,"aria-label":A,title:C?A:void 0,children:[K.jsx(ce,{boxSize:f.length(16),color:"text"}),E]})}):!t&&i&&K.jsxs(ae,{variant:"outline",size:"sm",borderRadius:f.radius(4),px:f.space(3),height:"auto",lineHeight:"1.5",border:"none",color:"text",bgColor:"lightBackground",_hover:{bgColor:"veryLightBackground"},padding:`${f.length(5)} ${f.length(9)}`,minH:T,onClick:()=>i?.(),fontFamily:xn,"aria-label":A,title:C?A:void 0,children:[K.jsx(ce,{boxSize:f.length(16),color:"text"}),E]}),l&&K.jsx(de,{size:"sm",boxSize:f.length(36),minW:f.length(36),variant:"ghost","aria-label":g("reload"),onClick:l,color:"text",_hover:{bgColor:"mutedText"},children:K.jsx(ue,{boxSize:t?f.length(16):f.length(24),color:"text"})}),K.jsx(de,{size:"sm",boxSize:f.length(36),minW:f.length(36),variant:"ghost","aria-label":g("close"),onClick:()=>{a&&i?.(),e()},color:"text",_hover:{bgColor:"mutedText"},children:K.jsx(pe,{boxSize:t?f.length(16):f.length(24),color:"text"})})]})]})};class In{static async getUploadCredentials(e){const t={file_extension:e,expires_in:3600,content_length_range:{min_bytes:1024,max_bytes:10485760}},n=await fetch(a.getUploadUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!n.ok)throw new Error(`Failed to get upload credentials: ${n.status} ${n.statusText}`);return await n.json()}static async compressImage(e,t=1024,n=.8){return new Promise(r=>{const o=document.createElement("canvas"),a=o.getContext("2d"),i=new Image;i.onload=()=>{const{width:s,height:l}=this.calculateDimensions(i.width,i.height,t);o.width=s,o.height=l,a.drawImage(i,0,0,s,l),o.toBlob(t=>{const a=new File([t],e.name,{type:"image/jpeg",lastModified:Date.now()});r({file:a,preview:o.toDataURL("image/jpeg",n),format:"jpeg"})},"image/jpeg",n)},i.src=URL.createObjectURL(e)})}static getFileExtension(e){const t=e.name.split(".").pop()?.toLowerCase();switch(t){case"jpg":case"jpeg":default:return"jpeg";case"webp":return"webp";case"png":return"png";case"heic":return"heic"}}static calculateDimensions(e,t,n){if(e<=n)return{width:e,height:t};const r=t/e;return{width:n,height:Math.round(n*r)}}static async uploadImage(e,t){const n=new FormData;Object.entries(e.fields).forEach(([e,t])=>{n.append(e,t)}),n.append("file",t);const r=await fetch(e.url,{method:"POST",body:n});if(!r.ok&&204!==r.status)throw new Error("Error uploading image");return e.public_url}}const Bn=()=>{const[e,t]=H.useState(null),[n,r]=H.useState(!1);return{uploadedImage:e,isUploading:n,handleFileSelect:()=>{const e=document.createElement("input");e.type="file",e.accept="image/jpeg,image/jpg,image/webp,image/png,image/heic",e.onchange=e=>{const n=e.target.files?.[0];n&&(async e=>{try{r(!0);const n=await In.compressImage(e),o=await In.getUploadCredentials(n.format),a=await In.uploadImage(o,n.file);t({url:a,preview:n.preview,name:e.name,size:n.file.size})}catch(n){console.error("Upload failed:",n),alert("Failed to upload image")}finally{r(!1)}})(n)},e.click()},removeImage:()=>{e?.preview&&URL.revokeObjectURL(e.preview),t(null)}}},Mn=({imageUrl:e,onRemove:t})=>{const n=$();return K.jsxs("div",{style:{position:"relative",display:"inline-block",background:"transparent"},children:[K.jsx(re,{src:e,alt:"Uploaded image",w:n.length(80),h:n.length(80),borderRadius:n.radius(12),objectFit:"cover",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.11)"}),K.jsx(de,{position:"absolute",top:n.length(6),right:n.length(6),bg:"primary",color:"buttonText","aria-label":"Remove image",onClick:t,size:"sm",borderRadius:"50%",minW:n.length(24),h:n.length(24),children:K.jsx(pe,{boxSize:n.length(14)})})]})},_n=()=>{const[e,t]=H.useState(!1);return H.useEffect(()=>{const e=e=>{"Tab"===e.key&&t(!0)},n=()=>t(!1);return window.addEventListener("keydown",e,!0),window.addEventListener("pointerdown",n,!0),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("pointerdown",n,!0)}},[]),e},Fn=e=>e?{"&:has(textarea:focus, input:focus)":{boxShadow:"inset 0 0 0 2px var(--chakra-colors-text)"}}:void 0,Ln=({placeholder:e="Write a prompt or paste a contract address",value:t="",onChange:n,onSend:r,isMobileView:o})=>{const{t:a}=ee(),i=_n(),{botData:s,chatState:{repliedProduct:l},setRepliedProduct:c}=J(),d=!s?.feature_flags?.hide_image_upload,u=$(),[p,h]=H.useState(t),{uploadedImage:f,isUploading:g,handleFileSelect:m,removeImage:b}=Bn();H.useEffect(()=>{h(y(t))},[t]);const x=e=>{(p.trim()||e||f)&&(r?.({message:e??p.trim(),imageUrl:f?.url},l?.product),c?.(null),h(""),b())},y=e=>e.trimStart();return K.jsxs(fe,{gap:u.space(2),align:"stretch",bg:"transparent",position:"relative",children:[f&&K.jsx(ne,{position:"absolute",bottom:l?o?u.length(300):u.length(190):u.length(90),left:u.length(12),zIndex:1e6,bg:"transparent",pointerEvents:"auto",children:K.jsx(Mn,{imageUrl:f.preview,onRemove:b})}),K.jsx(ne,{bgColor:"lightBackground",borderRadius:u.radius(24),css:Fn(i),position:"relative",p:u.space(2),w:"full",h:l?o?u.length(300):u.length(190):u.length(90),transition:"all 0.6s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",transform:"scale(1)",opacity:1,children:K.jsxs(ne,{position:"absolute",top:0,left:0,right:0,bottom:0,p:u.space(2),opacity:1,transform:"translateY(0) scale(1)",transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:"auto",children:[l&&K.jsxs(fe,{opacity:1,p:u.length(8),gap:u.length(8),borderRadius:u.radius(12),borderWidth:"1px",borderColor:"borderColor",bgColor:"lightBackground",children:[K.jsxs(oe,{justify:"space-between",align:"center",w:"full",children:[K.jsx(re,{src:l?.product?.image,alt:"product",w:u.length(40),h:u.length(40)}),K.jsx(se,{fontSize:u.font(12),fontWeight:400,color:"text",children:l?.product?.name}),K.jsx(de,{bg:"transparent","aria-label":"Remove product",onClick:()=>c?.(null),children:K.jsx(pe,{boxSize:u.length(24),color:"text"})})]}),l?.suggestions&&l.suggestions.length>0&&K.jsxs(K.Fragment,{children:[K.jsx(ne,{display:{base:"none",md:"block"},w:"full",children:K.jsx(oe,{w:"full",justify:"flex-start",align:"center",gap:u.space(2),children:l.suggestions.map(e=>K.jsx(ae,{variant:"outline",bg:"transparent",color:"text",fontSize:u.font(12),borderColor:"borderColor",borderRadius:u.radius(24),fontWeight:400,onClick:()=>x(e),h:u.length(32),px:u.space(3),minW:"unset",flex:1,lineHeight:"1.5",overflow:"hidden",children:K.jsx(ne,{as:"span",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",w:"100%",children:e})},e))})}),K.jsx(ne,{display:{base:"block",md:"none"},w:"full",children:K.jsx(fe,{w:"full",align:"stretch",gap:u.length(8),children:l.suggestions.map(e=>K.jsx(ae,{variant:"outline",bg:"transparent",w:"full",color:"text",fontSize:u.font(14),borderColor:"borderColor",borderRadius:u.radius(24),fontWeight:400,onClick:()=>x(e),children:e},e))})})]})]}),K.jsx(Tn,{"aria-label":a("messageInputLabel"),value:p,onChange:e=>(e=>{const t=y(e);h(t),n?.(t)})(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.repeat||(e.preventDefault(),x())},placeholder:e,fontSize:ge(u,16),color:"text",fontWeight:300,resize:"none",rows:1,lineHeight:"1.5",h:"100%",border:"none",bg:"transparent",_focus:{boxShadow:"none",border:"none",outline:"none"},_placeholder:{color:"mutedText"},pr:u.length(48),transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)"}),d&&K.jsx(de,{position:"absolute",bottom:u.length(8),left:u.length(12),size:"xs",boxSize:u.length(32),minW:u.length(32),borderRadius:"full",bg:"background","aria-label":"Upload image",onClick:m,_hover:{bg:"background"},disabled:g,transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",transform:"scale(1)",zIndex:2,border:"1px solid",borderColor:"borderColor",color:"text",children:g?K.jsx(me,{size:"sm",color:"text"}):K.jsx(be,{color:"text"})}),K.jsx(de,{position:"absolute",bottom:u.length(12),right:u.length(12),size:"xs",boxSize:u.length(32),minW:u.length(32),borderRadius:"full",bg:"background",color:"text","aria-label":"Send",onClick:()=>x(),_hover:{bg:"veryLightBackground"},disabled:!p.trim()&&!f,transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",_disabled:{bg:"background",cursor:"not-allowed",opacity:.7},transform:"scale(1)",zIndex:2,children:K.jsx(xe,{boxSize:u.length(30),color:"primary"})})]})})]})},Dn=({placeholder:e="Write a prompt or paste a contract address",onStop:t})=>{const n=$(),{stopCurrentRequest:r}=J();return K.jsx(fe,{gap:n.space(2),align:"stretch",bg:"transparent",position:"relative",children:K.jsx(ne,{bg:"lightBackground",borderRadius:n.radius(32),position:"relative",p:n.space(3),w:"full",h:n.length(48),transition:"all 0.6s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",transform:"scale(1)",opacity:1,children:K.jsx(ne,{position:"absolute",top:0,left:0,right:0,bottom:0,p:n.space(3),opacity:1,transform:"translateY(0) scale(1)",transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:"auto",children:K.jsxs(oe,{justify:"space-between",align:"center",h:"full",children:[K.jsx(se,{color:"mutedText",fontSize:n.font(16),flex:1,transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",children:e}),K.jsx(de,{size:"xs",boxSize:n.length(32),minW:n.length(32),borderRadius:"full",bg:"background",color:"text","aria-label":"Stop",onClick:()=>{r?.(),t?.()},_hover:{bg:"veryLightBackground"},transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",transform:"scale(1)",zIndex:2,children:K.jsx(ye,{boxSize:n.length(30),color:"primary"})})]})})})})},Pn=({placeholder:e="Write a prompt or paste a contract address",value:t="",onChange:n,onSend:r})=>{const{t:o}=ee(),a=_n(),i=$(),{botData:s}=J(),l=!s?.feature_flags?.hide_image_upload,[c,d]=H.useState(t),[u,p]=H.useState(!1),{uploadedImage:h,isUploading:f,handleFileSelect:g,removeImage:m}=Bn(),b=H.useRef(null);H.useEffect(()=>{d(t)},[t]);const x=()=>{(c.trim()||h)&&(r?.({message:c.trim(),imageUrl:h?.url}),d(""),m())};return K.jsxs(fe,{gap:i.space(2),align:"stretch",children:[h&&K.jsx(ne,{mb:i.space(2),alignSelf:"flex-start",bg:"transparent",children:K.jsx(Mn,{imageUrl:h.preview,onRemove:m})}),K.jsxs(ne,{bg:"lightBackground",borderRadius:i.radius(24),css:Fn(a),position:"relative",p:i.space(2),w:"full",h:u?i.length(80):i.length(48),transition:"all 0.6s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",cursor:"pointer",onClick:()=>{p(!0),setTimeout(()=>{if(b.current){b.current.focus();const e=b.current.value.length;b.current.setSelectionRange(e,e)}},100)},children:[K.jsx(ne,{position:"absolute",top:i.length(8),left:i.length(8),zIndex:2,children:K.jsx(we,{w:i.length(24),h:i.length(24),transform:"rotate(2700deg)",color:"primary"})}),K.jsx(ne,{position:"absolute",top:0,left:0,right:0,bottom:0,p:i.space(2),opacity:u?0:1,transform:u?"translateY(-20px) scale(0.95)":"translateY(0) scale(1)",transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:u?"none":"auto",children:K.jsx(oe,{justify:"space-between",align:"center",h:"full",children:K.jsx(se,{color:"#999999",fontSize:i.font(16),flex:1,paddingStart:i.length(32),transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",children:e})})}),l&&K.jsx(de,{position:"absolute",bottom:i.length(7.5),right:i.length(52),size:"xs",boxSize:i.length(32),minW:i.length(32),borderRadius:"full",bg:"background",color:"text","aria-label":"Upload image",onClick:e=>{e.stopPropagation(),g()},_hover:{bg:"veryLightBackground"},disabled:f,transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",transform:"scale(1)",zIndex:2,border:"1px solid",borderColor:"borderColor",children:f?K.jsx(me,{size:"sm"}):K.jsx(be,{size:i.length(24)})}),K.jsx(de,{position:"absolute",bottom:i.length(8),right:i.length(12),size:"xs",boxSize:i.length(32),minW:i.length(32),borderRadius:"full",bg:"primary","aria-label":"Send",onClick:e=>{e.stopPropagation(),x()},_hover:{bg:"darkPrimary"},disabled:!c.trim()&&!h,transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",_disabled:{bg:"primary",opacity:.5,cursor:"not-allowed"},transform:"scale(1) rotate(180deg)",zIndex:2,children:K.jsx(ve,{boxSize:i.length(30),color:"buttonText"})}),K.jsx(ne,{position:"absolute",top:0,left:0,right:0,bottom:0,p:i.space(2),opacity:u?1:0,transform:u?"translateY(0) scale(1)":"translateY(20px) scale(0.95)",transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:u?"auto":"none",children:K.jsx(Tn,{"aria-label":o("messageInputLabel"),ref:b,value:c,onChange:e=>{return t=e.target.value,d(t),void n?.(t);var t},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.repeat||(e.preventDefault(),x())},placeholder:e,paddingLeft:i.length(32),paddingRight:l?i.length(80):i.length(40),fontSize:ge(i,16),color:"text",fontWeight:300,resize:"none",h:"100%",border:"none",bg:"transparent",cursor:"text",_focus:{boxShadow:"none",border:"none",outline:"none"},_placeholder:{color:"mutedText"},transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",rows:2,lineHeight:"1.5"})})]})]})},Hn=({state:e="starting",placeholder:t="Write a prompt or paste a contract address",value:n="",onChange:r,onSend:o,onStop:a})=>{const[i,s]=H.useState(!1);return H.useEffect(()=>{const e=()=>{s(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),"starting"===e?K.jsx(Ln,{placeholder:t,value:n,onChange:r,onSend:o,isMobileView:i}):"generating"===e?K.jsx(Dn,{placeholder:t,onStop:a,isMobileView:i}):K.jsx(Pn,{placeholder:t,value:n,onChange:r,onSend:o})};function qn(e){const t=e?.white_label;if(t?.ai_notice_only)return{kind:"none"};const n=t?.logo_url?.trim();if(n)return{kind:"merchant",src:n,alt:t?.logo_alt?.trim()||e?.bot_name||"Store logo"};const r=Boolean(t?.disclaimer_text?.trim());return t?.is_white_labeled||r?{kind:"none"}:{kind:"dori"}}function On(e){return!e?.white_label?.ai_notice_only&&!1!==e?.customization?.enable_shopper_memory}function Yn(e){return"dori"===qn(e).kind?"Dori":e?.agent_name?.trim()||e?.bot_name?.trim()||"Dori"}const Nn="/policies/privacy-policy",Un=()=>{const{t:e}=ee(),{botData:t}=J(),n=$(),[r,o]=H.useState(!1);return K.jsxs(ne,{position:"relative",display:"inline-flex",alignItems:"center",children:[K.jsxs(ne,{as:"span",display:"inline-flex",alignItems:"center",gap:n.space(1),tabIndex:0,cursor:"default",px:n.space(2),py:"1px",borderRadius:"9999px",bgGradient:"to-r",gradientFrom:"primaryWash",gradientTo:"primaryWashStrong",color:"darkPrimary",border:"1px solid",borderColor:"primaryWash",lineHeight:"1.25",transition:"background 120ms ease, box-shadow 120ms ease",_hover:{boxShadow:"0 1px 6px rgba(0,0,0,0.10)"},_focusVisible:{outline:"2px solid",outlineColor:"primary",outlineOffset:"1px"},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),"aria-describedby":"dori-personalized-tip",children:[K.jsx(ke,{boxSize:n.font(11),"aria-hidden":"true"}),K.jsx(se,{as:"span",fontSize:n.font(10),fontWeight:"600",children:e("personalizedBadge")})]}),r&&K.jsx(ne,{id:"dori-personalized-tip",role:"tooltip",position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",zIndex:20,width:"max(220px, 80%)",maxW:"260px",bg:"rgba(32,34,35,0.96)",color:"white",fontSize:n.font(11),lineHeight:"1.45",px:n.space(3),py:n.space(2),borderRadius:"8px",boxShadow:"0 6px 20px rgba(0,0,0,0.22)",pointerEvents:"none",children:e("personalizedTooltip").split("{name}").join(Yn(t))})]})},Vn=()=>{const e=$(),{botData:t}=J(),{isMobile:n}=Se(),{t:r}=ee(),o=function(e){const t=e?.white_label;if(t?.ai_notice_only)return{kind:"short"};const n=t?.disclaimer_text?.trim();return n?{kind:"custom",text:n}:{kind:"default"}}(t),a="custom"===o.kind?o.text:r("short"===o.kind?"aiCanMakeMistakesShort":"aiCanMakeMistakes"),i=qn(t),s=function(e){const t=e?.white_label;if(!t?.privacy_link_enabled)return null;const n=t.privacy_link_url?.trim();return n?/^https?:\/\//i.test(n)||/^\/(?!\/)/.test(n)?n:/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/|$)/i.test(n)?`https://${n}`:Nn:Nn}(t);return K.jsxs(oe,{gapX:e.space(2),justifyContent:n?"start":"center",align:"center",alignContent:"center",alignItems:"center",w:"full",wrap:n?"wrap":"nowrap",children:["dori"===i.kind&&K.jsx(wn,{href:je("https://dori.tech/",t?.sharing_id||""),target:"_blank",rel:"noopener noreferrer",display:"inline-flex",alignItems:"center",children:K.jsx(re,{src:Rn,alt:"Dori AI",boxSize:Ce(e)})}),"merchant"===i.kind&&K.jsx(re,{src:i.src,alt:i.alt,h:Ce(e),w:"auto",maxW:ze(e),objectFit:"contain",flexShrink:0}),K.jsxs(ne,{fontSize:e.font(10),color:"mutedText",px:e.space(0),py:e.space(0),bg:"transparent",border:"none",display:"flex",alignItems:"center",justifyContent:"flex-start",gap:e.space(1),children:[K.jsx(ne,{as:"span",children:a}),s&&K.jsx(wn,{href:s,target:"_blank",rel:"noopener noreferrer",color:"inherit",textDecoration:"underline",whiteSpace:"nowrap",children:r("privacyPolicy")}),On(t)&&K.jsx(Un,{})]})]})};function Kn(e){return Ae({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"m112 184 144 144 144-144"},child:[]}]})(e)}function Qn(e){return Ae({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"m112 328 144-144 144 144"},child:[]}]})(e)}const Zn=(e={})=>{const{enableTwinkling:t=!0,enableFloating:n=!0,enableRotation:r=!0,enableScaling:o=!0,twinklingSpeed:a=1e3,floatingSpeed:i=3e3,rotationSpeed:s=8e3,scalingSpeed:l=4e3,floatingRange:c=2.5,rotationRange:d=90,scalingRange:u=1.2}=e,[p,h]=H.useState(1),[f,g]=H.useState(0),[m,b]=H.useState(0),[x,y]=H.useState(1);return H.useEffect(()=>{if(!t)return;const e=setInterval(()=>{h(e=>1===e?.2:1)},a);return()=>clearInterval(e)},[t,a]),H.useEffect(()=>{if(!n)return;const e=setInterval(()=>{g(e=>0===e?c:0)},i);return()=>clearInterval(e)},[n,i,c]),H.useEffect(()=>{if(!r)return;const e=setInterval(()=>{b(e=>0===e?d:0)},s);return()=>clearInterval(e)},[r,s,d]),H.useEffect(()=>{if(!o)return;const e=setInterval(()=>{y(e=>1===e?u:1)},l);return()=>clearInterval(e)},[o,l,u]),{getStarfieldTransform:(e,t)=>[].filter(Boolean).join(" "),getIconStyle:()=>({opacity:p,transition:"transform 0.8s ease-in-out, opacity 1s ease-in-out"}),twinkleOpacity:p,floatingOffset:f,rotationAngle:m,scaleFactor:x}};function Gn(e){if(!e)return null;const{customization:t,bot_image:n,agent_image:r,bot_image_original:o}=e;switch(t?.fab_avatar_source){case"none":return null;case"logo":return n||null;case"agent":return r||null}return t?.enable_avatar_in_fab&&((n&&n!==o?n:null)||r||n)||null}const Xn=e=>"bottom"===e?.anchor?"bottom":"middle",Jn=(e,t)=>t?(e=>e?.customization?.mobile?.position?{align:e.customization?.mobile?.position?.align??"right",sideSpacing:e.customization?.mobile?.position?.side_spacing??8,bottomSpacing:e.customization?.mobile?.position?.bottom_spacing??0,anchor:Xn(e.customization?.mobile?.position)}:{align:"right",sideSpacing:8,bottomSpacing:20,anchor:"middle"})(e):(e=>e?.customization?.position?{align:e.customization?.position?.align??"right",sideSpacing:e.customization?.position?.side_spacing??16,bottomSpacing:e.customization?.position?.bottom_spacing??0,anchor:Xn(e.customization?.position)}:{align:"right",sideSpacing:16,bottomSpacing:60,anchor:"middle"})(e),$n=(e,t,n)=>"bottom"===e.anchor||n&&!!Gn(t),er=(e,t)=>"bottom"===e.anchor?Math.max(0,e.bottomSpacing):t?.customization?.mobile?.position?.bottom_spacing??90;function tr(){return"undefined"!=typeof window&&!!window.$crisp}function nr(){tr()&&window.$crisp.push(["do","chat:hide"])}function rr(){console.log("trying to open"),tr()&&(console.log("trying to open2"),window.$crisp.push(["do","chat:show"]),window.$crisp.push(["do","chat:open"]))}const or=15e3,ar="chatra";let ir=!1,sr=!1,lr=null,cr=0,dr=null,ur=0,pr=!1;function hr(...e){console.log("[Dori-Chatra]",...e)}function fr(){return"undefined"!=typeof window&&"function"==typeof window.Chatra}function gr(){return!!fr()&&!!document.getElementById(ar)}function mr(e){if(fr())try{window.Chatra("hide"),hr("called Chatra('hide') —",e)}catch(t){hr("error calling hide:",t)}}function br(){null!==lr&&(clearInterval(lr),lr=null,hr("stopped maintain loop"))}function xr(){sr||Date.now()-cr>3e4?br():ir&&fr()&&mr("maintain loop")}function yr(){if(!sr)return;const e=document.getElementById(ar);if(!e)return;const t=e.className||"",n=-1!==t.indexOf("chatra--visible");-1!==t.indexOf("chatra--expanded")?pr=!0:pr&&(Date.now()-ur<1500||n&&mr("user closed chat"))}function wr(){hr("openChatraChat invoked"),sr=!0,pr=!1,br(),function(){if(dr||"undefined"==typeof document)return;const e=()=>{const e=document.getElementById(ar);return!!e&&(dr=new MutationObserver(yr),dr.observe(e,{attributes:!0,attributeFilter:["class","style"]}),hr("attached close observer to #chatra"),!0)};if(e())return;const t=Date.now(),n=setInterval(()=>{(e()||Date.now()-t>or)&&clearInterval(n)},200)}(),function(e){if(gr())return void e();const t=Date.now(),n=setInterval(()=>{gr()?(clearInterval(n),e()):Date.now()-t>or&&(clearInterval(n),hr("Chatra never fully loaded within",or,"ms"))},200)}(()=>{ur=Date.now();try{window.Chatra("show"),hr("called Chatra('show')"),setTimeout(()=>{try{window.Chatra("openChat"),hr("called Chatra('openChat')")}catch(e){hr("error calling openChat:",e)}},50)}catch(e){hr("error calling show:",e)}})}const vr="dori-shopify-inbox-hide",kr="data-dori-inbox-open",Sr="shopify-chat",jr="inbox-online-store-chat";let Cr=null;function zr(...e){console.log("[Dori-ShopifyInbox]",...e)}function Ar(){if("undefined"==typeof document)return null;const e=document.querySelector(Sr);if(e)return{el:e,legacy:!1};const t=document.querySelector(jr);return t?{el:t,legacy:!0}:null}function Er(){zr("openShopifyInbox invoked"),function(e){const t=Ar();if(t)return void e(t);const n=Date.now(),r=setInterval(()=>{const t=Ar();t?(clearInterval(r),e(t)):Date.now()-n>15e3&&(clearInterval(r),zr("Inbox embed never appeared within",15e3,"ms"))},200)}(({el:e,legacy:t})=>{if(document.documentElement.setAttribute(kr,""),t)requestAnimationFrame(()=>{const t=e.shadowRoot?.querySelector("button");t?(t.click(),zr("clicked legacy activator")):zr("legacy activator not found in shadow root")});else{if(function(e){Cr||"undefined"==typeof document||(Cr=new MutationObserver(()=>{e.hasAttribute("open")||document.documentElement.removeAttribute(kr)}),Cr.observe(e,{attributes:!0,attributeFilter:["open"]}))}(e),"function"==typeof e.show)try{return e.show(),void zr("called shopify-chat.show()")}catch(n){zr("show() failed, falling back to the open attribute:",n)}e.setAttribute("open","")}})}const Tr=e=>{if(!e)return[];const t=[];return e.crisp?.enabled&&t.push({type:"crisp",icon:e.crisp.icon,name:e.crisp.name,data:e.crisp}),e.chatra?.enabled&&t.push({type:"chatra",icon:e.chatra.icon,name:e.chatra.name,data:e.chatra}),e.shopifyInbox?.enabled&&t.push({type:"shopifyInbox",icon:e.shopifyInbox.icon,name:e.shopifyInbox.name,data:e.shopifyInbox}),e.customLink?.enabled&&t.push({type:"customLink",icon:e.customLink.icon,name:e.customLink.name,data:e.customLink}),e.telegram?.enabled&&t.push({type:"telegram",icon:e.telegram.icon,name:e.telegram.name,data:e.telegram}),e.whatsapp?.enabled&&t.push({type:"whatsapp",icon:e.whatsapp.icon,name:e.whatsapp.name,data:e.whatsapp}),t},Rr=(e,t,n)=>{switch(e){case"whatsapp":const e=t.phoneNumber?.replace(/\s/g,""),r=t.welcomeMessage?`?text=${encodeURIComponent(t.welcomeMessage)}`:"";window.open(`https://wa.me/${e}${r}`,"_blank");break;case"telegram":window.open(`https://t.me/${t.username}`,"_blank");break;case"customLink":window.open(t.linkUrl,"_blank");break;case"crisp":rr(),window.dispatchEvent(new Event("dori:close-widget"));break;case"chatra":wr(),window.dispatchEvent(new Event("dori:close-widget"));break;case"shopifyInbox":Er(),window.dispatchEvent(new Event("dori:close-widget"));break;case"dori":n&&n()}},Wr=({channels:e,isOpen:t,onToggle:n,isMobile:r,onMouseEnter:o,onChatClick:a})=>{const{botData:i}=J(),s=jn({base:!0,md:!1})??!1,l=Jn(i,s),c=!0!==i?.customization?.disable_idle_animation,{getStarfieldTransform:d,getIconStyle:u}=Zn({enableTwinkling:c,enableFloating:c,enableRotation:c,enableScaling:c}),p=Tr(e);return 0===p.length?null:K.jsxs(fe,{gap:2,align:"flex-end",alignItems:"center",position:"absolute",bottom:"100%",right:0,children:[r&&t&&K.jsx(de,{"aria-label":"Toggle support channels",size:"2xs",borderRadius:"full",bg:"primary",color:"buttonText",boxShadow:"md",mb:2,opacity:t||r?1:0,transition:"all 0.2s ease",_hover:{"@media (hover: hover) and (pointer: fine)":{transform:"scale(1.1)",boxShadow:"lg"}},onClick:n,display:r||!t?"flex":"none",children:K.jsx(Kn,{size:20})}),K.jsx(ne,{mb:3,opacity:t?1:0,transform:t?"translateY(0)":"translateY(10px)",transition:"all 0.2s ease",pointerEvents:t?"auto":"none",onMouseEnter:o,children:K.jsxs(fe,{gap:2,align:"flex-end",children:[K.jsx(ne,{borderRadius:"full",cursor:"pointer",onClick:()=>Rr("dori",{},a),bg:"primary",boxSize:{base:"36px",md:"48px"},display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"md",_hover:{"@media (hover: hover) and (pointer: fine)":{transform:"scale(1.1)",boxShadow:"lg"}},transition:"all 0.2s ease",children:K.jsx(Ee,{boxSize:{base:"24px",md:"32px"},color:"background",transform:d("expanded",l),...u()})}),p.map((e,t)=>K.jsx(ne,{borderRadius:"full",cursor:"pointer",onClick:()=>Rr(e.type,e.data,a),_hover:{"@media (hover: hover) and (pointer: fine)":{transform:"scale(1.1)"}},transition:"all 0.2s ease",children:K.jsx(re,{src:e.icon,alt:e.name,boxSize:{base:"36px",md:"48px"},borderRadius:"full",objectFit:"fill"})},`${e.type}-${t}`))]})}),r&&!t&&K.jsx(de,{"aria-label":"Toggle support channels",size:"2xs",borderRadius:"full",bg:"primary",color:"buttonText",boxShadow:"md",mb:2,opacity:t||r?1:0,transition:"all 0.2s ease",_hover:{"@media (hover: hover) and (pointer: fine)":{transform:"scale(1.1)",boxShadow:"lg"}},onClick:n,display:r||!t?"flex":"none",children:K.jsx(Qn,{size:20})})]})},Ir=({channels:e})=>{const t=$(),n=(e=>{if(!e)return[];const t=[];return e.crisp?.enabled&&t.push({type:"crisp",icon:e.crisp.icon,name:e.crisp.name,data:e.crisp}),e.chatra?.enabled&&t.push({type:"chatra",icon:e.chatra.icon,name:e.chatra.name,data:e.chatra}),e.shopifyInbox?.enabled&&t.push({type:"shopifyInbox",icon:e.shopifyInbox.icon,name:e.shopifyInbox.name,data:e.shopifyInbox}),e.customLink?.enabled&&t.push({type:"customLink",icon:e.customLink.icon,name:e.customLink.name,data:e.customLink}),e.telegram?.enabled&&t.push({type:"telegram",icon:e.telegram.icon,name:e.telegram.name,data:e.telegram}),e.whatsapp?.enabled&&t.push({type:"whatsapp",icon:e.whatsapp.icon,name:e.whatsapp.name,data:e.whatsapp}),t})(e);return 0===n.length?null:K.jsx(oe,{gap:t.space(3),w:"full",alignItems:"center",justifyContent:"start",wrap:"wrap",children:n.map((e,n)=>K.jsxs(ne,{display:"flex",alignItems:"center",gap:t.space(3),cursor:"pointer",borderRadius:t.radius(16),padding:"6px 8px",bg:"lightBackground",_hover:{"@media (hover: hover) and (pointer: fine)":{bg:"veryLightBackground",transform:"scale(1.05)"}},transition:"all 0.2s ease",onClick:()=>((e,t)=>{switch(e){case"whatsapp":const e=t.phoneNumber?.replace(/\s/g,""),n=t.welcomeMessage?`?text=${encodeURIComponent(t.welcomeMessage)}`:"";window.open(`https://wa.me/${e}${n}`,"_blank");break;case"telegram":window.open(`https://t.me/${t.username}`,"_blank");break;case"customLink":window.open(t.linkUrl,"_blank");break;case"crisp":rr(),window.dispatchEvent(new Event("dori:close-widget"));break;case"chatra":wr(),window.dispatchEvent(new Event("dori:close-widget"));break;case"shopifyInbox":Er(),window.dispatchEvent(new Event("dori:close-widget"))}})(e.type,e.data),flexShrink:0,children:[K.jsx(re,{src:e.icon,alt:e.name,boxSize:{base:t.length(22),md:t.length(24)},borderRadius:"full",objectFit:"cover"}),K.jsx(se,{fontSize:{base:t.font(12),md:t.font(14)},fontWeight:"400",color:"text",whiteSpace:"nowrap",children:e.name})]},`${e.type}-${n}`))})},Br=({offer:e,selections:t,onDone:n,onClose:r})=>{const o=$(),{isMobile:a}=Se(),{t:s}=ee(),{botData:l,chatState:c}=J(),[d,u]=H.useState(""),[p,h]=H.useState(!1),[f,g]=H.useState(!1),[m,b]=H.useState(null),x=(e,t={})=>i(e,{assistantId:l?.assistant_id,threadId:c.threadId,payload:{placement:"quiz",...t}}),y=async()=>{if(f)return;if(!We(d))return void b(s("followUpInvalidEmail"));if(!p)return;g(!0),b(null);const t=await Ie(d.trim(),e.tags);g(!1),"ok"===t?(Be(),Me(d.trim()),x("email_signup_joined")):x("email_signup_failed",{result:t}),n()};return K.jsxs(fe,{gap:o.space(3),align:"stretch",flex:1,justify:"start","data-dori-quiz-signup":"",children:[K.jsxs(oe,{justify:"space-between",align:"center",gap:o.space(2),children:[K.jsx(oe,{gap:o.space(1.5),flexWrap:"wrap",children:t.map((e,t)=>K.jsxs(ne,{px:o.space(3),py:o.space(1),borderRadius:o.radius(16),bg:"veryLightBackground",border:"1px solid",borderColor:"primary",fontSize:o.font(11),fontWeight:500,color:"primary",fontFamily:xn,whiteSpace:"nowrap",children:["✓ ",e]},t))}),r&&K.jsx(ne,{as:"button",onClick:r,cursor:"pointer",p:1,borderRadius:"full",opacity:.5,_hover:{opacity:1,bg:"lightBackground"},flexShrink:0,"aria-label":"Close",children:K.jsx(se,{fontSize:"16px",color:"text",lineHeight:"1",children:"×"})})]}),K.jsxs(oe,{gap:o.space(2),align:"flex-start",children:[K.jsx(ne,{color:"primary",mt:"3px",flexShrink:0,children:K.jsx(Te,{"aria-hidden":!0})}),K.jsxs(fe,{align:"stretch",gap:o.space(1),children:[K.jsx(se,{fontSize:o.font(17),fontWeight:700,color:"text",lineHeight:"1.4",fontFamily:xn,children:e.headline}),e.detail&&K.jsx(se,{fontSize:o.font(12),color:"mutedText",lineHeight:"1.5",fontFamily:xn,children:e.detail})]})]}),K.jsx(Re,{value:d,onChange:e=>{u(e.target.value),m&&b(null)},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:s("followUpEmailPlaceholder"),"aria-label":s("followUpEmailPlaceholder"),type:"email",inputMode:"email",autoComplete:"email",fontSize:a?ge(o,16):o.font(14),color:"text",bg:"background",borderColor:"border",borderRadius:o.radius(10),height:o.length(40),px:o.space(3),_placeholder:{color:"mutedText"},_focus:{borderColor:"primary",boxShadow:"none"}}),m&&K.jsx(se,{fontSize:o.font(11),color:"red.500",fontFamily:xn,"data-dori-quiz-signup-error":"",children:m}),K.jsxs("label",{style:{display:"flex",gap:6,alignItems:"flex-start",cursor:"pointer"},children:[K.jsx("input",{type:"checkbox",checked:p,onChange:e=>h(e.target.checked),style:{marginTop:2}}),K.jsxs(se,{as:"span",fontSize:o.font(11),color:"mutedText",lineHeight:"1.35",fontFamily:xn,children:[s("signupConsent")," ",K.jsx("a",{href:"/policies/privacy-policy",target:"_blank",rel:"noreferrer",style:{textDecoration:"underline"},children:s("followUpPrivacy")})]})]}),K.jsx(ae,{borderRadius:o.radius(24),bg:"primary",color:"buttonText",fontSize:o.font(13),fontWeight:600,height:o.length(40),loading:f,disabled:!p||!d.trim(),onClick:()=>{y()},fontFamily:xn,children:s("signupShowResults")}),K.jsx(ae,{variant:"outline",borderRadius:o.radius(24),borderColor:"border",color:"text",bg:"transparent",fontSize:o.font(13),height:o.length(40),onClick:()=>{x("email_signup_skipped"),n()},disabled:f,fontFamily:xn,_hover:{bg:"veryLightBackground"},"data-dori-quiz-signup-skip":"",children:s("signupSkip")})]})},Mr=({flow:e,onComplete:t,onClose:n})=>{const r=$(),[o,a]=H.useState(0),[i,s]=H.useState([]),[l,c]=H.useState("active"),[d,u]=H.useState(!1),[p,h]=H.useState(!1),[f,g]=H.useState(!1),m=H.useRef(null),b=H.useRef(null),x=H.useRef(null),y=H.useRef(null),w=_e("colors","primary"),v=Fe(w);H.useEffect(()=>{if("active"!==l)return;u(!1);const e=requestAnimationFrame(()=>{u(!0)});return()=>cancelAnimationFrame(e)},[o,l]),H.useEffect(()=>()=>{m.current&&clearTimeout(m.current),b.current&&clearTimeout(b.current),x.current&&clearTimeout(x.current),y.current&&clearTimeout(y.current)},[]);const k=H.useCallback(n=>{c("analyzing");const r=800+700*Math.random();x.current=setTimeout(()=>{const r=n.map(e=>e.option.label).join(" · ");let o=e.result_prompt;n.forEach((e,t)=>{const n=`{step${t+1}}`;o=o.split(n).join(e.option.value)});const a=Le(),i=n.map(e=>e.option.label).join(", ");t(r,`${a}[Quiz selections: ${i}] ${o}`)},r)},[e,t]),S=H.useCallback(t=>{if(f)return;g(!0);const n=[...i,{stepIndex:o,option:t}];s(n),o<e.steps.length-1?(u(!1),m.current=setTimeout(()=>{a(e=>e+1),g(!1)},280)):(h(!0),y.current=setTimeout(()=>{h(!1),!e.email_signup||De()?k(n):c("signup")},300))},[f,i,o,e,k]),j=H.useCallback(()=>{o<=0||p||(u(!1),b.current=setTimeout(()=>{s(e=>e.slice(0,-1)),a(e=>e-1),g(!1)},250))},[o,p]),C=e.steps[o];return"signup"===l&&e.email_signup?K.jsx(Br,{offer:e.email_signup,selections:i.map(e=>e.option.label),onDone:()=>{Pe(),k(i)},onClose:n}):"analyzing"===l?K.jsxs(fe,{gap:r.space(3),align:"center",flex:1,justify:"center",transition:"opacity 0.3s ease",children:[K.jsx(oe,{gap:r.space(2),flexWrap:"wrap",justify:"center",children:i.map((e,t)=>K.jsx(_r,{label:e.option.label},t))}),K.jsxs(fe,{gap:r.space(2),align:"center",py:r.space(4),children:[K.jsx(He,{boxSize:r.length(20),color:"primary",opacity:.6}),K.jsx(se,{fontSize:r.font(14),fontWeight:500,fontFamily:xn,css:{background:`linear-gradient(90deg, ${w}44, ${w}, ${w}44)`,backgroundSize:"200% 100%",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",animation:"dori-shimmer 1.5s ease-in-out infinite"},children:e.analyzing_text})]}),K.jsx("style",{children:"\n @keyframes dori-shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n }\n "})]}):K.jsxs(fe,{gap:r.space(4),align:"stretch",flex:1,justify:"start",opacity:p?0:1,transform:p?"translateY(-8px)":"translateY(0)",transition:"opacity 0.3s ease, transform 0.3s ease",children:[i.length>0&&K.jsxs(oe,{gap:r.space(2),flexWrap:"wrap",align:"center",children:[K.jsx(ne,{as:"button",onClick:j,"aria-label":"Back",cursor:"pointer",px:r.space(2),py:r.space(1),borderRadius:r.radius(12),fontSize:r.font(11),color:"primary",opacity:.8,_hover:{opacity:1,bg:"veryLightBackground"},transition:"all 0.15s ease",fontFamily:xn,flexShrink:0,children:"←"}),i.map((e,t)=>K.jsx(_r,{label:e.option.label},t))]}),K.jsxs(ne,{opacity:d?1:0,transform:d?"translateY(0)":"translateY(10px)",transition:"opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",children:[K.jsxs(fe,{align:"stretch",gap:r.space(3),mb:r.space(3),children:[K.jsxs(oe,{justify:"space-between",align:"center",gap:r.space(3),children:[K.jsxs(oe,{gap:r.space(2),align:"center",minW:0,children:[K.jsx(ne,{display:"flex",alignItems:"center",justifyContent:"center",boxSize:r.length(24),borderRadius:r.radius(12),bg:"background",border:"1px solid",borderColor:"primary",flexShrink:0,children:K.jsx(He,{boxSize:r.length(12),color:"primary"})}),K.jsx(se,{fontSize:r.font(11),fontWeight:600,fontFamily:xn,lineHeight:"1.4",css:{background:v,WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:e.entry_label})]}),K.jsxs(oe,{gap:r.space(1),align:"center",flexShrink:0,children:[K.jsxs(ne,{px:r.space(2.5),py:r.space(1),borderRadius:r.radius(999),bg:"background",border:"1px solid",borderColor:"primary",fontSize:r.font(10),fontWeight:700,color:"primary",fontFamily:xn,lineHeight:"1",flexShrink:0,children:[o+1,"/",e.steps.length]}),n&&K.jsx(ne,{as:"button",onClick:n,cursor:"pointer",p:1,borderRadius:"full",opacity:.5,_hover:{opacity:1,bg:"lightBackground"},transition:"all 0.15s ease",flexShrink:0,"aria-label":"Close",children:K.jsx(se,{fontSize:"16px",color:"text",lineHeight:"1",children:"×"})})]})]}),K.jsx(se,{fontSize:r.font(17),fontWeight:700,color:"text",lineHeight:"1.45",fontFamily:xn,children:C.question}),K.jsx(ne,{bg:"background",border:"1px solid",borderColor:"borderColor",borderRadius:r.radius(16),px:r.space(3),py:r.space(2.5),children:K.jsxs(oe,{gap:r.space(2),align:"start",children:[K.jsx(ne,{boxSize:r.length(7),borderRadius:"full",bg:"primary",mt:r.length(7),flexShrink:0}),K.jsx(se,{fontSize:r.font(12),color:"mutedText",fontWeight:500,lineHeight:"1.65",fontFamily:xn,opacity:.9,children:C.reason})]})})]}),K.jsx(ne,{display:"grid",gridTemplateColumns:{base:"1fr 1fr"},gap:r.space(2),children:C.options.map((e,t)=>K.jsx(ne,{as:"button",px:r.space(3),py:"8px",borderRadius:r.radius(24),border:"1px solid",borderColor:"primary",bg:"veryLightBackground",cursor:"pointer",textAlign:"start",display:"flex",alignItems:"center",gap:r.space(2),opacity:d?1:0,transform:d?"translateY(0)":"translateY(6px)",transition:`opacity 0.25s ease ${40*t}ms, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) ${40*t}ms, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease`,_hover:{bg:"lightBackground",boxShadow:`0 0 0 1px ${w}33`},_active:{bg:"lightBackground",transform:"translateY(0) scale(0.97)"},onClick:()=>S(e),fontFamily:xn,children:K.jsxs(ne,{flex:"1",minW:0,children:[K.jsx(se,{fontSize:r.font(13),fontWeight:500,color:"text",lineHeight:"1.4",whiteSpace:"normal",wordBreak:"break-word",children:e.label}),e.subtitle&&K.jsx(se,{fontSize:r.font(10),color:"mutedText",opacity:.6,lineHeight:"1.2",children:e.subtitle})]})},e.value))})]})]})},_r=({label:e})=>{const t=$();return K.jsxs(ne,{px:t.space(3),py:t.space(1),borderRadius:t.radius(16),bg:"veryLightBackground",border:"1px solid",borderColor:"primary",fontSize:t.font(11),fontWeight:500,color:"primary",fontFamily:xn,whiteSpace:"nowrap",children:["✓ ",e]})},Fr=({chips:e,onChipClick:t,onDismiss:n})=>{const r=$(),[o,a]=H.useState(!1);return H.useEffect(()=>{const e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)},[]),0===e.length?null:K.jsx(ne,{flexShrink:0,opacity:o?1:0,transform:o?"translateY(0)":"translateY(10px)",transition:"opacity 0.3s ease-out, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)","data-dori-nudge":"chip-row",children:K.jsxs(oe,{gap:r.space(2),wrap:"wrap",align:"center",children:[e.map((e,n)=>K.jsx(ae,{size:"sm",variant:"outline",borderRadius:r.radius(20),borderWidth:"1.5px",borderColor:"primary",bg:"veryLightBackground",color:"text",fontSize:r.font(13),fontWeight:500,px:r.space(3),py:r.space(1.5),height:"auto",whiteSpace:"normal",wordBreak:"break-word",textAlign:"start",_hover:{"@media (hover: hover) and (pointer: fine)":{bg:"lightBackground"}},onClick:()=>t(e),fontFamily:xn,children:e},`${n}-${e}`)),K.jsx(de,{size:"xs",borderRadius:"full",bg:"transparent","aria-label":"Dismiss nudge",color:"mutedText",_hover:{"@media (hover: hover) and (pointer: fine)":{bg:"lightBackground"}},minW:r.length(22),w:r.length(22),h:r.length(22),p:r.space(0),flexShrink:0,onClick:n,opacity:.6,children:K.jsx(pe,{boxSize:r.length(11)})})]})})};const Lr=({onStartChat:e,isMobile:t,isExpanded:n=!1,onToggleExpand:r,fullPageHref:o,onClose:a})=>{const{inputValue:i,handleInputChange:c}=((e="")=>{const[t,n]=H.useState(e),r=H.useCallback(e=>{n(e)},[]),o=H.useCallback(e=>{t.trim()&&e&&(e(t.trim()),n(""))},[t]),a=H.useCallback((e,t)=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),o(t))},[o]),i=H.useCallback(()=>{n("")},[]),s=H.useCallback(e=>{n(e)},[]);return{inputValue:t,setInputValue:n,handleInputChange:r,handleSubmit:o,handleKeyPress:a,clearInput:i,setInput:s}})(),{botData:d,effectiveSuggestedReplies:u}=J(),p=$(),h=qe(t?1:Oe(d).width),{t:f,translations:g}=ee(),m=s(d,g),b=_e("colors","primary"),x=Fe(b),y=u,w=!1,v=H.useMemo(()=>y.slice(0,4),[y]),[k,S]=Ye();H.useMemo(()=>y.slice(0,2),[y]);const j=({message:t,imageUrl:n})=>{(t.trim()||n)&&e(t.trim(),n)},C=!0===d?.feature_flags?.greeting_one_line,z=H.useRef(null),A=function(e,t,n,r,o){const[a,i]=H.useState(n);return H.useLayoutEffect(()=>{if(!t)return void i(n);const o=e.current,a=o?.parentElement;if(!o||!a)return;const s=()=>{const e=o.style.fontSize;o.style.fontSize=`${n}px`;const t=o.scrollWidth;o.style.fontSize=e,i(function(e,t,n,r){if(!(e>0&&t>e))return n;const o=Math.floor(n*(e/t)*.99);return Math.max(r,Math.min(n,o))}(a.clientWidth,t,n,r))};if(s(),"undefined"==typeof ResizeObserver)return;const l=new ResizeObserver(s);return l.observe(a),()=>l.disconnect()},[e,t,n,r,o]),a}(z,C,parseFloat(p.isMini?p.font(24):`${h.greetingFontPx}px`),14,m||""),E=!0===d?.feature_flags?.composer_at_bottom,T=K.jsx(ne,{children:K.jsx(Hn,{state:"minimized",placeholder:f("askAnything"),value:i,onChange:c,onSend:j})});return K.jsxs(K.Fragment,{children:[K.jsx(Wn,{onClose:a,isMobile:t,isExpanded:n,onToggleExpand:r,fullPageHref:o}),K.jsxs(fe,{h:"full",minH:0,justify:"flex-start",align:"stretch",gap:p.space(h.sectionGap),children:[m&&K.jsx(fe,{gap:p.space(3),w:"full",align:"start",mb:p.length(h.greetingGapPx),flexShrink:0,children:K.jsx(se,{ref:z,fontWeight:n?600:500,fontStyle:"normal",fontSize:C?`${A}px`:p.isMini?p.font(24):`${h.greetingFontPx}px`,whiteSpace:C?"nowrap":void 0,letterSpacing:"0",textAlign:n?"center":"right",fontFamily:xn,css:{background:x,WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:m})}),K.jsx(ne,{flex:1,minH:0,overflowY:"auto",overflowX:"hidden","data-scroll-container":"chat-messages",overscrollBehavior:"contain",css:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",msOverflowStyle:"none"},children:K.jsxs(fe,{gap:p.space(4),align:"stretch",justify:"start",pb:p.space(3),children:[!E&&T,k&&K.jsx(Fr,{chips:[k],onChipClick:t=>{l("offer_guide_chat_opened",{from:"opening"}),S(),Ue(t).then(n=>e(t,void 0,n))},onDismiss:()=>{Ne(),S()}}),w,w,v.length>0&&K.jsx(ne,{w:"full",children:K.jsx(ne,{display:"grid",gridTemplateColumns:{base:"1fr",md:h.starterColumns},gap:p.space(3),w:"full",children:v.map((e,t)=>K.jsxs(ae,{variant:"outline",borderRadius:p.radius(24),border:"1px solid",borderColor:"borderColor",bg:"lightBackground",color:"text",fontSize:p.font(14),fontWeight:400,padding:"8px 12px",_hover:{bg:"veryLightBackground",borderColor:"borderColor"},onClick:()=>(e=>{j({message:e,imageUrl:void 0})})(e),justifyContent:"start",w:"full",height:"auto",lineHeight:"1.5",whiteSpace:"pre-wrap",children:[K.jsx(He,{boxSize:p.length(16),color:"text"}),K.jsx(ne,{as:"span",flex:"1",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"break-word",fontFamily:xn,children:e})]},t))})})]})}),K.jsx(ne,{w:"full",flexShrink:0,children:K.jsx(Ir,{channels:d?.merchant_support_channels})}),E&&K.jsx(ne,{w:"full",flexShrink:0,children:T}),K.jsx(ne,{flexShrink:0,transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",children:K.jsx(Vn,{variant:"default"})})]})]})},Dr=({message:e,type:t="default"})=>{const n="loading"===t,{botData:r}=J(),o=$(),a=e.replace(/\\([!?.,'":;\-\[\](){}#*_~`>+])/g,"$1"),i=r?.agent_image||Rn,s=te(i),l=he(s.ratio),c=n?a.replace(/[.\u2026]{1,3}\s*$/u,"").trim():a;return K.jsxs(ne,{position:"relative",width:"full",children:[K.jsx(ne,{opacity:"0",bg:"lightBackground",borderRadius:o.radius(24),padding:o.length(16),children:K.jsx(se,{fontWeight:400,fontSize:o.font(14),lineHeight:o.lineHeight(21),fontFamily:xn,children:a})}),K.jsx(ne,{h:o.length(50)}),K.jsx(ne,{position:"absolute",left:0,bottom:0,children:K.jsx(re,{src:i,alt:"",role:"presentation",onLoad:s.onLoad,w:o.length(24),h:o.length(24),borderRadius:"50%",objectFit:l?"contain":"cover",...l?{p:"2px",bg:"background",border:"1px solid",borderColor:"borderColor"}:{}})}),K.jsx(ne,{position:"absolute",left:o.length(21),bottom:o.length(21),width:o.length(7.68),height:o.length(7.68),bg:"lightBackground",borderRadius:"100%",borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor"}),K.jsx(ne,{position:"absolute",left:o.length(27),bottom:o.length(27),width:o.length(15.8),height:o.length(15.8),bg:"lightBackground",borderRadius:"100%",borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor"}),K.jsx(ne,{position:"absolute",left:o.length(35),bottom:o.length(35),bg:"lightBackground",borderRadius:o.radius(24),padding:o.length(16),borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor",children:n?K.jsxs(oe,{gap:o.length(8),align:"center",children:[c&&K.jsx(se,{fontWeight:400,fontSize:o.font(14),lineHeight:o.lineHeight(21),color:"mutedText",fontFamily:xn,children:c}),K.jsx(oe,{gap:o.length(3),align:"center","aria-hidden":"true",children:[0,1,2].map(e=>K.jsx(ne,{w:o.length(4),h:o.length(4),borderRadius:"full",bg:"mutedText",css:{animation:`dori-typing-dot 1.2s ease-in-out ${.15*e}s infinite`}},e))}),K.jsx("style",{children:"\n @keyframes dori-typing-dot {\n 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }\n 30% { opacity: 1; transform: translateY(-3px); }\n }\n "})]}):K.jsx(se,{fontWeight:400,fontSize:o.font(14),lineHeight:o.lineHeight(21),color:"text",fontFamily:xn,children:a})})]})},Pr=({index:e,children:t})=>{const[n,r]=H.useState(!1);return H.useEffect(()=>{const t=setTimeout(()=>r(!0),70*e);return()=>clearTimeout(t)},[e]),K.jsx(ne,{opacity:n?1:0,transform:n?"translateY(0)":"translateY(6px)",transition:"opacity 0.3s ease-out, transform 0.3s ease-out",children:t})},Hr=({suggestions:e,options:t=!1})=>{const n=$(),{sendMessage:r,focusModeProduct:o}=J(),{visible:a,asOptions:i}=Ve(e,{options:t,focusMode:!!o});return K.jsx(An,{direction:"row",wrap:"wrap",gap:n.space(2),maxW:"full",alignSelf:"flex-start",children:a.map((e,t)=>K.jsx(Pr,{index:t,children:K.jsxs(ae,{bg:"background",border:"1px solid",borderColor:"borderColor",borderRadius:n.radius(18),px:n.space(3.5),h:"auto",lineHeight:"1.4",py:n.space(2),onClick:()=>(e=>{r({message:e})})(e),_hover:{bg:"lightBackground",borderColor:"primary"},_active:{bg:"veryLightBackground"},textAlign:"start",justifyContent:"flex-start",gap:n.space(1.5),w:"auto",maxW:"100%",children:[!i&&K.jsx(He,{boxSize:n.length(13),color:"primary",flexShrink:0}),K.jsx(se,{fontSize:{base:n.font(14),md:n.font(13)},fontWeight:"500",color:"text",textAlign:"start",wordBreak:"break-word",whiteSpace:"normal",lineClamp:2,children:e})]})},t))})},qr=()=>{const e=$(),{botData:t}=J(),{t:n}=ee(),a=!0===t?.hide_checkout_button;return K.jsxs(oe,{mt:e.space(3),gap:e.space(2),justify:"flex-start",children:[K.jsxs(ae,{size:"xs",variant:"outline",borderColor:"borderColor",color:"mutedText",fontSize:e.font(12),fontWeight:"500",borderRadius:e.radius(24),h:"auto",px:e.space(3),py:e.space(1.5),onClick:()=>{if(!r()){const e=`${o()}cart`;window.open(e,"_blank","noopener,noreferrer")||(window.location.href=e)}},_hover:{borderColor:"primary"},children:[K.jsx(le,{boxSize:e.length(14)}),n("cartViewCart")]}),!a&&K.jsxs(ae,{size:"xs",variant:"solid",bg:"primary",color:"buttonText",fontSize:e.font(12),fontWeight:"500",borderRadius:e.radius(24),h:"auto",px:e.space(3),py:e.space(1.5),onClick:()=>{c()},_hover:{opacity:.85},children:[n("cartCheckout"),K.jsx(Ke,{boxSize:e.length(14)})]})]})},Or=({add:e})=>{const t=$(),{botData:n,chatState:a}=J(),{t:s}=ee(),l=e?.cart??null,h=(l?.currency||n?.currency||"USD").split(" - ")[0]?.trim().toUpperCase(),f=e=>Qe(e/100,h),g=l?.added??null,m=g?.name||e?.product_name||null,b=g?.variant_title??null,x=g?.quantity??e?.quantity??null,y=null!=g?.unit_price&&null!=x?g.unit_price*x:null,w=null!=y?f(y):null,v=l?.others??[],k=l?p(l):0,S=e=>[e.variant_title,u(e.quantity,e.measure),null!=e.line_price?f(e.line_price):null].filter(Boolean).join(" · ");return K.jsx(ne,{mt:t.space(3),border:"1.5px solid",borderColor:"borderColor",borderRadius:t.radius(14),p:t.space(3.5),bg:"background",w:"full",maxW:t.length(360),boxShadow:"0 1px 6px rgba(0, 0, 0, 0.05)",children:K.jsxs(fe,{align:"stretch",gap:t.space(2.5),children:[K.jsxs(oe,{gap:t.space(1.5),children:[K.jsx(Ze,{boxSize:t.length(16),color:"primary"}),K.jsx(se,{fontSize:t.font(13),fontWeight:700,color:"primary",fontFamily:xn,children:s("addedToCart")})]}),m&&K.jsxs(oe,{gap:t.space(2.5),align:"center",children:[g?.image?K.jsx(re,{src:g.image,alt:m,w:t.length(48),h:t.length(48),objectFit:"cover",onLoad:Ge,borderRadius:t.radius(8),flexShrink:0,bg:"lightBackground"}):K.jsx(ne,{w:t.length(48),h:t.length(48),borderRadius:t.radius(8),flexShrink:0,bg:"lightBackground",display:"flex",alignItems:"center",justifyContent:"center",children:K.jsx(le,{boxSize:t.length(18),color:"mutedText"})}),K.jsxs(ne,{minW:0,flex:1,children:[K.jsx(se,{fontSize:t.font(13),fontWeight:600,color:"text",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:m}),K.jsx(se,{fontSize:t.font(12),color:"mutedText",fontFamily:xn,children:[b,d(e),w].filter(Boolean).join(" · ")})]})]}),v.map((e,n)=>K.jsxs(oe,{gap:t.space(2.5),align:"center",opacity:.75,children:[e.image?K.jsx(re,{src:e.image,alt:e.title||"",w:t.length(32),h:t.length(32),objectFit:"cover",onLoad:Ge,borderRadius:t.radius(6),flexShrink:0,bg:"lightBackground"}):K.jsx(ne,{w:t.length(32),h:t.length(32),borderRadius:t.radius(6),flexShrink:0,bg:"lightBackground",display:"flex",alignItems:"center",justifyContent:"center",children:K.jsx(le,{boxSize:t.length(14),color:"mutedText"})}),K.jsxs(ne,{minW:0,flex:1,children:[K.jsx(se,{fontSize:t.font(12),fontWeight:500,color:"text",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:e.title}),K.jsx(se,{fontSize:t.font(11),color:"mutedText",fontFamily:xn,children:S(e)})]})]},n)),!!l?.hidden_line_count&&l.hidden_line_count>0&&K.jsx(se,{fontSize:t.font(11),color:"mutedText",fontFamily:xn,children:s("cartMoreItems").replace("{count}",String(l.hidden_line_count))}),l&&k>0&&K.jsx(se,{fontSize:t.font(12),fontWeight:600,color:"text",borderTop:"1px solid",borderColor:"borderColor",pt:t.space(2),fontFamily:xn,children:s(1===k?"cartLineOne":"cartLine").replace("{count}",String(k)).replace("{total}",f(l.total_price))}),K.jsxs(oe,{gap:t.space(2),children:[K.jsxs(ae,{size:"sm",flex:1,variant:"outline",borderColor:"borderColor",color:"text",fontSize:t.font(13),fontWeight:"600",borderRadius:t.radius(10),h:t.length(38),onClick:()=>{if(i("closer_action_clicked",{assistantId:n?.assistant_id,threadId:a.threadId,payload:{action:"view_cart"}}),!r()){const e=`${o()}cart`;window.location.href=e}},_hover:{borderColor:"primary"},children:[K.jsx(le,{boxSize:t.length(13)}),s("cartViewCart")]}),!0!==n?.hide_checkout_button&&K.jsxs(ae,{size:"sm",flex:1,variant:"solid",bg:"primary",color:"buttonText",fontSize:t.font(13),fontWeight:"600",borderRadius:t.radius(10),h:t.length(38),onClick:()=>{i("closer_action_clicked",{assistantId:n?.assistant_id,threadId:a.threadId,payload:{action:"checkout"}}),c()},_hover:{opacity:.85},children:[s("cartCheckout"),K.jsx(Ke,{boxSize:t.length(13)})]})]})]})})},Yr=({onSubmit:e,onClose:t,existingText:n})=>{const r=$(),[o,a]=H.useState(n||""),[i,s]=H.useState(!1);return H.useEffect(()=>{a(n||"")},[n]),K.jsx(ne,{mt:r.space(2),bg:"background",borderRadius:r.radius(10),p:r.space(3),borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor",maxW:r.length(280),children:K.jsxs(fe,{gap:r.space(3),align:"stretch",children:[K.jsxs(fe,{gap:r.space(.5),align:"start",children:[K.jsx(se,{fontSize:r.font(13),fontWeight:"600",color:"text",lineHeight:"1.4",children:"Tell us what was wrong"}),K.jsx(se,{fontSize:r.font(11),color:"mutedText",lineHeight:"1.4",children:"Your comment is optional and helps us improve responses."})]}),K.jsx(Tn,{value:o,onChange:e=>a(e.target.value),placeholder:"Describe what you expected...","aria-label":"Describe what you expected",rows:3,fontSize:r.font(12),resize:"none",borderColor:"borderColor",borderRadius:r.radius(8),p:r.space(2),bg:"lightBackground",color:"text",autoFocus:!0,_placeholder:{color:"mutedText"},_focus:{outline:"none",borderColor:"primary",boxShadow:"none"}}),K.jsxs(oe,{gap:r.space(2),justify:"flex-end",children:[K.jsx(ae,{size:"sm",variant:"ghost",onClick:t,disabled:i,fontSize:r.font(12),color:"mutedText",px:r.space(3),h:r.length(30),_hover:{bg:"lightBackground"},children:"Cancel"}),K.jsx(ae,{size:"sm",variant:"outline",onClick:async()=>{s(!0),await e(void 0),s(!1)},disabled:i,fontSize:r.font(12),color:"text",borderColor:"borderColor",px:r.space(3),h:r.length(30),children:"No Comment"}),K.jsx(ae,{size:"sm",onClick:async()=>{s(!0),await e(o.trim()||void 0),s(!1)},disabled:i,fontSize:r.font(12),bg:"primary",color:"buttonText",px:r.space(3),h:r.length(30),borderRadius:r.radius(8),_hover:{opacity:.85},children:i?"Submitting...":"Submit"})]})]})})},Nr=({messageIndex:e,feedback:t})=>{const n=$(),{submitFeedback:r}=J(),[o,a]=H.useState(!1),i="like"===t?.rating,s="dislike"===t?.rating;return K.jsxs(ne,{mt:n.space(1.5),children:[K.jsxs(oe,{gap:n.space(1.5),align:"center",children:[K.jsx(ne,{as:"button",onClick:async()=>{i||(await r(e,"like"),a(!1))},display:"flex",alignItems:"center",justifyContent:"center",w:n.length(36),h:n.length(36),borderRadius:n.radius(8),bg:i?"primary":"lightBackground",borderWidth:"1px",borderStyle:"solid",borderColor:i?"primary":"borderColor",cursor:"pointer",title:"This response was helpful","aria-label":"This response was helpful",_hover:{opacity:.85,transform:"translateY(-1px)"},_active:{transform:"scale(0.95)"},transition:"all 0.15s",children:K.jsx(se,{fontSize:n.font(16),lineHeight:"1",children:"👍"})}),K.jsx(ne,{as:"button",onClick:()=>{a(!0)},display:"flex",alignItems:"center",justifyContent:"center",w:n.length(36),h:n.length(36),borderRadius:n.radius(8),bg:s?"red.500":"lightBackground",borderWidth:"1px",borderStyle:"solid",borderColor:s?"red.500":"borderColor",cursor:"pointer",title:"This response wasn't helpful","aria-label":"This response wasn't helpful",_hover:{opacity:.85,transform:"translateY(-1px)"},_active:{transform:"scale(0.95)"},transition:"all 0.15s",children:K.jsx(se,{fontSize:n.font(16),lineHeight:"1",children:"👎"})})]}),t?.feedbackText&&K.jsxs(ne,{mt:n.space(1),px:n.space(2.5),py:n.space(2),bg:"lightBackground",borderRadius:n.radius(8),borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor",maxW:n.length(280),children:[K.jsx(se,{fontSize:n.font(10),color:"mutedText",lineHeight:"1.2",fontWeight:"600",textTransform:"uppercase",mb:n.space(1),children:"Submitted Feedback"}),K.jsx(se,{fontSize:n.font(11),color:"mutedText",lineHeight:"1.4",children:t.feedbackText})]}),o&&K.jsx(ne,{maxW:n.length(280),children:K.jsx(Yr,{onSubmit:async t=>{await r(e,"dislike",t),a(!1)},onClose:()=>{a(!1)},existingText:t?.feedbackText})})]})},Ur=({variant:e,children:t,textSize:n={base:"15px",md:"14px"}})=>{const r=$(),o=Xe(r,n);return"user"===e?K.jsx(se,{wordBreak:"break-word",fontSize:r.font(14),fontWeight:"500",color:"text",fontFamily:xn,whiteSpace:"pre-wrap",children:t}):K.jsx(se,{fontSize:o,fontWeight:"400",color:"text",textAlign:"left",lineHeight:"1.6",whiteSpace:"pre-wrap",children:t})},Vr=(Kr=()=>g(()=>import("./MarkdownContent-ZQGRMI3l.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url),Qr=Ur,Zr="markdown",Je.lazy(()=>h(Kr,Qr,(e,t)=>{console.warn(`[Dori] chunk "${Zr}" failed twice, rendering plain fallback`,e,t);try{f(t instanceof Error?t:new Error(String(t)),{chunk:Zr,degraded:!0})}catch{}})));var Kr,Qr,Zr;const Gr=({message:e,isStreaming:t=!1,doriMessageIndex:n,isAfterProducts:r=!1})=>{const o=$(),{isTestMode:a,enterFocusMode:i,productFocusEnabled:s}=J(),l=_e("colors","primary"),c=Fe(l),d=function(e){const t=Date.now()-new Date(e).getTime()<2e3,[n,r]=H.useState(!t);return H.useEffect(()=>{if(!t)return;const e=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(e)},[t]),n}(e.timestamp),u=function(e,t){const n=H.useRef(e),r=H.useRef(t?0:e.length),[o,a]=H.useState(t?"":e),i=H.useRef(null),s=H.useRef(t);n.current=e,s.current=t;const l=H.useCallback(()=>{const e=n.current,t=e.length-r.current;if(t<=0||!s.current)return void(i.current=null);const o=Math.max(1,Math.ceil(.12*t));r.current=Math.min(e.length,r.current+o),a(e.slice(0,r.current)),r.current<e.length?i.current=requestAnimationFrame(l):i.current=null},[]),c=H.useCallback(()=>{null===i.current&&(i.current=requestAnimationFrame(l))},[l]),d=H.useCallback(()=>{null!==i.current&&(cancelAnimationFrame(i.current),i.current=null)},[]);return H.useEffect(()=>(t?r.current<e.length&&c():(d(),r.current=e.length,a(e)),d),[t]),H.useEffect(()=>{t&&r.current<e.length&&c()},[e,t,c]),o}(e.content,t);if("welcome"===e.type)return K.jsx(Dr,{message:e.content});if("loading"===e.type)return e.content&&K.jsx(Dr,{message:e.content,type:"loading"});if("user"===e.type)return K.jsxs(ne,{maxW:o.length(220),alignSelf:"flex-end",mb:o.space(2),children:[e.imageUrl&&K.jsx(ne,{w:o.length(120),h:o.length(120),mb:o.space(2),borderRadius:o.radius(12),background:c,children:K.jsx(re,{src:e.imageUrl,alt:"Uploaded image",w:"100%",h:"100%",borderRadius:o.radius(12),objectFit:"cover"})}),(e.content.length>0||e.repliedProduct)&&K.jsxs(fe,{bg:"lightBackground",borderRadius:o.radius(24),px:o.space(3),py:o.space(2),gap:o.space(2),alignItems:"start",w:"full",borderWidth:"1px",borderStyle:"solid",borderColor:"borderColor",children:[e.repliedProduct&&(()=>{const t=e.repliedProduct,n=s&&null!=t.id,r=()=>i(t,"replied_chip");return K.jsxs(oe,{bg:"background",borderRadius:o.radius(12),p:o.space(2),gap:o.space(2),w:"full",...n&&{role:"button",tabIndex:0,cursor:"pointer","aria-label":t.name,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r())},_hover:{bg:"veryLightBackground"},_focusVisible:{outline:"2px solid",outlineColor:"primary",outlineOffset:"1px"},transition:"background 0.15s"},children:[K.jsx(re,{src:t.image,alt:"product",w:o.length(40),h:o.length(40),objectFit:"cover",onLoad:Ge,borderRadius:o.radius(8)}),K.jsx(se,{fontSize:o.font(12),fontWeight:"400",color:"text",children:t.name})]})})(),K.jsx(H.Suspense,{fallback:K.jsx(Ur,{variant:"user",children:e.content}),children:K.jsx(Vr,{variant:"user",children:e.content})})]})]});if("products"===e.type)return K.jsx(ne,{maxW:"100%",alignSelf:"flex-start",mb:o.space(4),w:"full",opacity:d?1:0,transform:d?"translateY(0)":"translateY(4px)",transition:"opacity 0.3s ease-out, transform 0.3s ease-out",children:K.jsx(et,{products:e.products||[],shape:e.shape})});if("suggestions"===e.type)return K.jsx(Hr,{suggestions:e.suggestions||[],options:e.optionChips});if("follow_up"===e.type&&e.followUp)return K.jsx(tt,{message:e});if("handover"===e.type&&e.handover)return K.jsx(nt,{message:e});if("email_signup"===e.type&&e.emailSignup)return K.jsx(rt,{message:e});if("team"===e.type)return K.jsx(ot,{message:e});if("handover_event"===e.type&&e.handoverEvent)return K.jsx(at,{message:e});if("dori"===e.type&&!e.content?.trim()&&!t&&!e.showCartSummary)return null;const p="undefined"!=typeof document&&"true"===document.querySelector("script#dori-side-widget")?.getAttribute("data-hide-ratings"),h=a&&!p&&"dori"===e.type&&!t,f=Xe(o,r&&!t?{base:"14px",md:"13px"}:{base:"15px",md:"14px"});return K.jsxs(fe,{align:"stretch",gap:o.space(2),opacity:d?1:0,transform:d?"translateY(0)":"translateY(4px)",transition:"opacity 0.25s ease-out, transform 0.25s ease-out",children:[(!!u?.trim()||t)&&K.jsx(ne,{w:"full",alignSelf:"flex-start",children:K.jsx(H.Suspense,{fallback:K.jsx(Ur,{variant:"dori",textSize:f,children:u}),children:K.jsx(Vr,{variant:"dori",textSize:f,children:u})})}),e.showCartSummary?K.jsx(Or,{add:e.closerAdd}):e.showCartActions&&K.jsx(qr,{}),h&&void 0!==n&&K.jsx(Nr,{messageIndex:n,feedback:e.feedback})]})},Xr=e=>K.jsx($e,{label:"message",fallback:e.message?.content?K.jsx(Ur,{variant:"user"===e.message.type?"user":"dori",children:e.message.content}):null,children:K.jsx(Gr,{...e})}),Jr=({product:e,messages:t})=>{const n=$(),{enterFocusMode:r}=J(),{t:o}=ee(),a=t.filter(e=>"user"===e.type||"products"===e.type||"dori"===e.type&&(!!e.content?.trim()||e.showCartSummary)).length,i=1===a?o("productChatMessageOne"):o("productChatMessages").replace("{count}",String(a)),s=()=>r(e,"chat_card");return K.jsxs(oe,{role:"button",tabIndex:0,"aria-label":`${e.name} · ${i}`,onClick:s,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())},mt:n.space(1),mb:n.space(1),px:n.space(3),py:n.space(2.5),gap:n.space(2.5),align:"center",border:"1.5px solid",borderColor:"borderColor",borderRadius:n.radius(14),bg:"background",cursor:"pointer",_hover:{borderColor:"primary"},_focusVisible:{outline:"2px solid",outlineColor:"primary",outlineOffset:"1px"},transition:"border-color 0.15s",children:[e.image&&K.jsx(re,{src:e.image,alt:"",w:n.length(36),h:n.length(36),objectFit:"cover",onLoad:Ge,borderRadius:n.radius(8),flexShrink:0,bg:"lightBackground"}),K.jsxs(ne,{minW:0,flex:1,children:[K.jsx(se,{fontSize:n.font(12.5),fontWeight:600,color:"text",lineHeight:"1.3",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:e.name}),K.jsxs(se,{fontSize:n.font(11),color:"mutedText",fontFamily:xn,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[o("productChatLabel")," · ",i]})]}),K.jsx(Ke,{boxSize:n.length(13),color:"mutedText",flexShrink:0})]})},$r=["product_click","add_to_cart","exit_intent"];function eo(e){const t=(e?.fields??[]).filter(e=>"phone"===e||"email"===e);return Array.from(new Set(t))}const to="dori-lead-settled-",no="dori-lead-asks-";function ro(e){if("undefined"==typeof window)return null;try{return localStorage.getItem(e)}catch{return null}}function oo(e,t){if("undefined"!=typeof window)try{localStorage.setItem(e,t)}catch{}}function ao(e){e&&oo(`${to}${e}`,"1")}function io(e){if(!e)return 0;const t=Number.parseInt(ro(`${no}${e}`)??"",10);return Number.isFinite(t)&&t>0?t:0}const so=e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim()),lo=({threadId:e,fields:t,rule:n,message:r,note:o,onSettled:a})=>{const i=$(),{isMobile:s}=Se(),{t:l}=ee(),[c,d]=H.useState(!1),[u,p]=H.useState({phone:"",email:""}),[h,f]=H.useState(!1),[g,b]=H.useState(!1);H.useEffect(()=>{const e=requestAnimationFrame(()=>d(!0));return()=>cancelAnimationFrame(e)},[]),H.useEffect(()=>{if(!g)return;const e=setTimeout(a,2500);return()=>clearTimeout(e)},[g,a]);const x=H.useMemo(()=>{return{phone:t.includes("phone")&&(e=u.phone,(e.match(/\d/g)||[]).length>=6)?u.phone:void 0,email:t.includes("email")&&so(u.email)?u.email:void 0};var e},[t,u]),y=Boolean(x.phone||x.email),w=async()=>{!h&&y&&(f(!0),ao(e),await m(e,{...x,trigger:n.trigger}),f(!1),b(!0))},v=e=>l("phone"===e?"leadPromptPhonePlaceholder":"leadPromptEmailPlaceholder");return K.jsx(ne,{flexShrink:0,opacity:c?1:0,transform:c?"translateY(0)":"translateY(6px)",transition:"opacity 0.3s ease-out, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",borderWidth:"1px",borderColor:"border",borderRadius:i.radius(10),bg:"veryLightBackground",px:i.space(2.5),py:i.space(2),"data-dori-lead-capture":n.trigger,children:g?K.jsx(se,{fontSize:i.font(12),color:"text",fontFamily:xn,children:l("leadPromptSaved")}):K.jsxs(fe,{align:"stretch",gap:i.space(1.5),children:[K.jsx(se,{fontSize:i.font(12),lineHeight:"1.35",color:"text",fontFamily:xn,children:n.message||r||l("leadPromptText")}),K.jsxs(oe,{gap:i.space(1.5),wrap:"wrap",align:"center",children:[t.map(e=>K.jsx(Re,{value:u[e],onChange:t=>p(n=>({...n,[e]:t.target.value})),onKeyDown:e=>{"Enter"===e.key&&w()},placeholder:v(e),"aria-label":v(e),type:"phone"===e?"tel":"email",inputMode:"phone"===e?"tel":"email",autoComplete:"phone"===e?"tel":"email",fontSize:s?ge(i,16):i.font(13),color:"text",bg:"background",borderColor:"border",borderRadius:i.radius(8),flex:"1 1 8rem",minW:"8rem",height:i.length(32),px:i.space(2.5),py:0,_placeholder:{color:"mutedText"},_focus:{borderColor:"primary",boxShadow:"none"}},e)),K.jsx(ae,{size:"sm",flexShrink:0,borderRadius:i.radius(8),bg:"primary",color:"buttonText",fontSize:i.font(12),px:i.space(3),height:i.length(32),loading:h,disabled:!y,onClick:w,fontFamily:xn,children:l("leadPromptSave")})]}),K.jsxs(oe,{justify:"space-between",align:"center",gap:i.space(2),children:[K.jsx(se,{fontSize:i.font(10),lineHeight:"1.3",color:"mutedText",fontFamily:xn,children:o||l("leadPromptNote")}),K.jsx(ae,{size:"sm",variant:"plain",flexShrink:0,fontSize:i.font(11),color:"mutedText",px:0,height:"auto",minH:"auto",py:0,onClick:()=>{ao(e),a()},fontFamily:xn,children:l("leadPromptSkip")})]})]})})};function co(){const e=J(),t=e.botData?.feature_flags?.lead_capture,n=e.chatState.threadId,[r,o]=H.useState(!1),[a,i]=H.useState(null),[s,l]=H.useState(0),[c,d]=H.useState([]),[u,p]=H.useState(0),h=Boolean(t?.enabled),f=H.useMemo(()=>e.messages.filter(e=>"dori"===e.type).length,[e.messages]);H.useEffect(()=>{o(function(e){return!!e&&"1"===ro(`${to}${e}`)}(n)),l(io(n)),d([]),i(null)},[n]);const g=e=>d(t=>t.includes(e)?t:[...t,e]),m=H.useRef(Date.now());H.useEffect(()=>{m.current=Date.now(),p(0)},[e.messages.length]),H.useEffect(()=>{if(!h)return;const e=setInterval(()=>{p(Math.floor((Date.now()-m.current)/1e3))},5e3);return()=>clearInterval(e)},[h]),H.useEffect(()=>{h&&(e.focusedProduct||e.focusModeProduct)&&g("product_click")},[h,e.focusedProduct,e.focusModeProduct]);const b=H.useRef(e.cartItemCount??0);H.useEffect(()=>{if(!h)return;const t=e.cartItemCount??0;t>b.current&&g("add_to_cart"),b.current=t},[h,e.cartItemCount]),H.useEffect(()=>{if(!h)return;if("undefined"==typeof window||"undefined"==typeof document)return;if(window.matchMedia?.("(hover: none)")?.matches)return;const e=e=>{e.clientY<=0&&g("exit_intent")};return document.addEventListener("mouseout",e),()=>document.removeEventListener("mouseout",e)},[h]);const x=function(e,t){if(!e?.enabled)return null;if(!t.hasThread||t.settled||t.busy)return null;const n=e.fields??[],r=e.rules??[];if(0===n.length||0===r.length)return null;const o=e.max_asks??1;return t.asksUsed>=o?null:r.find(e=>function(e,t){switch(e.trigger){case"conversation_start":return!0;case"after_turns":return t.botTurns>=(e.value??1);case"idle":return t.botTurns>0&&t.idleSeconds>=(e.value??45);default:return!!$r.includes(e.trigger)&&t.firedEvents.includes(e.trigger)}}(e,t))??null}(t,{botTurns:f,idleSeconds:u,firedEvents:c,asksUsed:s,settled:r,hasThread:Boolean(n),busy:e.anySheetOpen||"generating"===e.inputState||!!e.handover});H.useEffect(()=>{!r&&!a&&x&&n&&(i(x),l(function(e){if(!e)return 0;const t=io(e)+1;return oo(`${no}${e}`,String(t)),t}(n)))},[x,a,r,n]);const y=function(e,t,n){return n?null:e??t}(a,x,r);return{rule:y,threadId:n,fields:eo(t),message:t?.message,note:t?.note,settle:()=>{i(null),o(!0)}}}const uo=({chat:e,t:t})=>{const n=$(),[r,o]=H.useState(!1);return H.useEffect(()=>{const e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),K.jsxs(oe,{role:"status","aria-live":"polite",flexShrink:0,justify:"space-between",align:"center",px:n.space(3),py:n.space(2),bg:"lightBackground",borderRadius:n.radius(8),borderLeft:"3px solid",borderLeftColor:"primary",fontSize:n.font(13),opacity:r?1:0,transform:r?"translateY(0)":"translateY(8px)",transition:"opacity 0.25s ease-out, transform 0.25s ease-out",children:[K.jsx(se,{color:"mutedText",fontSize:n.font(13),lineClamp:1,flex:1,children:"remove"===e.cartUndoState.operation?t("cartUndoRemoved").replace("{product}",e.cartUndoState.productName):t("cartUndoQuantityChanged").replace("{product}",e.cartUndoState.productName)}),K.jsxs(oe,{gap:n.space(1),children:[K.jsx(ae,{size:"xs",variant:"ghost",color:"primary",fontWeight:"600",fontSize:n.font(13),onClick:e.handleCartUndo,_hover:{bg:"transparent",opacity:.7},px:n.space(2),minW:"auto",children:t("cartUndoButton")}),K.jsx(de,{size:"xs",variant:"ghost","aria-label":"Dismiss",onClick:e.dismissCartUndo,color:"mutedText",_hover:{bg:"transparent",opacity:.7},minW:"auto",h:"auto",p:n.space(.5),children:K.jsx(pe,{boxSize:n.length(12)})})]})]})},po=({header:e})=>{const t=J(),n=it(t.handover),r=t.messages[t.messages.length-1],o=!!t.handover&&"user"===r?.type&&null!==t.handoverTeamReadAt&&t.handoverTeamReadAt>=new Date(r.timestamp).getTime(),{botData:a}=t,{t:i,translations:c}=ee(),d=s(a,c),{isMobile:u}=Se(),p=co(),h=$(),f=qe(u?1:Oe(t.botData).width),g=H.useRef(null),m=H.useRef(!0),x=H.useRef(!1),y=H.useRef(0),w=H.useCallback(()=>{if(x.current)return void(x.current=!1);if(Date.now()-y.current>3e3)return;const e=g.current;if(!e)return;const n=e.scrollHeight-e.scrollTop-e.clientHeight<80;n!==m.current&&(m.current=n,t.setAutoScrollEnabled(n))},[t.setAutoScrollEnabled]);H.useEffect(()=>{const e=g.current;e&&(t.handoverTeamTyping||o)&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&b(t.messagesEndRef.current)},[t.handoverTeamTyping,o,t.messagesEndRef]);const v=H.useRef(null),k=H.useRef(null),S=H.useCallback(e=>{const t=g.current,n=t?.querySelector(`[data-turn-anchor="${e}"]`),r=n?.firstElementChild??null;if(!t||!r)return!0;const o=()=>r.getBoundingClientRect().top-t.getBoundingClientRect().top-4,a=o();if(Math.abs(a)<=1)return!0;const i=t.scrollTop;return x.current=!0,t.scrollTop=i+a,t.scrollTop===i&&(x.current=!1),Math.abs(o())<=1},[]);H.useEffect(()=>{const e=t.answerAnchorTurnRef.current;if(e&&v.current!==e){const n=t.messages,r=n.findIndex(t=>"user"===t.type&&t.id===e);(-1===r?void 0:n.slice(r+1).find(e=>"dori"===e.type&&!e.showCartSummary||"products"===e.type))&&(v.current=e,t.setAutoScrollEnabled(!1),m.current=!1,k.current=e)}const n=k.current;n&&S(n)&&(k.current=null)},[t.messages,t.answerAnchorTurnRef,t.setAutoScrollEnabled,S]),H.useEffect(()=>{const e=g.current;if(!e||"undefined"==typeof ResizeObserver)return;const t=new ResizeObserver(()=>{const e=k.current;e&&S(e)&&(k.current=null)});for(const n of Array.from(e.children))t.observe(n);return()=>t.disconnect()},[S]);const j=H.useCallback(()=>{y.current=Date.now(),k.current=null},[]),C=H.useRef(0),z=null!=t.focusModeProduct,A=H.useRef(z);H.useLayoutEffect(()=>{const e=g.current,n=A.current;A.current=z,e&&(!n&&z?C.current=e.scrollTop:n&&!z&&(t.setAutoScrollEnabled(!1),m.current=!1,e.scrollTop=C.current))},[z,t.setAutoScrollEnabled]);const[E,T]=Ye(),R=_e("colors","primary"),W=Fe(R),I=H.useMemo(()=>{if(!t.chatState.isRequestInProgress)return null;if(t.messages.some(e=>"loading"===e.type))return null;for(let e=t.messages.length-1;e>=0;e--)if("dori"===t.messages[e].type)return t.messages[e].id;return null},[t.chatState.isRequestInProgress,t.messages]),B=H.useMemo(()=>{const e=[];for(const n of t.messages){const t=n.focusProductId;if(null!=t){const r=e[e.length-1];if(r&&"productChat"===r.kind&&r.tagId===t){r.messages.push(n);continue}e.push({kind:"productChat",tagId:t,product:null,messages:[n]});continue}e.push({kind:"msg",msg:n})}return e.flatMap(e=>{if("productChat"!==e.kind)return[e];const t=e.messages.find(t=>"user"===t.type&&t.repliedProduct&&String(t.repliedProduct.id)===e.tagId)?.repliedProduct??e.messages.find(e=>"user"===e.type&&e.repliedProduct)?.repliedProduct??null;return t?[{...e,product:t}]:e.messages.map(e=>({kind:"msg",msg:e}))})},[t.messages]),M=H.useMemo(()=>{const e=new Map;let n=0;for(const r of t.messages)"dori"===r.type&&e.set(r.id,n++);return e},[t.messages]);return K.jsxs(K.Fragment,{children:[e,d&&K.jsx(se,{fontWeight:"600",fontStyle:"normal",fontSize:h.isMini?h.font(24):`${f.greetingFontPx}px`,letterSpacing:"0",w:"fit-content",transition:"opacity 0.5s ease",fontFamily:xn,css:{background:W,WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:d}),K.jsxs(fe,{flex:1,justify:"center",align:"stretch",gap:h.space(f.sectionGap),minH:0,transition:"opacity 0.5s ease",opacity:1,children:[K.jsx(ne,{ref:g,flex:1,overflowY:"scroll",overflowX:"hidden","data-scroll-container":"chat-messages",overscrollBehavior:"contain",onScroll:w,onWheel:j,onTouchStart:j,onTouchMove:j,onPointerDown:j,onKeyDown:j,css:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch"},children:K.jsxs(fe,{overscrollBehavior:"contain",gap:h.space(2),align:"stretch",pb:h.space(2),children:["live"===t.handover?.state&&K.jsx(st,{card:t.handover}),K.jsx($e,{label:"message-list",children:B.reduce((e,t)=>{if("productChat"===t.kind)return e.elements.push(K.jsx(Jr,{product:t.product,messages:t.messages},`product-chat-${t.messages[0].id}`)),e.prevType="productChat",e;const n=t.msg,r="dori"===n.type,o=r&&"products"===e.prevType,a=K.jsx(Xr,{message:n,isStreaming:n.id===I,doriMessageIndex:r?M.get(n.id):void 0,isAfterProducts:o},n.id);return e.elements.push("user"===n.type?K.jsx("div",{"data-turn-anchor":n.id,style:{display:"contents"},children:a},n.id):a),e.prevType=n.type,e},{elements:[],prevType:""}).elements},B.length),t.handoverTeamTyping&&K.jsx(lt,{card:t.handover}),o&&K.jsx(ct,{}),K.jsx("div",{ref:t.messagesEndRef,style:{height:"1px"}})]})}),t.cartUndoState&&K.jsx(uo,{chat:t,t:i}),E&&!t.anySheetOpen&&K.jsx(Fr,{chips:[E],onChipClick:e=>{l("offer_guide_chat_opened",{from:"chat"}),T(),Ue(e).then(n=>t.sendMessage({message:e,apiMessage:n}))},onDismiss:()=>{Ne(),T()}}),p.rule&&p.threadId&&K.jsx(lo,{threadId:p.threadId,fields:p.fields,rule:p.rule,message:p.message,note:p.note,onSettled:p.settle}),K.jsx(ne,{flexShrink:0,bg:"transparent",borderRadius:h.radius(12),transition:"all 0.2s ease",onInput:t.noteHandoverTyping,children:K.jsx(Hn,{state:t.inputState,placeholder:"generating"===t.inputState?i("processing"):"live"===t.handover?.state?i("handoverMessagePlaceholder").replace("{team}",n):t.focusedProduct?i("askAboutProduct"):i("whatsYourQuestion"),onSend:t.isInputDisabled?void 0:t.sendMessage,onStop:t.stopCurrentRequest})})]})]})};function ho(e){return{position:"fixed",transition:"all 0.5s ease",visibility:e?"visible":"hidden",opacity:e?1:0,bgColor:"background",zIndex:1e6,overflow:"hidden",willChange:"transform",pointerEvents:e?"auto":"none",overscrollBehavior:"contain",touchAction:"pan-x pan-y"}}const fo=({children:e,showSuggestionScreen:t,isOpen:n,isExpanded:r=!1,onClose:o})=>{const{isMobile:a}=Se(),{botData:i}=J(),s=H.useRef(null),l=i?.customization?.position?.align??"right",c=Oe(i),d=mt(c.width,c.height),u=ht(i),p=qe(a?1:c.width),h=ft(gt(i,a)),f=_e("colors","borderColor"),g=!0===i?.feature_flags?.panel_drawer,m=(b={isMobile:a,mobileScale:u,isOpen:n,isExpanded:r,isDrawer:g,align:l,panel:d,borderColor:f}).isMobile?function(e){const{isOpen:t,mobileScale:n}=e,r=n<1;return{...ho(t),top:r?"auto":"0",left:"0",right:"0",bottom:"0",width:"auto",maxWidth:"100vw",height:r?`min(100dvh, max(${Math.round(100*n)}dvh, ${ut}px))`:"auto",border:"none",borderRadius:r?`${dt}px ${dt}px 0px 0px`:"0px",boxShadow:r?"0px -6px 24px rgba(0, 0, 0, 0.12)":"none",transform:t?"translateY(0)":"translateY(100vh)"}}(b):b.isDrawer?function(e){const{isOpen:t,align:n,panel:r}=e;return{...ho(t),top:"0",left:"left"===n?"0":"auto",right:"right"===n?"0":"auto",bottom:"0",width:r.width,maxWidth:"100vw",height:"100dvh",border:"none",borderRadius:"0px",boxShadow:"right"===n?"-8px 0px 28px rgba(0, 0, 0, 0.14)":"8px 0px 28px rgba(0, 0, 0, 0.14)",transform:t?"translateX(0)":"right"===n?"translateX(100%)":"translateX(-100%)"}}(b):function(e){const{isOpen:t,isExpanded:n,align:r,panel:o,borderColor:a}=e,i=n?"50%":"20px";return{...ho(t),top:"50%",left:"left"===r?i:"auto",right:"right"===r?i:"auto",bottom:"auto",width:n?o.expandedWidth:o.width,maxWidth:`calc(100vw - ${2*pt}px)`,height:n?o.expandedHeight:o.height,border:`1px solid ${a}`,borderRadius:"24px",boxShadow:"0px 4px 20px rgba(0, 0, 0, 0.1)",transform:t?n?"right"===r?"translate(50%, -50%)":"translate(-50%, -50%)":"translateY(-50%)":n?"right"===r?"translate(50%, -50%) translateX(120%)":"translate(-50%, -50%) translateX(-120%)":"right"===r?"translateY(-50%) translateX(120%)":"translateY(-50%) translateX(-120%)"}}(b);var b;return(({containerRef:e,isOpen:t,showSuggestionScreen:n})=>{H.useEffect(()=>{if(!t||!e.current)return;const n=e.current,r=e=>{if(e.scrollHeight<=e.clientHeight+1)return!1;const t=getComputedStyle(e).overflowY;return"auto"===t||"scroll"===t},o=e=>{e.preventDefault(),e.stopPropagation();const t=(e=>{let t=e.composedPath?.()[0]??e.target;for(;t&&t!==n;){if(t instanceof HTMLElement&&r(t))return t;t=t.parentElement}return null})(e)||n.querySelector('[data-scroll-container="sheet"]')||n.querySelector('[data-scroll-container="focus-mode"]')||n.querySelector('[data-scroll-container="chat-messages"]');t&&(t.scrollTop+=e.deltaY)};return n.addEventListener("wheel",o,{passive:!1}),()=>{n.removeEventListener("wheel",o)}},[t,n])})({containerRef:s,isOpen:n,showSuggestionScreen:t}),H.useEffect(()=>{const e=s.current;if(!e)return;const t=e=>e.preventDefault();return e.addEventListener("gesturestart",t,{passive:!1}),e.addEventListener("gesturechange",t,{passive:!1}),()=>{e.removeEventListener("gesturestart",t),e.removeEventListener("gesturechange",t)}},[]),H.useEffect(()=>{if(!n||!g||a||!o)return;const e=e=>{"Escape"===e.key&&setTimeout(()=>{e.defaultPrevented||o()},0)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,g,a,o]),K.jsxs(K.Fragment,{children:[!a&&g&&K.jsx(ne,{"data-dori-drawer-backdrop":"","aria-hidden":"true",position:"fixed",top:"0",left:"0",right:"0",bottom:"0",bgColor:"rgba(0, 0, 0, 0.4)",zIndex:1e6,opacity:n?1:0,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none",transition:"opacity 0.3s ease, visibility 0.3s ease",onClick:o}),K.jsx(ne,{ref:s,...m,children:K.jsxs(fe,{p:h.space(p.padding),pb:h.space(p.paddingBottom),h:"full",justify:"flex-start",align:"stretch",gap:h.space(p.contentGap),children:[e,!t&&K.jsx(ne,{transition:"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)",children:K.jsx(Vn,{variant:"default"})})]})})]})},go=/colo|couleur|farbe|màu|colore|kleur/i,mo=({variantSummary:e})=>{const t=$();if(!e?.options?.length)return null;const{options:n}=e,r=n.find(e=>go.test(e.name||"")||bt(e)),o=r?(()=>{const e=new Set(r.values.map(e=>e.image).filter(Boolean)).size>1,n=r.values.slice(0,6),o=r.values.length-n.length;return K.jsxs(oe,{gap:t.space(1),align:"center",wrap:"wrap",children:[n.map((n,r)=>{const o=!1===n.available,a=xt(n.value,n.swatch);return e&&n.image?K.jsx(ne,{position:"relative",title:n.value,w:t.length(16),h:t.length(16),borderRadius:t.radius(4),backgroundImage:`url(${n.image})`,backgroundSize:"cover",backgroundPosition:"center",border:"0.5px solid rgba(0,0,0,0.15)",opacity:o?.35:1,flexShrink:0,children:o&&K.jsx(ne,{position:"absolute",top:t.length(7),left:"-2px",w:t.length(20),h:"1.5px",bg:"text",transform:"rotate(-45deg)"})},r):a?K.jsx(ne,{position:"relative",title:n.value,w:t.length(15),h:t.length(15),borderRadius:"full",bg:a,border:"0.5px solid rgba(0,0,0,0.2)",opacity:o?.35:1,flexShrink:0,children:o&&K.jsx(ne,{position:"absolute",top:t.length(7),left:"-1px",w:t.length(17),h:"1.5px",bg:"text",transform:"rotate(-45deg)"})},r):K.jsx(se,{fontSize:t.font(10),px:t.space(1.5),py:t.space(.5),borderRadius:t.radius(6),border:"0.5px solid",borderColor:"borderColor",color:"mutedText",opacity:o?.5:1,textDecoration:o?"line-through":"none",whiteSpace:"nowrap",title:n.value,fontFamily:xn,children:n.value},r)}),o>0&&K.jsxs(se,{fontSize:t.font(11),color:"mutedText",fontFamily:xn,children:["+",o]})]})})():null,a=(r?n.filter(e=>e!==r):n).map(e=>{const n=e.values.slice(0,4),r=e.values.length-n.length;return K.jsxs(se,{fontSize:t.font(11),color:"mutedText",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxW:"100%",fontFamily:xn,children:[e.name,":"," ",n.map((e,t)=>K.jsxs(se,{as:"span",textDecoration:!1===e.available?"line-through":"none",opacity:!1===e.available?.6:1,children:[e.value,t<n.length-1?", ":""]},t)),r>0?`, +${r}`:""]},e.name)});return o||0!==a.length?K.jsxs(fe,{align:"start",gap:t.space(.5),w:"full",children:[o,a]}):null};let bo=1;const xo=[];let yo=!1,wo=0;function vo(){if(wo>0)return void wo--;const e=xo.pop();e&&e.close()}function ko(e,t){const n=H.useRef(t);n.current=t,H.useEffect(()=>{if(!e)return;const t=function(e){if("undefined"==typeof window||!window.history?.pushState)return null;const t=bo++;try{window.history.pushState({__dori_layer:t},"")}catch{return null}return yo||(yo=!0,window.addEventListener("popstate",vo)),xo.push({id:t,close:e}),t}(()=>n.current());return null!=t?()=>function(e){const t=xo.findIndex(t=>t.id===e);if(-1!==t){xo.splice(t,1);try{window.history.state?.__dori_layer===e&&(wo++,window.history.back())}catch{}}}(t):void 0},[e])}const So=({slides:e,initialIndex:t,alt:n,onClose:r})=>{const o=$(),a=H.useRef(null),[i,s]=H.useState(t);ko(!0,r),H.useEffect(()=>{const e=a.current;e&&e.clientWidth>0&&t>0&&e.scrollTo({left:t*e.clientWidth})},[]);const l=t=>{const n=a.current;!n||t<0||t>=e.length||(n.scrollTo({left:t*n.clientWidth,behavior:"smooth"}),s(t))},c=H.useRef(null);H.useEffect(()=>{const e=c.current;if(!e)return;const t=e.getRootNode().activeElement;return e.focus({preventScroll:!0}),()=>{t?.isConnected&&t.focus({preventScroll:!0})}},[]),H.useEffect(()=>{document.activeElement===document.body&&c.current?.focus({preventScroll:!0})},[i]);const d=e=>K.jsx(de,{"aria-label":e<0?"Previous image":"Next image",position:"absolute",top:"50%",...e<0?{left:o.length(10)}:{right:o.length(10)},transform:"translateY(-50%)",zIndex:2,size:"sm",minW:o.length(36),w:o.length(36),h:o.length(36),p:0,borderRadius:"full",bg:"rgba(255,255,255,0.92)",color:"text",border:"1px solid",borderColor:"borderColor",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",_hover:{bg:"white"},onClick:()=>l(i+e),children:e<0?K.jsx(ve,{boxSize:o.length(14)}):K.jsx(Ke,{boxSize:o.length(14)})});return K.jsxs(ne,{ref:c,tabIndex:-1,role:"dialog","aria-label":n,outline:"none",onKeyDown:e=>{"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(e.preventDefault(),l(i+("ArrowLeft"===e.key?-1:1)))},dir:"ltr",position:"absolute",inset:0,zIndex:60,bg:"rgba(12, 12, 12, 0.94)","data-dori-sheet":"true",children:[K.jsx(de,{"aria-label":"Close",position:"absolute",top:o.length(10),right:o.length(10),zIndex:2,size:"sm",minW:o.length(34),w:o.length(34),h:o.length(34),p:0,borderRadius:"full",bg:"rgba(255,255,255,0.14)",color:"white",_hover:{bg:"rgba(255,255,255,0.26)"},onClick:r,children:K.jsx(pe,{boxSize:o.length(12)})}),K.jsx(oe,{ref:a,gap:0,w:"full",h:"full",onScroll:()=>{const e=a.current;if(!e||0===e.clientWidth)return;const t=Math.round(e.scrollLeft/e.clientWidth);t!==i&&s(t)},onClick:r,css:{overflowX:"auto",scrollSnapType:"x mandatory",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},WebkitOverflowScrolling:"touch"},children:e.map(e=>K.jsx(ne,{css:{flex:"0 0 100%",scrollSnapAlign:"center"},h:"full",display:"flex",alignItems:"center",justifyContent:"center",p:4,children:K.jsx(re,{src:e.src,alt:n,w:"100%",h:"auto",maxH:"100%",objectFit:"contain",onClick:e=>e.stopPropagation()})},e.id))}),e.length>1&&i>0&&d(-1),e.length>1&&i<e.length-1&&d(1),e.length>1&&K.jsx(oe,{position:"absolute",bottom:o.length(14),left:"0",right:"0",justify:"center",gap:1.5,pointerEvents:"none",children:e.map((e,t)=>K.jsx(ne,{w:o.length(6),h:o.length(6),borderRadius:"full",bg:t===i?"white":"rgba(255,255,255,0.35)"},`dot-${e.id}`))})]})},jo=/colo|couleur|farbe|màu|colore|kleur/i,Co=e=>(e||"").replace(/^https?:/,"").split("?")[0],zo=({onClose:e})=>{const{focusModeProduct:t,focusModeAnchorTs:r,exitFocusMode:o,openVariantModal:a,variantModalProduct:s,addToCartDirect:l,sendMessage:c,stopCurrentRequest:d,botData:u,chatState:p,messages:h,inputState:f,isInputDisabled:g,shortlistEnabled:m,isShortlisted:b,toggleShortlist:v,answerAnchorTurnRef:k,isTestMode:S}=J(),j=$(),{t:C}=ee(),z=t,A=null!=z,E=H.useRef(null),[T,R]=H.useState(!1),[W,I]=H.useState(!1),B=H.useRef(null),M=H.useMemo(()=>"undefined"!=typeof window&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,[]);H.useEffect(()=>{if(!A)return R(!1),void I(!1);const e=requestAnimationFrame(()=>R(!0));return()=>cancelAnimationFrame(e)},[A]),H.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const _=H.useCallback(e=>{M?o(e):I(t=>t||(B.current=setTimeout(()=>o(e),180),!0))},[M,o]);ko(A,()=>_("back_gesture"));const[F,L]=H.useState(null);H.useEffect(()=>{if(!A)return;const e=e=>{"Escape"===e.key&&(e.preventDefault(),null==F?s||_("escape"):L(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[A,s,F,_]),H.useEffect(()=>{if(A){const e=requestAnimationFrame(()=>E.current?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)}},[A]);const[D,P]=H.useState(null),q=z?.url;H.useEffect(()=>{P(null);const e=q?wt(q):void 0;if(!e)return;let t=!1;return vt(e).then(e=>{!t&&e&&P(e)}).catch(()=>{}),()=>{t=!0}},[q]);const O=null!=z?.id?String(z.id):null,Y=H.useMemo(()=>null==O?[]:h.filter(e=>null!=e.focusProductId&&String(e.focusProductId)===O),[h,O]),N=H.useMemo(()=>{if(!p.isRequestInProgress)return null;if(Y.some(e=>"loading"===e.type))return null;for(let e=Y.length-1;e>=0;e--)if("dori"===Y[e].type)return Y[e].id;return null},[p.isRequestInProgress,Y]),U=H.useRef(null),V=H.useRef(null),Q=H.useRef(!1),Z=H.useRef(!1);Z.current=Y.length>0,H.useEffect(()=>{L(null);const e=U.current;Z.current?(Q.current=!0,e&&(e.scrollTop=e.scrollHeight)):(Q.current=!1,e&&(e.scrollTop=0)),B.current&&(clearTimeout(B.current),B.current=null),I(!1)},[r]);const G=H.useRef(!1),X=H.useCallback(()=>{if(G.current)return void(G.current=!1);const e=U.current;e&&(Q.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)},[]);H.useEffect(()=>{if(!A)return;const e=U.current,t=V.current;if(!e||!t)return;const n=new ResizeObserver(()=>{Q.current&&(G.current=!0,e.scrollTop=e.scrollHeight)});return n.observe(t),()=>n.disconnect()},[A]);const te=H.useCallback(()=>{Q.current=!0;const e=U.current;e&&(G.current=!0,e.scrollTop=e.scrollHeight)},[]),ce=H.useRef(null);H.useEffect(()=>{if(!A)return;const e=k.current;if(!e||ce.current===e)return;const t=Y.findIndex(t=>"user"===t.type&&t.id===e);if(-1===t)return;if(!Y.slice(t+1).find(e=>"dori"===e.type&&!e.showCartSummary||"products"===e.type))return;ce.current=e,Q.current=!1;const n=U.current,r=n?.querySelector(`[data-turn-anchor="${e}"]`),o=r?.firstElementChild??null;if(n&&o){const e=o.getBoundingClientRect().top-n.getBoundingClientRect().top;Math.abs(e-4)>1&&(G.current=!0,n.scrollTop+=e-4)}},[A,Y,k]);const ue=H.useMemo(()=>z?function(e,t){const n=[],r=new Set,o=(e,t,o)=>{t&&!r.has(Co(t))&&(r.add(Co(t)),n.push(null!=o?{id:e,src:t,color:o}:{id:e,src:t}))};if(t){const r=(t.options??[]).findIndex(e=>jo.test("string"==typeof e?e:e?.name||""));if(r>=0){const e=new Set;for(const n of t.variants){const t=yt(n,r+1);t&&!e.has(t)&&(e.add(t),o(`color:${t}`,n.featured_image?.src,t))}}for(const[e,a]of(t.images??[]).entries()){if(n.length>=8)break;o(`img:${e}`,a)}return 0===n.length&&o("main",e.image),n.slice(0,8)}const a=e.variant_summary?.options?.find(e=>jo.test(e.name||""));if(a?.values?.some(e=>e.image))for(const i of a.values)o(`color:${i.value}`,i.image,i.value);return 0===n.length&&o("main",e.image),n.slice(0,8)}(z,D):[],[z,D]);if(!z)return null;const he=ue[0]?.src||z.image,ge=ue.length>0?ue:he?[{id:"hero",src:he}]:[],me=n(u),be=(z.variant_summary?.options??[]).some(e=>(e.values?.length??0)>1),xe=(z.currency||u?.currency||"USD").split(" - ")[0]?.trim().toUpperCase()||"USD",ye=Boolean(z.is_on_sale&&null!=z.sale_price&&z.sale_price>0&&null!=z.price&&z.sale_price<z.price),we=ye&&z.sale_price?z.sale_price:z.price,ke=e=>i("focus_path_clicked",{assistantId:u?.assistant_id,threadId:p.threadId,payload:{product_id:z.id,path:e,mode_version:"focused_chat_v2"}}),Se=kt(z,u),je=null!==Se,Ce=(e,t)=>{ke(e),te(),c({message:t,apiMessage:`${t} (product id: ${z.id})`,focusScoped:!0})},ze=!0===u?.feature_flags?.hide_price_check,Ae=(e,t,n)=>K.jsxs(ae,{variant:"outline",h:j.length(40),px:j.space(2),gap:j.space(1.5),fontSize:j.font(12.5),fontWeight:500,color:"text",borderColor:"borderColor",borderRadius:j.radius(10),bg:"background",justifyContent:"center",_hover:{bg:"veryLightBackground",borderColor:"primary",color:"primary"},onClick:n,fontFamily:xn,children:[K.jsx(re,{src:e,alt:"",w:j.length(15),h:j.length(15),objectFit:"contain",flexShrink:0}),K.jsx(ne,{as:"span",minW:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t})]}),Ee=b(z.id);return K.jsxs(ne,{position:"absolute",inset:0,zIndex:30,bg:"background","data-dori-sheet":"true","data-focus-mode":"true",transform:T&&!W?"translateX(0)":"translateX(100%)",transition:M?"none":"transform 180ms ease-out",children:[K.jsxs(An,{direction:"column",h:"full",minH:0,children:[K.jsxs(An,{align:"center",gap:j.space(2),px:j.space(4),py:j.space(2.5),flexShrink:0,borderBottom:"1px solid",borderColor:"borderColor",bg:"background",children:[K.jsx(de,{ref:E,"aria-label":C("back"),size:"sm",variant:"ghost",color:"text",borderRadius:"full",minW:j.length(34),w:j.length(34),h:j.length(34),p:j.space(0),flexShrink:0,css:{"@media (hover: hover)":{"&:hover":{background:"var(--chakra-colors-lightBackground)"}}},onClick:()=>_("back"),children:K.jsx(ve,{boxSize:j.length(16)})}),z.image&&K.jsx(re,{src:z.image,alt:z.name,w:j.length(38),h:j.length(38),objectFit:"cover",onLoad:Ge,borderRadius:j.radius(8),flexShrink:0,bg:"lightBackground",border:"1px solid",borderColor:"borderColor"}),K.jsxs(ne,{minW:0,flex:1,children:[K.jsx(se,{fontSize:j.font(13.5),fontWeight:600,color:"text",lineHeight:"1.3",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:z.name}),K.jsxs(oe,{gap:j.space(1.5),align:"center",children:[ye&&null!=z.price&&K.jsx(se,{fontSize:j.font(11),color:"mutedText",textDecoration:"line-through",fontFamily:xn,children:Qe(z.price,xe)}),!!we&&we>0&&K.jsx(se,{fontSize:j.font(12.5),fontWeight:700,color:"text",fontFamily:xn,children:Qe(we,xe)}),z.price_on_request&&K.jsx(se,{fontSize:j.font(12.5),fontWeight:700,color:"text",fontFamily:xn,children:C("priceOnRequest")}),ye&&!!z.sale_percent_off&&K.jsxs(St,{bg:"errorBackground",color:"error",fontSize:j.font(10),borderRadius:j.radius(12),children:[z.sale_percent_off,"%"]})]})]}),m&&K.jsx(de,{"aria-label":C(Ee?"removeSaved":"saveForLater"),size:"sm",variant:"ghost",minW:j.length(34),w:j.length(34),h:j.length(34),p:j.space(0),borderRadius:"full",flexShrink:0,color:Ee?"primary":"mutedText",css:{"@media (hover: hover)":{"&:hover":{color:"var(--chakra-colors-primary)"}}},onClick:()=>v(z),children:Ee?K.jsx(ie,{boxSize:j.length(17)}):K.jsx(jt,{boxSize:j.length(17)})}),e&&K.jsx(de,{"aria-label":"Close",size:"sm",variant:"ghost",minW:j.length(34),w:j.length(34),h:j.length(34),p:j.space(0),borderRadius:"full",flexShrink:0,color:"mutedText",css:{"@media (hover: hover)":{"&:hover":{color:"var(--chakra-colors-primary)"}}},onClick:e,children:K.jsx(pe,{boxSize:j.length(13)})})]}),K.jsx(ne,{ref:U,flex:1,minH:0,overflowY:"auto",overflowX:"hidden",overscrollBehavior:"contain","data-scroll-container":"focus-mode",onScroll:X,px:j.space(4),py:j.space(3),css:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch"},children:K.jsxs(fe,{ref:V,align:"stretch",gap:j.space(3.5),children:[ue.length>1?K.jsx(Ct,{slides:ue,activeColor:null,height:zt(j,"gallery"),bgColor:"lightBackground",alt:z.name,onImageClick:e=>L(e)}):he&&K.jsx(re,{src:he,alt:z.name,role:"button",tabIndex:0,w:"full",h:zt(j,"single"),objectFit:"contain",borderRadius:j.radius(12),bg:"lightBackground",cursor:"zoom-in",onClick:()=>L(0),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),L(0))}}),!!z.description&&K.jsx(ne,{borderRadius:j.radius(8),borderLeft:"2px solid",borderLeftColor:"primary",px:j.length(10),py:j.length(6),bg:"lightBackground",children:K.jsx(se,{fontSize:j.font(12.5),color:"text",lineHeight:"1.5",lineClamp:3,fontFamily:xn,children:z.description})}),z.variant_summary&&K.jsx(mo,{variantSummary:z.variant_summary}),K.jsxs(fe,{align:"stretch",gap:j.space(1.5),children:[K.jsx(se,{fontSize:j.font(11),fontWeight:600,color:"mutedText",textTransform:"uppercase",letterSpacing:"0.05em",fontFamily:xn,children:C("needHelpDeciding")}),K.jsxs(ne,{display:"grid",gridTemplateColumns:`repeat(${ze?2:3}, minmax(0, 1fr))`,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LoKxoIczTgMzepI0VdHeU3gOOtcBADbt2+n9jWBVCpFqKnpYAvyc+h4y8aH0JxInMQXJuJx0e5dAW43LACurKzUuVOBHH0zqmaYGYWe5DzLuTkH7ulgI6NR9V2/QPHdvXzQrsFaCol7/nxP8a5802ymuZkiJSX8gxF93XsWLVybMdkBDtTmG6dePgZ1wBOrXl4bkBlcokLb7pz1yzEfff65X7gHAE7pDcy/aX6LMeaIzdzfDwB5gibddvXQfS31cwKjo8ba7m0ZXiE1Z1BgdE+GlQShHan2AoBvdA8GK0HCOFLtYXCh840L9QghaF/YCa3s3a3nw68+9Mym7woEOnGpz+XpY6snXd1iMk9qtl2ttbm4prPgJueLCpx18l0nZDGDGZBCQAnZVBouufn9P7+eKjz7ewOg0FsYveWyc3c27H1XGy2klJAsWgnYBsIhtr19KYDyzuDg72w748T5XJmZB1jYImMMXNflvqU9z39z4Uvvx9o1Pn8fEiCYmUfNuOB9j/U4YiAs3WTfbuV3vv6Hl7bR0dS5jiZxYqZLb5522jcte+7OmuAaBhBW7j8+eSZ9LuXqdSflFbvOKrSYesu0kcOmnWsHTzvHjr4mWsPMrpIKzOwU3grLD6fdOPh3p5P5He7Nr+mOvia6bsi0c+zw2Hl26uxpI0/0RUuFE+vNsc0mM5IUWQTgQAennD1rwrpRMy5UZ197saVDOsIO7hKjTk4JO07LWU/ikTMuFGOuncCBMWXMZKAkZY0/Gu06v08qAKjMHa65rgqLQEn2NTwblHm+Lus8k6V2Lv1wMQ4dpq3y0MxJKAWlXLc9LScVgHQid7zco6jnK/WNjX9zIkVngckW9i3Xjd0eB8r/HPqOEB3muJw6ygZR7o0eQEJIFp+Vu93+CoDytHx/cQABWPJGstQLSo5o9LrnP+s6+a79VZf/vrm5mUpKSrjwWQcg5Dg0c/KUBvsdvGT+fwEvnYKDff9ehQAAAABJRU5ErkJggg==",C("compareAction"),()=>Ce("compare",C("compareIntent").replace("{name}",z.name))),Ae("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAA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OAZ13BXIt89q4L5wyMyy/ZG5j/lU/EJYMk4kBm434cFTlHBJiMSuuiGTpzRevvD1vsFTRzaQaaQdVWR01V8PHwSBoqYmc8685lXW8RmmFNleKjZXkq1WeZ70hO6YNH9+jCBQfZMtZQm1/J0ZlMtlRG1ttyKi8Jm2mxcjfPOLlhkiPngmmE0y4aEQJZ5ovHzh6//xg9P9S08829z10him1laH1rx55/hGPxqg2upSqWWlQjyfBCE2Rpb9JFlBhGSqXD8coO8tvkv3YCBnmeEYoJeGTuvctf2xXVqJ4cawZThyTkDp2iez2axI7uuwdMv7H8DovyMzHeXI7DODhq4l43qISBKIqazESRhXOH3Q0NV9+x5DAOJcW0aMbWrpIemtTngSJNgpSbIQukNDGsasbm1tdem7OuxH48hMOTkpfvzt/7NbKrWBpCgL2GAnlIBWesOPv/3j3ZXk8x9VBDV0aBcBIKVT/0FlSuMSvmSS3toxM27ey1mIY2WF+vXcYBAEggH4ylsupACXCwRYCImE9lYwyvXD+KNLcdMOANeccMqqnpANO0tSSlI69SsA6Egfe65+NUCVFtcnBzxN5eSWAEMQM+pSdav69vljWmtrq8tms2LSFXfvECqx/ORhdV5vJEp+7fBfAaCKgT56h6fb2tr0tx5/4NXQxZ9mBhJKvznvylmn39ZyW+nDHp6u4vnqX357YK3dkekJdee0lvs6q//HR61lMuVE5cybW2ZNnHfRW43XXLS76W9mff7PeVKMP4SQ//8Ae5YJEhPYjogAAAAASUVORK5CYII=",C("similarAction"),()=>Ce("similar",`${C("doYouHaveSimilar")} ${z.name}`)),!ze&&Ae("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAVpElEQVR42s2beZyU1ZX3f+feZ+2NpluaIIYIcUEwEGiNW5yiBRS3OPqmUGlEQG2Zd4S4ZN5ETT5FzRsSEycqkDjayhpc6EokBhRkr2iMII3LCE40ajJJRNmapbue7d575o/qxoZIBFnv59N/dD1PVT2/7z3n3HPPPUXYdzAIBAJgOl4SIBgwJAkoo0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09fNWTgIgwTD7ffBi/6YQJHTtmGGP7jZhg2r3+TLpNb26x+d5rwzvuADQGcIHqz7wrn9iwq92RcFlOlKBdCy/1HIa189ZeatmI/Zjunt8/uyxI2bsVG3jVRgFluf4peLgA95Rc4H99fr9/rElV3nC/qV0LF9HKijouOFrN4+Yx+19up0PYDKZjEC6KL52zPBH9oh3Xb+sc7TfT4Z33FjAPj/KZEHEA0YPeSqGvk6FScH2nRJfOE2vzlp6HREx0u2BOQdNAM4ae/GjrTpsSMIosD3XL5clTWtmLT64JOe4APCJO0AKYc4ed8lTu5PCdSqIA+lavivsRf2/2GfSE1Me/4ABTLj/rpp1G968v1WFY1QUB5bn+hXSa1oz64VDNvtjBqDzb5OZmc9vuGzmzrBtrAqTWNrSkUxtlrRfAUMpo85KyFTrRIW253rltt+0ZsbiQwp4xweATj/XI8CcM27ET9t0eGcSJ2BjQLLYpKK0ARHguA7KLP/JV2Y8N/pwiz8qQXC/dgAwZyBembXkrhNKK/+P73prLWklAgQBwJGSSxxvY1enpOHVmYvrqVifOqzij6UFdAoMEMjCWELiijuurd28reUUNkZUVVX+9cGLb1x72mWXRZ2e87AfvPwvV+e0GtOjKzYAAAAASUVORK5CYII=",C("worthItAction"),()=>Ce("price_check",C("priceCheckIntent").replace("{name}",z.name)))]}),!!z.url&&K.jsxs(ae,{variant:"outline",h:j.length(40),w:"full",px:j.space(3),fontSize:j.font(12.5),fontWeight:500,color:"text",borderColor:"borderColor",bg:"background",justifyContent:"center",gap:j.space(1.5),borderRadius:j.radius(10),onClick:()=>{ke("product_page"),z.url&&u&&(x(z,u,p.threadId),Et(Tt(z.url),S))},_hover:{bg:"veryLightBackground",borderColor:"primary",color:"primary"},fontFamily:xn,children:[K.jsx(At,{boxSize:j.length(13)}),C("productPage")]})]}),Y.length>0&&K.jsx(fe,{align:"stretch",gap:j.space(2),children:Y.reduce((e,t)=>{const n=K.jsx(Xr,{message:t,isStreaming:t.id===N,isAfterProducts:"products"===e.prevType},t.id);return e.elements.push("user"===t.type?K.jsx("div",{"data-turn-anchor":t.id,style:{display:"contents"},children:n},t.id):n),e.prevType=t.type,e},{elements:[],prevType:""}).elements})]})}),K.jsxs(fe,{flexShrink:0,align:"stretch",gap:j.space(2),px:j.space(4),pt:j.space(2.5),borderTop:"1px solid",borderColor:"borderColor",bg:"background",children:[me&&K.jsxs(ae,{h:j.length(44),borderRadius:j.radius(12),fontSize:j.font(14),fontWeight:600,bg:"primary",color:"buttonText",w:"full",gap:j.space(1.5),onClick:()=>{Se?Et(Se.href,S):(ke("add"),te(),be?a(z,"focus_mode"):l({product_id:null!=z.id?String(z.id):void 0,product_name:z.name,product_url:z.url||void 0,product_handle:wt(z.url)||void 0,quantity:w(z),quantity_label:y(z)}))},_hover:{opacity:.92},fontFamily:xn,children:[je?null:K.jsx(le,{boxSize:j.length(16)}),C(je?Se.labelKey:"addToCartFull")]}),K.jsx(ne,{children:K.jsx(Hn,{state:f,placeholder:C("generating"===f?"processing":"askAboutProduct"),onSend:g?void 0:(e,t)=>(te(),c({message:e.message,imageUrl:e.imageUrl,focusScoped:!0},t)),onStop:d})})]})]}),null!=F&&ge.length>0&&K.jsx(So,{slides:ge,initialIndex:Math.min(F,ge.length-1),alt:z.name,onClose:()=>L(null)})]})},Ao=({open:e,onClose:t,title:n,children:r,onBack:o,footer:a})=>{const i=$(),s=H.useRef(null);return ko(e,o??t),H.useEffect(()=>{if(!e)return;const n=document.activeElement,r=e=>{"Escape"===e.key&&(e.preventDefault(),t())};window.addEventListener("keydown",r);const o=requestAnimationFrame(()=>{const e=s.current?.querySelector("[data-sheet-initial-focus='true']");(e||s.current)?.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(o),window.removeEventListener("keydown",r),n?.focus?.({preventScroll:!0})}},[e,t]),e?K.jsxs(ne,{position:"absolute",inset:0,zIndex:30,"data-dori-sheet":"true",children:[K.jsx(ne,{position:"absolute",inset:0,bg:"blackAlpha.500",onClick:t,"aria-hidden":"true"}),K.jsxs(An,{ref:s,tabIndex:-1,position:"absolute",bottom:0,left:0,right:0,direction:"column",bg:"background",borderTopRadius:"16px",maxH:"82%",pb:i.space(3),borderTop:"1px solid",borderColor:"borderColor",boxShadow:"0 -8px 24px rgba(0,0,0,0.18)",role:"dialog","aria-modal":"true","aria-label":n||void 0,children:[K.jsx(ne,{w:i.length(36),h:i.length(4),borderRadius:i.radius(2),bg:"borderColor",mx:"auto",mt:i.space(2),mb:i.space(1),flexShrink:0}),K.jsxs(An,{align:"center",justify:"space-between",px:i.space(4),py:i.space(1),flexShrink:0,gap:i.space(2),children:[K.jsxs(An,{align:"center",gap:i.space(1.5),minW:0,children:[o&&K.jsx(de,{"aria-label":"Back",size:"xs",variant:"ghost",color:"mutedText",borderRadius:"full",minW:i.length(24),w:i.length(24),h:i.length(24),p:i.space(0),css:{"@media (hover: hover)":{"&:hover":{background:"var(--chakra-colors-lightBackground)"}}},onClick:o,children:K.jsx(ve,{boxSize:i.length(13)})}),K.jsx(se,{fontSize:i.font(14),fontWeight:"600",color:"text",lineHeight:"1.3",fontFamily:xn,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:n||""})]}),K.jsx(de,{"aria-label":"Close",size:"xs",variant:"ghost",color:"mutedText",borderRadius:"full",minW:i.length(24),w:i.length(24),h:i.length(24),p:i.space(0),css:{"@media (hover: hover)":{"&:hover":{background:"var(--chakra-colors-lightBackground)"}}},onClick:t,children:K.jsx(pe,{boxSize:i.length(10)})})]}),K.jsx(ne,{flex:1,minH:0,overflowY:"auto","data-scroll-container":"sheet",px:i.space(4),pt:i.space(1),css:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:r}),a&&K.jsx(ne,{flexShrink:0,px:i.space(4),pt:i.space(2.5),borderTop:"1px solid",borderColor:"borderColor",children:a})]})]}):null},Eo=()=>{const e=$(),{variantModalProduct:t,variantModalSource:n,openVariantModal:r,addToCartDirect:o,botData:a,chatState:s,isTestMode:l}=J(),{t:c}=ee(),d=H.useRef(null),[u,p]=H.useState(null),[h,f]=H.useState(1),[g,m]=H.useState("idle"),[b,x]=H.useState(null),[y,w]=H.useState(null),v=t,k=null!=v?.id?String(v.id):null,S=H.useRef(k);if(H.useEffect(()=>{S.current!==k&&(S.current=k,null!=k&&(p(null),f(1),m("idle"),x(null),w(null)))},[k]),!v)return null;const j=y??v.selected_color??null,C=(j?v.variant_summary?.options?.flatMap(e=>e.values).find(e=>e.value===j&&e.image)?.image:null)||v.image,z=(v.currency||a?.currency||"USD").split(" - ")[0]?.trim().toUpperCase()||"USD",A=()=>{d.current&&(clearTimeout(d.current),d.current=null),p(null),f(1),m("idle"),x(null),w(null),r(null)},E="focus_mode"===n?A:void 0,T=u?.canAdd??!1,R=u?.priceCents??null,W=null!=R?Qe(R/100*h,z):null,I=Rt(e),B=!T&&"added"!==g,M="added"===g?`✓ ${c("addedToCart")}`:T?W?c("addQty").replace("{qty}",String(h)).replace("{price}",W):c("addToCartFull"):c("selectOptionsToContinue"),_=(e,t,n)=>K.jsx(ae,{variant:"ghost",size:"xs",minW:`${I.stepper}px`,h:`${I.stepper}px`,borderRadius:0,fontSize:`${I.stepperFont}px`,color:t?"mutedText":"text",disabled:t||"adding"===g||"added"===g,onClick:n,"aria-label":e,children:e}),F=K.jsxs(fe,{align:"stretch",gap:e.space(1.5),pb:e.space(1),children:[K.jsxs(oe,{gap:e.space(2.5),align:"center",children:[K.jsxs(oe,{gap:e.space(0),border:"1px solid",borderColor:"borderColor",borderRadius:e.radius(10),overflow:"hidden",flexShrink:0,children:[_("−",h<=1,()=>f(e=>Math.max(1,e-1))),K.jsx(se,{fontSize:`${I.stepperFont}px`,fontWeight:600,minW:`${I.qtyWidth}px`,textAlign:"center",color:"text",fontFamily:xn,children:h}),_("+",h>=10,()=>f(e=>Math.min(10,e+1)))]}),K.jsxs(ae,{flex:1,h:`${I.cta}px`,borderRadius:`${I.ctaRadius}px`,fontSize:`${B?I.ctaHintFont:I.ctaFont}px`,fontWeight:600,bg:"primary",color:"buttonText",gap:e.space(1.5),disabled:!T&&"added"!==g||"adding"===g,loading:"adding"===g,onClick:async()=>{if(!u?.canAdd||"adding"===g||"added"===g)return;m("adding"),x(null);const e=null!=v.id?String(v.id):void 0,t=u.variantId?{variant_id:u.variantId,product_id:e,product_name:v.name,quantity:h}:{product_id:e,product_name:v.name,product_url:v.url,selected_options:u.selectedOptions,quantity:h},n=kt(v,a);if(n)return void Et(n.href,l);const r=await o(t);"success"===r.type?(m("added"),i("variant_modal_added",{assistantId:a?.assistant_id,threadId:s.threadId,payload:{product_id:v.id,selected:u.selectedLabel,quantity:h}}),d.current=setTimeout(A,900)):"failed"===r.type&&"busy"===r.reason?m("idle"):(m("error"),x(It(r,c)||null))},_hover:{opacity:.92},fontFamily:xn,"data-sheet-initial-focus":"true",children:[K.jsx(le,{boxSize:`${I.ctaIcon}px`,flexShrink:0}),K.jsx(ne,{as:"span",minW:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:M})]})]}),"error"===g&&K.jsx(se,{fontSize:e.font(11),color:"error",fontFamily:xn,children:b||c("errorOccurred")})]});return K.jsx(Ao,{open:!0,onClose:A,onBack:E,title:c("chooseOptions"),footer:F,children:K.jsxs(fe,{align:"stretch",gap:e.space(3),pb:e.space(2),children:[K.jsxs(oe,{gap:e.space(2.5),align:"center",children:[C&&K.jsx(re,{src:C,alt:v.name,w:e.length(52),h:e.length(52),objectFit:"cover",onLoad:Ge,borderRadius:e.radius(10),flexShrink:0,bg:"lightBackground"}),K.jsxs(ne,{minW:0,children:[K.jsx(se,{fontSize:e.font(13),fontWeight:600,color:"text",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:v.name}),K.jsx(se,{fontSize:e.font(12),color:"mutedText",fontFamily:xn,children:u?.selectedLabel||(v.price?Qe(v.price,z):"")})]})]}),K.jsx(Wt,{product:v,controlled:!0,selectedColor:j,onColorChange:w,onSelectionChange:e=>{p(e),"error"===g&&(m("idle"),x(null))}},String(v.id))]})})},To=()=>{const e=$(),{shortlist:t,removeFromShortlist:n,shortlistOpen:r,setShortlistOpen:o,enterFocusMode:a,sendMessage:s,botData:l,chatState:c}=J(),{t:d}=ee();if(H.useEffect(()=>{r&&i("shortlist_opened",{assistantId:l?.assistant_id,threadId:c.threadId,payload:{count:t.length}})},[r]),!r)return null;const u=()=>o(!1),p=(e,t)=>{const n=(t||l?.currency||"USD").split(" - ")[0]?.trim().toUpperCase()||"USD";return Qe(e,n)},h=t.length>=2?K.jsx(ae,{w:"full",h:e.length(40),borderRadius:e.radius(12),fontSize:e.font(14),fontWeight:600,bg:"primary",color:"buttonText",onClick:()=>{const e=t.map(e=>e.name).join(", "),n=t.map(e=>e.id).join(", "),r=d("compareSavedIntent").replace("{names}",e);i("shortlist_compare_clicked",{assistantId:l?.assistant_id,threadId:c.threadId,payload:{count:t.length}}),u(),s({message:r,apiMessage:`${r} (product ids: ${n})`})},_hover:{opacity:.92},fontFamily:xn,children:d("compareSaved").replace("{count}",String(t.length))}):void 0;return K.jsx(Ao,{open:!0,onClose:u,title:d("savedProducts"),footer:h,children:K.jsxs(fe,{align:"stretch",gap:e.space(1.5),pb:e.space(2),children:[0===t.length&&K.jsx(se,{fontSize:e.font(13),color:"mutedText",textAlign:"center",py:e.space(6),fontFamily:xn,children:d("savedEmpty")}),t.map(t=>K.jsxs(oe,{gap:e.space(2.5),align:"center",p:e.space(1.5),borderRadius:e.radius(12),cursor:"pointer",onClick:()=>{u(),a(t,"shortlist")},_hover:{bg:"lightBackground"},transition:"background 0.15s",children:[t.image&&K.jsx(re,{src:t.image,alt:t.name,w:e.length(44),h:e.length(44),objectFit:"cover",onLoad:Ge,borderRadius:e.radius(10),flexShrink:0,bg:"lightBackground",border:"1px solid",borderColor:"borderColor"}),K.jsxs(ne,{minW:0,flex:1,children:[K.jsx(se,{fontSize:e.font(13),fontWeight:600,color:"text",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:xn,children:t.name}),!!t.price&&t.price>0&&K.jsx(se,{fontSize:e.font(12),color:"mutedText",fontFamily:xn,children:p(t.price,t.currency)}),t.price_on_request&&K.jsx(se,{fontSize:e.font(12),color:"mutedText",fontFamily:xn,children:d("priceOnRequest")})]}),K.jsx(de,{"aria-label":d("removeSaved"),size:"xs",variant:"ghost",minW:e.length(28),w:e.length(28),h:e.length(28),p:e.space(0),borderRadius:"full",color:"primary",css:{"@media (hover: hover)":{"&:hover":{background:"var(--chakra-colors-lightBackground)"}}},onClick:e=>{e.stopPropagation(),n(t.id)},children:K.jsx(ie,{boxSize:e.length(14)})})]},String(t.id)))]})})},Ro=({isOpen:n,onClose:r,isExpanded:o=!1,onToggleExpand:a,fullPageHref:i,pendingChat:s,onPendingChatConsumed:l})=>{const{sendMessage:c,addWelcomeMessage:d,resetBot:u,chatState:p,focusedProduct:h,isInputDisabled:f}=J(),{showSuggestionScreen:g,goToChat:m,goToSuggestion:b}=(n=>{const[r,o]=H.useState(!0),a=H.useRef(!1),i=H.useRef(!1);return H.useEffect(()=>{if(!i.current){const n=e();t()&&n.length>0&&(a.current=!0,o(!1),console.log("Skipping welcome screen - existing messages found:",n.length)),i.current=!0}},[]),H.useEffect(()=>{n&&!a.current?o(!0):n&&a.current&&o(!1)},[n]),{showSuggestionScreen:r,goToChat:H.useCallback(()=>{a.current=!0,o(!1)},[]),goToSuggestion:H.useCallback(()=>{a.current=!1,o(!0)},[])}})(n);H.useEffect(()=>{g&&(p.isRequestInProgress||h)&&m()},[g,p.isRequestInProgress,h,m]);const{isMobile:x}=Se(),y=H.useRef(!1);H.useEffect(()=>{n&&!y.current&&(v(),y.current=!0)},[n]);const w=x,k=(e,t,n)=>{m(),d(),c({message:e,imageUrl:t,apiMessage:n})};H.useEffect(()=>{if(n&&s&&!f){const e=setTimeout(()=>{k(s.message,s.imageUrl,s.apiMessage),l?.()},100);return()=>clearTimeout(e)}},[n,s,f]);return K.jsxs(fo,{showSuggestionScreen:g,isOpen:n,isExpanded:o,onClose:r,children:[g?K.jsx(Lr,{onStartChat:k,isMobile:w,isExpanded:o,onToggleExpand:a,fullPageHref:i,onClose:r}):K.jsx(po,{header:K.jsx(Wn,{onClose:r,isMobile:w,isExpanded:o,onToggleExpand:a,fullPageHref:i,onReload:()=>{u(),b()}})}),K.jsx(zo,{onClose:r}),K.jsx(Eo,{}),K.jsx(To,{})]})};function Wo(e,t=!1){const n=e?.feature_flags,r=(t?n?.mobile_fab_scale:void 0)??n?.fab_scale??e?.customization?.avatar_fab_scale;return"number"==typeof r&&Number.isFinite(r)?Math.min(1.5,Math.max(.4,r)):1}const Io="0 6px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06)",Bo={size:"xs",flexShrink:0,h:"32px",px:3,borderRadius:"full",bg:"primary",color:"buttonText",fontSize:"12px",fontWeight:600,fontFamily:xn,whiteSpace:"nowrap",transition:"transform 100ms ease-out",_active:{transform:"scale(0.97)"}},Mo=H.forwardRef(function({icon:e,children:t,action:n,actionBelow:r=!1,onClose:o,closeLabel:a,maxW:i},s){return K.jsxs(oe,{ref:s,gap:2,align:r?"flex-start":"center",maxW:i,minH:"44px",py:r?2.5:1.5,ps:3,pe:1,bg:"background",borderRadius:"22px",border:"1px solid",borderColor:"borderColor",boxShadow:Io,children:[K.jsx(ne,{flexShrink:0,display:"flex",color:"primary",mt:r?"2px":0,children:e}),K.jsxs(ne,{flex:"1",minW:0,children:[t,r&&n?K.jsx(ne,{mt:2,children:n}):null]}),r?null:n,K.jsx(de,{size:"xs",variant:"ghost","aria-label":a,onClick:o,flexShrink:0,w:"28px",minW:"28px",h:"28px",borderRadius:"full",color:"text",opacity:.55,transition:"transform 100ms ease-out",_active:{transform:"scale(0.9)"},children:K.jsx(pe,{boxSize:"12px"})})]})}),_o=()=>!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;function Fo(e,t,n,r){const o=H.useRef(null),a=H.useRef(r);a.current=r;const i=H.useRef(n);return i.current=n,H.useEffect(()=>{if(!e)return;o.current?.focus({preventScroll:!0});const n=e=>{const n=o.current;if(!n)return;if("Escape"===e.key)return t&&e.stopPropagation(),void i.current();if(!t||"Tab"!==e.key)return;const r=Array.from(n.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])')),a=function(e){return e.getRootNode().activeElement??null}(n),s=r[0],l=r[r.length-1];if(s&&a&&n.contains(a))!e.shiftKey||a!==s&&a!==n?e.shiftKey||a!==l||(e.preventDefault(),s.focus()):(e.preventDefault(),l.focus());else{e.preventDefault();const t=e.shiftKey?l:s;t?t.focus():n.focus()}};return document.addEventListener("keydown",n,!0),()=>{document.removeEventListener("keydown",n,!0),a.current?.()}},[e,t]),o}function Lo({layer:e,open:t,onCollapse:n,onClosed:r,label:o,children:a}){const i=Fo(t,!0,n,r),[s,l]=H.useState(!1);if(H.useEffect(()=>{if(!t)return void l(!1);const e=requestAnimationFrame(()=>l(!0)),n=document.documentElement,r=n.style.overflow;return n.style.overflow="hidden",()=>{cancelAnimationFrame(e),n.style.overflow=r}},[t]),!e)return null;const c=_o()?void 0:"transform 220ms ease-out, opacity 220ms ease-out";return Sn.createPortal(K.jsxs(ne,{display:t?"block":"none",children:[K.jsx(ne,{position:"fixed",inset:0,zIndex:1000001,bg:"blackAlpha.400",opacity:s?1:0,transition:c,touchAction:"none",onClick:n,"aria-hidden":!0}),K.jsxs(ne,{ref:i,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,outline:"none",position:"fixed",left:0,right:0,bottom:0,zIndex:1000002,display:"flex",flexDirection:"column",bg:"background",borderTopRadius:"20px",boxShadow:"0 -8px 32px rgba(0,0,0,0.14)",css:{maxHeight:"85vh","@supports (height: 1dvh)":{maxHeight:"85dvh"}},transform:s||_o()?"none":"translateY(24px)",opacity:s?1:0,transition:c,children:[K.jsx(ne,{as:"button",tabIndex:-1,"aria-hidden":!0,onClick:n,py:2.5,flexShrink:0,cursor:"pointer",children:K.jsx(ne,{w:"36px",h:"4px",mx:"auto",borderRadius:"full",bg:"blackAlpha.300"})}),K.jsx(ne,{overflowY:"auto",overscrollBehavior:"contain",px:4,pb:"calc(16px + env(safe-area-inset-bottom, 0px))",children:a})]})]}),e)}function Do({open:e,onCollapse:t,onClosed:n,label:r,children:o,w:a,maxH:i}){const s=Fo(e,!1,t,n),l=H.useRef(t);return l.current=t,H.useEffect(()=>{if(!e)return;const t=e=>{s.current&&!e.composedPath().includes(s.current)&&l.current()};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,s]),K.jsx(ne,{ref:s,display:e?"block":"none",role:"dialog","aria-label":r,tabIndex:-1,outline:"none",w:a,maxH:i,overflowY:"auto",overscrollBehavior:"contain",bg:"background",borderRadius:"20px",border:"1px solid",borderColor:"borderColor",boxShadow:Io,p:4,children:o})}function Po({isMobile:e,layer:t,w:n,maxH:r,...o}){return e?K.jsx(Lo,{layer:t,...o}):K.jsx(Do,{w:n,maxH:r,...o})}const Ho={size:"xs",borderRadius:"999px",fontSize:"12.5px",fontWeight:600,px:3,h:"28px",fontFamily:xn,transition:"transform 100ms ease-out",_active:{transform:"scale(0.97)"}},qo=e=>e&&"Default Title"!==e?e:"";function Oo({api:e,row:t}){const n=e.rowFacts(t),{price:r,note:o}=n,a="added"===t.state?null!=t.paid&&t.paid<r-.005?Math.max(0,t.paid):null:n.pay,i=t.variants.filter(e=>e.available),s="added"===t.state?e.say(null,"added_check"):"sold"===t.state?e.say(null,"sold_out"):e.say(null,"add");return K.jsxs(fe,{align:"stretch",gap:1.5,py:2,borderTop:"1px solid",borderColor:"blackAlpha.100","data-dori-guide-row":t.pid,children:[K.jsxs(oe,{align:"flex-start",gap:2,children:[t.image?K.jsx(re,{src:t.image,alt:"",boxSize:"48px",objectFit:"cover",onLoad:Ge,borderRadius:"8px",flexShrink:0,bg:"blackAlpha.50"}):null,K.jsxs(fe,{align:"stretch",gap:.5,flex:1,minW:0,children:[K.jsx(se,{fontSize:"12.5px",lineHeight:"1.3",lineClamp:2,fontFamily:xn,color:"text",children:t.title}),K.jsxs(se,{fontSize:"12.5px",fontFamily:xn,color:"text",children:[K.jsx("b",{children:null==a?e.money(r):a<.005?e.say(null,"free"):e.money(a)}),null!=a?K.jsx("s",{style:{marginInlineStart:6,opacity:.6},children:e.money(r)}):null]}),o?K.jsx(se,{fontSize:"11.5px",color:"mutedText",fontFamily:xn,children:o}):null,1===i.length&&qo(i[0].title)?K.jsx(se,{fontSize:"11.5px",color:"mutedText",fontFamily:xn,children:i[0].title}):null]}),K.jsx(ae,{...Ho,flexShrink:0,bg:"idle"===t.state?"primary":"blackAlpha.100",color:"idle"===t.state?"buttonText":"text",disabled:"idle"!==t.state||!t.chosen,loading:"adding"===t.state,onClick:()=>{e.add(t.pid)},"aria-label":`${s}: ${t.title}`,children:s})]}),i.length>1&&"added"!==t.state?K.jsx(oe,{gap:1,flexWrap:"wrap",ps:t.image?"56px":0,children:i.map(n=>K.jsx(ae,{...Ho,h:"auto",minH:"24px",py:"3px",maxW:"100%",whiteSpace:"normal",textAlign:"start",lineHeight:"1.25",fontWeight:500,variant:"outline","aria-pressed":t.chosen===n.id,bg:t.chosen===n.id?"text":"transparent",color:t.chosen===n.id?"background":"text",onClick:()=>e.choose(t.pid,n.id),children:n.title},n.id))}):null]})}const Yo=({api:e,isMobile:t,layer:n,pillMaxW:r,panelW:o,panelMaxH:a})=>{const{v:i,visible:s}=function(e){const[t,n]=H.useState(e),[r,o]=H.useState(!1);return H.useEffect(()=>{if(e){n(e);const t=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(t)}o(!1);const t=window.setTimeout(()=>n(null),200);return()=>window.clearTimeout(t)},[e]),{v:e??t,visible:!!e&&r}}(e.view),l=H.useRef(null);if(!i)return null;const c=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,d=!e.view,u=i.decision,p="add_this"!==u.cta&&"add_it"!==u.cta||!i.rows?.[0]?null:i.rows[0],h=p?.variants.find(e=>e.id===p.chosen)??null,f=p&&h?e.rowFacts(p):null,g=e.say(null,"close")||"Close",m=f?.note??i.note;let b=null;if(i.result)i.result.undoVid&&(b={label:e.say(null,"undo"),run:()=>{e.undo()},quiet:!0});else if("see_picks"===u.cta)b={label:e.say(null,"show_picks"),run:()=>{e.unfold()},opens:!0};else if(p&&"idle"===p.state){const t=f?null==f.pay?e.money(f.price):f.pay<.005?e.say(null,"free"):e.money(f.pay):"",n=h?[e.say(null,"add"),qo(h.title),t].filter(Boolean).join(" · "):"";b=n&&n.length<=40?{label:n,run:()=>{e.add(p.pid)}}:{label:e.say(null,"choose"),run:()=>{e.unfold()},opens:!0}}const x=b?K.jsx(ae,{ref:l,...Bo,...b.quiet?{bg:"blackAlpha.100",color:"text"}:{},"aria-haspopup":b.opens?"dialog":void 0,onClick:b.run,children:b.label}):null,y=i.result?K.jsx(se,{fontSize:"13px",lineHeight:"1.35",color:"text",fontFamily:xn,children:i.result.text}):null,w=i.rows??[];return K.jsxs(ne,{opacity:s?1:0,transform:s||c?"none":"translateY(8px) scale(0.98)",transformOrigin:"bottom",transition:"opacity 200ms ease-out, transform 200ms ease-out",pointerEvents:d?"none":void 0,"aria-hidden":d||void 0,"data-dori-offer-guide":d?void 0:u.offer,children:[!i.open&&K.jsx(Mo,{maxW:r,icon:K.jsx(le,{boxSize:"16px"}),closeLabel:g,onClose:e.close,action:x,actionBelow:!!b&&b.label.length>12,children:K.jsx(ne,{"aria-live":"polite",role:i.result?"status":void 0,children:y??K.jsxs(K.Fragment,{children:[K.jsx(se,{fontSize:"13px",fontWeight:600,lineHeight:"1.35",color:"text",fontFamily:xn,children:i.line}),m?K.jsx(se,{fontSize:"12px",lineHeight:"1.35",color:"mutedText",mt:.5,fontFamily:xn,children:m}):null]})})}),i.open&&K.jsx(Po,{isMobile:t,layer:n,open:!0,label:i.head||i.line,w:o,maxH:a,onCollapse:e.fold,onClosed:()=>l.current?.focus(),children:K.jsxs(fe,{align:"stretch",gap:2,children:[K.jsxs(oe,{align:"flex-start",gap:2,children:[K.jsx(se,{flex:1,fontSize:"13px",fontWeight:600,lineHeight:"1.4",color:"text",fontFamily:xn,children:i.line}),K.jsx(de,{size:"xs",variant:"ghost","aria-label":g,onClick:e.close,h:"auto",minW:"auto",p:1,color:"text",transition:"transform 100ms ease-out",_active:{transform:"scale(0.9)"},children:K.jsx(pe,{boxSize:"14px"})})]}),i.head?K.jsx(se,{fontSize:"12px",color:"mutedText",fontFamily:xn,children:i.head}):null,null==i.rows?K.jsx(oe,{justify:"center",py:4,children:K.jsx(me,{size:"sm",color:"primary"})}):w.length?w.map(t=>K.jsx(Oo,{api:e,row:t},t.pid)):K.jsx(se,{fontSize:"12.5px",color:"mutedText",py:2,fontFamily:xn,children:e.say(null,"sold_out")}),i.result?K.jsxs(oe,{role:"status","aria-live":"polite",gap:2,pt:1,borderTop:"1px solid",borderColor:"blackAlpha.100",children:[K.jsx(ne,{flex:1,children:y}),i.result.undoVid?K.jsx(ae,{variant:"plain",size:"xs",h:"auto",p:0,textDecoration:"underline",fontWeight:400,onClick:()=>{e.undo()},children:e.say(null,"undo")}):null]}):null]})})]})},No="dori-quiz-dismissed";function Uo(){try{return"true"===sessionStorage.getItem(No)}catch{return!1}}function Vo(){try{sessionStorage.setItem(No,"true")}catch{}}const Ko=e=>null==e?null:{p:new Set(e.p),v:new Set(e.v||[])},Qo=(e,t)=>null===e||e.p.has(t.pid)||e.v.has(t.vid),Zo=e=>Math.round(100*e)/100;function Go(e,t=new Date){const n=e.offers.filter(e=>!e.ends_at||new Date(e.ends_at)>t);return{pack:e,offers:n.map(e=>({o:e,scope:Ko(e.scope),buys:Ko(e.buys),gets:e.same?Ko(e.buys):Ko(e.gets)}))}}const Xo=e=>e.reduce((e,t)=>e+t.price*t.qty,0),Jo=e=>e.flatMap(e=>Array.from({length:e.qty},()=>({pid:e.pid,vid:e.vid,price:e.price}))),$o=(e,t)=>null!=e.pct?t*e.pct:Math.min(e.amount??0,t);function ea(e,t,n){const r=new Map,o=e.offers.filter(e=>"ship"!==e.o.kind).map(e=>"basic"===e.o.kind?function(e,t){const n=e.o,r=Jo(t).filter(t=>Qo(e.scope,t)),o=r.reduce((e,t)=>e+t.price,0),a=r.length,i=a>0&&(!n.min_amount||o>=n.min_amount)&&(!n.min_qty||a>=n.min_qty),s=i?null!=n.pct?n.pct*o:n.each?r.reduce((e,t)=>e+Math.min(n.amount??0,t.price),0):Math.min(n.amount??0,o):0;return{off:e,applies:i,value:s,disc:i?r:[],amt:o,qty:a,gapAmount:n.min_amount?Math.max(0,n.min_amount-o):null,gapQty:n.min_qty?Math.max(0,n.min_qty-a):null}}(e,t):function(e,t){const n=e.o,r=n.buy_qty||1,o=n.get_qty||1,a=Jo(t);if(n.same){const t=a.filter(t=>Qo(e.buys,t)).sort((e,t)=>t.price-e.price);let i=Math.floor(t.length/(r+o));n.per_order&&(i=Math.min(i,n.per_order));const s=t.slice(t.length-i*o).sort((e,t)=>e.price-t.price),l=t.length-i*(r+o);return{off:e,applies:i>0,value:s.reduce((e,t)=>e+$o(n,t.price),0),disc:s,el:t,earned:l>=r&&(!n.per_order||i<n.per_order)}}const i=a.filter(t=>Qo(e.buys,t)),s=a.filter(t=>Qo(e.gets,t)).sort((e,t)=>e.price-t.price),l=n.per_order?n.per_order*o:1/0,c=new Set;for(const h of s){if(c.size>=l)break;i.filter(e=>e!==h&&!c.has(e)).length>=r*Math.ceil((c.size+1)/o)&&c.add(h)}const d=s.filter(e=>c.has(e)),u=i.filter(e=>!c.has(e)).length,p=Math.min(Math.floor(u/r)*o,l);return{off:e,applies:d.length>0,value:d.reduce((e,t)=>e+$o(n,t.price),0),disc:d,earned:p>d.length,hasGet:s.length>0,hasBuy:u>0}}(e,t));o.forEach(e=>r.set(e.off.o.id,e));const a=o.filter(e=>e.applies&&e.value>0).sort((e,t)=>t.value-e.value),i=a.slice(0,1),s=a.slice(1).some(e=>{return t=i[0].off.o,n=e.off.o,!!t.cw?.[n.cls||"product"]&&!!n.cw?.[t.cls||"product"];var t,n}),l=Zo(Xo(t))-i.reduce((e,t)=>e+Zo(t.value),0),c=e.offers.filter(e=>"ship"===e.o.kind).map(e=>{const t=((e,t)=>!e.countries||!!t.country&&e.countries.includes(t.country))(e.o,n),o={off:e,applies:t&&l>=(e.o.min??0),value:0,disc:[],gap:Math.max(0,(e.o.min??0)-l)};var a,s;return!o.applies||!i.length||(a=i[0].off.o,"rates"===(s=e.o).source||a.ship_ok&&("order"===a.cls?s.with_order:s.with_product))||(o.applies=!1,o.offBy=i[0].off),r.set(e.o.id,o),o}),d=i.concat(c.filter(e=>e.applies));return{st:r,applied:d,ids:new Set(d.map(e=>e.off.o.id)),base:l,stacked:s}}const ta=(e,t,n)=>Zo(Xo(t))-ea(e,t,n).applied.reduce((e,t)=>e+Zo(t.value),0);function na(e,t,n,r){const o=ea(e,t,r);if(o.stacked)return!1;const a=o.applied.reduce((e,t)=>e+t.disc.length,0);return Math.abs(ta(e,t,r)-n)<=.01*(a+1)+1e-9}const ra=(e,t,n,r="")=>e.concat([{pid:t,vid:r,qty:1,price:n}]),oa=(e,t,n,r,o,a="")=>ta(e,ra(t,n,r,a),o)-ta(e,t,o),aa=(e,t,n)=>t.speak&&!n.blocked.has(t.id)&&!("ship"===t.kind&&n.country!==e.pack.main_country)&&(!t.ends_at||new Date(t.ends_at)>new Date),ia=(e,t)=>e.pack.products[t]?.p??0,sa=(e,t)=>e.pack.products[t]?.ty||"",la=(e,t)=>e.offers.find(n=>"ship"===n.o.kind&&aa(e,n.o,t))?.o??null;function ca(e,t,n){const r=function(e,t,n){const r=e=>!!e&&"basic"===e.off.o.kind&&!e.off.o.scope,o=n.applied.find(e=>r(e));return[...t.ids].filter(e=>!n.ids.has(e)).map(e=>t.st.get(e)).filter(e=>!(e.off.o.free_anyway||r(e)&&o&&o.value>e.value)).map(e=>e.off.o)}(0,t,n);return{block:r.find(e=>"ship"!==e.kind)??null,shipLost:r.find(e=>"ship"===e.kind)??null}}const da=e=>e.pct??0;function ua(e,t){const n=e.applied.find(e=>"basic"===e.off.o.kind&&!e.off.o.scope);return n&&!t.scope&&n.off.o.id!==t.id&&da(n.off.o)<da(t)?n.off.o:null}function pa(e,t,n,r,o,a,i){const s=e.offers.find(e=>e.o.id===n)?.o;if(!s||s.ends_at&&new Date(s.ends_at)<=new Date)return!1;const l=ea(e,t,i),c=ea(e,ra(t,r,a,o),i);return c.ids.has(n)&&!c.stacked&&!ca(0,l,c).block}function ha(e,t,n,r){const o=t.o,a=new Set(n.map(e=>e.pid)),i=t=>!a.has(t)&&!r.sold.has(t)&&!!e.pack.products[t],s=new Set(n.map(t=>sa(e,t.pid)).filter(Boolean)),l=t=>oa(e,n,t,ia(e,t),r);let c=[];if("ship"===o.kind||"basic"===o.kind&&!o.scope&&o.min_amount){const t=e.pack.closers.filter(t=>(t=>!r.sold.has(t)&&!!e.pack.products[t])(t)&&ea(e,ra(n,t,ia(e,t)),r).ids.has(o.id)).map((e,t)=>({id:e,i:t,x:l(e)})).sort((e,t)=>e.x-t.x||e.i-t.i);if(t.length){const n=2*t[0].x;c=[t[0],...t.filter(t=>s.has(sa(e,t.id))&&t.x<=n),...t].map(e=>e.id)}}else if("basic"===o.kind)c=(o.scope?o.picks||[]:e.pack.closers).filter(i);else{c=(o.picks||[]).filter(e=>i(e)&&Qo(t.gets,{pid:e,vid:""}));const a=la(e,r);if(a?.fee){const t=t=>{const o=ra(n,t,ia(e,t));return ta(e,o,r)+(ea(e,o,r).ids.has(a.id)?0:a.fee)},o=c.filter(t=>fa(e,n,t,ia(e,t),r)).sort((e,n)=>t(e)-t(n));o.length&&(!c.length||t(o[0])<t(c[0])-.005)&&(c=[o[0],...c])}}return[...new Set(c)].filter(t=>l(t)<=ia(e,t)+.005&&pa(e,n,o.id,t,"",ia(e,t),r)).slice(0,3)}function fa(e,t,n,r,o){const a=la(e,o);return a&&!ea(e,t,o).ids.has(a.id)&&ea(e,ra(t,n,r),o).ids.has(a.id)?a:null}function ga(e){return null!=e.pct?Math.round(1e3*e.pct)/10+"%":e.amount??0}function ma(e,t){const n=(t||e.language||"en").toLowerCase(),r=n.split("-")[0],o=e.copy[n]?n:e.copy[r]?r:null;return o?{lang:o,copy:e.copy[o]}:null}const ba=new Set(["US","GB","AE","NL","PH","CZ","DO","BS","GM","CF","KM","MV","MH","SB","VA","CD","CG"]),xa=new Set(["gap","fee","fee_lo","fee_hi","saving","price","paid","eff"]);const ya=9e3;function wa(e){const t=Date.parse(e?.checked_at||e?.built_at||"");return e&&Number.isFinite(t)&&Date.now()-t<2592e5?e:null}const va=new WeakMap;function ka(e){if(!1===e?.customization?.enable_offer_guide)return!1;const t=wa(e?.offer_guide);if(!t||!ma(t,Bt()))return!1;let n=va.get(t);return n||(n=Go(t),va.set(t,n)),r=n,o=Mt(k()??null),r.offers.some(e=>aa(r,e.o,o));var r,o}const Sa=e=>String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"");function ja(e,t){const n=t.variants.map(e=>({id:String(e.id),title:String(e.title||""),available:!1!==e.available,price:Number(e.price??0)/100})),r=n.filter(e=>e.available);return{pid:e,title:t.title,image:t.images?.[0]??null,variants:n,chosen:1===r.length?r[0].id:null,state:r.length?"idle":"sold"}}function Ca(e,t){const n=H.useMemo(()=>wa(e?.offer_guide),[e?.offer_guide]),r=H.useMemo(()=>n?Go(n):null,[n]),o=H.useMemo(()=>n?ma(n,Bt()):null,[n]),[a,i]=H.useState(null),[s,c]=H.useState(!1),d=H.useRef(null),u=H.useRef(null),p=H.useRef(!1),h=H.useRef(0),f=H.useRef(t);f.current!==t&&(f.current=t,t||(h.current+=1));const g=H.useRef(null),m=H.useRef(!1),b=k()??null,x=H.useCallback(e=>{d.current=e,i(e)},[]),y=H.useCallback(e=>{g.current&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const e=d.current;!e||p.current||e.open||x(null)},e)},[x]),w=H.useCallback((e,t,r={})=>{if(!o||!n)return"";const a=function(e,t,n){return(t?e.copy.offers[t]?.[n]:void 0)??e.copy.ui[n]??null}(o,e,t),i=e?n.offers.find(t=>t.id===e)??null:null;return a?function(e,t,n,r,o){const a={...t};return o&&null==a.off&&(a.off=ga(o)),o?.countries?.length&&null==a.country&&(a.country=function(e,t){try{const n=new Intl.DisplayNames([t],{type:"region"}).of(e)||e;return"en"===t&&ba.has(e)?`the ${n}`:n}catch{return e}}(o.countries[0],r)),e.replace(/\{([a-z_]+)\}/g,(e,t)=>{const r=a[t];return null==r?e:"number"!=typeof r||!xa.has(t)&&"off"!==t?String(r):Qe(r,n.currency)})}(a,r,n,o.lang,i):""},[o,n]),v=H.useCallback((e,t,n,o,a=()=>!0)=>{if(!r)return null;const i=e.variants.map(i=>({...i,available:i.available&&pa(r,n,t,e.pid,i.id,i.price,o)&&a(i)})),s=i.filter(e=>e.available);if(!s.length)return null;const l=1===s.length?s[0].id:s.some(t=>t.id===e.chosen)?e.chosen:null;return{...e,variants:i,chosen:l}},[r]),S=H.useCallback(async()=>{const e=h.current;if(!r||!o||!t||p.current||_t()||Ft())return;const n=d.current;if(n&&(n.open||n.result))return;const a=await Lt(),i=Mt(b);if(!a||a.unknown||a.currency!==r.pack.currency||!na(r,a.lines,a.total,i))return void(n&&x(null));if(u.current=a,n&&n.cart===Dt(a.lines))return;const s=await async function(){const e=window.ShopifyAnalytics?.meta?.product;if(!e?.id||!Array.isArray(e.variants)||!e.variants.length)return null;const t=new URLSearchParams(window.location.search).get("variant"),n=e.variants.find(e=>String(e.id)===t)??(1===e.variants.length?e.variants[0]:null),r=n?Number(n.price)/100:Math.min(...e.variants.map(e=>Number(e.price)/100));return{pid:String(e.id),vid:n?String(n.id):"",price:r}}(),c=function(e,t,n,r){const o=ea(e,t,r);if(o.stacked)return{quiet:"two discounts combine here"};const a=Xo(t);if(n&&!t.some(e=>e.pid===n.pid)){const a=ra(t,n.pid,n.price,n.vid),i=ea(e,a,r),{block:s,shipLost:l}=ca(0,o,i),c=i.applied.filter(t=>aa(e,t.off.o,r)&&(!o.ids.has(t.off.o.id)||t.value>(o.st.get(t.off.o.id)?.value??0)+.001));if(c.length&&!s&&!i.stacked){const i=c[0],s=i.off.o,d={offer:s.id,cta:"add_this",picks:[n.pid],shipNote:!!l};if("ship"===s.kind)return{...d,key:t.length?"page_add":"page_alone",vars:{}};if("basic"===s.kind){const e=ua(o,s);return e?{...d,key:"page_move",vars:{from:ga(e)}}:{...d,key:"page_add",vars:{}}}if(s.same){const n=ta(e,a,r)-ta(e,t,r);return{...d,key:"page_add",vars:{n:i.el?.length??0},costsNothing:Math.abs(n)<.005}}return{...d,key:Qo(i.off.gets,n)?"page_get":"page_buy",vars:{}}}}for(const i of e.offers){const n=i.o,a=o.st.get(n.id);if("bxgy"!==n.kind||!a.earned||!aa(e,n,r))continue;const s=ha(e,i,t,r);if(!s.length)continue;const l=s[0],c=ea(e,ra(t,l,ia(e,l)),r);if(!c.ids.has(n.id)||c.stacked)continue;const{block:d,shipLost:u}=ca(0,o,c);if(d)continue;if(n.same){const t=Math.min(ia(e,l),...(a.el??[]).map(e=>e.price));if($o(n,t)<.2*ia(e,l))continue;return{offer:n.id,key:"earned",vars:{},cta:"see_picks",picks:s,shipNote:!!u}}const p=!!i.gets&&1===i.gets.p.size;return{offer:n.id,key:"earned",vars:{},cta:p?"add_it":"see_picks",picks:s,shipNote:!!u}}for(const i of e.offers){const n=i.o,a=o.st.get(n.id);if("bxgy"!==n.kind||n.same||!a.hasGet||a.hasBuy||r.infoSeen.has(`lost-${n.id}`)||!aa(e,n,r))continue;const s=t.find(e=>Qo(i.gets,e));if(s)return{offer:n.id,key:"lost",vars:{price:s.price},cta:"info",picks:[],shipNote:!1,once:`lost-${n.id}`}}for(const i of e.offers){const n=i.o,s=o.st.get(n.id);if(!aa(e,n,r)||s.applies||!t.length)continue;const l="ship"===n.kind?s.gap??0:"basic"===n.kind&&!n.scope&&n.min_amount?s.gapAmount??0:0;if(l>0){if(l>.5*a)continue;const s=ha(e,i,t,r);if(!s.length)continue;const c=s[0];if("basic"===n.kind&&oa(e,t,c,ia(e,c),r)>.8*ia(e,c))continue;const d=ea(e,ra(t,c,ia(e,c)),r),{block:u,shipLost:p}=ca(0,o,d);if(u||d.stacked)continue;const h={offer:n.id,cta:"see_picks",picks:s,shipNote:!!p};if("ship"===n.kind)return null!=n.fee?{...h,key:"gap_fee",vars:{gap:l,fee:n.fee}}:n.fee_range?{...h,key:"gap_fee",vars:{gap:l,fee_lo:n.fee_range[0],fee_hi:n.fee_range[1]}}:{...h,key:"gap",vars:{gap:l}};const f=ua(o,n);return f?{...h,key:"gap_move",vars:{gap:l,from:ga(f)}}:{...h,key:"gap",vars:{gap:l}}}if("basic"===n.kind&&n.min_qty&&1===s.gapQty){const a=ha(e,i,t,r);if(!a.length)continue;const s=ea(e,ra(t,a[0],ia(e,a[0])),r),{block:l,shipLost:c}=ca(0,o,s);if(!s.ids.has(n.id)||l||s.stacked)continue;const d=n.scope?null:ua(o,n);return{offer:n.id,key:d?"one_more_move":"one_more",vars:d?{from:ga(d)}:{},cta:"see_picks",picks:a,shipNote:!!c}}}if(n)for(const i of e.offers){const t=i.o,a=o.st.get(t.id);if(!r.infoSeen.has(t.id)&&!o.ids.has(t.id)&&aa(e,t,r)){if("basic"===t.kind){if(!t.scope||!t.min_qty||!Qo(i.scope,n))continue}else{if("bxgy"!==t.kind)continue;if(!Qo(i.buys,n)||(t.same?(a.el?.length??0)>0:a.hasBuy))continue}return{offer:t.id,key:"info",vars:{},cta:"info",picks:[],shipNote:!1,once:t.id}}}return{quiet:"nothing true and worth saying here"}}(r,a.lines,s,i);if("quiet"in c)return void(n&&x(null));if("info"===c.cta&&m.current)return;const g=`${c.offer}|${c.key}|${Dt(a.lines)}|${s?.pid??""}`;if(n?.sig===g||Pt(g))return;const k=r.pack.offers.find(e=>e.id===c.offer)??null,S={sig:g,cart:Dt(a.lines),decision:c,offer:k,line:w(c.offer,c.key,c.vars)+(c.costsNothing?` ${w(null,"costs_nothing")}`:""),note:c.shipNote?w(null,"ship_note"):null,head:"see_picks"===c.cta&&w(c.offer,"picks_head")||null,open:!1,rows:null,result:null,used:!1};if(S.line){if("add_this"===c.cta||"add_it"===c.cta){const e=c.picks[0],t=r.pack.products[e]?.h??("add_this"===c.cta?window.location.pathname.match(/\/products\/([^/?#]+)/)?.[1]:null),n=t?await vt(decodeURIComponent(t)).catch(()=>null):null;if(!n)return;const o=ja(e,n),l=t=>!c.costsNothing||Math.abs(oa(r,a.lines,e,t.price,i,t.id))<.005,d="sold"===o.state?null:v(o,c.offer,a.lines,i,l);if(!d)return;if("add_this"===c.cta&&s?.vid&&d.variants.some(e=>e.id===s.vid&&e.available)&&(d.chosen=s.vid),"add_it"===c.cta&&!d.chosen){const e=a.lines.find(e=>e.vt&&d.variants.some(t=>t.available&&Sa(t.title)===Sa(e.vt))),t=e&&d.variants.find(t=>t.available&&Sa(t.title)===Sa(e.vt));t&&(d.chosen=t.id,S.line=w(c.offer,"earned_size",c.vars)||S.line)}S.rows=[d]}e===h.current&&f.current&&(Ht(g),m.current=!0,c.once&&qt(c.once),Ot(S.line,a),x(S),y(15e3),l("offer_guide_shown",{offer:c.offer,key:c.key,cta:c.cta,kind:k?.kind,lang:o.lang}))}},[r,o,t,b,w,x,y,v]),j=H.useCallback(async()=>{try{await S()}finally{c(!0)}},[S]);H.useEffect(()=>{if(!r||!o||!t)return;let e=null;const n=window.setTimeout(()=>{j()},1500),a=()=>{e&&window.clearTimeout(e),e=window.setTimeout(()=>{j()},800)};return window.addEventListener(Yt,a),()=>{window.clearTimeout(n),e&&window.clearTimeout(e),window.removeEventListener(Yt,a)}},[r,o,t,j]),H.useEffect(()=>()=>{h.current+=1,g.current&&window.clearTimeout(g.current)},[]);const C=H.useCallback(e=>{const t=d.current;t&&x(e(t))},[x]),z=H.useCallback(async()=>{const e=d.current;if(!e||!r)return;if(e.open)return;if(g.current&&window.clearTimeout(g.current),Nt(),l("offer_guide_unfolded",{offer:e.decision.offer,key:e.decision.key}),e.rows)return void C(e=>({...e,open:!0}));C(e=>({...e,open:!0}));const t=Mt(b),n=(await Promise.all(e.decision.picks.map(async n=>{const o=r.pack.products[n]?.h,a=o?await vt(o).catch(()=>null):null;if(!a)return null;const i=ja(n,a);return"sold"===i.state&&Ut(n),"sold"===i.state||t.sold.has(n)?null:v(i,e.decision.offer,u.current?.lines??[],t)}))).filter(e=>!!e);C(t=>t.sig===e.sig?{...t,rows:n}:t)},[r,b,C,v]),A=H.useCallback(()=>{const e=d.current;e?.open&&(C(e=>({...e,open:!1})),e.used&&y(ya))},[C,y]),E=H.useCallback(e=>{const t=e.variants.find(t=>t.id===e.chosen)??e.variants.filter(e=>e.available).sort((e,t)=>e.price-t.price)[0],o=t?.price??0,a=u.current?.lines??[];if(!r||!n||"added"===e.state)return{price:o,pay:null,note:null};const i=Mt(b),s=ea(r,a.concat([{pid:e.pid,vid:t?.id??"",qty:1,price:o}]),i).applied.find(t=>"bxgy"===t.off.o.kind&&t.disc.some(t=>t.pid===e.pid)),l=oa(r,a,e.pid,o,i,t?.id??""),c=[];let d=null;s&&Math.abs(l-o)>.005?d=Math.max(0,l):Math.abs(l-o)>.005&&c.push(w(null,"adds_to_total",{eff:l}));const p=fa(r,a,e.pid,o,i);return p&&c.push(w(p.id,"reaches")),function(e,t,n,r,o,a){return!!ca(0,ea(e,t,a),ea(e,ra(t,n,o,r),a)).shipLost}(r,a,e.pid,t?.id??"",o,i)&&c.push(w(null,"ship_note")),{price:o,pay:d,note:c.filter(Boolean).join(" · ")||null}},[r,n,b,w]),T=H.useCallback((e,t)=>{C(n=>({...n,rows:n.rows?.map(n=>n.pid===e?{...n,chosen:t}:n)??null}))},[C]),R=H.useCallback(async e=>{const t=d.current,o=t?.rows?.find(t=>t.pid===e);if(!t||!o||!o.chosen||!r||p.current)return;const a=o.variants.find(e=>e.id===o.chosen);if(!a)return;p.current=!0,g.current&&window.clearTimeout(g.current),C(t=>({...t,rows:t.rows?.map(t=>t.pid===e?{...t,state:"adding"}:t)??null}));const i=Mt(b),s=await Lt();if(!wa(n)||!s||s.unknown||s.currency!==r.pack.currency||Dt(s.lines)!==t.cart||!na(r,s.lines,s.total,i)||!pa(r,s.lines,t.decision.offer,e,a.id,a.price,i))return p.current=!1,x(null),void j();const c=await Vt(a.id,t.decision.offer),h="success"===c.type||"out_of_stock"===c.reason?s:await Lt(),f="success"===c.type||!!h&&Kt(h,a.id)>Kt(s,a.id);let m,v=!1,k="idle",S=null;if(f){k="added";const n=await Lt();u.current=n;const c=!!n&&!n.unknown&&n.currency===s.currency;if(S=c&&"bxgy"===t.offer?.kind?Zo(n.total-s.total):null,c&&na(r,n.lines,n.total,i)){const o=function(e,t,n,r,o,a,i,s){const l=e.offers.find(e=>e.o.id===t)??null,c=l?.o??null,d=s??ta(e,r,i)-ta(e,n,i),u=ea(e,r,i),p=ea(e,n,i).applied.find(e=>"ship"===e.off.o.kind),h=p?u.st.get(p.off.o.id):void 0,f=!(!p||!h||h.applies||!h.offBy||p.off.o.free_anyway),g=(e,t={},n=!1)=>({key:e,from:"ui",vars:t,ok:n,shipNote:f});if(!c)return d<a-.005?g("added_cost",{eff:d}):g("added");if("ship"===c.kind){const t=u.st.get(c.id);return aa(e,c,i)?t.applies?{key:"added_reached",from:"offer",vars:{},ok:!0,shipNote:f}:{key:"added_gap",from:"offer",vars:{gap:t.gap??0},ok:!0,shipNote:f}:g("added")}const m=u.applied.find(e=>e.off.o.id===c.id);if(d<a-.005){if(!m)return g("added_cost",{eff:d});if("basic"===c.kind)return{key:"added",from:"offer",vars:{saving:Zo(m.value)},ok:!0,shipNote:f};if(c.same){const t=m.disc[0];return t?{key:"added",from:"offer",vars:{title:e.pack.products[t.pid]?.t??"",price:t.price},ok:!0,shipNote:f}:g("added_cost",{eff:d},!0)}return"bxgy"!==c.kind||m.disc.some(e=>e.pid===o)?{key:"added",from:"offer",vars:{paid:Zo(d),price:a},ok:!0,shipNote:f}:g("added_cost",{eff:d},!0)}if(Math.abs(d-a)<.005){if("bxgy"===c.kind&&!c.same){const t=m?.disc.find(e=>e.pid!==o),n=t?e.pack.products[t.pid]?.t:null;if(n)return{key:"added_full_went",from:"offer",vars:{title:n},ok:!1,shipNote:f}}return g("added_full")}return g("added_cost",{eff:d})}(r,t.decision.offer,s.lines,n.lines,e,a.price,i,S);m=w("offer"===o.from?t.decision.offer:null,o.key,o.vars)+(o.shipNote?` ${w(null,"ship_note")}`:""),v=o.ok}else m=w(null,"added");const d=t.offer;d&&"ship"!==d.kind&&c&&n.total-s.total>=a.price-.005&&!ea(r,n.lines,i).ids.has(d.id)&&Qt(d.id),Zt(o.title),l("offer_guide_add",{offer:t.decision.offer,ok:!0,promised:v,kind:d?.kind})}else"out_of_stock"===c.reason?(Ut(e),k="sold",m=w(null,"sold_out_now")):h?m=w(null,"add_failed"):(k="unsure",m=w(null,"unsure")),l("offer_guide_add",{offer:t.decision.offer,ok:!1,reason:h?c.reason:"unread"});Gt(m),p.current=!1,C(t=>({...t,used:!0,rows:t.rows?.map(t=>t.pid===e?{...t,state:k,paid:S}:t)??null,result:{text:m,ok:v,undoVid:"added"===k?a.id:null}})),y(ya)},[r,b,w,C,y,x,j]),W=H.useCallback(async()=>{const e=d.current,t=e?.result?.undoVid;if(!e||!t||p.current)return;p.current=!0,g.current&&window.clearTimeout(g.current);const n=await Xt(t,e.decision.offer),r="done"===n;p.current=!1,l("offer_guide_undo",{offer:e.decision.offer,ok:r});const o=e.rows?.find(e=>e.variants.some(e=>e.id===t));r&&o&&Jt(o.title),C(e=>({...e,rows:r?e.rows?.map(e=>e.variants.some(e=>e.id===t)?{...e,state:"idle",paid:null}:e)??null:e.rows,result:{text:w(null,r?"removed":"failed"===n?"undo_failed":"unsure"),ok:!1,undoVid:"failed"===n?t:null}})),u.current=await Lt(),y(ya)},[w,C,y]),I=H.useCallback(()=>{const e=d.current;h.current+=1,$t(),Vo(),en(),tn(),x(null),l("offer_guide_closed",{offer:e?.decision.offer,used:!!e?.used})},[x]),B=H.useCallback(e=>Qe(e,n?.currency),[n?.currency]);return{view:a,looked:s,unfold:z,fold:A,choose:T,add:R,undo:W,close:I,rowFacts:E,say:w,money:B}}const za=H.forwardRef(function({hookText:e,cta:t,maxW:n,onStart:r,onDismiss:o},a){return K.jsx(Mo,{maxW:n,icon:K.jsx(He,{boxSize:"16px"}),closeLabel:"Close",onClose:o,action:K.jsxs(ae,{ref:a,...Bo,gap:"4px",onClick:r,children:[t,K.jsx(Ke,{boxSize:"12px"})]}),children:K.jsx(ne,{as:"button",onClick:r,w:"full",textAlign:"start",cursor:"pointer",tabIndex:-1,children:K.jsx(se,{fontSize:"13px",fontWeight:600,color:"text",lineHeight:"1.3",lineClamp:2,fontFamily:xn,children:e})})})});function Aa(e,t,n,r){const o=e%10,a=e%100;return 1===o&&11!==a?t:o>=2&&o<=4&&(a<12||a>14)?n:r}const Ea={English:{subtitle:e=>`Answer ${e} quick question${e>1?"s":""} for personalized recommendations`,cta:"Start",skip:"Or open chat instead"},Czech:{subtitle:e=>`Odpovězte na ${e} ${1===e?"otázku":"otázky"} pro personalizovaná doporučení`,cta:"Začít",skip:"Nebo otevřít chat"},German:{subtitle:e=>`Beantworten Sie ${e} kurze Frage${e>1?"n":""} für persönliche Empfehlungen`,cta:"Starten",skip:"Oder Chat öffnen"},Hungarian:{subtitle:e=>`Válaszolj ${e} gyors kérdésre személyre szabott ajánlásokért`,cta:"Indítás",skip:"Vagy nyisd meg a chatet"},Persian:{subtitle:e=>`به ${e} سوال کوتاه پاسخ بدید تا پیشنهادات شخصی دریافت کنید`,cta:"شروع",skip:"یا چت را باز کنید"},French:{subtitle:e=>`Répondez à ${e} question${e>1?"s":""} rapide${e>1?"s":""} pour des recommandations personnalisées`,cta:"Commencer",skip:"Ou ouvrir le chat"},Spanish:{subtitle:e=>`Responde ${e} pregunta${e>1?"s":""} rápida${e>1?"s":""} para recomendaciones personalizadas`,cta:"Empezar",skip:"O abrir el chat"},Arabic:{subtitle:e=>`أجب عن ${e} ${1===e?"سؤال سريع":"أسئلة سريعة"} للحصول على توصيات مخصصة`,cta:"ابدأ",skip:"أو افتح المحادثة"},Turkish:{subtitle:e=>`Kişiselleştirilmiş öneriler için ${e} hızlı soruyu yanıtlayın`,cta:"Başla",skip:"Veya sohbeti aç"},Portuguese:{subtitle:e=>`Responda ${e} pergunta${e>1?"s":""} rápida${e>1?"s":""} para recomendações personalizadas`,cta:"Começar",skip:"Ou abrir o chat"},Italian:{subtitle:e=>`Rispondi a ${e} ${1===e?"domanda veloce":"domande veloci"} per raccomandazioni personalizzate`,cta:"Inizia",skip:"Oppure apri la chat"},Japanese:{subtitle:e=>`${e}つの質問に答えるだけで、あなたにぴったりのおすすめをご提案します`,cta:"はじめる",skip:"チャットで相談する"},Chinese:{subtitle:e=>`回答${e}个简单问题,获取专属推荐`,cta:"开始",skip:"或直接打开聊天"},Korean:{subtitle:e=>`${e}개의 간단한 질문에 답하고 맞춤 추천을 받아보세요`,cta:"시작하기",skip:"또는 채팅 열기"},Russian:{subtitle:e=>`Ответьте на ${e} ${Aa(e,"короткий вопрос","коротких вопроса","коротких вопросов")}, чтобы получить персональные рекомендации`,cta:"Начать",skip:"Или открыть чат"},Ukrainian:{subtitle:e=>`Дайте відповідь на ${e} ${Aa(e,"коротке запитання","короткі запитання","коротких запитань")}, щоб отримати персональні рекомендації`,cta:"Почати",skip:"Або відкрити чат"},Polish:{subtitle:e=>`Odpowiedz na ${e} ${function(e){if(1===e)return"krótkie pytanie";const t=e%10,n=e%100;return t>=2&&t<=4&&(n<12||n>14)?"krótkie pytania":"krótkich pytań"}(e)}, aby otrzymać spersonalizowane rekomendacje`,cta:"Zacznij",skip:"Lub otwórz czat"},Slovak:{subtitle:e=>`Odpovedzte na ${e} ${1===e?"krátku otázku":e<5?"krátke otázky":"krátkych otázok"} a získajte odporúčania na mieru`,cta:"Začať",skip:"Alebo otvoriť chat"},Bulgarian:{subtitle:e=>`Отговорете на ${e} ${1===e?"кратък въпрос":"кратки въпроса"} за персонални препоръки`,cta:"Започни",skip:"Или отвори чата"},Croatian:{subtitle:e=>`Odgovorite na ${e} ${Aa(e,"kratko pitanje","kratka pitanja","kratkih pitanja")} za osobne preporuke`,cta:"Započni",skip:"Ili otvori chat"},Dutch:{subtitle:e=>`Beantwoord ${e} korte ${1===e?"vraag":"vragen"} voor persoonlijke aanbevelingen`,cta:"Starten",skip:"Of open de chat"},Swedish:{subtitle:e=>`Svara på ${e} ${1===e?"snabb fråga":"snabba frågor"} för personliga rekommendationer`,cta:"Börja",skip:"Eller öppna chatten"},Norwegian:{subtitle:e=>`Svar på ${e} ${1===e?"raskt spørsmål":"raske spørsmål"} for personlige anbefalinger`,cta:"Start",skip:"Eller åpne chatten"},Danish:{subtitle:e=>`Svar på ${e} ${1===e?"hurtigt spørgsmål":"hurtige spørgsmål"} for personlige anbefalinger`,cta:"Start",skip:"Eller åbn chatten"},Finnish:{subtitle:e=>`Vastaa ${e} lyhyeen kysymykseen ja saat henkilökohtaisia suosituksia`,cta:"Aloita",skip:"Tai avaa chat"},Estonian:{subtitle:e=>`Vasta ${e} lühikesele küsimusele ja saa isikupärastatud soovitusi`,cta:"Alusta",skip:"Või ava vestlus"},Latvian:{subtitle:e=>`Atbildiet uz ${e} ${e%10==1&&e%100!=11?"īsu jautājumu":"īsiem jautājumiem"} un saņemiet personalizētus ieteikumus`,cta:"Sākt",skip:"Vai atvērt tērzēšanu"},Lithuanian:{subtitle:e=>`Atsakykite į ${e} ${e%10==1&&e%100!=11?"trumpą klausimą":e%10>=2&&(e%100<10||e%100>=20)?"trumpus klausimus":"trumpų klausimų"} ir gaukite asmeninių rekomendacijų`,cta:"Pradėti",skip:"Arba atidarykite pokalbį"},Greek:{subtitle:e=>`Απαντήστε σε ${e} ${1===e?"σύντομη ερώτηση":"σύντομες ερωτήσεις"} για εξατομικευμένες προτάσεις`,cta:"Έναρξη",skip:"Ή ανοίξτε τη συνομιλία"},Romanian:{subtitle:e=>`Răspunde la ${e} ${1===e?"întrebare scurtă":"întrebări scurte"} pentru recomandări personalizate`,cta:"Începe",skip:"Sau deschide chatul"},Albanian:{subtitle:e=>`Përgjigjuni ${e} ${1===e?"pyetjeje të shkurtër":"pyetjeve të shkurtra"} për rekomandime të personalizuara`,cta:"Fillo",skip:"Ose hap bisedën"},Hebrew:{subtitle:e=>1===e?"ענו על שאלה קצרה אחת לקבלת המלצות מותאמות אישית":`ענו על ${e} שאלות קצרות לקבלת המלצות מותאמות אישית`,cta:"התחלה",skip:"או פתחו את הצ׳אט"},Urdu:{subtitle:e=>`ذاتی سفارشات کے لیے ${e} مختصر ${1===e?"سوال":"سوالات"} کے جواب دیں`,cta:"شروع کریں",skip:"یا چیٹ کھولیں"},Hindi:{subtitle:e=>`व्यक्तिगत सुझावों के लिए ${e} ${1===e?"छोटे सवाल":"छोटे सवालों"} का जवाब दें`,cta:"शुरू करें",skip:"या चैट खोलें"},Bengali:{subtitle:e=>`ব্যক্তিগত সুপারিশ পেতে ${e}টি ছোট প্রশ্নের উত্তর দিন`,cta:"শুরু করুন",skip:"অথবা চ্যাট খুলুন"},Tamil:{subtitle:e=>`தனிப்பட்ட பரிந்துரைகளுக்கு ${e} சிறிய ${1===e?"கேள்விக்கு":"கேள்விகளுக்கு"} பதிலளிக்கவும்`,cta:"தொடங்கு",skip:"அல்லது அரட்டையைத் திற"},Telugu:{subtitle:e=>`వ్యక్తిగత సిఫార్సుల కోసం ${e} చిన్న ${1===e?"ప్రశ్నకు":"ప్రశ్నలకు"} సమాధానం ఇవ్వండి`,cta:"ప్రారంభించండి",skip:"లేదా చాట్ తెరవండి"},Thai:{subtitle:e=>`ตอบคำถามสั้นๆ ${e} ข้อ เพื่อรับคำแนะนำเฉพาะคุณ`,cta:"เริ่มเลย",skip:"หรือเปิดแชท"},Vietnamese:{subtitle:e=>`Trả lời ${e} câu hỏi ngắn để nhận gợi ý dành riêng cho bạn`,cta:"Bắt đầu",skip:"Hoặc mở trò chuyện"},Indonesian:{subtitle:e=>`Jawab ${e} pertanyaan singkat untuk rekomendasi yang dipersonalisasi`,cta:"Mulai",skip:"Atau buka obrolan"},Malay:{subtitle:e=>`Jawab ${e} soalan ringkas untuk cadangan yang diperibadikan`,cta:"Mula",skip:"Atau buka sembang"},Swahili:{subtitle:e=>`Jibu ${1===e?"swali 1 fupi":`maswali ${e} mafupi`} upate mapendekezo yanayokufaa`,cta:"Anza",skip:"Au fungua gumzo"},Filipino:{subtitle:e=>`Sagutin ang ${e} maikling tanong para sa mga personal na rekomendasyon`,cta:"Simulan",skip:"O buksan ang chat"},Iraqi:{subtitle:e=>`جاوب على ${e} ${1===e?"سؤال سريع":"أسئلة سريعة"} حتى تحصل على اقتراحات تناسبك`,cta:"ابدأ",skip:"أو افتح المحادثة"},Amharic:{subtitle:e=>`ለግል ምክሮች ${e} አጭር ጥያቄ${1===e?"":"ዎች"}ን ይመልሱ`,cta:"ጀምር",skip:"ወይም ውይይቱን ይክፈቱ"},Burmese:{subtitle:e=>`သင့်အတွက် အကြံပြုချက်များ ရရန် မေးခွန်းတို ${e} ခုကို ဖြေဆိုပါ`,cta:"စတင်ရန်",skip:"သို့မဟုတ် ချက်တင်ကို ဖွင့်ပါ"},Gujarati:{subtitle:e=>`વ્યક્તિગત ભલામણો માટે ${e} ટૂંકા ${1===e?"પ્રશ્નનો":"પ્રશ્નોના"} જવાબ આપો`,cta:"શરૂ કરો",skip:"અથવા ચેટ ખોલો"},Hausa:{subtitle:e=>`Amsa ${1===e?"tambaya 1 gajera":`tambayoyi ${e} gajeru`} don samun shawarwari na musamman`,cta:"Fara",skip:"Ko buɗe hira"},Igbo:{subtitle:e=>`Zaa ajụjụ ${e} dị mkpụmkpụ maka ndụmọdụ ahaziri gị`,cta:"Malite",skip:"Ma ọ bụ mepee nkata"},Kannada:{subtitle:e=>`ವೈಯಕ್ತಿಕ ಶಿಫಾರಸುಗಳಿಗಾಗಿ ${e} ಚಿಕ್ಕ ${1===e?"ಪ್ರಶ್ನೆಗೆ":"ಪ್ರಶ್ನೆಗಳಿಗೆ"} ಉತ್ತರಿಸಿ`,cta:"ಪ್ರಾರಂಭಿಸಿ",skip:"ಅಥವಾ ಚಾಟ್ ತೆರೆಯಿರಿ"},Khmer:{subtitle:e=>`ឆ្លើយសំណួរខ្លីៗ ${e} ដើម្បីទទួលបានការណែនាំសម្រាប់អ្នក`,cta:"ចាប់ផ្តើម",skip:"ឬបើកការជជែក"},Lao:{subtitle:e=>`ຕອບຄຳຖາມສັ້ນໆ ${e} ຂໍ້ ເພື່ອຮັບຄຳແນະນຳສະເພາະທ່ານ`,cta:"ເລີ່ມ",skip:"ຫຼື ເປີດແຊັດ"},Malayalam:{subtitle:e=>`വ്യക്തിഗത ശുപാർശകൾക്കായി ${e} ചെറിയ ${1===e?"ചോദ്യത്തിന്":"ചോദ്യങ്ങൾക്ക്"} ഉത്തരം നൽകുക`,cta:"തുടങ്ങുക",skip:"അല്ലെങ്കിൽ ചാറ്റ് തുറക്കുക"},Marathi:{subtitle:e=>`वैयक्तिक शिफारशींसाठी ${e} ${1===e?"छोट्या प्रश्नाचे":"छोट्या प्रश्नांची"} उत्तरे द्या`,cta:"सुरू करा",skip:"किंवा चॅट उघडा"},Mongolian:{subtitle:e=>`Танд тохирсон зөвлөмж авахын тулд ${e} богино асуултад хариулна уу`,cta:"Эхлэх",skip:"Эсвэл чат нээх"},Nepali:{subtitle:e=>`व्यक्तिगत सुझावका लागि ${e} वटा छोटा प्रश्नको जवाफ दिनुहोस्`,cta:"सुरु गर्नुहोस्",skip:"वा च्याट खोल्नुहोस्"},Pashto:{subtitle:e=>`د شخصي وړاندیزونو لپاره ${e} لنډو ${1===e?"پوښتنې":"پوښتنو"} ته ځواب ورکړئ`,cta:"پیل",skip:"یا چیټ پرانیزئ"},Punjabi:{subtitle:e=>`ਨਿੱਜੀ ਸਿਫ਼ਾਰਸ਼ਾਂ ਲਈ ${e} ਛੋਟੇ ${1===e?"ਸਵਾਲ":"ਸਵਾਲਾਂ"} ਦੇ ਜਵਾਬ ਦਿਓ`,cta:"ਸ਼ੁਰੂ ਕਰੋ",skip:"ਜਾਂ ਚੈਟ ਖੋਲ੍ਹੋ"},Sinhala:{subtitle:e=>`ඔබට ගැළපෙන නිර්දේශ ලබා ගැනීමට කෙටි ප්‍රශ්න ${e}කට පිළිතුරු දෙන්න`,cta:"අරඹන්න",skip:"නැතහොත් කතාබහ විවෘත කරන්න"},Somali:{subtitle:e=>`Ka jawaab ${e} ${1===e?"su'aal gaaban":"su'aalood oo gaagaaban"} si aad u hesho talooyin kuu gaar ah`,cta:"Bilow",skip:"Ama fur wada-sheekaysiga"},Yoruba:{subtitle:e=>`Dáhùn ìbéèrè kúkúrú ${e} láti gba àbá tó bá ọ mu`,cta:"Bẹ̀rẹ̀",skip:"Tàbí ṣí ìjíròrò"},Zulu:{subtitle:e=>`Phendula ${1===e?"umbuzo omfushane o-1":`imibuzo emifushane engu-${e}`} ukuze uthole iziphakamiso ezenzelwe wena`,cta:"Qala",skip:"Noma vula ingxoxo"},Afrikaans:{subtitle:e=>`Beantwoord ${e} kort ${1===e?"vraag":"vrae"} vir persoonlike aanbevelings`,cta:"Begin",skip:"Of maak die klets oop"}},Ta={subtitle:e=>`Beantworte ${e} kurze Frage${e>1?"n":""} für persönliche Empfehlungen`,cta:"Starten",skip:"Oder Chat öffnen"};function Ra(e,t=!1){const n=nn(e),r=Object.keys(Ea).find(e=>e.toLowerCase()===n.toLowerCase()),o=Ea[e]||Ea[n]||(r?Ea[r]:void 0)||Ea.English;return t&&o===Ea.German?Ta:o}let Wa=!1;const Ia=({quiz:e,isMobile:t,layer:n,pillMaxW:r,panelW:o,panelMaxH:a})=>{const{phase:i,open:s,flow:l,text:c,handleStart:d,handleDismiss:u,handleCollapse:p,handleComplete:h,handleSkipToChat:f}=e,g=H.useRef(null);if("hidden"===i||!l)return null;const m={isMobile:t,layer:n,w:o,maxH:a,onCollapse:p,onClosed:()=>g.current?.focus()};return K.jsxs(K.Fragment,{children:[!s&&K.jsx(za,{ref:g,hookText:l.welcome_hook,cta:c.cta,maxW:r,onStart:d,onDismiss:u}),"expanded"===i&&K.jsxs(Po,{...m,open:s,label:l.entry_label,children:[K.jsx(Mr,{flow:l,onComplete:h,onClose:u}),K.jsx(ne,{as:"button",onClick:f,display:"block",mx:"auto",mt:1,fontSize:"12px",color:"mutedText",textDecoration:"underline",fontFamily:xn,cursor:"pointer",children:c.skip})]})]})};function Ba(e){const t={};for(const[n,r]of Object.entries(e))t["left"===n?"right":"right"===n?"left":n]=r;return t}const Ma=e=>"left"===e?"right":"left",_a=[".shopify-section-group-header-group","#shopify-section-header",".shopify-section-header","sticky-header","header-component","header"],Fa="#dori-react-widget-host";function La(e){const t=e.getBoundingClientRect();return{top:t.top,bottom:t.bottom,height:t.height}}const Da={own:3e3,hook:6400};function Pa(e){const t=e.codePointAt(0)??0;return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=12352&&t<=12543?4:t>=44032&&t<=55215?3:t>=1536&&t<=1791||t>=1872&&t<=1919?1.6:1}function Ha(e){const t=e?.feature_flags?.bubble_seconds;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:null}function qa(e){const t=e?.feature_flags?.bubble_stay;return"until_closed"===t?"until_closed":"seconds"===t&&null!==Ha(e)?"seconds":"read"}function Oa(e,t,n,r=Da.own){const o=qa(e);if("until_closed"===o)return null;if("seconds"===o)return 1e3*Math.min(20,Math.max(3,Ha(e)));const a="own"===n?r:Da[n];return Math.min(1e4,Math.max(a,function(e){let t=0;for(const n of e)t+=Pa(n);return Math.round(1e3+55*t)}(t)))}const Ya=["homepage","category","product","search","cart","other"],Na={home:"homepage",collection:"category",product:"product",searchresults:"search",search:"search",cart:"cart"};function Ua(){if("undefined"==typeof window)return"other";try{const e=window.ShopifyAnalytics?.meta?.page?.pageType;if("string"==typeof e&&e)return Na[e.toLowerCase()]??"other"}catch{}return rn()}function Va(e){return!(!function(e,t=Ua()){const n=function(e){const t=e?.customization?.quiz_pages;if(!Array.isArray(t))return null;const n=Ya.filter(e=>t.includes(e));return n.length?n:null}(e);return null===n||n.includes(t)}(e)||"product"===Ua()&&ka(e))}const Ka=({onClick:e,suppressBubble:t=!1,slot:n})=>{const{botData:r,diagnosticFlow:o,diagnosticShown:a,proactiveSuppressedThisSession:i,suppressProactiveForSession:s,effectiveFabCta:l,handover:c,handoverUnread:d}=J(),{t:u}=ee(),p=_e("colors","primary"),h=_e("colors","background"),f=_e("colors","lightBackground"),g=Fe(p),m=Array.isArray(p)?p[0]:p,b=on(h,f),x=function(e,t){if(t)return null;const n=e?.feature_flags?.fab_pill_each_page_seconds;return"number"!=typeof n||!Number.isFinite(n)||n<=0?null:Math.min(10,Math.max(1,n))}(r,!!Gn(r)),y="until_closed"===qa(r)&&!r?.customization?.disable_welcome_popup,[w,v]=H.useState(()=>y&&!an()||!y&&!sn()&&!ln()&&S()||null!==x&&!Ft()?"expanded":"minimized"),[k,C]=H.useState(!1),[z,A]=H.useState(!1),[E,T]=H.useState(!1),[R,W]=H.useState(!1),[I,B]=H.useState(!1),M=H.useRef(null),_=()=>{M.current&&(clearTimeout(M.current),M.current=null)},F=Tr(r?.merchant_support_channels).length>0,L=()=>{_(),!U&&F&&(T(!0),W(!0))};H.useEffect(()=>()=>_(),[]);const D=!0!==r?.customization?.disable_idle_animation,{getStarfieldTransform:P,getIconStyle:q}=Zn({enableTwinkling:D,enableFloating:D,enableRotation:D,enableScaling:D}),O=H.useRef(!1),Y=H.useRef(0),N=H.useRef(null),U=jn({base:!0,md:!1})??!1,V=Jn(r,U),Q=Gn(r),Z=!!Q,G=Wo(r,U),X=(e,t)=>function(e,t,n){return{base:`${Math.round(e*n)}px`,md:`${Math.round(t*n)}px`}}(e,t,G),$=function(e,t){return t&&!0===e?.feature_flags?.fab_transparent}(r,Z),te=function(e,t){return!t&&!0===e?.feature_flags?.fab_always_expanded}(r,Z),ie=function(e){return!0===e?.feature_flags?.fab_icon_only}(r),le=l??(r?.agent_name?u("askAgent").replace("{name}",r.agent_name):u("askDori")),ce=H.useRef(null),[ue,he]=H.useState(null);H.useEffect(()=>{let e=!1;const t=()=>{const t=ce.current;!e&&t&&he(t.scrollWidth)};return t(),document.fonts?.ready?.then(t).catch(()=>{}),()=>{e=!0}},[le,U]);const fe=(()=>{if(null==ue)return{base:"120px",md:"150px"};const e=U?120:150,t=2*(U?8:12),n=Math.round((U?20:24)*G),r=U?280:360,o=t+8+n+ue+2;return`${Math.min(r,Math.max(e,o))}px`})(),ge=!0===r?.customization?.enable_standalone_quiz&&Va(r)&&o&&!a?o.welcome_hook:null,me=!ge,be=H.useRef(ln()),xe=y?an():i,ye=t||xe||!y&&me&&be.current?null:function(e,t){return t||function(e){return e?.feature_flags?.bubble_text?.trim()||null}(e)}(r,ge),we=()=>{if(y&&an())return;j();const e=++Y.current;v("expanded"),A(!1),B(!1);const t=setTimeout(()=>{if(Y.current===e&&(C(!0),!r?.customization?.disable_welcome_popup)){const t=setTimeout(()=>{if(Y.current!==e)return;A(!0);const t=Oa(r,ye??"","own",1e3*(x??3));if(null===t)return;const n=setTimeout(()=>{Y.current===e&&(A(!1),setTimeout(()=>{Y.current===e&&v("minimized")},300))},t);return()=>clearTimeout(n)},100);return()=>clearTimeout(t)}},100);return()=>clearTimeout(t)},ve=()=>{v("minimized"),A(!1);const e=setTimeout(()=>{C(!0)},0);return()=>clearTimeout(e)},ke=e=>{const t=++Y.current;v("expanded"),A(!1);const n=setTimeout(()=>C(!0),100),r=setTimeout(()=>{Y.current===t&&v("minimized")},100+1e3*e);return()=>{clearTimeout(n),clearTimeout(r)}};H.useEffect(()=>{O.current||(O.current=!0,y?an()||ge?ve():we():sn()?null===x||Ft()?ve():ke(x):!ge||r?.customization?.disable_welcome_popup?!ln()&&S()?we():null!==x?ke(x):ve():ve())},[]),H.useEffect(()=>{const e=setInterval(()=>{sn()||ln()||S()&&we()},1e3);return()=>clearInterval(e)},[]),H.useEffect(()=>{if(!ge)return;if(r?.customization?.disable_welcome_popup)return;if(y?an():sn())return;Y.current++,C(!0),N.current&&(clearTimeout(N.current),N.current=null),B(!0),v("expanded");const e=setTimeout(()=>{A(!0)},400),t=Oa(r,ge,"hook"),n=null===t?null:setTimeout(()=>{A(!1),N.current=setTimeout(()=>{v("minimized"),N.current=null},350)},t);return()=>{clearTimeout(e),n&&clearTimeout(n),N.current&&(clearTimeout(N.current),N.current=null)}},[ge]);const Se=H.useRef(null);H.useEffect(()=>{if(z&&ye&&!r?.customization?.disable_welcome_popup){if(me){if(ln())return;return cn(),void dn(!1)}Se.current!==ye&&(Se.current=ye,dn(!0))}},[z,ye]);const je=()=>{pn(),e&&(e(),"minimized"===w&&(A(!1),setTimeout(()=>{v("expanded"),setTimeout(()=>{r?.customization?.disable_welcome_popup||setTimeout(()=>{A(!0)},50)},100)},0)))},Ce=je,ze=ie||!te&&("minimized"===w||Z),Ae=function(e){const t=e.hasAvatarFab&&e.animationsEnabled&&e.isMinimized&&!e.isMenuOpen;return{breathe:t,halo:t&&!e.isTransparentFab}}({hasAvatarFab:Z,animationsEnabled:D,isMinimized:ze,isMenuOpen:E,isTransparentFab:$}),Te=$n(V,r,U),Re="right"===V.align?"32px 0px 32px 32px":"0px 32px 32px 32px";return K.jsxs(ne,{position:"relative",transform:k?Te?"translateY(0) scale(1)":`translateY(calc(-50% + ${V.bottomSpacing}px)) scale(1)`:Te?"translateY(100px) scale(0.9)":`translateY(calc(-50% + ${V.bottomSpacing}px + 100px)) scale(0.9)`,opacity:k?1:0,onMouseLeave:()=>{U||(_(),M.current=setTimeout(()=>{T(!1),W(!1)},100))},children:[K.jsx(Wr,{channels:r?.merchant_support_channels,isOpen:E,onToggle:()=>T(!E),isMobile:U,onMouseEnter:L,onChatClick:e}),K.jsx(ne,{visibility:E?"hidden":void 0,"aria-hidden":E||void 0,children:n}),"expanded"===w&&ye&&!r?.customization?.disable_welcome_popup&&K.jsx(ne,{position:"absolute",bottom:"100%",[V.align]:"0",mb:2,w:{base:"70vw",md:"25vw"},maxW:{base:"300px",md:"300px"},bg:b,borderRadius:"16px",p:2,pe:3,boxShadow:I?"0 8px 32px rgba(0,0,0,0.16), 0 0 0 1.5px rgba(120,120,200,0.13)":"lg",opacity:z?1:0,transform:z?"translateY(0) scale(1)":I?"translateY(20px) scale(0.88)":"translateY(10px) scale(0.95)",transition:z?I?"opacity 0.5s ease, transform 0.7s cubic-bezier(0.22, 1.61, 0.36, 1), box-shadow 0.4s ease":"opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1)":"opacity 0.25s ease, transform 0.25s ease",cursor:"pointer",onClick:Ce,children:K.jsxs(oe,{gap:1,align:"center",width:"100%",justifyContent:"flex-start",children:[K.jsx(de,{size:"xs",variant:"ghost","aria-label":"Close",onClick:e=>{e.stopPropagation(),s(),tn(),$t(),Vo(),A(!1),setTimeout(()=>v("minimized"),300)},color:"text",_hover:{"@media (hover: hover) and (pointer: fine)":{bg:"rgba(0,0,0,0.1)"}},h:"auto",p:1,children:K.jsx(pe,{boxSize:"16px"})}),K.jsx(se,{fontSize:"12px",fontWeight:"400",color:"text",lineHeight:"1.75",flex:1,width:"100%",fontFamily:xn,children:ye})]})}),Ae.breathe&&K.jsx("style",{children:"\n @keyframes dori-avatar-breathe {\n 0%, 100% { scale: 1; }\n 50% { scale: 1.06; }\n }\n @keyframes dori-avatar-halo {\n 0% { box-shadow: 0 0 0 0 var(--dori-halo); }\n 70%, 100% { box-shadow: 0 0 0 12px var(--dori-halo-end); }\n }\n .dori-avatar-breathe {\n animation: dori-avatar-breathe 3s ease-in-out infinite;\n }\n .dori-avatar-breathe.dori-avatar-halo {\n animation:\n dori-avatar-breathe 3s ease-in-out infinite,\n dori-avatar-halo 3s ease-out infinite;\n }\n @media (prefers-reduced-motion: reduce) {\n .dori-avatar-breathe { animation: none !important; }\n }\n "}),K.jsx(ae,{borderRadius:ze?"50%":Re,borderWidth:0,bg:$?"transparent":g,color:"text",border:"none !important",w:ze?X(48,56):fe,minW:ze?X(48,56):fe,h:ze?X(48,56):"auto",p:ze?"0":{base:2,md:3},overflow:"hidden",transition:"width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), min-width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), border-radius 0.4s ease, padding 0.3s ease, transform 0.2s ease",onClick:je,className:["fab-glass",Ae.breathe&&"dori-avatar-breathe",Ae.halo&&"dori-avatar-halo"].filter(Boolean).join(" "),_hover:{"@media (hover: hover) and (pointer: fine)":{transform:"scale(1.05)"}},style:{borderRadius:ze?"50%":Re,cursor:"pointer",touchAction:"manipulation",WebkitTapHighlightColor:"transparent",...Ae.halo?{"--dori-halo":un(m,.5),"--dori-halo-end":un(m,0)}:{}},onMouseEnter:L,justifyContent:"center",children:K.jsxs(oe,{gap:ze?0:2,position:"relative",w:"full",justify:ze?"center":"space-between",overflow:"hidden",children:[K.jsx(se,{fontSize:{base:"14px",md:"16px"},fontWeight:{base:"500",md:"600"},lineHeight:"1.5",whiteSpace:"nowrap",fontFamily:xn,color:"background",opacity:ze?0:1,maxW:ze?"0px":"none",transition:"opacity 0.2s ease, max-width 0.35s ease",overflow:"hidden",ref:ce,children:le}),!E&&(Q?K.jsx(re,{src:Q,alt:"",role:"presentation",boxSize:X(52,60),borderRadius:"full",objectFit:"cover",flexShrink:0}):K.jsx(Ee,{boxSize:X(20,24),color:"background",transform:P(w,V),...q(),flexShrink:0}))]})}),d>0&&!E&&K.jsx(ne,{position:"absolute",top:X(-6,-6),..."right"===V.align?{left:X(-6,-6)}:{right:X(-6,-6)},minW:"20px",h:"20px",px:"5px",borderRadius:"full",bg:"#E5484D",color:"white",fontSize:"12px",fontWeight:"600",fontFamily:xn,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",boxShadow:"0 0 0 2px white",role:"status","aria-label":u("handoverUnread").replace("{team}",c?.teamName||u("handoverTheTeam")),"data-dori-handover-unread":d,children:d>9?"9+":d})]})};let Qa=!1;const Za=H.forwardRef(function({bubble:e,settled:t,styles:n,onClick:r,quiz:o,sheetLayer:a},i){const{botData:s}=J(),l=jn({base:!0,md:!1})??!1,[c,d]=H.useState(!1),u=Ca(s,!1!==s?.customization?.enable_offer_guide&&t&&!c),p=ka(s),[h,f]=H.useState(!1);H.useEffect(()=>{if(!p||!t||u.looked)return;const e=window.setTimeout(()=>f(!0),5e3);return()=>window.clearTimeout(e)},[p,t,u.looked]),H.useEffect(()=>{u.view&&(Qa=!0)},[u.view]);const g=!p||u.looked||h,m=Qa||!!u.view,b=c?"quiz":u.view?"guide":o.eligible&&t&&g&&!m?"quiz":null,x=function({speaking:e,onOpenWidget:t,onStartChat:n,onDismissed:r,onEngagedChange:o}){const{diagnosticFlow:a,diagnosticShown:i,markDiagnosticShown:s,effectiveLanguage:l,informalAddress:c,suppressProactiveForSession:d}=J(),[u,p]=H.useState("hidden"),[h,f]=H.useState(!1),g=!!a&&!i&&!Uo();return H.useEffect(()=>{o("expanded"===u)},[u]),H.useEffect(()=>()=>o(!1),[]),H.useEffect(()=>{if("expanded"!==u){if("hidden"===u&&e&&g){const e=setTimeout(()=>p("teaser"),800);return()=>clearTimeout(e)}"teaser"!==u||e&&g||p("hidden")}},[u,e,g]),H.useEffect(()=>{"teaser"!==u||Wa||(Wa=!0,v()?.capture("quiz_card_impression",{presentation:"pill"}))},[u]),{phase:u,open:h,flow:a,text:Ra(l||"English",c),handleStart:()=>{"expanded"!==u&&v()?.capture("quiz_card_started",{presentation:"pill"}),p("expanded"),f(!0)},handleDismiss:()=>{Vo(),d(),$t(),tn(),v()?.capture("quiz_card_dismiss",{phase:u,presentation:"pill"}),f(!1),p("hidden"),r?.()},handleCollapse:()=>f(!1),handleComplete:(e,t)=>{s(),v()?.capture("quiz_card_completed"),f(!1),p("hidden"),n(e,void 0,t),v()?.capture("quiz_card_widget_opened")},handleSkipToChat:()=>{Vo(),s(),v()?.capture("quiz_card_skip_to_chat"),f(!1),p("hidden"),r?.(),t()}}}({speaking:"quiz"===b,onStartChat:o.onStartChat,onOpenWidget:o.onOpenWidget,onDismissed:o.onDismissed,onEngagedChange:d}),y=Jn(s,l),w=Math.round((l?48:56)*Wo(s,l)),k=$n(y,s,l),S=`calc(100vw - ${2*y.sideSpacing}px)`,j=`min(${l?340:360}px, ${S})`,C=`min(400px, ${S})`,z=e=>k?`max(240px, calc(100vh - ${er(y,s)+(e?w+8:0)+16}px))`:`max(240px, calc(50vh + ${y.bottomSpacing+(e?-w/2-8:w/2)-16}px))`,A=z(e),E=l&&function(e){return"under_header"===e?.feature_flags?.quiz_mobile_place}(s),T=function(e){const[t,n]=H.useState(8);return H.useEffect(()=>{if(!e)return;let t=0;const r=()=>{t=0,n(function(){const e=[];for(const n of _a)document.querySelectorAll(n).forEach(t=>{t.closest(Fa)||e.push(La(t))});const t=window.innerWidth;for(const n of[8,t/2,t-8])for(const t of document.elementsFromPoint(n,1))if(!t.closest(Fa))for(let n=t;n&&n!==document.body;n=n.parentElement){const t=getComputedStyle(n).position;"fixed"!==t&&"sticky"!==t||e.push(La(n))}return function(e,t){let n=0;for(const r of e)r.height<=0||r.bottom<=0||r.top>.25*t||r.bottom>.4*t||(n=Math.max(n,r.bottom));return Math.round(n)}(e,window.innerHeight)}()+8)},o=()=>{t||(t=window.requestAnimationFrame(r))};r();const a=window.setTimeout(r,1500);return window.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o),()=>{window.clearTimeout(a),t&&window.cancelAnimationFrame(t),window.removeEventListener("scroll",o),window.removeEventListener("resize",o)}},[e]),t}(E),R=!E&&"opposite"===function(e){return"opposite"===e?.customization?.quiz_position?"opposite":"launcher"}(s),W=l&&e,I=e&&!l?`calc(100vw - ${2*y.sideSpacing+w+16}px)`:S,B=R?{pillMaxW:`min(${l?340:360}px, ${I})`,panelW:`min(400px, ${I})`,panelMaxH:z(W)}:{pillMaxW:j,panelW:C,panelMaxH:A},M=("quiz"===b||c)&&K.jsx(Ia,{quiz:x,isMobile:l,layer:a,...B}),_=K.jsxs(ne,{position:"absolute",bottom:e?"100%":0,mb:e?2:0,[y.align]:0,w:"max-content","data-dori-corner-slot":"",children:[K.jsx(Yo,{api:u,isMobile:l,layer:a,pillMaxW:j,panelW:C,panelMaxH:A}),!R&&!E&&M]}),F=R&&M?K.jsx(ne,{position:"fixed",zIndex:"1000000",...Ba(n),children:K.jsx(ne,{position:"relative",h:`${w}px`,transform:k?void 0:`translateY(calc(-50% + ${y.bottomSpacing}px))`,children:K.jsx(ne,{position:"absolute",bottom:W?`${w+8}px`:0,[Ma(y.align)]:0,w:"max-content","data-dori-corner-slot":"","data-dori-quiz-corner":"",children:M})})}):null,L=E&&M?K.jsx(ne,{position:"fixed",zIndex:"1000000",top:`${T}px`,left:"50%",transform:"translateX(-50%)",w:"max-content",maxW:S,"data-dori-corner-slot":"","data-dori-quiz-under-header":"",children:M}):null,D=null!==b||m||o.eligible&&!g;return e?K.jsxs(K.Fragment,{children:[K.jsx(ne,{ref:i,position:"fixed",zIndex:"1000000",...n,children:K.jsx(Ka,{onClick:r,suppressBubble:D,slot:_})}),F,L]}):K.jsxs(K.Fragment,{children:[K.jsx(ne,{position:"fixed",zIndex:"1000000",...n,children:K.jsx(ne,{position:"relative",h:`${w}px`,transform:k?void 0:`translateY(calc(-50% + ${y.bottomSpacing}px))`,children:_})}),F,L]})}),Ga="dori-chat",Xa="#dori-chat",Ja={open:!1,expand:!1};function $a(){if("undefined"==typeof window)return!1;try{const e=window.DORI_HIDE_LAUNCHER;if(!0===e||"true"===e)return!0;const t=document.querySelector("script#dori-side-widget");return"true"===t?.getAttribute("data-hide-launcher")}catch{return!1}}function ei({mode:e,askOn:t,askPlaced:n,pageHidden:r}){return!(r||"never"===e||"fallback"===e&&t&&!1!==n)}function ti({mode:e,askOn:t,askPlaced:n,pageHidden:r}){return r||"fallback"!==e||!t||null!==n}function ni(){const[e,t]=H.useState(()=>{const e=document.querySelector("script#dori-side-widget");return"true"===e?.getAttribute("data-test-mode")}),[n,r]=H.useState(!1),[s,l]=H.useState($a),[c,d]=H.useState(()=>window.__doriAskResult??null),[u,p]=H.useState(!1),h=c?c.placed:!u&&null,[f,g]=H.useState(""),{botData:m,botError:b,updateBotData:x,diagnosticFlow:y,diagnosticShown:w,onWidgetOpened:v,setPanelOpen:k}=J(),S=$(),j=H.useRef(m);j.current=m;const P=H.useRef(null),q=H.useCallback(e=>{const t=I(e);if(!t)return!1;const n=j.current;if(!n)return P.current=e??{},!0;const r=A(n.feature_flags,o(),t);return!!r&&(window.location.assign(r),!0)},[]);H.useEffect(()=>{const e=P.current;m&&e&&(P.current=null,window.doriWidget?.open?.(e))},[m]),function(e){const{isTestMode:t,sendMessage:n,submitFeedback:r,messages:o,inputState:a,chatState:i}=J(),s=H.useRef({open:e,sendMessage:n,submitFeedback:r});s.current={open:e,sendMessage:n,submitFeedback:r},H.useEffect(()=>{if(!t)return;const e=window,n=e=>{const t=String(e||"").trim();t&&(s.current.open(),s.current.sendMessage({message:t}))};return e.doriWidget={...e.doriWidget,ask:n,rateAnswer:(e,t,n)=>s.current.submitFeedback(e,t,n)},()=>{e.doriWidget?.ask===n&&(delete e.doriWidget.ask,delete e.doriWidget.rateAnswer)}},[t]);const l=H.useRef(o);l.current=o;const c=H.useRef(i.threadId);c.current=i.threadId;const d=H.useRef(!1);H.useEffect(()=>{const e="generating"===a,n=d.current&&!e;if(d.current=e,!t||!n)return;const r=window.setTimeout(()=>{const e=l.current.filter(e=>"dori"===e.type),t=e[e.length-1];t&&t.content?.trim()&&window.dispatchEvent(new CustomEvent("dori:test-answer",{detail:{widget:"side",index:e.length-1,text:t.content,threadId:c.current??null}}))},400);return()=>window.clearTimeout(r)},[a,t])}(()=>{N.current="api_open",t(!0)});const O=!0===m?.feature_flags?.panel_drawer,Y=n&&!S.isMini&&!O,N=H.useRef("unknown"),U=H.useRef(e),V=H.useRef(e);V.current=e,H.useEffect(()=>{e&&!U.current&&(v(),i("widget_opened",{assistantId:m?.assistant_id,payload:{trigger:N.current}}),N.current="unknown"),U.current=e},[e,m?.assistant_id,v]),H.useEffect(()=>{k(e)},[e,k]);const[Q,Z]=H.useState(null),G=m?.assistant_id;H.useEffect(()=>{E()},[]),H.useEffect(()=>{Q&&G&&(Z(null),i(Q.event,{assistantId:G,payload:{intent:Q.intent}}))},[Q,G]),H.useEffect(()=>{if(G)return T(e=>i("banner_seen",{assistantId:G,payload:{intent:e}}))},[G]);const[X,ee]=H.useState(null),[te,re]=H.useState(!1),oe=!0===m?.feature_flags?.base_channel&&!0===m?.customization?.disable_welcome_popup,ae=!0===m?.customization?.enable_standalone_quiz&&Va(m)&&!!y&&!w&&!te&&!e&&!Uo()&&!oe&&!_t(),[ie,se]=H.useState(null),{isCurrentPathBanned:le}=(e=>{const[t,n]=H.useState("");return H.useEffect(()=>{const e=()=>{n(C())};e();const t=()=>{e()};window.addEventListener("popstate",t);const r=history.pushState,o=history.replaceState;return history.pushState=function(...t){r.apply(history,t),e()},history.replaceState=function(...t){o.apply(history,t),e()},()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=o}},[]),{isCurrentPathBanned:()=>z(t,e)}})(m?.banned_paths||[]);H.useEffect(()=>{e&&tn()},[e]),H.useEffect(()=>{!function(e,t){if(!e)return;const n=function(e){return"number"==typeof e&&Number.isInteger(e)?e<1||e>2147483647?null:e:null}(t);if(null===n)return e.style.removeProperty("position"),void e.style.removeProperty("z-index");e.style.position="relative",e.style.zIndex=String(n)}(document.getElementById("dori-react-widget-host"),m?.feature_flags?.widget_z_index)},[m?.feature_flags?.widget_z_index]),H.useEffect(()=>{m?.merchant_support_channels?.crisp?.enabled&&(nr(),tr()&&window.$crisp.push(["on","chat:closed",()=>{nr()}]))},[m?.merchant_support_channels?.crisp?.enabled]),H.useEffect(()=>{m?.merchant_support_channels?.chatra?.enabled&&(hr("hideChatraWidget invoked"),ir=!0,function(e){if(fr())return void e();const t=Date.now(),n=setInterval(()=>{fr()?(clearInterval(n),e()):Date.now()-t>or&&(clearInterval(n),hr("Chatra never became ready within",or,"ms"))},200)}(()=>{sr||mr("initial hide")}),null!==lr||"undefined"==typeof window||sr||(cr=Date.now(),lr=setInterval(xr,1e3)))},[m?.merchant_support_channels?.chatra?.enabled]),H.useEffect(()=>{m?.merchant_support_channels?.shopifyInbox?.enabled&&function(){if("undefined"==typeof document)return;if(document.getElementById(vr))return;const e=document.createElement("style");e.id=vr,e.textContent=`\n html:not([${kr}]) ${Sr}::part(activator) { display: none !important; }\n html:not([${kr}]) ${jr} { display: none !important; }\n `,document.head.appendChild(e),zr("launcher hidden")}()},[m?.merchant_support_channels?.shopifyInbox?.enabled]),H.useEffect(()=>{if(!f||!m?.is_widget_enabled)return;const e=window.setTimeout(()=>{hn(a.klaviyoStorefront,f)},4e3);return()=>window.clearTimeout(e)},[f,m?.is_widget_enabled]),fn({sharingId:f});const ce=jn({base:!0,md:!1})??!1,de=Jn(m,ce),ue=((e,t=!1,n=null)=>{const{align:r,sideSpacing:o}=e;return t?{bottom:`${er(e,n)}px`,[r]:`${o}px`}:{top:"50%",[r]:`${o}px`}})(de,$n(de,m,ce),m);H.useEffect(()=>{window.chatbotData?g(window.chatbotData.sharingID):R("useEffect sharing ID",()=>{g((()=>{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||""})());const e=document.querySelector("script#dori-side-widget");if(!e)return;const t=new MutationObserver(t=>{for(const n of t)if("attributes"===n.type&&"data-sharing-id"===n.attributeName){const t=e.getAttribute("data-sharing-id")||"";g(t),console.log("data-sharing-id changed:",t)}});return t.observe(e,{attributes:!0,attributeFilter:["data-sharing-id"]}),()=>{t.disconnect()}})()},[]);const pe=H.useRef(null),he=H.useRef(!1),fe=H.useRef(null);H.useEffect(()=>{const e=e=>d(e.detail??null);return window.addEventListener("dori:ask-button",e),()=>window.removeEventListener("dori:ask-button",e)},[]);const ge=Boolean(m?.feature_flags?.ask_button);H.useEffect(()=>{if(!ge||c)return;const e=setTimeout(()=>p(!0),4e3);return()=>clearTimeout(e)},[ge,c]);const me={mode:m?.feature_flags?.bubble_mode,askOn:ge,askPlaced:h,pageHidden:s},be=c??(ge&&u?{zone:"none",device:vn()}:null);H.useEffect(()=>{if(!be||be.pending||!m?.assistant_id)return;let e=!0;try{e=kn(window.sessionStorage,be.device)}catch{}e&&i("header_entry",{assistantId:m.assistant_id,payload:{zone:be.zone,spot:be.spot,label:be.label,device:be.device}})},[be?.zone,be?.device,be?.pending,m?.assistant_id]);const xe=H.useCallback(()=>{const e=document.getElementById("dori-react-widget-host");e&&e.contains(document.activeElement)&&(he.current=!0),t(!1)},[]);H.useEffect(()=>{if(!e)return;const t=e=>{if("Escape"!==e.key)return;const t=document.getElementById("dori-react-widget-host");if(!(e.target instanceof Node))return;const n=fe.current;(n&&n.contains(e.target)||t&&t.contains(e.target))&&setTimeout(()=>{e.defaultPrevented||xe()},0)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,xe]);const ye=_n(),we=H.useRef(ye);we.current=ye,H.useEffect(()=>{if(!e||!we.current)return;const t=setTimeout(()=>{(function(){const e=document.getElementById("dori-react-widget-host");if(!e)return null;const t=[e];for(;t.length;){const e=t.shift();for(const t of e.querySelectorAll("textarea"))if(t.getClientRects().length)return t;for(const n of e.querySelectorAll("*"))n.shadowRoot&&t.push(n.shadowRoot)}return null})()?.focus({preventScroll:!0})},350);return()=>clearTimeout(t)},[e]),H.useEffect(()=>{if(e||!he.current)return;he.current=!1;const t=fe.current;fe.current=null;const n=requestAnimationFrame(()=>{t?.isConnected?t.focus({preventScroll:!0}):pe.current?.querySelector("button.fab-glass")?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(n)},[e]),H.useEffect(()=>{const e=e=>{if(q(e))return;if(B(V.current,e?.source))return void t(!1);const n=D(e),o="banner_link"===e?.source;N.current=n?o?"banner_link":"banner":e?.source??"api_open";const a=document.activeElement,i=document.getElementById("dori-react-widget-host");if(fe.current=a instanceof HTMLElement&&a!==document.body&&!i?.contains(a)?a:null,t(!0),e?.expand&&r(!0),n){const t=M(e),n=_(t),{firstTap:r,sendOpener:a}=F(n);r&&Z({intent:n,event:o?"banner_link_tapped":"banner_tapped"});const i=a?L(n,t?.initiator):null;i&&ee(i)}},n=()=>t(!1),o=e=>{"cart"===e.detail?.reason&&(Vo(),re(!0)),n()},a=()=>{N.current="api_toggle",t(e=>!e)},i=e=>{x(e)},s=()=>l(!0),c=()=>l(!1),d=window;d.doriWidget={...d.doriWidget,open:e,close:n,toggle:a,updateConfig:i,hideLauncher:s,showLauncher:c},W(t=>e(t));const u=t=>{const n=t.detail;e(n)};return window.addEventListener("dori:open-widget",u),window.addEventListener("dori:close-widget",o),window.addEventListener("dori:toggle-widget",a),window.addEventListener("dori:hide-launcher",s),window.addEventListener("dori:show-launcher",c),()=>{d.doriWidget&&(d.doriWidget.open===e&&delete d.doriWidget.open,d.doriWidget.close===n&&delete d.doriWidget.close,d.doriWidget.toggle===a&&delete d.doriWidget.toggle,d.doriWidget.updateConfig===i&&delete d.doriWidget.updateConfig,d.doriWidget.hideLauncher===s&&delete d.doriWidget.hideLauncher,d.doriWidget.showLauncher===c&&delete d.doriWidget.showLauncher),window.removeEventListener("dori:open-widget",u),window.removeEventListener("dori:close-widget",o),window.removeEventListener("dori:toggle-widget",a),window.removeEventListener("dori:hide-launcher",s),window.removeEventListener("dori:show-launcher",c)}},[x,q]),H.useEffect(()=>{const e=function(){if("undefined"==typeof window)return Ja;try{const e=new URLSearchParams(window.location.search).get(Ga)?.trim().toLowerCase();if("banner"===e)return{open:!0,expand:!0,banner:!0};if("open"===e||"expand"===e)return{open:!0,expand:"expand"===e};if(window.location.hash.toLowerCase()===Xa)return{open:!0,expand:!1}}catch{}return Ja}();e.open&&(function(){if("undefined"!=typeof window&&window.history?.replaceState)try{const e=new URL(window.location.href);let t=!1;e.searchParams.has(Ga)&&(e.searchParams.delete(Ga),t=!0),e.hash.toLowerCase()===Xa&&(e.hash="",t=!0),t&&window.history.replaceState(window.history.state,"",e.toString())}catch{}}(),e.banner?window.doriWidget?.open?.({source:"banner_link",expand:!0}):e.expand&&q({expand:!0,source:"link"})||(N.current="deep_link",t(!0),e.expand&&r(!0)))},[q]);const ve=gn({botData:m,botError:b,isPathBanned:le()});b&&!m&&console.warn("[Dori Widget] bot data unavailable — hiding widget:",b);const ke=H.useCallback((e,n,r)=>{re(!0),ee({message:e,imageUrl:n,apiMessage:r}),N.current="quiz_chat",t(!0)},[]),Se=H.useCallback(()=>{ee(null)},[]);return K.jsx(ne,{fontFamily:yn("system-ui, Avenir, Helvetica, Arial, sans-serif"),lineHeight:"1.5",fontWeight:"400",colorScheme:"light",children:!ve&&K.jsxs(K.Fragment,{children:[K.jsx(Ro,{isOpen:e,onClose:xe,isExpanded:Y,onToggleExpand:S.isMini||O?void 0:e=>r(void 0===e?!Y:e),fullPageHref:A(m?.feature_flags,o(),"chat"),pendingChat:X,onPendingChatConsumed:Se}),!e&&(je=m?.feature_flags,Ce=rn(),!(!0===je?.hide_on_product_pages&&"product"===Ce))&&K.jsx(Za,{ref:pe,bubble:ei(me),settled:ti(me),styles:ue,onClick:()=>{e||(N.current="fab",fe.current=null),t(!e)},quiz:{eligible:ae,onStartChat:ke,onOpenWidget:()=>{N.current="quiz_card",t(!0)},onDismissed:()=>re(!0)},sheetLayer:ie}),K.jsx(ne,{ref:se,"data-dori-corner-layer":""})]})});var je,Ce}function ri(){return K.jsx(ni,{})}console.log("isDevelopment",!1);let oi=!1;function ai(){if(oi)return console.log("[Dori Widget] Already initialized, skipping"),()=>{};oi=!0;const e=[];let t=document.getElementById("dori-react-widget-host");t||(t=document.createElement("div"),t.id="dori-react-widget-host",t.setAttribute("data-nosnippet",""),document.body.appendChild(t));const n=mn.createRoot(t);n.render(K.jsx(Je.StrictMode,{children:K.jsx($e,{children:K.jsx(bn,{children:K.jsx(ri,{})})})})),e.push(n);const r=()=>{g(()=>import("./MarkdownContent-ZQGRMI3l.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).catch(()=>{})};return"function"==typeof window.requestIdleCallback?window.requestIdleCallback(r,{timeout:3e3}):window.setTimeout(r,1500),()=>{e.forEach(e=>e.unmount()),oi=!1}}export{ai as initializeDoriWidget};
Binary file
Binary file