PageSourceSearch

https://empirerugs.com/cdn/shopifycloud/checkout-web/assets/c1/d22d2b80.BRIhtVxA.js

js empirerugs.com collected 2026-10-10 02:17:25 UTC 12,998 bytes, 1 lines download raw bytes

1import{q as e,T as t,C as s,g as n,h as o}from"./2c1ab0fe.qpvfywqb.js";import{e as r,dD as d,E as i,b as a,dE as c,an as u,aQ as p,o as l,y as f,dF as m,dG as g}from"./4b4bc88f.DkycdxSK.js";import{p as y,s as h,a as b,b as v}from"./f58f39d8.z0CUAjnp.js";import{s as A}from"./74835653.Cr7sKbVy.js";import{u as w}from"./a9fa9fda.BO9gwssW.js";import{cD as $,h as C,ez as I,o as k,d6 as S}from"./164ad2e3.DcJn775M.js";import{A as q}from"./60a453ce.DBFo6PRx.js";function x(e){return new Promise((t,s)=>{C(e.approvalScopes,q.CustomerPersonalData)||s(new d(`Extension ${e.id} at target \`${e.extensionPoint.target}\` is missing required access to read customer personal data.`)),t()})}function P(e,t,s){switch(!0){case e instanceof d:T(e,t);break;case e instanceof i:if("persisted"===t.type)T(e,t);else{const{extensionPoint:{target:n}}=t;s(new i(`[${n}] ${e.message}`))}break;default:s(e)}}function T(e,t){const s=`[${t.extensionPoint.target}] ${e.name}: ${e.message}`;console.error(s)}function E(e,t){const s={...e};return h(t)||delete s.addressLineComponents,b(t)||delete s.addressCode,s}function j(e,t){return e&&y(t)?{acceptedAddressInputFields:e}:{}}function M(e){return e?.length?e.sort(R):[{offset:0,length:0}]}function R(e,t){return e.offset-t.offset}function L(e,t){if("object"!=typeof e)throw new i("formattedAddress must be an object: received type "+typeof e);const s=E(e,t),n=z(s);if(n.length)throw new i(n.join("; "));return s}function z(e){const t=[],{address1:s,address2:n,city:o,company:r,provinceCode:d,zip:i,countryCode:c,latitude:u,longitude:p,addressLineComponents:l,addressCode:f}=e;if(s&&!N(s)&&t.push(`address1 must be a non-empty string: received type ${typeof s} in formattedAddress`),n&&!N(n)&&t.push(`address2 must be a non-empty string: received type ${typeof n} in formattedAddress`),o&&!N(o)&&t.push(`city must be a non-empty string: received type ${typeof o} in formattedAddress`),r&&!N(r)&&t.push(`company must be a non-empty string: received type ${typeof r} in formattedAddress`),d&&!N(d)&&t.push(`provinceCode must be a non-empty string: received type ${typeof d} in formattedAddress`),i&&!N(i)&&t.push(`zip must be a non-empty string: received type ${typeof i} in formattedAddress`),c&&!a(c)&&t.push(`countryCode must be a valid alpha-2 country code: received "${c}" in formattedAddress`),u&&("number"!=typeof u?t.push(`latitude must be a number: received type ${typeof u} in formattedAddress`):(u<-90||u>90)&&t.push(`latitude must be between -90 and 90: received ${u} in formattedAddress`)),l)if("object"!=typeof l||Array.isArray(l))t.push(`addressLineComponents must be an object: received type ${typeof l} in formattedAddress`);else for(const[a,m]of Object.entries(l))void 0===m||N(m)||t.push(`${a} must be a non-empty string: received type ${typeof m} in addressLineComponents`);return f&&!N(f)&&t.push(`addressCode must be a non-empty string: received type ${typeof f} in formattedAddress`),p&&("number"!=typeof p?t.push(`longitude must be a number: received type ${typeof p} in formattedAddress`):(p<-180||p>180)&&t.push(`longitude must be between -180 and 180: received ${p} in formattedAddress`)),t}function N(e){return("string"==typeof e||e instanceof String)&&e.trim().length>0}const _="address_clobber";function O(e){try{return e()}catch{return}}function V({addressType:d,countryCode:a,field:y,initialAddressQuery:h="",provider:b="autocomplete-service",allowAllCountries:C}){const{i18n:{locale:q},observability:T,userEvents:R,shop:V,source:Q,checkout:{address:U}}=r(),{id:F}=V,[B,X]=s(h),[H,J]=s(B),[K,W]=s(!1),[Y,Z]=s([]),[ee,te]=s([]),se=n(!1),[ne,oe]=s(D(Q.sourceId)
1),{geolocation:re}=$(),{search:de,fetchAddress:ie}=w(),ae=S(),{details:ce}=u(a),ue=p(),pe=null!==U.extendedAddressMode.get(a),le=e(()=>v({country:ce,extendedAddressMode:U.extendedAddressMode}),[U.extendedAddressMode,ce]),fe="pickup"===d?"google":void 0,me=n(void 0);me.current??=function({addressType:e,field:t,log:s,now:n=Date.now}){let o,r,d=0,i=0,a=0,c=0,u=!1,p=20,l=20;const f=(n,o)=>s(_,`${_}: ${n}`,{kind:n,addressType:e??"unknown",field:t??"unknown",...o});return{recordQuery(e){e!==o&&(o=e,c+=1)},resetPredictionContext(){r=void 0,u=!1},startPredictionRequest:()=>[c,++d,n()],recordPredictionResponse([e,t,s],o){const d=t<i,a=i;i=Math.max(i,t),r=e,u=d,d&&0!==p&&(p-=1,f("prediction-race",{latestAppliedPredictionGeneration:a,predictionCount:o,queryChangedSinceRequest:e!==c,requestGeneration:t,responseAgeMs:Math.max(0,n()-s)}))},startAddressRequest:()=>[c,++a,u||void 0!==r&&r!==c,n()],recordAddressResponse([e,t,s,o]){const r=t!==a,d=e!==c;(r||d||s)&&0!==l&&(l-=1,f("address-race",{latestRequestGeneration:a,newerSelectionStarted:r,queryChangedSinceSelection:d,requestGeneration:t,responseAgeMs:Math.max(0,n()-o),selectedFromStalePredictionResponse:s}))}}}({addressType:d,field:y,log:(e,t,s)=>T.log(e,t,s)});const ge=me.current,ye=k("purchase.address-autocomplete.suggest"),he=t(()=>ye.map(l),[ye]),be=function(s){const n=I(s),o=t(()=>s[0],[s]);return e((e,t,s)=>o?new Promise((r,d)=>{t.aborted&&d(new c(t.reason)),x(o).then(()=>n({signal:t,target:{...e,...j(s,o.apiVersion)}})).then(e=>e?.suggestions||[]).then(e=>function(e,t){const s=[];if(!Array.isArray(e))throw new i("An array of address suggestions must be defined");const n=e.slice(0,5);for(const[o,{id:r,label:d,matchedSubstrings:a,formattedAddress:c}]of n.entries()){if(N(d)||s.push(`label is required and must be a non-empty string: received ${typeof d} in suggestions[${o}]`),r&&!N(r)&&s.push(`id must be a non-empty string: received ${typeof r} in suggestions[${o}]`),a)if(Array.isArray(a))for(const[e,{offset:t,length:n}]of a.entries())"number"!=typeof t&&s.push(`offset must be a number: received type ${typeof t} in matchedSubstrings[${e}] for suggestions[${o}]`),"number"!=typeof n&&s.push(`length must be a number: received type ${typeof n} in matchedSubstrings[${e}] for suggestions[${o}]`);else s.push(`matchedSubstrings must be an array: received type ${typeof a} in suggestions[${o}]`);if(c)if("object"==typeof c){const e=z(E(c,t));for(const t of e)s.push(`${t} for suggestions[${o}]`)}else s.push(`formattedAddress must be an object: received type ${typeof c} in suggestions[${o}]`);if(s.length)throw new i(s.join("; "))}return n}(e,o.apiVersion)).then(e=>function(e,t){return e.map((e,s)=>{const{id:n,label:o,matchedSubstrings:r,formattedAddress:d}=e;return{internalId:`extension-suggestion-${s}`,matchedSubstrings:M(r),label:o,...n&&{id:n},...d&&{formattedAddress:E(d,t)}}})}(e,o.apiVersion)).then(e=>r(e)).catch(e=>{P(e,o,d),r([])}),t.addEventListener("abort",()=>{d(new c(t.reason))})}):Promise.resolve([]),[n,o])}(he),ve=t(()=>he.length>0,[he]),Ae=k("purchase.address-autocomplete.format-suggestion"),we=t(()=>Ae.map(l),[Ae]),$e=function(s){const n=I(s),o=t(()=>s[0],[s]),r=k("purchase.address-autocomplete.suggest"),d=t(()=>r.length>0,[r]);return e((e,t)=>o?new Promise((s,r)=>{(function(e){return new Promise((t,s)=>{e?t():s(new i("A purchase.address-autocomplete.suggest extension is required for a purchase.address-autocomplete.format-suggestion extension"))})})(d).then(()=>x(o)).then(()=>{const{internalId:s,...r}=e,d={target:{selectedSuggestion:r,...j(t,o.apiVersion)}};return n(d)}).then(e=>{s({formattedAddress:L(e?.formattedAddress||{},o.apiVersion)})}).catch(e=>{P(e,o,r),s({formattedAddress:{}})})}):Promise.resolve({formattedAddress:{}}),[n,o,d])}(we),Ce=t(()=>we.length>0,[we]),Ie=e((e,t,s,n)=>{const o=ue.value.defaultAttributes?.uniqToken||"";R.monorailEvent({schemaId:"checkout_autocomplete_suggestion/5.1",payload:{shopId:parseInt(f(F),10),checkoutToken:Q.checkoutSessionIdentifier||"",uniqueToken:o,provider:t[0]?.completionService??"",context:"shipping"===e?"Shipping address":"Billing address",territoryCode:a??re.country.code,locale:q,query:s,sessionToken:ne,requestProvider:n,requestLatitude:re.coordinates?.latitude,requestLongitude:re.coordinates?.longitude,addressIds:t.map(e=>e.addressId)}})},[a,re.country.code,q,ne,F,Q.checkoutSessionIdentifier,ue.value.defaultAttributes?.uniqToken,R,re.coordinates]),ke=t(()=>ve&&y&&G(d),[y,d,ve]),Se=t(()=>ke||C||A(a||re.country.code),[C,a,re.country.code,ke]);o(()=>{const e=setTimeout(()=>{ae&&J(B)},300);return()=>{clearTimeout(e)}},[ae,B]),o(()=>{O(()=>ge.recordQuery(h)),X(h)},[h,ge]),o(()=>{Se||Z([])},[Se]);const qe=n(a);o(()=>{qe.current!==a&&void 0!==qe.current&&(Z([]),te([]),se.current=!1),qe.current=a},[a]);const xe=function(t){const{observability:s}=r(),{geolocation:n}=$();return e(async(e,o,r)=>{const d=await t(e,o,r);return s.histogram({name:"prediction_duration",value:d.duration.end-d.duration.start,attributes:{buyerCountry:n.country.code}}),d.data},[t,s,n.country.code])}(de);o(()=>{let e=!1;if(Se&&K){const[t]=he;if(t&&y&&G(d)){const s=new AbortController;return async function({activeExtension:t,query:s,field:n,signal:o}){if(!s||"string"!=typeof s||s.length<=1)return O(()=>ge.resetPredictionContext()),te([]),void Z([]);try{const t=O(()=>ge.startPredictionRequest()),r=await be({value:s,field:function(e){switch(e){case"address1":case"streetName":return"address1";case"postalCode":return"zip";
1default:throw new m(`Unknown Address Autocomplete field: ${e}`)}}(n),selectedCountryCode:a},o,le());ae.current&&!e&&(t&&O(()=>ge.recordPredictionResponse(t,r.length)),te(r),Z(function(e){return e.map(({label:e,matchedSubstrings:t,internalId:s})=>({addressId:s,completionService:"AUTOCOMPLETE_EXTENSION",description:e,matchedSubstrings:t}))}(r)))}catch(r){if(r instanceof m&&T.error(r),"local"===t.type){if(!(r instanceof c))throw r;console.warn("AddressAutocompleteSignalAbortedError: ",r.message)}}}({activeExtension:t,query:H,field:y,signal:s.signal}),()=>{e=!0,s.abort("The query was debounced")}}!async function(t){try{if(!t||"string"!=typeof t||t.length<=1)return O(()=>ge.resetPredictionContext()),void Z([]);const s=O(()=>ge.startPredictionRequest()),n=await xe(t,{locale:q,countryCode:a??re.country.code,location:re.coordinates,requestToken:ne,shopId:f(F),sourceId:Q.sourceId||"",checkoutSessionIdentifier:Q.checkoutSessionIdentifier||""},fe);ae.current&&!e&&(s&&O(()=>ge.recordPredictionResponse(s,n.length)),Z(n),!se.current&&G(d)&&(Ie(d,n,t,fe),se.current=!0))}catch(s){console.warn(`Unable to fetch predictions: ${s}`),ae.current&&!e&&Z([])}}(H)}return()=>{e=!0}},[a,H,q,ne,Ie]);const Pe=e((e,t,s,n,o)=>{const r=ce?.zones.find(e=>e.code===t.zoneCode)?.name||void 0,d=ue.value.defaultAttributes?.uniqToken,i=s.findIndex(t=>t.addressId===e)+1;R.monorailEvent({schemaId:"checkout_autocomplete_selection/6.2",payload:{shopId:parseInt(f(F),10),checkoutToken:Q.checkoutSessionIdentifier||"",uniqueToken:d,address1:t.address1,address2:t.address2,city:t.city,zone:r,latitude:t.coordinates?.latitude,longitude:t.coordinates?.longitude,zip:t.postalCode,territoryCode:a??re.country.code,position:i,query:H,context:"shipping"===n?"Shipping address":"Billing address",locale:q,sessionToken:o,requestLatitude:re.coordinates?.latitude,requestLongitude:re.coordinates?.longitude}})},[ce,ue.value.defaultAttributes?.uniqToken,F,Q.checkoutSessionIdentifier,a,re.country.code,re.coordinates,H,q,R]),Te=e(async(e,t,s,n)=>{const o=O(()=>ge.startAddressRequest());try{let r,c;if("AUTOCOMPLETE_EXTENSION"===t)r=await async function(e){const t=function(e){const t=ee.find(t=>t.internalId===e);return t||T.error(new g("Could not find selected suggestion in extension suggestions.")),t}(e),s=le();return function(e,t,s){const n=e?.addressLineComponents,o=e=>t?.includes(e)?n?.[e]:void 0;return{address1:e?.address1,address2:e?.address2,city:e?.city,company:e?.company,zoneCode:e?.provinceCode,postalCode:e?.zip,coordinates:e?.latitude&&e?.longitude?{latitude:e.latitude,longitude:e.longitude}:void 0,streetName:n?.streetName,streetNumber:n?.streetNumber,line2:n?.additionalInformation,..."dedicated"===s?{district:o("district")}:{neighborhood:o("district")},subdistrict:o("subdistrict")}}(t?.formattedAddress||await async function(e,t){if(Ce&&e)return(await $e(e,t)).formattedAddress;const s=new i("The address fields could not be auto-populated. Please provide a `formattedAddress` for the selected suggestion or implement the `purchase.address-autocomplete.format-suggestion` extension.");console.error(`${s.name}: ${s.message}`)}(t,s),s,U.extendedAddressMode.get(a))}(e);else{const n=ne;r=await ie(e,{locale:q,requestToken:ne,completionService:t,shopId:f(F),sourceId:Q.sourceId||"",checkoutSessionIdentifier:Q.checkoutSessionIdentifier||"",extendedFields:!s&&pe}
1),c=n,ae.current&&(oe(D(Q.sourceId)),G(d)&&Pe(e,r,Y,d,n))}ae.current&&(o&&O(()=>ge.recordAddressResponse(o)),n(r,c))}catch(r){if(r instanceof i)throw r;console.warn(`Unable to select prediction: ${r}`)}},[q,ne,F,Q.sourceId,Q.checkoutSessionIdentifier,ie,ae,d,Pe,Y,Ce,ee,$e,T,pe,ge,le,U.extendedAddressMode,a]),Ee=e((e,t=!0)=>{O(()=>ge.recordQuery(e)),X(e),W(t)},[ge]);return{value:B,debouncedValue:H,setValue:Ee,predictions:Y,selectPrediction:Te,provider:b}}function D(e){return`${e}-${Date.now()}`}function G(e){return"billing"===e||"shipping"===e}export{V as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.