@magicx-eng/ai-autocomplete-react 0.26.2 → 0.28.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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END as tn,DATE_RANGE_META_START as an,DEFAULT_OPTION_COUNT_UNIT as on,dateCellMarks as nn,formatDate as rn,formatDateRange as sn,formatOptionCount as ln,isoDate as dn,monthLabel as cn,optionCountLabel as pn,optionHasImage as hn,optionImageSrc as un,optionLabel as mn,PRODUCT_PATH_PREFIX as fn,parseDate as gn,parseLooseDate as bn,parseLooseDateRange as vn,productFromMatchedItem as wn,productsFromCustomFields as xn,sanitizeOptionIconSvg as yn,selectedRangeFor as kn,visibleDateRange as Cn,WEEKDAY_LABELS as Pn,withSkippedParams as Sn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ei,useCallback as at,useEffect as Nt,useImperativeHandle as ti,useLayoutEffect as ai,useRef as De}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 on,cellDay as nn,cellIso as rn,DATE_RANGE_META_END as sn,DATE_RANGE_META_START as ln,DEFAULT_OPTION_COUNT_UNIT as dn,dateCellMarks as cn,formatDate as pn,formatDateRange as hn,formatOptionCount as un,isoDate as mn,monthLabel as gn,optionCountLabel as fn,optionHasImage as bn,optionImageSrc as vn,optionLabel as wn,PRODUCT_PATH_PREFIX as xn,parseDate as yn,parseLooseDate as kn,parseLooseDateRange as Cn,productFromMatchedItem as Pn,productsFromCustomFields as Sn,sanitizeOptionIconSvg as In,selectedRangeFor as En,visibleDateRange as Tn,WEEKDAY_LABELS as An,withSkippedParams as Rn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ni,useCallback as it,useEffect as Bt,useImperativeHandle as ri,useLayoutEffect as si,useRef as De}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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
262
262
  opacity: 0;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e)}var we={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 Ha,isCalendarFormat as Fa,SCROLL_ARROW_LABEL as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as He,useState as Ga}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 ye={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 _a,isCalendarFormat as qa,SCROLL_ARROW_LABEL as Ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as Ge,useState as Qa}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
  *
@@ -1041,7 +1041,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1041
1041
  opacity: 0.25;
1042
1042
  }
1043
1043
  }
1044
- `,document.head.appendChild(e)}var de={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 $t,cellIso as Ce,dateCellMarks as Vt,isoDate as Zt,monthLabel as Xt,visibleDateRange as Jt,WEEKDAY_LABELS as ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ta}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) ---
1044
+ `,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"};import{cellDay as Vt,cellIso as Pe,dateCellMarks as Xt,isoDate as Jt,monthLabel as ea,visibleDateRange as ta,WEEKDAY_LABELS as aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ia}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) ---
1045
1045
 
1046
1046
  One of three hand-maintained copies (vanilla styles.css, this file, Angular's
1047
1047
  date-grid.component.css). Only the class-naming layer differs \u2014 the
@@ -1204,7 +1204,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1204
1204
  opacity: 0.8;
1205
1205
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1206
1206
  }
1207
- `,document.head.appendChild(e)}var A={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 V,jsxs as dt}from"react/jsx-runtime";var aa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ct({options:e,activeIndex:n,listboxId:a,view:r,selection:s,onSelect:t,onHighlight:o,onPreviousMonth:u,onNextMonth:w}){let b=Zt(new Date),x=Jt({pendingStart:s.rangeStart,highlightedIso:Ce(e[n]),selected:s.selectedRange});return dt("div",{className:A.datepicker,"data-aia-datepicker":"",children:[dt("div",{className:A.header,children:[V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:p=>p.preventDefault(),onClick:u,children:"\u2039"}),V("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:Xt(r)}),V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:p=>p.preventDefault(),onClick:w,children:"\u203A"})]}),V("div",{className:A.weekdays,"aria-hidden":"true",children:ea.map((p,k)=>V("span",{className:A.weekday,children:p},aa[k]))}),V("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((p,k)=>V(ia,{option:p,id:`${a}-option-${k}`,index:k,isHighlighted:k===n&&p.is_tappable,isToday:Ce(p)===b,isPast:Ce(p)!=null&&Ce(p)<b,marks:Vt(Ce(p),{selectedIso:s.selectedIso,range:x}),onSelect:t,onHighlight:o},Ce(p)??`pad-${k}`))})]})}function ia({option:e,id:n,index:a,isHighlighted:r,isToday:s,isPast:t,marks:o,onSelect:u,onHighlight:w}){let[b,x]=ta(!1),p=$t(e);if(p==null)return V("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${A.cell} ${A.blank}`});let k=()=>{x(!0),u(e),setTimeout(()=>x(!1),170)},S=[A.cell,A.day,t?A.past:"",r?A.highlighted:"",s?A.today:"",o.inRange?A.inRange:"",o.selected?A.selected:"",b?A.pressed:""].filter(Boolean).join(" ");return V("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:S,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>w(a),children:V("span",{className:A.number,children:p})})}import{ATTRIBUTION_URL as oa,buildAttributionUrl as na,getFooterHint as ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as sa,useState as la}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 {
1207
+ `,document.head.appendChild(e)}var A={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 V,jsxs as ct}from"react/jsx-runtime";var oa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function pt({options:e,activeIndex:o,listboxId:a,view:n,selection:r,onSelect:t,onHighlight:s,onPreviousMonth:l,onNextMonth:v}){let w=Jt(new Date),b=ta({pendingStart:r.rangeStart,highlightedIso:Pe(e[o]),selected:r.selectedRange});return ct("div",{className:A.datepicker,"data-aia-datepicker":"",children:[ct("div",{className:A.header,children:[V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:l,children:"\u2039"}),V("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:ea(n)}),V("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u203A"})]}),V("div",{className:A.weekdays,"aria-hidden":"true",children:aa.map((u,y)=>V("span",{className:A.weekday,children:u},oa[y]))}),V("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((u,y)=>V(na,{option:u,id:`${a}-option-${y}`,index:y,isHighlighted:y===o&&u.is_tappable,isToday:Pe(u)===w,isPast:Pe(u)!=null&&Pe(u)<w,marks:Xt(Pe(u),{selectedIso:r.selectedIso,range:b}),onSelect:t,onHighlight:s},Pe(u)??`pad-${y}`))})]})}function na({option:e,id:o,index:a,isHighlighted:n,isToday:r,isPast:t,marks:s,onSelect:l,onHighlight:v}){let[w,b]=ia(!1),u=Vt(e);if(u==null)return V("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${A.cell} ${A.blank}`});let y=()=>{b(!0),l(e),setTimeout(()=>b(!1),170)},S=[A.cell,A.day,t?A.past:"",n?A.highlighted:"",r?A.today:"",s.inRange?A.inRange:"",s.selected?A.selected:"",w?A.pressed:""].filter(Boolean).join(" ");return V("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:S,onClick:y,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),y())},onMouseEnter:()=>v(a),children:V("span",{className:A.number,children:u})})}import{ATTRIBUTION_URL as ra,buildAttributionUrl as sa,getFooterHint as la}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as da,useState as ca}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 {
1208
1208
  display: flex;
1209
1209
  flex-wrap: wrap;
1210
1210
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1244,7 +1244,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1244
1244
  .aia-cluster[data-justify="around"] {
1245
1245
  justify-content: space-around;
1246
1246
  }
1247
- `,document.head.appendChild(e)}import{jsx as pt}from"react/jsx-runtime";function Te({gap:e,align:n="center",justify:a="start",noWrap:r=!1,inline:s=!1,className:t,children:o,...u}){let w=e?{"--aia-cluster-gap":e}:void 0,b={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":n,"data-justify":a,"data-nowrap":r||void 0,"data-inline":s||void 0,style:w,...u};return s?pt("span",{...b,children:o}):pt("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
1247
+ `,document.head.appendChild(e)}import{jsx as ht}from"react/jsx-runtime";function Ae({gap:e,align:o="center",justify:a="start",noWrap:n=!1,inline:r=!1,className:t,children:s,...l}){let v=e?{"--aia-cluster-gap":e}:void 0,w={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":o,"data-justify":a,"data-nowrap":n||void 0,"data-inline":r||void 0,style:v,...l};return r?ht("span",{...w,children:s}):ht("div",{...w,children:s})}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
1248
1248
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1249
1249
  room above the hint/branding row so the footer doesn't butt against the last
1250
1250
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1378,7 +1378,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1378
1378
  justify-content: flex-end;
1379
1379
  }
1380
1380
  }
