@magicx-eng/ai-autocomplete-react 0.57.1 → 0.57.2
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 -2
- package/REFERENCE.md +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -13
- 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 rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END as ds,DATE_RANGE_META_START as cs,DEFAULT_OPTION_COUNT_UNIT as ps,dateCellMarks as hs,formatDate as us,formatDateRange as ms,formatOptionCount as gs,formatPlace as fs,formatTime as bs,isoDate as ws,LOCATION_META_KEY as vs,monthLabel as xs,optionCountLabel as ys,optionHasImage as ks,optionImageSources as Cs,optionImageSrc as Ss,optionLabel as Ts,optionsShowLeadingVisuals as Ps,PRODUCT_PATH_PREFIX as Is,parseDate as Es,parseLooseDate as As,parseLooseDateRange as
|
|
1
|
+
import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END as ds,DATE_RANGE_META_START as cs,DEFAULT_OPTION_COUNT_UNIT as ps,dateCellMarks as hs,formatDate as us,formatDateRange as ms,formatOptionCount as gs,formatPlace as fs,formatTime as bs,isoDate as ws,LOCATION_META_KEY as vs,monthLabel as xs,optionCountLabel as ys,optionHasImage as ks,optionImageSources as Cs,optionImageSrc as Ss,optionLabel as Ts,optionsShowLeadingVisuals as Ps,PRODUCT_PATH_PREFIX as Is,parseDate as Es,parseLooseDate as As,parseLooseDateRange as Os,parseTime as Rs,productFromMatchedItem as Ls,productImageSources as zs,productsFromCustomFields as Ds,sanitizeOptionIconSvg as Ms,selectedRangeFor as Ns,TIME_META_KEY as Fs,visibleDateRange as Hs,WEEKDAY_LABELS as Bs,withSkippedParams as Ws}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as _o,useCallback as Dt,useEffect as Mt,useImperativeHandle as Vo,useLayoutEffect as Uo,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
|
|
@@ -1594,7 +1594,35 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1594
1594
|
transition-delay: 0s;
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
|
-
|
|
1597
|
+
|
|
1598
|
+
/* The multi-select Done row stays mounted while a request loads, so it leaves
|
|
1599
|
+
and returns with the options on the same 160ms instead of standing at full
|
|
1600
|
+
strength over rows that are gone (vanilla's styles.css does the same). */
|
|
1601
|
+
.aia-dropdown-yz2KC[data-aia-loading] [data-aia-multi-actions] {
|
|
1602
|
+
pointer-events: none;
|
|
1603
|
+
animation: aia-multiActionsLoadingOut-lSdMh 160ms ease-in forwards;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
.aia-dropdown-yz2KC:not([data-aia-loading]) [data-aia-multi-actions] {
|
|
1607
|
+
animation: aia-multiActionsFadeIn-zbGTG 160ms ease-out;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/* Ends and starts a hair above zero: iOS cancels a tap on an element at 0. */
|
|
1611
|
+
@keyframes aia-multiActionsLoadingOut-lSdMh {
|
|
1612
|
+
to {
|
|
1613
|
+
opacity: 0.01;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
@keyframes aia-multiActionsFadeIn-zbGTG {
|
|
1618
|
+
from {
|
|
1619
|
+
opacity: 0.01;
|
|
1620
|
+
}
|
|
1621
|
+
to {
|
|
1622
|
+
opacity: 1;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
`,document.head.appendChild(e)}var we={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 Na,cellIso as rt,dateCellMarks as Fa,isDimmedDay as Ha,isoDate as Ba,monthLabel as Wa,visibleDateRange as Ga,WEEKDAY_LABELS as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as qa}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) ---
|
|
1598
1626
|
|
|
1599
1627
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1600
1628
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1791,7 +1819,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1791
1819
|
opacity: 0.8;
|
|
1792
1820
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1793
1821
|
}
|
|
1794
|
-
`,document.head.appendChild(e)}var q={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 ve,jsxs as Vt}from"react/jsx-runtime";var _a=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ut({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:
|
|
1822
|
+
`,document.head.appendChild(e)}var q={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 ve,jsxs as Vt}from"react/jsx-runtime";var _a=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ut({options:e,activeIndex:o,listboxId:t,view:a,selection:i,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:f,onNextMonth:w}){let y=Ba(new Date),g=Ga({pendingStart:i.rangeStart,highlightedIso:rt(e[o]),selected:i.selectedRange,floor:i.floor});return Vt("div",{className:q.datepicker,"data-aia-datepicker":"",children:[Vt("div",{className:q.header,children:[ve("button",{type:"button",tabIndex:-1,className:q.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:f,children:"\u2039"}),ve("span",{className:q.month,"data-aia-date-month":"","aria-live":"polite",children:Wa(a)}),ve("button",{type:"button",tabIndex:-1,className:q.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:w,children:"\u203A"})]}),ve("div",{className:q.weekdays,"aria-hidden":"true",children:Ka.map((h,c)=>ve("span",{className:q.weekday,children:h},_a[c]))}),ve("div",{className:q.grid,"data-aia-date-grid":"",children:e.map((h,c)=>ve(Va,{option:h,id:`${t}-option-${c}`,index:c,isHighlighted:c===o&&h.is_tappable,isToday:rt(h)===y,isPast:Ha(rt(h),y,i.floor),marks:Fa(rt(h),{selectedIso:i.selectedIso,range:g,references:i.references}),onSelect:s,onHighlight:r,onUnhighlight:l},rt(h)??`pad-${c}`))})]})}function Va({option:e,id:o,index:t,isHighlighted:a,isToday:i,isPast:s,marks:r,onSelect:l,onHighlight:f,onUnhighlight:w}){let[y,g]=qa(!1),h=Na(e);if(h==null)return ve("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${q.cell} ${q.blank}`});let c=()=>{g(!0),l(e),setTimeout(()=>g(!1),170)},v=[q.cell,q.day,s?q.past:"",a?q.highlighted:"",i?q.today:"",r.inRange?q.inRange:"",r.selected?q.selected:"",r.reference?q.reference:"",y?q.pressed:""].filter(Boolean).join(" ");return ve("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:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),c())},onMouseEnter:()=>f(t),onMouseLeave:w?()=>w(t):void 0,children:ve("span",{className:q.number,children:h})})}import{ATTRIBUTION_URL as Ua,buildAttributionUrl as Qa,getFooterHint as Ya,uiStringsFor as ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $a,useState as Za}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 {
|
|
1795
1823
|
display: flex;
|
|
1796
1824
|
flex-wrap: wrap;
|
|
1797
1825
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1831,7 +1859,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
1831
1859
|
.aia-cluster[data-justify="around"] {
|
|
1832
1860
|
justify-content: space-around;
|
|
1833
1861
|
}
|
|
1834
|
-
`,document.head.appendChild(e)}import{jsx as Qt}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
|
|
1862
|
+
`,document.head.appendChild(e)}import{jsx as Qt}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 f=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:f,...l};return i?Qt("span",{...w,children:r}):Qt("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
|
|
1835
1863
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1836
1864
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1837
1865
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -2112,7 +2140,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2112
2140
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
2113
2141
|
width: 60%;
|
|
2114
2142
|
}
|
|
2115
|
-
`,document.head.appendChild(e)}var U={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 Ja=0;function dt(e){return e.getRootNode().activeElement??null}function Xt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function $t(e){if(!e.isContentEditable)return null;let o=Xt(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Zt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Xt(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 ei=De("svg",{className:U.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"})]}),ti=De("svg",{className:U.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 Jt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:
|
|
2143
|
+
`,document.head.appendChild(e)}var U={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 Ja=0;function dt(e){return e.getRootNode().activeElement??null}function Xt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function $t(e){if(!e.isContentEditable)return null;let o=Xt(e);if(!o||o.rangeCount===0)return null;let t=o.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Zt(e,o){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Xt(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 ei=De("svg",{className:U.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"})]}),ti=De("svg",{className:U.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 Jt({view:e,searchLabel:o,noResultsLabel:t,useTypedLabel:a,widgetFocused:i,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:f,onMove:w,onCommit:y,onFocusChange:g}){let h=le(null),c=le(null),v=le(null),I=le(null),_=le(null),z=le(!1),O=le(!1),te=le(!1),S=le(!1),M=le(i);M.current=i;let H=le(g);H.current=g;let N=d=>{S.current=d,g(d)},B=()=>{let d=h.current;return d!=null&&dt(d)===d},T=()=>{let d=c.current;if(!d)return;let P=dt(d);P instanceof HTMLElement&&P!==h.current&&P!==document.body&&!d.contains(P)&&(I.current=P,_.current=$t(P))},V=d=>{let P=c.current;!P||!(d instanceof HTMLElement)||d===I.current||d===document.body||P.contains(d)||(I.current=d,_.current=$t(d))},Y=le(null);Y.current===null&&(Y.current=`aia-location-${++Ja}`);let E=`${Y.current}-row-`;jt(()=>{let d=h.current;d&&d.value!==e.query&&dt(d)!==d&&(d.value=e.query)},[e.query]),jt(()=>{i&&(s&&!te.current&&(O.current=!1),te.current=s);let d=h.current;if(d){if(!r&&B()){O.current=!0,K();return}if(!i){setTimeout(()=>{if(M.current)return;let P=I.current;P&&dt(P)===P||(O.current=!1)},0);return}if(!(!s||O.current||!l||B())){if(T(),N(!0),d.focus({preventScroll:!0}),!B()){O.current=!0,N(!1);return}d.value&&d.select()}}}),Xa(()=>()=>{if(!S.current)return;let d=h.current,P=I.current;P?.isConnected&&d&&dt(d)===d&&(z.current=!0,Zt(P,_.current),z.current=!1),S.current=!1,H.current(!1)},[]);let K=(d=!1)=>{d&&(O.current=!0);let P=I.current;P?.isConnected&&B()&&(z.current=!0,Zt(P,_.current),z.current=!1),N(!1)},de=e.query.trim(),ae=e.highlighted>=0&&e.highlighted<e.places.length?`${E}${e.highlighted}`:void 0,re=null;return e.places.length>0?re=e.places.map((d,P)=>De("div",{id:`${E}${P}`,role:"option","aria-selected":P===e.highlighted,className:P===e.highlighted?`${U.row} ${U.highlighted}`:U.row,"data-aia-location-row":"","data-aia-index":P,onClick:()=>{l&&(K(!0),y(P))},children:[ne("span",{className:U.pin,children:ei}),De("span",{className:U.text,children:[ne("span",{className:U.name,children:d.name}),d.secondary&&ne("span",{className:U.secondary,children:d.secondary})]})]},d.id)):e.status==="loading"?re=De("div",{className:U.loading,"data-aia-location-loading":"",children:[ne("span",{className:U.loadingBar}),ne("span",{className:U.loadingBar}),ne("span",{className:U.loadingBar})]}):de&&(re=De("div",{className:U.note,"data-aia-location-note":"",children:[e.status==="done"&&ne("span",{className:U.empty,children:t}),ne("span",{children:a})]})),De("div",{ref:c,className:U.location,"data-aia-location":"",onMouseDown:d=>{!(d.target instanceof Node)||!v.current?.contains(d.target)||(d.stopPropagation(),T(),N(!0))},children:[De("label",{ref:v,className:U.field,children:[ti,ne("input",{ref:h,type:"text",className:U.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:o,"aria-label":o,"aria-activedescendant":ae,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:d=>f(d.target.value),onFocus:d=>{V(d.relatedTarget),N(!0)},onBlur:()=>{z.current||(O.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;K(!0),y();return;case"Escape":d.preventDefault(),d.stopPropagation(),O.current=!0,K();return;case"Backspace":if(d.currentTarget.value!=="")return;d.preventDefault(),O.current=!0,K();return}}})]}),ne("div",{className:U.results,"data-aia-location-results":"","aria-live":"polite",children:re})]})}import{isSmartSuggestion as ni,isTraditionalAutocompleteSuggestion as ri}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ai}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,
|
|
2116
2144
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
2117
2145
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
2118
2146
|
as it was when the outline was dashed. */
|
|
@@ -2270,7 +2298,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2270
2298
|
opacity: 0;
|
|
2271
2299
|
}
|
|
2272
2300
|
}
|
|
2273
|
-
`,document.head.appendChild(e)}var xe={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 ii,jsx as kt,jsxs as oi}from"react/jsx-runtime";var Ct={selected:1,first:.7,next:.4,last:.2};function ea({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let
|
|
2301
|
+
`,document.head.appendChild(e)}var xe={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 ii,jsx as kt,jsxs as oi}from"react/jsx-runtime";var Ct={selected:1,first:.7,next:.4,last:.2};function ea({label:e,state:o,active:t,rounded:a,loading:i,smartSuggestion:s,completionHeader:r,onClick:l}){let f=[xe.pill,a?xe.rounded:"",i?xe.skeleton:""].filter(Boolean).join(" ");return kt("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:f,style:{"--aia-pill-opacity":Ct[o]},onMouseDown:w=>w.preventDefault(),onClick:i?void 0:l,disabled:i,children:s?oi(ii,{children:[kt("span",{className:`${xe.smartText} magicx-aia-smart-suggestion-text`,children:e}),kt("span",{className:`${xe.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ai}})]}):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 {
|
|
2274
2302
|
position: relative;
|
|
2275
2303
|
z-index: 1;
|
|
2276
2304
|
pointer-events: auto;
|
|
@@ -2280,7 +2308,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2280
2308
|
align-items: center;
|
|
2281
2309
|
vertical-align: middle;
|
|
2282
2310
|
}
|
|
2283
|
-
`,document.head.appendChild(e)}var St={list:"aia-list-qvLqO"};import{jsx as ht}from"react/jsx-runtime";var si=[125,69];function ta(e){return e===0?"first":e===1?"next":"last"}function ut({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?ht("span",{className:St.list,"data-aia-pill-list-loading":"",children:si.map((r,l)=>ht("span",{"data-aia-pill-skeleton":"",className:`${xe.pill} ${i?xe.rounded:""} ${xe.skeleton}`,style:{width:r,"--aia-pill-opacity":Ct[ta(l)]}},`skel-${r}`))}):ht("span",{className:St.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let
|
|
2311
|
+
`,document.head.appendChild(e)}var St={list:"aia-list-qvLqO"};import{jsx as ht}from"react/jsx-runtime";var si=[125,69];function ta(e){return e===0?"first":e===1?"next":"last"}function ut({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:i,loading:s}){return s&&e.length===0?ht("span",{className:St.list,"data-aia-pill-list-loading":"",children:si.map((r,l)=>ht("span",{"data-aia-pill-skeleton":"",className:`${xe.pill} ${i?xe.rounded:""} ${xe.skeleton}`,style:{width:r,"--aia-pill-opacity":Ct[ta(l)]}},`skel-${r}`))}):ht("span",{className:St.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let f=!!a&&l===o;return ht(ea,{label:r.text,state:f?"selected":ta(l),selected:f,active:l===o,rounded:i,loading:s,smartSuggestion:ni(r),completionHeader:ri(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}import{attachProductRowWheel as li,productImageSources as di,productImageSrc as ci,productInitial as pi,productPhotoFill as hi,uiStringsFor as ui}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Tt,useRef as mt,useState as gt}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
|
|
2284
2312
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
2285
2313
|
theming one package sees the same result in the other.
|
|
2286
2314
|
|
|
@@ -2849,7 +2877,31 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2849
2877
|
.aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2850
2878
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2851
2879
|
}
|
|
2852
|
-
|
|
2880
|
+
|
|
2881
|
+
/* The strip leaves and returns with the options: it fades out on the same
|
|
2882
|
+
160ms while a request loads and fades back when the response lands, so a
|
|
2883
|
+
step change never leaves it at full strength over rows that are gone. */
|
|
2884
|
+
.aia-section-Hugfg[data-aia-loading] {
|
|
2885
|
+
pointer-events: none;
|
|
2886
|
+
animation: aia-stripLoadingOut-0jOOQ 160ms ease-in forwards;
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
.aia-section-Hugfg:not([data-aia-loading]) {
|
|
2890
|
+
animation: aia-stripFadeIn-0p9qx 160ms ease-out;
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
@keyframes aia-stripLoadingOut-0jOOQ {
|
|
2894
|
+
to {
|
|
2895
|
+
opacity: 0.01;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
@keyframes aia-stripFadeIn-0p9qx {
|
|
2900
|
+
from {
|
|
2901
|
+
opacity: 0.01;
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
`,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",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 aa({products:e,listboxId:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s=!0,loading:r=!1,layout:l="row",imageFallback:f="image",strings:w=ui()}){let y=e.length>0,g=mt(null);if(Tt(()=>{let c=g.current;if(!(!y||!c))return li(c)},[y]),!y)return null;let h=`${o}-products-label`;return Ze("section",{className:Q.section,"data-aia-products":"","data-aia-loading":r?"":void 0,"data-aia-products-layout":l,role:"group","aria-labelledby":h,children:[X("div",{className:Q.label,id:h,"data-aia-products-label":"",children:w.products}),X("div",{ref:g,className:Q.row,"data-aia-products-row":"",children:e.map((c,v)=>X(mi,{product:c,id:`${o}-product-${v}`,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:f,soldOut:w.soldOut,addToCart:w.addToCart},c.id))})]})}function mi({product:e,id:o,onSelect:t,onAddToCart:a,onFocusChange:i,focusable:s,imageFallback:r,soldOut:l,addToCart:f}){let w=!!a&&e.available!==!1,[y,g]=gt(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:Q.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(bi,{sources:di(e.imageUrl),title:e.title,fallback:r,onPhotoFill:g},ci(e.imageUrl)??""),Ze("span",{className:Q.body,children:[e.vendor?X("span",{className:Q.vendor,children:e.vendor}):null,X("span",{className:Q.title,children:e.title}),e.price?Ze("span",{className:Q.price,children:[e.price,e.compareAtPrice?X("s",{className:Q.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?X("span",{className:Q.badge,children:l}):null]}),w&&a?X(fi,{product:e,label:`${f}: ${e.title}`,focusable:s,onAddToCart:a,onFocus:()=>i?.(!0),onBlur:h},gi(e)):null]})}function gi(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(o=>o??"").join("\0")}function fi({product:e,label:o,focusable:t,onAddToCart:a,onFocus:i,onBlur:s}){let[r,l]=gt(null),f=mt(null),w=mt(e);w.current=e;let y=mt(!0);Tt(()=>(y.current=!0,()=>{y.current=!1}),[]);let g=c=>{f.current=c,y.current&&l(c)},h=c=>{if(c.preventDefault(),c.stopPropagation(),f.current==="adding")return;g("adding");let v;try{v=Promise.resolve(a(w.current))}catch(I){v=Promise.reject(I)}v.then(()=>g("added"),()=>g(null))};return X("span",{className:Q.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:Q.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:Q.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),X("path",{className:Q.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),X("path",{className:Q.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),X("circle",{className:Q.cartGlyph,cx:"9",cy:"20",r:"1.3"}),X("circle",{className:Q.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function bi({sources:e,title:o,fallback:t,onPhotoFill:a}){let[i,s]=gt(0),r=e[i],l=!!r,[f,w]=gt(null),y=!l&&t==="initial";return Tt(()=>()=>a(null),[a]),Ze("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&f===r?"":void 0,children:[l?X("img",{className:Q.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:g=>{w(r),a(hi(g.currentTarget.naturalWidth,g.currentTarget.naturalHeight))},onError:()=>{i+1>=e.length&&a(null),s(g=>g+1)}}):null,y?pi(o):null]})}import{isOptionsGridMobileViewport as Li,measureOptionsGrid as zi,needsOptionsGridMeasurement as Di,OPTIONS_GRID_MOBILE_QUERY as Mi,optionEnterDelayMs as Ni,optionsShowLeadingVisuals as Fi,planOptionsGrid as ra,releasePanelHug as Hi,sameOptionRows as Bi,syncPanelHug as Wi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Gi,useLayoutEffect as sa,useRef as la,useState as ca}from"react";import{optionsGridTemplateColumns as wi}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as vi,useRef as xi}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 {
|
|
2853
2905
|
display: grid;
|
|
2854
2906
|
grid-template-columns: repeat(
|
|
2855
2907
|
auto-fit,
|
|
@@ -2893,7 +2945,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
2893
2945
|
:where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
|
|
2894
2946
|
max-height: var(--aia-grid-max-height, 120px);
|
|
2895
2947
|
}
|
|
2896
|
-
`,document.head.appendChild(e)}import{jsx as yi}from"react/jsx-runtime";function ia({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:
|
|
2948
|
+
`,document.head.appendChild(e)}import{jsx as yi}from"react/jsx-runtime";function ia({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:i,scrollResetKey:s,cols:r,template:l,innerRef:f,className:w,children:y,...g}){let h=xi(null);vi(()=>{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=wi(r)),l&&(c.gridTemplateColumns=l),yi("div",{ref:v=>{h.current=v,f?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:c,...g,children:y})}import{formatOptionCount as ki,highlightParts as Ci,isMultiSelectToggleTap as Si,OPTION_ENTER_DELAY_VAR as Ti,optionImageSources as Pi,optionLabel as oa,sanitizeOptionIconSvg as Ii}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ei,useMemo as Ai,useRef as Oi,useState as ft}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 {
|
|
2897
2949
|
position: relative;
|
|
2898
2950
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2899
2951
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -3413,7 +3465,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3413
3465
|
border-radius: 6px;
|
|
3414
3466
|
font-size: 11px;
|
|
3415
3467
|
}
|
|
3416
|
-
`,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
|
|
3468
|
+
`,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 Ri,jsx as Se,jsxs as Pt}from"react/jsx-runtime";function na({option:e,isHighlighted:o,checked:t,onSelect:a,onHighlight:i,onUnhighlight:s,id:r,loading:l,showIcon:f=!0,showImage:w=!0,showCount:y=!0,scrollHint:g,enterDelayMs:h=0}){let[c]=ft(h),[v,I]=ft(!1),_=w?Pi(e.image_url):[],z=_[0]??null,[O,te]=ft([]),S=_.find(E=>!O.includes(E))??null,[M,H]=ft(null),N=Ai(()=>!z&&f&&e.icon_svg?Ii(e.icon_svg):null,[z,f,e.icon_svg]),B=y?ki(e.item_count):null,T=Oi(void 0);Ei(()=>()=>clearTimeout(T.current),[]);let V=E=>{if(l||!e.is_tappable||v&&t===void 0)return;I(!0);let K=E?.currentTarget;t!==void 0&&K!==void 0&&E!==void 0&&!Si(K,K.querySelector("[data-aia-checkbox]"),E)?a(e,{commit:!0}):a(e),clearTimeout(T.current),T.current=setTimeout(()=>I(!1),170)},Y=[J.item,o&&!l?J.highlighted:"",e.liveMatch&&!l?J.liveMatch:"",e.is_tappable?J.tappable:J.nonTappable,v?J.pressed:"",g?J.scrollHint:""].filter(Boolean).join(" ");return Se("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":N&&e.icon?e.icon:void 0,"data-aia-image":z?"":void 0,"data-aia-item-count":B!==null?e.item_count:void 0,"aria-selected":t??o,className:Y,style:{[Ti]:`${c}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:V,onKeyDown:E=>{!l&&e.is_tappable&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),V())},onMouseEnter:!l&&e.is_tappable?i:void 0,onMouseLeave:s,children:Pt("span",{className:J.content,children:[t!==void 0&&e.is_tappable&&Se("span",{className:J.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),z&&Se("span",{className:`${J.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":S!==null&&M===S?"":void 0,children:Se("img",{src:S??z,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onLoad:()=>H(S),onError:()=>{S!==null&&te(E=>[...E,S])}})}),N&&Se("span",{className:`${J.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:N}}),Pt("span",{className:J.text,children:[e.matchedText?Ci(oa(e),e.matchedText).map((E,K)=>E.bold?Se("strong",{className:`${J.match} magicx-aia-option-match`,children:E.text},K):E.text):oa(e),e.parameterLabel&&Pt(Ri,{children:[" ",Se("span",{className:`${J.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Se("span",{className:J.tag,children:e.tag}),B!==null&&Se("span",{className:`${J.count} magicx-aia-option-count`,children:B})]})})}import{jsx as da}from"react/jsx-runtime";function Ki(){let[e,o]=ca(Li);return Gi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Mi),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function pa({options:e,activeIndex:o,picked:t,onSelect:a,onHighlight:i,onUnhighlight:s,listboxId:r,loading:l,groupKey:f="",optionsPosition:w="below",showIcons:y=!0,showImages:g=!0,showCounts:h=!0}){let c=Ki(),v=la(null),[I,_]=ca(null),z=la(null);sa(()=>{if(l&&Bi(z.current,e))return;z.current=l?null:e;let S=v.current,M=S&&!l&&Di(e.length,c),H=S?.closest("[data-aia-dropdown]");M&&H&&Hi(H);let N=M?zi(S):null;_(N?ra(e.length,c,N.rowWidths,N.gridWidth):null)},[e,c,l]);let O=I??ra(e.length,c,null,null);sa(()=>{let S=v.current?.closest("[data-aia-dropdown]");S&&Wi(S)},[O.template,c]);let te=Fi(e,y,g);return da(ia,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:f,template:O.template,maxHeight:O.maxHeight,innerRef:S=>{v.current=S},"data-aia-group":f,children:e.map((S,M)=>da(na,{option:S,isHighlighted:M===o,checked:t?t.includes(S.text):void 0,onSelect:a,onHighlight:()=>i(M),onUnhighlight:s?()=>s(M):void 0,id:`${r}-option-${M}`,loading:l,showIcon:y&&te,showImage:g&&te,showCount:h,scrollHint:!l&&O.scrollHintIndices.includes(M),enterDelayMs:l?0:Ni(M,O.cols,e.length,w)},`${f}\0${S.text}`))})}import{formatTime as qi,TIME_WHEEL_COLUMNS as _i,TIME_WHEEL_ROW_HEIGHT as Vi,timeWheelIndex as ha,timeWheelIndexFromScroll as Ui,timeWheelRows as Qi,withTimeWheelIndex as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{Fragment as Yi,useEffect as ji,useLayoutEffect as $i,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) ---
|
|
3417
3469
|
|
|
3418
3470
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
3419
3471
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3535,7 +3587,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3535
3587
|
.aia-done-llNY5:hover {
|
|
3536
3588
|
background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
|
|
3537
3589
|
}
|
|
3538
|
-
`,document.head.appendChild(e)}var ue={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 It}from"react/jsx-runtime";var Zi=120;function ma({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return It("div",{className:ue.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[Qe("span",{className:ue.value,"data-aia-time-value":"","aria-live":"polite",children:qi(e.minutes)}),It("div",{className:ue.columns,"aria-hidden":"true",children:[Qe("div",{className:ue.band}),_i.map(r=>It(Yi,{children:[r==="minute"&&Qe("span",{className:ue.separator,children:":"}),Qe(Xi,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),Qe("button",{type:"button",tabIndex:-1,className:ue.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function Xi({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
|
|
3590
|
+
`,document.head.appendChild(e)}var ue={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 It}from"react/jsx-runtime";var Zi=120;function ma({view:e,label:o,doneLabel:t,interactive:a=!0,onTimeChange:i,onTimeCommit:s}){return It("div",{className:ue.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":o,onMouseDown:r=>r.preventDefault(),children:[Qe("span",{className:ue.value,"data-aia-time-value":"","aria-live":"polite",children:qi(e.minutes)}),It("div",{className:ue.columns,"aria-hidden":"true",children:[Qe("div",{className:ue.band}),_i.map(r=>It(Yi,{children:[r==="minute"&&Qe("span",{className:ue.separator,children:":"}),Qe(Xi,{column:r,minutes:e.minutes,interactive:a,onTimeChange:i})]},r))]}),Qe("button",{type:"button",tabIndex:-1,className:ue.done,"data-aia-time-done":"",onClick:()=>{a&&s()},children:t})]})}function Xi({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 f=ha(e,o);$i(()=>{let g=i.current;if(!g||r.current)return;let h=f*Vi;Math.abs(g.scrollTop-h)<1||(s.current=h,g.scrollTop=h)},[f]),ji(()=>()=>{r.current&&clearTimeout(r.current)},[]);let w=()=>{r.current=null;let g=i.current,h=l.current;if(!g||!h.interactive)return;let c=Ui(e,g.scrollTop);c!==ha(e,h.minutes)&&h.onTimeChange(ua(e,h.minutes,c))},y=()=>{let g=i.current;if(g){if(s.current!=null&&Math.abs(g.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(w,Zi)}};return Qe("div",{ref:i,className:ue.column,"data-aia-time-column":e,onScroll:y,children:Qi(e).map((g,h)=>Qe("div",{className:h===f?`${ue.row} ${ue.selected}`:ue.row,"data-aia-time-row":"","data-aia-index":h,onClick:()=>{l.current.interactive&&a(ua(e,l.current.minutes,h))},children:g.label},g.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3539
3591
|
display: flex;
|
|
3540
3592
|
flex-direction: column;
|
|
3541
3593
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3550,7 +3602,7 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3550
3602
|
align-items: end;
|
|
3551
3603
|
}
|
|
3552
3604
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3553
|
-
`,document.head.appendChild(e)}import{jsx as Ji}from"react/jsx-runtime";function ga({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Ji("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as ie,jsxs as Et}from"react/jsx-runtime";var bo=typeof window>"u"?Ye:At,wo=[159,119,164],vo=()=>{},fa=()=>{},xo=e=>{},yo=()=>{},ko=e=>{},Co=e=>{},So=e=>{},To=e=>{};function Po(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=fo(o);if(Ye(()=>{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 Io(e,o){let t=Xe(null);Ye(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=ho(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:eo({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),Ye(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Eo(e,o){let t=Xe(o);t.current=o;let a=Xe(null);At(()=>{let i=e.current;if(i){if(!a.current){a.current=to({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Ye(()=>()=>{a.current?.destroy(),a.current=null},[])}function
|
|
3605
|
+
`,document.head.appendChild(e)}import{jsx as Ji}from"react/jsx-runtime";function ga({space:e,align:o="stretch",className:t,children:a,...i}){let s=e?{"--aia-stack-space":e}:void 0;return Ji("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:s,...i,children:a})}import{jsx as ie,jsxs as Et}from"react/jsx-runtime";var bo=typeof window>"u"?Ye:At,wo=[159,119,164],vo=()=>{},fa=()=>{},xo=e=>{},yo=()=>{},ko=e=>{},Co=e=>{},So=e=>{},To=e=>{};function Po(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=fo(o);if(Ye(()=>{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 Io(e,o){let t=Xe(null);Ye(()=>{let a=e.current,i=o.current;if(!a||!i)return;let s=ho(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:eo({dropdown:a,grid:s,button:i})};return}t.current?.controller.update()}),Ye(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Eo(e,o){let t=Xe(o);t.current=o;let a=Xe(null);At(()=>{let i=e.current;if(i){if(!a.current){a.current=to({dropdown:i,isOpen:()=>t.current});return}a.current.update()}}),Ye(()=>()=>{a.current?.destroy(),a.current=null},[])}function Ot({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:i,isOpen:s,id:r,className:l,pills:f,onPillClick:w,showPills:y=!0,onSkip:g,showSkipButton:h=!0,showOptionIcons:c=!0,showOptionImages:v=!0,showOptionCounts:I=!0,skipDisabled:_=!1,activeSelected:z=!1,isLoading:O=!1,skeletonExiting:te=!1,isInputEmpty:S=!1,language:M,products:H,onProductSelect:N,onProductAddToCart:B,onProductFocusChange:T,productsLayout:V="row",productImageFallback:Y="image",formatType:E="options",dateView:K=null,selectedDateIso:de=null,selectedDateRange:ae=null,dateRangeStart:re=null,dateReferences:d,onPreviousMonth:P,onNextMonth:Te,timeView:m=null,multiSelectView:Me=null,onMultiSelectCommit:Pe,onTimeChange:Ie,onTimeCommit:Ee,locationView:ye=null,isReediting:Ae=!1,onLocationQuery:u,onLocationMove:k,onLocationCommit:C,onLocationFocusChange:A,isFocused:R=!1,optionsPosition:W="below",mode:ce}){let pe=Po(ce),ge=pe!==void 0,j=Xe(null),Ne=Xe(null);Io(j,Ne),Ye(()=>{if(j.current)return ao(j.current)},[]);let Fe=e[0]?.options??[],He=!!(f&&f.length>0&&w),Oe=!!(H&&H.length>0),Be=E==="time"&&m!=null,We=E==="location"&&ye!=null,Z=s&&(Fe.length>0||y&&He||O||Oe||Be||We);Eo(j,Z),bo(()=>{let F=j.current;F&&(ro(F,no(F)),mo(F))});let x={suggestions:e,activeIndex:o,pills:f,showPills:y,showSkipButton:h,showOptionIcons:c,showOptionImages:v,showOptionCounts:I,skipDisabled:_,activeSelected:z,isLoading:O,skeletonExiting:te,isInputEmpty:S,products:H,formatType:E,dateView:K,selectedDateIso:de,selectedDateRange:ae,dateRangeStart:re,dateReferences:d,timeView:m,multiSelectView:Me,locationView:ye,isReediting:Ae},Ge=Xe(x);Z&&(Ge.current=x);let n=Z?x:Ge.current,$=go(M),b=n.suggestions[0],fe=b?.options??[],Ke=n.activeIndex>=0&&!!fe[n.activeIndex]?.is_tappable,se=co(n.pills??[],$.keepTyping),Re=!!(se.length>0&&w),qe=n.showPills&&Re,Le=n.showPills&&!Re&&n.isLoading,je=qe||Le,he=Re&&so(se)&&n.showSkipButton&&!n.isInputEmpty&&!!g,be=se[0]?.text,ze=lo(n.formatType)&&n.dateView!=null,_e=fe.length>0&&!ze,$e=fe.length>0&&ze&&!n.isLoading,ke=n.formatType==="time"&&n.timeView!=null&&!n.isLoading,Ve=n.formatType==="location"&&n.locationView!=null&&!n.isLoading,p=n.isLoading&&!_e&&!$e&&!ke&&!Ve,G=n.products??[],L=po(qe?se:[]);return At(()=>{j.current&&uo(j.current,L,{visible:Z,anchorBottom:W==="above"})},[L,Z,W,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,V,M]),Ye(()=>{let F=j.current;return()=>{F&&oo(F)}},[]),Et("div",{ref:j,id:r,role:"listbox","aria-multiselectable":!!n.multiSelectView,"data-aia-dropdown":"","data-options-position":W,"data-mode":pe,"data-aia-loading":n.isLoading?"":void 0,"data-aia-skeleton-exiting":n.skeletonExiting?"":void 0,"data-aia-has-products":G.length>0?"":void 0,className:`${ge?"magicx-aia ":""}${we.dropdown} ${Z?we.visible:""} ${l??""}`,onMouseDown:F=>F.preventDefault(),children:[Et(ga,{space:"8px",children:[(je||he)&&Et(st,{noWrap:!0,className:we.pillBar,"data-aia-pillbar":"",children:[je&&ie("span",{className:we.pillScroll,"data-aia-pill-scroll":"",children:ie(ut,{pills:se,activePillIndex:0,activeSelected:n.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:n.isLoading})}),he&&ie("button",{type:"button",tabIndex:-1,className:we.skip,"data-aia-skip":"",disabled:n.isLoading||n.skipDisabled,"aria-label":be?`${$.skipLabel} ${be}`:$.skipLabel,onClick:g,children:$.skip})]}),_e&&ie(pa,{options:fe,activeIndex:n.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:i,listboxId:r,loading:n.isLoading,groupKey:b?`${b.parameter} ${b.text}`:"",optionsPosition:W,showIcons:n.showOptionIcons,showImages:n.showOptionImages,showCounts:n.showOptionCounts,picked:n.multiSelectView?.picked}),n.multiSelectView&&ie("div",{"data-aia-multi-actions":"",onClick:F=>{F.target.closest("[data-aia-multi-done]")&&!n.skipDisabled&&!n.isLoading&&Pe?.()},children:ie("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:we.multiDone,ref:F=>{F&&(F.disabled=!0,F.offsetHeight,F.disabled=n.skipDisabled||n.isLoading)},children:$.done})}),$e&&n.dateView&&ie(Ut,{options:fe,activeIndex:n.activeIndex,listboxId:r,view:n.dateView,selection:{selectedIso:n.selectedDateIso??null,selectedRange:n.selectedDateRange??null,rangeStart:n.dateRangeStart??null,floor:io(n.formatType,n.dateRangeStart),references:n.dateReferences??[]},onSelect:t,onHighlight:a,onUnhighlight:i,onPreviousMonth:P??fa,onNextMonth:Te??fa}),ke&&n.timeView&&ie(ma,{view:n.timeView,label:$.timeLabel,doneLabel:$.done,interactive:!n.skipDisabled,onTimeChange:Ie??xo,onTimeCommit:Ee??yo}),Ve&&n.locationView&&ie(Jt,{view:n.locationView,searchLabel:$.locationSearch,noResultsLabel:$.locationNoResults,useTypedLabel:$.locationUseTyped,widgetFocused:R&&Z,reediting:n.isReediting,visible:Z,interactive:!n.skipDisabled,onQuery:u??ko,onMove:k??Co,onCommit:C??So,onFocusChange:A??To}),p&&ie("div",{className:we.skeletonBars,"data-aia-skeleton-bars":"",children:wo.map(F=>ie("span",{className:we.skeletonBar,style:{width:F}},`bar-${F}`))}),ie(aa,{products:G,listboxId:r,onSelect:N??vo,onAddToCart:B,onFocusChange:T,focusable:Z&&!n.isLoading,loading:n.isLoading,layout:V,imageFallback:Y,strings:$}),ie(Yt,{isOptionHighlighted:Ke,isInputEmpty:n.isInputEmpty,strings:$})]}),ie("button",{ref:Ne,type:"button",tabIndex:-1,className:we.scrollArrow,"data-aia-scroll-arrow":"","aria-label":$.scrollArrow,"aria-hidden":"true",children:ie("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:ie("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Qo,ModeController as Yo,setCursorOffset as jo,uiStringsFor as $o,watchEditorHeight as Zo}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as Ao}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 {
|
|
3554
3606
|
flex-shrink: 0;
|
|
3555
3607
|
width: 32px;
|
|
3556
3608
|
height: 32px;
|
|
@@ -3621,5 +3673,5 @@ import{buildSubmitResult as rs,cellDay as ss,cellIso as ls,DATE_RANGE_META_END a
|
|
|
3621
3673
|
transition: none;
|
|
3622
3674
|
}
|
|
3623
3675
|
}
|
|
3624
|
-
`,document.head.appendChild(e)}var ba={submitButton:"aia-submitButton-otz7H"};import{jsx as Ot}from"react/jsx-runtime";function wa({disabled:e,ready:o,onClick:t,label:a=Ao().submit}){return Ot("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:Ot("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:Ot("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ro,dateSelectionFor as Oo,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,m,w)=>{let y=o.current?.[s];return y?y(l,m,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,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,dateReferences:[],dateFloor:null,timeView:null,multiSelectView: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:m,productId:w,visitorId:y,columns:f=2,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showOptionIcons:R,showOptionImages:te,showOptionCounts:S,showSkipButton:M,showProducts:F,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 g=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 O=ee(re);O.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,He=ae?Ne:void 0,Fe=xa(a);Je(()=>{if(typeof document>"u")return;let p=new Ro(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:m,productId:w,visitorId:pe,optionOverrides:Fe.overrides,maskCompletedText:i,columns:f,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:F,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=>O.current?.(L),onProductAddToCart:L=>W.current?.(L),setCursor:L=>A.current?.(L),products:ge.config,mapProducts:He});g.current=p,Pe(p.getState());let G=p.subscribe(L=>Pe(L));return()=>{G(),p.destroy(),g.current===p&&(g.current=null)}},[]),Je(()=>{V!==void 0&&g.current?.setValue(V)},[V]),Je(()=>{Y!==void 0&&g.current?.setCompletedParams(Y)},[Y]);let Re=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:m,productId:w,optionOverrides:Fe.overrides,dropdownTrigger:c,optionsPosition:h,closeDropdownOnBlur:x,prependPlaceholder:I,showNonTappableOptions:_,locationSearch:z,showProducts:F})},[Re,Be,l,m?.code,m?.rate,m?.country,w,Fe.key,c,h,x,I,_,z,F]);let We=ee(!1);Je(()=>{if(!We.current){We.current=!0;return}g.current?.update({products:ge.config})},[ge.enabled]),Je(()=>{g.current?.update({mapProducts:He})},[He]);let Z=ee(null);Z.current===null&&(Z.current={handleTextChange:p=>g.current?.handleTextChange(p),handleKeyDown:p=>{let G="nativeEvent"in p?p.nativeEvent:p;g.current?.handleKeyDown(G)},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()??Sa,recordSubmit:p=>g.current?.recordSubmit(p),selectOption:(p,G)=>g.current?.selectOption(p,G),selectProduct:p=>g.current?.selectProduct(p),addProductToCart:p=>{let G=g.current;return!G||!W.current?Promise.resolve():G.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 v=Z.current,Ge=Ca(p=>{let G=p.target.value,H=G.length>0&&!p.nativeEvent?.isComposing&&G[0]!==G[0].toUpperCase()?G[0].toUpperCase()+G.slice(1):G;g.current?.handleTextChange(H)},[]),n=Ca(p=>{g.current?.handleKeyDown(p.nativeEvent)},[]),$=g.current,b=Me??Sa,fe=V!==void 0?V:b.text,Ke=Y!==void 0?Y:b.completedParams,se=b.actionableSuggestions,Oe=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??Oe,$e=ze?[ze]:se,ke=Oo(b),Ve=!$||b.dropdownLoading;return{completedParams:Ke,multiSelectView:b.multiSelectView,toggleMultiSelectOption:v.toggleMultiSelectOption,commitMultiSelect:v.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:qe,setActivePill:v.setActivePill,skipActivePill:v.skipActivePill,removeLastParam:v.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:v.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:v.selectProduct,addProductToCart:v.addProductToCart,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:he,editingIdentified:be,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:v.startEditingParam,removeParam:v.removeParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:fe,placeholder:b.placeholderText||void 0,onChange:Ge,onKeyDown:n,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":je,"aria-autocomplete":"list","aria-controls":Le},reset:v.reset,refreshProducts:v.refreshProducts,prepareSubmit:v.prepareSubmit,getState:v.getState,recordSubmit:v.recordSubmit,dropdownProps:{suggestions:_e?[{..._e,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,onUnhighlight:v.clearHighlight,isOpen:b.isDropdownOpen,id:Le,pills:$e,activeSelected:b.isActivePillSelected,onPillClick:v.setActivePill,onSkip:v.skipActivePill,showSkipButton:(M??!0)&&!he&&!be,showOptionIcons:R??!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:v.selectProduct,onProductAddToCart:d?v.addProductToCart:void 0,onProductFocusChange:v.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:ke.selectedIso,selectedDateRange:ke.selectedRange,dateRangeStart:ke.rangeStart,dateReferences:ke.references,onPreviousMonth:v.showPreviousMonth,onNextMonth:v.showNextMonth,timeView:b.timeView,multiSelectView:b.multiSelectView,onMultiSelectCommit:v.commitMultiSelect,onTimeChange:v.setTime,onTimeCommit:v.commitTime,locationView:b.locationView,isReediting:b.editingParam!=null,onLocationQuery:v.setLocationQuery,onLocationMove:v.moveLocationHighlight,onLocationCommit:v.commitLocation,onLocationFocusChange:v.setLocationFieldFocused,isFocused:b.isFocused||b.locationFieldFocused,optionsPosition:h??"below"}}}import{attachChipRemove as No,cancelStartingHint as Ho,chipIdFromTap as Fo,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:m,editingAnchor:w,caretOffset:y,placeholderText:f,hintSuggestions:c,isFocused:h,isDropdownOpen:x,listboxId:I,activeDescendantId:_,autoFocus:z,handleTextChange:R,handleKeyDown:te,handleCaretAfterInput:S,handleCaretMove:M,startEditingParam:F,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 O=k.createRange();O.selectNodeContents(u),O.collapse(!0),C.removeAllRanges(),C.addRange(O)}},[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 O=A.anchorNode,W=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement,pe=(A.isCollapsed?W?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=l?.id??m?.id??null;if(pe&&pe!==ge){F(pe);return}performance.now()-de.current<50||M(Pa(u))};return k.addEventListener("selectionchange",C),()=>k.removeEventListener("selectionchange",C)},[l,m,F,M]),et(()=>{let u=T.current;if(!u)return;let k=C=>{let A=Fo(u,C.target);A&&(F(A),Bo(u,A))};return u.addEventListener("click",k),()=>u.removeEventListener("click",k)},[F]),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:f??"",isFocused:h,showChipIcons:t,showChipImages:a,showChipRemove:i,hintOptions:Ko(c??[])})},[o,r,l,f,c,h,t,a,i]),et(()=>{let u=T.current;return()=>{u&&Ho(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;R(A)},[R]),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,O=A.inputType;if(O==="insertParagraph"||O==="insertLineBreak"||O==="insertFromDrop"){C.preventDefault();return}if(O.startsWith("insert")||O.startsWith("delete")){let W=O.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,O=A.getSelection();if(!O||O.rangeCount===0)return;let W=O.getRangeAt(0);if(!k.contains(W.startContainer))return;W.deleteContents();let ce=A.createTextNode(C);W.insertNode(ce),W.setStartAfter(ce),W.collapse(!0),O.removeAllRanges(),O.addRange(W),ae()},[ae]),g=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":x,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:re,onKeyDown:g,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:m,language:w,currency:y,productId:f,visitorId:c,columns:h,pillPlacement:x="dropdown",mode:I="auto",optionsPosition:_="below",animations:z=!0,optionsStyle:R="floating",dropdownTrigger:te,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:F,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:g,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,submitButton:C,resetOnSubmit:A=!0},O){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 He=Dt(D=>{let oe=Ne.current?.current;oe&&(oe.focus(),jo(oe,D))},[]),{completedParams:Fe,suggestionPills:Re,setActivePill:Be,skipActivePill:We,segments:Z,newParamId:v,clearNewParamId:Ge,placeholderText:n,isFocused:$,isDropdownOpen:b,isActivePillSelected:fe,isLoading:Ke,isReady:se,activeIndex:Oe,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:H,reset:ct,refreshProducts:Ht,prepareSubmit:Ft,getState:Bt,recordSubmit:Wt}=Lt({onSubmit:D=>ge.current(D),onResult:t,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:l,additionalContext:m,language:w,currency:y,productId:f,visitorId:c,columns:h,dropdownTrigger:te,optionsPosition:_,closeDropdownOnBlur:S,prependPlaceholder:M,showNonTappableOptions:F,locationSearch:N,showOptionIcons:B,showOptionImages:E,showOptionCounts:K,showSkipButton:de,showProducts:ae,onFocus:Te,onBlur:g,value:Me,completedParams:Pe,onChange:Ie,onParamsChange:Ee,products:ye,mapProducts:Ae,onProductSelect:u,onProductAddToCart:k,source:"full-sdk",setCursor:He});Mt(()=>{if(!v)return;let D=window.setTimeout(()=>Ge(),650);return()=>window.clearTimeout(D)},[v,Ge]);let Aa=Oe>=0?`${qe}-option-${Oe}`:void 0,{inputRef:vt,editorProps:Ra,focus:pt,blur:Gt,getPlainText:Kt}=Ea({segments:Z,newParamId:v,editingParam:be,editingIdentified:ze,editingAnchor:_e,caretOffset:$e,placeholderText:n,hintSuggestions:x==="inline"?[]:Re,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,Re.length,Ke,vt]),Mt(()=>{let D=pe.current;if(D)return Zo(D)},[]),Vo(O,()=>({focus:pt,blur:Gt,reset:ct,refreshProducts:Ht,setMode:D=>j.current?.setMode(D),skipActivePill:We}),[pt,Gt,ct,Ht,We]);let ot=!!Z.length||Fe.length>0,xt=Dt(D=>{if(!ot)return;D&&Ft();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,Ft,Bt,o,ct,Kt]);ge.current=()=>xt(!1);let Oa=Dt(D=>{D.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||pt()},[pt]),La=x==="inline",za=x==="dropdown";return Nt("div",{ref:W,className:`magicx-aia ${Ue.container} ${r??""}`,"data-pill-placement":x,"data-options-position":_,"data-animations":z?"on":"off","data-aia-options-style":R,"data-mode":Xo(I),children:[it(Rt,{...H,showPills:za,productsLayout:re,productImageFallback:d}),Nt("div",{className:Ue.inputWrapper,"data-aia-input-wrapper":"",onClick:Oa,children:[Nt("div",{ref:pe,className:Ue.editorArea,"data-aia-editor":"",children:[it("div",{...Ra,className:Ue.input,"data-aia-input":""}),La&&(Ke||Re.length>0)&&it("span",{ref:ce,className:Ue.pillListContainer,"data-aia-pill-list-container":"",children:it(ut,{pills:Re,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,Rt 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,Hs 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,Rs as parseLooseDateRange,Os as parseTime,Ls as productFromMatchedItem,zs as productImageSources,Ds as productsFromCustomFields,Ms as sanitizeOptionIconSvg,Ns as selectedRangeFor,Lt as useAIAutocomplete,Fs as visibleDateRange,Ws as withSkippedParams};
|
|
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};
|
|
3625
3677
|
//# sourceMappingURL=index.mjs.map
|