@magicx-eng/ai-autocomplete-react 0.56.0 → 0.57.1

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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END as rs,DATE_RANGE_META_START as ss,DEFAULT_OPTION_COUNT_UNIT as ls,dateCellMarks as ds,formatDate as cs,formatDateRange as ps,formatOptionCount as hs,formatPlace as us,formatTime as ms,isoDate as gs,LOCATION_META_KEY as fs,monthLabel as bs,optionCountLabel as ws,optionHasImage as vs,optionImageSources as xs,optionImageSrc as ys,optionLabel as ks,optionsShowLeadingVisuals as Cs,PRODUCT_PATH_PREFIX as Ss,parseDate as Ts,parseLooseDate as Ps,parseLooseDateRange as Is,parseTime as Es,productFromMatchedItem as As,productImageSources as Rs,productsFromCustomFields as Os,sanitizeOptionIconSvg as Ls,selectedRangeFor as zs,TIME_META_KEY as Ds,visibleDateRange as Ms,WEEKDAY_LABELS as Ns,withSkippedParams as Hs}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Go,useCallback as zt,useEffect as Dt,useImperativeHandle as Ko,useLayoutEffect as qo,useRef as Je}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
1
+ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END as ds,DATE_RANGE_META_START as cs,DEFAULT_OPTION_COUNT_UNIT as ps,dateCellMarks as hs,formatDate as us,formatDateRange as ms,formatOptionCount as gs,formatPlace as fs,formatTime as bs,isoDate as ws,LOCATION_META_KEY as vs,monthLabel as xs,optionCountLabel as ys,optionHasImage as ks,optionImageSources as Cs,optionImageSrc as Ss,optionLabel as Ts,optionsShowLeadingVisuals as Ps,PRODUCT_PATH_PREFIX as Is,parseDate as Es,parseLooseDate as As,parseLooseDateRange as Rs,parseTime as Os,productFromMatchedItem as Ls,productImageSources as zs,productsFromCustomFields as Ds,sanitizeOptionIconSvg as Ms,selectedRangeFor as Ns,TIME_META_KEY as Hs,visibleDateRange as Fs,WEEKDAY_LABELS as Bs,withSkippedParams as Ws}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as _o,useCallback as Dt,useEffect as Mt,useImperativeHandle as Vo,useLayoutEffect as Uo,useRef as at}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
2
2
  position: relative;
3
3
  /* Inherits the host page's font by default. Consumers can pin a specific
4
4
  font on the library via \`--aia-font-family: 'Custom Font'\` without
@@ -151,6 +151,54 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
151
151
  height: 100%;
152
152
  }
153
153
 
154
+ /* The chip's remove "\xD7" (\`showChipRemove\`). Deliberately quiet: a thin glyph
155
+ a little smaller than the text, at low opacity, that firms up on hover. Its
156
+ tap area is padded out past the glyph (a negative margin keeps the chip the
157
+ same width) so it is easy to hit without looking like a button. */
158
+ :where(.aia-input-IW-P-) span[class~="magicx-aia-segment-remove"] {
159
+ display: inline-block;
160
+ width: 0.62em;
161
+ height: 0.62em;
162
+ margin-left: 5px;
163
+ padding: 4px;
164
+ margin-top: -4px;
165
+ margin-bottom: -4px;
166
+ margin-right: -4px;
167
+ box-sizing: content-box;
168
+ vertical-align: -0.02em;
169
+ color: currentColor;
170
+ opacity: var(--aia-chip-remove-opacity, 0.32);
171
+ cursor: pointer;
172
+ user-select: none;
173
+ -webkit-user-select: none;
174
+ /* Safari: the caret cannot be placed inside it. */
175
+ -webkit-user-modify: read-only;
176
+ transition: opacity 120ms ease;
177
+ }
178
+
179
+ /* Only where a pointer can hover: a touch would leave it stuck firmed up. */
180
+ @media (hover: hover) {
181
+ :where(.aia-input-IW-P-) span[class~="magicx-aia-segment-remove"]:hover {
182
+ opacity: var(--aia-chip-remove-opacity-hover, 0.7);
183
+ }
184
+ }
185
+
186
+ :where(.aia-input-IW-P-) span[class~="magicx-aia-segment-remove"] svg {
187
+ display: block;
188
+ width: 100%;
189
+ height: 100%;
190
+ fill: none;
191
+ stroke: currentColor;
192
+ stroke-width: 1.3;
193
+ stroke-linecap: round;
194
+ }
195
+
196
+ /* By class: a page's \`svg path { fill: \u2026 }\` would beat the attribute-less path. */
197
+ :where(.aia-input-IW-P-) span[class~="magicx-aia-segment-remove"] svg path {
198
+ fill: none;
199
+ stroke: currentColor;
200
+ }
201
+
154
202
  /* The picked option's picture: a small rounded tile inline before the chip
155
203
  text, in place of the icon. It is an empty inline span whose left padding
156
204
  is the tile's width and whose background is the picture (set inline as
@@ -358,7 +406,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
358
406
  transition: none;
359
407
  }
360
408
  }
361
- `,document.head.appendChild(e)}var Ge={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};import{attachScrollArrow as Xi,attachViewportFit as Ji,containScroll as eo,dateFloorFor as to,destroyPanelMorph as ao,findMultiSelectDone as io,fitMultiSelectDone as oo,hasSkippablePill as no,isCalendarFormat as ro,labelTraditionalAutocomplete as so,panelMorphKey as lo,queryLive as co,settlePanelMorph as po,syncPanelHug as ho,uiStringsFor as uo}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as qe,useLayoutEffect as Et,useRef as $e,useState as mo}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
409
+ `,document.head.appendChild(e)}var Ue={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};import{attachScrollArrow as eo,attachViewportFit as to,containScroll as ao,dateFloorFor as io,destroyPanelMorph as oo,findMultiSelectDone as no,fitMultiSelectDone as ro,hasSkippablePill as so,isCalendarFormat as lo,labelTraditionalAutocomplete as co,panelMorphKey as po,queryLive as ho,settlePanelMorph as uo,syncPanelHug as mo,uiStringsFor as go}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ye,useLayoutEffect as At,useRef as Xe,useState as fo}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
362
410
  * Built-in appearance defaults \u2014 zero specificity via :where().
363
411
  * Consumer CSS always wins without !important.
364
412
  *
@@ -1546,7 +1594,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
1546
1594
  transition-delay: 0s;
1547
1595
  }
1548
1596
  }
1549
- `,document.head.appendChild(e)}var ve={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",multiDone:"aia-multiDone-y12U7"};import{cellDay as Da,cellIso as nt,dateCellMarks as Ma,isDimmedDay as Na,isoDate as Ha,monthLabel as Fa,visibleDateRange as Ba,WEEKDAY_LABELS as Wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Ga}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
1597
+ `,document.head.appendChild(e)}var we={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",multiDone:"aia-multiDone-y12U7"};import{cellDay as Na,cellIso as rt,dateCellMarks as Ha,isDimmedDay as Fa,isoDate as Ba,monthLabel as Wa,visibleDateRange as Ga,WEEKDAY_LABELS as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as qa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
1550
1598
 
1551
1599
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1552
1600
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1730,17 +1778,20 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
1730
1778
  }
1731
1779
 
1732
1780
  /* A day another answer already holds (the pickup date while the return date is
1733
- asked): a soft box for reference, lighter than the picked fill, and still
1734
- pickable. */
1781
+ asked): a filled box for reference, still pickable. The fill is mixed from
1782
+ the day's own text colour, not the streak tint, so it shows on a light panel
1783
+ and a dark one alike, whatever the theme sets. */
1735
1784
  .aia-reference-Q5bXf .aia-number-aoT01 {
1736
- background: var(--aia-date-reference-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.07));
1785
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
1786
+ background: var(--aia-date-reference-bg, color-mix(in srgb, currentColor 14%, transparent));
1787
+ font-weight: 500;
1737
1788
  }
1738
1789
 
1739
1790
  .aia-pressed-bEyyN .aia-number-aoT01 {
1740
1791
  opacity: 0.8;
1741
1792
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1742
1793
  }
1743
- `,document.head.appendChild(e)}var G={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",reference:"aia-reference-Q5bXf",pressed:"aia-pressed-bEyyN"};import{jsx as xe,jsxs as qt}from"react/jsx-runtime";var Ka=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function _t({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:m,onNextMonth:w}){let y=Ha(new Date),g=Ba({pendingStart:i.rangeStart,highlightedIso:nt(e[o]),selected:i.selectedRange,floor:i.floor});return qt("div",{className:G.datepicker,"data-aia-datepicker":"",children:[qt("div",{className:G.header,children:[xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:c=>c.preventDefault(),onClick:m,children:"\u2039"}),xe("span",{className:G.month,"data-aia-date-month":"","aria-live":"polite",children:Fa(a)}),xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:c=>c.preventDefault(),onClick:w,children:"\u203A"})]}),xe("div",{className:G.weekdays,"aria-hidden":"true",children:Wa.map((c,h)=>xe("span",{className:G.weekday,children:c},Ka[h]))}),xe("div",{className:G.grid,"data-aia-date-grid":"",children:e.map((c,h)=>xe(qa,{option:c,id:`${t}-option-${h}`,index:h,isHighlighted:h===o&&c.is_tappable,isToday:nt(c)===y,isPast:Na(nt(c),y,i.floor),marks:Ma(nt(c),{selectedIso:i.selectedIso,range:g,references:i.references}),onSelect:s,onHighlight:r,onUnhighlight:l},nt(c)??`pad-${h}`))})]})}function qa({option:e,id:o,index:t,isHighlighted:a,isToday:i,isPast:s,marks:r,onSelect:l,onHighlight:m,onUnhighlight:w}){let[y,g]=Ga(!1),c=Da(e);if(c==null)return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${G.cell} ${G.blank}`});let h=()=>{g(!0),l(e),setTimeout(()=>g(!1),170)},v=[G.cell,G.day,s?G.past:"",a?G.highlighted:"",i?G.today:"",r.inRange?G.inRange:"",r.selected?G.selected:"",r.reference?G.reference:"",y?G.pressed:""].filter(Boolean).join(" ");return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:v,onClick:h,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),h())},onMouseEnter:()=>m(t),onMouseLeave:w?()=>w(t):void 0,children:xe("span",{className:G.number,children:c})})}import{ATTRIBUTION_URL as _a,buildAttributionUrl as Va,getFooterHint as Ua,uiStringsFor as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ya,useState as ja}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1794
+ `,document.head.appendChild(e)}var q={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",reference:"aia-reference-Q5bXf",pressed:"aia-pressed-bEyyN"};import{jsx as ve,jsxs as Vt}from"react/jsx-runtime";var _a=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ut({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:m,onNextMonth:w}){let y=Ba(new Date),f=Ga({pendingStart:i.rangeStart,highlightedIso:rt(e[o]),selected:i.selectedRange,floor:i.floor});return Vt("div",{className:q.datepicker,"data-aia-datepicker":"",children:[Vt("div",{className:q.header,children:[ve("button",{type:"button",tabIndex:-1,className:q.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:c=>c.preventDefault(),onClick:m,children:"\u2039"}),ve("span",{className:q.month,"data-aia-date-month":"","aria-live":"polite",children:Wa(a)}),ve("button",{type:"button",tabIndex:-1,className:q.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:c=>c.preventDefault(),onClick:w,children:"\u203A"})]}),ve("div",{className:q.weekdays,"aria-hidden":"true",children:Ka.map((c,h)=>ve("span",{className:q.weekday,children:c},_a[h]))}),ve("div",{className:q.grid,"data-aia-date-grid":"",children:e.map((c,h)=>ve(Va,{option:c,id:`${t}-option-${h}`,index:h,isHighlighted:h===o&&c.is_tappable,isToday:rt(c)===y,isPast:Fa(rt(c),y,i.floor),marks:Ha(rt(c),{selectedIso:i.selectedIso,range:f,references:i.references}),onSelect:s,onHighlight:r,onUnhighlight:l},rt(c)??`pad-${h}`))})]})}function Va({option:e,id:o,index:t,isHighlighted:a,isToday:i,isPast:s,marks:r,onSelect:l,onHighlight:m,onUnhighlight:w}){let[y,f]=qa(!1),c=Na(e);if(c==null)return ve("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${q.cell} ${q.blank}`});let h=()=>{f(!0),l(e),setTimeout(()=>f(!1),170)},x=[q.cell,q.day,s?q.past:"",a?q.highlighted:"",i?q.today:"",r.inRange?q.inRange:"",r.selected?q.selected:"",r.reference?q.reference:"",y?q.pressed:""].filter(Boolean).join(" ");return ve("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:x,onClick:h,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),h())},onMouseEnter:()=>m(t),onMouseLeave:w?()=>w(t):void 0,children:ve("span",{className:q.number,children:c})})}import{ATTRIBUTION_URL as Ua,buildAttributionUrl as Qa,getFooterHint as Ya,uiStringsFor as ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $a,useState as Za}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
1744
1795
  display: flex;
1745
1796
  flex-wrap: wrap;
1746
1797
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1780,7 +1831,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
1780
1831
  .aia-cluster[data-justify="around"] {
1781
1832
  justify-content: space-around;
1782
1833
  }
1783
- `,document.head.appendChild(e)}import{jsx as Vt}from"react/jsx-runtime";function rt({gap:e,align:o="center",justify:t="start",noWrap:a=!1,inline:i=!1,className:s,children:r,...l}){let m=e?{"--aia-cluster-gap":e}:void 0,w={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":a||void 0,"data-inline":i||void 0,style:m,...l};return i?Vt("span",{...w,children:r}):Vt("div",{...w,children:r})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1834
+ `,document.head.appendChild(e)}import{jsx as Qt}from"react/jsx-runtime";function st({gap:e,align:o="center",justify:t="start",noWrap:a=!1,inline:i=!1,className:s,children:r,...l}){let m=e?{"--aia-cluster-gap":e}:void 0,w={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":a||void 0,"data-inline":i||void 0,style:m,...l};return i?Qt("span",{...w,children:r}):Qt("div",{...w,children:r})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1784
1835
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1785
1836
  room above the hint/branding row so the footer doesn't butt against the last
1786
1837
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1927,7 +1978,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
1927
1978
  justify-content: flex-end;
1928
1979
  }
1929
1980
  }
