@magicx-eng/ai-autocomplete-react 0.32.5 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as hn,cellDay as un,cellIso as mn,DATE_RANGE_META_END as gn,DATE_RANGE_META_START as fn,DEFAULT_OPTION_COUNT_UNIT as bn,dateCellMarks as vn,formatDate as wn,formatDateRange as xn,formatOptionCount as yn,isoDate as kn,monthLabel as Cn,optionCountLabel as Pn,optionHasImage as Sn,optionImageSources as In,optionImageSrc as En,optionLabel as Tn,PRODUCT_PATH_PREFIX as An,parseDate as Rn,parseLooseDate as On,parseLooseDateRange as Dn,productFromMatchedItem as Ln,productImageSources as zn,productsFromCustomFields as Mn,sanitizeOptionIconSvg as Nn,selectedRangeFor as Bn,visibleDateRange as Hn,WEEKDAY_LABELS as Fn,withSkippedParams as Kn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ui,useCallback as lt,useEffect as Wt,useImperativeHandle as mi,useLayoutEffect as gi,useRef as Ne}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -262,7 +262,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var
|
|
265
|
+
`,document.head.appendChild(e)}var Ce={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};import{attachScrollArrow as Ya,containScroll as Za,isCalendarFormat as $a,SCROLL_ARROW_LABEL as Va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as je,useRef as Ue,useState as Xa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
266
266
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
267
267
|
* Consumer CSS always wins without !important.
|
|
268
268
|
*
|
|
@@ -1045,7 +1045,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1045
1045
|
opacity: 0.25;
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
`,document.head.appendChild(e)}var se={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as
|
|
1048
|
+
`,document.head.appendChild(e)}var se={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as ea,cellIso as Ee,dateCellMarks as ta,isoDate as aa,monthLabel as ia,visibleDateRange as oa,WEEKDAY_LABELS as na}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ra}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
1049
1049
|
|
|
1050
1050
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1051
1051
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1208,7 +1208,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1208
1208
|
opacity: 0.8;
|
|
1209
1209
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1210
1210
|
}
|
|
1211
|
-
`,document.head.appendChild(e)}var A={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as J,jsxs as
|
|
1211
|
+
`,document.head.appendChild(e)}var A={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as J,jsxs as gt}from"react/jsx-runtime";var sa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ft({options:e,activeIndex:o,listboxId:t,view:n,selection:r,onSelect:i,onHighlight:a,onUnhighlight:s,onPreviousMonth:v,onNextMonth:y}){let w=aa(new Date),P=oa({pendingStart:r.rangeStart,highlightedIso:Ee(e[o]),selected:r.selectedRange});return gt("div",{className:A.datepicker,"data-aia-datepicker":"",children:[gt("div",{className:A.header,children:[J("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u2039"}),J("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:ia(n)}),J("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:y,children:"\u203A"})]}),J("div",{className:A.weekdays,"aria-hidden":"true",children:na.map((u,f)=>J("span",{className:A.weekday,children:u},sa[f]))}),J("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((u,f)=>J(la,{option:u,id:`${t}-option-${f}`,index:f,isHighlighted:f===o&&u.is_tappable,isToday:Ee(u)===w,isPast:Ee(u)!=null&&Ee(u)<w,marks:ta(Ee(u),{selectedIso:r.selectedIso,range:P}),onSelect:i,onHighlight:a,onUnhighlight:s},Ee(u)??`pad-${f}`))})]})}function la({option:e,id:o,index:t,isHighlighted:n,isToday:r,isPast:i,marks:a,onSelect:s,onHighlight:v,onUnhighlight:y}){let[w,P]=ra(!1),u=ea(e);if(u==null)return J("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${A.cell} ${A.blank}`});let f=()=>{P(!0),s(e),setTimeout(()=>P(!1),170)},I=[A.cell,A.day,i?A.past:"",n?A.highlighted:"",r?A.today:"",a.inRange?A.inRange:"",a.selected?A.selected:"",w?A.pressed:""].filter(Boolean).join(" ");return J("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:I,onClick:f,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),f())},onMouseEnter:()=>v(t),onMouseLeave:y?()=>y(t):void 0,children:J("span",{className:A.number,children:u})})}import{ATTRIBUTION_URL as da,buildAttributionUrl as ca,getFooterHint as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ha,useState as ua}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1212
1212
|
display: flex;
|
|
1213
1213
|
flex-wrap: wrap;
|
|
1214
1214
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1248,7 +1248,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1248
1248
|
.aia-cluster[data-justify="around"] {
|
|
1249
1249
|
justify-content: space-around;
|
|
1250
1250
|
}
|
|
1251
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1251
|
+
`,document.head.appendChild(e)}import{jsx as bt}from"react/jsx-runtime";function Le({gap:e,align:o="center",justify:t="start",noWrap:n=!1,inline:r=!1,className:i,children:a,...s}){let v=e?{"--aia-cluster-gap":e}:void 0,y={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":n||void 0,"data-inline":r||void 0,style:v,...s};return r?bt("span",{...y,children:a}):bt("div",{...y,children:a})}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
|
|
1252
1252
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1253
1253
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1254
1254
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1395,7 +1395,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1395
1395
|
justify-content: flex-end;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
`,document.head.appendChild(e)}var le={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as
|
|
1398
|
+
`,document.head.appendChild(e)}var le={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};import{jsx as ze,jsxs as Je}from"react/jsx-runtime";function vt({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:t,hint:n}=pa(e,o),[r,i]=ua(da);return ha(()=>{i(ca())},[]),ze("footer",{className:le.footer,"data-aia-footer":"",children:Je(Le,{justify:"between",noWrap:!0,className:le.row,children:[Je(Le,{gap:"5px",className:le.hintGroup,children:[ze("kbd",{className:le.key,children:t}),ze("span",{className:le.hint,children:n})]}),Je("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[ze("span",{className:le.brand,children:"AI"}),ze("span",{className:le.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
1399
1399
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1400
1400
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1401
1401
|
as it was when the outline was dashed. */
|
|
@@ -1471,7 +1471,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1471
1471
|
opacity: 0;
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
`,document.head.appendChild(e)}var
|
|
1474
|
+
`,document.head.appendChild(e)}var we={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{jsx as ma}from"react/jsx-runtime";var et={selected:1,first:.7,next:.4,last:.2};function wt({label:e,state:o,rounded:t,loading:n,onClick:r}){let i=[we.pill,t?we.rounded:"",n?we.skeleton:""].filter(Boolean).join(" ");return ma("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:et[o]},onMouseDown:a=>a.preventDefault(),onClick:n?void 0:r,disabled:n,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1475
1475
|
position: relative;
|
|
1476
1476
|
z-index: 1;
|
|
1477
1477
|
pointer-events: auto;
|
|
@@ -1481,7 +1481,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1481
1481
|
align-items: center;
|
|
1482
1482
|
vertical-align: middle;
|
|
1483
1483
|
}
|
|
1484
|
-
`,document.head.appendChild(e)}var
|
|
1484
|
+
`,document.head.appendChild(e)}var tt={list:"aia-list-qvLqO"};import{jsx as We}from"react/jsx-runtime";var ga=[125,69];function xt(e){return e===0?"first":e===1?"next":"last"}function _e({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:n,rounded:r,loading:i}){return i&&e.length===0?We("span",{className:tt.list,"data-aia-pill-list-loading":"",children:ga.map((a,s)=>We("span",{"data-aia-pill-skeleton":"",className:`${we.pill} ${r?we.rounded:""} ${we.skeleton}`,style:{width:a,opacity:et[xt(s)]}},`skel-${a}`))}):We("span",{className:tt.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((a,s)=>{let v=!!n&&s===o;return We(wt,{label:a.text,state:v?"selected":xt(s),selected:v,rounded:r,loading:i,onClick:()=>t(s)},`${a.parameter}-${a.text}`)})})}import{attachProductRowWheel as fa,productImageSources as ba,productImageSrc as va,productInitial as wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as xa,useRef as ya,useState as ka}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
|
|
1485
1485
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1486
1486
|
theming one package sees the same result in the other.
|
|
1487
1487
|
|
|
@@ -1765,7 +1765,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1765
1765
|
letter-spacing: 0.02em;
|
|
1766
1766
|
text-align: center;
|
|
1767
1767
|
}
|
|
1768
|
-
`,document.head.appendChild(e)}var
|
|
1768
|
+
`,document.head.appendChild(e)}var U={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd"};import{jsx as de,jsxs as qe}from"react/jsx-runtime";function yt({products:e,listboxId:o,onSelect:t,onFocusChange:n,focusable:r=!0,layout:i="row",imageFallback:a="image"}){let s=e.length>0,v=ya(null);if(xa(()=>{let w=v.current;if(!(!s||!w))return fa(w)},[s]),!s)return null;let y=`${o}-products-label`;return qe("section",{className:U.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":y,children:[de("div",{className:U.label,id:y,"data-aia-products-label":"",children:"Products"}),de("div",{ref:v,className:U.row,"data-aia-products-row":"",children:e.map((w,P)=>de(Ca,{product:w,id:`${o}-product-${P}`,onSelect:t,onFocusChange:n,focusable:r,imageFallback:a},w.id))})]})}function Ca({product:e,id:o,onSelect:t,onFocusChange:n,focusable:r,imageFallback:i}){let a=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),t(e))};return qe("a",{id:o,className:U.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:a,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[de(Pa,{sources:ba(e.imageUrl),title:e.title,fallback:i},va(e.imageUrl)??""),qe("span",{className:U.body,children:[e.vendor?de("span",{className:U.vendor,children:e.vendor}):null,de("span",{className:U.title,children:e.title}),e.price?de("span",{className:U.price,children:e.price}):null,e.available===!1?de("span",{className:U.badge,children:"Sold out"}):null]})]})}function Pa({sources:e,title:o,fallback:t}){let[n,r]=ka(0),i=e[n],a=!!i,s=!a&&t==="initial";return qe("span",{className:U.media,"aria-hidden":"true","data-aia-product-placeholder":!a&&!s?"":void 0,"data-aia-product-initial":s?"":void 0,children:[a?de("img",{className:U.image,src:i,alt:"",loading:"lazy",decoding:"async",onError:()=>r(v=>v+1)}):null,s?wa(o):null]})}import{isOptionsGridMobileViewport as Ha,measureOptionsGrid as Fa,needsOptionsGridMeasurement as Ka,OPTIONS_GRID_MOBILE_QUERY as Ga,optionEnterDelayMs as Wa,planOptionsGrid as Pt,sameOptionRows as _a}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as qa,useLayoutEffect as Ua,useRef as St,useState as Et}from"react";import{optionsGridTemplateColumns as Sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ia,useRef as Ea}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1769
1769
|
display: grid;
|
|
1770
1770
|
grid-template-columns: repeat(
|
|
1771
1771
|
auto-fit,
|
|
@@ -1801,7 +1801,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
1801
1801
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1802
1802
|
display: none;
|
|
1803
1803
|
}
|
|
1804
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1804
|
+
`,document.head.appendChild(e)}import{jsx as Ta}from"react/jsx-runtime";function kt({min:e="16rem",max:o,gap:t,scroll:n=!1,maxHeight:r,scrollResetKey:i,cols:a,template:s,innerRef:v,className:y,children:w,...P}){let u=Ea(null);Ia(()=>{if(i===void 0)return;let I=u.current;I&&(I.scrollTop=0)},[i]);let f={"--aia-grid-min":e};return o&&(f["--aia-grid-max"]=o),t&&(f["--aia-grid-gap"]=t),r&&(f["--aia-grid-max-height"]=r),a&&(f.gridTemplateColumns=Sa(a)),s&&(f.gridTemplateColumns=s),Ta("div",{ref:I=>{u.current=I,v?.(I)},className:y?`aia-grid ${y}`:"aia-grid","data-scroll":n||void 0,style:f,...P,children:w})}import{formatOptionCount as Aa,OPTION_ENTER_DELAY_VAR as Ra,optionImageSources as Oa,optionLabel as Da,sanitizeOptionIconSvg as La}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as za,useMemo as Ma,useRef as Na,useState as at}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
1805
1805
|
position: relative;
|
|
1806
1806
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1807
1807
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2198,7 +2198,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
2198
2198
|
opacity: 0;
|
|
2199
2199
|
}
|
|
2200
2200
|
}
|
|
2201
|
-
`,document.head.appendChild(e)}var
|
|
2201
|
+
`,document.head.appendChild(e)}var W={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{jsx as Pe,jsxs as Ba}from"react/jsx-runtime";function Ct({option:e,isHighlighted:o,onSelect:t,onHighlight:n,onUnhighlight:r,id:i,loading:a,showIcon:s=!0,showImage:v=!0,showCount:y=!0,scrollHint:w,enterDelayMs:P=0}){let[u]=at(P),[f,I]=at(!1),D=v?Oa(e.image_url):[],L=D[0]??null,[H,E]=at([]),S=D.find(N=>!H.includes(N))??null,z=Ma(()=>!L&&s&&e.icon_svg?La(e.icon_svg):null,[L,s,e.icon_svg]),R=y?Aa(e.item_count):null,k=Na(void 0);za(()=>()=>clearTimeout(k.current),[]);let M=()=>{a||!e.is_tappable||f||(I(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>I(!1),170))},Q=[W.item,o&&!a?W.highlighted:"",e.is_tappable?W.tappable:W.nonTappable,f?W.pressed:"",w?W.scrollHint:""].filter(Boolean).join(" ");return Pe("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":z&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":R!==null?e.item_count:void 0,"aria-selected":o,className:Q,style:{[Ra]:`${u}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:M,onKeyDown:N=>{!a&&e.is_tappable&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),M())},onMouseEnter:!a&&e.is_tappable?n:void 0,onMouseLeave:r,children:Ba("span",{className:W.content,children:[L&&Pe("span",{className:`${W.image} magicx-aia-option-image`,"aria-hidden":"true",children:Pe("img",{src:S??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onError:()=>{S!==null&&E(N=>[...N,S])}})}),z&&Pe("span",{className:`${W.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:z}}),Pe("span",{className:W.text,children:Da(e)}),e.tag&&Pe("span",{className:W.tag,children:e.tag}),R!==null&&Pe("span",{className:`${W.count} magicx-aia-option-count`,children:R})]})})}import{jsx as It}from"react/jsx-runtime";function ja(){let[e,o]=Et(Ha);return qa(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ga),n=()=>o(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Tt({options:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:i,loading:a,groupKey:s="",optionsPosition:v="below",showIcons:y=!0,showImages:w=!0,showCounts:P=!0}){let u=ja(),f=St(null),[I,D]=Et(null),L=St(null);Ua(()=>{if(a&&_a(L.current,e))return;L.current=a?null:e;let E=f.current,z=E&&!a&&Ka(e.length,u)?Fa(E):null;D(z?Pt(e.length,u,z.rowWidths,z.gridWidth):null)},[e,u,a]);let H=I??Pt(e.length,u,null,null);return It(kt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:H.template,maxHeight:H.maxHeight,innerRef:E=>{f.current=E},"data-aia-group":s,children:e.map((E,S)=>It(Ct,{option:E,isHighlighted:S===o,onSelect:t,onHighlight:()=>n(S),onUnhighlight:r?()=>r(S):void 0,id:`${i}-option-${S}`,loading:a,showIcon:y,showImage:w,showCount:P,scrollHint:!a&&H.scrollHintIndices.includes(S),enterDelayMs:a?0:Wa(S,H.cols,e.length,v)},`${s}\0${E.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2202
2202
|
display: flex;
|
|
2203
2203
|
flex-direction: column;
|
|
2204
2204
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2213,7 +2213,7 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
2213
2213
|
align-items: end;
|
|
2214
2214
|
}
|
|
2215
2215
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2216
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2216
|
+
`,document.head.appendChild(e)}import{jsx as Qa}from"react/jsx-runtime";function At({space:e,align:o="stretch",className:t,children:n,...r}){let i=e?{"--aia-stack-space":e}:void 0;return Qa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...r,children:n})}import{jsx as j,jsxs as it}from"react/jsx-runtime";var Ja=[159,119,164],ei=()=>{},Rt=()=>{};function ti(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=Xa(o);if(je(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>n(r.matches);return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ai(e,o){let t=Ue(null);je(()=>{let n=e.current,r=o.current;if(!n||!r)return;let i=n.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==i&&(t.current.controller.destroy(),t.current=null),i&&!t.current){t.current={grid:i,controller:Ya({dropdown:n,grid:i,button:r})};return}t.current?.controller.update()}),je(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ot({suggestions:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,isOpen:i,id:a,className:s,pills:v,onPillClick:y,showPills:w=!0,onSkip:P,showSkipButton:u=!0,showOptionIcons:f=!0,showOptionImages:I=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:H=!1,isLoading:E=!1,skeletonExiting:S=!1,isInputEmpty:z=!1,products:R,onProductSelect:k,onProductFocusChange:M,productsLayout:Q="row",productImageFallback:N="image",formatType:ce="options",dateView:ee=null,selectedDateIso:_=null,selectedDateRange:pe=null,dateRangeStart:m=null,onPreviousMonth:xe,onNextMonth:he,optionsPosition:te="below",mode:ue}){let ae=ti(ue),me=ae!==void 0,G=Ue(null),Z=Ue(null);ai(G,Z),je(()=>{if(G.current)return Za(G.current)},[]);let ge=e[0]?.options??[],d=!!(v&&v.length>0&&y),h=!!(R&&R.length>0),g=i&&(ge.length>0||w&&d||E||h),b={suggestions:e,activeIndex:o,pills:v,showPills:w,showSkipButton:u,showOptionIcons:f,showOptionImages:I,showOptionCounts:D,skipDisabled:L,activeSelected:H,isLoading:E,skeletonExiting:S,isInputEmpty:z,products:R,formatType:ce,dateView:ee,selectedDateIso:_,selectedDateRange:pe,dateRangeStart:m},C=Ue(b);g&&(C.current=b);let l=g?b:C.current,F=l.suggestions[0],B=F?.options??[],ie=l.activeIndex>=0&&!!B[l.activeIndex]?.is_tappable,$=!!(l.pills&&l.pills.length>0&&y),x=l.showPills&&$,ye=l.showPills&&!$&&l.isLoading,Se=x||ye,oe=$&&l.showSkipButton&&!l.isInputEmpty&&!!P,c=l.pills?.[0]?.text,ne=$a(l.formatType)&&l.dateView!=null,ke=B.length>0&&!ne,fe=B.length>0&&ne&&!l.isLoading,Re=l.isLoading&&!ke&&!fe,re=l.products??[];return it("div",{ref:G,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":te,"data-mode":ae,"data-aia-loading":l.isLoading?"":void 0,"data-aia-skeleton-exiting":l.skeletonExiting?"":void 0,"data-aia-has-products":re.length>0?"":void 0,className:`${me?"magicx-aia ":""}${se.dropdown} ${g?se.visible:""} ${s??""}`,onMouseDown:be=>be.preventDefault(),children:[it(At,{space:"8px",children:[(Se||oe)&&it(Le,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[Se&&j("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:j(_e,{pills:l.pills??[],activePillIndex:0,activeSelected:l.activeSelected,onSelectPill:y??(()=>{}),rounded:!0,loading:l.isLoading})}),oe&&j("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:l.isLoading||l.skipDisabled,"aria-label":c?`Skip ${c}`:"Skip",onClick:P,children:"skip"})]}),ke&&j(Tt,{options:B,activeIndex:l.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:a,loading:l.isLoading,groupKey:F?`${F.parameter} ${F.text}`:"",optionsPosition:te,showIcons:l.showOptionIcons,showImages:l.showOptionImages,showCounts:l.showOptionCounts}),fe&&l.dateView&&j(ft,{options:B,activeIndex:l.activeIndex,listboxId:a,view:l.dateView,selection:{selectedIso:l.selectedDateIso??null,selectedRange:l.selectedDateRange??null,rangeStart:l.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:r,onPreviousMonth:xe??Rt,onNextMonth:he??Rt}),Re&&j("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Ja.map(be=>j("span",{className:se.skeletonBar,style:{width:be}},`bar-${be}`))}),j(yt,{products:re,listboxId:a,onSelect:k??ei,onFocusChange:M,focusable:g,layout:Q,imageFallback:N}),j(vt,{isOptionHighlighted:ie,isInputEmpty:l.isInputEmpty})]}),j("button",{ref:Z,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Va,"aria-hidden":"true",children:j("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:j("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as fi,ModeController as bi,setCursorOffset as vi}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
|
|
2217
2217
|
flex-shrink: 0;
|
|
2218
2218
|
width: 32px;
|
|
2219
2219
|
height: 32px;
|
|
@@ -2266,5 +2266,5 @@ import{buildSubmitResult as pn,cellDay as hn,cellIso as un,DATE_RANGE_META_END a
|
|
|
2266
2266
|
);
|
|
2267
2267
|
cursor: default;
|
|
2268
2268
|
}
|
|
2269
|
-
`,document.head.appendChild(e)}var Rt={submitButton:"aia-submitButton-otz7H"};import{jsx as ot}from"react/jsx-runtime";function Ot({disabled:e,onClick:o}){return ot("button",{type:"button","data-aia-submit":"",className:Rt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:ot("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:ot("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ai,dateSelectionFor as ii,identifiedParamLabel as oi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Nt,useEffect as ze,useRef as K,useState as ni}from"react";import{useRef as Dt}from"react";function Lt(e){let o=Dt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=Dt({key:"",overrides:void 0});if(n.current.key!==t){let r={};for(let i of Object.keys(e??{})){let a=(s,v,w)=>{let x=o.current?.[i];return x?x(s,v,w):[]};r[i]=a}n.current={key:t,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:t}}import{useRef as zt}from"react";function Mt(e){let o=zt(e);o.current=e;let t=zt(null);t.current===null&&(t.current={fetch:(r,i)=>{let a=o.current;return a?a.fetch(r,i):Promise.reject(new Error("products config removed"))},transform:r=>o.current?.transform(r)??[],get limit(){return o.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var ri={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function nt({onSubmit:e,onResult:o,onError:t,optionOverrides:n,maskCompletedText:r,apiConfig:i,additionalContext:a,visitorId:s,columns:v=2,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:P,showNonTappableOptions:u,showOptionIcons:y,showOptionImages:E,showOptionCounts:D,showSkipButton:L,showProducts:z,productImageFallback:R="image",onFocus:S,onBlur:M,value:I,completedParams:k,onChange:G,onParamsChange:Y,products:N,onProductSelect:ee,source:ce,setCursor:W}){let g=K(null),[ve,pe]=ni(null),he=K(e);he.current=e;let te=K(o);te.current=o;let ue=K(t);ue.current=t;let ae=K(G);ae.current=G;let $=K(Y);$.current=Y;let q=K(S);q.current=S;let ie=K(M);ie.current=M;let oe=K(W);oe.current=W;let d=K(ee);d.current=ee;let m=K(s);m.current=s;let h=K(()=>{let p=m.current;return typeof p=="function"?p():p}).current,f=Mt(N),C=Lt(n);ze(()=>{if(typeof document>"u")return;let p=new ai(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:a,visitorId:h,optionOverrides:C.overrides,maskCompletedText:r,columns:v,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:P,showNonTappableOptions:u,showProducts:z,source:ce,value:I,completedParams:k,onSubmit:(...O)=>he.current?.(...O),onResult:(...O)=>te.current?.(...O),onError:(...O)=>ue.current?.(...O),onChange:(...O)=>ae.current?.(...O),onParamsChange:(...O)=>$.current?.(...O),onFocus:()=>q.current?.(),onBlur:()=>ie.current?.(),onProductSelect:O=>d.current?.(O),setCursor:O=>oe.current?.(O),products:f.config});g.current=p,pe(p.getState());let U=p.subscribe(O=>pe(O));return()=>{U(),p.destroy(),g.current===p&&(g.current=null)}},[]),ze(()=>{I!==void 0&&g.current?.setValue(I)},[I]),ze(()=>{k!==void 0&&g.current?.setCompletedParams(k)},[k]);let l=JSON.stringify(i??null),B;try{B=JSON.stringify(a??null)}catch{B="[unstringifiable]"}ze(()=>{g.current?.update({apiConfig:i,additionalContext:a,optionOverrides:C.overrides,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:P,showNonTappableOptions:u,showProducts:z})},[l,B,C.key,w,x,P,u,z]);let H=K(!1);ze(()=>{if(!H.current){H.current=!0;return}g.current?.update({products:f.config})},[f.enabled]);let V=K(null);V.current===null&&(V.current={handleTextChange:p=>g.current?.handleTextChange(p),handleKeyDown:p=>{let U="nativeEvent"in p?p.nativeEvent:p;g.current?.handleKeyDown(U)},setFocused:p=>g.current?.setFocused(p),startEditingParam:p=>g.current?.startEditingParam(p),exitEditMode:()=>g.current?.exitEditMode(),handleCaretAfterInput:p=>g.current?.handleCaretAfterInput(p),handleCaretMove:p=>g.current?.handleCaretMove(p),replaceEditingRange:p=>g.current?.replaceEditingRange(p)??!1,setActivePill:p=>g.current?.setActivePill(p),skipActivePill:()=>g.current?.skipActivePill(),removeLastParam:()=>g.current?.removeLastParam(),clearNewParamId:()=>g.current?.clearNewParamId(),reset:()=>g.current?.reset(),recordSubmit:p=>g.current?.recordSubmit(p),selectOption:p=>g.current?.selectOption(p),selectProduct:p=>g.current?.selectProduct(p),setActiveDropdownIndex:p=>g.current?.setActiveDropdownIndex(p),clearHighlight:p=>g.current?.clearHighlight(p),showPreviousMonth:()=>g.current?.showPreviousMonth(),showNextMonth:()=>g.current?.showNextMonth(),handleFocus:()=>g.current?.setFocused(!0),handleBlur:()=>g.current?.setFocused(!1)});let b=V.current,we=Nt(p=>{let U=p.target.value,Ze=U.length>0&&!p.nativeEvent?.isComposing&&U[0]!==U[0].toUpperCase()?U[0].toUpperCase()+U.slice(1):U;g.current?.handleTextChange(Ze)},[]),Ae=Nt(p=>{g.current?.handleKeyDown(p.nativeEvent)},[]),ne=g.current,c=ve??ri,re=I!==void 0?I:c.text,xe=k!==void 0?k:c.completedParams,me=c.actionableSuggestions,Ce=me[0],ge=ne?.listboxId??"",Pe=c.activeDropdownIndex>=0&&ne?`${ge}-option-${c.activeDropdownIndex}`:void 0,F=c.editingParam,fe=c.editingIdentified,Se=F?{parameter:F.suggestionParameter,text:F.suggestionPlaceholder,required:!0,options:F.options}:fe?{parameter:fe.parameter,text:oi(fe.parameter),required:!0,options:[]}:null,Ne=c.dropdownSuggestion??Se??Ce,Ye=Se?[Se]:me,Re=ii(c),Be=!ne||c.dropdownLoading;return{completedParams:xe,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:me,setActivePill:b.setActivePill,skipActivePill:b.skipActivePill,removeLastParam:b.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:b.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Be,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:ge,error:c.error,products:c.products,customFields:c.customFields,selectProduct:b.selectProduct,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:F,editingIdentified:fe,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:b.startEditingParam,exitEditMode:b.exitEditMode,handleCaretAfterInput:b.handleCaretAfterInput,handleCaretMove:b.handleCaretMove,replaceEditingRange:b.replaceEditingRange,inputProps:{value:re,placeholder:c.placeholderText||void 0,onChange:we,onKeyDown:Ae,onFocus:b.handleFocus,onBlur:b.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":Pe,"aria-autocomplete":"list","aria-controls":ge},reset:b.reset,recordSubmit:b.recordSubmit,dropdownProps:{suggestions:Ne?[{...Ne,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:b.selectOption,onHighlight:b.setActiveDropdownIndex,onUnhighlight:b.clearHighlight,isOpen:c.isDropdownOpen,id:ge,pills:Ye,activeSelected:c.isActivePillSelected,onPillClick:b.setActivePill,onSkip:b.skipActivePill,showSkipButton:(L??!0)&&!F&&!fe,showOptionIcons:y??!0,showOptionImages:E??!0,showOptionCounts:D??!0,skipDisabled:c.inSelectionAnimation,isLoading:Be,skeletonExiting:c.skeletonExiting,isInputEmpty:re.trim().length===0,products:c.products,productImageFallback:R,onProductSelect:b.selectProduct,onProductFocusChange:b.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Re.selectedIso,selectedDateRange:Re.selectedRange,dateRangeStart:Re.rangeStart,onPreviousMonth:b.showPreviousMonth,onNextMonth:b.showNextMonth,optionsPosition:x??"below"}}}import{chipIdFromTap as si,extractPlainText as Bt,getCursorOffset as Ht,keepCaretOnChip as li,plainTextLength as di,renderEditableContent as ci,setCursorOffset as Ft}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Z,useEffect as je,useLayoutEffect as rt,useRef as Ee}from"react";var Qe;function pi(){if(Qe!==void 0)return Qe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Qe=e.contentEditable==="plaintext-only",Qe}function Kt(e){let{segments:o,showChipIcons:t=!0,showChipImages:n=!0,newParamId:r,editingParam:i,editingIdentified:a,editingAnchor:s,caretOffset:v,placeholderText:w,isFocused:x,isDropdownOpen:P,listboxId:u,activeDescendantId:y,autoFocus:E,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:z,handleCaretMove:R,startEditingParam:S,replaceEditingRange:M,setFocused:I}=e,k=Ee(null),G=Ee(!1),Y=Ee(""),N=Ee(""),ee=Ee(null),ce=Ee(0);ee.current=v,je(()=>{if(!E)return;let d=k.current;if(!d)return;document.activeElement===d?I(!0):d.focus();let m=d.ownerDocument??document,h=m.getSelection(),f=h&&h.rangeCount>0&&d.contains(h.anchorNode);if(h&&!f){let C=m.createRange();C.selectNodeContents(d),C.collapse(!0),h.removeAllRanges(),h.addRange(C)}},[E,I]),je(()=>{let d=k.current;if(!d)return;let m=d.ownerDocument??document,h=()=>{let f=m.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!d.contains(f.anchorNode))return;let C=f.anchorNode,l=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,H=(f.isCollapsed?l?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,V=i?.id??a?.id??null;if(H&&H!==V){S(H);return}performance.now()-ce.current<50||R(Ht(d))};return m.addEventListener("selectionchange",h),()=>m.removeEventListener("selectionchange",h)},[i,a,S,R]),je(()=>{let d=k.current;if(!d)return;let m=h=>{let f=si(d,h.target);f&&(S(f),li(d,f))};return d.addEventListener("click",m),()=>d.removeEventListener("click",m)},[S]),rt(()=>{let d=k.current;d&&ci({input:d,segments:o,newParamId:r,editingParamId:i?.id??null,placeholderText:w??"",isFocused:x,showChipIcons:t,showChipImages:n})},[o,r,i,w,x,t,n]),rt(()=>{let d=Y.current,m=r??"";if(Y.current=m,!m||m===d)return;let h=k.current;if(!h)return;h.focus();let f=ee.current??di(h);Ft(h,f)},[r]),rt(()=>{let d=N.current,m=i?.id??"";if(N.current=m,!m||m===d||s==null)return;let h=k.current;h&&Ft(h,s)},[i,s]);let W=Z(()=>{if(G.current)return;let d=k.current;if(!d)return;let m=Bt(d),f=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;D(f)},[D]),g=Z(()=>{ce.current=performance.now(),W();let d=k.current;d&&z(Ht(d))},[W,z]);je(()=>{let d=k.current;if(!d)return;let m=h=>{let f=h,C=f.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){h.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let l=C.startsWith("delete")?"":f.data??"";M(l)&&h.preventDefault()}};return d.addEventListener("beforeinput",m),()=>d.removeEventListener("beforeinput",m)},[M]);let ve=Z(()=>{G.current=!0},[]),pe=Z(()=>{G.current=!1,W()},[W]),he=Z(d=>{d.preventDefault();let m=k.current;if(!m)return;let h=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let f=m.ownerDocument??document,C=f.getSelection();if(!C||C.rangeCount===0)return;let l=C.getRangeAt(0);if(!m.contains(l.startContainer))return;l.deleteContents();let B=f.createTextNode(h);l.insertNode(B),l.setStartAfter(B),l.collapse(!0),C.removeAllRanges(),C.addRange(l),W()},[W]),te=Z(d=>L(d),[L]),ue=Z(()=>I(!0),[I]),ae=Z(()=>I(!1),[I]),$=Z(()=>k.current?.focus(),[]),q=Z(()=>k.current?.blur(),[]),ie=Z(()=>{let d=k.current;return d?Bt(d):""},[]),oe=pi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:oe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:g,onKeyDown:te,onCompositionStart:ve,onCompositionEnd:pe,onPaste:he,onFocus:ue,onBlur:ae},getPlainText:ie,focus:$,blur:q}}import{jsx as Te,jsxs as lt}from"react/jsx-runtime";function vi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var wi=hi(function({onSubmit:o,onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,className:a,apiConfig:s,additionalContext:v,visitorId:w,columns:x,pillPlacement:P="dropdown",mode:u="auto",optionsPosition:y="below",animations:E=!0,dropdownTrigger:D,closeDropdownOnBlur:L,showNonTappableOptions:z,showOptionIcons:R=!0,showChipIcons:S=!0,showChipImages:M=!0,showOptionImages:I=!0,showOptionCounts:k=!0,showSkipButton:G,showProducts:Y,productsLayout:N,productImageFallback:ee,autoFocus:ce=!0,onFocus:W,onBlur:g,value:ve,completedParams:pe,onChange:he,onParamsChange:te,products:ue,onProductSelect:ae,submitButton:$,resetOnSubmit:q=!0},ie){let oe=Me(null),d=Me(null),m=Me(()=>{}),h=Me(null),f=Me(null);Gt(()=>{let T=oe.current;if(T)return h.current?h.current.setMode(u):h.current=new fi(T,u),()=>{h.current?.destroy(),h.current=null}},[u]);let C=st(T=>{let X=f.current?.current;X&&(X.focus(),bi(X,T))},[]),{completedParams:l,skippedParams:B,identifiedParams:H,isReady:V,customFields:b,suggestionPills:we,setActivePill:Ae,skipActivePill:ne,segments:c,newParamId:re,clearNewParamId:xe,placeholderText:me,isFocused:Ce,isDropdownOpen:ge,isActivePillSelected:Pe,isLoading:F,activeIndex:fe,listboxId:Se,handleTextChange:Ne,handleKeyDown:Ye,setFocused:Re,editingParam:Be,editingIdentified:p,editingAnchor:U,caretOffset:O,startEditingParam:Ze,handleCaretAfterInput:Wt,handleCaretMove:_t,replaceEditingRange:qt,dropdownProps:Ut,reset:He,recordSubmit:dt}=nt({onSubmit:T=>m.current(T),onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,apiConfig:s,additionalContext:v,visitorId:w,columns:x,dropdownTrigger:D,optionsPosition:y,closeDropdownOnBlur:L,showNonTappableOptions:z,showOptionIcons:R,showOptionImages:I,showOptionCounts:k,showSkipButton:G,showProducts:Y,onFocus:W,onBlur:g,value:ve,completedParams:pe,onChange:he,onParamsChange:te,products:ue,onProductSelect:ae,source:"full-sdk",setCursor:C});Gt(()=>{if(!re)return;let T=window.setTimeout(()=>xe(),650);return()=>window.clearTimeout(T)},[re,xe]);let jt=fe>=0?`${Se}-option-${fe}`:void 0,{inputRef:$e,editorProps:Qt,focus:Fe,blur:ct,getPlainText:pt}=Kt({segments:c,newParamId:re,editingParam:Be,editingIdentified:p,editingAnchor:U,caretOffset:O,placeholderText:me,isFocused:Ce,showChipIcons:S,showChipImages:M,isDropdownOpen:ge,listboxId:Se,activeDescendantId:jt,autoFocus:ce,handleTextChange:Ne,handleKeyDown:Ye,handleCaretAfterInput:Wt,handleCaretMove:_t,startEditingParam:Ze,replaceEditingRange:qt,setFocused:Re});f.current=$e,mi(()=>{let T=d.current,X=$e.current;if(!T||!X)return;let Oe=()=>{let ut=T.firstElementChild;if(!ut)return;let Vt=ut.getBoundingClientRect(),Xt=X.getBoundingClientRect();Vt.top>=Xt.bottom-2?T.setAttribute("data-aia-pill-wrapped",""):T.removeAttribute("data-aia-pill-wrapped")};Oe();let ht=new ResizeObserver(Oe);return ht.observe(X),()=>ht.disconnect()},[c,we.length,F,$e]),ui(ie,()=>({focus:Fe,blur:ct,reset:He,setMode:T=>h.current?.setMode(T),skipActivePill:ne}),[Fe,ct,He,ne]);let Ke=!!c.length||l.length>0,Ve=st(T=>{if(!Ke)return;let X=pt(),Oe=gi(X,l,B,{identifiedParams:H,isReady:V,customFields:b});T&&dt(Oe),o(Oe),q&&He()},[dt,q,Ke,l,B,H,V,b,o,He,pt]);m.current=()=>Ve(!1);let Yt=st(T=>{T.target?.closest("[data-aia-pill]")||Fe()},[Fe]),Zt=P==="inline",$t=P==="dropdown";return lt("div",{ref:oe,className:`magicx-aia ${ye.container} ${a??""}`,"data-pill-placement":P,"data-options-position":y,"data-animations":E?"on":"off","data-mode":vi(u),children:[Te(it,{...Ut,showPills:$t,productsLayout:N,productImageFallback:ee}),lt("div",{className:ye.inputWrapper,"data-aia-input-wrapper":"",onClick:Yt,children:[lt("div",{className:ye.editorArea,"data-aia-editor":"",children:[Te("div",{...Qt,className:ye.input,"data-aia-input":""}),Zt&&(F||we.length>0)&&Te("span",{ref:d,className:ye.pillListContainer,"data-aia-pill-list-container":"",children:Te(We,{pills:we,activePillIndex:0,activeSelected:Pe,onSelectPill:Ae,loading:F})})]}),$===null?null:$===void 0?Te(Ot,{disabled:!Ke,onClick:()=>Ve(!0)}):Te("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ye.submitSlot,onClick:T=>{Ke&&(T.stopPropagation(),Ve(!0))},children:$})]})]})});export{wi as AIAutocomplete,it as AIAutocompleteDropdown,mn as DATE_RANGE_META_END,gn as DATE_RANGE_META_START,fn as DEFAULT_OPTION_COUNT_UNIT,Tn as PRODUCT_PATH_PREFIX,Hn as WEEKDAY_LABELS,pn as buildSubmitResult,hn as cellDay,un as cellIso,bn as dateCellMarks,vn as formatDate,wn as formatDateRange,xn as formatOptionCount,yn as isoDate,kn as monthLabel,Cn as optionCountLabel,Pn as optionHasImage,Sn as optionImageSources,In as optionImageSrc,En as optionLabel,An as parseDate,Rn as parseLooseDate,On as parseLooseDateRange,Dn as productFromMatchedItem,Ln as productImageSources,zn as productsFromCustomFields,Mn as sanitizeOptionIconSvg,Nn as selectedRangeFor,nt as useAIAutocomplete,Bn as visibleDateRange,Fn as withSkippedParams};
|
|
2269
|
+
`,document.head.appendChild(e)}var Ot={submitButton:"aia-submitButton-otz7H"};import{jsx as nt}from"react/jsx-runtime";function Dt({disabled:e,onClick:o}){return nt("button",{type:"button","data-aia-submit":"",className:Ot.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:nt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:nt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ii,dateSelectionFor as oi,identifiedParamLabel as ni}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Bt,useEffect as Me,useRef as K,useState as ri}from"react";import{useRef as Lt}from"react";function zt(e){let o=Lt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=Lt({key:"",overrides:void 0});if(n.current.key!==t){let r={};for(let i of Object.keys(e??{})){let a=(s,v,y)=>{let w=o.current?.[i];return w?w(s,v,y):[]};r[i]=a}n.current={key:t,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:t}}import{useRef as Mt}from"react";function Nt(e){let o=Mt(e);o.current=e;let t=Mt(null);t.current===null&&(t.current={fetch:(r,i)=>{let a=o.current;return a?a.fetch(r,i):Promise.reject(new Error("products config removed"))},transform:r=>o.current?.transform(r)??[],get limit(){return o.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var si={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function rt({onSubmit:e,onResult:o,onError:t,optionOverrides:n,maskCompletedText:r,apiConfig:i,additionalContext:a,language:s,visitorId:v,columns:y=2,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showOptionIcons:I,showOptionImages:D,showOptionCounts:L,showSkipButton:H,showProducts:E,productImageFallback:S="image",onFocus:z,onBlur:R,value:k,completedParams:M,onChange:Q,onParamsChange:N,products:ce,onProductSelect:ee,source:_,setCursor:pe}){let m=K(null),[xe,he]=ri(null),te=K(e);te.current=e;let ue=K(o);ue.current=o;let ae=K(t);ae.current=t;let me=K(Q);me.current=Q;let G=K(N);G.current=N;let Z=K(z);Z.current=z;let ge=K(R);ge.current=R;let d=K(pe);d.current=pe;let h=K(ee);h.current=ee;let g=K(v);g.current=v;let b=K(()=>{let p=g.current;return typeof p=="function"?p():p}).current,C=Nt(ce),l=zt(n);Me(()=>{if(typeof document>"u")return;let p=new ii(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:a,language:s,visitorId:b,optionOverrides:l.overrides,maskCompletedText:r,columns:y,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E,source:_,value:k,completedParams:M,onSubmit:(...O)=>te.current?.(...O),onResult:(...O)=>ue.current?.(...O),onError:(...O)=>ae.current?.(...O),onChange:(...O)=>me.current?.(...O),onParamsChange:(...O)=>G.current?.(...O),onFocus:()=>Z.current?.(),onBlur:()=>ge.current?.(),onProductSelect:O=>h.current?.(O),setCursor:O=>d.current?.(O),products:C.config});m.current=p,he(p.getState());let q=p.subscribe(O=>he(O));return()=>{q(),p.destroy(),m.current===p&&(m.current=null)}},[]),Me(()=>{k!==void 0&&m.current?.setValue(k)},[k]),Me(()=>{M!==void 0&&m.current?.setCompletedParams(M)},[M]);let F=JSON.stringify(i??null),B;try{B=JSON.stringify(a??null)}catch{B="[unstringifiable]"}Me(()=>{m.current?.update({apiConfig:i,additionalContext:a,language:s,optionOverrides:l.overrides,dropdownTrigger:w,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E})},[F,B,s,l.key,w,P,u,f,E]);let ie=K(!1);Me(()=>{if(!ie.current){ie.current=!0;return}m.current?.update({products:C.config})},[C.enabled]);let $=K(null);$.current===null&&($.current={handleTextChange:p=>m.current?.handleTextChange(p),handleKeyDown:p=>{let q="nativeEvent"in p?p.nativeEvent:p;m.current?.handleKeyDown(q)},setFocused:p=>m.current?.setFocused(p),startEditingParam:p=>m.current?.startEditingParam(p),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:p=>m.current?.handleCaretAfterInput(p),handleCaretMove:p=>m.current?.handleCaretMove(p),replaceEditingRange:p=>m.current?.replaceEditingRange(p)??!1,setActivePill:p=>m.current?.setActivePill(p),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),recordSubmit:p=>m.current?.recordSubmit(p),selectOption:p=>m.current?.selectOption(p),selectProduct:p=>m.current?.selectProduct(p),setActiveDropdownIndex:p=>m.current?.setActiveDropdownIndex(p),clearHighlight:p=>m.current?.clearHighlight(p),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let x=$.current,ye=Bt(p=>{let q=p.target.value,$e=q.length>0&&!p.nativeEvent?.isComposing&&q[0]!==q[0].toUpperCase()?q[0].toUpperCase()+q.slice(1):q;m.current?.handleTextChange($e)},[]),Se=Bt(p=>{m.current?.handleKeyDown(p.nativeEvent)},[]),oe=m.current,c=xe??si,ne=k!==void 0?k:c.text,ke=M!==void 0?M:c.completedParams,fe=c.actionableSuggestions,Re=fe[0],re=oe?.listboxId??"",be=c.activeDropdownIndex>=0&&oe?`${re}-option-${c.activeDropdownIndex}`:void 0,V=c.editingParam,ve=c.editingIdentified,Ie=V?{parameter:V.suggestionParameter,text:V.suggestionPlaceholder,required:!0,options:V.options}:ve?{parameter:ve.parameter,text:ni(ve.parameter),required:!0,options:[]}:null,Be=c.dropdownSuggestion??Ie??Re,Ze=Ie?[Ie]:fe,Oe=oi(c),He=!oe||c.dropdownLoading;return{completedParams:ke,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:fe,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:x.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:He,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:re,error:c.error,products:c.products,customFields:c.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:V,editingIdentified:ve,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:ne,placeholder:c.placeholderText||void 0,onChange:ye,onKeyDown:Se,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":be,"aria-autocomplete":"list","aria-controls":re},reset:x.reset,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:c.isDropdownOpen,id:re,pills:Ze,activeSelected:c.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(H??!0)&&!V&&!ve,showOptionIcons:I??!0,showOptionImages:D??!0,showOptionCounts:L??!0,skipDisabled:c.inSelectionAnimation,isLoading:He,skeletonExiting:c.skeletonExiting,isInputEmpty:ne.trim().length===0,products:c.products,productImageFallback:S,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Oe.selectedIso,selectedDateRange:Oe.selectedRange,dateRangeStart:Oe.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:P??"below"}}}import{chipIdFromTap as li,extractPlainText as Ht,getCursorOffset as Ft,keepCaretOnChip as di,plainTextLength as ci,renderEditableContent as pi,setCursorOffset as Kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Y,useEffect as Qe,useLayoutEffect as st,useRef as Te}from"react";var Ye;function hi(){if(Ye!==void 0)return Ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ye=e.contentEditable==="plaintext-only",Ye}function Gt(e){let{segments:o,showChipIcons:t=!0,showChipImages:n=!0,newParamId:r,editingParam:i,editingIdentified:a,editingAnchor:s,caretOffset:v,placeholderText:y,isFocused:w,isDropdownOpen:P,listboxId:u,activeDescendantId:f,autoFocus:I,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:H,handleCaretMove:E,startEditingParam:S,replaceEditingRange:z,setFocused:R}=e,k=Te(null),M=Te(!1),Q=Te(""),N=Te(""),ce=Te(null),ee=Te(0);ce.current=v,Qe(()=>{if(!I)return;let d=k.current;if(!d)return;document.activeElement===d?R(!0):d.focus();let h=d.ownerDocument??document,g=h.getSelection(),b=g&&g.rangeCount>0&&d.contains(g.anchorNode);if(g&&!b){let C=h.createRange();C.selectNodeContents(d),C.collapse(!0),g.removeAllRanges(),g.addRange(C)}},[I,R]),Qe(()=>{let d=k.current;if(!d)return;let h=d.ownerDocument??document,g=()=>{let b=h.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!d.contains(b.anchorNode))return;let C=b.anchorNode,l=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,B=(b.isCollapsed?l?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ie=i?.id??a?.id??null;if(B&&B!==ie){S(B);return}performance.now()-ee.current<50||E(Ft(d))};return h.addEventListener("selectionchange",g),()=>h.removeEventListener("selectionchange",g)},[i,a,S,E]),Qe(()=>{let d=k.current;if(!d)return;let h=g=>{let b=li(d,g.target);b&&(S(b),di(d,b))};return d.addEventListener("click",h),()=>d.removeEventListener("click",h)},[S]),st(()=>{let d=k.current;d&&pi({input:d,segments:o,newParamId:r,editingParamId:i?.id??null,placeholderText:y??"",isFocused:w,showChipIcons:t,showChipImages:n})},[o,r,i,y,w,t,n]),st(()=>{let d=Q.current,h=r??"";if(Q.current=h,!h||h===d)return;let g=k.current;if(!g)return;g.focus();let b=ce.current??ci(g);Kt(g,b)},[r]),st(()=>{let d=N.current,h=i?.id??"";if(N.current=h,!h||h===d||s==null)return;let g=k.current;g&&Kt(g,s)},[i,s]);let _=Y(()=>{if(M.current)return;let d=k.current;if(!d)return;let h=Ht(d),b=h.length>0&&h[0]!==h[0].toUpperCase()?h[0].toUpperCase()+h.slice(1):h;D(b)},[D]),pe=Y(()=>{ee.current=performance.now(),_();let d=k.current;d&&H(Ft(d))},[_,H]);Qe(()=>{let d=k.current;if(!d)return;let h=g=>{let b=g,C=b.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){g.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let l=C.startsWith("delete")?"":b.data??"";z(l)&&g.preventDefault()}};return d.addEventListener("beforeinput",h),()=>d.removeEventListener("beforeinput",h)},[z]);let m=Y(()=>{M.current=!0},[]),xe=Y(()=>{M.current=!1,_()},[_]),he=Y(d=>{d.preventDefault();let h=k.current;if(!h)return;let g=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!g)return;let b=h.ownerDocument??document,C=b.getSelection();if(!C||C.rangeCount===0)return;let l=C.getRangeAt(0);if(!h.contains(l.startContainer))return;l.deleteContents();let F=b.createTextNode(g);l.insertNode(F),l.setStartAfter(F),l.collapse(!0),C.removeAllRanges(),C.addRange(l),_()},[_]),te=Y(d=>L(d),[L]),ue=Y(()=>R(!0),[R]),ae=Y(()=>R(!1),[R]),me=Y(()=>k.current?.focus(),[]),G=Y(()=>k.current?.blur(),[]),Z=Y(()=>{let d=k.current;return d?Ht(d):""},[]),ge=hi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:ge,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":f,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:te,onCompositionStart:m,onCompositionEnd:xe,onPaste:he,onFocus:ue,onBlur:ae},getPlainText:Z,focus:me,blur:G}}import{jsx as Ae,jsxs as dt}from"react/jsx-runtime";function wi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xi=ui(function({onSubmit:o,onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,className:a,apiConfig:s,additionalContext:v,language:y,visitorId:w,columns:P,pillPlacement:u="dropdown",mode:f="auto",optionsPosition:I="below",animations:D=!0,dropdownTrigger:L,closeDropdownOnBlur:H,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:z=!0,showChipImages:R=!0,showOptionImages:k=!0,showOptionCounts:M=!0,showSkipButton:Q,showProducts:N,productsLayout:ce,productImageFallback:ee,autoFocus:_=!0,onFocus:pe,onBlur:m,value:xe,completedParams:he,onChange:te,onParamsChange:ue,products:ae,onProductSelect:me,submitButton:G,resetOnSubmit:Z=!0},ge){let d=Ne(null),h=Ne(null),g=Ne(()=>{}),b=Ne(null),C=Ne(null);Wt(()=>{let T=d.current;if(T)return b.current?b.current.setMode(f):b.current=new bi(T,f),()=>{b.current?.destroy(),b.current=null}},[f]);let l=lt(T=>{let X=C.current?.current;X&&(X.focus(),vi(X,T))},[]),{completedParams:F,skippedParams:B,identifiedParams:ie,isReady:$,customFields:x,suggestionPills:ye,setActivePill:Se,skipActivePill:oe,segments:c,newParamId:ne,clearNewParamId:ke,placeholderText:fe,isFocused:Re,isDropdownOpen:re,isActivePillSelected:be,isLoading:V,activeIndex:ve,listboxId:Ie,handleTextChange:Be,handleKeyDown:Ze,setFocused:Oe,editingParam:He,editingIdentified:p,editingAnchor:q,caretOffset:O,startEditingParam:$e,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:Fe,recordSubmit:ct}=rt({onSubmit:T=>g.current(T),onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,apiConfig:s,additionalContext:v,language:y,visitorId:w,columns:P,dropdownTrigger:L,optionsPosition:I,closeDropdownOnBlur:H,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:k,showOptionCounts:M,showSkipButton:Q,showProducts:N,onFocus:pe,onBlur:m,value:xe,completedParams:he,onChange:te,onParamsChange:ue,products:ae,onProductSelect:me,source:"full-sdk",setCursor:l});Wt(()=>{if(!ne)return;let T=window.setTimeout(()=>ke(),650);return()=>window.clearTimeout(T)},[ne,ke]);let Qt=ve>=0?`${Ie}-option-${ve}`:void 0,{inputRef:Ve,editorProps:Yt,focus:Ke,blur:pt,getPlainText:ht}=Gt({segments:c,newParamId:ne,editingParam:He,editingIdentified:p,editingAnchor:q,caretOffset:O,placeholderText:fe,isFocused:Re,showChipIcons:z,showChipImages:R,isDropdownOpen:re,listboxId:Ie,activeDescendantId:Qt,autoFocus:_,handleTextChange:Be,handleKeyDown:Ze,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:$e,replaceEditingRange:Ut,setFocused:Oe});C.current=Ve,gi(()=>{let T=h.current,X=Ve.current;if(!T||!X)return;let De=()=>{let mt=T.firstElementChild;if(!mt)return;let Xt=mt.getBoundingClientRect(),Jt=X.getBoundingClientRect();Xt.top>=Jt.bottom-2?T.setAttribute("data-aia-pill-wrapped",""):T.removeAttribute("data-aia-pill-wrapped")};De();let ut=new ResizeObserver(De);return ut.observe(X),()=>ut.disconnect()},[c,ye.length,V,Ve]),mi(ge,()=>({focus:Ke,blur:pt,reset:Fe,setMode:T=>b.current?.setMode(T),skipActivePill:oe}),[Ke,pt,Fe,oe]);let Ge=!!c.length||F.length>0,Xe=lt(T=>{if(!Ge)return;let X=ht(),De=fi(X,F,B,{identifiedParams:ie,isReady:$,customFields:x});T&&ct(De),o(De),Z&&Fe()},[ct,Z,Ge,F,B,ie,$,x,o,Fe,ht]);g.current=()=>Xe(!1);let Zt=lt(T=>{T.target?.closest("[data-aia-pill]")||Ke()},[Ke]),$t=u==="inline",Vt=u==="dropdown";return dt("div",{ref:d,className:`magicx-aia ${Ce.container} ${a??""}`,"data-pill-placement":u,"data-options-position":I,"data-animations":D?"on":"off","data-mode":wi(f),children:[Ae(ot,{...jt,showPills:Vt,productsLayout:ce,productImageFallback:ee}),dt("div",{className:Ce.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[dt("div",{className:Ce.editorArea,"data-aia-editor":"",children:[Ae("div",{...Yt,className:Ce.input,"data-aia-input":""}),$t&&(V||ye.length>0)&&Ae("span",{ref:h,className:Ce.pillListContainer,"data-aia-pill-list-container":"",children:Ae(_e,{pills:ye,activePillIndex:0,activeSelected:be,onSelectPill:Se,loading:V})})]}),G===null?null:G===void 0?Ae(Dt,{disabled:!Ge,onClick:()=>Xe(!0)}):Ae("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ce.submitSlot,onClick:T=>{Ge&&(T.stopPropagation(),Xe(!0))},children:G})]})]})});export{xi as AIAutocomplete,ot as AIAutocompleteDropdown,gn as DATE_RANGE_META_END,fn as DATE_RANGE_META_START,bn as DEFAULT_OPTION_COUNT_UNIT,An as PRODUCT_PATH_PREFIX,Fn as WEEKDAY_LABELS,hn as buildSubmitResult,un as cellDay,mn as cellIso,vn as dateCellMarks,wn as formatDate,xn as formatDateRange,yn as formatOptionCount,kn as isoDate,Cn as monthLabel,Pn as optionCountLabel,Sn as optionHasImage,In as optionImageSources,En as optionImageSrc,Tn as optionLabel,Rn as parseDate,On as parseLooseDate,Dn as parseLooseDateRange,Ln as productFromMatchedItem,zn as productImageSources,Mn as productsFromCustomFields,Nn as sanitizeOptionIconSvg,Bn as selectedRangeFor,rt as useAIAutocomplete,Hn as visibleDateRange,Kn as withSkippedParams};
|
|
2270
2270
|
//# sourceMappingURL=index.mjs.map
|