@askdialog/dialog-react 0.0.0-beta-20260922144524 → 0.0.0-beta-20260929090414

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.
@@ -203,7 +203,7 @@ const W = ({
203
203
  m(() => {
204
204
  D({
205
205
  method: "react",
206
- version: "0.0.0-beta-20260922144524"
206
+ version: "0.0.0-beta-20260929090414"
207
207
  }), K("pdp-block");
208
208
  }, []);
209
209
  const u = y(
@@ -859,7 +859,7 @@ const W = ({
859
859
  }), m(() => {
860
860
  D({
861
861
  method: "react",
862
- version: "0.0.0-beta-20260922144524"
862
+ version: "0.0.0-beta-20260929090414"
863
863
  });
864
864
  const i = r();
865
865
  return () => {
@@ -1 +1 @@
1
- (function(b,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("@askdialog/dialog-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@askdialog/dialog-sdk","react-dom"],s):(b=typeof globalThis<"u"?globalThis:b||self,s(b["dialog-react"]={},b["react/jsx-runtime"],b.React,b.dialogSdk,b.ReactDOM))})(this,(function(b,s,u,v,H){"use strict";const B=({title:e="Your expert",description:t="A question about this product?"})=>s.jsxs("div",{className:"dialog-block-header-container",children:[s.jsx("div",{className:"dialog-block-title",children:e}),s.jsx("div",{className:"dialog-block-description",children:t})]}),F=({color:e="#181825"})=>s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsxs("g",{clipPath:"url(#clip0_466_934)",children:[s.jsx("path",{d:"M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011 12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684 13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559 15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232 16.3622 6.2917 16.5834 6.07046 17.0259L5.41675 18.3333L4.76303 17.0259C4.54179 16.5834 4.43117 16.3622 4.28339 16.1704C4.15225 16.0003 3.99974 15.8478 3.82962 15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418 13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225 13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675 10.8333Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175 5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687 6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632 8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348 9.8631 13.7173 10.1686 13.4823 10.7796L12.5001 13.3333L11.5179 10.7796C11.2829 10.1686 11.1654 9.8631 10.9827 9.60612C10.8207 9.37836 10.6217 9.17937 10.3939 9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043 6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207 5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001 1.66666Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_466_934",children:s.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}),q=({client:e,questions:t,productId:o,productTitle:r,selectedVariantId:a})=>{const l=i=>{e.sendProductMessage({productId:o,productTitle:r,selectedVariantId:a,question:i,fromQuestionSuggestion:!0})};return s.jsx(s.Fragment,{children:t.map(i=>s.jsxs("button",{className:"dialog-block-suggestions-item",onClick:()=>l(i.question),children:[s.jsx(F,{color:e.theme.primaryColor}),s.jsx("span",{className:"dialog-block-suggestions-item-label",children:i.question})]},i.question))})},V=()=>s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"})]}),K=({client:e,questions:t,isLoading:o,productId:r,productTitle:a,selectedVariantId:l})=>s.jsx("div",{className:"dialog-block-suggestions-container",children:o||!t?s.jsx(V,{}):s.jsx(q,{client:e,questions:t,productId:r,productTitle:a,selectedVariantId:l})}),j=({color:e="#ffffff"})=>s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),N=({client:e,placeholder:t="Ask anything...",productId:o,productTitle:r,selectedVariantId:a})=>{const l=u.useRef(null),[i,n]=u.useState(""),c=()=>{var d;(d=l.current)==null||d.focus()},h=()=>{const d=i;d.trim()&&(e.sendProductMessage({productId:o,productTitle:r,selectedVariantId:a,question:d,fromQuestionSuggestion:!0}),n(""))},f=d=>{d.key==="Enter"&&h()};return s.jsxs("div",{className:"dialog-input-wrapper",onClick:c,children:[s.jsx("input",{id:"dialog-ask-anything-input-ai-input",ref:l,value:i,onChange:d=>n(d.target.value),className:"dialog-ask-anything-input-ai-input",placeholder:t,onKeyDown:f}),s.jsx("button",{id:"send-message-button-ai-input",className:"dialog-input-submit",disabled:!i.trim(),onClick:h,children:s.jsx(j,{color:e.theme.ctaTextColor})})]})},k=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),z=e=>{if(!e)return;const t=document.body;Object.keys(e).forEach(o=>{const r=o,a=k(o);if(e[r]!==void 0){if(typeof e[r]=="object"){Object.keys(e[r]).forEach(l=>{var n;const i=l;if(i!==void 0){const c=k(l),h=e[r];t.style.setProperty(`--dialog-theme-${a}-${c}`,(n=h[i])==null?void 0:n.toString())}});return}if(r==="ctaBorderType"){const l=e[r]==="rounded"?"24px":"0";t.style.setProperty(`--dialog-theme-${a}`,l);return}t.style.setProperty(`--dialog-theme-${a}`,e[r].toString())}})},U=({theme:e,children:t})=>(u.useEffect(()=>{e&&z(e)},[e]),s.jsx(s.Fragment,{children:t})),W=({client:e,productId:t,productTitle:o,selectedVariantId:r,enableInput:a=!0})=>{const[l,i]=u.useState(!0),[n,c]=u.useState(void 0);u.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"0.0.0-beta-20260922144524"}),v.addAuditCapability("pdp-block")},[]);const h=u.useMemo(()=>l?"":n==null?void 0:n.assistantName,[n,l]),f=u.useMemo(()=>l?"":n==null?void 0:n.description,[n,l]),d=u.useMemo(()=>l?"":n==null?void 0:n.inputPlaceholder,[n,l]),p=u.useMemo(()=>{var g;return v.resolveTextDirection((g=e.getLocalizationInformations())==null?void 0:g.languageCode)},[e]);return u.useEffect(()=>{let g=!0;return(async()=>{i(!0),c(void 0);try{const m=await e.getSuggestions(t);g&&c(m)}catch(m){console.error("error",m)}finally{g&&i(!1)}})(),()=>{g=!1}},[e,t]),s.jsx(U,{theme:e.theme,children:s.jsxs("div",{id:"dialog-instant",className:"dialog-block-container",dir:p,children:[s.jsx(B,{title:h,description:f}),s.jsx(K,{client:e,questions:n==null?void 0:n.questions,isLoading:l,productId:t,productTitle:o,selectedVariantId:r}),a&&s.jsx(N,{client:e,placeholder:d,productId:t,productTitle:o,selectedVariantId:r})]})})},Q=()=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Z="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",X=({color:e="currentColor"})=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:Z,fill:e})}),G=({controller:e,placeholder:t="Search products...",autoFocus:o=!1,submitAriaLabel:r="Search"})=>{const[a,l]=u.useState(""),i=n=>{n.preventDefault(),e.submit(a)};return s.jsxs("form",{className:"dialog-search-bar",role:"search",onSubmit:i,children:[s.jsxs("div",{className:"dialog-search-bar-field",children:[s.jsx("span",{className:"dialog-search-bar-icon",children:s.jsx(X,{})}),s.jsx("input",{type:"text",name:"dialog-search-query",className:"dialog-search-bar-input",value:a,"aria-label":t,placeholder:t,autoFocus:o,onChange:n=>{l(n.target.value),e.setQuery(n.target.value)}})]}),s.jsx("button",{type:"submit",className:"dialog-search-bar-submit","aria-label":r,children:s.jsx(Q,{})})]})},Y=(e,t)=>{try{return new Intl.NumberFormat(t).format(e)}catch{return String(e)}},P={en:e=>({searching:t=>`Searching “${t}”…`,noResults:"No matching products",retry:"Retry",collectionsLabel:"Collections",productsLabel:"Products",collectionsCount:t=>t===1?"1 collection":`${e(t)} collections`,resultsCount:t=>t===1?"1 result":`${e(t)} results`,seeAllLabel:t=>t===1?"See the result":`See all ${e(t)} results`,previous:"Previous",next:"Next",pageOf:(t,o)=>`Page ${e(t)} / ${e(o)}`}),fr:e=>({searching:t=>`Recherche de « ${t} »…`,noResults:"Aucun produit correspondant",retry:"Réessayer",collectionsLabel:"Collections",productsLabel:"Produits",collectionsCount:t=>t===1?"1 collection":`${e(t)} collections`,resultsCount:t=>t===1?"1 résultat":`${e(t)} résultats`,seeAllLabel:t=>t===1?"Voir le résultat":`Voir les ${e(t)} résultats`,previous:"Précédent",next:"Suivant",pageOf:(t,o)=>`Page ${e(t)} / ${e(o)}`}),de:e=>({searching:t=>`Suche nach „${t}“…`,noResults:"Keine passenden Produkte",retry:"Erneut versuchen",collectionsLabel:"Kollektionen",productsLabel:"Produkte",collectionsCount:t=>t===1?"1 Kollektion":`${e(t)} Kollektionen`,resultsCount:t=>t===1?"1 Ergebnis":`${e(t)} Ergebnisse`,seeAllLabel:t=>t===1?"Das Ergebnis anzeigen":`Alle ${e(t)} Ergebnisse anzeigen`,previous:"Zurück",next:"Weiter",pageOf:(t,o)=>`Seite ${e(t)} / ${e(o)}`}),es:e=>({searching:t=>`Buscando «${t}»…`,noResults:"No hay productos que coincidan",retry:"Reintentar",collectionsLabel:"Colecciones",productsLabel:"Productos",collectionsCount:t=>t===1?"1 colección":`${e(t)} colecciones`,resultsCount:t=>t===1?"1 resultado":`${e(t)} resultados`,seeAllLabel:t=>t===1?"Ver el resultado":`Ver los ${e(t)} resultados`,previous:"Anterior",next:"Siguiente",pageOf:(t,o)=>`Página ${e(t)} / ${e(o)}`}),it:e=>({searching:t=>`Ricerca di “${t}”…`,noResults:"Nessun prodotto corrispondente",retry:"Riprova",collectionsLabel:"Collezioni",productsLabel:"Prodotti",collectionsCount:t=>t===1?"1 collezione":`${e(t)} collezioni`,resultsCount:t=>t===1?"1 risultato":`${e(t)} risultati`,seeAllLabel:t=>t===1?"Vedi il risultato":`Vedi tutti i ${e(t)} risultati`,previous:"Precedente",next:"Successivo",pageOf:(t,o)=>`Pagina ${e(t)} / ${e(o)}`})},E=e=>{var r;const t=((r=e==null?void 0:e.split("-")[0])==null?void 0:r.toLowerCase())??"en";return(P[t]??P.en)(a=>Y(a,e))},A=e=>e.status!==v.SearchStatus.LOADING&&e.response!==void 0&&e.response.nbPages>1,x=({controller:e,state:t,locale:o})=>{const r=t.response;if(r===void 0||!A(t))return null;const a=E(o);return s.jsxs("nav",{"aria-label":"Search results pages",className:"dialog-search-pagination",children:[s.jsx("button",{type:"button",disabled:r.page===0,onClick:()=>e.setPage(r.page-1),children:a.previous}),s.jsx("span",{children:a.pageOf(r.page+1,r.nbPages)}),s.jsx("button",{type:"button",disabled:r.page>=r.nbPages-1,onClick:()=>e.setPage(r.page+1),children:a.next})]})},$=e=>e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").replace(/ẞ/gu,"ß").toUpperCase().toLowerCase().replace(/ς/g,"σ"),J=(e,t)=>{const o={before:"",match:e,after:""},r=$(t.trim());if(r==="")return o;const a=[...e],l=[];let i="";a.forEach((f,d)=>{const p=$(f);for(let g=0;g<p.length;g+=1)l.push(d);i+=p});const n=i.indexOf(r);if(n===-1)return o;const c=l[n],h=l[n+r.length-1]+1;return{before:a.slice(0,c).join(""),match:a.slice(c,h).join(""),after:a.slice(h).join("")}},D=({title:e,query:t})=>{const{before:o,match:r,after:a}=J(e,t);return s.jsxs(s.Fragment,{children:[o!==""&&s.jsx("span",{className:"dialog-search-muted",children:o}),s.jsx("span",{className:"dialog-search-match",children:r}),a!==""&&s.jsx("span",{className:"dialog-search-muted",children:a})]})},R=({amount:e,currencyCode:t},o)=>t===void 0?new Intl.NumberFormat(o).format(Number(e)):new Intl.NumberFormat(o,{style:"currency",currency:t}).format(Number(e)),ee=(e,t)=>{if(e===void 0)return"";try{return R(e.min,t)}catch{return""}},te=e=>{try{const{protocol:t}=new URL(e,window.location.href);return t==="http:"||t==="https:"?e:void 0}catch{return}},M=e=>e.url===void 0||e.url===""?void 0:te(e.url),I=e=>e.title??e.handle??e.objectID,T=({controller:e,hit:t,index:o,locale:r,query:a=""})=>{const l=u.useRef(null);u.useEffect(()=>{l.current!==null&&e.observeResult(l.current,o)},[e,t,o]);const i=d=>{const p=d.metaKey||d.ctrlKey||d.shiftKey||d.altKey;e.selectResult(o,{navigate:!p})&&d.preventDefault()},n=d=>{d.button===1&&e.selectResult(o,{navigate:!1})},c=ee(t.priceRange,r),h=M(t),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"dialog-search-product-thumb","aria-hidden":!0,children:t.imageUrl!==void 0&&t.imageUrl!==""&&s.jsx("img",{src:t.imageUrl,alt:"",loading:"lazy"})}),s.jsx("span",{className:"dialog-search-product-title",children:s.jsx(D,{title:I(t),query:a})}),c!==""&&s.jsx("span",{className:"dialog-search-product-price",children:c})]});return s.jsx("li",{ref:l,className:"dialog-search-card",children:h===void 0?s.jsx("div",{className:"dialog-search-product",children:f}):s.jsx("a",{className:"dialog-search-product",href:h,onClick:i,onAuxClick:n,children:f})})},se=()=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),re=()=>s.jsx("svg",{width:12,height:12,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"})}),O=e=>(e??[]).flatMap(t=>{const o=M(t);return o===void 0?[]:[{collection:t,href:o}]}),oe=({collections:e,query:t,messages:o})=>{const r=O(e);return r.length===0?null:s.jsxs("aside",{className:"dialog-search-collections",children:[s.jsxs("div",{className:"dialog-search-section-head",children:[s.jsx("p",{className:"dialog-search-label",children:o.collectionsLabel}),s.jsx("span",{className:"dialog-search-count",children:o.collectionsCount(r.length)})]}),s.jsx("ul",{className:"dialog-search-collection-list",children:r.map(({collection:a,href:l})=>s.jsx("li",{children:s.jsxs("a",{className:"dialog-search-collection",href:l,children:[s.jsx("span",{className:"dialog-search-collection-thumb","aria-hidden":!0,children:a.imageUrl!==void 0&&a.imageUrl!==""&&s.jsx("img",{src:a.imageUrl,alt:"",loading:"lazy"})}),s.jsx("span",{className:"dialog-search-collection-title",children:s.jsx(D,{title:I(a),query:t})}),s.jsx("span",{className:"dialog-search-caret",children:s.jsx(re,{})})]})},a.objectID))})]})},ae=({controller:e,response:t,locale:o,messages:r})=>s.jsxs("section",{className:"dialog-search-products",children:[s.jsx("div",{className:"dialog-search-section-head",children:s.jsxs("p",{className:"dialog-search-label",children:[r.productsLabel,t.nbHits>0&&s.jsx("span",{className:"dialog-search-label-count",children:` · ${r.resultsCount(t.nbHits)}`})]})}),s.jsx("ul",{className:"dialog-search-results",children:t.hits.length===0?s.jsx("li",{className:"dialog-search-empty",role:"status",children:r.noResults}):t.hits.map((a,l)=>s.jsx(T,{controller:e,hit:a,index:l,locale:o,query:t.query},a.objectID))})]}),y=8,C=16,ne=200,ce=1440,le=(e,t)=>e.bottom>0&&e.top<t,ie=(e,t)=>{const o=Math.min(ce,t-2*C),r=e.left+e.width/2-o/2;return{left:Math.min(Math.max(r,C),t-C-o),width:o}},de=(e,t,o)=>{const r=o-e.bottom-y-C,a=e.top-y-C,l=ie(e,t);return r<ne&&a>r?{...l,bottom:o-e.top+y,maxHeight:Math.max(a,0)}:{...l,top:e.bottom+y,maxHeight:Math.max(r,0)}},ue=e=>{const t=e.trim().replace(/^#/,"");if(!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))return;const o=t.length<=4?[...t].map(r=>r+r).join(""):t;return[0,2,4].map(r=>Number.parseInt(o.slice(r,r+2),16))},he=e=>{const t=/^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);if(t!==null)return[t[1],t[2],t[3]].map(Number)},ge=e=>{if(typeof document>"u")return;const t=document.createElement("span");if(t.style.color=e,t.style.color==="")return;document.body.appendChild(t);const o=he(getComputedStyle(t).color);return t.remove(),o},fe=e=>ue(e)??ge(e),pe=e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},_=e=>{const t=fe(e);if(t===void 0)return;const[o,r,a]=t.map(pe);return .2126*o+.7152*r+.0722*a},be="#181825",ve="#ffffff",Ce="straight",w=.5,L={light:{panel:"#ffffff",side:"#fafbfc",text:"#111827","text-sec":"#6b7280",border:"#eceef2",hover:"#eef2f7",thumb:"#eef1f5"},dark:{panel:"#15171c",side:"#1b1e25",text:"#f3f4f6","text-sec":"#9ca3af",border:"#2b2f38",hover:"#242830",thumb:"#2b2f38"}},ye={rectangle:{"r-panel":"4px","r-item":"4px","r-thumb":"2px","r-btn":"4px"},"rectangle-rounded":{"r-panel":"16px","r-item":"10px","r-thumb":"8px","r-btn":"10px"}},S=e=>e===void 0||e.trim()===""?void 0:e.trim(),Se=e=>{const t=e===void 0?void 0:_(e);return t===void 0?"light":t<w?"dark":"light"},we=(e,t)=>{const o=_(e);return o===void 0?L[t].text:(t==="light"?o<w:o>=w)?e:L[t].text},Le=e=>{const t=Se(S(e==null?void 0:e.backgroundColor)),o=(e==null?void 0:e.ctaBorderType)===Ce?"rectangle":"rectangle-rounded",r=S(e==null?void 0:e.primaryColor)??be,a=S(e==null?void 0:e.fontFamily),l={...L[t],...ye[o],primary:r,accent:we(r,t),"cta-text":S(e==null?void 0:e.ctaTextColor)??ve,...a===void 0?{}:{font:a}};return Object.fromEntries(Object.entries(l).map(([i,n])=>[`--dso-${i}`,n]))},me=e=>{const t=u.useRef(null),[o,r]=u.useState(void 0),[a,l]=u.useState({width:0,height:0});return u.useLayoutEffect(()=>{if(!e)return;const i=()=>{const n=t.current;if(n===null)return;const c=n.previousElementSibling??n,{top:h,bottom:f,left:d,width:p}=c.getBoundingClientRect();l(g=>g.width===window.innerWidth&&g.height===window.innerHeight?g:{width:window.innerWidth,height:window.innerHeight}),r(g=>g!==void 0&&g.top===h&&g.bottom===f&&g.left===d&&g.width===p?g:{top:h,bottom:f,left:d,width:p})};return i(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e]),{anchorRef:t,rect:o,viewport:a}},Ne=(e,t)=>{const[o,r]=u.useState(!1),a=u.useRef(null),l=e.status!==v.SearchStatus.IDLE&&!o;return u.useEffect(()=>{r(!1)},[e.query]),u.useEffect(()=>{if(!l)return;const i=n=>{var p,g;const c=n.target;if(!(c instanceof Node))return;const h=(p=t.current)==null?void 0:p.previousElementSibling,f=((g=a.current)==null?void 0:g.contains(c))??!1,d=(h==null?void 0:h.contains(c))??!1;!f&&!d&&r(!0)};return document.addEventListener("pointerdown",i),()=>document.removeEventListener("pointerdown",i)},[l,t]),u.useEffect(()=>{var c;const i=(c=t.current)==null?void 0:c.previousElementSibling;if(i==null)return;const n=()=>r(!1);return i.addEventListener("focusin",n),()=>i.removeEventListener("focusin",n)},[t]),{isOpen:l,panelRef:a}},ke=e=>e instanceof v.DialogSearchError?`Search failed (${e.status}${e.code?` ${e.code}`:""}): ${e.message}`:"Search failed: network error. Check your connection and try again.",Pe=(e,t)=>{var p,g;const{controller:o,state:r,locale:a,seeAllHref:l}=e,{status:i,response:n}=r;if(i===v.SearchStatus.ERROR)return s.jsxs("div",{className:"dialog-search-error",children:[s.jsx("p",{role:"alert",className:"dialog-search-status dialog-search-status-error",children:ke(r.error)}),s.jsx("button",{type:"button",className:"dialog-search-retry",onClick:()=>o.retry(),children:t.retry})]});if(n===void 0)return s.jsx("p",{role:"status",className:"dialog-search-status",children:t.searching(r.query)});const c=((g=(p=r.sections)==null?void 0:p.collections)==null?void 0:g.hits)??[],h=O(c).length>0,f=l!==void 0&&n.nbHits>0,d=!f&&A(r);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`dialog-search-body${h?"":" dialog-search-body--no-collections"}`,children:[s.jsx(oe,{collections:c,query:n.query,messages:t}),s.jsx(ae,{controller:o,response:n,locale:a,messages:t})]}),(f||d)&&s.jsx("div",{className:"dialog-search-footer",children:f?s.jsxs("a",{className:"dialog-search-cta",href:l(n.query),children:[t.seeAllLabel(n.nbHits),s.jsx(se,{})]}):s.jsx(x,{controller:o,state:r,locale:a})})]})},Ee=e=>{const{state:t,locale:o,theme:r,layout:a="list"}=e,l=t.status!==v.SearchStatus.IDLE,{anchorRef:i,rect:n,viewport:c}=me(l),{isOpen:h,panelRef:f}=Ne(t,i),d=E(o),p=u.useMemo(()=>Le(r),[r]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:i}),h&&n!==void 0&&le(n,c.height)&&H.createPortal(s.jsx("div",{ref:f,className:`dialog-search-panel dialog-search-panel--${a}`,style:{...de(n,c.width,c.height),...p},children:Pe(e,d)}),document.body)]})},Ae={status:v.SearchStatus.IDLE,query:"",page:0},xe=e=>{const t=u.useRef(e);t.current=e;const o=u.useRef(void 0),r=u.useCallback(()=>{if(o.current===void 0){const{client:c,surface:h="search_page",...f}=t.current;o.current=v.createSearchController({search:(d,p)=>c.search(d,p),analytics:{surface:h,trackViewSearchResults:d=>c.trackViewSearchResults(d),trackSelectSearchResult:d=>c.trackSelectSearchResult(d)},...f})}return o.current},[]),a=u.useRef(void 0);a.current??(a.current={setQuery:c=>r().setQuery(c),submit:c=>r().submit(c),setPage:c=>r().setPage(c),retry:()=>r().retry(),observeResult:(c,h)=>r().observeResult(c,h),selectResult:(c,h)=>r().selectResult(c,h),subscribe:c=>r().subscribe(c),getState:()=>r().getState(),dispose:()=>{var c;(c=o.current)==null||c.dispose(),o.current=void 0}}),u.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"0.0.0-beta-20260922144524"});const c=r();return()=>{c.dispose(),o.current===c&&(o.current=void 0)}},[r]);const l=u.useCallback(c=>r().subscribe(c),[r]),i=u.useCallback(()=>r().getState(),[r]),n=u.useSyncExternalStore(l,i,()=>Ae);return{controller:a.current,state:n,theme:e.client.theme}};b.DialogInput=N,b.DialogProductBlock=W,b.DialogSearchBar=G,b.DialogSearchPagination=x,b.DialogSearchProductCard=T,b.DialogSearchResults=Ee,b.useDialogSearch=xe,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(b,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("@askdialog/dialog-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@askdialog/dialog-sdk","react-dom"],s):(b=typeof globalThis<"u"?globalThis:b||self,s(b["dialog-react"]={},b["react/jsx-runtime"],b.React,b.dialogSdk,b.ReactDOM))})(this,(function(b,s,u,v,H){"use strict";const B=({title:e="Your expert",description:t="A question about this product?"})=>s.jsxs("div",{className:"dialog-block-header-container",children:[s.jsx("div",{className:"dialog-block-title",children:e}),s.jsx("div",{className:"dialog-block-description",children:t})]}),F=({color:e="#181825"})=>s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsxs("g",{clipPath:"url(#clip0_466_934)",children:[s.jsx("path",{d:"M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011 12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684 13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559 15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232 16.3622 6.2917 16.5834 6.07046 17.0259L5.41675 18.3333L4.76303 17.0259C4.54179 16.5834 4.43117 16.3622 4.28339 16.1704C4.15225 16.0003 3.99974 15.8478 3.82962 15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418 13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225 13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675 10.8333Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175 5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687 6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632 8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348 9.8631 13.7173 10.1686 13.4823 10.7796L12.5001 13.3333L11.5179 10.7796C11.2829 10.1686 11.1654 9.8631 10.9827 9.60612C10.8207 9.37836 10.6217 9.17937 10.3939 9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043 6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207 5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001 1.66666Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_466_934",children:s.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}),q=({client:e,questions:t,productId:o,productTitle:r,selectedVariantId:a})=>{const l=i=>{e.sendProductMessage({productId:o,productTitle:r,selectedVariantId:a,question:i,fromQuestionSuggestion:!0})};return s.jsx(s.Fragment,{children:t.map(i=>s.jsxs("button",{className:"dialog-block-suggestions-item",onClick:()=>l(i.question),children:[s.jsx(F,{color:e.theme.primaryColor}),s.jsx("span",{className:"dialog-block-suggestions-item-label",children:i.question})]},i.question))})},V=()=>s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),s.jsx("div",{className:"dialog-block-suggestions-skeleton-item"})]}),K=({client:e,questions:t,isLoading:o,productId:r,productTitle:a,selectedVariantId:l})=>s.jsx("div",{className:"dialog-block-suggestions-container",children:o||!t?s.jsx(V,{}):s.jsx(q,{client:e,questions:t,productId:r,productTitle:a,selectedVariantId:l})}),j=({color:e="#ffffff"})=>s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),N=({client:e,placeholder:t="Ask anything...",productId:o,productTitle:r,selectedVariantId:a})=>{const l=u.useRef(null),[i,n]=u.useState(""),c=()=>{var d;(d=l.current)==null||d.focus()},h=()=>{const d=i;d.trim()&&(e.sendProductMessage({productId:o,productTitle:r,selectedVariantId:a,question:d,fromQuestionSuggestion:!0}),n(""))},f=d=>{d.key==="Enter"&&h()};return s.jsxs("div",{className:"dialog-input-wrapper",onClick:c,children:[s.jsx("input",{id:"dialog-ask-anything-input-ai-input",ref:l,value:i,onChange:d=>n(d.target.value),className:"dialog-ask-anything-input-ai-input",placeholder:t,onKeyDown:f}),s.jsx("button",{id:"send-message-button-ai-input",className:"dialog-input-submit",disabled:!i.trim(),onClick:h,children:s.jsx(j,{color:e.theme.ctaTextColor})})]})},k=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),z=e=>{if(!e)return;const t=document.body;Object.keys(e).forEach(o=>{const r=o,a=k(o);if(e[r]!==void 0){if(typeof e[r]=="object"){Object.keys(e[r]).forEach(l=>{var n;const i=l;if(i!==void 0){const c=k(l),h=e[r];t.style.setProperty(`--dialog-theme-${a}-${c}`,(n=h[i])==null?void 0:n.toString())}});return}if(r==="ctaBorderType"){const l=e[r]==="rounded"?"24px":"0";t.style.setProperty(`--dialog-theme-${a}`,l);return}t.style.setProperty(`--dialog-theme-${a}`,e[r].toString())}})},U=({theme:e,children:t})=>(u.useEffect(()=>{e&&z(e)},[e]),s.jsx(s.Fragment,{children:t})),W=({client:e,productId:t,productTitle:o,selectedVariantId:r,enableInput:a=!0})=>{const[l,i]=u.useState(!0),[n,c]=u.useState(void 0);u.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"0.0.0-beta-20260929090414"}),v.addAuditCapability("pdp-block")},[]);const h=u.useMemo(()=>l?"":n==null?void 0:n.assistantName,[n,l]),f=u.useMemo(()=>l?"":n==null?void 0:n.description,[n,l]),d=u.useMemo(()=>l?"":n==null?void 0:n.inputPlaceholder,[n,l]),p=u.useMemo(()=>{var g;return v.resolveTextDirection((g=e.getLocalizationInformations())==null?void 0:g.languageCode)},[e]);return u.useEffect(()=>{let g=!0;return(async()=>{i(!0),c(void 0);try{const m=await e.getSuggestions(t);g&&c(m)}catch(m){console.error("error",m)}finally{g&&i(!1)}})(),()=>{g=!1}},[e,t]),s.jsx(U,{theme:e.theme,children:s.jsxs("div",{id:"dialog-instant",className:"dialog-block-container",dir:p,children:[s.jsx(B,{title:h,description:f}),s.jsx(K,{client:e,questions:n==null?void 0:n.questions,isLoading:l,productId:t,productTitle:o,selectedVariantId:r}),a&&s.jsx(N,{client:e,placeholder:d,productId:t,productTitle:o,selectedVariantId:r})]})})},Q=()=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Z="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",X=({color:e="currentColor"})=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:Z,fill:e})}),G=({controller:e,placeholder:t="Search products...",autoFocus:o=!1,submitAriaLabel:r="Search"})=>{const[a,l]=u.useState(""),i=n=>{n.preventDefault(),e.submit(a)};return s.jsxs("form",{className:"dialog-search-bar",role:"search",onSubmit:i,children:[s.jsxs("div",{className:"dialog-search-bar-field",children:[s.jsx("span",{className:"dialog-search-bar-icon",children:s.jsx(X,{})}),s.jsx("input",{type:"text",name:"dialog-search-query",className:"dialog-search-bar-input",value:a,"aria-label":t,placeholder:t,autoFocus:o,onChange:n=>{l(n.target.value),e.setQuery(n.target.value)}})]}),s.jsx("button",{type:"submit",className:"dialog-search-bar-submit","aria-label":r,children:s.jsx(Q,{})})]})},Y=(e,t)=>{try{return new Intl.NumberFormat(t).format(e)}catch{return String(e)}},P={en:e=>({searching:t=>`Searching “${t}”…`,noResults:"No matching products",retry:"Retry",collectionsLabel:"Collections",productsLabel:"Products",collectionsCount:t=>t===1?"1 collection":`${e(t)} collections`,resultsCount:t=>t===1?"1 result":`${e(t)} results`,seeAllLabel:t=>t===1?"See the result":`See all ${e(t)} results`,previous:"Previous",next:"Next",pageOf:(t,o)=>`Page ${e(t)} / ${e(o)}`}),fr:e=>({searching:t=>`Recherche de « ${t} »…`,noResults:"Aucun produit correspondant",retry:"Réessayer",collectionsLabel:"Collections",productsLabel:"Produits",collectionsCount:t=>t===1?"1 collection":`${e(t)} collections`,resultsCount:t=>t===1?"1 résultat":`${e(t)} résultats`,seeAllLabel:t=>t===1?"Voir le résultat":`Voir les ${e(t)} résultats`,previous:"Précédent",next:"Suivant",pageOf:(t,o)=>`Page ${e(t)} / ${e(o)}`}),de:e=>({searching:t=>`Suche nach „${t}“…`,noResults:"Keine passenden Produkte",retry:"Erneut versuchen",collectionsLabel:"Kollektionen",productsLabel:"Produkte",collectionsCount:t=>t===1?"1 Kollektion":`${e(t)} Kollektionen`,resultsCount:t=>t===1?"1 Ergebnis":`${e(t)} Ergebnisse`,seeAllLabel:t=>t===1?"Das Ergebnis anzeigen":`Alle ${e(t)} Ergebnisse anzeigen`,previous:"Zurück",next:"Weiter",pageOf:(t,o)=>`Seite ${e(t)} / ${e(o)}`}),es:e=>({searching:t=>`Buscando «${t}»…`,noResults:"No hay productos que coincidan",retry:"Reintentar",collectionsLabel:"Colecciones",productsLabel:"Productos",collectionsCount:t=>t===1?"1 colección":`${e(t)} colecciones`,resultsCount:t=>t===1?"1 resultado":`${e(t)} resultados`,seeAllLabel:t=>t===1?"Ver el resultado":`Ver los ${e(t)} resultados`,previous:"Anterior",next:"Siguiente",pageOf:(t,o)=>`Página ${e(t)} / ${e(o)}`}),it:e=>({searching:t=>`Ricerca di “${t}”…`,noResults:"Nessun prodotto corrispondente",retry:"Riprova",collectionsLabel:"Collezioni",productsLabel:"Prodotti",collectionsCount:t=>t===1?"1 collezione":`${e(t)} collezioni`,resultsCount:t=>t===1?"1 risultato":`${e(t)} risultati`,seeAllLabel:t=>t===1?"Vedi il risultato":`Vedi tutti i ${e(t)} risultati`,previous:"Precedente",next:"Successivo",pageOf:(t,o)=>`Pagina ${e(t)} / ${e(o)}`})},E=e=>{var r;const t=((r=e==null?void 0:e.split("-")[0])==null?void 0:r.toLowerCase())??"en";return(P[t]??P.en)(a=>Y(a,e))},A=e=>e.status!==v.SearchStatus.LOADING&&e.response!==void 0&&e.response.nbPages>1,x=({controller:e,state:t,locale:o})=>{const r=t.response;if(r===void 0||!A(t))return null;const a=E(o);return s.jsxs("nav",{"aria-label":"Search results pages",className:"dialog-search-pagination",children:[s.jsx("button",{type:"button",disabled:r.page===0,onClick:()=>e.setPage(r.page-1),children:a.previous}),s.jsx("span",{children:a.pageOf(r.page+1,r.nbPages)}),s.jsx("button",{type:"button",disabled:r.page>=r.nbPages-1,onClick:()=>e.setPage(r.page+1),children:a.next})]})},$=e=>e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").replace(/ẞ/gu,"ß").toUpperCase().toLowerCase().replace(/ς/g,"σ"),J=(e,t)=>{const o={before:"",match:e,after:""},r=$(t.trim());if(r==="")return o;const a=[...e],l=[];let i="";a.forEach((f,d)=>{const p=$(f);for(let g=0;g<p.length;g+=1)l.push(d);i+=p});const n=i.indexOf(r);if(n===-1)return o;const c=l[n],h=l[n+r.length-1]+1;return{before:a.slice(0,c).join(""),match:a.slice(c,h).join(""),after:a.slice(h).join("")}},D=({title:e,query:t})=>{const{before:o,match:r,after:a}=J(e,t);return s.jsxs(s.Fragment,{children:[o!==""&&s.jsx("span",{className:"dialog-search-muted",children:o}),s.jsx("span",{className:"dialog-search-match",children:r}),a!==""&&s.jsx("span",{className:"dialog-search-muted",children:a})]})},R=({amount:e,currencyCode:t},o)=>t===void 0?new Intl.NumberFormat(o).format(Number(e)):new Intl.NumberFormat(o,{style:"currency",currency:t}).format(Number(e)),ee=(e,t)=>{if(e===void 0)return"";try{return R(e.min,t)}catch{return""}},te=e=>{try{const{protocol:t}=new URL(e,window.location.href);return t==="http:"||t==="https:"?e:void 0}catch{return}},M=e=>e.url===void 0||e.url===""?void 0:te(e.url),I=e=>e.title??e.handle??e.objectID,T=({controller:e,hit:t,index:o,locale:r,query:a=""})=>{const l=u.useRef(null);u.useEffect(()=>{l.current!==null&&e.observeResult(l.current,o)},[e,t,o]);const i=d=>{const p=d.metaKey||d.ctrlKey||d.shiftKey||d.altKey;e.selectResult(o,{navigate:!p})&&d.preventDefault()},n=d=>{d.button===1&&e.selectResult(o,{navigate:!1})},c=ee(t.priceRange,r),h=M(t),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"dialog-search-product-thumb","aria-hidden":!0,children:t.imageUrl!==void 0&&t.imageUrl!==""&&s.jsx("img",{src:t.imageUrl,alt:"",loading:"lazy"})}),s.jsx("span",{className:"dialog-search-product-title",children:s.jsx(D,{title:I(t),query:a})}),c!==""&&s.jsx("span",{className:"dialog-search-product-price",children:c})]});return s.jsx("li",{ref:l,className:"dialog-search-card",children:h===void 0?s.jsx("div",{className:"dialog-search-product",children:f}):s.jsx("a",{className:"dialog-search-product",href:h,onClick:i,onAuxClick:n,children:f})})},se=()=>s.jsx("svg",{width:16,height:16,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),re=()=>s.jsx("svg",{width:12,height:12,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:s.jsx("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"})}),O=e=>(e??[]).flatMap(t=>{const o=M(t);return o===void 0?[]:[{collection:t,href:o}]}),oe=({collections:e,query:t,messages:o})=>{const r=O(e);return r.length===0?null:s.jsxs("aside",{className:"dialog-search-collections",children:[s.jsxs("div",{className:"dialog-search-section-head",children:[s.jsx("p",{className:"dialog-search-label",children:o.collectionsLabel}),s.jsx("span",{className:"dialog-search-count",children:o.collectionsCount(r.length)})]}),s.jsx("ul",{className:"dialog-search-collection-list",children:r.map(({collection:a,href:l})=>s.jsx("li",{children:s.jsxs("a",{className:"dialog-search-collection",href:l,children:[s.jsx("span",{className:"dialog-search-collection-thumb","aria-hidden":!0,children:a.imageUrl!==void 0&&a.imageUrl!==""&&s.jsx("img",{src:a.imageUrl,alt:"",loading:"lazy"})}),s.jsx("span",{className:"dialog-search-collection-title",children:s.jsx(D,{title:I(a),query:t})}),s.jsx("span",{className:"dialog-search-caret",children:s.jsx(re,{})})]})},a.objectID))})]})},ae=({controller:e,response:t,locale:o,messages:r})=>s.jsxs("section",{className:"dialog-search-products",children:[s.jsx("div",{className:"dialog-search-section-head",children:s.jsxs("p",{className:"dialog-search-label",children:[r.productsLabel,t.nbHits>0&&s.jsx("span",{className:"dialog-search-label-count",children:` · ${r.resultsCount(t.nbHits)}`})]})}),s.jsx("ul",{className:"dialog-search-results",children:t.hits.length===0?s.jsx("li",{className:"dialog-search-empty",role:"status",children:r.noResults}):t.hits.map((a,l)=>s.jsx(T,{controller:e,hit:a,index:l,locale:o,query:t.query},a.objectID))})]}),y=8,C=16,ne=200,ce=1440,le=(e,t)=>e.bottom>0&&e.top<t,ie=(e,t)=>{const o=Math.min(ce,t-2*C),r=e.left+e.width/2-o/2;return{left:Math.min(Math.max(r,C),t-C-o),width:o}},de=(e,t,o)=>{const r=o-e.bottom-y-C,a=e.top-y-C,l=ie(e,t);return r<ne&&a>r?{...l,bottom:o-e.top+y,maxHeight:Math.max(a,0)}:{...l,top:e.bottom+y,maxHeight:Math.max(r,0)}},ue=e=>{const t=e.trim().replace(/^#/,"");if(!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))return;const o=t.length<=4?[...t].map(r=>r+r).join(""):t;return[0,2,4].map(r=>Number.parseInt(o.slice(r,r+2),16))},he=e=>{const t=/^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);if(t!==null)return[t[1],t[2],t[3]].map(Number)},ge=e=>{if(typeof document>"u")return;const t=document.createElement("span");if(t.style.color=e,t.style.color==="")return;document.body.appendChild(t);const o=he(getComputedStyle(t).color);return t.remove(),o},fe=e=>ue(e)??ge(e),pe=e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},_=e=>{const t=fe(e);if(t===void 0)return;const[o,r,a]=t.map(pe);return .2126*o+.7152*r+.0722*a},be="#181825",ve="#ffffff",Ce="straight",w=.5,L={light:{panel:"#ffffff",side:"#fafbfc",text:"#111827","text-sec":"#6b7280",border:"#eceef2",hover:"#eef2f7",thumb:"#eef1f5"},dark:{panel:"#15171c",side:"#1b1e25",text:"#f3f4f6","text-sec":"#9ca3af",border:"#2b2f38",hover:"#242830",thumb:"#2b2f38"}},ye={rectangle:{"r-panel":"4px","r-item":"4px","r-thumb":"2px","r-btn":"4px"},"rectangle-rounded":{"r-panel":"16px","r-item":"10px","r-thumb":"8px","r-btn":"10px"}},S=e=>e===void 0||e.trim()===""?void 0:e.trim(),Se=e=>{const t=e===void 0?void 0:_(e);return t===void 0?"light":t<w?"dark":"light"},we=(e,t)=>{const o=_(e);return o===void 0?L[t].text:(t==="light"?o<w:o>=w)?e:L[t].text},Le=e=>{const t=Se(S(e==null?void 0:e.backgroundColor)),o=(e==null?void 0:e.ctaBorderType)===Ce?"rectangle":"rectangle-rounded",r=S(e==null?void 0:e.primaryColor)??be,a=S(e==null?void 0:e.fontFamily),l={...L[t],...ye[o],primary:r,accent:we(r,t),"cta-text":S(e==null?void 0:e.ctaTextColor)??ve,...a===void 0?{}:{font:a}};return Object.fromEntries(Object.entries(l).map(([i,n])=>[`--dso-${i}`,n]))},me=e=>{const t=u.useRef(null),[o,r]=u.useState(void 0),[a,l]=u.useState({width:0,height:0});return u.useLayoutEffect(()=>{if(!e)return;const i=()=>{const n=t.current;if(n===null)return;const c=n.previousElementSibling??n,{top:h,bottom:f,left:d,width:p}=c.getBoundingClientRect();l(g=>g.width===window.innerWidth&&g.height===window.innerHeight?g:{width:window.innerWidth,height:window.innerHeight}),r(g=>g!==void 0&&g.top===h&&g.bottom===f&&g.left===d&&g.width===p?g:{top:h,bottom:f,left:d,width:p})};return i(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e]),{anchorRef:t,rect:o,viewport:a}},Ne=(e,t)=>{const[o,r]=u.useState(!1),a=u.useRef(null),l=e.status!==v.SearchStatus.IDLE&&!o;return u.useEffect(()=>{r(!1)},[e.query]),u.useEffect(()=>{if(!l)return;const i=n=>{var p,g;const c=n.target;if(!(c instanceof Node))return;const h=(p=t.current)==null?void 0:p.previousElementSibling,f=((g=a.current)==null?void 0:g.contains(c))??!1,d=(h==null?void 0:h.contains(c))??!1;!f&&!d&&r(!0)};return document.addEventListener("pointerdown",i),()=>document.removeEventListener("pointerdown",i)},[l,t]),u.useEffect(()=>{var c;const i=(c=t.current)==null?void 0:c.previousElementSibling;if(i==null)return;const n=()=>r(!1);return i.addEventListener("focusin",n),()=>i.removeEventListener("focusin",n)},[t]),{isOpen:l,panelRef:a}},ke=e=>e instanceof v.DialogSearchError?`Search failed (${e.status}${e.code?` ${e.code}`:""}): ${e.message}`:"Search failed: network error. Check your connection and try again.",Pe=(e,t)=>{var p,g;const{controller:o,state:r,locale:a,seeAllHref:l}=e,{status:i,response:n}=r;if(i===v.SearchStatus.ERROR)return s.jsxs("div",{className:"dialog-search-error",children:[s.jsx("p",{role:"alert",className:"dialog-search-status dialog-search-status-error",children:ke(r.error)}),s.jsx("button",{type:"button",className:"dialog-search-retry",onClick:()=>o.retry(),children:t.retry})]});if(n===void 0)return s.jsx("p",{role:"status",className:"dialog-search-status",children:t.searching(r.query)});const c=((g=(p=r.sections)==null?void 0:p.collections)==null?void 0:g.hits)??[],h=O(c).length>0,f=l!==void 0&&n.nbHits>0,d=!f&&A(r);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`dialog-search-body${h?"":" dialog-search-body--no-collections"}`,children:[s.jsx(oe,{collections:c,query:n.query,messages:t}),s.jsx(ae,{controller:o,response:n,locale:a,messages:t})]}),(f||d)&&s.jsx("div",{className:"dialog-search-footer",children:f?s.jsxs("a",{className:"dialog-search-cta",href:l(n.query),children:[t.seeAllLabel(n.nbHits),s.jsx(se,{})]}):s.jsx(x,{controller:o,state:r,locale:a})})]})},Ee=e=>{const{state:t,locale:o,theme:r,layout:a="list"}=e,l=t.status!==v.SearchStatus.IDLE,{anchorRef:i,rect:n,viewport:c}=me(l),{isOpen:h,panelRef:f}=Ne(t,i),d=E(o),p=u.useMemo(()=>Le(r),[r]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:i}),h&&n!==void 0&&le(n,c.height)&&H.createPortal(s.jsx("div",{ref:f,className:`dialog-search-panel dialog-search-panel--${a}`,style:{...de(n,c.width,c.height),...p},children:Pe(e,d)}),document.body)]})},Ae={status:v.SearchStatus.IDLE,query:"",page:0},xe=e=>{const t=u.useRef(e);t.current=e;const o=u.useRef(void 0),r=u.useCallback(()=>{if(o.current===void 0){const{client:c,surface:h="search_page",...f}=t.current;o.current=v.createSearchController({search:(d,p)=>c.search(d,p),analytics:{surface:h,trackViewSearchResults:d=>c.trackViewSearchResults(d),trackSelectSearchResult:d=>c.trackSelectSearchResult(d)},...f})}return o.current},[]),a=u.useRef(void 0);a.current??(a.current={setQuery:c=>r().setQuery(c),submit:c=>r().submit(c),setPage:c=>r().setPage(c),retry:()=>r().retry(),observeResult:(c,h)=>r().observeResult(c,h),selectResult:(c,h)=>r().selectResult(c,h),subscribe:c=>r().subscribe(c),getState:()=>r().getState(),dispose:()=>{var c;(c=o.current)==null||c.dispose(),o.current=void 0}}),u.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"0.0.0-beta-20260929090414"});const c=r();return()=>{c.dispose(),o.current===c&&(o.current=void 0)}},[r]);const l=u.useCallback(c=>r().subscribe(c),[r]),i=u.useCallback(()=>r().getState(),[r]),n=u.useSyncExternalStore(l,i,()=>Ae);return{controller:a.current,state:n,theme:e.client.theme}};b.DialogInput=N,b.DialogProductBlock=W,b.DialogSearchBar=G,b.DialogSearchPagination=x,b.DialogSearchProductCard=T,b.DialogSearchResults=Ee,b.useDialogSearch=xe,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdialog/dialog-react",
3
- "version": "0.0.0-beta-20260922144524",
3
+ "version": "0.0.0-beta-20260929090414",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/dialog-react.umd.js",
@@ -19,14 +19,14 @@
19
19
  "dist"
20
20
  ],
21
21
  "peerDependencies": {
22
- "@askdialog/dialog-sdk": "0.0.0-beta-20260922144524",
22
+ "@askdialog/dialog-sdk": "0.0.0-beta-20260929090414",
23
23
  "react": "^19.0.0",
24
24
  "react-dom": "^19.0.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.2.7",
28
28
  "@types/react-dom": "^19.2.3",
29
- "@askdialog/dialog-sdk": "0.0.0-beta-20260922144524"
29
+ "@askdialog/dialog-sdk": "0.0.0-beta-20260929090414"
30
30
  },
31
31
  "author": "Dialog",
32
32
  "publishConfig": {