@occluze/tether 0.6.8 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +28 -28
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
  4. package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
  5. package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
  6. package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
  7. package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
  8. package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
  9. package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
  10. package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
  11. package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
  12. package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
  13. package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
  14. package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
  15. package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
  16. package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
  17. package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
  18. package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
  19. package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
  20. package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
  21. package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
  22. package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/server.js +2 -2
  25. package/dist/presets/barba.esm.js +19 -23
  26. package/dist/tether.account-pages.js +332 -367
  27. package/dist/tether.account-pages.min.js +1 -1
  28. package/dist/tether.account.js +253 -492
  29. package/dist/tether.account.min.js +1 -1
  30. package/dist/tether.analytics.js +82 -89
  31. package/dist/tether.analytics.min.js +1 -1
  32. package/dist/tether.diagnose.js +52 -34
  33. package/dist/tether.diagnose.min.js +2 -2
  34. package/dist/tether.extras.js +42 -37
  35. package/dist/tether.extras.min.js +1 -1
  36. package/dist/tether.js +1361 -935
  37. package/dist/tether.markets.js +89 -91
  38. package/dist/tether.markets.min.js +1 -1
  39. package/dist/tether.min.js +0 -0
  40. package/dist/tether.min.js.map +4 -4
  41. package/dist/tether.search.js +60 -69
  42. package/dist/tether.search.min.js +1 -1
  43. package/dist/types/server/src/shared/account-orders.d.ts +44 -0
  44. package/dist/types/server/src/shared/account-routes.d.ts +153 -0
  45. package/dist/types/server/src/shared/api-versions.d.ts +13 -0
  46. package/dist/types/server/src/shared/cart-id.d.ts +2 -0
  47. package/dist/types/server/src/shared/error-message.d.ts +2 -0
  48. package/dist/types/server/src/shared/json.d.ts +25 -0
  49. package/dist/types/server/src/shared/market-codes.d.ts +16 -0
  50. package/dist/types/src/account/addresses-view.d.ts +5 -0
  51. package/dist/types/src/account/answers.d.ts +40 -0
  52. package/dist/types/src/account/markup.d.ts +19 -0
  53. package/dist/types/src/account/operations.d.ts +41 -0
  54. package/dist/types/src/account/order-lines.d.ts +13 -0
  55. package/dist/types/src/account/order-list.d.ts +12 -0
  56. package/dist/types/src/account/order-page.d.ts +6 -0
  57. package/dist/types/src/account/page-answers.d.ts +182 -0
  58. package/dist/types/src/account/page-events.d.ts +2 -0
  59. package/dist/types/src/account/server-client.d.ts +60 -0
  60. package/dist/types/src/account/subscriptions-view.d.ts +2 -0
  61. package/dist/types/src/account-api.d.ts +18 -0
  62. package/dist/types/src/account-marks.d.ts +15 -0
  63. package/dist/types/src/account-pages.d.ts +8 -0
  64. package/dist/types/src/account.d.ts +64 -0
  65. package/dist/types/src/amounts.d.ts +12 -0
  66. package/dist/types/src/analytics-shopify.d.ts +41 -0
  67. package/dist/types/src/analytics.d.ts +2 -0
  68. package/dist/types/src/api-version.d.ts +28 -0
  69. package/dist/types/src/astro.d.ts +42 -0
  70. package/dist/types/src/cart/cart-shape.d.ts +43 -0
  71. package/dist/types/src/cart/checkout.d.ts +16 -0
  72. package/dist/types/src/cart/drawer.d.ts +18 -0
  73. package/dist/types/src/cart/mutations.d.ts +85 -0
  74. package/dist/types/src/cart/render.d.ts +17 -0
  75. package/dist/types/src/cart/store.d.ts +185 -0
  76. package/dist/types/src/cart.d.ts +106 -0
  77. package/dist/types/src/client.d.ts +134 -0
  78. package/dist/types/src/collection.d.ts +25 -0
  79. package/dist/types/src/config-sections.d.ts +40 -0
  80. package/dist/types/src/config.d.ts +190 -0
  81. package/dist/types/src/controls/cart-controls.d.ts +2 -0
  82. package/dist/types/src/controls/discount.d.ts +2 -0
  83. package/dist/types/src/controls/extras.d.ts +5 -0
  84. package/dist/types/src/controls/navigation.d.ts +12 -0
  85. package/dist/types/src/diagnose-markup.d.ts +19 -0
  86. package/dist/types/src/diagnose.d.ts +60 -0
  87. package/dist/types/src/dom.d.ts +75 -0
  88. package/dist/types/src/extras.d.ts +21 -0
  89. package/dist/types/src/fragments.d.ts +158 -0
  90. package/dist/types/src/globals.d.ts +15 -0
  91. package/dist/types/src/images.d.ts +20 -0
  92. package/dist/types/src/index.d.ts +167 -0
  93. package/dist/types/src/initial.d.ts +56 -0
  94. package/dist/types/src/lazy.d.ts +28 -0
  95. package/dist/types/src/loader.d.ts +84 -0
  96. package/dist/types/src/market-codes.d.ts +6 -0
  97. package/dist/types/src/markets-ui.d.ts +32 -0
  98. package/dist/types/src/markets.d.ts +72 -0
  99. package/dist/types/src/markup.d.ts +131 -0
  100. package/dist/types/src/mounting.d.ts +46 -0
  101. package/dist/types/src/page-market.d.ts +27 -0
  102. package/dist/types/src/presets/barba.d.ts +56 -0
  103. package/dist/types/src/product-events.d.ts +2 -0
  104. package/dist/types/src/product-render.d.ts +17 -0
  105. package/dist/types/src/product-shape.d.ts +90 -0
  106. package/dist/types/src/product-state.d.ts +110 -0
  107. package/dist/types/src/product.d.ts +66 -0
  108. package/dist/types/src/repeaters.d.ts +16 -0
  109. package/dist/types/src/search.d.ts +33 -0
  110. package/dist/types/src/selling-plans.d.ts +64 -0
  111. package/dist/types/src/server.d.ts +88 -0
  112. package/dist/types/src/shopify-values.d.ts +46 -0
  113. package/dist/types/src/status.d.ts +33 -0
  114. package/dist/types/src/storage.d.ts +12 -0
  115. package/dist/types/src/store-html.d.ts +39 -0
  116. package/dist/types/src/storefront/catalog.d.ts +38 -0
  117. package/dist/types/src/storefront/json-ld.d.ts +20 -0
  118. package/dist/types/src/variant-render.d.ts +14 -0
  119. package/package.json +24 -24
  120. package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
  121. package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
  122. package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
  123. package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
  124. package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
  125. package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
  126. package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
  127. package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
  128. package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
  129. package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
  130. package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
  131. package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
  132. package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
  133. package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
  134. package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
  135. package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
  136. package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
  137. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
  138. package/dist/esm/chunks/search-OU75RNQL.js +0 -1
  139. package/src/account/addresses-view.js +0 -92
  140. package/src/account/browser-session.js +0 -359
  141. package/src/account/markup.js +0 -48
  142. package/src/account/operations.js +0 -180
  143. package/src/account/order-lines.js +0 -96
  144. package/src/account/order-list.js +0 -91
  145. package/src/account/order-page.js +0 -192
  146. package/src/account/page-events.js +0 -288
  147. package/src/account/server-client.js +0 -172
  148. package/src/account/shared.js +0 -111
  149. package/src/account/shopify-auth.js +0 -150
  150. package/src/account/subscriptions-view.js +0 -158
  151. package/src/account-api.js +0 -118
  152. package/src/account-links.js +0 -35
  153. package/src/account-pages.js +0 -89
  154. package/src/account.js +0 -342
  155. package/src/amounts.js +0 -36
  156. package/src/analytics-shopify.js +0 -241
  157. package/src/analytics.js +0 -352
  158. package/src/api-version.js +0 -85
  159. package/src/astro.js +0 -266
  160. package/src/cart/checkout.js +0 -97
  161. package/src/cart/drawer.js +0 -138
  162. package/src/cart/mutations.js +0 -234
  163. package/src/cart/render.js +0 -294
  164. package/src/cart/store.js +0 -326
  165. package/src/cart.js +0 -391
  166. package/src/client.js +0 -267
  167. package/src/collection.js +0 -183
  168. package/src/config.js +0 -349
  169. package/src/controls/cart-controls.js +0 -155
  170. package/src/controls/discount.js +0 -96
  171. package/src/controls/extras.js +0 -63
  172. package/src/controls/navigation.js +0 -83
  173. package/src/diagnose-markup.js +0 -333
  174. package/src/diagnose.js +0 -295
  175. package/src/dom.js +0 -287
  176. package/src/extras.js +0 -145
  177. package/src/fragments.js +0 -237
  178. package/src/images.js +0 -104
  179. package/src/index.js +0 -353
  180. package/src/initial.js +0 -87
  181. package/src/lazy-iife.js +0 -116
  182. package/src/lazy.js +0 -39
  183. package/src/loader.js +0 -337
  184. package/src/market-codes.js +0 -35
  185. package/src/markets-ui.js +0 -204
  186. package/src/markets.js +0 -334
  187. package/src/markup.js +0 -64
  188. package/src/mounting.js +0 -277
  189. package/src/page-market.js +0 -116
  190. package/src/parts/account-pages.js +0 -6
  191. package/src/parts/account.js +0 -6
  192. package/src/parts/analytics.js +0 -6
  193. package/src/parts/diagnose.js +0 -6
  194. package/src/parts/extras.js +0 -6
  195. package/src/parts/markets.js +0 -6
  196. package/src/parts/search.js +0 -6
  197. package/src/presets/barba.js +0 -190
  198. package/src/product-events.js +0 -130
  199. package/src/product-render.js +0 -257
  200. package/src/product-state.js +0 -318
  201. package/src/product.js +0 -344
  202. package/src/repeaters.js +0 -173
  203. package/src/search.js +0 -323
  204. package/src/selling-plans.js +0 -154
  205. package/src/server.js +0 -215
  206. package/src/shopify-values.js +0 -89
  207. package/src/status.js +0 -126
  208. package/src/store-html.js +0 -0
  209. package/src/storefront/catalog.js +0 -199
  210. package/src/storefront/json-ld.js +0 -167
  211. package/src/variant-render.js +0 -165
  212. package/types/astro.d.ts +0 -28
  213. package/types/barba.d.ts +0 -16
  214. package/types/index.d.ts +0 -577
  215. package/types/server.d.ts +0 -182
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as k}from"./chunks/chunk-27PJJZGC.js";import{a as J,b as X,d as C,f as b,g as Z,h as p,i as tt,j as et,k as nt,l as rt,m as ot}from"./chunks/chunk-V74KGEJF.js";import{a as Y}from"./chunks/chunk-2FSXS55U.js";import"./chunks/chunk-HEQILZVR.js";import{a as W}from"./chunks/chunk-FCSWQDVV.js";import{a as l,b as it}from"./chunks/chunk-VT4CDUJJ.js";import{a as G,b as c}from"./chunks/chunk-MPTQYLSM.js";import{a as B,b as V,c as K,d as z,h as Q,i as j}from"./chunks/chunk-NEHZ37TU.js";import{l as F}from"./chunks/chunk-JOOEXYF3.js";import{G as U,P as m,b as r,e as D,f as L,g as E,h as O,i as a,j as N,k as _,l as v,n as H,p as R,r as d,s as i,x as g,y as q}from"./chunks/chunk-YJLWX2HK.js";import"./chunks/chunk-FOMSMIAM.js";var at={country:void 0,language:void 0,locale:void 0},x=!1;function ut(){let t=n=>document.querySelector(`meta[name="${r.prefix}-page-${n}"]`)?.getAttribute("content")||void 0,e=N(t("country"));return e?{country:e,language:_(t("language"))??void 0,locale:t("locale")}:null}async function Mt(){let t=r.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:k();try{return(await l("markets")).detectMarket(t)}catch(e){return a(e,"markets"),null}}async function st(t){at={country:r.country,language:r.language,locale:r.locale};let e=ut();if(x=e!==null,e){r.country=e.country,r.language=e.language,e.locale&&(r.locale=e.locale);return}let n=await Mt();n&&(n.country&&(r.country=n.country),n.language&&(r.language=n.language),n.locale&&!t.locale&&(r.locale=n.locale),E("market",n))}var ct=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase();function lt(){let t=ut(),e=t===null&&x;x=t!==null;let n=t??(e?k()??at:null);return!n?.country||ct(n.country,r.country)&&ct(n.language,r.language)?null:{country:n.country,language:n.language,locale:n.locale}}function y(t,e){return l("markets").then(n=>n.setCountry(t,e))}var Pt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],$t=()=>[...Pt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){let t=`${r.prefix}:account:${r.domain}`,e=`${r.prefix}:account-hint:${r.domain}`;try{return!!(sessionStorage.getItem(t)||localStorage.getItem(t)||localStorage.getItem(e))}catch{return!1}}function dt(t){!r.account?.clientId&&!r.account?.server||!(p(t,$t()).length>0||/[?&]code=/.test(window.location.search)||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function s(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:s("login"),logout:s("logout"),handleCallback:s("handleCallback"),getToken:s("getToken"),isLoggedIn:s("isLoggedIn"),query:s("query"),customer:s("customer"),orders:s("orders"),order:s("order"),updateProfile:s("updateProfile"),addresses:s("addresses"),saveAddress:s("saveAddress"),deleteAddress:s("deleteAddress"),subscriptions:s("subscriptions"),subscriptionAction:s("subscriptionAction"),requestReturn:s("requestReturn"),render:s("render"),mountAccount:s("mountAccount")};var mt=()=>`data-${r.prefix}-key`,gt=t=>t instanceof window.Element;function yt(t){let e=t.closest(`[${mt()}]`),n=e?.getAttribute(mt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=yt(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:u}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(c.removeLine(u),"cart line");return}let $=Nt(e);!$||!c.lines.some(It=>It.id===u)||(t.preventDefault(),w(c.changeQuantity(u,$),"cart line"))}function Nt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function _t(t){let{target:e}=t;if(!gt(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),m(n,()=>c.clear().catch(u=>{a(u,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),m(o,()=>c.checkout());return}Ot(t,e)}function pt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t){let{target:e}=t;if(!gt(e))return;let n=yt(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?pt(n.line,c.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?pt(n.line,c.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Rt(e)&&e.matches(i("cart-note"))&&w(c.setNote(e.value),"cart note")}var Rt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function qt(t){if(c.isOpen()){if(t.key==="Escape"){c.close();return}G(t)}}function ht(){document.addEventListener("click",_t),document.addEventListener("change",Ht),document.addEventListener("keydown",qt)}var A=t=>t instanceof window.Element;function Ut(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Et(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ft(t,e,n){try{await c.applyDiscount(n),Et(t,e,!1),g("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Et(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?g("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Ut(n),u=o?.value.trim();u&&m(n,()=>Ft(n,o,u))}function Bt(t){let{target:e}=t;if(!A(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Vt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(d("discount-code"));o&&c.removeDiscount(o).catch(u=>{a(u,"discount")})}function vt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Bt),document.addEventListener("click",Vt)}var T=t=>l("extras").then(e=>e.addGroup(t)),S=t=>{a(t,"extras")};function Kt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),m(n,()=>T(n)).catch(S))}function zt(t){!r.domain||!t.key?.startsWith(`${r.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(S)}function Qt(t){let{target:e}=t;e instanceof window.Element&&(!r.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(S))}function bt(){document.addEventListener("click",Kt),window.addEventListener("storage",zt),document.addEventListener(`${r.prefix}:variant-changed`,Qt)}var I=null;function wt(){I=document.body}async function jt(t){await t.ready();let e=lt();if(!e){I!==document.body&&t.mount(document);return}try{await y(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Wt(t){document.addEventListener("astro:page-load",()=>{jt(t)}),document.addEventListener("astro:before-swap",()=>{I=null,t.unmount()})}function Yt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&y(e.value).catch(n=>{a(n,"country")})}function Jt(){et(),b.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){r.astro&&Wt(t),document.addEventListener("change",Yt),window.addEventListener("online",Jt)}var kt="0.6.8",Xt=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],Zt=50,xt=()=>window,f=null,M=null,At=null,Ct=!1;function te(t){let e=0;return p(t,J()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=new X(n);b.add(o),n.addEventListener(`${r.prefix}:list-rendered`,u=>{h(u.detail.container)}),nt(o.load())}),e}function ee(t){p(t,`${i("country-select")},${i("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),dt(t),p(t,i("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function h(t=document){if(!L())return 0;t===document&&wt(),Z(),ot(t.ownerDocument??document);let e=te(t);return p(t,i("product")).forEach(n=>{tt(n)&&e++}),ee(t),rt(),c.render(),E(`mounted ${e} scope(s)`,t),e}function Tt(){c.close()}function ne(t){let e=t?.closest(i("product"));return e?Y.get(e)??null:null}function re(){Ct||(Ct=!0,ht(),vt(),bt(),Lt({ready:()=>f??Promise.resolve(null),mount:h,unmount:Tt}))}function oe(){let t=[];At=t,Xt.forEach(e=>{document.addEventListener(`${r.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",()=>t.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=r.country?.toUpperCase(),n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await c.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:(D({...xt().TETHER_CONFIG,...t}),L()?(re(),r.observe&&ce(),r.analytics&&!At&&oe(),f=st(t).then(()=>c.init()).then(ie).then(e=>(g("ready",{cart:e}),P)),f):(O("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function ce(){if(M||typeof MutationObserver>"u")return;let t,e=new Set;M=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(u=>{u instanceof window.Element&&e.add(u)})}),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&h(o)}),e.clear()},Zt)}),M.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>l("markets").then(e=>e.detectMarket(t??r.markets)),ue=()=>l("markets").then(t=>t.getLocalization()),se=t=>l("diagnose").then(e=>e.diagnose({...t,version:kt}));function le(t,e){let n=o=>{let u=o;e(u.detail,u)};return document.addEventListener(`${r.prefix}:${t}`,n),()=>{document.removeEventListener(`${r.prefix}:${t}`,n)}}var P={VERSION:kt,init:St,mount:h,unmount:Tt,get config(){return r},get ready(){return f??Promise.resolve(null)},query:R,withContext:H,cart:c,getProduct:K,getProducts:Q,getRecommendations:j,getScope:ne,addGroup:T,account:ft,primeProduct:V,normalizeProductKey:B,clearProductCache:z,formatMoney:U,imageUrl:q,plans:F,TetherError:v,resolveProductKey:W,setCountry:y,detectMarket:ae,getLocalization:ue,diagnose:se,__core:it,__parts:{},on:le},nn=P;function de(){let t=xt();if(t.Tether=P,!t.TETHER_CONFIG||t.TETHER_CONFIG.autoMount===!1||t.TETHER_INTEGRATION)return;let e=()=>{St().then(()=>h(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&de();export{kt as VERSION,T as addGroup,P as api,nn as default,ne as getScope,St as init,h as mount,y as setCountry,Tt as unmount};
1
+ import{a as nt,b as ot,d as T,f as w,g as C,h as p,i as rt,j as it,k as st,l as k,m as S}from"./chunks/chunk-4HD4J5JC.js";import{a as at,b as ct,c as h}from"./chunks/chunk-EW5SYO6L.js";import"./chunks/chunk-RPMBCAGS.js";import{a as et}from"./chunks/chunk-YN6LEBEN.js";import"./chunks/chunk-BBVUVPMO.js";import{a as tt}from"./chunks/chunk-VFNHIGCS.js";import{a as ut,b as lt,c as dt}from"./chunks/chunk-WT7RGGJU.js";import{a as l,b as mt}from"./chunks/chunk-Z6HS3H7K.js";import{a as z,b as Z,e as s}from"./chunks/chunk-HJY2JSNB.js";import{D as J,E as X,o as q,t as K,u as Q,v as W,w as Y}from"./chunks/chunk-6TFMLT4A.js";import{D as j,K as P,N as f,a as v,g as _,k as G,m as d,n as r,s as U,t as g,u as y,v as B}from"./chunks/chunk-MQYB6BH4.js";import{e as H,r as c,s as $,v as V,w as E,x as L,y as F,z as a}from"./chunks/chunk-E5YO6274.js";var Nt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Ot=()=>[...Nt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){return!!Z(ut())}function ft(t){!c.account||!(p(t,Ot()).length>0||dt(new URLSearchParams(window.location.search).get("account"))||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function u(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var pt={login:u("login"),logout:u("logout"),isLoggedIn:u("isLoggedIn"),customer:u("customer"),orders:u("orders"),order:u("order"),updateProfile:u("updateProfile"),addresses:u("addresses"),saveAddress:u("saveAddress"),deleteAddress:u("deleteAddress"),subscriptions:u("subscriptions"),subscriptionAction:u("subscriptionAction"),requestReturn:u("requestReturn"),render:u("render"),mountAccount:u("mountAccount")};var gt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${gt()}]`),n=e?.getAttribute(gt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Rt(t,e){let n=Et(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let R=Ht(e);!R||!s.lines.some(It=>It.id===i)||(t.preventDefault(),A(s.changeQuantity(i,R),"cart line"))}function Ht(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function $t(t){let{target:e}=t;if(!ht(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Rt(t,e)}function yt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Vt(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?yt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?yt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Ft(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var Ft=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function _t(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function vt(){document.addEventListener("click",$t),document.addEventListener("change",Vt),document.addEventListener("keydown",_t)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Pt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ut(t,e,n){try{await s.applyDiscount(n),Pt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Pt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Bt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),i=o?.value.trim();i&&f(n,()=>Ut(n,o,i))}function jt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function qt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function wt(){document.addEventListener("submit",Bt,!0),document.addEventListener("input",jt),document.addEventListener("click",qt)}var M=t=>l("extras").then(e=>e.addGroup(t)),I=t=>{a(t,"extras")};function zt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>M(n)).catch(I))}function Kt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(I)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(I))}function At(){document.addEventListener("click",zt),window.addEventListener("storage",Kt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var N=null;function bt(){N=document.body}async function Wt(t){await t.ready();let e=ct();if(!e){N!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Yt(t){document.addEventListener("astro:page-load",()=>{Wt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{N=null,t.unmount()})}function Jt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){it(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){c.astro&&Yt(t),document.addEventListener("change",Jt),window.addEventListener("online",Xt)}var Ct="0.7.1",Zt=50;function te(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,O=null,kt=null,Tt=!1;function ee(t){let e=0;return p(t,nt()).forEach(n=>{if(T.has(n))return;T.add(n),e++;let o=new ot(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),st(o.load())}),e}function ne(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),ft(t),p(t,r("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function St(t){let e=ee(t);return p(t,r("product")).forEach(n=>{rt(n)&&e++}),ne(t),e}function b(t=document){if(!E())return 0;t===document&&bt(),C(),S(t.ownerDocument??document);let e=St(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function oe(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;C(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+St(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function xt(){s.close()}function re(t){let e=t?.closest(r("product"));return e?et.get(e)??null:null}function ie(){Tt||(Tt=!0,vt(),wt(),At(),Lt({ready:()=>m??Promise.resolve(null),mount:b,unmount:xt}))}function se(){let t=[];kt=t,U.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ae(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function Mt(t={}){return m&&!Object.keys(t).length?m:(V({...te(),...t}),E()?(lt(),ie(),c.observe&&ce(),c.analytics&&!kt&&se(),m=at(t).then(()=>s.init()).then(ae).then(e=>(y("ready",{cart:e}),D)),m):(F("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function ce(){if(O||typeof MutationObserver>"u")return;let t,e=new Set;O=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),oe(o)},Zt)}),O.observe(document.body,{childList:!0,subtree:!0})}var ue=t=>l("markets").then(e=>e.detectMarket(t??c.markets)),le=()=>l("markets").then(t=>t.getLocalization()),de=t=>l("diagnose").then(e=>e.diagnose({...t,version:Ct}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:Ct,init:Mt,mount:b,unmount:xt,get config(){return $},get ready(){return m??Promise.resolve(null)},query:G,withContext:_,cart:s,getProduct:W,getProducts:J,getRecommendations:X,getScope:re,addGroup:M,account:pt,primeProduct:Q,normalizeProductKey:K,clearProductCache:Y,formatMoney:j,imageUrl:B,plans:q,TetherError:v,resolveProductKey:tt,setCountry:h,detectMarket:ue,getLocalization:le,diagnose:de,on:me},pe={__core:mt,__parts:{}},D=Object.assign(fe,pe),sn=D;function ge(){Reflect.set(window,"Tether",D);let t=P("TETHER_CONFIG");if(!t||H(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{Mt().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{Ct as VERSION,M as addGroup,D as api,sn as default,re as getScope,Mt as init,b as mount,h as setCountry,xt as unmount};
@@ -1,2 +1,2 @@
1
- import{b as x,d as q,e as F}from"./chunks/chunk-HEQILZVR.js";import{a as D,c as T,e as v,f as I,g as C,i as R,l as L}from"./chunks/chunk-JOOEXYF3.js";import{F as b,a as g,d as U,l as _,n as J,o as y,y as N}from"./chunks/chunk-YJLWX2HK.js";import{b as O,e as A,f as S,g as $}from"./chunks/chunk-FOMSMIAM.js";function B(e,t={}){if(!e)return null;let{variant:a,sellingPlan:c,defaultPurchase:l=g.defaultPurchase,lowStock:u=g.lowStock}=t,i=q(e,{variant:a,sellingPlan:c,defaultPurchase:l}),n=F(e,{...i,quantity:1},u);if(!n)return null;let{selected:f,isSubscription:p}=n,o=(r,s)=>!x(e,f,r,s);return{variant:n.variant,selected:f,purchase:n.purchase.kind,plan:p?n.plan:null,plans:v(e).map(r=>({id:r.id,name:r.name,price:C(n.variant,r.id),savings:R(n.variant,r.id).percentage,selected:p&&r.id===n.purchase.planId,available:!!I(n.variant,r.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(e.options.map(r=>[r.name,r.optionValues.map(s=>s.name).filter(s=>o(r.name,s))])),isUnavailable:o}}var Q=500,z=100,W=100,X="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",Z="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ee=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,te="query TetherServerProducts($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}}}",re=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,ne=e=>`query TetherServerRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`;function K(e,t){let a=(o,r)=>y(e,`${o}
2
- ${D(e)}`,r);async function c(o){let r=$(o);if(!r)return null;if(r.startsWith("gid://")){let d=await a(X,{id:r});return d.node?.id?d.node:null}return(await a(Z,{handle:r})).product}async function l(o,{first:r=t,after:s=null,sortKey:d,reverse:m=!1,filters:E}){let P=await a(ee(),{handle:o,first:r,after:s,sortKey:d||void 0,reverse:m,filters:E??void 0});if(!P.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:h,...Y}=P.collection;return{collection:Y,products:h.nodes,pageInfo:h.pageInfo}}async function u(o={}){let{collection:r,query:s,first:d=t,after:m=null,sortKey:E,reverse:P=!1}=o;if(r)return l(r,o);let h=await a(te,{first:d,after:m,query:s||void 0,sortKey:E||void 0,reverse:P});return{collection:null,products:h.products.nodes,pageInfo:h.products.pageInfo}}async function i(o={}){let r=[],s=null;for(let d=0;d<Q;d++){let m=await u({...o,first:t,after:s});if(r.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return r}async function n(o,r={}){let s=await u({...r,collection:o});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function f(){let o=[],r=null;for(let s=0;s<W;s++){let d=await y(e,re(),{first:z,after:r});if(o.push(...d.collections.nodes),!d.collections.pageInfo.hasNextPage)break;r=d.collections.pageInfo.endCursor}return o}async function p(o,r="RELATED"){let s=$(typeof o=="object"?o?.id:o),d=s?.startsWith("gid://")??!1;return(await a(ne(d),d?{id:s,intent:r}:{handle:s,intent:r})).productRecommendations??[]}return{getProduct:c,getProducts:u,allProducts:i,getCollection:n,allCollections:f,getRecommendations:p}}var M={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},k=e=>JSON.stringify(e).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function j(e){return JSON.parse(JSON.stringify(e))}var G=e=>e.split("/").pop()??e;function oe(e){return e.availableForSale?e.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function ae(e,t){if(!e.requiresSellingPlan)return t.price;let a=v(e).find(c=>I(t,c.id));return(a&&C(t,a.id))??t.price}function H(e,t,a){let c=ae(e,t),l=a?.includes("?")?"&":"?";return{"@type":"Offer",price:c.amount,priceCurrency:c.currencyCode,availability:oe(t),url:a?`${a}${l}variant=${G(t.id)}`:void 0}}function ie(e,t,a,c){let l=t.selectedOptions.flatMap(u=>{let i=M[u.name.toLowerCase()];return i?[[i.split("/").pop()??i,u.value]]:[]});return{"@type":"Product",name:`${e.title} - ${t.title}`,sku:t.sku||void 0,image:t.image?.url||c[0],...Object.fromEntries(l),offers:H(e,t,a)}}function se(e,{url:t},a){if(t)return t;if(a.siteUrl)return new URL(S(a.productPath,e.handle,e.id),a.siteUrl).toString()}function w(e,t,a){if(!e)return null;let c=se(e,t,a),l=e.images.nodes.map(o=>o.url).filter(Boolean),u=t.brand||e.vendor,i=u?{"@type":"Brand",name:u}:void 0,n=e.description.trim()||void 0,f=e.variants.nodes;if(f.length<=1){let[o]=f;return j({"@context":"https://schema.org","@type":"Product",name:e.title,description:n,url:c,image:l,sku:o?.sku||void 0,brand:i,offers:o?H(e,o,c):void 0})}let p=e.options.map(o=>M[o.name.toLowerCase()]).filter(Boolean);return j({"@context":"https://schema.org","@type":"ProductGroup",name:e.title,description:n,url:c,productGroupID:G(e.id),image:l,brand:i,variesBy:[...new Set(p)],hasVariant:f.map(o=>ie(e,o,c,l))})}var ce=25,le=2,ue=1;function de(e,{productPath:t=g.productPath,id:a}={}){return S(t,e,a)}function V(e,t){for(let a of t){let c=e[a];if(typeof c=="string"&&c)return c}return""}function fe(e){let t={};for(let[u,i]of Object.entries(e))u in g&&(t[u]=i);let a=typeof e.domain=="string"&&e.domain?e.domain:"",c=typeof e.token=="string"&&e.token?e.token:"",l=U({...t,domain:a||V(e,O.domain),token:c||V(e,O.token)});return e.fetch&&(l.fetch=e.fetch),e.pageSize!==void 0&&(l.pageSize=e.pageSize),e.siteUrl!==void 0&&(l.siteUrl=e.siteUrl),l}var pe=e=>typeof e=="number"&&Number.isInteger(e)&&e>0?e:ce;function me(e,t){return{...e,description:"",descriptionHtml:"",images:{nodes:e.images.nodes.slice(0,Math.max(1,t))},variants:{nodes:e.variants.nodes.map(a=>({...a,image:null}))}}}function be(e={}){let t=fe(e);if(!t.domain||!t.token)throw new _("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let a=K(t,pe(t.pageSize)),c={productPath:t.productPath,siteUrl:t.siteUrl};function l(i,{card:n=!1,images:f=le}={}){let p=(Array.isArray(i)?i:[i]).filter(r=>r!=null),o={v:ue,at:new Date().toISOString(),country:t.country||null,language:t.language||null,products:n?p.map(r=>me(r,f)):p};return`<script type="application/json" data-tether-hydrate>${k(o)}<\/script>`}function u(i,n={}){return i?`<script type="application/ld+json">${k(w(i,n,c))}<\/script>`:""}return{config:t,query:(i,n,f)=>y(t,i,n,f),...a,hydrate:l,formatMoney:(i,n=t.locale)=>A(i,n),formatPercent:(i,n=t.locale)=>b(i,n),imageUrl:N,jsonLd:u,jsonLdData:(i,n={})=>w(i,n,c),initialState:(i,n={})=>B(i,{defaultPurchase:t.defaultPurchase,lowStock:t.lowStock,...n}),productUrl:(i,n={})=>de(i,{productPath:t.productPath,...n}),plans:L}}export{_ as TetherError,be as createStorefront,A as formatMoney,b as formatPercent,N as imageUrl,B as initialState,L as plans,$ as productKey,de as productUrl,J as withContext};
1
+ import{b as G,f as H,g as Q}from"./chunks/chunk-BBVUVPMO.js";import{A as J,B as K,C as j,a as M,c as T,h as v,i as b,j as $,l as F,o as q,q as V,s as B}from"./chunks/chunk-6TFMLT4A.js";import{C as _,a as S,c as k,d as C,f as L,g as rt,h as P,j as N,v as D}from"./chunks/chunk-MQYB6BH4.js";import{B as E,E as U,F as I,G as O,q as g,t as A}from"./chunks/chunk-E5YO6274.js";function Y(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=H(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=Q(t,{...d,quantity:1},u);if(!n)throw new S(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!G(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:v(t).map(o=>({id:o.id,name:o.name,price:$(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!b(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var ot=500,it=100,at=100,st="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",lt="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ct=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,ut="query TetherServerProducts($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}}}",dt=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,ft=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,pt=C({product:k(V)}),mt=C({node:k(B)}),gt=C({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function yt(t){let e=[],r=null;for(let a=0;a<at;a++){let c=await P(t,dt(),{first:it,after:r},gt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function z(t,e){let r=(i,o,s)=>P(t,f=>`${i}
2
+ ${M(t,f)}`,o,s);async function a(i){let o=O(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(st,{id:o},mt);return f?.id?f:null}return(await r(lt,{handle:o},pt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:w}){let h=await r(ct(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:w??void 0},J);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:y,...nt}=h.collection;return{collection:nt,products:y.nodes,pageInfo:y.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:w,reverse:h=!1}=i;if(o)return c(o,i);let y=await r(ut,{first:f,after:m,query:s||void 0,sortKey:w||void 0,reverse:h},K);return{collection:null,products:y.products.nodes,pageInfo:y.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<ot;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=O(typeof i=="object"?i?.id:i),f=s?.startsWith("gid://")??!1;return(await r(ft(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>yt(t),getRecommendations:l}}var X={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},R=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function W(t){return JSON.parse(JSON.stringify(t))}var Z=t=>t.split("/").pop()??t;function Pt(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function ht(t,e){if(!t.requiresSellingPlan)return e.price;let r=v(t).find(a=>b(e,a.id));return(r&&$(e,r.id))??e.price}function tt(t,e,r){let a=ht(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:Pt(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function St(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=X[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:tt(t,e,r)}}function Ct(t,{url:e},r){if(e)return e;let a=I(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function x(t,e,r){if(!t)return null;let a=Ct(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return W({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?tt(t,i,a):void 0})}let p=t.options.map(i=>X[i.name.toLowerCase()]).filter(Boolean);return W({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:Z(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>St(t,i,a,c))})}var It=25,Ot=2,vt=1;function bt(t,{productPath:e=g.productPath,id:r}={}){return I(e,t,r)}function et(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function $t(t){let e={};for(let[u,d]of Object.entries(t))u in g&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c=A({...e,domain:r||et(t,E.domain),token:a||et(t,E.token)});return t.fetch&&(c.fetch=t.fetch),t.pageSize!==void 0&&(c.pageSize=t.pageSize),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}var wt=t=>typeof t=="number"&&Number.isInteger(t)&&t>0?t:It;function kt(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function Yt(t={}){let e=$t(t);if(!e.domain||!e.token)throw new S("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=z(e,wt(e.pageSize)),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=Ot}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:vt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>kt(s,p)):i};return`<script type="application/json" data-tether-hydrate>${R(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${R(x(n,l,a))}<\/script>`:""}function d(n,l={}){return Y(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>P(e,n,l??{},N,{...p,operation:L(n)}),...r,hydrate:c,formatMoney:(n,l=e.locale)=>U(n,l),formatPercent:(n,l=e.locale)=>_(n,l),imageUrl:D,jsonLd:u,jsonLdData:(n,l={})=>x(n,l,a),initialState:d,productUrl:(n,l={})=>bt(n,{productPath:e.productPath,...l}),plans:q}}export{S as TetherError,Yt as createStorefront,U as formatMoney,_ as formatPercent,D as imageUrl,Y as initialState,q as plans,O as productKey,bt as productUrl,rt as withContext};
@@ -1,4 +1,4 @@
1
- // src/presets/barba.js
1
+ // src/presets/barba.ts
2
2
  var LINE_DURATION_SECONDS = 0.3;
3
3
  var collapsed = () => ({
4
4
  height: 0,
@@ -10,31 +10,27 @@ var collapsed = () => ({
10
10
  });
11
11
  var ANIMATED_PROPS = "height,paddingTop,paddingBottom,borderBottomWidth,opacity,overflow";
12
12
  var reducedMotion = () => typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
13
- function current(option) {
14
- if (typeof option !== "function") return option;
15
- const getter = (
16
- /** @type {() => unknown} */
17
- option
18
- );
19
- return getter();
13
+ var GETTER_OPTIONS = ["gsap", "lenis", "scrollTrigger"];
14
+ function checkGetters(options) {
15
+ for (const name of GETTER_OPTIONS) {
16
+ const option = options[name];
17
+ if (option !== void 0 && option !== null && typeof option !== "function") {
18
+ throw new TypeError(`barbaPreset: ${name} must be a function that returns it, such as () => ${name}`);
19
+ }
20
+ }
20
21
  }
21
22
  function callIfPresent(target, method) {
22
- if (typeof target !== "object" || target === null) return;
23
+ if (typeof target !== "object" && typeof target !== "function" || target === null) return;
23
24
  const fn = Reflect.get(target, method);
24
25
  if (typeof fn === "function") fn.call(target);
25
26
  }
26
27
  var isGsap = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fromTo") === "function" && typeof Reflect.get(value, "to") === "function";
27
28
  function barbaPreset(options = {}) {
29
+ checkGetters(options);
28
30
  const {
29
- gsap = () => (
30
- /** @type {unknown} */
31
- Reflect.get(window, "gsap")
32
- ),
31
+ gsap = () => Reflect.get(window, "gsap"),
33
32
  lenis = null,
34
- scrollTrigger = () => (
35
- /** @type {unknown} */
36
- Reflect.get(window, "ScrollTrigger")
37
- ),
33
+ scrollTrigger = () => Reflect.get(window, "ScrollTrigger"),
38
34
  lockScroll = null,
39
35
  unlockScroll = null,
40
36
  onResize = null,
@@ -45,23 +41,23 @@ function barbaPreset(options = {}) {
45
41
  let locked = false;
46
42
  const animator = (node) => {
47
43
  if (!animateLines || reducedMotion() || node.offsetHeight <= 0) return null;
48
- const animation = current(gsap);
44
+ const animation = gsap();
49
45
  return isGsap(animation) ? animation : null;
50
46
  };
51
47
  return {
52
48
  autoMount: false,
53
49
  onLayoutChange() {
54
- callIfPresent(current(lenis), "resize");
55
- callIfPresent(current(scrollTrigger), "refresh");
50
+ callIfPresent(lenis?.(), "resize");
51
+ callIfPresent(scrollTrigger(), "refresh");
56
52
  },
57
53
  onCartOpen(drawers) {
58
54
  const drawer = drawers[0];
59
- if (locked || typeof lockScroll !== "function" || !drawer) return;
55
+ if (locked || !lockScroll || !drawer) return;
60
56
  lockScroll(drawer);
61
57
  locked = true;
62
58
  },
63
59
  onCartClose() {
64
- if (locked && typeof unlockScroll === "function") unlockScroll();
60
+ if (locked && unlockScroll) unlockScroll();
65
61
  locked = false;
66
62
  },
67
63
  onLineEnter(node) {
@@ -94,7 +90,7 @@ function barbaPreset(options = {}) {
94
90
  }
95
91
  });
96
92
  },
97
- onValueChange: typeof onValueChange === "function" ? onValueChange : null
93
+ onValueChange
98
94
  };
99
95
  }
100
96
  var barba_default = barbaPreset;