@magicx-eng/ai-autocomplete-react 0.22.0 → 0.23.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 Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END as _o,DATE_RANGE_META_START as qo,dateCellMarks as Uo,formatDate as jo,formatDateRange as $o,isoDate as Vo,monthLabel as Qo,optionLabel as Zo,PRODUCT_PATH_PREFIX as Yo,parseDate as Xo,parseLooseDate as Jo,parseLooseDateRange as en,productFromMatchedItem as tn,productsFromCustomFields as an,sanitizeOptionIconSvg as on,selectedRangeFor as nn,visibleDateRange as rn,WEEKDAY_LABELS as sn,withSkippedParams as ln}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as qa,useCallback as Je,useEffect as Mt,useImperativeHandle as Ua,useLayoutEffect as ja,useRef as Ie}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 Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END as Vo,DATE_RANGE_META_START as Qo,dateCellMarks as Zo,formatDate as Yo,formatDateRange as Xo,isoDate as Jo,monthLabel as en,optionLabel as tn,PRODUCT_PATH_PREFIX as an,parseDate as on,parseLooseDate as nn,parseLooseDateRange as rn,productFromMatchedItem as sn,productsFromCustomFields as ln,sanitizeOptionIconSvg as dn,selectedRangeFor as cn,visibleDateRange as pn,WEEKDAY_LABELS as hn,withSkippedParams as un}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as $a,useCallback as Je,useEffect as Mt,useImperativeHandle as Va,useLayoutEffect as Qa,useRef as Ie}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
@@ -227,7 +227,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
227
227
  opacity: 0;
228
228
  }
229
229
  }
230
- `,document.head.appendChild(e)}var ge={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as Ta,isCalendarFormat as Aa,SCROLL_ARROW_LABEL as Ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Ne,useState as Da}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
230
+ `,document.head.appendChild(e)}var ge={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as Da,isCalendarFormat as La,SCROLL_ARROW_LABEL as Ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Ne,useState as Oa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
231
231
  * Built-in appearance defaults \u2014 zero specificity via :where().
232
232
  * Consumer CSS always wins without !important.
233
233
  *
@@ -1145,7 +1145,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1145
1145
  opacity: 0.8;
1146
1146
  background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
1147
1147
  }