1381
- `,document.head.appendChild(e)}var ce={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};import{jsx as Ae,jsxs as qe}from"react/jsx-runtime";function ht({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:a,hint:r}=ra(e,n),[s,t]=la(oa);return sa(()=>{t(na())},[]),Ae("footer",{className:ce.footer,"data-aia-footer":"",children:qe(Te,{justify:"between",noWrap:!0,className:ce.row,children:[qe(Te,{gap:"5px",className:ce.hintGroup,children:[Ae("kbd",{className:ce.key,children:a}),Ae("span",{className:ce.hint,children:r})]}),qe("a",{className:ce.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[Ae("span",{className:ce.brand,children:"AI"}),Ae("span",{className:ce.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,
1381
+ `,document.head.appendChild(e)}var le={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};import{jsx as Re,jsxs as Qe}from"react/jsx-runtime";function ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:a,hint:n}=la(e,o),[r,t]=ca(ra);return da(()=>{t(sa())},[]),Re("footer",{className:le.footer,"data-aia-footer":"",children:Qe(Ae,{justify:"between",noWrap:!0,className:le.row,children:[Qe(Ae,{gap:"5px",className:le.hintGroup,children:[Re("kbd",{className:le.key,children:a}),Re("span",{className:le.hint,children:n})]}),Qe("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Re("span",{className:le.brand,children:"AI"}),Re("span",{className:le.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,
1382
1382
  no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
1383
1383
  The border is kept as a 1px transparent line so the box stays the same size
1384
1384
  as it was when the outline was dashed. */
@@ -1454,7 +1454,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1454
1454
  opacity: 0;
1455
1455
  }
1456
1456
  }
1457
- `,document.head.appendChild(e)}var be={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 da}from"react/jsx-runtime";var Ue={selected:1,first:.7,next:.4,last:.2};function ut({label:e,state:n,rounded:a,loading:r,onClick:s}){let t=[be.pill,a?be.rounded:"",r?be.skeleton:""].filter(Boolean).join(" ");return da("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:Ue[n]},onMouseDown:o=>o.preventDefault(),onClick:r?void 0:s,disabled:r,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 {
1457
+ `,document.head.appendChild(e)}var be={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 pa}from"react/jsx-runtime";var Ye={selected:1,first:.7,next:.4,last:.2};function mt({label:e,state:o,rounded:a,loading:n,onClick:r}){let t=[be.pill,a?be.rounded:"",n?be.skeleton:""].filter(Boolean).join(" ");return pa("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:Ye[o]},onMouseDown:s=>s.preventDefault(),onClick:n?void 0:r,disabled:n,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 {
1458
1458
  position: relative;
1459
1459
  z-index: 1;
1460
1460
  pointer-events: auto;
@@ -1464,7 +1464,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1464
1464
  align-items: center;
1465
1465
  vertical-align: middle;
1466
1466
  }
1467
- `,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as Ne}from"react/jsx-runtime";var ca=[125,69];function mt(e){return e===0?"first":e===1?"next":"last"}function Be({pills:e,activePillIndex:n,onSelectPill:a,activeSelected:r,rounded:s,loading:t}){return t&&e.length===0?Ne("span",{className:je.list,"data-aia-pill-list-loading":"",children:ca.map((o,u)=>Ne("span",{"data-aia-pill-skeleton":"",className:`${be.pill} ${s?be.rounded:""} ${be.skeleton}`,style:{width:o,opacity:Ue[mt(u)]}},`skel-${o}`))}):Ne("span",{className:je.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((o,u)=>{let w=!!r&&u===n;return Ne(ut,{label:o.text,state:w?"selected":mt(u),selected:w,rounded:s,loading:t,onClick:()=>a(u)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ha,useRef as ua}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
1467
+ `,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as He}from"react/jsx-runtime";var ha=[125,69];function gt(e){return e===0?"first":e===1?"next":"last"}function Fe({pills:e,activePillIndex:o,onSelectPill:a,activeSelected:n,rounded:r,loading:t}){return t&&e.length===0?He("span",{className:je.list,"data-aia-pill-list-loading":"",children:ha.map((s,l)=>He("span",{"data-aia-pill-skeleton":"",className:`${be.pill} ${r?be.rounded:""} ${be.skeleton}`,style:{width:s,opacity:Ye[gt(l)]}},`skel-${s}`))}):He("span",{className:je.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((s,l)=>{let v=!!n&&l===o;return He(mt,{label:s.text,state:v?"selected":gt(l),selected:v,rounded:r,loading:t,onClick:()=>a(l)},`${s.type}-${s.text}`)})})}import{attachProductRowWheel as ua,productInitial as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ga,useRef as fa,useState as ba}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
1468
1468
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1469
1469
  theming one package sees the same result in the other.
1470
1470
 
@@ -1579,6 +1579,16 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1579
1579
  the same media fill, so a card without art reads as "no photo" instead of
1580
1580
  broken. The pictogram is inlined as a data URI so the placeholder needs no
1581
1581
  network and no asset pipeline; --aia-product-placeholder-image swaps it. */
1582
+ .aia-media-RrbGe:where([data-aia-product-initial]) {
1583
+ display: flex;
1584
+ align-items: center;
1585
+ justify-content: center;
1586
+ color: var(--aia-product-title-color, var(--aia-option-color-selected, currentColor));
1587
+ font-size: 24px;
1588
+ font-weight: 600;
1589
+ line-height: 1;
1590
+ }
1591
+
1582
1592
  .aia-media-RrbGe[data-aia-product-placeholder]::after {
1583
1593
  content: "";
1584
1594
  position: absolute;
@@ -1682,7 +1692,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1682
1692
  .aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
1683
1693
  flex: 1 1 auto;
1684
1694
  }
1685
- `,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"};import{jsx as ve,jsxs as Qe}from"react/jsx-runtime";function ft({products:e,listboxId:n,onSelect:a,onFocusChange:r,focusable:s=!0,layout:t="row"}){let o=e.length>0,u=ua(null);if(ha(()=>{let b=u.current;if(!(!o||!b))return pa(b)},[o]),!o)return null;let w=`${n}-products-label`;return Qe("section",{className:q.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":w,children:[ve("div",{className:q.label,id:w,"data-aia-products-label":"",children:"Products"}),ve("div",{ref:u,className:q.row,"data-aia-products-row":"",children:e.map((b,x)=>ve(ma,{product:b,id:`${n}-product-${x}`,onSelect:a,onFocusChange:r,focusable:s},b.id))})]})}function ma({product:e,id:n,onSelect:a,onFocusChange:r,focusable:s}){let t=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),a(e))};return Qe("a",{id:n,className:q.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:t,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[ve("span",{className:q.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?ve("img",{className:q.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Qe("span",{className:q.body,children:[e.vendor?ve("span",{className:q.vendor,children:e.vendor}):null,ve("span",{className:q.title,children:e.title}),e.price?ve("span",{className:q.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as Ta,measureOptionsGrid as Aa,needsOptionsGridMeasurement as Ra,OPTIONS_GRID_MOBILE_QUERY as Da,optionEnterDelayMs as Oa,planOptionsGrid as vt,sameOptionRows as La}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ma,useLayoutEffect as za,useRef as wt,useState as yt}from"react";import{optionsGridTemplateColumns as fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ga,useRef as ba}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 {
1695
+ `,document.head.appendChild(e)}var G={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"};import{jsx as ve,jsxs as Ke}from"react/jsx-runtime";function ft({products:e,listboxId:o,onSelect:a,onFocusChange:n,focusable:r=!0,layout:t="row",imageFallback:s="image"}){let l=e.length>0,v=fa(null);if(ga(()=>{let b=v.current;if(!(!l||!b))return ua(b)},[l]),!l)return null;let w=`${o}-products-label`;return Ke("section",{className:G.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":w,children:[ve("div",{className:G.label,id:w,"data-aia-products-label":"",children:"Products"}),ve("div",{ref:v,className:G.row,"data-aia-products-row":"",children:e.map((b,u)=>ve(va,{product:b,id:`${o}-product-${u}`,onSelect:a,onFocusChange:n,focusable:r,imageFallback:s},b.id))})]})}function va({product:e,id:o,onSelect:a,onFocusChange:n,focusable:r,imageFallback:t}){let s=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),a(e))};return Ke("a",{id:o,className:G.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:s,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),a(e))},onFocus:()=>n?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[ve(wa,{src:e.imageUrl?.trim(),title:e.title,fallback:t},e.imageUrl?.trim()??""),Ke("span",{className:G.body,children:[e.vendor?ve("span",{className:G.vendor,children:e.vendor}):null,ve("span",{className:G.title,children:e.title}),e.price?ve("span",{className:G.price,children:e.price}):null]})]})}function wa({src:e,title:o,fallback:a}){let[n,r]=ba(!1),t=!!e&&!n,s=!t&&a==="initial";return Ke("span",{className:G.media,"aria-hidden":"true","data-aia-product-placeholder":!t&&!s?"":void 0,"data-aia-product-initial":s?"":void 0,children:[t?ve("img",{className:G.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,s?ma(o):null]})}import{isOptionsGridMobileViewport as La,measureOptionsGrid as Ma,needsOptionsGridMeasurement as za,OPTIONS_GRID_MOBILE_QUERY as Na,optionEnterDelayMs as Ba,planOptionsGrid as wt,sameOptionRows as Ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Fa,useLayoutEffect as Ka,useRef as xt,useState as kt}from"react";import{optionsGridTemplateColumns as xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ya,useRef as ka}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 {
1686
1696
  display: grid;
1687
1697
  grid-template-columns: repeat(
1688
1698
  auto-fit,
@@ -1715,7 +1725,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
1715
1725
  background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
1716
1726
  border-radius: 3px;
1717
1727
  }
1718
- `,document.head.appendChild(e)}import{jsx as va}from"react/jsx-runtime";function gt({min:e="16rem",max:n,gap:a,scroll:r=!1,maxHeight:s,scrollResetKey:t,cols:o,template:u,innerRef:w,className:b,children:x,...p}){let k=ba(null);ga(()=>{if(t===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[t]);let S={"--aia-grid-min":e};return n&&(S["--aia-grid-max"]=n),a&&(S["--aia-grid-gap"]=a),s&&(S["--aia-grid-max-height"]=s),o&&(S.gridTemplateColumns=fa(o)),u&&(S.gridTemplateColumns=u),va("div",{ref:y=>{k.current=y,w?.(y)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":r||void 0,style:S,...p,children:x})}import{formatOptionCount as wa,OPTION_ENTER_DELAY_VAR as xa,optionImageSrc as ya,optionLabel as ka,sanitizeOptionIconSvg as Ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pa,useMemo as Sa,useRef as Ia,useState as Ye}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 {
1728
+ `,document.head.appendChild(e)}import{jsx as Ca}from"react/jsx-runtime";function bt({min:e="16rem",max:o,gap:a,scroll:n=!1,maxHeight:r,scrollResetKey:t,cols:s,template:l,innerRef:v,className:w,children:b,...u}){let y=ka(null);ya(()=>{if(t===void 0)return;let x=y.current;x&&(x.scrollTop=0)},[t]);let S={"--aia-grid-min":e};return o&&(S["--aia-grid-max"]=o),a&&(S["--aia-grid-gap"]=a),r&&(S["--aia-grid-max-height"]=r),s&&(S.gridTemplateColumns=xa(s)),l&&(S.gridTemplateColumns=l),Ca("div",{ref:x=>{y.current=x,v?.(x)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":n||void 0,style:S,...u,children:b})}import{formatOptionCount as Pa,OPTION_ENTER_DELAY_VAR as Sa,optionImageSrc as Ia,optionLabel as Ea,sanitizeOptionIconSvg as Ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Aa,useMemo as Ra,useRef as Oa,useState as Ze}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 {
1719
1729
  position: relative;
1720
1730
  /* Clip, not visible: the entrance rise below runs on the inner content,
1721
1731
  and a transformed box extends its scroll container's scrollable area.
@@ -2033,6 +2043,36 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
2033
2043
  --aia-option-row-height: calc(var(--aia-option-image-size, 40px) + 16px);
2034
2044
  }
2035
2045
 
2046
+ /* A row without a picture, in a grid where other rows have one, lines up
2047
+ with them: it becomes the same centred flex row, its icon sits centred in a
2048
+ tile-sized box, and a row with no icon either is indented by the tile and
2049
+ its gap, so every option's text starts at the same x. Grids with no
2050
+ pictures keep the inline icon and hanging indent above. The text is left
2051
+ to size itself: letting it grow here would out-rank the loading-bar rule
2052
+ that makes a skeleton bar hug its text. */
2053
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) {
2054
+ display: flex;
2055
+ flex: 1 1 auto;
2056
+ align-items: center;
2057
+ gap: var(--aia-option-image-gap, 12px);
2058
+ min-width: 0;
2059
+ min-height: var(--aia-option-image-size, 40px);
2060
+ padding-left: 0;
2061
+ text-indent: 0;
2062
+ }
2063
+
2064
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) .aia-icon-Qw938 {
2065
+ flex: 0 0 auto;
2066
+ justify-content: center;
2067
+ width: var(--aia-option-image-size, 40px);
2068
+ height: var(--aia-option-image-size, 40px);
2069
+ margin-right: 0;
2070
+ }
2071
+
2072
+ [data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)):not(:has(.aia-icon-Qw938)) {
2073
+ padding-left: calc(var(--aia-option-image-size, 40px) + var(--aia-option-image-gap, 12px));
2074
+ }
2075
+
2036
2076
  @keyframes aia-skeletonPulse-plvdD {
2037
2077
  0%,
2038
2078
  100% {
@@ -2075,7 +2115,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
2075
2115
  opacity: 0;
2076
2116
  }
2077
2117
  }
2078
- `,document.head.appendChild(e)}var B={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 xe,jsxs as Ea}from"react/jsx-runtime";function bt({option:e,isHighlighted:n,onSelect:a,onHighlight:r,id:s,loading:t,showIcon:o=!0,showImage:u=!0,showCount:w=!0,scrollHint:b,enterDelayMs:x=0}){let[p]=Ye(x),[k,S]=Ye(!1),y=u?ya(e.image_url):null,[z,O]=Ye(null),P=Sa(()=>!y&&o&&e.icon_svg?Ca(e.icon_svg):null,[y,o,e.icon_svg]),T=w?wa(e.item_count):null,I=Ia(void 0);Pa(()=>()=>clearTimeout(I.current),[]);let R=()=>{t||!e.is_tappable||k||(S(!0),a(e),clearTimeout(I.current),I.current=setTimeout(()=>S(!1),170))},L=[B.item,n&&!t?B.highlighted:"",e.is_tappable?B.tappable:B.nonTappable,k?B.pressed:"",b?B.scrollHint:""].filter(Boolean).join(" ");return xe("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":P&&e.icon?e.icon:void 0,"data-aia-image":y?"":void 0,"data-aia-item-count":T!==null?e.item_count:void 0,"aria-selected":n,className:L,style:{[xa]:`${p}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:R,onKeyDown:C=>{!t&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),R())},onMouseEnter:!t&&e.is_tappable?r:void 0,children:Ea("span",{className:B.content,children:[y&&xe("span",{className:`${B.image} magicx-aia-option-image`,"aria-hidden":"true",children:xe("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===y,onError:()=>O(y)})}),P&&xe("span",{className:`${B.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:P}}),xe("span",{className:B.text,children:ka(e)}),e.tag&&xe("span",{className:B.tag,children:e.tag}),T!==null&&xe("span",{className:`${B.count} magicx-aia-option-count`,children:T})]})})}import{jsx as xt}from"react/jsx-runtime";function Na(){let[e,n]=yt(Ta);return Ma(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(Da),r=()=>n(a.matches);return r(),a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),e}function kt({options:e,activeIndex:n,onSelect:a,onHighlight:r,listboxId:s,loading:t,groupKey:o="",optionsPosition:u="below",showIcons:w=!0,showImages:b=!0,showCounts:x=!0}){let p=Na(),k=wt(null),[S,y]=yt(null),z=wt(null);za(()=>{if(t&&La(z.current,e))return;z.current=t?null:e;let P=k.current,I=P&&!t&&Ra(e.length,p)?Aa(P):null;y(I?vt(e.length,p,I.rowWidths,I.gridWidth):null)},[e,p,t]);let O=S??vt(e.length,p,null,null);return xt(gt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:O.template,maxHeight:O.maxHeight,innerRef:P=>{k.current=P},"data-aia-group":o,children:e.map((P,T)=>xt(bt,{option:P,isHighlighted:T===n,onSelect:a,onHighlight:()=>r(T),id:`${s}-option-${T}`,loading:t,showIcon:w,showImage:b,showCount:x,scrollHint:!t&&O.scrollHintIndices.includes(T),enterDelayMs:t?0:Oa(T,O.cols,e.length,u)},`${o}\0${P.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2118
+ `,document.head.appendChild(e)}var N={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 ke,jsxs as Da}from"react/jsx-runtime";function vt({option:e,isHighlighted:o,onSelect:a,onHighlight:n,id:r,loading:t,showIcon:s=!0,showImage:l=!0,showCount:v=!0,scrollHint:w,enterDelayMs:b=0}){let[u]=Ze(b),[y,S]=Ze(!1),x=l?Ia(e.image_url):null,[z,L]=Ze(null),I=Ra(()=>!x&&s&&e.icon_svg?Ta(e.icon_svg):null,[x,s,e.icon_svg]),T=v?Pa(e.item_count):null,M=Oa(void 0);Aa(()=>()=>clearTimeout(M.current),[]);let O=()=>{t||!e.is_tappable||y||(S(!0),a(e),clearTimeout(M.current),M.current=setTimeout(()=>S(!1),170))},R=[N.item,o&&!t?N.highlighted:"",e.is_tappable?N.tappable:N.nonTappable,y?N.pressed:"",w?N.scrollHint:""].filter(Boolean).join(" ");return ke("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":I&&e.icon?e.icon:void 0,"data-aia-image":x?"":void 0,"data-aia-item-count":T!==null?e.item_count:void 0,"aria-selected":o,className:R,style:{[Sa]:`${u}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:O,onKeyDown:C=>{!t&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),O())},onMouseEnter:!t&&e.is_tappable?n:void 0,children:Da("span",{className:N.content,children:[x&&ke("span",{className:`${N.image} magicx-aia-option-image`,"aria-hidden":"true",children:ke("img",{src:x,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===x,onError:()=>L(x)})}),I&&ke("span",{className:`${N.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:I}}),ke("span",{className:N.text,children:Ea(e)}),e.tag&&ke("span",{className:N.tag,children:e.tag}),T!==null&&ke("span",{className:`${N.count} magicx-aia-option-count`,children:T})]})})}import{jsx as yt}from"react/jsx-runtime";function Ga(){let[e,o]=kt(La);return Fa(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(Na),n=()=>o(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}function Ct({options:e,activeIndex:o,onSelect:a,onHighlight:n,listboxId:r,loading:t,groupKey:s="",optionsPosition:l="below",showIcons:v=!0,showImages:w=!0,showCounts:b=!0}){let u=Ga(),y=xt(null),[S,x]=kt(null),z=xt(null);Ka(()=>{if(t&&Ha(z.current,e))return;z.current=t?null:e;let I=y.current,M=I&&!t&&za(e.length,u)?Ma(I):null;x(M?wt(e.length,u,M.rowWidths,M.gridWidth):null)},[e,u,t]);let L=S??wt(e.length,u,null,null);return yt(bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:L.template,maxHeight:L.maxHeight,innerRef:I=>{y.current=I},"data-aia-group":s,children:e.map((I,T)=>yt(vt,{option:I,isHighlighted:T===o,onSelect:a,onHighlight:()=>n(T),id:`${r}-option-${T}`,loading:t,showIcon:v,showImage:w,showCount:b,scrollHint:!t&&L.scrollHintIndices.includes(T),enterDelayMs:t?0:Ba(T,L.cols,e.length,l)},`${s}\0${I.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
2079
2119
  display: flex;
2080
2120
  flex-direction: column;
2081
2121
  gap: var(--aia-stack-space, 0.5rem);
@@ -2090,7 +2130,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
2090
2130
  align-items: end;
2091
2131
  }
2092
2132
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
2093
- `,document.head.appendChild(e)}import{jsx as Ba}from"react/jsx-runtime";function Ct({space:e,align:n="stretch",className:a,children:r,...s}){let t=e?{"--aia-stack-space":e}:void 0;return Ba("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":n,style:t,...s,children:r})}import{jsx as G,jsxs as $e}from"react/jsx-runtime";var Wa=[159,119,164],_a=()=>{},Pt=()=>{};function qa(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=Ga(n);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>r(s.matches);return s.addEventListener("change",t),()=>s.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Ua(e,n){let a=He(null);Ve(()=>{let r=e.current,s=n.current;if(!r||!s)return;let t=r.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:Ha({dropdown:r,grid:t,button:s})};return}a.current?.controller.update()}),Ve(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Ze({suggestions:e,activeIndex:n,onSelect:a,onHighlight:r,isOpen:s,id:t,className:o,pills:u,onPillClick:w,showPills:b=!0,onSkip:x,showSkipButton:p=!0,showOptionIcons:k=!0,showOptionImages:S=!0,showOptionCounts:y=!0,skipDisabled:z=!1,activeSelected:O=!1,isLoading:P=!1,skeletonExiting:T=!1,isInputEmpty:I=!1,products:R,onProductSelect:L,onProductFocusChange:C,productsLayout:Z="row",formatType:X="options",dateView:pe=null,selectedDateIso:J=null,selectedDateRange:h=null,dateRangeStart:H=null,onPreviousMonth:he,onNextMonth:ue,optionsPosition:ee="below",mode:me}){let te=qa(me),j=te!==void 0,ae=He(null),Q=He(null);Ua(ae,Q);let ie=e[0]?.options??[],oe=!!(u&&u.length>0&&w),M=!!(R&&R.length>0),l=s&&(ie.length>0||b&&oe||P||M),m={suggestions:e,activeIndex:n,pills:u,showPills:b,showSkipButton:p,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,skipDisabled:z,activeSelected:O,isLoading:P,skeletonExiting:T,isInputEmpty:I,products:R,formatType:X,dateView:pe,selectedDateIso:J,selectedDateRange:h,dateRangeStart:H},f=He(m);l&&(f.current=m);let i=l?m:f.current,v=i.suggestions[0],d=v?.options??[],Y=i.activeIndex>=0&&!!d[i.activeIndex]?.is_tappable,N=!!(i.pills&&i.pills.length>0&&w),ne=i.showPills&&N,c=i.showPills&&!N&&i.isLoading,re=ne||c,fe=N&&i.showSkipButton&&!i.isInputEmpty&&!!x,se=i.pills?.[0]?.text,ye=Fa(i.formatType)&&i.dateView!=null,le=d.length>0&&!ye,ke=d.length>0&&ye&&!i.isLoading,$=i.isLoading&&!le&&!ke,F=i.products??[];return $e("div",{ref:ae,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ee,"data-mode":te,"data-aia-loading":i.isLoading?"":void 0,"data-aia-skeleton-exiting":i.skeletonExiting?"":void 0,"data-aia-has-products":F.length>0?"":void 0,className:`${j?"magicx-aia ":""}${de.dropdown} ${l?de.visible:""} ${o??""}`,onMouseDown:_=>_.preventDefault(),children:[$e(Ct,{space:"8px",children:[(re||fe)&&$e(Te,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:[re&&G("span",{className:de.pillScroll,"data-aia-pill-scroll":"",children:G(Be,{pills:i.pills??[],activePillIndex:0,activeSelected:i.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:i.isLoading})}),fe&&G("button",{type:"button",tabIndex:-1,className:de.skip,"data-aia-skip":"",disabled:i.isLoading||i.skipDisabled,"aria-label":se?`Skip ${se}`:"Skip",onClick:x,children:"skip"})]}),le&&G(kt,{options:d,activeIndex:i.activeIndex,onSelect:a,onHighlight:r,listboxId:t,loading:i.isLoading,groupKey:v?`${v.type} ${v.text}`:"",optionsPosition:ee,showIcons:i.showOptionIcons,showImages:i.showOptionImages,showCounts:i.showOptionCounts}),ke&&i.dateView&&G(ct,{options:d,activeIndex:i.activeIndex,listboxId:t,view:i.dateView,selection:{selectedIso:i.selectedDateIso??null,selectedRange:i.selectedDateRange??null,rangeStart:i.dateRangeStart??null},onSelect:a,onHighlight:r,onPreviousMonth:he??Pt,onNextMonth:ue??Pt}),$&&G("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:Wa.map(_=>G("span",{className:de.skeletonBar,style:{width:_}},`bar-${_}`))}),G(ft,{products:F,listboxId:t,onSelect:L??_a,onFocusChange:C,focusable:l,layout:Z}),G(ht,{isOptionHighlighted:Y,isInputEmpty:i.isInputEmpty})]}),G("button",{ref:Q,type:"button",tabIndex:-1,className:de.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ka,"aria-hidden":"true",children:G("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:G("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as ii,ModeController as oi,setCursorOffset as ni}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 {
2133
+ `,document.head.appendChild(e)}import{jsx as Wa}from"react/jsx-runtime";function Pt({space:e,align:o="stretch",className:a,children:n,...r}){let t=e?{"--aia-stack-space":e}:void 0;return Wa("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":o,style:t,...r,children:n})}import{jsx as F,jsxs as $e}from"react/jsx-runtime";var Ya=[159,119,164],ja=()=>{},St=()=>{};function Za(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,n]=Qa(o);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>n(r.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function $a(e,o){let a=Ge(null);Ve(()=>{let n=e.current,r=o.current;if(!n||!r)return;let t=n.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:_a({dropdown:n,grid:t,button:r})};return}a.current?.controller.update()}),Ve(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Xe({suggestions:e,activeIndex:o,onSelect:a,onHighlight:n,isOpen:r,id:t,className:s,pills:l,onPillClick:v,showPills:w=!0,onSkip:b,showSkipButton:u=!0,showOptionIcons:y=!0,showOptionImages:S=!0,showOptionCounts:x=!0,skipDisabled:z=!1,activeSelected:L=!1,isLoading:I=!1,skeletonExiting:T=!1,isInputEmpty:M=!1,products:O,onProductSelect:R,onProductFocusChange:C,productsLayout:_="row",productImageFallback:de="image",formatType:X="options",dateView:ce=null,selectedDateIso:J=null,selectedDateRange:p=null,dateRangeStart:we=null,onPreviousMonth:pe,onNextMonth:he,optionsPosition:ee="below",mode:ue}){let te=Za(ue),q=te!==void 0,U=Ge(null),ae=Ge(null);$a(U,ae);let ie=e[0]?.options??[],oe=!!(l&&l.length>0&&v),d=!!(O&&O.length>0),c=r&&(ie.length>0||w&&oe||I||d),f={suggestions:e,activeIndex:o,pills:l,showPills:w,showSkipButton:u,showOptionIcons:y,showOptionImages:S,showOptionCounts:x,skipDisabled:z,activeSelected:L,isLoading:I,skeletonExiting:T,isInputEmpty:M,products:O,formatType:X,dateView:ce,selectedDateIso:J,selectedDateRange:p,dateRangeStart:we},k=Ge(f);c&&(k.current=f);let i=c?f:k.current,P=i.suggestions[0],m=P?.options??[],Q=i.activeIndex>=0&&!!m[i.activeIndex]?.is_tappable,Y=!!(i.pills&&i.pills.length>0&&v),ne=i.showPills&&Y,h=i.showPills&&!Y&&i.isLoading,me=ne||h,ge=Y&&i.showSkipButton&&!i.isInputEmpty&&!!b,j=i.pills?.[0]?.text,xe=qa(i.formatType)&&i.dateView!=null,re=m.length>0&&!xe,Ce=m.length>0&&xe&&!i.isLoading,Z=i.isLoading&&!re&&!Ce,$=i.products??[];return $e("div",{ref:U,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":ee,"data-mode":te,"data-aia-loading":i.isLoading?"":void 0,"data-aia-skeleton-exiting":i.skeletonExiting?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${q?"magicx-aia ":""}${se.dropdown} ${c?se.visible:""} ${s??""}`,onMouseDown:B=>B.preventDefault(),children:[$e(Pt,{space:"8px",children:[(me||ge)&&$e(Ae,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[me&&F("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:F(Fe,{pills:i.pills??[],activePillIndex:0,activeSelected:i.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:i.isLoading})}),ge&&F("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:i.isLoading||i.skipDisabled,"aria-label":j?`Skip ${j}`:"Skip",onClick:b,children:"skip"})]}),re&&F(Ct,{options:m,activeIndex:i.activeIndex,onSelect:a,onHighlight:n,listboxId:t,loading:i.isLoading,groupKey:P?`${P.type} ${P.text}`:"",optionsPosition:ee,showIcons:i.showOptionIcons,showImages:i.showOptionImages,showCounts:i.showOptionCounts}),Ce&&i.dateView&&F(pt,{options:m,activeIndex:i.activeIndex,listboxId:t,view:i.dateView,selection:{selectedIso:i.selectedDateIso??null,selectedRange:i.selectedDateRange??null,rangeStart:i.dateRangeStart??null},onSelect:a,onHighlight:n,onPreviousMonth:pe??St,onNextMonth:he??St}),Z&&F("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Ya.map(B=>F("span",{className:se.skeletonBar,style:{width:B}},`bar-${B}`))}),F(ft,{products:$,listboxId:t,onSelect:R??ja,onFocusChange:C,focusable:c,layout:_,imageFallback:de}),F(ut,{isOptionHighlighted:Q,isInputEmpty:i.isInputEmpty})]}),F("button",{ref:ae,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ua,"aria-hidden":"true",children:F("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:F("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as li,ModeController as di,setCursorOffset 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 {
2094
2134
  flex-shrink: 0;
2095
2135
  width: 32px;
2096
2136
  height: 32px;
@@ -2143,5 +2183,5 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
2143
2183
  );
2144
2184
  cursor: default;
2145
2185
  }
2146
- `,document.head.appendChild(e)}var St={submitButton:"aia-submitButton-otz7H"};import{jsx as Xe}from"react/jsx-runtime";function It({disabled:e,onClick:n}){return Xe("button",{type:"button","data-aia-submit":"",className:St.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Xe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Xe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ja,dateSelectionFor as Qa,identifiedParamLabel as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Re,useRef as W,useState as $a}from"react";import{useRef as Et}from"react";function Tt(e){let n=Et(e);n.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=Et({key:"",overrides:void 0});if(r.current.key!==a){let s={};for(let t of Object.keys(e??{})){let o=(u,w,b)=>{let x=n.current?.[t];return x?x(u,w,b):[]};s[t]=o}r.current={key:a,overrides:e?s:void 0}}return{overrides:r.current.overrides,key:a}}import{useRef as At}from"react";function Rt(e){let n=At(e);n.current=e;let a=At(null);a.current===null&&(a.current={fetch:(s,t)=>{let o=n.current;return o?o.fetch(s,t):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var Va={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 Je({onSubmit:e,onResult:n,onError:a,optionOverrides:r,maskCompletedText:s,apiConfig:t,additionalContext:o,columns:u=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,showSkipButton:z,showProducts:O,onFocus:P,onBlur:T,value:I,completedParams:R,onChange:L,onParamsChange:C,products:Z,onProductSelect:X,source:pe,setCursor:J}){let h=W(null),[H,he]=$a(null),ue=W(e);ue.current=e;let ee=W(n);ee.current=n;let me=W(a);me.current=a;let te=W(L);te.current=L;let j=W(C);j.current=C;let ae=W(P);ae.current=P;let Q=W(T);Q.current=T;let ie=W(J);ie.current=J;let oe=W(X);oe.current=X;let M=Rt(Z),l=Tt(r);Re(()=>{if(typeof document>"u")return;let g=new ja(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:o,optionOverrides:l.overrides,maskCompletedText:s,columns:u,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O,source:pe,value:I,completedParams:R,onSubmit:(...D)=>ue.current?.(...D),onResult:(...D)=>ee.current?.(...D),onError:(...D)=>me.current?.(...D),onChange:(...D)=>te.current?.(...D),onParamsChange:(...D)=>j.current?.(...D),onFocus:()=>ae.current?.(),onBlur:()=>Q.current?.(),onProductSelect:D=>oe.current?.(D),setCursor:D=>ie.current?.(D),products:M.config});h.current=g,he(g.getState());let K=g.subscribe(D=>he(D));return()=>{K(),g.destroy(),h.current===g&&(h.current=null)}},[]),Re(()=>{I!==void 0&&h.current?.setValue(I)},[I]),Re(()=>{R!==void 0&&h.current?.setCompletedParams(R)},[R]);let m=JSON.stringify(t??null),f;try{f=JSON.stringify(o??null)}catch{f="[unstringifiable]"}Re(()=>{h.current?.update({apiConfig:t,additionalContext:o,optionOverrides:l.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O})},[m,f,l.key,w,b,x,p,O]);let i=W(!1);Re(()=>{if(!i.current){i.current=!0;return}h.current?.update({products:M.config})},[M.enabled]);let v=W(null);v.current===null&&(v.current={handleTextChange:g=>h.current?.handleTextChange(g),handleKeyDown:g=>{let K="nativeEvent"in g?g.nativeEvent:g;h.current?.handleKeyDown(K)},setFocused:g=>h.current?.setFocused(g),startEditingParam:g=>h.current?.startEditingParam(g),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:g=>h.current?.handleCaretAfterInput(g),handleCaretMove:g=>h.current?.handleCaretMove(g),replaceEditingRange:g=>h.current?.replaceEditingRange(g)??!1,setActivePill:g=>h.current?.setActivePill(g),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:g=>h.current?.selectOption(g),selectProduct:g=>h.current?.selectProduct(g),setActiveDropdownIndex:g=>h.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let d=v.current,Y=Dt(g=>{let K=g.target.value,Ge=K.length>0&&!g.nativeEvent?.isComposing&&K[0]!==K[0].toUpperCase()?K[0].toUpperCase()+K.slice(1):K;h.current?.handleTextChange(Ge)},[]),N=Dt(g=>{h.current?.handleKeyDown(g.nativeEvent)},[]),ne=h.current,c=H??Va,re=I!==void 0?I:c.text,fe=R!==void 0?R:c.completedParams,se=c.actionableSuggestions,ye=se[0],le=ne?.listboxId??"",ke=c.activeDropdownIndex>=0&&ne?`${le}-option-${c.activeDropdownIndex}`:void 0,$=c.editingParam,F=c.editingIdentified,_=$?{type:$.suggestionType,text:$.suggestionPlaceholder,required:!0,options:$.options}:F?{type:F.type,text:Ya(F.type),required:!0,options:[]}:null,Ie=c.dropdownSuggestion??_??ye,Ke=_?[_]:se,Ee=Qa(c),Oe=!ne||c.dropdownLoading;return{completedParams:fe,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:se,setActivePill:d.setActivePill,skipActivePill:d.skipActivePill,removeLastParam:d.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:d.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Oe,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:le,error:c.error,products:c.products,customFields:c.customFields,selectProduct:d.selectProduct,handleTextChange:d.handleTextChange,handleKeyDown:d.handleKeyDown,setFocused:d.setFocused,editingParam:$,editingIdentified:F,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:d.startEditingParam,exitEditMode:d.exitEditMode,handleCaretAfterInput:d.handleCaretAfterInput,handleCaretMove:d.handleCaretMove,replaceEditingRange:d.replaceEditingRange,inputProps:{value:re,placeholder:c.placeholderText||void 0,onChange:Y,onKeyDown:N,onFocus:d.handleFocus,onBlur:d.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":le},reset:d.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:d.selectOption,onHighlight:d.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:le,pills:Ke,activeSelected:c.isActivePillSelected,onPillClick:d.setActivePill,onSkip:d.skipActivePill,showSkipButton:(z??!0)&&!$&&!F,showOptionIcons:k??!0,showOptionImages:S??!0,showOptionCounts:y??!0,skipDisabled:c.inSelectionAnimation,isLoading:Oe,skeletonExiting:c.skeletonExiting,isInputEmpty:re.trim().length===0,products:c.products,onProductSelect:d.selectProduct,onProductFocusChange:d.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Ee.selectedIso,selectedDateRange:Ee.selectedRange,dateRangeStart:Ee.rangeStart,onPreviousMonth:d.showPreviousMonth,onNextMonth:d.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as Ot,getCursorOffset as Lt,plainTextLength as Za,renderEditableContent as Xa,setCursorOffset as Mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as et,useLayoutEffect as tt,useRef as Pe}from"react";var Fe;function Ja(){if(Fe!==void 0)return Fe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Fe=e.contentEditable==="plaintext-only",Fe}function zt(e){let{segments:n,showChipIcons:a=!0,showChipImages:r=!0,newParamId:s,editingParam:t,editingIdentified:o,editingAnchor:u,caretOffset:w,placeholderText:b,isFocused:x,isDropdownOpen:p,listboxId:k,activeDescendantId:S,autoFocus:y,handleTextChange:z,handleKeyDown:O,handleCaretAfterInput:P,handleCaretMove:T,startEditingParam:I,replaceEditingRange:R,setFocused:L}=e,C=Pe(null),Z=Pe(!1),X=Pe(""),pe=Pe(""),J=Pe(null),h=Pe(0);J.current=w,et(()=>{if(!y)return;let l=C.current;if(!l)return;document.activeElement===l?L(!0):l.focus();let m=l.ownerDocument??document,f=m.getSelection(),i=f&&f.rangeCount>0&&l.contains(f.anchorNode);if(f&&!i){let v=m.createRange();v.selectNodeContents(l),v.collapse(!0),f.removeAllRanges(),f.addRange(v)}},[y,L]),et(()=>{let l=C.current;if(!l)return;let m=l.ownerDocument??document,f=()=>{let i=m.getSelection();if(!i||i.rangeCount===0||!i.anchorNode||!l.contains(i.anchorNode))return;let v=i.anchorNode,d=v.nodeType===Node.ELEMENT_NODE?v:v.parentElement,N=(i.isCollapsed?d?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ne=t?.id??o?.id??null;if(N&&N!==ne){I(N);return}performance.now()-h.current<50||T(Lt(l))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[t,o,I,T]),tt(()=>{let l=C.current;l&&Xa({input:l,segments:n,newParamId:s,editingParamId:t?.id??null,placeholderText:b??"",isFocused:x,showChipIcons:a,showChipImages:r})},[n,s,t,b,x,a,r]),tt(()=>{let l=X.current,m=s??"";if(X.current=m,!m||m===l)return;let f=C.current;if(!f)return;f.focus();let i=J.current??Za(f);Mt(f,i)},[s]),tt(()=>{let l=pe.current,m=t?.id??"";if(pe.current=m,!m||m===l||u==null)return;let f=C.current;f&&Mt(f,u)},[t,u]);let H=U(()=>{if(Z.current)return;let l=C.current;if(!l)return;let m=Ot(l),i=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;z(i)},[z]),he=U(()=>{h.current=performance.now(),H();let l=C.current;l&&P(Lt(l))},[H,P]);et(()=>{let l=C.current;if(!l)return;let m=f=>{let i=f,v=i.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){f.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let d=v.startsWith("delete")?"":i.data??"";R(d)&&f.preventDefault()}};return l.addEventListener("beforeinput",m),()=>l.removeEventListener("beforeinput",m)},[R]);let ue=U(()=>{Z.current=!0},[]),ee=U(()=>{Z.current=!1,H()},[H]),me=U(l=>{l.preventDefault();let m=C.current;if(!m)return;let f=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let i=m.ownerDocument??document,v=i.getSelection();if(!v||v.rangeCount===0)return;let d=v.getRangeAt(0);if(!m.contains(d.startContainer))return;d.deleteContents();let Y=i.createTextNode(f);d.insertNode(Y),d.setStartAfter(Y),d.collapse(!0),v.removeAllRanges(),v.addRange(d),H()},[H]),te=U(l=>O(l),[O]),j=U(()=>L(!0),[L]),ae=U(()=>L(!1),[L]),Q=U(()=>C.current?.focus(),[]),ie=U(()=>C.current?.blur(),[]),oe=U(()=>{let l=C.current;return l?Ot(l):""},[]),M=Ja()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:M,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":p,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:he,onKeyDown:te,onCompositionStart:ue,onCompositionEnd:ee,onPaste:me,onFocus:j,onBlur:ae},getPlainText:oe,focus:Q,blur:ie}}import{jsx as Se,jsxs as it}from"react/jsx-runtime";function ri(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var si=ei(function({onSubmit:n,onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,className:o,apiConfig:u,additionalContext:w,columns:b,pillPlacement:x="dropdown",mode:p="auto",optionsPosition:k="below",animations:S=!0,dropdownTrigger:y,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P=!0,showChipIcons:T=!0,showChipImages:I=!0,showOptionImages:R=!0,showOptionCounts:L=!0,showSkipButton:C,showProducts:Z,productsLayout:X,autoFocus:pe=!0,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,submitButton:j},ae){let Q=De(null),ie=De(null),oe=De(()=>{}),M=De(null),l=De(null);Nt(()=>{let E=Q.current;if(E)return M.current?M.current.setMode(p):M.current=new oi(E,p),()=>{M.current?.destroy(),M.current=null}},[p]);let m=at(E=>{let ge=l.current?.current;ge&&(ge.focus(),ni(ge,E))},[]),{completedParams:f,skippedParams:i,identifiedParams:v,isReady:d,customFields:Y,suggestionPills:N,setActivePill:ne,skipActivePill:c,segments:re,newParamId:fe,clearNewParamId:se,placeholderText:ye,isFocused:le,isDropdownOpen:ke,isActivePillSelected:$,isLoading:F,activeIndex:_,listboxId:Ie,handleTextChange:Ke,handleKeyDown:Ee,setFocused:Oe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,startEditingParam:Bt,handleCaretAfterInput:Ht,handleCaretMove:Ft,replaceEditingRange:Kt,dropdownProps:Gt,reset:Le}=Je({onSubmit:E=>oe.current(E),onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,apiConfig:u,additionalContext:w,columns:b,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P,showOptionImages:R,showOptionCounts:L,showSkipButton:C,showProducts:Z,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,source:"full-sdk",setCursor:m});Nt(()=>{if(!fe)return;let E=window.setTimeout(()=>se(),650);return()=>window.clearTimeout(E)},[fe,se]);let Wt=_>=0?`${Ie}-option-${_}`:void 0,{inputRef:We,editorProps:_t,focus:Me,blur:ot,getPlainText:nt}=zt({segments:re,newParamId:fe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,placeholderText:ye,isFocused:le,showChipIcons:T,showChipImages:I,isDropdownOpen:ke,listboxId:Ie,activeDescendantId:Wt,autoFocus:pe,handleTextChange:Ke,handleKeyDown:Ee,handleCaretAfterInput:Ht,handleCaretMove:Ft,startEditingParam:Bt,replaceEditingRange:Kt,setFocused:Oe});l.current=We,ai(()=>{let E=ie.current,ge=We.current;if(!E||!ge)return;let rt=()=>{let lt=E.firstElementChild;if(!lt)return;let Qt=lt.getBoundingClientRect(),Yt=ge.getBoundingClientRect();Qt.top>=Yt.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};rt();let st=new ResizeObserver(rt);return st.observe(ge),()=>st.disconnect()},[re,N.length,F,We]),ti(ae,()=>({focus:Me,blur:ot,reset:Le,setMode:E=>M.current?.setMode(E),skipActivePill:c}),[Me,ot,Le,c]);let ze=!!re.length||f.length>0,_e=at(()=>{if(!ze)return;let E=nt();n(ii(E,f,i,{identifiedParams:v,isReady:d,customFields:Y})),Le()},[ze,f,i,v,d,Y,n,Le,nt]);oe.current=_e;let qt=at(E=>{E.target?.closest("[data-aia-pill]")||Me()},[Me]),Ut=x==="inline",jt=x==="dropdown";return it("div",{ref:Q,className:`magicx-aia ${we.container} ${o??""}`,"data-pill-placement":x,"data-options-position":k,"data-animations":S?"on":"off","data-mode":ri(p),children:[Se(Ze,{...Gt,showPills:jt,productsLayout:X}),it("div",{className:we.inputWrapper,"data-aia-input-wrapper":"",onClick:qt,children:[it("div",{className:we.editorArea,"data-aia-editor":"",children:[Se("div",{..._t,className:we.input,"data-aia-input":""}),Ut&&(F||N.length>0)&&Se("span",{ref:ie,className:we.pillListContainer,"data-aia-pill-list-container":"",children:Se(Be,{pills:N,activePillIndex:0,activeSelected:$,onSelectPill:ne,loading:F})})]}),j===null?null:j===void 0?Se(It,{disabled:!ze,onClick:_e}):Se("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:we.submitSlot,onClick:E=>{ze&&(E.stopPropagation(),_e())},children:j})]})]})});export{si as AIAutocomplete,Ze as AIAutocompleteDropdown,tn as DATE_RANGE_META_END,an as DATE_RANGE_META_START,on as DEFAULT_OPTION_COUNT_UNIT,fn as PRODUCT_PATH_PREFIX,Pn as WEEKDAY_LABELS,Xo as buildSubmitResult,Jo as cellDay,en as cellIso,nn as dateCellMarks,rn as formatDate,sn as formatDateRange,ln as formatOptionCount,dn as isoDate,cn as monthLabel,pn as optionCountLabel,hn as optionHasImage,un as optionImageSrc,mn as optionLabel,gn as parseDate,bn as parseLooseDate,vn as parseLooseDateRange,wn as productFromMatchedItem,xn as productsFromCustomFields,yn as sanitizeOptionIconSvg,kn as selectedRangeFor,Je as useAIAutocomplete,Cn as visibleDateRange,Sn as withSkippedParams};
2186
+ `,document.head.appendChild(e)}var It={submitButton:"aia-submitButton-otz7H"};import{jsx as Je}from"react/jsx-runtime";function Et({disabled:e,onClick:o}){return Je("button",{type:"button","data-aia-submit":"",className:It.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":"Submit",children:Je("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Je("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Va,dateSelectionFor as Xa,identifiedParamLabel as Ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Oe,useRef as K,useState as ei}from"react";import{useRef as Tt}from"react";function At(e){let o=Tt(e);o.current=e;let a=Object.keys(e??{}).sort().join("\0"),n=Tt({key:"",overrides:void 0});if(n.current.key!==a){let r={};for(let t of Object.keys(e??{})){let s=(l,v,w)=>{let b=o.current?.[t];return b?b(l,v,w):[]};r[t]=s}n.current={key:a,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:a}}import{useRef as Rt}from"react";function Ot(e){let o=Rt(e);o.current=e;let a=Rt(null);a.current===null&&(a.current={fetch:(r,t)=>{let s=o.current;return s?s.fetch(r,t):Promise.reject(new Error("products config removed"))},transform:r=>o.current?.transform(r)??[],get limit(){return o.current?.limit}});let n=e!==void 0;return{config:n?a.current:void 0,enabled:n}}var ti={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 et({onSubmit:e,onResult:o,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:t,additionalContext:s,columns:l=2,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:b,showNonTappableOptions:u,showOptionIcons:y,showOptionImages:S,showOptionCounts:x,showSkipButton:z,showProducts:L,productImageFallback:I="image",onFocus:T,onBlur:M,value:O,completedParams:R,onChange:C,onParamsChange:_,products:de,onProductSelect:X,source:ce,setCursor:J}){let p=K(null),[we,pe]=ei(null),he=K(e);he.current=e;let ee=K(o);ee.current=o;let ue=K(a);ue.current=a;let te=K(C);te.current=C;let q=K(_);q.current=_;let U=K(T);U.current=T;let ae=K(M);ae.current=M;let ie=K(J);ie.current=J;let oe=K(X);oe.current=X;let d=Ot(de),c=At(n);Oe(()=>{if(typeof document>"u")return;let g=new Va(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:s,optionOverrides:c.overrides,maskCompletedText:r,columns:l,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:b,showNonTappableOptions:u,showProducts:L,source:ce,value:O,completedParams:R,onSubmit:(...D)=>he.current?.(...D),onResult:(...D)=>ee.current?.(...D),onError:(...D)=>ue.current?.(...D),onChange:(...D)=>te.current?.(...D),onParamsChange:(...D)=>q.current?.(...D),onFocus:()=>U.current?.(),onBlur:()=>ae.current?.(),onProductSelect:D=>oe.current?.(D),setCursor:D=>ie.current?.(D),products:d.config});p.current=g,pe(g.getState());let H=g.subscribe(D=>pe(D));return()=>{H(),g.destroy(),p.current===g&&(p.current=null)}},[]),Oe(()=>{O!==void 0&&p.current?.setValue(O)},[O]),Oe(()=>{R!==void 0&&p.current?.setCompletedParams(R)},[R]);let f=JSON.stringify(t??null),k;try{k=JSON.stringify(s??null)}catch{k="[unstringifiable]"}Oe(()=>{p.current?.update({apiConfig:t,additionalContext:s,optionOverrides:c.overrides,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:b,showNonTappableOptions:u,showProducts:L})},[f,k,c.key,v,w,b,u,L]);let i=K(!1);Oe(()=>{if(!i.current){i.current=!0;return}p.current?.update({products:d.config})},[d.enabled]);let P=K(null);P.current===null&&(P.current={handleTextChange:g=>p.current?.handleTextChange(g),handleKeyDown:g=>{let H="nativeEvent"in g?g.nativeEvent:g;p.current?.handleKeyDown(H)},setFocused:g=>p.current?.setFocused(g),startEditingParam:g=>p.current?.startEditingParam(g),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:g=>p.current?.handleCaretAfterInput(g),handleCaretMove:g=>p.current?.handleCaretMove(g),replaceEditingRange:g=>p.current?.replaceEditingRange(g)??!1,setActivePill:g=>p.current?.setActivePill(g),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:g=>p.current?.selectOption(g),selectProduct:g=>p.current?.selectProduct(g),setActiveDropdownIndex:g=>p.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let m=P.current,Q=Dt(g=>{let H=g.target.value,_e=H.length>0&&!g.nativeEvent?.isComposing&&H[0]!==H[0].toUpperCase()?H[0].toUpperCase()+H.slice(1):H;p.current?.handleTextChange(_e)},[]),Y=Dt(g=>{p.current?.handleKeyDown(g.nativeEvent)},[]),ne=p.current,h=we??ti,me=O!==void 0?O:h.text,ge=R!==void 0?R:h.completedParams,j=h.actionableSuggestions,xe=j[0],re=ne?.listboxId??"",Ce=h.activeDropdownIndex>=0&&ne?`${re}-option-${h.activeDropdownIndex}`:void 0,Z=h.editingParam,$=h.editingIdentified,B=Z?{type:Z.suggestionType,text:Z.suggestionPlaceholder,required:!0,options:Z.options}:$?{type:$.type,text:Ja($.type),required:!0,options:[]}:null,Ee=h.dropdownSuggestion??B??xe,Le=B?[B]:j,Te=Xa(h),Me=!ne||h.dropdownLoading;return{completedParams:ge,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:j,setActivePill:m.setActivePill,skipActivePill:m.skipActivePill,removeLastParam:m.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:m.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:Me,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:re,error:h.error,products:h.products,customFields:h.customFields,selectProduct:m.selectProduct,handleTextChange:m.handleTextChange,handleKeyDown:m.handleKeyDown,setFocused:m.setFocused,editingParam:Z,editingIdentified:$,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:m.startEditingParam,exitEditMode:m.exitEditMode,handleCaretAfterInput:m.handleCaretAfterInput,handleCaretMove:m.handleCaretMove,replaceEditingRange:m.replaceEditingRange,inputProps:{value:me,placeholder:h.placeholderText||void 0,onChange:Q,onKeyDown:Y,onFocus:m.handleFocus,onBlur:m.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":Ce,"aria-autocomplete":"list","aria-controls":re},reset:m.reset,dropdownProps:{suggestions:Ee?[{...Ee,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:m.selectOption,onHighlight:m.setActiveDropdownIndex,isOpen:h.isDropdownOpen,id:re,pills:Le,activeSelected:h.isActivePillSelected,onPillClick:m.setActivePill,onSkip:m.skipActivePill,showSkipButton:(z??!0)&&!Z&&!$,showOptionIcons:y??!0,showOptionImages:S??!0,showOptionCounts:x??!0,skipDisabled:h.inSelectionAnimation,isLoading:Me,skeletonExiting:h.skeletonExiting,isInputEmpty:me.trim().length===0,products:h.products,productImageFallback:I,onProductSelect:m.selectProduct,onProductFocusChange:m.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Te.selectedIso,selectedDateRange:Te.selectedRange,dateRangeStart:Te.rangeStart,onPreviousMonth:m.showPreviousMonth,onNextMonth:m.showNextMonth,optionsPosition:w??"below"}}}import{extractPlainText as Lt,getCursorOffset as Mt,plainTextLength as ai,renderEditableContent as ii,setCursorOffset as zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as W,useEffect as tt,useLayoutEffect as at,useRef as Se}from"react";var We;function oi(){if(We!==void 0)return We;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),We=e.contentEditable==="plaintext-only",We}function Nt(e){let{segments:o,showChipIcons:a=!0,showChipImages:n=!0,newParamId:r,editingParam:t,editingIdentified:s,editingAnchor:l,caretOffset:v,placeholderText:w,isFocused:b,isDropdownOpen:u,listboxId:y,activeDescendantId:S,autoFocus:x,handleTextChange:z,handleKeyDown:L,handleCaretAfterInput:I,handleCaretMove:T,startEditingParam:M,replaceEditingRange:O,setFocused:R}=e,C=Se(null),_=Se(!1),de=Se(""),X=Se(""),ce=Se(null),J=Se(0);ce.current=v,tt(()=>{if(!x)return;let d=C.current;if(!d)return;document.activeElement===d?R(!0):d.focus();let c=d.ownerDocument??document,f=c.getSelection(),k=f&&f.rangeCount>0&&d.contains(f.anchorNode);if(f&&!k){let i=c.createRange();i.selectNodeContents(d),i.collapse(!0),f.removeAllRanges(),f.addRange(i)}},[x,R]),tt(()=>{let d=C.current;if(!d)return;let c=d.ownerDocument??document,f=()=>{let k=c.getSelection();if(!k||k.rangeCount===0||!k.anchorNode||!d.contains(k.anchorNode))return;let i=k.anchorNode,P=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,Q=(k.isCollapsed?P?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Y=t?.id??s?.id??null;if(Q&&Q!==Y){M(Q);return}performance.now()-J.current<50||T(Mt(d))};return c.addEventListener("selectionchange",f),()=>c.removeEventListener("selectionchange",f)},[t,s,M,T]),at(()=>{let d=C.current;d&&ii({input:d,segments:o,newParamId:r,editingParamId:t?.id??null,placeholderText:w??"",isFocused:b,showChipIcons:a,showChipImages:n})},[o,r,t,w,b,a,n]),at(()=>{let d=de.current,c=r??"";if(de.current=c,!c||c===d)return;let f=C.current;if(!f)return;f.focus();let k=ce.current??ai(f);zt(f,k)},[r]),at(()=>{let d=X.current,c=t?.id??"";if(X.current=c,!c||c===d||l==null)return;let f=C.current;f&&zt(f,l)},[t,l]);let p=W(()=>{if(_.current)return;let d=C.current;if(!d)return;let c=Lt(d),k=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;z(k)},[z]),we=W(()=>{J.current=performance.now(),p();let d=C.current;d&&I(Mt(d))},[p,I]);tt(()=>{let d=C.current;if(!d)return;let c=f=>{let k=f,i=k.inputType;if(i==="insertParagraph"||i==="insertLineBreak"||i==="insertFromDrop"){f.preventDefault();return}if(i.startsWith("insert")||i.startsWith("delete")){let P=i.startsWith("delete")?"":k.data??"";O(P)&&f.preventDefault()}};return d.addEventListener("beforeinput",c),()=>d.removeEventListener("beforeinput",c)},[O]);let pe=W(()=>{_.current=!0},[]),he=W(()=>{_.current=!1,p()},[p]),ee=W(d=>{d.preventDefault();let c=C.current;if(!c)return;let f=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let k=c.ownerDocument??document,i=k.getSelection();if(!i||i.rangeCount===0)return;let P=i.getRangeAt(0);if(!c.contains(P.startContainer))return;P.deleteContents();let m=k.createTextNode(f);P.insertNode(m),P.setStartAfter(m),P.collapse(!0),i.removeAllRanges(),i.addRange(P),p()},[p]),ue=W(d=>L(d),[L]),te=W(()=>R(!0),[R]),q=W(()=>R(!1),[R]),U=W(()=>C.current?.focus(),[]),ae=W(()=>C.current?.blur(),[]),ie=W(()=>{let d=C.current;return d?Lt(d):""},[]),oe=oi()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:oe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":y,"aria-expanded":u,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:we,onKeyDown:ue,onCompositionStart:pe,onCompositionEnd:he,onPaste:ee,onFocus:te,onBlur:q},getPlainText:ie,focus:U,blur:ae}}import{jsx as Ie,jsxs as ot}from"react/jsx-runtime";function pi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var hi=ni(function({onSubmit:o,onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,className:s,apiConfig:l,additionalContext:v,columns:w,pillPlacement:b="dropdown",mode:u="auto",optionsPosition:y="below",animations:S=!0,dropdownTrigger:x,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I=!0,showChipIcons:T=!0,showChipImages:M=!0,showOptionImages:O=!0,showOptionCounts:R=!0,showSkipButton:C,showProducts:_,productsLayout:de,productImageFallback:X,autoFocus:ce=!0,onFocus:J,onBlur:p,value:we,completedParams:pe,onChange:he,onParamsChange:ee,products:ue,onProductSelect:te,submitButton:q,resetOnSubmit:U=!0},ae){let ie=De(null),oe=De(null),d=De(()=>{}),c=De(null),f=De(null);Bt(()=>{let E=ie.current;if(E)return c.current?c.current.setMode(u):c.current=new di(E,u),()=>{c.current?.destroy(),c.current=null}},[u]);let k=it(E=>{let fe=f.current?.current;fe&&(fe.focus(),ci(fe,E))},[]),{completedParams:i,skippedParams:P,identifiedParams:m,isReady:Q,customFields:Y,suggestionPills:ne,setActivePill:h,skipActivePill:me,segments:ge,newParamId:j,clearNewParamId:xe,placeholderText:re,isFocused:Ce,isDropdownOpen:Z,isActivePillSelected:$,isLoading:B,activeIndex:Ee,listboxId:Le,handleTextChange:Te,handleKeyDown:Me,setFocused:g,editingParam:H,editingIdentified:D,editingAnchor:_e,caretOffset:Ht,startEditingParam:Ft,handleCaretAfterInput:Kt,handleCaretMove:Gt,replaceEditingRange:Wt,dropdownProps:_t,reset:ze}=et({onSubmit:E=>d.current(E),onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,apiConfig:l,additionalContext:v,columns:w,dropdownTrigger:x,optionsPosition:y,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I,showOptionImages:O,showOptionCounts:R,showSkipButton:C,showProducts:_,onFocus:J,onBlur:p,value:we,completedParams:pe,onChange:he,onParamsChange:ee,products:ue,onProductSelect:te,source:"full-sdk",setCursor:k});Bt(()=>{if(!j)return;let E=window.setTimeout(()=>xe(),650);return()=>window.clearTimeout(E)},[j,xe]);let qt=Ee>=0?`${Le}-option-${Ee}`:void 0,{inputRef:qe,editorProps:Ut,focus:Ne,blur:nt,getPlainText:rt}=Nt({segments:ge,newParamId:j,editingParam:H,editingIdentified:D,editingAnchor:_e,caretOffset:Ht,placeholderText:re,isFocused:Ce,showChipIcons:T,showChipImages:M,isDropdownOpen:Z,listboxId:Le,activeDescendantId:qt,autoFocus:ce,handleTextChange:Te,handleKeyDown:Me,handleCaretAfterInput:Kt,handleCaretMove:Gt,startEditingParam:Ft,replaceEditingRange:Wt,setFocused:g});f.current=qe,si(()=>{let E=oe.current,fe=qe.current;if(!E||!fe)return;let st=()=>{let dt=E.firstElementChild;if(!dt)return;let Zt=dt.getBoundingClientRect(),$t=fe.getBoundingClientRect();Zt.top>=$t.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};st();let lt=new ResizeObserver(st);return lt.observe(fe),()=>lt.disconnect()},[ge,ne.length,B,qe]),ri(ae,()=>({focus:Ne,blur:nt,reset:ze,setMode:E=>c.current?.setMode(E),skipActivePill:me}),[Ne,nt,ze,me]);let Be=!!ge.length||i.length>0,Ue=it(()=>{if(!Be)return;let E=rt();o(li(E,i,P,{identifiedParams:m,isReady:Q,customFields:Y})),U&&ze()},[U,Be,i,P,m,Q,Y,o,ze,rt]);d.current=Ue;let Qt=it(E=>{E.target?.closest("[data-aia-pill]")||Ne()},[Ne]),Yt=b==="inline",jt=b==="dropdown";return ot("div",{ref:ie,className:`magicx-aia ${ye.container} ${s??""}`,"data-pill-placement":b,"data-options-position":y,"data-animations":S?"on":"off","data-mode":pi(u),children:[Ie(Xe,{..._t,showPills:jt,productsLayout:de,productImageFallback:X}),ot("div",{className:ye.inputWrapper,"data-aia-input-wrapper":"",onClick:Qt,children:[ot("div",{className:ye.editorArea,"data-aia-editor":"",children:[Ie("div",{...Ut,className:ye.input,"data-aia-input":""}),Yt&&(B||ne.length>0)&&Ie("span",{ref:oe,className:ye.pillListContainer,"data-aia-pill-list-container":"",children:Ie(Fe,{pills:ne,activePillIndex:0,activeSelected:$,onSelectPill:h,loading:B})})]}),q===null?null:q===void 0?Ie(Et,{disabled:!Be,onClick:Ue}):Ie("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ye.submitSlot,onClick:E=>{Be&&(E.stopPropagation(),Ue())},children:q})]})]})});export{hi as AIAutocomplete,Xe as AIAutocompleteDropdown,sn as DATE_RANGE_META_END,ln as DATE_RANGE_META_START,dn as DEFAULT_OPTION_COUNT_UNIT,xn as PRODUCT_PATH_PREFIX,An as WEEKDAY_LABELS,on as buildSubmitResult,nn as cellDay,rn as cellIso,cn as dateCellMarks,pn as formatDate,hn as formatDateRange,un as formatOptionCount,mn as isoDate,gn as monthLabel,fn as optionCountLabel,bn as optionHasImage,vn as optionImageSrc,wn as optionLabel,yn as parseDate,kn as parseLooseDate,Cn as parseLooseDateRange,Pn as productFromMatchedItem,Sn as productsFromCustomFields,In as sanitizeOptionIconSvg,En as selectedRangeFor,et as useAIAutocomplete,Tn as visibleDateRange,Rn as withSkippedParams};
2147
2187
  //# sourceMappingURL=index.mjs.map