@magicx-eng/ai-autocomplete-react 0.57.2 → 0.58.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/README.md +2 -1
- package/REFERENCE.md +2 -2
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +47 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as ls,cellDay as ds,cellIso as cs,DATE_RANGE_META_END as ps,DATE_RANGE_META_START as hs,DEFAULT_OPTION_COUNT_UNIT as us,dateCellMarks as ms,formatDate as gs,formatDateRange as fs,formatOptionCount as bs,formatPlace as ws,formatTime as vs,isoDate as xs,LOCATION_META_KEY as ys,monthLabel as ks,optionCountLabel as Cs,optionHasImage as Ss,optionImageSources as Ts,optionImageSrc as Ps,optionLabel as Is,optionsShowLeadingVisuals as Es,PRODUCT_PATH_PREFIX as As,parseDate as Os,parseLooseDate as Rs,parseLooseDateRange as Ls,parseTime as zs,productFromMatchedItem as Ds,productImageSources as Ms,productsFromCustomFields as Ns,sanitizeOptionIconSvg as Fs,selectedRangeFor as Hs,TIME_META_KEY as Bs,visibleDateRange as Ws,WEEKDAY_LABELS as Gs,withSkippedParams as Ks}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Uo,useCallback as Mt,useEffect as Nt,useImperativeHandle as Qo,useLayoutEffect as Yo,useRef as at}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -406,7 +406,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
406
406
|
transition: none;
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
`,document.head.appendChild(e)}var
|
|
409
|
+
`,document.head.appendChild(e)}var Ke={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};import{attachScrollArrow as to,attachViewportFit as ao,containScroll as io,dateFloorFor as oo,destroyPanelMorph as no,findMultiSelectDone as ro,fitMultiSelectDone as so,hasSkippablePill as lo,isCalendarFormat as co,labelTraditionalAutocomplete as po,panelMorphKey as ho,queryLive as uo,settlePanelMorph as mo,syncPanelHug as go,uiStringsFor as fo}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as _e,useLayoutEffect as Ot,useRef as Xe,useState as bo}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
410
410
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
411
411
|
* Consumer CSS always wins without !important.
|
|
412
412
|
*
|
|
@@ -1107,6 +1107,37 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1107
1107
|
);
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
|
+
/* While the panel glides wider (panelMorph.ts), its new content is laid out at
|
|
1111
|
+
the width it lands at and the panel, which clips, reveals it as it opens:
|
|
1112
|
+
squeezed into the narrow width it starts from, two columns would wrap. The
|
|
1113
|
+
leaving copy keeps its own width. */
|
|
1114
|
+
[data-aia-dropdown][data-aia-glide-width]
|
|
1115
|
+
> :not(.magicx-aia-panel-ghost):not([data-aia-scroll-arrow]) {
|
|
1116
|
+
min-width: var(--aia-glide-content-width, auto);
|
|
1117
|
+
}
|
|
1118
|
+
/* The All row's tile shows the first options' pictures together: two side by
|
|
1119
|
+
side, three as a tall half and two quarters, four in a 2x2 grid. Each is
|
|
1120
|
+
cropped to its cell, since a contained picture would leave the cells
|
|
1121
|
+
mostly empty. */
|
|
1122
|
+
[data-aia-option] [data-aia-collage] {
|
|
1123
|
+
display: grid;
|
|
1124
|
+
grid-template-columns: 1fr 1fr;
|
|
1125
|
+
gap: 1px;
|
|
1126
|
+
}
|
|
1127
|
+
[data-aia-option] [data-aia-collage="3"],
|
|
1128
|
+
[data-aia-option] [data-aia-collage="4"] {
|
|
1129
|
+
grid-template-rows: 1fr 1fr;
|
|
1130
|
+
}
|
|
1131
|
+
[data-aia-option] [data-aia-collage="3"] > img:first-child {
|
|
1132
|
+
grid-row: 1 / span 2;
|
|
1133
|
+
}
|
|
1134
|
+
[data-aia-option] [data-aia-collage] > img {
|
|
1135
|
+
width: 100%;
|
|
1136
|
+
height: 100%;
|
|
1137
|
+
min-width: 0;
|
|
1138
|
+
min-height: 0;
|
|
1139
|
+
object-fit: cover;
|
|
1140
|
+
}
|
|
1110
1141
|
/* Done spans the panel, whatever the panel's width. */
|
|
1111
1142
|
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *)) [data-aia-multi-done] {
|
|
1112
1143
|
width: var(--aia-multi-done-width, 100%);
|
|
@@ -1317,7 +1348,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1317
1348
|
A bare down chevron at the bottom-centre of the option list, shown while
|
|
1318
1349
|
there is more to scroll to \u2014 no disc, border or shadow around it. It rests
|
|
1319
1350
|
just above the grid's reserved band, or \u2014 when a product strip follows the
|
|
1320
|
-
grid \u2014 centred on the strip's "
|
|
1351
|
+
grid \u2014 centred on the strip's "Items" label row, off the last option row
|
|
1321
1352
|
(--aia-scroll-arrow-bottom is measured and set inline by the controller so
|
|
1322
1353
|
it tracks the layout). It never travels with the scroll: the controller toggles
|
|
1323
1354
|
data-aia-visible and the only thing that transitions is opacity \u2014 a slow,
|
|
@@ -1622,7 +1653,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1622
1653
|
opacity: 1;
|
|
1623
1654
|
}
|
|
1624
1655
|
}
|
|
1625
|
-
`,document.head.appendChild(e)}var
|
|
1656
|
+
`,document.head.appendChild(e)}var ve={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",multiDone:"aia-multiDone-y12U7",multiActionsLoadingOut:"aia-multiActionsLoadingOut-lSdMh",multiActionsFadeIn:"aia-multiActionsFadeIn-zbGTG"};import{cellDay as Ha,cellIso as rt,dateCellMarks as Ba,isDimmedDay as Wa,isoDate as Ga,monthLabel as Ka,visibleDateRange as qa,WEEKDAY_LABELS as _a}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Va}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) ---
|
|
1626
1657
|
|
|
1627
1658
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1628
1659
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1819,7 +1850,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1819
1850
|
opacity: 0.8;
|
|
1820
1851
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1821
1852
|
}
|
|
1822
|
-
`,document.head.appendChild(e)}var
|
|
1853
|
+
`,document.head.appendChild(e)}var G={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",reference:"aia-reference-Q5bXf",pressed:"aia-pressed-bEyyN"};import{jsx as xe,jsxs as Ut}from"react/jsx-runtime";var Ua=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Qt({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:b,onNextMonth:w}){let y=Ga(new Date),m=qa({pendingStart:i.rangeStart,highlightedIso:rt(e[o]),selected:i.selectedRange,floor:i.floor});return Ut("div",{className:G.datepicker,"data-aia-datepicker":"",children:[Ut("div",{className:G.header,children:[xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:b,children:"\u2039"}),xe("span",{className:G.month,"data-aia-date-month":"","aria-live":"polite",children:Ka(a)}),xe("button",{type:"button",tabIndex:-1,className:G.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:w,children:"\u203A"})]}),xe("div",{className:G.weekdays,"aria-hidden":"true",children:_a.map((h,c)=>xe("span",{className:G.weekday,children:h},Ua[c]))}),xe("div",{className:G.grid,"data-aia-date-grid":"",children:e.map((h,c)=>xe(Qa,{option:h,id:`${t}-option-${c}`,index:c,isHighlighted:c===o&&h.is_tappable,isToday:rt(h)===y,isPast:Wa(rt(h),y,i.floor),marks:Ba(rt(h),{selectedIso:i.selectedIso,range:m,references:i.references}),onSelect:s,onHighlight:r,onUnhighlight:l},rt(h)??`pad-${c}`))})]})}function Qa({option:e,id:o,index:t,isHighlighted:a,isToday:i,isPast:s,marks:r,onSelect:l,onHighlight:b,onUnhighlight:w}){let[y,m]=Va(!1),h=Ha(e);if(h==null)return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${G.cell} ${G.blank}`});let c=()=>{m(!0),l(e),setTimeout(()=>m(!1),170)},v=[G.cell,G.day,s?G.past:"",a?G.highlighted:"",i?G.today:"",r.inRange?G.inRange:"",r.selected?G.selected:"",r.reference?G.reference:"",y?G.pressed:""].filter(Boolean).join(" ");return xe("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:v,onClick:c,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),c())},onMouseEnter:()=>b(t),onMouseLeave:w?()=>w(t):void 0,children:xe("span",{className:G.number,children:h})})}import{ATTRIBUTION_URL as Ya,buildAttributionUrl as ja,getFooterHint as $a,uiStringsFor as Za}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Xa,useState as Ja}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1823
1854
|
display: flex;
|
|
1824
1855
|
flex-wrap: wrap;
|
|
1825
1856
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1859,7 +1890,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1859
1890
|
.aia-cluster[data-justify="around"] {
|
|
1860
1891
|
justify-content: space-around;
|
|
1861
1892
|
}
|
|
1862
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1893
|
+
`,document.head.appendChild(e)}import{jsx as Yt}from"react/jsx-runtime";function st({gap:e,align:o="center",justify:t="start",noWrap:a=!1,inline:i=!1,className:s,children:r,...l}){let b=e?{"--aia-cluster-gap":e}:void 0,w={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":a||void 0,"data-inline":i||void 0,style:b,...l};return i?Yt("span",{...w,children:r}):Yt("div",{...w,children:r})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1863
1894
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1864
1895
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1865
1896
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -2006,7 +2037,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2006
2037
|
justify-content: flex-end;
|
|
2007
2038
|
}
|
|
2008
2039
|
}
|
|
2009
|
-
`,document.head.appendChild(e)}var
|
|
2040
|
+
`,document.head.appendChild(e)}var Ie={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as lt,jsxs as kt}from"react/jsx-runtime";function jt({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=Za()}){let{key:a,hint:i}=$a(e,o,t),[s,r]=Ja(Ya);return Xa(()=>{r(ja())},[]),lt("footer",{className:Ie.footer,"data-aia-footer":"",children:kt(st,{justify:"between",noWrap:!0,className:Ie.row,children:[kt(st,{gap:"5px",className:Ie.hintGroup,children:[lt("kbd",{className:Ie.key,children:a}),lt("span",{className:Ie.hint,children:i})]}),kt("a",{className:Ie.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[lt("span",{className:Ie.brand,children:"AI"}),lt("span",{className:Ie.badge,children:"Autocomplete"})]})]})})}import{useEffect as $t,useLayoutEffect as ei,useRef as ce}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
|
|
2010
2041
|
Angular copy). The three are kept identical by
|
|
2011
2042
|
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
2012
2043
|
.aia-location-6-fsr {
|
|
@@ -2140,7 +2171,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2140
2171
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
2141
2172
|
width: 60%;
|
|
2142
2173
|
}
|
|
2143
|
-
`,document.head.appendChild(e)}var
|
|
2174
|
+
`,document.head.appendChild(e)}var V={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};import{jsx as ne,jsxs as De}from"react/jsx-runtime";var ti=0;function dt(e){return e.getRootNode().activeElement??null}function Jt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Zt(e){if(!e.isContentEditable)return null;let o=Jt(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Xt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Jt(e);if(!t)return;let a=o;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var ai=De("svg",{className:V.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ne("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),ne("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),ii=De("svg",{className:V.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[ne("circle",{cx:"11",cy:"11",r:"7"}),ne("path",{d:"m20 20-3.5-3.5"})]});function ea({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:b,onMove:w,onCommit:y,onFocusChange:m}){let h=ce(null),c=ce(null),v=ce(null),E=ce(null),K=ce(null),D=ce(!1),R=ce(!1),ee=ce(!1),P=ce(!1),z=ce(i);z.current=i;let q=ce(m);q.current=m;let N=d=>{P.current=d,m(d)},Q=()=>{let d=h.current;return d!=null&&dt(d)===d},A=()=>{let d=c.current;if(!d)return;let T=dt(d);T instanceof HTMLElement&&T!==h.current&&T!==document.body&&!d.contains(T)&&(E.current=T,K.current=Zt(T))},$=d=>{let T=c.current;!T||!(d instanceof HTMLElement)||d===E.current||d===document.body||T.contains(d)||(E.current=d,K.current=Zt(d))},W=ce(null);W.current===null&&(W.current=`aia-location-${++ti}`);let F=`${W.current}-row-`;$t(()=>{let d=h.current;d&&d.value!==e.query&&dt(d)!==d&&(d.value=e.query)},[e.query]),$t(()=>{i&&(s&&!ee.current&&(R.current=!1),ee.current=s);let d=h.current;if(d){if(!r&&Q()){R.current=!0,Y();return}if(!i){setTimeout(()=>{if(z.current)return;let T=E.current;T&&dt(T)===T||(R.current=!1)},0);return}if(!(!s||R.current||!l||Q())){if(A(),N(!0),d.focus({preventScroll:!0}),!Q()){R.current=!0,N(!1);return}d.value&&d.select()}}}),ei(()=>()=>{if(!P.current)return;let d=h.current,T=E.current;T?.isConnected&&d&&dt(d)===d&&(D.current=!0,Xt(T,K.current),D.current=!1),P.current=!1,q.current(!1)},[]);let Y=(d=!1)=>{d&&(R.current=!0);let T=E.current;T?.isConnected&&Q()&&(D.current=!0,Xt(T,K.current),D.current=!1),N(!1)},re=e.query.trim(),S=e.highlighted>=0&&e.highlighted<e.places.length?`${F}${e.highlighted}`:void 0,H=null;return e.places.length>0?H=e.places.map((d,T)=>De("div",{id:`${F}${T}`,role:"option","aria-selected":T===e.highlighted,className:T===e.highlighted?`${V.row} ${V.highlighted}`:V.row,"data-aia-location-row":"","data-aia-index":T,onClick:()=>{l&&(Y(!0),y(T))},children:[ne("span",{className:V.pin,children:ai}),De("span",{className:V.text,children:[ne("span",{className:V.name,children:d.name}),d.secondary&&ne("span",{className:V.secondary,children:d.secondary})]})]},d.id)):e.status==="loading"?H=De("div",{className:V.loading,"data-aia-location-loading":"",children:[ne("span",{className:V.loadingBar}),ne("span",{className:V.loadingBar}),ne("span",{className:V.loadingBar})]}):re&&(H=De("div",{className:V.note,"data-aia-location-note":"",children:[e.status==="done"&&ne("span",{className:V.empty,children:t}),ne("span",{children:a})]})),De("div",{ref:c,className:V.location,"data-aia-location":"",onMouseDown:d=>{!(d.target instanceof Node)||!v.current?.contains(d.target)||(d.stopPropagation(),A(),N(!0))},children:[De("label",{ref:v,className:V.field,children:[ii,ne("input",{ref:h,type:"text",className:V.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:o,"aria-label":o,"aria-activedescendant":S,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:d=>b(d.target.value),onFocus:d=>{$(d.relatedTarget),N(!0)},onBlur:()=>{D.current||(R.current=!0,N(!1))},onKeyDown:d=>{if(!d.nativeEvent.isComposing)switch(d.key){case"ArrowDown":case"ArrowUp":d.preventDefault(),w(d.key==="ArrowDown"?1:-1);return;case"Enter":if(d.preventDefault(),!l)return;Y(!0),y();return;case"Escape":d.preventDefault(),d.stopPropagation(),R.current=!0,Y();return;case"Backspace":if(d.currentTarget.value!=="")return;d.preventDefault(),R.current=!0,Y();return}}})]}),ne("div",{className:V.results,"data-aia-location-results":"","aria-live":"polite",children:H})]})}import{isSmartSuggestion as si,isTraditionalAutocompleteSuggestion as li}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as oi}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
2144
2175
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
2145
2176
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
2146
2177
|
as it was when the outline was dashed. */
|
|
@@ -2298,7 +2329,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2298
2329
|
opacity: 0;
|
|
2299
2330
|
}
|
|
2300
2331
|
}
|
|
2301
|
-
`,document.head.appendChild(e)}var
|
|
2332
|
+
`,document.head.appendChild(e)}var ye={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",loadingOut:"aia-loadingOut-Aj9xO"};import{Fragment as ni,jsx as Ct,jsxs as ri}from"react/jsx-runtime";var St={selected:1,first:.7,next:.4,last:.2};function ta({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let b=[ye.pill,a?ye.rounded:"",i?ye.skeleton:""].filter(Boolean).join(" ");return Ct("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":i?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:b,style:{"--aia-pill-opacity":St[o]},onMouseDown:w=>w.preventDefault(),onClick:i?void 0:l,disabled:i,children:s?ri(ni,{children:[Ct("span",{className:`${ye.smartText} magicx-aia-smart-suggestion-text`,children:e}),Ct("span",{className:`${ye.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:oi}})]}):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 {
|
|
2302
2333
|
position: relative;
|
|
2303
2334
|
z-index: 1;
|
|
2304
2335
|
pointer-events: auto;
|
|
@@ -2308,7 +2339,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2308
2339
|
align-items: center;
|
|
2309
2340
|
vertical-align: middle;
|
|
2310
2341
|
}
|
|
2311
|
-
`,document.head.appendChild(e)}var
|
|
2342
|
+
`,document.head.appendChild(e)}var Tt={list:"aia-list-qvLqO"};import{jsx as ut}from"react/jsx-runtime";var di=[125,69];function aa(e){return e===0?"first":e===1?"next":"last"}function mt({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?ut("span",{className:Tt.list,"data-aia-pill-list-loading":"",children:di.map((r,l)=>ut("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${i?ye.rounded:""} ${ye.skeleton}`,style:{width:r,"--aia-pill-opacity":St[aa(l)]}},`skel-${r}`))}):ut("span",{className:Tt.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let b=!!a&&l===o;return ut(ta,{label:r.text,state:b?"selected":aa(l),selected:b,active:l===o,rounded:i,loading:s,smartSuggestion:si(r),completionHeader:li(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}import{attachProductRowWheel as ci,productImageSources as pi,productImageSrc as hi,productInitial as ui,productPhotoFill as mi,uiStringsFor as gi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pt,useRef as gt,useState as ft}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
|
|
2312
2343
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
2313
2344
|
theming one package sees the same result in the other.
|
|
2314
2345
|
|
|
@@ -2901,7 +2932,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2901
2932
|
opacity: 0.01;
|
|
2902
2933
|
}
|
|
2903
2934
|
}
|
|
2904
|
-
`,document.head.appendChild(e)}var
|
|
2935
|
+
`,document.head.appendChild(e)}var U={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr",stripLoadingOut:"aia-stripLoadingOut-0jOOQ",stripFadeIn:"aia-stripFadeIn-0p9qx"};import{jsx as X,jsxs as Ze}from"react/jsx-runtime";function ia({products:e,listboxId:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s=!0,loading:r=!1,layout:l="row",imageFallback:b="image",strings:w=gi()}){let y=e.length>0,m=gt(null);if(Pt(()=>{let c=m.current;if(!(!y||!c))return ci(c)},[y]),!y)return null;let h=`${o}-products-label`;return Ze("section",{className:U.section,"data-aia-products":"","data-aia-loading":r?"":void 0,"data-aia-products-layout":l,role:"group","aria-labelledby":h,children:[X("div",{className:U.label,id:h,"data-aia-products-label":"",children:w.products}),X("div",{ref:m,className:U.row,"data-aia-products-row":"",children:e.map((c,v)=>X(fi,{product:c,id:`${o}-product-${v}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:b,soldOut:w.soldOut,addToCart:w.addToCart},c.id))})]})}function fi({product:e,id:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:r,soldOut:l,addToCart:b}){let w=!!a&&e.available!==!1,[y,m]=ft(null),h=v=>{v.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},c=v=>{v.metaKey||v.ctrlKey||v.shiftKey||v.altKey||v.button!==0||(v.preventDefault(),t(e))};return Ze("a",{id:o,className:U.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":w?"":void 0,role:"option","aria-selected":!1,style:y?{"--aia-product-photo-fill-x":String(y.x),"--aia-product-photo-fill-y":String(y.y)}:void 0,href:e.url,tabIndex:s?0:-1,onClick:c,onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:h,children:[X(vi,{sources:pi(e.imageUrl),title:e.title,fallback:r,onPhotoFill:m},hi(e.imageUrl)??""),Ze("span",{className:U.body,children:[e.vendor?X("span",{className:U.vendor,children:e.vendor}):null,X("span",{className:U.title,children:e.title}),e.price?Ze("span",{className:U.price,children:[e.price,e.compareAtPrice?X("s",{className:U.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?X("span",{className:U.badge,children:l}):null]}),w&&a?X(wi,{product:e,label:`${b}: ${e.title}`,focusable:s,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:h},bi(e)):null]})}function bi(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(o=>o??"").join("\0")}function wi({product:e,label:o,focusable:t,onAddToCart:a,onFocus:i,onBlur:s}){let[r,l]=ft(null),b=gt(null),w=gt(e);w.current=e;let y=gt(!0);Pt(()=>(y.current=!0,()=>{y.current=!1}),[]);let m=c=>{b.current=c,y.current&&l(c)},h=c=>{if(c.preventDefault(),c.stopPropagation(),b.current==="adding")return;m("adding");let v;try{v=Promise.resolve(a(w.current))}catch(E){v=Promise.reject(E)}v.then(()=>m("added"),()=>m(null))};return X("span",{className:U.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":o,tabIndex:t?0:-1,onClick:h,onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||h(c)},onFocus:c=>{c.stopPropagation(),i()},onBlur:c=>{c.stopPropagation(),s(c)},children:Ze("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[X("path",{className:U.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),X("path",{className:U.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),X("path",{className:U.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),X("path",{className:U.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),X("circle",{className:U.cartGlyph,cx:"9",cy:"20",r:"1.3"}),X("circle",{className:U.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function vi({sources:e,title:o,fallback:t,onPhotoFill:a}){let[i,s]=ft(0),r=e[i],l=!!r,[b,w]=ft(null),y=!l&&t==="initial";return Pt(()=>()=>a(null),[a]),Ze("span",{className:U.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&b===r?"":void 0,children:[l?X("img",{className:U.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:m=>{w(r),a(mi(m.currentTarget.naturalWidth,m.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),s(m=>m+1)}}):null,y?ui(o):null]})}import{isOptionsGridMobileViewport as zi,measureOptionsGrid as Di,needsOptionsGridMeasurement as Mi,OPTIONS_GRID_MOBILE_QUERY as Ni,optionEnterDelayMs as Fi,optionsShowLeadingVisuals as Hi,planOptionsGrid as la,releasePanelHug as Bi,sameOptionRows as Wi,syncPanelHug as Gi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ki,useLayoutEffect as da,useRef as ca,useState as ha}from"react";import{optionsGridTemplateColumns as xi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as yi,useRef as ki}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 {
|
|
2905
2936
|
display: grid;
|
|
2906
2937
|
grid-template-columns: repeat(
|
|
2907
2938
|
auto-fit,
|
|
@@ -2945,7 +2976,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2945
2976
|
:where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
|
|
2946
2977
|
max-height: var(--aia-grid-max-height, 120px);
|
|
2947
2978
|
}
|
|
2948
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2979
|
+
`,document.head.appendChild(e)}import{jsx as Ci}from"react/jsx-runtime";function oa({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:b,className:w,children:y,...m}){let h=ki(null);yi(()=>{if(s===void 0)return;let v=h.current;v&&(v.scrollTop=0)},[s]);let c={"--aia-grid-min":e};return o&&(c["--aia-grid-max"]=o),t&&(c["--aia-grid-gap"]=t),i&&(c["--aia-grid-max-height"]=i),r&&(c.gridTemplateColumns=xi(r)),l&&(c.gridTemplateColumns=l),Ci("div",{ref:v=>{h.current=v,b?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:c,...m,children:y})}import{formatOptionCount as Si,highlightParts as Ti,isMultiSelectToggleTap as Pi,OPTION_ENTER_DELAY_VAR as Ii,optionImageSources as na,optionLabel as ra,sanitizeOptionIconSvg as Ei}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ai,useMemo as Oi,useRef as Ri,useState as ct}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 {
|
|
2949
2980
|
position: relative;
|
|
2950
2981
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2951
2982
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -3465,7 +3496,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3465
3496
|
border-radius: 6px;
|
|
3466
3497
|
font-size: 11px;
|
|
3467
3498
|
}
|
|
3468
|
-
`,document.head.appendChild(e)}var
|
|
3499
|
+
`,document.head.appendChild(e)}var j={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",loadingOut:"aia-loadingOut-hI-qI",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",text:"aia-text-yqoh9",checkbox:"aia-checkbox-KGRhg"};import{Fragment as Li,jsx as ue,jsxs as It}from"react/jsx-runtime";function sa({option:e,isHighlighted:o,checked:t,onSelect:a,onHighlight:i,onUnhighlight:s,id:r,loading:l,showIcon:b=!0,showImage:w=!0,showCount:y=!0,scrollHint:m,enterDelayMs:h=0}){let[c]=ct(h),[v,E]=ct(!1),K=w?na(e.image_url):[],D=K[0]??null,[R,ee]=ct([]),P=K.find(S=>!R.includes(S))??null,z=w?(e.imageCollage??[]).map(S=>na(S)[0]).filter(S=>S!==void 0):[],[q,N]=ct(!1),[Q,A]=ct(null),$=Oi(()=>!D&&b&&e.icon_svg?Ei(e.icon_svg):null,[D,b,e.icon_svg]),W=y?Si(e.item_count):null,F=Ri(void 0);Ai(()=>()=>clearTimeout(F.current),[]);let Y=S=>{if(l||!e.is_tappable||v&&t===void 0)return;E(!0);let H=S?.currentTarget;t!==void 0&&H!==void 0&&S!==void 0&&!Pi(H,H.querySelector("[data-aia-checkbox]"),S)?a(e,{commit:!0}):a(e),clearTimeout(F.current),F.current=setTimeout(()=>E(!1),170)},re=[j.item,o&&!l?j.highlighted:"",e.liveMatch&&!l?j.liveMatch:"",e.is_tappable?j.tappable:j.nonTappable,v?j.pressed:"",m?j.scrollHint:""].filter(Boolean).join(" ");return ue("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":$&&e.icon?e.icon:void 0,"data-aia-image":D?"":void 0,"data-aia-item-count":W!==null?e.item_count:void 0,"aria-selected":t??o,className:re,style:{[Ii]:`${c}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:Y,onKeyDown:S=>{!l&&e.is_tappable&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),Y())},onMouseEnter:!l&&e.is_tappable?i:void 0,onMouseLeave:s,children:It("span",{className:j.content,children:[t!==void 0&&e.is_tappable&&ue("span",{className:j.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),D&&z.length>1&&ue("span",{className:`${j.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-collage":z.length,"data-aia-image-loaded":q?"":void 0,children:z.map(S=>ue("img",{src:S,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onLoad:()=>N(!0),onError:H=>{H.currentTarget.hidden=!0}},S))}),D&&z.length<=1&&ue("span",{className:`${j.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":P!==null&&Q===P?"":void 0,children:ue("img",{src:P??D,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:P===null,onLoad:()=>A(P),onError:()=>{P!==null&&ee(S=>[...S,P])}})}),$&&ue("span",{className:`${j.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:$}}),It("span",{className:j.text,children:[e.matchedText?Ti(ra(e),e.matchedText).map((S,H)=>S.bold?ue("strong",{className:`${j.match} magicx-aia-option-match`,children:S.text},H):S.text):ra(e),e.parameterLabel&&It(Li,{children:[" ",ue("span",{className:`${j.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&ue("span",{className:j.tag,children:e.tag}),W!==null&&ue("span",{className:`${j.count} magicx-aia-option-count`,children:W})]})})}import{jsx as pa}from"react/jsx-runtime";function qi(){let[e,o]=ha(zi);return Ki(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ni),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function ua({options:e,activeIndex:o,picked:t,onSelect:a,onHighlight:i,onUnhighlight:s,listboxId:r,loading:l,groupKey:b="",optionsPosition:w="below",showIcons:y=!0,showImages:m=!0,showCounts:h=!0}){let c=qi(),v=ca(null),[E,K]=ha(null),D=ca(null);da(()=>{if(l&&Wi(D.current,e))return;D.current=l?null:e;let P=v.current,z=P&&!l&&Mi(e.length,c),q=P?.closest("[data-aia-dropdown]");z&&q&&Bi(q);let N=z?Di(P):null;K(N?la(e.length,c,N.rowWidths,N.gridWidth):null)},[e,c,l]);let R=E??la(e.length,c,null,null);da(()=>{let P=v.current?.closest("[data-aia-dropdown]");P&&Gi(P)},[R.template,c]);let ee=Hi(e,y,m);return pa(oa,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:b,template:R.template,maxHeight:R.maxHeight,innerRef:P=>{v.current=P},"data-aia-group":b,children:e.map((P,z)=>pa(sa,{option:P,isHighlighted:z===o,checked:t?t.includes(P.text):void 0,onSelect:a,onHighlight:()=>i(z),onUnhighlight:s?()=>s(z):void 0,id:`${r}-option-${z}`,loading:l,showIcon:y&&ee,showImage:m&&ee,showCount:h,scrollHint:!l&&R.scrollHintIndices.includes(z),enterDelayMs:l?0:Fi(z,R.cols,e.length,w)},`${b}\0${P.parameter??""}\0${P.text}`))})}import{formatTime as _i,TIME_WHEEL_COLUMNS as Vi,TIME_WHEEL_ROW_HEIGHT as Ui,timeWheelIndex as ma,timeWheelIndexFromScroll as Qi,timeWheelRows as Yi,withTimeWheelIndex as ga}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as ji,useEffect as $i,useLayoutEffect as Zi,useRef as bt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
|
|
3469
3500
|
|
|
3470
3501
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
3471
3502
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3587,7 +3618,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3587
3618
|
.aia-done-llNY5:hover {
|
|
3588
3619
|
background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
|
|
3589
3620
|
}
|
|
3590
|
-
`,document.head.appendChild(e)}var
|
|
3621
|
+
`,document.head.appendChild(e)}var me={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};import{jsx as qe,jsxs as Et}from"react/jsx-runtime";var Xi=120;function fa({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return Et("div",{className:me.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[qe("span",{className:me.value,"data-aia-time-value":"","aria-live":"polite",children:_i(e.minutes)}),Et("div",{className:me.columns,"aria-hidden":"true",children:[qe("div",{className:me.band}),Vi.map(r=>Et(ji,{children:[r==="minute"&&qe("span",{className:me.separator,children:":"}),qe(Ji,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),qe("button",{type:"button",tabIndex:-1,className:me.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function Ji({column:e,minutes:o,interactive:t,onTimeChange:a}){let i=bt(null),s=bt(null),r=bt(null),l=bt({minutes:o,interactive:t,onTimeChange:a});l.current={minutes:o,interactive:t,onTimeChange:a};let b=ma(e,o);Zi(()=>{let m=i.current;if(!m||r.current)return;let h=b*Ui;Math.abs(m.scrollTop-h)<1||(s.current=h,m.scrollTop=h)},[b]),$i(()=>()=>{r.current&&clearTimeout(r.current)},[]);let w=()=>{r.current=null;let m=i.current,h=l.current;if(!m||!h.interactive)return;let c=Qi(e,m.scrollTop);c!==ma(e,h.minutes)&&h.onTimeChange(ga(e,h.minutes,c))},y=()=>{let m=i.current;if(m){if(s.current!=null&&Math.abs(m.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(w,Xi)}};return qe("div",{ref:i,className:me.column,"data-aia-time-column":e,onScroll:y,children:Yi(e).map((m,h)=>qe("div",{className:h===b?`${me.row} ${me.selected}`:me.row,"data-aia-time-row":"","data-aia-index":h,onClick:()=>{l.current.interactive&&a(ga(e,l.current.minutes,h))},children:m.label},m.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3591
3622
|
display: flex;
|
|
3592
3623
|
flex-direction: column;
|
|
3593
3624
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3602,7 +3633,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3602
3633
|
align-items: end;
|
|
3603
3634
|
}
|
|
3604
3635
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3605
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
3636
|
+
`,document.head.appendChild(e)}import{jsx as eo}from"react/jsx-runtime";function ba({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return eo("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as ae,jsxs as At}from"react/jsx-runtime";var wo=typeof window>"u"?_e:Ot,vo=[159,119,164],xo=()=>{},wa=()=>{},yo=e=>{},ko=()=>{},Co=e=>{},So=e=>{},To=e=>{},Po=e=>{};function Io(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=bo(o);if(_e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>a(i.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Eo(e,o){let t=Xe(null);_e(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=uo(a,".aia-grid[data-scroll]");if(t.current&&t.current.grid!==s&&(t.current.controller.destroy(),t.current=null),s&&!t.current){t.current={grid:s,controller:to({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),_e(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ao(e,o){let t=Xe(o);t.current=o;let a=Xe(null);Ot(()=>{let i=e.current;if(i){if(!a.current){a.current=ao({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),_e(()=>()=>{a.current?.destroy(),a.current=null},[])}function Rt({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:b,onPillClick:w,showPills:y=!0,onSkip:m,showSkipButton:h=!0,showOptionIcons:c=!0,showOptionImages:v=!0,showOptionCounts:E=!0,skipDisabled:K=!1,activeSelected:D=!1,isLoading:R=!1,skeletonExiting:ee=!1,isInputEmpty:P=!1,language:z,products:q,onProductSelect:N,onProductAddToCart:Q,onProductFocusChange:A,productsLayout:$="row",productImageFallback:W="image",formatType:F="options",dateView:Y=null,selectedDateIso:re=null,selectedDateRange:S=null,dateRangeStart:H=null,dateReferences:d,onPreviousMonth:T,onNextMonth:Me,timeView:ke=null,multiSelectView:g=null,onMultiSelectCommit:Ne,onTimeChange:Ee,onTimeCommit:Ae,locationView:Ce=null,isReediting:Oe=!1,onLocationQuery:u,onLocationMove:C,onLocationCommit:I,onLocationFocusChange:O,isFocused:L=!1,optionsPosition:_="below",mode:se}){let le=Io(se),Re=le!==void 0,te=Xe(null),de=Xe(null);Eo(te,de),_e(()=>{if(te.current)return io(te.current)},[]);let Ve=e[0]?.options??[],Fe=!!(b&&b.length>0&&w),He=!!(q&&q.length>0),Le=F==="time"&&ke!=null,Be=F==="location"&&Ce!=null,ie=s&&(Ve.length>0||y&&Fe||R||He||Le||Be);Ao(te,ie),wo(()=>{let k=te.current;k&&(so(k,ro(k)),go(k))});let pe={suggestions:e,activeIndex:o,pills:b,showPills:y,showSkipButton:h,showOptionIcons:c,showOptionImages:v,showOptionCounts:E,skipDisabled:K,activeSelected:D,isLoading:R,skeletonExiting:ee,isInputEmpty:P,products:q,formatType:F,dateView:Y,selectedDateIso:re,selectedDateRange:S,dateRangeStart:H,dateReferences:d,timeView:ke,multiSelectView:g,locationView:Ce,isReediting:Oe},x=Xe(pe);ie&&(x.current=pe);let n=ie?pe:x.current,Z=fo(z),fe=n.suggestions[0],f=fe?.options??[],Ue=n.activeIndex>=0&&!!f[n.activeIndex]?.is_tappable,he=po(n.pills??[],Z.keepTyping),be=!!(he.length>0&&w),We=n.showPills&&be,Qe=n.showPills&&!be&&n.isLoading,Se=We||Qe,Ye=be&&lo(he)&&n.showSkipButton&&!n.isInputEmpty&&!!m,Te=he[0]?.text,we=co(n.formatType)&&n.dateView!=null,ze=f.length>0&&!we,Ge=f.length>0&&we&&!n.isLoading,je=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,Pe=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,$e=n.isLoading&&!ze&&!Ge&&!je&&!Pe,p=n.products??[],B=ho(We?he:[]);return Ot(()=>{te.current&&mo(te.current,B,{visible:ie,anchorBottom:_==="above"})},[B,ie,_,n.suggestions,n.pills,n.isLoading,n.skeletonExiting,n.isInputEmpty,n.products,n.formatType,n.dateView,n.selectedDateIso,n.selectedDateRange,n.dateRangeStart,n.dateReferences,n.timeView,n.multiSelectView,n.locationView,n.showPills,n.showSkipButton,n.showOptionIcons,n.showOptionImages,n.showOptionCounts,$,z]),_e(()=>{let k=te.current;return()=>{k&&no(k)}},[]),At("div",{ref:te,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":_,"data-mode":le,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":p.length>0?"":void 0,className:`${Re?"magicx-aia ":""}${ve.dropdown} ${ie?ve.visible:""} ${l??""}`,onMouseDown:k=>k.preventDefault(),children:[At(ba,{space:"8px",children:[(Se||Ye)&&At(st,{noWrap:!0,className:ve.pillBar,"data-aia-pillbar":"",children:[Se&&ae("span",{className:ve.pillScroll,"data-aia-pill-scroll":"",children:ae(mt,{pills:he,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:n.isLoading})}),Ye&&ae("button",{type:"button",tabIndex:-1,className:ve.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":Te?`${Z.skipLabel} ${Te}`:Z.skipLabel,onClick:m,children:Z.skip})]}),ze&&ae(ua,{options:f,activeIndex:n.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:r,loading:n.isLoading,groupKey:fe?`${fe.parameter} ${fe.text}`:"",optionsPosition:_,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.multiSelectView?.picked}),n.multiSelectView&&ae("div",{"data-aia-multi-actions":"",onClick:k=>{k.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&!n.isLoading&&Ne?.()},children:ae("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:ve.multiDone,ref:k=>{k&&(k.disabled=!0,k.offsetHeight,k.disabled=n.skipDisabled||n.isLoading)},children:Z.done})}),Ge&&n.dateView&&ae(Qt,{options:f,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:oo(n.formatType,n.dateRangeStart),references:n.dateReferences??[]},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:T??wa,onNextMonth:Me??wa}),je&&n.timeView&&ae(fa,{view:n.timeView,label:Z.timeLabel,doneLabel:Z.done,interactive:!n.skipDisabled,onTimeChange:Ee??yo,onTimeCommit:Ae??ko}),Pe&&n.locationView&&ae(ea,{view:n.locationView,searchLabel:Z.locationSearch,noResultsLabel:Z.locationNoResults,useTypedLabel:Z.locationUseTyped,widgetFocused:L&&ie,reediting:n.isReediting,visible:ie,interactive:!n.skipDisabled,onQuery:u??Co,onMove:C??So,onCommit:I??To,onFocusChange:O??Po}),$e&&ae("div",{className:ve.skeletonBars,"data-aia-skeleton-bars":"",children:vo.map(k=>ae("span",{className:ve.skeletonBar,style:{width:k}},`bar-${k}`))}),ae(ia,{products:p,listboxId:r,onSelect:N??xo,onAddToCart:Q,onFocusChange:A,focusable:ie&&!n.isLoading,loading:n.isLoading,layout:$,imageFallback:W,strings:Z}),ae(jt,{isOptionHighlighted:Ue,isInputEmpty:n.isInputEmpty,strings:Z})]}),ae("button",{ref:de,type:"button",tabIndex:-1,className:ve.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Z.scrollArrow,"aria-hidden":"true",children:ae("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:ae("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as jo,ModeController as $o,setCursorOffset as Zo,uiStringsFor as Xo,watchEditorHeight as Jo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Oo}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 {
|
|
3606
3637
|
flex-shrink: 0;
|
|
3607
3638
|
width: 32px;
|
|
3608
3639
|
height: 32px;
|
|
@@ -3673,5 +3704,5 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3673
3704
|
transition: none;
|
|
3674
3705
|
}
|
|
3675
3706
|
}
|
|
3676
|
-
`,document.head.appendChild(e)}var ba={submitButton:"aia-submitButton-otz7H"};import{jsx as Rt}from"react/jsx-runtime";function wa({disabled:e,ready:o,onClick:t,label:a=Ao().submit}){return Rt("button",{type:"button","data-aia-submit":"",className:ba.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Rt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Rt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Oo,dateSelectionFor as Ro,identifiedParamLabel as Lo,withoutTraditionalAutocomplete as zo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ca,useEffect as Je,useMemo as Do,useRef as ee,useState as Mo}from"react";import{useRef as va}from"react";function xa(e){let o=va(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=va({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,f,w)=>{let y=o.current?.[s];return y?y(l,f,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as ya}from"react";function ka(e){let o=ya(e);o.current=e;let t=ya(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Sa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,dropdownMultiSelect:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function Lt({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:f,productId:w,visitorId:y,columns:g=2,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showOptionIcons:O,showOptionImages:te,showOptionCounts:S,showSkipButton:M,showProducts:H,productImageFallback:N="image",onFocus:B,onBlur:T,value:V,completedParams:Y,onChange:E,onParamsChange:K,products:de,mapProducts:ae,onProductSelect:re,onProductAddToCart:d,source:P,setCursor:Te}){let m=ee(null),[Me,Pe]=Mo(null),Ie=ee(e);Ie.current=e;let Ee=ee(o);Ee.current=o;let ye=ee(t);ye.current=t;let Ae=ee(E);Ae.current=E;let u=ee(K);u.current=K;let k=ee(B);k.current=B;let C=ee(T);C.current=T;let A=ee(Te);A.current=Te;let R=ee(re);R.current=re;let W=ee(d);W.current=d;let ce=ee(y);ce.current=y;let pe=ee(()=>{let p=ce.current;return typeof p=="function"?p():p}).current,ge=ka(de),j=ee(ae);j.current=ae;let Ne=ee((p,G)=>{let L=j.current;return L?L(p,G):p}).current,Fe=ae?Ne:void 0,He=xa(a);Je(()=>{if(typeof document>"u")return;let p=new Oo(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:f,productId:w,visitorId:pe,optionOverrides:He.overrides,maskCompletedText:i,columns:g,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:H,source:P,value:V,completedParams:Y,onSubmit:(...L)=>Ie.current?.(...L),onResult:(...L)=>Ee.current?.(...L),onError:(...L)=>ye.current?.(...L),onChange:(...L)=>Ae.current?.(...L),onParamsChange:(...L)=>u.current?.(...L),onFocus:()=>k.current?.(),onBlur:()=>C.current?.(),onProductSelect:L=>R.current?.(L),onProductAddToCart:L=>W.current?.(L),setCursor:L=>A.current?.(L),products:ge.config,mapProducts:Fe});m.current=p,Pe(p.getState());let G=p.subscribe(L=>Pe(L));return()=>{G(),p.destroy(),m.current===p&&(m.current=null)}},[]),Je(()=>{V!==void 0&&m.current?.setValue(V)},[V]),Je(()=>{Y!==void 0&&m.current?.setCompletedParams(Y)},[Y]);let Oe=JSON.stringify(s??null),Be;try{Be=JSON.stringify(r??null)}catch{Be="[unstringifiable]"}Je(()=>{m.current?.update({apiConfig:s,additionalContext:r,language:l,currency:f,productId:w,optionOverrides:He.overrides,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:H})},[Oe,Be,l,f?.code,f?.rate,f?.country,w,He.key,h,c,v,I,_,z,H]);let We=ee(!1);Je(()=>{if(!We.current){We.current=!0;return}m.current?.update({products:ge.config})},[ge.enabled]),Je(()=>{m.current?.update({mapProducts:Fe})},[Fe]);let Z=ee(null);Z.current===null&&(Z.current={handleTextChange:p=>m.current?.handleTextChange(p),handleKeyDown:p=>{let G="nativeEvent"in p?p.nativeEvent:p;m.current?.handleKeyDown(G)},setFocused:p=>m.current?.setFocused(p),startEditingParam:p=>m.current?.startEditingParam(p),removeParam:p=>m.current?.removeParam(p)??!1,exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:p=>m.current?.handleCaretAfterInput(p),handleCaretMove:p=>m.current?.handleCaretMove(p),replaceEditingRange:p=>m.current?.replaceEditingRange(p)??!1,setActivePill:p=>m.current?.setActivePill(p),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),prepareSubmit:()=>m.current?.prepareSubmit(),getState:()=>m.current?.getState()??Sa,recordSubmit:p=>m.current?.recordSubmit(p),selectOption:(p,G)=>m.current?.selectOption(p,G),selectProduct:p=>m.current?.selectProduct(p),addProductToCart:p=>{let G=m.current;return!G||!W.current?Promise.resolve():G.addProductToCart(p)},setActiveDropdownIndex:p=>m.current?.setActiveDropdownIndex(p),clearHighlight:p=>m.current?.clearHighlight(p),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),setTime:p=>m.current?.setTime(p),commitTime:()=>m.current?.commitTime(),toggleMultiSelectOption:p=>m.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>m.current?.commitMultiSelect(),setLocationQuery:p=>m.current?.setLocationQuery(p),moveLocationHighlight:p=>m.current?.moveLocationHighlight(p),commitLocation:p=>m.current?.commitLocation(p),setLocationFieldFocused:p=>m.current?.setLocationFieldFocused(p),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let x=Z.current,Ge=Ca(p=>{let G=p.target.value,F=G.length>0&&!p.nativeEvent?.isComposing&&G[0]!==G[0].toUpperCase()?G[0].toUpperCase()+G.slice(1):G;m.current?.handleTextChange(F)},[]),n=Ca(p=>{m.current?.handleKeyDown(p.nativeEvent)},[]),$=m.current,b=Me??Sa,fe=V!==void 0?V:b.text,Ke=Y!==void 0?Y:b.completedParams,se=b.actionableSuggestions,Re=se[0],qe=Do(()=>zo(se),[se]),Le=$?.listboxId??"",je=b.activeDropdownIndex>=0&&$?`${Le}-option-${b.activeDropdownIndex}`:void 0,he=b.editingParam,be=b.editingIdentified,ze=he?{parameter:he.suggestionParameter,text:he.suggestionPlaceholder,required:!0,options:he.options}:be?{parameter:be.parameter,text:Lo(be.parameter),required:!0,options:[]}:null,_e=b.dropdownSuggestion??ze??Re,$e=ze?[ze]:se,ke=Ro(b),Ve=!$||b.dropdownLoading;return{completedParams:Ke,multiSelectView:b.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:qe,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:x.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:Ve,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:Le,error:b.error,products:b.products,customFields:b.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:he,editingIdentified:be,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:x.startEditingParam,removeParam:x.removeParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:fe,placeholder:b.placeholderText||void 0,onChange:Ge,onKeyDown:n,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":je,"aria-autocomplete":"list","aria-controls":Le},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:_e?[{..._e,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:b.isDropdownOpen,id:Le,pills:$e,activeSelected:b.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(M??!0)&&!he&&!be,showOptionIcons:O??!0,showOptionImages:te??!0,showOptionCounts:S??!0,skipDisabled:b.inSelectionAnimation,isLoading:Ve,skeletonExiting:b.skeletonExiting,isInputEmpty:fe.trim().length===0,language:l,products:b.products,productImageFallback:N,onProductSelect:x.selectProduct,onProductAddToCart:d?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:ke.selectedIso,selectedDateRange:ke.selectedRange,dateRangeStart:ke.rangeStart,dateReferences:ke.references,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:b.timeView,multiSelectView:b.dropdownMultiSelect,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:b.locationView,isReediting:b.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:b.isFocused||b.locationFieldFocused,optionsPosition:c??"below"}}}import{attachChipRemove as No,cancelStartingHint as Fo,chipIdFromTap as Ho,extractPlainText as Ta,getCursorOffset as Pa,keepCaretOnChip as Bo,plainTextLength as Wo,renderEditableContent as Go,setCursorOffset as Ia,startingHintOptions as Ko}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as me,useEffect as et,useLayoutEffect as zt,useRef as tt}from"react";var wt;function qo(){if(wt!==void 0)return wt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),wt=e.contentEditable==="plaintext-only",wt}function Ea(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,showChipRemove:i=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:f,editingAnchor:w,caretOffset:y,placeholderText:g,hintSuggestions:h,isFocused:c,isDropdownOpen:v,listboxId:I,activeDescendantId:_,autoFocus:z,handleTextChange:O,handleKeyDown:te,handleCaretAfterInput:S,handleCaretMove:M,startEditingParam:H,replaceEditingRange:N,setFocused:B}=e,T=tt(null),V=tt(!1),Y=tt(""),E=tt(""),K=tt(null),de=tt(0);K.current=y,et(()=>{if(!z)return;let u=T.current;if(!u)return;document.activeElement===u?B(!0):u.focus();let k=u.ownerDocument??document,C=k.getSelection(),A=C&&C.rangeCount>0&&u.contains(C.anchorNode);if(C&&!A){let R=k.createRange();R.selectNodeContents(u),R.collapse(!0),C.removeAllRanges(),C.addRange(R)}},[z,B]),et(()=>{let u=T.current;if(!u)return;let k=u.ownerDocument??document,C=()=>{let A=k.getSelection();if(!A||A.rangeCount===0||!A.anchorNode||!u.contains(A.anchorNode))return;let R=A.anchorNode,W=R.nodeType===Node.ELEMENT_NODE?R:R.parentElement,pe=(A.isCollapsed?W?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=l?.id??f?.id??null;if(pe&&pe!==ge){H(pe);return}performance.now()-de.current<50||M(Pa(u))};return k.addEventListener("selectionchange",C),()=>k.removeEventListener("selectionchange",C)},[l,f,H,M]),et(()=>{let u=T.current;if(!u)return;let k=C=>{let A=Ho(u,C.target);A&&(H(A),Bo(u,A))};return u.addEventListener("click",k),()=>u.removeEventListener("click",k)},[H]),et(()=>{let u=T.current;if(!(!u||!s||!i))return No(u,s)},[s,i]),zt(()=>{let u=T.current;u&&Go({input:u,segments:o,newParamId:r,editingParamId:l?.id??null,placeholderText:g??"",isFocused:c,showChipIcons:t,showChipImages:a,showChipRemove:i,hintOptions:Ko(h??[])})},[o,r,l,g,h,c,t,a,i]),et(()=>{let u=T.current;return()=>{u&&Fo(u)}},[]),zt(()=>{let u=Y.current,k=r??"";if(Y.current=k,!k||k===u)return;let C=T.current;if(!C)return;C.focus();let A=K.current??Wo(C);Ia(C,A)},[r]),zt(()=>{let u=E.current,k=l?.id??"";if(E.current=k,!k||k===u||w==null)return;let C=T.current;C&&Ia(C,w)},[l,w]);let ae=me(()=>{if(V.current)return;let u=T.current;if(!u)return;let k=Ta(u),A=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;O(A)},[O]),re=me(()=>{de.current=performance.now(),ae();let u=T.current;u&&S(Pa(u))},[ae,S]);et(()=>{let u=T.current;if(!u)return;let k=C=>{let A=C,R=A.inputType;if(R==="insertParagraph"||R==="insertLineBreak"||R==="insertFromDrop"){C.preventDefault();return}if(R.startsWith("insert")||R.startsWith("delete")){let W=R.startsWith("delete")?"":A.data??"";N(W)&&C.preventDefault()}};return u.addEventListener("beforeinput",k),()=>u.removeEventListener("beforeinput",k)},[N]);let d=me(()=>{V.current=!0,T.current?.setAttribute("data-aia-composing","true")},[]),P=me(()=>{V.current=!1,T.current?.removeAttribute("data-aia-composing"),ae()},[ae]),Te=me(u=>{u.preventDefault();let k=T.current;if(!k)return;let C=(u.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!C)return;let A=k.ownerDocument??document,R=A.getSelection();if(!R||R.rangeCount===0)return;let W=R.getRangeAt(0);if(!k.contains(W.startContainer))return;W.deleteContents();let ce=A.createTextNode(C);W.insertNode(ce),W.setStartAfter(ce),W.collapse(!0),R.removeAllRanges(),R.addRange(W),ae()},[ae]),m=me(u=>te(u),[te]),Me=me(()=>B(!0),[B]),Pe=me(()=>B(!1),[B]),Ie=me(()=>T.current?.focus(),[]),Ee=me(()=>T.current?.blur(),[]),ye=me(()=>{let u=T.current;return u?Ta(u):""},[]),Ae=qo()?"plaintext-only":"true";return{inputRef:T,editorProps:{ref:T,contentEditable:Ae,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":I,"aria-expanded":v,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:re,onKeyDown:m,onCompositionStart:d,onCompositionEnd:P,onPaste:Te,onFocus:Me,onBlur:Pe},getPlainText:ye,focus:Ie,blur:Ee}}import{jsx as it,jsxs as Nt}from"react/jsx-runtime";function Xo(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Jo=_o(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:f,language:w,currency:y,productId:g,visitorId:h,columns:c,pillPlacement:v="dropdown",mode:I="auto",optionsPosition:_="below",animations:z=!0,optionsStyle:O="floating",dropdownTrigger:te,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:H,locationSearch:N,showOptionIcons:B=!0,showChipIcons:T=!0,showChipImages:V=!0,showChipRemove:Y=!1,showOptionImages:E=!0,showOptionCounts:K=!0,showSkipButton:de,showProducts:ae,productsLayout:re,productImageFallback:d,autoFocus:P=!0,onFocus:Te,onBlur:m,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,submitButton:C,resetOnSubmit:A=!0},R){let W=at(null),ce=at(null),pe=at(null),ge=at(()=>{}),j=at(null),Ne=at(null);Mt(()=>{let D=W.current;if(D)return j.current?j.current.setMode(I):j.current=new Yo(D,I),()=>{j.current?.destroy(),j.current=null}},[I]);let Fe=Dt(D=>{let oe=Ne.current?.current;oe&&(oe.focus(),jo(oe,D))},[]),{completedParams:He,suggestionPills:Oe,setActivePill:Be,skipActivePill:We,segments:Z,newParamId:x,clearNewParamId:Ge,placeholderText:n,isFocused:$,isDropdownOpen:b,isActivePillSelected:fe,isLoading:Ke,isReady:se,activeIndex:Re,listboxId:qe,handleTextChange:Le,handleKeyDown:je,setFocused:he,editingParam:be,editingIdentified:ze,editingAnchor:_e,caretOffset:$e,startEditingParam:ke,removeParam:Ve,handleCaretAfterInput:p,handleCaretMove:G,replaceEditingRange:L,dropdownProps:F,reset:ct,refreshProducts:Ft,prepareSubmit:Ht,getState:Bt,recordSubmit:Wt}=Lt({onSubmit:D=>ge.current(D),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:f,language:w,currency:y,productId:g,visitorId:h,columns:c,dropdownTrigger:te,optionsPosition:_,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:H,locationSearch:N,showOptionIcons:B,showOptionImages:E,showOptionCounts:K,showSkipButton:de,showProducts:ae,onFocus:Te,onBlur:m,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,source:"full-sdk",setCursor:Fe});Mt(()=>{if(!x)return;let D=window.setTimeout(()=>Ge(),650);return()=>window.clearTimeout(D)},[x,Ge]);let Aa=Re>=0?`${qe}-option-${Re}`:void 0,{inputRef:vt,editorProps:Oa,focus:pt,blur:Gt,getPlainText:Kt}=Ea({segments:Z,newParamId:x,editingParam:be,editingIdentified:ze,editingAnchor:_e,caretOffset:$e,placeholderText:n,hintSuggestions:v==="inline"?[]:Oe,isFocused:$,showChipIcons:T,showChipImages:V,showChipRemove:Y,removeParam:Ve,isDropdownOpen:b,listboxId:qe,activeDescendantId:Aa,autoFocus:P,handleTextChange:Le,handleKeyDown:je,handleCaretAfterInput:p,handleCaretMove:G,startEditingParam:ke,replaceEditingRange:L,setFocused:he});Ne.current=vt,Uo(()=>{let D=ce.current,oe=vt.current;if(!D||!oe)return;let nt=()=>{let _t=D.firstElementChild;if(!_t)return;let Da=_t.getBoundingClientRect(),Ma=oe.getBoundingClientRect();Da.top>=Ma.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};nt();let qt=new ResizeObserver(nt);return qt.observe(oe),()=>qt.disconnect()},[Z,Oe.length,Ke,vt]),Mt(()=>{let D=pe.current;if(D)return Zo(D)},[]),Vo(R,()=>({focus:pt,blur:Gt,reset:ct,refreshProducts:Ft,setMode:D=>j.current?.setMode(D),skipActivePill:We}),[pt,Gt,ct,Ft,We]);let ot=!!Z.length||He.length>0,xt=Dt(D=>{if(!ot)return;D&&Ht();let oe=Bt(),nt=Qo(Kt(),oe.completedParams,oe.skippedParams,{identifiedParams:oe.identifiedParams,isReady:oe.isReady,customFields:oe.customFields});D&&Wt(nt),o(nt),A&&ct()},[Wt,A,ot,Ht,Bt,o,ct,Kt]);ge.current=()=>xt(!1);let Ra=Dt(D=>{D.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||pt()},[pt]),La=v==="inline",za=v==="dropdown";return Nt("div",{ref:W,className:`magicx-aia ${Ue.container} ${r??""}`,"data-pill-placement":v,"data-options-position":_,"data-animations":z?"on":"off","data-aia-options-style":O,"data-mode":Xo(I),children:[it(Ot,{...F,showPills:za,productsLayout:re,productImageFallback:d}),Nt("div",{className:Ue.inputWrapper,"data-aia-input-wrapper":"",onClick:Ra,children:[Nt("div",{ref:pe,className:Ue.editorArea,"data-aia-editor":"",children:[it("div",{...Oa,className:Ue.input,"data-aia-input":""}),La&&(Ke||Oe.length>0)&&it("span",{ref:ce,className:Ue.pillListContainer,"data-aia-pill-list-container":"",children:it(ut,{pills:Oe,activePillIndex:0,activeSelected:fe,onSelectPill:Be,loading:Ke})})]}),C===null?null:C===void 0?it(wa,{disabled:!ot,ready:ot&&se,onClick:()=>xt(!0),label:$o(w).submit}):it("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ue.submitSlot,onClick:D=>{ot&&(D.stopPropagation(),xt(!0))},children:C})]})]})});export{Jo as AIAutocomplete,Ot as AIAutocompleteDropdown,ds as DATE_RANGE_META_END,cs as DATE_RANGE_META_START,ps as DEFAULT_OPTION_COUNT_UNIT,vs as LOCATION_META_KEY,Is as PRODUCT_PATH_PREFIX,Fs as TIME_META_KEY,Bs as WEEKDAY_LABELS,rs as buildSubmitResult,ss as cellDay,ls as cellIso,hs as dateCellMarks,us as formatDate,ms as formatDateRange,gs as formatOptionCount,fs as formatPlace,bs as formatTime,ws as isoDate,xs as monthLabel,ys as optionCountLabel,ks as optionHasImage,Cs as optionImageSources,Ss as optionImageSrc,Ts as optionLabel,Ps as optionsShowLeadingVisuals,Es as parseDate,As as parseLooseDate,Os as parseLooseDateRange,Rs as parseTime,Ls as productFromMatchedItem,zs as productImageSources,Ds as productsFromCustomFields,Ms as sanitizeOptionIconSvg,Ns as selectedRangeFor,Lt as useAIAutocomplete,Hs as visibleDateRange,Ws as withSkippedParams};
|
|
3707
|
+
`,document.head.appendChild(e)}var va={submitButton:"aia-submitButton-otz7H"};import{jsx as Lt}from"react/jsx-runtime";function xa({disabled:e,ready:o,onClick:t,label:a=Oo().submit}){return Lt("button",{type:"button","data-aia-submit":"",className:va.submitButton,disabled:e,"data-aia-ready":o?"":void 0,onClick:i=>{i.stopPropagation(),t()},"aria-label":a,children:Lt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Lt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ro,dateSelectionFor as Lo,editingSuggestion as zo,identifiedParamLabel as Do,withoutTraditionalAutocomplete as Mo}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ta,useEffect as Je,useMemo as No,useRef as J,useState as Fo}from"react";import{useRef as ya}from"react";function ka(e){let o=ya(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=ya({key:"",overrides:void 0});if(a.current.key!==t){let i={};for(let s of Object.keys(e??{})){let r=(l,b,w)=>{let y=o.current?.[s];return y?y(l,b,w):[]};i[s]=r}a.current={key:t,overrides:e?i:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as Ca}from"react";function Sa(e){let o=Ca(e);o.current=e;let t=Ca(null);t.current===null&&(t.current={fetch:(i,s)=>{let r=o.current;return r?r.fetch(i,s):Promise.reject(new Error("products config removed"))},transform:i=>o.current?.transform(i)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Pa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,skeletonPicked:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView:null,dropdownMultiSelect:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",leadInText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function zt({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:i,apiConfig:s,additionalContext:r,language:l,currency:b,productId:w,visitorId:y,columns:m=2,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:E,allOption:K,showNonTappableOptions:D,locationSearch:R,showOptionIcons:ee,showOptionImages:P,showOptionCounts:z,showSkipButton:q,showProducts:N,productImageFallback:Q="image",onFocus:A,onBlur:$,value:W,completedParams:F,onChange:Y,onParamsChange:re,products:S,mapProducts:H,onProductSelect:d,onProductAddToCart:T,source:Me,setCursor:ke}){let g=J(null),[Ne,Ee]=Fo(null),Ae=J(e);Ae.current=e;let Ce=J(o);Ce.current=o;let Oe=J(t);Oe.current=t;let u=J(Y);u.current=Y;let C=J(re);C.current=re;let I=J(A);I.current=A;let O=J($);O.current=$;let L=J(ke);L.current=ke;let _=J(d);_.current=d;let se=J(T);se.current=T;let le=J(y);le.current=y;let Re=J(()=>{let p=le.current;return typeof p=="function"?p():p}).current,te=Sa(S),de=J(H);de.current=H;let Ve=J((p,B)=>{let k=de.current;return k?k(p,B):p}).current,Fe=H?Ve:void 0,He=ka(a);Je(()=>{if(typeof document>"u")return;let p=new Ro(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:b,productId:w,visitorId:Re,optionOverrides:He.overrides,maskCompletedText:i,columns:m,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:E,allOption:K,showNonTappableOptions:D,locationSearch:R,showProducts:N,source:Me,value:W,completedParams:F,onSubmit:(...k)=>Ae.current?.(...k),onResult:(...k)=>Ce.current?.(...k),onError:(...k)=>Oe.current?.(...k),onChange:(...k)=>u.current?.(...k),onParamsChange:(...k)=>C.current?.(...k),onFocus:()=>I.current?.(),onBlur:()=>O.current?.(),onProductSelect:k=>_.current?.(k),onProductAddToCart:k=>se.current?.(k),setCursor:k=>L.current?.(k),products:te.config,mapProducts:Fe});g.current=p,Ee(p.getState());let B=p.subscribe(k=>Ee(k));return()=>{B(),p.destroy(),g.current===p&&(g.current=null)}},[]),Je(()=>{W!==void 0&&g.current?.setValue(W)},[W]),Je(()=>{F!==void 0&&g.current?.setCompletedParams(F)},[F]);let Le=JSON.stringify(s??null),Be;try{Be=JSON.stringify(r??null)}catch{Be="[unstringifiable]"}Je(()=>{g.current?.update({apiConfig:s,additionalContext:r,language:l,currency:b,productId:w,optionOverrides:He.overrides,dropdownTrigger:h,optionsPosition:c,closeDropdownOnBlur:v,prependPlaceholder:E,allOption:K,showNonTappableOptions:D,locationSearch:R,showProducts:N})},[Le,Be,l,b?.code,b?.rate,b?.country,w,He.key,h,c,v,E,K,D,R,N]);let ie=J(!1);Je(()=>{if(!ie.current){ie.current=!0;return}g.current?.update({products:te.config})},[te.enabled]),Je(()=>{g.current?.update({mapProducts:Fe})},[Fe]);let pe=J(null);pe.current===null&&(pe.current={handleTextChange:p=>g.current?.handleTextChange(p),handleKeyDown:p=>{let B="nativeEvent"in p?p.nativeEvent:p;g.current?.handleKeyDown(B)},setFocused:p=>g.current?.setFocused(p),startEditingParam:p=>g.current?.startEditingParam(p),removeParam:p=>g.current?.removeParam(p)??!1,exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:p=>g.current?.handleCaretAfterInput(p),handleCaretMove:p=>g.current?.handleCaretMove(p),replaceEditingRange:p=>g.current?.replaceEditingRange(p)??!1,setActivePill:p=>g.current?.setActivePill(p),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),refreshProducts:()=>g.current?.refreshProducts(),prepareSubmit:()=>g.current?.prepareSubmit(),getState:()=>g.current?.getState()??Pa,recordSubmit:p=>g.current?.recordSubmit(p),selectOption:(p,B)=>g.current?.selectOption(p,B),selectProduct:p=>g.current?.selectProduct(p),addProductToCart:p=>{let B=g.current;return!B||!se.current?Promise.resolve():B.addProductToCart(p)},setActiveDropdownIndex:p=>g.current?.setActiveDropdownIndex(p),clearHighlight:p=>g.current?.clearHighlight(p),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),setTime:p=>g.current?.setTime(p),commitTime:()=>g.current?.commitTime(),toggleMultiSelectOption:p=>g.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>g.current?.commitMultiSelect(),setLocationQuery:p=>g.current?.setLocationQuery(p),moveLocationHighlight:p=>g.current?.moveLocationHighlight(p),commitLocation:p=>g.current?.commitLocation(p),setLocationFieldFocused:p=>g.current?.setLocationFieldFocused(p),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let x=pe.current,n=Ta(p=>{let B=p.target.value,vt=B.length>0&&!p.nativeEvent?.isComposing&&B[0]!==B[0].toUpperCase()?B[0].toUpperCase()+B.slice(1):B;g.current?.handleTextChange(vt)},[]),Z=Ta(p=>{g.current?.handleKeyDown(p.nativeEvent)},[]),fe=g.current,f=Ne??Pa,Ue=W!==void 0?W:f.text,he=F!==void 0?F:f.completedParams,be=f.actionableSuggestions,We=be[0],Qe=No(()=>Mo(be),[be]),Se=fe?.listboxId??"",Ye=f.activeDropdownIndex>=0&&fe?`${Se}-option-${f.activeDropdownIndex}`:void 0,Te=f.editingParam,we=f.editingIdentified,ze=Te?zo(Te):we?{parameter:we.parameter,text:Do(we.parameter),required:!0,options:[]}:null,Ge=f.dropdownSuggestion??ze??We,je=ze?[ze]:be,Pe=Lo(f),$e=!fe||f.dropdownLoading;return{completedParams:he,multiSelectView:f.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:f.skippedParams,identifiedParams:f.identifiedParams,suggestionPills:Qe,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:f.segments,newParamId:f.newParamId,clearNewParamId:x.clearNewParamId,suggestions:f.suggestions,activeIndex:f.activeDropdownIndex,isReady:f.isReady,isLoading:$e,isFocused:f.isFocused,isDropdownOpen:f.isDropdownOpen,isActivePillSelected:f.isActivePillSelected,placeholderText:f.placeholderText,listboxId:Se,error:f.error,products:f.products,customFields:f.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:Te,editingIdentified:we,editingAnchor:f.editingAnchor,caretOffset:f.caretOffset,startEditingParam:x.startEditingParam,removeParam:x.removeParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ue,placeholder:f.placeholderText||void 0,onChange:n,onKeyDown:Z,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":f.isDropdownOpen,"aria-activedescendant":Ye,"aria-autocomplete":"list","aria-controls":Se},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Ge?[{...Ge,options:f.dropdownOptions}]:[],activeIndex:f.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:f.isDropdownOpen,id:Se,pills:je,activeSelected:f.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(q??!0)&&!Te&&!we,showOptionIcons:ee??!0,showOptionImages:P??!0,showOptionCounts:z??!0,skipDisabled:f.inSelectionAnimation,isLoading:$e,skeletonExiting:f.skeletonExiting,isInputEmpty:Ue.trim().length===0,language:l,products:f.products,productImageFallback:Q,onProductSelect:x.selectProduct,onProductAddToCart:T?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:f.activeFormatType,dateView:f.dateView,selectedDateIso:Pe.selectedIso,selectedDateRange:Pe.selectedRange,dateRangeStart:Pe.rangeStart,dateReferences:Pe.references,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:f.timeView,multiSelectView:f.dropdownMultiSelect,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,locationView:f.locationView,isReediting:f.editingParam!=null,onLocationQuery:x.setLocationQuery,onLocationMove:x.moveLocationHighlight,onLocationCommit:x.commitLocation,onLocationFocusChange:x.setLocationFieldFocused,isFocused:f.isFocused||f.locationFieldFocused,optionsPosition:c??"below"}}}import{attachChipRemove as Ho,cancelStartingHint as Bo,chipIdFromTap as Wo,extractPlainText as Ia,getCursorOffset as Ea,keepCaretOnChip as Go,plainTextLength as Ko,renderEditableContent as qo,setCursorOffset as Aa,startingHintOptions as _o}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as ge,useEffect as et,useLayoutEffect as Dt,useRef as tt}from"react";var wt;function Vo(){if(wt!==void 0)return wt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),wt=e.contentEditable==="plaintext-only",wt}function Oa(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,showChipRemove:i=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:b,editingAnchor:w,caretOffset:y,placeholderText:m,hintSuggestions:h,isFocused:c,isDropdownOpen:v,listboxId:E,activeDescendantId:K,autoFocus:D,handleTextChange:R,handleKeyDown:ee,handleCaretAfterInput:P,handleCaretMove:z,startEditingParam:q,replaceEditingRange:N,setFocused:Q}=e,A=tt(null),$=tt(!1),W=tt(""),F=tt(""),Y=tt(null),re=tt(0);Y.current=y,et(()=>{if(!D)return;let u=A.current;if(!u)return;document.activeElement===u?Q(!0):u.focus();let C=u.ownerDocument??document,I=C.getSelection(),O=I&&I.rangeCount>0&&u.contains(I.anchorNode);if(I&&!O){let L=C.createRange();L.selectNodeContents(u),L.collapse(!0),I.removeAllRanges(),I.addRange(L)}},[D,Q]),et(()=>{let u=A.current;if(!u)return;let C=u.ownerDocument??document,I=()=>{let O=C.getSelection();if(!O||O.rangeCount===0||!O.anchorNode||!u.contains(O.anchorNode))return;let L=O.anchorNode,_=L.nodeType===Node.ELEMENT_NODE?L:L.parentElement,le=(O.isCollapsed?_?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Re=l?.id??b?.id??null;if(le&&le!==Re){q(le);return}performance.now()-re.current<50||z(Ea(u))};return C.addEventListener("selectionchange",I),()=>C.removeEventListener("selectionchange",I)},[l,b,q,z]),et(()=>{let u=A.current;if(!u)return;let C=I=>{let O=Wo(u,I.target);O&&(q(O),Go(u,O))};return u.addEventListener("click",C),()=>u.removeEventListener("click",C)},[q]),et(()=>{let u=A.current;if(!(!u||!s||!i))return Ho(u,s)},[s,i]),Dt(()=>{let u=A.current;u&&qo({input:u,segments:o,newParamId:r,editingParamId:l?.id??null,placeholderText:m??"",isFocused:c,showChipIcons:t,showChipImages:a,showChipRemove:i,hintOptions:_o(h??[])})},[o,r,l,m,h,c,t,a,i]),et(()=>{let u=A.current;return()=>{u&&Bo(u)}},[]),Dt(()=>{let u=W.current,C=r??"";if(W.current=C,!C||C===u)return;let I=A.current;if(!I)return;I.focus();let O=Y.current??Ko(I);Aa(I,O)},[r]),Dt(()=>{let u=F.current,C=l?.id??"";if(F.current=C,!C||C===u||w==null)return;let I=A.current;I&&Aa(I,w)},[l,w]);let S=ge(()=>{if($.current)return;let u=A.current;if(!u)return;let C=Ia(u),O=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;R(O)},[R]),H=ge(()=>{re.current=performance.now(),S();let u=A.current;u&&P(Ea(u))},[S,P]);et(()=>{let u=A.current;if(!u)return;let C=I=>{let O=I,L=O.inputType;if(L==="insertParagraph"||L==="insertLineBreak"||L==="insertFromDrop"){I.preventDefault();return}if(L.startsWith("insert")||L.startsWith("delete")){let _=L.startsWith("delete")?"":O.data??"";N(_)&&I.preventDefault()}};return u.addEventListener("beforeinput",C),()=>u.removeEventListener("beforeinput",C)},[N]);let d=ge(()=>{$.current=!0,A.current?.setAttribute("data-aia-composing","true")},[]),T=ge(()=>{$.current=!1,A.current?.removeAttribute("data-aia-composing"),S()},[S]),Me=ge(u=>{u.preventDefault();let C=A.current;if(!C)return;let I=(u.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!I)return;let O=C.ownerDocument??document,L=O.getSelection();if(!L||L.rangeCount===0)return;let _=L.getRangeAt(0);if(!C.contains(_.startContainer))return;_.deleteContents();let se=O.createTextNode(I);_.insertNode(se),_.setStartAfter(se),_.collapse(!0),L.removeAllRanges(),L.addRange(_),S()},[S]),ke=ge(u=>ee(u),[ee]),g=ge(()=>Q(!0),[Q]),Ne=ge(()=>Q(!1),[Q]),Ee=ge(()=>A.current?.focus(),[]),Ae=ge(()=>A.current?.blur(),[]),Ce=ge(()=>{let u=A.current;return u?Ia(u):""},[]),Oe=Vo()?"plaintext-only":"true";return{inputRef:A,editorProps:{ref:A,contentEditable:Oe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":E,"aria-expanded":v,"aria-activedescendant":K,spellCheck:!0,enterKeyHint:"send",onInput:H,onKeyDown:ke,onCompositionStart:d,onCompositionEnd:T,onPaste:Me,onFocus:g,onBlur:Ne},getPlainText:Ce,focus:Ee,blur:Ae}}import{jsx as it,jsxs as Ft}from"react/jsx-runtime";function en(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var tn=Uo(function({onSubmit:o,onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,className:r,apiConfig:l,additionalContext:b,language:w,currency:y,productId:m,visitorId:h,columns:c,pillPlacement:v="dropdown",mode:E="auto",optionsPosition:K="below",animations:D=!0,optionsStyle:R="floating",dropdownTrigger:ee,closeDropdownOnBlur:P,prependPlaceholder:z,allOption:q,showNonTappableOptions:N,locationSearch:Q,showOptionIcons:A=!0,showChipIcons:$=!0,showChipImages:W=!0,showChipRemove:F=!1,showOptionImages:Y=!0,showOptionCounts:re=!0,showSkipButton:S,showProducts:H,productsLayout:d,productImageFallback:T,autoFocus:Me=!0,onFocus:ke,onBlur:g,value:Ne,completedParams:Ee,onChange:Ae,onParamsChange:Ce,products:Oe,mapProducts:u,onProductSelect:C,onProductAddToCart:I,submitButton:O,resetOnSubmit:L=!0},_){let se=at(null),le=at(null),Re=at(null),te=at(()=>{}),de=at(null),Ve=at(null);Nt(()=>{let M=se.current;if(M)return de.current?de.current.setMode(E):de.current=new $o(M,E),()=>{de.current?.destroy(),de.current=null}},[E]);let Fe=Mt(M=>{let oe=Ve.current?.current;oe&&(oe.focus(),Zo(oe,M))},[]),{completedParams:He,suggestionPills:Le,setActivePill:Be,skipActivePill:ie,segments:pe,newParamId:x,clearNewParamId:n,placeholderText:Z,isFocused:fe,isDropdownOpen:f,isActivePillSelected:Ue,isLoading:he,isReady:be,activeIndex:We,listboxId:Qe,handleTextChange:Se,handleKeyDown:Ye,setFocused:Te,editingParam:we,editingIdentified:ze,editingAnchor:Ge,caretOffset:je,startEditingParam:Pe,removeParam:$e,handleCaretAfterInput:p,handleCaretMove:B,replaceEditingRange:k,dropdownProps:vt,reset:pt,refreshProducts:Ht,prepareSubmit:Bt,getState:Wt,recordSubmit:Gt}=zt({onSubmit:M=>te.current(M),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:b,language:w,currency:y,productId:m,visitorId:h,columns:c,dropdownTrigger:ee,optionsPosition:K,closeDropdownOnBlur:P,prependPlaceholder:z,allOption:q,showNonTappableOptions:N,locationSearch:Q,showOptionIcons:A,showOptionImages:Y,showOptionCounts:re,showSkipButton:S,showProducts:H,onFocus:ke,onBlur:g,value:Ne,completedParams:Ee,onChange:Ae,onParamsChange:Ce,products:Oe,mapProducts:u,onProductSelect:C,onProductAddToCart:I,source:"full-sdk",setCursor:Fe});Nt(()=>{if(!x)return;let M=window.setTimeout(()=>n(),650);return()=>window.clearTimeout(M)},[x,n]);let Ra=We>=0?`${Qe}-option-${We}`:void 0,{inputRef:xt,editorProps:La,focus:ht,blur:Kt,getPlainText:qt}=Oa({segments:pe,newParamId:x,editingParam:we,editingIdentified:ze,editingAnchor:Ge,caretOffset:je,placeholderText:Z,hintSuggestions:v==="inline"?[]:Le,isFocused:fe,showChipIcons:$,showChipImages:W,showChipRemove:F,removeParam:$e,isDropdownOpen:f,listboxId:Qe,activeDescendantId:Ra,autoFocus:Me,handleTextChange:Se,handleKeyDown:Ye,handleCaretAfterInput:p,handleCaretMove:B,startEditingParam:Pe,replaceEditingRange:k,setFocused:Te});Ve.current=xt,Yo(()=>{let M=le.current,oe=xt.current;if(!M||!oe)return;let nt=()=>{let Vt=M.firstElementChild;if(!Vt)return;let Na=Vt.getBoundingClientRect(),Fa=oe.getBoundingClientRect();Na.top>=Fa.bottom-2?M.setAttribute("data-aia-pill-wrapped",""):M.removeAttribute("data-aia-pill-wrapped")};nt();let _t=new ResizeObserver(nt);return _t.observe(oe),()=>_t.disconnect()},[pe,Le.length,he,xt]),Nt(()=>{let M=Re.current;if(M)return Jo(M)},[]),Qo(_,()=>({focus:ht,blur:Kt,reset:pt,refreshProducts:Ht,setMode:M=>de.current?.setMode(M),skipActivePill:ie}),[ht,Kt,pt,Ht,ie]);let ot=!!pe.length||He.length>0,yt=Mt(M=>{if(!ot)return;M&&Bt();let oe=Wt(),nt=jo(qt(),oe.completedParams,oe.skippedParams,{identifiedParams:oe.identifiedParams,isReady:oe.isReady,customFields:oe.customFields});M&&Gt(nt),o(nt),L&&pt()},[Gt,L,ot,Bt,Wt,o,pt,qt]);te.current=()=>yt(!1);let za=Mt(M=>{M.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||ht()},[ht]),Da=v==="inline",Ma=v==="dropdown";return Ft("div",{ref:se,className:`magicx-aia ${Ke.container} ${r??""}`,"data-pill-placement":v,"data-options-position":K,"data-animations":D?"on":"off","data-aia-options-style":R,"data-mode":en(E),children:[it(Rt,{...vt,showPills:Ma,productsLayout:d,productImageFallback:T}),Ft("div",{className:Ke.inputWrapper,"data-aia-input-wrapper":"",onClick:za,children:[Ft("div",{ref:Re,className:Ke.editorArea,"data-aia-editor":"",children:[it("div",{...La,className:Ke.input,"data-aia-input":""}),Da&&(he||Le.length>0)&&it("span",{ref:le,className:Ke.pillListContainer,"data-aia-pill-list-container":"",children:it(mt,{pills:Le,activePillIndex:0,activeSelected:Ue,onSelectPill:Be,loading:he})})]}),O===null?null:O===void 0?it(xa,{disabled:!ot,ready:ot&&be,onClick:()=>yt(!0),label:Xo(w).submit}):it("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ke.submitSlot,onClick:M=>{ot&&(M.stopPropagation(),yt(!0))},children:O})]})]})});export{tn as AIAutocomplete,Rt as AIAutocompleteDropdown,ps as DATE_RANGE_META_END,hs as DATE_RANGE_META_START,us as DEFAULT_OPTION_COUNT_UNIT,ys as LOCATION_META_KEY,As as PRODUCT_PATH_PREFIX,Bs as TIME_META_KEY,Gs as WEEKDAY_LABELS,ls as buildSubmitResult,ds as cellDay,cs as cellIso,ms as dateCellMarks,gs as formatDate,fs as formatDateRange,bs as formatOptionCount,ws as formatPlace,vs as formatTime,xs as isoDate,ks as monthLabel,Cs as optionCountLabel,Ss as optionHasImage,Ts as optionImageSources,Ps as optionImageSrc,Is as optionLabel,Es as optionsShowLeadingVisuals,Os as parseDate,Rs as parseLooseDate,Ls as parseLooseDateRange,zs as parseTime,Ds as productFromMatchedItem,Ms as productImageSources,Ns as productsFromCustomFields,Fs as sanitizeOptionIconSvg,Hs as selectedRangeFor,zt as useAIAutocomplete,Ws as visibleDateRange,Ks as withSkippedParams};
|
|
3677
3708
|
//# sourceMappingURL=index.mjs.map
|