@occluze/tether 0.8.0 → 0.9.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 +5 -5
- package/dist/esm/astro.js +1 -1
- package/dist/esm/chunks/account-FKLGF264.js +1 -0
- package/dist/esm/chunks/{account-pages-XR6QZ3DX.js → account-pages-PNORWX72.js} +1 -1
- package/dist/esm/chunks/analytics-V24XX2J7.js +1 -0
- package/dist/esm/chunks/{chunk-255K6OZ7.js → chunk-2IHA3PVC.js} +1 -1
- package/dist/esm/chunks/chunk-2LYWZ72A.js +1 -0
- package/dist/esm/chunks/{chunk-3OEIEDTK.js → chunk-2NV5PSJ2.js} +1 -1
- package/dist/esm/chunks/chunk-2X5U24IC.js +1 -0
- package/dist/esm/chunks/chunk-5B36ISJF.js +1 -0
- package/dist/esm/chunks/chunk-6WE7XCHH.js +1 -0
- package/dist/esm/chunks/chunk-6ZIOAYKF.js +1 -0
- package/dist/esm/chunks/{chunk-FM7ZLLVP.js → chunk-CR5IGHCO.js} +1 -1
- package/dist/esm/chunks/{chunk-KNJB72OO.js → chunk-E3JL6WS3.js} +1 -1
- package/dist/esm/chunks/{chunk-KVPLRK6Y.js → chunk-F5CLIGSC.js} +1 -1
- package/dist/esm/chunks/{chunk-O4G2PAQC.js → chunk-GOKJQGLG.js} +1 -1
- package/dist/esm/chunks/chunk-RW23CJDZ.js +1 -0
- package/dist/esm/chunks/chunk-TW34GYSL.js +1 -0
- package/dist/esm/chunks/chunk-VKKKH75V.js +1 -0
- package/dist/esm/chunks/{chunk-A3GXCQJ4.js → chunk-YWQWLKFW.js} +1 -1
- package/dist/esm/chunks/chunk-YYNBHXQF.js +1 -0
- package/dist/esm/chunks/{diagnose-XQQTDHLQ.js → diagnose-3RTKEBNW.js} +1 -1
- package/dist/esm/chunks/extras-O54VUXK6.js +1 -0
- package/dist/esm/chunks/lists-MRTI5RXY.js +1 -0
- package/dist/esm/chunks/markets-ui-P7G33T6Y.js +1 -0
- package/dist/esm/chunks/search-YSRDFVD7.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/tether.account-pages.js +2 -2
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +2 -2
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +2 -2
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +4 -4
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +1 -1
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +83 -206
- package/dist/tether.lists.js +268 -0
- package/dist/tether.lists.min.js +1 -0
- package/dist/tether.markets.js +3 -3
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +1 -4
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +2 -2
- package/dist/tether.search.min.js +1 -1
- package/dist/types/src/client.d.ts +6 -6
- package/dist/types/src/collection.d.ts +7 -23
- package/dist/types/src/config-sections.d.ts +7 -0
- package/dist/types/src/config.d.ts +6 -0
- package/dist/types/src/index.d.ts +6 -5
- package/dist/types/src/lazy.d.ts +1 -0
- package/dist/types/src/lists.d.ts +20 -0
- package/dist/types/src/loader.d.ts +7 -27
- package/dist/types/src/mounting.d.ts +1 -6
- package/dist/types/src/product-shape.d.ts +13 -36
- package/dist/types/src/server.d.ts +5 -4
- package/dist/types/src/shopify-values.d.ts +6 -0
- package/dist/types/src/storefront/catalog.d.ts +2 -4
- package/dist/types/src/version.d.ts +1 -0
- package/package.json +5 -5
- package/dist/esm/chunks/account-5X563BON.js +0 -1
- package/dist/esm/chunks/analytics-JSFHDBU3.js +0 -1
- package/dist/esm/chunks/chunk-55OHYO66.js +0 -1
- package/dist/esm/chunks/chunk-EW3GKRT4.js +0 -1
- package/dist/esm/chunks/chunk-GXCCTPDF.js +0 -1
- package/dist/esm/chunks/chunk-J7GYROV4.js +0 -4
- package/dist/esm/chunks/chunk-WNFEYPHV.js +0 -1
- package/dist/esm/chunks/chunk-WXF4L42L.js +0 -1
- package/dist/esm/chunks/extras-6WLNUEGD.js +0 -1
- package/dist/esm/chunks/markets-ui-OAJW4PFU.js +0 -1
- package/dist/esm/chunks/search-LUECIYJR.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var b=Object.defineProperty;var Y=(n,e,t)=>e in n?b(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ln=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})};var Un=(n,e,t)=>Y(n,typeof e!="symbol"?e+"":e,t);var G=/^(\d{4})-(01|04|07|10)$/;function C(n){let e=G.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var S=n=>C(n)!==null,z=(n,e)=>`${n}-${String(e).padStart(2,"0")}`;function A(n,e=1){let t=C(n);if(!t)throw new Error(`not a quarterly Shopify API version: ${n}`);let o=t.year*4+(t.month-1)/3+e;return z(Math.floor(o/4),o%4*3+1)}function Fn(n,e=new Date){if(n==="unstable")return{version:n,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=C(n);if(!t)return{version:n,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),i=(r.getTime()-e.getTime())/2630016e3,f=o<=e,u=`supported until about ${r.toISOString().slice(0,7)}`;return f?i<=0?u="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":i<3&&(u=`${u}: plan the upgrade to ${A(n)} or later (see docs/reference.md)`):u="not released yet (release candidate at best)",{version:n,ok:f&&i>0,monthsLeft:Math.round(i),next:A(n),note:u}}function O(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function j(n,e){return O(n)?n[e]:void 0}function v(n){return Array.isArray(n)?n:[]}function Q(n){return typeof n=="string"&&n!==""?n:null}var Z=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Vn=n=>Z(n)??0,x=(n,e)=>v(n).map(t=>e(t)),Hn=(n,e)=>({nodes:x(j(n,"nodes"),e)}),Dn=n=>x(n,Q).filter(e=>e!==null);var B=/^[A-Z]{2}$/,W=new Set(["XX","T1"]),J=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),X=/^[A-Z]{2,3}$/;function h(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!B.test(e)||W.has(e)?null:e}function T(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(J.has(e))return e;let t=e.split("_")[0]??"";return X.test(t)?t:null}var E="2026-07";var q=/^[A-Za-z0-9_.-]+$/,nn=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,en=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,tn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,on=/^[A-Za-z_$][\w$]*$/,R="https://site.invalid",rn=new Set(["localhost","127.0.0.1","[::1]"]),N=["saved","server","webflow"],sn=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",an=n=>typeof n=="function";function P(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return fn(t)?t:(e("domain",n),"")}function M(n){if(!y(n))return!1;try{let e=new URL(n,`${R}/`);return e.origin===R?!0:e.protocol==="https:"||e.protocol==="http:"&&rn.has(e.hostname)}catch{return!1}}function L(n,e){return n==null||n===""?null:typeof n=="string"&&(M(n)||un(n))?n:(e("partsUrl",n),null)}function un(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function ln(n){if(typeof n!="string")return null;try{let e=new URL(n);return e.protocol==="https:"&&e.href===new URL(e.origin).href?e.origin:null}catch{return null}}function U(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=ln(r);i?t.push(i):e("embedOrigin",r)}return t}function cn(n){let e,t;if(typeof n=="string"){let o=n.indexOf(".");e=o>0?n.slice(0,o):"",t=n.slice(o+1)}else typeof n=="object"&&n!==null&&(e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key"));return typeof e!="string"||typeof t!="string"?null:nn.test(e)&&q.test(t)?{namespace:e,key:t}:null}function I(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=cn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var d=n=>e=>n(e)?e:void 0,fn=n=>y(n)&&en.test(n),dn=n=>y(n)&&tn.test(n),pn=n=>typeof n=="boolean"||y(n)&&on.test(n),g=d(M),k=d(y),_=d(n=>typeof n=="boolean"),F=d(an);function m(n,e,t,o){if(e==null)return null;if(!O(e))return o(n,e),null;let r={};for(let i in t){let f=e[i];if(f===void 0)continue;let u=t[i](f);u===void 0?o(`${n}.${i}`,f):r[i]=u}return r}var gn={server:g,orderUrl:g,subscriptionsUrl:g,paymentUrl:g,logoutUrl:g,locale:k,navigate:F},yn="customer accounts need the Worker since 0.7.0: set account.server",mn={country:k,language:k,locale:k},On={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?N.filter(t=>e.includes(t)):void 0},locales:n=>{if(!O(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,mn,()=>{});r&&(e[t]=r)}return e},cookie:d(dn),remember:_,strict:_},kn={consent:n=>sn.find(e=>e===n),proxy:n=>n!==void 0&&!!n},Cn={dataLayer:d(pn),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,kn,()=>{})??void 0,onEvent:F};function $(n,e,t){let o=m("account",n,gn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(yn),null):{...o,server:r}}var w=(n,e)=>m("markets",n,On,e),V=(n,e)=>m("analytics",n,Cn,e);var l={domain:"",token:"",apiVersion:E,country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],embedOrigins:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,revalidate:!0,storageKey:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},a={...l};function K(n){let e=t=>(c(`Tether.config is read-only (${String(t)}): pass options to Tether.init() instead`),!1);return new Proxy(n,{get(t,o){let r=Reflect.get(t,o);return typeof r=="object"&&r!==null?K(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var Xn=K(a),hn=/^[a-z][a-z0-9-]*$/,Tn=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],wn=["token","productPath","collectionPath","cartDrawerOpenClass"],bn=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock","searchDelay"],An=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function p(n,e,t){return e!==void 0&&c(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function s(n,e){c(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function Sn(n){for(let e of Object.keys(n))e in l||c(`unknown option ${JSON.stringify(e)}: ignored`)}function xn(n,e,t){typeof t=="function"?n[e]=t:t!=null&&s(e,t)}function En(n,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:p(n,e,l[n])}function Rn(n,e){return typeof e=="boolean"?e:p(n,e,l[n])}function _n(n,e){return typeof e=="string"?e:p(n,e,l[n])}function Nn(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}s("locale",n)}}function H(n,e,t){return t.find(o=>o===e)??p(n,e,t[0])}function Pn(n){return n==="unstable"?(c('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):S(n)?n:p("apiVersion",n,l.apiVersion)}function D(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;s(n,e)}function Mn(n){Sn(n);let e=P(n.domain,s),t=typeof n.prefix=="string"&&hn.test(n.prefix)?n.prefix:p("prefix",n.prefix,l.prefix),o={...l,domain:e,apiVersion:Pn(n.apiVersion),country:D("country",n.country,h),locale:Nn(n.locale),partsUrl:L(n.partsUrl,s),language:D("language",n.language,T),markets:w(n.markets,s),analytics:V(n.analytics,s),account:$(n.account,s,c),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:I(n.metafields??[],s),embedOrigins:U(n.embedOrigins??[],s),checkoutTarget:H("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:H("defaultPurchase",n.defaultPurchase,["one-time","subscription"])};for(let r of bn)o[r]=En(r,n[r]);for(let r of Tn)o[r]=Rn(r,n[r]);for(let r of wn)o[r]=_n(r,n[r]);for(let r of An)xn(o,r,n[r]);return o}var qn=n=>w(n,s);function ne(n={}){let e=Mn(n);for(let t of Object.keys(a))t in e||Reflect.deleteProperty(a,t);return Object.assign(a,e)}var ee=()=>!!(a.domain&&a.token);function te(...n){a.debug&&console.log(`[${a.prefix}]`,...n)}function c(...n){console.warn(`[${a.prefix}]`,...n)}function oe(n,e){if(c(e,n instanceof Error&&n.message?n.message:n),!!a.onError)try{a.onError(n,e)}catch(t){c("onError threw",t)}}function se(n){return n instanceof Error?n.message:String(n)}var ue={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function le(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function ce(n){return/^shp[a-z]{2}_/.test(n.trim())}function fe(n,e){if(!n)return"";let t=parseFloat(n.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:n.currencyCode}).format(t)}catch{return`${n.currencyCode} ${t.toFixed(2)}`}}function de(n,e,t){if(!/\{(handle|id)\}/.test(n))return e?`${n.replace(/\/$/,"")}/${encodeURIComponent(e)}`:null;let o=t?t.split("/").at(-1)??"":"";return n.includes("{handle}")&&!e||n.includes("{id}")&&!o?null:n.replace(/\{handle\}/g,encodeURIComponent(e??"")).replace(/\{id\}/g,encodeURIComponent(o))}function pe(n){let e=String(n??"").trim();return e?e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/Product/${e}`:/\/products\/([^/?#]+)/.exec(e)?.[1]??e:null}export{Ln as a,Un as b,Fn as c,O as d,j as e,v as f,Q as g,Z as h,Vn as i,x as j,Hn as k,Dn as l,N as m,cn as n,h as o,T as p,l as q,a as r,Xn as s,Mn as t,qn as u,ne as v,ee as w,te as x,c as y,oe as z,se as A,ue as B,le as C,ce as D,fe as E,de as F,pe as G};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as b,b as h,c as y,d as v,h as $}from"./chunk-EW3GKRT4.js";import{G as k,a as te,d as x,e as T,n as _,r as P,x as V}from"./chunk-GXCCTPDF.js";var de={};te(de,{GID:()=>Q,allPlans:()=>I,allocationFor:()=>M,findPlan:()=>ue,hasPlans:()=>oe,planAdjustment:()=>ce,planCheckoutCharge:()=>se,planPrice:()=>B,planSavings:()=>ae,plansForVariant:()=>le,toGid:()=>C});var re=/^(-?)(\d+)(?:\.(\d+))?$/;function G(e,n){let t=re.exec(e.trim());if(!t)return null;let[,r="",o="0",l=""]=t,u=BigInt(`${o}${l.padEnd(n,"0")}`);return r==="-"?-u:u}var L=e=>e.split(".")[1]?.length??0;function Fe(e,n){if(e==null||n==null)return!1;let t=Math.max(L(e.trim()),L(n.trim())),r=G(e,t),o=G(n,t);return r===null||o===null?!1:r>o}var q=2,U=new Map;function W(e){let n=U.get(e);if(n!==void 0)return n;let t=q;try{t=new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??q}catch{}return U.set(e,t),t}function O(e){return Math.round(parseFloat(e.amount)*10**W(e.currencyCode))}function K(e,n){let t=W(n);return{amount:(e/10**t).toFixed(t),currencyCode:n}}var ie=100;function C(e,n){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${n}/${t}`:t:null}var Q={product:e=>C(e,"Product"),variant:e=>C(e,"ProductVariant"),sellingPlan:e=>C(e,"SellingPlan")};function I(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function oe(e){return I(e).length>0}function M(e,n){return!e||!n?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===n)??null}function le(e,n){return I(e).filter(t=>M(n,t.id))}function B(e,n){let t=M(e,n)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function se(e,n){let t=M(e,n);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function ae(e,n){let t=B(e,n);if(!e||!t)return{amount:null,percentage:0};let r=parseFloat(e.price.amount),o=parseFloat(t.amount);if(!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o>=r)return{amount:null,percentage:0};let l=O(e.price)-O(t);return{amount:K(l,e.price.currencyCode),percentage:Math.round((1-o/r)*ie)}}function ce(e){let n=e?.priceAdjustments[0]?.adjustmentValue;if(!n)return null;switch(n.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:n.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:n.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:n.price};default:return null}}function ue(e,n){if(!n)return null;let t=I(e),r=Q.sellingPlan(n),o=n.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(u=>u.value.toLowerCase()===o))??null}var i="amount currencyCode",H={inventory:!0},Y=e=>e.inventory?"quantityAvailable":"",g="url altText width height";function pe(e){let n=[];for(let r of e){let o=_(r);o&&n.push(o)}return n.length?`metafields(identifiers:[${n.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${g}}}}}`:""}var ge=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${i}}}... on SellingPlanFixedPriceAdjustment{price{${i}}}}}`,me=` sellingPlan{id}checkoutChargeAmount{${i}}remainingBalanceChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}unitPrice{${i}}}`;function z(e=P,n=H){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${g}}images(first:${e.imagesFirst}){nodes{${g}}}options{name optionValues{name swatch{color image{previewImage{${g}}}}}}priceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}compareAtPriceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}${pe(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${ge}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${Y(n)} sku barcode selectedOptions{name value}image{${g}}price{${i}}compareAtPrice{${i}}unitPrice{${i}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${me}}}}}}`}function Ne(e=H){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${i}}totalAmount{${i}}checkoutChargeAmount{${i}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${i}}subtotalAmount{${i}}amountPerQuantity{${i}}compareAtAmountPerQuantity{${i}}}discountAllocations{discountedAmount{${i}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${Y(e)} image{${g}}price{${i}}compareAtPrice{${i}}selectedOptions{name value}product{id title handle vendor featuredImage{${g}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function J(){return`
|
|
2
|
-
id handle title description descriptionHtml
|
|
3
|
-
image { ${g} }
|
|
4
|
-
seo { title description }`}var N={amount:"string",currencyCode:"string"},f={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:N,maxVariantPrice:N},variants:{nodes:[{id:"string",price:N,selectedOptions:["object"]}]}},D={nodes:[f],pageInfo:{hasNextPage:"boolean"}},_e=e=>T(e,"id")!==""&&T(e,"handle")!==""&&h(e,f),X=e=>x(e)&&(e.id===void 0||h(e,f));var fe=1e4,Pe=6e4,c=new Map,E=new Map,m=new Set,F=new Map,ne=[],R=!1,A=0,Z=e=>e.startsWith("gid://"),j=k;function S(e){if(!e)return;let n=Promise.resolve(e);c.set(e.handle,n),c.set(e.id,n)}function he(e){let n=j(e);if(!n)return Promise.reject(new b("empty product key",{code:"NOT_FOUND"}));let t=c.get(n);if(t)return t;let r=new Promise((o,l)=>{E.set(n,{resolve:o,reject:l}),ne.push(n),R||(R=!0,setTimeout(()=>void Se(),0))});return c.set(n,r),r}var w=e=>n=>`${e}${z(P,n)}`;function ye(e){let n=e.filter(Z),t=e.filter(p=>!Z(p)),r=[],o=[],l={};return n.length&&(r.push("$ids: [ID!]!"),l.ids=n,o.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),t.forEach((p,s)=>{r.push(`$h${s}: String!`),l[`h${s}`]=p,o.push(`h${s}: product(handle: $h${s}) { ...TetherProduct }`)}),{query:w(`query TetherProducts(${r.join(",")}){${o.join(" ")}}`),variables:l,handles:t}}function ee(e,n){let t=E.get(e);E.delete(e),t&&n(t)}function $e(e,n){if(n!==A)return;let t=c.get(e);setTimeout(()=>{c.get(e)===t&&c.delete(e)},fe)}function Ae(e){if(!x(e))return!1;let{byId:n=[],...t}=e;return h(n,[y(X)])&&Object.values(t).every(y(f))}async function Se(){R=!1;let e=A,n=ne.splice(0);if(!n.length)return;let{query:t,variables:r,handles:o}=ye(n);V("fetch products",n);let l;try{l=await $(t,r,Ae)}catch(s){n.forEach(d=>{ee(d,a=>{e===A&&c.delete(d),a.reject(s)})});return}let u=new Map;for(let s of l.byId??[])s?.id&&u.set(s.id,s);o.forEach((s,d)=>{let a=l[`h${d}`];a&&u.set(s,a)});let p=Date.now();n.forEach(s=>{ee(s,d=>{let a=u.get(s);if(!a){$e(s,e),d.reject(new b(`Product not found: ${s}`,{code:"NOT_FOUND"}));return}e===A&&(S(a),F.set(a.handle,p),F.set(a.id,p)),d.resolve(a)})})}function Ke(){c.clear(),A+=1,m.clear(),F.clear()}function Qe(e){for(let n of e??[])!n.id||!n.handle||Date.now()-(F.get(n.handle)??0)<Pe&&c.has(n.handle)||(S(n),m.add(n.handle),m.add(n.id))}function Be(e){let n=j(e);return!n||!m.has(n)?!1:(m.delete(n),c.get(n)?.then(t=>{m.delete(t.handle),m.delete(t.id)},xe),!0)}function xe(){}function He(e){let n=j(e);return n&&c.delete(n),he(e)}var be=v({collection:y({handle:"string",products:D})}),ve=v({products:D}),Ce=v({productRecommendations:y([f])}),Ie=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${J()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,Me="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function Ye({collection:e,query:n,first:t=P.collectionFirst,after:r=null,sortKey:o,reverse:l=!1,filters:u}={}){if(e){let s=await $(w(Ie),{handle:e,first:t,after:r,sortKey:o||void 0,reverse:l,filters:u??void 0},be);if(!s.collection)throw new b(`Collection not found: ${e}`,{code:"NOT_FOUND"});let{products:d,...a}=s.collection;return d.nodes.forEach(S),{collection:a,products:d.nodes,pageInfo:d.pageInfo}}let p=await $(w(Me),{first:t,after:r,query:n||void 0,sortKey:o||void 0,reverse:l},ve);return p.products.nodes.forEach(S),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function ze(e,n="RELATED"){let t=j(typeof e=="object"?e?.id:e),r=t?.startsWith("gid://")??!1,l=(await $(w(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),r?{id:t,intent:n}:{handle:t,intent:n},Ce)).productRecommendations??[];return l.forEach(S),l}export{z as a,Ne as b,J as c,Fe as d,O as e,K as f,Q as g,I as h,M as i,B as j,se as k,ae as l,ce as m,ue as n,de as o,N as p,f as q,_e as r,X as s,j as t,S as u,he as v,Ke as w,Qe as x,Be as y,He as z,be as A,ve as B,Ce as C,Ye as D,ze as E};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e={diagnose:()=>import("./diagnose-XQQTDHLQ.js"),markets:()=>import("./markets-ui-OAJW4PFU.js"),search:()=>import("./search-LUECIYJR.js"),extras:()=>import("./extras-6WLNUEGD.js"),account:()=>import("./account-5X563BON.js"),"account-pages":()=>import("./account-pages-XR6QZ3DX.js"),analytics:()=>import("./analytics-JSFHDBU3.js")},a=t=>e[t](),r=void 0;export{a,r as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as k,b as z,c as B}from"./chunk-3OEIEDTK.js";import{b as g,d as y,g as l}from"./chunk-A3GXCQJ4.js";import{D as _,E as J,r as D,v as U,x as W,y as Q,z as Y}from"./chunk-J7GYROV4.js";import{E as K,F as C,H as w,K as F,M as q,a as H,l as u,m as c,n as s,o as P,p as N,q as A,t as d,w as O,y as I}from"./chunk-EW3GKRT4.js";import{b as m,d as M,o as b,p as $,r as p,x as v,y as x,z as h}from"./chunk-GXCCTPDF.js";var j="url:",T=()=>`${c("collection")},${c("products")},${c("recommendations")}`,et=t=>t instanceof window.Element,G=t=>parseInt(t??"",10)||void 0,ot=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",V=class{constructor(e){m(this,"root");m(this,"products",[]);m(this,"pageInfo",null);m(this,"collection",null);m(this,"loadToken",0);this.root=e,l(e,"loading"),e.addEventListener("click",o=>{if(!et(o.target))return;let n=o.target.closest(c("load-more"));n?.closest(T())===e&&(o.preventDefault(),q(n,()=>this.load(!0)))})}$(e){return A(this.root,e,T())}options(){let{root:e}=this,o={reverse:s(e,"reverse")==="true"},n=G(s(e,"limit"));n&&(o.first=n);let r=s(e,"sort");if(r&&(o.sortKey=r),P(e,"collection"))return o.collection=s(e,"collection")??"",o;let i=s(e,"products")??"";return o.query=i.startsWith(j)?new URL(window.location.href).searchParams.get(i.slice(j.length))||"":i,o}async loadRecommendations(){let{key:e}=g(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));if(!e&&o&&({key:e}=g(o)),!e)throw new H("No product for recommendations",{code:"NOT_FOUND"});return J(e,ot(s(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let o=this.loadToken,n=()=>o!==this.loadToken;try{if(P(this.root,"recommendations")){let r=await this.loadRecommendations();if(n())return;let i=G(s(this.root,"limit"));this.products=i?r.slice(0,i):r}else{let r=await _({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),l(this.root,"ready"),d("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(n())return;e||l(this.root,y(r)?"not-found":"error",r),y(r)&&P(this.root,"recommendations")||h(r,"list load failed"),d("error",{error:r,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(s(n,"collection-bind")??""){case"title":C(n,e?.title??"");break;case"description":K(n,e?.descriptionHtml);break;case"image":O(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":C(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{I(n,this.products,(r,i)=>{r.setAttribute(u("product"),i.handle),r.removeAttribute(u("state"))}),d("list-rendered",{container:n},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(n=>{let r=s(n,"show");r==="list-empty"&&w(n,o),r==="list-filled"&&w(n,!o)}),this.$(c("load-more")).forEach(n=>{w(n,!!this.pageInfo?.hasNextPage)}),F("list")}};var rt='script[type="application/json"][data-tether-hydrate]',L=new WeakSet,Ht=new WeakSet,E=new Set,X=new Set,Z=new WeakMap;function nt(){E.forEach(t=>{t.isConnected||E.delete(t)}),X.forEach(t=>{t.root.isConnected||X.delete(t)})}function it(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function st(t,e){let o=s(t,"page-title");!o||typeof document>"u"||(document.title=o.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ct(t,{fromUrl:e,raw:o}){e?(L.add(t),l(t,"not-found"),d("product-not-found",{key:null,source:o},t)):t.closest(T())||x(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function at(t,e,{fromUrl:o,raw:n},r){let i=y(r);if(l(t,i?"not-found":"error",r),!i){h(r,`product ${e}`),d("error",{error:r,context:"product",key:e},t);return}d("product-not-found",{key:e,source:n},t),o?v(`product not found: ${e}`):h(r,`product ${e}`)}function ut(t){if(L.has(t))return!1;let{key:e,...o}=g(t);if(!e)return ct(t,o),!1;L.add(t),E.add(t);let n={};Z.set(t,n);let r=()=>Z.get(t)===n;return k.get(t)?t.setAttribute(u("state"),"updating"):l(t,"loading"),mt(U(e)).then(f=>{if(!r())return;let R=k.get(t);R?R.update(f):new B(t,f),st(t,f),p.revalidate&&Q(e)&&dt(e)}).catch(f=>{r()&&at(t,e,o,f)}),!0}function Nt(){nt(),E.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(L.delete(t),ut(t))})}var S=new Set;function dt(t){S.size||setTimeout(ft,0),S.add(t)}function lt(t,e){E.forEach(o=>{let n=k.get(o);if(!n||!o.isConnected)return;let r=g(o).key;r!==t&&r!==e.handle&&r!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ft(){let t=[...S];S=new Set,t.forEach(e=>{Y(e).then(o=>{lt(e,o)}).catch(o=>{h(o,`refresh ${e}`)})})}var a=null,mt=t=>(a?.add(t),t);function pt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){pt();return}a=null,document.documentElement.classList.remove(`${p.prefix}-market-pending`)}})}function ht(t){if(!M(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,o=Array.isArray(e)?e:[];return{country:b(t.country)??void 0,language:$(t.language)??void 0,products:o.filter(D)}}var tt=new WeakSet;function At(t=document){it(t,rt).forEach(e=>{if(tt.has(e))return;tt.add(e);let o;try{o=JSON.parse(e.textContent)}catch(f){x("bad data-tether-hydrate",f);return}let{country:n,language:r,products:i}=ht(o);if(z(i),n===p.country&&r===p.language){W(i);return}v("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${p.prefix}-market-pending`))})}export{T as a,V as b,L as c,Ht as d,E as e,X as f,nt as g,it as h,ut as i,Nt as j,mt as k,pt as l,At as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as v}from"./chunk-KVPLRK6Y.js";import{a as b,b as S}from"./chunk-O4G2PAQC.js";import{a as k}from"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import"./chunk-WNFEYPHV.js";import{h as p}from"./chunk-55OHYO66.js";import"./chunk-J7GYROV4.js";import{N as h,O as w,m as l,n as f,o as g,p as d,t as y}from"./chunk-EW3GKRT4.js";import{r as s,y as m,z as u}from"./chunk-GXCCTPDF.js";function U(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(l("group"));if(!r)return null;let e=f(r,"group"),n=U(r,e),i=d(r,l("product")).flatMap(a=>{let o=k.get(a);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let c=o.getLine();return c?[{...c,attributes:[...c.attributes??[],...n]}]:[]});if(!i.length)return m("group-add: nothing selected"),null;try{let a=await p.add(i);return y("group-added",{group:e,lines:i},r),a}catch(a){return u(a,"group add"),null}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{u(n,"cart from another tab")});return}if(t.key!==b()||!t.newValue)return;let r=S(t.newValue);if(!r)return;let e={language:r.language??null,locale:r.locale,remember:!1};v(r.country,e).catch(n=>{u(n,"market from another tab")})}var E=new WeakMap,K=t=>t.split("/").pop()??t;function x(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:r,sellingPlanId:e}){let n=`${r.id}|${e??""}`,i=E.get(t);if(E.set(t,n),!i||i===n)return;let a=s.variantUrl&&document.querySelector(l("product"))===t;if(!g(t,"variant-url")&&!a)return;let o=new URL(window.location.href);o.searchParams.set("variant",K(r.id)),e?o.searchParams.set("selling_plan",K(e)):o.searchParams.delete("selling_plan"),x(o)}export{V as addGroup,_ as onStorage,$ as writeVariantUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E,c as P,e as k,f as T,g as A,h as p,i as x}from"./chunk-WXF4L42L.js";import{d as F,e as I}from"./chunk-O4G2PAQC.js";import"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import{h as u}from"./chunk-55OHYO66.js";import{w}from"./chunk-J7GYROV4.js";import{a as L,d as h,h as b,l as s,m as C,n as v,t as z}from"./chunk-EW3GKRT4.js";import{o as f,p as g,r as a,z as y}from"./chunk-GXCCTPDF.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),A(),T.forEach(o=>n.push(o.load())),k.forEach(o=>{o.closest(E())||(P.delete(o),x(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&I({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as M}from"./chunk-WXF4L42L.js";import"./chunk-3OEIEDTK.js";import"./chunk-255K6OZ7.js";import"./chunk-A3GXCQJ4.js";import"./chunk-55OHYO66.js";import"./chunk-J7GYROV4.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-EW3GKRT4.js";import{b as a,r as u,x as b,z as y}from"./chunk-GXCCTPDF.js";var N=E({predictiveSearch:S({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(A("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await T(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};
|