@magicx-eng/ai-autocomplete-react 0.45.0 → 0.46.0

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 Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END as Kn,DATE_RANGE_META_START as qn,DEFAULT_OPTION_COUNT_UNIT as Wn,dateCellMarks as Un,formatDate as _n,formatDateRange as jn,formatOptionCount as Vn,isoDate as Yn,monthLabel as Qn,optionCountLabel as $n,optionHasImage as Zn,optionImageSources as Xn,optionImageSrc as Jn,optionLabel as er,optionsShowLeadingVisuals as tr,PRODUCT_PATH_PREFIX as ar,parseDate as ir,parseLooseDate as or,parseLooseDateRange as nr,productFromMatchedItem as rr,productImageSources as sr,productsFromCustomFields as lr,sanitizeOptionIconSvg as dr,selectedRangeFor as cr,visibleDateRange as pr,WEEKDAY_LABELS as hr,withSkippedParams as ur}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Mi,useCallback as yt,useEffect as aa,useImperativeHandle as Ni,useLayoutEffect as Fi,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 cr,cellDay as pr,cellIso as hr,DATE_RANGE_META_END as ur,DATE_RANGE_META_START as mr,DEFAULT_OPTION_COUNT_UNIT as gr,dateCellMarks as fr,formatDate as br,formatDateRange as wr,formatOptionCount as vr,formatTime as xr,isoDate as yr,monthLabel as kr,optionCountLabel as Sr,optionHasImage as Cr,optionImageSources as Tr,optionImageSrc as Pr,optionLabel as Ir,optionsShowLeadingVisuals as Er,PRODUCT_PATH_PREFIX as Ar,parseDate as Rr,parseLooseDate as Or,parseLooseDateRange as Dr,parseTime as Lr,productFromMatchedItem as Mr,productImageSources as zr,productsFromCustomFields as Nr,sanitizeOptionIconSvg as Hr,selectedRangeFor as Fr,TIME_META_KEY as Br,visibleDateRange as Wr,WEEKDAY_LABELS as Gr,withSkippedParams as Kr}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as eo,useCallback as Tt,useEffect as da,useImperativeHandle as to,useLayoutEffect as ao,useRef as Ze}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
@@ -280,7 +280,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
280
280
  opacity: 0;
281
281
  }
282
282
  }
283
- `,document.head.appendChild(e)}var Ae={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",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as pi,attachViewportFit as hi,containScroll as ui,hasSkippablePill as gi,isCalendarFormat as mi,labelTraditionalAutocomplete as fi,uiStringsFor as bi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Me,useRef as ze,useState as wi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
283
+ `,document.head.appendChild(e)}var De={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",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as Ei,attachViewportFit as Ai,containScroll as Ri,hasSkippablePill as Oi,isCalendarFormat as Di,labelTraditionalAutocomplete as Li,uiStringsFor as Mi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Be,useRef as Fe,useState as zi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
284
284
  * Built-in appearance defaults \u2014 zero specificity via :where().
285
285
  * Consumer CSS always wins without !important.
286
286
  *
@@ -822,6 +822,15 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
822
822
  max-height: none;
823
823
  overflow: visible;
824
824
  }
825
+
826
+ [data-aia-dropdown][aria-multiselectable="true"] {
827
+ --aia-grid-scroll-bottom: 0px;
828
+ --aia-grid-overlap-bottom: 0px;
829
+ --aia-grid-scroll-top: 0px;
830
+ --aia-grid-overlap-top: 0px;
831
+ --aia-footer-fade-lead: 0px;
832
+ --aia-footer-row-min-height: 0px;
833
+ }
825
834
  `,document.head.appendChild(e)}if(typeof document<"u"&&!document.getElementById("ac-style-3819c762")){let e=document.createElement("style");e.id="ac-style-3819c762",e.textContent=`.aia-dropdown-yz2KC {
826
835
  position: absolute;
827
836
  left: 0;
@@ -875,6 +884,11 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
875
884
  max-width: var(--aia-date-panel-width, 312px);
876
885
  }
877
886
 
887
+ /* The time wheel is narrower still \u2014 three short wheels and a button. */
888
+ .aia-dropdown-yz2KC:has([data-aia-time-wheel]) {
889
+ max-width: var(--aia-time-panel-width, 240px);
890
+ }
891
+
878
892
  .aia-dropdown-yz2KC[data-aia-surface="glass"] {
879
893
  background: transparent;
880
894
  border-color: transparent;
@@ -1132,7 +1146,23 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1132
1146
  opacity: 0.25;
1133
1147
  }
1134
1148
  }
1135
- `,document.head.appendChild(e)}var pe={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",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as ca,cellIso as Le,dateCellMarks as pa,isoDate as ha,monthLabel as ua,visibleDateRange as ga,WEEKDAY_LABELS as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as fa}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) ---
1149
+
1150
+ .aia-multiDone-y12U7 {
1151
+ display: block;
1152
+ width: auto;
1153
+ margin-left: auto;
1154
+ height: 32px;
1155
+ padding: 0 18px;
1156
+ border: none;
1157
+ border-radius: 999px;
1158
+ background: var(--aia-option-bg, transparent);
1159
+ color: var(--aia-option-color);
1160
+ font-family: inherit;
1161
+ font-size: 15px;
1162
+ font-weight: inherit;
1163
+ cursor: pointer;
1164
+ }
1165
+ `,document.head.appendChild(e)}var se={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",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q",multiDone:"aia-multiDone-y12U7"};import{cellDay as ba,cellIso as He,dateCellMarks as wa,isoDate as va,monthLabel as xa,visibleDateRange as ya,WEEKDAY_LABELS as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Sa}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) ---
1136
1166
 
1137
1167
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1138
1168
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1295,7 +1325,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1295
1325
  opacity: 0.8;
1296
1326
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1297
1327
  }
