@magicx-eng/ai-autocomplete-vanilla 0.67.1 → 0.68.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 +11 -11
- package/REFERENCE.md +10 -4
- package/dist/index.d.mts +49 -13
- package/dist/index.d.ts +49 -13
- package/dist/index.js +151 -206
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -206
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var hi=Object.defineProperty;var Xa=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var Za=Object.prototype.hasOwnProperty;var es=(t,e)=>{for(var n in e)hi(t,n,{get:e[n],enumerable:!0})},ts=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ja(e))!Za.call(t,o)&&o!==n&&hi(t,o,{get:()=>e[o],enumerable:!(i=Xa(e,o))||i.enumerable});return t};var ns=t=>ts(hi({},"__esModule",{value:!0}),t);var Rc={};es(Rc,{AIAutocomplete:()=>gi,ATTRIBUTION_URL:()=>zi,DATE_RANGE_META_END:()=>bn,DATE_RANGE_META_START:()=>hn,DEFAULT_OPTION_COUNT_UNIT:()=>mo,EDITOR_GROW_MS:()=>Ia,LOCATION_META_KEY:()=>bi,LOCATION_MIN_QUERY:()=>Pt,MULTI_DONE_FIT_VAR:()=>Hn,MULTI_SELECT_TOGGLE_MIN_PX:()=>pa,MULTI_SELECT_TOGGLE_SLOP_PX:()=>ma,ModeController:()=>Ve,OPTIONS_GRID_MOBILE_QUERY:()=>lt,OPTION_ENTER_DELAY_VAR:()=>Wn,OPTION_ENTER_FADE_MS:()=>Fr,OPTION_ENTER_RISE_MS:()=>Wr,OPTION_ENTER_RISE_PX:()=>Br,OPTION_ENTER_STAGGER_MS:()=>Hr,OPTION_IMAGE_WIDTH:()=>Qn,PANEL_ENTER_DELAY_MS:()=>io,PANEL_ENTER_MS:()=>no,PANEL_GHOST_CLASS:()=>ce,PANEL_GLIDE_MS:()=>eo,PANEL_LEAVE_MS:()=>to,PLACEHOLDER_FADE_OUT_MS:()=>wr,PLACEHOLDER_LEAVING_ATTR:()=>Te,PLACEHOLDER_SWAP_GAP_MS:()=>Cr,PLACEHOLDER_TYPE_MS:()=>Er,PLACEHOLDER_WORD_PAUSE_MS:()=>Pr,PRODUCT_IMAGE_WIDTH:()=>aa,PRODUCT_PATH_PREFIX:()=>Di,PRODUCT_ROW_PX_PER_LINE:()=>ia,RANGE_SEPARATOR:()=>Wi,SCHEMA_VERSION:()=>xi,SCROLL_ARROW_ATTR:()=>dt,SCROLL_ARROW_BOTTOM_VAR:()=>Zi,SCROLL_ARROW_CLASS:()=>Qi,SCROLL_ARROW_FADE_MS:()=>Xi,SCROLL_ARROW_LABEL:()=>Ur,SCROLL_ARROW_SCROLL_IDLE_MS:()=>Ji,SCROLL_ARROW_VISIBLE_ATTR:()=>Ee,SKIPPED_PARAM_TEXT:()=>yi,SMART_SUGGESTION_SPARKLE_SVG:()=>Rt,TIME_META_KEY:()=>Li,TIME_STEP_MINUTES:()=>nn,TIME_WHEEL_COLUMNS:()=>it,TIME_WHEEL_ROW_HEIGHT:()=>nt,VIEWPORT_FIT_ATTR:()=>Ce,VIEWPORT_FIT_HEIGHT_VAR:()=>ft,WEEKDAY_LABELS:()=>Qe,addMonths:()=>Wt,attachProductRowWheel:()=>jn,attachScrollArrow:()=>Vn,attachViewportFit:()=>ii,buildAttributionUrl:()=>_n,buildDateOptions:()=>Bt,buildLocationOption:()=>wt,buildQuery:()=>N,buildSubmitResult:()=>ae,buildTimeOption:()=>on,cellDay:()=>Vt,cellIso:()=>G,chipIdFromTap:()=>Qt,computeOptionsGridLayout:()=>Vi,containScroll:()=>Nn,createStore:()=>di,cursorIsAtEnd:()=>Jt,dateCellMarks:()=>Mn,dateFloorFor:()=>Rn,dateSelectionFor:()=>We,destroyPanelMorph:()=>Kn,extractPlainText:()=>et,findMultiSelectDone:()=>Nr,fitMultiSelectDone:()=>Fn,formatAbsoluteDate:()=>ye,formatDate:()=>vi,formatDateRange:()=>Bi,formatOptionCount:()=>Ue,formatPlace:()=>Si,formatTime:()=>tt,getCursorOffset:()=>$,getFooterHint:()=>Dn,hasSkippablePill:()=>_t,highlightParts:()=>wn,identifiedParamLabel:()=>Q,inPanelGhost:()=>ve,isCalendarFormat:()=>k,isDimmedDay:()=>kn,isMultiSelectToggleTap:()=>Zn,isOptionsGridMobileViewport:()=>vn,isPickerFormat:()=>_,isSmartSuggestion:()=>je,isTraditionalAutocompleteSuggestion:()=>C,isoDate:()=>V,isoTime:()=>ki,keepCaretOnChip:()=>Xt,labelTraditionalAutocomplete:()=>kt,locationEndpointFor:()=>Ct,matchTypedPhrase:()=>ct,measureOptionsGrid:()=>Tn,monthLabel:()=>Ft,needsOptionsGridMeasurement:()=>yn,notePanelMorphHeight:()=>qn,optionCountLabel:()=>ha,optionEnterDelayMs:()=>Bn,optionHasImage:()=>po,optionImageSources:()=>gt,optionImageSrc:()=>pe,optionLabel:()=>pt,optionsEntranceDurationMs:()=>Un,optionsGridTemplateColumns:()=>Sn,optionsShowLeadingVisuals:()=>ti,panelMorphGlide:()=>ue,panelMorphKey:()=>Gn,panelMorphTargetHeight:()=>$n,parseDate:()=>Xe,parseLooseDate:()=>Ne,parseLooseDateRange:()=>st,parseTime:()=>tn,plainTextLength:()=>Yt,planOptionsGrid:()=>xn,previousGraphemeBoundary:()=>Zt,productFromMatchedItem:()=>Ni,productImageSources:()=>mt,productImageSrc:()=>sa,productInitial:()=>Yn,productPhotoFill:()=>Xn,productRowWheelTarget:()=>ro,productsFromCustomFields:()=>un,queryLive:()=>de,renderEditableContent:()=>ci,resolveFormatType:()=>j,resolveIdentifiedDate:()=>gn,sameOptionRows:()=>En,sanitizeOptionIconSvg:()=>me,scrollCaretIntoView:()=>Kt,selectedIsoFromText:()=>Ut,selectedRangeFor:()=>He,setCursorOffset:()=>H,settlePanelMorph:()=>ut,shopifyImageSrc:()=>ao,timeWheelIndex:()=>ot,timeWheelIndexFromScroll:()=>an,timeWheelRows:()=>rn,toWireIdentifiedParams:()=>Ae,typedFragment:()=>qi,uiStringsFor:()=>O,visibleDateRange:()=>On,watchEditorHeight:()=>li,withSkippedParams:()=>Oe,withTimeWheelIndex:()=>rt,withoutTraditionalAutocomplete:()=>Mt});module.exports=ns(Rc);function k(t){return t==="date"||t==="date-range"}function _(t){return t!=="options"}function j(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var yt=class{constructor(e){this.config=e;this.current=null;this.expiresAt=null;this.inFlightRefresh=null;e.accessToken&&(this.current=e.accessToken)}async getToken(e=!1){if(!e&&this.current&&!this.isExpired())return this.current;if(!e&&this.inFlightRefresh)return this.inFlightRefresh;this.inFlightRefresh=this.refresh();try{return await this.inFlightRefresh}finally{this.inFlightRefresh=null}}async refresh(){let e=await this.config.getAccessToken();return this.current=e.accessToken,this.expiresAt=e.expiresAt??null,this.current}isExpired(){return this.expiresAt==null?!1:Date.now()>=this.expiresAt-3e4}};var is="https://api.ai-autocomplete.com",Y=`${is}/api/suggest`,xt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),vo=new WeakMap;function Ge(t){return t?.type==="accessToken"}function os(t){if(!(!t||Ge(t)))return t}function Tt(t){let e=vo.get(t.getAccessToken);return e||(e=new yt(t),vo.set(t.getAccessToken,e)),e}function vt(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function Et(t){let e=os(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var bi="aiaPlace",Pt=2,Eo=250;function Si(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function wt(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Si(t),is_tappable:!0,kind:null,metadata:{[bi]:{id:t.id}}}}function Ct(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??Y,n=e.indexOf("?"),i=n<0?e:e.slice(0,n),o=n<0?"":e.slice(n+1);if(!/\/suggest\/?$/.test(i))return null;let r=i.replace(/\/suggest\/?$/,"/locations/autocomplete");return o?`${r}?${o}`:r}function Po(t){let e=t?.places;if(!Array.isArray(e))return[];let n=[];for(let i of e){let{id:o,name:r,secondary:a}=i??{};typeof o!="string"||!o||typeof r!="string"||!r.trim()||n.push({id:o,name:r.trim(),...typeof a=="string"&&a.trim()?{secondary:a.trim()}:{}})}return n}function Ae(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var yi="skipped";function Oe(t,e){if(t.some(o=>"group"in o)&&(t=t.map(o=>{let{group:r,...a}=o;return a})),e.length===0)return t;let n=new Set(t.map(o=>o.parameter)),i=e.filter(o=>!n.has(o.parameter)).map(o=>({placeholder:"",parameter:o.parameter,text:yi,kind:null}));return i.length>0?[...t,...i]:t}var rs="0.67.1",xi="1.0",wo=!1;function as(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function ne(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function ss(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function ls(t,e,n,i,o,r,a,s,l,d,c,u,p){let f=e.find(S=>S.parameter==="contact"&&S.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof f=="number"?f:void 0,h=ss();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:p??[],completed_params:Oe(e.map(S=>as(S,n)),l??[]),...a&&a.length>0&&{identified_params:Ae(a)},...s&&s.length>0&&{recently_suggested:s},...g!=null&&{contact_account_count:g},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:ne(c),...h&&{timezone:h},...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:rs,session_id:i,source:r,schema_version:xi}}}async function Co(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Lo(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=ls(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),a=i?.endpoint??Y,s=await Io(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function Io(t,e,n,i){let o=vt(n);if(Ge(n)){let a=Tt(n),s=await a.getToken(),l=await Co(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await Co(t,o,d,e,i)}return l}let r=Et(n);return!r&&!wo&&(wo=!0,console.warn("[AIAutocomplete] No apiKey in apiConfig. Requests will be sent without an Authorization header.")),r&&(o.Authorization=r),fetch(t,{method:"POST",headers:o,body:e,signal:i})}var $e=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Ao(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:ne(n.language)}),o=await Io(t,i,n.apiConfig,n.signal);if(!o.ok)throw new $e(o.status);return Po(await o.json())}var Lt=/[\p{L}\p{N}]/u,cs=/['\u2019-]/;function Oo(t,e,n){let i=t[e];if(i===void 0)return!1;if(Lt.test(i))return!0;let o=t[e+n];return cs.test(i)&&o!==void 0&&Lt.test(o)}function ds(t,e,n){let i=e+n.length;return!(Lt.test(n[0])&&Oo(t,e-1,-1)||Lt.test(n[n.length-1])&&Oo(t,i,1))}function Z(t,e,n=0,i=()=>!0){if(e.length===0)return t.indexOf(e,n);let o=-1,r=t.indexOf(e,n);for(;r!==-1;){if(i(r)){if(ds(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function N(t,e){let n=t,i={},o=[],r=[],a=0;for(let s of e){let l=(i[s.parameter]??0)+1;i[s.parameter]=l;let c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=f=>Z(n,s.text,f,g=>!r.some(h=>g<h.end&&g+s.text.length>h.start)),p=u(a);if(p===-1&&(p=u(0)),p!==-1){n=n.slice(0,p)+c+n.slice(p+s.text.length);let f=c.length-s.text.length;for(let g of r)g.start>=p+s.text.length&&(g.start+=f,g.end+=f);r.push({start:p,end:p+c.length}),a=p>=a?p+c.length:a+f}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function ie(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Me(t,e){return e===!1?"":t}function At(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function qe(t,e,n){let i=t.slice(e);if(n||e===0||t[e-1]===" ")return i;let o=i.indexOf(" ");return o===-1?"":i.slice(o+1)}function Mo(t,e){let n=t.trimEnd().replace(/\s+/g," ");if(n.length===0||e.length===0)return 0;let i=n.split(" "),o=e.toLowerCase();for(let r=0;r<i.length;r++){let a=i.slice(r).join(" ");if(o.startsWith(a.toLowerCase())){let s=n.length-a.length;return t.length-s}}return 0}function ko(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function us(t,e){let n=ko(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function be(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?ko(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||us(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function It(t,e){if(!t)return null;let n=e.trim();if(!n)return null;let i=n.toLowerCase();return t.find(o=>o.is_tappable&&o.text.toLowerCase()===i)??null}function Ke(t,e,n,i,o){let r=qe(e,n,i),a=It(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return It(t,e.slice(s))}function Ro(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function Do(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function No(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every(_o)?t:t.map(o=>_o(o)?o:{...o,icon:n,icon_svg:i})}function _o(t){return!!(t.icon_svg||t.image_url)}function ms(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function Q(t){let e=ms(t);return e.length>0?e.join(" "):t}function X(t,e){return t.parameter||e}function ze(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:Q(t)}}function Ot(t,e){let n=X(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?ze(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function C(t){return t?.type?.kind==="traditional_autocomplete"}function Ho(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function je(t){return C(t)||t?.smart_suggestion===!0}function Mt(t){return t.some(C)?t.filter(e=>!C(e)):t}function kt(t,e){return t.some(n=>C(n)&&!n.text)?t.map(n=>C(n)&&!n.text?{...n,text:e}:n):t}var Rt='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function _t(t){return t.some(e=>!C(e))}function Fo(t,e){let n=0,i=e;for(let o of t)n+=o.value.length,o.type!=="text"&&(i=Math.max(i,n));return i}function Wo(t,e){let n=0;for(let i of t){let o=n+i.value.length;if(i.type==="text"&&o>e&&i.value.slice(Math.max(e-n,0)).trim().length>0)return!1;n=o}return!0}function Bo(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||C(o))continue;let r=i.get(o.parameter);r||(r={parameter:o.parameter,text:o.text},i.set(o.parameter,r),n.push(r));for(let a of o.options??[])!a.is_tappable||r.options?.includes(a.text)||(r.options??(r.options=[]),r.options.push(a.text))}return n}function Uo(t,e,n){if(t===e)return n;let i=Math.min(t.length,e.length),o=0;for(;o<i&&t[o]===e[o];)o++;if(o>=n)return n;let r=0;for(;r<i-o&&t[t.length-1-r]===e[e.length-1-r];)r++;return t.length-r<=n?n+(e.length-t.length):null}function Dt(t,e){let n=[],i=[],o=0;for(let r of e){let a=Z(t,r.text,o);if(a===-1){i.push(r);continue}n.push({start:a,end:a+r.text.length,param:r}),o=a+r.text.length}return{located:n,missing:i}}function Se(t,e){let{located:n}=Dt(t,e);return n.length>0?n[n.length-1].end:0}function Vo(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=Z(t,a.text,r,l=>!e.some(d=>l<d.end&&l+a.text.length>d.start));if(s===-1){o.push(a);continue}i.push({start:s,end:s+a.text.length,param:a}),r=s+a.text.length}return{located:i,missing:o}}function Go(t,e,n=[]){let i=Dt(t,e).located,o=[];for(let c of i){let u=o[o.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Vo(t,o,n).located,a=[...o.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...r.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),s=[],l=0;for(let c of a)c.start>l&&s.push({type:"text",value:t.slice(l,c.start)}),s.push(c.segment),l=c.end;let d=t.slice(l);return d&&s.push({type:"text",value:d}),s}function $o(t,e){let{located:n,missing:i}=Dt(t,e),o=new Set(i.map(a=>a.group).filter(Boolean)),r=n.map(a=>a.param).filter(a=>!o.has(a.group));return{valid:r,invalid:e.filter(a=>!r.includes(a))}}function Ye(t,e,n){let i=Dt(t,e).located,{located:o,missing:r}=Vo(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function qo(t,e,n){let i=e?.endpoint??Y,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${ps(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=xt.get(a);return s?`https://${s}`:r})}function ps(t){let e=t?.replace(/_/g,"-").toLowerCase()??"",[n,i=""]=e.split("-");return n!=="zh"?/^[a-z]{2,3}$/.test(n)?`/${n}`:"":/^[a-z]{4}$/.test(i)?i==="hant"?"/zh-TW":"/zh":["tw","hk","mo"].includes(i)?"/zh-TW":"/zh"}async function Ko(t){try{let e=await t;if(!e.ok)return null;let n=await e.json();return Array.isArray(n?.data?.suggestions)?n:null}catch{return null}}function gs(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var fs=100,hs=300,bs=2,Nt=class{constructor(e,n,i,o,r,a,s,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=a;this.getSource=s;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,a=this.store.get().text;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:i.signal,isCurrent:()=>o===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let s=this.store.get(),l=s.pendingSpan?Bo(s.pendingSpan.snapshot,s.actionableSuggestions):void 0,d=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0?this.startingStateUrl():void 0,u=c?await Ko(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let p=u??await Lo(e,n,{sessionId:this.getSessionId(),requestId:d,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:s.identifiedParams,recentlySuggested:l,skippedParams:s.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=p.meta?.phrase_exact_match===!0;let f=(p.data.suggestions??[]).find(C),g=f?[]:p.data.input??[],h=v=>({id:crypto.randomUUID(),parameter:v.parameter,text:v.text,...v.type?{type:v.type}:{},...v.iso_date?{isoDate:v.iso_date}:{},...v.iso_date_end?{isoDateEnd:v.iso_date_end}:{}}),S=g.filter(v=>v.source==="identified");this.callbacks.waitIdentified?.(S.filter(v=>v.state==="need_confirmation").map(h),a);let y=S.filter(v=>v.state!=="need_confirmation").map(h),m=this.callbacks.isWordOpen?.()??!1,b=this.store.get().text.toLowerCase(),x=v=>m&&b.endsWith(v.text.toLowerCase()),T=y.filter(v=>!x(v));m&&this.callbacks.holdIdentified?.(y.filter(x));let P=f?[f]:Do(p.data.suggestions??[],this.getOptionOverrides()),I=g,E=I[I.length-1],w=this.store.get().text,D,M;if(E?.state==="in_progress"){M=!0;let v=w.toLowerCase().lastIndexOf(E.text.toLowerCase());D=v!==-1?v:r}else M=!1,D=r;let L=P.filter(v=>v.parameter!=="placeholder")[0],U=null;if(L&&!C(L)&&!m&&L.type?.kind!=="multi_select"&&!_(j(L))){let v=Ke(L.options,w,D,M,this.phraseExactMatch);v&&(U={id:crypto.randomUUID(),placeholder:"",parameter:X(v,L.parameter),text:v.text,value:v.value,kind:v.kind,suggestionParameter:L.parameter,suggestionValueType:L.type,suggestionPlaceholder:L.text,suggestionIcon:L.icon,suggestionIconSvg:L.icon_svg,options:L.options??[],metadata:v.metadata,icon:v.icon,icon_svg:v.icon_svg,image_url:v.image_url},P=P.filter(fe=>fe!==L),this.callbacks.onAutoMatch?.({active:L,matched:v,rawQuery:e}))}let ge=p.data.custom_fields??null,z=this.callbacks.productsForResponse?.(ge);this.store.set(v=>{let fe=U?[...v.completedParams,U]:v.completedParams,he=Ye(v.text,fe,T).valid,ht=new Set(s.skippedParams.map(K=>K.id)),bt=new Set(v.skippedParams.filter(K=>!ht.has(K.id)).map(K=>K.parameter));return{suggestions:bt.size>0?P.filter(K=>K.parameter==="placeholder"||!bt.has(K.parameter)):P,isLoading:!1,isReady:p.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:D,filterInProgress:M,identifiedParams:he,customFields:ge,traditionalAutocomplete:p.meta?.traditional_autocomplete===!0,...z!==void 0?{products:z}:{},...U?{completedParams:fe}:{}}}),this.callbacks.onResponse?.({requestId:d,funnelTelemetry:p.meta?.funnel_telemetry===!0,visibleImpression:p.meta?.visible_impression===!0})}catch(s){let l=gs(s);o===this.fetchVersion&&(this.store.set({error:l,isLoading:!1}),this.getOnError()?.(l))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?qo(e,this.getApiConfig(),ne(this.getLanguage())):void 0}attemptNow(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.attemptFetch(1,!0)}scheduleFetch(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.debounceTimer=setTimeout(()=>{this.attemptFetch(bs)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},fs),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),hs)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=Me(o.suggestions.filter(P=>P.parameter==="placeholder").map(P=>P.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=ie(o.text,o.filterBase,a),l=qe(o.text,s,o.filterInProgress),d=o.suggestions.filter(P=>P.parameter!=="placeholder"),c=C(d[0])?void 0:d[0],u=_(o.activeFormatType),p=c&&!u?be(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&p.length>0)return!1;let f=p.filter(P=>P.is_tappable),g=c&&!u&&!this.callbacks.isWordOpen?.()?Ke(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,h=l.trim().length>0,S=i&&o.products.length>0;if(f.length>0&&!g&&h&&!S||At(o.text,o.completedParams.length,a))return!1;let{rawQuery:y,completedParams:m}=N(o.text,o.completedParams),b=y.length<o.lastRawQuery.length,x=Math.abs(y.length-o.lastRawQuery.length),T=n&&y!==o.lastRawQuery;return b||x>=e||T?(this.doFetch(y,m),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Ss="(hover: none) and (pointer: coarse)";var ys="[data-aia-dropdown], [data-aia-input-wrapper]",xs=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),Ht=class{constructor(e,n){this.store=e;this.container=n;this.listening=!1;this.declined=!1;this.pressOutside=!1;this.pressWhileFocused=!1;this.recheckTimer=null;this.releaseTimer=null;this.onPointerDown=e=>{let n=e.composedPath(),i=this.isInside(n);this.pressOutside=!i;let o=this.store.get();this.pressWhileFocused=o.isFocused,!(i||!o.isFocused)&&(this.declined=n.some(r=>r instanceof Element&&r.matches(xs)),this.declined&&o.dropdownHeld?this.store.set({dropdownHeld:!1}):!this.declined&&!o.dropdownHeld&&o.isDropdownOpen&&this.store.set({dropdownHeld:!0}))};this.onPointerCancel=()=>{this.pressOutside=!1,this.pressWhileFocused&&this.declined&&this.scheduleRecheck(),this.pressWhileFocused=!1};this.onPointerUp=e=>{let n=this.pressOutside&&!this.isInside(e.composedPath()),i=this.pressWhileFocused;if(this.pressOutside=!1,this.pressWhileFocused=!1,i){this.declined&&this.scheduleRecheck();return}!n||this.store.get().isFocused||(this.cancelRelease(),this.releaseTimer=setTimeout(()=>{this.releaseTimer=null;let o=this.store.get();o.dropdownHeld&&!o.isFocused&&this.store.set({dropdownHeld:!1})},150))};this.touchPrimary=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Ss):null,this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}sync(){let e=this.store.get(),n=this.touchPrimary?.matches??!1;e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.store.set({dropdownHeld:!1});let i=this.store.get();this.listen(n&&i.isDropdownOpen),i.isFocused&&this.cancelRelease()}listen(e){if(!(e===this.listening||typeof document>"u")){if(this.listening=e,e){document.addEventListener("pointerdown",this.onPointerDown,!0),document.addEventListener("pointerup",this.onPointerUp,!0),document.addEventListener("pointercancel",this.onPointerCancel,!0);return}document.removeEventListener("pointerdown",this.onPointerDown,!0),document.removeEventListener("pointerup",this.onPointerUp,!0),document.removeEventListener("pointercancel",this.onPointerCancel,!0),this.pressOutside=!1}}scheduleRecheck(){this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=setTimeout(()=>{this.recheckTimer=null,!(!this.declined||!this.store.get().isFocused)&&(this.declined=!1,this.sync())},150)}cancelRelease(){this.releaseTimer!==null&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}isInside(e){let n=this.container,i=n?.getRootNode(),o=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i.host:null;for(let r of e)if(r===n||r===o||r instanceof Element&&r.matches(ys))return!0;return!1}};var ke=["January","February","March","April","May","June","July","August","September","October","November","December"],Qe=["S","M","T","W","T","F","S"],Yo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Qo="aiaDate",Xo="aiaDay",zo=t=>String(t).padStart(2,"0");function V(t){return`${t.getFullYear()}-${zo(t.getMonth()+1)}-${zo(t.getDate())}`}function Ti(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ts(t){let e=Ti(t).getTime()-Ti(new Date).getTime();return Math.round(e/864e5)}function vi(t){let e=Ts(t);return e>=0&&e<7?Yo[t.getDay()]:ye(t)}function ye(t){return t.getFullYear()===new Date().getFullYear()?`${ke[t.getMonth()]} ${t.getDate()}`:`${ke[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function Xe(t){if(!t)return null;let e=Yo.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=Ti(new Date),l=(e-s.getDay()+7)%7;return new Date(s.getFullYear(),s.getMonth(),s.getDate()+l)}let n=/^\s*([A-Za-z]+)\s+(\d{1,2})(?:\s+(\d{4}))?\s*$/.exec(t);if(!n)return null;let i=ke.findIndex(s=>s.toLowerCase()===n[1].toLowerCase());if(i<0)return null;let o=Number(n[2]),r=n[3]?Number(n[3]):new Date().getFullYear(),a=new Date(r,i,o);return a.getMonth()!==i||a.getDate()!==o?null:a}function Ft(t){return`${ke[t.month]} ${t.year}`}function Ei(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function Jo(t){return{year:t.getFullYear(),month:t.getMonth()}}function Wt(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function jo(){return{text:"",is_tappable:!1,kind:null}}function Bt(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),i=[];for(let o=0;o<e;o++)i.push(jo());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:vi(r),is_tappable:!0,kind:null,metadata:{[Qo]:V(r),[Xo]:o}})}for(;i.length%Qe.length!==0;)i.push(jo());return i}function Ut(t){let e=Xe(t);return e?V(e):null}function G(t){let e=t?.metadata?.[Qo];return typeof e=="string"?e:null}function Vt(t){let e=t?.metadata?.[Xo];return typeof e=="number"?e:null}function vs(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function oe(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&vs(e)?e:t.ownerDocument??t}function Gt(t){return oe(t).activeElement??null}function R(t){return t.ownerDocument??t}function Es(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Zo(t){let e=oe(t);return!Es(e)||typeof e.getSelection=="function"?null:e}function er(t){let e=Zo(t);if(!e)return null;let n=R(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function tr(t,e){let n=t,i;try{i=n.getComposedRanges({shadowRoots:[e]})}catch{i=n.getComposedRanges(e)}return i.length>0?i[0]:null}function Je(t){let n=oe(t).getSelection?.();return n||(R(t).getSelection?.()??null)}function re(t){let e=Je(t);if(!e||e.rangeCount===0)return null;let n=er(t);if(n){let i=tr(e,n);return i?{node:i.startContainer,offset:i.startOffset,collapsed:i.startContainer===i.endContainer&&i.startOffset===i.endOffset}:null}return e.anchorNode?{node:e.anchorNode,offset:e.anchorOffset,collapsed:e.isCollapsed}:null}function xe(t){let e=Je(t);if(!e||e.rangeCount===0)return null;let n=er(t);if(!n)return e.getRangeAt(0);let i=tr(e,n);if(!i)return null;let o=R(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function Ze(t,e,n){let i=Je(t);if(!i)return null;if(Zo(t))return i.collapse(e,n),i;let o=R(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function $t(t,e){let n=t?oe(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var qt=2,Ps="magicx-aia";function nr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function ws(t){let e=R(t),n=e.defaultView;if(!n?.getComputedStyle)return null;let i=t;for(;i&&i!==e.body&&i!==e.documentElement;){let o=i.scrollWidth>i.clientWidth,r=i.scrollHeight>i.clientHeight;if(o||r){let a=n.getComputedStyle(i);if(o&&nr(a.overflowX)||r&&nr(a.overflowY))return i}if(i.classList.contains(Ps))return null;i=i.parentElement}return null}function Kt(t){let e=xe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=ws(t);if(!n||typeof e.getBoundingClientRect!="function")return;let i=e.getBoundingClientRect();if(i.height===0)return;let o=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let r=o.left+n.clientLeft,a=r+n.clientWidth;i.right>a?n.scrollLeft+=i.right-a+qt:i.left<r&&(n.scrollLeft-=r-i.left+qt)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+qt:i.top<r&&(n.scrollTop-=r-i.top+qt)}}var or='[contenteditable="false"]',wi="strong[data-param-id]",Re;function Cs(){if(Re!==void 0)return Re;let t=globalThis.Intl.Segmenter;if(!t)return Re=null,null;try{Re=new t(void 0,{granularity:"grapheme"})}catch{Re=null}return Re??null}function zt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(or))return!0;n=n.parentNode}return!1}function jt(t){return R(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return zt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function et(t){let e=jt(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Yt(t){let e=jt(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function $(t){let e=re(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(zt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Ci(o.childNodes[a],t);return r+Pi(o,t)}return n.nodeType!==Node.TEXT_NODE||zt(n,t)?null:Pi(n,t)+i}function Ci(t,e){if(t.nodeType===Node.TEXT_NODE)return zt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(or))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Ci(o,e);return i}function Pi(t,e){let n=jt(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function H(t,e){let n=R(t),i=Math.max(0,Math.min(e,Yt(t))),o=jt(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let p=o.nextNode();p?(a=p,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),Ze(t,c.startContainer,c.startOffset)&&(Ls(t,c,i),Kt(t))}function ir(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(wi)??null;return i&&e.contains(i)?i:null}function Ls(t,e,n){let i=ir(re(t)?.node??null,t);if(i&&i!==ir(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function rr(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=$(t);return i!==null&&n===`${i}:${e}`}function ar(t){return oe(t).activeElement===t}function Qt(t,e){if(!e||e.nodeType===void 0)return null;let n=e,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(wi);if(!o||!t.contains(o))return null;let r=re(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function Xt(t,e){let n=null;for(let a of t.querySelectorAll(wi))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=Pi(n,t),o=i+Ci(n,t),r=$(t);r!=null&&r>=i&&r<=o||H(t,i)}function Jt(t){let e=$(t);return e==null?!1:e>=Yt(t)}function Zt(t,e){if(e<=0)return 0;let n=Cs();if(!n)return e-1;let i=t.slice(0,e),o=0;for(let{index:r}of n.segment(i))r<e&&(o=r);return o}var Li="aiaTime",nn=5;var Ii=[12,1,2,3,4,5,6,7,8,9,10,11],Ai=Array.from({length:60/5},(t,e)=>e*5),Oi=["AM","PM"];function De(t){return(Math.round(t)%1440+1440)%1440}function Mi(t){let e=De(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function en(t){let e=t.hour%12+(t.period==="PM"?12:0);return De(e*60+t.minute)}function tt(t){let{hour:e,minute:n,period:i}=Mi(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function ki(t){let e=De(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function _e(t){return De(Math.round(t/5)*5)}function sr(t,e){return De(t+e)}var Is=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,As=/^(\d{1,2}):(\d{2})$/;function tn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Is.exec(e);if(n){let o=Number(n[1]),r=n[2]===void 0?0:Number(n[2]);return o<1||o>12||r>59?null:en({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=As.exec(e);if(i){let o=Number(i[1]),r=Number(i[2]);return o>23||r>59?null:o*60+r}return null}function lr(t){let e=tn(t.editingText);if(e!=null)return _e(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>tn(o.text)).filter(o=>o!=null);if(n.length>0)return _e(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return De((i.getHours()+1)*60)}function on(t){return{text:tt(t),is_tappable:!0,kind:null,metadata:{[Li]:ki(t)}}}var nt=30,it=["hour","minute","period"],Ri={hour:Ii.map(t=>({label:String(t)})),minute:Ai.map(t=>({label:String(t).padStart(2,"0")})),period:Oi.map(t=>({label:t}))};function rn(t){return Ri[t]}function ot(t,e){let n=Mi(_e(e));return t==="hour"?Ii.indexOf(n.hour):t==="minute"?Ai.indexOf(n.minute):Oi.indexOf(n.period)}function rt(t,e,n){let i=Ri[t],o=Math.min(Math.max(n,0),i.length-1),r=Mi(_e(e));return en(t==="hour"?{...r,hour:Ii[o]}:t==="minute"?{...r,minute:Ai[o]}:{...r,period:Oi[o]})}function an(t,e){let n=Ri[t].length-1;return Math.min(Math.max(Math.round(e/nt),0),n)}function ae(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:Oe(r,n),identified_params:Ae(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function sn(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?Jt(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function _i(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?$(t):null}var ln=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=sn(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(e.preventDefault(),l.length===0)return;if(k(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let g=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===g){this.store.set({activeDropdownIndex:-1});break}}let p=l.indexOf(n.activeDropdownIndex),f=p<l.length-1?p+1:0;this.store.set({activeDropdownIndex:l[f]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let p=sn(e.target,n),f=!!n.editingParam;if(!p&&!f)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let p=n.activeDropdownIndex+1;p<n.filteredOptions.length&&n.filteredOptions[p]?.is_tappable&&this.store.set({activeDropdownIndex:p})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,p=n.editingTail;this.ctx.exitEditMode?.(),H(u,p);break}sn(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=_i(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),H(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=_i(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=_i(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r);else if(s){this.ctx.endTypedWord?.(!0);let c=this.store.get();s(ae(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((f,g)=>f.is_tappable?g:-1).filter(f=>f!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let f=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:f});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),p;if(u<0)p=e.shiftKey?c.length-1:0;else{let f=e.shiftKey?-1:1;p=(u+f+c.length)%c.length}this.store.set({activeDropdownIndex:c[p]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),H(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let i=n.timeView;if(n.activeFormatType!=="time"||!i||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!sn(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){if(e.dateFloor){let a=e.filteredOptions.findIndex(s=>G(s)===e.dateFloor);if(a>=0)return a}let i=V(new Date),o=e.filteredOptions.findIndex(a=>G(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=$t(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=$t(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let a=r.split(" ").filter(Boolean).length;if(a>0)return a}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=$t(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var cn=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(_(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},query:e.optionQuery}:null;let i=e.actionableSuggestions[0];return!i||!this.hasOverride(i.parameter)?null:{mode:"pill",key:i,parameter:i.parameter,suggestion:i,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],i=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let o=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:o};let r;try{r=n(e.query,o.signal,e.suggestion)}catch(a){this.logOnce(a),this.commit(e,[],i);return}if(Array.isArray(r)){this.commit(e,r,i);return}this.setSearch(e,"loading"),this.await(e,r,o.signal,i)}async await(e,n,i,o){let r;try{let a=await n;if(i.aborted||o!==this.version)return;r=Array.isArray(a)?a:[]}catch(a){if(i.aborted||o!==this.version||Os(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=No(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let a={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(s=>({editingParam:s.editingParam&&s.editingParam.id===e.key?{...s.editingParam,options:o}:s.editingParam,optionSearch:a}));else{let s={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(l=>({suggestions:l.suggestions.map(d=>d===e.suggestion?s:d),optionSearch:a}))}o.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function Os(t){return t instanceof Error&&t.name==="AbortError"}var dn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(C(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var Di="/products/",cr="https://relative.invalid";function Ms(t){if(!t)return;let e;try{e=new URL(t,`${cr}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===cr?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function Ni(t,e){let n=Ms(t.item_url)??Rs(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:dr(t.price,t.currency,e)},...ks(t)&&{compareAtPrice:dr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function ks(t){if(!t.price||!t.compare_at_price)return!1;let e=Number(t.price),n=Number(t.compare_at_price);return Number.isFinite(e)&&Number.isFinite(n)&&n>e}function dr(t,e,n){if(n===void 0||!e||!/^\d+(\.\d+)?$/.test(t))return t;try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).format(Number(t))}catch{return t}}function Rs(t){if(!t.handle)return;let e=`${Di}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function un(t,e){return(t?.items.matched??[]).map(n=>Ni(n,e))}var mn=class{constructor(e,n,i=()=>!0,o=()=>{},r=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=i;this.getLanguage=o;this.getMapper=r;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=un(e,ne(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||_s(a)||(this.logOnce(a),r()))return;this.clear(i)}}owns(e){return this.isEnabled()&&this.getConfig()===e}resync(){let e=this.forResponse(this.store.get().customFields);this.commit(e??[])}refresh(){if(this.getConfig())return;let e=this.forResponse(this.store.get().customFields);e!==void 0&&this.commit(e)}clear(e){e()&&this.commit([])}commit(e){e.length===0&&this.store.get().products.length===0||this.store.set({products:e})}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function _s(t){return t instanceof Error&&t.name==="AbortError"}function Ds(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function ur(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:ke.findIndex(n=>n.toLowerCase().startsWith(e))}function Ns(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}function mr(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Ne(t,e={}){if(!t)return null;let n=e.today??new Date,i=Ds(t.trim().toLowerCase()).replace(/\s+/g," "),o=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i);if(o){let l=mr(Number(o[1]),Number(o[2])-1,Number(o[3]));return l?V(l):null}let r=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(i);if(r){let l=ur(r[1]);if(l>=0)return pn(l,Number(r[2]),r[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(i);if(a){let l=ur(a[2]);if(l>=0)return pn(l,Number(a[1]),a[3],n)}let s=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(i);if(s){let l=Number(s[1]),d=Number(s[2]);return l>12&&d<=12?pn(d-1,l,s[3],n):d>12&&l<=12?pn(l-1,d,s[3],n):null}return null}function pn(t,e,n,i){if(n){if(n.length!==4)return null;let r=mr(Number(n),t,e);return r?V(r):null}let o=Ns(t,e,i);return o?V(o):null}var Hs=/^\d{4}-\d{2}-\d{2}$/;function Hi(t){return typeof t=="string"&&Hs.test(t)?t:null}function gn(t,e={}){return Hi(t.isoDate)??Ne(t.text,e)}function fn(t){let e=Hi(t.isoDate);return e?{start:e,end:Hi(t.isoDateEnd)}:null}var Wi=" - ",hn="aiaDateRangeStart",bn="aiaDateRangeEnd";function at(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Fi=/^\d{4}-\d{2}-\d{2}$/;function pr(t){if(!Fi.test(t))return null;let[e,n,i]=t.split("-").map(Number),o=new Date(e,n-1,i);return o.getMonth()===n-1&&o.getDate()===i?o:null}var Fs=/\s+(?:to|through|thru|until|til|till)\s+/g,Ws=/[-–—]/g;function Bs(t){let e=[];for(let n of[Fs,Ws]){n.lastIndex=0;let i=n.exec(t);for(;i!==null;)e.push([t.slice(0,i.index),t.slice(i.index+i[0].length)]),i=n.exec(t)}return e}function st(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of Bs(t.trim())){let a=Ne(o.trim(),e);if(!a)continue;let s=Ne(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Bi(t){let e=pr(t.start),n=pr(t.end);return!e||!n?"":t.start===t.end?ye(e):`${ye(e)}${Wi}${ye(n)}`}function gr(t,e){let n=at(t,e);return{text:Bi(n),is_tappable:!0,kind:null,metadata:{[hn]:n.start,[bn]:n.end}}}function He(t,e={}){let n=t?.metadata?.[hn],i=t?.metadata?.[bn];return typeof n=="string"&&typeof i=="string"&&Fi.test(n)&&Fi.test(i)?at(n,i):st(t?.text,e)}var lt="(max-width: 768px)";var Us="var(--aia-option-row-height, 25.9px)",Vs="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function Vi(t,e){return e?Ui(1,Math.min(t,5)):Ui(1,Math.min(t,4))}function Ui(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${Us} + ${Vs})`}}function yn(t,e){return!e&&t>=5}function xn(t,e,n,i){if(!(!e&&t>=5&&Gs(n,i))){let a=Vi(t,e);return{...a,template:Sn(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Ui(2,3),template:Sn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function Gs(t,e){return!t||t.length===0||e==null||e<=0||t.some(i=>i<=0)?!1:Math.ceil(Math.max(...t))*2<=e}function Tn(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let a of e){let s=a.cloneNode(!0);s.removeAttribute("id"),s.removeAttribute("role"),s.removeAttribute("aria-selected"),s.style.whiteSpace="nowrap",s.style.width="max-content",n.appendChild(s)}t.appendChild(n);let i=Array.from(n.children).map(a=>a.offsetWidth);n.remove();let o=getComputedStyle(t),r=t.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0)-(Number.parseFloat(o.columnGap)||0);return{rowWidths:i,gridWidth:r}}function Sn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function vn(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(lt).matches}function En(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function fr(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,a=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let s=i?t.isFocused||t.dropdownHeld:!0;return a&&s}if(n==="auto"){let s=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&d}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function B(t){if(t.editingIdentified){let{parameter:n,anchor:i}=t.editingIdentified;return`identified:${n}@${i}`}return t.editingParam!=null&&t.editingAnchor!=null?`edit:${t.editingParam?.id}`:`pill:${t.actionableSuggestions[0]?.parameter??""}`}function Gi(t){if(!t)return Ei();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function $s(t){let e=Xe(t);return e?Jo(e):Ei()}function qs(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=fn(n);if(i&&i.end==null)return i.start}return null}function hr(t,e){let n=Go(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(A=>A.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(A=>A.parameter==="placeholder").map(A=>A.text).join(" "),a=Me(r,e.prependPlaceholder),s=ie(t.text,Math.min(t.filterBase,t.text.length),a),d=s===0&&At(t.text,t.completedParams.length,a)?"":qe(t.text,s,t.filterInProgress),c=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,p=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",f,g,h,S;if(u&&t.editingParam&&t.editingAnchor!=null){let A=t.editingParam.id,F=t.completedParams.some(Qa=>Qa.id===A),Ie=t.caretOffset??t.editingAnchor,St=F?"":t.text.slice(t.editingAnchor,Ie);g=St.trim(),h=t.editingParam.options,S=t.editingParam.suggestionParameter,f=be(t.editingParam.options,St)}else g=d.trim(),h=c,S=o?.parameter,f=C(o)?c.map(A=>({...A,matchedText:t.text.slice(Se(t.text,t.completedParams)),parameterLabel:Ho(A.parameter)})):be(c,d,t.traditionalAutocomplete);let y=t.optionSearch,m=y!=null&&S!=null&&y.parameter===S;m&&y.status==="done"&&y.query===g&&(f=h);let b=m&&y.status==="loading",x=e.showNonTappableOptions===!1;x&&(f=f.filter(A=>A.is_tappable));let T=u?g:t.text.slice(Se(t.text,t.completedParams)),P=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":C(o);!p&&!P&&(f=Ro(f,T));let I=t.editingIdentified,E=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,w=I?I.format:j(E),D=u?t.editingParam?.suggestionParameter:o?.parameter,M=w==="location"&&D&&e.optionOverrides?.[D]?"options":w,Le=u&&M==="date-range"?He(t.editingParam):null,L=!u&&!I&&M==="date"?qs(o?.parameter,t.identifiedParams):null,U=null,ge=null;if(k(M)){let A=B({...t,actionableSuggestions:i}),F=t.dateViewMonth;U=F&&F.key===A?{year:F.year,month:F.month}:I?Gi(I.iso):Le?Gi(Le.start):L?Gi(L):$s(t.editingParam?.text),f=Bt(U);let Ie=t.pendingRangeStart;M==="date-range"&&Ie&&Ie.key===A&&(ge=Ie.iso)}let z=null;if(M==="time"){let A=B({...t,actionableSuggestions:i}),F=t.timeDraft;z=F&&F.key===A?{minutes:F.minutes,touched:!0}:{minutes:lr({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},f=[]}let v=null;if(M==="location"){let A=B({...t,actionableSuggestions:i}),F=t.locationSearch;if(F&&F.key===A){let{key:Ie,...St}=F;v=St}else v={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};f=[]}let fe=A=>x?A.is_tappable:!0,he;if(u){let A=t.editingParam?.options??[];he=t.editingParam!=null&&A.filter(fe).length===0}else he=o!=null&&c.filter(fe).length===0;z&&(he=!0),v&&(he=!0);let ht=fr({inEditMode:u||I!=null,filteredOptionsLength:f.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||b,pillTapped:t.pillTapped,activePillHasNoOptions:he,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),bt=ht&&t.activeDropdownIndex>=0&&!!f[t.activeDropdownIndex]?.is_tappable,fi=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,K=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||b||fi,To=K&&t.skeletonOptions!==null,ja=To&&t.skeletonOptions?t.skeletonOptions:f,Ya=To?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:f,dropdownLoading:K,dropdownOptions:ja,dropdownSuggestion:Ya,skeletonExiting:fi,activeFormatType:M,dateView:U,dateRangeStart:ge,dateFloor:L,timeView:z,multiSelectView:p?{picked:t.multiSelectDraft?.key===B({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:v,placeholderText:r,leadInText:a,optionQuery:g,isSearchingOptions:b,isDropdownOpen:ht,isActivePillSelected:bt}}function Pn(t){return t.mode!=="edit"?zs(t):js(t)}function Ks(t,e,n){let i=t.find(C);if(!i?.options)return null;let o=e.slice(Se(e,n)).trim().toLowerCase();if(!o)return null;let r=i.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===o);if(new Set(r.map(l=>X(l,i.parameter))).size!==1)return null;let s=r[0];return{suggestion:i,option:s,matchText:s.text.trim()}}function br(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!C(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=ie(e,i,Me(s,t.prependPlaceholder)),d=Ke(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function zs(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?br(t):null)??Ks(i,e,n):br(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,p=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,h={id:crypto.randomUUID(),placeholder:"",parameter:X(a,r.parameter),text:p,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&C(r)?ze(X(a,r.parameter)):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,h],suggestions:i.filter(S=>S!==r),filterBase:g,newParamId:h.id,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:a,suggestion:r}}function js(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(b=>b.id===i.id))return null;let a=e.slice(o,r),s=It(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,p=e.slice(c,u),f=u<e.length&&e[u]===" "?u+1:u,g=e.length,h={id:crypto.randomUUID(),placeholder:"",...Ot(i,s),text:p,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},S=n.length,y=0;for(let b=0;b<n.length;b++){let x=Z(e,n[b].text,y);if(x!==-1){if(x>=f){S=b;break}y=x+n[b].text.length}}let m=[...n];return m.splice(S,0,h),{patch:{text:e,completedParams:m,newParamId:h.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:s}}function qi(t){return t.slice(t.search(/\S*$/))}function Sr(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function yr(t,e){let n="",i=0;for(let o of t){if(n+=Sr(o),i+=o.length,n.length>=e.length)return n.startsWith(e)?i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function $i(t){return[...t].map(Sr).join("")}function ct(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map($i),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:$i(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),a=r[o-1];for(let s=0;s+o<=i.length;s++){if(!r.slice(0,-1).every((u,p)=>i[s+p].folded===u))continue;let d=i[s+o-1],c=yr(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function wn(t,e){let n=e?ct(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?qi(e):"",o=$i(i);if(!o)return[{text:t,bold:!1}];let r=[];for(let a of t.split(/(\s+)/)){if(a==="")continue;let s=/^\s/.test(a)?0:yr(a,o);s>0&&r.push({text:a.slice(0,s),bold:!0});let l=s>0?a.slice(s):a;l&&r.push({text:l,bold:!1})}return r}var Ys=6e4;function Qs(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function Xs(t){return(t??Y).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function Js(t){return Ge(t)?`Bearer ${await Tt(t).getToken()}`:Et(t)}async function xr(t){try{let e=Xs(t.apiConfig?.endpoint),n=vt(t.apiConfig),i=await Js(t.apiConfig);i&&(n.Authorization=i);let o=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.requestId&&{request_id:t.requestId},type:t.type,...t.language&&{language:t.language},at:new Date().toISOString(),query_data:t.queryData});await fetch(e,{method:"POST",headers:n,body:o,...t.keepalive&&Qs(o)<=Ys&&{keepalive:!0}})}catch{}}function se(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Ki=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function Zs(t,e,n){let i=Ki(t??"");if(i.length===0)return"";let r=Ki(e).slice(-i.length),a=Ki(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Tr(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=C(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:X(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(Se(t.text,t.completedParams),s.length),u=!1;if(i){let E=[...s.slice(c).matchAll(/\S+/g)],w=ct(e.text,s.slice(c)),D=E[E.length-(w?.typedWords??1)];s=s.slice(0,D?c+(D.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let E=[...s.slice(c).matchAll(/\S+/g)],w=E[E.length-1];s=s.slice(0,w?c+(w.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let E=Mo(s.slice(c),e.text);E>0&&(s=s.slice(0,s.length-E)),u=E>0}let p=s.length>0&&s[s.length-1]!==" ",f=i||n.completes_word===!0||u,g=t.activeFormatType!==void 0&&!_(t.activeFormatType)&&_(j({type:n.type})),h=f||g?"":Zs(n.lead_in,s,e.text),S=`${s}${p?" ":""}${h?`${h} `:""}${e.text} `,m=(l||d||i&&s.length===0)&&S.length>0?S[0].toUpperCase()+S.slice(1):S,b=m.toLowerCase().lastIndexOf(e.text.toLowerCase()),x=b>=0?m.slice(b,b+e.text.length):e.text,T=i?ze(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},P={id:crypto.randomUUID(),placeholder:"",...T,text:x,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},I=t.actionableSuggestions.length-1;return{patch:{text:m,filterBase:m.length,completedParams:[...t.completedParams,P],newParamId:P.id,caretOffset:m.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(E=>E.text!==e.text).map(E=>E.text),key:i?r:n.parameter,position:se(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:I}}function Cn(t){let e=_(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,n=t.editingParam,i=n?{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:e,skeletonSuggestion:e?i:null,skeletonRequested:!1}}function Ln(t,e,n){let i=t.slice(0,e),o=t.slice(n),r=(i===""||i.endsWith(" "))&&o.startsWith(" ");return r&&(o=o.slice(1)),{text:i+o,removed:n-e+(r?1:0)}}var In=class{constructor(e){this.deps=e}start(e){let n=this.deps.store.get();if(n.editingParam?.id===e)return;let i=n.completedParams.find(a=>a.id===e);if(!i)return;let o=0,r=-1;for(let a of n.completedParams){let s=Z(n.text,a.text,o);if(s!==-1){if(a.id===e){r=s;break}o=s+a.text.length}}r<0||this.deps.store.set({editingParam:i,editingAnchor:r,editingTail:r+i.text.length,caretOffset:r+i.text.length,activeDropdownIndex:-1,editingIdentified:null})}exit(){this.deps.store.get().editingParam&&this.deps.store.set({editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1})}replaceRange(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null||!n.completedParams.some(l=>l.id===i.id))return!1;let{text:a}=e===""?Ln(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(d=>d.id!==i.id),editingTail:s,caretOffset:s,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(s),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),i={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(i.editingParam=null,i.editingAnchor=null,i.editingTail=null,i.activeDropdownIndex=-1):n.editingTail!=null&&(i.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(i),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null)return;let a=Ot(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(m=>m.text!==e.text).map(m=>m.text),key:a.suggestionParameter,position:se(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,p=s+u+l,f=p.length,g={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},h=n.completedParams.findIndex(m=>m.id===i.id),S=n.completedParams.filter(m=>m.id!==i.id),y=h>=0?Math.min(h,S.length):S.length;S.splice(y,0,g),this.deps.store.set({text:p,completedParams:S,newParamId:g.id,filterBase:f,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:f,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...Cn(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(f),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=Pn({mode:"edit",text:e.text,completedParams:e.completedParams,editingParam:e.editingParam,editingAnchor:e.editingAnchor,editingTail:e.editingTail});n&&(this.deps.store.set(n.patch),this.deps.scheduleSetCursor(n.caretPos))}};var Er=33,Pr=70,wr=120,Cr=50,Te="data-aia-placeholder-leaving",Fe=new WeakMap;function An(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function el(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Lr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Ir(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Lr(t,e,e.shown+1),e.shown>=e.target.length))return;let n=e.target[e.shown-1],i=n===" "||n==="-"?70:0;e.timer=setTimeout(()=>Ir(t,e),33+i)}function vr(t,e){Lr(t,e,0),e.timer=setTimeout(()=>Ir(t,e),33)}function Ar(t,e){let n=Fe.get(t);if(e===""){n&&(An(n),Fe.delete(t)),t.removeAttribute(Te),delete t.dataset.placeholder;return}if(n?.target===e)return;if(el(t)){n&&An(n),t.removeAttribute(Te),Fe.set(t,{target:e,shown:e.length,timer:null}),t.dataset.placeholder=e;return}let i={target:e,shown:0,timer:null},o=n&&n.shown>0?n:null;if(n&&An(n),Fe.set(t,i),o){t.setAttribute(Te,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(Te),t.isConnected&&vr(t,i)},170);return}t.removeAttribute(Te),vr(t,i)}function Or(t){let e=Fe.get(t);e&&(An(e),Fe.delete(t))}var tl={selectedIso:null,selectedRange:null,rangeStart:null};function We(t){if(!k(t.activeFormatType))return tl;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?at(i,o):null,rangeStart:t.dateRangeStart}}let n=He(t.editingParam);return{selectedIso:n?null:Ut(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null}}function On(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?at(t.pendingStart,e??t.pendingStart):t.selected}function Mn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end;return{selected:o,inRange:r}}function kn(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function Rn(t,e){return t==="date"?e??null:null}var zi="https://ai-autocomplete.com";function _n(t=zi){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var Mr={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},nl={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},ji={en:Mr,es:nl,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure",locationSearch:"Dites un lieu",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora",locationSearch:"Di' un luogo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd",locationSearch:"Noem een locatie",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid",locationSearch:"S\xE4g en plats",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid",locationSearch:"Si et sted",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika",locationSearch:"Sano sijainti",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},il={pt:"pt-BR",no:"nb",nn:"nb"};function O(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return ji[o?"zh-TW":"zh-CN"]}let i=il[e]??e;return Object.prototype.hasOwnProperty.call(ji,i)?ji[i]:Mr}function Dn(t,e,n=O()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Nn(t){let e=a=>{a.ctrlKey||kr(a.target,t,a.deltaX,a.deltaY)||a.preventDefault()},n=0,i=0,o=a=>{let s=a.touches[0];s&&(n=s.clientX,i=s.clientY)},r=a=>{if(a.touches.length!==1)return;let s=a.touches[0],l=n-s.clientX,d=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!kr(a.target,t,l,d)&&a.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",o,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",r)}}function kr(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&ol(o,i)||n!==0&&rl(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var Rr=/^(auto|scroll|overlay)$/;function ol(t,e){return t.scrollHeight<=t.clientHeight||!Rr.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function rl(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!Rr.test(n.overflowX))return!1;let i=Math.abs(t.scrollLeft),o=t.scrollWidth-t.clientWidth;return(n.direction==="rtl"?e<0:e>0)?i<o-1:i>0}var _r=new WeakMap,Dr=new WeakSet;function W(t,e,n){if(_r.set(t,n),Dr.has(t))return;Dr.add(t);let i=()=>_r.get(t),o=r=>{if(!(r instanceof Element))return null;let a=r.closest(e.itemSelector);return a&&t.contains(a)?a:null};e.onClick&&t.addEventListener("click",r=>{let a=o(r.target);a&&e.onClick?.(a,i(),r)}),e.onEnter&&t.addEventListener("mouseenter",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onEnter?.(a,i())},!0),e.onLeave&&t.addEventListener("mouseleave",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onLeave?.(a,i())},!0),e.preventMousedown&&t.addEventListener("mousedown",r=>r.preventDefault())}function le(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function q(t){t.offsetWidth}var ce="magicx-aia-panel-ghost";function ve(t){return t.closest(`.${ce}`)!==null}function de(t,e){for(let n of t.querySelectorAll(e))if(!ve(n))return n;return null}var Hn="--aia-multi-done-fit";function Nr(t){return de(t,"[data-aia-multi-done]")}function Fn(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let a of t.querySelectorAll("[data-aia-option]")){if(ve(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,d=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=n.createRange();for(let u=d.nextNode();u;u=d.nextNode()){if(!u.textContent?.trim())continue;c.selectNodeContents(u);let p=c.getBoundingClientRect();if(p.width===0)continue;let f=i?o.right-p.left:p.right-o.left;r=Math.max(r,f+l)}}r>0?e.style.setProperty(Hn,`${Math.ceil(r)}px`):e.style.removeProperty(Hn)}var Hr=40,Fr=340,Wr=340,Br=7,Wn="--aia-option-enter-delay";function Bn(t,e,n,i="below"){let o=Math.max(1,Math.floor(e)),r=Math.floor(Math.max(0,t)/o);if(i!=="above")return r*40;let a=Math.max(1,Math.ceil(Math.max(0,n)/o));return Math.max(0,a-1-r)*40}function Un(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*40+340}var Qi="magicx-aia-scroll-arrow",dt="data-aia-scroll-arrow",Ee="data-aia-visible",Xi=1e3,Ji=160,Zi="--aia-scroll-arrow-bottom",Ur="Scroll down for more options",al="[data-aia-products-label]",sl=4,ll=8,cl=240;function dl(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||Yi(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-s)/cl),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function ul(t=document){let e="http://www.w3.org/2000/svg",n=t.createElementNS(e,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");let i=t.createElementNS(e,"path");return i.setAttribute("d","M4 6.5 8 10.5l4-4"),n.appendChild(i),n}function Vr(t=document,e=O()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=Qi,n.setAttribute(dt,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(ul(t)),n}function ml(t){let e=t.style.gridTemplateColumns.trim();return e?Math.max(1,e.split(/\s+/).length):1}function Yi(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Vn({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=m=>{if(m){if(n.hasAttribute(Ee))return;if(n.setAttribute(Ee,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),Yi(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Ee)&&(n.disabled=!1)},Xi)}else n.removeAttribute(Ee),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=m=>{let b=0,x=m;for(;x&&x!==t;)b+=x.offsetTop,x=x.offsetParent instanceof HTMLElement?x.offsetParent:null;return b},u=()=>{let m=de(t,al),b;if(m){let x=c(m)+m.offsetHeight/2;b=t.clientHeight-x-n.offsetHeight/2}else{let x=c(e),T=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;b=t.clientHeight-(x+e.offsetHeight)+(T>0?0:ll)}n.style.setProperty(Zi,`${Math.max(0,Math.round(b))}px`)},p=()=>{if(o||a!==null||s!==null)return;let m=e.querySelector("[data-aia-option][data-aia-loading]")!==null,b=e.scrollHeight-e.clientHeight-e.scrollTop;d(!m&&b>sl)},f=()=>{if(o)return;u();let m=e.getAttribute("data-aia-group")??"";if(m!==r){r=m,d(!1),a!==null&&clearTimeout(a);let b=e.querySelectorAll("[data-aia-option]").length,x=Yi(e)?0:Un(b,ml(e));a=setTimeout(()=>{a=null,p()},x);return}p()},g=()=>{o||a!==null||(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,p()},Ji))};e.addEventListener("scroll",g,{passive:!0});let h=m=>m.preventDefault(),S=()=>{let m=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,b=Math.max(1,e.clientHeight-m);dl(e,b,i,g)};n.addEventListener("mousedown",h),n.addEventListener("click",S);let y=null;return i&&typeof i.ResizeObserver=="function"&&(y=new i.ResizeObserver(()=>{u(),p()}),y.observe(e)),f(),{update:f,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",g),n.removeEventListener("mousedown",h),n.removeEventListener("click",S),y?.disconnect(),n.removeAttribute(Ee),n.setAttribute("aria-hidden","true"))}}}var Gr="cubic-bezier(0.25, 0.1, 0.25, 1)",pl="cubic-bezier(0.32, 0.72, 0, 1)",eo=360,to=280,no=320,io=40,$r="blur(2px)";function qr(t){return t.hasAttribute(dt)}var ee=new WeakMap;function gl(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function fl(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(ce)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function hl(t){let e=t.ownerDocument.createElement("div");e.className=ce,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(ce)||qr(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex"),n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function bl(t,e,n){for(let r of Array.from(t.children))r.classList.contains(ce)&&r.remove();let i=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0","right:0",n?"bottom:0":"top:0",`padding:${i.padding}`,"pointer-events:none","box-sizing:border-box"].join(";");let o=Array.from(t.children).filter(r=>!qr(r));t.appendChild(e),e.animate([{opacity:1,filter:"blur(0px)"},{opacity:0,filter:$r}],{duration:to,easing:Gr,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove());for(let r of o)r.animate([{opacity:0,filter:$r},{opacity:1,filter:"blur(0px)"}],{duration:no,delay:io,easing:Gr,fill:"backwards"})}function Gn(t){let e=t[0]?.text;return e==null||e===""?null:e}function ut(t,e,n){let i=n.visible,o=gl(t,n.enabled??!0),r=ee.get(t);if(!i||!o){o||r?.glide?.cancel(),ee.set(t,{height:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null});return}let a=fl(t,e);if(r&&r.height>0&&r.glide&&r.signature===a)return;let s=ue(t),l=t.getBoundingClientRect().height;r?.glide?.cancel();let d=t.getBoundingClientRect().height,c=null,u=r?s?l:r.height:0;if(r&&u>0&&(e!==r.key&&r.snapshot&&bl(t,r.snapshot,n.anchorBottom??!1),Math.abs(u-d)>1)){c=t.animate([{height:`${u}px`},{height:`${d}px`}],{duration:eo,easing:pl});let f=c;c.finished.then(()=>{let g=ee.get(t);g?.glide===f&&(g.glide=null)},()=>{})}let p=null;e!==null&&(p=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:hl(t)),ee.set(t,{height:d,key:e,signature:a,snapshot:p,glide:c})}function ue(t){let e=ee.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function $n(t){if(!ue(t))return null;let e=ee.get(t)?.height??0;return e>0?e:null}function qn(t,e){let n=ee.get(t);n&&n.height>0&&!ue(t)&&e>0&&(n.height=e)}function Kn(t){ee.get(t)?.glide?.cancel(),ee.delete(t)}var Kr="data-aia-key";function J(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(Kr);s!=null&&i.set(s,a)}let o=new Set,r=[];for(let a=0;a<e.length;a++){let s=e[a],l=n.keyOf(s,a);o.add(l);let d=i.get(l);d||(d=n.create(s,a),d.setAttribute(Kr,l)),n.update?.(d,s,a),t.children[a]!==d&&t.insertBefore(d,t.children[a]??null),r.push(d)}for(let[a,s]of i)o.has(a)||s.remove();return r}function zr(t,e){if(!e.interactive)return null;let n=e.options[le(t)];return n?.is_tappable?n:null}var Sl={itemSelector:"[data-aia-date-cell], [data-aia-date-prev], [data-aia-date-next]",onClick:(t,e)=>{if(t.hasAttribute("data-aia-date-prev")){e.callbacks.onPreviousMonth();return}if(t.hasAttribute("data-aia-date-next")){e.callbacks.onNextMonth();return}let n=zr(t,e);n&&(t.classList.add("magicx-aia-date-cell--pressed"),e.callbacks.onSelect(n),setTimeout(()=>t.classList.remove("magicx-aia-date-cell--pressed"),170))},onEnter:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&zr(t,e)&&e.callbacks.onHighlight(le(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,le(t))}};function Yr(t,e,n,i,o,r,a,s=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!o||e.length===0){l?.remove();return}if(!l){l=Tl(),t.appendChild(l),q(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}W(l,Sl,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Ft(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&yl(c,e,n,i,r)}function yl(t,e,n,i,o){let r=V(new Date),a=On({pendingStart:o.rangeStart,highlightedIso:G(e[n]),selected:o.selectedRange,floor:o.floor});J(t,e,{keyOf:(s,l)=>G(s)??`pad-${l}`,create:s=>xl(s),update:(s,l,d)=>{let c=G(l),u=Mn(c,{selectedIso:o.selectedIso,range:a}),p=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(p)),s.classList.toggle("magicx-aia-date-cell--past",kn(c,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",p),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function xl(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=Vt(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function Tl(){let t=document.createElement("div");t.className="magicx-aia-datepicker",t.setAttribute("data-aia-datepicker","");let e=document.createElement("div");e.className="magicx-aia-datepicker-header";let n=document.createElement("span");n.className="magicx-aia-datepicker-month",n.setAttribute("data-aia-date-month",""),n.setAttribute("aria-live","polite"),e.append(jr("prev","Previous month","\u2039"),n,jr("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of Qe){let a=document.createElement("span");a.className="magicx-aia-datepicker-weekday",a.textContent=r,i.appendChild(a)}let o=document.createElement("div");return o.className="magicx-aia-datepicker-grid",o.setAttribute("data-aia-date-grid",""),t.append(e,i,o),t}function jr(t,e,n){let i=document.createElement("button");return i.type="button",i.tabIndex=-1,i.className="magicx-aia-datepicker-nav",i.setAttribute(`data-aia-date-${t}`,""),i.setAttribute("aria-label",e),i.textContent=n,i.disabled=!0,i}var vl='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/></svg>',Qr="data-aia-location-body";function El(t){let e=document.createElement("div");e.className="magicx-aia-location-row",e.setAttribute("data-aia-location-row",""),e.setAttribute("role","option");let n=document.createElement("span");n.className="magicx-aia-location-pin",n.innerHTML=vl;let i=document.createElement("span");i.className="magicx-aia-location-text";let o=document.createElement("span");if(o.className="magicx-aia-location-name",o.textContent=t.name,i.appendChild(o),t.secondary){let r=document.createElement("span");r.className="magicx-aia-location-secondary",r.textContent=t.secondary,i.appendChild(r)}return e.append(n,i),e}function Pl(t,e){if(t==="loading"){let o=document.createElement("div");o.className="magicx-aia-location-loading",o.setAttribute("data-aia-location-loading","");for(let r=0;r<3;r++)o.appendChild(document.createElement("span")).className="magicx-aia-location-loading-bar";return o}if(t==="")return null;let n=document.createElement("div");if(n.className="magicx-aia-location-note",n.setAttribute("data-aia-location-note",""),t==="note-empty"){let o=document.createElement("span");o.className="magicx-aia-location-empty",o.textContent=e.locationNoResults,n.appendChild(o)}let i=document.createElement("span");return i.textContent=e.locationUseTyped,n.appendChild(i),n}function Xr(t,e,n,i){let o=e.places,r="";if(o.length===0&&(e.status==="loading"?r="loading":e.query.trim()&&(r=e.status==="done"?"note-empty":"note")),t.getAttribute(Qr)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=Pl(r,n);a&&t.appendChild(a),t.setAttribute(Qr,r)}J(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>El(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var te=new WeakMap,wl=0,Pe=new WeakMap,Cl='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>',we=t=>Gt(t.input)===t.input;function Jr(t,e){let n=Gt(t);if(n instanceof HTMLElement&&n!==e.input&&n!==R(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=xe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Ll(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==R(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=xe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Il(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=Je(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=R(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var Al={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Be(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Be(t,e=!1){let n=Pe.get(t),i=te.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&we(n)&&(n.returning=!0,Il(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function Ol(t){let e=Pe.get(t),n=te.get(t);if(!(!e||!n||we(e))){if(Jr(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!we(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function Ml(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++wl}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Cl;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1,wasReediting:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),Jr(t,r),te.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>te.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{Ll(t,r,a.relatedTarget),te.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,te.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=te.get(t);if(!(!s||a.isComposing))switch(a.key){case"ArrowDown":case"ArrowUp":a.preventDefault(),s.callbacks.onLocationMove(a.key==="ArrowDown"?1:-1);return;case"Enter":if(a.preventDefault(),!s.interactive)return;Be(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Be(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Be(t);return}}),Pe.set(t,r),r}function Zr(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=Pe.get(e);n&&(we(n)&&Be(e),n.declined=!1,n.input.tabIndex=-1)}}function ea(t,e,n,i,o={}){let r=Array.from(t.children).find(l=>l.hasAttribute("data-aia-location"))??null;if(!e){if(r){let l=Pe.get(r);l&&we(l)&&Be(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=Pe.get(r)??Ml(r,n);a.input.tabIndex=0,te.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),W(a.results,Al,te.get(r)),a.input.value!==e.query&&!we(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(Xr(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),o.inputFocused){let l=o.reediting??!1;l&&!a.wasReediting&&(a.declined=!1),a.wasReediting=l}if(a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!a.declined&&o.interactive!==!1&&!we(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!Pe.get(l)?.declined&&Ol(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&Gt(d)===d||(l.declined=!1)},0)}}var kl={itemSelector:"[data-aia-pill]",onClick:(t,e)=>{if(e.loading||t.disabled)return;let n=Number.parseInt(t.dataset.aiaPillIndex??"-1",10);n>=0&&e.onSelectPill(n)},preventMousedown:!0},ta=[125,69];function na(t,e){return e?1:t===0?.7:t===1?.4:.2}function zn(t,e,n,i,o=!1,r=!1,a=!1){let s=t.querySelector(".magicx-aia-pill-list");if(s||(s=document.createElement("span"),s.className="magicx-aia-pill-list",t.appendChild(s)),W(s,kl,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<ta.length;l++){let d=ta[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.setProperty("--aia-pill-opacity",String(na(l,!1))),s.appendChild(c)}return}r?s.setAttribute("data-aia-pill-list-loading",""):s.removeAttribute("data-aia-pill-list-loading");for(let l of s.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();J(s,e,{keyOf:l=>`${l.type?.kind??""}|${je(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),je(l)){d.setAttribute("data-aia-smart-suggestion",C(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Rt,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,p=a&&c===n&&!r,f=["magicx-aia-pill"];o&&f.push("magicx-aia-pill--rounded"),r&&f.push("magicx-aia-pill--skeleton"),u.className=f.join(" "),u.style.width="",u.style.setProperty("--aia-pill-opacity",String(na(c,p))),u.dataset.aiaPillIndex=String(c),u.toggleAttribute("data-aia-pill-active",c===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),q(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function oo(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var ia=32;function ro(t,e){if(e.ctrlKey)return null;let n=e.deltaY||0,i=e.deltaX||0;if(!n||Math.abs(i)>=Math.abs(n))return null;let o=t.scrollWidth-t.clientWidth;if(o<=1)return null;let r=t.scrollLeft,a=n;return e.deltaMode===1?a*=32:e.deltaMode===2&&(a*=t.clientWidth),Math.max(0,Math.min(o,r+a))}function jn(t){let e=n=>{let i=ro(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var oa=Intl.Segmenter,ra=oa?new oa(void 0,{granularity:"grapheme"}):null;function Yn(t){let e=t.trim().normalize("NFC").toUpperCase();if(ra)for(let n of ra.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Qn=120,aa=360;function Rl(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function ao(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=Rl(n);return i?(n.searchParams.set("width",String(e)),i.format&&n.searchParams.set("format",i.format),t.startsWith("/")&&!t.startsWith("//")?`${n.pathname}${n.search}${n.hash}`:n.href):t}function so(t,e){let n=ao(t,e);return n===t?[t]:[n,t]}function Xn(t,e){if(!(t>0)||!(e>0))return null;let n=t/e,i=o=>Math.round(o*1e3)/1e3;return{x:i(Math.min(n,1)),y:i(Math.min(1/n,1))}}function mt(t){let e=t?.trim();return e?so(e,360):[]}function sa(t){return mt(t)[0]}var Jn=new WeakMap,co=new WeakMap,ca=new WeakMap;function da(t,e,n,i,o,r="row",a="image",s=O(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let p=document.createElement("div");p.className="magicx-aia-products-label",p.id=`${n}-products-label`,p.setAttribute("data-aia-products-label",""),p.textContent=s.products;let f=document.createElement("div");f.className="magicx-aia-products-row",f.setAttribute("data-aia-products-row",""),jn(f),d.append(p,f),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){J(u,e,{keyOf:p=>Hl(p,!!l),create:p=>Fl(p,i,o,a,s,l),update:(p,f,g)=>{Jn.set(p,f),_l(p,f.price,f.compareAtPrice),p.id=`${n}-product-${g}`,p.dataset.aiaIndex=String(g),ca.get(p)?.(a);let h=p.querySelector(".magicx-aia-product-badge");h&&h.textContent!==s.soldOut&&(h.textContent=s.soldOut);let S=p.querySelector(".magicx-aia-product-cart");S&&S.setAttribute("aria-label",ua(f,s))}}),q(u);for(let p of u.querySelectorAll("[data-aia-product]")){let f=co.get(p);f&&(co.delete(p),f())}}}function uo(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)ve(i)||(i.tabIndex=e?0:-1)}function _l(t,e,n){let i=t.querySelector(".magicx-aia-product-price");if(!e){i?.remove();return}i||(i=document.createElement("span"),i.className="magicx-aia-product-price",i.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(i));let o=i.firstChild;o.data!==e&&(o.data=e);let r=i.querySelector(".magicx-aia-product-compare-at");if(!n){r?.remove();return}r||(r=document.createElement("s"),r.className="magicx-aia-product-compare-at",i.append(r)),r.textContent!==n&&(r.textContent=n)}function la(t,e){e?(t.style.setProperty("--aia-product-photo-fill-x",String(e.x)),t.style.setProperty("--aia-product-photo-fill-y",String(e.y))):(t.style.removeProperty("--aia-product-photo-fill-x"),t.style.removeProperty("--aia-product-photo-fill-y"))}function ua(t,e){return`${e.addToCart}: ${t.title}`}var lo="http://www.w3.org/2000/svg";function Dl(){let t=document.createElementNS(lo,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=[["magicx-aia-product-cart-glyph","M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"],["magicx-aia-product-cart-glyph","M13.5 6.5v-4M11.5 4.5h4"],["magicx-aia-product-cart-check","M5 12.5l4.5 4.5L19 7.5"],["magicx-aia-product-cart-spinner","M12 4a8 8 0 1 0 8 8"]];for(let[n,i]of e){let o=document.createElementNS(lo,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(lo,"circle");i.setAttribute("class","magicx-aia-product-cart-glyph"),i.setAttribute("cx",n),i.setAttribute("cy","20"),i.setAttribute("r","1.3"),t.appendChild(i)}return t}function Nl(t,e,n,i,o){let r=document.createElement("span");r.className="magicx-aia-product-cart",r.setAttribute("data-aia-product-cart",""),r.setAttribute("role","button"),r.setAttribute("aria-label",ua(e,o)),r.tabIndex=0,r.appendChild(Dl());let a=s=>{s.preventDefault(),s.stopPropagation(),r.getAttribute("data-aia-cart-state")!=="adding"&&(r.setAttribute("data-aia-cart-state","adding"),r.setAttribute("aria-busy","true"),n(Jn.get(t)??e).then(()=>{r.removeAttribute("aria-busy"),r.setAttribute("data-aia-cart-state","added")},()=>{r.removeAttribute("aria-busy"),r.removeAttribute("data-aia-cart-state")}))};return r.addEventListener("keydown",s=>{s.key!=="Enter"&&s.key!==" "||a(s)}),r.addEventListener("focus",()=>i(!0)),r.addEventListener("blur",s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||i(!1)}),{el:r,arm:()=>r.addEventListener("click",a)}}function Hl(t,e){return[e?"cart":"",t.id,t.title,t.url,t.imageUrl,t.vendor,t.available===!1?"sold-out":""].map(n=>n??"").join("\0")}function Fl(t,e,n,i,o,r){let a=document.createElement("a");a.className="magicx-aia-product",a.setAttribute("data-aia-product",""),a.setAttribute("role","option"),a.setAttribute("aria-selected","false"),a.tabIndex=0;let s=document.createElement("span");s.className="magicx-aia-product-media",s.setAttribute("aria-hidden","true");let l=mt(t.imageUrl),d=l[0],c=!!d,u=()=>{s.replaceChildren(),s.removeAttribute("data-aia-image-loaded"),s.toggleAttribute("data-aia-product-placeholder",i==="image"),s.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(s.textContent=Yn(t.title))};if(ca.set(a,h=>{h!==i&&(i=h,c||u())}),d){let h=document.createElement("img"),S=0;h.onload=()=>{s.setAttribute("data-aia-image-loaded",""),la(a,Xn(h.naturalWidth,h.naturalHeight))},h.onerror=()=>{let y=l[++S];if(y){h.src=y;return}c=!1,la(a,null),u()},h.className="magicx-aia-product-image",h.src=d,h.alt="",h.loading="lazy",h.decoding="async",s.appendChild(h)}else u();a.appendChild(s);let p=document.createElement("span");if(p.className="magicx-aia-product-body",t.vendor){let h=document.createElement("span");h.className="magicx-aia-product-vendor",h.textContent=t.vendor,p.appendChild(h)}let f=document.createElement("span");if(f.className="magicx-aia-product-title",f.textContent=t.title,p.appendChild(f),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let h=document.createElement("span");h.className="magicx-aia-product-badge",h.textContent=o.soldOut,p.appendChild(h)}a.appendChild(p);let g=r&&t.available!==!1?Nl(a,t,r,n,o):null;return g&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(g.el)),co.set(a,()=>{g?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.altKey||h.button!==0||(h.preventDefault(),e(Jn.get(a)??t))})}),a.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),e(Jn.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",h=>{h.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var ma=10,pa=44;function Zn(t,e,n){if(!e||n.detail===0)return!0;let i=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(t.ownerDocument.defaultView?.getComputedStyle(t).direction==="rtl"){let s=Math.min(o.left-10,i.right-44);return n.clientX>=s}let a=Math.max(o.right+10,i.left+44);return n.clientX<=a}var ga="http://www.w3.org/2000/svg",Wl=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function Bl(t,e){let n=t.toLowerCase();return n.startsWith("on")||n.includes("href")||n==="style"||n==="xml:base"||n==="id"||n==="name"||/^\s*javascript:/i.test(e)||/url\s*\(\s*['"]?\s*[^#'"\s)]/i.test(e)}var Ul=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],Vl=/^[a-zA-Z0-9#.,%\s()-]+$/;function Gl(t){let e=[];for(let n of Ul){let i=t.getAttribute(n);i===null||!Vl.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function fa(t){for(let e of Array.from(t.attributes))Bl(e.name,e.value)&&t.removeAttribute(e.name);Gl(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!Wl.has(n.localName)||n.namespaceURI!==ga?n.remove():fa(n)}else e.remove()}function me(t){if(typeof DOMParser>"u"||typeof XMLSerializer>"u")return null;let e=new DOMParser().parseFromString(t,"image/svg+xml"),n=e.documentElement;return!n||n.localName!=="svg"||n.namespaceURI!==ga||e.getElementsByTagName("parsererror").length>0?null:(fa(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function pt(t){return t.text}function pe(t){return gt(t)[0]??null}function gt(t){let e=$l(t);return e?so(e,120):[]}function $l(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function Ue(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var mo={one:"item",other:"items"};function ha(t,e=mo){let n=Ue(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function po(t){return pe(t.image_url)!==null}var ei=new Map;function ql(t){let e=t.icon_svg;if(!e)return!1;let n=ei.get(e);return n===void 0&&(n=me(e)!==null,ei.size>=256&&ei.clear(),ei.set(e,n)),n}function ti(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&po(i)||e&&ql(i))}var ba=new WeakMap;function Kl(t,e,n){let i=e.length,o=vn(),r=ba.get(t),a=n&&r&&En(r.options,e)?r.plan:null,s=!a&&!n&&yn(i,o)?Tn(t):null,l=a??xn(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||ba.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function Sa(t,e){if(e.loading||!e.interactive)return null;let n=e.options[le(t)];return n?.is_tappable?n:null}var zl={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=Sa(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!Zn(t,o,n);if(o){let a=r||t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(a)),o.dataset.checked=String(a),o.textContent=a?"\u2713":""}r?e.onSelect(i,{commit:!0}):e.onSelect(i),setTimeout(()=>t.classList.remove("magicx-aia-option--pressed"),170)},onEnter:(t,e)=>{Sa(t,e)&&e.onHighlight(le(t))},onLeave:(t,e)=>e.onHighlight(-1,le(t))};function ya(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,p=!0,f){let g=t.querySelector(".aia-grid");if(e.length===0){g?.remove();return}g||(g=document.createElement("div"),g.className="aia-grid magicx-aia-grid",g.setAttribute("data-scroll",""),g.style.setProperty("--aia-grid-min","250px"),g.style.setProperty("--aia-grid-max","1fr"),g.style.setProperty("--aia-grid-gap","0"),t.appendChild(g)),W(g,zl,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:p});let h=g.dataset.aiaGroup!==s;g.dataset.aiaGroup=s;let S=ti(e,d,c);jl(g,e,n,r,a,{showIcons:d&&S,showImages:c&&S,showCounts:u,picked:f});let y=Kl(g,e,a);Yl(g,e.length,y,a,l),h&&(g.scrollTop=0)}function jl(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?g=>g.icon??g.icon_svg??"":()=>"",p=d?g=>pe(g.image_url)??"":()=>"",f=c?g=>Ue(g.item_count)??"":()=>"";J(t,e,{keyOf:g=>`${g.text}\0${g.parameterLabel??""}\0${u(g)}\0${p(g)}\0${f(g)}\0${a}\0${s}`,create:(g,h)=>{let S=Ql(g,o,r);return o||(S.dataset.aiaEntering=""),S},update:(g,h,S)=>{if(go.get(g)!==(h.matchedText??"")){let b=g.querySelector(".magicx-aia-option-text");b&&xa(b,h),go.set(g,h.matchedText??"")}let y=S===n&&!o;g.id=`${i}-option-${S}`,g.dataset.aiaIndex=String(S),g.setAttribute("aria-selected",String(r.picked?r.picked.includes(h.text):y));let m=g.querySelector(".magicx-aia-checkbox");r.picked&&h.is_tappable?(m||(m=document.createElement("span"),m.className="magicx-aia-checkbox",m.setAttribute("aria-hidden","true"),g.querySelector(".magicx-aia-option-content")?.prepend(m)),m.dataset.checked=String(r.picked.includes(h.text)),m.textContent=r.picked.includes(h.text)?"\u2713":""):m?.remove(),g.classList.toggle("magicx-aia-option--highlighted",y),g.classList.toggle("magicx-aia-option--live-match",!!h.liveMatch&&!o)}})}function Yl(t,e,n,i,o){for(let r of t.querySelectorAll("[data-aia-entering]")){if(!i){let a=Number.parseInt(r.dataset.aiaIndex??"-1",10);a>=0&&r.style.setProperty(Wn,`${Bn(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var go=new WeakMap;function xa(t,e){if(t.replaceChildren(),e.matchedText)for(let n of wn(pt(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(pt(e)));if(e.parameterLabel){t.appendChild(document.createTextNode(" "));let n=document.createElement("span");n.className="magicx-aia-option-parameter",n.textContent=e.parameterLabel,t.appendChild(n)}}function Ql(t,e,{showIcons:n,showImages:i,showCounts:o}){let r=document.createElement("div");r.setAttribute("role","option"),r.setAttribute("data-aia-option",""),e&&r.setAttribute("data-aia-loading",""),r.tabIndex=e||!t.is_tappable?-1:0;let a=["magicx-aia-option"];t.is_tappable?a.push("magicx-aia-option--tappable"):a.push("magicx-aia-option--non-tappable"),r.className=a.join(" ");let s=document.createElement("span");s.className="magicx-aia-option-content";let l=i?gt(t.image_url):[],d=l[0];if(d){let f=document.createElement("span");f.className="magicx-aia-option-image",f.setAttribute("aria-hidden","true");let g=document.createElement("img");g.setAttribute("alt",""),g.setAttribute("loading","lazy"),g.setAttribute("decoding","async"),g.setAttribute("referrerpolicy","no-referrer"),g.setAttribute("draggable","false");let h=0;g.onload=()=>f.setAttribute("data-aia-image-loaded",""),g.onerror=()=>{let S=l[++h];S?g.src=S:g.hidden=!0},g.src=d,f.appendChild(g),s.appendChild(f),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?me(t.icon_svg):null;if(c){let f=document.createElement("span");f.className="magicx-aia-option-icon",f.setAttribute("aria-hidden","true"),f.innerHTML=c,s.appendChild(f),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",xa(u,t),go.set(r,t.matchedText??""),s.appendChild(u),t.tag){let f=document.createElement("span");f.className="magicx-aia-option-tag",f.textContent=t.tag,s.appendChild(f)}let p=o?Ue(t.item_count):null;if(p!==null){let f=document.createElement("span");f.className="magicx-aia-option-count",f.textContent=p,s.appendChild(f),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var Xl=120,Jl={itemSelector:"[data-aia-time-row], [data-aia-time-done]",onClick:(t,e)=>{if(!e.interactive)return;if(t.hasAttribute("data-aia-time-done")){e.callbacks.onTimeCommit();return}let n=t.dataset.aiaTimeColumn;n&&e.callbacks.onTimeChange(rt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},va=new WeakMap,Ta=new WeakMap;function Ea(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=tc(),t.appendChild(r),q(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};va.set(r,a),W(r,Jl,a),r.setAttribute("aria-label",n.timeLabel);let s=r.querySelector("[data-aia-time-done]");s&&(s.textContent=n.done);let l=r.querySelector("[data-aia-time-value]");l&&(l.textContent=tt(e.minutes));for(let d of it){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&Zl(c,d,e.minutes)}}function Zl(t,e,n){let i=ot(e,n);for(let a of t.querySelectorAll("[data-aia-time-row]")){let s=Number(a.dataset.aiaIndex)===i;a.classList.toggle("magicx-aia-time-wheel-row--selected",s),a.setAttribute("aria-selected",String(s))}let o=ni(t);if(o.settle)return;let r=i*nt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function ni(t){let e=Ta.get(t);return e||(e={syncedTop:null,settle:null},Ta.set(t,e)),e}function ec(t,e,n){let i=ni(e);if(i.syncedTop!=null&&Math.abs(e.scrollTop-i.syncedTop)<1){i.syncedTop=null;return}i.syncedTop=null,i.settle&&clearTimeout(i.settle),i.settle=setTimeout(()=>Pa(t,e,n),Xl)}function Pa(t,e,n){let i=ni(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=va.get(t);if(!o||!o.interactive)return;let r=an(n,e.scrollTop);r!==ot(n,o.view.minutes)&&o.callbacks.onTimeChange(rt(n,o.view.minutes,r))}function tc(){let t=document.createElement("div");t.className="magicx-aia-time-wheel",t.setAttribute("data-aia-time-wheel",""),t.setAttribute("role","group");let e=document.createElement("span");e.className="magicx-aia-time-wheel-value",e.setAttribute("data-aia-time-value",""),e.setAttribute("aria-live","polite");let n=document.createElement("div");n.className="magicx-aia-time-wheel-columns",n.setAttribute("aria-hidden","true");let i=document.createElement("div");i.className="magicx-aia-time-wheel-band",n.appendChild(i);for(let r of it){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(nc(t,r))}let o=document.createElement("button");return o.type="button",o.tabIndex=-1,o.className="magicx-aia-time-wheel-done",o.setAttribute("data-aia-time-done",""),o.disabled=!0,t.append(e,n,o),t}function nc(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),rn(e).forEach((i,o)=>{let r=document.createElement("div");r.className="magicx-aia-time-wheel-row",r.setAttribute("data-aia-time-row",""),r.dataset.aiaTimeColumn=e,r.dataset.aiaIndex=String(o),r.textContent=i.label,n.appendChild(r)}),n.addEventListener("scroll",()=>ec(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{ni(n).settle&&Pa(t,n,e)}),n}var Ce="data-aia-fit",ft="--aia-dropdown-fit-height",wa=8,ic=160;function ii({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,d=!1,c=()=>{t.removeAttribute(Ce),t.style.removeProperty(ft)},u=()=>{if(ue(t)){d=!0;return}d=!1,qn(t,t.getBoundingClientRect().height)},p=m=>`${r}|${(m??t).scrollHeight}|${t.offsetWidth}`,f=m=>s?.key===p(m)?s.height:null,g=m=>{let b=p(m);if(s?.key===b)return s.height;let x=m?.scrollTop??0;t.removeAttribute(Ce);let T=t.offsetHeight;return t.setAttribute(Ce,""),m&&x&&(m.scrollTop=x),s={key:b,height:T},T},h=()=>{if(i)return;if(!e()){o=!1;return}let m=ue(t),b=m?$n(t):null;m&&l!==m&&(l=m,m.finished.then(S,S)),!m&&d&&u(),o||(o=!0,c());let x=t.hasAttribute(Ce),T=de(t,".aia-grid")?.getAttribute("data-aia-group")??null,P=T!==r;r=T;let I=rc(t,n);if(I===null)return;let E=oc(t);if(x){let M=m?f(E):g(E);if(M!==null&&M<=I){c(),u();return}}else if((b??t.offsetHeight)<=I)return;let w=`${Math.max(ic,Math.floor(I))}px`,D=t.style.getPropertyValue(ft)!==w;D&&t.style.setProperty(ft,w),x?P&&E&&(E.scrollTop=0):t.setAttribute(Ce,""),(D||!x)&&u()},S=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,h()}))},y=n?.visualViewport??null;return y?.addEventListener("resize",S),y?.addEventListener("scroll",S),n?.addEventListener("resize",S),n?.addEventListener("scroll",S,{capture:!0,passive:!0}),h(),{update:h,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),y?.removeEventListener("resize",S),y?.removeEventListener("scroll",S),n?.removeEventListener("resize",S),n?.removeEventListener("scroll",S,{capture:!0}))}}}function oc(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function rc(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,a=r?r.getBoundingClientRect().top:0,s=r?a+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?s+t.offsetHeight:t.getBoundingClientRect().bottom)-i-wa:i+o-s-wa}var ac=[159,119,164];function ai(t){let e=document.createElement("div");return e.id=t,e.setAttribute("role","listbox"),e.setAttribute("data-aia-dropdown",""),e.className="magicx-aia-dropdown",e.addEventListener("mousedown",n=>n.preventDefault()),Nn(e),e}var oi=new WeakMap;function sc(t,e,n){let i=oi.get(t);if(i||(i={button:Vr(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),oi.set(t,i)),i.button.getAttribute("aria-label")!==n.scrollArrow&&i.button.setAttribute("aria-label",n.scrollArrow),i.grid!==e&&(i.controller?.destroy(),i.controller=null,i.grid=e,e)){i.controller=Vn({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var ri=new WeakMap;function Ca(t){let e=ri.get(t);if(e){e.update();return}ri.set(t,ii({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function fo(t){ri.get(t)?.destroy(),ri.delete(t),Kn(t);let e=oi.get(t);e&&(e.controller?.destroy(),oi.delete(t))}function si(t,e){let n=e.strings??O(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:p}=e,f=kt(e.pills,n.keepTyping),g=_t(f),h=s&&f.length>0,S=i.length>0,y=e.products.length>0,m=e.formatType==="time"&&e.timeView!=null,b=e.formatType==="location"&&e.locationView!=null,x=r&&(S||h||a||y||m||b);if(x?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),a?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!x){uo(t,!1),Zr(t),Ca(t),ut(t,null,{visible:!1});return}y?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let T=t.querySelector(".aia-stack");T||(T=document.createElement("div"),T.className="aia-stack",T.style.setProperty("--aia-stack-space","8px"),t.appendChild(T));let P=e.showSkipButton&&g&&!e.isInputEmpty,I=h||a&&s||P,E=T.querySelector(".magicx-aia-pill-bar");if(I){E||(E=document.createElement("div"),E.className="magicx-aia-pill-bar aia-cluster",E.setAttribute("data-nowrap",""),E.setAttribute("data-aia-pillbar",""),T.insertBefore(E,T.firstChild));let z=h||a&&s,v=E.querySelector(".magicx-aia-pill-scroll");z?(v||(v=document.createElement("span"),v.className="magicx-aia-pill-scroll",v.setAttribute("data-aia-pill-scroll",""),E.insertBefore(v,E.firstChild)),zn(v,f,0,u,!0,a,l)):v&&v.remove(),dc(E,P,a||e.skipDisabled,f[0],p,n)}else E&&E.remove();let w=e.suggestions[0],D=w?`${w.parameter} ${w.text}`:"",M=k(e.formatType),Le=M&&!a;ya(T,M?[]:i,o,d,c,e.listboxId,a,D,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,a?void 0:e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),hc(T,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),sc(t,T.querySelector(".aia-grid"),n),Yr(T,Le?i:[],o,e.listboxId,Le?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:Rn(e.formatType,e.dateRangeStart)},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Ea(T,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),ea(T,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let L=T.querySelector(".magicx-aia-skeleton-bars");if(a&&(!S||_(e.formatType))){if(!L){L=document.createElement("div"),L.className="magicx-aia-skeleton-bars",L.setAttribute("data-aia-skeleton-bars","");for(let z of ac){let v=document.createElement("span");v.className="magicx-aia-skeleton-bar",v.style.width=`${z}px`,L.appendChild(v)}T.appendChild(L)}}else L&&L.remove();da(T,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),uo(t,!0),gc(T,e.onSeeAllResults,n.seeAllResults);let U=T.querySelector(".magicx-aia-footer")??mc(n),ge=o>=0&&!!i[o]?.is_tappable;uc(U,Dn(ge,e.isInputEmpty,n)),U.isConnected||T.appendChild(U),lc(T,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),Fn(T,T.querySelector(".magicx-aia-multi-done")),Ca(t),ut(t,Gn(s?f:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function lc(t,e){let n=e.map(i=>t.querySelector(`:scope > ${i}`)).filter(i=>i!==null);for(let i=0;i<n.length;i++)t.children[i]!==n[i]&&t.insertBefore(n[i],t.children[i]??null)}var cc={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function dc(t,e,n,i,o,r){W(t,cc,{onSkip:o,loading:n});let a=t.querySelector(".magicx-aia-skip");if(!e){a?.remove();return}a||(a=document.createElement("button"),a.type="button",a.tabIndex=-1,a.className="magicx-aia-skip",a.setAttribute("data-aia-skip",""),a.textContent=r.skip,a.disabled=!0,t.appendChild(a),q(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function uc(t,{key:e,hint:n}){let i=t.querySelector(".magicx-aia-footer-key"),o=t.querySelector(".magicx-aia-footer-hint");!i||!o||(i.textContent!==e&&(i.textContent=e),o.textContent!==n&&(o.textContent=n))}function mc(t){let e=document.createElement("footer");e.className="magicx-aia-footer",e.setAttribute("data-aia-footer","");let n=document.createElement("div");n.className="aia-cluster magicx-aia-footer-row",n.setAttribute("data-align","center"),n.setAttribute("data-justify","between"),n.setAttribute("data-nowrap","");let i=document.createElement("div");i.className="aia-cluster magicx-aia-footer-hint-group",i.setAttribute("data-align","center"),i.style.setProperty("--aia-cluster-gap","5px");let o=document.createElement("kbd");o.className="magicx-aia-footer-key",o.textContent="tab";let r=document.createElement("span");r.className="magicx-aia-footer-hint",r.textContent=t.select,i.append(o,r);let a=document.createElement("a");a.className="aia-cluster magicx-aia-footer-brand-link",a.setAttribute("data-align","center"),a.href=_n(),a.target="_blank",a.rel="noopener noreferrer",a.style.setProperty("--aia-cluster-gap","2px");let s=document.createElement("span");s.className="magicx-aia-footer-brand",s.textContent="AI";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.textContent="Autocomplete",a.append(s,l),n.append(i,a),e.append(n),e}var pc={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function gc(t,e,n){let i=t.querySelector(":scope > [data-aia-see-all]");if(!e){i?.remove();return}if(!i){i=document.createElement("div"),i.className="magicx-aia-see-all-row",i.dataset.aiaSeeAll="";let r=document.createElement("button");r.type="button",r.tabIndex=-1,r.className="magicx-aia-see-all",r.disabled=!0,i.appendChild(r),t.appendChild(i),q(r)}W(i,pc,{submit:e});let o=i.querySelector("button");o&&(o.textContent!==n&&(o.textContent=n),o.disabled=!1)}var fc={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function hc(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.disabled=!0,r.appendChild(s),t.appendChild(r),q(s)}W(r,fc,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function La(t,e){let n=ai(e.listboxId);return t.appendChild(n),{dropdown:n}}function ho(t,e,n){let i=We(e);si(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:Q(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var Ia=340;function li(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let p of c)if(p.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var bc=6,Sc=.3;function Aa(t){return t<=0?"0px":`${(-Math.min(Sc,2*bc/t)).toFixed(3)}px`}var Oa=new Map;function yc(t,e,n){let i=Oa.get(e);if(i!==void 0){t.style.setProperty("--aia-chip-image-fit",i),t.setAttribute("data-aia-image-loaded","");return}let o=n.createElement("img");o.setAttribute("referrerpolicy","no-referrer"),o.onload=()=>{if(!t.isConnected)return;t.setAttribute("data-aia-image-loaded","");let r=t.getBoundingClientRect().height,a=Number.parseFloat(getComputedStyle(t).fontSize);if(!(r>0&&a>0&&o.naturalWidth>0&&o.naturalHeight>0))return;let s=`${(r/a*(o.naturalWidth/o.naturalHeight)).toFixed(3)}em`;Oa.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function ci(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,a=t.showChipIcons??!0,s=t.showChipImages??!0,l=n.length===0;e.dataset.aiaEmpty=l?"true":"false",Ar(e,l?r:"");let d=n.map(m=>m.type==="completed"?`${m.type}:${m.value}${a?m.param.icon??m.param.icon_svg??"":""}${s?pe(m.param.image_url)??"":""}`:`${m.type}:${m.value}`).join("\0"),c=e.dataset.segKey??"",u=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(d===c&&(i??"")===u&&(o??"")===p)return;if(d===c){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let m of e.querySelectorAll("strong[data-param-id]")){let b=m.dataset.paramId,x=m.dataset.seg==="completed"&&b===i;m.classList.toggle("magicx-aia-shimmer-revealed",x),m.classList.toggle("magicx-aia-shimmer-sweep",x),m.classList.toggle("magicx-aia-segment--editing",b===o)}return}let f=ar(e),g=f?$(e):null;e.dataset.segKey=d,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=R(e),S=h.createDocumentFragment(),y=0;for(let m of n)if(y+=m.value.length,m.type==="completed"){let b=h.createElement("strong");b.dataset.seg="completed",b.dataset.paramId=m.param.id;let x=m.param.id===i,T=m.param.id===o,P=["magicx-aia-segment","magicx-aia-segment--completed"];x&&P.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),T&&P.push("magicx-aia-segment--editing"),b.className=P.join(" "),b.style.letterSpacing=Aa(m.value.length);let I=s?pe(m.param.image_url):null;if(I){let w=h.createElement("span");w.className="magicx-aia-segment-image",w.setAttribute("contenteditable","false"),w.setAttribute("aria-hidden","true"),w.style.setProperty("--aia-chip-image",`url("${I}")`),yc(w,I,h),b.appendChild(w),b.dataset.aiaImage=""}let E=!I&&a&&m.param.icon_svg?me(m.param.icon_svg):null;if(E){let w=h.createElement("span");w.className="magicx-aia-segment-icon",w.setAttribute("contenteditable","false"),w.setAttribute("aria-hidden","true"),w.innerHTML=E,b.appendChild(w),m.param.icon&&(b.dataset.aiaIcon=m.param.icon)}b.appendChild(h.createTextNode(m.value)),S.appendChild(b)}else if(m.type==="identified"){let b=h.createElement("strong");b.dataset.seg="identified",b.dataset.paramId=m.param.id;let x=["magicx-aia-segment","magicx-aia-segment--completed"];m.param.id===o&&x.push("magicx-aia-segment--editing"),b.className=x.join(" "),b.style.letterSpacing=Aa(m.value.length),b.textContent=m.value,S.appendChild(b)}else S.appendChild(h.createTextNode(m.value));e.replaceChildren(S),e.dataset.aiaTextLength=String(y),g!=null?H(e,Math.max(0,Math.min(g,y))):f&&H(e,y)}var xc='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Ma(t=O()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=xc.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function ka(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function Ra(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(ae(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function Tc(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function _a(t,e){let n=e.firstElementChild;if(!n){e.removeAttribute("data-aia-pill-wrapped");return}let i=n.getBoundingClientRect(),o=t.getBoundingClientRect();i.top>=o.bottom-2?e.setAttribute("data-aia-pill-wrapped",""):e.removeAttribute("data-aia-pill-wrapped")}function Da(t,e){let{listboxId:n}=e,i=ai(n);t.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-input-wrapper",o.setAttribute("data-aia-input-wrapper",""),t.appendChild(o);let r=document.createElement("div");r.className="magicx-aia-editor",r.setAttribute("data-aia-editor",""),o.appendChild(r);let a=document.createElement("div");a.className="magicx-aia-input",a.setAttribute("data-aia-input",""),a.setAttribute("contenteditable",Tc()?"plaintext-only":"true"),a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-haspopup","listbox"),a.setAttribute("aria-controls",n),a.setAttribute("aria-expanded","false"),a.setAttribute("spellcheck","true"),a.setAttribute("enterkeyhint","send"),r.appendChild(a);let s=document.createElement("span");s.className="magicx-aia-pill-list-container",s.setAttribute("data-aia-pill-list-container",""),r.appendChild(s);let l=null,d=null;e.submitButton===void 0?(l=Ma(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,p=!1,f=0,g=()=>{let m=et(a),x=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;e.handleChange(x)},h=()=>{let m=re(a)?.node??null;if(!m||!a.contains(m))return null;let T=(m.nodeType===Node.ELEMENT_NODE?m:m.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return T&&rr(a,T)?null:T};if(o.addEventListener("click",m=>{m.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u}),a.addEventListener("input",()=>{p||(f=performance.now(),g(),e.handleCaretAfterInput($(a)))},{signal:u}),R(a).addEventListener("selectionchange",()=>{let m=re(a);if(!m||!a.contains(m.node))return;let b=m.collapsed?h():null,x=e.store.get(),T=x.editingParam?.id??x.editingIdentified?.id??null;if(b&&b!==T){e.startEditingParam(b);return}performance.now()-f<50||e.handleCaretMove($(a))},{signal:u}),a.addEventListener("click",m=>{let b=Qt(a,m.target);b&&(e.startEditingParam(b),Xt(a,b))},{signal:u}),a.addEventListener("compositionstart",()=>{p=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{p=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",m=>{let b=m,x=b.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){m.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let T=x.startsWith("delete")?"":b.data??"";e.replaceEditingRange(T)&&m.preventDefault()}},{signal:u}),a.addEventListener("paste",m=>{m.preventDefault();let b=(m.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let x=R(a),T=xe(a);if(!T||!a.contains(T.startContainer))return;T.deleteContents();let P=x.createTextNode(b);T.insertNode(P),T.setStartAfter(P),Ze(a,T.startContainer,T.startOffset),g()},{signal:u}),a.addEventListener("keydown",m=>e.handleKeyDown(m),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),d&&d.addEventListener("click",m=>{ka(e)&&(m.stopPropagation(),Ra(e))},{signal:u}),e.autoFocus!==!1){a.focus();let m=re(a);(!m||!a.contains(m.node))&&Ze(a,a,0)}if(typeof ResizeObserver<"u"){let m=new ResizeObserver(()=>_a(a,s));m.observe(a),c.signal.addEventListener("abort",()=>m.disconnect(),{once:!0})}let y=li(r);return c.signal.addEventListener("abort",y,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c}}function bo(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let y=n.strings??O();a.getAttribute("aria-label")!==y.submit&&a.setAttribute("aria-label",y.submit);let m=a.querySelector("svg");m&&m.getAttribute("aria-label")!==y.submit&&m.setAttribute("aria-label",y.submit);let b=!!e.text||e.completedParams.length>0;a.disabled=!b,a.toggleAttribute("data-aia-ready",b&&e.isReady)}let p=i.dataset.newParamId??"",f=e.newParamId!==null&&e.newParamId!==p;if(ci({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),s==="inline"){let y=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,m=Mt(e.actionableSuggestions);y||m.length>0?zn(o,m,0,l,!1,y,e.isActivePillSelected):oo(o)}else oo(o);_a(i,o),f?(i.focus(),H(i,e.caretOffset??e.text.length)):e.isFocused&&et(i)!==e.text&&H(i,e.text.length);let g=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:Q(e.editingIdentified.parameter),required:!0,options:[]}:null,h=e.dropdownSuggestion??g??e.actionableSuggestions[0],S=We(e);si(r,{strings:n.strings,suggestions:h?[{...h,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:g?[g]:e.actionableSuggestions,showPills:s==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:S.selectedIso,selectedDateRange:S.selectedRange,dateRangeStart:S.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(y,m)=>{m!==void 0&&c.get().activeDropdownIndex!==m||c.set({activeDropdownIndex:y})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:y=>c.set({isFocused:y}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&ka(n)?()=>Ra(n):void 0})}function di(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let p of n)p(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function Na(t,e){let n,i,o=r=>(r!==n&&(n=r,i=e(r)),i);return{get:()=>{let r=t.get();return{...r,...o(r)}},set:r=>{typeof r=="function"?t.set(a=>{let s={...a,...o(a)};return r(s)}):t.set(r)},peek:r=>{let a={...t.get(),...r};return{...a,...e(a)}},subscribe:r=>t.subscribe((a,s)=>{let l={...s,...o(s)},d={...a,...o(a)};r(d,l)})}}var So=new WeakSet,Ha=new WeakMap;function Wa(t){return t.nodeType===Node.DOCUMENT_NODE}function vc(t){return Wa(t)?t:t.ownerDocument}function Ec(t){let e=Ha.get(t);if(e)return e;let n=t.defaultView?.CSSStyleSheet;if(typeof n!="function")return null;try{let i=new n;return typeof i.replaceSync!="function"?null:(i.replaceSync(Ua),Ha.set(t,i),i)}catch{return null}}function Fa(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=Ua,e.appendChild(n)}function Ba(t){if(typeof document>"u")return;let e=t??document;if(So.has(e))return;let n=vc(e);if(Wa(e)){let r=e.head??e.documentElement;if(!r)return;Fa(n,r),So.add(e);return}let i=Ec(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):Fa(n,e),So.add(e)}var Ua=`.aia-stack {
|
|
1
|
+
"use strict";var Si=Object.defineProperty;var ms=Object.getOwnPropertyDescriptor;var ps=Object.getOwnPropertyNames;var gs=Object.prototype.hasOwnProperty;var fs=(t,e)=>{for(var n in e)Si(t,n,{get:e[n],enumerable:!0})},hs=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ps(e))!gs.call(t,o)&&o!==n&&Si(t,o,{get:()=>e[o],enumerable:!(i=ms(e,o))||i.enumerable});return t};var bs=t=>hs(Si({},"__esModule",{value:!0}),t);var od={};fs(od,{AIAutocomplete:()=>hi,ATTRIBUTION_URL:()=>Yi,DATE_RANGE_META_END:()=>Tn,DATE_RANGE_META_START:()=>yn,DEFAULT_OPTION_COUNT_UNIT:()=>yo,EDITOR_GROW_MS:()=>Va,LOCATION_META_KEY:()=>yi,LOCATION_MIN_QUERY:()=>Ke,MULTI_DONE_FIT_VAR:()=>Fn,MULTI_SELECT_TOGGLE_MIN_PX:()=>La,MULTI_SELECT_TOGGLE_SLOP_PX:()=>Ca,ModeController:()=>$e,OPTIONS_GRID_MOBILE_QUERY:()=>ut,OPTION_ENTER_DELAY_VAR:()=>Un,OPTION_ENTER_FADE_MS:()=>Xr,OPTION_ENTER_RISE_MS:()=>Jr,OPTION_ENTER_RISE_PX:()=>Zr,OPTION_ENTER_STAGGER_MS:()=>Yr,OPTION_IMAGE_WIDTH:()=>Jn,PANEL_ENTER_DELAY_MS:()=>uo,PANEL_ENTER_MS:()=>co,PANEL_GHOST_CLASS:()=>ue,PANEL_GLIDE_MS:()=>so,PANEL_LEAVE_MS:()=>lo,PLACEHOLDER_FADE_OUT_MS:()=>Dr,PLACEHOLDER_LEAVING_ATTR:()=>ve,PLACEHOLDER_SWAP_GAP_MS:()=>Nr,PLACEHOLDER_TYPE_MS:()=>Rr,PLACEHOLDER_WORD_PAUSE_MS:()=>_r,PRODUCT_IMAGE_WIDTH:()=>Ta,PRODUCT_PATH_PREFIX:()=>Hi,PRODUCT_ROW_PX_PER_LINE:()=>ba,RANGE_SEPARATOR:()=>Ui,SCHEMA_VERSION:()=>vi,SCROLL_ARROW_ATTR:()=>gt,SCROLL_ARROW_BOTTOM_VAR:()=>ao,SCROLL_ARROW_CLASS:()=>io,SCROLL_ARROW_FADE_MS:()=>oo,SCROLL_ARROW_LABEL:()=>ta,SCROLL_ARROW_SCROLL_IDLE_MS:()=>ro,SCROLL_ARROW_VISIBLE_ATTR:()=>Pe,SKIPPED_PARAM_TEXT:()=>xi,SMART_SUGGESTION_SPARKLE_SVG:()=>Nt,TIME_META_KEY:()=>Ii,TIME_STEP_MINUTES:()=>an,TIME_WHEEL_COLUMNS:()=>at,TIME_WHEEL_ROW_HEIGHT:()=>rt,VIEWPORT_FIT_ATTR:()=>Le,VIEWPORT_FIT_HEIGHT_VAR:()=>yt,WEEKDAY_LABELS:()=>Ze,addMonths:()=>Vt,attachProductRowWheel:()=>Yn,attachScrollArrow:()=>$n,attachViewportFit:()=>ri,buildAttributionUrl:()=>Dn,buildDateOptions:()=>Gt,buildLocationOption:()=>At,buildQuery:()=>N,buildSubmitResult:()=>le,buildTimeOption:()=>sn,cellDay:()=>qt,cellIso:()=>$,chipIdFromTap:()=>Zt,computeOptionsGridLayout:()=>$i,containScroll:()=>Hn,createStore:()=>mi,cursorIsAtEnd:()=>tn,dateCellMarks:()=>kn,dateFloorFor:()=>_n,dateSelectionFor:()=>Ue,destroyPanelMorph:()=>jn,extractPlainText:()=>it,findMultiSelectDone:()=>Kr,fitMultiSelectDone:()=>Wn,formatAbsoluteDate:()=>Te,formatDate:()=>Pi,formatDateRange:()=>Vi,formatOptionCount:()=>Ge,formatPlace:()=>Ti,formatTime:()=>ot,getCursorOffset:()=>q,getFooterHint:()=>Nn,hasSkippablePill:()=>Ht,highlightParts:()=>Cn,identifiedParamLabel:()=>X,inPanelGhost:()=>Ee,isCalendarFormat:()=>k,isDimmedDay:()=>Rn,isMultiSelectToggleTap:()=>ti,isOptionsGridMobileViewport:()=>We,isPickerFormat:()=>D,isSmartSuggestion:()=>Xe,isTraditionalAutocompleteSuggestion:()=>L,isoDate:()=>G,isoTime:()=>_i,keepCaretOnChip:()=>en,labelTraditionalAutocomplete:()=>Dt,locationEndpointFor:()=>It,matchTypedPhrase:()=>mt,measureOptionsGrid:()=>Fe,monthLabel:()=>Ut,needsOptionsGridMeasurement:()=>vn,notePanelMorphHeight:()=>zn,optionCountLabel:()=>Oa,optionEnterDelayMs:()=>Vn,optionHasImage:()=>To,optionImageSources:()=>St,optionImageSrc:()=>ge,optionLabel:()=>bt,optionsEntranceDurationMs:()=>Gn,optionsGridTemplateColumns:()=>xn,optionsShowLeadingVisuals:()=>ii,panelMorphGlide:()=>me,panelMorphKey:()=>qn,panelMorphTargetHeight:()=>Kn,parseDate:()=>et,parseLooseDate:()=>Ne,parseLooseDateRange:()=>dt,parseTime:()=>rn,plainTextLength:()=>Jt,planOptionsGrid:()=>En,previousGraphemeBoundary:()=>nn,productFromMatchedItem:()=>Fi,productImageSources:()=>ht,productImageSrc:()=>xa,productInitial:()=>Xn,productPhotoFill:()=>Zn,productRowWheelTarget:()=>po,productsFromCustomFields:()=>gn,queryLive:()=>F,releasePanelHug:()=>pt,renderEditableContent:()=>ui,resolveFormatType:()=>Q,resolveIdentifiedDate:()=>bn,sameOptionRows:()=>Pn,sanitizeOptionIconSvg:()=>pe,scrollCaretIntoView:()=>Qt,selectedIsoFromText:()=>$t,selectedRangeFor:()=>He,setCursorOffset:()=>H,settlePanelMorph:()=>ft,shopifyImageSrc:()=>go,syncPanelHug:()=>Qr,timeWheelIndex:()=>st,timeWheelIndexFromScroll:()=>cn,timeWheelRows:()=>ln,toWireIdentifiedParams:()=>Ie,typedFragment:()=>ji,uiStringsFor:()=>M,visibleDateRange:()=>Mn,watchEditorHeight:()=>di,withSkippedParams:()=>Oe,withTimeWheelIndex:()=>lt,withoutTraditionalAutocomplete:()=>_t});module.exports=bs(od);function k(t){return t==="date"||t==="date-range"}function D(t){return t!=="options"}function Q(t){return t?.type?.kind==="date"?"date":t?.type?.kind==="date_range"?"date-range":t?.type?.kind==="time"?"time":t?.type?.kind==="location"&&!t.options?.length?"location":"options"}var Et=class{constructor(e){this.config=e;this.current=null;this.expiresAt=null;this.inFlightRefresh=null;e.accessToken&&(this.current=e.accessToken)}async getToken(e=!1){if(!e&&this.current&&!this.isExpired())return this.current;if(!e&&this.inFlightRefresh)return this.inFlightRefresh;this.inFlightRefresh=this.refresh();try{return await this.inFlightRefresh}finally{this.inFlightRefresh=null}}async refresh(){let e=await this.config.getAccessToken();return this.current=e.accessToken,this.expiresAt=e.expiresAt??null,this.current}isExpired(){return this.expiresAt==null?!1:Date.now()>=this.expiresAt-3e4}};var Ss="https://api.ai-autocomplete.com",Y=`${Ss}/api/suggest`,Pt=new Map([["api.ai-autocomplete.com","cdn.ai-autocomplete.com"],["dev-api.ai-autocomplete.com","dev-cdn.ai-autocomplete.com"]]),Io=new WeakMap;function qe(t){return t?.type==="accessToken"}function ys(t){if(!(!t||qe(t)))return t}function wt(t){let e=Io.get(t.getAccessToken);return e||(e=new Et(t),Io.set(t.getAccessToken,e)),e}function Ct(t){return{"Content-Type":"application/json",...t?.appIdentifier&&{"X-App-Identifier":t.appIdentifier},...t?.headers}}function Lt(t){let e=ys(t),n=e?.apiKey;return n?(e?.authScheme??"Bearer")==="Basic"?`Basic ${btoa(n)}`:`Bearer ${n}`:null}var yi="aiaPlace",Ke=2,ko=250,Oo=new Set("new san los las santa saint st fort port north south east west lake mount el la rio de palm long grand cape salt hong".split(" ")),Mo=new Set("city beach springs falls island park heights valley bay".split(" "));function Ro(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0)return"";let n=e[e.length-1].replace(/[.,]+$/,"");if(!n)return"";let i=e.length>1?e[e.length-2]:void 0,o=e.length>2?e[e.length-3]:void 0,r=a=>a.toLowerCase().replace(/[.,]+$/,"");return i&&o&&Oo.has(r(o))&&Mo.has(r(n))?`${o} ${i} ${n}`:i&&(Oo.has(r(i))||Mo.has(r(n)))?`${i} ${n}`:n}function Ti(t){let e=t.secondary?.split(",")[0]?.trim();return e?`${t.name}, ${e}`:t.name}function At(t){return typeof t=="string"?{text:t,is_tappable:!0,kind:null}:{text:Ti(t),is_tappable:!0,kind:null,metadata:{[yi]:{id:t.id}}}}function It(t){if(t?.locationEndpoint)return t.locationEndpoint;let e=t?.endpoint??Y,n=e.indexOf("?"),i=n<0?e:e.slice(0,n),o=n<0?"":e.slice(n+1);if(!/\/suggest\/?$/.test(i))return null;let r=i.replace(/\/suggest\/?$/,"/locations/autocomplete");return o?`${r}?${o}`:r}function _o(t){let e=t?.places;if(!Array.isArray(e))return[];let n=[];for(let i of e){let{id:o,name:r,secondary:a}=i??{};typeof o!="string"||!o||typeof r!="string"||!r.trim()||n.push({id:o,name:r.trim(),...typeof a=="string"&&a.trim()?{secondary:a.trim()}:{}})}return n}function Ie(t){return t.map(e=>({parameter:e.parameter,text:e.text}))}var xi="skipped";function Oe(t,e){if(t.some(o=>"group"in o)&&(t=t.map(o=>{let{group:r,...a}=o;return a})),e.length===0)return t;let n=new Set(t.map(o=>o.parameter)),i=e.filter(o=>!n.has(o.parameter)).map(o=>({placeholder:"",parameter:o.parameter,text:xi,kind:null}));return i.length>0?[...t,...i]:t}var Ts="0.68.0",vi="1.0",Do=!1;function xs(t,e){return{placeholder:t.placeholder,parameter:t.parameter,...e&&{text:t.value??t.text},kind:t.kind}}function oe(t){return t??(typeof navigator<"u"?navigator.language:"en-US")}function vs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Es(t,e,n,i,o,r,a,s,l,d,c,u,p){let f=e.find(b=>b.parameter==="contact"&&b.metadata?.contact_account_count)?.metadata?.contact_account_count,g=typeof f=="number"?f:void 0,h=vs();return{data:{raw_query:t,accepts_traditional_autocomplete:!0,client_option_parameters:p??[],completed_params:Oe(e.map(b=>xs(b,n)),l??[]),...a&&a.length>0&&{identified_params:Ie(a)},...s&&s.length>0&&{recently_suggested:s},...g!=null&&{contact_account_count:g},...d!==void 0&&{additional_context:d}},meta:{request_id:o,request_at:new Date().toISOString(),language:oe(c),...h&&{timezone:h},...u?.code&&Number.isFinite(u.rate)&&u.rate>0&&{currency:u.code,currency_rate:u.rate,...u.country!==void 0&&{country:u.country}},client_version:Ts,session_id:i,source:r,schema_version:vi}}}async function No(t,e,n,i,o){return fetch(t,{method:"POST",headers:{...e,Authorization:`Bearer ${n}`},body:i,signal:o})}async function Ho(t,e,n){let i=n.apiConfig,o=!n.maskCompletedText,r=Es(t,e,o,n.sessionId,n.requestId??crypto.randomUUID(),n.source,n.identifiedParams,n.recentlySuggested,n.skippedParams,n.additionalContext,n.language,n.currency,n.clientOptionParameters),a=i?.endpoint??Y,s=await Fo(a,JSON.stringify(r),i,n.signal);if(!s.ok)throw new Error(`API error: ${s.status} ${s.statusText}`);return s.json()}async function Fo(t,e,n,i){let o=Ct(n);if(qe(n)){let a=wt(n),s=await a.getToken(),l=await No(t,o,s,e,i);if(l.status===401){let d=await a.getToken(!0);l=await No(t,o,d,e,i)}return l}let r=Lt(n);return!r&&!Do&&(Do=!0,console.warn("[AIAutocomplete] No apiKey in apiConfig. Requests will be sent without an Authorization header.")),r&&(o.Authorization=r),fetch(t,{method:"POST",headers:o,body:e,signal:i})}var ze=class extends Error{constructor(n){super(`Location search error: ${n}`);this.status=n;this.name="LocationSearchError"}};async function Wo(t,e,n){let i=JSON.stringify({query:e,session_token:n.sessionToken,language:oe(n.language)}),o=await Fo(t,i,n.apiConfig,n.signal);if(!o.ok)throw new ze(o.status);return _o(await o.json())}var Ot=/[\p{L}\p{N}]/u,Ps=/['\u2019-]/;function Bo(t,e,n){let i=t[e];if(i===void 0)return!1;if(Ot.test(i))return!0;let o=t[e+n];return Ps.test(i)&&o!==void 0&&Ot.test(o)}function ws(t,e,n){let i=e+n.length;return!(Ot.test(n[0])&&Bo(t,e-1,-1)||Ot.test(n[n.length-1])&&Bo(t,i,1))}function te(t,e,n=0,i=()=>!0){if(e.length===0)return t.indexOf(e,n);let o=-1,r=t.indexOf(e,n);for(;r!==-1;){if(i(r)){if(ws(t,r,e))return r;o===-1&&(o=r)}r=t.indexOf(e,r+1)}return o}function N(t,e){let n=t,i={},o=[],r=[],a=0;for(let s of e){let l=(i[s.parameter]??0)+1;i[s.parameter]=l;let c=`{{${s.parameter.toUpperCase().replace(/\s+/g,"_")}_${l}}}`,u=f=>te(n,s.text,f,g=>!r.some(h=>g<h.end&&g+s.text.length>h.start)),p=u(a);if(p===-1&&(p=u(0)),p!==-1){n=n.slice(0,p)+c+n.slice(p+s.text.length);let f=c.length-s.text.length;for(let g of r)g.start>=p+s.text.length&&(g.start+=f,g.end+=f);r.push({start:p,end:p+c.length}),a=p>=a?p+c.length:a+f}o.push({...s,placeholder:c})}return{rawQuery:n,completedParams:o}}function re(t,e,n){return e>0||!n?e:t.toLowerCase().startsWith(n.toLowerCase())?n.length:e}function Me(t,e){return e===!1?"":t}function kt(t,e,n){return e===0&&t.length>0&&n.length>0&&n.toLowerCase().startsWith(t.toLowerCase())}function je(t,e,n){let i=t.slice(e);if(n||e===0||t[e-1]===" ")return i;let o=i.indexOf(" ");return o===-1?"":i.slice(o+1)}function Uo(t,e){let n=t.trimEnd().replace(/\s+/g," ");if(n.length===0||e.length===0)return 0;let i=n.split(" "),o=e.toLowerCase();for(let r=0;r<i.length;r++){let a=i.slice(r).join(" ");if(o.startsWith(a.toLowerCase())){let s=n.length-a.length;return t.length-s}}return 0}function Vo(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[_\-\s]+/g," ")}function Cs(t,e){let n=Vo(t).trim();return n.startsWith(e)||n.includes(` ${e}`)}function Se(t,e,n=!1){if(!t)return[];let i=e.trimStart();if(!i)return t;let o=n?Vo(i).trimStart():"";if(o)return t.filter(a=>!a.is_tappable||Cs(a.text,o));let r=i.toLowerCase();return t.filter(a=>!a.is_tappable||a.text.toLowerCase().includes(r))}function Mt(t,e){if(!t)return null;let n=e.trim();if(!n)return null;let i=n.toLowerCase();return t.find(o=>o.is_tappable&&o.text.toLowerCase()===i)??null}function Qe(t,e,n,i,o){let r=je(e,n,i),a=Mt(t,r);if(a||!o||!r.trim())return a;if(r===e.slice(n))return null;let s=e.lastIndexOf(" ",n-1)+1;return Mt(t,e.slice(s))}function Go(t,e){let n=e.replace(/^\s+/,"").toLowerCase();for(let i=0;i<n.length;){let o=n.slice(i);if(o.trim().length>=2){let a=t.findIndex(s=>s.is_tappable&&s.text.toLowerCase().startsWith(o));if(a>=0)return t.map((s,l)=>l===a?{...s,liveMatch:!0}:s)}let r=n.indexOf(" ",i);if(r<0)break;i=r+1}return t}function qo(t,e){return e?t.map(n=>e[n.parameter]?{...n,options:[]}:n):t}function Ko(t,e){let{icon:n,icon_svg:i}=e;return!i||t.every($o)?t:t.map(o=>$o(o)?o:{...o,icon:n,icon_svg:i})}function $o(t){return!!(t.icon_svg||t.image_url)}function Ls(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function X(t){let e=Ls(t);return e.length>0?e.join(" "):t}function J(t,e){return t.parameter||e}function Ye(t){return{parameter:t,suggestionParameter:t,suggestionValueType:{kind:"traditional_autocomplete"},suggestionPlaceholder:X(t)}}function Rt(t,e){let n=J(e,t.suggestionParameter);return t.suggestionValueType?.kind==="traditional_autocomplete"?Ye(n):{parameter:n,suggestionParameter:t.suggestionParameter,suggestionValueType:t.suggestionValueType,suggestionPlaceholder:t.suggestionPlaceholder,suggestionIcon:t.suggestionIcon,suggestionIconSvg:t.suggestionIconSvg}}function L(t){return t?.type?.kind==="traditional_autocomplete"}function zo(t){let e=t?.replace(/[_\-\s]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):void 0}function Xe(t){return L(t)||t?.smart_suggestion===!0}function _t(t){return t.some(L)?t.filter(e=>!L(e)):t}function Dt(t,e){return t.some(n=>L(n)&&!n.text)?t.map(n=>L(n)&&!n.text?{...n,text:e}:n):t}var Nt='<svg viewBox="0 0 20 20" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path class="aia-sparkle-large" d="M8 5C8.5 9.5 10.5 11.5 15 12C10.5 12.5 8.5 14.5 8 19C7.5 14.5 5.5 12.5 1 12C5.5 11.5 7.5 9.5 8 5Z"/><path class="aia-sparkle-small" d="M16 1C16.2 3 17 3.8 19 4C17 4.2 16.2 5 16 7C15.8 5 15 4.2 13 4C15 3.8 15.8 3 16 1Z"/></svg>';function Ht(t){return t.some(e=>!L(e))}function jo(t,e){let n=0,i=e;for(let o of t)n+=o.value.length,o.type!=="text"&&(i=Math.max(i,n));return i}function Qo(t,e){let n=0;for(let i of t){let o=n+i.value.length;if(i.type==="text"&&o>e&&i.value.slice(Math.max(e-n,0)).trim().length>0)return!1;n=o}return!0}function Yo(t,e){let n=[],i=new Map;for(let o of[...t,...e]){if(o.parameter==="placeholder"||L(o))continue;let r=i.get(o.parameter);r||(r={parameter:o.parameter,text:o.text},i.set(o.parameter,r),n.push(r));for(let a of o.options??[])!a.is_tappable||r.options?.includes(a.text)||(r.options??(r.options=[]),r.options.push(a.text))}return n}function Xo(t,e,n){if(t===e)return n;let i=Math.min(t.length,e.length),o=0;for(;o<i&&t[o]===e[o];)o++;if(o>=n)return n;let r=0;for(;r<i-o&&t[t.length-1-r]===e[e.length-1-r];)r++;return t.length-r<=n?n+(e.length-t.length):null}function Ft(t,e){let n=[],i=[],o=0;for(let r of e){let a=te(t,r.text,o);if(a===-1){i.push(r);continue}n.push({start:a,end:a+r.text.length,param:r}),o=a+r.text.length}return{located:n,missing:i}}function ye(t,e){let{located:n}=Ft(t,e);return n.length>0?n[n.length-1].end:0}function Jo(t,e,n){let i=[],o=[],r=0;for(let a of n){let s=te(t,a.text,r,l=>!e.some(d=>l<d.end&&l+a.text.length>d.start));if(s===-1){o.push(a);continue}i.push({start:s,end:s+a.text.length,param:a}),r=s+a.text.length}return{located:i,missing:o}}function Zo(t,e,n=[]){let i=Ft(t,e).located,o=[];for(let c of i){let u=o[o.length-1];c.param.group&&u?.param.group===c.param.group?(u.end=c.end,u.params?.push(c.param)):o.push({...c,...c.param.group?{params:[c.param]}:{}})}let r=Jo(t,o,n).located,a=[...o.map(c=>({start:c.start,end:c.end,segment:{type:"completed",value:t.slice(c.start,c.end),param:c.param,...c.params?{params:c.params}:{}}})),...r.map(c=>({start:c.start,end:c.end,segment:{type:"identified",value:c.param.text,param:c.param}}))].sort((c,u)=>c.start-u.start),s=[],l=0;for(let c of a)c.start>l&&s.push({type:"text",value:t.slice(l,c.start)}),s.push(c.segment),l=c.end;let d=t.slice(l);return d&&s.push({type:"text",value:d}),s}function er(t,e){let{located:n,missing:i}=Ft(t,e),o=new Set(i.map(a=>a.group).filter(Boolean)),r=n.map(a=>a.param).filter(a=>!o.has(a.group));return{valid:r,invalid:e.filter(a=>!r.includes(a))}}function Je(t,e,n){let i=Ft(t,e).located,{located:o,missing:r}=Jo(t,i,n);return{valid:o.map(a=>a.param),invalid:r}}function tr(t,e,n){let i=e?.endpoint??Y,o=i.replace(/\/suggest(?=[?#]|$)/,`/starting-state/${encodeURIComponent(t)}${As(n)}`);if(o!==i)return o.replace(/^https:\/\/([^/?#]+)/,(r,a)=>{let s=Pt.get(a);return s?`https://${s}`:r})}function As(t){let e=t?.replace(/_/g,"-").toLowerCase()??"",[n,i=""]=e.split("-");return n!=="zh"?/^[a-z]{2,3}$/.test(n)?`/${n}`:"":/^[a-z]{4}$/.test(i)?i==="hant"?"/zh-TW":"/zh":["tw","hk","mo"].includes(i)?"/zh-TW":"/zh"}async function nr(t){try{let e=await t;if(!e.ok)return null;let n=await e.json();return Array.isArray(n?.data?.suggestions)?n:null}catch{return null}}function Is(t){if(t instanceof Error)return t;try{return new Error(String(t))}catch{return new Error("Unknown error")}}var Os=100,Ms=300,ks=2,Wt=class{constructor(e,n,i,o,r,a,s,l,d,c={}){this.store=e;this.getApiConfig=n;this.getOptionOverrides=i;this.getMaskCompletedText=o;this.getOnError=r;this.getSessionId=a;this.getSource=s;this.getAdditionalContext=l;this.getLanguage=d;this.callbacks=c;this.fetchVersion=0;this.abortController=null;this.debounceTimer=null;this.slowDebounceTimer=null;this.unsubscribe=null;this.phraseExactMatch=!1}start(){this.doFetch("",[]);let e=this.store.get().text,n=this.store.get().completedParams;this.unsubscribe=this.store.subscribe(i=>{(i.text!==e||i.completedParams!==n)&&(e=i.text,n=i.completedParams,this.scheduleFetch())})}isPhraseExactMatch(){return this.phraseExactMatch}dispose(){this.abortController?.abort(),this.clearTimers(),this.unsubscribe?.()}async doFetch(e,n){this.abortController?.abort();let i=new AbortController;this.abortController=i;let o=++this.fetchVersion,r=this.store.get().text.length,a=this.store.get().text;try{this.callbacks.onRequest?.({query:this.store.get().text,signal:i.signal,isCurrent:()=>o===this.fetchVersion})}catch{}try{this.store.set({isLoading:!0,error:null});let s=this.store.get(),l=s.pendingSpan?Yo(s.pendingSpan.snapshot,s.actionableSuggestions):void 0,d=crypto.randomUUID(),c=e===""&&n.length===0&&s.skippedParams.length===0&&s.identifiedParams.length===0?this.startingStateUrl():void 0,u=c?await nr(fetch(c,{signal:i.signal})):null;if(o!==this.fetchVersion)return;let p=u??await Ho(e,n,{sessionId:this.getSessionId(),requestId:d,source:this.getSource(),maskCompletedText:this.getMaskCompletedText(),signal:i.signal,apiConfig:this.getApiConfig(),identifiedParams:s.identifiedParams,recentlySuggested:l,skippedParams:s.skippedParams,additionalContext:this.getAdditionalContext(),language:this.getLanguage(),currency:this.callbacks.getCurrency?.(),clientOptionParameters:Object.keys(this.getOptionOverrides()??{})});if(o!==this.fetchVersion)return;this.phraseExactMatch=p.meta?.phrase_exact_match===!0;let f=(p.data.suggestions??[]).find(L),g=f?[]:p.data.input??[],h=v=>({id:crypto.randomUUID(),parameter:v.parameter,text:v.text,...v.type?{type:v.type}:{},...v.iso_date?{isoDate:v.iso_date}:{},...v.iso_date_end?{isoDateEnd:v.iso_date_end}:{}}),b=g.filter(v=>v.source==="identified");this.callbacks.waitIdentified?.(b.filter(v=>v.state==="need_confirmation").map(h),a);let x=b.filter(v=>v.state!=="need_confirmation").map(h),m=this.callbacks.isWordOpen?.()??!1,S=this.store.get().text.toLowerCase(),P=v=>m&&S.endsWith(v.text.toLowerCase()),T=x.filter(v=>!P(v));m&&this.callbacks.holdIdentified?.(x.filter(P));let E=f?[f]:qo(p.data.suggestions??[],this.getOptionOverrides()),w=g,y=w[w.length-1],C=this.store.get().text,_,O;if(y?.state==="in_progress"){O=!0;let v=C.toLowerCase().lastIndexOf(y.text.toLowerCase());_=v!==-1?v:r}else O=!1,_=r;let A=E.filter(v=>v.parameter!=="placeholder")[0],V=null;if(A&&!L(A)&&!m&&A.type?.kind!=="multi_select"&&!D(Q(A))){let v=Qe(A.options,C,_,O,this.phraseExactMatch);v&&(V={id:crypto.randomUUID(),placeholder:"",parameter:J(v,A.parameter),text:v.text,value:v.value,kind:v.kind,suggestionParameter:A.parameter,suggestionValueType:A.type,suggestionPlaceholder:A.text,suggestionIcon:A.icon,suggestionIconSvg:A.icon_svg,options:A.options??[],metadata:v.metadata,icon:v.icon,icon_svg:v.icon_svg,image_url:v.image_url},E=E.filter(he=>he!==A),this.callbacks.onAutoMatch?.({active:A,matched:v,rawQuery:e}))}let fe=p.data.custom_fields??null,j=this.callbacks.productsForResponse?.(fe);this.store.set(v=>{let he=V?[...v.completedParams,V]:v.completedParams,be=Je(v.text,he,T).valid,Tt=new Set(s.skippedParams.map(z=>z.id)),xt=new Set(v.skippedParams.filter(z=>!Tt.has(z.id)).map(z=>z.parameter));return{suggestions:xt.size>0?E.filter(z=>z.parameter==="placeholder"||!xt.has(z.parameter)):E,isLoading:!1,isReady:p.data.is_ready??!1,lastRawQuery:e,activeDropdownIndex:-1,filterBase:_,filterInProgress:O,identifiedParams:be,customFields:fe,traditionalAutocomplete:p.meta?.traditional_autocomplete===!0,...j!==void 0?{products:j}:{},...V?{completedParams:he}:{}}}),this.callbacks.onResponse?.({requestId:d,funnelTelemetry:p.meta?.funnel_telemetry===!0,visibleImpression:p.meta?.visible_impression===!0})}catch(s){let l=Is(s);o===this.fetchVersion&&(this.store.set({error:l,isLoading:!1}),this.getOnError()?.(l))}finally{if(o===this.fetchVersion&&this.store.get().isLoading)try{this.store.set({isLoading:!1})}catch{}}}startingStateUrl(){let e=this.callbacks.getProductId?.();return e?tr(e,this.getApiConfig(),oe(this.getLanguage())):void 0}attemptNow(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.attemptFetch(1,!0)}scheduleFetch(){if(this.clearTimers(),this.store.get().skipNextFetch){this.store.set({skipNextFetch:!1});return}this.debounceTimer=setTimeout(()=>{this.attemptFetch(ks)&&this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer)},Os),this.slowDebounceTimer=setTimeout(()=>this.attemptFetch(1,!0,!0),Ms)}attemptFetch(e,n=!1,i=!1){let o=this.store.get();if(!o.text&&o.completedParams.length===0)return this.doFetch("",[]),!0;let r=this.callbacks.consumerTick?.(o,e)??"no";if(r==="asked")return!0;if(r==="owns")return!1;let a=Me(o.suggestions.filter(E=>E.parameter==="placeholder").map(E=>E.text).join(" "),this.callbacks.getPrependPlaceholder?.()),s=re(o.text,o.filterBase,a),l=je(o.text,s,o.filterInProgress),d=o.suggestions.filter(E=>E.parameter!=="placeholder"),c=L(d[0])?void 0:d[0],u=D(o.activeFormatType),p=c&&!u?Se(c.options,l,o.traditionalAutocomplete):[];if(o.multiSelectView&&l.trim().length>0&&p.length>0)return!1;let f=p.filter(E=>E.is_tappable),g=c&&!u&&!this.callbacks.isWordOpen?.()?Qe(c.options,o.text,s,o.filterInProgress,this.phraseExactMatch)!==null:!1,h=l.trim().length>0,b=i&&o.products.length>0;if(f.length>0&&!g&&h&&!b||kt(o.text,o.completedParams.length,a))return!1;let{rawQuery:x,completedParams:m}=N(o.text,o.completedParams),S=x.length<o.lastRawQuery.length,P=Math.abs(x.length-o.lastRawQuery.length),T=n&&x!==o.lastRawQuery;return S||P>=e||T?(this.doFetch(x,m),!0):!1}clearTimers(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.slowDebounceTimer&&clearTimeout(this.slowDebounceTimer),this.debounceTimer=null,this.slowDebounceTimer=null}};var Rs="(hover: none) and (pointer: coarse)";var _s="[data-aia-dropdown], [data-aia-input-wrapper]",Ds=["a[href]","button","input","select","textarea","label","summary","[contenteditable]:not([contenteditable='false'])","[role='button']","[role='link']","[tabindex]:not([tabindex='-1'])"].join(", "),Bt=class{constructor(e,n){this.store=e;this.container=n;this.listening=!1;this.declined=!1;this.pressOutside=!1;this.pressWhileFocused=!1;this.recheckTimer=null;this.releaseTimer=null;this.onPointerDown=e=>{let n=e.composedPath(),i=this.isInside(n);this.pressOutside=!i;let o=this.store.get();this.pressWhileFocused=o.isFocused,!(i||!o.isFocused)&&(this.declined=n.some(r=>r instanceof Element&&r.matches(Ds)),this.declined&&o.dropdownHeld?this.store.set({dropdownHeld:!1}):!this.declined&&!o.dropdownHeld&&o.isDropdownOpen&&this.store.set({dropdownHeld:!0}))};this.onPointerCancel=()=>{this.pressOutside=!1,this.pressWhileFocused&&this.declined&&this.scheduleRecheck(),this.pressWhileFocused=!1};this.onPointerUp=e=>{let n=this.pressOutside&&!this.isInside(e.composedPath()),i=this.pressWhileFocused;if(this.pressOutside=!1,this.pressWhileFocused=!1,i){this.declined&&this.scheduleRecheck();return}!n||this.store.get().isFocused||(this.cancelRelease(),this.releaseTimer=setTimeout(()=>{this.releaseTimer=null;let o=this.store.get();o.dropdownHeld&&!o.isFocused&&this.store.set({dropdownHeld:!1})},150))};this.touchPrimary=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Rs):null,this.unsubscribe=e.subscribe(()=>this.sync())}dispose(){this.unsubscribe(),this.listen(!1),this.cancelRelease(),this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=null}sync(){let e=this.store.get(),n=this.touchPrimary?.matches??!1;e.isFocused||(this.declined=!1),e.isDropdownOpen?e.isFocused&&!e.dropdownHeld&&!this.declined&&n&&this.store.set({dropdownHeld:!0}):e.dropdownHeld&&this.store.set({dropdownHeld:!1});let i=this.store.get();this.listen(n&&i.isDropdownOpen),i.isFocused&&this.cancelRelease()}listen(e){if(!(e===this.listening||typeof document>"u")){if(this.listening=e,e){document.addEventListener("pointerdown",this.onPointerDown,!0),document.addEventListener("pointerup",this.onPointerUp,!0),document.addEventListener("pointercancel",this.onPointerCancel,!0);return}document.removeEventListener("pointerdown",this.onPointerDown,!0),document.removeEventListener("pointerup",this.onPointerUp,!0),document.removeEventListener("pointercancel",this.onPointerCancel,!0),this.pressOutside=!1}}scheduleRecheck(){this.recheckTimer!==null&&clearTimeout(this.recheckTimer),this.recheckTimer=setTimeout(()=>{this.recheckTimer=null,!(!this.declined||!this.store.get().isFocused)&&(this.declined=!1,this.sync())},150)}cancelRelease(){this.releaseTimer!==null&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}isInside(e){let n=this.container,i=n?.getRootNode(),o=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i.host:null;for(let r of e)if(r===n||r===o||r instanceof Element&&r.matches(_s))return!0;return!1}};var ke=["January","February","March","April","May","June","July","August","September","October","November","December"],Ze=["S","M","T","W","T","F","S"],rr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar="aiaDate",sr="aiaDay",ir=t=>String(t).padStart(2,"0");function G(t){return`${t.getFullYear()}-${ir(t.getMonth()+1)}-${ir(t.getDate())}`}function Ei(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Ns(t){let e=Ei(t).getTime()-Ei(new Date).getTime();return Math.round(e/864e5)}function Pi(t){let e=Ns(t);return e>=0&&e<7?rr[t.getDay()]:Te(t)}function Te(t){return t.getFullYear()===new Date().getFullYear()?`${ke[t.getMonth()]} ${t.getDate()}`:`${ke[t.getMonth()]} ${t.getDate()} ${t.getFullYear()}`}function et(t){if(!t)return null;let e=rr.findIndex(s=>s.toLowerCase()===t.trim().toLowerCase());if(e>=0){let s=Ei(new Date),l=(e-s.getDay()+7)%7;return new Date(s.getFullYear(),s.getMonth(),s.getDate()+l)}let n=/^\s*([A-Za-z]+)\s+(\d{1,2})(?:\s+(\d{4}))?\s*$/.exec(t);if(!n)return null;let i=ke.findIndex(s=>s.toLowerCase()===n[1].toLowerCase());if(i<0)return null;let o=Number(n[2]),r=n[3]?Number(n[3]):new Date().getFullYear(),a=new Date(r,i,o);return a.getMonth()!==i||a.getDate()!==o?null:a}function Ut(t){return`${ke[t.month]} ${t.year}`}function wi(){let t=new Date;return{year:t.getFullYear(),month:t.getMonth()}}function lr(t){return{year:t.getFullYear(),month:t.getMonth()}}function Vt(t,e){let n=new Date(t.year,t.month+e,1);return{year:n.getFullYear(),month:n.getMonth()}}function or(){return{text:"",is_tappable:!1,kind:null}}function Gt(t){let e=new Date(t.year,t.month,1).getDay(),n=new Date(t.year,t.month+1,0).getDate(),i=[];for(let o=0;o<e;o++)i.push(or());for(let o=1;o<=n;o++){let r=new Date(t.year,t.month,o);i.push({text:Pi(r),is_tappable:!0,kind:null,metadata:{[ar]:G(r),[sr]:o}})}for(;i.length%Ze.length!==0;)i.push(or());return i}function $t(t){let e=et(t);return e?G(e):null}function $(t){let e=t?.metadata?.[ar];return typeof e=="string"?e:null}function qt(t){let e=t?.metadata?.[sr];return typeof e=="number"?e:null}function Hs(t){return t.nodeType===Node.DOCUMENT_NODE?!0:t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function ae(t){let e=typeof t.getRootNode=="function"?t.getRootNode():null;return e&&Hs(e)?e:t.ownerDocument??t}function Kt(t){return ae(t).activeElement??null}function R(t){return t.ownerDocument??t}function Fs(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function cr(t){let e=ae(t);return!Fs(e)||typeof e.getSelection=="function"?null:e}function dr(t){let e=cr(t);if(!e)return null;let n=R(t).getSelection?.();return!n||typeof n.getComposedRanges!="function"?null:e}function ur(t,e){let n=t,i;try{i=n.getComposedRanges({shadowRoots:[e]})}catch{i=n.getComposedRanges(e)}return i.length>0?i[0]:null}function tt(t){let n=ae(t).getSelection?.();return n||(R(t).getSelection?.()??null)}function se(t){let e=tt(t);if(!e||e.rangeCount===0)return null;let n=dr(t);if(n){let i=ur(e,n);return i?{node:i.startContainer,offset:i.startOffset,collapsed:i.startContainer===i.endContainer&&i.startOffset===i.endOffset}:null}return e.anchorNode?{node:e.anchorNode,offset:e.anchorOffset,collapsed:e.isCollapsed}:null}function xe(t){let e=tt(t);if(!e||e.rangeCount===0)return null;let n=dr(t);if(!n)return e.getRangeAt(0);let i=ur(e,n);if(!i)return null;let o=R(t).createRange();return o.setStart(i.startContainer,i.startOffset),o.setEnd(i.endContainer,i.endOffset),o}function nt(t,e,n){let i=tt(t);if(!i)return null;if(cr(t))return i.collapse(e,n),i;let o=R(t).createRange();return o.setStart(e,n),o.collapse(!0),i.removeAllRanges(),i.addRange(o),i}function zt(t,e){let n=t?ae(t):typeof document<"u"?document:null;return n?typeof n.getElementById=="function"?n.getElementById(e):typeof document<"u"?document.getElementById(e):null:null}var jt=2,Ws="magicx-aia";function mr(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="overlay"}function Bs(t){let e=R(t),n=e.defaultView;if(!n?.getComputedStyle)return null;let i=t;for(;i&&i!==e.body&&i!==e.documentElement;){let o=i.scrollWidth>i.clientWidth,r=i.scrollHeight>i.clientHeight;if(o||r){let a=n.getComputedStyle(i);if(o&&mr(a.overflowX)||r&&mr(a.overflowY))return i}if(i.classList.contains(Ws))return null;i=i.parentElement}return null}function Qt(t){let e=xe(t);if(!e||!e.collapsed||!t.contains(e.startContainer))return;let n=Bs(t);if(!n||typeof e.getBoundingClientRect!="function")return;let i=e.getBoundingClientRect();if(i.height===0)return;let o=n.getBoundingClientRect();if(n.scrollWidth>n.clientWidth){let r=o.left+n.clientLeft,a=r+n.clientWidth;i.right>a?n.scrollLeft+=i.right-a+jt:i.left<r&&(n.scrollLeft-=r-i.left+jt)}if(n.scrollHeight>n.clientHeight){let r=o.top+n.clientTop,a=r+n.clientHeight;i.bottom>a?n.scrollTop+=i.bottom-a+jt:i.top<r&&(n.scrollTop-=r-i.top+jt)}}var gr='[contenteditable="false"]',Li="strong[data-param-id]",Re;function Us(){if(Re!==void 0)return Re;let t=globalThis.Intl.Segmenter;if(!t)return Re=null,null;try{Re=new t(void 0,{granularity:"grapheme"})}catch{Re=null}return Re??null}function Yt(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&n.matches(gr))return!0;n=n.parentNode}return!1}function Xt(t){return R(t).createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(e){return Yt(e,t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function it(t){let e=Xt(t),n="",i=e.nextNode();for(;i;)n+=i.data,i=e.nextNode();return n}function Jt(t){let e=Xt(t),n=0,i=e.nextNode();for(;i;)n+=i.data.length,i=e.nextNode();return n}function q(t){let e=se(t);if(!e)return null;let n=e.node,i=e.offset;if(!t.contains(n))return null;if(n.nodeType===Node.ELEMENT_NODE){let o=n;if(Yt(o,t)&&o!==t)return null;let r=0;for(let a=0;a<i&&a<o.childNodes.length;a++)r+=Ai(o.childNodes[a],t);return r+Ci(o,t)}return n.nodeType!==Node.TEXT_NODE||Yt(n,t)?null:Ci(n,t)+i}function Ai(t,e){if(t.nodeType===Node.TEXT_NODE)return Yt(t,e)?0:t.data.length;if(t.nodeType!==Node.ELEMENT_NODE)return 0;let n=t;if(n.matches(gr))return 0;let i=0;for(let o of Array.from(n.childNodes))i+=Ai(o,e);return i}function Ci(t,e){let n=Xt(e),i=0,o=n.nextNode();for(;o;){if(o===t||t.nodeType===Node.ELEMENT_NODE&&t.contains(o))return i;i+=o.data.length,o=n.nextNode()}return i}function H(t,e){let n=R(t),i=Math.max(0,Math.min(e,Jt(t))),o=Xt(t),r=0,a=null,s=0,l=o.nextNode(),d=null;for(;l;){let u=l.data.length;if(i<r+u){a=l,s=i-r;break}if(i===r+u){let p=o.nextNode();p?(a=p,s=0):(a=l,s=u);break}r+=u,d=l,l=o.nextNode()}let c=n.createRange();if(a){let u=a.parentElement?.closest('strong[data-seg="completed"]');u&&u!==t&&t.contains(u)?s===0?c.setStartBefore(u):s===a.data.length?c.setStartAfter(u):c.setStart(a,s):c.setStart(a,s)}else d?c.setStart(d,d.data.length):c.setStart(t,0);c.collapse(!0),nt(t,c.startContainer,c.startOffset)&&(Vs(t,c,i),Qt(t))}function pr(t,e){if(!t||!e.contains(t))return null;let i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(Li)??null;return i&&e.contains(i)?i:null}function Vs(t,e,n){let i=pr(se(t)?.node??null,t);if(i&&i!==pr(e.startContainer,t)){t.dataset.aiaCaretEscapedChip=`${n}:${i.dataset.paramId}`;return}delete t.dataset.aiaCaretEscapedChip}function fr(t,e){let n=t.dataset.aiaCaretEscapedChip;if(!n)return!1;let i=q(t);return i!==null&&n===`${i}:${e}`}function hr(t){return ae(t).activeElement===t}function Zt(t,e){if(!e||e.nodeType===void 0)return null;let n=e,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(Li);if(!o||!t.contains(o))return null;let r=se(t);return r&&!r.collapsed?null:o.dataset.paramId??null}function en(t,e){let n=null;for(let a of t.querySelectorAll(Li))if(a.dataset.paramId===e){n=a;break}if(!n)return;let i=Ci(n,t),o=i+Ai(n,t),r=q(t);r!=null&&r>=i&&r<=o||H(t,i)}function tn(t){let e=q(t);return e==null?!1:e>=Jt(t)}function nn(t,e){if(e<=0)return 0;let n=Us();if(!n)return e-1;let i=t.slice(0,e),o=0;for(let{index:r}of n.segment(i))r<e&&(o=r);return o}var Ii="aiaTime",an=5;var Oi=[12,1,2,3,4,5,6,7,8,9,10,11],Mi=Array.from({length:60/5},(t,e)=>e*5),ki=["AM","PM"];function De(t){return(Math.round(t)%1440+1440)%1440}function Ri(t){let e=De(t),n=Math.floor(e/60);return{hour:n%12===0?12:n%12,minute:e%60,period:n<12?"AM":"PM"}}function on(t){let e=t.hour%12+(t.period==="PM"?12:0);return De(e*60+t.minute)}function ot(t){let{hour:e,minute:n,period:i}=Ri(t);return`${e}:${String(n).padStart(2,"0")} ${i}`}function _i(t){let e=De(t);return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function _e(t){return De(Math.round(t/5)*5)}function br(t,e){return De(t+e)}var Gs=/^(\d{1,2})(?::(\d{2}))?\s*([ap])\.?\s*m?\.?$/i,$s=/^(\d{1,2}):(\d{2})$/;function rn(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="noon"||e==="midday")return 720;if(e==="midnight")return 0;let n=Gs.exec(e);if(n){let o=Number(n[1]),r=n[2]===void 0?0:Number(n[2]);return o<1||o>12||r>59?null:on({hour:o,minute:r,period:n[3]==="a"?"AM":"PM"})}let i=$s.exec(e);if(i){let o=Number(i[1]),r=Number(i[2]);return o>23||r>59?null:o*60+r}return null}function Sr(t){let e=rn(t.editingText);if(e!=null)return _e(e);let n=(t.options??[]).filter(o=>o.is_tappable).map(o=>rn(o.text)).filter(o=>o!=null);if(n.length>0)return _e(n[Math.floor((n.length-1)/2)]);let i=t.now??new Date;return De((i.getHours()+1)*60)}function sn(t){return{text:ot(t),is_tappable:!0,kind:null,metadata:{[Ii]:_i(t)}}}var rt=30,at=["hour","minute","period"],Di={hour:Oi.map(t=>({label:String(t)})),minute:Mi.map(t=>({label:String(t).padStart(2,"0")})),period:ki.map(t=>({label:t}))};function ln(t){return Di[t]}function st(t,e){let n=Ri(_e(e));return t==="hour"?Oi.indexOf(n.hour):t==="minute"?Mi.indexOf(n.minute):ki.indexOf(n.period)}function lt(t,e,n){let i=Di[t],o=Math.min(Math.max(n,0),i.length-1),r=Ri(_e(e));return on(t==="hour"?{...r,hour:Oi[o]}:t==="minute"?{...r,minute:Mi[o]}:{...r,period:ki[o]})}function cn(t,e){let n=Di[t].length-1;return Math.min(Math.max(Math.round(e/rt),0),n)}function le(t,e,n=[],i={}){let{rawQuery:o,completedParams:r}=N(t,e);return{query:t.trim(),raw_query:o,completed_params:Oe(r,n),identified_params:Ie(i.identifiedParams??[]),is_ready:i.isReady??!1,...i.customFields?{custom_fields:i.customFields}:{}}}function dn(t,e){return t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement?t.selectionStart!=null&&t.selectionStart===t.value.length:t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?tn(t):e?.caretOffset!=null?e.caretOffset>=e.text.length:!1}function Ni(t){return t instanceof HTMLElement&&t.hasAttribute("data-aia-input")?q(t):null}var un=class{constructor(e,n){this.store=e;this.ctx=n}handleKeyDown(e){if(e.isComposing||e.keyCode===229)return;let n=this.store.get(),{listboxId:i,getOnSubmit:o}=this.ctx,r=e.target instanceof Node?e.target:null,a=this.getEffectiveColumns(r),s=o(),l=this.getTappableIndices(a);if((e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)&&(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return;let d=this.ctx.getOptionsPosition()==="above";if(n.multiSelectView&&n.isDropdownOpen){let c=n.filteredOptions[n.activeDropdownIndex];if(e.key===" "&&!n.optionQuery&&c?.is_tappable){e.preventDefault(),this.ctx.selectOption(c);return}if(e.key==="Enter"){e.preventDefault(),n.multiSelectView.picked.length===0&&c?.is_tappable&&this.ctx.selectOption(c),this.ctx.commitMultiSelect?.();return}}if(!this.handleTimeWheelKey(e,n))switch(e.key){case"ArrowDown":{let c=dn(e.target,n),u=!!n.editingParam;if(!c&&!u&&n.activeDropdownIndex<0)break;if(n.activeDropdownIndex<0){if(d)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!1):l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(e.preventDefault(),l.length===0)return;if(k(n.activeFormatType)){this.stepDateWeek(n,7);break}if(n.filteredOptions.length>0){let g=Math.floor((n.filteredOptions.length-1)/a);if(Math.floor(n.activeDropdownIndex/a)===g){this.store.set({activeDropdownIndex:-1});break}}let p=l.indexOf(n.activeDropdownIndex),f=p<l.length-1?p+1:0;this.store.set({activeDropdownIndex:l[f]});break}case"ArrowUp":{if(n.activeDropdownIndex<0){if(!d)break;let p=dn(e.target,n),f=!!n.editingParam;if(!p&&!f)break;e.preventDefault();let g=k(n.activeFormatType)?this.dateEntryIndex(n,!0):this.firstTappableInBottomRow(a)??l[0]??0;if(!n.isDropdownOpen&&n.actionableSuggestions.length>0){this.store.set({pillTapped:!0,activeDropdownIndex:g});break}if(l.length===0)return;this.store.set({activeDropdownIndex:g});break}if(l.length===0)break;if(e.preventDefault(),k(n.activeFormatType)){this.stepDateWeek(n,-7);break}if(n.activeDropdownIndex<a){this.store.set({activeDropdownIndex:-1});break}let c=l.indexOf(n.activeDropdownIndex),u=c>0?c-1:l.length-1;this.store.set({activeDropdownIndex:l[u]});break}case"ArrowRight":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,1);break}if(n.activeDropdownIndex%a<a-1){let p=n.activeDropdownIndex+1;p<n.filteredOptions.length&&n.filteredOptions[p]?.is_tappable&&this.store.set({activeDropdownIndex:p})}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){e.preventDefault();let u=e.target.closest("[data-aia-input]")??e.target,p=n.editingTail;this.ctx.exitEditMode?.(),H(u,p);break}dn(e.target,n)&&n.actionableSuggestions.length>=1&&(e.preventDefault(),this.ctx.skipActivePill());break}case"ArrowLeft":{if(n.activeDropdownIndex>=0){if(e.preventDefault(),k(n.activeFormatType)){this.stepDateDay(n,-1);break}if(n.activeDropdownIndex%a>0){let c=n.activeDropdownIndex-1;c>=0&&n.filteredOptions[c]?.is_tappable&&this.store.set({activeDropdownIndex:c});break}if(!n.editingParam&&this.ctx.startEditingParamAtCaret){let c=Ni(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)}break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingAnchor!=null){e.preventDefault();let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingAnchor;this.ctx.exitEditMode?.(),H(c,u);break}if(this.ctx.startEditingParamAtCaret){let c=Ni(e.target);c!=null&&this.ctx.startEditingParamAtCaret(c)&&e.preventDefault()}break}case"Backspace":{if(n.editingParam||!this.ctx.removeParamAtCaret)break;let c=Ni(e.target);if(c==null)break;this.ctx.removeParamAtCaret(c)&&e.preventDefault();break}case"Enter":{if(e.preventDefault(),n.activeDropdownIndex>=0&&n.filteredOptions[n.activeDropdownIndex]?.is_tappable)this.clickOrSelect(n.activeDropdownIndex,n.filteredOptions,i,r);else if(s){this.ctx.endTypedWord?.(!0);let c=this.store.get();s(le(c.text,c.completedParams,c.skippedParams,{identifiedParams:c.identifiedParams,isReady:c.isReady,customFields:c.customFields}))&&this.ctx.afterSubmit?.()}break}case"Tab":{if(this.ctx.endTypedWord?.()){e.preventDefault();break}let c=n.filteredOptions.map((f,g)=>f.is_tappable?g:-1).filter(f=>f!==-1);if(c.length===0)break;if(!n.isDropdownOpen){if(n.actionableSuggestions.length===0)break;e.preventDefault();let f=e.shiftKey?c[c.length-1]:c[0];this.store.set({pillTapped:!0,activeDropdownIndex:f});break}e.preventDefault();let u=c.indexOf(n.activeDropdownIndex),p;if(u<0)p=e.shiftKey?c.length-1:0;else{let f=e.shiftKey?-1:1;p=(u+f+c.length)%c.length}this.store.set({activeDropdownIndex:c[p]});break}case"Escape":{if(n.dateRangeStart){this.store.set({pendingRangeStart:null});break}if(n.editingIdentified){this.ctx.exitEditingIdentified?.(),this.store.set({activeDropdownIndex:-1});break}if(n.editingParam&&e.target instanceof HTMLElement&&n.editingTail!=null){let c=e.target.closest("[data-aia-input]")??e.target,u=n.editingTail;this.ctx.exitEditMode?.(),H(c,u)}this.store.set({activeDropdownIndex:-1});break}}}handleTimeWheelKey(e,n){let i=n.timeView;if(n.activeFormatType!=="time"||!i||!n.isDropdownOpen)return!1;switch(e.key){case"ArrowDown":case"ArrowUp":return!dn(e.target,n)&&!n.editingParam?!1:(e.preventDefault(),this.ctx.stepTime?.(e.key==="ArrowDown"?5:-5),!0);case"Enter":return i.touched?(e.preventDefault(),this.ctx.commitTime?.(),!0):!1;case"Escape":return i.touched?(this.store.set({timeDraft:null}),!0):!1;default:return!1}}firstTappableInBottomRow(e){let n=this.store.get();if(n.filteredOptions.length===0)return null;let o=Math.floor((n.filteredOptions.length-1)/e)*e;for(let r=o;r<n.filteredOptions.length;r++)if(n.filteredOptions[r]?.is_tappable)return r;return null}dateEntryIndex(e,n){if(e.dateFloor){let a=e.filteredOptions.findIndex(s=>$(s)===e.dateFloor);if(a>=0)return a}let i=G(new Date),o=e.filteredOptions.findIndex(a=>$(a)===i);if(o>=0)return o;let r=e.filteredOptions.map((a,s)=>a.is_tappable?s:-1).filter(a=>a!==-1);return(n?r[r.length-1]:r[0])??0}stepDateDay(e,n){for(let i=e.activeDropdownIndex+n;i>=0&&i<e.filteredOptions.length;i+=n)if(e.filteredOptions[i]?.is_tappable){this.store.set({activeDropdownIndex:i});return}}stepDateWeek(e,n){let i=e.activeDropdownIndex+n;this.store.set({activeDropdownIndex:e.filteredOptions[i]?.is_tappable?i:-1})}getTappableIndices(e){let i=this.store.get().filteredOptions.map((r,a)=>r.is_tappable?a:-1).filter(r=>r!==-1),o=Array.from({length:e},()=>[]);for(let r of i)o[r%e].push(r);return o.flat()}getEffectiveColumns(e){let n=zt(e,this.ctx.listboxId);if(!n)return this.store.get().multiSelectView?1:this.ctx.columns;let o=zt(e,`${this.ctx.listboxId}-option-0`)?.parentElement??null;for(;o;){let r=getComputedStyle(o).gridTemplateColumns;if(r&&r!=="none"){let a=r.split(" ").filter(Boolean).length;if(a>0)return a}if(o===n)break;o=o.parentElement}return this.ctx.columns}clickOrSelect(e,n,i,o){let r=zt(o,`${i}-option-${e}`);r?r.click():this.ctx.selectOption(n[e])}};var mn=class{constructor(e,n,i={}){this.store=e;this.getOverrides=n;this.callbacks=i;this.unsubscribe=null;this.current=null;this.version=0;this.lastMiss=null;this.hasLoggedError=!1}start(){this.unsubscribe=this.store.subscribe(e=>this.sync(e)),this.sync(this.store.get())}dispose(){this.unsubscribe?.(),this.unsubscribe=null,this.cancel(),this.current=null}reset(){this.cancel(),this.current=null,this.lastMiss=null}refresh(){this.reset(),this.sync(this.store.get())}hasOverride(e){return!!this.getOverrides()?.[e]}owns(e,n){return this.hasOverride(e)&&!this.missCovers(e,n)}tick(e,n){let i=this.resolveTarget(e);if(!i||this.missCovers(i.parameter,i.query))return"no";let o=this.current;if(o&&o.key===i.key){if(o.query===i.query)return"owns";let r=Math.abs(i.query.length-o.query.length),a=i.query.length<o.query.length;if(n>1&&!a&&r<n)return"owns"}return this.ask(i),"asked"}sync(e){let n=this.resolveTarget(e);if(!n){this.current&&(this.cancel(),this.current=null),e.optionSearch&&this.store.set({optionSearch:null});return}this.current&&this.current.key===n.key||this.ask(n)}resolveTarget(e){if(D(e.activeFormatType)||e.editingIdentified)return null;let n=e.editingParam;if(n&&e.editingAnchor!=null)return this.hasOverride(n.suggestionParameter)?{mode:"edit",key:n.id,parameter:n.suggestionParameter,suggestion:{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options,icon:n.suggestionIcon,icon_svg:n.suggestionIconSvg},query:e.optionQuery}:null;let i=e.actionableSuggestions[0];return!i||!this.hasOverride(i.parameter)?null:{mode:"pill",key:i,parameter:i.parameter,suggestion:i,query:e.optionQuery}}missCovers(e,n){return this.lastMiss!=null&&this.lastMiss.parameter===e&&this.lastMiss.query===n}ask(e){this.cancel();let n=this.getOverrides()?.[e.parameter],i=++this.version;if(!n||this.missCovers(e.parameter,e.query)){this.current={key:e.key,parameter:e.parameter,query:e.query,abort:null},this.setSearch(e,"done");return}let o=new AbortController;this.current={key:e.key,parameter:e.parameter,query:e.query,abort:o};let r;try{r=n(e.query,o.signal,e.suggestion)}catch(a){this.logOnce(a),this.commit(e,[],i);return}if(Array.isArray(r)){this.commit(e,r,i);return}this.setSearch(e,"loading"),this.await(e,r,o.signal,i)}async await(e,n,i,o){let r;try{let a=await n;if(i.aborted||o!==this.version)return;r=Array.isArray(a)?a:[]}catch(a){if(i.aborted||o!==this.version||qs(a))return;this.logOnce(a),r=[]}this.commit(e,r,o)}commit(e,n,i){if(i!==this.version)return;let o=Ko(n,e.suggestion),r=this.resolveTarget(this.store.get());if(!r||r.key!==e.key)return;o.length===0?this.lastMiss={parameter:e.parameter,query:e.query}:this.lastMiss?.parameter===e.parameter&&(this.lastMiss=null);let a={parameter:e.parameter,query:e.query,status:"done"};if(e.mode==="edit")this.store.set(s=>({editingParam:s.editingParam&&s.editingParam.id===e.key?{...s.editingParam,options:o}:s.editingParam,optionSearch:a}));else{let s={...e.suggestion,options:o};this.current&&this.current.key===e.key&&(this.current.key=s),this.store.set(l=>({suggestions:l.suggestions.map(d=>d===e.suggestion?s:d),optionSearch:a}))}o.length===0?this.callbacks.onMiss?.(e.mode,e.query):this.callbacks.onAnswer?.(e.mode,e.query)}setSearch(e,n){let i=this.store.get().optionSearch;i&&i.parameter===e.parameter&&i.query===e.query&&i.status===n||this.store.set({optionSearch:{parameter:e.parameter,query:e.query,status:n}})}cancel(){this.current?.abort?.abort(),this.version++}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] an optionOverrides entry threw or rejected \u2014 treated as no options. Later failures on this instance are not logged.",e))}};function qs(t){return t instanceof Error&&t.name==="AbortError"}var pn=class{constructor(e,n={}){this.store=e;this.callbacks=n}setActivePill(e){let n=this.store.get(),i=n.suggestions.filter(d=>d.parameter!=="placeholder");if(e<0||e>=i.length)return;let o=i[e];if(L(o))return;let r=i.filter((d,c)=>c!==e),a=n.suggestions.filter(d=>d.parameter==="placeholder");if(this.callbacks.onPillSelected){let{rawQuery:d}=N(n.text,n.completedParams);this.callbacks.onPillSelected({rawQuery:d,selectedPill:o.text,otherPills:r.map(c=>c.text)})}let s=[...a,o,...r],l=this.store.peek({suggestions:s}).filteredOptions.findIndex(d=>d.is_tappable);this.store.set({suggestions:s,pillTapped:!0,activeDropdownIndex:l})}removeLastParam(){this.store.get().completedParams.length!==0&&this.store.set(n=>({completedParams:n.completedParams.slice(0,-1),activeDropdownIndex:-1}))}};var Hi="/products/",yr="https://relative.invalid";function Ks(t){if(!t)return;let e;try{e=new URL(t,`${yr}/`)}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return t.startsWith("/")?e.origin===yr?t:void 0:/^https?:\/\//i.test(t)?t:void 0}function Fi(t,e){let n=Ks(t.item_url)??js(t);return{id:t.source_id,title:t.title,...n&&{url:n},imageUrl:t.image_url||null,...t.price&&{price:Tr(t.price,t.currency,e)},...zs(t)&&{compareAtPrice:Tr(t.compare_at_price,t.currency,e)},...t.vendor&&{vendor:t.vendor},...typeof t.available=="boolean"&&{available:t.available}}}function zs(t){if(!t.price||!t.compare_at_price)return!1;let e=Number(t.price),n=Number(t.compare_at_price);return Number.isFinite(e)&&Number.isFinite(n)&&n>e}function Tr(t,e,n){if(n===void 0||!e||!/^\d+(\.\d+)?$/.test(t))return t;try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).format(Number(t))}catch{return t}}function js(t){if(!t.handle)return;let e=`${Hi}${encodeURIComponent(t.handle)}`;return t.variant_id?`${e}?variant=${encodeURIComponent(t.variant_id)}`:e}function gn(t,e){return(t?.items.matched??[]).map(n=>Fi(n,e))}var fn=class{constructor(e,n,i=()=>!0,o=()=>{},r=()=>{}){this.store=e;this.getConfig=n;this.isEnabled=i;this.getLanguage=o;this.getMapper=r;this.hasLoggedError=!1;this.hasLoggedMapperError=!1}forResponse(e){if(!this.isEnabled())return[];if(this.getConfig())return;let n=gn(e,oe(this.getLanguage())),i=this.getMapper();if(!i)return n;try{let o=i(n,e?.items.matched??[]);if(Array.isArray(o))return o}catch(o){this.hasLoggedMapperError||(this.hasLoggedMapperError=!0,console.warn("[AIAutocomplete] mapProducts failed. The original cards are shown.",o))}return n}async run(e,n,i){if(!this.isEnabled())return;let o=this.getConfig();if(!o)return;if(e.trim().length===0){this.clear(i);return}let r=()=>n.aborted||!i()||!this.owns(o);try{let a=await o.fetch(e,n);if(r())return;let s=o.transform(a),l=Array.isArray(s)?s:[],d=o.limit!=null?l.slice(0,o.limit):l;if(r())return;this.commit(d)}catch(a){if(n.aborted||Qs(a)||(this.logOnce(a),r()))return;this.clear(i)}}owns(e){return this.isEnabled()&&this.getConfig()===e}resync(){let e=this.forResponse(this.store.get().customFields);this.commit(e??[])}refresh(){if(this.getConfig())return;let e=this.forResponse(this.store.get().customFields);e!==void 0&&this.commit(e)}clear(e){e()&&this.commit([])}commit(e){e.length===0&&this.store.get().products.length===0||this.store.set({products:e})}logOnce(e){this.hasLoggedError||(this.hasLoggedError=!0,console.warn("[AIAutocomplete] products.fetch/transform failed \u2014 the product strip is hidden. Later failures on this instance are not logged.",e))}};function Qs(t){return t instanceof Error&&t.name==="AbortError"}function Ys(t){return t.replace(/(\d+)(?:st|nd|rd|th)\b/g,"$1")}function xr(t){let e=t.toLowerCase().replace(/\.$/,"");return e.length<3?-1:ke.findIndex(n=>n.toLowerCase().startsWith(e))}function Xs(t,e,n){let i=new Date(n.getFullYear(),t,e);if(i.getMonth()!==t||i.getDate()!==e)return null;let o=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i>=o)return i;let r=new Date(n.getFullYear()+1,t,e);return r.getMonth()===t&&r.getDate()===e?r:null}function vr(t,e,n){let i=new Date(t,e,n);return i.getMonth()===e&&i.getDate()===n?i:null}function Ne(t,e={}){if(!t)return null;let n=e.today??new Date,i=Ys(t.trim().toLowerCase()).replace(/\s+/g," "),o=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i);if(o){let l=vr(Number(o[1]),Number(o[2])-1,Number(o[3]));return l?G(l):null}let r=/^([a-z]+)\.? (\d{1,2})(?:,? (\d{4}))?$/.exec(i);if(r){let l=xr(r[1]);if(l>=0)return hn(l,Number(r[2]),r[3],n)}let a=/^(\d{1,2}) (?:of )?([a-z]+)\.?(?:,? (\d{4}))?$/.exec(i);if(a){let l=xr(a[2]);if(l>=0)return hn(l,Number(a[1]),a[3],n)}let s=/^(\d{1,2})[/\-.](\d{1,2})(?:[/\-.](\d{2,4}))?$/.exec(i);if(s){let l=Number(s[1]),d=Number(s[2]);return l>12&&d<=12?hn(d-1,l,s[3],n):d>12&&l<=12?hn(l-1,d,s[3],n):null}return null}function hn(t,e,n,i){if(n){if(n.length!==4)return null;let r=vr(Number(n),t,e);return r?G(r):null}let o=Xs(t,e,i);return o?G(o):null}var Js=/^\d{4}-\d{2}-\d{2}$/;function Wi(t){return typeof t=="string"&&Js.test(t)?t:null}function bn(t,e={}){return Wi(t.isoDate)??Ne(t.text,e)}function Sn(t){let e=Wi(t.isoDate);return e?{start:e,end:Wi(t.isoDateEnd)}:null}var Ui=" - ",yn="aiaDateRangeStart",Tn="aiaDateRangeEnd";function ct(t,e){return t<=e?{start:t,end:e}:{start:e,end:t}}var Bi=/^\d{4}-\d{2}-\d{2}$/;function Er(t){if(!Bi.test(t))return null;let[e,n,i]=t.split("-").map(Number),o=new Date(e,n-1,i);return o.getMonth()===n-1&&o.getDate()===i?o:null}var Zs=/\s+(?:to|through|thru|until|til|till)\s+/g,el=/[-–—]/g;function tl(t){let e=[];for(let n of[Zs,el]){n.lastIndex=0;let i=n.exec(t);for(;i!==null;)e.push([t.slice(0,i.index),t.slice(i.index+i[0].length)]),i=n.exec(t)}return e}function dt(t,e={}){if(!t)return null;let n=new Set,i=null;for(let[o,r]of tl(t.trim())){let a=Ne(o.trim(),e);if(!a)continue;let s=Ne(r.trim(),e);!s||s<a||(n.add(`${a}|${s}`),i={start:a,end:s})}return n.size===1?i:null}function Vi(t){let e=Er(t.start),n=Er(t.end);return!e||!n?"":t.start===t.end?Te(e):`${Te(e)}${Ui}${Te(n)}`}function Pr(t,e){let n=ct(t,e);return{text:Vi(n),is_tappable:!0,kind:null,metadata:{[yn]:n.start,[Tn]:n.end}}}function He(t,e={}){let n=t?.metadata?.[yn],i=t?.metadata?.[Tn];return typeof n=="string"&&typeof i=="string"&&Bi.test(n)&&Bi.test(i)?ct(n,i):dt(t?.text,e)}var ut="(max-width: 768px)";var nl="var(--aia-option-row-height, 25.9px)",il="var(--aia-grid-scroll-top, 0px) + var(--aia-grid-scroll-bottom, 0px)";function $i(t,e){return e?Gi(1,Math.min(t,5)):Gi(1,Math.min(t,4))}function Gi(t,e){return{cols:t,rows:e,maxHeight:`calc(${e} * ${nl} + ${il})`}}function vn(t,e){return!e&&t>=5}function En(t,e,n,i){if(!(!e&&t>=5&&ol(n,i))){let a=$i(t,e);return{...a,template:xn(a.cols),scrollHintIndices:!e&&t>a.rows?[a.rows-1]:[]}}let r=6;return{...Gi(2,3),template:xn(2),scrollHintIndices:t>r?[r-2,r-1]:[]}}function ol(t,e){return!t||t.length===0||e==null||e<=0||t.some(i=>i<=0)?!1:Math.ceil(Math.max(...t))*2<=e}function Fe(t){if(typeof document>"u")return null;let e=Array.from(t.querySelectorAll("[data-aia-option]"));if(e.length===0)return null;let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:-9999px;top:0;";for(let a of e){let s=a.cloneNode(!0);s.removeAttribute("id"),s.removeAttribute("role"),s.removeAttribute("aria-selected"),s.style.whiteSpace="nowrap",s.style.width="max-content",n.appendChild(s)}t.appendChild(n);let i=Array.from(n.children).map(a=>a.offsetWidth);n.remove();let o=getComputedStyle(t),r=t.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0)-(Number.parseFloat(o.columnGap)||0);return{rowWidths:i,gridWidth:r}}function xn(t){return Array.from({length:t},()=>"minmax(0,1fr)").join(" ")}function We(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(ut).matches}function Pn(t,e){return!t||t.length!==e.length?!1:t.every((n,i)=>n.text===e[i].text)}function wr(t,e){let n=e.dropdownTrigger??"auto",i=e.closeDropdownOnBlur??!0,a=t.filteredOptionsLength>0||t.activePillHasNoOptions||t.hasProducts;if(t.inEditMode){let s=i?t.isFocused||t.dropdownHeld:!0;return a&&s}if(n==="auto"){let s=i?t.isFocused||t.dropdownHeld:!0,l=t.text.replace(/\s+$/,"").length,d=t.caretOffset==null||t.caretOffset>=l;return(a||t.isLoading)&&s&&d}return n==="manual"?(a||t.isLoading)&&t.pillTapped:!1}function U(t){if(t.editingIdentified){let{parameter:n,anchor:i}=t.editingIdentified;return`identified:${n}@${i}`}return t.editingParam!=null&&t.editingAnchor!=null?`edit:${t.editingParam?.id}`:`pill:${t.actionableSuggestions[0]?.parameter??""}`}function qi(t){if(!t)return wi();let[e,n]=t.split("-").map(Number);return{year:e,month:n-1}}function rl(t){let e=et(t);return e?lr(e):wi()}function al(t,e){if(!t)return null;for(let n of e){if(n.parameter!==t||n.type?.kind!=="date_range")continue;let i=Sn(n);if(i&&i.end==null)return i.start}return null}function Ki(t,e){return t.editingParam!=null&&t.editingAnchor!=null?e:t.text.slice(ye(t.text,t.completedParams))}function Cr(t,e){let n=Zo(t.text,t.completedParams,t.identifiedParams),i=t.suggestions.filter(I=>I.parameter!=="placeholder"),o=i[0],r=t.suggestions.filter(I=>I.parameter==="placeholder").map(I=>I.text).join(" "),a=Me(r,e.prependPlaceholder),s=re(t.text,Math.min(t.filterBase,t.text.length),a),d=s===0&&kt(t.text,t.completedParams.length,a)?"":je(t.text,s,t.filterInProgress),c=o?.options??[],u=t.editingParam!=null&&t.editingAnchor!=null,p=!u&&!t.editingIdentified&&o?.type?.kind==="multi_select",f,g,h,b;if(u&&t.editingParam&&t.editingAnchor!=null){let I=t.editingParam.id,W=t.completedParams.some(us=>us.id===I),Ae=t.caretOffset??t.editingAnchor,vt=W?"":t.text.slice(t.editingAnchor,Ae);g=vt.trim(),h=t.editingParam.options,b=t.editingParam.suggestionParameter,f=Se(t.editingParam.options,vt)}else g=d.trim(),h=c,b=o?.parameter,f=L(o)?c.map(I=>({...I,matchedText:t.text.slice(ye(t.text,t.completedParams)),parameterLabel:zo(I.parameter)})):Se(c,d,t.traditionalAutocomplete);let x=t.optionSearch,m=x!=null&&b!=null&&x.parameter===b;m&&x.status==="done"&&x.query===g&&(f=h);let S=m&&x.status==="loading",P=e.showNonTappableOptions===!1;P&&(f=f.filter(I=>I.is_tappable));let T=Ki(t,g),E=u?t.editingParam?.suggestionValueType?.kind==="traditional_autocomplete":L(o);!p&&!E&&(f=Go(f,T));let w=t.editingIdentified,y=u?t.editingParam&&{type:t.editingParam.suggestionValueType,options:t.editingParam.options}:o,C=w?w.format:Q(y),_=u?t.editingParam?.suggestionParameter:o?.parameter,O=C==="location"&&_&&e.optionOverrides?.[_]?"options":C,ee=u&&O==="date-range"?He(t.editingParam):null,A=!u&&!w&&O==="date"?al(o?.parameter,t.identifiedParams):null,V=null,fe=null;if(k(O)){let I=U({...t,actionableSuggestions:i}),W=t.dateViewMonth;V=W&&W.key===I?{year:W.year,month:W.month}:w?qi(w.iso):ee?qi(ee.start):A?qi(A):rl(t.editingParam?.text),f=Gt(V);let Ae=t.pendingRangeStart;O==="date-range"&&Ae&&Ae.key===I&&(fe=Ae.iso)}let j=null;if(O==="time"){let I=U({...t,actionableSuggestions:i}),W=t.timeDraft;j=W&&W.key===I?{minutes:W.minutes,touched:!0}:{minutes:Sr({editingText:u?t.editingParam?.text:null,options:u?t.editingParam?.options:o?.options}),touched:!1},f=[]}let v=null;if(O==="location"){let I=U({...t,actionableSuggestions:i}),W=t.locationSearch;if(W&&W.key===I){let{key:Ae,...vt}=W;v=vt}else v={query:u?t.editingParam?.text??"":"",places:[],status:t.locationAutocomplete&&e.locationSearch!==!1?"idle":"unavailable",highlighted:-1};f=[]}let he=I=>P?I.is_tappable:!0,be;if(u){let I=t.editingParam?.options??[];be=t.editingParam!=null&&I.filter(he).length===0}else be=o!=null&&c.filter(he).length===0;j&&(be=!0),v&&(be=!0);let Tt=wr({inEditMode:u||w!=null,filteredOptionsLength:f.length,isFocused:t.isFocused||t.locationFieldFocused,dropdownHeld:t.dropdownHeld,text:t.text,caretOffset:t.caretOffset,isLoading:t.isLoading||S,pillTapped:t.pillTapped,activePillHasNoOptions:be,hasProducts:t.products.length>0},{dropdownTrigger:e.dropdownTrigger,closeDropdownOnBlur:e.closeDropdownOnBlur}),xt=Tt&&t.activeDropdownIndex>=0&&!!f[t.activeDropdownIndex]?.is_tappable,bi=t.skeletonOptions!==null&&t.skeletonRequested&&!t.isLoading&&!t.editingParam&&!t.inSelectionAnimation,z=t.isLoading&&!t.editingParam&&!t.inSelectionAnimation||S||bi,Ao=z&&t.skeletonOptions!==null,cs=Ao&&t.skeletonOptions?t.skeletonOptions:f,ds=Ao?t.skeletonSuggestion:null;return{segments:n,actionableSuggestions:i,filteredOptions:f,dropdownLoading:z,dropdownOptions:cs,dropdownSuggestion:ds,skeletonExiting:bi,activeFormatType:O,dateView:V,dateRangeStart:fe,dateFloor:A,timeView:j,multiSelectView:p?{picked:t.multiSelectDraft?.key===U({...t,actionableSuggestions:i})?t.multiSelectDraft.picked:[]}:null,locationView:v,placeholderText:r,leadInText:a,optionQuery:g,isSearchingOptions:S,isDropdownOpen:Tt,isActivePillSelected:xt}}function wn(t){return t.mode!=="edit"?ll(t):cl(t)}function sl(t,e,n){let i=t.find(L);if(!i?.options)return null;let o=e.slice(ye(e,n)).trim().toLowerCase();if(!o)return null;let r=i.options.filter(l=>l.is_tappable&&l.text.trim().toLowerCase()===o);if(new Set(r.map(l=>J(l,i.parameter))).size!==1)return null;let s=r[0];return{suggestion:i,option:s,matchText:s.text.trim()}}function Lr(t){let{text:e,suggestions:n,filterBase:i,filterInProgress:o,phraseExactMatch:r}=t,a=n.find(c=>c.parameter!=="placeholder"&&!L(c));if(!a?.options||a.type?.kind==="multi_select")return null;let s=n.filter(c=>c.parameter==="placeholder").map(c=>c.text).join(" "),l=re(e,i,Me(s,t.prependPlaceholder)),d=Qe(a.options,e,l,o,r===!0);return d?{suggestion:a,option:d,matchText:d.text}:null}function ll(t){let{text:e,completedParams:n,suggestions:i}=t,o=t.mode==="submit"?(t.finishWord?Lr(t):null)??sl(i,e,n):Lr(t);if(!o)return null;let{suggestion:r,option:a,matchText:s}=o,l=s.toLowerCase(),d=e.toLowerCase().lastIndexOf(l),c=d>=0?d:Math.max(0,e.length-a.text.length),u=c+s.length,p=e.slice(c,u),g=u<e.length&&e[u]===" "?u+1:u,h={id:crypto.randomUUID(),placeholder:"",parameter:J(a,r.parameter),text:p,value:a.value,kind:a.kind,suggestionParameter:r.parameter,suggestionValueType:r.type,suggestionPlaceholder:r.text,suggestionIcon:r.icon,suggestionIconSvg:r.icon_svg,...t.mode==="submit"&&L(r)?Ye(J(a,r.parameter)):{},options:r.options??[],metadata:a.metadata,icon:a.icon,icon_svg:a.icon_svg,image_url:a.image_url};return{patch:{text:e,completedParams:[...n,h],suggestions:i.filter(b=>b!==r),filterBase:g,newParamId:h.id,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:a,suggestion:r}}function cl(t){let{text:e,completedParams:n,editingParam:i,editingAnchor:o,editingTail:r}=t;if(n.some(S=>S.id===i.id))return null;let a=e.slice(o,r),s=Mt(i.options,a);if(!s)return null;let l=s.text.toLowerCase(),d=a.toLowerCase().lastIndexOf(l),c=o+Math.max(0,d),u=c+s.text.length,p=e.slice(c,u),f=u<e.length&&e[u]===" "?u+1:u,g=e.length,h={id:crypto.randomUUID(),placeholder:"",...Rt(i,s),text:p,value:s.value,kind:s.kind,options:i.options,metadata:s.metadata,icon:s.icon,icon_svg:s.icon_svg,image_url:s.image_url},b=n.length,x=0;for(let S=0;S<n.length;S++){let P=te(e,n[S].text,x);if(P!==-1){if(P>=f){b=S;break}x=P+n[S].text.length}}let m=[...n];return m.splice(b,0,h),{patch:{text:e,completedParams:m,newParamId:h.id,filterBase:g,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:g,activeDropdownIndex:-1},caretPos:g,option:s}}function ji(t){return t.slice(t.search(/\S*$/))}function Ar(t){return t.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function Ir(t,e){let n="",i=0;for(let o of t){if(n+=Ar(o),i+=o.length,n.length>=e.length)return n.startsWith(e)?i+(t.slice(i).match(/^\p{M}*/u)?.[0].length??0):0;if(!e.startsWith(n))return 0}return 0}function zi(t){return[...t].map(Ar).join("")}function mt(t,e){if(/\s$/.test(e))return null;let n=e.split(/\s+/).filter(Boolean).map(zi),i=[...t.matchAll(/\S+/g)].map(o=>({index:o.index??0,text:o[0],folded:zi(o[0])}));for(let o=n.length;o>=1;o--){let r=n.slice(n.length-o),a=r[o-1];for(let s=0;s+o<=i.length;s++){if(!r.slice(0,-1).every((u,p)=>i[s+p].folded===u))continue;let d=i[s+o-1],c=Ir(d.text,a);if(c>0)return{typedWords:o,start:i[s].index,end:d.index+c}}}return null}function Cn(t,e){let n=e?mt(t,e):null;if(n&&n.typedWords>1)return[{text:t.slice(0,n.start),bold:!1},{text:t.slice(n.start,n.end),bold:!0},{text:t.slice(n.end),bold:!1}].filter(a=>a.text!=="");let i=e?ji(e):"",o=zi(i);if(!o)return[{text:t,bold:!1}];let r=[];for(let a of t.split(/(\s+)/)){if(a==="")continue;let s=/^\s/.test(a)?0:Ir(a,o);s>0&&r.push({text:a.slice(0,s),bold:!0});let l=s>0?a.slice(s):a;l&&r.push({text:l,bold:!1})}return r}var dl=6e4;function ul(t){return typeof TextEncoder>"u"?t.length*3:new TextEncoder().encode(t).length}function ml(t){return(t??Y).replace(/\/suggest(\?|#|$)/,"/telemetry/events$1")}async function pl(t){return qe(t)?`Bearer ${await wt(t).getToken()}`:Lt(t)}async function Or(t){try{let e=ml(t.apiConfig?.endpoint),n=Ct(t.apiConfig),i=await pl(t.apiConfig);i&&(n.Authorization=i);let o=JSON.stringify({source:t.source,session_id:t.sessionId,...t.visitorId&&{visitor_id:t.visitorId},...t.requestId&&{request_id:t.requestId},type:t.type,...t.language&&{language:t.language},at:new Date().toISOString(),query_data:t.queryData});await fetch(e,{method:"POST",headers:n,body:o,...t.keepalive&&ul(o)<=dl&&{keepalive:!0}})}catch{}}function ce(t,e){let n=t.findIndex(i=>i.text===e);return n>=0?n+1:null}var Qi=t=>t.toLowerCase().split(/\s+/).filter(Boolean);function gl(t,e,n){let i=Qi(t??"");if(i.length===0)return"";let r=Qi(e).slice(-i.length),a=Qi(n).slice(0,i.length);return r.join(" ")===i.join(" ")||a.join(" ")===i.join(" ")?"":(t??"").trim().split(/\s+/).join(" ")}function Mr(t,e){let n=t.actionableSuggestions[0];if(!n)return null;let i=L(n),o=e.parameter;if(i&&!o)return null;let r=i&&o?o:J(e,n.parameter),a=i?t.text.length:t.filterBase,s=t.text.slice(0,a),l=s.length===0&&t.text.length===0,d=s.length===0&&t.text.length>0&&t.placeholderText.length>0&&t.placeholderText.toLowerCase().startsWith(t.text.toLowerCase());(l||d)&&t.placeholderText&&(s=`${t.placeholderText} `);let c=Math.min(ye(t.text,t.completedParams),s.length),u=!1;if(i){let y=[...s.slice(c).matchAll(/\S+/g)],C=mt(e.text,s.slice(c)),_=y[y.length-(C?.typedWords??1)];s=s.slice(0,_?c+(_.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word===!0){let y=[...s.slice(c).matchAll(/\S+/g)],C=y[y.length-1];s=s.slice(0,C?c+(C.index??0):Math.max(s.lastIndexOf(" ")+1,c))}else if(n.completes_word!==!1){let y=Uo(s.slice(c),e.text);y>0&&(s=s.slice(0,s.length-y)),u=y>0}let p=s.length>0&&s[s.length-1]!==" ",f=i||n.completes_word===!0||u,g=t.activeFormatType!==void 0&&!D(t.activeFormatType)&&D(Q({type:n.type})),h=f||g?"":gl(n.lead_in,s,e.text),b=`${s}${p?" ":""}${h?`${h} `:""}${e.text} `,m=(l||d||i&&s.length===0)&&b.length>0?b[0].toUpperCase()+b.slice(1):b,S=m.toLowerCase().lastIndexOf(e.text.toLowerCase()),P=S>=0?m.slice(S,S+e.text.length):e.text,T=i?Ye(r):{parameter:r,suggestionParameter:n.parameter,suggestionValueType:n.type,suggestionPlaceholder:n.text,suggestionIcon:n.icon,suggestionIconSvg:n.icon_svg},E={id:crypto.randomUUID(),placeholder:"",...T,text:P,value:e.value,kind:e.kind,options:n.options??[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},w=t.actionableSuggestions.length-1;return{patch:{text:m,filterBase:m.length,completedParams:[...t.completedParams,E],newParamId:E.id,caretOffset:m.length,pillTapped:!1,activeDropdownIndex:-1,skipNextFetch:!0,inSelectionAnimation:!0,pendingSpan:null},telemetry:{selectedOption:e.text,otherOptions:t.filteredOptions.filter(y=>y.text!==e.text).map(y=>y.text),key:i?r:n.parameter,position:ce(n.options??[],e.text)},consumedSuggestion:n,remainingActionable:w}}function Ln(t){let e=D(t.activeFormatType)||t.filteredOptions.length===0?null:t.filteredOptions,n=t.editingParam,i=n?{parameter:n.suggestionParameter,text:n.suggestionPlaceholder,required:!0,options:n.options}:t.actionableSuggestions[0]??null;return{skeletonOptions:e,skeletonSuggestion:e?i:null,skeletonRequested:!1}}function An(t,e,n){let i=t.slice(0,e),o=t.slice(n),r=(i===""||i.endsWith(" "))&&o.startsWith(" ");return r&&(o=o.slice(1)),{text:i+o,removed:n-e+(r?1:0)}}var In=class{constructor(e){this.deps=e}start(e){let n=this.deps.store.get();if(n.editingParam?.id===e)return;let i=n.completedParams.find(a=>a.id===e);if(!i)return;let o=0,r=-1;for(let a of n.completedParams){let s=te(n.text,a.text,o);if(s!==-1){if(a.id===e){r=s;break}o=s+a.text.length}}r<0||this.deps.store.set({editingParam:i,editingAnchor:r,editingTail:r+i.text.length,caretOffset:r+i.text.length,activeDropdownIndex:-1,editingIdentified:null})}exit(){this.deps.store.get().editingParam&&this.deps.store.set({editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1})}replaceRange(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null||!n.completedParams.some(l=>l.id===i.id))return!1;let{text:a}=e===""?An(n.text,o,r):{text:n.text.slice(0,o)+e+n.text.slice(r)},s=o+e.length;return this.deps.store.set(l=>({text:a,completedParams:l.completedParams.filter(d=>d.id!==i.id),editingTail:s,caretOffset:s,activeDropdownIndex:-1})),this.deps.scheduleSetCursor(s),this.promoteIfExact(),!0}caretAfterInput(e){let n=this.deps.store.get(),i={caretOffset:e};n.editingParam&&n.editingAnchor!=null&&e!=null&&(e<n.editingAnchor?(i.editingParam=null,i.editingAnchor=null,i.editingTail=null,i.activeDropdownIndex=-1):n.editingTail!=null&&(i.editingTail=Math.max(n.editingTail,e))),this.deps.store.set(i),this.promoteIfExact()}caretMove(e){let n=this.deps.store.get();if(n.editingParam&&n.editingAnchor!=null&&n.editingTail!=null&&e!=null&&(e<n.editingAnchor||e>n.editingTail)){this.deps.store.set({caretOffset:e,editingParam:null,editingAnchor:null,editingTail:null,activeDropdownIndex:-1});return}this.deps.store.set({caretOffset:e})}selectOption(e){let n=this.deps.store.get(),i=n.editingParam,o=n.editingAnchor,r=n.editingTail;if(!i||o==null||r==null)return;let a=Rt(i,e);this.deps.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:i.options.filter(m=>m.text!==e.text).map(m=>m.text),key:a.suggestionParameter,position:ce(i.options,e.text),chip_origin:"tap"});let s=n.text.slice(0,o),l=n.text.slice(r),d=o===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,u=l.length===0||l[0]!==" "?`${d} `:d,p=s+u+l,f=p.length,g={id:crypto.randomUUID(),placeholder:"",...a,text:d,value:e.value,kind:e.kind,options:i.options,metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url},h=n.completedParams.findIndex(m=>m.id===i.id),b=n.completedParams.filter(m=>m.id!==i.id),x=h>=0?Math.min(h,b.length):b.length;b.splice(x,0,g),this.deps.store.set({text:p,completedParams:b,newParamId:g.id,filterBase:f,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:f,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0,...Ln(n)}),this.deps.startSelectionAnimationTimer(),this.deps.scheduleSetCursor(f),this.deps.fetchNow()}promoteIfExact(){let e=this.deps.store.get();if(!e.editingParam||e.editingAnchor==null||e.editingTail==null)return;let n=wn({mode:"edit",text:e.text,completedParams:e.completedParams,editingParam:e.editingParam,editingAnchor:e.editingAnchor,editingTail:e.editingTail});n&&(this.deps.store.set(n.patch),this.deps.scheduleSetCursor(n.caretPos))}};var Rr=33,_r=70,Dr=120,Nr=50,ve="data-aia-placeholder-leaving",Be=new WeakMap;function On(t){t.timer!==null&&(clearTimeout(t.timer),t.timer=null)}function fl(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Hr(t,e,n){e.shown=n,t.dataset.placeholder=e.target.slice(0,n)}function Fr(t,e){if(e.timer=null,!t.isConnected||e.shown>=e.target.length||(Hr(t,e,e.shown+1),e.shown>=e.target.length))return;let n=e.target[e.shown-1],i=n===" "||n==="-"?70:0;e.timer=setTimeout(()=>Fr(t,e),33+i)}function kr(t,e){Hr(t,e,0),e.timer=setTimeout(()=>Fr(t,e),33)}function Wr(t,e){let n=Be.get(t);if(e===""){n&&(On(n),Be.delete(t)),t.removeAttribute(ve),delete t.dataset.placeholder;return}if(n?.target===e)return;if(fl(t)){n&&On(n),t.removeAttribute(ve),Be.set(t,{target:e,shown:e.length,timer:null}),t.dataset.placeholder=e;return}let i={target:e,shown:0,timer:null},o=n&&n.shown>0?n:null;if(n&&On(n),Be.set(t,i),o){t.setAttribute(ve,""),i.timer=setTimeout(()=>{i.timer=null,t.removeAttribute(ve),t.isConnected&&kr(t,i)},170);return}t.removeAttribute(ve),kr(t,i)}function Br(t){let e=Be.get(t);e&&(On(e),Be.delete(t))}var hl={selectedIso:null,selectedRange:null,rangeStart:null};function Ue(t){if(!k(t.activeFormatType))return hl;let e=t.editingIdentified;if(e){let{iso:i,isoEnd:o}=e;return{selectedIso:o?null:i,selectedRange:i&&o?ct(i,o):null,rangeStart:t.dateRangeStart}}let n=He(t.editingParam);return{selectedIso:n?null:$t(t.editingParam?.text),selectedRange:n,rangeStart:t.dateRangeStart??t.dateFloor??null,floor:t.dateFloor??null}}function Mn(t){let e=t.floor!=null&&t.highlightedIso!=null&&t.highlightedIso<t.floor?null:t.highlightedIso;return t.pendingStart?ct(t.pendingStart,e??t.pendingStart):t.selected}function kn(t,e){if(t==null)return{selected:!1,inRange:!1};let{selectedIso:n,range:i}=e,o=t===n||i!=null&&(t===i.start||t===i.end),r=i!=null&&t>i.start&&t<i.end;return{selected:o,inRange:r}}function Rn(t,e,n){return t==null?!1:t<e||n!=null&&t<n}function _n(t,e){return t==="date"?e??null:null}var Yi="https://ai-autocomplete.com";function Dn(t=Yi){try{if(typeof window>"u"||!window.location)return t;let e=window.location.hostname;if(!e)return t;let n=new URL(t);return n.searchParams.set("utm_source",e),n.toString()}catch{return t}}var Ur={language:"en",and:"and",proceed:"to proceed",select:"to select",skipHint:"to skip",skip:"skip",skipLabel:"Skip",products:"Best match",soldOut:"Sold out",addToCart:"Add to cart",submit:"Submit",seeAllResults:"See all results",scrollArrow:"Scroll down for more options",keepTyping:"Keep typing",done:"Done",timeLabel:"Time",locationSearch:"Say a location",locationNoResults:"No places found",locationUseTyped:"Press Enter to use what you typed"},bl={language:"es",and:"y",proceed:"para continuar",select:"para seleccionar",skipHint:"para omitir",skip:"omitir",skipLabel:"Omitir",products:"Mejor coincidencia",soldOut:"Agotado",addToCart:"A\xF1adir al carrito",submit:"Buscar",seeAllResults:"Ver todos los resultados",scrollArrow:"Despl\xE1zate para ver m\xE1s opciones",keepTyping:"Sigue escribiendo",done:"Listo",timeLabel:"Hora",locationSearch:"Di una ubicaci\xF3n",locationNoResults:"No se encontraron lugares",locationUseTyped:"Pulsa Intro para usar lo que escribiste"},Xi={en:Ur,es:bl,fr:{language:"fr",and:"et",proceed:"pour continuer",select:"pour s\xE9lectionner",skipHint:"pour passer",skip:"passer",skipLabel:"Passer",products:"Meilleure correspondance",soldOut:"\xC9puis\xE9",addToCart:"Ajouter au panier",submit:"Rechercher",seeAllResults:"Voir tous les r\xE9sultats",scrollArrow:"Faites d\xE9filer pour voir plus d\u2019options",keepTyping:"Continuez \xE0 taper",done:"Termin\xE9",timeLabel:"Heure",locationSearch:"Dites un lieu",locationNoResults:"Aucun lieu trouv\xE9",locationUseTyped:"Appuyez sur Entr\xE9e pour utiliser votre saisie"},"pt-BR":{language:"pt-BR",and:"e",proceed:"para continuar",select:"para selecionar",skipHint:"para pular",skip:"pular",skipLabel:"Pular",products:"Melhor correspond\xEAncia",soldOut:"Esgotado",addToCart:"Adicionar ao carrinho",submit:"Buscar",seeAllResults:"Ver todos os resultados",scrollArrow:"Role para ver mais op\xE7\xF5es",keepTyping:"Continue digitando",done:"Conclu\xEDdo",timeLabel:"Hor\xE1rio",locationSearch:"Diga um local",locationNoResults:"Nenhum lugar encontrado",locationUseTyped:"Pressione Enter para usar o que voc\xEA digitou"},it:{language:"it",and:"e",proceed:"per continuare",select:"per selezionare",skipHint:"per saltare",skip:"salta",skipLabel:"Salta",products:"Migliore corrispondenza",soldOut:"Esaurito",addToCart:"Aggiungi al carrello",submit:"Cerca",seeAllResults:"Vedi tutti i risultati",scrollArrow:"Scorri per vedere altre opzioni",keepTyping:"Continua a scrivere",done:"Fatto",timeLabel:"Ora",locationSearch:"Di' un luogo",locationNoResults:"Nessun luogo trovato",locationUseTyped:"Premi Invio per usare ci\xF2 che hai scritto"},tr:{language:"tr",and:"ve",proceed:"devam etmek i\xE7in",select:"se\xE7mek i\xE7in",skipHint:"atlamak i\xE7in",skip:"atla",skipLabel:"Atla",products:"En iyi e\u015Fle\u015Fme",soldOut:"T\xFCkendi",addToCart:"Sepete ekle",submit:"Ara",seeAllResults:"T\xFCm sonu\xE7lar\u0131 g\xF6r",scrollArrow:"Daha fazla se\xE7enek i\xE7in kayd\u0131r",keepTyping:"Yazmaya devam et",done:"Tamam",timeLabel:"Saat",locationSearch:"Bir konum s\xF6yleyin",locationNoResults:"Yer bulunamad\u0131",locationUseTyped:"Yazd\u0131\u011F\u0131n\u0131z\u0131 kullanmak i\xE7in Enter'a bas\u0131n"},id:{language:"id",and:"dan",proceed:"untuk melanjutkan",select:"untuk memilih",skipHint:"untuk melewati",skip:"lewati",skipLabel:"Lewati",products:"Paling cocok",soldOut:"Habis",addToCart:"Tambah ke keranjang",submit:"Cari",seeAllResults:"Lihat semua hasil",scrollArrow:"Gulir untuk melihat opsi lainnya",keepTyping:"Teruskan mengetik",done:"Selesai",timeLabel:"Waktu",locationSearch:"Sebutkan lokasi",locationNoResults:"Tempat tidak ditemukan",locationUseTyped:"Tekan Enter untuk memakai yang Anda ketik"},pl:{language:"pl",and:"i",proceed:"aby kontynuowa\u0107",select:"aby wybra\u0107",skipHint:"aby pomin\u0105\u0107",skip:"pomi\u0144",skipLabel:"Pomi\u0144",products:"Najlepsze dopasowanie",soldOut:"Wyprzedane",addToCart:"Dodaj do koszyka",submit:"Szukaj",seeAllResults:"Zobacz wszystkie wyniki",scrollArrow:"Przewi\u0144, aby zobaczy\u0107 wi\u0119cej opcji",keepTyping:"Pisz dalej",done:"Gotowe",timeLabel:"Godzina",locationSearch:"Podaj lokalizacj\u0119",locationNoResults:"Nie znaleziono miejsc",locationUseTyped:"Naci\u015Bnij Enter, aby u\u017Cy\u0107 wpisanego tekstu"},de:{language:"de",and:"und",proceed:"zum Fortfahren",select:"zum Ausw\xE4hlen",skipHint:"zum \xDCberspringen",skip:"\xFCberspringen",skipLabel:"\xDCberspringen",products:"Beste Treffer",soldOut:"Ausverkauft",addToCart:"In den Warenkorb",submit:"Suchen",seeAllResults:"Alle Ergebnisse anzeigen",scrollArrow:"Scrolle f\xFCr weitere Optionen",keepTyping:"Weitertippen",done:"Fertig",timeLabel:"Uhrzeit",locationSearch:"Nenne einen Ort",locationNoResults:"Keine Orte gefunden",locationUseTyped:"Dr\xFCcke Enter, um deine Eingabe zu verwenden"},nl:{language:"nl",and:"en",proceed:"om door te gaan",select:"om te selecteren",skipHint:"om over te slaan",skip:"overslaan",skipLabel:"Overslaan",products:"Beste match",soldOut:"Uitverkocht",addToCart:"In winkelwagen",submit:"Zoeken",seeAllResults:"Alle resultaten bekijken",scrollArrow:"Scrol voor meer opties",keepTyping:"Blijf typen",done:"Klaar",timeLabel:"Tijd",locationSearch:"Noem een locatie",locationNoResults:"Geen plaatsen gevonden",locationUseTyped:"Druk op Enter om je invoer te gebruiken"},sv:{language:"sv",and:"och",proceed:"f\xF6r att forts\xE4tta",select:"f\xF6r att v\xE4lja",skipHint:"f\xF6r att hoppa \xF6ver",skip:"hoppa \xF6ver",skipLabel:"Hoppa \xF6ver",products:"B\xE4sta matchning",soldOut:"Sluts\xE5ld",addToCart:"L\xE4gg i varukorgen",submit:"S\xF6k",seeAllResults:"Visa alla resultat",scrollArrow:"Skrolla f\xF6r fler alternativ",keepTyping:"Forts\xE4tt skriva",done:"Klar",timeLabel:"Tid",locationSearch:"S\xE4g en plats",locationNoResults:"Inga platser hittades",locationUseTyped:"Tryck p\xE5 Enter f\xF6r att anv\xE4nda det du skrev"},nb:{language:"nb",and:"og",proceed:"for \xE5 fortsette",select:"for \xE5 velge",skipHint:"for \xE5 hoppe over",skip:"hopp over",skipLabel:"Hopp over",products:"Beste treff",soldOut:"Utsolgt",addToCart:"Legg i handlekurven",submit:"S\xF8k",seeAllResults:"Se alle resultater",scrollArrow:"Rull ned for \xE5 se flere alternativer",keepTyping:"Fortsett \xE5 skrive",done:"Ferdig",timeLabel:"Tid",locationSearch:"Si et sted",locationNoResults:"Fant ingen steder",locationUseTyped:"Trykk Enter for \xE5 bruke det du skrev"},da:{language:"da",and:"og",proceed:"for at forts\xE6tte",select:"for at v\xE6lge",skipHint:"for at springe over",skip:"spring over",skipLabel:"Spring over",products:"Bedste match",soldOut:"Udsolgt",addToCart:"L\xE6g i kurv",submit:"S\xF8g",seeAllResults:"Se alle resultater",scrollArrow:"Rul for flere muligheder",keepTyping:"Forts\xE6t med at skrive",done:"F\xE6rdig",timeLabel:"Tidspunkt",locationSearch:"Sig et sted",locationNoResults:"Ingen steder fundet",locationUseTyped:"Tryk p\xE5 Enter for at bruge det, du skrev"},fi:{language:"fi",and:"ja",proceed:"jatkaaksesi",select:"valitaksesi",skipHint:"ohittaaksesi",skip:"ohita",skipLabel:"Ohita",products:"Paras vastaavuus",soldOut:"Loppuunmyyty",addToCart:"Lis\xE4\xE4 ostoskoriin",submit:"Hae",seeAllResults:"N\xE4yt\xE4 kaikki tulokset",scrollArrow:"Vierit\xE4 n\xE4hd\xE4ksesi lis\xE4\xE4 vaihtoehtoja",keepTyping:"Jatka kirjoittamista",done:"Valmis",timeLabel:"Aika",locationSearch:"Sano sijainti",locationNoResults:"Paikkoja ei l\xF6ytynyt",locationUseTyped:"Paina Enteri\xE4 k\xE4ytt\xE4\xE4ksesi kirjoittamaasi"},ja:{language:"ja",and:"\u3068",proceed:"\u3067\u6B21\u3078",select:"\u3067\u9078\u629E",skipHint:"\u3067\u30B9\u30AD\u30C3\u30D7",skip:"\u30B9\u30AD\u30C3\u30D7",skipLabel:"\u30B9\u30AD\u30C3\u30D7",products:"\u30D9\u30B9\u30C8\u30DE\u30C3\u30C1",soldOut:"\u58F2\u308A\u5207\u308C",addToCart:"\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",submit:"\u691C\u7D22",seeAllResults:"\u3059\u3079\u3066\u306E\u7D50\u679C\u3092\u898B\u308B",scrollArrow:"\u30B9\u30AF\u30ED\u30FC\u30EB\u3057\u3066\u4ED6\u306E\u5019\u88DC\u3092\u898B\u308B",keepTyping:"\u5165\u529B\u3092\u7D9A\u3051\u308B",done:"\u5B8C\u4E86",timeLabel:"\u6642\u523B",locationSearch:"\u5834\u6240\u3092\u8A00\u3063\u3066\u304F\u3060\u3055\u3044",locationNoResults:"\u5834\u6240\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",locationUseTyped:"\u5165\u529B\u3057\u305F\u5185\u5BB9\u3092\u4F7F\u3046\u306B\u306F Enter \u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044"},ko:{language:"ko",and:"\uBC0F",proceed:"\uACC4\uC18D",select:"\uC120\uD0DD",skipHint:"\uAC74\uB108\uB6F0\uAE30",skip:"\uAC74\uB108\uB6F0\uAE30",skipLabel:"\uAC74\uB108\uB6F0\uAE30",products:"\uCD94\uCC9C \uC0C1\uD488",soldOut:"\uD488\uC808",addToCart:"\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uB2F4\uAE30",submit:"\uAC80\uC0C9",seeAllResults:"\uBAA8\uB4E0 \uACB0\uACFC \uBCF4\uAE30",scrollArrow:"\uB354 \uB9CE\uC740 \uC635\uC158\uC744 \uBCF4\uB824\uBA74 \uC2A4\uD06C\uB864\uD558\uC138\uC694",keepTyping:"\uACC4\uC18D \uC785\uB825\uD558\uC138\uC694",done:"\uC644\uB8CC",timeLabel:"\uC2DC\uAC04",locationSearch:"\uC704\uCE58\uB97C \uB9D0\uD558\uC138\uC694",locationNoResults:"\uC7A5\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",locationUseTyped:"\uC785\uB825\uD55C \uB0B4\uC6A9\uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 Enter\uB97C \uB204\uB974\uC138\uC694"},"zh-CN":{language:"zh-CN",and:"\u548C",proceed:"\u7EE7\u7EED",select:"\u9009\u62E9",skipHint:"\u8DF3\u8FC7",skip:"\u8DF3\u8FC7",skipLabel:"\u8DF3\u8FC7",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u7F44",addToCart:"\u52A0\u5165\u8D2D\u7269\u8F66",submit:"\u641C\u7D22",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7ED3\u679C",scrollArrow:"\u5411\u4E0B\u6EDA\u52A8\u67E5\u770B\u66F4\u591A\u9009\u9879",keepTyping:"\u7EE7\u7EED\u8F93\u5165",done:"\u5B8C\u6210",timeLabel:"\u65F6\u95F4",locationSearch:"\u8BF4\u51FA\u5730\u70B9",locationNoResults:"\u672A\u627E\u5230\u5730\u70B9",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F93\u5165\u7684\u5185\u5BB9"},"zh-TW":{language:"zh-TW",and:"\u548C",proceed:"\u7E7C\u7E8C",select:"\u9078\u64C7",skipHint:"\u7565\u904E",skip:"\u7565\u904E",skipLabel:"\u7565\u904E",products:"\u6700\u4F73\u5339\u914D",soldOut:"\u552E\u5B8C",addToCart:"\u52A0\u5165\u8CFC\u7269\u8ECA",submit:"\u641C\u5C0B",seeAllResults:"\u67E5\u770B\u5168\u90E8\u7D50\u679C",scrollArrow:"\u5411\u4E0B\u6372\u52D5\u67E5\u770B\u66F4\u591A\u9078\u9805",keepTyping:"\u7E7C\u7E8C\u8F38\u5165",done:"\u5B8C\u6210",timeLabel:"\u6642\u9593",locationSearch:"\u8AAA\u51FA\u5730\u9EDE",locationNoResults:"\u627E\u4E0D\u5230\u5730\u9EDE",locationUseTyped:"\u6309 Enter \u4F7F\u7528\u4F60\u8F38\u5165\u7684\u5167\u5BB9"}},Sl={pt:"pt-BR",no:"nb",nn:"nb"};function M(t){let[e,...n]=t?.toLowerCase().split("-")??[];if(e==="zh"){let o=n.some(r=>["hant","tw","hk","mo"].includes(r));return Xi[o?"zh-TW":"zh-CN"]}let i=Sl[e]??e;return Object.prototype.hasOwnProperty.call(Xi,i)?Xi[i]:Ur}function Nn(t,e,n=M()){return t?{key:"enter",hint:n.proceed}:e?{key:"tab",hint:n.select}:{key:"\u2192",hint:n.skipHint}}function Hn(t){let e=a=>{a.ctrlKey||Vr(a.target,t,a.deltaX,a.deltaY)||a.preventDefault()},n=0,i=0,o=a=>{let s=a.touches[0];s&&(n=s.clientX,i=s.clientY)},r=a=>{if(a.touches.length!==1)return;let s=a.touches[0],l=n-s.clientX,d=i-s.clientY;n=s.clientX,i=s.clientY,a.cancelable&&!Vr(a.target,t,l,d)&&a.preventDefault()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",o,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",r)}}function Vr(t,e,n,i){let o=t instanceof Element?t:null;for(;o;){if(i!==0&&yl(o,i)||n!==0&&Tl(o,n))return!0;if(o===e)break;o=o.parentElement}return!1}var Gr=/^(auto|scroll|overlay)$/;function yl(t,e){return t.scrollHeight<=t.clientHeight||!Gr.test(getComputedStyle(t).overflowY)?!1:e>0?t.scrollTop+t.clientHeight<t.scrollHeight-1:t.scrollTop>0}function Tl(t,e){if(t.scrollWidth<=t.clientWidth)return!1;let n=getComputedStyle(t);if(!Gr.test(n.overflowX))return!1;let i=Math.abs(t.scrollLeft),o=t.scrollWidth-t.clientWidth;return(n.direction==="rtl"?e<0:e>0)?i<o-1:i>0}var $r=new WeakMap,qr=new WeakSet;function B(t,e,n){if($r.set(t,n),qr.has(t))return;qr.add(t);let i=()=>$r.get(t),o=r=>{if(!(r instanceof Element))return null;let a=r.closest(e.itemSelector);return a&&t.contains(a)?a:null};e.onClick&&t.addEventListener("click",r=>{let a=o(r.target);a&&e.onClick?.(a,i(),r)}),e.onEnter&&t.addEventListener("mouseenter",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onEnter?.(a,i())},!0),e.onLeave&&t.addEventListener("mouseleave",r=>{let a=r.target;a instanceof HTMLElement&&a.matches(e.itemSelector)&&e.onLeave?.(a,i())},!0),e.preventMousedown&&t.addEventListener("mousedown",r=>r.preventDefault())}function de(t){return Number.parseInt(t.dataset.aiaIndex??"-1",10)}function K(t){t.offsetWidth}var ue="magicx-aia-panel-ghost";function Ee(t){return t.closest(`.${ue}`)!==null}function F(t,e){for(let n of t.querySelectorAll(e))if(!Ee(n))return n;return null}var Fn="--aia-multi-done-fit";function Kr(t){return F(t,"[data-aia-multi-done]")}function Wn(t,e){if(!e?.isConnected)return;let n=e.ownerDocument,i=n.defaultView?.getComputedStyle(e).direction==="rtl";if(typeof n.createRange().getBoundingClientRect!="function")return;let o=e.getBoundingClientRect(),r=0;for(let a of t.querySelectorAll("[data-aia-option]")){if(Ee(a))continue;let s=n.defaultView?.getComputedStyle(a),l=Number.parseFloat(i?s?.paddingRight??"0":s?.paddingLeft??"0")||0,d=n.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=n.createRange();for(let u=d.nextNode();u;u=d.nextNode()){if(!u.textContent?.trim())continue;c.selectNodeContents(u);let p=c.getBoundingClientRect();if(p.width===0)continue;let f=i?o.right-p.left:p.right-o.left;r=Math.max(r,f+l)}}r>0?e.style.setProperty(Fn,`${Math.ceil(r)}px`):e.style.removeProperty(Fn)}var Ji="data-aia-hug",Bn="--aia-panel-fit-width",xl=36;function pt(t){t.removeAttribute(Ji)}function Zi(t,e,{eligible:n,loading:i}){if(!n){t.style.removeProperty(Bn);return}if(i){t.style.getPropertyValue(Bn)&&t.setAttribute(Ji,"");return}let o=vl(t,e);if(o==null){t.style.removeProperty(Bn);return}t.style.setProperty(Bn,`${o}px`),t.setAttribute(Ji,"")}var zr=new WeakMap;function vl(t,e){if(We())return null;let n=F(e,".aia-grid");if(!n||t.offsetWidth===0)return null;let i=F(e,"[data-aia-pillbar]"),o=[n.style.gridTemplateColumns,i?.textContent??"",...Array.from(n.querySelectorAll("[data-aia-option]"),s=>s.textContent)].join("\0"),r=zr.get(t);if(r?.key===o)return r.width;let a=El(t,e,n);return zr.set(t,{key:o,width:a}),a}function El(t,e,n){let i=Fe(n);if(!i||i.rowWidths.some(s=>s<=0))return null;let o=Math.ceil(Math.max(...i.rowWidths)),r=Math.max(1,eo(n.style.gridTemplateColumns)),a=jr(n,t,r-1)+r*(o+xl);return Math.ceil(Math.max(a,Pl(e,t)))}function Pl(t,e){let n=F(t,"[data-aia-pillbar]");if(!n)return 0;let i=n.querySelector("[data-aia-pill-scroll]")?.scrollWidth??0,o=n.querySelector("[data-aia-skip]")?.offsetWidth??0;return i+o===0?0:jr(n,e,i>0&&o>0?1:0)+i+o}function eo(t){let e=0,n=0,i=!1;for(let o of t)o==="("?e++:o===")"&&e--,e===0&&/\s/.test(o)?i=!1:i||(i=!0,n++);return n}function jr(t,e,n){let i=0;for(let o=t;o;o=o.parentElement){let r=getComputedStyle(o);if(i+=(Number.parseFloat(r.paddingLeft)||0)+(Number.parseFloat(r.paddingRight)||0)+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(r.borderRightWidth)||0),o===t&&(i+=n*(Number.parseFloat(r.columnGap)||0)),o===e)break}return i}var wl="[data-aia-products], [data-aia-datepicker], [data-aia-date-grid], [data-aia-time-wheel], [data-aia-location]";function Qr(t){let e=!t.hasAttribute("data-aia-has-products")&&F(t,".aia-grid [data-aia-option]")!==null&&F(t,wl)===null,n=F(t,".aia-grid [data-aia-option][data-aia-loading]")!==null;e||pt(t),Zi(t,t,{eligible:e,loading:n})}var Yr=40,Xr=340,Jr=340,Zr=7,Un="--aia-option-enter-delay";function Vn(t,e,n,i="below"){let o=Math.max(1,Math.floor(e)),r=Math.floor(Math.max(0,t)/o);if(i!=="above")return r*40;let a=Math.max(1,Math.ceil(Math.max(0,n)/o));return Math.max(0,a-1-r)*40}function Gn(t,e){let n=Math.max(1,Math.floor(e));return(Math.max(1,Math.ceil(Math.max(0,t)/n))-1)*40+340}var io="magicx-aia-scroll-arrow",gt="data-aia-scroll-arrow",Pe="data-aia-visible",oo=1e3,ro=160,ao="--aia-scroll-arrow-bottom",ta="Scroll down for more options",to="data-aia-scrollable",Cl="--aia-scroll-track-top",Ll="--aia-scroll-track-height",Al="--aia-scroll-track-right",Il="--aia-scroll-thumb-top",Ol="--aia-scroll-thumb-height",Ml=12,kl=.5,Rl="[data-aia-products-label]",ea=4,_l=8,Dl=240;function Nl(t,e,n,i){let o=t.scrollTop,r=n?.requestAnimationFrame,a=t.ownerDocument?.visibilityState==="hidden";if(!r||a||no(t)){t.scrollTop=o+e,i();return}let s=n.performance?.now?.()??Date.now(),l=()=>n.performance?.now?.()??Date.now(),d=()=>{let c=Math.min(1,(l()-s)/Dl),u=1-(1-c)*(1-c);t.scrollTop=o+e*u,c<1?r.call(n,d):i()};r.call(n,d)}function Hl(t=document){let e="http://www.w3.org/2000/svg",n=t.createElementNS(e,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");let i=t.createElementNS(e,"path");return i.setAttribute("d","M4 6.5 8 10.5l4-4"),n.appendChild(i),n}function na(t=document,e=M()){let n=t.createElement("button");return n.type="button",n.tabIndex=-1,n.className=io,n.setAttribute(gt,""),n.setAttribute("aria-label",e.scrollArrow),n.setAttribute("aria-hidden","true"),n.disabled=!0,n.appendChild(Hl(t)),n}function Fl(t){return Math.max(1,eo(t.style.gridTemplateColumns))}function no(t){return t.closest('[data-animations="off"]')?!0:!!t.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function $n({dropdown:t,grid:e,button:n}){let i=e.ownerDocument?.defaultView??(typeof window<"u"?window:null),o=!1;n.disabled=!0;let r=null,a=null,s=null,l=null,d=E=>{if(E){if(n.hasAttribute(Pe))return;if(n.setAttribute(Pe,""),n.setAttribute("aria-hidden","false"),l!==null&&clearTimeout(l),no(e)){n.disabled=!1;return}l=setTimeout(()=>{l=null,!o&&n.hasAttribute(Pe)&&(n.disabled=!1)},oo)}else n.removeAttribute(Pe),n.setAttribute("aria-hidden","true"),l!==null&&clearTimeout(l),l=null,n.disabled=!0},c=E=>{let w=0,y=E;for(;y&&y!==t;)w+=y.offsetTop,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},u=()=>{let E=F(t,Rl),w;if(E){let y=c(E)+E.offsetHeight/2;w=t.clientHeight-y-n.offsetHeight/2}else{let y=c(e),C=i&&Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0;w=t.clientHeight-(y+e.offsetHeight)+(C>0?0:_l)}n.style.setProperty(ao,`${Math.max(0,Math.round(w))}px`)},p=E=>{let w=0,y=E;for(;y&&y!==t;)w+=y.offsetLeft,y=y.offsetParent instanceof HTMLElement?y.offsetParent:null;return w},f=null,g=(E,w)=>{let y=Math.min(1,Math.max(0,e.scrollTop/E));n.style.setProperty(Il,`${Math.round(w*y)}px`)},h=()=>{let E=e.scrollHeight-e.clientHeight,w=e.querySelector("[data-aia-option][data-aia-loading]")!==null;if(E<=ea||w){f=null,n.removeAttribute(to);return}let y=e.clientHeight,C=Math.round(y*kl),_=c(e)+(y-C)/2,O=t.clientWidth-(p(e)+e.offsetWidth),ee=Math.min(C,Math.max(Ml,Math.round(C*y/e.scrollHeight)));f={overflow:E,travel:C-ee},n.style.setProperty(Cl,`${Math.round(_)}px`),n.style.setProperty(Ll,`${C}px`),n.style.setProperty(Al,`${Math.max(0,Math.round(O))}px`),n.style.setProperty(Ol,`${ee}px`),g(E,f.travel),n.setAttribute(to,"")},b=()=>{if(o||a!==null||s!==null)return;let E=e.querySelector("[data-aia-option][data-aia-loading]")!==null,w=e.scrollHeight-e.clientHeight-e.scrollTop;d(!E&&w>ea)},x=()=>{if(o)return;u(),h();let E=e.getAttribute("data-aia-group")??"";if(E!==r){r=E,d(!1),a!==null&&clearTimeout(a);let w=e.querySelectorAll("[data-aia-option]").length,y=no(e)?0:Gn(w,Fl(e));a=setTimeout(()=>{a=null,b()},y);return}b()},m=()=>{o||(f&&g(f.overflow,f.travel),a===null&&(d(!1),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,b()},ro)))};e.addEventListener("scroll",m,{passive:!0});let S=E=>E.preventDefault(),P=()=>{let E=i?(Number.parseFloat(i.getComputedStyle(e).paddingTop)||0)+(Number.parseFloat(i.getComputedStyle(e).paddingBottom)||0):0,w=Math.max(1,e.clientHeight-E);Nl(e,w,i,m)};n.addEventListener("mousedown",S),n.addEventListener("click",P);let T=null;return i&&typeof i.ResizeObserver=="function"&&(T=new i.ResizeObserver(()=>{u(),h(),b()}),T.observe(e)),x(),{update:x,destroy(){o||(o=!0,a!==null&&clearTimeout(a),a=null,s!==null&&clearTimeout(s),s=null,l!==null&&clearTimeout(l),l=null,n.disabled=!0,e.removeEventListener("scroll",m),n.removeEventListener("mousedown",S),n.removeEventListener("click",P),T?.disconnect(),n.removeAttribute(Pe),n.removeAttribute(to),n.setAttribute("aria-hidden","true"))}}}var ia="cubic-bezier(0.25, 0.1, 0.25, 1)",Wl="cubic-bezier(0.32, 0.72, 0, 1)",so=360,lo=280,co=320,uo=40,oa="blur(2px)";function ra(t){return t.hasAttribute(gt)}var ne=new WeakMap;function Bl(t,e){return!e||typeof t.animate!="function"||t.closest('[data-animations="off"]')||t.closest('[data-aia-options-style="classic"]')?!1:!(t.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)")??null)?.matches}function Ul(t,e){let n=0,i="";for(let o of Array.from(t.children))o.classList.contains(ue)||(n+=1+o.getElementsByTagName("*").length,i+=`${o.textContent??""}\0`);return`${e??""}${n}${i}`}function Vl(t){let e=t.ownerDocument.createElement("div");e.className=ue,e.setAttribute("aria-hidden","true"),e.inert=!0;for(let n of Array.from(t.children))n.classList.contains(ue)||ra(n)||e.appendChild(n.cloneNode(!0));for(let n of[e,...Array.from(e.querySelectorAll("*"))]){n.removeAttribute("id"),n.removeAttribute("role"),n.removeAttribute("tabindex"),n.tagName==="A"&&n.removeAttribute("href"),n.tagName==="BUTTON"&&(n.disabled=!0);for(let i of Array.from(n.attributes))i.name.startsWith("aria-")&&i.name!=="aria-hidden"&&n.removeAttribute(i.name)}return e}function Gl(t,e,n){for(let r of Array.from(t.children))r.classList.contains(ue)&&r.remove();let i=(t.ownerDocument.defaultView??window).getComputedStyle(t);e.style.cssText=["position:absolute","left:0","right:0",n?"bottom:0":"top:0",`padding:${i.padding}`,"pointer-events:none","box-sizing:border-box"].join(";");let o=Array.from(t.children).filter(r=>!ra(r));t.appendChild(e),e.animate([{opacity:1,filter:"blur(0px)"},{opacity:0,filter:oa}],{duration:lo,easing:ia,fill:"forwards"}).finished.then(()=>e.remove(),()=>e.remove());for(let r of o)r.animate([{opacity:0,filter:oa},{opacity:1,filter:"blur(0px)"}],{duration:co,delay:uo,easing:ia,fill:"backwards"})}function qn(t){let e=t[0]?.text;return e==null||e===""?null:e}function ft(t,e,n){let i=n.visible,o=Bl(t,n.enabled??!0),r=ne.get(t);if(!i||!o){o||r?.glide?.cancel(),ne.set(t,{height:0,key:i?e:null,signature:"",snapshot:null,glide:o?r?.glide??null:null});return}let a=Ul(t,e);if(r&&r.height>0&&r.glide&&r.signature===a)return;let s=me(t),l=t.getBoundingClientRect().height;r?.glide?.cancel();let d=t.getBoundingClientRect().height,c=null,u=r?s?l:r.height:0;if(r&&u>0&&(e!==r.key&&r.snapshot&&Gl(t,r.snapshot,n.anchorBottom??!1),Math.abs(u-d)>1)){c=t.animate([{height:`${u}px`},{height:`${d}px`}],{duration:so,easing:Wl});let f=c;c.finished.then(()=>{let g=ne.get(t);g?.glide===f&&(g.glide=null)},()=>{})}let p=null;e!==null&&(p=r&&r.signature===a&&r.snapshot&&!r.snapshot.isConnected?r.snapshot:Vl(t)),ne.set(t,{height:d,key:e,signature:a,snapshot:p,glide:c})}function me(t){let e=ne.get(t)?.glide??null;return e&&(e.playState==="running"||e.pending)?e:null}function Kn(t){if(!me(t))return null;let e=ne.get(t)?.height??0;return e>0?e:null}function zn(t,e){let n=ne.get(t);n&&n.height>0&&!me(t)&&e>0&&(n.height=e)}function jn(t){ne.get(t)?.glide?.cancel(),ne.delete(t)}var aa="data-aia-key";function Z(t,e,n){let i=new Map;for(let a of Array.from(t.children)){let s=a.getAttribute(aa);s!=null&&i.set(s,a)}let o=new Set,r=[];for(let a=0;a<e.length;a++){let s=e[a],l=n.keyOf(s,a);o.add(l);let d=i.get(l);d||(d=n.create(s,a),d.setAttribute(aa,l)),n.update?.(d,s,a),t.children[a]!==d&&t.insertBefore(d,t.children[a]??null),r.push(d)}for(let[a,s]of i)o.has(a)||s.remove();return r}function sa(t,e){if(!e.interactive)return null;let n=e.options[de(t)];return n?.is_tappable?n:null}var $l={itemSelector:"[data-aia-date-cell], [data-aia-date-prev], [data-aia-date-next]",onClick:(t,e)=>{if(t.hasAttribute("data-aia-date-prev")){e.callbacks.onPreviousMonth();return}if(t.hasAttribute("data-aia-date-next")){e.callbacks.onNextMonth();return}let n=sa(t,e);n&&(t.classList.add("magicx-aia-date-cell--pressed"),e.callbacks.onSelect(n),setTimeout(()=>t.classList.remove("magicx-aia-date-cell--pressed"),170))},onEnter:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&sa(t,e)&&e.callbacks.onHighlight(de(t))},onLeave:(t,e)=>{t.hasAttribute("data-aia-date-cell")&&e.callbacks.onHighlight(-1,de(t))}};function ca(t,e,n,i,o,r,a,s=!0){let l=t.querySelector(".magicx-aia-datepicker");if(!o||e.length===0){l?.remove();return}if(!l){l=zl(),t.appendChild(l),K(l);for(let u of l.querySelectorAll(".magicx-aia-datepicker-nav"))u.disabled=!1}B(l,$l,{options:e,callbacks:a,interactive:s});let d=l.querySelector(".magicx-aia-datepicker-month");d&&(d.textContent=Ut(o));let c=l.querySelector(".magicx-aia-datepicker-grid");c&&ql(c,e,n,i,r)}function ql(t,e,n,i,o){let r=G(new Date),a=Mn({pendingStart:o.rangeStart,highlightedIso:$(e[n]),selected:o.selectedRange,floor:o.floor});Z(t,e,{keyOf:(s,l)=>$(s)??`pad-${l}`,create:s=>Kl(s),update:(s,l,d)=>{let c=$(l),u=kn(c,{selectedIso:o.selectedIso,range:a}),p=d===n&&l.is_tappable;s.id=`${i}-option-${d}`,s.dataset.aiaIndex=String(d),s.setAttribute("aria-selected",String(p)),s.classList.toggle("magicx-aia-date-cell--past",Rn(c,r,o.floor)),s.classList.toggle("magicx-aia-date-cell--highlighted",p),s.classList.toggle("magicx-aia-date-cell--today",c!=null&&c===r),s.classList.toggle("magicx-aia-date-cell--selected",u.selected),s.classList.toggle("magicx-aia-date-cell--in-range",u.inRange)}})}function Kl(t){let e=document.createElement("div");e.setAttribute("role","option"),e.setAttribute("data-aia-option",""),e.setAttribute("data-aia-date-cell","");let n=qt(t);if(n==null)return e.className="magicx-aia-date-cell magicx-aia-date-cell--blank",e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e;e.className="magicx-aia-date-cell magicx-aia-date-cell--day",e.tabIndex=0,e.setAttribute("aria-label",t.text);let i=document.createElement("span");return i.className="magicx-aia-date-cell-number",i.textContent=String(n),e.appendChild(i),e}function zl(){let t=document.createElement("div");t.className="magicx-aia-datepicker",t.setAttribute("data-aia-datepicker","");let e=document.createElement("div");e.className="magicx-aia-datepicker-header";let n=document.createElement("span");n.className="magicx-aia-datepicker-month",n.setAttribute("data-aia-date-month",""),n.setAttribute("aria-live","polite"),e.append(la("prev","Previous month","\u2039"),n,la("next","Next month","\u203A"));let i=document.createElement("div");i.className="magicx-aia-datepicker-weekdays",i.setAttribute("aria-hidden","true");for(let r of Ze){let a=document.createElement("span");a.className="magicx-aia-datepicker-weekday",a.textContent=r,i.appendChild(a)}let o=document.createElement("div");return o.className="magicx-aia-datepicker-grid",o.setAttribute("data-aia-date-grid",""),t.append(e,i,o),t}function la(t,e,n){let i=document.createElement("button");return i.type="button",i.tabIndex=-1,i.className="magicx-aia-datepicker-nav",i.setAttribute(`data-aia-date-${t}`,""),i.setAttribute("aria-label",e),i.textContent=n,i.disabled=!0,i}var jl='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/></svg>',da="data-aia-location-body";function Ql(t){let e=document.createElement("div");e.className="magicx-aia-location-row",e.setAttribute("data-aia-location-row",""),e.setAttribute("role","option");let n=document.createElement("span");n.className="magicx-aia-location-pin",n.innerHTML=jl;let i=document.createElement("span");i.className="magicx-aia-location-text";let o=document.createElement("span");if(o.className="magicx-aia-location-name",o.textContent=t.name,i.appendChild(o),t.secondary){let r=document.createElement("span");r.className="magicx-aia-location-secondary",r.textContent=t.secondary,i.appendChild(r)}return e.append(n,i),e}function Yl(t,e){if(t==="loading"){let o=document.createElement("div");o.className="magicx-aia-location-loading",o.setAttribute("data-aia-location-loading","");for(let r=0;r<3;r++)o.appendChild(document.createElement("span")).className="magicx-aia-location-loading-bar";return o}if(t==="")return null;let n=document.createElement("div");if(n.className="magicx-aia-location-note",n.setAttribute("data-aia-location-note",""),t==="note-empty"){let o=document.createElement("span");o.className="magicx-aia-location-empty",o.textContent=e.locationNoResults,n.appendChild(o)}let i=document.createElement("span");return i.textContent=e.locationUseTyped,n.appendChild(i),n}function ua(t,e,n,i){let o=e.places,r="";if(o.length===0&&(e.status==="loading"?r="loading":e.query.trim()&&(r=e.status==="done"?"note-empty":"note")),t.getAttribute(da)!==r){for(let s of Array.from(t.children))s.hasAttribute("data-aia-location-row")||s.remove();let a=Yl(r,n);a&&t.appendChild(a),t.setAttribute(da,r)}Z(t,o,{keyOf:(a,s)=>`${s}:${a.id}`,create:a=>Ql(a),update:(a,s,l)=>{let d=l===e.highlighted;a.classList.toggle("magicx-aia-location-row--highlighted",d),a.setAttribute("aria-selected",String(d)),a.setAttribute("data-aia-index",String(l)),a.id=i(l)}})}var ie=new WeakMap,Xl=0,we=new WeakMap,Jl='<svg class="magicx-aia-location-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>',Ce=t=>Kt(t.input)===t.input;function ma(t,e){let n=Kt(t);if(n instanceof HTMLElement&&n!==e.input&&n!==R(t).body&&!t.contains(n)&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=xe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function Zl(t,e,n){if(!(!(n instanceof HTMLElement)||n===e.returnTo||t.contains(n))&&n!==R(t).body&&(e.returnTo=n,e.returnRange=null,n.isContentEditable)){let i=xe(n);i&&n.contains(i.startContainer)&&(e.returnRange=i.cloneRange())}}function ec(t,e){if(t.focus({preventScroll:!0}),!t.isContentEditable)return;let n=tt(t);if(!n)return;let i=e;(!i||!i.startContainer.isConnected||!t.contains(i.startContainer))&&(i=R(t).createRange(),i.selectNodeContents(t),i.collapse(!1)),n.removeAllRanges(),n.addRange(i)}var tc={itemSelector:"[data-aia-location-row]",onClick:(t,e)=>{if(!e.interactive)return;let n=t.closest("[data-aia-location]");n&&Ve(n,!0),e.callbacks.onLocationCommit(Number(t.dataset.aiaIndex))}};function Ve(t,e=!1){let n=we.get(t),i=ie.get(t);if(!n||!i)return;e&&(n.declined=!0);let o=n.returnTo;o?.isConnected&&Ce(n)&&(n.returning=!0,ec(o,n.returnRange),n.returning=!1),i.callbacks.onLocationFocusChange(!1)}function nc(t){let e=we.get(t),n=ie.get(t);if(!(!e||!n||Ce(e))){if(ma(t,e),n.callbacks.onLocationFocusChange(!0),e.input.focus({preventScroll:!0}),!Ce(e)){e.declined=!0,n.callbacks.onLocationFocusChange(!1);return}e.input.value&&e.input.select()}}function ic(t,e){t.className="magicx-aia-location",t.setAttribute("data-aia-location",""),t.id=`magicx-aia-location-${++Xl}`;let n=document.createElement("label");n.className="magicx-aia-location-field",n.innerHTML=Jl;let i=document.createElement("input");i.type="text",i.className="magicx-aia-location-input",i.setAttribute("data-aia-location-input",""),i.setAttribute("autocomplete","off"),i.setAttribute("autocapitalize","words"),i.setAttribute("enterkeyhint","done"),i.spellcheck=!1,i.placeholder=e.locationSearch,i.setAttribute("aria-label",e.locationSearch),n.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-location-results",o.setAttribute("data-aia-location-results",""),o.setAttribute("aria-live","polite"),t.append(n,o);let r={input:i,field:n,results:o,returnTo:null,returnRange:null,returning:!1,declined:!1,widgetFocused:!1,wasReediting:!1};return t.addEventListener("mousedown",a=>{!(a.target instanceof Node)||!n.contains(a.target)||(a.stopPropagation(),ma(t,r),ie.get(t)?.callbacks.onLocationFocusChange(!0))}),i.addEventListener("input",()=>ie.get(t)?.callbacks.onLocationQuery(i.value)),i.addEventListener("focus",a=>{Zl(t,r,a.relatedTarget),ie.get(t)?.callbacks.onLocationFocusChange(!0)}),i.addEventListener("blur",()=>{r.returning||(r.declined=!0,ie.get(t)?.callbacks.onLocationFocusChange(!1))}),i.addEventListener("keydown",a=>{let s=ie.get(t);if(!(!s||a.isComposing))switch(a.key){case"ArrowDown":case"ArrowUp":a.preventDefault(),s.callbacks.onLocationMove(a.key==="ArrowDown"?1:-1);return;case"Enter":if(a.preventDefault(),!s.interactive)return;Ve(t,!0),s.callbacks.onLocationCommit();return;case"Escape":a.preventDefault(),a.stopPropagation(),r.declined=!0,Ve(t);return;case"Backspace":if(i.value!=="")return;a.preventDefault(),r.declined=!0,Ve(t);return}}),we.set(t,r),r}function pa(t){for(let e of t.querySelectorAll("[data-aia-location]")){let n=we.get(e);n&&(Ce(n)&&Ve(e),n.declined=!1,n.input.tabIndex=-1)}}function ga(t,e,n,i,o={}){let r=Array.from(t.children).find(l=>l.hasAttribute("data-aia-location"))??null;if(!e){if(r){let l=we.get(r);l&&Ce(l)&&Ve(r),r.remove()}return}r||(r=document.createElement("div"),t.appendChild(r));let a=we.get(r)??ic(r,n);a.input.tabIndex=0,ie.set(r,{view:e,callbacks:i,interactive:o.interactive??!0}),B(a.results,tc,ie.get(r)),a.input.value!==e.query&&!Ce(a)&&(a.input.value=e.query);let s=l=>`${r?.id}-row-${l}`;if(ua(a.results,e,n,s),e.highlighted>=0&&e.highlighted<e.places.length?a.input.setAttribute("aria-activedescendant",s(e.highlighted)):a.input.removeAttribute("aria-activedescendant"),o.inputFocused){let l=o.reediting??!1;l&&!a.wasReediting&&(a.declined=!1),a.wasReediting=l}if(a.widgetFocused=o.inputFocused??!1,o.inputFocused){if(o.reediting&&!a.declined&&o.interactive!==!1&&!Ce(a)){let l=r;queueMicrotask(()=>{l.isConnected&&!we.get(l)?.declined&&nc(l)})}}else{let l=a;setTimeout(()=>{if(l.widgetFocused)return;let d=l.returnTo;d&&Kt(d)===d||(l.declined=!1)},0)}}var oc={itemSelector:"[data-aia-pill]",onClick:(t,e)=>{if(e.loading||t.disabled)return;let n=Number.parseInt(t.dataset.aiaPillIndex??"-1",10);n>=0&&e.onSelectPill(n)},preventMousedown:!0},fa=[125,69];function ha(t,e){return e?1:t===0?.7:t===1?.4:.2}function Qn(t,e,n,i,o=!1,r=!1,a=!1){let s=t.querySelector(".magicx-aia-pill-list");if(s||(s=document.createElement("span"),s.className="magicx-aia-pill-list",t.appendChild(s)),B(s,oc,{onSelectPill:i,loading:r}),r&&e.length===0){s.setAttribute("data-aia-pill-list-loading",""),s.innerHTML="";for(let l=0;l<fa.length;l++){let d=fa[l],c=document.createElement("span");c.setAttribute("data-aia-pill-skeleton",""),c.className=`magicx-aia-pill magicx-aia-pill--skeleton${o?" magicx-aia-pill--rounded":""}`,c.style.width=`${d}px`,c.style.setProperty("--aia-pill-opacity",String(ha(l,!1))),s.appendChild(c)}return}r?s.setAttribute("data-aia-pill-list-loading",""):s.removeAttribute("data-aia-pill-list-loading");for(let l of s.querySelectorAll("[data-aia-pill-skeleton]"))l.remove();Z(s,e,{keyOf:l=>`${l.type?.kind??""}|${Xe(l)?1:0}|${l.parameter}|${l.text}`,create:l=>{let d=document.createElement("button");if(d.type="button",d.tabIndex=-1,d.setAttribute("data-aia-pill",""),d.setAttribute("contenteditable","false"),Xe(l)){d.setAttribute("data-aia-smart-suggestion",L(l)?"header":"");let c=document.createElement("span");c.className="magicx-aia-smart-suggestion-text",c.textContent=l.text;let u=document.createElement("span");u.className="magicx-aia-smart-suggestion-sparkle",u.innerHTML=Nt,d.append(c,u)}else d.textContent=l.text;return d.disabled=!0,d},update:(l,d,c)=>{let u=l,p=a&&c===n&&!r,f=["magicx-aia-pill"];o&&f.push("magicx-aia-pill--rounded"),r&&f.push("magicx-aia-pill--skeleton"),u.className=f.join(" "),u.style.width="",u.style.setProperty("--aia-pill-opacity",String(ha(c,p))),u.dataset.aiaPillIndex=String(c),u.toggleAttribute("data-aia-pill-active",c===n),r?u.setAttribute("data-aia-loading",""):u.removeAttribute("data-aia-loading")}}),K(s);for(let l of s.querySelectorAll("[data-aia-pill]"))l.disabled=r}function mo(t){t.querySelector(".magicx-aia-pill-list")?.remove()}var ba=32;function po(t,e){if(e.ctrlKey)return null;let n=e.deltaY||0,i=e.deltaX||0;if(!n||Math.abs(i)>=Math.abs(n))return null;let o=t.scrollWidth-t.clientWidth;if(o<=1)return null;let r=t.scrollLeft,a=n;return e.deltaMode===1?a*=32:e.deltaMode===2&&(a*=t.clientWidth),Math.max(0,Math.min(o,r+a))}function Yn(t){let e=n=>{let i=po(t,n);i!==null&&(n.preventDefault(),t.scrollLeft=i)};return t.addEventListener("wheel",e,{passive:!1}),()=>t.removeEventListener("wheel",e)}var Sa=Intl.Segmenter,ya=Sa?new Sa(void 0,{granularity:"grapheme"}):null;function Xn(t){let e=t.trim().normalize("NFC").toUpperCase();if(ya)for(let n of ya.segment(e))return n.segment;return Array.from(e)[0]??"?"}var Jn=120,Ta=360;function rc(t){let e=t.pathname;return t.hostname==="cdn.shopify.com"&&e.startsWith("/s/files/")||e.startsWith("/cdn/shop/")?/\.png$/i.test(e)?{format:"pjpg"}:/\.webp$/i.test(e)?{format:null}:null:null}function go(t,e){let n;try{n=new URL(t,typeof document>"u"?void 0:document.baseURI)}catch{return t}let i=rc(n);return i?(n.searchParams.set("width",String(e)),i.format&&n.searchParams.set("format",i.format),t.startsWith("/")&&!t.startsWith("//")?`${n.pathname}${n.search}${n.hash}`:n.href):t}function fo(t,e){let n=go(t,e);return n===t?[t]:[n,t]}function Zn(t,e){if(!(t>0)||!(e>0))return null;let n=t/e,i=o=>Math.round(o*1e3)/1e3;return{x:i(Math.min(n,1)),y:i(Math.min(1/n,1))}}function ht(t){let e=t?.trim();return e?fo(e,360):[]}function xa(t){return ht(t)[0]}var ei=new WeakMap,bo=new WeakMap,Ea=new WeakMap;function Pa(t,e,n,i,o,r="row",a="image",s=M(),l){let d=t.querySelector(".magicx-aia-products");if(e.length===0){d?.remove();return}if(!d){d=document.createElement("section"),d.className="magicx-aia-products",d.setAttribute("data-aia-products",""),d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${n}-products-label`);let p=document.createElement("div");p.className="magicx-aia-products-label",p.id=`${n}-products-label`,p.setAttribute("data-aia-products-label",""),p.textContent=s.products;let f=document.createElement("div");f.className="magicx-aia-products-row",f.setAttribute("data-aia-products-row",""),Yn(f),d.append(p,f),t.appendChild(d)}d.setAttribute("data-aia-products-layout",r);let c=d.querySelector(".magicx-aia-products-label");c&&c.textContent!==s.products&&(c.textContent=s.products);let u=d.querySelector(".magicx-aia-products-row");if(u){Z(u,e,{keyOf:p=>cc(p,!!l),create:p=>dc(p,i,o,a,s,l),update:(p,f,g)=>{ei.set(p,f),ac(p,f.price,f.compareAtPrice),p.id=`${n}-product-${g}`,p.dataset.aiaIndex=String(g),Ea.get(p)?.(a);let h=p.querySelector(".magicx-aia-product-badge");h&&h.textContent!==s.soldOut&&(h.textContent=s.soldOut);let b=p.querySelector(".magicx-aia-product-cart");b&&b.setAttribute("aria-label",wa(f,s))}}),K(u);for(let p of u.querySelectorAll("[data-aia-product]")){let f=bo.get(p);f&&(bo.delete(p),f())}}}function So(t,e){let n=t.querySelectorAll("[data-aia-product], [data-aia-product-cart]");for(let i of n)Ee(i)||(i.tabIndex=e?0:-1)}function ac(t,e,n){let i=t.querySelector(".magicx-aia-product-price");if(!e){i?.remove();return}i||(i=document.createElement("span"),i.className="magicx-aia-product-price",i.append(document.createTextNode("")),t.querySelector(".magicx-aia-product-title")?.after(i));let o=i.firstChild;o.data!==e&&(o.data=e);let r=i.querySelector(".magicx-aia-product-compare-at");if(!n){r?.remove();return}r||(r=document.createElement("s"),r.className="magicx-aia-product-compare-at",i.append(r)),r.textContent!==n&&(r.textContent=n)}function va(t,e){e?(t.style.setProperty("--aia-product-photo-fill-x",String(e.x)),t.style.setProperty("--aia-product-photo-fill-y",String(e.y))):(t.style.removeProperty("--aia-product-photo-fill-x"),t.style.removeProperty("--aia-product-photo-fill-y"))}function wa(t,e){return`${e.addToCart}: ${t.title}`}var ho="http://www.w3.org/2000/svg";function sc(){let t=document.createElementNS(ho,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=[["magicx-aia-product-cart-glyph","M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"],["magicx-aia-product-cart-glyph","M13.5 6.5v-4M11.5 4.5h4"],["magicx-aia-product-cart-check","M5 12.5l4.5 4.5L19 7.5"],["magicx-aia-product-cart-spinner","M12 4a8 8 0 1 0 8 8"]];for(let[n,i]of e){let o=document.createElementNS(ho,"path");o.setAttribute("class",n),o.setAttribute("d",i),t.appendChild(o)}for(let n of["9","17.5"]){let i=document.createElementNS(ho,"circle");i.setAttribute("class","magicx-aia-product-cart-glyph"),i.setAttribute("cx",n),i.setAttribute("cy","20"),i.setAttribute("r","1.3"),t.appendChild(i)}return t}function lc(t,e,n,i,o){let r=document.createElement("span");r.className="magicx-aia-product-cart",r.setAttribute("data-aia-product-cart",""),r.setAttribute("role","button"),r.setAttribute("aria-label",wa(e,o)),r.tabIndex=0,r.appendChild(sc());let a=s=>{s.preventDefault(),s.stopPropagation(),r.getAttribute("data-aia-cart-state")!=="adding"&&(r.setAttribute("data-aia-cart-state","adding"),r.setAttribute("aria-busy","true"),n(ei.get(t)??e).then(()=>{r.removeAttribute("aria-busy"),r.setAttribute("data-aia-cart-state","added")},()=>{r.removeAttribute("aria-busy"),r.removeAttribute("data-aia-cart-state")}))};return r.addEventListener("keydown",s=>{s.key!=="Enter"&&s.key!==" "||a(s)}),r.addEventListener("focus",()=>i(!0)),r.addEventListener("blur",s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||i(!1)}),{el:r,arm:()=>r.addEventListener("click",a)}}function cc(t,e){return[e?"cart":"",t.id,t.title,t.url,t.imageUrl,t.vendor,t.available===!1?"sold-out":""].map(n=>n??"").join("\0")}function dc(t,e,n,i,o,r){let a=document.createElement("a");a.className="magicx-aia-product",a.setAttribute("data-aia-product",""),a.setAttribute("role","option"),a.setAttribute("aria-selected","false"),a.tabIndex=0;let s=document.createElement("span");s.className="magicx-aia-product-media",s.setAttribute("aria-hidden","true");let l=ht(t.imageUrl),d=l[0],c=!!d,u=()=>{s.replaceChildren(),s.removeAttribute("data-aia-image-loaded"),s.toggleAttribute("data-aia-product-placeholder",i==="image"),s.toggleAttribute("data-aia-product-initial",i==="initial"),i==="initial"&&(s.textContent=Xn(t.title))};if(Ea.set(a,h=>{h!==i&&(i=h,c||u())}),d){let h=document.createElement("img"),b=0;h.onload=()=>{s.setAttribute("data-aia-image-loaded",""),va(a,Zn(h.naturalWidth,h.naturalHeight))},h.onerror=()=>{let x=l[++b];if(x){h.src=x;return}c=!1,va(a,null),u()},h.className="magicx-aia-product-image",h.src=d,h.alt="",h.loading="lazy",h.decoding="async",s.appendChild(h)}else u();a.appendChild(s);let p=document.createElement("span");if(p.className="magicx-aia-product-body",t.vendor){let h=document.createElement("span");h.className="magicx-aia-product-vendor",h.textContent=t.vendor,p.appendChild(h)}let f=document.createElement("span");if(f.className="magicx-aia-product-title",f.textContent=t.title,p.appendChild(f),t.available===!1){a.setAttribute("data-aia-product-sold-out","");let h=document.createElement("span");h.className="magicx-aia-product-badge",h.textContent=o.soldOut,p.appendChild(h)}a.appendChild(p);let g=r&&t.available!==!1?lc(a,t,r,n,o):null;return g&&(a.setAttribute("data-aia-product-has-cart",""),a.appendChild(g.el)),bo.set(a,()=>{g?.arm(),t.url&&(a.href=t.url),a.addEventListener("click",h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.altKey||h.button!==0||(h.preventDefault(),e(ei.get(a)??t))})}),a.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),e(ei.get(a)??t))}),a.addEventListener("focus",()=>n(!0)),a.addEventListener("blur",h=>{h.relatedTarget?.closest("[data-aia-dropdown]")||n(!1)}),a}var Ca=10,La=44;function ti(t,e,n){if(!e||n.detail===0)return!0;let i=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(t.ownerDocument.defaultView?.getComputedStyle(t).direction==="rtl"){let s=Math.min(o.left-10,i.right-44);return n.clientX>=s}let a=Math.max(o.right+10,i.left+44);return n.clientX<=a}var Aa="http://www.w3.org/2000/svg",uc=new Set(["svg","g","path","circle","ellipse","line","polyline","polygon","rect"]);function mc(t,e){let n=t.toLowerCase();return n.startsWith("on")||n.includes("href")||n==="style"||n==="xml:base"||n==="id"||n==="name"||/^\s*javascript:/i.test(e)||/url\s*\(\s*['"]?\s*[^#'"\s)]/i.test(e)}var pc=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","fill-rule","clip-rule","opacity","fill-opacity","stroke-opacity"],gc=/^[a-zA-Z0-9#.,%\s()-]+$/;function fc(t){let e=[];for(let n of pc){let i=t.getAttribute(n);i===null||!gc.test(i)||/url\s*\(/i.test(i)||e.push(`${n}: ${i.trim()}`)}e.length>0&&t.setAttribute("style",e.join("; "))}function Ia(t){for(let e of Array.from(t.attributes))mc(e.name,e.value)&&t.removeAttribute(e.name);fc(t);for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE){let n=e;!uc.has(n.localName)||n.namespaceURI!==Aa?n.remove():Ia(n)}else e.remove()}function pe(t){if(typeof DOMParser>"u"||typeof XMLSerializer>"u")return null;let e=new DOMParser().parseFromString(t,"image/svg+xml"),n=e.documentElement;return!n||n.localName!=="svg"||n.namespaceURI!==Aa||e.getElementsByTagName("parsererror").length>0?null:(Ia(n),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),new XMLSerializer().serializeToString(n))}function bt(t){return t.text}function ge(t){return St(t)[0]??null}function St(t){let e=hc(t);return e?fo(e,120):[]}function hc(t){if(!t)return null;let e=t.trim();if(e==="")return null;let n;try{n=new URL(e,typeof document>"u"?void 0:document.baseURI)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}function Ge(t){return t===void 0||!Number.isInteger(t)||t<0?null:t.toLocaleString()}var yo={one:"item",other:"items"};function Oa(t,e=yo){let n=Ge(t);if(n===null)return null;let i=typeof e=="string"?e:t===1?e.one:e.other;return i===""?n:`${n} ${i}`}function To(t){return ge(t.image_url)!==null}var ni=new Map;function bc(t){let e=t.icon_svg;if(!e)return!1;let n=ni.get(e);return n===void 0&&(n=pe(e)!==null,ni.size>=256&&ni.clear(),ni.set(e,n)),n}function ii(t,e,n){return!e&&!n?!1:t.every(i=>!i.is_tappable||n&&To(i)||e&&bc(i))}var Ma=new WeakMap;function Sc(t,e,n){let i=e.length,o=We(),r=Ma.get(t),a=n&&r&&Pn(r.options,e)?r.plan:null,s=!a&&!n&&vn(i,o)?Fe(t):null,l=a??En(i,o,s?.rowWidths??null,s?.gridWidth??null);return n||Ma.set(t,{options:e,plan:l}),t.style.gridTemplateColumns=l.template,t.style.setProperty("--aia-grid-max-height",l.maxHeight),t.querySelectorAll("[data-aia-option]").forEach((d,c)=>{d.classList.toggle("magicx-aia-option--scroll-hint",!n&&l.scrollHintIndices.includes(c))}),l.cols}function ka(t,e){if(e.loading||!e.interactive)return null;let n=e.options[de(t)];return n?.is_tappable?n:null}var yc={itemSelector:"[data-aia-option]",onClick:(t,e,n)=>{let i=ka(t,e);if(!i)return;t.classList.add("magicx-aia-option--pressed");let o=t.querySelector(".magicx-aia-checkbox"),r=o!==null&&!ti(t,o,n);if(o){let a=r||t.getAttribute("aria-selected")!=="true";t.setAttribute("aria-selected",String(a)),o.dataset.checked=String(a),o.textContent=a?"\u2713":""}r?e.onSelect(i,{commit:!0}):e.onSelect(i),setTimeout(()=>t.classList.remove("magicx-aia-option--pressed"),170)},onEnter:(t,e)=>{ka(t,e)&&e.onHighlight(de(t))},onLeave:(t,e)=>e.onHighlight(-1,de(t))};function Ra(t,e,n,i,o,r,a,s="",l="below",d=!0,c=!0,u=!0,p=!0,f){let g=t.querySelector(".aia-grid");if(e.length===0){g?.remove();return}g||(g=document.createElement("div"),g.className="aia-grid magicx-aia-grid",g.setAttribute("data-scroll",""),g.style.setProperty("--aia-grid-min","250px"),g.style.setProperty("--aia-grid-max","1fr"),g.style.setProperty("--aia-grid-gap","0"),t.appendChild(g)),B(g,yc,{options:e,onSelect:i,onHighlight:o,loading:a,interactive:p});let h=g.dataset.aiaGroup!==s;g.dataset.aiaGroup=s;let b=ii(e,d,c);Tc(g,e,n,r,a,{showIcons:d&&b,showImages:c&&b,showCounts:u,picked:f});let x=Sc(g,e,a);xc(g,e.length,x,a,l),h&&(g.scrollTop=0)}function Tc(t,e,n,i,o,r){let a=o?"1":"0",s=t.dataset.aiaGroup??"",{showIcons:l,showImages:d,showCounts:c}=r,u=l?g=>g.icon??g.icon_svg??"":()=>"",p=d?g=>ge(g.image_url)??"":()=>"",f=c?g=>Ge(g.item_count)??"":()=>"";Z(t,e,{keyOf:g=>`${g.text}\0${g.parameterLabel??""}\0${u(g)}\0${p(g)}\0${f(g)}\0${a}\0${s}`,create:(g,h)=>{let b=vc(g,o,r);return o||(b.dataset.aiaEntering=""),b},update:(g,h,b)=>{if(xo.get(g)!==(h.matchedText??"")){let S=g.querySelector(".magicx-aia-option-text");S&&_a(S,h),xo.set(g,h.matchedText??"")}let x=b===n&&!o;g.id=`${i}-option-${b}`,g.dataset.aiaIndex=String(b),g.setAttribute("aria-selected",String(r.picked?r.picked.includes(h.text):x));let m=g.querySelector(".magicx-aia-checkbox");r.picked&&h.is_tappable?(m||(m=document.createElement("span"),m.className="magicx-aia-checkbox",m.setAttribute("aria-hidden","true"),g.querySelector(".magicx-aia-option-content")?.prepend(m)),m.dataset.checked=String(r.picked.includes(h.text)),m.textContent=r.picked.includes(h.text)?"\u2713":""):m?.remove(),g.classList.toggle("magicx-aia-option--highlighted",x),g.classList.toggle("magicx-aia-option--live-match",!!h.liveMatch&&!o)}})}function xc(t,e,n,i,o){for(let r of t.querySelectorAll("[data-aia-entering]")){if(!i){let a=Number.parseInt(r.dataset.aiaIndex??"-1",10);a>=0&&r.style.setProperty(Un,`${Vn(a,n,e,o)}ms`)}delete r.dataset.aiaEntering}}var xo=new WeakMap;function _a(t,e){if(t.replaceChildren(),e.matchedText)for(let n of Cn(bt(e),e.matchedText))if(n.bold){let i=document.createElement("strong");i.className="magicx-aia-option-match",i.textContent=n.text,t.appendChild(i)}else t.appendChild(document.createTextNode(n.text));else t.appendChild(document.createTextNode(bt(e)));if(e.parameterLabel){t.appendChild(document.createTextNode(" "));let n=document.createElement("span");n.className="magicx-aia-option-parameter",n.textContent=e.parameterLabel,t.appendChild(n)}}function vc(t,e,{showIcons:n,showImages:i,showCounts:o}){let r=document.createElement("div");r.setAttribute("role","option"),r.setAttribute("data-aia-option",""),e&&r.setAttribute("data-aia-loading",""),r.tabIndex=e||!t.is_tappable?-1:0;let a=["magicx-aia-option"];t.is_tappable?a.push("magicx-aia-option--tappable"):a.push("magicx-aia-option--non-tappable"),r.className=a.join(" ");let s=document.createElement("span");s.className="magicx-aia-option-content";let l=i?St(t.image_url):[],d=l[0];if(d){let f=document.createElement("span");f.className="magicx-aia-option-image",f.setAttribute("aria-hidden","true");let g=document.createElement("img");g.setAttribute("alt",""),g.setAttribute("loading","lazy"),g.setAttribute("decoding","async"),g.setAttribute("referrerpolicy","no-referrer"),g.setAttribute("draggable","false");let h=0;g.onload=()=>f.setAttribute("data-aia-image-loaded",""),g.onerror=()=>{let b=l[++h];b?g.src=b:g.hidden=!0},g.src=d,f.appendChild(g),s.appendChild(f),r.dataset.aiaImage=""}let c=!d&&n&&t.icon_svg?pe(t.icon_svg):null;if(c){let f=document.createElement("span");f.className="magicx-aia-option-icon",f.setAttribute("aria-hidden","true"),f.innerHTML=c,s.appendChild(f),t.icon&&(r.dataset.aiaIcon=t.icon)}let u=document.createElement("span");if(u.className="magicx-aia-option-text",_a(u,t),xo.set(r,t.matchedText??""),s.appendChild(u),t.tag){let f=document.createElement("span");f.className="magicx-aia-option-tag",f.textContent=t.tag,s.appendChild(f)}let p=o?Ge(t.item_count):null;if(p!==null){let f=document.createElement("span");f.className="magicx-aia-option-count",f.textContent=p,s.appendChild(f),r.dataset.aiaItemCount=String(t.item_count)}return r.appendChild(s),r}var Ec=120,Pc={itemSelector:"[data-aia-time-row], [data-aia-time-done]",onClick:(t,e)=>{if(!e.interactive)return;if(t.hasAttribute("data-aia-time-done")){e.callbacks.onTimeCommit();return}let n=t.dataset.aiaTimeColumn;n&&e.callbacks.onTimeChange(lt(n,e.view.minutes,Number(t.dataset.aiaIndex)))}},Na=new WeakMap,Da=new WeakMap;function Ha(t,e,n,i,o=!0){let r=t.querySelector(".magicx-aia-time-wheel");if(!e){r?.remove();return}if(!r){r=Lc(),t.appendChild(r),K(r);let d=r.querySelector("[data-aia-time-done]");d&&(d.disabled=!1)}let a={view:e,callbacks:i,interactive:o};Na.set(r,a),B(r,Pc,a),r.setAttribute("aria-label",n.timeLabel);let s=r.querySelector("[data-aia-time-done]");s&&(s.textContent=n.done);let l=r.querySelector("[data-aia-time-value]");l&&(l.textContent=ot(e.minutes));for(let d of at){let c=r.querySelector(`[data-aia-time-column="${d}"]`);c&&wc(c,d,e.minutes)}}function wc(t,e,n){let i=st(e,n);for(let a of t.querySelectorAll("[data-aia-time-row]")){let s=Number(a.dataset.aiaIndex)===i;a.classList.toggle("magicx-aia-time-wheel-row--selected",s),a.setAttribute("aria-selected",String(s))}let o=oi(t);if(o.settle)return;let r=i*rt;Math.abs(t.scrollTop-r)<1||(o.syncedTop=r,t.scrollTop=r)}function oi(t){let e=Da.get(t);return e||(e={syncedTop:null,settle:null},Da.set(t,e)),e}function Cc(t,e,n){let i=oi(e);if(i.syncedTop!=null&&Math.abs(e.scrollTop-i.syncedTop)<1){i.syncedTop=null;return}i.syncedTop=null,i.settle&&clearTimeout(i.settle),i.settle=setTimeout(()=>Fa(t,e,n),Ec)}function Fa(t,e,n){let i=oi(e);i.settle&&clearTimeout(i.settle),i.settle=null;let o=Na.get(t);if(!o||!o.interactive)return;let r=cn(n,e.scrollTop);r!==st(n,o.view.minutes)&&o.callbacks.onTimeChange(lt(n,o.view.minutes,r))}function Lc(){let t=document.createElement("div");t.className="magicx-aia-time-wheel",t.setAttribute("data-aia-time-wheel",""),t.setAttribute("role","group");let e=document.createElement("span");e.className="magicx-aia-time-wheel-value",e.setAttribute("data-aia-time-value",""),e.setAttribute("aria-live","polite");let n=document.createElement("div");n.className="magicx-aia-time-wheel-columns",n.setAttribute("aria-hidden","true");let i=document.createElement("div");i.className="magicx-aia-time-wheel-band",n.appendChild(i);for(let r of at){if(r==="minute"){let a=document.createElement("span");a.className="magicx-aia-time-wheel-separator",a.textContent=":",n.appendChild(a)}n.appendChild(Ac(t,r))}let o=document.createElement("button");return o.type="button",o.tabIndex=-1,o.className="magicx-aia-time-wheel-done",o.setAttribute("data-aia-time-done",""),o.disabled=!0,t.append(e,n,o),t}function Ac(t,e){let n=document.createElement("div");return n.className="magicx-aia-time-wheel-column",n.setAttribute("data-aia-time-column",e),ln(e).forEach((i,o)=>{let r=document.createElement("div");r.className="magicx-aia-time-wheel-row",r.setAttribute("data-aia-time-row",""),r.dataset.aiaTimeColumn=e,r.dataset.aiaIndex=String(o),r.textContent=i.label,n.appendChild(r)}),n.addEventListener("scroll",()=>Cc(t,n,e),{passive:!0}),n.addEventListener("scrollend",()=>{oi(n).settle&&Fa(t,n,e)}),n}var Le="data-aia-fit",yt="--aia-dropdown-fit-height",Wa=8,Ic=160;function ri({dropdown:t,isOpen:e}){let n=t.ownerDocument?.defaultView??null,i=!1,o=!1,r=null,a=null,s=null,l=null,d=!1,c=()=>{t.removeAttribute(Le),t.style.removeProperty(yt)},u=()=>{if(me(t)){d=!0;return}d=!1,zn(t,t.getBoundingClientRect().height)},p=m=>`${r}|${(m??t).scrollHeight}|${t.offsetWidth}`,f=m=>s?.key===p(m)?s.height:null,g=m=>{let S=p(m);if(s?.key===S)return s.height;let P=m?.scrollTop??0;t.removeAttribute(Le);let T=t.offsetHeight;return t.setAttribute(Le,""),m&&P&&(m.scrollTop=P),s={key:S,height:T},T},h=()=>{if(i)return;if(!e()){o=!1;return}let m=me(t),S=m?Kn(t):null;m&&l!==m&&(l=m,m.finished.then(b,b)),!m&&d&&u(),o||(o=!0,c());let P=t.hasAttribute(Le),T=F(t,".aia-grid")?.getAttribute("data-aia-group")??null,E=T!==r;r=T;let w=Mc(t,n);if(w===null)return;let y=Oc(t);if(P){let O=m?f(y):g(y);if(O!==null&&O<=w){c(),u();return}}else if((S??t.offsetHeight)<=w)return;let C=`${Math.max(Ic,Math.floor(w))}px`,_=t.style.getPropertyValue(yt)!==C;_&&t.style.setProperty(yt,C),P?E&&y&&(y.scrollTop=0):t.setAttribute(Le,""),(_||!P)&&u()},b=()=>{i||a!==null||!n||(a=n.requestAnimationFrame(()=>{a=null,h()}))},x=n?.visualViewport??null;return x?.addEventListener("resize",b),x?.addEventListener("scroll",b),n?.addEventListener("resize",b),n?.addEventListener("scroll",b,{capture:!0,passive:!0}),h(),{update:h,destroy(){i||(i=!0,a!==null&&n?.cancelAnimationFrame(a),x?.removeEventListener("resize",b),x?.removeEventListener("scroll",b),n?.removeEventListener("resize",b),n?.removeEventListener("scroll",b,{capture:!0}))}}}function Oc(t){for(let e of Array.from(t.children))if(e.classList.contains("aia-stack"))return e;return null}function Mc(t,e){if(!e)return null;let n=e.visualViewport,i=n?n.offsetTop:0,o=n?n.height:e.innerHeight;if(!o)return null;let r=t.offsetParent,a=r?r.getBoundingClientRect().top:0,s=r?a+t.offsetTop:t.getBoundingClientRect().top;return t.closest("[data-options-position]")?.getAttribute("data-options-position")==="above"?(r?s+t.offsetHeight:t.getBoundingClientRect().bottom)-i-Wa:i+o-s-Wa}var kc=[159,119,164];function li(t){let e=document.createElement("div");return e.id=t,e.setAttribute("role","listbox"),e.setAttribute("data-aia-dropdown",""),e.className="magicx-aia-dropdown",e.addEventListener("mousedown",n=>n.preventDefault()),Hn(e),e}var ai=new WeakMap;function Rc(t,e,n){let i=ai.get(t);if(i||(i={button:na(t.ownerDocument,n),grid:null,controller:null},t.appendChild(i.button),ai.set(t,i)),i.button.getAttribute("aria-label")!==n.scrollArrow&&i.button.setAttribute("aria-label",n.scrollArrow),i.grid!==e&&(i.controller?.destroy(),i.controller=null,i.grid=e,e)){i.controller=$n({dropdown:t,grid:e,button:i.button});return}i.controller?.update()}var si=new WeakMap;function Ba(t){let e=si.get(t);if(e){e.update();return}si.set(t,ri({dropdown:t,isOpen:()=>t.classList.contains("magicx-aia-dropdown--visible")}))}function vo(t){si.get(t)?.destroy(),si.delete(t),jn(t);let e=ai.get(t);e&&(e.controller?.destroy(),ai.delete(t))}function ci(t,e){let n=e.strings??M(),{filteredOptions:i,activeIndex:o,isOpen:r,isLoading:a,showPills:s,isActivePillSelected:l,onSelect:d,onHighlight:c,onPillClick:u,onSkip:p}=e,f=Dt(e.pills,n.keepTyping),g=Ht(f),h=s&&f.length>0,b=i.length>0,x=e.products.length>0,m=e.formatType==="time"&&e.timeView!=null,S=e.formatType==="location"&&e.locationView!=null,P=r&&(b||h||a||x||m||S);if(P?t.classList.add("magicx-aia-dropdown--visible"):t.classList.remove("magicx-aia-dropdown--visible"),a?t.setAttribute("data-aia-loading",""):t.removeAttribute("data-aia-loading"),!P){So(t,!1),pa(t),Ba(t),ft(t,null,{visible:!1});return}x?t.setAttribute("data-aia-has-products",""):t.removeAttribute("data-aia-has-products"),pt(t),t.toggleAttribute("data-aia-skeleton-exiting",!!e.skeletonExiting);let T=t.querySelector(".aia-stack");T||(T=document.createElement("div"),T.className="aia-stack",T.style.setProperty("--aia-stack-space","8px"),t.appendChild(T));let E=e.showSkipButton&&g&&!e.isInputEmpty,w=h||a&&s||E,y=T.querySelector(".magicx-aia-pill-bar");if(w){y||(y=document.createElement("div"),y.className="magicx-aia-pill-bar aia-cluster",y.setAttribute("data-nowrap",""),y.setAttribute("data-aia-pillbar",""),T.insertBefore(y,T.firstChild));let j=h||a&&s,v=y.querySelector(".magicx-aia-pill-scroll");j?(v||(v=document.createElement("span"),v.className="magicx-aia-pill-scroll",v.setAttribute("data-aia-pill-scroll",""),y.insertBefore(v,y.firstChild)),Qn(v,f,0,u,!0,a,l)):v&&v.remove(),Nc(y,E,a||e.skipDisabled,f[0],p,n)}else y&&y.remove();let C=e.suggestions[0],_=C?`${C.parameter} ${C.text}`:"",O=k(e.formatType),ee=O&&!a;Ra(T,O?[]:i,o,d,c,e.listboxId,a,_,e.optionsPosition??"below",e.showOptionIcons??!0,e.showOptionImages??!0,e.showOptionCounts??!0,!e.skipDisabled,a?void 0:e.multiSelectView?.picked),t.setAttribute("aria-multiselectable",String(!!e.multiSelectView)),Vc(T,!!e.multiSelectView&&!a,e.skipDisabled,e.onMultiSelectCommit,n.done),Rc(t,T.querySelector(".aia-grid"),n),ca(T,ee?i:[],o,e.listboxId,ee?e.dateView:null,{selectedIso:e.selectedDateIso,selectedRange:e.selectedDateRange,rangeStart:e.dateRangeStart,floor:_n(e.formatType,e.dateRangeStart)},{onSelect:d,onHighlight:c,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth},!e.skipDisabled),Ha(T,e.formatType==="time"&&!a?e.timeView:null,n,{onTimeChange:e.onTimeChange,onTimeCommit:e.onTimeCommit},!e.skipDisabled),ga(T,e.formatType==="location"&&!a?e.locationView:null,n,{onLocationQuery:e.onLocationQuery,onLocationMove:e.onLocationMove,onLocationCommit:e.onLocationCommit,onLocationFocusChange:e.onLocationFocusChange},{interactive:!e.skipDisabled,inputFocused:e.isFocused??!1,reediting:e.isReediting??!1});let A=T.querySelector(".magicx-aia-skeleton-bars");if(a&&(!b||D(e.formatType))){if(!A){A=document.createElement("div"),A.className="magicx-aia-skeleton-bars",A.setAttribute("data-aia-skeleton-bars","");for(let j of kc){let v=document.createElement("span");v.className="magicx-aia-skeleton-bar",v.style.width=`${j}px`,A.appendChild(v)}T.appendChild(A)}}else A&&A.remove();Pa(T,e.products,e.listboxId,e.onProductSelect,e.onProductFocusChange,e.productsLayout??"row",e.productImageFallback??"image",n,e.onProductAddToCart),So(t,!0),Bc(T,e.onSeeAllResults,n.seeAllResults);let V=T.querySelector(".magicx-aia-footer")??Fc(n),fe=o>=0&&!!i[o]?.is_tappable;Hc(V,Nn(fe,e.isInputEmpty,n)),V.isConnected||T.appendChild(V),_c(T,[".magicx-aia-pill-bar",".aia-grid","[data-aia-multi-actions]",".magicx-aia-datepicker",".magicx-aia-time-wheel","[data-aia-location]",".magicx-aia-skeleton-bars",".magicx-aia-products","[data-aia-see-all]",".magicx-aia-footer"]),Wn(T,T.querySelector(".magicx-aia-multi-done")),Zi(t,T,{eligible:b&&!x&&!O&&!m&&!S,loading:a}),Ba(t),ft(t,qn(s?f:[]),{visible:!0,anchorBottom:e.optionsPosition==="above"})}function _c(t,e){let n=e.map(i=>t.querySelector(`:scope > ${i}`)).filter(i=>i!==null);for(let i=0;i<n.length;i++)t.children[i]!==n[i]&&t.insertBefore(n[i],t.children[i]??null)}var Dc={itemSelector:".magicx-aia-skip",onClick:(t,e)=>{e.loading||e.onSkip()}};function Nc(t,e,n,i,o,r){B(t,Dc,{onSkip:o,loading:n});let a=t.querySelector(".magicx-aia-skip");if(!e){a?.remove();return}a||(a=document.createElement("button"),a.type="button",a.tabIndex=-1,a.className="magicx-aia-skip",a.setAttribute("data-aia-skip",""),a.textContent=r.skip,a.disabled=!0,t.appendChild(a),K(a)),a.textContent!==r.skip&&(a.textContent=r.skip),a.setAttribute("aria-label",i?`${r.skipLabel} ${i.text}`:r.skipLabel),a.disabled=n}function Hc(t,{key:e,hint:n}){let i=t.querySelector(".magicx-aia-footer-key"),o=t.querySelector(".magicx-aia-footer-hint");!i||!o||(i.textContent!==e&&(i.textContent=e),o.textContent!==n&&(o.textContent=n))}function Fc(t){let e=document.createElement("footer");e.className="magicx-aia-footer",e.setAttribute("data-aia-footer","");let n=document.createElement("div");n.className="aia-cluster magicx-aia-footer-row",n.setAttribute("data-align","center"),n.setAttribute("data-justify","between"),n.setAttribute("data-nowrap","");let i=document.createElement("div");i.className="aia-cluster magicx-aia-footer-hint-group",i.setAttribute("data-align","center"),i.style.setProperty("--aia-cluster-gap","5px");let o=document.createElement("kbd");o.className="magicx-aia-footer-key",o.textContent="tab";let r=document.createElement("span");r.className="magicx-aia-footer-hint",r.textContent=t.select,i.append(o,r);let a=document.createElement("a");a.className="aia-cluster magicx-aia-footer-brand-link",a.setAttribute("data-align","center"),a.href=Dn(),a.target="_blank",a.rel="noopener noreferrer",a.style.setProperty("--aia-cluster-gap","2px");let s=document.createElement("span");s.className="magicx-aia-footer-brand",s.textContent="AI";let l=document.createElement("span");return l.className="magicx-aia-footer-badge",l.textContent="Autocomplete",a.append(s,l),n.append(i,a),e.append(n),e}var Wc={itemSelector:".magicx-aia-see-all",onClick:(t,e,n)=>{e.submit&&(n.stopPropagation(),e.submit())}};function Bc(t,e,n){let i=t.querySelector(":scope > [data-aia-see-all]");if(!e){i?.remove();return}if(!i){i=document.createElement("div"),i.className="magicx-aia-see-all-row",i.dataset.aiaSeeAll="";let r=document.createElement("button");r.type="button",r.tabIndex=-1,r.className="magicx-aia-see-all",r.disabled=!0,i.appendChild(r),t.appendChild(i),K(r)}B(i,Wc,{submit:e});let o=i.querySelector("button");o&&(o.textContent!==n&&(o.textContent=n),o.disabled=!1)}var Uc={itemSelector:".magicx-aia-multi-done",onClick:(t,e)=>{e.disabled||e.commit?.()}};function Vc(t,e,n,i,o){let r=t.querySelector("[data-aia-multi-actions]");if(!e){r?.remove();return}if(!r){r=document.createElement("div"),r.dataset.aiaMultiActions="";let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="magicx-aia-multi-done",s.setAttribute("data-aia-multi-done",""),s.disabled=!0,r.appendChild(s),t.appendChild(r),K(s)}B(r,Uc,{commit:i,disabled:n});let a=r.querySelector("button");a&&(a.textContent=o,a.disabled=n)}function Ua(t,e){let n=li(e.listboxId);return t.appendChild(n),{dropdown:n}}function Eo(t,e,n){let i=Ue(e);ci(t.dropdown,{strings:n.strings,suggestions:e.editingIdentified?[{parameter:e.editingIdentified.parameter,text:X(e.editingIdentified.parameter),required:!0,options:e.filteredOptions}]:e.dropdownSuggestion??e.actionableSuggestions[0]?[{...e.dropdownSuggestion??e.actionableSuggestions[0],options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:e.actionableSuggestions,showPills:!0,showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:i.selectedIso,selectedDateRange:i.selectedRange,dateRangeStart:i.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:n.selectOption,onHighlight:(o,r)=>{r!==void 0&&n.store.get().activeDropdownIndex!==r||n.store.set({activeDropdownIndex:o})},onPillClick:n.setActivePill,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:o=>n.store.set({isFocused:o})})}var Va=340;function di(t){let e=t.ownerDocument.defaultView;if(!e||typeof e.MutationObserver!="function")return()=>{};let n=()=>{if(!t.isConnected)return;let c=t.style.height?t.getBoundingClientRect().height:0;t.style.height="";let u=t.getBoundingClientRect().height;if(u!==0){if(c===0||Math.abs(u-c)<.5){t.style.height=`${u}px`;return}t.style.height=`${c}px`,t.getBoundingClientRect(),t.style.height=`${u}px`}},i=-1,o=typeof e.ResizeObserver=="function"?new e.ResizeObserver(c=>{for(let p of c)if(p.target!==t){n();return}let u=t.getBoundingClientRect().width;Math.abs(u-i)<.5||(i=u,n())}):null,r=()=>{for(let c of Array.from(t.children))o?.observe(c)},a=0,s=()=>{r(),n(),e.clearTimeout(a),a=e.setTimeout(n,340)},l=new e.MutationObserver(s);l.observe(t,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["data-placeholder","data-aia-empty"]}),o?.observe(t),r(),t.addEventListener("load",s,!0);let d=!1;return t.ownerDocument.fonts?.ready.then(()=>{d||n()}),n(),()=>{d=!0,t.removeEventListener("load",s,!0),l.disconnect(),o?.disconnect(),e.clearTimeout(a),t.style.height=""}}var Gc=6,$c=.3;function Ga(t){return t<=0?"0px":`${(-Math.min($c,2*Gc/t)).toFixed(3)}px`}var $a=new Map;function qc(t,e,n){let i=$a.get(e);if(i!==void 0){t.style.setProperty("--aia-chip-image-fit",i),t.setAttribute("data-aia-image-loaded","");return}let o=n.createElement("img");o.setAttribute("referrerpolicy","no-referrer"),o.onload=()=>{if(!t.isConnected)return;t.setAttribute("data-aia-image-loaded","");let r=t.getBoundingClientRect().height,a=Number.parseFloat(getComputedStyle(t).fontSize);if(!(r>0&&a>0&&o.naturalWidth>0&&o.naturalHeight>0))return;let s=`${(r/a*(o.naturalWidth/o.naturalHeight)).toFixed(3)}em`;$a.set(e,s),t.style.setProperty("--aia-chip-image-fit",s)},o.src=e}function ui(t){let{input:e,segments:n,newParamId:i,editingParamId:o,placeholderText:r}=t,a=t.showChipIcons??!0,s=t.showChipImages??!0,l=n.length===0;e.dataset.aiaEmpty=l?"true":"false",Wr(e,l?r:"");let d=n.map(m=>m.type==="completed"?`${m.type}:${m.value}${a?m.param.icon??m.param.icon_svg??"":""}${s?ge(m.param.image_url)??"":""}`:`${m.type}:${m.value}`).join("\0"),c=e.dataset.segKey??"",u=e.dataset.newParamId??"",p=e.dataset.editingParamId??"";if(d===c&&(i??"")===u&&(o??"")===p)return;if(d===c){e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";for(let m of e.querySelectorAll("strong[data-param-id]")){let S=m.dataset.paramId,P=m.dataset.seg==="completed"&&S===i;m.classList.toggle("magicx-aia-shimmer-revealed",P),m.classList.toggle("magicx-aia-shimmer-sweep",P),m.classList.toggle("magicx-aia-segment--editing",S===o)}return}let f=hr(e),g=f?q(e):null;e.dataset.segKey=d,e.dataset.newParamId=i??"",e.dataset.editingParamId=o??"";let h=R(e),b=h.createDocumentFragment(),x=0;for(let m of n)if(x+=m.value.length,m.type==="completed"){let S=h.createElement("strong");S.dataset.seg="completed",S.dataset.paramId=m.param.id;let P=m.param.id===i,T=m.param.id===o,E=["magicx-aia-segment","magicx-aia-segment--completed"];P&&E.push("magicx-aia-shimmer-revealed","magicx-aia-shimmer-sweep"),T&&E.push("magicx-aia-segment--editing"),S.className=E.join(" "),S.style.letterSpacing=Ga(m.value.length);let w=s?ge(m.param.image_url):null;if(w){let C=h.createElement("span");C.className="magicx-aia-segment-image",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.style.setProperty("--aia-chip-image",`url("${w}")`),qc(C,w,h),S.appendChild(C),S.dataset.aiaImage=""}let y=!w&&a&&m.param.icon_svg?pe(m.param.icon_svg):null;if(y){let C=h.createElement("span");C.className="magicx-aia-segment-icon",C.setAttribute("contenteditable","false"),C.setAttribute("aria-hidden","true"),C.innerHTML=y,S.appendChild(C),m.param.icon&&(S.dataset.aiaIcon=m.param.icon)}S.appendChild(h.createTextNode(m.value)),b.appendChild(S)}else if(m.type==="identified"){let S=h.createElement("strong");S.dataset.seg="identified",S.dataset.paramId=m.param.id;let P=["magicx-aia-segment","magicx-aia-segment--completed"];m.param.id===o&&P.push("magicx-aia-segment--editing"),S.className=P.join(" "),S.style.letterSpacing=Ga(m.value.length),S.textContent=m.value,b.appendChild(S)}else b.appendChild(h.createTextNode(m.value));e.replaceChildren(b),e.dataset.aiaTextLength=String(x),g!=null?H(e,Math.max(0,Math.min(g,x))):f&&H(e,x)}var Kc='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" role="img" aria-label="Submit"><path d="M9 14V4M9 4L4 9M9 4L14 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function qa(t=M()){let e=document.createElement("button");return e.type="button",e.className="magicx-aia-submit",e.setAttribute("aria-label",t.submit),e.setAttribute("data-aia-submit",""),e.innerHTML=Kc.replace('aria-label="Submit"',`aria-label="${t.submit}"`),e}function Ka(t){let e=t.store.get();return(!!e.text||e.completedParams.length>0)&&!!t.onSubmit}function za(t){if(!t.onSubmit)return;t.endTypedWord?.();let e=t.store.get();t.onSubmit(le(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields}))&&t.afterSubmit?.()}function zc(){let t=document.createElement("div");return t.setAttribute("contenteditable","plaintext-only"),t.contentEditable==="plaintext-only"}function ja(t,e){let n=e.firstElementChild;if(!n){e.removeAttribute("data-aia-pill-wrapped");return}let i=n.getBoundingClientRect(),o=t.getBoundingClientRect();i.top>=o.bottom-2?e.setAttribute("data-aia-pill-wrapped",""):e.removeAttribute("data-aia-pill-wrapped")}function Qa(t,e){let{listboxId:n}=e,i=li(n);t.appendChild(i);let o=document.createElement("div");o.className="magicx-aia-input-wrapper",o.setAttribute("data-aia-input-wrapper",""),t.appendChild(o);let r=document.createElement("div");r.className="magicx-aia-editor",r.setAttribute("data-aia-editor",""),o.appendChild(r);let a=document.createElement("div");a.className="magicx-aia-input",a.setAttribute("data-aia-input",""),a.setAttribute("contenteditable",zc()?"plaintext-only":"true"),a.setAttribute("role","combobox"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-haspopup","listbox"),a.setAttribute("aria-controls",n),a.setAttribute("aria-expanded","false"),a.setAttribute("spellcheck","true"),a.setAttribute("enterkeyhint","send"),r.appendChild(a);let s=document.createElement("span");s.className="magicx-aia-pill-list-container",s.setAttribute("data-aia-pill-list-container",""),r.appendChild(s);let l=null,d=null;e.submitButton===void 0?(l=qa(e.strings),o.appendChild(l),d=l):e.submitButton!==null&&(d=e.submitButton,d.hasAttribute("data-aia-submit")||d.setAttribute("data-aia-submit",""),d.setAttribute("data-aia-submit-slot",""),o.appendChild(d));let c=new AbortController,{signal:u}=c,p=!1,f=0,g=()=>{let m=it(a),P=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;e.handleChange(P)},h=()=>{let m=se(a)?.node??null;if(!m||!a.contains(m))return null;let T=(m.nodeType===Node.ELEMENT_NODE?m:m.parentElement)?.closest("strong[data-param-id]")?.dataset.paramId??null;return T&&fr(a,T)?null:T};if(o.addEventListener("click",m=>{m.target?.closest("[data-aia-pill]")||a.getRootNode().activeElement?.closest("[data-aia-location]")||a.focus()},{signal:u}),a.addEventListener("input",()=>{p||(f=performance.now(),g(),e.handleCaretAfterInput(q(a)))},{signal:u}),R(a).addEventListener("selectionchange",()=>{let m=se(a);if(!m||!a.contains(m.node))return;let S=m.collapsed?h():null,P=e.store.get(),T=P.editingParam?.id??P.editingIdentified?.id??null;if(S&&S!==T){e.startEditingParam(S);return}performance.now()-f<50||e.handleCaretMove(q(a))},{signal:u}),a.addEventListener("click",m=>{let S=Zt(a,m.target);S&&(e.startEditingParam(S),en(a,S))},{signal:u}),a.addEventListener("compositionstart",()=>{p=!0,a.setAttribute("data-aia-composing","true")},{signal:u}),a.addEventListener("compositionend",()=>{p=!1,a.removeAttribute("data-aia-composing"),g()},{signal:u}),a.addEventListener("beforeinput",m=>{let S=m,P=S.inputType;if(P==="insertParagraph"||P==="insertLineBreak"||P==="insertFromDrop"){m.preventDefault();return}if(P.startsWith("insert")||P.startsWith("delete")){let T=P.startsWith("delete")?"":S.data??"";e.replaceEditingRange(T)&&m.preventDefault()}},{signal:u}),a.addEventListener("paste",m=>{m.preventDefault();let S=(m.clipboardData?.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let P=R(a),T=xe(a);if(!T||!a.contains(T.startContainer))return;T.deleteContents();let E=P.createTextNode(S);T.insertNode(E),T.setStartAfter(E),nt(a,T.startContainer,T.startOffset),g()},{signal:u}),a.addEventListener("keydown",m=>e.handleKeyDown(m),{signal:u}),a.addEventListener("focus",()=>e.store.set({isFocused:!0}),{signal:u}),a.addEventListener("blur",()=>e.store.set({isFocused:!1}),{signal:u}),d&&d.addEventListener("click",m=>{Ka(e)&&(m.stopPropagation(),za(e))},{signal:u}),e.autoFocus!==!1){a.focus();let m=se(a);(!m||!a.contains(m.node))&&nt(a,a,0)}if(typeof ResizeObserver<"u"){let m=new ResizeObserver(()=>ja(a,s));m.observe(a),c.signal.addEventListener("abort",()=>m.disconnect(),{once:!0})}let x=di(r);return c.signal.addEventListener("abort",x,{once:!0}),{input:a,inlinePillContainer:s,dropdown:i,submitButton:l,abort:c}}function Po(t,e,n){let{input:i,inlinePillContainer:o,dropdown:r,submitButton:a}=t,{pillPlacement:s,setActivePill:l,selectOption:d,store:c}=n;i.setAttribute("aria-expanded",String(e.isDropdownOpen));let u=e.activeDropdownIndex>=0?`${n.listboxId}-option-${e.activeDropdownIndex}`:"";if(u?i.setAttribute("aria-activedescendant",u):i.removeAttribute("aria-activedescendant"),a){let x=n.strings??M();a.getAttribute("aria-label")!==x.submit&&a.setAttribute("aria-label",x.submit);let m=a.querySelector("svg");m&&m.getAttribute("aria-label")!==x.submit&&m.setAttribute("aria-label",x.submit);let S=!!e.text||e.completedParams.length>0;a.disabled=!S,a.toggleAttribute("data-aia-ready",S&&e.isReady)}let p=i.dataset.newParamId??"",f=e.newParamId!==null&&e.newParamId!==p;if(ui({input:i,segments:e.segments,newParamId:e.newParamId,editingParamId:e.editingParam?.id??null,placeholderText:e.placeholderText,isFocused:e.isFocused,showChipIcons:n.showChipIcons??!0,showChipImages:n.showChipImages??!0}),s==="inline"){let x=e.isLoading&&!e.editingParam&&!e.inSelectionAnimation,m=_t(e.actionableSuggestions);x||m.length>0?Qn(o,m,0,l,!1,x,e.isActivePillSelected):mo(o)}else mo(o);ja(i,o),f?(i.focus(),H(i,e.caretOffset??e.text.length)):e.isFocused&&it(i)!==e.text&&H(i,e.text.length);let g=e.editingParam?{parameter:e.editingParam.suggestionParameter,text:e.editingParam.suggestionPlaceholder,required:!0,options:e.editingParam.options}:e.editingIdentified?{parameter:e.editingIdentified.parameter,text:X(e.editingIdentified.parameter),required:!0,options:[]}:null,h=e.dropdownSuggestion??g??e.actionableSuggestions[0],b=Ue(e);ci(r,{strings:n.strings,suggestions:h?[{...h,options:e.dropdownOptions}]:[],filteredOptions:e.dropdownOptions,activeIndex:e.activeDropdownIndex,isOpen:e.isDropdownOpen,isLoading:e.dropdownLoading,skeletonExiting:e.skeletonExiting,listboxId:n.listboxId,pills:g?[g]:e.actionableSuggestions,showPills:s==="dropdown",showSkipButton:n.showSkipButton&&!e.editingParam&&!e.editingIdentified,skipDisabled:e.inSelectionAnimation,showOptionIcons:n.showOptionIcons??!0,showOptionImages:n.showOptionImages??!0,showOptionCounts:n.showOptionCounts??!0,isActivePillSelected:e.isActivePillSelected,isInputEmpty:e.text.trim().length===0,products:e.products,productsLayout:n.productsLayout??"row",productImageFallback:n.productImageFallback??"image",onProductAddToCart:n.addProductToCart,formatType:e.activeFormatType,dateView:e.dateView,selectedDateIso:b.selectedIso,selectedDateRange:b.selectedRange,dateRangeStart:b.rangeStart,timeView:e.timeView,multiSelectView:e.multiSelectView,locationView:e.locationView,isReediting:e.editingParam!=null,isFocused:e.isFocused||e.locationFieldFocused,optionsPosition:n.optionsPosition??"below",onSelect:d,onHighlight:(x,m)=>{m!==void 0&&c.get().activeDropdownIndex!==m||c.set({activeDropdownIndex:x})},onPillClick:l,onSkip:n.skipActivePill,onPreviousMonth:n.showPreviousMonth,onNextMonth:n.showNextMonth,onTimeChange:n.setTime,onTimeCommit:n.commitTime,onMultiSelectCommit:n.commitMultiSelect,onLocationQuery:n.setLocationQuery,onLocationMove:n.moveLocationHighlight,onLocationCommit:n.commitLocation,onLocationFocusChange:n.setLocationFieldFocused,onProductSelect:n.selectProduct,onProductFocusChange:x=>c.set({isFocused:x}),onSeeAllResults:n.seeAllResults&&e.text.trim().length>0&&Ka(n)?()=>za(n):void 0})}function mi(t){let e=t,n=new Set,i=[],o=!1;return{get:()=>e,set:r=>{let a=typeof r=="function"?r(e):r,s=e;if(e={...e,...a},i.push([e,s]),!o){o=!0;try{let l=0;for(let d=i.shift();d;d=i.shift()){if(++l>1e4)throw i.length=0,new Error("createStore: notifications did not settle after 10000 deliveries \u2014 a listener is likely calling set() on every notification");let[c,u]=d;for(let p of n)p(c,u)}}catch(l){throw i.length=0,l}finally{o=!1}}},subscribe:r=>(n.add(r),()=>{n.delete(r)})}}function Ya(t,e){let n,i,o=r=>(r!==n&&(n=r,i=e(r)),i);return{get:()=>{let r=t.get();return{...r,...o(r)}},set:r=>{typeof r=="function"?t.set(a=>{let s={...a,...o(a)};return r(s)}):t.set(r)},peek:r=>{let a={...t.get(),...r};return{...a,...e(a)}},subscribe:r=>t.subscribe((a,s)=>{let l={...s,...o(s)},d={...a,...o(a)};r(d,l)})}}var wo=new WeakSet,Xa=new WeakMap;function Za(t){return t.nodeType===Node.DOCUMENT_NODE}function jc(t){return Za(t)?t:t.ownerDocument}function Qc(t){let e=Xa.get(t);if(e)return e;let n=t.defaultView?.CSSStyleSheet;if(typeof n!="function")return null;try{let i=new n;return typeof i.replaceSync!="function"?null:(i.replaceSync(ts),Xa.set(t,i),i)}catch{return null}}function Ja(t,e){if(e.querySelector("style[data-magicx-aia]"))return;let n=t.createElement("style");n.setAttribute("data-magicx-aia",""),n.textContent=ts,e.appendChild(n)}function es(t){if(typeof document>"u")return;let e=t??document;if(wo.has(e))return;let n=jc(e);if(Za(e)){let r=e.head??e.documentElement;if(!r)return;Ja(n,r),wo.add(e);return}let i=Qc(n),o=e.adoptedStyleSheets;i&&Array.isArray(o)?o.includes(i)||(e.adoptedStyleSheets=[...o,i]):Ja(n,e),wo.add(e)}var ts=`.aia-stack {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -586,7 +586,8 @@
|
|
|
586
586
|
white-space: nowrap;
|
|
587
587
|
transition:
|
|
588
588
|
color 150ms ease-out,
|
|
589
|
-
background-color 150ms ease-out
|
|
589
|
+
background-color 150ms ease-out,
|
|
590
|
+
opacity 160ms ease-out;
|
|
590
591
|
}
|
|
591
592
|
|
|
592
593
|
.magicx-aia-skip:hover {
|
|
@@ -597,46 +598,30 @@
|
|
|
597
598
|
background: var(--aia-skip-hover-bg, var(--aia-option-bg, transparent));
|
|
598
599
|
}
|
|
599
600
|
|
|
601
|
+
/* Disabled while a request is in flight (and in the press window after a
|
|
602
|
+
pick, which always starts one): it fades out with the options and back in
|
|
603
|
+
when the response lands. */
|
|
600
604
|
.magicx-aia-skip:disabled {
|
|
601
605
|
pointer-events: none;
|
|
602
606
|
cursor: default;
|
|
603
|
-
|
|
607
|
+
/* 0.01, never 0: iOS reads exactly 0 as hidden, and this button is
|
|
608
|
+
re-enabled in place, so a tap in flight would be cancelled. */
|
|
609
|
+
opacity: 0.01;
|
|
604
610
|
}
|
|
605
611
|
|
|
606
|
-
/* --- Fallback loading
|
|
612
|
+
/* --- Fallback loading space (only when no cached options, or a picker) ---
|
|
613
|
+
Holds the panel's height while the first options load; draws nothing. */
|
|
607
614
|
.magicx-aia-skeleton-bars {
|
|
608
615
|
display: flex;
|
|
609
616
|
flex-direction: column;
|
|
610
617
|
gap: 20px;
|
|
611
618
|
padding: 7px 8px;
|
|
612
|
-
|
|
619
|
+
visibility: hidden;
|
|
613
620
|
}
|
|
614
621
|
|
|
615
622
|
.magicx-aia-skeleton-bar {
|
|
616
623
|
display: block;
|
|
617
624
|
height: 14px;
|
|
618
|
-
border-radius: 999px;
|
|
619
|
-
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
|
|
620
|
-
opacity: 0.5;
|
|
621
|
-
animation: magicx-aia-skeleton-pulse 1.4s ease-in-out infinite;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
.magicx-aia-skeleton-bar:nth-child(2) {
|
|
625
|
-
animation-delay: 150ms;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
.magicx-aia-skeleton-bar:nth-child(3) {
|
|
629
|
-
animation-delay: 300ms;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
@keyframes magicx-aia-skeleton-pulse {
|
|
633
|
-
0%,
|
|
634
|
-
100% {
|
|
635
|
-
opacity: 0.5;
|
|
636
|
-
}
|
|
637
|
-
50% {
|
|
638
|
-
opacity: 0.25;
|
|
639
|
-
}
|
|
640
625
|
}
|
|
641
626
|
|
|
642
627
|
/* ===================================================================
|
|
@@ -1362,24 +1347,28 @@
|
|
|
1362
1347
|
}
|
|
1363
1348
|
}
|
|
1364
1349
|
|
|
1365
|
-
/* --- Loading
|
|
1350
|
+
/* --- Loading: the previous options fade out ---
|
|
1351
|
+
While a request is in flight the core keeps the previous options on screen
|
|
1352
|
+
(data-aia-loading) and they fade to nothing over 160ms, the motion spec's
|
|
1353
|
+
leave, with no grey skeleton. They keep their layout, so the panel holds
|
|
1354
|
+
its size until the response's options play their entrance. The content's
|
|
1355
|
+
own entrance stays off, so a rebuilt row never fades back in. */
|
|
1366
1356
|
.magicx-aia-option[data-aia-loading] {
|
|
1367
1357
|
cursor: default;
|
|
1368
|
-
|
|
1358
|
+
pointer-events: none;
|
|
1359
|
+
animation: magicx-aia-loading-out 160ms ease-in forwards;
|
|
1369
1360
|
}
|
|
1370
1361
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
box-decoration-break: clone;
|
|
1382
|
-
animation: magicx-aia-skeleton-bar-in 100ms ease-out;
|
|
1362
|
+
.magicx-aia-option[data-aia-loading] .magicx-aia-option-content {
|
|
1363
|
+
animation: none;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/* Ends a hair above zero, like magicx-aia-fadeIn starts: a pill kept by key
|
|
1367
|
+
is re-enabled in place, and iOS cancels a tap on an element leaving 0. */
|
|
1368
|
+
@keyframes magicx-aia-loading-out {
|
|
1369
|
+
to {
|
|
1370
|
+
opacity: 0.01;
|
|
1371
|
+
}
|
|
1383
1372
|
}
|
|
1384
1373
|
|
|
1385
1374
|
.magicx-aia-option-tag {
|
|
@@ -1388,13 +1377,9 @@
|
|
|
1388
1377
|
opacity: 0.5;
|
|
1389
1378
|
}
|
|
1390
1379
|
|
|
1391
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-tag {
|
|
1392
|
-
display: none;
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
1380
|
/* The parameter an option is a value of, under its text ("Flavor", "Subcategory"):
|
|
1396
1381
|
muted and smaller, so options that read alike are told apart. Block inside the
|
|
1397
|
-
text box, so a hanging indent never moves it
|
|
1382
|
+
text box, so a hanging indent never moves it. */
|
|
1398
1383
|
.magicx-aia-option-parameter {
|
|
1399
1384
|
display: block;
|
|
1400
1385
|
font-size: var(--aia-option-parameter-font-size, 8.4px);
|
|
@@ -1405,10 +1390,6 @@
|
|
|
1405
1390
|
opacity: var(--aia-option-parameter-opacity, 0.6);
|
|
1406
1391
|
}
|
|
1407
1392
|
|
|
1408
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-parameter {
|
|
1409
|
-
display: none;
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
1393
|
/* The part of a completion the typed text matches, in the Smart Suggestion accent. */
|
|
1413
1394
|
.magicx-aia-option-match {
|
|
1414
1395
|
color: var(--aia-smart-suggestion-accent, #b84549);
|
|
@@ -1440,14 +1421,6 @@
|
|
|
1440
1421
|
height: 1em;
|
|
1441
1422
|
}
|
|
1442
1423
|
|
|
1443
|
-
/* Skeleton rows keep the icon's column (hidden, not removed) and the
|
|
1444
|
-
hanging indent below, so a row that flips into loading and back \u2014 the
|
|
1445
|
-
same element in React, a rebuilt one in vanilla \u2014 draws its bar and its
|
|
1446
|
-
text at the same x and nothing slides sideways. */
|
|
1447
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-icon {
|
|
1448
|
-
visibility: hidden;
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
1424
|
/* With an icon, the content box hangs its continuation lines: a left pad the
|
|
1452
1425
|
width of the icon plus its gap, and a matching negative first-line indent
|
|
1453
1426
|
that pulls the icon back into that pad. Wrapped lines then start under the
|
|
@@ -1481,15 +1454,6 @@
|
|
|
1481
1454
|
min-width: 0;
|
|
1482
1455
|
}
|
|
1483
1456
|
|
|
1484
|
-
/* A skeleton bar hugs its text. The rules above let the text grow to fill a
|
|
1485
|
-
picture / count row (so the count sits at the trailing edge); a loading row
|
|
1486
|
-
hides the count, and a growing text box would paint the bar across the
|
|
1487
|
-
whole column. One compound deeper than those rules, so it wins in every
|
|
1488
|
-
copy regardless of source order. */
|
|
1489
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-content .magicx-aia-option-text {
|
|
1490
|
-
flex: 0 1 auto;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
1457
|
/* The picture: a square tile, centred on the text beside it (a one-line
|
|
1494
1458
|
option reads as the reference row; a wrapped one keeps the tile on its
|
|
1495
1459
|
vertical middle). Sized and rounded by token so a consumer can shrink it
|
|
@@ -1725,27 +1689,12 @@
|
|
|
1725
1689
|
content: var(--aia-option-count-unit-one, var(--aia-option-count-unit, "\u4EF6"));
|
|
1726
1690
|
}
|
|
1727
1691
|
|
|
1728
|
-
/* Skeleton rows fill the tile even when the picture has loaded (the fill
|
|
1729
|
-
pulses with the row) and hide the picture, and drop the count like the
|
|
1730
|
-
tag. */
|
|
1731
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-image {
|
|
1732
|
-
background: var(--aia-option-image-bg, var(--aia-skeleton-bg, rgba(189, 189, 189, 0.083)));
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-image img {
|
|
1736
|
-
visibility: hidden;
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
.magicx-aia-option[data-aia-loading] .magicx-aia-option-count {
|
|
1740
|
-
display: none;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
1692
|
/* A grid of rows with a parameter line is taller per row: the row's text
|
|
1744
1693
|
line and padding plus the parameter line, so the visible-rows cap
|
|
1745
1694
|
(\`--aia-grid-max-height\`) does not cut the last row. Before the picture rule,
|
|
1746
1695
|
which wins when a group has both. */
|
|
1747
1696
|
[data-aia-group]:has(.magicx-aia-option-parameter) {
|
|
1748
|
-
--aia-option-row-height:
|
|
1697
|
+
--aia-option-row-height: calc(25.9px + 2 * var(--aia-option-padding-block, 5.6px));
|
|
1749
1698
|
}
|
|
1750
1699
|
|
|
1751
1700
|
/* A grid of picture rows is taller per row: the visible-rows cap
|
|
@@ -1753,7 +1702,11 @@
|
|
|
1753
1702
|
planOptionsGrid) follows the tile's height plus the row's padding, so the
|
|
1754
1703
|
same number of rows shows before the list scrolls. */
|
|
1755
1704
|
[data-aia-group]:has(.magicx-aia-option-image) {
|
|
1756
|
-
--aia-option-row-height: calc(
|
|
1705
|
+
--aia-option-row-height: calc(
|
|
1706
|
+
var(--aia-option-image-size, 28px) +
|
|
1707
|
+
2 *
|
|
1708
|
+
var(--aia-option-padding-block, 5.6px)
|
|
1709
|
+
);
|
|
1757
1710
|
}
|
|
1758
1711
|
|
|
1759
1712
|
/* A row without a picture, in a grid where other rows have one, lines up
|
|
@@ -1762,8 +1715,7 @@
|
|
|
1762
1715
|
does. A row with neither a picture nor an icon is not indented to match:
|
|
1763
1716
|
its text sits flush left, as it would in a grid with no pictures. Grids
|
|
1764
1717
|
with no pictures keep the inline icon and hanging indent above. The text
|
|
1765
|
-
is left to size itself
|
|
1766
|
-
loading-bar rule that makes a skeleton bar hug its text. */
|
|
1718
|
+
is left to size itself. */
|
|
1767
1719
|
[data-aia-group]:has(.magicx-aia-option-image)
|
|
1768
1720
|
.magicx-aia-option-content:not(:has(.magicx-aia-option-image)) {
|
|
1769
1721
|
display: flex;
|
|
@@ -1799,16 +1751,6 @@
|
|
|
1799
1751
|
height: var(--aia-option-tile-icon-size, 1.5em);
|
|
1800
1752
|
}
|
|
1801
1753
|
|
|
1802
|
-
@keyframes magicx-aia-option-skeleton-pulse {
|
|
1803
|
-
0%,
|
|
1804
|
-
100% {
|
|
1805
|
-
filter: brightness(1);
|
|
1806
|
-
}
|
|
1807
|
-
50% {
|
|
1808
|
-
filter: brightness(0.55);
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
1754
|
/* --- Pill list --- */
|
|
1813
1755
|
.magicx-aia-pill-list {
|
|
1814
1756
|
position: relative;
|
|
@@ -1903,11 +1845,6 @@
|
|
|
1903
1845
|
animation-name: magicx-aia-smart-suggestion-sparkle-small;
|
|
1904
1846
|
}
|
|
1905
1847
|
|
|
1906
|
-
.magicx-aia-pill[data-aia-loading] .magicx-aia-smart-suggestion-text,
|
|
1907
|
-
.magicx-aia-pill[data-aia-loading] .magicx-aia-smart-suggestion-sparkle {
|
|
1908
|
-
visibility: hidden;
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
1848
|
@keyframes magicx-aia-smart-suggestion-shimmer {
|
|
1912
1849
|
0% {
|
|
1913
1850
|
background-position: 100% 0;
|
|
@@ -1961,31 +1898,28 @@
|
|
|
1961
1898
|
}
|
|
1962
1899
|
}
|
|
1963
1900
|
|
|
1964
|
-
/*
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
(inside the dashed border) and pulse it so it still reads as a loading chip. */
|
|
1901
|
+
/* A real pill mirrored from the previous state while loading: it fades out
|
|
1902
|
+
with the options (see .magicx-aia-option[data-aia-loading]), keeping its
|
|
1903
|
+
box so the bar holds its size. */
|
|
1968
1904
|
.magicx-aia-pill[data-aia-loading] {
|
|
1969
1905
|
pointer-events: none;
|
|
1970
1906
|
cursor: default;
|
|
1971
|
-
|
|
1972
|
-
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
|
|
1973
|
-
animation:
|
|
1974
|
-
magicx-aia-skeleton-in 100ms ease-out,
|
|
1975
|
-
magicx-aia-pill-skeleton-pulse 1.4s ease-in-out infinite;
|
|
1907
|
+
animation: magicx-aia-loading-out 160ms ease-in forwards;
|
|
1976
1908
|
}
|
|
1977
1909
|
|
|
1978
|
-
/*
|
|
1910
|
+
/* Every pill while loading takes no tap. renderPills puts this class on the
|
|
1911
|
+
pills kept from the last response too, so it must not hide them: they fade
|
|
1912
|
+
(above). */
|
|
1979
1913
|
.magicx-aia-pill--skeleton {
|
|
1980
1914
|
pointer-events: none;
|
|
1981
1915
|
cursor: default;
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/* Fallback placeholder pills (no previous pills yet): hold the bar's height,
|
|
1919
|
+
draw nothing. */
|
|
1920
|
+
.magicx-aia-pill--skeleton[data-aia-pill-skeleton] {
|
|
1921
|
+
visibility: hidden;
|
|
1922
|
+
animation: none;
|
|
1989
1923
|
}
|
|
1990
1924
|
|
|
1991
1925
|
.magicx-aia-pill--skeleton:hover,
|
|
@@ -1993,16 +1927,6 @@
|
|
|
1993
1927
|
filter: none;
|
|
1994
1928
|
}
|
|
1995
1929
|
|
|
1996
|
-
@keyframes magicx-aia-pill-skeleton-pulse {
|
|
1997
|
-
0%,
|
|
1998
|
-
100% {
|
|
1999
|
-
filter: brightness(1);
|
|
2000
|
-
}
|
|
2001
|
-
50% {
|
|
2002
|
-
filter: brightness(0.55);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
1930
|
/* Starts a hair above zero on purpose. iOS reads an element at exactly
|
|
2007
1931
|
\`opacity: 0\` as hidden, and a clickable element (a pill is a native button,
|
|
2008
1932
|
a chip sits in the editable) going from hidden to visible while a finger is
|
|
@@ -2047,7 +1971,7 @@
|
|
|
2047
1971
|
/* 5.6px radius on the highlighted fill (--aia-option-bg), matching the Figma
|
|
2048
1972
|
SuggestionItem selection at 70%. The 5.6px/10px inset is the item's own padding. */
|
|
2049
1973
|
border-radius: 5.6px;
|
|
2050
|
-
padding: 5.6px 10px;
|
|
1974
|
+
padding: var(--aia-option-padding-block, 5.6px) 10px;
|
|
2051
1975
|
/* No entrance animation on the row itself \u2014 deliberately. The row is the
|
|
2052
1976
|
tappable element, and iOS Safari drops a tap on a scripted-clickable
|
|
2053
1977
|
element (a div with a click handler; a native button is exempt) whose
|
|
@@ -2723,48 +2647,12 @@
|
|
|
2723
2647
|
width: 60%;
|
|
2724
2648
|
}
|
|
2725
2649
|
|
|
2726
|
-
/* --- Loading
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
to nothing before the response's options replace them. Keep 100ms in step
|
|
2733
|
-
with SKELETON_FADE_MS in AIAutocomplete.ts. */
|
|
2734
|
-
/* During the fade-out the skeleton rows play nothing but the fade: no
|
|
2735
|
-
entrance, no text crossfade. Rows keep their identity through it (the core's
|
|
2736
|
-
dropdownSuggestion), but if one were ever remounted here, replaying either
|
|
2737
|
-
animation would bring the previous option's text back on screen. */
|
|
2738
|
-
[data-aia-skeleton-exiting] .magicx-aia-option[data-aia-loading] .magicx-aia-option-content,
|
|
2739
|
-
[data-aia-skeleton-exiting] .magicx-aia-option[data-aia-loading] .magicx-aia-option-text {
|
|
2740
|
-
animation: none;
|
|
2741
|
-
}
|
|
2742
|
-
|
|
2743
|
-
[data-aia-skeleton-exiting] .magicx-aia-option[data-aia-loading],
|
|
2744
|
-
[data-aia-skeleton-exiting] .magicx-aia-pill[data-aia-loading],
|
|
2745
|
-
[data-aia-skeleton-exiting] .magicx-aia-pill--skeleton,
|
|
2746
|
-
[data-aia-skeleton-exiting] .magicx-aia-skeleton-bars {
|
|
2747
|
-
animation: magicx-aia-skeleton-out 100ms ease-in forwards;
|
|
2748
|
-
}
|
|
2749
|
-
|
|
2750
|
-
@keyframes magicx-aia-skeleton-in {
|
|
2751
|
-
from {
|
|
2752
|
-
opacity: 0;
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
|
|
2756
|
-
@keyframes magicx-aia-skeleton-bar-in {
|
|
2757
|
-
from {
|
|
2758
|
-
background-color: transparent;
|
|
2759
|
-
color: inherit;
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
|
|
2763
|
-
@keyframes magicx-aia-skeleton-out {
|
|
2764
|
-
to {
|
|
2765
|
-
opacity: 0;
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2650
|
+
/* --- Loading fades ---
|
|
2651
|
+
The previous options and pills fade out from the moment loading starts
|
|
2652
|
+
(magicx-aia-loading-out above) and stay out through the core's hold for
|
|
2653
|
+
the rest of it (SKELETON_FADE_MS, data-aia-skeleton-exiting), so nothing
|
|
2654
|
+
extra plays there: a second animation would restart the fade from full
|
|
2655
|
+
strength. */
|
|
2768
2656
|
|
|
2769
2657
|
.magicx-aia-option-content:has(.magicx-aia-checkbox) {
|
|
2770
2658
|
display: flex;
|
|
@@ -3294,8 +3182,11 @@
|
|
|
3294
3182
|
--aia-completed-pill-color: var(--aia-primitive-neutral-0);
|
|
3295
3183
|
|
|
3296
3184
|
--aia-option-bg: var(--aia-primitive-blue-50);
|
|
3297
|
-
/*
|
|
3298
|
-
--aia-option-color: var(--aia-primitive-neutral-
|
|
3185
|
+
/* Option text: a softer grey than the parameter label above it. */
|
|
3186
|
+
--aia-option-color: var(--aia-primitive-neutral-500);
|
|
3187
|
+
/* The floating box's thin options scrollbar: track and thumb. */
|
|
3188
|
+
--aia-scrollbar-track: rgba(15, 23, 42, 0.05);
|
|
3189
|
+
--aia-scrollbar-thumb: rgba(15, 23, 42, 0.22);
|
|
3299
3190
|
--aia-option-color-selected: var(--aia-primitive-neutral-0);
|
|
3300
3191
|
--aia-option-font-size: 11.2px;
|
|
3301
3192
|
|
|
@@ -3367,8 +3258,10 @@
|
|
|
3367
3258
|
--aia-completed-pill-color: var(--aia-primitive-neutral-1000);
|
|
3368
3259
|
|
|
3369
3260
|
--aia-option-bg: var(--aia-primitive-neutral-250);
|
|
3370
|
-
/*
|
|
3371
|
-
--aia-option-color: var(--aia-primitive-neutral-
|
|
3261
|
+
/* Option text: a softer grey than the parameter label above it. */
|
|
3262
|
+
--aia-option-color: var(--aia-primitive-neutral-750);
|
|
3263
|
+
--aia-scrollbar-track: rgba(255, 255, 255, 0.08);
|
|
3264
|
+
--aia-scrollbar-thumb: rgba(255, 255, 255, 0.28);
|
|
3372
3265
|
--aia-option-color-selected: var(--aia-primitive-neutral-1000);
|
|
3373
3266
|
--aia-option-font-size: 11.2px;
|
|
3374
3267
|
|
|
@@ -3676,8 +3569,8 @@
|
|
|
3676
3569
|
}
|
|
3677
3570
|
|
|
3678
3571
|
/* Floating options box (2026-11). The panel reads as a light sheet under the
|
|
3679
|
-
text: no footer, only the parameter being asked (sentence case),
|
|
3680
|
-
|
|
3572
|
+
text: no footer, only the parameter being asked (sentence case), "skip" at
|
|
3573
|
+
the header row's trailing edge, and roomier rows. With no footer there is
|
|
3681
3574
|
no band for the rows to slide under, so it is zeroed in every layout.
|
|
3682
3575
|
Declared last so it follows every rule that sets the band. Mirrored in all
|
|
3683
3576
|
four appearance copies; floatingOptionsParity.test.ts pins them together. */
|
|
@@ -3714,7 +3607,7 @@
|
|
|
3714
3607
|
[data-aia-dropdown] [data-aia-pillbar] [data-aia-pill][data-aia-pill-active] {
|
|
3715
3608
|
text-transform: none;
|
|
3716
3609
|
letter-spacing: normal;
|
|
3717
|
-
font-size: var(--aia-param-label-font-size,
|
|
3610
|
+
font-size: var(--aia-param-label-font-size, 12px);
|
|
3718
3611
|
font-weight: 500;
|
|
3719
3612
|
opacity: 1;
|
|
3720
3613
|
}
|
|
@@ -3736,21 +3629,83 @@
|
|
|
3736
3629
|
padding-inline: 5.6px;
|
|
3737
3630
|
font-size: var(--aia-skip-font-size, 9.45px);
|
|
3738
3631
|
}
|
|
3739
|
-
/*
|
|
3740
|
-
row
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3632
|
+
/* Roomier rows: 10.5px above and below each option instead of 5.6px. The
|
|
3633
|
+
row height feeds the visible-rows cap (planOptionsGrid), so it moves with
|
|
3634
|
+
the padding; picture and parameter-line rows add the same padding to their
|
|
3635
|
+
own heights. Tokens on the themed root at zero specificity, like the rest,
|
|
3636
|
+
so a consumer's value wins and the classic block below can restore its own. */
|
|
3637
|
+
:where(.magicx-aia) {
|
|
3638
|
+
--aia-option-padding-block: 10.5px;
|
|
3639
|
+
--aia-option-row-height: calc(14.7px + 2 * var(--aia-option-padding-block));
|
|
3640
|
+
}
|
|
3641
|
+
/* The panel hugs its options (panelHugWidth): as wide as the widest option
|
|
3642
|
+
times the columns, plus the panel's padding and 36px of breathing room,
|
|
3643
|
+
never under the header row (the whole label and "skip") or the minimum,
|
|
3644
|
+
nor over the full width. Desktop only: on a phone the panel keeps the
|
|
3645
|
+
full width. The width is set only on a panel of plain options; pickers and
|
|
3646
|
+
product strips stay full width. The rules below skip optionsStyle:
|
|
3647
|
+
"classic", which keeps the full-width panel, the fitted Done and the
|
|
3648
|
+
chevron. */
|
|
3649
|
+
@media (min-width: 769px) {
|
|
3650
|
+
[data-aia-dropdown][data-aia-hug]:not(:where([data-aia-options-style="classic"] *)) {
|
|
3651
|
+
inset-inline-end: auto;
|
|
3652
|
+
width: clamp(
|
|
3653
|
+
min(var(--aia-panel-min-width, 160px), 100%),
|
|
3654
|
+
var(--aia-panel-fit-width, 100%),
|
|
3655
|
+
100%
|
|
3656
|
+
);
|
|
3657
|
+
}
|
|
3744
3658
|
}
|
|
3745
|
-
|
|
3659
|
+
/* Done spans the panel, whatever the panel's width. */
|
|
3660
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *)) [data-aia-multi-done] {
|
|
3661
|
+
width: var(--aia-multi-done-width, 100%);
|
|
3662
|
+
}
|
|
3663
|
+
/* A long list shows a thin scrollbar on its right edge instead of the
|
|
3664
|
+
"more below" chevron: the same button (scrollArrow.ts), drawn as a 3px
|
|
3665
|
+
rounded thumb on a faint track, placed and sized by the inline
|
|
3666
|
+
--aia-scroll-track-* / --aia-scroll-thumb-* vars. Shown whenever the list
|
|
3667
|
+
overflows (data-aia-scrollable), at the top, mid-scroll and at the end;
|
|
3668
|
+
it takes no clicks, the list scrolls by wheel, touch and keyboard. */
|
|
3669
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *)) [data-aia-scroll-arrow] {
|
|
3670
|
+
top: var(--aia-scroll-track-top, 0px);
|
|
3671
|
+
right: var(--aia-scroll-track-right, 0px);
|
|
3672
|
+
bottom: auto;
|
|
3673
|
+
left: auto;
|
|
3674
|
+
width: 3px;
|
|
3675
|
+
height: var(--aia-scroll-track-height, 0px);
|
|
3676
|
+
margin: 0 2px 0 0;
|
|
3677
|
+
border-radius: 3px;
|
|
3678
|
+
background: var(--aia-scrollbar-track, rgba(15, 23, 42, 0.05));
|
|
3679
|
+
pointer-events: none;
|
|
3680
|
+
animation: none;
|
|
3681
|
+
transition: opacity 200ms ease-out;
|
|
3682
|
+
}
|
|
3683
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *)) [data-aia-scroll-arrow] svg {
|
|
3684
|
+
display: none;
|
|
3685
|
+
}
|
|
3686
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *))
|
|
3687
|
+
[data-aia-scroll-arrow]::after {
|
|
3746
3688
|
content: "";
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3689
|
+
position: absolute;
|
|
3690
|
+
top: var(--aia-scroll-thumb-top, 0px);
|
|
3691
|
+
left: 0;
|
|
3692
|
+
width: 100%;
|
|
3693
|
+
height: var(--aia-scroll-thumb-height, 0px);
|
|
3694
|
+
border-radius: 3px;
|
|
3695
|
+
background: var(--aia-scrollbar-thumb, rgba(15, 23, 42, 0.22));
|
|
3696
|
+
}
|
|
3697
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *))
|
|
3698
|
+
[data-aia-scroll-arrow][data-aia-visible] {
|
|
3699
|
+
pointer-events: none;
|
|
3700
|
+
opacity: 0;
|
|
3701
|
+
}
|
|
3702
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *))
|
|
3703
|
+
[data-aia-scroll-arrow][data-aia-scrollable] {
|
|
3704
|
+
opacity: 1;
|
|
3705
|
+
}
|
|
3706
|
+
/* Room between the last row and Done, so the last line reads clear of it. */
|
|
3707
|
+
[data-aia-dropdown]:not(:where([data-aia-options-style="classic"] *)) [data-aia-multi-actions] {
|
|
3708
|
+
padding-top: 14px;
|
|
3754
3709
|
}
|
|
3755
3710
|
/* End floating options box. */
|
|
3756
3711
|
|
|
@@ -3769,6 +3724,10 @@
|
|
|
3769
3724
|
:where([data-aia-options-style="classic"] .magicx-aia[data-mode="light"]) {
|
|
3770
3725
|
--aia-dropdown-border: var(--aia-primitive-neutral-900-a50);
|
|
3771
3726
|
--aia-option-font-size: 16px;
|
|
3727
|
+
/* Full-size rows with classic's own 8px padding. The first two selectors
|
|
3728
|
+
match in dark mode too, so the rows hold in both. */
|
|
3729
|
+
--aia-option-padding-block: 8px;
|
|
3730
|
+
--aia-option-row-height: 37px;
|
|
3772
3731
|
}
|
|
3773
3732
|
:where(.magicx-aia[data-aia-options-style="classic"][data-mode="dark"]),
|
|
3774
3733
|
:where([data-aia-options-style="classic"] .magicx-aia[data-mode="dark"]) {
|
|
@@ -3803,19 +3762,5 @@
|
|
|
3803
3762
|
padding-inline: 8px;
|
|
3804
3763
|
font-size: var(--aia-skip-font-size, 13.5px);
|
|
3805
3764
|
}
|
|
3806
|
-
:where([data-aia-options-style="classic"])
|
|
3807
|
-
[data-aia-dropdown]
|
|
3808
|
-
[data-aia-pillbar]
|
|
3809
|
-
[data-aia-pill-scroll]
|
|
3810
|
-
+ [data-aia-skip]::before {
|
|
3811
|
-
margin-inline-end: 8px;
|
|
3812
|
-
margin-inline-start: -4px;
|
|
3813
|
-
}
|
|
3814
|
-
|
|
3815
|
-
/* Classic options box: full-size rows. On the element carrying the
|
|
3816
|
-
attribute, at zero specificity, so a value the consumer sets wins. */
|
|
3817
|
-
:where([data-aia-options-style="classic"]) {
|
|
3818
|
-
--aia-option-row-height: 37px;
|
|
3819
|
-
}
|
|
3820
|
-
`;var ui=class{constructor(){this.reported=new Set}run(e,n){try{return n()}catch(i){this.report(e,i,e);return}}runListener(e,n,i=e){try{return n(),!0}catch(o){return this.report(e,o,i),!1}}report(e,n,i){this.reported.has(i)||(this.reported.add(i),console.error(`[AIAutocomplete] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var mi=class{constructor(e){this.boundary=e;this.listeners={};this.keys=new WeakMap;this.registrationCount=0}on(e,n){let i=`${String(e)}#${++this.registrationCount}`,o=(...a)=>n(...a);this.keys.set(o,i);let r=this.listeners[e];return r||(r=new Set,this.listeners[e]=r),r.add(o),()=>{this.listeners[e]?.delete(o)}}emit(e,...n){let i=this.listeners[e];if(!i)return!0;let o=!0;for(let r of i)this.boundary.runListener(String(e),()=>r(...n),this.keys.get(r)??String(e))||(o=!1);return o}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};var pi=class{constructor(){this.timers=new Map}schedule(e,n,i){this.clear(e);let o=setTimeout(()=>{this.timers.delete(e),n()},i);this.timers.set(e,o)}clear(e){let n=this.timers.get(e);n!==void 0&&(clearTimeout(n),this.timers.delete(e))}clearAll(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear()}};function Pc(t){let e;try{e=new URL(t??Y).host}catch{return null}let n=xt.get(e);return n?`https://${n}`:null}var Va=new WeakMap;function Ga(t,e){if(!t.head)return;let n=Pc(e);if(!n)return;let i=Va.get(t);i||(i=new Map,Va.set(t,i));let o=i.get(n);o||(o=t.createElement("link"),o.rel="preconnect",o.href=n,i.set(n,o)),t.head.append(o)}var Ve=class{constructor(e,n="auto",i){this.container=e;this.mode=n;this.onResolve=i;this.mediaQuery=null;this.onSystemChange=e=>{this.setResolved(e.matches?"dark":"light")};this.apply()}setMode(e){this.detachListener(),this.mode=e,this.apply()}destroy(){this.detachListener()}apply(){this.mode==="auto"?(this.mediaQuery??(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)")),this.mediaQuery.addEventListener("change",this.onSystemChange),this.setResolved(this.mediaQuery.matches?"dark":"light")):this.setResolved(this.mode)}setResolved(e){this.container.dataset.mode=e,this.onResolve?.(e)}detachListener(){this.mediaQuery?.removeEventListener("change",this.onSystemChange)}};function yo(t){return t.isDropdownOpen&&!t.isLoading}var wc=50,Cc=new Set(["search_started","submit","product_click","impression"]),Lc="newParam",$a="suggestionRemoval",Ic="selectionAnimation",xo="skeletonExit",qa="locationSearch",Ac=650,Oc=0;function Mc(){return`:ac-${++Oc}:`}var Ka=170,kc=100;function za(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var gi=class{constructor(e,n={}){this.inputStore=di(za());this._listboxId=Mc();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new pi;this.boundary=new ui;this.subscriberCount=0;this.emitter=new mi(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=Na(this.inputStore,i=>hr(i,this.opts)),n.onSubmit&&this.emitter.on("submit",n.onSubmit),n.onResult&&this.emitter.on("result",n.onResult),n.onError&&this.emitter.on("error",n.onError),n.onChange&&this.emitter.on("change",n.onChange),n.onParamsChange&&this.emitter.on("paramsChange",n.onParamsChange),n.onStateChange&&this.emitter.on("stateChange",n.onStateChange),n.onFocus&&this.emitter.on("focus",n.onFocus),n.onBlur&&this.emitter.on("blur",n.onBlur),n.onProductSelect&&this.emitter.on("productSelect",n.onProductSelect),n.value!==void 0&&this.store.set({text:n.value}),n.completedParams!==void 0&&this.store.set({completedParams:n.completedParams}),this.holdOpen=new Ht(this.store,e),this.pillsController=new dn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new In({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new mn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new cn(this.store,()=>this.opts.optionOverrides,{onAnswer:i=>{i==="edit"?this.reEdit.promoteIfExact():this.maybePromoteExactMatch(this.store.get().text)},onMiss:(i,o)=>{i==="pill"&&o.length>0&&this.fetchController.attemptNow()}}),this.fetchController=new Nt(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,getPrependPlaceholder:()=>this.opts.prependPlaceholder,onRequest:({query:i,signal:o,isCurrent:r})=>{Ga(this.container.ownerDocument,this.opts.apiConfig?.endpoint),this.productsController.run(i,o,r).catch(()=>{})},onAutoMatch:({active:i,matched:o,rawQuery:r})=>{let a=i.options??[];this.fireTelemetry("option",{raw_query:r,selected_option:o.text,other_options:a.filter(s=>s.text!==o.text).map(s=>s.text),key:i.parameter,position:se(a,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.pendingSearchStarted&&(this.pendingSearchStarted=!1,this.fireTelemetry("search_started",{})),this.fireImpression(),this.emitter.hasListeners("result")&&this.emitter.emit("result",this.buildResult())},productsForResponse:i=>this.productsController.forResponse(i),consumerTick:(i,o)=>this.optionSource.tick(i,o),isWordOpen:()=>this.isWordOpen(),holdIdentified:i=>{this.heldIdentified={text:this.store.get().text,candidates:i}},waitIdentified:(i,o)=>{this.waitingIdentified=i.length>0&&this.store.get().text===o?{text:o,candidates:i}:null}}),this.keyboardController=new ln(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.text===o.text&&i.completedParams===o.completedParams||i.identifiedParams.length===0)return;let{valid:r,invalid:a}=Ye(i.text,i.completedParams,i.identifiedParams);a.length>0&&this.store.set({identifiedParams:r})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.identifiedParams===o.identifiedParams)return;let r=i.editingIdentified;if(!r||i.identifiedParams.some(l=>l.id===r.id))return;let a=0,s;for(let l of i.segments){if(l.type==="identified"&&a===r.anchor&&l.value===r.text){s=l.param;break}a+=l.value.length}if(s){this.store.set({editingIdentified:{...r,id:s.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.pendingRangeStart;!o||o.key===B(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==B(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===B(i)||this.store.set({timeDraft:null})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{let r=i.pendingSpan;if(!r||i.text===o.text&&i.completedParams===o.completedParams&&i.identifiedParams===o.identifiedParams)return;let a=r.anchor;if(i.text!==o.text){let l=Uo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||Wo(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(Ba(this.opts.styleRoot??oe(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...za(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.waitingIdentified=null,this.heldIdentified=null,this.openWordText=null,this.fetchController.doFetch("",[])}resetAfterSubmit(){this.opts.resetOnSubmit!==!1&&this.reset()}destroy(){this.destroyed=!0,this.fetchController.dispose(),this.optionSource.dispose(),this.holdOpen.dispose(),this.cancelLocationSearch(),this.modeController?.destroy(),this.timers.clearAll(),this.emitter.clear();for(let e of this.unsubscribers)e();this.unsubscribers=[],this.domRefs?.abort.abort(),this.domRefs&&(Or(this.domRefs.input),fo(this.domRefs.dropdown)),this.dropdownRefs&&fo(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:i}=this.store.get(),{start:o,end:r}=n;if(e===r){let{text:l,removed:d}=Ln(i,o,r);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>o?Math.max(o,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(o),!0}let a=Zt(i,e),s=i.slice(0,a)+i.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),H(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=j(i);if(!k(o))return!1;let r=o==="date-range"?fn(i)??st(i.text):null,a=0,s=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){s=a;break}a+=d.value.length}if(s<0)return!1;let l=s+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:s,tail:l,text:i.text,iso:r?r.start:gn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),i=n.products.findIndex(r=>r.id===e.id),o=n.customFields?.items?.matched?.find(r=>r.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=Wt(n.dateView,e);this.store.set({dateViewMonth:{...i,key:B(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:_e(e),key:B(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(sr(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:B(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${O(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(on(e.timeView.minutes)),this.store.get().completedParams!==e.completedParams&&this.store.set({timeDraft:null}))}setLocationQuery(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=B(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?Ct(this.opts.apiConfig):null,s="loading";a?e.trim().length<Pt&&(s="idle"):s="unavailable",this.store.set({locationSearch:{key:o,query:e,places:s==="loading"?i.places:[],status:s,highlighted:-1}}),!(s!=="loading"||!a)&&this.timers.schedule(qa,()=>{this.runLocationSearch(o,e,a)},Eo)}moveLocationHighlight(e){let n=this.store.get().locationSearch,i=this.store.get().locationView;if(!n||!i||i.places.length===0||i.status==="loading")return;let o=i.places.length,r=i.highlighted<0?e>0?-1:0:i.highlighted;this.store.set({locationSearch:{...n,highlighted:((r+e)%o+o)%o}})}commitLocation(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=e??i.highlighted,r=o>=0?i.places[o]:void 0,a=i.query.trim();!r&&!a||(this.cancelLocationSearch(),this.locationSession=null,this.selectOption(wt(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await Ao(i,n.trim(),{apiConfig:this.opts.apiConfig,sessionToken:this.locationSession.token,language:this.opts.language,signal:o.signal}),status:"done"}}catch(s){let l=s instanceof $e&&s.status===404;l&&this.store.set({locationAutocomplete:!1}),r={places:[],status:l?"unavailable":"error"}}if(this.destroyed||o.signal.aborted||this.locationAbort!==o)return;this.locationAbort=null;let a=this.store.get().locationSearch;!a||a.key!==e||a.query!==n||this.store.set({locationSearch:{...a,...r,highlighted:r.places.length>0?0:-1}})}cancelLocationSearch(){this.timers.clear(qa),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(s=>s.parameter==="placeholder"),i=e.suggestions.filter(s=>s.parameter!=="placeholder");if(i.length===0||C(i[0]))return;let o=i[0],r=i.slice(1),a=e.skippedParams.some(s=>s.parameter===o.parameter);this.store.set({suggestions:[...n,...r],pillTapped:r.length>0,activeDropdownIndex:-1,...a?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:o.parameter,suggestionPlaceholder:o.text}]}}),r.length===0&&this.fetchNow()}handleKeyDown(e){this.keyboardController.handleKeyDown(e)}setFocused(e){this.store.get().isFocused!==e&&this.store.set({isFocused:e})}setLocationFieldFocused(e){this.store.get().locationFieldFocused!==e&&this.store.set({locationFieldFocused:e})}subscribe(e){let n=`subscribe#${++this.subscriberCount}`;return this.store.subscribe(i=>{this.boundary.runListener("subscribe",()=>e(i),n)})}getState(){return this.store.get()}getResult(){return this.buildResult()}getRequestId(){return this.lastRequestId}buildResult(){let e=this.store.get();return ae(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,i=this.opts.mapProducts,o=this.opts.showProducts,r=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.dateFloor){let a=G(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=G(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:B(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(gr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(xo),this.reEdit.selectOption(e);return}let r=Tr({...o,placeholderText:o.leadInText},e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let p=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=p+u.text.length,{...a,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:s,parameter:r.consumedSuggestion.parameter,text:l.slice(p,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:_(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:_(o.activeFormatType)?null:se(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(xo),this.store.set({...r.patch,...Cn(o)}),this.startSelectionAnimationTimer(),this.timers.clear($a),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule($a,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},Ka)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(Ic,()=>this.store.set({inSelectionAnimation:!1}),Ka)}resolveVisitorId(){let e=this.opts.visitorId;if(typeof e!="function")return e;try{return e()}catch{return}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),yo(e)&&!yo(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!yo(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!C(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,wc).map(a=>a.text)})),i=e.products.map(r=>r.id);if(n.length===0&&i.length===0)return;let o=JSON.stringify([n,i]);o!==this.lastImpressionKey&&(this.lastImpressionKey=o,this.fireTelemetry("impression",{query:e.text,pills:n,product_ids:i}))}fireTelemetry(e,n){let i=this.funnelTelemetry===!0;if(!i&&Cc.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();xr({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:ne(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=O(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new Ve(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,get seeAllResults(){return e.opts.seeAllResults===!0},autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.keyboardController.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),startEditingParam:o=>this.startEditingParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=Da(this.container,n);let i=()=>{this.domRefs&&bo(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),bo(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return O(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o)};this.dropdownRefs=La(this.container,n);let i=()=>{this.dropdownRefs&&ho(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),ho(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(lt),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeSkeletonMirror(){this.unsubscribers.push(this.store.subscribe((e,n)=>{if(!e.skeletonOptions)return;if(!n.isLoading&&e.isLoading){e.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!n.isLoading||e.isLoading)return;let i={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!e.skeletonExiting){this.store.set(i);return}this.timers.schedule(xo,()=>this.store.set(i),kc)}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Lc,()=>this.store.set({newParamId:null}),Ac)}))}handleChange(e,n){let i=this.store.get();n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=$o(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=null),this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),a&&/^\s+$/.test(e.slice(a.text.length))&&e.startsWith(a.text)&&this.admitIdentified(a.candidates),this.maybeOpenPendingSpan();let s=this.store.get();s.multiSelectView&&s.optionQuery&&s.filteredOptions.length===0&&this.finishMultiSelect(s.optionQuery)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=Ye(n.text,n.completedParams,e);i.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...i]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let a=this.store.get();return a.completedParams!==o.completedParams||a.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=ie(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=Fo(e.segments,n);e.text.slice(i).trim().length!==0&&this.store.set({pendingSpan:{anchor:i,snapshot:e.actionableSuggestions}})}maybeExitReEditOnNoMatch(){let e=this.store.get();if(!e.editingParam||e.editingAnchor==null||e.completedParams.some(r=>r.id===e.editingParam?.id)||this.optionSource.owns(e.editingParam.suggestionParameter,e.optionQuery))return;let n=e.caretOffset??e.editingAnchor,i=e.text.slice(e.editingAnchor,n);be(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=N(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),a=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${a} `:a,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:Q(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(p=>p.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(_(o.activeFormatType)||this.isWordOpen())return;let r=Pn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query:N(e,o.completedParams).rawQuery,selected_option:r.option.text,other_options:s.filter(l=>l.text!==r.option.text).map(l=>l.text),key:a.parameter,position:se(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};0&&(module.exports={AIAutocomplete,ATTRIBUTION_URL,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,EDITOR_GROW_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_DONE_FIT_VAR,MULTI_SELECT_TOGGLE_MIN_PX,MULTI_SELECT_TOGGLE_SLOP_PX,ModeController,OPTIONS_GRID_MOBILE_QUERY,OPTION_ENTER_DELAY_VAR,OPTION_ENTER_FADE_MS,OPTION_ENTER_RISE_MS,OPTION_ENTER_RISE_PX,OPTION_ENTER_STAGGER_MS,OPTION_IMAGE_WIDTH,PANEL_ENTER_DELAY_MS,PANEL_ENTER_MS,PANEL_GHOST_CLASS,PANEL_GLIDE_MS,PANEL_LEAVE_MS,PLACEHOLDER_FADE_OUT_MS,PLACEHOLDER_LEAVING_ATTR,PLACEHOLDER_SWAP_GAP_MS,PLACEHOLDER_TYPE_MS,PLACEHOLDER_WORD_PAUSE_MS,PRODUCT_IMAGE_WIDTH,PRODUCT_PATH_PREFIX,PRODUCT_ROW_PX_PER_LINE,RANGE_SEPARATOR,SCHEMA_VERSION,SCROLL_ARROW_ATTR,SCROLL_ARROW_BOTTOM_VAR,SCROLL_ARROW_CLASS,SCROLL_ARROW_FADE_MS,SCROLL_ARROW_LABEL,SCROLL_ARROW_SCROLL_IDLE_MS,SCROLL_ARROW_VISIBLE_ATTR,SKIPPED_PARAM_TEXT,SMART_SUGGESTION_SPARKLE_SVG,TIME_META_KEY,TIME_STEP_MINUTES,TIME_WHEEL_COLUMNS,TIME_WHEEL_ROW_HEIGHT,VIEWPORT_FIT_ATTR,VIEWPORT_FIT_HEIGHT_VAR,WEEKDAY_LABELS,addMonths,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateFloorFor,dateSelectionFor,destroyPanelMorph,extractPlainText,findMultiSelectDone,fitMultiSelectDone,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,notePanelMorphHeight,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,panelMorphGlide,panelMorphKey,panelMorphTargetHeight,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,queryLive,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,settlePanelMorph,shopifyImageSrc,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
|
|
3765
|
+
`;var pi=class{constructor(){this.reported=new Set}run(e,n){try{return n()}catch(i){this.report(e,i,e);return}}runListener(e,n,i=e){try{return n(),!0}catch(o){return this.report(e,o,i),!1}}report(e,n,i){this.reported.has(i)||(this.reported.add(i),console.error(`[AIAutocomplete] "${e}" threw. The error is contained \u2014 SDK state is unaffected. Later failures of "${e}" on this instance are not logged.`,n))}};var gi=class{constructor(e){this.boundary=e;this.listeners={};this.keys=new WeakMap;this.registrationCount=0}on(e,n){let i=`${String(e)}#${++this.registrationCount}`,o=(...a)=>n(...a);this.keys.set(o,i);let r=this.listeners[e];return r||(r=new Set,this.listeners[e]=r),r.add(o),()=>{this.listeners[e]?.delete(o)}}emit(e,...n){let i=this.listeners[e];if(!i)return!0;let o=!0;for(let r of i)this.boundary.runListener(String(e),()=>r(...n),this.keys.get(r)??String(e))||(o=!1);return o}hasListeners(e){return(this.listeners[e]?.size??0)>0}clear(){this.listeners={}}};var fi=class{constructor(){this.timers=new Map}schedule(e,n,i){this.clear(e);let o=setTimeout(()=>{this.timers.delete(e),n()},i);this.timers.set(e,o)}clear(e){let n=this.timers.get(e);n!==void 0&&(clearTimeout(n),this.timers.delete(e))}clearAll(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear()}};function Yc(t){let e;try{e=new URL(t??Y).host}catch{return null}let n=Pt.get(e);return n?`https://${n}`:null}var ns=new WeakMap;function is(t,e){if(!t.head)return;let n=Yc(e);if(!n)return;let i=ns.get(t);i||(i=new Map,ns.set(t,i));let o=i.get(n);o||(o=t.createElement("link"),o.rel="preconnect",o.href=n,i.set(n,o)),t.head.append(o)}var $e=class{constructor(e,n="auto",i){this.container=e;this.mode=n;this.onResolve=i;this.mediaQuery=null;this.onSystemChange=e=>{this.setResolved(e.matches?"dark":"light")};this.apply()}setMode(e){this.detachListener(),this.mode=e,this.apply()}destroy(){this.detachListener()}apply(){this.mode==="auto"?(this.mediaQuery??(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)")),this.mediaQuery.addEventListener("change",this.onSystemChange),this.setResolved(this.mediaQuery.matches?"dark":"light")):this.setResolved(this.mode)}setResolved(e){this.container.dataset.mode=e,this.onResolve?.(e)}detachListener(){this.mediaQuery?.removeEventListener("change",this.onSystemChange)}};function Co(t){return t.isDropdownOpen&&!t.isLoading}var Xc=50,Jc=new Set(["search_started","submit","product_click","impression"]),Zc="newParam",os="suggestionRemoval",ed="selectionAnimation",Lo="skeletonExit",rs="locationSearch",td=650,nd=0;function id(){return`:ac-${++nd}:`}var as=170,ss=160;function ls(){return{text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,locationAutocomplete:!0,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!1,isReady:!1,error:null,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null,multiSelectDraft:null,locationSearch:null,locationFieldFocused:!1,editingIdentified:null}}var hi=class{constructor(e,n={}){this.inputStore=mi(ls());this._listboxId=id();this.modeController=null;this.unsubscribers=[];this.domRefs=null;this.dropdownRefs=null;this.timers=new fi;this.boundary=new pi;this.subscriberCount=0;this.emitter=new gi(this.boundary);this.sessionId=crypto.randomUUID();this.lastRequestId=null;this.searchStartedSessionId=null;this.funnelTelemetry=null;this.pendingSearchStarted=!1;this.openWordText=null;this.locationMirrorText=null;this.heldIdentified=null;this.waitingIdentified=null;this.lastImpressionKey="";this.visibleImpression=!1;this.destroyed=!1;this.locationAbort=null;this.locationSession=null;this.emitSubmit=e=>(this.recordSubmit(e),this.emitter.emit("submit",e));this.emitError=e=>this.emitter.emit("error",e);this.container=e,this.opts=n,this.renderMode=n.renderMode??"full",this.store=Ya(this.inputStore,i=>Cr(i,this.opts)),n.onSubmit&&this.emitter.on("submit",n.onSubmit),n.onResult&&this.emitter.on("result",n.onResult),n.onError&&this.emitter.on("error",n.onError),n.onChange&&this.emitter.on("change",n.onChange),n.onParamsChange&&this.emitter.on("paramsChange",n.onParamsChange),n.onStateChange&&this.emitter.on("stateChange",n.onStateChange),n.onFocus&&this.emitter.on("focus",n.onFocus),n.onBlur&&this.emitter.on("blur",n.onBlur),n.onProductSelect&&this.emitter.on("productSelect",n.onProductSelect),n.value!==void 0&&this.store.set({text:n.value}),n.completedParams!==void 0&&this.store.set({completedParams:n.completedParams}),this.holdOpen=new Bt(this.store,e),this.pillsController=new pn(this.store,{onPillSelected:({rawQuery:i,selectedPill:o,otherPills:r})=>{this.fireTelemetry("pill",{raw_query:i,selected_pill:o,other_pills:r})}}),this.reEdit=new In({store:this.store,scheduleSetCursor:i=>this.scheduleSetCursor(i),fireTelemetry:(i,o)=>this.fireTelemetry(i,o),startSelectionAnimationTimer:()=>this.startSelectionAnimationTimer(),fetchNow:()=>this.fetchNow()}),this.productsController=new fn(this.store,()=>this.opts.products,()=>this.opts.showProducts!==!1,()=>this.opts.language,()=>this.opts.mapProducts),this.optionSource=new mn(this.store,()=>this.opts.optionOverrides,{onAnswer:i=>{i==="edit"?this.reEdit.promoteIfExact():this.maybePromoteExactMatch(this.store.get().text)},onMiss:(i,o)=>{i==="pill"&&o.length>0&&this.fetchController.attemptNow()}}),this.fetchController=new Wt(this.store,()=>this.opts.apiConfig,()=>this.opts.optionOverrides,()=>this.opts.maskCompletedText,()=>this.emitter.hasListeners("error")?this.emitError:void 0,()=>this.sessionId,()=>this.resolveSource(),()=>this.opts.additionalContext,()=>this.opts.language,{getProductId:()=>this.opts.productId,getCurrency:()=>this.opts.currency,getPrependPlaceholder:()=>this.opts.prependPlaceholder,onRequest:({query:i,signal:o,isCurrent:r})=>{is(this.container.ownerDocument,this.opts.apiConfig?.endpoint),this.productsController.run(i,o,r).catch(()=>{})},onAutoMatch:({active:i,matched:o,rawQuery:r})=>{let a=i.options??[];this.fireTelemetry("option",{raw_query:r,selected_option:o.text,other_options:a.filter(s=>s.text!==o.text).map(s=>s.text),key:i.parameter,position:ce(a,o.text),chip_origin:"typed"})},onResponse:({requestId:i,funnelTelemetry:o,visibleImpression:r})=>{this.lastRequestId=i,this.funnelTelemetry=o,this.visibleImpression=r,this.pendingSearchStarted&&(this.pendingSearchStarted=!1,this.fireTelemetry("search_started",{})),this.fireImpression(),this.emitter.hasListeners("result")&&this.emitter.emit("result",this.buildResult())},productsForResponse:i=>this.productsController.forResponse(i),consumerTick:(i,o)=>this.optionSource.tick(i,o),isWordOpen:()=>this.isWordOpen(),holdIdentified:i=>{this.heldIdentified={text:this.store.get().text,candidates:i}},waitIdentified:(i,o)=>{this.waitingIdentified=i.length>0&&this.store.get().text===o?{text:o,candidates:i}:null}}),this.keyboardController=new un(this.store,{columns:n.columns??2,listboxId:this.listboxId,getOnSubmit:()=>this.emitter.hasListeners("submit")?this.emitSubmit:void 0,getOptionsPosition:()=>this.opts.optionsPosition??"below",afterSubmit:this.renderMode==="full"?()=>this.resetAfterSubmit():void 0,selectOption:i=>this.selectOption(i),removeParamAtCaret:i=>this.removeParamAtCaret(i),startEditingParamAtCaret:i=>this.startEditingParamAtCaret(i),exitEditMode:()=>this.exitEditMode(),exitEditingIdentified:()=>this.exitEditingIdentified(),skipActivePill:()=>this.skipActivePill(),endTypedWord:i=>this.endTypedWord(i),stepTime:i=>this.stepTime(i),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect()}),this.unsubscribers.push(this.store.subscribe((i,o)=>{i.text!==o.text&&this.emitter.emit("change",i.text),i.completedParams!==o.completedParams&&this.emitter.emit("paramsChange",i.completedParams);let r=i.isFocused||i.locationFieldFocused;r!==(o.isFocused||o.locationFieldFocused)&&(r?this.emitter.emit("focus"):this.emitter.emit("blur")),this.emitter.emit("stateChange",i)})),this.unsubscribers.push(this.store.subscribe(()=>this.maybeExitReEditOnNoMatch())),this.unsubscribers.push(this.store.subscribe(()=>{let i=this.store.get();i.locationFieldFocused&&!i.locationView&&this.store.set({locationFieldFocused:!1})})),this.subscribeSkeletonMirror(),this.subscribeLocationMirror(),this.subscribeVisibleImpression(),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.text===o.text&&i.completedParams===o.completedParams||i.identifiedParams.length===0)return;let{valid:r,invalid:a}=Je(i.text,i.completedParams,i.identifiedParams);a.length>0&&this.store.set({identifiedParams:r})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{if(i.identifiedParams===o.identifiedParams)return;let r=i.editingIdentified;if(!r||i.identifiedParams.some(l=>l.id===r.id))return;let a=0,s;for(let l of i.segments){if(l.type==="identified"&&a===r.anchor&&l.value===r.text){s=l.param;break}a+=l.value.length}if(s){this.store.set({editingIdentified:{...r,id:s.id}});return}this.store.set({editingIdentified:null,activeDropdownIndex:-1})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.pendingRangeStart;!o||o.key===U(i)||this.store.set({pendingRangeStart:null})})),this.unsubscribers.push(this.store.subscribe(i=>{let o=i.multiSelectDraft;o&&o.key!==U(i)&&this.store.set({multiSelectDraft:null});let r=i.timeDraft;!r||r.key===U(i)||this.store.set({timeDraft:null})})),this.unsubscribers.push(this.store.subscribe((i,o)=>{let r=i.pendingSpan;if(!r||i.text===o.text&&i.completedParams===o.completedParams&&i.identifiedParams===o.identifiedParams)return;let a=r.anchor;if(i.text!==o.text){let l=Xo(o.text,i.text,a);if(l===null){this.store.set({pendingSpan:null});return}a=l}i.text.slice(a).trim().length===0||Qo(i.segments,a)?this.store.set({pendingSpan:null}):a!==r.anchor&&this.store.set({pendingSpan:{anchor:a,snapshot:r.snapshot}})})),this.renderMode!=="headless"&&(es(this.opts.styleRoot??ae(this.container)),this.setupContainer()),this.renderMode==="full"?this.buildAndRenderFull():this.renderMode==="dropdown"&&this.buildAndRenderDropdown(),this.optionSource.start(),this.fetchController.start()}focus(){this.domRefs?.input.focus()}blur(){this.domRefs?.input.blur()}reset(){let{isFocused:e,dropdownHeld:n}=this.store.get();this.optionSource.reset(),this.store.set({...ls(),isFocused:e,dropdownHeld:n,skipNextFetch:!0}),this.sessionId=crypto.randomUUID(),this.lastRequestId=null,this.lastImpressionKey="",this.pendingSearchStarted=!1,this.waitingIdentified=null,this.heldIdentified=null,this.openWordText=null,this.fetchController.doFetch("",[])}resetAfterSubmit(){this.opts.resetOnSubmit!==!1&&this.reset()}destroy(){this.destroyed=!0,this.fetchController.dispose(),this.optionSource.dispose(),this.holdOpen.dispose(),this.cancelLocationSearch(),this.modeController?.destroy(),this.timers.clearAll(),this.emitter.clear();for(let e of this.unsubscribers)e();this.unsubscribers=[],this.domRefs?.abort.abort(),this.domRefs&&(Br(this.domRefs.input),vo(this.domRefs.dropdown)),this.dropdownRefs&&vo(this.dropdownRefs.dropdown),this.domRefs=null,this.dropdownRefs=null,this.renderMode!=="headless"&&(this.container.innerHTML="")}setMode(e){this.modeController?.setMode(e)}prefillText(e){this.applyTextChange(e,!1)}noteSearchStarted(){this.searchStartedSessionId!==this.sessionId&&(this.searchStartedSessionId=this.sessionId,this.funnelTelemetry===null?this.pendingSearchStarted=!0:this.fireTelemetry("search_started",{}))}setValue(e){let n=this.store.get();if(n.editingIdentified&&e!==n.text){this.store.set({text:e,editingIdentified:null,activeDropdownIndex:-1});return}this.store.set({text:e})}setCompletedParams(e){this.store.set({completedParams:e})}setActivePill(e){this.pillsController.setActivePill(e);let n=this.store.get().text.length;this.store.set({caretOffset:n,isFocused:!0}),this.scheduleSetCursor(n)}removeLastParam(){this.pillsController.removeLastParam()}findChipSpanAt(e){let n=0;for(let i of this.store.get().segments){let o=n;if(n+=i.value.length,i.type!=="text"&&e>o&&e<=n)return{kind:i.type,param:i.param,start:o,end:n}}return null}withoutChip(e,n){return n.kind==="completed"?{completedParams:e.completedParams.filter(i=>i.id!==n.param.id&&(!n.param.group||i.group!==n.param.group))}:{identifiedParams:e.identifiedParams.filter(i=>i.id!==n.param.id)}}removeParamAtCaret(e){let n=this.findChipSpanAt(e);if(!n)return!1;let{text:i}=this.store.get(),{start:o,end:r}=n;if(e===r){let{text:l,removed:d}=An(i,o,r);return this.store.set(c=>({text:l,filterBase:Math.min(c.filterBase>o?Math.max(o,c.filterBase-d):c.filterBase,l.length),...this.withoutChip(c,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(o),!0}let a=nn(i,e),s=i.slice(0,a)+i.slice(e);return this.store.set(l=>({text:s,filterBase:Math.min(l.filterBase,s.length),...this.withoutChip(l,n),pillTapped:!1,activeDropdownIndex:-1})),this.scheduleSetCursor(a),!0}startEditingParamAtCaret(e){let n=this.findChipSpanAt(e);return!n||n.kind!=="completed"||n.end!==e||this.store.get().completedParams.find(i=>i.id===n.param.id)?.group?!1:(this.reEdit.start(n.param.id),this.store.get().editingParam?.id===n.param.id)}scheduleSetCursor(e){queueMicrotask(()=>{let n=this.domRefs;if(n)n.input.focus(),H(n.input,e);else{let i=this.opts.setCursor;i&&this.boundary.runListener("setCursor",()=>i(e))}})}clearNewParamId(){this.store.set({newParamId:null})}startEditingIdentified(e){let n=this.store.get();if(n.editingIdentified?.id===e)return!0;let i=n.identifiedParams.find(d=>d.id===e);if(!i)return!1;let o=Q(i);if(!k(o))return!1;let r=o==="date-range"?Sn(i)??dt(i.text):null,a=0,s=-1;for(let d of n.segments){if(d.type!=="text"&&d.param.id===e){s=a;break}a+=d.value.length}if(s<0)return!1;let l=s+i.text.length;return this.store.set({editingIdentified:{id:e,parameter:i.parameter,anchor:s,tail:l,text:i.text,iso:r?r.start:bn(i),isoEnd:r?r.end:null,format:o},editingParam:null,editingAnchor:null,editingTail:null,caretOffset:l,activeDropdownIndex:-1,pillTapped:!0}),!0}exitEditingIdentified(){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1})}startEditingParam(e){this.store.get().completedParams.find(n=>n.id===e)?.group||(this.reEdit.start(e),this.store.get().editingParam?.id!==e&&this.startEditingIdentified(e))}replaceEditingRange(e){return this.reEdit.replaceRange(e)}exitEditMode(){this.reEdit.exit()}handleCaretAfterInput(e){this.reEdit.caretAfterInput(e)}handleCaretMove(e){let n=this.store.get().editingIdentified;n&&e!=null&&(e<n.anchor||e>n.tail)&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.reEdit.caretMove(e)}setActiveDropdownIndex(e){this.store.set({activeDropdownIndex:e})}clearHighlight(e){this.store.get().activeDropdownIndex===e&&this.store.set({activeDropdownIndex:-1})}prepareSubmit(){this.endTypedWord(!0)}recordSubmit(e){this.fireTelemetry("submit",{query:e.query,completed_pills:e.completed_params.filter(n=>n.placeholder).map(n=>({key:n.parameter,value:n.text??""}))})}selectProduct(e){let n=this.store.get(),i=n.products.findIndex(r=>r.id===e.id),o=n.customFields?.items?.matched?.find(r=>r.source_id===e.id)?.origin_id;this.fireTelemetry("product_click",{query:n.text,product_id:e.id,...o&&{origin_id:o},position:i>=0?i+1:null}),this.emitter.emit("productSelect",e)}addProductToCart(e){let n=this.opts.onProductAddToCart;if(!n)return Promise.resolve();try{return Promise.resolve(n(e)).then(()=>{})}catch(i){return Promise.reject(i)}}hasProductAddToCart(){return typeof this.opts.onProductAddToCart=="function"}handleTextChange(e){this.applyTextChange(e,!0)}applyTextChange(e,n){this.store.get().editingIdentified&&this.store.set({editingIdentified:null,activeDropdownIndex:-1}),this.handleChange(e,n)}showPreviousMonth(){this.pageDateView(-1)}showNextMonth(){this.pageDateView(1)}pageDateView(e){let n=this.store.get();if(!k(n.activeFormatType)||!n.dateView)return;let i=Vt(n.dateView,e);this.store.set({dateViewMonth:{...i,key:U(n)},activeDropdownIndex:-1})}setTime(e){let n=this.store.get();n.activeFormatType!=="time"||!n.timeView||this.store.set({timeDraft:{minutes:_e(e),key:U(n)}})}stepTime(e){let n=this.store.get().timeView;n&&this.setTime(br(n.minutes,e))}toggleMultiSelectOption(e){let n=this.store.get();if(!n.multiSelectView||!e.is_tappable)return;let i=n.multiSelectView.picked;this.store.set({multiSelectDraft:{key:U(n),picked:i.includes(e.text)?i.filter(o=>o!==e.text):[...i,e.text]}})}commitMultiSelect(){this.finishMultiSelect()}answerMultiSelectWith(e){let n=this.store.get().multiSelectView;!n||!e.is_tappable||(n.picked.includes(e.text)||this.toggleMultiSelectOption(e),this.finishMultiSelect())}finishMultiSelect(e=""){let n=this.store.get();if(!n.multiSelectView)return;let i=n.multiSelectView.picked;if(i.length===0){this.store.set({multiSelectDraft:null}),this.skipActivePill();return}let o=i.map(a=>n.actionableSuggestions[0].options?.find(s=>s.text===a)).filter(a=>a!==void 0);if(o.length===0)return;let r=i.length===1?i[0]:`${i.slice(0,-1).join(", ")} ${M(this.opts.language).and} ${i[i.length-1]}`;this.applyOption({text:r,is_tappable:!0,kind:null},o,e),n.text||this.noteSearchStarted()}commitTime(){let e=this.store.get();e.activeFormatType!=="time"||!e.timeView||(this.selectOption(sn(e.timeView.minutes)),this.store.get().completedParams!==e.completedParams&&this.store.set({timeDraft:null}))}setLocationQuery(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=U(n);this.cancelLocationSearch();let a=n.locationAutocomplete&&this.opts.locationSearch!==!1?It(this.opts.apiConfig):null,s="loading";a?e.trim().length<Ke&&(s="idle"):s="unavailable",this.store.set({locationSearch:{key:o,query:e,places:s==="loading"?i.places:[],status:s,highlighted:-1}}),!(s!=="loading"||!a)&&this.timers.schedule(rs,()=>{this.runLocationSearch(o,e,a)},ko)}moveLocationHighlight(e){let n=this.store.get().locationSearch,i=this.store.get().locationView;if(!n||!i||i.places.length===0||i.status==="loading")return;let o=i.places.length,r=i.highlighted<0?e>0?-1:0:i.highlighted;this.store.set({locationSearch:{...n,highlighted:((r+e)%o+o)%o}})}commitLocation(e){let n=this.store.get(),i=n.locationView;if(n.activeFormatType!=="location"||!i)return;let o=e??i.highlighted,r=o>=0?i.places[o]:void 0,a=i.query.trim();!r&&!a||(this.cancelLocationSearch(),this.locationSession=null,this.selectOption(At(r??a)),this.store.get().completedParams!==n.completedParams&&this.store.set({locationSearch:null}))}async runLocationSearch(e,n,i){let o=new AbortController;this.locationAbort=o,this.locationSession?.key!==e&&(this.locationSession={key:e,token:crypto.randomUUID()});let r;try{r={places:await Wo(i,n.trim(),{apiConfig:this.opts.apiConfig,sessionToken:this.locationSession.token,language:this.opts.language,signal:o.signal}),status:"done"}}catch(s){let l=s instanceof ze&&s.status===404;l&&this.store.set({locationAutocomplete:!1}),r={places:[],status:l?"unavailable":"error"}}if(this.destroyed||o.signal.aborted||this.locationAbort!==o)return;this.locationAbort=null;let a=this.store.get().locationSearch;!a||a.key!==e||a.query!==n||this.store.set({locationSearch:{...a,...r,highlighted:r.places.length>0?0:-1}})}cancelLocationSearch(){this.timers.clear(rs),this.locationAbort?.abort(),this.locationAbort=null}skipActivePill(){let e=this.store.get();if(e.editingParam||e.inSelectionAnimation)return;let n=e.suggestions.filter(s=>s.parameter==="placeholder"),i=e.suggestions.filter(s=>s.parameter!=="placeholder");if(i.length===0||L(i[0]))return;let o=i[0],r=i.slice(1),a=e.skippedParams.some(s=>s.parameter===o.parameter);this.store.set({suggestions:[...n,...r],pillTapped:r.length>0,activeDropdownIndex:-1,...a?{}:{skippedParams:[...e.skippedParams,{id:crypto.randomUUID(),parameter:o.parameter,suggestionPlaceholder:o.text}]}}),r.length===0&&this.fetchNow()}handleKeyDown(e){this.keyboardController.handleKeyDown(e)}setFocused(e){this.store.get().isFocused!==e&&this.store.set({isFocused:e})}setLocationFieldFocused(e){this.store.get().locationFieldFocused!==e&&this.store.set({locationFieldFocused:e})}subscribe(e){let n=`subscribe#${++this.subscriberCount}`;return this.store.subscribe(i=>{this.boundary.runListener("subscribe",()=>e(i),n)})}getState(){return this.store.get()}getResult(){return this.buildResult()}getRequestId(){return this.lastRequestId}buildResult(){let e=this.store.get();return le(e.text,e.completedParams,e.skippedParams,{identifiedParams:e.identifiedParams,isReady:e.isReady,customFields:e.customFields})}get listboxId(){return this._listboxId}get isReady(){return this.store.get().isReady}on(e,n){return this.emitter.on(e,n)}refreshProducts(){this.opts.mapProducts&&this.productsController.refresh()}update(e){let n=this.opts.products,i=this.opts.mapProducts,o=this.opts.showProducts,r=this.opts.optionOverrides;Object.assign(this.opts,e),"language"in e&&this.updateLanguageAttribute(),"optionOverrides"in e&&e.optionOverrides!==r&&this.optionSource.refresh(),"products"in e&&e.products!==n||"showProducts"in e&&e.showProducts!==o?this.productsController.resync():"mapProducts"in e&&e.mapProducts!==i&&this.productsController.refresh(),e.mode!==void 0&&this.modeController?.setMode(e.mode),e.optionsPosition!==void 0&&(this.container.dataset.optionsPosition=e.optionsPosition),e.animations!==void 0&&(this.container.dataset.animations=e.animations?"on":"off"),e.optionsStyle!==void 0&&(this.container.dataset.aiaOptionsStyle=e.optionsStyle),e.pillPlacement!==void 0&&(this.container.dataset.pillPlacement=e.pillPlacement,this.store.set({})),(e.dropdownTrigger!==void 0||e.closeDropdownOnBlur!==void 0||e.prependPlaceholder!==void 0||e.showNonTappableOptions!==void 0||e.showSkipButton!==void 0||e.showOptionIcons!==void 0||e.showOptionImages!==void 0||e.showOptionCounts!==void 0||e.productsLayout!==void 0||e.productImageFallback!==void 0||e.seeAllResults!==void 0||e.showChipIcons!==void 0||e.showChipImages!==void 0||"language"in e)&&this.store.set({}),e.value!==void 0&&this.setValue(e.value),e.completedParams!==void 0&&this.store.set({completedParams:e.completedParams})}selectOption(e,n){if(this.store.get().multiSelectView){n?.commit?this.answerMultiSelectWith(e):this.toggleMultiSelectOption(e);return}let o=!this.store.get().text;this.applyOption(e),o&&this.store.get().text&&this.noteSearchStarted()}applyOption(e,n,i=""){let o=this.store.get();if(o.dateFloor){let a=$(e);if(a&&a<o.dateFloor)return}if(o.activeFormatType==="date-range"){let a=$(e);if(a){let s=o.dateRangeStart;if(!s){this.store.set({pendingRangeStart:{iso:a,key:U(o)}});return}this.store.set({pendingRangeStart:null}),this.selectOption(Pr(s,a));return}}if(o.editingIdentified){this.commitIdentifiedDate(e);return}if(o.editingParam&&o.editingAnchor!=null&&o.editingTail!=null){this.timers.clear(Lo),this.reEdit.selectOption(e);return}let r=Mr({...o,placeholderText:o.leadInText},e);if(r){if(n){let a=r.patch.completedParams?.[o.completedParams.length];if(!a||!r.patch.text)return;let s=crypto.randomUUID(),l=r.patch.text,d=l.toLowerCase().lastIndexOf(e.text.toLowerCase()),c=n.map(u=>{let p=l.toLowerCase().indexOf(u.text.toLowerCase(),d);return d=p+u.text.length,{...a,value:u.value,kind:u.kind,metadata:u.metadata,icon:u.icon,icon_svg:u.icon_svg,image_url:u.image_url,id:crypto.randomUUID(),group:s,parameter:r.consumedSuggestion.parameter,text:l.slice(p,d)}});r.patch.completedParams=[...o.completedParams,...c],r.patch.newParamId=c[0].id,r.patch.multiSelectDraft=null,r.patch.text+=i,r.patch.caretOffset=r.patch.text.length,r.patch.suggestions=o.suggestions.filter(u=>u!==r.consumedSuggestion)}for(let a of n??[e])this.fireTelemetry("option",{raw_query:N(o.text,o.completedParams).rawQuery,selected_option:a.text,other_options:D(o.activeFormatType)?[]:o.filteredOptions.filter(s=>s.text!==a.text).map(s=>s.text),key:r.telemetry.key,position:D(o.activeFormatType)?null:ce(r.consumedSuggestion.options??[],a.text),chip_origin:"tap"});if(this.timers.clear(Lo),this.store.set({...r.patch,...Ln(o)}),this.startSelectionAnimationTimer(),this.timers.clear(os),r.remainingActionable>0){let a=r.consumedSuggestion;this.timers.schedule(os,()=>{this.store.get().suggestions.includes(a)&&this.store.set(s=>({suggestions:s.suggestions.filter(l=>l!==a)}))},as)}this.fetchNow()}}startSelectionAnimationTimer(){this.timers.schedule(ed,()=>this.store.set({inSelectionAnimation:!1}),as)}resolveVisitorId(){let e=this.opts.visitorId;if(typeof e!="function")return e;try{return e()}catch{return}}resolveSource(){return this.opts.source??(this.renderMode==="full"?"full-sdk":"headless-sdk")}subscribeVisibleImpression(){this.unsubscribers.push(this.store.subscribe((e,n)=>{this.visibleImpression&&(!e.isDropdownOpen&&n.isDropdownOpen&&(this.lastImpressionKey=""),Co(e)&&!Co(n)&&queueMicrotask(()=>this.fireImpression()))}))}fireImpression(){if(this.funnelTelemetry!==!0||this.destroyed)return;let e=this.store.get();if(this.visibleImpression&&!Co(e))return;let n=e.suggestions.filter(r=>r.parameter!=="placeholder"&&!L(r)).map(r=>({key:r.parameter,options:(r.options??[]).slice(0,Xc).map(a=>a.text)})),i=e.products.map(r=>r.id);if(n.length===0&&i.length===0)return;let o=JSON.stringify([n,i]);o!==this.lastImpressionKey&&(this.lastImpressionKey=o,this.fireTelemetry("impression",{query:e.text,pills:n,product_ids:i}))}fireTelemetry(e,n){let i=this.funnelTelemetry===!0;if(!i&&Jc.has(e))return;if(!i&&e==="option"){let{key:r,position:a,chip_origin:s,...l}=n;n=l}let o=this.resolveSource();Or({source:o,sessionId:this.sessionId,visitorId:i?this.resolveVisitorId():void 0,requestId:i?this.lastRequestId:null,keepalive:i,type:e,language:oe(this.opts.language),queryData:n,apiConfig:this.opts.apiConfig})}updateLanguageAttribute(){let{language:e}=M(this.opts.language);e!=="en"?this.container.dataset.aiaLanguage=e:delete this.container.dataset.aiaLanguage}setupContainer(){this.container.classList.add("magicx-aia"),this.updateLanguageAttribute(),this.container.dataset.pillPlacement=this.renderMode==="dropdown"?"dropdown":this.opts.pillPlacement??"dropdown",this.container.dataset.optionsPosition=this.opts.optionsPosition??"below",this.container.dataset.animations=this.opts.animations??!0?"on":"off",this.container.dataset.aiaOptionsStyle=this.opts.optionsStyle??"floating",this.modeController=new $e(this.container,this.opts.mode??"auto")}buildAndRenderFull(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return M(e.opts.language)},get pillPlacement(){return e.opts.pillPlacement??"dropdown"},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get showChipIcons(){return e.opts.showChipIcons??!0},get showChipImages(){return e.opts.showChipImages??!0},get optionsPosition(){return e.opts.optionsPosition??"below"},get onSubmit(){return e.emitter.hasListeners("submit")?e.emitSubmit:void 0},afterSubmit:()=>e.resetAfterSubmit(),endTypedWord:()=>e.endTypedWord(!0),submitButton:this.opts.submitButton,get seeAllResults(){return e.opts.seeAllResults===!0},autoFocus:this.opts.autoFocus??!0,selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o),handleKeyDown:o=>this.keyboardController.handleKeyDown(o),handleChange:o=>this.handleChange(o,!0),startEditingParam:o=>this.startEditingParam(o),handleCaretAfterInput:o=>this.handleCaretAfterInput(o),handleCaretMove:o=>this.handleCaretMove(o),replaceEditingRange:o=>this.replaceEditingRange(o)};this.domRefs=Qa(this.container,n);let i=()=>{this.domRefs&&Po(this.domRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Po(this.domRefs,this.store.get(),n),this.subscribeNewParamTimer()}buildAndRenderDropdown(){let e=this,n={store:this.store,listboxId:this.listboxId,get strings(){return M(e.opts.language)},get showSkipButton(){return e.opts.showSkipButton??!0},get showOptionIcons(){return e.opts.showOptionIcons??!0},get showOptionImages(){return e.opts.showOptionImages??!0},get showOptionCounts(){return e.opts.showOptionCounts??!0},get productsLayout(){return e.opts.productsLayout??"row"},get productImageFallback(){return e.opts.productImageFallback??"image"},get addProductToCart(){return e.hasProductAddToCart()?o=>e.addProductToCart(o):void 0},get optionsPosition(){return e.opts.optionsPosition??"below"},selectOption:(o,r)=>this.selectOption(o,r),setActivePill:o=>this.pillsController.setActivePill(o),skipActivePill:()=>this.skipActivePill(),selectProduct:o=>this.selectProduct(o),showPreviousMonth:()=>this.showPreviousMonth(),showNextMonth:()=>this.showNextMonth(),setTime:o=>this.setTime(o),commitTime:()=>this.commitTime(),commitMultiSelect:()=>this.commitMultiSelect(),setLocationQuery:o=>this.setLocationQuery(o),moveLocationHighlight:o=>this.moveLocationHighlight(o),commitLocation:o=>this.commitLocation(o),setLocationFieldFocused:o=>this.setLocationFieldFocused(o)};this.dropdownRefs=Ua(this.container,n);let i=()=>{this.dropdownRefs&&Eo(this.dropdownRefs,this.store.get(),n)};this.subscribeBatchedRender(i),this.subscribeViewportBreakpoint(i),Eo(this.dropdownRefs,this.store.get(),n),this.subscribeNewParamTimer()}subscribeViewportBreakpoint(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(ut),i=()=>e();n.addEventListener("change",i),this.unsubscribers.push(()=>n.removeEventListener("change",i))}subscribeBatchedRender(e){let n=!1;this.unsubscribers.push(this.store.subscribe(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,e()}))}))}subscribeLocationMirror(){this.unsubscribers.push(this.store.subscribe(e=>{if(e.activeFormatType!=="location"){this.locationMirrorText=null;return}!e.isDropdownOpen||e.text===this.locationMirrorText||(this.locationMirrorText=e.text,this.mirrorTypedIntoLocationSearch())}))}subscribeSkeletonMirror(){let e=Date.now();this.unsubscribers.push(this.store.subscribe((n,i)=>{let o=s=>s.dropdownLoading&&s.skeletonOptions!==null;if(!o(i)&&o(n)&&(e=Date.now()),!n.skeletonOptions)return;if(!i.isLoading&&n.isLoading){n.skeletonRequested||this.store.set({skeletonRequested:!0});return}if(!i.isLoading||n.isLoading)return;let r={skeletonOptions:null,skeletonSuggestion:null,skeletonRequested:!1};if(!n.skeletonExiting){this.store.set(r);return}let a=ss-(Date.now()-e);this.timers.schedule(Lo,()=>this.store.set(r),Math.min(ss,Math.max(0,a)))}))}subscribeNewParamTimer(){this.unsubscribers.push(this.store.subscribe((e,n)=>{e.newParamId&&e.newParamId!==n.newParamId&&this.timers.schedule(Zc,()=>this.store.set({newParamId:null}),td)}))}handleChange(e,n){let i=this.store.get();n&&e&&!i.text&&this.noteSearchStarted(),this.store.set({text:e,pillTapped:!1,activeDropdownIndex:-1});let{valid:o,invalid:r}=er(e,i.completedParams);r.length>0&&this.store.set({completedParams:o});let a=this.heldIdentified;this.heldIdentified=null,this.waitingIdentified?.text!==e&&(this.waitingIdentified=null),this.openWordText=n&&/\S$/.test(e)?e:null,this.maybePromoteExactMatch(e),a&&/^\s+$/.test(e.slice(a.text.length))&&e.startsWith(a.text)&&this.admitIdentified(a.candidates),this.maybeOpenPendingSpan();let s=this.store.get();s.multiSelectView&&s.optionQuery&&s.filteredOptions.length===0&&this.finishMultiSelect(s.optionQuery)}mirrorTypedIntoLocationSearch(){let e=this.store.get(),n=e.locationView;if(e.activeFormatType!=="location"||!n||!e.isDropdownOpen||e.locationFieldFocused)return;let i=Ki(e,e.optionQuery),r=e.editingParam!=null&&e.editingAnchor!=null?i.trim():Ro(i);r.length<Ke||r===n.query||this.setLocationQuery(r)}isWordOpen(){return this.opts.commitOnWordEnd===!0&&this.openWordText===this.store.get().text}admitIdentified(e){let n=this.store.get(),{valid:i}=Je(n.text,n.completedParams,e);i.length!==0&&this.store.set({identifiedParams:[...n.identifiedParams,...i]})}endTypedWord(e=!1){let n=this.isWordOpen();if(!n&&!e)return!1;let i=this.heldIdentified;this.heldIdentified=null,this.openWordText=null;let o=this.store.get();this.maybePromoteExactMatch(o.text,e?"submit":"fresh",n),i?.text===o.text&&this.admitIdentified(i.candidates);let r=this.waitingIdentified;e&&r?.text===o.text&&(this.waitingIdentified=null,this.admitIdentified(r.candidates));let a=this.store.get();return a.completedParams!==o.completedParams||a.identifiedParams!==o.identifiedParams}maybeOpenPendingSpan(){let e=this.store.get();if(e.pendingSpan||e.actionableSuggestions.length===0)return;let n=re(e.text,Math.min(e.filterBase,e.text.length),e.leadInText),i=jo(e.segments,n);e.text.slice(i).trim().length!==0&&this.store.set({pendingSpan:{anchor:i,snapshot:e.actionableSuggestions}})}maybeExitReEditOnNoMatch(){let e=this.store.get();if(!e.editingParam||e.editingAnchor==null||e.completedParams.some(r=>r.id===e.editingParam?.id)||this.optionSource.owns(e.editingParam.suggestionParameter,e.optionQuery))return;let n=e.caretOffset??e.editingAnchor,i=e.text.slice(e.editingAnchor,n);Se(e.editingParam.options,i).some(r=>r.is_tappable)||(this.reEdit.exit(),this.fetchNow())}fetchNow(){let e=this.store.get(),{rawQuery:n,completedParams:i}=N(e.text,e.completedParams);this.fetchController.doFetch(n,i)}commitIdentifiedDate(e){let n=this.store.get(),i=n.editingIdentified;if(!i)return;if(n.text.slice(i.anchor,i.tail)!==i.text){this.store.set({editingIdentified:null,activeDropdownIndex:-1});return}let o=n.text.slice(0,i.anchor),r=n.text.slice(i.tail),a=i.anchor===0&&e.text.length>0?e.text[0].toUpperCase()+e.text.slice(1):e.text,l=r.length===0||r[0]!==" "?`${a} `:a,d=o+l+r,c=d.length,u={id:crypto.randomUUID(),placeholder:"",parameter:i.parameter,text:a,value:e.value,kind:e.kind,suggestionParameter:i.parameter,suggestionPlaceholder:X(i.parameter),options:[],metadata:e.metadata,icon:e.icon,icon_svg:e.icon_svg,image_url:e.image_url};this.fireTelemetry("option",{raw_query:N(n.text,n.completedParams).rawQuery,selected_option:e.text,other_options:[],key:i.parameter,position:null,chip_origin:"tap"}),this.store.set({text:d,completedParams:[...n.completedParams,u],identifiedParams:n.identifiedParams.filter(p=>p.id!==i.id),newParamId:u.id,filterBase:c,caretOffset:c,editingIdentified:null,activeDropdownIndex:-1,pillTapped:!1,skipNextFetch:!0,inSelectionAnimation:!0}),this.startSelectionAnimationTimer(),this.scheduleSetCursor(c),this.fetchNow()}maybePromoteExactMatch(e,n="fresh",i=!1){let o=this.store.get();if(D(o.activeFormatType)||this.isWordOpen())return;let r=wn({mode:n,finishWord:i,text:e,completedParams:o.completedParams,suggestions:o.suggestions,filterBase:o.filterBase,filterInProgress:o.filterInProgress,phraseExactMatch:this.fetchController.isPhraseExactMatch(),prependPlaceholder:this.opts.prependPlaceholder});if(r){if(this.funnelTelemetry===!0){let a=n==="submit"&&r.suggestion?r.suggestion:o.actionableSuggestions[0],s=a.options??[];this.fireTelemetry("option",{raw_query:N(e,o.completedParams).rawQuery,selected_option:r.option.text,other_options:s.filter(l=>l.text!==r.option.text).map(l=>l.text),key:a.parameter,position:ce(s,r.option.text),chip_origin:"typed"})}this.store.set(r.patch)}}};0&&(module.exports={AIAutocomplete,ATTRIBUTION_URL,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,EDITOR_GROW_MS,LOCATION_META_KEY,LOCATION_MIN_QUERY,MULTI_DONE_FIT_VAR,MULTI_SELECT_TOGGLE_MIN_PX,MULTI_SELECT_TOGGLE_SLOP_PX,ModeController,OPTIONS_GRID_MOBILE_QUERY,OPTION_ENTER_DELAY_VAR,OPTION_ENTER_FADE_MS,OPTION_ENTER_RISE_MS,OPTION_ENTER_RISE_PX,OPTION_ENTER_STAGGER_MS,OPTION_IMAGE_WIDTH,PANEL_ENTER_DELAY_MS,PANEL_ENTER_MS,PANEL_GHOST_CLASS,PANEL_GLIDE_MS,PANEL_LEAVE_MS,PLACEHOLDER_FADE_OUT_MS,PLACEHOLDER_LEAVING_ATTR,PLACEHOLDER_SWAP_GAP_MS,PLACEHOLDER_TYPE_MS,PLACEHOLDER_WORD_PAUSE_MS,PRODUCT_IMAGE_WIDTH,PRODUCT_PATH_PREFIX,PRODUCT_ROW_PX_PER_LINE,RANGE_SEPARATOR,SCHEMA_VERSION,SCROLL_ARROW_ATTR,SCROLL_ARROW_BOTTOM_VAR,SCROLL_ARROW_CLASS,SCROLL_ARROW_FADE_MS,SCROLL_ARROW_LABEL,SCROLL_ARROW_SCROLL_IDLE_MS,SCROLL_ARROW_VISIBLE_ATTR,SKIPPED_PARAM_TEXT,SMART_SUGGESTION_SPARKLE_SVG,TIME_META_KEY,TIME_STEP_MINUTES,TIME_WHEEL_COLUMNS,TIME_WHEEL_ROW_HEIGHT,VIEWPORT_FIT_ATTR,VIEWPORT_FIT_HEIGHT_VAR,WEEKDAY_LABELS,addMonths,attachProductRowWheel,attachScrollArrow,attachViewportFit,buildAttributionUrl,buildDateOptions,buildLocationOption,buildQuery,buildSubmitResult,buildTimeOption,cellDay,cellIso,chipIdFromTap,computeOptionsGridLayout,containScroll,createStore,cursorIsAtEnd,dateCellMarks,dateFloorFor,dateSelectionFor,destroyPanelMorph,extractPlainText,findMultiSelectDone,fitMultiSelectDone,formatAbsoluteDate,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,getCursorOffset,getFooterHint,hasSkippablePill,highlightParts,identifiedParamLabel,inPanelGhost,isCalendarFormat,isDimmedDay,isMultiSelectToggleTap,isOptionsGridMobileViewport,isPickerFormat,isSmartSuggestion,isTraditionalAutocompleteSuggestion,isoDate,isoTime,keepCaretOnChip,labelTraditionalAutocomplete,locationEndpointFor,matchTypedPhrase,measureOptionsGrid,monthLabel,needsOptionsGridMeasurement,notePanelMorphHeight,optionCountLabel,optionEnterDelayMs,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsEntranceDurationMs,optionsGridTemplateColumns,optionsShowLeadingVisuals,panelMorphGlide,panelMorphKey,panelMorphTargetHeight,parseDate,parseLooseDate,parseLooseDateRange,parseTime,plainTextLength,planOptionsGrid,previousGraphemeBoundary,productFromMatchedItem,productImageSources,productImageSrc,productInitial,productPhotoFill,productRowWheelTarget,productsFromCustomFields,queryLive,releasePanelHug,renderEditableContent,resolveFormatType,resolveIdentifiedDate,sameOptionRows,sanitizeOptionIconSvg,scrollCaretIntoView,selectedIsoFromText,selectedRangeFor,setCursorOffset,settlePanelMorph,shopifyImageSrc,syncPanelHug,timeWheelIndex,timeWheelIndexFromScroll,timeWheelRows,toWireIdentifiedParams,typedFragment,uiStringsFor,visibleDateRange,watchEditorHeight,withSkippedParams,withTimeWheelIndex,withoutTraditionalAutocomplete});
|
|
3821
3766
|
//# sourceMappingURL=index.js.map
|