@magicx-eng/ai-autocomplete-react 0.35.0 → 0.37.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 xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END as Cn,DATE_RANGE_META_START as Pn,DEFAULT_OPTION_COUNT_UNIT as Sn,dateCellMarks as In,formatDate as En,formatDateRange as Tn,formatOptionCount as An,isoDate as Rn,monthLabel as On,optionCountLabel as Dn,optionHasImage as Ln,optionImageSources as zn,optionImageSrc as Mn,optionLabel as Nn,PRODUCT_PATH_PREFIX as Bn,parseDate as Hn,parseLooseDate as Fn,parseLooseDateRange as Kn,productFromMatchedItem as Gn,productImageSources as Wn,productsFromCustomFields as _n,sanitizeOptionIconSvg as Un,selectedRangeFor as qn,visibleDateRange as jn,WEEKDAY_LABELS as Qn,withSkippedParams as Yn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as wi,useCallback as ut,useEffect as Yt,useImperativeHandle as xi,useLayoutEffect as yi,useRef as Ke}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 kn,cellDay as Cn,cellIso as Pn,DATE_RANGE_META_END as Sn,DATE_RANGE_META_START as In,DEFAULT_OPTION_COUNT_UNIT as En,dateCellMarks as Tn,formatDate as An,formatDateRange as Rn,formatOptionCount as On,isoDate as Dn,monthLabel as Ln,optionCountLabel as zn,optionHasImage as Mn,optionImageSources as Nn,optionImageSrc as Fn,optionLabel as Bn,PRODUCT_PATH_PREFIX as Hn,parseDate as Kn,parseLooseDate as Gn,parseLooseDateRange as Wn,productFromMatchedItem as _n,productImageSources as Un,productsFromCustomFields as qn,sanitizeOptionIconSvg as jn,selectedRangeFor as Qn,visibleDateRange as Yn,WEEKDAY_LABELS as Zn,withSkippedParams as Vn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as yi,useCallback as ut,useEffect as Yt,useImperativeHandle as ki,useLayoutEffect as Ci,useRef as We}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
@@ -262,7 +262,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
262
262
  opacity: 0;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e)}var Ie={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 Ja,containScroll as ei,isCalendarFormat as ti,uiStringsFor as ai}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as $e,useState as ii}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
265
+ `,document.head.appendChild(e)}var Ie={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 Ja,attachViewportFit as ei,containScroll as ti,isCalendarFormat as ai,uiStringsFor as ii}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as De,useRef as Oe,useState as oi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
266
266
  * Built-in appearance defaults \u2014 zero specificity via :where().
267
267
  * Consumer CSS always wins without !important.
268
268
  *
@@ -735,6 +735,59 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
735
735
  background: var(--aia-surface, #ffffff);
736
736
  }
737
737
  }
738
+
739
+ /* Fitted to the visible viewport. When the open panel would run past the
740
+ screen's edge (a phone's keyboard, a short window), the core's viewportFit
741
+ controller sets data-aia-fit and caps the panel at the space that is left
742
+ (--aia-dropdown-fit-height). The section stack becomes the one scroll box:
743
+ the options grid drops its own row cap, so options, product strip and
744
+ footer scroll together and the strip is reached by scrolling past the last
745
+ option instead of being cut off below it. Nothing slides under the footer
746
+ any more, so its reserved band goes, as it does with a product strip.
747
+ Declared last: the two-attribute selector ties the unwrapped
748
+ above-position rule some copies carry, and must win it on source order. */
749
+ [data-aia-dropdown][data-aia-fit] {
750
+ max-height: var(--aia-dropdown-fit-height, none);
751
+ --aia-grid-scroll-bottom: 0px;
752
+ --aia-grid-overlap-bottom: 0px;
753
+ --aia-grid-scroll-top: 0px;
754
+ --aia-grid-overlap-top: 0px;
755
+ --aia-footer-fade-lead: 0px;
756
+ --aia-footer-row-min-height: 0px;
757
+ }
758
+
759
+ /* The stack is the panel's flex child, so it shrinks to the cap and scrolls.
760
+ It reaches 6px into the panel's side padding on each side: the product row
761
+ hangs that far outside the stack (its cards' hover fill), and a scroll box
762
+ clips sideways as well as down. The scrollbar is hidden, as the grid's is. */
763
+ [data-aia-dropdown][data-aia-fit] > .aia-stack {
764
+ flex: 1 1 auto;
765
+ min-height: 0;
766
+ margin-inline: -6px;
767
+ padding-inline: 6px;
768
+ overflow-x: hidden;
769
+ overflow-y: auto;
770
+ overscroll-behavior: contain;
771
+ scrollbar-width: none;
772
+ }
773
+
774
+ [data-aia-dropdown][data-aia-fit] > .aia-stack::-webkit-scrollbar {
775
+ display: none;
776
+ }
777
+
778
+ /* Sections keep their own height and overflow the stack instead. Flex items
779
+ shrink by default, and one that clips (the pill bar is overflow: hidden)
780
+ has no content floor to stop it \u2014 it collapsed to nothing. */
781
+ [data-aia-dropdown][data-aia-fit] > .aia-stack > * {
782
+ flex-shrink: 0;
783
+ }
784
+
785
+ /* The grid shows every row and leaves the scrolling to the stack. Not a
786
+ scroll box at all, so a swipe that starts on an option scrolls the panel. */
787
+ [data-aia-dropdown][data-aia-fit] .aia-grid[data-scroll] {
788
+ max-height: none;
789
+ overflow: visible;
790
+ }
738
791
  `,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 {
739
792
  position: absolute;
740
793
  left: 0;
@@ -1208,7 +1261,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1208
1261
  opacity: 0.8;
1209
1262
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1210
1263
  }
1211
- `,document.head.appendChild(e)}var R={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 ee,jsxs as yt}from"react/jsx-runtime";var ca=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function kt({options:e,activeIndex:n,listboxId:t,view:i,selection:r,onSelect:o,onHighlight:a,onUnhighlight:p,onPreviousMonth:l,onNextMonth:v}){let P=na(new Date),C=sa({pendingStart:r.rangeStart,highlightedIso:Re(e[n]),selected:r.selectedRange});return yt("div",{className:R.datepicker,"data-aia-datepicker":"",children:[yt("div",{className:R.header,children:[ee("button",{type:"button",tabIndex:-1,className:R.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:l,children:"\u2039"}),ee("span",{className:R.month,"data-aia-date-month":"","aria-live":"polite",children:ra(i)}),ee("button",{type:"button",tabIndex:-1,className:R.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:v,children:"\u203A"})]}),ee("div",{className:R.weekdays,"aria-hidden":"true",children:la.map((m,b)=>ee("span",{className:R.weekday,children:m},ca[b]))}),ee("div",{className:R.grid,"data-aia-date-grid":"",children:e.map((m,b)=>ee(pa,{option:m,id:`${t}-option-${b}`,index:b,isHighlighted:b===n&&m.is_tappable,isToday:Re(m)===P,isPast:Re(m)!=null&&Re(m)<P,marks:oa(Re(m),{selectedIso:r.selectedIso,range:C}),onSelect:o,onHighlight:a,onUnhighlight:p},Re(m)??`pad-${b}`))})]})}function pa({option:e,id:n,index:t,isHighlighted:i,isToday:r,isPast:o,marks:a,onSelect:p,onHighlight:l,onUnhighlight:v}){let[P,C]=da(!1),m=ia(e);if(m==null)return ee("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${R.cell} ${R.blank}`});let b=()=>{C(!0),p(e),setTimeout(()=>C(!1),170)},S=[R.cell,R.day,o?R.past:"",i?R.highlighted:"",r?R.today:"",a.inRange?R.inRange:"",a.selected?R.selected:"",P?R.pressed:""].filter(Boolean).join(" ");return ee("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:S,onClick:b,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),b())},onMouseEnter:()=>l(t),onMouseLeave:v?()=>v(t):void 0,children:ee("span",{className:R.number,children:m})})}import{ATTRIBUTION_URL as ha,buildAttributionUrl as ua,getFooterHint as ma,uiStringsFor as ga}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as fa,useState as ba}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 {
1264
+ `,document.head.appendChild(e)}var R={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 ee,jsxs as yt}from"react/jsx-runtime";var ca=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function kt({options:e,activeIndex:o,listboxId:t,view:a,selection:n,onSelect:r,onHighlight:i,onUnhighlight:p,onPreviousMonth:l,onNextMonth:v}){let P=na(new Date),C=sa({pendingStart:n.rangeStart,highlightedIso:Re(e[o]),selected:n.selectedRange});return yt("div",{className:R.datepicker,"data-aia-datepicker":"",children:[yt("div",{className:R.header,children:[ee("button",{type:"button",tabIndex:-1,className:R.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:l,children:"\u2039"}),ee("span",{className:R.month,"data-aia-date-month":"","aria-live":"polite",children:ra(a)}),ee("button",{type:"button",tabIndex:-1,className:R.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:v,children:"\u203A"})]}),ee("div",{className:R.weekdays,"aria-hidden":"true",children:la.map((g,b)=>ee("span",{className:R.weekday,children:g},ca[b]))}),ee("div",{className:R.grid,"data-aia-date-grid":"",children:e.map((g,b)=>ee(pa,{option:g,id:`${t}-option-${b}`,index:b,isHighlighted:b===o&&g.is_tappable,isToday:Re(g)===P,isPast:Re(g)!=null&&Re(g)<P,marks:oa(Re(g),{selectedIso:n.selectedIso,range:C}),onSelect:r,onHighlight:i,onUnhighlight:p},Re(g)??`pad-${b}`))})]})}function pa({option:e,id:o,index:t,isHighlighted:a,isToday:n,isPast:r,marks:i,onSelect:p,onHighlight:l,onUnhighlight:v}){let[P,C]=da(!1),g=ia(e);if(g==null)return ee("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${R.cell} ${R.blank}`});let b=()=>{C(!0),p(e),setTimeout(()=>C(!1),170)},S=[R.cell,R.day,r?R.past:"",a?R.highlighted:"",n?R.today:"",i.inRange?R.inRange:"",i.selected?R.selected:"",P?R.pressed:""].filter(Boolean).join(" ");return ee("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:S,onClick:b,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),b())},onMouseEnter:()=>l(t),onMouseLeave:v?()=>v(t):void 0,children:ee("span",{className:R.number,children:g})})}import{ATTRIBUTION_URL as ha,buildAttributionUrl as ua,getFooterHint as ga,uiStringsFor as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as fa,useState as ba}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 {
1212
1265
  display: flex;
1213
1266
  flex-wrap: wrap;
1214
1267
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1248,7 +1301,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1248
1301
  .aia-cluster[data-justify="around"] {
1249
1302
  justify-content: space-around;
1250
1303
  }
1251
- `,document.head.appendChild(e)}import{jsx as Ct}from"react/jsx-runtime";function He({gap:e,align:n="center",justify:t="start",noWrap:i=!1,inline:r=!1,className:o,children:a,...p}){let l=e?{"--aia-cluster-gap":e}:void 0,v={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":i||void 0,"data-inline":r||void 0,style:l,...p};return r?Ct("span",{...v,children:a}):Ct("div",{...v,children:a})}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
1304
+ `,document.head.appendChild(e)}import{jsx as Ct}from"react/jsx-runtime";function Ke({gap:e,align:o="center",justify:t="start",noWrap:a=!1,inline:n=!1,className:r,children:i,...p}){let l=e?{"--aia-cluster-gap":e}:void 0,v={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":a||void 0,"data-inline":n||void 0,style:l,...p};return n?Ct("span",{...v,children:i}):Ct("div",{...v,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
1252
1305
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1253
1306
  room above the hint/branding row so the footer doesn't butt against the last
1254
1307
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1395,7 +1448,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1395
1448
  justify-content: flex-end;
1396
1449
  }
1397
1450
  }
