@magicx-eng/ai-autocomplete-react 0.61.1 → 0.62.1
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 +11 -5
- package/REFERENCE.md +100 -1
- package/dist/index.d.mts +79 -9
- package/dist/index.d.ts +79 -9
- package/dist/index.js +140 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Wa=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Gt=(e,i)=>{for(var t in i)Wa(e,t,{get:i[t],enumerable:!0})},Kt=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of Bt(i))!Wt.call(e,o)&&o!==t&&Wa(e,o,{get:()=>i[o],enumerable:!(n=Ht(i,o))||n.enumerable});return e};var qt=e=>Kt(Wa({},"__esModule",{value:!0}),e);var bi={};Gt(bi,{AIAutocomplete:()=>At,AIAutocompleteDropdown:()=>La,DATE_RANGE_META_END:()=>c.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>c.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>c.DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY:()=>c.LOCATION_META_KEY,PRODUCT_PATH_PREFIX:()=>c.PRODUCT_PATH_PREFIX,TIME_META_KEY:()=>c.TIME_META_KEY,WEEKDAY_LABELS:()=>c.WEEKDAY_LABELS,buildSubmitResult:()=>c.buildSubmitResult,cellDay:()=>c.cellDay,cellIso:()=>c.cellIso,dateCellMarks:()=>c.dateCellMarks,formatDate:()=>c.formatDate,formatDateRange:()=>c.formatDateRange,formatOptionCount:()=>c.formatOptionCount,formatPlace:()=>c.formatPlace,formatTime:()=>c.formatTime,isoDate:()=>c.isoDate,monthLabel:()=>c.monthLabel,optionCountLabel:()=>c.optionCountLabel,optionHasImage:()=>c.optionHasImage,optionImageSources:()=>c.optionImageSources,optionImageSrc:()=>c.optionImageSrc,optionLabel:()=>c.optionLabel,optionsShowLeadingVisuals:()=>c.optionsShowLeadingVisuals,parseDate:()=>c.parseDate,parseLooseDate:()=>c.parseLooseDate,parseLooseDateRange:()=>c.parseLooseDateRange,parseTime:()=>c.parseTime,productFromMatchedItem:()=>c.productFromMatchedItem,productImageSources:()=>c.productImageSources,productsFromCustomFields:()=>c.productsFromCustomFields,sanitizeOptionIconSvg:()=>c.sanitizeOptionIconSvg,selectedRangeFor:()=>c.selectedRangeFor,useAIAutocomplete:()=>Ma,visibleDateRange:()=>c.visibleDateRange,withSkippedParams:()=>c.withSkippedParams});module.exports=qt(bi);var c=require("@magicx-eng/ai-autocomplete-vanilla");var j=require("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
|
|
@@ -29,6 +29,16 @@
|
|
|
29
29
|
gap: 12px;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/* Opt-in focus ring on the whole field while the editor (or anything else in
|
|
33
|
+
it) has focus. Off by default: set --aia-focus-ring to an outline value
|
|
34
|
+
(\`2px solid #1668e3\`) and --aia-focus-ring-offset to pull it inside the
|
|
35
|
+
border (negative) or push it out. An outline, not a shadow, so it never
|
|
36
|
+
replaces --aia-shadow, and it follows the field's corner radius. */
|
|
37
|
+
.aia-inputWrapper-FLq1b:focus-within {
|
|
38
|
+
outline: var(--aia-focus-ring, none);
|
|
39
|
+
outline-offset: var(--aia-focus-ring-offset, 0px);
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
.aia-editorArea-7rBWq {
|
|
33
43
|
position: relative;
|
|
34
44
|
flex: 1;
|
|
@@ -85,6 +95,19 @@
|
|
|
85
95
|
-webkit-user-modify: read-write-plaintext-only;
|
|
86
96
|
}
|
|
87
97
|
|
|
98
|
+
/* The editor never draws a focus ring of its own; the field shows focus
|
|
99
|
+
instead (--aia-focus-ring above). A page-wide \`:focus-visible { outline \u2026 }\`
|
|
100
|
+
names a pseudo-class, so the consumer-isolation reset can't stop it, and it
|
|
101
|
+
ties with the editor's \`outline: none\` \u2014 whichever stylesheet loaded last
|
|
102
|
+
wins, and the page's loads last under a dev server, CSS-in-JS or
|
|
103
|
+
route-split CSS. The ring then outlines the bare editor: a blue bar beside
|
|
104
|
+
the caret while it is empty, a box around the text once it isn't. Pinned at
|
|
105
|
+
(0,3,0) so the editor stays bare whatever the load order. */
|
|
106
|
+
.aia-input-IW-P-[contenteditable]:focus,
|
|
107
|
+
.aia-input-IW-P-[contenteditable]:focus-visible {
|
|
108
|
+
outline: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
88
111
|
/* Completed params render as inline pills (Figma "RichTextPill") \u2014 a compact
|
|
89
112
|
~26px chip with regular-weight primary-color text on a faint-gray fill.
|
|
90
113
|
inline-block gives the padding/radius a box while the text stays part of the
|
|
@@ -406,7 +429,7 @@
|
|
|
406
429
|
transition: none;
|
|
407
430
|
}
|
|
408
431
|
}
|
|
409
|
-
`,document.head.appendChild(e)}var ha={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};var L=require("@magicx-eng/ai-autocomplete-vanilla"),
|
|
432
|
+
`,document.head.appendChild(e)}var ha={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};var L=require("@magicx-eng/ai-autocomplete-vanilla"),X=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
410
433
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
411
434
|
* Consumer CSS always wins without !important.
|
|
412
435
|
*
|
|
@@ -1262,7 +1285,8 @@
|
|
|
1262
1285
|
left: 0;
|
|
1263
1286
|
right: 0;
|
|
1264
1287
|
top: 100%;
|
|
1265
|
-
|
|
1288
|
+
/* Widest the panel gets; \`none\` lets it span the whole field. */
|
|
1289
|
+
max-width: var(--aia-dropdown-max-width, 544px);
|
|
1266
1290
|
/* Gap between the input box and the dropdown. Tunable via --aia-dropdown-offset. */
|
|
1267
1291
|
margin-top: var(--aia-dropdown-offset, 13px);
|
|
1268
1292
|
display: flex;
|
|
@@ -1623,6 +1647,39 @@
|
|
|
1623
1647
|
background: var(--aia-see-all-bg-hover, #3d3d3d);
|
|
1624
1648
|
}
|
|
1625
1649
|
|
|
1650
|
+
/* A submit in progress: the add-to-cart button's spinning arc turns beside
|
|
1651
|
+
the label, in the label's colour, until the page the submit opens takes
|
|
1652
|
+
over. Its margins cancel its width and its height at any
|
|
1653
|
+
--aia-spinner-size, so it takes no room in the line: the label stays where
|
|
1654
|
+
it was and the button keeps its size. A slower turn under reduced motion. The state sits
|
|
1655
|
+
in :where(), so a page's own rule on the attribute restyles or hides it. */
|
|
1656
|
+
.aia-seeAll-0Zbgc:where([data-aia-see-all-state="busy"])::after {
|
|
1657
|
+
content: "";
|
|
1658
|
+
display: inline-block;
|
|
1659
|
+
margin: calc(var(--aia-spinner-size, 16px) / -2) calc(-8px - var(--aia-spinner-size, 16px))
|
|
1660
|
+
calc(var(--aia-spinner-size, 16px) / -2) 8px;
|
|
1661
|
+
vertical-align: middle;
|
|
1662
|
+
box-sizing: border-box;
|
|
1663
|
+
width: var(--aia-spinner-size, 16px);
|
|
1664
|
+
height: var(--aia-spinner-size, 16px);
|
|
1665
|
+
border: var(--aia-spinner-width, 2px) solid var(--aia-see-all-spinner-color, currentColor);
|
|
1666
|
+
border-right-color: transparent;
|
|
1667
|
+
border-radius: 50%;
|
|
1668
|
+
animation: aia-seeAllSpin-jlsZP 0.8s linear infinite;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
@keyframes aia-seeAllSpin-jlsZP {
|
|
1672
|
+
to {
|
|
1673
|
+
transform: rotate(360deg);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1678
|
+
.aia-seeAll-0Zbgc:where([data-aia-see-all-state="busy"])::after {
|
|
1679
|
+
animation-duration: 2s;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1626
1683
|
/* The open panel's leaving ghost (panelMorph.ts) is a frozen copy of the
|
|
1627
1684
|
last step: the rows' own entrance must not replay in it while it fades. */
|
|
1628
1685
|
.aia-dropdown-yz2KC .magicx-aia-panel-ghost,
|
|
@@ -1726,7 +1783,7 @@
|
|
|
1726
1783
|
opacity: 1;
|
|
1727
1784
|
}
|
|
1728
1785
|
}
|
|
1729
|
-
`,document.head.appendChild(e)}var
|
|
1786
|
+
`,document.head.appendChild(e)}var Ce={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",seeAllRow:"aia-seeAllRow-icrau",seeAll:"aia-seeAll-0Zbgc",seeAllSpin:"aia-seeAllSpin-jlsZP",multiActionsLoadingOut:"aia-multiActionsLoadingOut-lSdMh",multiActionsFadeIn:"aia-multiActionsFadeIn-zbGTG",seeAllLoadingOut:"aia-seeAllLoadingOut-THnrl",seeAllFadeIn:"aia-seeAllFadeIn-1GWpl"};var J=require("@magicx-eng/ai-autocomplete-vanilla"),at=require("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) ---
|
|
1730
1787
|
|
|
1731
1788
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1732
1789
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1923,7 +1980,7 @@
|
|
|
1923
1980
|
opacity: 0.8;
|
|
1924
1981
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1925
1982
|
}
|
|
1926
|
-
`,document.head.appendChild(e)}var
|
|
1983
|
+
`,document.head.appendChild(e)}var $={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"};var xe=require("react/jsx-runtime"),_t=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function tt({options:e,activeIndex:i,listboxId:t,view:n,selection:o,onSelect:s,onHighlight:r,onUnhighlight:l,onPreviousMonth:b,onNextMonth:v}){let x=(0,J.isoDate)(new Date),f=(0,J.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,J.cellIso)(e[i]),selected:o.selectedRange,floor:o.floor});return(0,xe.jsxs)("div",{className:$.datepicker,"data-aia-datepicker":"",children:[(0,xe.jsxs)("div",{className:$.header,children:[(0,xe.jsx)("button",{type:"button",tabIndex:-1,className:$.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:b,children:"\u2039"}),(0,xe.jsx)("span",{className:$.month,"data-aia-date-month":"","aria-live":"polite",children:(0,J.monthLabel)(n)}),(0,xe.jsx)("button",{type:"button",tabIndex:-1,className:$.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:v,children:"\u203A"})]}),(0,xe.jsx)("div",{className:$.weekdays,"aria-hidden":"true",children:J.WEEKDAY_LABELS.map((h,u)=>(0,xe.jsx)("span",{className:$.weekday,children:h},_t[u]))}),(0,xe.jsx)("div",{className:$.grid,"data-aia-date-grid":"",children:e.map((h,u)=>(0,xe.jsx)(Vt,{option:h,id:`${t}-option-${u}`,index:u,isHighlighted:u===i&&h.is_tappable,isToday:(0,J.cellIso)(h)===x,isPast:(0,J.isDimmedDay)((0,J.cellIso)(h),x,o.floor),marks:(0,J.dateCellMarks)((0,J.cellIso)(h),{selectedIso:o.selectedIso,range:f,references:o.references}),onSelect:s,onHighlight:r,onUnhighlight:l},(0,J.cellIso)(h)??`pad-${u}`))})]})}function Vt({option:e,id:i,index:t,isHighlighted:n,isToday:o,isPast:s,marks:r,onSelect:l,onHighlight:b,onUnhighlight:v}){let[x,f]=(0,at.useState)(!1),h=(0,J.cellDay)(e);if(h==null)return(0,xe.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${$.cell} ${$.blank}`});let u=()=>{f(!0),l(e),setTimeout(()=>f(!1),170)},y=[$.cell,$.day,s?$.past:"",n?$.highlighted:"",o?$.today:"",r.inRange?$.inRange:"",r.selected?$.selected:"",r.reference?$.reference:"",x?$.pressed:""].filter(Boolean).join(" ");return(0,xe.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:y,onClick:u,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),u())},onMouseEnter:()=>b(t),onMouseLeave:v?()=>v(t):void 0,children:(0,xe.jsx)("span",{className:$.number,children:h})})}var sa=require("@magicx-eng/ai-autocomplete-vanilla"),Ea=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1927
1984
|
display: flex;
|
|
1928
1985
|
flex-wrap: wrap;
|
|
1929
1986
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1963,7 +2020,7 @@
|
|
|
1963
2020
|
.aia-cluster[data-justify="around"] {
|
|
1964
2021
|
justify-content: space-around;
|
|
1965
2022
|
}
|
|
1966
|
-
`,document.head.appendChild(e)}var
|
|
2023
|
+
`,document.head.appendChild(e)}var Ga=require("react/jsx-runtime");function Sa({gap:e,align:i="center",justify:t="start",noWrap:n=!1,inline:o=!1,className:s,children:r,...l}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:s?`aia-cluster ${s}`:"aia-cluster","data-align":i,"data-justify":t,"data-nowrap":n||void 0,"data-inline":o||void 0,style:b,...l};return o?(0,Ga.jsx)("span",{...v,children:r}):(0,Ga.jsx)("div",{...v,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
|
|
1967
2024
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1968
2025
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1969
2026
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -2110,7 +2167,7 @@
|
|
|
2110
2167
|
justify-content: flex-end;
|
|
2111
2168
|
}
|
|
2112
2169
|
}
|
|
2113
|
-
`,document.head.appendChild(e)}var
|
|
2170
|
+
`,document.head.appendChild(e)}var Ue={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};var Be=require("react/jsx-runtime");function it({isOptionHighlighted:e=!1,isInputEmpty:i=!1,strings:t=(0,sa.uiStringsFor)()}){let{key:n,hint:o}=(0,sa.getFooterHint)(e,i,t),[s,r]=(0,Ea.useState)(sa.ATTRIBUTION_URL);return(0,Ea.useEffect)(()=>{r((0,sa.buildAttributionUrl)())},[]),(0,Be.jsx)("footer",{className:Ue.footer,"data-aia-footer":"",children:(0,Be.jsxs)(Sa,{justify:"between",noWrap:!0,className:Ue.row,children:[(0,Be.jsxs)(Sa,{gap:"5px",className:Ue.hintGroup,children:[(0,Be.jsx)("kbd",{className:Ue.key,children:n}),(0,Be.jsx)("span",{className:Ue.hint,children:o})]}),(0,Be.jsxs)("a",{className:Ue.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[(0,Be.jsx)("span",{className:Ue.brand,children:"AI"}),(0,Be.jsx)("span",{className:Ue.badge,children:"Autocomplete"})]})]})})}var re=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
|
|
2114
2171
|
Angular copy). The three are kept identical by
|
|
2115
2172
|
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
2116
2173
|
.aia-location-6-fsr {
|
|
@@ -2244,7 +2301,7 @@
|
|
|
2244
2301
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
2245
2302
|
width: 60%;
|
|
2246
2303
|
}
|
|
2247
|
-
`,document.head.appendChild(e)}var
|
|
2304
|
+
`,document.head.appendChild(e)}var ee={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"};var V=require("react/jsx-runtime"),Ut=0;function Ca(e){return e.getRootNode().activeElement??null}function rt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function ot(e){if(!e.isContentEditable)return null;let i=rt(e);if(!i||i.rangeCount===0)return null;let t=i.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function nt(e,i){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=rt(e);if(!t)return;let n=i;(!n||!n.startContainer.isConnected||!e.contains(n.startContainer))&&(n=document.createRange(),n.selectNodeContents(e),n.collapse(!1)),t.removeAllRanges(),t.addRange(n)}var Qt=(0,V.jsxs)("svg",{className:ee.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,V.jsx)("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),(0,V.jsx)("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Yt=(0,V.jsxs)("svg",{className:ee.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,V.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,V.jsx)("path",{d:"m20 20-3.5-3.5"})]});function st({view:e,searchLabel:i,noResultsLabel:t,useTypedLabel:n,widgetFocused:o,reediting:s=!1,visible:r=!0,interactive:l=!0,onQuery:b,onMove:v,onCommit:x,onFocusChange:f}){let h=(0,re.useRef)(null),u=(0,re.useRef)(null),y=(0,re.useRef)(null),k=(0,re.useRef)(null),C=(0,re.useRef)(null),F=(0,re.useRef)(!1),M=(0,re.useRef)(!1),he=(0,re.useRef)(!1),A=(0,re.useRef)(!1),H=(0,re.useRef)(o);H.current=o;let oe=(0,re.useRef)(f);oe.current=f;let G=p=>{A.current=p,f(p)},de=()=>{let p=h.current;return p!=null&&Ca(p)===p},ce=()=>{let p=u.current;if(!p)return;let P=Ca(p);P instanceof HTMLElement&&P!==h.current&&P!==document.body&&!p.contains(P)&&(k.current=P,C.current=ot(P))},E=p=>{let P=u.current;!P||!(p instanceof HTMLElement)||p===k.current||p===document.body||P.contains(p)||(k.current=p,C.current=ot(p))},ne=(0,re.useRef)(null);ne.current===null&&(ne.current=`aia-location-${++Ut}`);let ue=`${ne.current}-row-`;(0,re.useEffect)(()=>{let p=h.current;p&&p.value!==e.query&&Ca(p)!==p&&(p.value=e.query)},[e.query]),(0,re.useEffect)(()=>{o&&(s&&!he.current&&(M.current=!1),he.current=s);let p=h.current;if(p){if(!r&&de()){M.current=!0,_();return}if(!o){setTimeout(()=>{if(H.current)return;let P=k.current;P&&Ca(P)===P||(M.current=!1)},0);return}if(!(!s||M.current||!l||de())){if(ce(),G(!0),p.focus({preventScroll:!0}),!de()){M.current=!0,G(!1);return}p.value&&p.select()}}}),(0,re.useLayoutEffect)(()=>()=>{if(!A.current)return;let p=h.current,P=k.current;P?.isConnected&&p&&Ca(p)===p&&(F.current=!0,nt(P,C.current),F.current=!1),A.current=!1,oe.current(!1)},[]);let _=(p=!1)=>{p&&(M.current=!0);let P=k.current;P?.isConnected&&de()&&(F.current=!0,nt(P,C.current),F.current=!1),G(!1)},pe=e.query.trim(),T=e.highlighted>=0&&e.highlighted<e.places.length?`${ue}${e.highlighted}`:void 0,W=null;return e.places.length>0?W=e.places.map((p,P)=>(0,V.jsxs)("div",{id:`${ue}${P}`,role:"option","aria-selected":P===e.highlighted,className:P===e.highlighted?`${ee.row} ${ee.highlighted}`:ee.row,"data-aia-location-row":"","data-aia-index":P,onClick:()=>{l&&(_(!0),x(P))},children:[(0,V.jsx)("span",{className:ee.pin,children:Qt}),(0,V.jsxs)("span",{className:ee.text,children:[(0,V.jsx)("span",{className:ee.name,children:p.name}),p.secondary&&(0,V.jsx)("span",{className:ee.secondary,children:p.secondary})]})]},p.id)):e.status==="loading"?W=(0,V.jsxs)("div",{className:ee.loading,"data-aia-location-loading":"",children:[(0,V.jsx)("span",{className:ee.loadingBar}),(0,V.jsx)("span",{className:ee.loadingBar}),(0,V.jsx)("span",{className:ee.loadingBar})]}):pe&&(W=(0,V.jsxs)("div",{className:ee.note,"data-aia-location-note":"",children:[e.status==="done"&&(0,V.jsx)("span",{className:ee.empty,children:t}),(0,V.jsx)("span",{children:n})]})),(0,V.jsxs)("div",{ref:u,className:ee.location,"data-aia-location":"",onMouseDown:p=>{!(p.target instanceof Node)||!y.current?.contains(p.target)||(p.stopPropagation(),ce(),G(!0))},children:[(0,V.jsxs)("label",{ref:y,className:ee.field,children:[Yt,(0,V.jsx)("input",{ref:h,type:"text",className:ee.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:i,"aria-label":i,"aria-activedescendant":T,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:p=>b(p.target.value),onFocus:p=>{E(p.relatedTarget),G(!0)},onBlur:()=>{F.current||(M.current=!0,G(!1))},onKeyDown:p=>{if(!p.nativeEvent.isComposing)switch(p.key){case"ArrowDown":case"ArrowUp":p.preventDefault(),v(p.key==="ArrowDown"?1:-1);return;case"Enter":if(p.preventDefault(),!l)return;_(!0),x();return;case"Escape":p.preventDefault(),p.stopPropagation(),M.current=!0,_();return;case"Backspace":if(p.currentTarget.value!=="")return;p.preventDefault(),M.current=!0,_();return}}})]}),(0,V.jsx)("div",{className:ee.results,"data-aia-location-results":"","aria-live":"polite",children:W})]})}var za=require("@magicx-eng/ai-autocomplete-vanilla");var lt=require("@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,
|
|
2248
2305
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
2249
2306
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
2250
2307
|
as it was when the outline was dashed. */
|
|
@@ -2402,7 +2459,7 @@
|
|
|
2402
2459
|
opacity: 0;
|
|
2403
2460
|
}
|
|
2404
2461
|
}
|
|
2405
|
-
`,document.head.appendChild(e)}var
|
|
2462
|
+
`,document.head.appendChild(e)}var We={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"};var la=require("react/jsx-runtime"),Ka={selected:1,first:.7,next:.4,last:.2};function dt({label:e,state:i,active:t,rounded:n,loading:o,smartSuggestion:s,completionHeader:r,onClick:l}){let b=[We.pill,n?We.rounded:"",o?We.skeleton:""].filter(Boolean).join(" ");return(0,la.jsx)("button",{type:"button","data-aia-pill":"","data-aia-pill-active":t?"":void 0,"data-aia-loading":o?"":void 0,"data-aia-smart-suggestion":s?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:b,style:{"--aia-pill-opacity":Ka[i]},onMouseDown:v=>v.preventDefault(),onClick:o?void 0:l,disabled:o,children:s?(0,la.jsxs)(la.Fragment,{children:[(0,la.jsx)("span",{className:`${We.smartText} magicx-aia-smart-suggestion-text`,children:e}),(0,la.jsx)("span",{className:`${We.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:lt.SMART_SUGGESTION_SPARKLE_SVG}})]}):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 {
|
|
2406
2463
|
position: relative;
|
|
2407
2464
|
z-index: 1;
|
|
2408
2465
|
pointer-events: auto;
|
|
@@ -2412,7 +2469,7 @@
|
|
|
2412
2469
|
align-items: center;
|
|
2413
2470
|
vertical-align: middle;
|
|
2414
2471
|
}
|
|
2415
|
-
`,document.head.appendChild(e)}var
|
|
2472
|
+
`,document.head.appendChild(e)}var qa={list:"aia-list-qvLqO"};var Ta=require("react/jsx-runtime"),jt=[125,69];function ct(e){return e===0?"first":e===1?"next":"last"}function Ra({pills:e,activePillIndex:i,onSelectPill:t,activeSelected:n,rounded:o,loading:s}){return s&&e.length===0?(0,Ta.jsx)("span",{className:qa.list,"data-aia-pill-list-loading":"",children:jt.map((r,l)=>(0,Ta.jsx)("span",{"data-aia-pill-skeleton":"",className:`${We.pill} ${o?We.rounded:""} ${We.skeleton}`,style:{width:r,"--aia-pill-opacity":Ka[ct(l)]}},`skel-${r}`))}):(0,Ta.jsx)("span",{className:qa.list,"data-aia-pill-list-loading":s?"":void 0,children:e.map((r,l)=>{let b=!!n&&l===i;return(0,Ta.jsx)(dt,{label:r.text,state:b?"selected":ct(l),selected:b,active:l===i,rounded:o,loading:s,smartSuggestion:(0,za.isSmartSuggestion)(r),completionHeader:(0,za.isTraditionalAutocompleteSuggestion)(r),onClick:()=>t(l)},`${r.parameter}-${r.text}`)})})}var Te=require("@magicx-eng/ai-autocomplete-vanilla"),ye=require("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
|
|
2416
2473
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
2417
2474
|
theming one package sees the same result in the other.
|
|
2418
2475
|
|
|
@@ -2788,6 +2845,40 @@
|
|
|
2788
2845
|
}
|
|
2789
2846
|
}
|
|
2790
2847
|
|
|
2848
|
+
/* A selection in progress (\`onProductSelect\` ran, its page has not taken
|
|
2849
|
+
over): the add-to-cart button's disc and spinning arc sit on the middle of
|
|
2850
|
+
the tapped card's picture. The disc is the arc's own fill and spread, so
|
|
2851
|
+
the turn moves only the arc, and nothing in the card changes size. A slower
|
|
2852
|
+
turn under reduced motion: it is the only sign the tap took. The state
|
|
2853
|
+
sits in :where(), so a page's own rule on the attribute restyles or hides
|
|
2854
|
+
it. */
|
|
2855
|
+
.aia-card-JBGYT:where([data-aia-product-state="busy"]) .aia-media-RrbGe::before {
|
|
2856
|
+
content: "";
|
|
2857
|
+
position: absolute;
|
|
2858
|
+
top: 50%;
|
|
2859
|
+
left: 50%;
|
|
2860
|
+
z-index: 1;
|
|
2861
|
+
margin: calc(var(--aia-spinner-size, 16px) / -2) 0 0 calc(var(--aia-spinner-size, 16px) / -2);
|
|
2862
|
+
box-sizing: border-box;
|
|
2863
|
+
width: var(--aia-spinner-size, 16px);
|
|
2864
|
+
height: var(--aia-spinner-size, 16px);
|
|
2865
|
+
border: var(--aia-spinner-width, 2px) solid
|
|
2866
|
+
var(--aia-product-spinner-color, var(--aia-product-cart-color, #1f2328));
|
|
2867
|
+
border-right-color: transparent;
|
|
2868
|
+
border-radius: 50%;
|
|
2869
|
+
animation: aia-magicx-aia-product-cart-spin-x8mgr 0.8s linear infinite;
|
|
2870
|
+
background: var(--aia-product-spinner-bg, var(--aia-product-cart-bg, rgba(255, 255, 255, 0.94)));
|
|
2871
|
+
box-shadow:
|
|
2872
|
+
0 0 0 6px var(--aia-product-spinner-bg, var(--aia-product-cart-bg, rgba(255, 255, 255, 0.94))),
|
|
2873
|
+
0 0 0 7px rgba(0, 0, 0, 0.08);
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2877
|
+
.aia-card-JBGYT:where([data-aia-product-state="busy"]) .aia-media-RrbGe::before {
|
|
2878
|
+
animation-duration: 2s;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2791
2882
|
/* A sold-out product's image steps back, so the badge is not the only cue.
|
|
2792
2883
|
Desaturated rather than faded: opacity lets the panel show through, which
|
|
2793
2884
|
muddies a photo on a dark surface. */
|
|
@@ -3005,7 +3096,7 @@
|
|
|
3005
3096
|
opacity: 0.01;
|
|
3006
3097
|
}
|
|
3007
3098
|
}
|
|
3008
|
-
`,document.head.appendChild(e)}var
|
|
3099
|
+
`,document.head.appendChild(e)}var ae={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"};var q=require("react/jsx-runtime");function pt({products:e,listboxId:i,onSelect:t,busyProductId:n=null,onAddToCart:o,onFocusChange:s,focusable:r=!0,loading:l=!1,layout:b="row",imageFallback:v="image",showVendor:x=!0,strings:f=(0,Te.uiStringsFor)()}){let h=e.length>0,u=(0,ye.useRef)(null);if((0,ye.useEffect)(()=>{let k=u.current;if(!(!h||!k))return(0,Te.attachProductRowWheel)(k)},[h]),!h)return null;let y=`${i}-products-label`;return(0,q.jsxs)("section",{className:ae.section,"data-aia-products":"","data-aia-loading":l?"":void 0,"data-aia-products-layout":b,role:"group","aria-labelledby":y,children:[(0,q.jsx)("div",{className:ae.label,id:y,"data-aia-products-label":"",children:f.products}),(0,q.jsx)("div",{ref:u,className:ae.row,"data-aia-products-row":"",children:e.map((k,C)=>(0,q.jsx)($t,{product:k,id:`${i}-product-${C}`,onSelect:t,busy:k.id===n,onAddToCart:o,onFocusChange:s,focusable:r,imageFallback:v,showVendor:x,soldOut:f.soldOut,addToCart:f.addToCart},k.id))})]})}function $t({product:e,id:i,onSelect:t,busy:n,onAddToCart:o,onFocusChange:s,focusable:r,imageFallback:l,showVendor:b,soldOut:v,addToCart:x}){let f=!!o&&e.available!==!1,[h,u]=(0,ye.useState)(null),y=C=>{C.relatedTarget?.closest("[data-aia-dropdown]")||s?.(!1)},k=C=>{C.metaKey||C.ctrlKey||C.shiftKey||C.altKey||C.button!==0||(C.preventDefault(),t(e))};return(0,q.jsxs)("a",{id:i,className:ae.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":f?"":void 0,"data-aia-product-state":n?"busy":void 0,"aria-busy":n?!0:void 0,role:"option","aria-selected":!1,style:h?{"--aia-product-photo-fill-x":String(h.x),"--aia-product-photo-fill-y":String(h.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:k,onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),t(e))},onFocus:()=>s?.(!0),onBlur:y,children:[(0,q.jsx)(Jt,{sources:(0,Te.productImageSources)(e.imageUrl),title:e.title,fallback:l,onPhotoFill:u},(0,Te.productImageSrc)(e.imageUrl)??""),(0,q.jsxs)("span",{className:ae.body,children:[b&&e.vendor?(0,q.jsx)("span",{className:ae.vendor,children:e.vendor}):null,(0,q.jsx)("span",{className:ae.title,children:e.title}),e.price?(0,q.jsxs)("span",{className:ae.price,children:[e.price,e.compareAtPrice?(0,q.jsx)("s",{className:ae.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?(0,q.jsx)("span",{className:ae.badge,children:v}):null]}),f&&o?(0,q.jsx)(Xt,{product:e,label:`${x}: ${e.title}`,focusable:r,onAddToCart:o,onFocus:()=>s?.(!0),onBlur:y},Zt(e)):null]})}function Zt(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(i=>i??"").join("\0")}function Xt({product:e,label:i,focusable:t,onAddToCart:n,onFocus:o,onBlur:s}){let[r,l]=(0,ye.useState)(null),b=(0,ye.useRef)(null),v=(0,ye.useRef)(e);v.current=e;let x=(0,ye.useRef)(!0);(0,ye.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let f=u=>{b.current=u,x.current&&l(u)},h=u=>{if(u.preventDefault(),u.stopPropagation(),b.current==="adding")return;f("adding");let y;try{y=Promise.resolve(n(v.current))}catch(k){y=Promise.reject(k)}y.then(()=>f("added"),()=>f(null))};return(0,q.jsx)("span",{className:ae.cart,"data-aia-product-cart":"","data-aia-cart-state":r??void 0,"aria-busy":r==="adding"?!0:void 0,role:"button","aria-label":i,tabIndex:t?0:-1,onClick:h,onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||h(u)},onFocus:u=>{u.stopPropagation(),o()},onBlur:u=>{u.stopPropagation(),s(u)},children:(0,q.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[(0,q.jsx)("path",{className:ae.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"}),(0,q.jsx)("path",{className:ae.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),(0,q.jsx)("path",{className:ae.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),(0,q.jsx)("path",{className:ae.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),(0,q.jsx)("circle",{className:ae.cartGlyph,cx:"9",cy:"20",r:"1.3"}),(0,q.jsx)("circle",{className:ae.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Jt({sources:e,title:i,fallback:t,onPhotoFill:n}){let[o,s]=(0,ye.useState)(0),r=e[o],l=!!r,[b,v]=(0,ye.useState)(null),x=!l&&t==="initial";return(0,ye.useEffect)(()=>()=>n(null),[n]),(0,q.jsxs)("span",{className:ae.media,"data-aia-product-media":"","aria-hidden":"true","data-aia-product-placeholder":!l&&!x?"":void 0,"data-aia-product-initial":x?"":void 0,"data-aia-image-loaded":l&&b===r?"":void 0,children:[l?(0,q.jsx)("img",{className:ae.image,src:r,alt:"",loading:"lazy",decoding:"async",onLoad:f=>{v(r),n((0,Te.productPhotoFill)(f.currentTarget.naturalWidth,f.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&n(null),s(f=>f+1)}}):null,x?(0,Te.productInitial)(i):null]})}var Z=require("@magicx-eng/ai-autocomplete-vanilla"),ze=require("react");var ht=require("@magicx-eng/ai-autocomplete-vanilla"),Oa=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
3009
3100
|
display: grid;
|
|
3010
3101
|
grid-template-columns: repeat(
|
|
3011
3102
|
auto-fit,
|
|
@@ -3049,7 +3140,7 @@
|
|
|
3049
3140
|
:where([data-aia-options-style="classic"]) .aia-grid[data-scroll] {
|
|
3050
3141
|
max-height: var(--aia-grid-max-height, 120px);
|
|
3051
3142
|
}
|
|
3052
|
-
`,document.head.appendChild(e)}var
|
|
3143
|
+
`,document.head.appendChild(e)}var mt=require("react/jsx-runtime");function ut({min:e="16rem",max:i,gap:t,scroll:n=!1,maxHeight:o,scrollResetKey:s,cols:r,template:l,innerRef:b,className:v,children:x,...f}){let h=(0,Oa.useRef)(null);(0,Oa.useLayoutEffect)(()=>{if(s===void 0)return;let y=h.current;y&&(y.scrollTop=0)},[s]);let u={"--aia-grid-min":e};return i&&(u["--aia-grid-max"]=i),t&&(u["--aia-grid-gap"]=t),o&&(u["--aia-grid-max-height"]=o),r&&(u.gridTemplateColumns=(0,ht.optionsGridTemplateColumns)(r)),l&&(u.gridTemplateColumns=l),(0,mt.jsx)("div",{ref:y=>{h.current=y,b?.(y)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":n||void 0,style:u,...f,children:x})}var ge=require("@magicx-eng/ai-autocomplete-vanilla"),Pe=require("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 {
|
|
3053
3144
|
position: relative;
|
|
3054
3145
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
3055
3146
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -3575,7 +3666,7 @@
|
|
|
3575
3666
|
border-radius: 6px;
|
|
3576
3667
|
font-size: 11px;
|
|
3577
3668
|
}
|
|
3578
|
-
`,document.head.appendChild(e)}var
|
|
3669
|
+
`,document.head.appendChild(e)}var se={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"};var le=require("react/jsx-runtime");function gt({option:e,isHighlighted:i,checked:t,onSelect:n,onHighlight:o,onUnhighlight:s,id:r,loading:l,showIcon:b=!0,showImage:v=!0,showCount:x=!0,scrollHint:f,enterDelayMs:h=0}){let[u]=(0,Pe.useState)(h),[y,k]=(0,Pe.useState)(!1),C=v?(0,ge.optionImageSources)(e.image_url):[],F=C[0]??null,[M,he]=(0,Pe.useState)([]),A=C.find(T=>!M.includes(T))??null,H=v?(e.imageCollage??[]).map(T=>(0,ge.optionImageSources)(T)[0]).filter(T=>T!==void 0):[],[oe,G]=(0,Pe.useState)(!1),[de,ce]=(0,Pe.useState)(null),E=(0,Pe.useMemo)(()=>!F&&b&&e.icon_svg?(0,ge.sanitizeOptionIconSvg)(e.icon_svg):null,[F,b,e.icon_svg]),ne=x?(0,ge.formatOptionCount)(e.item_count):null,ue=(0,Pe.useRef)(void 0);(0,Pe.useEffect)(()=>()=>clearTimeout(ue.current),[]);let _=T=>{if(l||!e.is_tappable||y&&t===void 0)return;k(!0);let W=T?.currentTarget;t!==void 0&&W!==void 0&&T!==void 0&&!(0,ge.isMultiSelectToggleTap)(W,W.querySelector("[data-aia-checkbox]"),T)?n(e,{commit:!0}):n(e),clearTimeout(ue.current),ue.current=setTimeout(()=>k(!1),170)},pe=[se.item,i&&!l?se.highlighted:"",e.liveMatch&&!l?se.liveMatch:"",e.is_tappable?se.tappable:se.nonTappable,y?se.pressed:"",f?se.scrollHint:""].filter(Boolean).join(" ");return(0,le.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":E&&e.icon?e.icon:void 0,"data-aia-image":F?"":void 0,"data-aia-item-count":ne!==null?e.item_count:void 0,"aria-selected":t??i,className:pe,style:{[ge.OPTION_ENTER_DELAY_VAR]:`${u}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:_,onKeyDown:T=>{!l&&e.is_tappable&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),_())},onMouseEnter:!l&&e.is_tappable?o:void 0,onMouseLeave:s,children:(0,le.jsxs)("span",{className:se.content,children:[t!==void 0&&e.is_tappable&&(0,le.jsx)("span",{className:se.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),F&&H.length>1&&(0,le.jsx)("span",{className:`${se.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-collage":H.length,"data-aia-image-loaded":oe?"":void 0,children:H.map(T=>(0,le.jsx)("img",{src:T,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onLoad:()=>G(!0),onError:W=>{W.currentTarget.hidden=!0}},T))}),F&&H.length<=1&&(0,le.jsx)("span",{className:`${se.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":A!==null&&de===A?"":void 0,children:(0,le.jsx)("img",{src:A??F,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:A===null,onLoad:()=>ce(A),onError:()=>{A!==null&&he(T=>[...T,A])}})}),E&&(0,le.jsx)("span",{className:`${se.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:E}}),(0,le.jsxs)("span",{className:se.text,children:[e.matchedText?(0,ge.highlightParts)((0,ge.optionLabel)(e),e.matchedText).map((T,W)=>T.bold?(0,le.jsx)("strong",{className:`${se.match} magicx-aia-option-match`,"data-aia-match-partial":T.partial?"":void 0,children:T.text},W):T.text):(0,ge.optionLabel)(e),e.parameterLabel&&(0,le.jsxs)(le.Fragment,{children:[" ",(0,le.jsx)("span",{className:`${se.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&(0,le.jsx)("span",{className:se.tag,children:e.tag}),ne!==null&&(0,le.jsx)("span",{className:`${se.count} magicx-aia-option-count`,children:ne})]})})}var _a=require("react/jsx-runtime");function ei(){let[e,i]=(0,ze.useState)(Z.isOptionsGridMobileViewport);return(0,ze.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Z.OPTIONS_GRID_MOBILE_QUERY),n=()=>i(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function ft({options:e,activeIndex:i,picked:t,onSelect:n,onHighlight:o,onUnhighlight:s,listboxId:r,loading:l,groupKey:b="",optionsPosition:v="below",showIcons:x=!0,showImages:f=!0,showCounts:h=!0}){let u=ei(),y=(0,ze.useRef)(null),[k,C]=(0,ze.useState)(null),F=(0,ze.useRef)(null);(0,ze.useLayoutEffect)(()=>{if(l&&(0,Z.sameOptionRows)(F.current,e))return;F.current=l?null:e;let A=y.current,H=A&&!l&&(0,Z.needsOptionsGridMeasurement)(e.length,u),oe=A?.closest("[data-aia-dropdown]");H&&oe&&(0,Z.releasePanelHug)(oe);let G=H?(0,Z.measureOptionsGrid)(A):null;C(G?(0,Z.planOptionsGrid)(e.length,u,G.rowWidths,G.gridWidth):null)},[e,u,l]);let M=k??(0,Z.planOptionsGrid)(e.length,u,null,null);(0,ze.useLayoutEffect)(()=>{let A=y.current?.closest("[data-aia-dropdown]");A&&(0,Z.syncPanelHug)(A)},[M.template,u]);let he=(0,Z.optionsShowLeadingVisuals)(e,x,f);return(0,_a.jsx)(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:b,template:M.template,maxHeight:M.maxHeight,innerRef:A=>{y.current=A},"data-aia-group":b,children:e.map((A,H)=>(0,_a.jsx)(gt,{option:A,isHighlighted:H===i,checked:t?t.includes(A.text):void 0,onSelect:n,onHighlight:()=>o(H),onUnhighlight:s?()=>s(H):void 0,id:`${r}-option-${H}`,loading:l,showIcon:x&&he,showImage:f&&he,showCount:h,scrollHint:!l&&M.scrollHintIndices.includes(H),enterDelayMs:l?0:(0,Z.optionEnterDelayMs)(H,M.cols,e.length,v)},`${b}\0${A.parameter??""}\0${A.text}`))})}var fe=require("@magicx-eng/ai-autocomplete-vanilla"),Oe=require("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) ---
|
|
3579
3670
|
|
|
3580
3671
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
3581
3672
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3697,7 +3788,7 @@
|
|
|
3697
3788
|
.aia-done-llNY5:hover {
|
|
3698
3789
|
background: var(--aia-time-done-bg-hover, var(--aia-done-bg-hover, #d8dde8));
|
|
3699
3790
|
}
|
|
3700
|
-
`,document.head.appendChild(e)}var
|
|
3791
|
+
`,document.head.appendChild(e)}var Re={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"};var Ie=require("react/jsx-runtime"),ai=120;function bt({view:e,label:i,doneLabel:t,interactive:n=!0,onTimeChange:o,onTimeCommit:s}){return(0,Ie.jsxs)("div",{className:Re.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":i,onMouseDown:r=>r.preventDefault(),children:[(0,Ie.jsx)("span",{className:Re.value,"data-aia-time-value":"","aria-live":"polite",children:(0,fe.formatTime)(e.minutes)}),(0,Ie.jsxs)("div",{className:Re.columns,"aria-hidden":"true",children:[(0,Ie.jsx)("div",{className:Re.band}),fe.TIME_WHEEL_COLUMNS.map(r=>(0,Ie.jsxs)(Oe.Fragment,{children:[r==="minute"&&(0,Ie.jsx)("span",{className:Re.separator,children:":"}),(0,Ie.jsx)(ti,{column:r,minutes:e.minutes,interactive:n,onTimeChange:o})]},r))]}),(0,Ie.jsx)("button",{type:"button",tabIndex:-1,className:Re.done,"data-aia-time-done":"",onClick:()=>{n&&s()},children:t})]})}function ti({column:e,minutes:i,interactive:t,onTimeChange:n}){let o=(0,Oe.useRef)(null),s=(0,Oe.useRef)(null),r=(0,Oe.useRef)(null),l=(0,Oe.useRef)({minutes:i,interactive:t,onTimeChange:n});l.current={minutes:i,interactive:t,onTimeChange:n};let b=(0,fe.timeWheelIndex)(e,i);(0,Oe.useLayoutEffect)(()=>{let f=o.current;if(!f||r.current)return;let h=b*fe.TIME_WHEEL_ROW_HEIGHT;Math.abs(f.scrollTop-h)<1||(s.current=h,f.scrollTop=h)},[b]),(0,Oe.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);let v=()=>{r.current=null;let f=o.current,h=l.current;if(!f||!h.interactive)return;let u=(0,fe.timeWheelIndexFromScroll)(e,f.scrollTop);u!==(0,fe.timeWheelIndex)(e,h.minutes)&&h.onTimeChange((0,fe.withTimeWheelIndex)(e,h.minutes,u))},x=()=>{let f=o.current;if(f){if(s.current!=null&&Math.abs(f.scrollTop-s.current)<1){s.current=null;return}s.current=null,r.current&&clearTimeout(r.current),r.current=setTimeout(v,ai)}};return(0,Ie.jsx)("div",{ref:o,className:Re.column,"data-aia-time-column":e,onScroll:x,children:(0,fe.timeWheelRows)(e).map((f,h)=>(0,Ie.jsx)("div",{className:h===b?`${Re.row} ${Re.selected}`:Re.row,"data-aia-time-row":"","data-aia-index":h,onClick:()=>{l.current.interactive&&n((0,fe.withTimeWheelIndex)(e,l.current.minutes,h))},children:f.label},f.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
3701
3792
|
display: flex;
|
|
3702
3793
|
flex-direction: column;
|
|
3703
3794
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -3712,7 +3803,7 @@
|
|
|
3712
3803
|
align-items: end;
|
|
3713
3804
|
}
|
|
3714
3805
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
3715
|
-
`,document.head.appendChild(e)}var
|
|
3806
|
+
`,document.head.appendChild(e)}var vt=require("react/jsx-runtime");function wt({space:e,align:i="stretch",className:t,children:n,...o}){let s=e?{"--aia-stack-space":e}:void 0;return(0,vt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":i,style:s,...o,children:n})}var U=require("react/jsx-runtime"),ii=typeof window>"u"?X.useEffect:X.useLayoutEffect,oi=[159,119,164],ni=()=>{},xt=()=>{},ri=e=>{},si=()=>{},li=e=>{},di=e=>{},ci=e=>{},pi=e=>{};function hi(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=(0,X.useState)(i);if((0,X.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n(o.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ui(e,i){let t=(0,X.useRef)(null);(0,X.useEffect)(()=>{let n=e.current,o=i.current;if(!n||!o)return;let s=(0,L.queryLive)(n,".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:(0,L.attachScrollArrow)({dropdown:n,grid:s,button:o})};return}t.current?.controller.update()}),(0,X.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function mi(e,i){let t=(0,X.useRef)(i);t.current=i;let n=(0,X.useRef)(null);(0,X.useLayoutEffect)(()=>{let o=e.current;if(o){if(!n.current){n.current=(0,L.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}n.current.update()}}),(0,X.useEffect)(()=>()=>{n.current?.destroy(),n.current=null},[])}function La({suggestions:e,activeIndex:i,onSelect:t,onHighlight:n,onUnhighlight:o,isOpen:s,id:r,className:l,pills:b,onPillClick:v,showPills:x=!0,onSkip:f,showSkipButton:h=!0,showOptionIcons:u=!0,showOptionImages:y=!0,showOptionCounts:k=!0,skipDisabled:C=!1,activeSelected:F=!1,isLoading:M=!1,skeletonExiting:he=!1,isInputEmpty:A=!1,language:H,products:oe,onProductSelect:G,onProductAddToCart:de,onProductFocusChange:ce,productsLayout:E="row",productImageFallback:ne="image",showProductVendor:ue=!0,formatType:_="options",dateView:pe=null,selectedDateIso:T=null,selectedDateRange:W=null,dateRangeStart:p=null,dateReferences:P,onPreviousMonth:Qe,onNextMonth:Ke,timeView:Ye=null,multiSelectView:je=null,onMultiSelectCommit:m,onSeeAllResults:$e,seeAllBusy:De=!1,busyProductId:Ze=null,fullWidth:Xe=!1,onTimeChange:g,onTimeCommit:S,locationView:I=null,isReediting:R=!1,onLocationQuery:N,onLocationMove:te,onLocationCommit:Se,onLocationFocusChange:Ae,isFocused:qe=!1,optionsPosition:_e="below",mode:Je}){let ea=hi(Je),Me=ea!==void 0,me=(0,X.useRef)(null),aa=(0,X.useRef)(null);ui(me,aa),(0,X.useEffect)(()=>{if(me.current)return(0,L.containScroll)(me.current)},[]);let wa=e[0]?.options??[],Ne=!!(b&&b.length>0&&v),ua=!!(oe&&oe.length>0),ta=_==="time"&&Ye!=null,w=_==="location"&&I!=null,be=s&&(wa.length>0||x&&Ne||M||ua||ta||w);mi(me,be),ii(()=>{let O=me.current;O&&((0,L.fitMultiSelectDone)(O,(0,L.findMultiSelectDone)(O)),(0,L.syncPanelHug)(O))});let ia={suggestions:e,activeIndex:i,pills:b,showPills:x,showSkipButton:h,showOptionIcons:u,showOptionImages:y,showOptionCounts:k,skipDisabled:C,activeSelected:F,isLoading:M,skeletonExiting:he,isInputEmpty:A,products:oe,formatType:_,dateView:pe,selectedDateIso:T,selectedDateRange:W,dateRangeStart:p,dateReferences:P,timeView:Ye,multiSelectView:je,locationView:I,isReediting:R,showsSeeAll:!!$e},oa=(0,X.useRef)(ia);be&&(oa.current=ia);let a=be?ia:oa.current,ie=(0,L.uiStringsFor)(H),na=a.suggestions[0],we=na?.options??[],va=a.activeIndex>=0&&!!we[a.activeIndex]?.is_tappable,Fe=(0,L.labelTraditionalAutocomplete)(a.pills??[],ie.keepTyping),Ee=!!(Fe.length>0&&v),ma=a.showPills&&Ee,ra=a.showPills&&!Ee&&a.isLoading,He=ma||ra,da=Ee&&(0,L.hasSkippablePill)(Fe)&&a.showSkipButton&&!a.isInputEmpty&&!!f,ca=Fe[0]?.text,ga=(0,L.isCalendarFormat)(a.formatType)&&a.dateView!=null,Ve=we.length>0&&!ga,pa=we.length>0&&ga&&!a.isLoading,d=a.formatType==="time"&&a.timeView!=null&&!a.isLoading,Y=a.formatType==="location"&&a.locationView!=null&&!a.isLoading,K=a.isLoading&&!Ve&&!pa&&!d&&!Y,fa=a.products??[],Pa=(0,L.panelMorphKey)(ma?Fe:[]);return(0,X.useLayoutEffect)(()=>{me.current&&(0,L.settlePanelMorph)(me.current,Pa,{visible:be,anchorBottom:_e==="above"})},[Pa,be,_e,a.suggestions,a.pills,a.isLoading,a.skeletonExiting,a.isInputEmpty,a.products,a.formatType,a.dateView,a.selectedDateIso,a.selectedDateRange,a.dateRangeStart,a.dateReferences,a.timeView,a.multiSelectView,a.locationView,a.showPills,a.showSkipButton,a.showOptionIcons,a.showOptionImages,a.showOptionCounts,a.showsSeeAll,E,H]),(0,X.useEffect)(()=>{let O=me.current;return()=>{O&&(0,L.destroyPanelMorph)(O)}},[]),(0,U.jsxs)("div",{ref:me,id:r,role:"listbox","aria-multiselectable":!!a.multiSelectView,"data-aia-dropdown":"","data-options-position":_e,"data-mode":ea,"data-aia-loading":a.isLoading?"":void 0,"data-aia-skeleton-exiting":a.skeletonExiting?"":void 0,"data-aia-has-products":fa.length>0?"":void 0,"data-aia-full-width":Xe?"":void 0,className:`${Me?"magicx-aia ":""}${Ce.dropdown} ${be?Ce.visible:""} ${l??""}`,onMouseDown:O=>O.preventDefault(),children:[(0,U.jsxs)(wt,{space:"8px",children:[(He||da)&&(0,U.jsxs)(Sa,{noWrap:!0,className:Ce.pillBar,"data-aia-pillbar":"",children:[He&&(0,U.jsx)("span",{className:Ce.pillScroll,"data-aia-pill-scroll":"",children:(0,U.jsx)(Ra,{pills:Fe,activePillIndex:0,activeSelected:a.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:a.isLoading})}),da&&(0,U.jsx)("button",{type:"button",tabIndex:-1,className:Ce.skip,"data-aia-skip":"",disabled:a.isLoading||a.skipDisabled,"aria-label":ca?`${ie.skipLabel} ${ca}`:ie.skipLabel,onClick:f,children:ie.skip})]}),Ve&&(0,U.jsx)(ft,{options:we,activeIndex:a.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:o,listboxId:r,loading:a.isLoading,groupKey:na?`${na.parameter} ${na.text}`:"",optionsPosition:_e,showIcons:a.showOptionIcons,showImages:a.showOptionImages,showCounts:a.showOptionCounts,picked:a.multiSelectView?.picked}),a.multiSelectView&&(0,U.jsx)("div",{"data-aia-multi-actions":"",onClick:O=>{O.target.closest("[data-aia-multi-done]")&&!a.skipDisabled&&!a.isLoading&&m?.()},children:(0,U.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:Ce.multiDone,ref:O=>{O&&(O.disabled=!0,O.offsetHeight,O.disabled=a.skipDisabled||a.isLoading)},children:ie.done})}),pa&&a.dateView&&(0,U.jsx)(tt,{options:we,activeIndex:a.activeIndex,listboxId:r,view:a.dateView,selection:{selectedIso:a.selectedDateIso??null,selectedRange:a.selectedDateRange??null,rangeStart:a.dateRangeStart??null,floor:(0,L.dateFloorFor)(a.formatType,a.dateRangeStart),references:a.dateReferences??[]},onSelect:t,onHighlight:n,onUnhighlight:o,onPreviousMonth:Qe??xt,onNextMonth:Ke??xt}),d&&a.timeView&&(0,U.jsx)(bt,{view:a.timeView,label:ie.timeLabel,doneLabel:ie.done,interactive:!a.skipDisabled,onTimeChange:g??ri,onTimeCommit:S??si}),Y&&a.locationView&&(0,U.jsx)(st,{view:a.locationView,searchLabel:ie.locationSearch,noResultsLabel:ie.locationNoResults,useTypedLabel:ie.locationUseTyped,widgetFocused:qe&&be,reediting:a.isReediting,visible:be,interactive:!a.skipDisabled,onQuery:N??li,onMove:te??di,onCommit:Se??ci,onFocusChange:Ae??pi}),K&&(0,U.jsx)("div",{className:Ce.skeletonBars,"data-aia-skeleton-bars":"",children:oi.map(O=>(0,U.jsx)("span",{className:Ce.skeletonBar,style:{width:O}},`bar-${O}`))}),(0,U.jsx)(pt,{products:fa,listboxId:r,onSelect:G??ni,busyProductId:Ze,onAddToCart:de,onFocusChange:ce,focusable:be&&!a.isLoading,loading:a.isLoading,layout:E,imageFallback:ne,showVendor:ue,strings:ie}),a.showsSeeAll&&(0,U.jsx)("div",{className:Ce.seeAllRow,"data-aia-see-all":"",onClick:O=>{O.target.closest("[data-aia-see-all-button]")&&(O.stopPropagation(),!(a.isLoading||De)&&$e?.())},children:(0,U.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-see-all-button":"","data-aia-see-all-state":De?"busy":void 0,"aria-busy":De?!0:void 0,className:Ce.seeAll,ref:O=>{O&&(O.disabled=!0,O.offsetHeight,O.disabled=a.isLoading)},children:ie.seeAllResults})}),(0,U.jsx)(it,{isOptionHighlighted:va,isInputEmpty:a.isInputEmpty,strings:ie})]}),(0,U.jsx)("button",{ref:aa,type:"button",tabIndex:-1,className:Ce.scrollArrow,"data-aia-scroll-arrow":"","aria-label":ie.scrollArrow,"aria-hidden":"true",children:(0,U.jsx)("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:(0,U.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Ge=require("@magicx-eng/ai-autocomplete-vanilla");var kt=require("@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 {
|
|
3716
3807
|
flex-shrink: 0;
|
|
3717
3808
|
width: 32px;
|
|
3718
3809
|
height: 32px;
|
|
@@ -3778,10 +3869,43 @@
|
|
|
3778
3869
|
transform: scale(1.08);
|
|
3779
3870
|
}
|
|
3780
3871
|
|
|
3872
|
+
/* A submit in progress (Enter, this button, "See all results"): the arrow
|
|
3873
|
+
gives way to the spinning arc the add-to-cart button shows, in the arrow's
|
|
3874
|
+
colour, until the page the submit opens takes over. The button keeps its
|
|
3875
|
+
size and stays enabled; a press is ignored. A slower turn under reduced
|
|
3876
|
+
motion: it is the only sign the submit took. The state sits in :where(),
|
|
3877
|
+
so a page's own rule on the attribute restyles or hides it. */
|
|
3878
|
+
.aia-submitButton-otz7H:where([data-aia-submit-state="busy"]) svg {
|
|
3879
|
+
display: none;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
.aia-submitButton-otz7H:where([data-aia-submit-state="busy"])::after {
|
|
3883
|
+
content: "";
|
|
3884
|
+
box-sizing: border-box;
|
|
3885
|
+
width: var(--aia-spinner-size, 16px);
|
|
3886
|
+
height: var(--aia-spinner-size, 16px);
|
|
3887
|
+
border: var(--aia-spinner-width, 2px) solid var(--aia-submit-spinner-color, currentColor);
|
|
3888
|
+
border-right-color: transparent;
|
|
3889
|
+
border-radius: 50%;
|
|
3890
|
+
animation: aia-submitSpin-0llcF 0.8s linear infinite;
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
@keyframes aia-submitSpin-0llcF {
|
|
3894
|
+
to {
|
|
3895
|
+
transform: rotate(360deg);
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3900
|
+
.aia-submitButton-otz7H:where([data-aia-submit-state="busy"])::after {
|
|
3901
|
+
animation-duration: 2s;
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3781
3905
|
@media (prefers-reduced-motion: reduce) {
|
|
3782
3906
|
.aia-submitButton-otz7H {
|
|
3783
3907
|
transition: none;
|
|
3784
3908
|
}
|
|
3785
3909
|
}
|
|
3786
|
-
`,document.head.appendChild(e)}var bt={submitButton:"aia-submitButton-otz7H"};var Oa=require("react/jsx-runtime");function vt({disabled:e,ready:t,onClick:a,label:i=(0,wt.uiStringsFor)().submit}){return(0,Oa.jsx)("button",{type:"button","data-aia-submit":"",className:bt.submitButton,disabled:e,"data-aia-ready":t?"":void 0,onClick:o=>{o.stopPropagation(),a()},"aria-label":i,children:(0,Oa.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":i,children:(0,Oa.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ne=require("@magicx-eng/ai-autocomplete-vanilla"),O=require("react");var Wa=require("react");function xt(e){let t=(0,Wa.useRef)(e);t.current=e;let a=Object.keys(e??{}).sort().join("\0"),i=(0,Wa.useRef)({key:"",overrides:void 0});if(i.current.key!==a){let o={};for(let s of Object.keys(e??{})){let r=(l,v,x)=>{let k=t.current?.[s];return k?k(l,v,x):[]};o[s]=r}i.current={key:a,overrides:e?o:void 0}}return{overrides:i.current.overrides,key:a}}var Ga=require("react");function yt(e){let t=(0,Ga.useRef)(e);t.current=e;let a=(0,Ga.useRef)(null);a.current===null&&(a.current={fetch:(o,s)=>{let r=t.current;return r?r.fetch(o,s):Promise.reject(new Error("products config removed"))},transform:o=>t.current?.transform(o)??[],get limit(){return t.current?.limit}});let i=e!==void 0;return{config:i?a.current:void 0,enabled:i}}var kt={text:"",composing:null,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 La({onSubmit:e,onResult:t,onError:a,optionOverrides:i,maskCompletedText:o,apiConfig:s,additionalContext:r,language:l,currency:v,productId:x,visitorId:k,columns:b=2,dropdownTrigger:u,optionsPosition:h,closeDropdownOnBlur:C,prependPlaceholder:y,allOption:j,showNonTappableOptions:F,locationSearch:D,showOptionIcons:he,showOptionImages:P,showOptionCounts:H,showSkipButton:oe,showProducts:W,productImageFallback:ge="image",showProductVendor:pe=!0,onFocus:A,onBlur:ne,value:ee,completedParams:_,onChange:xe,onParamsChange:T,products:G,mapProducts:c,onProductSelect:I,onProductAddToCart:Fe,source:na,setCursor:Be}){let w=(0,O.useRef)(null),[ra,We]=(0,O.useState)(null),$e=(0,O.useRef)(e);$e.current=e;let Ze=(0,O.useRef)(t);Ze.current=t;let Xe=(0,O.useRef)(a);Xe.current=a;let g=(0,O.useRef)(xe);g.current=xe;let S=(0,O.useRef)(T);S.current=T;let E=(0,O.useRef)(A);E.current=A;let R=(0,O.useRef)(ne);R.current=ne;let N=(0,O.useRef)(Be);N.current=Be;let re=(0,O.useRef)(I);re.current=I;let Te=(0,O.useRef)(Fe);Te.current=Fe;let fe=(0,O.useRef)(k);fe.current=k;let Je=(0,O.useRef)(()=>{let p=fe.current;return typeof p=="function"?p():p}).current,Ge=yt(G),sa=(0,O.useRef)(c);sa.current=c;let se=(0,O.useRef)((p,$)=>{let B=sa.current;return B?B(p,$):p}).current,Ke=c?se:void 0,la=xt(i);(0,O.useEffect)(()=>{if(typeof document>"u")return;let p=new Ne.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:v,productId:x,visitorId:Je,optionOverrides:la.overrides,maskCompletedText:o,columns:b,dropdownTrigger:u,optionsPosition:h,closeDropdownOnBlur:C,prependPlaceholder:y,allOption:j,showNonTappableOptions:F,locationSearch:D,showProducts:W,source:na,value:ee,completedParams:_,onSubmit:(...B)=>$e.current?.(...B),onResult:(...B)=>Ze.current?.(...B),onError:(...B)=>Xe.current?.(...B),onChange:(...B)=>g.current?.(...B),onParamsChange:(...B)=>S.current?.(...B),onFocus:()=>E.current?.(),onBlur:()=>R.current?.(),onProductSelect:B=>re.current?.(B),onProductAddToCart:B=>Te.current?.(B),setCursor:B=>N.current?.(B),products:Ge.config,mapProducts:Ke});w.current=p,We(p.getState());let $=p.subscribe(B=>We(B));return()=>{$(),p.destroy(),w.current===p&&(w.current=null)}},[]),(0,O.useEffect)(()=>{ee!==void 0&&w.current?.setValue(ee)},[ee]),(0,O.useEffect)(()=>{_!==void 0&&w.current?.setCompletedParams(_)},[_]);let ba=JSON.stringify(s??null),Re;try{Re=JSON.stringify(r??null)}catch{Re="[unstringifiable]"}(0,O.useEffect)(()=>{w.current?.update({apiConfig:s,additionalContext:r,language:l,currency:v,productId:x,optionOverrides:la.overrides,dropdownTrigger:u,optionsPosition:h,closeDropdownOnBlur:C,prependPlaceholder:y,allOption:j,showNonTappableOptions:F,locationSearch:D,showProducts:W})},[ba,Re,l,v?.code,v?.rate,v?.country,x,la.key,u,h,C,y,j,F,D,W]);let ua=(0,O.useRef)(!1);(0,O.useEffect)(()=>{if(!ua.current){ua.current=!0;return}w.current?.update({products:Ge.config})},[Ge.enabled]),(0,O.useEffect)(()=>{w.current?.update({mapProducts:Ke})},[Ke]);let ea=(0,O.useRef)(null);ea.current===null&&(ea.current={handleTextChange:p=>w.current?.handleTextChange(p),handleCompositionText:p=>w.current?.handleCompositionText(p),handleKeyDown:p=>{let $="nativeEvent"in p?p.nativeEvent:p;w.current?.handleKeyDown($)},setFocused:p=>w.current?.setFocused(p),startEditingParam:p=>w.current?.startEditingParam(p),removeParam:p=>w.current?.removeParam(p)??!1,exitEditMode:()=>w.current?.exitEditMode(),handleCaretAfterInput:p=>w.current?.handleCaretAfterInput(p),handleCaretMove:p=>w.current?.handleCaretMove(p),replaceEditingRange:p=>w.current?.replaceEditingRange(p)??!1,setActivePill:p=>w.current?.setActivePill(p),skipActivePill:()=>w.current?.skipActivePill(),removeLastParam:()=>w.current?.removeLastParam(),clearNewParamId:()=>w.current?.clearNewParamId(),reset:()=>w.current?.reset(),refreshProducts:()=>w.current?.refreshProducts(),prepareSubmit:()=>w.current?.prepareSubmit(),getState:()=>w.current?.getState()??kt,recordSubmit:p=>w.current?.recordSubmit(p),selectOption:(p,$)=>w.current?.selectOption(p,$),selectProduct:p=>w.current?.selectProduct(p),addProductToCart:p=>{let $=w.current;return!$||!Te.current?Promise.resolve():$.addProductToCart(p)},setActiveDropdownIndex:p=>w.current?.setActiveDropdownIndex(p),clearHighlight:p=>w.current?.clearHighlight(p),showPreviousMonth:()=>w.current?.showPreviousMonth(),showNextMonth:()=>w.current?.showNextMonth(),setTime:p=>w.current?.setTime(p),commitTime:()=>w.current?.commitTime(),toggleMultiSelectOption:p=>w.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>w.current?.commitMultiSelect(),setLocationQuery:p=>w.current?.setLocationQuery(p),moveLocationHighlight:p=>w.current?.moveLocationHighlight(p),commitLocation:p=>w.current?.commitLocation(p),setLocationFieldFocused:p=>w.current?.setLocationFieldFocused(p),handleFocus:()=>w.current?.setFocused(!0),handleBlur:()=>w.current?.setFocused(!1)});let f=ea.current,qe=(0,O.useCallback)(p=>{let $=p.target.value,ga=$.length>0&&!p.nativeEvent?.isComposing&&$[0]!==$[0].toUpperCase()?$[0].toUpperCase()+$.slice(1):$;w.current?.handleTextChange(ga)},[]),da=(0,O.useCallback)(p=>{w.current?.handleKeyDown(p.nativeEvent)},[]),n=w.current,m=ra??kt,_e=ee!==void 0?ee:m.text,Ve=_!==void 0?_:m.completedParams,Oe=m.actionableSuggestions,Ue=Oe[0],aa=(0,O.useMemo)(()=>(0,Ne.withoutTraditionalAutocomplete)(Oe),[Oe]),Le=n?.listboxId??"",wa=m.activeDropdownIndex>=0&&n?`${Le}-option-${m.activeDropdownIndex}`:void 0,Qe=m.editingParam,ze=m.editingIdentified,ta=Qe?(0,Ne.editingSuggestion)(Qe):ze?{parameter:ze.parameter,text:(0,Ne.identifiedParamLabel)(ze.parameter),required:!0,options:[]}:null,ca=m.dropdownSuggestion??ta??Ue,ma=ta?[ta]:Oe,Ye=(0,Ne.dateSelectionFor)(m),pa=!n||m.dropdownLoading;return{completedParams:Ve,multiSelectView:m.multiSelectView,toggleMultiSelectOption:f.toggleMultiSelectOption,commitMultiSelect:f.commitMultiSelect,skippedParams:m.skippedParams,identifiedParams:m.identifiedParams,suggestionPills:aa,setActivePill:f.setActivePill,skipActivePill:f.skipActivePill,removeLastParam:f.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:f.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:pa,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:Le,error:m.error,products:m.products,customFields:m.customFields,selectProduct:f.selectProduct,addProductToCart:f.addProductToCart,handleTextChange:f.handleTextChange,handleCompositionText:f.handleCompositionText,handleKeyDown:f.handleKeyDown,setFocused:f.setFocused,editingParam:Qe,editingIdentified:ze,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:f.startEditingParam,removeParam:f.removeParam,exitEditMode:f.exitEditMode,handleCaretAfterInput:f.handleCaretAfterInput,handleCaretMove:f.handleCaretMove,replaceEditingRange:f.replaceEditingRange,inputProps:{value:_e,placeholder:m.placeholderText||void 0,onChange:qe,onKeyDown:da,onFocus:f.handleFocus,onBlur:f.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":wa,"aria-autocomplete":"list","aria-controls":Le},reset:f.reset,refreshProducts:f.refreshProducts,prepareSubmit:f.prepareSubmit,getState:f.getState,recordSubmit:f.recordSubmit,dropdownProps:{suggestions:ca?[{...ca,options:m.dropdownOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:f.selectOption,onHighlight:f.setActiveDropdownIndex,onUnhighlight:f.clearHighlight,isOpen:m.isDropdownOpen,id:Le,pills:ma,activeSelected:m.isActivePillSelected,onPillClick:f.setActivePill,onSkip:f.skipActivePill,showSkipButton:(oe??!0)&&!Qe&&!ze,showOptionIcons:he??!0,showOptionImages:P??!0,showOptionCounts:H??!0,skipDisabled:m.inSelectionAnimation,isLoading:pa,skeletonExiting:m.skeletonExiting,isInputEmpty:_e.trim().length===0,language:l,products:m.products,productImageFallback:ge,showProductVendor:pe,onProductSelect:f.selectProduct,onProductAddToCart:Fe?f.addProductToCart:void 0,onProductFocusChange:f.setFocused,formatType:m.activeFormatType,dateView:m.dateView,selectedDateIso:Ye.selectedIso,selectedDateRange:Ye.selectedRange,dateRangeStart:Ye.rangeStart,dateReferences:Ye.references,onPreviousMonth:f.showPreviousMonth,onNextMonth:f.showNextMonth,timeView:m.timeView,multiSelectView:m.dropdownMultiSelect,onMultiSelectCommit:f.commitMultiSelect,onTimeChange:f.setTime,onTimeCommit:f.commitTime,locationView:m.locationView,isReediting:m.editingParam!=null,onLocationQuery:f.setLocationQuery,onLocationMove:f.moveLocationHighlight,onLocationCommit:f.commitLocation,onLocationFocusChange:f.setLocationFieldFocused,isFocused:m.isFocused||m.locationFieldFocused,optionsPosition:h??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),z=require("react"),za;function pi(){if(za!==void 0)return za;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),za=e.contentEditable==="plaintext-only",za}function Ct(e){let{segments:t,showChipIcons:a=!0,showChipImages:i=!0,showChipRemove:o=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:v,editingAnchor:x,caretOffset:k,placeholderText:b,hintSuggestions:u,isFocused:h,isDropdownOpen:C,listboxId:y,activeDescendantId:j,autoFocus:F,handleTextChange:D,handleCompositionText:he,handleKeyDown:P,handleCaretAfterInput:H,handleCaretMove:oe,startEditingParam:W,replaceEditingRange:ge,setFocused:pe}=e,A=(0,z.useRef)(null),ne=(0,z.useRef)(!1),ee=(0,z.useRef)(""),_=(0,z.useRef)(""),xe=(0,z.useRef)(null),T=(0,z.useRef)(0);xe.current=k,(0,z.useEffect)(()=>{if(!F)return;let g=A.current;if(!g)return;document.activeElement===g?pe(!0):g.focus();let S=g.ownerDocument??document,E=S.getSelection(),R=E&&E.rangeCount>0&&g.contains(E.anchorNode);if(E&&!R){let N=S.createRange();N.selectNodeContents(g),N.collapse(!0),E.removeAllRanges(),E.addRange(N)}},[F,pe]),(0,z.useEffect)(()=>{let g=A.current;if(!g)return;let S=g.ownerDocument??document,E=()=>{let R=S.getSelection();if(!R||R.rangeCount===0||!R.anchorNode||!g.contains(R.anchorNode))return;let N=R.anchorNode,re=N.nodeType===Node.ELEMENT_NODE?N:N.parentElement,fe=(R.isCollapsed?re?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Je=l?.id??v?.id??null;if(fe&&fe!==Je){W(fe);return}performance.now()-T.current<50||oe((0,Q.getCursorOffset)(g))};return S.addEventListener("selectionchange",E),()=>S.removeEventListener("selectionchange",E)},[l,v,W,oe]),(0,z.useEffect)(()=>{let g=A.current;if(!g)return;let S=E=>{let R=(0,Q.chipIdFromTap)(g,E.target);R&&(W(R),(0,Q.keepCaretOnChip)(g,R))};return g.addEventListener("click",S),()=>g.removeEventListener("click",S)},[W]),(0,z.useEffect)(()=>{let g=A.current;if(!(!g||!s||!o))return(0,Q.attachChipRemove)(g,s)},[s,o]),(0,z.useLayoutEffect)(()=>{let g=A.current;g&&(0,Q.renderEditableContent)({input:g,segments:t,newParamId:r,editingParamId:l?.id??null,placeholderText:b??"",isFocused:h,showChipIcons:a,showChipImages:i,showChipRemove:o,hintOptions:(0,Q.startingHintOptions)(u??[])})},[t,r,l,b,u,h,a,i,o]),(0,z.useEffect)(()=>{let g=A.current;return()=>{g&&(0,Q.cancelStartingHint)(g)}},[]),(0,z.useLayoutEffect)(()=>{let g=ee.current,S=r??"";if(ee.current=S,!S||S===g)return;let E=A.current;if(!E)return;E.focus();let R=xe.current??(0,Q.plainTextLength)(E);(0,Q.setCursorOffset)(E,R)},[r]),(0,z.useLayoutEffect)(()=>{let g=_.current,S=l?.id??"";if(_.current=S,!S||S===g||x==null)return;let E=A.current;E&&(0,Q.setCursorOffset)(E,x)},[l,x]);let G=(0,z.useCallback)(()=>{let g=A.current;if(!g)return;let S=(0,Q.extractPlainText)(g),R=S.length>0&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;if(ne.current){he(R);return}D(R)},[D,he]),c=(0,z.useCallback)(()=>{T.current=performance.now(),G();let g=A.current;g&&H((0,Q.getCursorOffset)(g))},[G,H]);(0,z.useEffect)(()=>{let g=A.current;if(!g)return;let S=E=>{let R=E,N=R.inputType;if(N==="insertParagraph"||N==="insertLineBreak"||N==="insertFromDrop"){E.preventDefault();return}if(N.startsWith("insert")||N.startsWith("delete")){let re=N.startsWith("delete")?"":R.data??"";ge(re)&&E.preventDefault()}};return g.addEventListener("beforeinput",S),()=>g.removeEventListener("beforeinput",S)},[ge]);let I=(0,z.useCallback)(()=>{ne.current=!0,A.current?.setAttribute("data-aia-composing","true")},[]),Fe=(0,z.useCallback)(()=>{ne.current=!1,A.current?.removeAttribute("data-aia-composing"),G()},[G]),na=(0,z.useCallback)(g=>{g.preventDefault();let S=A.current;if(!S)return;let E=(g.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!E)return;let R=S.ownerDocument??document,N=R.getSelection();if(!N||N.rangeCount===0)return;let re=N.getRangeAt(0);if(!S.contains(re.startContainer))return;re.deleteContents();let Te=R.createTextNode(E);re.insertNode(Te),re.setStartAfter(Te),re.collapse(!0),N.removeAllRanges(),N.addRange(re),G()},[G]),Be=(0,z.useCallback)(g=>P(g),[P]),w=(0,z.useCallback)(()=>pe(!0),[pe]),ra=(0,z.useCallback)(()=>pe(!1),[pe]),We=(0,z.useCallback)(()=>A.current?.focus(),[]),$e=(0,z.useCallback)(()=>A.current?.blur(),[]),Ze=(0,z.useCallback)(()=>{let g=A.current;return g?(0,Q.extractPlainText)(g):""},[]),Xe=pi()?"plaintext-only":"true";return{inputRef:A,editorProps:{ref:A,contentEditable:Xe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":y,"aria-expanded":C,"aria-activedescendant":j,spellCheck:!0,enterKeyHint:"send",onInput:c,onKeyDown:Be,onCompositionStart:I,onCompositionEnd:Fe,onPaste:na,onFocus:w,onBlur:ra},getPlainText:Ze,focus:We,blur:$e}}var Ae=require("react/jsx-runtime");function hi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var St=(0,Y.forwardRef)(function({onSubmit:t,onResult:a,onError:i,optionOverrides:o,maskCompletedText:s,className:r,apiConfig:l,additionalContext:v,language:x,currency:k,productId:b,visitorId:u,columns:h,pillPlacement:C="dropdown",mode:y="auto",optionsPosition:j="below",animations:F=!0,optionsStyle:D="floating",dropdownTrigger:he,closeDropdownOnBlur:P,prependPlaceholder:H,allOption:oe,showNonTappableOptions:W,locationSearch:ge,showOptionIcons:pe=!0,showChipIcons:A=!0,showChipImages:ne=!0,showChipRemove:ee=!1,showOptionImages:_=!0,showOptionCounts:xe=!0,showSkipButton:T,showProducts:G,productsLayout:c,productImageFallback:I,showProductVendor:Fe,autoFocus:na=!0,onFocus:Be,onBlur:w,value:ra,completedParams:We,onChange:$e,onParamsChange:Ze,products:Xe,mapProducts:g,onProductSelect:S,onProductAddToCart:E,submitButton:R,resetOnSubmit:N=!0,seeAllResults:re=!1},Te){let fe=(0,Y.useRef)(null),Je=(0,Y.useRef)(null),Ge=(0,Y.useRef)(null),sa=(0,Y.useRef)(()=>{}),se=(0,Y.useRef)(null),Ke=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let K=fe.current;if(K)return se.current?se.current.setMode(y):se.current=new He.ModeController(K,y),()=>{se.current?.destroy(),se.current=null}},[y]);let la=(0,Y.useCallback)(K=>{let be=Ke.current?.current;be&&(be.focus(),(0,He.setCursorOffset)(be,K))},[]),{completedParams:ba,suggestionPills:Re,setActivePill:ua,skipActivePill:ea,segments:f,newParamId:qe,clearNewParamId:da,placeholderText:n,isFocused:m,isDropdownOpen:_e,isActivePillSelected:Ve,isLoading:Oe,isReady:Ue,activeIndex:aa,listboxId:Le,handleTextChange:wa,handleCompositionText:Qe,handleKeyDown:ze,setFocused:ta,editingParam:ca,editingIdentified:ma,editingAnchor:Ye,caretOffset:pa,startEditingParam:p,removeParam:$,handleCaretAfterInput:B,handleCaretMove:ga,replaceEditingRange:M,dropdownProps:Ka,reset:Sa,refreshProducts:qa,prepareSubmit:_a,getState:Va,recordSubmit:Ua}=La({onSubmit:K=>sa.current(K),onResult:a,onError:i,optionOverrides:o,maskCompletedText:s,apiConfig:l,additionalContext:v,language:x,currency:k,productId:b,visitorId:u,columns:h,dropdownTrigger:he,optionsPosition:j,closeDropdownOnBlur:P,prependPlaceholder:H,allOption:oe,showNonTappableOptions:W,locationSearch:ge,showOptionIcons:pe,showOptionImages:_,showOptionCounts:xe,showSkipButton:T,showProducts:G,onFocus:Be,onBlur:w,value:ra,completedParams:We,onChange:$e,onParamsChange:Ze,products:Xe,mapProducts:g,onProductSelect:S,onProductAddToCart:E,source:"full-sdk",setCursor:la});(0,Y.useEffect)(()=>{if(!qe)return;let K=window.setTimeout(()=>da(),650);return()=>window.clearTimeout(K)},[qe,da]);let Tt=aa>=0?`${Le}-option-${aa}`:void 0,{inputRef:Da,editorProps:Pt,focus:Ta,blur:Qa,getPlainText:Ya}=Ct({segments:f,newParamId:qe,editingParam:ca,editingIdentified:ma,editingAnchor:Ye,caretOffset:pa,placeholderText:n,hintSuggestions:C==="inline"?[]:Re,isFocused:m,showChipIcons:A,showChipImages:ne,showChipRemove:ee,removeParam:$,isDropdownOpen:_e,listboxId:Le,activeDescendantId:Tt,autoFocus:na,handleTextChange:wa,handleCompositionText:Qe,handleKeyDown:ze,handleCaretAfterInput:B,handleCaretMove:ga,startEditingParam:p,replaceEditingRange:M,setFocused:ta});Ke.current=Da,(0,Y.useLayoutEffect)(()=>{let K=Je.current,be=Da.current;if(!K||!be)return;let xa=()=>{let $a=K.firstElementChild;if(!$a)return;let Lt=$a.getBoundingClientRect(),zt=be.getBoundingClientRect();Lt.top>=zt.bottom-2?K.setAttribute("data-aia-pill-wrapped",""):K.removeAttribute("data-aia-pill-wrapped")};xa();let ja=new ResizeObserver(xa);return ja.observe(be),()=>ja.disconnect()},[f,Re.length,Oe,Da]),(0,Y.useEffect)(()=>{let K=Ge.current;if(K)return(0,He.watchEditorHeight)(K)},[]),(0,Y.useImperativeHandle)(Te,()=>({focus:Ta,blur:Qa,reset:Sa,refreshProducts:qa,setMode:K=>se.current?.setMode(K),skipActivePill:ea}),[Ta,Qa,Sa,qa,ea]);let fa=!!f.length||ba.length>0,va=(0,Y.useCallback)(K=>{if(!fa)return;K&&_a();let be=Va(),xa=(0,He.buildSubmitResult)(Ya(),be.completedParams,be.skippedParams,{identifiedParams:be.identifiedParams,isReady:be.isReady,customFields:be.customFields});K&&Ua(xa),t(xa),N&&Sa()},[Ua,N,fa,_a,Va,t,Sa,Ya]);sa.current=()=>va(!1);let It=re&&!Ka.isInputEmpty&&fa,Et=(0,Y.useCallback)(()=>va(!0),[va]),At=(0,Y.useCallback)(K=>{K.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||Ta()},[Ta]),Rt=C==="inline",Ot=C==="dropdown";return(0,Ae.jsxs)("div",{ref:fe,className:`magicx-aia ${ha.container} ${r??""}`,"data-pill-placement":C,"data-options-position":j,"data-animations":F?"on":"off","data-aia-options-style":D,"data-mode":hi(y),children:[(0,Ae.jsx)(Ra,{...Ka,showPills:Ot,productsLayout:c,productImageFallback:I,showProductVendor:Fe,onSeeAllResults:It?Et:void 0,fullWidth:re}),(0,Ae.jsxs)("div",{className:ha.inputWrapper,"data-aia-input-wrapper":"",onClick:At,children:[(0,Ae.jsxs)("div",{ref:Ge,className:ha.editorArea,"data-aia-editor":"",children:[(0,Ae.jsx)("div",{...Pt,className:ha.input,"data-aia-input":""}),Rt&&(Oe||Re.length>0)&&(0,Ae.jsx)("span",{ref:Je,className:ha.pillListContainer,"data-aia-pill-list-container":"",children:(0,Ae.jsx)(Ea,{pills:Re,activePillIndex:0,activeSelected:Ve,onSelectPill:ua,loading:Oe})})]}),R===null?null:R===void 0?(0,Ae.jsx)(vt,{disabled:!fa,ready:fa&&Ue,onClick:()=>va(!0),label:(0,He.uiStringsFor)(x).submit}):(0,Ae.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ha.submitSlot,onClick:K=>{fa&&(K.stopPropagation(),va(!0))},children:R})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
3910
|
+
`,document.head.appendChild(e)}var yt={submitButton:"aia-submitButton-otz7H",submitSpin:"aia-submitSpin-0llcF"};var Da=require("react/jsx-runtime");function St({disabled:e,ready:i,busy:t=!1,onClick:n,label:o=(0,kt.uiStringsFor)().submit}){return(0,Da.jsx)("button",{type:"button","data-aia-submit":"",className:yt.submitButton,disabled:e,"data-aia-ready":i?"":void 0,"data-aia-submit-state":t?"busy":void 0,"aria-busy":t?!0:void 0,onClick:s=>{s.stopPropagation(),n()},"aria-label":o,children:(0,Da.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":o,children:(0,Da.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var ke=require("@magicx-eng/ai-autocomplete-vanilla"),z=require("react");var Va=require("react");function Ct(e){let i=(0,Va.useRef)(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,Va.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let o={};for(let s of Object.keys(e??{})){let r=(l,b,v)=>{let x=i.current?.[s];return x?x(l,b,v):[]};o[s]=r}n.current={key:t,overrides:e?o:void 0}}return{overrides:n.current.overrides,key:t}}var Ua=require("react");function Tt(e){let i=(0,Ua.useRef)(e);i.current=e;let t=(0,Ua.useRef)(null);t.current===null&&(t.current={fetch:(o,s)=>{let r=i.current;return r?r.fetch(o,s):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var Pt={text:"",composing:null,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,isSubmitting:!1,selectingProductId:null,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 Ma({onSubmit:e,onResult:i,onError:t,optionOverrides:n,maskCompletedText:o,apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,visitorId:x,columns:f=2,dropdownTrigger:h,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:k,allOption:C,showNonTappableOptions:F,locationSearch:M,showOptionIcons:he,showOptionImages:A,showOptionCounts:H,showSkipButton:oe,showProducts:G,submitProgress:de,productImageFallback:ce="image",showProductVendor:E=!0,onFocus:ne,onBlur:ue,value:_,completedParams:pe,onChange:T,onParamsChange:W,products:p,mapProducts:P,onProductSelect:Qe,onProductAddToCart:Ke,source:Ye,setCursor:je}){let m=(0,z.useRef)(null),[$e,De]=(0,z.useState)(null),Ze=(0,z.useRef)(e);Ze.current=e;let Xe=(0,z.useRef)(i);Xe.current=i;let g=(0,z.useRef)(t);g.current=t;let S=(0,z.useRef)(T);S.current=T;let I=(0,z.useRef)(W);I.current=W;let R=(0,z.useRef)(ne);R.current=ne;let N=(0,z.useRef)(ue);N.current=ue;let te=(0,z.useRef)(je);te.current=je;let Se=(0,z.useRef)(Qe);Se.current=Qe;let Ae=(0,z.useRef)(Ke);Ae.current=Ke;let qe=(0,z.useRef)(x);qe.current=x;let _e=(0,z.useRef)(()=>{let d=qe.current;return typeof d=="function"?d():d}).current,Je=Tt(p),ea=(0,z.useRef)(P);ea.current=P;let Me=(0,z.useRef)((d,Y)=>{let K=ea.current;return K?K(d,Y):d}).current,me=P?Me:void 0,aa=Ct(n);(0,z.useEffect)(()=>{if(typeof document>"u")return;let d=new ke.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,visitorId:_e,optionOverrides:aa.overrides,maskCompletedText:o,columns:f,dropdownTrigger:h,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:k,allOption:C,showNonTappableOptions:F,locationSearch:M,showProducts:G,submitProgress:de,source:Ye,value:_,completedParams:pe,onSubmit:(...K)=>Ze.current?.(...K),onResult:(...K)=>Xe.current?.(...K),onError:(...K)=>g.current?.(...K),onChange:(...K)=>S.current?.(...K),onParamsChange:(...K)=>I.current?.(...K),onFocus:()=>R.current?.(),onBlur:()=>N.current?.(),onProductSelect:K=>Se.current?Se.current(K):ke.HANDOFF_NOT_HANDLED,onProductAddToCart:K=>Ae.current?.(K),setCursor:K=>te.current?.(K),products:Je.config,mapProducts:me});m.current=d,De(d.getState());let Y=d.subscribe(K=>De(K));return()=>{Y(),d.destroy(),m.current===d&&(m.current=null)}},[]),(0,z.useEffect)(()=>{_!==void 0&&m.current?.setValue(_)},[_]),(0,z.useEffect)(()=>{pe!==void 0&&m.current?.setCompletedParams(pe)},[pe]);let wa=JSON.stringify(s??null),Ne;try{Ne=JSON.stringify(r??null)}catch{Ne="[unstringifiable]"}(0,z.useEffect)(()=>{m.current?.update({apiConfig:s,additionalContext:r,language:l,currency:b,productId:v,optionOverrides:aa.overrides,dropdownTrigger:h,optionsPosition:u,closeDropdownOnBlur:y,prependPlaceholder:k,allOption:C,showNonTappableOptions:F,locationSearch:M,showProducts:G,submitProgress:de})},[wa,Ne,l,b?.code,b?.rate,b?.country,v,aa.key,h,u,y,k,C,F,M,G,de]);let ua=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(!ua.current){ua.current=!0;return}m.current?.update({products:Je.config})},[Je.enabled]),(0,z.useEffect)(()=>{m.current?.update({mapProducts:me})},[me]);let ta=(0,z.useRef)(null);ta.current===null&&(ta.current={handleTextChange:d=>m.current?.handleTextChange(d),handleCompositionText:d=>m.current?.handleCompositionText(d),handleKeyDown:d=>{let Y="nativeEvent"in d?d.nativeEvent:d;m.current?.handleKeyDown(Y)},setFocused:d=>m.current?.setFocused(d),startEditingParam:d=>m.current?.startEditingParam(d),removeParam:d=>m.current?.removeParam(d)??!1,exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:d=>m.current?.handleCaretAfterInput(d),handleCaretMove:d=>m.current?.handleCaretMove(d),replaceEditingRange:d=>m.current?.replaceEditingRange(d)??!1,setActivePill:d=>m.current?.setActivePill(d),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()??Pt,recordSubmit:d=>m.current?.recordSubmit(d),holdSubmit:d=>m.current?.holdSubmit(d),endSubmitProgress:()=>m.current?.endSubmitProgress(),selectOption:(d,Y)=>m.current?.selectOption(d,Y),selectProduct:d=>m.current?.selectProduct(d),addProductToCart:d=>{let Y=m.current;return!Y||!Ae.current?Promise.resolve():Y.addProductToCart(d)},setActiveDropdownIndex:d=>m.current?.setActiveDropdownIndex(d),clearHighlight:d=>m.current?.clearHighlight(d),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),setTime:d=>m.current?.setTime(d),commitTime:()=>m.current?.commitTime(),toggleMultiSelectOption:d=>m.current?.toggleMultiSelectOption(d),commitMultiSelect:()=>m.current?.commitMultiSelect(),setLocationQuery:d=>m.current?.setLocationQuery(d),moveLocationHighlight:d=>m.current?.moveLocationHighlight(d),commitLocation:d=>m.current?.commitLocation(d),setLocationFieldFocused:d=>m.current?.setLocationFieldFocused(d),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let w=ta.current,be=(0,z.useCallback)(d=>{let Y=d.target.value,fa=Y.length>0&&!d.nativeEvent?.isComposing&&Y[0]!==Y[0].toUpperCase()?Y[0].toUpperCase()+Y.slice(1):Y;m.current?.handleTextChange(fa)},[]),ia=(0,z.useCallback)(d=>{m.current?.handleKeyDown(d.nativeEvent)},[]),oa=m.current,a=$e??Pt,ie=_!==void 0?_:a.text,na=pe!==void 0?pe:a.completedParams,we=a.actionableSuggestions,va=we[0],Fe=(0,z.useMemo)(()=>(0,ke.withoutTraditionalAutocomplete)(we),[we]),Ee=oa?.listboxId??"",ma=a.activeDropdownIndex>=0&&oa?`${Ee}-option-${a.activeDropdownIndex}`:void 0,ra=a.editingParam,He=a.editingIdentified,da=ra?(0,ke.editingSuggestion)(ra):He?{parameter:He.parameter,text:(0,ke.identifiedParamLabel)(He.parameter),required:!0,options:[]}:null,ca=a.dropdownSuggestion??da??va,ga=(0,ke.dropdownPillsFor)(a.dropdownSuggestion,da,we),Ve=(0,ke.dateSelectionFor)(a),pa=!oa||a.dropdownLoading;return{completedParams:na,multiSelectView:a.multiSelectView,toggleMultiSelectOption:w.toggleMultiSelectOption,commitMultiSelect:w.commitMultiSelect,skippedParams:a.skippedParams,identifiedParams:a.identifiedParams,suggestionPills:Fe,setActivePill:w.setActivePill,skipActivePill:w.skipActivePill,removeLastParam:w.removeLastParam,segments:a.segments,newParamId:a.newParamId,clearNewParamId:w.clearNewParamId,suggestions:a.suggestions,activeIndex:a.activeDropdownIndex,isReady:a.isReady,isLoading:pa,isFocused:a.isFocused,isDropdownOpen:a.isDropdownOpen,isActivePillSelected:a.isActivePillSelected,placeholderText:a.placeholderText,listboxId:Ee,error:a.error,products:a.products,customFields:a.customFields,selectProduct:w.selectProduct,addProductToCart:w.addProductToCart,handleTextChange:w.handleTextChange,handleCompositionText:w.handleCompositionText,handleKeyDown:w.handleKeyDown,setFocused:w.setFocused,editingParam:ra,editingIdentified:He,editingAnchor:a.editingAnchor,caretOffset:a.caretOffset,startEditingParam:w.startEditingParam,removeParam:w.removeParam,exitEditMode:w.exitEditMode,handleCaretAfterInput:w.handleCaretAfterInput,handleCaretMove:w.handleCaretMove,replaceEditingRange:w.replaceEditingRange,inputProps:{value:ie,placeholder:a.placeholderText||void 0,onChange:be,onKeyDown:ia,onFocus:w.handleFocus,onBlur:w.handleBlur,role:"combobox","aria-expanded":a.isDropdownOpen,"aria-activedescendant":ma,"aria-autocomplete":"list","aria-controls":Ee},reset:w.reset,refreshProducts:w.refreshProducts,prepareSubmit:w.prepareSubmit,getState:w.getState,recordSubmit:w.recordSubmit,holdSubmit:w.holdSubmit,endSubmitProgress:w.endSubmitProgress,isSubmitting:a.isSubmitting,selectingProductId:a.selectingProductId,dropdownProps:{suggestions:ca?[{...ca,options:a.dropdownOptions}]:[],activeIndex:a.activeDropdownIndex,onSelect:w.selectOption,onHighlight:w.setActiveDropdownIndex,onUnhighlight:w.clearHighlight,isOpen:a.isDropdownOpen,id:Ee,pills:ga,activeSelected:a.isActivePillSelected,onPillClick:w.setActivePill,onSkip:w.skipActivePill,showSkipButton:(oe??!0)&&!ra&&!He,showOptionIcons:he??!0,showOptionImages:A??!0,showOptionCounts:H??!0,skipDisabled:a.inSelectionAnimation,isLoading:pa,skeletonExiting:a.skeletonExiting,isInputEmpty:ie.trim().length===0,language:l,products:a.products,productImageFallback:ce,showProductVendor:E,onProductSelect:w.selectProduct,busyProductId:a.selectingProductId,seeAllBusy:a.isSubmitting,onProductAddToCart:Ke?w.addProductToCart:void 0,onProductFocusChange:w.setFocused,formatType:a.activeFormatType,dateView:a.dateView,selectedDateIso:Ve.selectedIso,selectedDateRange:Ve.selectedRange,dateRangeStart:Ve.rangeStart,dateReferences:Ve.references,onPreviousMonth:w.showPreviousMonth,onNextMonth:w.showNextMonth,timeView:a.timeView,multiSelectView:a.dropdownMultiSelect,onMultiSelectCommit:w.commitMultiSelect,onTimeChange:w.setTime,onTimeCommit:w.commitTime,locationView:a.locationView,isReediting:a.editingParam!=null,onLocationQuery:w.setLocationQuery,onLocationMove:w.moveLocationHighlight,onLocationCommit:w.commitLocation,onLocationFocusChange:w.setLocationFieldFocused,isFocused:a.isFocused||a.locationFieldFocused,optionsPosition:u??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),D=require("react"),Na;function gi(){if(Na!==void 0)return Na;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Na=e.contentEditable==="plaintext-only",Na}function It(e){let{segments:i,showChipIcons:t=!0,showChipImages:n=!0,showChipRemove:o=!1,removeParam:s,newParamId:r,editingParam:l,editingIdentified:b,editingAnchor:v,caretOffset:x,placeholderText:f,hintSuggestions:h,isFocused:u,isDropdownOpen:y,listboxId:k,activeDescendantId:C,autoFocus:F,handleTextChange:M,handleCompositionText:he,handleKeyDown:A,handleCaretAfterInput:H,handleCaretMove:oe,startEditingParam:G,replaceEditingRange:de,setFocused:ce}=e,E=(0,D.useRef)(null),ne=(0,D.useRef)(!1),ue=(0,D.useRef)(""),_=(0,D.useRef)(""),pe=(0,D.useRef)(null),T=(0,D.useRef)(0);pe.current=x,(0,D.useEffect)(()=>{if(!F)return;let g=E.current;if(!g)return;document.activeElement===g?ce(!0):g.focus();let S=g.ownerDocument??document,I=S.getSelection(),R=I&&I.rangeCount>0&&g.contains(I.anchorNode);if(I&&!R){let N=S.createRange();N.selectNodeContents(g),N.collapse(!0),I.removeAllRanges(),I.addRange(N)}},[F,ce]),(0,D.useEffect)(()=>{let g=E.current;if(!g)return;let S=g.ownerDocument??document,I=()=>{let R=S.getSelection();if(!R||R.rangeCount===0||!R.anchorNode||!g.contains(R.anchorNode))return;let N=R.anchorNode,te=N.nodeType===Node.ELEMENT_NODE?N:N.parentElement,Ae=(R.isCollapsed?te?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,qe=l?.id??b?.id??null;if(Ae&&Ae!==qe){G(Ae);return}performance.now()-T.current<50||oe((0,Q.getCursorOffset)(g))};return S.addEventListener("selectionchange",I),()=>S.removeEventListener("selectionchange",I)},[l,b,G,oe]),(0,D.useEffect)(()=>{let g=E.current;if(!g)return;let S=I=>{let R=(0,Q.chipIdFromTap)(g,I.target);R&&(G(R),(0,Q.keepCaretOnChip)(g,R))};return g.addEventListener("click",S),()=>g.removeEventListener("click",S)},[G]),(0,D.useEffect)(()=>{let g=E.current;if(!(!g||!s||!o))return(0,Q.attachChipRemove)(g,s)},[s,o]),(0,D.useLayoutEffect)(()=>{let g=E.current;g&&(0,Q.renderEditableContent)({input:g,segments:i,newParamId:r,editingParamId:l?.id??null,placeholderText:f??"",isFocused:u,showChipIcons:t,showChipImages:n,showChipRemove:o,hintOptions:(0,Q.startingHintOptions)(h??[])})},[i,r,l,f,h,u,t,n,o]),(0,D.useEffect)(()=>{let g=E.current;return()=>{g&&(0,Q.cancelStartingHint)(g)}},[]),(0,D.useLayoutEffect)(()=>{let g=ue.current,S=r??"";if(ue.current=S,!S||S===g)return;let I=E.current;if(!I)return;I.focus();let R=pe.current??(0,Q.plainTextLength)(I);(0,Q.setCursorOffset)(I,R)},[r]),(0,D.useLayoutEffect)(()=>{let g=_.current,S=l?.id??"";if(_.current=S,!S||S===g||v==null)return;let I=E.current;I&&(0,Q.setCursorOffset)(I,v)},[l,v]);let W=(0,D.useCallback)(()=>{let g=E.current;if(!g)return;let S=(0,Q.extractPlainText)(g),R=S.length>0&&S[0]!==S[0].toUpperCase()?S[0].toUpperCase()+S.slice(1):S;if(ne.current){he(R);return}M(R)},[M,he]),p=(0,D.useCallback)(()=>{T.current=performance.now(),W();let g=E.current;g&&H((0,Q.getCursorOffset)(g))},[W,H]);(0,D.useEffect)(()=>{let g=E.current;if(!g)return;let S=I=>{let R=I,N=R.inputType;if(N==="insertParagraph"||N==="insertLineBreak"||N==="insertFromDrop"){I.preventDefault();return}if(N.startsWith("insert")||N.startsWith("delete")){let te=N.startsWith("delete")?"":R.data??"";de(te)&&I.preventDefault()}};return g.addEventListener("beforeinput",S),()=>g.removeEventListener("beforeinput",S)},[de]);let P=(0,D.useCallback)(()=>{ne.current=!0,E.current?.setAttribute("data-aia-composing","true")},[]),Qe=(0,D.useCallback)(()=>{ne.current=!1,E.current?.removeAttribute("data-aia-composing"),W()},[W]),Ke=(0,D.useCallback)(g=>{g.preventDefault();let S=E.current;if(!S)return;let I=(g.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!I)return;let R=S.ownerDocument??document,N=R.getSelection();if(!N||N.rangeCount===0)return;let te=N.getRangeAt(0);if(!S.contains(te.startContainer))return;te.deleteContents();let Se=R.createTextNode(I);te.insertNode(Se),te.setStartAfter(Se),te.collapse(!0),N.removeAllRanges(),N.addRange(te),W()},[W]),Ye=(0,D.useCallback)(g=>A(g),[A]),je=(0,D.useCallback)(()=>ce(!0),[ce]),m=(0,D.useCallback)(()=>ce(!1),[ce]),$e=(0,D.useCallback)(()=>E.current?.focus(),[]),De=(0,D.useCallback)(()=>E.current?.blur(),[]),Ze=(0,D.useCallback)(()=>{let g=E.current;return g?(0,Q.extractPlainText)(g):""},[]),Xe=gi()?"plaintext-only":"true";return{inputRef:E,editorProps:{ref:E,contentEditable:Xe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":y,"aria-activedescendant":C,spellCheck:!0,enterKeyHint:"send",onInput:p,onKeyDown:Ye,onCompositionStart:P,onCompositionEnd:Qe,onPaste:Ke,onFocus:je,onBlur:m},getPlainText:Ze,focus:$e,blur:De}}var Le=require("react/jsx-runtime");function fi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var At=(0,j.forwardRef)(function({onSubmit:i,onResult:t,onError:n,optionOverrides:o,maskCompletedText:s,className:r,apiConfig:l,additionalContext:b,language:v,currency:x,productId:f,visitorId:h,columns:u,pillPlacement:y="dropdown",mode:k="auto",optionsPosition:C="below",animations:F=!0,optionsStyle:M="floating",dropdownTrigger:he,closeDropdownOnBlur:A,prependPlaceholder:H,allOption:oe,showNonTappableOptions:G,locationSearch:de,showOptionIcons:ce=!0,showChipIcons:E=!0,showChipImages:ne=!0,showChipRemove:ue=!1,showOptionImages:_=!0,showOptionCounts:pe=!0,showSkipButton:T,showProducts:W,submitProgress:p,productsLayout:P,productImageFallback:Qe,showProductVendor:Ke,autoFocus:Ye=!0,onFocus:je,onBlur:m,value:$e,completedParams:De,onChange:Ze,onParamsChange:Xe,products:g,mapProducts:S,onProductSelect:I,onProductAddToCart:R,submitButton:N,resetOnSubmit:te=!0,seeAllResults:Se=!1},Ae){let qe=(0,j.useRef)(null),_e=(0,j.useRef)(null),Je=(0,j.useRef)(null),ea=(0,j.useRef)(()=>{}),Me=(0,j.useRef)(null),me=(0,j.useRef)(null);(0,j.useEffect)(()=>{let B=qe.current;if(B)return Me.current?Me.current.setMode(k):Me.current=new Ge.ModeController(B,k),()=>{Me.current?.destroy(),Me.current=null}},[k]);let aa=(0,j.useCallback)(B=>{let ve=me.current?.current;ve&&(ve.focus(),(0,Ge.setCursorOffset)(ve,B))},[]),{completedParams:wa,suggestionPills:Ne,setActivePill:ua,skipActivePill:ta,segments:w,newParamId:be,clearNewParamId:ia,placeholderText:oa,isFocused:a,isDropdownOpen:ie,isActivePillSelected:na,isLoading:we,isReady:va,activeIndex:Fe,listboxId:Ee,handleTextChange:ma,handleCompositionText:ra,handleKeyDown:He,setFocused:da,editingParam:ca,editingIdentified:ga,editingAnchor:Ve,caretOffset:pa,startEditingParam:d,removeParam:Y,handleCaretAfterInput:K,handleCaretMove:fa,replaceEditingRange:Pa,dropdownProps:O,reset:Ia,refreshProducts:Qa,prepareSubmit:Ya,getState:Fa,recordSubmit:ja,holdSubmit:$a,endSubmitProgress:Za,isSubmitting:Ha}=Ma({onSubmit:B=>ea.current(B),onResult:t,onError:n,optionOverrides:o,maskCompletedText:s,apiConfig:l,additionalContext:b,language:v,currency:x,productId:f,visitorId:h,columns:u,dropdownTrigger:he,optionsPosition:C,closeDropdownOnBlur:A,prependPlaceholder:H,allOption:oe,showNonTappableOptions:G,locationSearch:de,showOptionIcons:ce,showOptionImages:_,showOptionCounts:pe,showSkipButton:T,showProducts:W,submitProgress:p,onFocus:je,onBlur:m,value:$e,completedParams:De,onChange:Ze,onParamsChange:Xe,products:g,mapProducts:S,onProductSelect:I,onProductAddToCart:R,source:"full-sdk",setCursor:aa});(0,j.useEffect)(()=>{if(!be)return;let B=window.setTimeout(()=>ia(),650);return()=>window.clearTimeout(B)},[be,ia]);let Et=Fe>=0?`${Ee}-option-${Fe}`:void 0,{inputRef:Ba,editorProps:zt,focus:Aa,blur:Xa,getPlainText:Ja}=It({segments:w,newParamId:be,editingParam:ca,editingIdentified:ga,editingAnchor:Ve,caretOffset:pa,placeholderText:oa,hintSuggestions:y==="inline"?[]:Ne,isFocused:a,showChipIcons:E,showChipImages:ne,showChipRemove:ue,removeParam:Y,isDropdownOpen:ie,listboxId:Ee,activeDescendantId:Et,autoFocus:Ye,handleTextChange:ma,handleCompositionText:ra,handleKeyDown:He,handleCaretAfterInput:K,handleCaretMove:fa,startEditingParam:d,replaceEditingRange:Pa,setFocused:da});me.current=Ba,(0,j.useLayoutEffect)(()=>{let B=_e.current,ve=Ba.current;if(!B||!ve)return;let ya=()=>{let et=B.firstElementChild;if(!et)return;let Nt=et.getBoundingClientRect(),Ft=ve.getBoundingClientRect();Nt.top>=Ft.bottom-2?B.setAttribute("data-aia-pill-wrapped",""):B.removeAttribute("data-aia-pill-wrapped")};ya();let ka=new ResizeObserver(ya);return ka.observe(ve),()=>ka.disconnect()},[w,Ne.length,we,Ba]),(0,j.useEffect)(()=>{let B=Je.current;if(B)return(0,Ge.watchEditorHeight)(B)},[]),(0,j.useImperativeHandle)(Ae,()=>({focus:Aa,blur:Xa,reset:Ia,refreshProducts:Qa,setMode:B=>Me.current?.setMode(B),skipActivePill:ta,endSubmitProgress:Za}),[Aa,Xa,Ia,Qa,ta,Za]);let ba=!!w.length||wa.length>0,xa=(0,j.useCallback)(B=>{if(!ba||B&&Fa().isSubmitting)return;B&&Ya();let ve=Fa(),ya=(0,Ge.buildSubmitResult)(Ja(),ve.completedParams,ve.skippedParams,{identifiedParams:ve.identifiedParams,isReady:ve.isReady,customFields:ve.customFields});B&&ja(ya);let ka=i(ya);return B&&!te&&$a(ka),te&&Ia(),ka},[ja,$a,te,ba,Ya,Fa,i,Ia,Ja]);ea.current=()=>xa(!1);let Rt=Se&&!O.isInputEmpty&&ba,Ot=(0,j.useCallback)(()=>xa(!0),[xa]),Lt=(0,j.useCallback)(B=>{B.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||Aa()},[Aa]),Dt=y==="inline",Mt=y==="dropdown";return(0,Le.jsxs)("div",{ref:qe,className:`magicx-aia ${ha.container} ${r??""}`,"data-pill-placement":y,"data-options-position":C,"data-animations":F?"on":"off","data-aia-options-style":M,"data-mode":fi(k),children:[(0,Le.jsx)(La,{...O,showPills:Mt,productsLayout:P,productImageFallback:Qe,showProductVendor:Ke,onSeeAllResults:Rt?Ot:void 0,fullWidth:Se}),(0,Le.jsxs)("div",{className:ha.inputWrapper,"data-aia-input-wrapper":"",onClick:Lt,children:[(0,Le.jsxs)("div",{ref:Je,className:ha.editorArea,"data-aia-editor":"",children:[(0,Le.jsx)("div",{...zt,className:ha.input,"data-aia-input":""}),Dt&&(we||Ne.length>0)&&(0,Le.jsx)("span",{ref:_e,className:ha.pillListContainer,"data-aia-pill-list-container":"",children:(0,Le.jsx)(Ra,{pills:Ne,activePillIndex:0,activeSelected:na,onSelectPill:ua,loading:we})})]}),N===null?null:N===void 0?(0,Le.jsx)(St,{disabled:!ba,ready:ba&&va,busy:Ha,onClick:()=>xa(!0),label:(0,Ge.uiStringsFor)(v).submit}):(0,Le.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"","data-aia-submit-state":Ha?"busy":void 0,"aria-busy":Ha?!0:void 0,className:ha.submitSlot,onClick:B=>{ba&&(B.stopPropagation(),xa(!0))},children:N})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
3787
3911
|
//# sourceMappingURL=index.js.map
|