1148
- `,document.head.appendChild(e)}var S={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 Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:f,onNextMonth:v}){let g=jt(new Date),w=Vt({pendingStart:s.rangeStart,highlightedIso:we(e[r]),selected:s.selectedRange});return rt("div",{className:S.datepicker,"data-aia-datepicker":"",children:[rt("div",{className:S.header,children:[Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:f,children:"\u2039"}),Z("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:$t(n)}),Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u203A"})]}),Z("div",{className:S.weekdays,"aria-hidden":"true",children:Qt.map((u,x)=>Z("span",{className:S.weekday,children:u},Yt[x]))}),Z("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((u,x)=>Z(Xt,{option:u,id:`${i}-option-${x}`,index:x,isHighlighted:x===r&&u.is_tappable,isToday:we(u)===g,isPast:we(u)!=null&&we(u)<g,marks:Ut(we(u),{selectedIso:s.selectedIso,range:w}),onSelect:a,onHighlight:o},we(u)??`pad-${x}`))})]})}function Xt({option:e,id:r,index:i,isHighlighted:n,isToday:s,isPast:a,marks:o,onSelect:f,onHighlight:v}){let[g,w]=Zt(!1),u=qt(e);if(u==null)return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let x=()=>{w(!0),f(e),setTimeout(()=>w(!1),170)},k=[S.cell,S.day,a?S.past:"",n?S.highlighted:"",s?S.today:"",o.inRange?S.inRange:"",o.selected?S.selected:"",g?S.pressed:""].filter(Boolean).join(" ");return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:k,onClick:x,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x())},onMouseEnter:()=>v(i),children:Z("span",{className:S.number,children:u})})}import{ATTRIBUTION_URL as Jt,buildAttributionUrl as ea,getFooterHint as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as aa,useState as ia}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 {
1148
+ `,document.head.appendChild(e)}var S={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 Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:g,onNextMonth:f}){let b=jt(new Date),w=Vt({pendingStart:s.rangeStart,highlightedIso:we(e[r]),selected:s.selectedRange});return rt("div",{className:S.datepicker,"data-aia-datepicker":"",children:[rt("div",{className:S.header,children:[Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:g,children:"\u2039"}),Z("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:$t(n)}),Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:f,children:"\u203A"})]}),Z("div",{className:S.weekdays,"aria-hidden":"true",children:Qt.map((u,x)=>Z("span",{className:S.weekday,children:u},Yt[x]))}),Z("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((u,x)=>Z(Xt,{option:u,id:`${i}-option-${x}`,index:x,isHighlighted:x===r&&u.is_tappable,isToday:we(u)===b,isPast:we(u)!=null&&we(u)<b,marks:Ut(we(u),{selectedIso:s.selectedIso,range:w}),onSelect:a,onHighlight:o},we(u)??`pad-${x}`))})]})}function Xt({option:e,id:r,index:i,isHighlighted:n,isToday:s,isPast:a,marks:o,onSelect:g,onHighlight:f}){let[b,w]=Zt(!1),u=qt(e);if(u==null)return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let x=()=>{w(!0),g(e),setTimeout(()=>w(!1),170)},k=[S.cell,S.day,a?S.past:"",n?S.highlighted:"",s?S.today:"",o.inRange?S.inRange:"",o.selected?S.selected:"",b?S.pressed:""].filter(Boolean).join(" ");return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:k,onClick:x,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),x())},onMouseEnter:()=>f(i),children:Z("span",{className:S.number,children:u})})}import{ATTRIBUTION_URL as Jt,buildAttributionUrl as ea,getFooterHint as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as aa,useState as ia}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 {
1149
1149
  display: flex;
1150
1150
  flex-wrap: wrap;
1151
1151
  gap: var(--aia-cluster-gap, 0.5rem);
@@ -1185,7 +1185,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1185
1185
  .aia-cluster[data-justify="around"] {
1186
1186
  justify-content: space-around;
1187
1187
  }
1188
- `,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...f}){let v=e?{"--aia-cluster-gap":e}:void 0,g={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":r,"data-justify":i,"data-nowrap":n||void 0,"data-inline":s||void 0,style:v,...f};return s?lt("span",{...g,children:o}):lt("div",{...g,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
1188
+ `,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...g}){let f=e?{"--aia-cluster-gap":e}:void 0,b={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":r,"data-justify":i,"data-nowrap":n||void 0,"data-inline":s||void 0,style:f,...g};return s?lt("span",{...b,children:o}):lt("div",{...b,children:o})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
1189
1189
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
1190
1190
  room above the hint/branding row so the footer doesn't butt against the last
1191
1191
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -1386,7 +1386,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1386
1386
  align-items: center;
1387
1387
  vertical-align: middle;
1388
1388
  }
1389
- `,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,f)=>Me("span",{"data-aia-pill-skeleton":"",className:`${me.pill} ${s?me.rounded:""} ${me.skeleton}`,style:{width:o,opacity:_e[pt(f)]}},`skel-${o}`))}):Me("span",{className:qe.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((o,f)=>{let v=!!n&&f===r;return Me(ct,{label:o.text,state:v?"selected":pt(f),selected:v,rounded:s,loading:a,onClick:()=>i(f)},`${o.type}-${o.text}`)})})}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
1389
+ `,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,g)=>Me("span",{"data-aia-pill-skeleton":"",className:`${me.pill} ${s?me.rounded:""} ${me.skeleton}`,style:{width:o,opacity:_e[pt(g)]}},`skel-${o}`))}):Me("span",{className:qe.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((o,g)=>{let f=!!n&&g===r;return Me(ct,{label:o.text,state:f?"selected":pt(g),selected:f,rounded:s,loading:a,onClick:()=>i(g)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as sa,useRef as la}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
1390
1390
  (packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
1391
1391
  theming one package sees the same result in the other.
1392
1392
 
@@ -1437,7 +1437,10 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1437
1437
  same way the option's highlight fill hangs outside its text. */
1438
1438
  margin-inline: -6px;
1439
1439
  /* Hide the scrollbar chrome across all three engines while leaving the box
1440
- scrollable by trackpad, wheel, touch and keyboard. */
1440
+ scrollable by trackpad, touch and keyboard. A mouse wheel is vertical and
1441
+ would otherwise have no way through a row with no scrollbar to grab, so
1442
+ ProductStrip.tsx binds the vanilla package's attachProductRowWheel on the
1443
+ row to turn a wheel over it into sideways travel. */
1441
1444
  scrollbar-width: none;
1442
1445
  -ms-overflow-style: none;
1443
1446
  }
@@ -1564,7 +1567,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1564
1567
  var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
1565
1568
  );
1566
1569
  }
1567
- `,document.head.appendChild(e)}var _={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 fe,jsxs as Ue}from"react/jsx-runtime";function ht({products:e,listboxId:r,onSelect:i,onFocusChange:n,focusable:s=!0}){if(e.length===0)return null;let a=`${r}-products-label`;return Ue("section",{className:_.section,"data-aia-products":"",role:"group","aria-labelledby":a,children:[fe("div",{className:_.label,id:a,"data-aia-products-label":"",children:"Products"}),fe("div",{className:_.row,"data-aia-products-row":"",children:e.map((o,f)=>fe(ra,{product:o,id:`${r}-product-${f}`,onSelect:i,onFocusChange:n,focusable:s},o.id))})]})}function ra({product:e,id:r,onSelect:i,onFocusChange:n,focusable:s}){let a=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Ue("a",{id:r,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[fe("span",{className:_.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?fe("img",{className:_.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ue("span",{className:_.body,children:[e.vendor?fe("span",{className:_.vendor,children:e.vendor}):null,fe("span",{className:_.title,children:e.title}),e.price?fe("span",{className:_.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as va,measureOptionsGrid as wa,needsOptionsGridMeasurement as xa,OPTIONS_GRID_MOBILE_QUERY as ya,optionEnterDelayMs as ka,planOptionsGrid as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ca,useLayoutEffect as Pa,useRef as Sa,useState as vt}from"react";import{optionsGridTemplateColumns as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as la,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 {
1570
+ `,document.head.appendChild(e)}var _={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 fe,jsxs as Ue}from"react/jsx-runtime";function ht({products:e,listboxId:r,onSelect:i,onFocusChange:n,focusable:s=!0}){let a=e.length>0,o=la(null);if(sa(()=>{let f=o.current;if(!(!a||!f))return ra(f)},[a]),!a)return null;let g=`${r}-products-label`;return Ue("section",{className:_.section,"data-aia-products":"",role:"group","aria-labelledby":g,children:[fe("div",{className:_.label,id:g,"data-aia-products-label":"",children:"Products"}),fe("div",{ref:o,className:_.row,"data-aia-products-row":"",children:e.map((f,b)=>fe(da,{product:f,id:`${r}-product-${b}`,onSelect:i,onFocusChange:n,focusable:s},f.id))})]})}function da({product:e,id:r,onSelect:i,onFocusChange:n,focusable:s}){let a=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Ue("a",{id:r,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[fe("span",{className:_.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?fe("img",{className:_.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ue("span",{className:_.body,children:[e.vendor?fe("span",{className:_.vendor,children:e.vendor}):null,fe("span",{className:_.title,children:e.title}),e.price?fe("span",{className:_.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as ya,measureOptionsGrid as ka,needsOptionsGridMeasurement as Ca,OPTIONS_GRID_MOBILE_QUERY as Pa,optionEnterDelayMs as Sa,planOptionsGrid as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ea,useLayoutEffect as Ia,useRef as Ta,useState as vt}from"react";import{optionsGridTemplateColumns as ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as pa,useRef as ha}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 {
1568
1571
  display: grid;
1569
1572
  grid-template-columns: repeat(
1570
1573
  auto-fit,
@@ -1597,7 +1600,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1597
1600
  background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
1598
1601
  border-radius: 3px;
1599
1602
  }
1600
- `,document.head.appendChild(e)}import{jsx as ca}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:i,scroll:n=!1,maxHeight:s,scrollResetKey:a,cols:o,template:f,innerRef:v,className:g,children:w,...u}){let x=da(null);la(()=>{if(a===void 0)return;let b=x.current;b&&(b.scrollTop=0)},[a]);let k={"--aia-grid-min":e};return r&&(k["--aia-grid-max"]=r),i&&(k["--aia-grid-gap"]=i),s&&(k["--aia-grid-max-height"]=s),o&&(k.gridTemplateColumns=sa(o)),f&&(k.gridTemplateColumns=f),ca("div",{ref:b=>{x.current=b,v?.(b)},className:g?`aia-grid ${g}`:"aia-grid","data-scroll":n||void 0,style:k,...u,children:w})}import{OPTION_ENTER_DELAY_VAR as pa,optionLabel as ha,sanitizeOptionIconSvg as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ma,useMemo as fa,useRef as ga,useState as mt}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 {
1603
+ `,document.head.appendChild(e)}import{jsx as ua}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:i,scroll:n=!1,maxHeight:s,scrollResetKey:a,cols:o,template:g,innerRef:f,className:b,children:w,...u}){let x=ha(null);pa(()=>{if(a===void 0)return;let v=x.current;v&&(v.scrollTop=0)},[a]);let k={"--aia-grid-min":e};return r&&(k["--aia-grid-max"]=r),i&&(k["--aia-grid-gap"]=i),s&&(k["--aia-grid-max-height"]=s),o&&(k.gridTemplateColumns=ca(o)),g&&(k.gridTemplateColumns=g),ua("div",{ref:v=>{x.current=v,f?.(v)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":n||void 0,style:k,...u,children:w})}import{OPTION_ENTER_DELAY_VAR as ma,optionLabel as fa,sanitizeOptionIconSvg as ga}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ba,useMemo as va,useRef as wa,useState as mt}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 {
1601
1604
  position: relative;
1602
1605
  /* Clip, not visible: the entrance rise below runs on the inner content,
1603
1606
  and a transformed box extends its scroll container's scrollable area.
@@ -1802,7 +1805,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1802
1805
  filter: brightness(0.55);
1803
1806
  }
1804
1807
  }
1805
- `,document.head.appendChild(e)}var q={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",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",icon:"aia-icon-Qw938"};import{jsx as ze,jsxs as ba}from"react/jsx-runtime";function ft({option:e,isHighlighted:r,onSelect:i,onHighlight:n,id:s,loading:a,showIcon:o=!0,scrollHint:f,enterDelayMs:v=0}){let[g]=mt(v),[w,u]=mt(!1),x=fa(()=>o&&e.icon_svg?ua(e.icon_svg):null,[o,e.icon_svg]),k=ga(void 0);ma(()=>()=>clearTimeout(k.current),[]);let b=()=>{a||!e.is_tappable||w||(u(!0),i(e),clearTimeout(k.current),k.current=setTimeout(()=>u(!1),170))},E=[q.item,r&&!a?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,w?q.pressed:"",f?q.scrollHint:""].filter(Boolean).join(" ");return ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":x&&e.icon?e.icon:void 0,"aria-selected":r,className:E,style:{[pa]:`${g}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:b,onKeyDown:T=>{!a&&e.is_tappable&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),b())},onMouseEnter:!a&&e.is_tappable?n:void 0,children:ba("span",{className:q.content,children:[x&&ze("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x}}),ze("span",{className:q.text,children:ha(e)}),e.tag&&ze("span",{className:q.tag,children:e.tag})]})})}import{jsx as bt}from"react/jsx-runtime";function Ea(){let[e,r]=vt(va);return Ca(()=>{if(typeof window>"u"||!window.matchMedia)return;let i=window.matchMedia(ya),n=()=>r(i.matches);return n(),i.addEventListener("change",n),()=>i.removeEventListener("change",n)},[]),e}function wt({options:e,activeIndex:r,onSelect:i,onHighlight:n,listboxId:s,loading:a,groupKey:o="",optionsPosition:f="below",showIcons:v=!0}){let g=Ea(),w=Sa(null),[u,x]=vt(null);Pa(()=>{let b=w.current,T=b&&!a&&xa(e.length,g)?wa(b):null;x(T?gt(e.length,g,T.rowWidths,T.gridWidth):null)},[e,g,a]);let k=u??gt(e.length,g,null,null);return bt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:k.template,maxHeight:k.maxHeight,innerRef:b=>{w.current=b},"data-aia-group":o,children:e.map((b,E)=>bt(ft,{option:b,isHighlighted:E===r,onSelect:i,onHighlight:()=>n(E),id:`${s}-option-${E}`,loading:a,showIcon:v,scrollHint:!a&&k.scrollHintIndices.includes(E),enterDelayMs:a?0:ka(E,k.cols,e.length,f)},`${o}\0${b.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
1808
+ `,document.head.appendChild(e)}var q={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",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",icon:"aia-icon-Qw938"};import{jsx as ze,jsxs as xa}from"react/jsx-runtime";function ft({option:e,isHighlighted:r,onSelect:i,onHighlight:n,id:s,loading:a,showIcon:o=!0,scrollHint:g,enterDelayMs:f=0}){let[b]=mt(f),[w,u]=mt(!1),x=va(()=>o&&e.icon_svg?ga(e.icon_svg):null,[o,e.icon_svg]),k=wa(void 0);ba(()=>()=>clearTimeout(k.current),[]);let v=()=>{a||!e.is_tappable||w||(u(!0),i(e),clearTimeout(k.current),k.current=setTimeout(()=>u(!1),170))},E=[q.item,r&&!a?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,w?q.pressed:"",g?q.scrollHint:""].filter(Boolean).join(" ");return ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":x&&e.icon?e.icon:void 0,"aria-selected":r,className:E,style:{[ma]:`${b}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:v,onKeyDown:T=>{!a&&e.is_tappable&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),v())},onMouseEnter:!a&&e.is_tappable?n:void 0,children:xa("span",{className:q.content,children:[x&&ze("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x}}),ze("span",{className:q.text,children:fa(e)}),e.tag&&ze("span",{className:q.tag,children:e.tag})]})})}import{jsx as bt}from"react/jsx-runtime";function Aa(){let[e,r]=vt(ya);return Ea(()=>{if(typeof window>"u"||!window.matchMedia)return;let i=window.matchMedia(Pa),n=()=>r(i.matches);return n(),i.addEventListener("change",n),()=>i.removeEventListener("change",n)},[]),e}function wt({options:e,activeIndex:r,onSelect:i,onHighlight:n,listboxId:s,loading:a,groupKey:o="",optionsPosition:g="below",showIcons:f=!0}){let b=Aa(),w=Ta(null),[u,x]=vt(null);Ia(()=>{let v=w.current,T=v&&!a&&Ca(e.length,b)?ka(v):null;x(T?gt(e.length,b,T.rowWidths,T.gridWidth):null)},[e,b,a]);let k=u??gt(e.length,b,null,null);return bt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:k.template,maxHeight:k.maxHeight,innerRef:v=>{w.current=v},"data-aia-group":o,children:e.map((v,E)=>bt(ft,{option:v,isHighlighted:E===r,onSelect:i,onHighlight:()=>n(E),id:`${s}-option-${E}`,loading:a,showIcon:f,scrollHint:!a&&k.scrollHintIndices.includes(E),enterDelayMs:a?0:Sa(E,k.cols,e.length,g)},`${o}\0${v.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
1806
1809
  display: flex;
1807
1810
  flex-direction: column;
1808
1811
  gap: var(--aia-stack-space, 0.5rem);
@@ -1817,7 +1820,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1817
1820
  align-items: end;
1818
1821
  }
1819
1822
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1820
- `,document.head.appendChild(e)}import{jsx as Ia}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:i,children:n,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Ia("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":r,style:a,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var La=[159,119,164],Ma=()=>{},yt=()=>{};function Oa(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,n]=Da(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function za(e,r){let i=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let a=n.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Ta({dropdown:n,grid:a,button:s})};return}i.current?.controller.update()}),$e(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:i,onHighlight:n,isOpen:s,id:a,className:o,pills:f,onPillClick:v,showPills:g=!0,onSkip:w,showSkipButton:u=!0,showOptionIcons:x=!0,skipDisabled:k=!1,activeSelected:b=!1,isLoading:E=!1,isInputEmpty:T=!1,products:R,onProductSelect:O,onProductFocusChange:Y,formatType:z="options",dateView:P=null,selectedDateIso:j=null,selectedDateRange:ne=null,dateRangeStart:X=null,onPreviousMonth:p,onNextMonth:re,optionsPosition:D="below",mode:se}){let J=Oa(se),$=J!==void 0,ee=Ne(null),V=Ne(null);za(ee,V);let te=e[0]?.options??[],ae=!!(f&&f.length>0&&v),N=!!(R&&R.length>0),H=s&&(te.length>0||g&&ae||E||N),W={suggestions:e,activeIndex:r,pills:f,showPills:g,showSkipButton:u,showOptionIcons:x,skipDisabled:k,activeSelected:b,isLoading:E,isInputEmpty:T,products:R,formatType:z,dateView:P,selectedDateIso:j,selectedDateRange:ne,dateRangeStart:X},B=Ne(W);H&&(B.current=W);let t=H?W:B.current,c=t.suggestions[0],h=c?.options??[],y=t.activeIndex>=0&&!!h[t.activeIndex]?.is_tappable,l=!!(t.pills&&t.pills.length>0&&v),A=t.showPills&&l,Q=t.showPills&&!l&&t.isLoading,L=A||Q,d=l&&t.showSkipButton&&!t.isInputEmpty&&!!w,le=t.pills?.[0]?.text,be=Aa(t.formatType)&&t.dateView!=null,de=h.length>0&&!be,ve=h.length>0&&be&&!t.isLoading,ce=t.isLoading&&!de&&!ve,pe=t.products??[];return je("div",{ref:ee,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":D,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":pe.length>0?"":void 0,className:`${$?"magicx-aia ":""}${ie.dropdown} ${H?ie.visible:""} ${o??""}`,onMouseDown:M=>M.preventDefault(),children:[je(xt,{space:"8px",children:[(L||d)&&je(Pe,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[L&&K("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:K(Oe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:t.isLoading})}),d&&K("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":le?`Skip ${le}`:"Skip",onClick:w,children:"skip"})]}),de&&K(wt,{options:h,activeIndex:t.activeIndex,onSelect:i,onHighlight:n,listboxId:a,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:D,showIcons:t.showOptionIcons}),ve&&t.dateView&&K(st,{options:h,activeIndex:t.activeIndex,listboxId:a,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:i,onHighlight:n,onPreviousMonth:p??yt,onNextMonth:re??yt}),ce&&K("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:La.map(M=>K("span",{className:ie.skeletonBar,style:{width:M}},`bar-${M}`))}),K(ht,{products:pe,listboxId:a,onSelect:O??Ma,onFocusChange:Y,focusable:H}),K(dt,{isOptionHighlighted:y,isInputEmpty:t.isInputEmpty})]}),K("button",{ref:V,type:"button",tabIndex:-1,className:ie.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ra,"aria-hidden":"true",children:K("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:K("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as $a,ModeController as Va,setCursorOffset as Qa}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 {
1823
+ `,document.head.appendChild(e)}import{jsx as Ra}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:i,children:n,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Ra("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":r,style:a,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var za=[159,119,164],Na=()=>{},yt=()=>{};function Ha(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,n]=Oa(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function Ba(e,r){let i=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let a=n.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Da({dropdown:n,grid:a,button:s})};return}i.current?.controller.update()}),$e(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:i,onHighlight:n,isOpen:s,id:a,className:o,pills:g,onPillClick:f,showPills:b=!0,onSkip:w,showSkipButton:u=!0,showOptionIcons:x=!0,skipDisabled:k=!1,activeSelected:v=!1,isLoading:E=!1,isInputEmpty:T=!1,products:R,onProductSelect:O,onProductFocusChange:Y,formatType:z="options",dateView:P=null,selectedDateIso:j=null,selectedDateRange:ne=null,dateRangeStart:X=null,onPreviousMonth:p,onNextMonth:re,optionsPosition:D="below",mode:se}){let J=Ha(se),$=J!==void 0,ee=Ne(null),V=Ne(null);Ba(ee,V);let te=e[0]?.options??[],ae=!!(g&&g.length>0&&f),N=!!(R&&R.length>0),H=s&&(te.length>0||b&&ae||E||N),W={suggestions:e,activeIndex:r,pills:g,showPills:b,showSkipButton:u,showOptionIcons:x,skipDisabled:k,activeSelected:v,isLoading:E,isInputEmpty:T,products:R,formatType:z,dateView:P,selectedDateIso:j,selectedDateRange:ne,dateRangeStart:X},B=Ne(W);H&&(B.current=W);let t=H?W:B.current,c=t.suggestions[0],h=c?.options??[],y=t.activeIndex>=0&&!!h[t.activeIndex]?.is_tappable,l=!!(t.pills&&t.pills.length>0&&f),A=t.showPills&&l,Q=t.showPills&&!l&&t.isLoading,L=A||Q,d=l&&t.showSkipButton&&!t.isInputEmpty&&!!w,le=t.pills?.[0]?.text,be=La(t.formatType)&&t.dateView!=null,de=h.length>0&&!be,ve=h.length>0&&be&&!t.isLoading,ce=t.isLoading&&!de&&!ve,pe=t.products??[];return je("div",{ref:ee,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":D,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":pe.length>0?"":void 0,className:`${$?"magicx-aia ":""}${ie.dropdown} ${H?ie.visible:""} ${o??""}`,onMouseDown:M=>M.preventDefault(),children:[je(xt,{space:"8px",children:[(L||d)&&je(Pe,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[L&&K("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:K(Oe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:t.isLoading})}),d&&K("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":le?`Skip ${le}`:"Skip",onClick:w,children:"skip"})]}),de&&K(wt,{options:h,activeIndex:t.activeIndex,onSelect:i,onHighlight:n,listboxId:a,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:D,showIcons:t.showOptionIcons}),ve&&t.dateView&&K(st,{options:h,activeIndex:t.activeIndex,listboxId:a,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:i,onHighlight:n,onPreviousMonth:p??yt,onNextMonth:re??yt}),ce&&K("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:za.map(M=>K("span",{className:ie.skeletonBar,style:{width:M}},`bar-${M}`))}),K(ht,{products:pe,listboxId:a,onSelect:O??Na,onFocusChange:Y,focusable:H}),K(dt,{isOptionHighlighted:y,isInputEmpty:t.isInputEmpty})]}),K("button",{ref:V,type:"button",tabIndex:-1,className:ie.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ma,"aria-hidden":"true",children:K("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:K("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Za,ModeController as Ya,setCursorOffset as Xa}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 {
1821
1824
  flex-shrink: 0;
1822
1825
  width: 32px;
1823
1826
  height: 32px;
@@ -1870,5 +1873,5 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
1870
1873
  );
1871
1874
  cursor: default;
1872
1875
  }
1873
- `,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Na,dateSelectionFor as Ha,identifiedParamLabel as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Fa}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let i=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(f,v,g)=>{let w=r.current?.[a];return w?w(f,v,g):[]};s[a]=o}n.current={key:i,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:i}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let i=Et(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=r.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?i.current:void 0,enabled:n}}var Ka={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:[],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 Ze({onSubmit:e,onResult:r,onError:i,optionOverrides:n,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:f=2,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:b,onFocus:E,onBlur:T,value:R,completedParams:O,onChange:Y,onParamsChange:z,products:P,onProductSelect:j,source:ne,setCursor:X}){let p=G(null),[re,D]=Fa(null),se=G(e);se.current=e;let J=G(r);J.current=r;let $=G(i);$.current=i;let ee=G(Y);ee.current=Y;let V=G(z);V.current=z;let te=G(E);te.current=E;let ae=G(T);ae.current=T;let N=G(X);N.current=X;let H=G(j);H.current=j;let W=It(P),B=St(n);Ee(()=>{if(typeof document>"u")return;let m=new Na(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:f,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b,source:ne,value:R,completedParams:O,onSubmit:(...I)=>se.current?.(...I),onResult:(...I)=>J.current?.(...I),onError:(...I)=>$.current?.(...I),onChange:(...I)=>ee.current?.(...I),onParamsChange:(...I)=>V.current?.(...I),onFocus:()=>te.current?.(),onBlur:()=>ae.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>N.current?.(I),products:W.config});p.current=m,D(m.getState());let F=m.subscribe(I=>D(I));return()=>{F(),m.destroy(),p.current===m&&(p.current=null)}},[]),Ee(()=>{R!==void 0&&p.current?.setValue(R)},[R]),Ee(()=>{O!==void 0&&p.current?.setCompletedParams(O)},[O]);let t=JSON.stringify(a??null),c;try{c=JSON.stringify(o??null)}catch{c="[unstringifiable]"}Ee(()=>{p.current?.update({apiConfig:a,additionalContext:o,optionOverrides:B.overrides,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b})},[t,c,B.key,v,g,w,u,b]);let h=G(!1);Ee(()=>{if(!h.current){h.current=!0;return}p.current?.update({products:W.config})},[W.enabled]);let y=G(null);y.current===null&&(y.current={handleTextChange:m=>p.current?.handleTextChange(m),handleKeyDown:m=>{let F="nativeEvent"in m?m.nativeEvent:m;p.current?.handleKeyDown(F)},setFocused:m=>p.current?.setFocused(m),startEditingParam:m=>p.current?.startEditingParam(m),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:m=>p.current?.handleCaretAfterInput(m),handleCaretMove:m=>p.current?.handleCaretMove(m),replaceEditingRange:m=>p.current?.replaceEditingRange(m)??!1,setActivePill:m=>p.current?.setActivePill(m),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:m=>p.current?.selectOption(m),selectProduct:m=>p.current?.selectProduct(m),setActiveDropdownIndex:m=>p.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=y.current,A=Tt(m=>{let F=m.target.value,Fe=F.length>0&&!m.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;p.current?.handleTextChange(Fe)},[]),Q=Tt(m=>{p.current?.handleKeyDown(m.nativeEvent)},[]),L=p.current,d=re??Ka,le=R!==void 0?R:d.text,be=O!==void 0?O:d.completedParams,de=d.actionableSuggestions,ve=de[0],ce=L?.listboxId??"",pe=d.activeDropdownIndex>=0&&L?`${ce}-option-${d.activeDropdownIndex}`:void 0,M=d.editingParam,he=d.editingIdentified,ke=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:he?{type:he.type,text:Ba(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ha(d),Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:be,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:de,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ce,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:M,editingIdentified:he,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:le,placeholder:d.placeholderText||void 0,onChange:A,onKeyDown:Q,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":pe,"aria-autocomplete":"list","aria-controls":ce},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ce,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!M&&!he,showOptionIcons:x??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:le.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:g??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as Ga,renderEditableContent as Wa,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function _a(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:f,placeholderText:v,isFocused:g,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:b,handleKeyDown:E,handleCaretAfterInput:T,handleCaretMove:R,startEditingParam:O,replaceEditingRange:Y,setFocused:z}=e,P=xe(null),j=xe(!1),ne=xe(""),X=xe(""),p=xe(null),re=xe(0);p.current=f,Ye(()=>{if(!k)return;let t=P.current;if(!t)return;document.activeElement===t?z(!0):t.focus();let c=t.ownerDocument??document,h=c.getSelection(),y=h&&h.rangeCount>0&&t.contains(h.anchorNode);if(h&&!y){let l=c.createRange();l.selectNodeContents(t),l.collapse(!0),h.removeAllRanges(),h.addRange(l)}},[k,z]),Ye(()=>{let t=P.current;if(!t)return;let c=t.ownerDocument??document,h=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!t.contains(y.anchorNode))return;let l=y.anchorNode,A=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,L=(y.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??a?.id??null;if(L&&L!==d){O(L);return}performance.now()-re.current<50||R(Rt(t))};return c.addEventListener("selectionchange",h),()=>c.removeEventListener("selectionchange",h)},[s,a,O,R]),Xe(()=>{let t=P.current;t&&Wa({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:v??"",isFocused:g,showChipIcons:i})},[r,n,s,v,g,i]),Xe(()=>{let t=ne.current,c=n??"";if(ne.current=c,!c||c===t)return;let h=P.current;if(!h)return;h.focus();let y=p.current??Ga(h);Dt(h,y)},[n]),Xe(()=>{let t=X.current,c=s?.id??"";if(X.current=c,!c||c===t||o==null)return;let h=P.current;h&&Dt(h,o)},[s,o]);let D=U(()=>{if(j.current)return;let t=P.current;if(!t)return;let c=At(t),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;b(y)},[b]),se=U(()=>{re.current=performance.now(),D();let t=P.current;t&&T(Rt(t))},[D,T]);Ye(()=>{let t=P.current;if(!t)return;let c=h=>{let y=h,l=y.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){h.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let A=l.startsWith("delete")?"":y.data??"";Y(A)&&h.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Y]);let J=U(()=>{j.current=!0},[]),$=U(()=>{j.current=!1,D()},[D]),ee=U(t=>{t.preventDefault();let c=P.current;if(!c)return;let h=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let y=c.ownerDocument??document,l=y.getSelection();if(!l||l.rangeCount===0)return;let A=l.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let Q=y.createTextNode(h);A.insertNode(Q),A.setStartAfter(Q),A.collapse(!0),l.removeAllRanges(),l.addRange(A),D()},[D]),V=U(t=>E(t),[E]),te=U(()=>z(!0),[z]),ae=U(()=>z(!1),[z]),N=U(()=>P.current?.focus(),[]),H=U(()=>P.current?.blur(),[]),W=U(()=>{let t=P.current;return t?At(t):""},[]),B=_a()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:V,onCompositionStart:J,onCompositionEnd:$,onPaste:ee,onFocus:te,onBlur:ae},getPlainText:W,focus:N,blur:H}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function Za(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ya=qa(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:f,additionalContext:v,columns:g,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:b,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R=!0,showChipIcons:O=!0,showSkipButton:Y,showProducts:z,autoFocus:P=!0,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),N=Ie(null),H=Ie(null);Mt(()=>{let C=V.current;if(C)return N.current?N.current.setMode(u):N.current=new Va(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Qa(ue,C))},[]),{completedParams:B,skippedParams:t,identifiedParams:c,isReady:h,customFields:y,suggestionPills:l,setActivePill:A,skipActivePill:Q,segments:L,newParamId:d,clearNewParamId:le,placeholderText:be,isFocused:de,isDropdownOpen:ve,isActivePillSelected:ce,isLoading:pe,activeIndex:M,listboxId:he,handleTextChange:ke,handleKeyDown:Te,setFocused:Be,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,startEditingParam:I,handleCaretAfterInput:Fe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,apiConfig:f,additionalContext:v,columns:g,dropdownTrigger:b,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R,showSkipButton:Y,showProducts:z,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!d)return;let C=window.setTimeout(()=>le(),650);return()=>window.clearTimeout(C)},[d,le]);let Ht=M>=0?`${he}-option-${M}`:void 0,{inputRef:Ke,editorProps:Bt,focus:De,blur:tt,getPlainText:at}=Lt({segments:L,newParamId:d,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,placeholderText:be,isFocused:de,showChipIcons:O,isDropdownOpen:ve,listboxId:he,activeDescendantId:Ht,autoFocus:P,handleTextChange:ke,handleKeyDown:Te,handleCaretAfterInput:Fe,handleCaretMove:Ot,startEditingParam:I,replaceEditingRange:zt,setFocused:Be});H.current=Ke,ja(()=>{let C=te.current,ue=Ke.current;if(!C||!ue)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let Wt=nt.getBoundingClientRect(),_t=ue.getBoundingClientRect();Wt.top>=_t.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(ue),()=>ot.disconnect()},[L,l.length,pe,Ke]),Ua(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>N.current?.setMode(C),skipActivePill:Q}),[De,tt,Re,Q]);let Le=!!L.length||B.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r($a(C,B,t,{identifiedParams:c,isReady:h,customFields:y})),Re()},[Le,B,t,c,h,y,r,Re,at]);ae.current=Ge;let Ft=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Kt=w==="inline",Gt=w==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":w,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Za(u),children:[ye(Ve,{...Nt,showPills:Gt}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Bt,className:ge.input,"data-aia-input":""}),Kt&&(pe||l.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:l,activePillIndex:0,activeSelected:ce,onSelectPill:A,loading:pe})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{Ya as AIAutocomplete,Ve as AIAutocompleteDropdown,_o as DATE_RANGE_META_END,qo as DATE_RANGE_META_START,Yo as PRODUCT_PATH_PREFIX,sn as WEEKDAY_LABELS,Ko as buildSubmitResult,Go as cellDay,Wo as cellIso,Uo as dateCellMarks,jo as formatDate,$o as formatDateRange,Vo as isoDate,Qo as monthLabel,Zo as optionLabel,Xo as parseDate,Jo as parseLooseDate,en as parseLooseDateRange,tn as productFromMatchedItem,an as productsFromCustomFields,on as sanitizeOptionIconSvg,nn as selectedRangeFor,Ze as useAIAutocomplete,rn as visibleDateRange,ln as withSkippedParams};
1876
+ `,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Fa,dateSelectionFor as Ka,identifiedParamLabel as Ga}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Wa}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let i=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(g,f,b)=>{let w=r.current?.[a];return w?w(g,f,b):[]};s[a]=o}n.current={key:i,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:i}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let i=Et(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=r.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?i.current:void 0,enabled:n}}var _a={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:[],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 Ze({onSubmit:e,onResult:r,onError:i,optionOverrides:n,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:g=2,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:v,onFocus:E,onBlur:T,value:R,completedParams:O,onChange:Y,onParamsChange:z,products:P,onProductSelect:j,source:ne,setCursor:X}){let p=G(null),[re,D]=Wa(null),se=G(e);se.current=e;let J=G(r);J.current=r;let $=G(i);$.current=i;let ee=G(Y);ee.current=Y;let V=G(z);V.current=z;let te=G(E);te.current=E;let ae=G(T);ae.current=T;let N=G(X);N.current=X;let H=G(j);H.current=j;let W=It(P),B=St(n);Ee(()=>{if(typeof document>"u")return;let m=new Fa(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:g,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:v,source:ne,value:R,completedParams:O,onSubmit:(...I)=>se.current?.(...I),onResult:(...I)=>J.current?.(...I),onError:(...I)=>$.current?.(...I),onChange:(...I)=>ee.current?.(...I),onParamsChange:(...I)=>V.current?.(...I),onFocus:()=>te.current?.(),onBlur:()=>ae.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>N.current?.(I),products:W.config});p.current=m,D(m.getState());let F=m.subscribe(I=>D(I));return()=>{F(),m.destroy(),p.current===m&&(p.current=null)}},[]),Ee(()=>{R!==void 0&&p.current?.setValue(R)},[R]),Ee(()=>{O!==void 0&&p.current?.setCompletedParams(O)},[O]);let t=JSON.stringify(a??null),c;try{c=JSON.stringify(o??null)}catch{c="[unstringifiable]"}Ee(()=>{p.current?.update({apiConfig:a,additionalContext:o,optionOverrides:B.overrides,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:v})},[t,c,B.key,f,b,w,u,v]);let h=G(!1);Ee(()=>{if(!h.current){h.current=!0;return}p.current?.update({products:W.config})},[W.enabled]);let y=G(null);y.current===null&&(y.current={handleTextChange:m=>p.current?.handleTextChange(m),handleKeyDown:m=>{let F="nativeEvent"in m?m.nativeEvent:m;p.current?.handleKeyDown(F)},setFocused:m=>p.current?.setFocused(m),startEditingParam:m=>p.current?.startEditingParam(m),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:m=>p.current?.handleCaretAfterInput(m),handleCaretMove:m=>p.current?.handleCaretMove(m),replaceEditingRange:m=>p.current?.replaceEditingRange(m)??!1,setActivePill:m=>p.current?.setActivePill(m),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:m=>p.current?.selectOption(m),selectProduct:m=>p.current?.selectProduct(m),setActiveDropdownIndex:m=>p.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=y.current,A=Tt(m=>{let F=m.target.value,Fe=F.length>0&&!m.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;p.current?.handleTextChange(Fe)},[]),Q=Tt(m=>{p.current?.handleKeyDown(m.nativeEvent)},[]),L=p.current,d=re??_a,le=R!==void 0?R:d.text,be=O!==void 0?O:d.completedParams,de=d.actionableSuggestions,ve=de[0],ce=L?.listboxId??"",pe=d.activeDropdownIndex>=0&&L?`${ce}-option-${d.activeDropdownIndex}`:void 0,M=d.editingParam,he=d.editingIdentified,ke=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:he?{type:he.type,text:Ga(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ka(d),Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:be,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:de,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ce,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:M,editingIdentified:he,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:le,placeholder:d.placeholderText||void 0,onChange:A,onKeyDown:Q,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":pe,"aria-autocomplete":"list","aria-controls":ce},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ce,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!M&&!he,showOptionIcons:x??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:le.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as qa,renderEditableContent as Ua,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function ja(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:g,placeholderText:f,isFocused:b,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:v,handleKeyDown:E,handleCaretAfterInput:T,handleCaretMove:R,startEditingParam:O,replaceEditingRange:Y,setFocused:z}=e,P=xe(null),j=xe(!1),ne=xe(""),X=xe(""),p=xe(null),re=xe(0);p.current=g,Ye(()=>{if(!k)return;let t=P.current;if(!t)return;document.activeElement===t?z(!0):t.focus();let c=t.ownerDocument??document,h=c.getSelection(),y=h&&h.rangeCount>0&&t.contains(h.anchorNode);if(h&&!y){let l=c.createRange();l.selectNodeContents(t),l.collapse(!0),h.removeAllRanges(),h.addRange(l)}},[k,z]),Ye(()=>{let t=P.current;if(!t)return;let c=t.ownerDocument??document,h=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!t.contains(y.anchorNode))return;let l=y.anchorNode,A=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,L=(y.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??a?.id??null;if(L&&L!==d){O(L);return}performance.now()-re.current<50||R(Rt(t))};return c.addEventListener("selectionchange",h),()=>c.removeEventListener("selectionchange",h)},[s,a,O,R]),Xe(()=>{let t=P.current;t&&Ua({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:f??"",isFocused:b,showChipIcons:i})},[r,n,s,f,b,i]),Xe(()=>{let t=ne.current,c=n??"";if(ne.current=c,!c||c===t)return;let h=P.current;if(!h)return;h.focus();let y=p.current??qa(h);Dt(h,y)},[n]),Xe(()=>{let t=X.current,c=s?.id??"";if(X.current=c,!c||c===t||o==null)return;let h=P.current;h&&Dt(h,o)},[s,o]);let D=U(()=>{if(j.current)return;let t=P.current;if(!t)return;let c=At(t),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;v(y)},[v]),se=U(()=>{re.current=performance.now(),D();let t=P.current;t&&T(Rt(t))},[D,T]);Ye(()=>{let t=P.current;if(!t)return;let c=h=>{let y=h,l=y.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){h.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let A=l.startsWith("delete")?"":y.data??"";Y(A)&&h.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Y]);let J=U(()=>{j.current=!0},[]),$=U(()=>{j.current=!1,D()},[D]),ee=U(t=>{t.preventDefault();let c=P.current;if(!c)return;let h=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let y=c.ownerDocument??document,l=y.getSelection();if(!l||l.rangeCount===0)return;let A=l.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let Q=y.createTextNode(h);A.insertNode(Q),A.setStartAfter(Q),A.collapse(!0),l.removeAllRanges(),l.addRange(A),D()},[D]),V=U(t=>E(t),[E]),te=U(()=>z(!0),[z]),ae=U(()=>z(!1),[z]),N=U(()=>P.current?.focus(),[]),H=U(()=>P.current?.blur(),[]),W=U(()=>{let t=P.current;return t?At(t):""},[]),B=ja()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:V,onCompositionStart:J,onCompositionEnd:$,onPaste:ee,onFocus:te,onBlur:ae},getPlainText:W,focus:N,blur:H}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function Ja(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ei=$a(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:g,additionalContext:f,columns:b,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:v,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R=!0,showChipIcons:O=!0,showSkipButton:Y,showProducts:z,autoFocus:P=!0,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),N=Ie(null),H=Ie(null);Mt(()=>{let C=V.current;if(C)return N.current?N.current.setMode(u):N.current=new Ya(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Xa(ue,C))},[]),{completedParams:B,skippedParams:t,identifiedParams:c,isReady:h,customFields:y,suggestionPills:l,setActivePill:A,skipActivePill:Q,segments:L,newParamId:d,clearNewParamId:le,placeholderText:be,isFocused:de,isDropdownOpen:ve,isActivePillSelected:ce,isLoading:pe,activeIndex:M,listboxId:he,handleTextChange:ke,handleKeyDown:Te,setFocused:Be,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,startEditingParam:I,handleCaretAfterInput:Fe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,apiConfig:g,additionalContext:f,columns:b,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R,showSkipButton:Y,showProducts:z,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!d)return;let C=window.setTimeout(()=>le(),650);return()=>window.clearTimeout(C)},[d,le]);let Ht=M>=0?`${he}-option-${M}`:void 0,{inputRef:Ke,editorProps:Bt,focus:De,blur:tt,getPlainText:at}=Lt({segments:L,newParamId:d,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,placeholderText:be,isFocused:de,showChipIcons:O,isDropdownOpen:ve,listboxId:he,activeDescendantId:Ht,autoFocus:P,handleTextChange:ke,handleKeyDown:Te,handleCaretAfterInput:Fe,handleCaretMove:Ot,startEditingParam:I,replaceEditingRange:zt,setFocused:Be});H.current=Ke,Qa(()=>{let C=te.current,ue=Ke.current;if(!C||!ue)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let Wt=nt.getBoundingClientRect(),_t=ue.getBoundingClientRect();Wt.top>=_t.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(ue),()=>ot.disconnect()},[L,l.length,pe,Ke]),Va(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>N.current?.setMode(C),skipActivePill:Q}),[De,tt,Re,Q]);let Le=!!L.length||B.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r(Za(C,B,t,{identifiedParams:c,isReady:h,customFields:y})),Re()},[Le,B,t,c,h,y,r,Re,at]);ae.current=Ge;let Ft=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Kt=w==="inline",Gt=w==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":w,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Ja(u),children:[ye(Ve,{...Nt,showPills:Gt}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Bt,className:ge.input,"data-aia-input":""}),Kt&&(pe||l.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:l,activePillIndex:0,activeSelected:ce,onSelectPill:A,loading:pe})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{ei as AIAutocomplete,Ve as AIAutocompleteDropdown,Vo as DATE_RANGE_META_END,Qo as DATE_RANGE_META_START,an as PRODUCT_PATH_PREFIX,hn as WEEKDAY_LABELS,Uo as buildSubmitResult,jo as cellDay,$o as cellIso,Zo as dateCellMarks,Yo as formatDate,Xo as formatDateRange,Jo as isoDate,en as monthLabel,tn as optionLabel,on as parseDate,nn as parseLooseDate,rn as parseLooseDateRange,sn as productFromMatchedItem,ln as productsFromCustomFields,dn as sanitizeOptionIconSvg,cn as selectedRangeFor,Ze as useAIAutocomplete,pn as visibleDateRange,un as withSkippedParams};
1874
1877
  //# sourceMappingURL=index.mjs.map