1398
- `,document.head.appendChild(e)}var re={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 Fe,jsxs as ot}from"react/jsx-runtime";function Pt({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=ga()}){let{key:i,hint:r}=ma(e,n,t),[o,a]=ba(ha);return fa(()=>{a(ua())},[]),Fe("footer",{className:re.footer,"data-aia-footer":"",children:ot(He,{justify:"between",noWrap:!0,className:re.row,children:[ot(He,{gap:"5px",className:re.hintGroup,children:[Fe("kbd",{className:re.key,children:i}),Fe("span",{className:re.hint,children:r})]}),ot("a",{className:re.brandLink,href:o,target:"_blank",rel:"noopener noreferrer",children:[Fe("span",{className:re.brand,children:"AI"}),Fe("span",{className:re.badge,children:"Autocomplete"})]})]})})}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,
1451
+ `,document.head.appendChild(e)}var re={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 Ge,jsxs as ot}from"react/jsx-runtime";function Pt({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=ma()}){let{key:a,hint:n}=ga(e,o,t),[r,i]=ba(ha);return fa(()=>{i(ua())},[]),Ge("footer",{className:re.footer,"data-aia-footer":"",children:ot(Ke,{justify:"between",noWrap:!0,className:re.row,children:[ot(Ke,{gap:"5px",className:re.hintGroup,children:[Ge("kbd",{className:re.key,children:a}),Ge("span",{className:re.hint,children:n})]}),ot("a",{className:re.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Ge("span",{className:re.brand,children:"AI"}),Ge("span",{className:re.badge,children:"Autocomplete"})]})]})})}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,
1399
1452
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1400
1453
  The border is kept as a 1px transparent line so the box stays the same size
1401
1454
  as it was when the outline was dashed. */
@@ -1471,7 +1524,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1471
1524
  opacity: 0;
1472
1525
  }
1473
1526
  }
1474
- `,document.head.appendChild(e)}var ye={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{jsx as va}from"react/jsx-runtime";var nt={selected:1,first:.7,next:.4,last:.2};function St({label:e,state:n,rounded:t,loading:i,onClick:r}){let o=[ye.pill,t?ye.rounded:"",i?ye.skeleton:""].filter(Boolean).join(" ");return va("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:nt[n]},onMouseDown:a=>a.preventDefault(),onClick:i?void 0:r,disabled:i,children: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 {
1527
+ `,document.head.appendChild(e)}var ye={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{jsx as wa}from"react/jsx-runtime";var nt={selected:1,first:.7,next:.4,last:.2};function St({label:e,state:o,rounded:t,loading:a,onClick:n}){let r=[ye.pill,t?ye.rounded:"",a?ye.skeleton:""].filter(Boolean).join(" ");return wa("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:nt[o]},onMouseDown:i=>i.preventDefault(),onClick:a?void 0:n,disabled:a,children: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 {
1475
1528
  position: relative;
1476
1529
  z-index: 1;
1477
1530
  pointer-events: auto;
@@ -1481,7 +1534,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1481
1534
  align-items: center;
1482
1535
  vertical-align: middle;
1483
1536
  }
1484
- `,document.head.appendChild(e)}var rt={list:"aia-list-qvLqO"};import{jsx as Qe}from"react/jsx-runtime";var wa=[125,69];function It(e){return e===0?"first":e===1?"next":"last"}function Ye({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:i,rounded:r,loading:o}){return o&&e.length===0?Qe("span",{className:rt.list,"data-aia-pill-list-loading":"",children:wa.map((a,p)=>Qe("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${r?ye.rounded:""} ${ye.skeleton}`,style:{width:a,opacity:nt[It(p)]}},`skel-${a}`))}):Qe("span",{className:rt.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((a,p)=>{let l=!!i&&p===n;return Qe(St,{label:a.text,state:l?"selected":It(p),selected:l,rounded:r,loading:o,onClick:()=>t(p)},`${a.parameter}-${a.text}`)})})}import{attachProductRowWheel as xa,productImageSources as ya,productImageSrc as ka,productInitial as Ca,uiStringsFor as Pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Sa,useRef as Ia,useState as Ea}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
1537
+ `,document.head.appendChild(e)}var rt={list:"aia-list-qvLqO"};import{jsx as Ze}from"react/jsx-runtime";var va=[125,69];function It(e){return e===0?"first":e===1?"next":"last"}function Ve({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:n,loading:r}){return r&&e.length===0?Ze("span",{className:rt.list,"data-aia-pill-list-loading":"",children:va.map((i,p)=>Ze("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${n?ye.rounded:""} ${ye.skeleton}`,style:{width:i,opacity:nt[It(p)]}},`skel-${i}`))}):Ze("span",{className:rt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((i,p)=>{let l=!!a&&p===o;return Ze(St,{label:i.text,state:l?"selected":It(p),selected:l,rounded:n,loading:r,onClick:()=>t(p)},`${i.parameter}-${i.text}`)})})}import{attachProductRowWheel as xa,productImageSources as ya,productImageSrc as ka,productInitial as Ca,uiStringsFor as Pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Sa,useRef as Ia,useState as Ea}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
1485
1538
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1486
1539
  theming one package sees the same result in the other.
1487
1540
 
@@ -1765,7 +1818,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1765
1818
  letter-spacing: 0.02em;
1766
1819
  text-align: center;
1767
1820
  }