1298
- `,document.head.appendChild(e)}var L={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",pressed:"aia-pressed-bEyyN"};import{jsx as ne,jsxs as It}from"react/jsx-runtime";var ba=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Et({options:e,activeIndex:n,listboxId:t,view:a,selection:o,onSelect:r,onHighlight:i,onUnhighlight:c,onPreviousMonth:u,onNextMonth:g}){let w=ha(new Date),k=ga({pendingStart:o.rangeStart,highlightedIso:Le(e[n]),selected:o.selectedRange});return It("div",{className:L.datepicker,"data-aia-datepicker":"",children:[It("div",{className:L.header,children:[ne("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:p=>p.preventDefault(),onClick:u,children:"\u2039"}),ne("span",{className:L.month,"data-aia-date-month":"","aria-live":"polite",children:ua(a)}),ne("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:p=>p.preventDefault(),onClick:g,children:"\u203A"})]}),ne("div",{className:L.weekdays,"aria-hidden":"true",children:ma.map((p,s)=>ne("span",{className:L.weekday,children:p},ba[s]))}),ne("div",{className:L.grid,"data-aia-date-grid":"",children:e.map((p,s)=>ne(wa,{option:p,id:`${t}-option-${s}`,index:s,isHighlighted:s===n&&p.is_tappable,isToday:Le(p)===w,isPast:Le(p)!=null&&Le(p)<w,marks:pa(Le(p),{selectedIso:o.selectedIso,range:k}),onSelect:r,onHighlight:i,onUnhighlight:c},Le(p)??`pad-${s}`))})]})}function wa({option:e,id:n,index:t,isHighlighted:a,isToday:o,isPast:r,marks:i,onSelect:c,onHighlight:u,onUnhighlight:g}){let[w,k]=fa(!1),p=ca(e);if(p==null)return ne("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${L.cell} ${L.blank}`});let s=()=>{k(!0),c(e),setTimeout(()=>k(!1),170)},f=[L.cell,L.day,r?L.past:"",a?L.highlighted:"",o?L.today:"",i.inRange?L.inRange:"",i.selected?L.selected:"",w?L.pressed:""].filter(Boolean).join(" ");return ne("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:f,onClick:s,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),s())},onMouseEnter:()=>u(t),onMouseLeave:g?()=>g(t):void 0,children:ne("span",{className:L.number,children:p})})}import{ATTRIBUTION_URL as va,buildAttributionUrl as xa,getFooterHint as ya,uiStringsFor as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ca,useState as Sa}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 {
1328
+ `,document.head.appendChild(e)}var D={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",pressed:"aia-pressed-bEyyN"};import{jsx as le,jsxs as Ot}from"react/jsx-runtime";var Ca=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Dt({options:e,activeIndex:n,listboxId:t,view:a,selection:i,onSelect:r,onHighlight:o,onUnhighlight:s,onPreviousMonth:h,onNextMonth:b}){let x=va(new Date),m=ya({pendingStart:i.rangeStart,highlightedIso:He(e[n]),selected:i.selectedRange});return Ot("div",{className:D.datepicker,"data-aia-datepicker":"",children:[Ot("div",{className:D.header,children:[le("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:l=>l.preventDefault(),onClick:h,children:"\u2039"}),le("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:xa(a)}),le("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:l=>l.preventDefault(),onClick:b,children:"\u203A"})]}),le("div",{className:D.weekdays,"aria-hidden":"true",children:ka.map((l,d)=>le("span",{className:D.weekday,children:l},Ca[d]))}),le("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((l,d)=>le(Ta,{option:l,id:`${t}-option-${d}`,index:d,isHighlighted:d===n&&l.is_tappable,isToday:He(l)===x,isPast:He(l)!=null&&He(l)<x,marks:wa(He(l),{selectedIso:i.selectedIso,range:m}),onSelect:r,onHighlight:o,onUnhighlight:s},He(l)??`pad-${d}`))})]})}function Ta({option:e,id:n,index:t,isHighlighted:a,isToday:i,isPast:r,marks:o,onSelect:s,onHighlight:h,onUnhighlight:b}){let[x,m]=Sa(!1),l=ba(e);if(l==null)return le("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let d=()=>{m(!0),s(e),setTimeout(()=>m(!1),170)},w=[D.cell,D.day,r?D.past:"",a?D.highlighted:"",i?D.today:"",o.inRange?D.inRange:"",o.selected?D.selected:"",x?D.pressed:""].filter(Boolean).join(" ");return le("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:w,onClick:d,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),d())},onMouseEnter:()=>h(t),onMouseLeave:b?()=>b(t):void 0,children:le("span",{className:D.number,children:l})})}import{ATTRIBUTION_URL as Pa,buildAttributionUrl as Ia,getFooterHint as Ea,uiStringsFor as Aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ra,useState as Oa}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 {
1299
1329
  display: flex;
1300
1330
  flex-wrap: wrap;
1301
1331
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1335,7 +1365,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1335
1365
  .aia-cluster[data-justify="around"] {
1336
1366
  justify-content: space-around;
1337
1367
  }
1338
- `,document.head.appendChild(e)}import{jsx as At}from"react/jsx-runtime";function We({gap:e,align:n="center",justify:t="start",noWrap:a=!1,inline:o=!1,className:r,children:i,...c}){let u=e?{"--aia-cluster-gap":e}:void 0,g={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":a||void 0,"data-inline":o||void 0,style:u,...c};return o?At("span",{...g,children:i}):At("div",{...g,children:i})}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
1368
+ `,document.head.appendChild(e)}import{jsx as Lt}from"react/jsx-runtime";function je({gap:e,align:n="center",justify:t="start",noWrap:a=!1,inline:i=!1,className:r,children:o,...s}){let h=e?{"--aia-cluster-gap":e}:void 0,b={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":a||void 0,"data-inline":i||void 0,style:h,...s};return i?Lt("span",{...b,children:o}):Lt("div",{...b,children:o})}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
1339
1369
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1340
1370
  room above the hint/branding row so the footer doesn't butt against the last
1341
1371
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1482,7 +1512,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1482
1512
  justify-content: flex-end;
1483
1513
  }
1484
1514
  }
1485
- `,document.head.appendChild(e)}var he={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 Ue,jsxs as ct}from"react/jsx-runtime";function Rt({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=ka()}){let{key:a,hint:o}=ya(e,n,t),[r,i]=Sa(va);return Ca(()=>{i(xa())},[]),Ue("footer",{className:he.footer,"data-aia-footer":"",children:ct(We,{justify:"between",noWrap:!0,className:he.row,children:[ct(We,{gap:"5px",className:he.hintGroup,children:[Ue("kbd",{className:he.key,children:a}),Ue("span",{className:he.hint,children:o})]}),ct("a",{className:he.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Ue("span",{className:he.brand,children:"AI"}),Ue("span",{className:he.badge,children:"Autocomplete"})]})]})})}import{isSmartSuggestion as Ea,isTraditionalAutocompleteSuggestion as Aa}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as Pa}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,
1515
+ `,document.head.appendChild(e)}var me={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 Qe,jsxs as ut}from"react/jsx-runtime";function Mt({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=Aa()}){let{key:a,hint:i}=Ea(e,n,t),[r,o]=Oa(Pa);return Ra(()=>{o(Ia())},[]),Qe("footer",{className:me.footer,"data-aia-footer":"",children:ut(je,{justify:"between",noWrap:!0,className:me.row,children:[ut(je,{gap:"5px",className:me.hintGroup,children:[Qe("kbd",{className:me.key,children:a}),Qe("span",{className:me.hint,children:i})]}),ut("a",{className:me.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Qe("span",{className:me.brand,children:"AI"}),Qe("span",{className:me.badge,children:"Autocomplete"})]})]})})}import{isSmartSuggestion as za,isTraditionalAutocompleteSuggestion as Na}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as Da}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,
1486
1516
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1487
1517
  The border is kept as a 1px transparent line so the box stays the same size
1488
1518
  as it was when the outline was dashed. */
@@ -1662,7 +1692,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1662
1692
  opacity: 0;
1663
1693
  }
1664
1694
  }
1665
- `,document.head.appendChild(e)}var re={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",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{Fragment as Ta,jsx as pt,jsxs as Ia}from"react/jsx-runtime";var ht={selected:1,first:.7,next:.4,last:.2};function Dt({label:e,state:n,rounded:t,loading:a,smartSuggestion:o,completionHeader:r,onClick:i}){let c=[re.pill,t?re.rounded:"",a?re.skeleton:""].filter(Boolean).join(" ");return pt("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,"data-aia-smart-suggestion":o?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:c,style:{opacity:ht[n]},onMouseDown:u=>u.preventDefault(),onClick:a?void 0:i,disabled:a,children:o?Ia(Ta,{children:[pt("span",{className:`${re.smartText} magicx-aia-smart-suggestion-text`,children:e}),pt("span",{className:`${re.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:Pa}})]}):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 {
1695
+ `,document.head.appendChild(e)}var de={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",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{Fragment as La,jsx as mt,jsxs as Ma}from"react/jsx-runtime";var gt={selected:1,first:.7,next:.4,last:.2};function zt({label:e,state:n,rounded:t,loading:a,smartSuggestion:i,completionHeader:r,onClick:o}){let s=[de.pill,t?de.rounded:"",a?de.skeleton:""].filter(Boolean).join(" ");return mt("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,"data-aia-smart-suggestion":i?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:s,style:{opacity:gt[n]},onMouseDown:h=>h.preventDefault(),onClick:a?void 0:o,disabled:a,children:i?Ma(La,{children:[mt("span",{className:`${de.smartText} magicx-aia-smart-suggestion-text`,children:e}),mt("span",{className:`${de.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:Da}})]}):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 {
1666
1696
  position: relative;
1667
1697
  z-index: 1;
1668
1698
  pointer-events: auto;
@@ -1672,7 +1702,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
1672
1702
  align-items: center;
1673
1703
  vertical-align: middle;
1674
1704
  }
1675
- `,document.head.appendChild(e)}var ut={list:"aia-list-qvLqO"};import{jsx as Ze}from"react/jsx-runtime";var Ra=[125,69];function Ot(e){return e===0?"first":e===1?"next":"last"}function Xe({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:a,rounded:o,loading:r}){return r&&e.length===0?Ze("span",{className:ut.list,"data-aia-pill-list-loading":"",children:Ra.map((i,c)=>Ze("span",{"data-aia-pill-skeleton":"",className:`${re.pill} ${o?re.rounded:""} ${re.skeleton}`,style:{width:i,opacity:ht[Ot(c)]}},`skel-${i}`))}):Ze("span",{className:ut.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((i,c)=>{let u=!!a&&c===n;return Ze(Dt,{label:i.text,state:u?"selected":Ot(c),selected:u,rounded:o,loading:r,smartSuggestion:Ea(i),completionHeader:Aa(i),onClick:()=>t(c)},`${i.parameter}-${i.text}`)})})}import{attachProductRowWheel as Da,productImageSources as Oa,productImageSrc as La,productInitial as za,productPhotoFill as Ma,uiStringsFor as Na}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as gt,useRef as Je,useState as et}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
1705
+ `,document.head.appendChild(e)}var ft={list:"aia-list-qvLqO"};import{jsx as at}from"react/jsx-runtime";var Ha=[125,69];function Nt(e){return e===0?"first":e===1?"next":"last"}function it({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:a,rounded:i,loading:r}){return r&&e.length===0?at("span",{className:ft.list,"data-aia-pill-list-loading":"",children:Ha.map((o,s)=>at("span",{"data-aia-pill-skeleton":"",className:`${de.pill} ${i?de.rounded:""} ${de.skeleton}`,style:{width:o,opacity:gt[Nt(s)]}},`skel-${o}`))}):at("span",{className:ft.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,s)=>{let h=!!a&&s===n;return at(zt,{label:o.text,state:h?"selected":Nt(s),selected:h,rounded:i,loading:r,smartSuggestion:za(o),completionHeader:Na(o),onClick:()=>t(s)},`${o.parameter}-${o.text}`)})})}import{attachProductRowWheel as Fa,productImageSources as Ba,productImageSrc as Wa,productInitial as Ga,productPhotoFill as Ka,uiStringsFor as qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as bt,useRef as ot,useState as nt}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
1676
1706
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1677
1707
  theming one package sees the same result in the other.
1678
1708
 
@@ -2116,7 +2146,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
2116
2146
  .aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT[data-aia-product-has-cart] {
2117
2147
  padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
2118
2148
  }
2119
- `,document.head.appendChild(e)}var z={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",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 B,jsxs as _e}from"react/jsx-runtime";function Lt({products:e,listboxId:n,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r=!0,layout:i="row",imageFallback:c="image",strings:u=Na()}){let g=e.length>0,w=Je(null);if(gt(()=>{let p=w.current;if(!(!g||!p))return Da(p)},[g]),!g)return null;let k=`${n}-products-label`;return _e("section",{className:z.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":k,children:[B("div",{className:z.label,id:k,"data-aia-products-label":"",children:u.products}),B("div",{ref:w,className:z.row,"data-aia-products-row":"",children:e.map((p,s)=>B(Fa,{product:p,id:`${n}-product-${s}`,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:c,soldOut:u.soldOut,addToCart:u.addToCart},p.id))})]})}function Fa({product:e,id:n,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:i,soldOut:c,addToCart:u}){let g=!!a&&e.available!==!1,[w,k]=et(null),p=f=>{f.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},s=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||f.button!==0||(f.preventDefault(),t(e))};return _e("a",{id:n,className:z.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":g?"":void 0,role:"option","aria-selected":!1,style:w?{"--aia-product-photo-fill-x":String(w.x),"--aia-product-photo-fill-y":String(w.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:s,onKeyDown:f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:p,children:[B(Ga,{sources:Oa(e.imageUrl),title:e.title,fallback:i,onPhotoFill:k},La(e.imageUrl)??""),_e("span",{className:z.body,children:[e.vendor?B("span",{className:z.vendor,children:e.vendor}):null,B("span",{className:z.title,children:e.title}),e.price?B("span",{className:z.price,children:e.price}):null,e.available===!1?B("span",{className:z.badge,children:c}):null]}),g&&a?B(Ba,{product:e,label:`${u}: ${e.title}`,focusable:r,onAddToCart:a,onFocus:()=>o?.(!0),onBlur:p},Ha(e)):null]})}function Ha(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(n=>n??"").join("\0")}function Ba({product:e,label:n,focusable:t,onAddToCart:a,onFocus:o,onBlur:r}){let[i,c]=et(null),u=Je(null),g=Je(e);g.current=e;let w=Je(!0);gt(()=>(w.current=!0,()=>{w.current=!1}),[]);let k=s=>{u.current=s,w.current&&c(s)},p=s=>{if(s.preventDefault(),s.stopPropagation(),u.current==="adding")return;k("adding");let f;try{f=Promise.resolve(a(g.current))}catch(I){f=Promise.reject(I)}f.then(()=>k("added"),()=>k(null))};return B("span",{className:z.cart,"data-aia-product-cart":"","data-aia-cart-state":i??void 0,"aria-busy":i==="adding"?!0:void 0,role:"button","aria-label":n,tabIndex:t?0:-1,onClick:p,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||p(s)},onFocus:s=>{s.stopPropagation(),o()},onBlur:s=>{s.stopPropagation(),r(s)},children:_e("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[B("path",{className:z.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"}),B("path",{className:z.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),B("path",{className:z.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),B("path",{className:z.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),B("circle",{className:z.cartGlyph,cx:"9",cy:"20",r:"1.3"}),B("circle",{className:z.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Ga({sources:e,title:n,fallback:t,onPhotoFill:a}){let[o,r]=et(0),i=e[o],c=!!i,[u,g]=et(null),w=!c&&t==="initial";return gt(()=>()=>a(null),[a]),_e("span",{className:z.media,"aria-hidden":"true","data-aia-product-placeholder":!c&&!w?"":void 0,"data-aia-product-initial":w?"":void 0,"data-aia-image-loaded":c&&u===i?"":void 0,children:[c?B("img",{className:z.image,src:i,alt:"",loading:"lazy",decoding:"async",onLoad:k=>{g(i),a(Ma(k.currentTarget.naturalWidth,k.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&a(null),r(k=>k+1)}}):null,w?za(n):null]})}import{isOptionsGridMobileViewport as ei,measureOptionsGrid as ti,needsOptionsGridMeasurement as ai,OPTIONS_GRID_MOBILE_QUERY as ii,optionEnterDelayMs as oi,optionsShowLeadingVisuals as ni,planOptionsGrid as Ft,sameOptionRows as ri}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as si,useLayoutEffect as li,useRef as Ht,useState as Gt}from"react";import{optionsGridTemplateColumns as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as qa,useRef as Wa}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 {
2149
+ `,document.head.appendChild(e)}var z={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",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 W,jsxs as $e}from"react/jsx-runtime";function Ht({products:e,listboxId:n,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:r=!0,layout:o="row",imageFallback:s="image",strings:h=qa()}){let b=e.length>0,x=ot(null);if(bt(()=>{let l=x.current;if(!(!b||!l))return Fa(l)},[b]),!b)return null;let m=`${n}-products-label`;return $e("section",{className:z.section,"data-aia-products":"","data-aia-products-layout":o,role:"group","aria-labelledby":m,children:[W("div",{className:z.label,id:m,"data-aia-products-label":"",children:h.products}),W("div",{ref:x,className:z.row,"data-aia-products-row":"",children:e.map((l,d)=>W(_a,{product:l,id:`${n}-product-${d}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:r,imageFallback:s,soldOut:h.soldOut,addToCart:h.addToCart},l.id))})]})}function _a({product:e,id:n,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:r,imageFallback:o,soldOut:s,addToCart:h}){let b=!!a&&e.available!==!1,[x,m]=nt(null),l=w=>{w.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},d=w=>{w.metaKey||w.ctrlKey||w.shiftKey||w.altKey||w.button!==0||(w.preventDefault(),t(e))};return $e("a",{id:n,className:z.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":b?"":void 0,role:"option","aria-selected":!1,style:x?{"--aia-product-photo-fill-x":String(x.x),"--aia-product-photo-fill-y":String(x.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:d,onKeyDown:w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:l,children:[W(Ya,{sources:Ba(e.imageUrl),title:e.title,fallback:o,onPhotoFill:m},Wa(e.imageUrl)??""),$e("span",{className:z.body,children:[e.vendor?W("span",{className:z.vendor,children:e.vendor}):null,W("span",{className:z.title,children:e.title}),e.price?W("span",{className:z.price,children:e.price}):null,e.available===!1?W("span",{className:z.badge,children:s}):null]}),b&&a?W(Va,{product:e,label:`${h}: ${e.title}`,focusable:r,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:l},Ua(e)):null]})}function Ua(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(n=>n??"").join("\0")}function Va({product:e,label:n,focusable:t,onAddToCart:a,onFocus:i,onBlur:r}){let[o,s]=nt(null),h=ot(null),b=ot(e);b.current=e;let x=ot(!0);bt(()=>(x.current=!0,()=>{x.current=!1}),[]);let m=d=>{h.current=d,x.current&&s(d)},l=d=>{if(d.preventDefault(),d.stopPropagation(),h.current==="adding")return;m("adding");let w;try{w=Promise.resolve(a(b.current))}catch(I){w=Promise.reject(I)}w.then(()=>m("added"),()=>m(null))};return W("span",{className:z.cart,"data-aia-product-cart":"","data-aia-cart-state":o??void 0,"aria-busy":o==="adding"?!0:void 0,role:"button","aria-label":n,tabIndex:t?0:-1,onClick:l,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||l(d)},onFocus:d=>{d.stopPropagation(),i()},onBlur:d=>{d.stopPropagation(),r(d)},children:$e("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[W("path",{className:z.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"}),W("path",{className:z.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),W("path",{className:z.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),W("path",{className:z.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),W("circle",{className:z.cartGlyph,cx:"9",cy:"20",r:"1.3"}),W("circle",{className:z.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Ya({sources:e,title:n,fallback:t,onPhotoFill:a}){let[i,r]=nt(0),o=e[i],s=!!o,[h,b]=nt(null),x=!s&&t==="initial";return bt(()=>()=>a(null),[a]),$e("span",{className:z.media,"aria-hidden":"true","data-aia-product-placeholder":!s&&!x?"":void 0,"data-aia-product-initial":x?"":void 0,"data-aia-image-loaded":s&&h===o?"":void 0,children:[s?W("img",{className:z.image,src:o,alt:"",loading:"lazy",decoding:"async",onLoad:m=>{b(o),a(Ka(m.currentTarget.naturalWidth,m.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),r(m=>m+1)}}):null,x?Ga(n):null]})}import{isOptionsGridMobileViewport as si,measureOptionsGrid as li,needsOptionsGridMeasurement as di,OPTIONS_GRID_MOBILE_QUERY as ci,optionEnterDelayMs as pi,optionsShowLeadingVisuals as hi,planOptionsGrid as Gt,sameOptionRows as ui}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as mi,useLayoutEffect as gi,useRef as Kt,useState as _t}from"react";import{optionsGridTemplateColumns as ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Qa,useRef as $a}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 {
2120
2150
  display: grid;
2121
2151
  grid-template-columns: repeat(
2122
2152
  auto-fit,
@@ -2152,7 +2182,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
2152
2182
  .aia-grid[data-scroll]::-webkit-scrollbar {
2153
2183
  display: none;
2154
2184
  }
2155
- `,document.head.appendChild(e)}import{jsx as Ua}from"react/jsx-runtime";function zt({min:e="16rem",max:n,gap:t,scroll:a=!1,maxHeight:o,scrollResetKey:r,cols:i,template:c,innerRef:u,className:g,children:w,...k}){let p=Wa(null);qa(()=>{if(r===void 0)return;let f=p.current;f&&(f.scrollTop=0)},[r]);let s={"--aia-grid-min":e};return n&&(s["--aia-grid-max"]=n),t&&(s["--aia-grid-gap"]=t),o&&(s["--aia-grid-max-height"]=o),i&&(s.gridTemplateColumns=Ka(i)),c&&(s.gridTemplateColumns=c),Ua("div",{ref:f=>{p.current=f,u?.(f)},className:g?`aia-grid ${g}`:"aia-grid","data-scroll":a||void 0,style:s,...k,children:w})}import{formatOptionCount as _a,highlightParts as ja,OPTION_ENTER_DELAY_VAR as Va,optionImageSources as Ya,optionLabel as Mt,sanitizeOptionIconSvg as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $a,useMemo as Za,useRef as Xa,useState as tt}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 {
2185
+ `,document.head.appendChild(e)}import{jsx as Za}from"react/jsx-runtime";function Ft({min:e="16rem",max:n,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:r,cols:o,template:s,innerRef:h,className:b,children:x,...m}){let l=$a(null);Qa(()=>{if(r===void 0)return;let w=l.current;w&&(w.scrollTop=0)},[r]);let d={"--aia-grid-min":e};return n&&(d["--aia-grid-max"]=n),t&&(d["--aia-grid-gap"]=t),i&&(d["--aia-grid-max-height"]=i),o&&(d.gridTemplateColumns=ja(o)),s&&(d.gridTemplateColumns=s),Za("div",{ref:w=>{l.current=w,h?.(w)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":a||void 0,style:d,...m,children:x})}import{formatOptionCount as Xa,highlightParts as Ja,OPTION_ENTER_DELAY_VAR as ei,optionImageSources as ti,optionLabel as Bt,sanitizeOptionIconSvg as ai}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ii,useMemo as oi,useRef as ni,useState as rt}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 {
2156
2186
  position: relative;
2157
2187
  /* Clip, not visible: the entrance rise below runs on the inner content,
2158
2188
  and a transformed box extends its scroll container's scrollable area.
@@ -2610,7 +2640,163 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
2610
2640
  opacity: 0;
2611
2641
  }
2612
2642
  }
2613
- `,document.head.appendChild(e)}var W={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",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{Fragment as Ja,jsx as Ce,jsxs as mt}from"react/jsx-runtime";function Nt({option:e,isHighlighted:n,onSelect:t,onHighlight:a,onUnhighlight:o,id:r,loading:i,showIcon:c=!0,showImage:u=!0,showCount:g=!0,scrollHint:w,enterDelayMs:k=0}){let[p]=tt(k),[s,f]=tt(!1),I=u?Ya(e.image_url):[],M=I[0]??null,[q,U]=tt([]),T=I.find(R=>!q.includes(R))??null,[D,N]=tt(null),S=Za(()=>!M&&c&&e.icon_svg?Qa(e.icon_svg):null,[M,c,e.icon_svg]),_=g?_a(e.item_count):null,H=Xa(void 0);$a(()=>()=>clearTimeout(H.current),[]);let K=()=>{i||!e.is_tappable||s||(f(!0),t(e),clearTimeout(H.current),H.current=setTimeout(()=>f(!1),170))},X=[W.item,n&&!i?W.highlighted:"",e.is_tappable?W.tappable:W.nonTappable,s?W.pressed:"",w?W.scrollHint:""].filter(Boolean).join(" ");return Ce("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":S&&e.icon?e.icon:void 0,"data-aia-image":M?"":void 0,"data-aia-item-count":_!==null?e.item_count:void 0,"aria-selected":n,className:X,style:{[Va]:`${p}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:K,onKeyDown:R=>{!i&&e.is_tappable&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),K())},onMouseEnter:!i&&e.is_tappable?a:void 0,onMouseLeave:o,children:mt("span",{className:W.content,children:[M&&Ce("span",{className:`${W.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":T!==null&&D===T?"":void 0,children:Ce("img",{src:T??M,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onLoad:()=>N(T),onError:()=>{T!==null&&U(R=>[...R,T])}})}),S&&Ce("span",{className:`${W.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:S}}),mt("span",{className:W.text,children:[e.matchedText?ja(Mt(e),e.matchedText).map((R,j)=>R.bold?Ce("strong",{className:`${W.match} magicx-aia-option-match`,children:R.text},j):R.text):Mt(e),e.parameterLabel&&mt(Ja,{children:[" ",Ce("span",{className:`${W.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Ce("span",{className:W.tag,children:e.tag}),_!==null&&Ce("span",{className:`${W.count} magicx-aia-option-count`,children:_})]})})}import{jsx as Bt}from"react/jsx-runtime";function di(){let[e,n]=Gt(ei);return si(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ii),a=()=>n(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Kt({options:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:r,loading:i,groupKey:c="",optionsPosition:u="below",showIcons:g=!0,showImages:w=!0,showCounts:k=!0}){let p=di(),s=Ht(null),[f,I]=Gt(null),M=Ht(null);li(()=>{if(i&&ri(M.current,e))return;M.current=i?null:e;let T=s.current,N=T&&!i&&ai(e.length,p)?ti(T):null;I(N?Ft(e.length,p,N.rowWidths,N.gridWidth):null)},[e,p,i]);let q=f??Ft(e.length,p,null,null),U=ni(e,g,w);return Bt(zt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:c,template:q.template,maxHeight:q.maxHeight,innerRef:T=>{s.current=T},"data-aia-group":c,children:e.map((T,D)=>Bt(Nt,{option:T,isHighlighted:D===n,onSelect:t,onHighlight:()=>a(D),onUnhighlight:o?()=>o(D):void 0,id:`${r}-option-${D}`,loading:i,showIcon:g&&U,showImage:w&&U,showCount:k,scrollHint:!i&&q.scrollHintIndices.includes(D),enterDelayMs:i?0:oi(D,q.cols,e.length,u)},`${c}\0${T.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2643
+
2644
+ .aia-content-T-Qba:has(.aia-checkbox-KGRhg) {
2645
+ display: flex;
2646
+ align-items: center;
2647
+ gap: 10px;
2648
+ }
2649
+
2650
+ .aia-checkbox-KGRhg {
2651
+ display: inline-flex;
2652
+ align-items: center;
2653
+ justify-content: center;
2654
+ flex: 0 0 18px;
2655
+ width: 18px;
2656
+ height: 18px;
2657
+ border: 1px solid var(--aia-border);
2658
+ border-radius: 6px;
2659
+ background: var(--aia-surface);
2660
+ color: transparent;
2661
+ font-size: 11px;
2662
+ line-height: 1;
2663
+ }
2664
+
2665
+ .aia-checkbox-KGRhg[data-checked="true"] {
2666
+ background: rgba(var(--aia-streak-rgb, 99, 102, 241), 0.16);
2667
+ border-color: rgba(var(--aia-streak-rgb, 99, 102, 241), 0.45);
2668
+ color: rgb(var(--aia-streak-rgb, 99, 102, 241));
2669
+ }
2670
+
2671
+ .aia-item-d4vpD:has(.aia-checkbox-KGRhg[data-checked="true"]) {
2672
+ background: var(--aia-option-bg, transparent);
2673
+ }
2674
+ `,document.head.appendChild(e)}var _={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",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd",checkbox:"aia-checkbox-KGRhg"};import{Fragment as ri,jsx as ge,jsxs as wt}from"react/jsx-runtime";function Wt({option:e,isHighlighted:n,checked:t,onSelect:a,onHighlight:i,onUnhighlight:r,id:o,loading:s,showIcon:h=!0,showImage:b=!0,showCount:x=!0,scrollHint:m,enterDelayMs:l=0}){let[d]=rt(l),[w,I]=rt(!1),j=b?ti(e.image_url):[],H=j[0]??null,[K,U]=rt([]),P=j.find(E=>!K.includes(E))??null,[R,S]=rt(null),Q=oi(()=>!H&&h&&e.icon_svg?ai(e.icon_svg):null,[H,h,e.icon_svg]),F=x?Xa(e.item_count):null,B=ni(void 0);ii(()=>()=>clearTimeout(B.current),[]);let Z=()=>{s||!e.is_tappable||w&&t===void 0||(I(!0),a(e),clearTimeout(B.current),B.current=setTimeout(()=>I(!1),170))},ee=[_.item,n&&!s?_.highlighted:"",e.is_tappable?_.tappable:_.nonTappable,w?_.pressed:"",m?_.scrollHint:""].filter(Boolean).join(" ");return ge("div",{id:o,role:"option","data-aia-option":"","data-aia-loading":s?"":void 0,"data-aia-icon":Q&&e.icon?e.icon:void 0,"data-aia-image":H?"":void 0,"data-aia-item-count":F!==null?e.item_count:void 0,"aria-selected":t??n,className:ee,style:{[ei]:`${d}ms`},tabIndex:s||!e.is_tappable?-1:0,onClick:Z,onKeyDown:E=>{!s&&e.is_tappable&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),Z())},onMouseEnter:!s&&e.is_tappable?i:void 0,onMouseLeave:r,children:wt("span",{className:_.content,children:[t!==void 0&&ge("span",{className:_.checkbox,"aria-hidden":"true","data-checked":t,children:t?"\u2713":""}),H&&ge("span",{className:`${_.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":P!==null&&R===P?"":void 0,children:ge("img",{src:P??H,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:P===null,onLoad:()=>S(P),onError:()=>{P!==null&&U(E=>[...E,P])}})}),Q&&ge("span",{className:`${_.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:Q}}),wt("span",{className:_.text,children:[e.matchedText?Ja(Bt(e),e.matchedText).map((E,te)=>E.bold?ge("strong",{className:`${_.match} magicx-aia-option-match`,children:E.text},te):E.text):Bt(e),e.parameterLabel&&wt(ri,{children:[" ",ge("span",{className:`${_.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&ge("span",{className:_.tag,children:e.tag}),F!==null&&ge("span",{className:`${_.count} magicx-aia-option-count`,children:F})]})})}import{jsx as qt}from"react/jsx-runtime";function fi(){let[e,n]=_t(si);return mi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ci),a=()=>n(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Ut({options:e,activeIndex:n,picked:t,onSelect:a,onHighlight:i,onUnhighlight:r,listboxId:o,loading:s,groupKey:h="",optionsPosition:b="below",showIcons:x=!0,showImages:m=!0,showCounts:l=!0}){let d=fi(),w=Kt(null),[I,j]=_t(null),H=Kt(null);gi(()=>{if(s&&ui(H.current,e))return;H.current=s?null:e;let P=w.current,S=P&&!s&&di(e.length,d)?li(P):null;j(S?Gt(e.length,d,S.rowWidths,S.gridWidth):null)},[e,d,s]);let K=I??Gt(e.length,d,null,null),U=hi(e,x,m);return qt(Ft,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:h,template:K.template,maxHeight:K.maxHeight,innerRef:P=>{w.current=P},"data-aia-group":h,children:e.map((P,R)=>qt(Wt,{option:P,isHighlighted:R===n,checked:t?t.includes(P.text):void 0,onSelect:a,onHighlight:()=>i(R),onUnhighlight:r?()=>r(R):void 0,id:`${o}-option-${R}`,loading:s,showIcon:x&&U,showImage:m&&U,showCount:l,scrollHint:!s&&K.scrollHintIndices.includes(R),enterDelayMs:s?0:pi(R,K.cols,e.length,b)},`${h}\0${P.text}`))})}import{formatTime as bi,TIME_WHEEL_COLUMNS as wi,TIME_WHEEL_ROW_HEIGHT as vi,timeWheelIndex as Vt,timeWheelIndexFromScroll as xi,timeWheelRows as yi,withTimeWheelIndex as Yt}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as ki,useEffect as Si,useLayoutEffect as Ci,useRef as st}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) ---
2675
+
2676
+ One of three hand-maintained copies (vanilla styles.css, this file, Angular's
2677
+ time-wheel.component.css). Only the class-naming layer differs \u2014 the
2678
+ declarations must match, and \`timeWheelParity.test.ts\` fails the build if
2679
+ they drift. See CLAUDE.md's duplicated-stylesheet rule.
2680
+
2681
+ Colours go through the same --aia-option-* chain as the option rows and the
2682
+ calendar (see DateGrid.module.css for why). The 30px row height is
2683
+ load-bearing: the component turns a column's scroll offset into a row as
2684
+ \`scrollTop / 30\` (TIME_WHEEL_ROW_HEIGHT in the core), so it is not a token. */
2685
+ .aia-timeWheel-KdR4A {
2686
+ display: flex;
2687
+ flex-direction: column;
2688
+ align-items: center;
2689
+ gap: 8px;
2690
+ padding: 6px 6px 4px;
2691
+ }
2692
+
2693
+ /* Announces the time to AT (the wheels themselves are aria-hidden). */
2694
+ .aia-value--wqvm {
2695
+ position: absolute;
2696
+ width: 1px;
2697
+ height: 1px;
2698
+ overflow: hidden;
2699
+ clip-path: inset(50%);
2700
+ white-space: nowrap;
2701
+ }
2702
+
2703
+ .aia-columns-TaD-f {
2704
+ position: relative;
2705
+ display: flex;
2706
+ align-items: flex-start;
2707
+ justify-content: center;
2708
+ gap: 2px;
2709
+ width: 100%;
2710
+ }
2711
+
2712
+ /* The one soft band the chosen time sits in, behind the wheels' top rows. */
2713
+ .aia-band-pVy-f {
2714
+ position: absolute;
2715
+ top: 0;
2716
+ right: 0;
2717
+ left: 0;
2718
+ height: 30px;
2719
+ border-radius: 8px;
2720
+ background: var(--aia-time-band-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08));
2721
+ pointer-events: none;
2722
+ }
2723
+
2724
+ .aia-column-lwtdd {
2725
+ position: relative;
2726
+ flex: 0 0 auto;
2727
+ width: 44px;
2728
+ /* Three rows show: the chosen one and the two after it. The bottom padding
2729
+ lets the last row scroll up to the top; border-box keeps it inside those
2730
+ 90px, where it only adds scroll range, rather than adding 60px of visible
2731
+ column below them. */
2732
+ height: 90px;
2733
+ padding-bottom: 60px;
2734
+ box-sizing: border-box;
2735
+ overflow-y: auto;
2736
+ overscroll-behavior: contain;
2737
+ scroll-snap-type: y mandatory;
2738
+ scrollbar-width: none;
2739
+ -webkit-mask-image: linear-gradient(to bottom, #000 34%, transparent 100%);
2740
+ mask-image: linear-gradient(to bottom, #000 34%, transparent 100%);
2741
+ }
2742
+
2743
+ .aia-column-lwtdd::-webkit-scrollbar {
2744
+ display: none;
2745
+ }
2746
+
2747
+ .aia-row-A3pAx {
2748
+ display: flex;
2749
+ align-items: center;
2750
+ justify-content: center;
2751
+ height: 30px;
2752
+ scroll-snap-align: start;
2753
+ font-family: inherit;
2754
+ font-size: var(--aia-time-font-size, 15px);
2755
+ font-variant-numeric: tabular-nums;
2756
+ font-weight: 450;
2757
+ line-height: 20px;
2758
+ color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
2759
+ cursor: pointer;
2760
+ }
2761
+
2762
+ .aia-selected-xgOWY {
2763
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2764
+ font-weight: 500;
2765
+ }
2766
+
2767
+ .aia-separator-kX9WO {
2768
+ display: flex;
2769
+ align-items: center;
2770
+ height: 30px;
2771
+ font-size: var(--aia-time-font-size, 15px);
2772
+ font-weight: 500;
2773
+ line-height: 20px;
2774
+ color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
2775
+ }
2776
+
2777
+ .aia-done-llNY5 {
2778
+ align-self: stretch;
2779
+ height: 32px;
2780
+ padding: 0 12px;
2781
+ border: none;
2782
+ border-radius: 8px;
2783
+ background: var(--aia-time-done-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.1));
2784
+ font-family: inherit;
2785
+ font-size: 13px;
2786
+ font-weight: 500;
2787
+ line-height: 20px;
2788
+ color: var(
2789
+ --aia-time-done-color,
2790
+ var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
2791
+ );
2792
+ cursor: pointer;
2793
+ transition: background-color 150ms ease-out;
2794
+ }
2795
+
2796
+ .aia-done-llNY5:hover {
2797
+ background: var(--aia-time-done-bg-hover, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.16));
2798
+ }
2799
+ `,document.head.appendChild(e)}var oe={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 Le,jsxs as vt}from"react/jsx-runtime";var Ti=120;function jt({view:e,label:n,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:r}){return vt("div",{className:oe.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":n,onMouseDown:o=>o.preventDefault(),children:[Le("span",{className:oe.value,"data-aia-time-value":"","aria-live":"polite",children:bi(e.minutes)}),vt("div",{className:oe.columns,"aria-hidden":"true",children:[Le("div",{className:oe.band}),wi.map(o=>vt(ki,{children:[o==="minute"&&Le("span",{className:oe.separator,children:":"}),Le(Pi,{column:o,minutes:e.minutes,interactive:a,onTimeChange:i})]},o))]}),Le("button",{type:"button",tabIndex:-1,className:oe.done,"data-aia-time-done":"",onClick:()=>{a&&r()},children:t})]})}function Pi({column:e,minutes:n,interactive:t,onTimeChange:a}){let i=st(null),r=st(null),o=st(null),s=st({minutes:n,interactive:t,onTimeChange:a});s.current={minutes:n,interactive:t,onTimeChange:a};let h=Vt(e,n);Ci(()=>{let m=i.current;if(!m||o.current)return;let l=h*vi;Math.abs(m.scrollTop-l)<1||(r.current=l,m.scrollTop=l)},[h]),Si(()=>()=>{o.current&&clearTimeout(o.current)},[]);let b=()=>{o.current=null;let m=i.current,l=s.current;if(!m||!l.interactive)return;let d=xi(e,m.scrollTop);d!==Vt(e,l.minutes)&&l.onTimeChange(Yt(e,l.minutes,d))},x=()=>{let m=i.current;if(m){if(r.current!=null&&Math.abs(m.scrollTop-r.current)<1){r.current=null;return}r.current=null,o.current&&clearTimeout(o.current),o.current=setTimeout(b,Ti)}};return Le("div",{ref:i,className:oe.column,"data-aia-time-column":e,onScroll:x,children:yi(e).map((m,l)=>Le("div",{className:l===h?`${oe.row} ${oe.selected}`:oe.row,"data-aia-time-row":"","data-aia-index":l,onClick:()=>{s.current.interactive&&a(Yt(e,s.current.minutes,l))},children:m.label},m.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2614
2800
  display: flex;
2615
2801
  flex-direction: column;
2616
2802
  gap: var(--aia-stack-space, 0.5rem);
@@ -2625,7 +2811,7 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
2625
2811
  align-items: end;
2626
2812
  }
2627
2813
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2628
- `,document.head.appendChild(e)}import{jsx as ci}from"react/jsx-runtime";function qt({space:e,align:n="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return ci("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:r,...o,children:a})}import{jsx as Z,jsxs as ft}from"react/jsx-runtime";var vi=[159,119,164],xi=()=>{},Wt=()=>{};function yi(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=wi(n);if(Me(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ki(e,n){let t=ze(null);Me(()=>{let a=e.current,o=n.current;if(!a||!o)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:pi({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),Me(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ci(e,n){let t=ze(n);t.current=n;let a=ze(null);Me(()=>{let o=e.current;if(o){if(!a.current){a.current=hi({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),Me(()=>()=>{a.current?.destroy(),a.current=null},[])}function bt({suggestions:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:i,className:c,pills:u,onPillClick:g,showPills:w=!0,onSkip:k,showSkipButton:p=!0,showOptionIcons:s=!0,showOptionImages:f=!0,showOptionCounts:I=!0,skipDisabled:M=!1,activeSelected:q=!1,isLoading:U=!1,skeletonExiting:T=!1,isInputEmpty:D=!1,language:N,products:S,onProductSelect:_,onProductAddToCart:H,onProductFocusChange:K,productsLayout:X="row",productImageFallback:R="image",formatType:j="options",dateView:se=null,selectedDateIso:ue=null,selectedDateRange:le=null,dateRangeStart:Se=null,onPreviousMonth:ge,onNextMonth:m,optionsPosition:me="below",mode:fe}){let de=yi(fe),be=de!==void 0,$=ze(null),l=ze(null);ki($,l),Me(()=>{if($.current)return ui($.current)},[]);let v=e[0]?.options??[],y=!!(u&&u.length>0&&g),P=!!(S&&S.length>0),C=r&&(v.length>0||w&&y||U||P);Ci($,C);let O={suggestions:e,activeIndex:n,pills:u,showPills:w,showSkipButton:p,showOptionIcons:s,showOptionImages:f,showOptionCounts:I,skipDisabled:M,activeSelected:q,isLoading:U,skeletonExiting:T,isInputEmpty:D,products:S,formatType:j,dateView:se,selectedDateIso:ue,selectedDateRange:le,dateRangeStart:Se},Q=ze(O);C&&(Q.current=O);let h=C?O:Q.current,V=bi(N),ee=h.suggestions[0],te=ee?.options??[],Pe=h.activeIndex>=0&&!!te[h.activeIndex]?.is_tappable,ae=fi(h.pills??[],V.keepTyping),ie=!!(ae.length>0&&g),Te=h.showPills&&ie,ce=h.showPills&&!ie&&h.isLoading,we=Te||ce,ve=ie&&gi(ae)&&h.showSkipButton&&!h.isInputEmpty&&!!k,x=ae[0]?.text,Re=mi(h.formatType)&&h.dateView!=null,De=te.length>0&&!Re,oe=te.length>0&&Re&&!h.isLoading,b=h.isLoading&&!De&&!oe,xe=h.products??[];return ft("div",{ref:$,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":me,"data-mode":de,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":xe.length>0?"":void 0,className:`${be?"magicx-aia ":""}${pe.dropdown} ${C?pe.visible:""} ${c??""}`,onMouseDown:ye=>ye.preventDefault(),children:[ft(qt,{space:"8px",children:[(we||ve)&&ft(We,{noWrap:!0,className:pe.pillBar,"data-aia-pillbar":"",children:[we&&Z("span",{className:pe.pillScroll,"data-aia-pill-scroll":"",children:Z(Xe,{pills:ae,activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:h.isLoading})}),ve&&Z("button",{type:"button",tabIndex:-1,className:pe.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":x?`${V.skipLabel} ${x}`:V.skipLabel,onClick:k,children:V.skip})]}),De&&Z(Kt,{options:te,activeIndex:h.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:i,loading:h.isLoading,groupKey:ee?`${ee.parameter} ${ee.text}`:"",optionsPosition:me,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts}),oe&&h.dateView&&Z(Et,{options:te,activeIndex:h.activeIndex,listboxId:i,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:ge??Wt,onNextMonth:m??Wt}),b&&Z("div",{className:pe.skeletonBars,"data-aia-skeleton-bars":"",children:vi.map(ye=>Z("span",{className:pe.skeletonBar,style:{width:ye}},`bar-${ye}`))}),Z(Lt,{products:xe,listboxId:i,onSelect:_??xi,onAddToCart:H,onFocusChange:K,focusable:C,layout:X,imageFallback:R,strings:V}),Z(Rt,{isOptionHighlighted:Pe,isInputEmpty:h.isInputEmpty,strings:V})]}),Z("button",{ref:l,type:"button",tabIndex:-1,className:pe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":V.scrollArrow,"aria-hidden":"true",children:Z("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:Z("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Hi,ModeController as Bi,setCursorOffset as Gi,uiStringsFor as Ki}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Si}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 {
2814
+ `,document.head.appendChild(e)}import{jsx as Ii}from"react/jsx-runtime";function Qt({space:e,align:n="stretch",className:t,children:a,...i}){let r=e?{"--aia-stack-space":e}:void 0;return Ii("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:r,...i,children:a})}import{jsx as Y,jsxs as xt}from"react/jsx-runtime";var Ni=[159,119,164],Hi=()=>{},$t=()=>{},Fi=e=>{},Bi=()=>{};function Wi(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=zi(n);if(Be(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(i.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Gi(e,n){let t=Fe(null);Be(()=>{let a=e.current,i=n.current;if(!a||!i)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:Ei({dropdown:a,grid:r,button:i})};return}t.current?.controller.update()}),Be(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ki(e,n){let t=Fe(n);t.current=n;let a=Fe(null);Be(()=>{let i=e.current;if(i){if(!a.current){a.current=Ai({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Be(()=>()=>{a.current?.destroy(),a.current=null},[])}function yt({suggestions:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:r,id:o,className:s,pills:h,onPillClick:b,showPills:x=!0,onSkip:m,showSkipButton:l=!0,showOptionIcons:d=!0,showOptionImages:w=!0,showOptionCounts:I=!0,skipDisabled:j=!1,activeSelected:H=!1,isLoading:K=!1,skeletonExiting:U=!1,isInputEmpty:P=!1,language:R,products:S,onProductSelect:Q,onProductAddToCart:F,onProductFocusChange:B,productsLayout:Z="row",productImageFallback:ee="image",formatType:E="options",dateView:te=null,selectedDateIso:fe=null,selectedDateRange:ce=null,dateRangeStart:Ie=null,onPreviousMonth:be,onNextMonth:g,timeView:we=null,multiSelectView:ve=null,onMultiSelectCommit:xe,onTimeChange:ye,onTimeCommit:ke,optionsPosition:u="below",mode:y}){let k=Wi(y),T=k!==void 0,C=Fe(null),L=Fe(null);Gi(C,L),Be(()=>{if(C.current)return Ri(C.current)},[]);let X=e[0]?.options??[],V=!!(h&&h.length>0&&b),Se=!!(S&&S.length>0),Ee=E==="time"&&we!=null,re=r&&(X.length>0||x&&V||K||Se||Ee);Ki(C,re);let pe={suggestions:e,activeIndex:n,pills:h,showPills:x,showSkipButton:l,showOptionIcons:d,showOptionImages:w,showOptionCounts:I,skipDisabled:j,activeSelected:H,isLoading:K,skeletonExiting:U,isInputEmpty:P,products:S,formatType:E,dateView:te,selectedDateIso:fe,selectedDateRange:ce,dateRangeStart:Ie,timeView:we,multiSelectView:ve},Ce=Fe(pe);re&&(Ce.current=pe);let p=re?pe:Ce.current,q=Mi(R),J=p.suggestions[0],ae=J?.options??[],Ae=p.activeIndex>=0&&!!ae[p.activeIndex]?.is_tappable,v=Li(p.pills??[],q.keepTyping),Re=!!(v.length>0&&b),qe=p.showPills&&Re,he=p.showPills&&!Re&&p.isLoading,f=qe||he,Te=Re&&Oi(v)&&p.showSkipButton&&!p.isInputEmpty&&!!m,Me=v[0]?.text,Pe=Di(p.formatType)&&p.dateView!=null,ze=ae.length>0&&!Pe,Ne=ae.length>0&&Pe&&!p.isLoading,ue=p.formatType==="time"&&p.timeView!=null&&!p.isLoading,_e=p.isLoading&&!ze&&!Ne&&!ue,ie=p.products??[];return xt("div",{ref:C,id:o,role:"listbox","aria-multiselectable":!!p.multiSelectView,"data-aia-dropdown":"","data-options-position":u,"data-mode":k,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":ie.length>0?"":void 0,className:`${T?"magicx-aia ":""}${se.dropdown} ${re?se.visible:""} ${s??""}`,onMouseDown:M=>M.preventDefault(),children:[xt(Qt,{space:"8px",children:[(f||Te)&&xt(je,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[f&&Y("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:Y(it,{pills:v,activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:p.isLoading})}),Te&&Y("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":Me?`${q.skipLabel} ${Me}`:q.skipLabel,onClick:m,children:q.skip})]}),ze&&Y(Ut,{options:ae,activeIndex:p.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:o,loading:p.isLoading,groupKey:J?`${J.parameter} ${J.text}`:"",optionsPosition:u,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts,picked:p.isLoading?void 0:p.multiSelectView?.picked}),p.multiSelectView&&!p.isLoading&&Y("div",{onClick:M=>{M.target.closest("[data-aia-multi-done]")&&!p.skipDisabled&&xe?.()},children:Y("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:se.multiDone,ref:M=>{M&&(M.disabled=!0,M.offsetHeight,M.disabled=p.skipDisabled)},children:q.done})}),Ne&&p.dateView&&Y(Dt,{options:ae,activeIndex:p.activeIndex,listboxId:o,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:be??$t,onNextMonth:g??$t}),ue&&p.timeView&&Y(jt,{view:p.timeView,label:q.timeLabel,doneLabel:q.done,interactive:!p.skipDisabled,onTimeChange:ye??Fi,onTimeCommit:ke??Bi}),_e&&Y("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Ni.map(M=>Y("span",{className:se.skeletonBar,style:{width:M}},`bar-${M}`))}),Y(Ht,{products:ie,listboxId:o,onSelect:Q??Hi,onAddToCart:F,onFocusChange:B,focusable:re,layout:Z,imageFallback:ee,strings:q}),Y(Mt,{isOptionHighlighted:Ae,isInputEmpty:p.isInputEmpty,strings:q})]}),Y("button",{ref:L,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":q.scrollArrow,"aria-hidden":"true",children:Y("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:Y("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as io,ModeController as oo,setCursorOffset as no,uiStringsFor as ro}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as qi}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 {
2629
2815
  flex-shrink: 0;
2630
2816
  width: 32px;
2631
2817
  height: 32px;
@@ -2678,5 +2864,5 @@ import{buildSubmitResult as Hn,cellDay as Bn,cellIso as Gn,DATE_RANGE_META_END a
2678
2864
  );
2679
2865
  cursor: default;
2680
2866
  }
2681
- `,document.head.appendChild(e)}var Ut={submitButton:"aia-submitButton-otz7H"};import{jsx as wt}from"react/jsx-runtime";function _t({disabled:e,onClick:n,label:t=Si().submit}){return wt("button",{type:"button","data-aia-submit":"",className:Ut.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":t,children:wt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:wt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Pi,dateSelectionFor as Ti,identifiedParamLabel as Ii,withoutTraditionalAutocomplete as Ei}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as $t,useEffect as Ne,useRef as G,useState as Ai}from"react";import{useRef as jt}from"react";function Vt(e){let n=jt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=jt({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let i=(c,u,g)=>{let w=n.current?.[r];return w?w(c,u,g):[]};o[r]=i}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as Yt}from"react";function Qt(e){let n=Yt(e);n.current=e;let t=Yt(null);t.current===null&&(t.current={fetch:(o,r)=>{let i=n.current;return i?i.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>n.current?.transform(o)??[],get limit(){return n.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Zt={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,placeholderText:"",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};function vt({onSubmit:e,onResult:n,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:i,language:c,currency:u,productId:g,visitorId:w,columns:k=2,dropdownTrigger:p,optionsPosition:s,closeDropdownOnBlur:f,showNonTappableOptions:I,showOptionIcons:M,showOptionImages:q,showOptionCounts:U,showSkipButton:T,showProducts:D,productImageFallback:N="image",onFocus:S,onBlur:_,value:H,completedParams:K,onChange:X,onParamsChange:R,products:j,mapProducts:se,onProductSelect:ue,onProductAddToCart:le,source:Se,setCursor:ge}){let m=G(null),[me,fe]=Ai(null),de=G(e);de.current=e;let be=G(n);be.current=n;let $=G(t);$.current=t;let l=G(X);l.current=X;let v=G(R);v.current=R;let y=G(S);y.current=S;let P=G(_);P.current=_;let C=G(ge);C.current=ge;let O=G(ue);O.current=ue;let Q=G(le);Q.current=le;let h=G(w);h.current=w;let V=G(()=>{let d=h.current;return typeof d=="function"?d():d}).current,ee=Qt(j),te=G(se);te.current=se;let Pe=G((d,F)=>{let E=te.current;return E?E(d,F):d}).current,ae=se?Pe:void 0,ie=Vt(a);Ne(()=>{if(typeof document>"u")return;let d=new Pi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:c,currency:u,productId:g,visitorId:V,optionOverrides:ie.overrides,maskCompletedText:o,columns:k,dropdownTrigger:p,optionsPosition:s,closeDropdownOnBlur:f,showNonTappableOptions:I,showProducts:D,source:Se,value:H,completedParams:K,onSubmit:(...E)=>de.current?.(...E),onResult:(...E)=>be.current?.(...E),onError:(...E)=>$.current?.(...E),onChange:(...E)=>l.current?.(...E),onParamsChange:(...E)=>v.current?.(...E),onFocus:()=>y.current?.(),onBlur:()=>P.current?.(),onProductSelect:E=>O.current?.(E),onProductAddToCart:E=>Q.current?.(E),setCursor:E=>C.current?.(E),products:ee.config,mapProducts:ae});m.current=d,fe(d.getState());let F=d.subscribe(E=>fe(E));return()=>{F(),d.destroy(),m.current===d&&(m.current=null)}},[]),Ne(()=>{H!==void 0&&m.current?.setValue(H)},[H]),Ne(()=>{K!==void 0&&m.current?.setCompletedParams(K)},[K]);let Te=JSON.stringify(r??null),ce;try{ce=JSON.stringify(i??null)}catch{ce="[unstringifiable]"}Ne(()=>{m.current?.update({apiConfig:r,additionalContext:i,language:c,currency:u,productId:g,optionOverrides:ie.overrides,dropdownTrigger:p,optionsPosition:s,closeDropdownOnBlur:f,showNonTappableOptions:I,showProducts:D})},[Te,ce,c,u?.code,u?.rate,u?.country,g,ie.key,p,s,f,I,D]);let we=G(!1);Ne(()=>{if(!we.current){we.current=!0;return}m.current?.update({products:ee.config})},[ee.enabled]),Ne(()=>{m.current?.update({mapProducts:ae})},[ae]);let ve=G(null);ve.current===null&&(ve.current={handleTextChange:d=>m.current?.handleTextChange(d),handleKeyDown:d=>{let F="nativeEvent"in d?d.nativeEvent:d;m.current?.handleKeyDown(F)},setFocused:d=>m.current?.setFocused(d),startEditingParam:d=>m.current?.startEditingParam(d),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:d=>m.current?.handleCaretAfterInput(d),handleCaretMove:d=>m.current?.handleCaretMove(d),replaceEditingRange:d=>m.current?.replaceEditingRange(d)??!1,setActivePill:d=>m.current?.setActivePill(d),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),prepareSubmit:()=>m.current?.prepareSubmit(),getState:()=>m.current?.getState()??Zt,recordSubmit:d=>m.current?.recordSubmit(d),selectOption:d=>m.current?.selectOption(d),selectProduct:d=>m.current?.selectProduct(d),addProductToCart:d=>{let F=m.current;return!F||!Q.current?Promise.resolve():F.addProductToCart(d)},setActiveDropdownIndex:d=>m.current?.setActiveDropdownIndex(d),clearHighlight:d=>m.current?.clearHighlight(d),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let x=ve.current,Re=$t(d=>{let F=d.target.value,Ye=F.length>0&&!d.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;m.current?.handleTextChange(Ye)},[]),De=$t(d=>{m.current?.handleKeyDown(d.nativeEvent)},[]),oe=m.current,b=me??Zt,xe=H!==void 0?H:b.text,ye=K!==void 0?K:b.completedParams,Be=b.actionableSuggestions,ot=Be[0],nt=Ei(Be),Oe=oe?.listboxId??"",rt=b.activeDropdownIndex>=0&&oe?`${Oe}-option-${b.activeDropdownIndex}`:void 0,ke=b.editingParam,Ie=b.editingIdentified,Ge=ke?{parameter:ke.suggestionParameter,text:ke.suggestionPlaceholder,required:!0,options:ke.options}:Ie?{parameter:Ie.parameter,text:Ii(Ie.parameter),required:!0,options:[]}:null,Ve=b.dropdownSuggestion??Ge??ot,st=Ge?[Ge]:Be,Ke=Ti(b),Ee=!oe||b.dropdownLoading;return{completedParams:ye,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:nt,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:Ee,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:Oe,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:ke,editingIdentified:Ie,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:xe,placeholder:b.placeholderText||void 0,onChange:Re,onKeyDown:De,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":rt,"aria-autocomplete":"list","aria-controls":Oe},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Ve?[{...Ve,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:b.isDropdownOpen,id:Oe,pills:st,activeSelected:b.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(T??!0)&&!ke&&!Ie,showOptionIcons:M??!0,showOptionImages:q??!0,showOptionCounts:U??!0,skipDisabled:b.inSelectionAnimation,isLoading:Ee,skeletonExiting:b.skeletonExiting,isInputEmpty:xe.trim().length===0,language:c,products:b.products,productImageFallback:N,onProductSelect:x.selectProduct,onProductAddToCart:le?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:Ke.selectedIso,selectedDateRange:Ke.selectedRange,dateRangeStart:Ke.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:s??"below"}}}import{chipIdFromTap as Ri,extractPlainText as Xt,getCursorOffset as Jt,keepCaretOnChip as Di,plainTextLength as Oi,renderEditableContent as Li,setCursorOffset as ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as J,useEffect as at,useLayoutEffect as xt,useRef as Fe}from"react";var it;function zi(){if(it!==void 0)return it;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),it=e.contentEditable==="plaintext-only",it}function ta(e){let{segments:n,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:i,editingAnchor:c,caretOffset:u,placeholderText:g,isFocused:w,isDropdownOpen:k,listboxId:p,activeDescendantId:s,autoFocus:f,handleTextChange:I,handleKeyDown:M,handleCaretAfterInput:q,handleCaretMove:U,startEditingParam:T,replaceEditingRange:D,setFocused:N}=e,S=Fe(null),_=Fe(!1),H=Fe(""),K=Fe(""),X=Fe(null),R=Fe(0);X.current=u,at(()=>{if(!f)return;let l=S.current;if(!l)return;document.activeElement===l?N(!0):l.focus();let v=l.ownerDocument??document,y=v.getSelection(),P=y&&y.rangeCount>0&&l.contains(y.anchorNode);if(y&&!P){let C=v.createRange();C.selectNodeContents(l),C.collapse(!0),y.removeAllRanges(),y.addRange(C)}},[f,N]),at(()=>{let l=S.current;if(!l)return;let v=l.ownerDocument??document,y=()=>{let P=v.getSelection();if(!P||P.rangeCount===0||!P.anchorNode||!l.contains(P.anchorNode))return;let C=P.anchorNode,O=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,h=(P.isCollapsed?O?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,V=r?.id??i?.id??null;if(h&&h!==V){T(h);return}performance.now()-R.current<50||U(Jt(l))};return v.addEventListener("selectionchange",y),()=>v.removeEventListener("selectionchange",y)},[r,i,T,U]),at(()=>{let l=S.current;if(!l)return;let v=y=>{let P=Ri(l,y.target);P&&(T(P),Di(l,P))};return l.addEventListener("click",v),()=>l.removeEventListener("click",v)},[T]),xt(()=>{let l=S.current;l&&Li({input:l,segments:n,newParamId:o,editingParamId:r?.id??null,placeholderText:g??"",isFocused:w,showChipIcons:t,showChipImages:a})},[n,o,r,g,w,t,a]),xt(()=>{let l=H.current,v=o??"";if(H.current=v,!v||v===l)return;let y=S.current;if(!y)return;y.focus();let P=X.current??Oi(y);ea(y,P)},[o]),xt(()=>{let l=K.current,v=r?.id??"";if(K.current=v,!v||v===l||c==null)return;let y=S.current;y&&ea(y,c)},[r,c]);let j=J(()=>{if(_.current)return;let l=S.current;if(!l)return;let v=Xt(l),P=v.length>0&&v[0]!==v[0].toUpperCase()?v[0].toUpperCase()+v.slice(1):v;I(P)},[I]),se=J(()=>{R.current=performance.now(),j();let l=S.current;l&&q(Jt(l))},[j,q]);at(()=>{let l=S.current;if(!l)return;let v=y=>{let P=y,C=P.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){y.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let O=C.startsWith("delete")?"":P.data??"";D(O)&&y.preventDefault()}};return l.addEventListener("beforeinput",v),()=>l.removeEventListener("beforeinput",v)},[D]);let ue=J(()=>{_.current=!0,S.current?.setAttribute("data-aia-composing","true")},[]),le=J(()=>{_.current=!1,S.current?.removeAttribute("data-aia-composing"),j()},[j]),Se=J(l=>{l.preventDefault();let v=S.current;if(!v)return;let y=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!y)return;let P=v.ownerDocument??document,C=P.getSelection();if(!C||C.rangeCount===0)return;let O=C.getRangeAt(0);if(!v.contains(O.startContainer))return;O.deleteContents();let Q=P.createTextNode(y);O.insertNode(Q),O.setStartAfter(Q),O.collapse(!0),C.removeAllRanges(),C.addRange(O),j()},[j]),ge=J(l=>M(l),[M]),m=J(()=>N(!0),[N]),me=J(()=>N(!1),[N]),fe=J(()=>S.current?.focus(),[]),de=J(()=>S.current?.blur(),[]),be=J(()=>{let l=S.current;return l?Xt(l):""},[]),$=zi()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":p,"aria-expanded":k,"aria-activedescendant":s,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:ge,onCompositionStart:ue,onCompositionEnd:le,onPaste:Se,onFocus:m,onBlur:me},getPlainText:be,focus:fe,blur:de}}import{jsx as He,jsxs as kt}from"react/jsx-runtime";function qi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wi=Mi(function({onSubmit:n,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:i,apiConfig:c,additionalContext:u,language:g,currency:w,productId:k,visitorId:p,columns:s,pillPlacement:f="dropdown",mode:I="auto",optionsPosition:M="below",animations:q=!0,dropdownTrigger:U,closeDropdownOnBlur:T,showNonTappableOptions:D,showOptionIcons:N=!0,showChipIcons:S=!0,showChipImages:_=!0,showOptionImages:H=!0,showOptionCounts:K=!0,showSkipButton:X,showProducts:R,productsLayout:j,productImageFallback:se,autoFocus:ue=!0,onFocus:le,onBlur:Se,value:ge,completedParams:m,onChange:me,onParamsChange:fe,products:de,mapProducts:be,onProductSelect:$,onProductAddToCart:l,submitButton:v,resetOnSubmit:y=!0},P){let C=je(null),O=je(null),Q=je(()=>{}),h=je(null),V=je(null);aa(()=>{let A=C.current;if(A)return h.current?h.current.setMode(I):h.current=new Bi(A,I),()=>{h.current?.destroy(),h.current=null}},[I]);let ee=yt(A=>{let Y=V.current?.current;Y&&(Y.focus(),Gi(Y,A))},[]),{completedParams:te,suggestionPills:Pe,setActivePill:ae,skipActivePill:ie,segments:Te,newParamId:ce,clearNewParamId:we,placeholderText:ve,isFocused:x,isDropdownOpen:Re,isActivePillSelected:De,isLoading:oe,activeIndex:b,listboxId:xe,handleTextChange:ye,handleKeyDown:Be,setFocused:ot,editingParam:nt,editingIdentified:Oe,editingAnchor:rt,caretOffset:ke,startEditingParam:Ie,handleCaretAfterInput:Ge,handleCaretMove:Ve,replaceEditingRange:st,dropdownProps:Ke,reset:Ee,refreshProducts:d,prepareSubmit:F,getState:E,recordSubmit:Ye}=vt({onSubmit:A=>Q.current(A),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:c,additionalContext:u,language:g,currency:w,productId:k,visitorId:p,columns:s,dropdownTrigger:U,optionsPosition:M,closeDropdownOnBlur:T,showNonTappableOptions:D,showOptionIcons:N,showOptionImages:H,showOptionCounts:K,showSkipButton:X,showProducts:R,onFocus:le,onBlur:Se,value:ge,completedParams:m,onChange:me,onParamsChange:fe,products:de,mapProducts:be,onProductSelect:$,onProductAddToCart:l,source:"full-sdk",setCursor:ee});aa(()=>{if(!ce)return;let A=window.setTimeout(()=>we(),650);return()=>window.clearTimeout(A)},[ce,we]);let ia=b>=0?`${xe}-option-${b}`:void 0,{inputRef:lt,editorProps:oa,focus:Qe,blur:Ct,getPlainText:St}=ta({segments:Te,newParamId:ce,editingParam:nt,editingIdentified:Oe,editingAnchor:rt,caretOffset:ke,placeholderText:ve,isFocused:x,showChipIcons:S,showChipImages:_,isDropdownOpen:Re,listboxId:xe,activeDescendantId:ia,autoFocus:ue,handleTextChange:ye,handleKeyDown:Be,handleCaretAfterInput:Ge,handleCaretMove:Ve,startEditingParam:Ie,replaceEditingRange:st,setFocused:ot});V.current=lt,Fi(()=>{let A=O.current,Y=lt.current;if(!A||!Y)return;let qe=()=>{let Tt=A.firstElementChild;if(!Tt)return;let la=Tt.getBoundingClientRect(),da=Y.getBoundingClientRect();la.top>=da.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};qe();let Pt=new ResizeObserver(qe);return Pt.observe(Y),()=>Pt.disconnect()},[Te,Pe.length,oe,lt]),Ni(P,()=>({focus:Qe,blur:Ct,reset:Ee,refreshProducts:d,setMode:A=>h.current?.setMode(A),skipActivePill:ie}),[Qe,Ct,Ee,d,ie]);let $e=!!Te.length||te.length>0,dt=yt(A=>{if(!$e)return;A&&F();let Y=E(),qe=Hi(St(),Y.completedParams,Y.skippedParams,{identifiedParams:Y.identifiedParams,isReady:Y.isReady,customFields:Y.customFields});A&&Ye(qe),n(qe),y&&Ee()},[Ye,y,$e,F,E,n,Ee,St]);Q.current=()=>dt(!1);let na=yt(A=>{A.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ra=f==="inline",sa=f==="dropdown";return kt("div",{ref:C,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":f,"data-options-position":M,"data-animations":q?"on":"off","data-mode":qi(I),children:[He(bt,{...Ke,showPills:sa,productsLayout:j,productImageFallback:se}),kt("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:na,children:[kt("div",{className:Ae.editorArea,"data-aia-editor":"",children:[He("div",{...oa,className:Ae.input,"data-aia-input":""}),ra&&(oe||Pe.length>0)&&He("span",{ref:O,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:He(Xe,{pills:Pe,activePillIndex:0,activeSelected:De,onSelectPill:ae,loading:oe})})]}),v===null?null:v===void 0?He(_t,{disabled:!$e,onClick:()=>dt(!0),label:Ki(g).submit}):He("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:A=>{$e&&(A.stopPropagation(),dt(!0))},children:v})]})]})});export{Wi as AIAutocomplete,bt as AIAutocompleteDropdown,Kn as DATE_RANGE_META_END,qn as DATE_RANGE_META_START,Wn as DEFAULT_OPTION_COUNT_UNIT,ar as PRODUCT_PATH_PREFIX,hr as WEEKDAY_LABELS,Hn as buildSubmitResult,Bn as cellDay,Gn as cellIso,Un as dateCellMarks,_n as formatDate,jn as formatDateRange,Vn as formatOptionCount,Yn as isoDate,Qn as monthLabel,$n as optionCountLabel,Zn as optionHasImage,Xn as optionImageSources,Jn as optionImageSrc,er as optionLabel,tr as optionsShowLeadingVisuals,ir as parseDate,or as parseLooseDate,nr as parseLooseDateRange,rr as productFromMatchedItem,sr as productImageSources,lr as productsFromCustomFields,dr as sanitizeOptionIconSvg,cr as selectedRangeFor,vt as useAIAutocomplete,pr as visibleDateRange,ur as withSkippedParams};
2867
+ `,document.head.appendChild(e)}var Zt={submitButton:"aia-submitButton-otz7H"};import{jsx as kt}from"react/jsx-runtime";function Xt({disabled:e,onClick:n,label:t=qi().submit}){return kt("button",{type:"button","data-aia-submit":"",className:Zt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":t,children:kt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:kt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as _i,dateSelectionFor as Ui,identifiedParamLabel as Vi,withoutTraditionalAutocomplete as Yi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ia,useEffect as We,useRef as G,useState as ji}from"react";import{useRef as Jt}from"react";function ea(e){let n=Jt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Jt({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(s,h,b)=>{let x=n.current?.[r];return x?x(s,h,b):[]};i[r]=o}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as ta}from"react";function aa(e){let n=ta(e);n.current=e;let t=ta(null);t.current===null&&(t.current={fetch:(i,r)=>{let o=n.current;return o?o.fetch(i,r):Promise.reject(new Error("products config removed"))},transform:i=>n.current?.transform(i)??[],get limit(){return n.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var oa={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,timeView:null,multiSelectView:null,multiSelectDraft:null,placeholderText:"",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 St({onSubmit:e,onResult:n,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:r,additionalContext:o,language:s,currency:h,productId:b,visitorId:x,columns:m=2,dropdownTrigger:l,optionsPosition:d,closeDropdownOnBlur:w,showNonTappableOptions:I,showOptionIcons:j,showOptionImages:H,showOptionCounts:K,showSkipButton:U,showProducts:P,productImageFallback:R="image",onFocus:S,onBlur:Q,value:F,completedParams:B,onChange:Z,onParamsChange:ee,products:E,mapProducts:te,onProductSelect:fe,onProductAddToCart:ce,source:Ie,setCursor:be}){let g=G(null),[we,ve]=ji(null),xe=G(e);xe.current=e;let ye=G(n);ye.current=n;let ke=G(t);ke.current=t;let u=G(Z);u.current=Z;let y=G(ee);y.current=ee;let k=G(S);k.current=S;let T=G(Q);T.current=Q;let C=G(be);C.current=be;let L=G(fe);L.current=fe;let X=G(ce);X.current=ce;let V=G(x);V.current=x;let Se=G(()=>{let c=V.current;return typeof c=="function"?c():c}).current,Ee=aa(E),re=G(te);re.current=te;let pe=G((c,N)=>{let A=re.current;return A?A(c,N):c}).current,Ce=te?pe:void 0,p=ea(a);We(()=>{if(typeof document>"u")return;let c=new _i(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,language:s,currency:h,productId:b,visitorId:Se,optionOverrides:p.overrides,maskCompletedText:i,columns:m,dropdownTrigger:l,optionsPosition:d,closeDropdownOnBlur:w,showNonTappableOptions:I,showProducts:P,source:Ie,value:F,completedParams:B,onSubmit:(...A)=>xe.current?.(...A),onResult:(...A)=>ye.current?.(...A),onError:(...A)=>ke.current?.(...A),onChange:(...A)=>u.current?.(...A),onParamsChange:(...A)=>y.current?.(...A),onFocus:()=>k.current?.(),onBlur:()=>T.current?.(),onProductSelect:A=>L.current?.(A),onProductAddToCart:A=>X.current?.(A),setCursor:A=>C.current?.(A),products:Ee.config,mapProducts:Ce});g.current=c,ve(c.getState());let N=c.subscribe(A=>ve(A));return()=>{N(),c.destroy(),g.current===c&&(g.current=null)}},[]),We(()=>{F!==void 0&&g.current?.setValue(F)},[F]),We(()=>{B!==void 0&&g.current?.setCompletedParams(B)},[B]);let q=JSON.stringify(r??null),J;try{J=JSON.stringify(o??null)}catch{J="[unstringifiable]"}We(()=>{g.current?.update({apiConfig:r,additionalContext:o,language:s,currency:h,productId:b,optionOverrides:p.overrides,dropdownTrigger:l,optionsPosition:d,closeDropdownOnBlur:w,showNonTappableOptions:I,showProducts:P})},[q,J,s,h?.code,h?.rate,h?.country,b,p.key,l,d,w,I,P]);let ae=G(!1);We(()=>{if(!ae.current){ae.current=!0;return}g.current?.update({products:Ee.config})},[Ee.enabled]),We(()=>{g.current?.update({mapProducts:Ce})},[Ce]);let Ae=G(null);Ae.current===null&&(Ae.current={handleTextChange:c=>g.current?.handleTextChange(c),handleKeyDown:c=>{let N="nativeEvent"in c?c.nativeEvent:c;g.current?.handleKeyDown(N)},setFocused:c=>g.current?.setFocused(c),startEditingParam:c=>g.current?.startEditingParam(c),exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:c=>g.current?.handleCaretAfterInput(c),handleCaretMove:c=>g.current?.handleCaretMove(c),replaceEditingRange:c=>g.current?.replaceEditingRange(c)??!1,setActivePill:c=>g.current?.setActivePill(c),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()??oa,recordSubmit:c=>g.current?.recordSubmit(c),selectOption:c=>g.current?.selectOption(c),selectProduct:c=>g.current?.selectProduct(c),addProductToCart:c=>{let N=g.current;return!N||!X.current?Promise.resolve():N.addProductToCart(c)},setActiveDropdownIndex:c=>g.current?.setActiveDropdownIndex(c),clearHighlight:c=>g.current?.clearHighlight(c),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),setTime:c=>g.current?.setTime(c),commitTime:()=>g.current?.commitTime(),toggleMultiSelectOption:c=>g.current?.toggleMultiSelectOption(c),commitMultiSelect:()=>g.current?.commitMultiSelect(),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let v=Ae.current,Re=ia(c=>{let N=c.target.value,Je=N.length>0&&!c.nativeEvent?.isComposing&&N[0]!==N[0].toUpperCase()?N[0].toUpperCase()+N.slice(1):N;g.current?.handleTextChange(Je)},[]),qe=ia(c=>{g.current?.handleKeyDown(c.nativeEvent)},[]),he=g.current,f=we??oa,Te=F!==void 0?F:f.text,Me=B!==void 0?B:f.completedParams,Pe=f.actionableSuggestions,ze=Pe[0],Ne=Yi(Pe),ue=he?.listboxId??"",_e=f.activeDropdownIndex>=0&&he?`${ue}-option-${f.activeDropdownIndex}`:void 0,ie=f.editingParam,M=f.editingIdentified,Ue=ie?{parameter:ie.suggestionParameter,text:ie.suggestionPlaceholder,required:!0,options:ie.options}:M?{parameter:M.parameter,text:Vi(M.parameter),required:!0,options:[]}:null,Xe=f.dropdownSuggestion??Ue??ze,ct=Ue?[Ue]:Pe,Ve=Ui(f),Oe=!he||f.dropdownLoading;return{completedParams:Me,multiSelectView:f.multiSelectView,toggleMultiSelectOption:v.toggleMultiSelectOption,commitMultiSelect:v.commitMultiSelect,skippedParams:f.skippedParams,identifiedParams:f.identifiedParams,suggestionPills:Ne,setActivePill:v.setActivePill,skipActivePill:v.skipActivePill,removeLastParam:v.removeLastParam,segments:f.segments,newParamId:f.newParamId,clearNewParamId:v.clearNewParamId,suggestions:f.suggestions,activeIndex:f.activeDropdownIndex,isReady:f.isReady,isLoading:Oe,isFocused:f.isFocused,isDropdownOpen:f.isDropdownOpen,isActivePillSelected:f.isActivePillSelected,placeholderText:f.placeholderText,listboxId:ue,error:f.error,products:f.products,customFields:f.customFields,selectProduct:v.selectProduct,addProductToCart:v.addProductToCart,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:ie,editingIdentified:M,editingAnchor:f.editingAnchor,caretOffset:f.caretOffset,startEditingParam:v.startEditingParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:Te,placeholder:f.placeholderText||void 0,onChange:Re,onKeyDown:qe,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":f.isDropdownOpen,"aria-activedescendant":_e,"aria-autocomplete":"list","aria-controls":ue},reset:v.reset,refreshProducts:v.refreshProducts,prepareSubmit:v.prepareSubmit,getState:v.getState,recordSubmit:v.recordSubmit,dropdownProps:{suggestions:Xe?[{...Xe,options:f.dropdownOptions}]:[],activeIndex:f.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,onUnhighlight:v.clearHighlight,isOpen:f.isDropdownOpen,id:ue,pills:ct,activeSelected:f.isActivePillSelected,onPillClick:v.setActivePill,onSkip:v.skipActivePill,showSkipButton:(U??!0)&&!ie&&!M,showOptionIcons:j??!0,showOptionImages:H??!0,showOptionCounts:K??!0,skipDisabled:f.inSelectionAnimation,isLoading:Oe,skeletonExiting:f.skeletonExiting,isInputEmpty:Te.trim().length===0,language:s,products:f.products,productImageFallback:R,onProductSelect:v.selectProduct,onProductAddToCart:ce?v.addProductToCart:void 0,onProductFocusChange:v.setFocused,formatType:f.activeFormatType,dateView:f.dateView,selectedDateIso:Ve.selectedIso,selectedDateRange:Ve.selectedRange,dateRangeStart:Ve.rangeStart,onPreviousMonth:v.showPreviousMonth,onNextMonth:v.showNextMonth,timeView:f.timeView,multiSelectView:f.multiSelectView,onMultiSelectCommit:v.commitMultiSelect,onTimeChange:v.setTime,onTimeCommit:v.commitTime,optionsPosition:d??"below"}}}import{chipIdFromTap as Qi,extractPlainText as na,getCursorOffset as ra,keepCaretOnChip as $i,plainTextLength as Zi,renderEditableContent as Xi,setCursorOffset as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ne,useEffect as lt,useLayoutEffect as Ct,useRef as Ge}from"react";var dt;function Ji(){if(dt!==void 0)return dt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),dt=e.contentEditable==="plaintext-only",dt}function la(e){let{segments:n,showChipIcons:t=!0,showChipImages:a=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:s,caretOffset:h,placeholderText:b,isFocused:x,isDropdownOpen:m,listboxId:l,activeDescendantId:d,autoFocus:w,handleTextChange:I,handleKeyDown:j,handleCaretAfterInput:H,handleCaretMove:K,startEditingParam:U,replaceEditingRange:P,setFocused:R}=e,S=Ge(null),Q=Ge(!1),F=Ge(""),B=Ge(""),Z=Ge(null),ee=Ge(0);Z.current=h,lt(()=>{if(!w)return;let u=S.current;if(!u)return;document.activeElement===u?R(!0):u.focus();let y=u.ownerDocument??document,k=y.getSelection(),T=k&&k.rangeCount>0&&u.contains(k.anchorNode);if(k&&!T){let C=y.createRange();C.selectNodeContents(u),C.collapse(!0),k.removeAllRanges(),k.addRange(C)}},[w,R]),lt(()=>{let u=S.current;if(!u)return;let y=u.ownerDocument??document,k=()=>{let T=y.getSelection();if(!T||T.rangeCount===0||!T.anchorNode||!u.contains(T.anchorNode))return;let C=T.anchorNode,L=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,V=(T.isCollapsed?L?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Se=r?.id??o?.id??null;if(V&&V!==Se){U(V);return}performance.now()-ee.current<50||K(ra(u))};return y.addEventListener("selectionchange",k),()=>y.removeEventListener("selectionchange",k)},[r,o,U,K]),lt(()=>{let u=S.current;if(!u)return;let y=k=>{let T=Qi(u,k.target);T&&(U(T),$i(u,T))};return u.addEventListener("click",y),()=>u.removeEventListener("click",y)},[U]),Ct(()=>{let u=S.current;u&&Xi({input:u,segments:n,newParamId:i,editingParamId:r?.id??null,placeholderText:b??"",isFocused:x,showChipIcons:t,showChipImages:a})},[n,i,r,b,x,t,a]),Ct(()=>{let u=F.current,y=i??"";if(F.current=y,!y||y===u)return;let k=S.current;if(!k)return;k.focus();let T=Z.current??Zi(k);sa(k,T)},[i]),Ct(()=>{let u=B.current,y=r?.id??"";if(B.current=y,!y||y===u||s==null)return;let k=S.current;k&&sa(k,s)},[r,s]);let E=ne(()=>{if(Q.current)return;let u=S.current;if(!u)return;let y=na(u),T=y.length>0&&y[0]!==y[0].toUpperCase()?y[0].toUpperCase()+y.slice(1):y;I(T)},[I]),te=ne(()=>{ee.current=performance.now(),E();let u=S.current;u&&H(ra(u))},[E,H]);lt(()=>{let u=S.current;if(!u)return;let y=k=>{let T=k,C=T.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){k.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let L=C.startsWith("delete")?"":T.data??"";P(L)&&k.preventDefault()}};return u.addEventListener("beforeinput",y),()=>u.removeEventListener("beforeinput",y)},[P]);let fe=ne(()=>{Q.current=!0,S.current?.setAttribute("data-aia-composing","true")},[]),ce=ne(()=>{Q.current=!1,S.current?.removeAttribute("data-aia-composing"),E()},[E]),Ie=ne(u=>{u.preventDefault();let y=S.current;if(!y)return;let k=(u.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!k)return;let T=y.ownerDocument??document,C=T.getSelection();if(!C||C.rangeCount===0)return;let L=C.getRangeAt(0);if(!y.contains(L.startContainer))return;L.deleteContents();let X=T.createTextNode(k);L.insertNode(X),L.setStartAfter(X),L.collapse(!0),C.removeAllRanges(),C.addRange(L),E()},[E]),be=ne(u=>j(u),[j]),g=ne(()=>R(!0),[R]),we=ne(()=>R(!1),[R]),ve=ne(()=>S.current?.focus(),[]),xe=ne(()=>S.current?.blur(),[]),ye=ne(()=>{let u=S.current;return u?na(u):""},[]),ke=Ji()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:ke,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":l,"aria-expanded":m,"aria-activedescendant":d,spellCheck:!0,enterKeyHint:"send",onInput:te,onKeyDown:be,onCompositionStart:fe,onCompositionEnd:ce,onPaste:Ie,onFocus:g,onBlur:we},getPlainText:ye,focus:ve,blur:xe}}import{jsx as Ke,jsxs as Pt}from"react/jsx-runtime";function so(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var lo=eo(function({onSubmit:n,onResult:t,onError:a,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:s,additionalContext:h,language:b,currency:x,productId:m,visitorId:l,columns:d,pillPlacement:w="dropdown",mode:I="auto",optionsPosition:j="below",animations:H=!0,dropdownTrigger:K,closeDropdownOnBlur:U,showNonTappableOptions:P,showOptionIcons:R=!0,showChipIcons:S=!0,showChipImages:Q=!0,showOptionImages:F=!0,showOptionCounts:B=!0,showSkipButton:Z,showProducts:ee,productsLayout:E,productImageFallback:te,autoFocus:fe=!0,onFocus:ce,onBlur:Ie,value:be,completedParams:g,onChange:we,onParamsChange:ve,products:xe,mapProducts:ye,onProductSelect:ke,onProductAddToCart:u,submitButton:y,resetOnSubmit:k=!0},T){let C=Ze(null),L=Ze(null),X=Ze(()=>{}),V=Ze(null),Se=Ze(null);da(()=>{let O=C.current;if(O)return V.current?V.current.setMode(I):V.current=new oo(O,I),()=>{V.current?.destroy(),V.current=null}},[I]);let Ee=Tt(O=>{let $=Se.current?.current;$&&($.focus(),no($,O))},[]),{completedParams:re,suggestionPills:pe,setActivePill:Ce,skipActivePill:p,segments:q,newParamId:J,clearNewParamId:ae,placeholderText:Ae,isFocused:v,isDropdownOpen:Re,isActivePillSelected:qe,isLoading:he,activeIndex:f,listboxId:Te,handleTextChange:Me,handleKeyDown:Pe,setFocused:ze,editingParam:Ne,editingIdentified:ue,editingAnchor:_e,caretOffset:ie,startEditingParam:M,handleCaretAfterInput:Ue,handleCaretMove:Xe,replaceEditingRange:ct,dropdownProps:Ve,reset:Oe,refreshProducts:c,prepareSubmit:N,getState:A,recordSubmit:Je}=St({onSubmit:O=>X.current(O),onResult:t,onError:a,optionOverrides:i,maskCompletedText:r,apiConfig:s,additionalContext:h,language:b,currency:x,productId:m,visitorId:l,columns:d,dropdownTrigger:K,optionsPosition:j,closeDropdownOnBlur:U,showNonTappableOptions:P,showOptionIcons:R,showOptionImages:F,showOptionCounts:B,showSkipButton:Z,showProducts:ee,onFocus:ce,onBlur:Ie,value:be,completedParams:g,onChange:we,onParamsChange:ve,products:xe,mapProducts:ye,onProductSelect:ke,onProductAddToCart:u,source:"full-sdk",setCursor:Ee});da(()=>{if(!J)return;let O=window.setTimeout(()=>ae(),650);return()=>window.clearTimeout(O)},[J,ae]);let ca=f>=0?`${Te}-option-${f}`:void 0,{inputRef:pt,editorProps:pa,focus:et,blur:It,getPlainText:Et}=la({segments:q,newParamId:J,editingParam:Ne,editingIdentified:ue,editingAnchor:_e,caretOffset:ie,placeholderText:Ae,isFocused:v,showChipIcons:S,showChipImages:Q,isDropdownOpen:Re,listboxId:Te,activeDescendantId:ca,autoFocus:fe,handleTextChange:Me,handleKeyDown:Pe,handleCaretAfterInput:Ue,handleCaretMove:Xe,startEditingParam:M,replaceEditingRange:ct,setFocused:ze});Se.current=pt,ao(()=>{let O=L.current,$=pt.current;if(!O||!$)return;let Ye=()=>{let Rt=O.firstElementChild;if(!Rt)return;let ga=Rt.getBoundingClientRect(),fa=$.getBoundingClientRect();ga.top>=fa.bottom-2?O.setAttribute("data-aia-pill-wrapped",""):O.removeAttribute("data-aia-pill-wrapped")};Ye();let At=new ResizeObserver(Ye);return At.observe($),()=>At.disconnect()},[q,pe.length,he,pt]),to(T,()=>({focus:et,blur:It,reset:Oe,refreshProducts:c,setMode:O=>V.current?.setMode(O),skipActivePill:p}),[et,It,Oe,c,p]);let tt=!!q.length||re.length>0,ht=Tt(O=>{if(!tt)return;O&&N();let $=A(),Ye=io(Et(),$.completedParams,$.skippedParams,{identifiedParams:$.identifiedParams,isReady:$.isReady,customFields:$.customFields});O&&Je(Ye),n(Ye),k&&Oe()},[Je,k,tt,N,A,n,Oe,Et]);X.current=()=>ht(!1);let ha=Tt(O=>{O.target?.closest("[data-aia-pill]")||et()},[et]),ua=w==="inline",ma=w==="dropdown";return Pt("div",{ref:C,className:`magicx-aia ${De.container} ${o??""}`,"data-pill-placement":w,"data-options-position":j,"data-animations":H?"on":"off","data-mode":so(I),children:[Ke(yt,{...Ve,showPills:ma,productsLayout:E,productImageFallback:te}),Pt("div",{className:De.inputWrapper,"data-aia-input-wrapper":"",onClick:ha,children:[Pt("div",{className:De.editorArea,"data-aia-editor":"",children:[Ke("div",{...pa,className:De.input,"data-aia-input":""}),ua&&(he||pe.length>0)&&Ke("span",{ref:L,className:De.pillListContainer,"data-aia-pill-list-container":"",children:Ke(it,{pills:pe,activePillIndex:0,activeSelected:qe,onSelectPill:Ce,loading:he})})]}),y===null?null:y===void 0?Ke(Xt,{disabled:!tt,onClick:()=>ht(!0),label:ro(b).submit}):Ke("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:De.submitSlot,onClick:O=>{tt&&(O.stopPropagation(),ht(!0))},children:y})]})]})});export{lo as AIAutocomplete,yt as AIAutocompleteDropdown,ur as DATE_RANGE_META_END,mr as DATE_RANGE_META_START,gr as DEFAULT_OPTION_COUNT_UNIT,Ar as PRODUCT_PATH_PREFIX,Br as TIME_META_KEY,Gr as WEEKDAY_LABELS,cr as buildSubmitResult,pr as cellDay,hr as cellIso,fr as dateCellMarks,br as formatDate,wr as formatDateRange,vr as formatOptionCount,xr as formatTime,yr as isoDate,kr as monthLabel,Sr as optionCountLabel,Cr as optionHasImage,Tr as optionImageSources,Pr as optionImageSrc,Ir as optionLabel,Er as optionsShowLeadingVisuals,Rr as parseDate,Or as parseLooseDate,Dr as parseLooseDateRange,Lr as parseTime,Mr as productFromMatchedItem,zr as productImageSources,Nr as productsFromCustomFields,Hr as sanitizeOptionIconSvg,Fr as selectedRangeFor,St as useAIAutocomplete,Wr as visibleDateRange,Kr as withSkippedParams};
2682
2868
  //# sourceMappingURL=index.mjs.map