1930
- `,document.head.appendChild(e)}var Se={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as st,jsxs as xt}from"react/jsx-runtime";function Ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=Qa()}){let{key:a,hint:i}=Ua(e,o,t),[s,r]=ja(_a);return Ya(()=>{r(Va())},[]),st("footer",{className:Se.footer,"data-aia-footer":"",children:xt(rt,{justify:"between",noWrap:!0,className:Se.row,children:[xt(rt,{gap:"5px",className:Se.hintGroup,children:[st("kbd",{className:Se.key,children:a}),st("span",{className:Se.hint,children:i})]}),xt("a",{className:Se.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[st("span",{className:Se.brand,children:"AI"}),st("span",{className:Se.badge,children:"Autocomplete"})]})]})})}import{useEffect as Qt,useLayoutEffect as $a,useRef as ce}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
1981
+ `,document.head.appendChild(e)}var Ce={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as lt,jsxs as yt}from"react/jsx-runtime";function Yt({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=ja()}){let{key:a,hint:i}=Ya(e,o,t),[s,r]=Za(Ua);return $a(()=>{r(Qa())},[]),lt("footer",{className:Ce.footer,"data-aia-footer":"",children:yt(st,{justify:"between",noWrap:!0,className:Ce.row,children:[yt(st,{gap:"5px",className:Ce.hintGroup,children:[lt("kbd",{className:Ce.key,children:a}),lt("span",{className:Ce.hint,children:i})]}),yt("a",{className:Ce.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[lt("span",{className:Ce.brand,children:"AI"}),lt("span",{className:Ce.badge,children:"Autocomplete"})]})]})})}import{useEffect as jt,useLayoutEffect as Xa,useRef as le}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
1931
1982
  Angular copy). The three are kept identical by
1932
1983
  packages/vanilla/tests/render/locationFieldParity.test.ts. */
1933
1984
  .aia-location-6-fsr {
@@ -2061,7 +2112,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
2061
2112
  .aia-loadingBar-OLCr4:nth-child(3) {
2062
2113
  width: 60%;
2063
2114
  }
2064
- `,document.head.appendChild(e)}var K={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};import{jsx as ne,jsxs as Me}from"react/jsx-runtime";var Za=0;function lt(e){return e.getRootNode().activeElement??null}function $t(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Yt(e){if(!e.isContentEditable)return null;let o=$t(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function jt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=$t(e);if(!t)return;let a=o;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var Xa=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ne("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),ne("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Ja=Me("svg",{className:K.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[ne("circle",{cx:"11",cy:"11",r:"7"}),ne("path",{d:"m20 20-3.5-3.5"})]});function Zt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:m,onMove:w,onCommit:y,onFocusChange:g}){let c=ce(null),h=ce(null),v=ce(null),I=ce(null),W=ce(null),z=ce(!1),L=ce(!1),J=ce(!1),S=ce(!1),N=ce(i);N.current=i;let H=ce(g);H.current=g;let k=d=>{S.current=d,g(d)},_=()=>{let d=c.current;return d!=null&&lt(d)===d},ee=()=>{let d=h.current;if(!d)return;let P=lt(d);P instanceof HTMLElement&&P!==c.current&&P!==document.body&&!d.contains(P)&&(I.current=P,W.current=Yt(P))},V=d=>{let P=h.current;!P||!(d instanceof HTMLElement)||d===I.current||d===document.body||P.contains(d)||(I.current=d,W.current=Yt(d))},U=ce(null);U.current===null&&(U.current=`aia-location-${++Za}`);let A=`${U.current}-row-`;Qt(()=>{let d=c.current;d&&d.value!==e.query&&lt(d)!==d&&(d.value=e.query)},[e.query]),Qt(()=>{i&&(s&&!J.current&&(L.current=!1),J.current=s);let d=c.current;if(d){if(!r&&_()){L.current=!0,D();return}if(!i){setTimeout(()=>{if(N.current)return;let P=I.current;P&&lt(P)===P||(L.current=!1)},0);return}if(!(!s||L.current||!l||_())){if(ee(),k(!0),d.focus({preventScroll:!0}),!_()){L.current=!0,k(!1);return}d.value&&d.select()}}}),$a(()=>()=>{if(!S.current)return;let d=c.current,P=I.current;P?.isConnected&&d&&lt(d)===d&&(z.current=!0,jt(P,W.current),z.current=!1),S.current=!1,H.current(!1)},[]);let D=(d=!1)=>{d&&(L.current=!0);let P=I.current;P?.isConnected&&_()&&(z.current=!0,jt(P,W.current),z.current=!1),k(!1)},fe=e.query.trim(),pe=e.highlighted>=0&&e.highlighted<e.places.length?`${A}${e.highlighted}`:void 0,re=null;return e.places.length>0?re=e.places.map((d,P)=>Me("div",{id:`${A}${P}`,role:"option","aria-selected":P===e.highlighted,className:P===e.highlighted?`${K.row} ${K.highlighted}`:K.row,"data-aia-location-row":"","data-aia-index":P,onClick:()=>{l&&(D(!0),y(P))},children:[ne("span",{className:K.pin,children:Xa}),Me("span",{className:K.text,children:[ne("span",{className:K.name,children:d.name}),d.secondary&&ne("span",{className:K.secondary,children:d.secondary})]})]},d.id)):e.status==="loading"?re=Me("div",{className:K.loading,"data-aia-location-loading":"",children:[ne("span",{className:K.loadingBar}),ne("span",{className:K.loadingBar}),ne("span",{className:K.loadingBar})]}):fe&&(re=Me("div",{className:K.note,"data-aia-location-note":"",children:[e.status==="done"&&ne("span",{className:K.empty,children:t}),ne("span",{children:a})]})),Me("div",{ref:h,className:K.location,"data-aia-location":"",onMouseDown:d=>{!(d.target instanceof Node)||!v.current?.contains(d.target)||(d.stopPropagation(),ee(),k(!0))},children:[Me("label",{ref:v,className:K.field,children:[Ja,ne("input",{ref:c,type:"text",className:K.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:o,"aria-label":o,"aria-activedescendant":pe,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:d=>m(d.target.value),onFocus:d=>{V(d.relatedTarget),k(!0)},onBlur:()=>{z.current||(L.current=!0,k(!1))},onKeyDown:d=>{if(!d.nativeEvent.isComposing)switch(d.key){case"ArrowDown":case"ArrowUp":d.preventDefault(),w(d.key==="ArrowDown"?1:-1);return;case"Enter":if(d.preventDefault(),!l)return;D(!0),y();return;case"Escape":d.preventDefault(),d.stopPropagation(),L.current=!0,D();return;case"Backspace":if(d.currentTarget.value!=="")return;d.preventDefault(),L.current=!0,D();return}}})]}),ne("div",{className:K.results,"data-aia-location-results":"","aria-live":"polite",children:re})]})}import{isSmartSuggestion as ii,isTraditionalAutocompleteSuggestion as oi}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ei}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
2115
+ `,document.head.appendChild(e)}var U={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};import{jsx as ne,jsxs as De}from"react/jsx-runtime";var Ja=0;function dt(e){return e.getRootNode().activeElement??null}function Xt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function $t(e){if(!e.isContentEditable)return null;let o=Xt(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Zt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Xt(e);if(!t)return;let a=o;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var ei=De("svg",{className:U.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ne("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),ne("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),ti=De("svg",{className:U.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[ne("circle",{cx:"11",cy:"11",r:"7"}),ne("path",{d:"m20 20-3.5-3.5"})]});function Jt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:m,onMove:w,onCommit:y,onFocusChange:f}){let c=le(null),h=le(null),x=le(null),I=le(null),_=le(null),z=le(!1),R=le(!1),te=le(!1),S=le(!1),M=le(i);M.current=i;let F=le(f);F.current=f;let N=d=>{S.current=d,f(d)},B=()=>{let d=c.current;return d!=null&&dt(d)===d},T=()=>{let d=h.current;if(!d)return;let P=dt(d);P instanceof HTMLElement&&P!==c.current&&P!==document.body&&!d.contains(P)&&(I.current=P,_.current=$t(P))},V=d=>{let P=h.current;!P||!(d instanceof HTMLElement)||d===I.current||d===document.body||P.contains(d)||(I.current=d,_.current=$t(d))},Y=le(null);Y.current===null&&(Y.current=`aia-location-${++Ja}`);let E=`${Y.current}-row-`;jt(()=>{let d=c.current;d&&d.value!==e.query&&dt(d)!==d&&(d.value=e.query)},[e.query]),jt(()=>{i&&(s&&!te.current&&(R.current=!1),te.current=s);let d=c.current;if(d){if(!r&&B()){R.current=!0,K();return}if(!i){setTimeout(()=>{if(M.current)return;let P=I.current;P&&dt(P)===P||(R.current=!1)},0);return}if(!(!s||R.current||!l||B())){if(T(),N(!0),d.focus({preventScroll:!0}),!B()){R.current=!0,N(!1);return}d.value&&d.select()}}}),Xa(()=>()=>{if(!S.current)return;let d=c.current,P=I.current;P?.isConnected&&d&&dt(d)===d&&(z.current=!0,Zt(P,_.current),z.current=!1),S.current=!1,F.current(!1)},[]);let K=(d=!1)=>{d&&(R.current=!0);let P=I.current;P?.isConnected&&B()&&(z.current=!0,Zt(P,_.current),z.current=!1),N(!1)},de=e.query.trim(),ae=e.highlighted>=0&&e.highlighted<e.places.length?`${E}${e.highlighted}`:void 0,re=null;return e.places.length>0?re=e.places.map((d,P)=>De("div",{id:`${E}${P}`,role:"option","aria-selected":P===e.highlighted,className:P===e.highlighted?`${U.row} ${U.highlighted}`:U.row,"data-aia-location-row":"","data-aia-index":P,onClick:()=>{l&&(K(!0),y(P))},children:[ne("span",{className:U.pin,children:ei}),De("span",{className:U.text,children:[ne("span",{className:U.name,children:d.name}),d.secondary&&ne("span",{className:U.secondary,children:d.secondary})]})]},d.id)):e.status==="loading"?re=De("div",{className:U.loading,"data-aia-location-loading":"",children:[ne("span",{className:U.loadingBar}),ne("span",{className:U.loadingBar}),ne("span",{className:U.loadingBar})]}):de&&(re=De("div",{className:U.note,"data-aia-location-note":"",children:[e.status==="done"&&ne("span",{className:U.empty,children:t}),ne("span",{children:a})]})),De("div",{ref:h,className:U.location,"data-aia-location":"",onMouseDown:d=>{!(d.target instanceof Node)||!x.current?.contains(d.target)||(d.stopPropagation(),T(),N(!0))},children:[De("label",{ref:x,className:U.field,children:[ti,ne("input",{ref:c,type:"text",className:U.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:o,"aria-label":o,"aria-activedescendant":ae,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:d=>m(d.target.value),onFocus:d=>{V(d.relatedTarget),N(!0)},onBlur:()=>{z.current||(R.current=!0,N(!1))},onKeyDown:d=>{if(!d.nativeEvent.isComposing)switch(d.key){case"ArrowDown":case"ArrowUp":d.preventDefault(),w(d.key==="ArrowDown"?1:-1);return;case"Enter":if(d.preventDefault(),!l)return;K(!0),y();return;case"Escape":d.preventDefault(),d.stopPropagation(),R.current=!0,K();return;case"Backspace":if(d.currentTarget.value!=="")return;d.preventDefault(),R.current=!0,K();return}}})]}),ne("div",{className:U.results,"data-aia-location-results":"","aria-live":"polite",children:re})]})}import{isSmartSuggestion as ni,isTraditionalAutocompleteSuggestion as ri}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ai}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
2065
2116
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
2066
2117
  The border is kept as a 1px transparent line so the box stays the same size
2067
2118
  as it was when the outline was dashed. */
@@ -2219,7 +2270,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
2219
2270
  opacity: 0;
2220
2271
  }
2221
2272
  }
2222
- `,document.head.appendChild(e)}var ye={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",loadingOut:"aia-loadingOut-Aj9xO"};import{Fragment as ti,jsx as yt,jsxs as ai}from"react/jsx-runtime";var kt={selected:1,first:.7,next:.4,last:.2};function Xt({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let m=[ye.pill,a?ye.rounded:"",i?ye.skeleton:""].filter(Boolean).join(" ");return yt("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":i?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:m,style:{"--aia-pill-opacity":kt[o]},onMouseDown:w=>w.preventDefault(),onClick:i?void 0:l,disabled:i,children:s?ai(ti,{children:[yt("span",{className:`${ye.smartText} magicx-aia-smart-suggestion-text`,children:e}),yt("span",{className:`${ye.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ei}})]}):e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
2273
+ `,document.head.appendChild(e)}var xe={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",loadingOut:"aia-loadingOut-Aj9xO"};import{Fragment as ii,jsx as kt,jsxs as oi}from"react/jsx-runtime";var Ct={selected:1,first:.7,next:.4,last:.2};function ea({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let m=[xe.pill,a?xe.rounded:"",i?xe.skeleton:""].filter(Boolean).join(" ");return kt("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":i?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:m,style:{"--aia-pill-opacity":Ct[o]},onMouseDown:w=>w.preventDefault(),onClick:i?void 0:l,disabled:i,children:s?oi(ii,{children:[kt("span",{className:`${xe.smartText} magicx-aia-smart-suggestion-text`,children:e}),kt("span",{className:`${xe.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ai}})]}):e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
2223
2274
  position: relative;