1768
- `,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};import{jsx as se,jsxs as Ze}from"react/jsx-runtime";function Et({products:e,listboxId:n,onSelect:t,onFocusChange:i,focusable:r=!0,layout:o="row",imageFallback:a="image",strings:p=Pa()}){let l=e.length>0,v=Ia(null);if(Sa(()=>{let C=v.current;if(!(!l||!C))return xa(C)},[l]),!l)return null;let P=`${n}-products-label`;return Ze("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":o,role:"group","aria-labelledby":P,children:[se("div",{className:Q.label,id:P,"data-aia-products-label":"",children:p.products}),se("div",{ref:v,className:Q.row,"data-aia-products-row":"",children:e.map((C,m)=>se(Ta,{product:C,id:`${n}-product-${m}`,onSelect:t,onFocusChange:i,focusable:r,imageFallback:a,soldOut:p.soldOut},C.id))})]})}function Ta({product:e,id:n,onSelect:t,onFocusChange:i,focusable:r,imageFallback:o,soldOut:a}){let p=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return Ze("a",{id:n,className:Q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:p,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[se(Aa,{sources:ya(e.imageUrl),title:e.title,fallback:o},ka(e.imageUrl)??""),Ze("span",{className:Q.body,children:[e.vendor?se("span",{className:Q.vendor,children:e.vendor}):null,se("span",{className:Q.title,children:e.title}),e.price?se("span",{className:Q.price,children:e.price}):null,e.available===!1?se("span",{className:Q.badge,children:a}):null]})]})}function Aa({sources:e,title:n,fallback:t}){let[i,r]=Ea(0),o=e[i],a=!!o,p=!a&&t==="initial";return Ze("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!a&&!p?"":void 0,"data-aia-product-initial":p?"":void 0,children:[a?se("img",{className:Q.image,src:o,alt:"",loading:"lazy",decoding:"async",onError:()=>r(l=>l+1)}):null,p?Ca(n):null]})}import{isOptionsGridMobileViewport as _a,measureOptionsGrid as Ua,needsOptionsGridMeasurement as qa,OPTIONS_GRID_MOBILE_QUERY as ja,optionEnterDelayMs as Qa,planOptionsGrid as Rt,sameOptionRows as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Za,useLayoutEffect as $a,useRef as Ot,useState as Lt}from"react";import{optionsGridTemplateColumns as Ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Oa,useRef as Da}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 {
1821
+ `,document.head.appendChild(e)}var Y={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"};import{jsx as se,jsxs as $e}from"react/jsx-runtime";function Et({products:e,listboxId:o,onSelect:t,onFocusChange:a,focusable:n=!0,layout:r="row",imageFallback:i="image",strings:p=Pa()}){let l=e.length>0,v=Ia(null);if(Sa(()=>{let C=v.current;if(!(!l||!C))return xa(C)},[l]),!l)return null;let P=`${o}-products-label`;return $e("section",{className:Y.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":P,children:[se("div",{className:Y.label,id:P,"data-aia-products-label":"",children:p.products}),se("div",{ref:v,className:Y.row,"data-aia-products-row":"",children:e.map((C,g)=>se(Ta,{product:C,id:`${o}-product-${g}`,onSelect:t,onFocusChange:a,focusable:n,imageFallback:i,soldOut:p.soldOut},C.id))})]})}function Ta({product:e,id:o,onSelect:t,onFocusChange:a,focusable:n,imageFallback:r,soldOut:i}){let p=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return $e("a",{id:o,className:Y.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:p,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>a?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||a?.(!1)},children:[se(Aa,{sources:ya(e.imageUrl),title:e.title,fallback:r},ka(e.imageUrl)??""),$e("span",{className:Y.body,children:[e.vendor?se("span",{className:Y.vendor,children:e.vendor}):null,se("span",{className:Y.title,children:e.title}),e.price?se("span",{className:Y.price,children:e.price}):null,e.available===!1?se("span",{className:Y.badge,children:i}):null]})]})}function Aa({sources:e,title:o,fallback:t}){let[a,n]=Ea(0),r=e[a],i=!!r,p=!i&&t==="initial";return $e("span",{className:Y.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!p?"":void 0,"data-aia-product-initial":p?"":void 0,children:[i?se("img",{className:Y.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>n(l=>l+1)}):null,p?Ca(o):null]})}import{isOptionsGridMobileViewport as _a,measureOptionsGrid as Ua,needsOptionsGridMeasurement as qa,OPTIONS_GRID_MOBILE_QUERY as ja,optionEnterDelayMs as Qa,planOptionsGrid as Rt,sameOptionRows as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Za,useLayoutEffect as Va,useRef as Ot,useState as Lt}from"react";import{optionsGridTemplateColumns as Ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Oa,useRef as Da}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 {
1769
1822
  display: grid;
1770
1823
  grid-template-columns: repeat(
1771
1824
  auto-fit,
@@ -1801,7 +1854,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1801
1854
  .aia-grid[data-scroll]::-webkit-scrollbar {
1802
1855
  display: none;
1803
1856
  }
1804
- `,document.head.appendChild(e)}import{jsx as La}from"react/jsx-runtime";function Tt({min:e="16rem",max:n,gap:t,scroll:i=!1,maxHeight:r,scrollResetKey:o,cols:a,template:p,innerRef:l,className:v,children:P,...C}){let m=Da(null);Oa(()=>{if(o===void 0)return;let S=m.current;S&&(S.scrollTop=0)},[o]);let b={"--aia-grid-min":e};return n&&(b["--aia-grid-max"]=n),t&&(b["--aia-grid-gap"]=t),r&&(b["--aia-grid-max-height"]=r),a&&(b.gridTemplateColumns=Ra(a)),p&&(b.gridTemplateColumns=p),La("div",{ref:S=>{m.current=S,l?.(S)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":i||void 0,style:b,...C,children:P})}import{formatOptionCount as za,OPTION_ENTER_DELAY_VAR as Ma,optionImageSources as Na,optionLabel as Ba,sanitizeOptionIconSvg as Ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Fa,useMemo as Ka,useRef as Ga,useState as st}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 {
1857
+ `,document.head.appendChild(e)}import{jsx as La}from"react/jsx-runtime";function Tt({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:n,scrollResetKey:r,cols:i,template:p,innerRef:l,className:v,children:P,...C}){let g=Da(null);Oa(()=>{if(r===void 0)return;let S=g.current;S&&(S.scrollTop=0)},[r]);let b={"--aia-grid-min":e};return o&&(b["--aia-grid-max"]=o),t&&(b["--aia-grid-gap"]=t),n&&(b["--aia-grid-max-height"]=n),i&&(b.gridTemplateColumns=Ra(i)),p&&(b.gridTemplateColumns=p),La("div",{ref:S=>{g.current=S,l?.(S)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":a||void 0,style:b,...C,children:P})}import{formatOptionCount as za,OPTION_ENTER_DELAY_VAR as Ma,optionImageSources as Na,optionLabel as Fa,sanitizeOptionIconSvg as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ha,useMemo as Ka,useRef as Ga,useState as st}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 {
1805
1858
  position: relative;
1806
1859
  /* Clip, not visible: the entrance rise below runs on the inner content,
1807
1860
  and a transformed box extends its scroll container's scrollable area.
@@ -1935,6 +1988,13 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
1935
1988
  mask-image: linear-gradient(to bottom, rgb(0 0 0), rgb(0 0 0 / 0.6));
1936
1989
  }
1937
1990
 
1991
+ /* A panel fitted to the viewport (data-aia-fit, see appearance.css) shows
1992
+ every row, so the row the hint picked is not the last one on screen. */
1993
+ [data-aia-fit] .aia-scrollHint-xKXPt .aia-content-T-Qba {
1994
+ -webkit-mask-image: none;
1995
+ mask-image: none;
1996
+ }
1997
+
1938
1998
  /* Loading state \u2014 preserve the row's exact dimensions. The content stays an
1939
1999
  inline span so the line box and padding match the non-loading state byte
1940
2000
  for byte. Just hide the text and apply a background as a skeleton bar; the
@@ -2198,7 +2258,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
2198
2258
  opacity: 0;
2199
2259
  }
2200
2260
  }
2201
- `,document.head.appendChild(e)}var U={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",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{jsx as Ee,jsxs as Wa}from"react/jsx-runtime";function At({option:e,isHighlighted:n,onSelect:t,onHighlight:i,onUnhighlight:r,id:o,loading:a,showIcon:p=!0,showImage:l=!0,showCount:v=!0,scrollHint:P,enterDelayMs:C=0}){let[m]=st(C),[b,S]=st(!1),D=l?Na(e.image_url):[],L=D[0]??null,[F,O]=st([]),I=D.find(N=>!F.includes(N))??null,B=Ka(()=>!L&&p&&e.icon_svg?Ha(e.icon_svg):null,[L,p,e.icon_svg]),z=v?za(e.item_count):null,k=Ga(void 0);Fa(()=>()=>clearTimeout(k.current),[]);let M=()=>{a||!e.is_tappable||b||(S(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>S(!1),170))},K=[U.item,n&&!a?U.highlighted:"",e.is_tappable?U.tappable:U.nonTappable,b?U.pressed:"",P?U.scrollHint:""].filter(Boolean).join(" ");return Ee("div",{id:o,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":B&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":z!==null?e.item_count:void 0,"aria-selected":n,className:K,style:{[Ma]:`${m}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:M,onKeyDown:N=>{!a&&e.is_tappable&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),M())},onMouseEnter:!a&&e.is_tappable?i:void 0,onMouseLeave:r,children:Wa("span",{className:U.content,children:[L&&Ee("span",{className:`${U.image} magicx-aia-option-image`,"aria-hidden":"true",children:Ee("img",{src:I??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:I===null,onError:()=>{I!==null&&O(N=>[...N,I])}})}),B&&Ee("span",{className:`${U.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:B}}),Ee("span",{className:U.text,children:Ba(e)}),e.tag&&Ee("span",{className:U.tag,children:e.tag}),z!==null&&Ee("span",{className:`${U.count} magicx-aia-option-count`,children:z})]})})}import{jsx as Dt}from"react/jsx-runtime";function Va(){let[e,n]=Lt(_a);return Za(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ja),i=()=>n(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function zt({options:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:o,loading:a,groupKey:p="",optionsPosition:l="below",showIcons:v=!0,showImages:P=!0,showCounts:C=!0}){let m=Va(),b=Ot(null),[S,D]=Lt(null),L=Ot(null);$a(()=>{if(a&&Ya(L.current,e))return;L.current=a?null:e;let O=b.current,B=O&&!a&&qa(e.length,m)?Ua(O):null;D(B?Rt(e.length,m,B.rowWidths,B.gridWidth):null)},[e,m,a]);let F=S??Rt(e.length,m,null,null);return Dt(Tt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:p,template:F.template,maxHeight:F.maxHeight,innerRef:O=>{b.current=O},"data-aia-group":p,children:e.map((O,I)=>Dt(At,{option:O,isHighlighted:I===n,onSelect:t,onHighlight:()=>i(I),onUnhighlight:r?()=>r(I):void 0,id:`${o}-option-${I}`,loading:a,showIcon:v,showImage:P,showCount:C,scrollHint:!a&&F.scrollHintIndices.includes(I),enterDelayMs:a?0:Qa(I,F.cols,e.length,l)},`${p}\0${O.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2261
+ `,document.head.appendChild(e)}var U={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",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{jsx as Ee,jsxs as Wa}from"react/jsx-runtime";function At({option:e,isHighlighted:o,onSelect:t,onHighlight:a,onUnhighlight:n,id:r,loading:i,showIcon:p=!0,showImage:l=!0,showCount:v=!0,scrollHint:P,enterDelayMs:C=0}){let[g]=st(C),[b,S]=st(!1),D=l?Na(e.image_url):[],L=D[0]??null,[H,O]=st([]),I=D.find(N=>!H.includes(N))??null,F=Ka(()=>!L&&p&&e.icon_svg?Ba(e.icon_svg):null,[L,p,e.icon_svg]),z=v?za(e.item_count):null,k=Ga(void 0);Ha(()=>()=>clearTimeout(k.current),[]);let M=()=>{i||!e.is_tappable||b||(S(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>S(!1),170))},K=[U.item,o&&!i?U.highlighted:"",e.is_tappable?U.tappable:U.nonTappable,b?U.pressed:"",P?U.scrollHint:""].filter(Boolean).join(" ");return Ee("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":F&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":z!==null?e.item_count:void 0,"aria-selected":o,className:K,style:{[Ma]:`${g}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:M,onKeyDown:N=>{!i&&e.is_tappable&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),M())},onMouseEnter:!i&&e.is_tappable?a:void 0,onMouseLeave:n,children:Wa("span",{className:U.content,children:[L&&Ee("span",{className:`${U.image} magicx-aia-option-image`,"aria-hidden":"true",children:Ee("img",{src:I??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:I===null,onError:()=>{I!==null&&O(N=>[...N,I])}})}),F&&Ee("span",{className:`${U.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:F}}),Ee("span",{className:U.text,children:Fa(e)}),e.tag&&Ee("span",{className:U.tag,children:e.tag}),z!==null&&Ee("span",{className:`${U.count} magicx-aia-option-count`,children:z})]})})}import{jsx as Dt}from"react/jsx-runtime";function $a(){let[e,o]=Lt(_a);return Za(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ja),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function zt({options:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:n,listboxId:r,loading:i,groupKey:p="",optionsPosition:l="below",showIcons:v=!0,showImages:P=!0,showCounts:C=!0}){let g=$a(),b=Ot(null),[S,D]=Lt(null),L=Ot(null);Va(()=>{if(i&&Ya(L.current,e))return;L.current=i?null:e;let O=b.current,F=O&&!i&&qa(e.length,g)?Ua(O):null;D(F?Rt(e.length,g,F.rowWidths,F.gridWidth):null)},[e,g,i]);let H=S??Rt(e.length,g,null,null);return Dt(Tt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:p,template:H.template,maxHeight:H.maxHeight,innerRef:O=>{b.current=O},"data-aia-group":p,children:e.map((O,I)=>Dt(At,{option:O,isHighlighted:I===o,onSelect:t,onHighlight:()=>a(I),onUnhighlight:n?()=>n(I):void 0,id:`${r}-option-${I}`,loading:i,showIcon:v,showImage:P,showCount:C,scrollHint:!i&&H.scrollHintIndices.includes(I),enterDelayMs:i?0:Qa(I,H.cols,e.length,l)},`${p}\0${O.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2202
2262
  display: flex;
2203
2263
  flex-direction: column;
2204
2264
  gap: var(--aia-stack-space, 0.5rem);
@@ -2213,7 +2273,7 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
2213
2273
  align-items: end;
2214
2274
  }
2215
2275
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2216
- `,document.head.appendChild(e)}import{jsx as Xa}from"react/jsx-runtime";function Mt({space:e,align:n="stretch",className:t,children:i,...r}){let o=e?{"--aia-stack-space":e}:void 0;return Xa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:o,...r,children:i})}import{jsx as Y,jsxs as lt}from"react/jsx-runtime";var oi=[159,119,164],ni=()=>{},Nt=()=>{};function ri(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=ii(n);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>i(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function si(e,n){let t=$e(null);Ve(()=>{let i=e.current,r=n.current;if(!i||!r)return;let o=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==o&&(t.current.controller.destroy(),t.current=null),o&&!t.current){t.current={grid:o,controller:Ja({dropdown:i,grid:o,button:r})};return}t.current?.controller.update()}),Ve(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function dt({suggestions:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,isOpen:o,id:a,className:p,pills:l,onPillClick:v,showPills:P=!0,onSkip:C,showSkipButton:m=!0,showOptionIcons:b=!0,showOptionImages:S=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:F=!1,isLoading:O=!1,skeletonExiting:I=!1,isInputEmpty:B=!1,language:z,products:k,onProductSelect:M,onProductFocusChange:K,productsLayout:N="row",productImageFallback:te="image",formatType:le="options",dateView:W=null,selectedDateIso:de=null,selectedDateRange:ke=null,dateRangeStart:ce=null,onPreviousMonth:u,onNextMonth:Ce,optionsPosition:ae="below",mode:pe}){let ie=ri(pe),he=ie!==void 0,Z=$e(null),$=$e(null);si(Z,$),Ve(()=>{if(Z.current)return ei(Z.current)},[]);let s=e[0]?.options??[],g=!!(l&&l.length>0&&v),f=!!(k&&k.length>0),w=o&&(s.length>0||P&&g||O||f),y={suggestions:e,activeIndex:n,pills:l,showPills:P,showSkipButton:m,showOptionIcons:b,showOptionImages:S,showOptionCounts:D,skipDisabled:L,activeSelected:F,isLoading:O,skeletonExiting:I,isInputEmpty:B,products:k,formatType:le,dateView:W,selectedDateIso:de,selectedDateRange:ke,dateRangeStart:ce},E=$e(y);w&&(E.current=y);let c=w?y:E.current,G=ai(z),q=c.suggestions[0],j=q?.options??[],ue=c.activeIndex>=0&&!!j[c.activeIndex]?.is_tappable,me=!!(c.pills&&c.pills.length>0&&v),ge=c.showPills&&me,fe=c.showPills&&!me&&c.isLoading,be=ge||fe,x=me&&c.showSkipButton&&!c.isInputEmpty&&!!C,ve=c.pills?.[0]?.text,we=ti(c.formatType)&&c.dateView!=null,oe=j.length>0&&!we,h=j.length>0&&we&&!c.isLoading,Te=c.isLoading&&!oe&&!h,Ae=c.products??[];return lt("div",{ref:Z,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":ae,"data-mode":ie,"data-aia-loading":c.isLoading?"":void 0,"data-aia-skeleton-exiting":c.skeletonExiting?"":void 0,"data-aia-has-products":Ae.length>0?"":void 0,className:`${he?"magicx-aia ":""}${ne.dropdown} ${w?ne.visible:""} ${p??""}`,onMouseDown:X=>X.preventDefault(),children:[lt(Mt,{space:"8px",children:[(be||x)&&lt(He,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:[be&&Y("span",{className:ne.pillScroll,"data-aia-pill-scroll":"",children:Y(Ye,{pills:c.pills??[],activePillIndex:0,activeSelected:c.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:c.isLoading})}),x&&Y("button",{type:"button",tabIndex:-1,className:ne.skip,"data-aia-skip":"",disabled:c.isLoading||c.skipDisabled,"aria-label":ve?`${G.skipLabel} ${ve}`:G.skipLabel,onClick:C,children:G.skip})]}),oe&&Y(zt,{options:j,activeIndex:c.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:a,loading:c.isLoading,groupKey:q?`${q.parameter} ${q.text}`:"",optionsPosition:ae,showIcons:c.showOptionIcons,showImages:c.showOptionImages,showCounts:c.showOptionCounts}),h&&c.dateView&&Y(kt,{options:j,activeIndex:c.activeIndex,listboxId:a,view:c.dateView,selection:{selectedIso:c.selectedDateIso??null,selectedRange:c.selectedDateRange??null,rangeStart:c.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:r,onPreviousMonth:u??Nt,onNextMonth:Ce??Nt}),Te&&Y("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:oi.map(X=>Y("span",{className:ne.skeletonBar,style:{width:X}},`bar-${X}`))}),Y(Et,{products:Ae,listboxId:a,onSelect:M??ni,onFocusChange:K,focusable:w,layout:N,imageFallback:te,strings:G}),Y(Pt,{isOptionHighlighted:ue,isInputEmpty:c.isInputEmpty,strings:G})]}),Y("button",{ref:$,type:"button",tabIndex:-1,className:ne.scrollArrow,"data-aia-scroll-arrow":"","aria-label":G.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 ki,ModeController as Ci,setCursorOffset as Pi,uiStringsFor as Si}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as li}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 {
2276
+ `,document.head.appendChild(e)}import{jsx as Xa}from"react/jsx-runtime";function Mt({space:e,align:o="stretch",className:t,children:a,...n}){let r=e?{"--aia-stack-space":e}:void 0;return Xa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:r,...n,children:a})}import{jsx as Z,jsxs as lt}from"react/jsx-runtime";var ni=[159,119,164],ri=()=>{},Nt=()=>{};function si(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=oi(o);if(De(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function li(e,o){let t=Oe(null);De(()=>{let a=e.current,n=o.current;if(!a||!n)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:Ja({dropdown:a,grid:r,button:n})};return}t.current?.controller.update()}),De(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function di(e,o){let t=Oe(o);t.current=o;let a=Oe(null);De(()=>{let n=e.current;if(n){if(!a.current){a.current=ei({dropdown:n,isOpen:()=>t.current});return}a.current.update()}}),De(()=>()=>{a.current?.destroy(),a.current=null},[])}function dt({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:n,isOpen:r,id:i,className:p,pills:l,onPillClick:v,showPills:P=!0,onSkip:C,showSkipButton:g=!0,showOptionIcons:b=!0,showOptionImages:S=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:H=!1,isLoading:O=!1,skeletonExiting:I=!1,isInputEmpty:F=!1,language:z,products:k,onProductSelect:M,onProductFocusChange:K,productsLayout:N="row",productImageFallback:te="image",formatType:le="options",dateView:W=null,selectedDateIso:de=null,selectedDateRange:ke=null,dateRangeStart:ce=null,onPreviousMonth:u,onNextMonth:Ce,optionsPosition:ae="below",mode:pe}){let ie=si(pe),he=ie!==void 0,q=Oe(null),V=Oe(null);li(q,V),De(()=>{if(q.current)return ti(q.current)},[]);let s=e[0]?.options??[],m=!!(l&&l.length>0&&v),f=!!(k&&k.length>0),w=r&&(s.length>0||P&&m||O||f);di(q,w);let y={suggestions:e,activeIndex:o,pills:l,showPills:P,showSkipButton:g,showOptionIcons:b,showOptionImages:S,showOptionCounts:D,skipDisabled:L,activeSelected:H,isLoading:O,skeletonExiting:I,isInputEmpty:F,products:k,formatType:le,dateView:W,selectedDateIso:de,selectedDateRange:ke,dateRangeStart:ce},E=Oe(y);w&&(E.current=y);let c=w?y:E.current,G=ii(z),j=c.suggestions[0],Q=j?.options??[],ue=c.activeIndex>=0&&!!Q[c.activeIndex]?.is_tappable,ge=!!(c.pills&&c.pills.length>0&&v),me=c.showPills&&ge,fe=c.showPills&&!ge&&c.isLoading,be=me||fe,x=ge&&c.showSkipButton&&!c.isInputEmpty&&!!C,we=c.pills?.[0]?.text,ve=ai(c.formatType)&&c.dateView!=null,oe=Q.length>0&&!ve,h=Q.length>0&&ve&&!c.isLoading,Te=c.isLoading&&!oe&&!h,Ae=c.products??[];return lt("div",{ref:q,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":ae,"data-mode":ie,"data-aia-loading":c.isLoading?"":void 0,"data-aia-skeleton-exiting":c.skeletonExiting?"":void 0,"data-aia-has-products":Ae.length>0?"":void 0,className:`${he?"magicx-aia ":""}${ne.dropdown} ${w?ne.visible:""} ${p??""}`,onMouseDown:X=>X.preventDefault(),children:[lt(Mt,{space:"8px",children:[(be||x)&&lt(Ke,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:[be&&Z("span",{className:ne.pillScroll,"data-aia-pill-scroll":"",children:Z(Ve,{pills:c.pills??[],activePillIndex:0,activeSelected:c.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:c.isLoading})}),x&&Z("button",{type:"button",tabIndex:-1,className:ne.skip,"data-aia-skip":"",disabled:c.isLoading||c.skipDisabled,"aria-label":we?`${G.skipLabel} ${we}`:G.skipLabel,onClick:C,children:G.skip})]}),oe&&Z(zt,{options:Q,activeIndex:c.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:n,listboxId:i,loading:c.isLoading,groupKey:j?`${j.parameter} ${j.text}`:"",optionsPosition:ae,showIcons:c.showOptionIcons,showImages:c.showOptionImages,showCounts:c.showOptionCounts}),h&&c.dateView&&Z(kt,{options:Q,activeIndex:c.activeIndex,listboxId:i,view:c.dateView,selection:{selectedIso:c.selectedDateIso??null,selectedRange:c.selectedDateRange??null,rangeStart:c.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:n,onPreviousMonth:u??Nt,onNextMonth:Ce??Nt}),Te&&Z("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:ni.map(X=>Z("span",{className:ne.skeletonBar,style:{width:X}},`bar-${X}`))}),Z(Et,{products:Ae,listboxId:i,onSelect:M??ri,onFocusChange:K,focusable:w,layout:N,imageFallback:te,strings:G}),Z(Pt,{isOptionHighlighted:ue,isInputEmpty:c.isInputEmpty,strings:G})]}),Z("button",{ref:V,type:"button",tabIndex:-1,className:ne.scrollArrow,"data-aia-scroll-arrow":"","aria-label":G.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 Pi,ModeController as Si,setCursorOffset as Ii,uiStringsFor as Ei}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as ci}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 {
2217
2277
  flex-shrink: 0;
2218
2278
  width: 32px;
2219
2279
  height: 32px;
@@ -2266,5 +2326,5 @@ import{buildSubmitResult as xn,cellDay as yn,cellIso as kn,DATE_RANGE_META_END a
2266
2326
  );
2267
2327
  cursor: default;
2268
2328
  }
2269
- `,document.head.appendChild(e)}var Bt={submitButton:"aia-submitButton-otz7H"};import{jsx as ct}from"react/jsx-runtime";function Ht({disabled:e,onClick:n,label:t=li().submit}){return ct("button",{type:"button","data-aia-submit":"",className:Bt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":t,children:ct("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ct("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as di,dateSelectionFor as ci,identifiedParamLabel as pi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as _t,useEffect as Oe,useRef as H,useState as hi}from"react";import{useRef as Ft}from"react";function Kt(e){let n=Ft(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=Ft({key:"",overrides:void 0});if(i.current.key!==t){let r={};for(let o of Object.keys(e??{})){let a=(p,l,v)=>{let P=n.current?.[o];return P?P(p,l,v):[]};r[o]=a}i.current={key:t,overrides:e?r:void 0}}return{overrides:i.current.overrides,key:t}}import{useRef as Gt}from"react";function Wt(e){let n=Gt(e);n.current=e;let t=Gt(null);t.current===null&&(t.current={fetch:(r,o)=>{let a=n.current;return a?a.fetch(r,o):Promise.reject(new Error("products config removed"))},transform:r=>n.current?.transform(r)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var ui={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],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,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function pt({onSubmit:e,onResult:n,onError:t,optionOverrides:i,maskCompletedText:r,apiConfig:o,additionalContext:a,language:p,productId:l,visitorId:v,columns:P=2,dropdownTrigger:C,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:S,showOptionIcons:D,showOptionImages:L,showOptionCounts:F,showSkipButton:O,showProducts:I,productImageFallback:B="image",onFocus:z,onBlur:k,value:M,completedParams:K,onChange:N,onParamsChange:te,products:le,mapProducts:W,onProductSelect:de,source:ke,setCursor:ce}){let u=H(null),[Ce,ae]=hi(null),pe=H(e);pe.current=e;let ie=H(n);ie.current=n;let he=H(t);he.current=t;let Z=H(N);Z.current=N;let $=H(te);$.current=te;let s=H(z);s.current=z;let g=H(k);g.current=k;let f=H(ce);f.current=ce;let w=H(de);w.current=de;let y=H(v);y.current=v;let E=H(()=>{let d=y.current;return typeof d=="function"?d():d}).current,c=Wt(le),G=H(W);G.current=W;let q=H((d,_)=>{let T=G.current;return T?T(d,_):d}).current,j=W?q:void 0,ue=Kt(i);Oe(()=>{if(typeof document>"u")return;let d=new di(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:a,language:p,productId:l,visitorId:E,optionOverrides:ue.overrides,maskCompletedText:r,columns:P,dropdownTrigger:C,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I,source:ke,value:M,completedParams:K,onSubmit:(...T)=>pe.current?.(...T),onResult:(...T)=>ie.current?.(...T),onError:(...T)=>he.current?.(...T),onChange:(...T)=>Z.current?.(...T),onParamsChange:(...T)=>$.current?.(...T),onFocus:()=>s.current?.(),onBlur:()=>g.current?.(),onProductSelect:T=>w.current?.(T),setCursor:T=>f.current?.(T),products:c.config,mapProducts:j});u.current=d,ae(d.getState());let _=d.subscribe(T=>ae(T));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Oe(()=>{M!==void 0&&u.current?.setValue(M)},[M]),Oe(()=>{K!==void 0&&u.current?.setCompletedParams(K)},[K]);let me=JSON.stringify(o??null),ge;try{ge=JSON.stringify(a??null)}catch{ge="[unstringifiable]"}Oe(()=>{u.current?.update({apiConfig:o,additionalContext:a,language:p,productId:l,optionOverrides:ue.overrides,dropdownTrigger:C,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I})},[me,ge,p,l,ue.key,C,m,b,S,I]);let fe=H(!1);Oe(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:c.config})},[c.enabled]),Oe(()=>{u.current?.update({mapProducts:j})},[j]);let be=H(null);be.current===null&&(be.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=be.current,ve=_t(d=>{let _=d.target.value,tt=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(tt)},[]),we=_t(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),oe=u.current,h=Ce??ui,Te=M!==void 0?M:h.text,Ae=K!==void 0?K:h.completedParams,X=h.actionableSuggestions,ze=X[0],Pe=oe?.listboxId??"",Ge=h.activeDropdownIndex>=0&&oe?`${Pe}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Se=h.editingIdentified,Me=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Se?{parameter:Se.parameter,text:pi(Se.parameter),required:!0,options:[]}:null,We=h.dropdownSuggestion??Me??ze,et=Me?[Me]:X,Ne=ci(h),_e=!oe||h.dropdownLoading;return{completedParams:Ae,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:X,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:_e,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Pe,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Se,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Te,placeholder:h.placeholderText||void 0,onChange:ve,onKeyDown:we,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":Ge,"aria-autocomplete":"list","aria-controls":Pe},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:We?[{...We,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Pe,pills:et,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(O??!0)&&!xe&&!Se,showOptionIcons:D??!0,showOptionImages:L??!0,showOptionCounts:F??!0,skipDisabled:h.inSelectionAnimation,isLoading:_e,skeletonExiting:h.skeletonExiting,isInputEmpty:Te.trim().length===0,language:p,products:h.products,productImageFallback:B,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Ne.selectedIso,selectedDateRange:Ne.selectedRange,dateRangeStart:Ne.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:m??"below"}}}import{chipIdFromTap as mi,extractPlainText as Ut,getCursorOffset as qt,keepCaretOnChip as gi,plainTextLength as fi,renderEditableContent as bi,setCursorOffset as jt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as V,useEffect as Xe,useLayoutEffect as ht,useRef as De}from"react";var Je;function vi(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Qt(e){let{segments:n,showChipIcons:t=!0,showChipImages:i=!0,newParamId:r,editingParam:o,editingIdentified:a,editingAnchor:p,caretOffset:l,placeholderText:v,isFocused:P,isDropdownOpen:C,listboxId:m,activeDescendantId:b,autoFocus:S,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:F,handleCaretMove:O,startEditingParam:I,replaceEditingRange:B,setFocused:z}=e,k=De(null),M=De(!1),K=De(""),N=De(""),te=De(null),le=De(0);te.current=l,Xe(()=>{if(!S)return;let s=k.current;if(!s)return;document.activeElement===s?z(!0):s.focus();let g=s.ownerDocument??document,f=g.getSelection(),w=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!w){let y=g.createRange();y.selectNodeContents(s),y.collapse(!0),f.removeAllRanges(),f.addRange(y)}},[S,z]),Xe(()=>{let s=k.current;if(!s)return;let g=s.ownerDocument??document,f=()=>{let w=g.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!s.contains(w.anchorNode))return;let y=w.anchorNode,E=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,G=(w.isCollapsed?E?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,q=o?.id??a?.id??null;if(G&&G!==q){I(G);return}performance.now()-le.current<50||O(qt(s))};return g.addEventListener("selectionchange",f),()=>g.removeEventListener("selectionchange",f)},[o,a,I,O]),Xe(()=>{let s=k.current;if(!s)return;let g=f=>{let w=mi(s,f.target);w&&(I(w),gi(s,w))};return s.addEventListener("click",g),()=>s.removeEventListener("click",g)},[I]),ht(()=>{let s=k.current;s&&bi({input:s,segments:n,newParamId:r,editingParamId:o?.id??null,placeholderText:v??"",isFocused:P,showChipIcons:t,showChipImages:i})},[n,r,o,v,P,t,i]),ht(()=>{let s=K.current,g=r??"";if(K.current=g,!g||g===s)return;let f=k.current;if(!f)return;f.focus();let w=te.current??fi(f);jt(f,w)},[r]),ht(()=>{let s=N.current,g=o?.id??"";if(N.current=g,!g||g===s||p==null)return;let f=k.current;f&&jt(f,p)},[o,p]);let W=V(()=>{if(M.current)return;let s=k.current;if(!s)return;let g=Ut(s),w=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;D(w)},[D]),de=V(()=>{le.current=performance.now(),W();let s=k.current;s&&F(qt(s))},[W,F]);Xe(()=>{let s=k.current;if(!s)return;let g=f=>{let w=f,y=w.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){f.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let E=y.startsWith("delete")?"":w.data??"";B(E)&&f.preventDefault()}};return s.addEventListener("beforeinput",g),()=>s.removeEventListener("beforeinput",g)},[B]);let ke=V(()=>{M.current=!0},[]),ce=V(()=>{M.current=!1,W()},[W]),u=V(s=>{s.preventDefault();let g=k.current;if(!g)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let w=g.ownerDocument??document,y=w.getSelection();if(!y||y.rangeCount===0)return;let E=y.getRangeAt(0);if(!g.contains(E.startContainer))return;E.deleteContents();let c=w.createTextNode(f);E.insertNode(c),E.setStartAfter(c),E.collapse(!0),y.removeAllRanges(),y.addRange(E),W()},[W]),Ce=V(s=>L(s),[L]),ae=V(()=>z(!0),[z]),pe=V(()=>z(!1),[z]),ie=V(()=>k.current?.focus(),[]),he=V(()=>k.current?.blur(),[]),Z=V(()=>{let s=k.current;return s?Ut(s):""},[]),$=vi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":C,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:de,onKeyDown:Ce,onCompositionStart:ke,onCompositionEnd:ce,onPaste:u,onFocus:ae,onBlur:pe},getPlainText:Z,focus:ie,blur:he}}import{jsx as Le,jsxs as mt}from"react/jsx-runtime";function Ii(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ei=wi(function({onSubmit:n,onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,className:a,apiConfig:p,additionalContext:l,language:v,productId:P,visitorId:C,columns:m,pillPlacement:b="dropdown",mode:S="auto",optionsPosition:D="below",animations:L=!0,dropdownTrigger:F,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:B=!0,showChipIcons:z=!0,showChipImages:k=!0,showOptionImages:M=!0,showOptionCounts:K=!0,showSkipButton:N,showProducts:te,productsLayout:le,productImageFallback:W,autoFocus:de=!0,onFocus:ke,onBlur:ce,value:u,completedParams:Ce,onChange:ae,onParamsChange:pe,products:ie,mapProducts:he,onProductSelect:Z,submitButton:$,resetOnSubmit:s=!0},g){let f=Ke(null),w=Ke(null),y=Ke(()=>{}),E=Ke(null),c=Ke(null);Yt(()=>{let A=f.current;if(A)return E.current?E.current.setMode(S):E.current=new Ci(A,S),()=>{E.current?.destroy(),E.current=null}},[S]);let G=ut(A=>{let J=c.current?.current;J&&(J.focus(),Pi(J,A))},[]),{completedParams:q,skippedParams:j,identifiedParams:ue,isReady:me,customFields:ge,suggestionPills:fe,setActivePill:be,skipActivePill:x,segments:ve,newParamId:we,clearNewParamId:oe,placeholderText:h,isFocused:Te,isDropdownOpen:Ae,isActivePillSelected:X,isLoading:ze,activeIndex:Pe,listboxId:Ge,handleTextChange:xe,handleKeyDown:Se,setFocused:Me,editingParam:We,editingIdentified:et,editingAnchor:Ne,caretOffset:_e,startEditingParam:d,handleCaretAfterInput:_,handleCaretMove:T,replaceEditingRange:tt,dropdownProps:Zt,reset:Ue,refreshProducts:gt,recordSubmit:ft}=pt({onSubmit:A=>y.current(A),onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,apiConfig:p,additionalContext:l,language:v,productId:P,visitorId:C,columns:m,dropdownTrigger:F,optionsPosition:D,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:B,showOptionImages:M,showOptionCounts:K,showSkipButton:N,showProducts:te,onFocus:ke,onBlur:ce,value:u,completedParams:Ce,onChange:ae,onParamsChange:pe,products:ie,mapProducts:he,onProductSelect:Z,source:"full-sdk",setCursor:G});Yt(()=>{if(!we)return;let A=window.setTimeout(()=>oe(),650);return()=>window.clearTimeout(A)},[we,oe]);let $t=Pe>=0?`${Ge}-option-${Pe}`:void 0,{inputRef:at,editorProps:Vt,focus:qe,blur:bt,getPlainText:vt}=Qt({segments:ve,newParamId:we,editingParam:We,editingIdentified:et,editingAnchor:Ne,caretOffset:_e,placeholderText:h,isFocused:Te,showChipIcons:z,showChipImages:k,isDropdownOpen:Ae,listboxId:Ge,activeDescendantId:$t,autoFocus:de,handleTextChange:xe,handleKeyDown:Se,handleCaretAfterInput:_,handleCaretMove:T,startEditingParam:d,replaceEditingRange:tt,setFocused:Me});c.current=at,yi(()=>{let A=w.current,J=at.current;if(!A||!J)return;let Be=()=>{let xt=A.firstElementChild;if(!xt)return;let ta=xt.getBoundingClientRect(),aa=J.getBoundingClientRect();ta.top>=aa.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};Be();let wt=new ResizeObserver(Be);return wt.observe(J),()=>wt.disconnect()},[ve,fe.length,ze,at]),xi(g,()=>({focus:qe,blur:bt,reset:Ue,refreshProducts:gt,setMode:A=>E.current?.setMode(A),skipActivePill:x}),[qe,bt,Ue,gt,x]);let je=!!ve.length||q.length>0,it=ut(A=>{if(!je)return;let J=vt(),Be=ki(J,q,j,{identifiedParams:ue,isReady:me,customFields:ge});A&&ft(Be),n(Be),s&&Ue()},[ft,s,je,q,j,ue,me,ge,n,Ue,vt]);y.current=()=>it(!1);let Xt=ut(A=>{A.target?.closest("[data-aia-pill]")||qe()},[qe]),Jt=b==="inline",ea=b==="dropdown";return mt("div",{ref:f,className:`magicx-aia ${Ie.container} ${a??""}`,"data-pill-placement":b,"data-options-position":D,"data-animations":L?"on":"off","data-mode":Ii(S),children:[Le(dt,{...Zt,showPills:ea,productsLayout:le,productImageFallback:W}),mt("div",{className:Ie.inputWrapper,"data-aia-input-wrapper":"",onClick:Xt,children:[mt("div",{className:Ie.editorArea,"data-aia-editor":"",children:[Le("div",{...Vt,className:Ie.input,"data-aia-input":""}),Jt&&(ze||fe.length>0)&&Le("span",{ref:w,className:Ie.pillListContainer,"data-aia-pill-list-container":"",children:Le(Ye,{pills:fe,activePillIndex:0,activeSelected:X,onSelectPill:be,loading:ze})})]}),$===null?null:$===void 0?Le(Ht,{disabled:!je,onClick:()=>it(!0),label:Si(v).submit}):Le("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ie.submitSlot,onClick:A=>{je&&(A.stopPropagation(),it(!0))},children:$})]})]})});export{Ei as AIAutocomplete,dt as AIAutocompleteDropdown,Cn as DATE_RANGE_META_END,Pn as DATE_RANGE_META_START,Sn as DEFAULT_OPTION_COUNT_UNIT,Bn as PRODUCT_PATH_PREFIX,Qn as WEEKDAY_LABELS,xn as buildSubmitResult,yn as cellDay,kn as cellIso,In as dateCellMarks,En as formatDate,Tn as formatDateRange,An as formatOptionCount,Rn as isoDate,On as monthLabel,Dn as optionCountLabel,Ln as optionHasImage,zn as optionImageSources,Mn as optionImageSrc,Nn as optionLabel,Hn as parseDate,Fn as parseLooseDate,Kn as parseLooseDateRange,Gn as productFromMatchedItem,Wn as productImageSources,_n as productsFromCustomFields,Un as sanitizeOptionIconSvg,qn as selectedRangeFor,pt as useAIAutocomplete,jn as visibleDateRange,Yn as withSkippedParams};
2329
+ `,document.head.appendChild(e)}var Ft={submitButton:"aia-submitButton-otz7H"};import{jsx as ct}from"react/jsx-runtime";function Bt({disabled:e,onClick:o,label:t=ci().submit}){return ct("button",{type:"button","data-aia-submit":"",className:Ft.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":t,children:ct("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ct("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as pi,dateSelectionFor as hi,identifiedParamLabel as ui}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as _t,useEffect as Le,useRef as B,useState as gi}from"react";import{useRef as Ht}from"react";function Kt(e){let o=Ht(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Ht({key:"",overrides:void 0});if(a.current.key!==t){let n={};for(let r of Object.keys(e??{})){let i=(p,l,v)=>{let P=o.current?.[r];return P?P(p,l,v):[]};n[r]=i}a.current={key:t,overrides:e?n:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as Gt}from"react";function Wt(e){let o=Gt(e);o.current=e;let t=Gt(null);t.current===null&&(t.current={fetch:(n,r)=>{let i=o.current;return i?i.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var mi={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],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 pt({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:n,apiConfig:r,additionalContext:i,language:p,productId:l,visitorId:v,columns:P=2,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showOptionIcons:D,showOptionImages:L,showOptionCounts:H,showSkipButton:O,showProducts:I,productImageFallback:F="image",onFocus:z,onBlur:k,value:M,completedParams:K,onChange:N,onParamsChange:te,products:le,mapProducts:W,onProductSelect:de,source:ke,setCursor:ce}){let u=B(null),[Ce,ae]=gi(null),pe=B(e);pe.current=e;let ie=B(o);ie.current=o;let he=B(t);he.current=t;let q=B(N);q.current=N;let V=B(te);V.current=te;let s=B(z);s.current=z;let m=B(k);m.current=k;let f=B(ce);f.current=ce;let w=B(de);w.current=de;let y=B(v);y.current=v;let E=B(()=>{let d=y.current;return typeof d=="function"?d():d}).current,c=Wt(le),G=B(W);G.current=W;let j=B((d,_)=>{let T=G.current;return T?T(d,_):d}).current,Q=W?j:void 0,ue=Kt(a);Le(()=>{if(typeof document>"u")return;let d=new pi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:p,productId:l,visitorId:E,optionOverrides:ue.overrides,maskCompletedText:n,columns:P,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I,source:ke,value:M,completedParams:K,onSubmit:(...T)=>pe.current?.(...T),onResult:(...T)=>ie.current?.(...T),onError:(...T)=>he.current?.(...T),onChange:(...T)=>q.current?.(...T),onParamsChange:(...T)=>V.current?.(...T),onFocus:()=>s.current?.(),onBlur:()=>m.current?.(),onProductSelect:T=>w.current?.(T),setCursor:T=>f.current?.(T),products:c.config,mapProducts:Q});u.current=d,ae(d.getState());let _=d.subscribe(T=>ae(T));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Le(()=>{M!==void 0&&u.current?.setValue(M)},[M]),Le(()=>{K!==void 0&&u.current?.setCompletedParams(K)},[K]);let ge=JSON.stringify(r??null),me;try{me=JSON.stringify(i??null)}catch{me="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:p,productId:l,optionOverrides:ue.overrides,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I})},[ge,me,p,l,ue.key,C,g,b,S,I]);let fe=B(!1);Le(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:c.config})},[c.enabled]),Le(()=>{u.current?.update({mapProducts:Q})},[Q]);let be=B(null);be.current===null&&(be.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=be.current,we=_t(d=>{let _=d.target.value,tt=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(tt)},[]),ve=_t(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),oe=u.current,h=Ce??mi,Te=M!==void 0?M:h.text,Ae=K!==void 0?K:h.completedParams,X=h.actionableSuggestions,Ne=X[0],Pe=oe?.listboxId??"",_e=h.activeDropdownIndex>=0&&oe?`${Pe}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Se=h.editingIdentified,Fe=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Se?{parameter:Se.parameter,text:ui(Se.parameter),required:!0,options:[]}:null,Ue=h.dropdownSuggestion??Fe??Ne,et=Fe?[Fe]:X,Be=hi(h),qe=!oe||h.dropdownLoading;return{completedParams:Ae,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:X,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:qe,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Pe,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Se,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Te,placeholder:h.placeholderText||void 0,onChange:we,onKeyDown:ve,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":_e,"aria-autocomplete":"list","aria-controls":Pe},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Ue?[{...Ue,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Pe,pills:et,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(O??!0)&&!xe&&!Se,showOptionIcons:D??!0,showOptionImages:L??!0,showOptionCounts:H??!0,skipDisabled:h.inSelectionAnimation,isLoading:qe,skeletonExiting:h.skeletonExiting,isInputEmpty:Te.trim().length===0,language:p,products:h.products,productImageFallback:F,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:g??"below"}}}import{chipIdFromTap as fi,extractPlainText as Ut,getCursorOffset as qt,keepCaretOnChip as bi,plainTextLength as wi,renderEditableContent as vi,setCursorOffset as jt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as $,useEffect as Xe,useLayoutEffect as ht,useRef as ze}from"react";var Je;function xi(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Qt(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:n,editingParam:r,editingIdentified:i,editingAnchor:p,caretOffset:l,placeholderText:v,isFocused:P,isDropdownOpen:C,listboxId:g,activeDescendantId:b,autoFocus:S,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:H,handleCaretMove:O,startEditingParam:I,replaceEditingRange:F,setFocused:z}=e,k=ze(null),M=ze(!1),K=ze(""),N=ze(""),te=ze(null),le=ze(0);te.current=l,Xe(()=>{if(!S)return;let s=k.current;if(!s)return;document.activeElement===s?z(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),w=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!w){let y=m.createRange();y.selectNodeContents(s),y.collapse(!0),f.removeAllRanges(),f.addRange(y)}},[S,z]),Xe(()=>{let s=k.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let w=m.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!s.contains(w.anchorNode))return;let y=w.anchorNode,E=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,G=(w.isCollapsed?E?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=r?.id??i?.id??null;if(G&&G!==j){I(G);return}performance.now()-le.current<50||O(qt(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[r,i,I,O]),Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=fi(s,f.target);w&&(I(w),bi(s,w))};return s.addEventListener("click",m),()=>s.removeEventListener("click",m)},[I]),ht(()=>{let s=k.current;s&&vi({input:s,segments:o,newParamId:n,editingParamId:r?.id??null,placeholderText:v??"",isFocused:P,showChipIcons:t,showChipImages:a})},[o,n,r,v,P,t,a]),ht(()=>{let s=K.current,m=n??"";if(K.current=m,!m||m===s)return;let f=k.current;if(!f)return;f.focus();let w=te.current??wi(f);jt(f,w)},[n]),ht(()=>{let s=N.current,m=r?.id??"";if(N.current=m,!m||m===s||p==null)return;let f=k.current;f&&jt(f,p)},[r,p]);let W=$(()=>{if(M.current)return;let s=k.current;if(!s)return;let m=Ut(s),w=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;D(w)},[D]),de=$(()=>{le.current=performance.now(),W();let s=k.current;s&&H(qt(s))},[W,H]);Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=f,y=w.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){f.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let E=y.startsWith("delete")?"":w.data??"";F(E)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[F]);let ke=$(()=>{M.current=!0},[]),ce=$(()=>{M.current=!1,W()},[W]),u=$(s=>{s.preventDefault();let m=k.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let w=m.ownerDocument??document,y=w.getSelection();if(!y||y.rangeCount===0)return;let E=y.getRangeAt(0);if(!m.contains(E.startContainer))return;E.deleteContents();let c=w.createTextNode(f);E.insertNode(c),E.setStartAfter(c),E.collapse(!0),y.removeAllRanges(),y.addRange(E),W()},[W]),Ce=$(s=>L(s),[L]),ae=$(()=>z(!0),[z]),pe=$(()=>z(!1),[z]),ie=$(()=>k.current?.focus(),[]),he=$(()=>k.current?.blur(),[]),q=$(()=>{let s=k.current;return s?Ut(s):""},[]),V=xi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:V,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":C,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:de,onKeyDown:Ce,onCompositionStart:ke,onCompositionEnd:ce,onPaste:u,onFocus:ae,onBlur:pe},getPlainText:q,focus:ie,blur:he}}import{jsx as Me,jsxs as gt}from"react/jsx-runtime";function Ti(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ai=yi(function({onSubmit:o,onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,className:i,apiConfig:p,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,pillPlacement:b="dropdown",mode:S="auto",optionsPosition:D="below",animations:L=!0,dropdownTrigger:H,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:F=!0,showChipIcons:z=!0,showChipImages:k=!0,showOptionImages:M=!0,showOptionCounts:K=!0,showSkipButton:N,showProducts:te,productsLayout:le,productImageFallback:W,autoFocus:de=!0,onFocus:ke,onBlur:ce,value:u,completedParams:Ce,onChange:ae,onParamsChange:pe,products:ie,mapProducts:he,onProductSelect:q,submitButton:V,resetOnSubmit:s=!0},m){let f=We(null),w=We(null),y=We(()=>{}),E=We(null),c=We(null);Yt(()=>{let A=f.current;if(A)return E.current?E.current.setMode(S):E.current=new Si(A,S),()=>{E.current?.destroy(),E.current=null}},[S]);let G=ut(A=>{let J=c.current?.current;J&&(J.focus(),Ii(J,A))},[]),{completedParams:j,skippedParams:Q,identifiedParams:ue,isReady:ge,customFields:me,suggestionPills:fe,setActivePill:be,skipActivePill:x,segments:we,newParamId:ve,clearNewParamId:oe,placeholderText:h,isFocused:Te,isDropdownOpen:Ae,isActivePillSelected:X,isLoading:Ne,activeIndex:Pe,listboxId:_e,handleTextChange:xe,handleKeyDown:Se,setFocused:Fe,editingParam:Ue,editingIdentified:et,editingAnchor:Be,caretOffset:qe,startEditingParam:d,handleCaretAfterInput:_,handleCaretMove:T,replaceEditingRange:tt,dropdownProps:Zt,reset:je,refreshProducts:mt,recordSubmit:ft}=pt({onSubmit:A=>y.current(A),onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:p,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,dropdownTrigger:H,optionsPosition:D,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:F,showOptionImages:M,showOptionCounts:K,showSkipButton:N,showProducts:te,onFocus:ke,onBlur:ce,value:u,completedParams:Ce,onChange:ae,onParamsChange:pe,products:ie,mapProducts:he,onProductSelect:q,source:"full-sdk",setCursor:G});Yt(()=>{if(!ve)return;let A=window.setTimeout(()=>oe(),650);return()=>window.clearTimeout(A)},[ve,oe]);let Vt=Pe>=0?`${_e}-option-${Pe}`:void 0,{inputRef:at,editorProps:$t,focus:Qe,blur:bt,getPlainText:wt}=Qt({segments:we,newParamId:ve,editingParam:Ue,editingIdentified:et,editingAnchor:Be,caretOffset:qe,placeholderText:h,isFocused:Te,showChipIcons:z,showChipImages:k,isDropdownOpen:Ae,listboxId:_e,activeDescendantId:Vt,autoFocus:de,handleTextChange:xe,handleKeyDown:Se,handleCaretAfterInput:_,handleCaretMove:T,startEditingParam:d,replaceEditingRange:tt,setFocused:Fe});c.current=at,Ci(()=>{let A=w.current,J=at.current;if(!A||!J)return;let He=()=>{let xt=A.firstElementChild;if(!xt)return;let ta=xt.getBoundingClientRect(),aa=J.getBoundingClientRect();ta.top>=aa.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};He();let vt=new ResizeObserver(He);return vt.observe(J),()=>vt.disconnect()},[we,fe.length,Ne,at]),ki(m,()=>({focus:Qe,blur:bt,reset:je,refreshProducts:mt,setMode:A=>E.current?.setMode(A),skipActivePill:x}),[Qe,bt,je,mt,x]);let Ye=!!we.length||j.length>0,it=ut(A=>{if(!Ye)return;let J=wt(),He=Pi(J,j,Q,{identifiedParams:ue,isReady:ge,customFields:me});A&&ft(He),o(He),s&&je()},[ft,s,Ye,j,Q,ue,ge,me,o,je,wt]);y.current=()=>it(!1);let Xt=ut(A=>{A.target?.closest("[data-aia-pill]")||Qe()},[Qe]),Jt=b==="inline",ea=b==="dropdown";return gt("div",{ref:f,className:`magicx-aia ${Ie.container} ${i??""}`,"data-pill-placement":b,"data-options-position":D,"data-animations":L?"on":"off","data-mode":Ti(S),children:[Me(dt,{...Zt,showPills:ea,productsLayout:le,productImageFallback:W}),gt("div",{className:Ie.inputWrapper,"data-aia-input-wrapper":"",onClick:Xt,children:[gt("div",{className:Ie.editorArea,"data-aia-editor":"",children:[Me("div",{...$t,className:Ie.input,"data-aia-input":""}),Jt&&(Ne||fe.length>0)&&Me("span",{ref:w,className:Ie.pillListContainer,"data-aia-pill-list-container":"",children:Me(Ve,{pills:fe,activePillIndex:0,activeSelected:X,onSelectPill:be,loading:Ne})})]}),V===null?null:V===void 0?Me(Bt,{disabled:!Ye,onClick:()=>it(!0),label:Ei(v).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ie.submitSlot,onClick:A=>{Ye&&(A.stopPropagation(),it(!0))},children:V})]})]})});export{Ai as AIAutocomplete,dt as AIAutocompleteDropdown,Sn as DATE_RANGE_META_END,In as DATE_RANGE_META_START,En as DEFAULT_OPTION_COUNT_UNIT,Hn as PRODUCT_PATH_PREFIX,Zn as WEEKDAY_LABELS,kn as buildSubmitResult,Cn as cellDay,Pn as cellIso,Tn as dateCellMarks,An as formatDate,Rn as formatDateRange,On as formatOptionCount,Dn as isoDate,Ln as monthLabel,zn as optionCountLabel,Mn as optionHasImage,Nn as optionImageSources,Fn as optionImageSrc,Bn as optionLabel,Kn as parseDate,Gn as parseLooseDate,Wn as parseLooseDateRange,_n as productFromMatchedItem,Un as productImageSources,qn as productsFromCustomFields,jn as sanitizeOptionIconSvg,Qn as selectedRangeFor,pt as useAIAutocomplete,Yn as visibleDateRange,Vn as withSkippedParams};
2270
2330
  //# sourceMappingURL=index.mjs.map