2224
2275
  z-index: 1;
2225
2276
  pointer-events: auto;
@@ -2229,7 +2280,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
2229
2280
  align-items: center;
2230
2281
  vertical-align: middle;
2231
2282
  }
2232
- `,document.head.appendChild(e)}var Ct={list:"aia-list-qvLqO"};import{jsx as pt}from"react/jsx-runtime";var ni=[125,69];function Jt(e){return e===0?"first":e===1?"next":"last"}function ht({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?pt("span",{className:Ct.list,"data-aia-pill-list-loading":"",children:ni.map((r,l)=>pt("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${i?ye.rounded:""} ${ye.skeleton}`,style:{width:r,"--aia-pill-opacity":kt[Jt(l)]}},`skel-${r}`))}):pt("span",{className:Ct.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let m=!!a&&l===o;return pt(Xt,{label:r.text,state:m?"selected":Jt(l),selected:m,active:l===o,rounded:i,loading:s,smartSuggestion:ii(r),completionHeader:oi(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}import{attachProductRowWheel as ri,productImageSources as si,productImageSrc as li,productInitial as di,productPhotoFill as ci,uiStringsFor as pi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as St,useRef as ut,useState as mt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
2283
+ `,document.head.appendChild(e)}var St={list:"aia-list-qvLqO"};import{jsx as ht}from"react/jsx-runtime";var si=[125,69];function ta(e){return e===0?"first":e===1?"next":"last"}function ut({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?ht("span",{className:St.list,"data-aia-pill-list-loading":"",children:si.map((r,l)=>ht("span",{"data-aia-pill-skeleton":"",className:`${xe.pill} ${i?xe.rounded:""} ${xe.skeleton}`,style:{width:r,"--aia-pill-opacity":Ct[ta(l)]}},`skel-${r}`))}):ht("span",{className:St.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let m=!!a&&l===o;return ht(ea,{label:r.text,state:m?"selected":ta(l),selected:m,active:l===o,rounded:i,loading:s,smartSuggestion:ni(r),completionHeader:ri(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}import{attachProductRowWheel as li,productImageSources as di,productImageSrc as ci,productInitial as pi,productPhotoFill as hi,uiStringsFor as ui}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Tt,useRef as mt,useState as gt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
2233
2284
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
2234
2285
  theming one package sees the same result in the other.
2235
2286
 
@@ -2798,7 +2849,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
2798
2849
  .aia-card-JBGYT[data-aia-product-has-cart] {
2799
2850
  padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
2800
2851
  }
2801
- `,document.head.appendChild(e)}var q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};import{jsx as $,jsxs as je}from"react/jsx-runtime";function ea({products:e,listboxId:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s=!0,layout:r="row",imageFallback:l="image",strings:m=pi()}){let w=e.length>0,y=ut(null);if(St(()=>{let c=y.current;if(!(!w||!c))return ri(c)},[w]),!w)return null;let g=`${o}-products-label`;return je("section",{className:q.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":g,children:[$("div",{className:q.label,id:g,"data-aia-products-label":"",children:m.products}),$("div",{ref:y,className:q.row,"data-aia-products-row":"",children:e.map((c,h)=>$(hi,{product:c,id:`${o}-product-${h}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:l,soldOut:m.soldOut,addToCart:m.addToCart},c.id))})]})}function hi({product:e,id:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:r,soldOut:l,addToCart:m}){let w=!!a&&e.available!==!1,[y,g]=mt(null),c=v=>{v.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},h=v=>{v.metaKey||v.ctrlKey||v.shiftKey||v.altKey||v.button!==0||(v.preventDefault(),t(e))};return je("a",{id:o,className:q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":w?"":void 0,role:"option","aria-selected":!1,style:y?{"--aia-product-photo-fill-x":String(y.x),"--aia-product-photo-fill-y":String(y.y)}:void 0,href:e.url,tabIndex:s?0:-1,onClick:h,onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:c,children:[$(gi,{sources:si(e.imageUrl),title:e.title,fallback:r,onPhotoFill:g},li(e.imageUrl)??""),je("span",{className:q.body,children:[e.vendor?$("span",{className:q.vendor,children:e.vendor}):null,$("span",{className:q.title,children:e.title}),e.price?je("span",{className:q.price,children:[e.price,e.compareAtPrice?$("s",{className:q.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?$("span",{className:q.badge,children:l}):null]}),w&&a?$(mi,{product:e,label:`${m}: ${e.title}`,focusable:s,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:c},ui(e)):null]})}function ui(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(o=>o??"").join("\0")}function mi({product:e,label:o,focusable:t,onAddToCart:a,onFocus:i,onBlur:s}){let[r,l]=mt(null),m=ut(null),w=ut(e);w.current=e;let y=ut(!0);St(()=>(y.current=!0,()=>{y.current=!1}),[]);let g=h=>{m.current=h,y.current&&l(h)},c=h=>{if(h.preventDefault(),h.stopPropagation(),m.current==="adding")return;g("adding");let v;try{v=Promise.resolve(a(w.current))}catch(I){v=Promise.reject(I)}v.then(()=>g("added"),()=>g(null))};return $("span",{className:q.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":o,tabIndex:t?0:-1,onClick:c,onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||c(h)},onFocus:h=>{h.stopPropagation(),i()},onBlur:h=>{h.stopPropagation(),s(h)},children:je("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[$("path",{className:q.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),$("path",{className:q.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),$("path",{className:q.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),$("path",{className:q.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),$("circle",{className:q.cartGlyph,cx:"9",cy:"20",r:"1.3"}),$("circle",{className:q.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function gi({sources:e,title:o,fallback:t,onPhotoFill:a}){let[i,s]=mt(0),r=e[i],l=!!r,[m,w]=mt(null),y=!l&&t==="initial";return St(()=>()=>a(null),[a]),je("span",{className:q.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&m===r?"":void 0,children:[l?$("img",{className:q.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:g=>{w(r),a(ci(g.currentTarget.naturalWidth,g.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),s(g=>g+1)}}):null,y?di(o):null]})}import{isOptionsGridMobileViewport as Ri,measureOptionsGrid as Oi,needsOptionsGridMeasurement as Li,OPTIONS_GRID_MOBILE_QUERY as zi,optionEnterDelayMs as Di,optionsShowLeadingVisuals as Mi,planOptionsGrid as oa,releasePanelHug as Ni,sameOptionRows as Hi,syncPanelHug as Fi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Bi,useLayoutEffect as na,useRef as ra,useState as la}from"react";import{optionsGridTemplateColumns as fi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as bi,useRef as wi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
2852
+ `,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};import{jsx as X,jsxs as Ze}from"react/jsx-runtime";function aa({products:e,listboxId:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s=!0,layout:r="row",imageFallback:l="image",strings:m=ui()}){let w=e.length>0,y=mt(null);if(Tt(()=>{let c=y.current;if(!(!w||!c))return li(c)},[w]),!w)return null;let f=`${o}-products-label`;return Ze("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":f,children:[X("div",{className:Q.label,id:f,"data-aia-products-label":"",children:m.products}),X("div",{ref:y,className:Q.row,"data-aia-products-row":"",children:e.map((c,h)=>X(mi,{product:c,id:`${o}-product-${h}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:l,soldOut:m.soldOut,addToCart:m.addToCart},c.id))})]})}function mi({product:e,id:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:r,soldOut:l,addToCart:m}){let w=!!a&&e.available!==!1,[y,f]=gt(null),c=x=>{x.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},h=x=>{x.metaKey||x.ctrlKey||x.shiftKey||x.altKey||x.button!==0||(x.preventDefault(),t(e))};return Ze("a",{id:o,className:Q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":w?"":void 0,role:"option","aria-selected":!1,style:y?{"--aia-product-photo-fill-x":String(y.x),"--aia-product-photo-fill-y":String(y.y)}:void 0,href:e.url,tabIndex:s?0:-1,onClick:h,onKeyDown:x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:c,children:[X(bi,{sources:di(e.imageUrl),title:e.title,fallback:r,onPhotoFill:f},ci(e.imageUrl)??""),Ze("span",{className:Q.body,children:[e.vendor?X("span",{className:Q.vendor,children:e.vendor}):null,X("span",{className:Q.title,children:e.title}),e.price?Ze("span",{className:Q.price,children:[e.price,e.compareAtPrice?X("s",{className:Q.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?X("span",{className:Q.badge,children:l}):null]}),w&&a?X(fi,{product:e,label:`${m}: ${e.title}`,focusable:s,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:c},gi(e)):null]})}function gi(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(o=>o??"").join("\0")}function fi({product:e,label:o,focusable:t,onAddToCart:a,onFocus:i,onBlur:s}){let[r,l]=gt(null),m=mt(null),w=mt(e);w.current=e;let y=mt(!0);Tt(()=>(y.current=!0,()=>{y.current=!1}),[]);let f=h=>{m.current=h,y.current&&l(h)},c=h=>{if(h.preventDefault(),h.stopPropagation(),m.current==="adding")return;f("adding");let x;try{x=Promise.resolve(a(w.current))}catch(I){x=Promise.reject(I)}x.then(()=>f("added"),()=>f(null))};return X("span",{className:Q.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":o,tabIndex:t?0:-1,onClick:c,onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||c(h)},onFocus:h=>{h.stopPropagation(),i()},onBlur:h=>{h.stopPropagation(),s(h)},children:Ze("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[X("path",{className:Q.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),X("path",{className:Q.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),X("path",{className:Q.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),X("path",{className:Q.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),X("circle",{className:Q.cartGlyph,cx:"9",cy:"20",r:"1.3"}),X("circle",{className:Q.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function bi({sources:e,title:o,fallback:t,onPhotoFill:a}){let[i,s]=gt(0),r=e[i],l=!!r,[m,w]=gt(null),y=!l&&t==="initial";return Tt(()=>()=>a(null),[a]),Ze("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&m===r?"":void 0,children:[l?X("img",{className:Q.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:f=>{w(r),a(hi(f.currentTarget.naturalWidth,f.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),s(f=>f+1)}}):null,y?pi(o):null]})}import{isOptionsGridMobileViewport as Li,measureOptionsGrid as zi,needsOptionsGridMeasurement as Di,OPTIONS_GRID_MOBILE_QUERY as Mi,optionEnterDelayMs as Ni,optionsShowLeadingVisuals as Hi,planOptionsGrid as ra,releasePanelHug as Fi,sameOptionRows as Bi,syncPanelHug as Wi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Gi,useLayoutEffect as sa,useRef as la,useState as ca}from"react";import{optionsGridTemplateColumns as wi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as vi,useRef as xi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
2802
2853
  display: grid;
2803
2854
  grid-template-columns: repeat(
2804
2855
  auto-fit,
@@ -2842,7 +2893,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
2842
2893
  :where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
2843
2894
  max-height: var(--aia-grid-max-height, 120px);
2844
2895
  }
2845
- `,document.head.appendChild(e)}import{jsx as vi}from"react/jsx-runtime";function ta({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:m,className:w,children:y,...g}){let c=wi(null);bi(()=>{if(s===void 0)return;let v=c.current;v&&(v.scrollTop=0)},[s]);let h={"--aia-grid-min":e};return o&&(h["--aia-grid-max"]=o),t&&(h["--aia-grid-gap"]=t),i&&(h["--aia-grid-max-height"]=i),r&&(h.gridTemplateColumns=fi(r)),l&&(h.gridTemplateColumns=l),vi("div",{ref:v=>{c.current=v,m?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:h,...g,children:y})}import{formatOptionCount as xi,highlightParts as yi,isMultiSelectToggleTap as ki,OPTION_ENTER_DELAY_VAR as Ci,optionImageSources as Si,optionLabel as aa,sanitizeOptionIconSvg as Ti}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pi,useMemo as Ii,useRef as Ei,useState as gt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
2896
+ `,document.head.appendChild(e)}import{jsx as yi}from"react/jsx-runtime";function ia({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:m,className:w,children:y,...f}){let c=xi(null);vi(()=>{if(s===void 0)return;let x=c.current;x&&(x.scrollTop=0)},[s]);let h={"--aia-grid-min":e};return o&&(h["--aia-grid-max"]=o),t&&(h["--aia-grid-gap"]=t),i&&(h["--aia-grid-max-height"]=i),r&&(h.gridTemplateColumns=wi(r)),l&&(h.gridTemplateColumns=l),yi("div",{ref:x=>{c.current=x,m?.(x)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:h,...f,children:y})}import{formatOptionCount as ki,highlightParts as Ci,isMultiSelectToggleTap as Si,OPTION_ENTER_DELAY_VAR as Ti,optionImageSources as Pi,optionLabel as oa,sanitizeOptionIconSvg as Ii}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ei,useMemo as Ai,useRef as Ri,useState as ft}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
2846
2897
  position: relative;
2847
2898
  /* Clip, not visible: the entrance rise below runs on the inner content,
2848
2899
  and a transformed box extends its scroll container's scrollable area.
@@ -3362,7 +3413,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
3362
3413
  border-radius: 6px;
3363
3414
  font-size: 11px;
3364
3415
  }
3365
- `,document.head.appendChild(e)}var Z={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Ai,jsx as Te,jsxs as Tt}from"react/jsx-runtime";function ia({option:e,isHighlighted:o,checked:t,onSelect:a,onHighlight:i,onUnhighlight:s,id:r,loading:l,showIcon:m=!0,showImage:w=!0,showCount:y=!0,scrollHint:g,enterDelayMs:c=0}){let[h]=gt(c),[v,I]=gt(!1),W=w?Si(e.image_url):[],z=W[0]??null,[L,J]=gt([]),S=W.find(A=>!L.includes(A))??null,[N,H]=gt(null),k=Ii(()=>!z&&m&&e.icon_svg?Ti(e.icon_svg):null,[z,m,e.icon_svg]),_=y?xi(e.item_count):null,ee=Ei(void 0);Pi(()=>()=>clearTimeout(ee.current),[]);let V=A=>{if(l||!e.is_tappable||v&&t===void 0)return;I(!0);let D=A?.currentTarget;t!==void 0&&D!==void 0&&A!==void 0&&!ki(D,D.querySelector("[data-aia-checkbox]"),A)?a(e,{commit:!0}):a(e),clearTimeout(ee.current),ee.current=setTimeout(()=>I(!1),170)},U=[Z.item,o&&!l?Z.highlighted:"",e.liveMatch&&!l?Z.liveMatch:"",e.is_tappable?Z.tappable:Z.nonTappable,v?Z.pressed:"",g?Z.scrollHint:""].filter(Boolean).join(" ");return Te("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":k&&e.icon?e.icon:void 0,"data-aia-image":z?"":void 0,"data-aia-item-count":_!==null?e.item_count:void 0,"aria-selected":t??o,className:U,style:{[Ci]:`${h}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:V,onKeyDown:A=>{!l&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),V())},onMouseEnter:!l&&e.is_tappable?i:void 0,onMouseLeave:s,children:Tt("span",{className:Z.content,children:[t!==void 0&&e.is_tappable&&Te("span",{className:Z.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),z&&Te("span",{className:`${Z.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":S!==null&&N===S?"":void 0,children:Te("img",{src:S??z,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onLoad:()=>H(S),onError:()=>{S!==null&&J(A=>[...A,S])}})}),k&&Te("span",{className:`${Z.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:k}}),Tt("span",{className:Z.text,children:[e.matchedText?yi(aa(e),e.matchedText).map((A,D)=>A.bold?Te("strong",{className:`${Z.match} magicx-aia-option-match`,children:A.text},D):A.text):aa(e),e.parameterLabel&&Tt(Ai,{children:[" ",Te("span",{className:`${Z.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Te("span",{className:Z.tag,children:e.tag}),_!==null&&Te("span",{className:`${Z.count} magicx-aia-option-count`,children:_})]})})}import{jsx as sa}from"react/jsx-runtime";function Wi(){let[e,o]=la(Ri);return Bi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(zi),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function da({options:e,activeIndex:o,picked:t,onSelect:a,onHighlight:i,onUnhighlight:s,listboxId:r,loading:l,groupKey:m="",optionsPosition:w="below",showIcons:y=!0,showImages:g=!0,showCounts:c=!0}){let h=Wi(),v=ra(null),[I,W]=la(null),z=ra(null);na(()=>{if(l&&Hi(z.current,e))return;z.current=l?null:e;let S=v.current,N=S&&!l&&Li(e.length,h),H=S?.closest("[data-aia-dropdown]");N&&H&&Ni(H);let k=N?Oi(S):null;W(k?oa(e.length,h,k.rowWidths,k.gridWidth):null)},[e,h,l]);let L=I??oa(e.length,h,null,null);na(()=>{let S=v.current?.closest("[data-aia-dropdown]");S&&Fi(S)},[L.template,h]);let J=Mi(e,y,g);return sa(ta,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:m,template:L.template,maxHeight:L.maxHeight,innerRef:S=>{v.current=S},"data-aia-group":m,children:e.map((S,N)=>sa(ia,{option:S,isHighlighted:N===o,checked:t?t.includes(S.text):void 0,onSelect:a,onHighlight:()=>i(N),onUnhighlight:s?()=>s(N):void 0,id:`${r}-option-${N}`,loading:l,showIcon:y&&J,showImage:g&&J,showCount:c,scrollHint:!l&&L.scrollHintIndices.includes(N),enterDelayMs:l?0:Di(N,L.cols,e.length,w)},`${m}\0${S.text}`))})}import{formatTime as Gi,TIME_WHEEL_COLUMNS as Ki,TIME_WHEEL_ROW_HEIGHT as qi,timeWheelIndex as ca,timeWheelIndexFromScroll as _i,timeWheelRows as Vi,withTimeWheelIndex as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as Ui,useEffect as Qi,useLayoutEffect as Yi,useRef as ft}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
3416
+ `,document.head.appendChild(e)}var J={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Oi,jsx as Se,jsxs as Pt}from"react/jsx-runtime";function na({option:e,isHighlighted:o,checked:t,onSelect:a,onHighlight:i,onUnhighlight:s,id:r,loading:l,showIcon:m=!0,showImage:w=!0,showCount:y=!0,scrollHint:f,enterDelayMs:c=0}){let[h]=ft(c),[x,I]=ft(!1),_=w?Pi(e.image_url):[],z=_[0]??null,[R,te]=ft([]),S=_.find(E=>!R.includes(E))??null,[M,F]=ft(null),N=Ai(()=>!z&&m&&e.icon_svg?Ii(e.icon_svg):null,[z,m,e.icon_svg]),B=y?ki(e.item_count):null,T=Ri(void 0);Ei(()=>()=>clearTimeout(T.current),[]);let V=E=>{if(l||!e.is_tappable||x&&t===void 0)return;I(!0);let K=E?.currentTarget;t!==void 0&&K!==void 0&&E!==void 0&&!Si(K,K.querySelector("[data-aia-checkbox]"),E)?a(e,{commit:!0}):a(e),clearTimeout(T.current),T.current=setTimeout(()=>I(!1),170)},Y=[J.item,o&&!l?J.highlighted:"",e.liveMatch&&!l?J.liveMatch:"",e.is_tappable?J.tappable:J.nonTappable,x?J.pressed:"",f?J.scrollHint:""].filter(Boolean).join(" ");return Se("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":N&&e.icon?e.icon:void 0,"data-aia-image":z?"":void 0,"data-aia-item-count":B!==null?e.item_count:void 0,"aria-selected":t??o,className:Y,style:{[Ti]:`${h}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:V,onKeyDown:E=>{!l&&e.is_tappable&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),V())},onMouseEnter:!l&&e.is_tappable?i:void 0,onMouseLeave:s,children:Pt("span",{className:J.content,children:[t!==void 0&&e.is_tappable&&Se("span",{className:J.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),z&&Se("span",{className:`${J.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":S!==null&&M===S?"":void 0,children:Se("img",{src:S??z,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onLoad:()=>F(S),onError:()=>{S!==null&&te(E=>[...E,S])}})}),N&&Se("span",{className:`${J.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:N}}),Pt("span",{className:J.text,children:[e.matchedText?Ci(oa(e),e.matchedText).map((E,K)=>E.bold?Se("strong",{className:`${J.match} magicx-aia-option-match`,children:E.text},K):E.text):oa(e),e.parameterLabel&&Pt(Oi,{children:[" ",Se("span",{className:`${J.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Se("span",{className:J.tag,children:e.tag}),B!==null&&Se("span",{className:`${J.count} magicx-aia-option-count`,children:B})]})})}import{jsx as da}from"react/jsx-runtime";function Ki(){let[e,o]=ca(Li);return Gi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Mi),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function pa({options:e,activeIndex:o,picked:t,onSelect:a,onHighlight:i,onUnhighlight:s,listboxId:r,loading:l,groupKey:m="",optionsPosition:w="below",showIcons:y=!0,showImages:f=!0,showCounts:c=!0}){let h=Ki(),x=la(null),[I,_]=ca(null),z=la(null);sa(()=>{if(l&&Bi(z.current,e))return;z.current=l?null:e;let S=x.current,M=S&&!l&&Di(e.length,h),F=S?.closest("[data-aia-dropdown]");M&&F&&Fi(F);let N=M?zi(S):null;_(N?ra(e.length,h,N.rowWidths,N.gridWidth):null)},[e,h,l]);let R=I??ra(e.length,h,null,null);sa(()=>{let S=x.current?.closest("[data-aia-dropdown]");S&&Wi(S)},[R.template,h]);let te=Hi(e,y,f);return da(ia,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:m,template:R.template,maxHeight:R.maxHeight,innerRef:S=>{x.current=S},"data-aia-group":m,children:e.map((S,M)=>da(na,{option:S,isHighlighted:M===o,checked:t?t.includes(S.text):void 0,onSelect:a,onHighlight:()=>i(M),onUnhighlight:s?()=>s(M):void 0,id:`${r}-option-${M}`,loading:l,showIcon:y&&te,showImage:f&&te,showCount:c,scrollHint:!l&&R.scrollHintIndices.includes(M),enterDelayMs:l?0:Ni(M,R.cols,e.length,w)},`${m}\0${S.text}`))})}import{formatTime as qi,TIME_WHEEL_COLUMNS as _i,TIME_WHEEL_ROW_HEIGHT as Vi,timeWheelIndex as ha,timeWheelIndexFromScroll as Ui,timeWheelRows as Qi,withTimeWheelIndex as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as Yi,useEffect as ji,useLayoutEffect as $i,useRef as bt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
3366
3417
 
3367
3418
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
3368
3419
  time-wheel.component.css). Only the class-naming layer differs \u2014 the
@@ -3484,7 +3535,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
3484
3535
  .aia-done-llNY5:hover {
3485
3536
  background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
3486
3537
  }
3487
- `,document.head.appendChild(e)}var me={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};import{jsx as Ke,jsxs as Pt}from"react/jsx-runtime";var ji=120;function ha({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return Pt("div",{className:me.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[Ke("span",{className:me.value,"data-aia-time-value":"","aria-live":"polite",children:Gi(e.minutes)}),Pt("div",{className:me.columns,"aria-hidden":"true",children:[Ke("div",{className:me.band}),Ki.map(r=>Pt(Ui,{children:[r==="minute"&&Ke("span",{className:me.separator,children:":"}),Ke($i,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),Ke("button",{type:"button",tabIndex:-1,className:me.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function $i({column:e,minutes:o,interactive:t,onTimeChange:a}){let i=ft(null),s=ft(null),r=ft(null),l=ft({minutes:o,interactive:t,onTimeChange:a});l.current={minutes:o,interactive:t,onTimeChange:a};let m=ca(e,o);Yi(()=>{let g=i.current;if(!g||r.current)return;let c=m*qi;Math.abs(g.scrollTop-c)<1||(s.current=c,g.scrollTop=c)},[m]),Qi(()=>()=>{r.current&&clearTimeout(r.current)},[]);let w=()=>{r.current=null;let g=i.current,c=l.current;if(!g||!c.interactive)return;let h=_i(e,g.scrollTop);h!==ca(e,c.minutes)&&c.onTimeChange(pa(e,c.minutes,h))},y=()=>{let g=i.current;if(g){if(s.current!=null&&Math.abs(g.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(w,ji)}};return Ke("div",{ref:i,className:me.column,"data-aia-time-column":e,onScroll:y,children:Vi(e).map((g,c)=>Ke("div",{className:c===m?`${me.row} ${me.selected}`:me.row,"data-aia-time-row":"","data-aia-index":c,onClick:()=>{l.current.interactive&&a(pa(e,l.current.minutes,c))},children:g.label},g.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
3538
+ `,document.head.appendChild(e)}var ue={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};import{jsx as Qe,jsxs as It}from"react/jsx-runtime";var Zi=120;function ma({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return It("div",{className:ue.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[Qe("span",{className:ue.value,"data-aia-time-value":"","aria-live":"polite",children:qi(e.minutes)}),It("div",{className:ue.columns,"aria-hidden":"true",children:[Qe("div",{className:ue.band}),_i.map(r=>It(Yi,{children:[r==="minute"&&Qe("span",{className:ue.separator,children:":"}),Qe(Xi,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),Qe("button",{type:"button",tabIndex:-1,className:ue.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function Xi({column:e,minutes:o,interactive:t,onTimeChange:a}){let i=bt(null),s=bt(null),r=bt(null),l=bt({minutes:o,interactive:t,onTimeChange:a});l.current={minutes:o,interactive:t,onTimeChange:a};let m=ha(e,o);$i(()=>{let f=i.current;if(!f||r.current)return;let c=m*Vi;Math.abs(f.scrollTop-c)<1||(s.current=c,f.scrollTop=c)},[m]),ji(()=>()=>{r.current&&clearTimeout(r.current)},[]);let w=()=>{r.current=null;let f=i.current,c=l.current;if(!f||!c.interactive)return;let h=Ui(e,f.scrollTop);h!==ha(e,c.minutes)&&c.onTimeChange(ua(e,c.minutes,h))},y=()=>{let f=i.current;if(f){if(s.current!=null&&Math.abs(f.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(w,Zi)}};return Qe("div",{ref:i,className:ue.column,"data-aia-time-column":e,onScroll:y,children:Qi(e).map((f,c)=>Qe("div",{className:c===m?`${ue.row} ${ue.selected}`:ue.row,"data-aia-time-row":"","data-aia-index":c,onClick:()=>{l.current.interactive&&a(ua(e,l.current.minutes,c))},children:f.label},f.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
3488
3539
  display: flex;
3489
3540
  flex-direction: column;
3490
3541
  gap: var(--aia-stack-space, 0.5rem);
@@ -3499,7 +3550,7 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
3499
3550
  align-items: end;
3500
3551
  }
3501
3552
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
3502
- `,document.head.appendChild(e)}import{jsx as Zi}from"react/jsx-runtime";function ua({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Zi("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as te,jsxs as It}from"react/jsx-runtime";var go=typeof window>"u"?qe:Et,fo=[159,119,164],bo=()=>{},ma=()=>{},wo=e=>{},vo=()=>{},xo=e=>{},yo=e=>{},ko=e=>{},Co=e=>{};function So(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=mo(o);if(qe(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>a(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function To(e,o){let t=$e(null);qe(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=co(a,".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:Xi({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),qe(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Po(e,o){let t=$e(o);t.current=o;let a=$e(null);Et(()=>{let i=e.current;if(i){if(!a.current){a.current=Ji({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),qe(()=>()=>{a.current?.destroy(),a.current=null},[])}function At({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:m,onPillClick:w,showPills:y=!0,onSkip:g,showSkipButton:c=!0,showOptionIcons:h=!0,showOptionImages:v=!0,showOptionCounts:I=!0,skipDisabled:W=!1,activeSelected:z=!1,isLoading:L=!1,skeletonExiting:J=!1,isInputEmpty:S=!1,language:N,products:H,onProductSelect:k,onProductAddToCart:_,onProductFocusChange:ee,productsLayout:V="row",productImageFallback:U="image",formatType:A="options",dateView:D=null,selectedDateIso:fe=null,selectedDateRange:pe=null,dateRangeStart:re=null,dateReferences:d,onPreviousMonth:P,onNextMonth:Pe,timeView:f=null,multiSelectView:Ne=null,onMultiSelectCommit:Ie,onTimeChange:Ee,onTimeCommit:Ae,locationView:u=null,isReediting:C=!1,onLocationQuery:T,onLocationMove:E,onLocationCommit:O,onLocationFocusChange:Y,isFocused:he=!1,optionsPosition:ae="below",mode:ke}){let He=So(ke),le=He!==void 0,ie=$e(null),_e=$e(null);To(ie,_e),qe(()=>{if(ie.current)return eo(ie.current)},[]);let Fe=e[0]?.options??[],be=!!(m&&m.length>0&&w),tt=!!(H&&H.length>0),Re=A==="time"&&f!=null,Oe=A==="location"&&u!=null,j=s&&(Fe.length>0||y&&be||L||tt||Re||Oe);Po(ie,j),go(()=>{let F=ie.current;F&&(oo(F,io(F)),ho(F))});let x={suggestions:e,activeIndex:o,pills:m,showPills:y,showSkipButton:c,showOptionIcons:h,showOptionImages:v,showOptionCounts:I,skipDisabled:W,activeSelected:z,isLoading:L,skeletonExiting:J,isInputEmpty:S,products:H,formatType:A,dateView:D,selectedDateIso:fe,selectedDateRange:pe,dateRangeStart:re,dateReferences:d,timeView:f,multiSelectView:Ne,locationView:u,isReediting:C},Ve=$e(x);j&&(Ve.current=x);let n=j?x:Ve.current,Q=uo(N),b=n.suggestions[0],de=b?.options??[],at=n.activeIndex>=0&&!!de[n.activeIndex]?.is_tappable,se=so(n.pills??[],Q.keepTyping),Le=!!(se.length>0&&w),Ue=n.showPills&&Le,ze=n.showPills&&!Le&&n.isLoading,Qe=Ue||ze,ue=Le&&no(se)&&n.showSkipButton&&!n.isInputEmpty&&!!g,we=se[0]?.text,De=ro(n.formatType)&&n.dateView!=null,Be=de.length>0&&!De,Ye=de.length>0&&De&&!n.isLoading,Ce=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,We=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,p=n.isLoading&&!Be&&!Ye&&!Ce&&!We,B=n.products??[],R=lo(Ue?se:[]);return Et(()=>{ie.current&&po(ie.current,R,{visible:j,anchorBottom:ae==="above"})},[R,j,ae,n.suggestions,n.pills,n.isLoading,n.skeletonExiting,n.isInputEmpty,n.products,n.formatType,n.dateView,n.selectedDateIso,n.selectedDateRange,n.dateRangeStart,n.dateReferences,n.timeView,n.multiSelectView,n.locationView,n.showPills,n.showSkipButton,n.showOptionIcons,n.showOptionImages,n.showOptionCounts,V,N]),qe(()=>{let F=ie.current;return()=>{F&&ao(F)}},[]),It("div",{ref:ie,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":ae,"data-mode":He,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":B.length>0?"":void 0,className:`${le?"magicx-aia ":""}${ve.dropdown} ${j?ve.visible:""} ${l??""}`,onMouseDown:F=>F.preventDefault(),children:[It(ua,{space:"8px",children:[(Qe||ue)&&It(rt,{noWrap:!0,className:ve.pillBar,"data-aia-pillbar":"",children:[Qe&&te("span",{className:ve.pillScroll,"data-aia-pill-scroll":"",children:te(ht,{pills:se,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:n.isLoading})}),ue&&te("button",{type:"button",tabIndex:-1,className:ve.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":we?`${Q.skipLabel} ${we}`:Q.skipLabel,onClick:g,children:Q.skip})]}),Be&&te(da,{options:de,activeIndex:n.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:r,loading:n.isLoading,groupKey:b?`${b.parameter} ${b.text}`:"",optionsPosition:ae,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.isLoading?void 0:n.multiSelectView?.picked}),n.multiSelectView&&!n.isLoading&&te("div",{"data-aia-multi-actions":"",onClick:F=>{F.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&Ie?.()},children:te("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:ve.multiDone,ref:F=>{F&&(F.disabled=!0,F.offsetHeight,F.disabled=n.skipDisabled)},children:Q.done})}),Ye&&n.dateView&&te(_t,{options:de,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:to(n.formatType,n.dateRangeStart),references:n.dateReferences??[]},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:P??ma,onNextMonth:Pe??ma}),Ce&&n.timeView&&te(ha,{view:n.timeView,label:Q.timeLabel,doneLabel:Q.done,interactive:!n.skipDisabled,onTimeChange:Ee??wo,onTimeCommit:Ae??vo}),We&&n.locationView&&te(Zt,{view:n.locationView,searchLabel:Q.locationSearch,noResultsLabel:Q.locationNoResults,useTypedLabel:Q.locationUseTyped,widgetFocused:he&&j,reediting:n.isReediting,visible:j,interactive:!n.skipDisabled,onQuery:T??xo,onMove:E??yo,onCommit:O??ko,onFocusChange:Y??Co}),p&&te("div",{className:ve.skeletonBars,"data-aia-skeleton-bars":"",children:fo.map(F=>te("span",{className:ve.skeletonBar,style:{width:F}},`bar-${F}`))}),te(ea,{products:B,listboxId:r,onSelect:k??bo,onAddToCart:_,onFocusChange:ee,focusable:j,layout:V,imageFallback:U,strings:Q}),te(Ut,{isOptionHighlighted:at,isInputEmpty:n.isInputEmpty,strings:Q})]}),te("button",{ref:_e,type:"button",tabIndex:-1,className:ve.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Q.scrollArrow,"aria-hidden":"true",children:te("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:te("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as _o,ModeController as Vo,setCursorOffset as Uo,uiStringsFor as Qo,watchEditorHeight as Yo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Io}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
3553
+ `,document.head.appendChild(e)}import{jsx as Ji}from"react/jsx-runtime";function ga({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Ji("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as ie,jsxs as Et}from"react/jsx-runtime";var bo=typeof window>"u"?Ye:At,wo=[159,119,164],vo=()=>{},fa=()=>{},xo=e=>{},yo=()=>{},ko=e=>{},Co=e=>{},So=e=>{},To=e=>{};function Po(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=fo(o);if(Ye(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>a(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Io(e,o){let t=Xe(null);Ye(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=ho(a,".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:eo({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),Ye(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Eo(e,o){let t=Xe(o);t.current=o;let a=Xe(null);At(()=>{let i=e.current;if(i){if(!a.current){a.current=to({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Ye(()=>()=>{a.current?.destroy(),a.current=null},[])}function Rt({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:m,onPillClick:w,showPills:y=!0,onSkip:f,showSkipButton:c=!0,showOptionIcons:h=!0,showOptionImages:x=!0,showOptionCounts:I=!0,skipDisabled:_=!1,activeSelected:z=!1,isLoading:R=!1,skeletonExiting:te=!1,isInputEmpty:S=!1,language:M,products:F,onProductSelect:N,onProductAddToCart:B,onProductFocusChange:T,productsLayout:V="row",productImageFallback:Y="image",formatType:E="options",dateView:K=null,selectedDateIso:de=null,selectedDateRange:ae=null,dateRangeStart:re=null,dateReferences:d,onPreviousMonth:P,onNextMonth:Te,timeView:g=null,multiSelectView:Me=null,onMultiSelectCommit:Pe,onTimeChange:Ie,onTimeCommit:Ee,locationView:ye=null,isReediting:Ae=!1,onLocationQuery:u,onLocationMove:k,onLocationCommit:C,onLocationFocusChange:A,isFocused:O=!1,optionsPosition:W="below",mode:ce}){let pe=Po(ce),ge=pe!==void 0,j=Xe(null),Ne=Xe(null);Io(j,Ne),Ye(()=>{if(j.current)return ao(j.current)},[]);let He=e[0]?.options??[],Fe=!!(m&&m.length>0&&w),Re=!!(F&&F.length>0),Be=E==="time"&&g!=null,We=E==="location"&&ye!=null,Z=s&&(He.length>0||y&&Fe||R||Re||Be||We);Eo(j,Z),bo(()=>{let H=j.current;H&&(ro(H,no(H)),mo(H))});let v={suggestions:e,activeIndex:o,pills:m,showPills:y,showSkipButton:c,showOptionIcons:h,showOptionImages:x,showOptionCounts:I,skipDisabled:_,activeSelected:z,isLoading:R,skeletonExiting:te,isInputEmpty:S,products:F,formatType:E,dateView:K,selectedDateIso:de,selectedDateRange:ae,dateRangeStart:re,dateReferences:d,timeView:g,multiSelectView:Me,locationView:ye,isReediting:Ae},Ge=Xe(v);Z&&(Ge.current=v);let n=Z?v:Ge.current,$=go(M),b=n.suggestions[0],fe=b?.options??[],Ke=n.activeIndex>=0&&!!fe[n.activeIndex]?.is_tappable,se=co(n.pills??[],$.keepTyping),Oe=!!(se.length>0&&w),qe=n.showPills&&Oe,Le=n.showPills&&!Oe&&n.isLoading,je=qe||Le,he=Oe&&so(se)&&n.showSkipButton&&!n.isInputEmpty&&!!f,be=se[0]?.text,ze=lo(n.formatType)&&n.dateView!=null,_e=fe.length>0&&!ze,$e=fe.length>0&&ze&&!n.isLoading,ke=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,Ve=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,p=n.isLoading&&!_e&&!$e&&!ke&&!Ve,G=n.products??[],L=po(qe?se:[]);return At(()=>{j.current&&uo(j.current,L,{visible:Z,anchorBottom:W==="above"})},[L,Z,W,n.suggestions,n.pills,n.isLoading,n.skeletonExiting,n.isInputEmpty,n.products,n.formatType,n.dateView,n.selectedDateIso,n.selectedDateRange,n.dateRangeStart,n.dateReferences,n.timeView,n.multiSelectView,n.locationView,n.showPills,n.showSkipButton,n.showOptionIcons,n.showOptionImages,n.showOptionCounts,V,M]),Ye(()=>{let H=j.current;return()=>{H&&oo(H)}},[]),Et("div",{ref:j,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":W,"data-mode":pe,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":G.length>0?"":void 0,className:`${ge?"magicx-aia ":""}${we.dropdown} ${Z?we.visible:""} ${l??""}`,onMouseDown:H=>H.preventDefault(),children:[Et(ga,{space:"8px",children:[(je||he)&&Et(st,{noWrap:!0,className:we.pillBar,"data-aia-pillbar":"",children:[je&&ie("span",{className:we.pillScroll,"data-aia-pill-scroll":"",children:ie(ut,{pills:se,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:n.isLoading})}),he&&ie("button",{type:"button",tabIndex:-1,className:we.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":be?`${$.skipLabel} ${be}`:$.skipLabel,onClick:f,children:$.skip})]}),_e&&ie(pa,{options:fe,activeIndex:n.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:r,loading:n.isLoading,groupKey:b?`${b.parameter} ${b.text}`:"",optionsPosition:W,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.isLoading?void 0:n.multiSelectView?.picked}),n.multiSelectView&&!n.isLoading&&ie("div",{"data-aia-multi-actions":"",onClick:H=>{H.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&Pe?.()},children:ie("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:we.multiDone,ref:H=>{H&&(H.disabled=!0,H.offsetHeight,H.disabled=n.skipDisabled)},children:$.done})}),$e&&n.dateView&&ie(Ut,{options:fe,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:io(n.formatType,n.dateRangeStart),references:n.dateReferences??[]},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:P??fa,onNextMonth:Te??fa}),ke&&n.timeView&&ie(ma,{view:n.timeView,label:$.timeLabel,doneLabel:$.done,interactive:!n.skipDisabled,onTimeChange:Ie??xo,onTimeCommit:Ee??yo}),Ve&&n.locationView&&ie(Jt,{view:n.locationView,searchLabel:$.locationSearch,noResultsLabel:$.locationNoResults,useTypedLabel:$.locationUseTyped,widgetFocused:O&&Z,reediting:n.isReediting,visible:Z,interactive:!n.skipDisabled,onQuery:u??ko,onMove:k??Co,onCommit:C??So,onFocusChange:A??To}),p&&ie("div",{className:we.skeletonBars,"data-aia-skeleton-bars":"",children:wo.map(H=>ie("span",{className:we.skeletonBar,style:{width:H}},`bar-${H}`))}),ie(aa,{products:G,listboxId:r,onSelect:N??vo,onAddToCart:B,onFocusChange:T,focusable:Z,layout:V,imageFallback:Y,strings:$}),ie(Yt,{isOptionHighlighted:Ke,isInputEmpty:n.isInputEmpty,strings:$})]}),ie("button",{ref:Ne,type:"button",tabIndex:-1,className:we.scrollArrow,"data-aia-scroll-arrow":"","aria-label":$.scrollArrow,"aria-hidden":"true",children:ie("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:ie("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Qo,ModeController as Yo,setCursorOffset as jo,uiStringsFor as $o,watchEditorHeight as Zo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Ao}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
3503
3554
  flex-shrink: 0;
3504
3555
  width: 32px;
3505
3556
  height: 32px;
@@ -3570,5 +3621,5 @@ import{buildSubmitResult as is,cellDay as os,cellIso as ns,DATE_RANGE_META_END a
3570
3621
  transition: none;
3571
3622
  }
3572
3623
  }
3573
- `,document.head.appendChild(e)}var ga={submitButton:"aia-submitButton-otz7H"};import{jsx as Rt}from"react/jsx-runtime";function fa({disabled:e,ready:o,onClick:t,label:a=Io().submit}){return Rt("button",{type:"button","data-aia-submit":"",className:ga.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Rt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Rt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Eo,dateSelectionFor as Ao,identifiedParamLabel as Ro,withoutTraditionalAutocomplete as Oo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ya,useEffect as Ze,useMemo as Lo,useRef as X,useState as zo}from"react";import{useRef as ba}from"react";function wa(e){let o=ba(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ba({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,m,w)=>{let y=o.current?.[s];return y?y(l,m,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as va}from"react";function xa(e){let o=va(e);o.current=e;let t=va(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ka={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function Ot({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,visitorId:y,columns:g=2,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:W,locationSearch:z,showOptionIcons:L,showOptionImages:J,showOptionCounts:S,showSkipButton:N,showProducts:H,productImageFallback:k="image",onFocus:_,onBlur:ee,value:V,completedParams:U,onChange:A,onParamsChange:D,products:fe,mapProducts:pe,onProductSelect:re,onProductAddToCart:d,source:P,setCursor:Pe}){let f=X(null),[Ne,Ie]=zo(null),Ee=X(e);Ee.current=e;let Ae=X(o);Ae.current=o;let u=X(t);u.current=t;let C=X(A);C.current=A;let T=X(D);T.current=D;let E=X(_);E.current=_;let O=X(ee);O.current=ee;let Y=X(Pe);Y.current=Pe;let he=X(re);he.current=re;let ae=X(d);ae.current=d;let ke=X(y);ke.current=y;let He=X(()=>{let p=ke.current;return typeof p=="function"?p():p}).current,le=xa(fe),ie=X(pe);ie.current=pe;let _e=X((p,B)=>{let R=ie.current;return R?R(p,B):p}).current,Fe=pe?_e:void 0,be=wa(a);Ze(()=>{if(typeof document>"u")return;let p=new Eo(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,visitorId:He,optionOverrides:be.overrides,maskCompletedText:i,columns:g,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:W,locationSearch:z,showProducts:H,source:P,value:V,completedParams:U,onSubmit:(...R)=>Ee.current?.(...R),onResult:(...R)=>Ae.current?.(...R),onError:(...R)=>u.current?.(...R),onChange:(...R)=>C.current?.(...R),onParamsChange:(...R)=>T.current?.(...R),onFocus:()=>E.current?.(),onBlur:()=>O.current?.(),onProductSelect:R=>he.current?.(R),onProductAddToCart:R=>ae.current?.(R),setCursor:R=>Y.current?.(R),products:le.config,mapProducts:Fe});f.current=p,Ie(p.getState());let B=p.subscribe(R=>Ie(R));return()=>{B(),p.destroy(),f.current===p&&(f.current=null)}},[]),Ze(()=>{V!==void 0&&f.current?.setValue(V)},[V]),Ze(()=>{U!==void 0&&f.current?.setCompletedParams(U)},[U]);let tt=JSON.stringify(s??null),Re;try{Re=JSON.stringify(r??null)}catch{Re="[unstringifiable]"}Ze(()=>{f.current?.update({apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,optionOverrides:be.overrides,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:W,locationSearch:z,showProducts:H})},[tt,Re,l,m?.code,m?.rate,m?.country,w,be.key,c,h,v,I,W,z,H]);let Oe=X(!1);Ze(()=>{if(!Oe.current){Oe.current=!0;return}f.current?.update({products:le.config})},[le.enabled]),Ze(()=>{f.current?.update({mapProducts:Fe})},[Fe]);let j=X(null);j.current===null&&(j.current={handleTextChange:p=>f.current?.handleTextChange(p),handleKeyDown:p=>{let B="nativeEvent"in p?p.nativeEvent:p;f.current?.handleKeyDown(B)},setFocused:p=>f.current?.setFocused(p),startEditingParam:p=>f.current?.startEditingParam(p),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:p=>f.current?.handleCaretAfterInput(p),handleCaretMove:p=>f.current?.handleCaretMove(p),replaceEditingRange:p=>f.current?.replaceEditingRange(p)??!1,setActivePill:p=>f.current?.setActivePill(p),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??ka,recordSubmit:p=>f.current?.recordSubmit(p),selectOption:(p,B)=>f.current?.selectOption(p,B),selectProduct:p=>f.current?.selectProduct(p),addProductToCart:p=>{let B=f.current;return!B||!ae.current?Promise.resolve():B.addProductToCart(p)},setActiveDropdownIndex:p=>f.current?.setActiveDropdownIndex(p),clearHighlight:p=>f.current?.clearHighlight(p),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:p=>f.current?.setTime(p),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:p=>f.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>f.current?.commitMultiSelect(),setLocationQuery:p=>f.current?.setLocationQuery(p),moveLocationHighlight:p=>f.current?.moveLocationHighlight(p),commitLocation:p=>f.current?.commitLocation(p),setLocationFieldFocused:p=>f.current?.setLocationFieldFocused(p),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let x=j.current,Ve=ya(p=>{let B=p.target.value,F=B.length>0&&!p.nativeEvent?.isComposing&&B[0]!==B[0].toUpperCase()?B[0].toUpperCase()+B.slice(1):B;f.current?.handleTextChange(F)},[]),n=ya(p=>{f.current?.handleKeyDown(p.nativeEvent)},[]),Q=f.current,b=Ne??ka,de=V!==void 0?V:b.text,at=U!==void 0?U:b.completedParams,se=b.actionableSuggestions,Le=se[0],Ue=Lo(()=>Oo(se),[se]),ze=Q?.listboxId??"",Qe=b.activeDropdownIndex>=0&&Q?`${ze}-option-${b.activeDropdownIndex}`:void 0,ue=b.editingParam,we=b.editingIdentified,De=ue?{parameter:ue.suggestionParameter,text:ue.suggestionPlaceholder,required:!0,options:ue.options}:we?{parameter:we.parameter,text:Ro(we.parameter),required:!0,options:[]}:null,Be=b.dropdownSuggestion??De??Le,Ye=De?[De]:se,Ce=Ao(b),We=!Q||b.dropdownLoading;return{completedParams:at,multiSelectView:b.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:Ue,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:x.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:We,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:ze,error:b.error,products:b.products,customFields:b.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:ue,editingIdentified:we,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:de,placeholder:b.placeholderText||void 0,onChange:Ve,onKeyDown:n,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":Qe,"aria-autocomplete":"list","aria-controls":ze},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:b.isDropdownOpen,id:ze,pills:Ye,activeSelected:b.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(N??!0)&&!ue&&!we,showOptionIcons:L??!0,showOptionImages:J??!0,showOptionCounts:S??!0,skipDisabled:b.inSelectionAnimation,isLoading:We,skeletonExiting:b.skeletonExiting,isInputEmpty:de.trim().length===0,language:l,products:b.products,productImageFallback:k,onProductSelect:x.selectProduct,onProductAddToCart:d?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,dateReferences:Ce.references,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:b.timeView,multiSelectView:b.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:b.locationView,isReediting:b.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:b.isFocused||b.locationFieldFocused,optionsPosition:h??"below"}}}import{cancelStartingHint as Do,chipIdFromTap as Mo,extractPlainText as Ca,getCursorOffset as Sa,keepCaretOnChip as No,plainTextLength as Ho,renderEditableContent as Fo,setCursorOffset as Ta,startingHintOptions as Bo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ge,useEffect as dt,useLayoutEffect as Lt,useRef as Xe}from"react";var bt;function Wo(){if(bt!==void 0)return bt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),bt=e.contentEditable==="plaintext-only",bt}function Pa(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:i,editingParam:s,editingIdentified:r,editingAnchor:l,caretOffset:m,placeholderText:w,hintSuggestions:y,isFocused:g,isDropdownOpen:c,listboxId:h,activeDescendantId:v,autoFocus:I,handleTextChange:W,handleKeyDown:z,handleCaretAfterInput:L,handleCaretMove:J,startEditingParam:S,replaceEditingRange:N,setFocused:H}=e,k=Xe(null),_=Xe(!1),ee=Xe(""),V=Xe(""),U=Xe(null),A=Xe(0);U.current=m,dt(()=>{if(!I)return;let u=k.current;if(!u)return;document.activeElement===u?H(!0):u.focus();let C=u.ownerDocument??document,T=C.getSelection(),E=T&&T.rangeCount>0&&u.contains(T.anchorNode);if(T&&!E){let O=C.createRange();O.selectNodeContents(u),O.collapse(!0),T.removeAllRanges(),T.addRange(O)}},[I,H]),dt(()=>{let u=k.current;if(!u)return;let C=u.ownerDocument??document,T=()=>{let E=C.getSelection();if(!E||E.rangeCount===0||!E.anchorNode||!u.contains(E.anchorNode))return;let O=E.anchorNode,Y=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,ae=(E.isCollapsed?Y?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ke=s?.id??r?.id??null;if(ae&&ae!==ke){S(ae);return}performance.now()-A.current<50||J(Sa(u))};return C.addEventListener("selectionchange",T),()=>C.removeEventListener("selectionchange",T)},[s,r,S,J]),dt(()=>{let u=k.current;if(!u)return;let C=T=>{let E=Mo(u,T.target);E&&(S(E),No(u,E))};return u.addEventListener("click",C),()=>u.removeEventListener("click",C)},[S]),Lt(()=>{let u=k.current;u&&Fo({input:u,segments:o,newParamId:i,editingParamId:s?.id??null,placeholderText:w??"",isFocused:g,showChipIcons:t,showChipImages:a,hintOptions:Bo(y??[])})},[o,i,s,w,y,g,t,a]),dt(()=>{let u=k.current;return()=>{u&&Do(u)}},[]),Lt(()=>{let u=ee.current,C=i??"";if(ee.current=C,!C||C===u)return;let T=k.current;if(!T)return;T.focus();let E=U.current??Ho(T);Ta(T,E)},[i]),Lt(()=>{let u=V.current,C=s?.id??"";if(V.current=C,!C||C===u||l==null)return;let T=k.current;T&&Ta(T,l)},[s,l]);let D=ge(()=>{if(_.current)return;let u=k.current;if(!u)return;let C=Ca(u),E=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;W(E)},[W]),fe=ge(()=>{A.current=performance.now(),D();let u=k.current;u&&L(Sa(u))},[D,L]);dt(()=>{let u=k.current;if(!u)return;let C=T=>{let E=T,O=E.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){T.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let Y=O.startsWith("delete")?"":E.data??"";N(Y)&&T.preventDefault()}};return u.addEventListener("beforeinput",C),()=>u.removeEventListener("beforeinput",C)},[N]);let pe=ge(()=>{_.current=!0,k.current?.setAttribute("data-aia-composing","true")},[]),re=ge(()=>{_.current=!1,k.current?.removeAttribute("data-aia-composing"),D()},[D]),d=ge(u=>{u.preventDefault();let C=k.current;if(!C)return;let T=(u.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!T)return;let E=C.ownerDocument??document,O=E.getSelection();if(!O||O.rangeCount===0)return;let Y=O.getRangeAt(0);if(!C.contains(Y.startContainer))return;Y.deleteContents();let he=E.createTextNode(T);Y.insertNode(he),Y.setStartAfter(he),Y.collapse(!0),O.removeAllRanges(),O.addRange(Y),D()},[D]),P=ge(u=>z(u),[z]),Pe=ge(()=>H(!0),[H]),f=ge(()=>H(!1),[H]),Ne=ge(()=>k.current?.focus(),[]),Ie=ge(()=>k.current?.blur(),[]),Ee=ge(()=>{let u=k.current;return u?Ca(u):""},[]),Ae=Wo()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:Ae,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":h,"aria-expanded":c,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:fe,onKeyDown:P,onCompositionStart:pe,onCompositionEnd:re,onPaste:d,onFocus:Pe,onBlur:f},getPlainText:Ee,focus:Ne,blur:Ie}}import{jsx as et,jsxs as Mt}from"react/jsx-runtime";function jo(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var $o=Go(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:m,language:w,currency:y,productId:g,visitorId:c,columns:h,pillPlacement:v="dropdown",mode:I="auto",optionsPosition:W="below",animations:z=!0,optionsStyle:L="floating",dropdownTrigger:J,closeDropdownOnBlur:S,prependPlaceholder:N,showNonTappableOptions:H,locationSearch:k,showOptionIcons:_=!0,showChipIcons:ee=!0,showChipImages:V=!0,showOptionImages:U=!0,showOptionCounts:A=!0,showSkipButton:D,showProducts:fe,productsLayout:pe,productImageFallback:re,autoFocus:d=!0,onFocus:P,onBlur:Pe,value:f,completedParams:Ne,onChange:Ie,onParamsChange:Ee,products:Ae,mapProducts:u,onProductSelect:C,onProductAddToCart:T,submitButton:E,resetOnSubmit:O=!0},Y){let he=Je(null),ae=Je(null),ke=Je(null),He=Je(()=>{}),le=Je(null),ie=Je(null);Dt(()=>{let M=he.current;if(M)return le.current?le.current.setMode(I):le.current=new Vo(M,I),()=>{le.current?.destroy(),le.current=null}},[I]);let _e=zt(M=>{let oe=ie.current?.current;oe&&(oe.focus(),Uo(oe,M))},[]),{completedParams:Fe,suggestionPills:be,setActivePill:tt,skipActivePill:Re,segments:Oe,newParamId:j,clearNewParamId:x,placeholderText:Ve,isFocused:n,isDropdownOpen:Q,isActivePillSelected:b,isLoading:de,isReady:at,activeIndex:se,listboxId:Le,handleTextChange:Ue,handleKeyDown:ze,setFocused:Qe,editingParam:ue,editingIdentified:we,editingAnchor:De,caretOffset:Be,startEditingParam:Ye,handleCaretAfterInput:Ce,handleCaretMove:We,replaceEditingRange:p,dropdownProps:B,reset:R,refreshProducts:F,prepareSubmit:Nt,getState:Ht,recordSubmit:Ft}=Ot({onSubmit:M=>He.current(M),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:m,language:w,currency:y,productId:g,visitorId:c,columns:h,dropdownTrigger:J,optionsPosition:W,closeDropdownOnBlur:S,prependPlaceholder:N,showNonTappableOptions:H,locationSearch:k,showOptionIcons:_,showOptionImages:U,showOptionCounts:A,showSkipButton:D,showProducts:fe,onFocus:P,onBlur:Pe,value:f,completedParams:Ne,onChange:Ie,onParamsChange:Ee,products:Ae,mapProducts:u,onProductSelect:C,onProductAddToCart:T,source:"full-sdk",setCursor:_e});Dt(()=>{if(!j)return;let M=window.setTimeout(()=>x(),650);return()=>window.clearTimeout(M)},[j,x]);let Ia=se>=0?`${Le}-option-${se}`:void 0,{inputRef:wt,editorProps:Ea,focus:ct,blur:Bt,getPlainText:Wt}=Pa({segments:Oe,newParamId:j,editingParam:ue,editingIdentified:we,editingAnchor:De,caretOffset:Be,placeholderText:Ve,hintSuggestions:v==="inline"?[]:be,isFocused:n,showChipIcons:ee,showChipImages:V,isDropdownOpen:Q,listboxId:Le,activeDescendantId:Ia,autoFocus:d,handleTextChange:Ue,handleKeyDown:ze,handleCaretAfterInput:Ce,handleCaretMove:We,startEditingParam:Ye,replaceEditingRange:p,setFocused:Qe});ie.current=wt,qo(()=>{let M=ae.current,oe=wt.current;if(!M||!oe)return;let ot=()=>{let Kt=M.firstElementChild;if(!Kt)return;let La=Kt.getBoundingClientRect(),za=oe.getBoundingClientRect();La.top>=za.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};ot();let Gt=new ResizeObserver(ot);return Gt.observe(oe),()=>Gt.disconnect()},[Oe,be.length,de,wt]),Dt(()=>{let M=ke.current;if(M)return Yo(M)},[]),Ko(Y,()=>({focus:ct,blur:Bt,reset:R,refreshProducts:F,setMode:M=>le.current?.setMode(M),skipActivePill:Re}),[ct,Bt,R,F,Re]);let it=!!Oe.length||Fe.length>0,vt=zt(M=>{if(!it)return;M&&Nt();let oe=Ht(),ot=_o(Wt(),oe.completedParams,oe.skippedParams,{identifiedParams:oe.identifiedParams,isReady:oe.isReady,customFields:oe.customFields});M&&Ft(ot),o(ot),O&&R()},[Ft,O,it,Nt,Ht,o,R,Wt]);He.current=()=>vt(!1);let Aa=zt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||ct()},[ct]),Ra=v==="inline",Oa=v==="dropdown";return Mt("div",{ref:he,className:`magicx-aia ${Ge.container} ${r??""}`,"data-pill-placement":v,"data-options-position":W,"data-animations":z?"on":"off","data-aia-options-style":L,"data-mode":jo(I),children:[et(At,{...B,showPills:Oa,productsLayout:pe,productImageFallback:re}),Mt("div",{className:Ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Aa,children:[Mt("div",{ref:ke,className:Ge.editorArea,"data-aia-editor":"",children:[et("div",{...Ea,className:Ge.input,"data-aia-input":""}),Ra&&(de||be.length>0)&&et("span",{ref:ae,className:Ge.pillListContainer,"data-aia-pill-list-container":"",children:et(ht,{pills:be,activePillIndex:0,activeSelected:b,onSelectPill:tt,loading:de})})]}),E===null?null:E===void 0?et(fa,{disabled:!it,ready:it&&at,onClick:()=>vt(!0),label:Qo(w).submit}):et("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ge.submitSlot,onClick:M=>{it&&(M.stopPropagation(),vt(!0))},children:E})]})]})});export{$o as AIAutocomplete,At as AIAutocompleteDropdown,rs as DATE_RANGE_META_END,ss as DATE_RANGE_META_START,ls as DEFAULT_OPTION_COUNT_UNIT,fs as LOCATION_META_KEY,Ss as PRODUCT_PATH_PREFIX,Ds as TIME_META_KEY,Ns as WEEKDAY_LABELS,is as buildSubmitResult,os as cellDay,ns as cellIso,ds as dateCellMarks,cs as formatDate,ps as formatDateRange,hs as formatOptionCount,us as formatPlace,ms as formatTime,gs as isoDate,bs as monthLabel,ws as optionCountLabel,vs as optionHasImage,xs as optionImageSources,ys as optionImageSrc,ks as optionLabel,Cs as optionsShowLeadingVisuals,Ts as parseDate,Ps as parseLooseDate,Is as parseLooseDateRange,Es as parseTime,As as productFromMatchedItem,Rs as productImageSources,Os as productsFromCustomFields,Ls as sanitizeOptionIconSvg,zs as selectedRangeFor,Ot as useAIAutocomplete,Ms as visibleDateRange,Hs as withSkippedParams};
3624
+ `,document.head.appendChild(e)}var ba={submitButton:"aia-submitButton-otz7H"};import{jsx as Ot}from"react/jsx-runtime";function wa({disabled:e,ready:o,onClick:t,label:a=Ao().submit}){return Ot("button",{type:"button","data-aia-submit":"",className:ba.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Ot("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Ot("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ro,dateSelectionFor as Oo,identifiedParamLabel as Lo,withoutTraditionalAutocomplete as zo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ca,useEffect as Je,useMemo as Do,useRef as ee,useState as Mo}from"react";import{useRef as va}from"react";function xa(e){let o=va(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=va({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,m,w)=>{let y=o.current?.[s];return y?y(l,m,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as ya}from"react";function ka(e){let o=ya(e);o.current=e;let t=ya(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Sa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function Lt({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,visitorId:y,columns:f=2,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showOptionIcons:R,showOptionImages:te,showOptionCounts:S,showSkipButton:M,showProducts:F,productImageFallback:N="image",onFocus:B,onBlur:T,value:V,completedParams:Y,onChange:E,onParamsChange:K,products:de,mapProducts:ae,onProductSelect:re,onProductAddToCart:d,source:P,setCursor:Te}){let g=ee(null),[Me,Pe]=Mo(null),Ie=ee(e);Ie.current=e;let Ee=ee(o);Ee.current=o;let ye=ee(t);ye.current=t;let Ae=ee(E);Ae.current=E;let u=ee(K);u.current=K;let k=ee(B);k.current=B;let C=ee(T);C.current=T;let A=ee(Te);A.current=Te;let O=ee(re);O.current=re;let W=ee(d);W.current=d;let ce=ee(y);ce.current=y;let pe=ee(()=>{let p=ce.current;return typeof p=="function"?p():p}).current,ge=ka(de),j=ee(ae);j.current=ae;let Ne=ee((p,G)=>{let L=j.current;return L?L(p,G):p}).current,He=ae?Ne:void 0,Fe=xa(a);Je(()=>{if(typeof document>"u")return;let p=new Ro(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,visitorId:pe,optionOverrides:Fe.overrides,maskCompletedText:i,columns:f,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:F,source:P,value:V,completedParams:Y,onSubmit:(...L)=>Ie.current?.(...L),onResult:(...L)=>Ee.current?.(...L),onError:(...L)=>ye.current?.(...L),onChange:(...L)=>Ae.current?.(...L),onParamsChange:(...L)=>u.current?.(...L),onFocus:()=>k.current?.(),onBlur:()=>C.current?.(),onProductSelect:L=>O.current?.(L),onProductAddToCart:L=>W.current?.(L),setCursor:L=>A.current?.(L),products:ge.config,mapProducts:He});g.current=p,Pe(p.getState());let G=p.subscribe(L=>Pe(L));return()=>{G(),p.destroy(),g.current===p&&(g.current=null)}},[]),Je(()=>{V!==void 0&&g.current?.setValue(V)},[V]),Je(()=>{Y!==void 0&&g.current?.setCompletedParams(Y)},[Y]);let Re=JSON.stringify(s??null),Be;try{Be=JSON.stringify(r??null)}catch{Be="[unstringifiable]"}Je(()=>{g.current?.update({apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,optionOverrides:Fe.overrides,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:F})},[Re,Be,l,m?.code,m?.rate,m?.country,w,Fe.key,c,h,x,I,_,z,F]);let We=ee(!1);Je(()=>{if(!We.current){We.current=!0;return}g.current?.update({products:ge.config})},[ge.enabled]),Je(()=>{g.current?.update({mapProducts:He})},[He]);let Z=ee(null);Z.current===null&&(Z.current={handleTextChange:p=>g.current?.handleTextChange(p),handleKeyDown:p=>{let G="nativeEvent"in p?p.nativeEvent:p;g.current?.handleKeyDown(G)},setFocused:p=>g.current?.setFocused(p),startEditingParam:p=>g.current?.startEditingParam(p),removeParam:p=>g.current?.removeParam(p)??!1,exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:p=>g.current?.handleCaretAfterInput(p),handleCaretMove:p=>g.current?.handleCaretMove(p),replaceEditingRange:p=>g.current?.replaceEditingRange(p)??!1,setActivePill:p=>g.current?.setActivePill(p),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),prepareSubmit:()=>g.current?.prepareSubmit(),getState:()=>g.current?.getState()??Sa,recordSubmit:p=>g.current?.recordSubmit(p),selectOption:(p,G)=>g.current?.selectOption(p,G),selectProduct:p=>g.current?.selectProduct(p),addProductToCart:p=>{let G=g.current;return!G||!W.current?Promise.resolve():G.addProductToCart(p)},setActiveDropdownIndex:p=>g.current?.setActiveDropdownIndex(p),clearHighlight:p=>g.current?.clearHighlight(p),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),setTime:p=>g.current?.setTime(p),commitTime:()=>g.current?.commitTime(),toggleMultiSelectOption:p=>g.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>g.current?.commitMultiSelect(),setLocationQuery:p=>g.current?.setLocationQuery(p),moveLocationHighlight:p=>g.current?.moveLocationHighlight(p),commitLocation:p=>g.current?.commitLocation(p),setLocationFieldFocused:p=>g.current?.setLocationFieldFocused(p),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let v=Z.current,Ge=Ca(p=>{let G=p.target.value,H=G.length>0&&!p.nativeEvent?.isComposing&&G[0]!==G[0].toUpperCase()?G[0].toUpperCase()+G.slice(1):G;g.current?.handleTextChange(H)},[]),n=Ca(p=>{g.current?.handleKeyDown(p.nativeEvent)},[]),$=g.current,b=Me??Sa,fe=V!==void 0?V:b.text,Ke=Y!==void 0?Y:b.completedParams,se=b.actionableSuggestions,Oe=se[0],qe=Do(()=>zo(se),[se]),Le=$?.listboxId??"",je=b.activeDropdownIndex>=0&&$?`${Le}-option-${b.activeDropdownIndex}`:void 0,he=b.editingParam,be=b.editingIdentified,ze=he?{parameter:he.suggestionParameter,text:he.suggestionPlaceholder,required:!0,options:he.options}:be?{parameter:be.parameter,text:Lo(be.parameter),required:!0,options:[]}:null,_e=b.dropdownSuggestion??ze??Oe,$e=ze?[ze]:se,ke=Oo(b),Ve=!$||b.dropdownLoading;return{completedParams:Ke,multiSelectView:b.multiSelectView,toggleMultiSelectOption:v.toggleMultiSelectOption,commitMultiSelect:v.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:qe,setActivePill:v.setActivePill,skipActivePill:v.skipActivePill,removeLastParam:v.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:v.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:Ve,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:Le,error:b.error,products:b.products,customFields:b.customFields,selectProduct:v.selectProduct,addProductToCart:v.addProductToCart,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:he,editingIdentified:be,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:v.startEditingParam,removeParam:v.removeParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:fe,placeholder:b.placeholderText||void 0,onChange:Ge,onKeyDown:n,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":je,"aria-autocomplete":"list","aria-controls":Le},reset:v.reset,refreshProducts:v.refreshProducts,prepareSubmit:v.prepareSubmit,getState:v.getState,recordSubmit:v.recordSubmit,dropdownProps:{suggestions:_e?[{..._e,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,onUnhighlight:v.clearHighlight,isOpen:b.isDropdownOpen,id:Le,pills:$e,activeSelected:b.isActivePillSelected,onPillClick:v.setActivePill,onSkip:v.skipActivePill,showSkipButton:(M??!0)&&!he&&!be,showOptionIcons:R??!0,showOptionImages:te??!0,showOptionCounts:S??!0,skipDisabled:b.inSelectionAnimation,isLoading:Ve,skeletonExiting:b.skeletonExiting,isInputEmpty:fe.trim().length===0,language:l,products:b.products,productImageFallback:N,onProductSelect:v.selectProduct,onProductAddToCart:d?v.addProductToCart:void 0,onProductFocusChange:v.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:ke.selectedIso,selectedDateRange:ke.selectedRange,dateRangeStart:ke.rangeStart,dateReferences:ke.references,onPreviousMonth:v.showPreviousMonth,onNextMonth:v.showNextMonth,timeView:b.timeView,multiSelectView:b.multiSelectView,onMultiSelectCommit:v.commitMultiSelect,onTimeChange:v.setTime,onTimeCommit:v.commitTime,locationView:b.locationView,isReediting:b.editingParam!=null,onLocationQuery:v.setLocationQuery,onLocationMove:v.moveLocationHighlight,onLocationCommit:v.commitLocation,onLocationFocusChange:v.setLocationFieldFocused,isFocused:b.isFocused||b.locationFieldFocused,optionsPosition:h??"below"}}}import{attachChipRemove as No,cancelStartingHint as Ho,chipIdFromTap as Fo,extractPlainText as Ta,getCursorOffset as Pa,keepCaretOnChip as Bo,plainTextLength as Wo,renderEditableContent as Go,setCursorOffset as Ia,startingHintOptions as Ko}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as me,useEffect as et,useLayoutEffect as zt,useRef as tt}from"react";var wt;function qo(){if(wt!==void 0)return wt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),wt=e.contentEditable==="plaintext-only",wt}function Ea(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,showChipRemove:i=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:m,editingAnchor:w,caretOffset:y,placeholderText:f,hintSuggestions:c,isFocused:h,isDropdownOpen:x,listboxId:I,activeDescendantId:_,autoFocus:z,handleTextChange:R,handleKeyDown:te,handleCaretAfterInput:S,handleCaretMove:M,startEditingParam:F,replaceEditingRange:N,setFocused:B}=e,T=tt(null),V=tt(!1),Y=tt(""),E=tt(""),K=tt(null),de=tt(0);K.current=y,et(()=>{if(!z)return;let u=T.current;if(!u)return;document.activeElement===u?B(!0):u.focus();let k=u.ownerDocument??document,C=k.getSelection(),A=C&&C.rangeCount>0&&u.contains(C.anchorNode);if(C&&!A){let O=k.createRange();O.selectNodeContents(u),O.collapse(!0),C.removeAllRanges(),C.addRange(O)}},[z,B]),et(()=>{let u=T.current;if(!u)return;let k=u.ownerDocument??document,C=()=>{let A=k.getSelection();if(!A||A.rangeCount===0||!A.anchorNode||!u.contains(A.anchorNode))return;let O=A.anchorNode,W=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,pe=(A.isCollapsed?W?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=l?.id??m?.id??null;if(pe&&pe!==ge){F(pe);return}performance.now()-de.current<50||M(Pa(u))};return k.addEventListener("selectionchange",C),()=>k.removeEventListener("selectionchange",C)},[l,m,F,M]),et(()=>{let u=T.current;if(!u)return;let k=C=>{let A=Fo(u,C.target);A&&(F(A),Bo(u,A))};return u.addEventListener("click",k),()=>u.removeEventListener("click",k)},[F]),et(()=>{let u=T.current;if(!(!u||!s||!i))return No(u,s)},[s,i]),zt(()=>{let u=T.current;u&&Go({input:u,segments:o,newParamId:r,editingParamId:l?.id??null,placeholderText:f??"",isFocused:h,showChipIcons:t,showChipImages:a,showChipRemove:i,hintOptions:Ko(c??[])})},[o,r,l,f,c,h,t,a,i]),et(()=>{let u=T.current;return()=>{u&&Ho(u)}},[]),zt(()=>{let u=Y.current,k=r??"";if(Y.current=k,!k||k===u)return;let C=T.current;if(!C)return;C.focus();let A=K.current??Wo(C);Ia(C,A)},[r]),zt(()=>{let u=E.current,k=l?.id??"";if(E.current=k,!k||k===u||w==null)return;let C=T.current;C&&Ia(C,w)},[l,w]);let ae=me(()=>{if(V.current)return;let u=T.current;if(!u)return;let k=Ta(u),A=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;R(A)},[R]),re=me(()=>{de.current=performance.now(),ae();let u=T.current;u&&S(Pa(u))},[ae,S]);et(()=>{let u=T.current;if(!u)return;let k=C=>{let A=C,O=A.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){C.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let W=O.startsWith("delete")?"":A.data??"";N(W)&&C.preventDefault()}};return u.addEventListener("beforeinput",k),()=>u.removeEventListener("beforeinput",k)},[N]);let d=me(()=>{V.current=!0,T.current?.setAttribute("data-aia-composing","true")},[]),P=me(()=>{V.current=!1,T.current?.removeAttribute("data-aia-composing"),ae()},[ae]),Te=me(u=>{u.preventDefault();let k=T.current;if(!k)return;let C=(u.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!C)return;let A=k.ownerDocument??document,O=A.getSelection();if(!O||O.rangeCount===0)return;let W=O.getRangeAt(0);if(!k.contains(W.startContainer))return;W.deleteContents();let ce=A.createTextNode(C);W.insertNode(ce),W.setStartAfter(ce),W.collapse(!0),O.removeAllRanges(),O.addRange(W),ae()},[ae]),g=me(u=>te(u),[te]),Me=me(()=>B(!0),[B]),Pe=me(()=>B(!1),[B]),Ie=me(()=>T.current?.focus(),[]),Ee=me(()=>T.current?.blur(),[]),ye=me(()=>{let u=T.current;return u?Ta(u):""},[]),Ae=qo()?"plaintext-only":"true";return{inputRef:T,editorProps:{ref:T,contentEditable:Ae,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":I,"aria-expanded":x,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:re,onKeyDown:g,onCompositionStart:d,onCompositionEnd:P,onPaste:Te,onFocus:Me,onBlur:Pe},getPlainText:ye,focus:Ie,blur:Ee}}import{jsx as it,jsxs as Nt}from"react/jsx-runtime";function Xo(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Jo=_o(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:m,language:w,currency:y,productId:f,visitorId:c,columns:h,pillPlacement:x="dropdown",mode:I="auto",optionsPosition:_="below",animations:z=!0,optionsStyle:R="floating",dropdownTrigger:te,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:F,locationSearch:N,showOptionIcons:B=!0,showChipIcons:T=!0,showChipImages:V=!0,showChipRemove:Y=!1,showOptionImages:E=!0,showOptionCounts:K=!0,showSkipButton:de,showProducts:ae,productsLayout:re,productImageFallback:d,autoFocus:P=!0,onFocus:Te,onBlur:g,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,submitButton:C,resetOnSubmit:A=!0},O){let W=at(null),ce=at(null),pe=at(null),ge=at(()=>{}),j=at(null),Ne=at(null);Mt(()=>{let D=W.current;if(D)return j.current?j.current.setMode(I):j.current=new Yo(D,I),()=>{j.current?.destroy(),j.current=null}},[I]);let He=Dt(D=>{let oe=Ne.current?.current;oe&&(oe.focus(),jo(oe,D))},[]),{completedParams:Fe,suggestionPills:Re,setActivePill:Be,skipActivePill:We,segments:Z,newParamId:v,clearNewParamId:Ge,placeholderText:n,isFocused:$,isDropdownOpen:b,isActivePillSelected:fe,isLoading:Ke,isReady:se,activeIndex:Oe,listboxId:qe,handleTextChange:Le,handleKeyDown:je,setFocused:he,editingParam:be,editingIdentified:ze,editingAnchor:_e,caretOffset:$e,startEditingParam:ke,removeParam:Ve,handleCaretAfterInput:p,handleCaretMove:G,replaceEditingRange:L,dropdownProps:H,reset:ct,refreshProducts:Ht,prepareSubmit:Ft,getState:Bt,recordSubmit:Wt}=Lt({onSubmit:D=>ge.current(D),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:m,language:w,currency:y,productId:f,visitorId:c,columns:h,dropdownTrigger:te,optionsPosition:_,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:F,locationSearch:N,showOptionIcons:B,showOptionImages:E,showOptionCounts:K,showSkipButton:de,showProducts:ae,onFocus:Te,onBlur:g,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,source:"full-sdk",setCursor:He});Mt(()=>{if(!v)return;let D=window.setTimeout(()=>Ge(),650);return()=>window.clearTimeout(D)},[v,Ge]);let Aa=Oe>=0?`${qe}-option-${Oe}`:void 0,{inputRef:vt,editorProps:Ra,focus:pt,blur:Gt,getPlainText:Kt}=Ea({segments:Z,newParamId:v,editingParam:be,editingIdentified:ze,editingAnchor:_e,caretOffset:$e,placeholderText:n,hintSuggestions:x==="inline"?[]:Re,isFocused:$,showChipIcons:T,showChipImages:V,showChipRemove:Y,removeParam:Ve,isDropdownOpen:b,listboxId:qe,activeDescendantId:Aa,autoFocus:P,handleTextChange:Le,handleKeyDown:je,handleCaretAfterInput:p,handleCaretMove:G,startEditingParam:ke,replaceEditingRange:L,setFocused:he});Ne.current=vt,Uo(()=>{let D=ce.current,oe=vt.current;if(!D||!oe)return;let nt=()=>{let _t=D.firstElementChild;if(!_t)return;let Da=_t.getBoundingClientRect(),Ma=oe.getBoundingClientRect();Da.top>=Ma.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};nt();let qt=new ResizeObserver(nt);return qt.observe(oe),()=>qt.disconnect()},[Z,Re.length,Ke,vt]),Mt(()=>{let D=pe.current;if(D)return Zo(D)},[]),Vo(O,()=>({focus:pt,blur:Gt,reset:ct,refreshProducts:Ht,setMode:D=>j.current?.setMode(D),skipActivePill:We}),[pt,Gt,ct,Ht,We]);let ot=!!Z.length||Fe.length>0,xt=Dt(D=>{if(!ot)return;D&&Ft();let oe=Bt(),nt=Qo(Kt(),oe.completedParams,oe.skippedParams,{identifiedParams:oe.identifiedParams,isReady:oe.isReady,customFields:oe.customFields});D&&Wt(nt),o(nt),A&&ct()},[Wt,A,ot,Ft,Bt,o,ct,Kt]);ge.current=()=>xt(!1);let Oa=Dt(D=>{D.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||pt()},[pt]),La=x==="inline",za=x==="dropdown";return Nt("div",{ref:W,className:`magicx-aia ${Ue.container} ${r??""}`,"data-pill-placement":x,"data-options-position":_,"data-animations":z?"on":"off","data-aia-options-style":R,"data-mode":Xo(I),children:[it(Rt,{...H,showPills:za,productsLayout:re,productImageFallback:d}),Nt("div",{className:Ue.inputWrapper,"data-aia-input-wrapper":"",onClick:Oa,children:[Nt("div",{ref:pe,className:Ue.editorArea,"data-aia-editor":"",children:[it("div",{...Ra,className:Ue.input,"data-aia-input":""}),La&&(Ke||Re.length>0)&&it("span",{ref:ce,className:Ue.pillListContainer,"data-aia-pill-list-container":"",children:it(ut,{pills:Re,activePillIndex:0,activeSelected:fe,onSelectPill:Be,loading:Ke})})]}),C===null?null:C===void 0?it(wa,{disabled:!ot,ready:ot&&se,onClick:()=>xt(!0),label:$o(w).submit}):it("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ue.submitSlot,onClick:D=>{ot&&(D.stopPropagation(),xt(!0))},children:C})]})]})});export{Jo as AIAutocomplete,Rt as AIAutocompleteDropdown,ds as DATE_RANGE_META_END,cs as DATE_RANGE_META_START,ps as DEFAULT_OPTION_COUNT_UNIT,vs as LOCATION_META_KEY,Is as PRODUCT_PATH_PREFIX,Hs as TIME_META_KEY,Bs as WEEKDAY_LABELS,rs as buildSubmitResult,ss as cellDay,ls as cellIso,hs as dateCellMarks,us as formatDate,ms as formatDateRange,gs as formatOptionCount,fs as formatPlace,bs as formatTime,ws as isoDate,xs as monthLabel,ys as optionCountLabel,ks as optionHasImage,Cs as optionImageSources,Ss as optionImageSrc,Ts as optionLabel,Ps as optionsShowLeadingVisuals,Es as parseDate,As as parseLooseDate,Rs as parseLooseDateRange,Os as parseTime,Ls as productFromMatchedItem,zs as productImageSources,Ds as productsFromCustomFields,Ms as sanitizeOptionIconSvg,Ns as selectedRangeFor,Lt as useAIAutocomplete,Fs as visibleDateRange,Ws as withSkippedParams};
3574
3625
  //# sourceMappingURL=index.mjs.map