@tagadapay/headless-sdk 1.13.0 → 1.14.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/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/modules/checkout.d.ts +3 -16
- package/dist/core/modules/checkout.d.ts.map +1 -1
- package/dist/core/modules/checkout.js +16 -1
- package/dist/core/modules/checkout.js.map +1 -1
- package/dist/core/modules/payment.d.ts +8 -0
- package/dist/core/modules/payment.d.ts.map +1 -1
- package/dist/core/modules/payment.js +58 -4
- package/dist/core/modules/payment.js.map +1 -1
- package/dist/core/modules/rx.d.ts +1 -1
- package/dist/core/modules/rx.d.ts.map +1 -1
- package/dist/core/modules/rx.js +2 -2
- package/dist/core/modules/rx.js.map +1 -1
- package/dist/core/types.d.ts +34 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/react/hooks/useCheckout.d.ts +3 -16
- package/dist/react/hooks/useCheckout.d.ts.map +1 -1
- package/dist/react/hooks/useCheckout.js.map +1 -1
- package/dist/react/hooks/useRx.d.ts +1 -1
- package/dist/react/hooks/useRx.d.ts.map +1 -1
- package/dist/react/hooks/useRx.js +2 -2
- package/dist/react/hooks/useRx.js.map +1 -1
- package/dist/tagada-headless-react.min.js +2 -2
- package/dist/tagada-headless-react.min.js.map +3 -3
- package/dist/tagada-headless.js +68 -13
- package/dist/tagada-headless.min.js +2 -2
- package/dist/tagada-headless.min.js.map +3 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckout.js","sourceRoot":"","sources":["../../../src/react/hooks/useCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useCheckout.js","sourceRoot":"","sources":["../../../src/react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,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC9C,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,MAAM,kBAAkB,GAAG,WAAW,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QAC9D,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC7D,MAAM,WAAW,EAAE,CAAC;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAEnC,OAAO;QACL,OAAO;QACP,SAAS;QACT,KAAK;QACL,OAAO,EAAE,WAAW;QACpB,aAAa;QACb,gBAAgB;QAChB,UAAU;QACV,cAAc;QACd,aAAa;QACb,wBAAwB;QACxB,UAAU;QACV,WAAW;QACX,gBAAgB;QAChB,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -16,7 +16,7 @@ export interface UseRxReturn {
|
|
|
16
16
|
clinicalNetworkId?: string;
|
|
17
17
|
}) => Promise<RxRequiredForProduct>;
|
|
18
18
|
/** Fetch network-authored intake questions for a product. */
|
|
19
|
-
getQuestionsForProduct: (productId: string) => Promise<RxQuestionsForProduct>;
|
|
19
|
+
getQuestionsForProduct: (productId: string, variantId?: string) => Promise<RxQuestionsForProduct>;
|
|
20
20
|
/**
|
|
21
21
|
* Submit a fresh case after the order is paid. The result is also
|
|
22
22
|
* stored in `lastSubmission` so the thank-you page can read it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRx.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useRx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,yEAAyE;IACzE,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB;;;;OAIG;IACH,oBAAoB,EAAE,CACpB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,KAClC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEnC,6DAA6D;IAC7D,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useRx.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useRx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,yEAAyE;IACzE,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB;;;;OAIG;IACH,oBAAoB,EAAE,CACpB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,KAClC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEnC,6DAA6D;IAC7D,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElG;;;OAGG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEtE;;;OAGG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAEpG;;;;OAIG;IACH,SAAS,EAAE,CACT,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,EACjD,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAA;KAAE,KACxE,MAAM,IAAI,CAAC;CACjB;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,IAAI,WAAW,CA+HnC"}
|
|
@@ -53,11 +53,11 @@ export function useRx() {
|
|
|
53
53
|
setIsLoading(false);
|
|
54
54
|
}
|
|
55
55
|
}, [client]);
|
|
56
|
-
const getQuestionsForProduct = useCallback(async (productId) => {
|
|
56
|
+
const getQuestionsForProduct = useCallback(async (productId, variantId) => {
|
|
57
57
|
setIsLoading(true);
|
|
58
58
|
setError(null);
|
|
59
59
|
try {
|
|
60
|
-
return await client.rx.getQuestionsForProduct(productId);
|
|
60
|
+
return await client.rx.getQuestionsForProduct(productId, variantId);
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
63
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRx.js","sourceRoot":"","sources":["../../../src/react/hooks/useRx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAsDnD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAA0B;IACzD,UAAU;IACV,SAAS;IACT,WAAW;IACX,UAAU;IACV,WAAW;IACX,OAAO;CACR,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,KAAK;IACnB,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IACxD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAA4B,IAAI,CAAC,CAAC;IACtF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,MAAM,CAAwC,IAAI,CAAC,CAAC;IAEzE,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO;gBAAE,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,oBA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AAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;oBACpF,IAAI,YAAY,CAAC,OAAO;wBAAE,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;oBAC9D,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;gBAC9B,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC9D,QAAQ,CAAC,CAAC,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC;QAEF,KAAK,IAAI,EAAE,CAAC;QACZ,YAAY,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACrD,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO;gBAAE,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC9D,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,KAAK;QACL,cAAc;QACd,SAAS;QACT,KAAK;QACL,oBAAoB;QACpB,sBAAsB;QACtB,UAAU;QACV,kBAAkB;QAClB,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @tagadapay/headless-sdk v1.
|
|
2
|
+
* @tagadapay/headless-sdk v1.14.0
|
|
3
3
|
* Headless checkout, payments, offers, and CRM
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var TagadaHeadlessReactBundle=(()=>{var rt=Object.create;var ie=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var F=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var at=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},Ee=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of st(e))!ot.call(s,n)&&n!==t&&ie(s,n,{get:()=>e[n],enumerable:!(r=nt(e,n))||r.enumerable});return s};var Le=(s,e,t)=>(t=s!=null?rt(it(s)):{},Ee(e||!s||!s.__esModule?ie(t,"default",{value:s,enumerable:!0}):t,s)),ct=s=>Ee(ie({},"__esModule",{value:!0}),s);var Ct={};at(Ct,{CurrencyUtils:()=>V,GoogleAutocompleteCore:()=>K,ISODataCore:()=>B,TagadaHeadlessProvider:()=>Fe,formatMoney:()=>Te,loadGoogleMapsScript:()=>te,parseTokensFromUrl:()=>Ne,useCatalog:()=>ze,useCheckout:()=>Ge,useCountryOptions:()=>Ze,useCustomer:()=>Ke,useGoogleAutocomplete:()=>Ve,useHeadlessClient:()=>D,useISOData:()=>Se,useOffers:()=>je,useOrder:()=>Be,usePayment:()=>He,useRegionOptions:()=>Xe,useRx:()=>Je});var Q=F("react");var q=class extends Error{constructor(e,t,r,n){super(e),this.name="TagadaError",this.code=t,this.statusCode=r,this.details=n}},oe=class extends q{constructor(e="Authentication failed. Check your API key or checkout token."){super(e,"auth_error",401),this.name="TagadaAuthError"}},ae=class extends q{constructor(e,t=[],r,n){super(e,"validation_error",422,{errors:t,...n}),this.name="TagadaValidationError",this.errors=t,this.appCode=r}},ce=class extends q{constructor(e,t){super(`${e} "${t}" not found.`,"not_found",404),this.name="TagadaNotFoundError"}},ue=class extends q{constructor(e=1e3){super(`Rate limited. Retry after ${e}ms.`,"rate_limit",429),this.name="TagadaRateLimitError",this.retryAfterMs=e}};var Z=class extends q{constructor(e="Network request failed. Check your connection."){super(e,"network_error"),this.name="TagadaNetworkError"}};var Ue={production:"https://api.tagada.io",development:"https://api.tagada.dev",local:"http://localhost:3000"},X=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.timeout=e.timeout,this.apiKey=e.apiKey,this.getToken=e.getToken}static resolveBaseUrl(e,t){return t??Ue[e]??Ue.production}async request(e,t={}){var d;let{method:r="GET",body:n,headers:o={},params:i,token:a,signal:u}=t,c=`${this.baseUrl}${e}`;if(i){let y=new URLSearchParams;for(let[g,k]of Object.entries(i))k!==void 0&&y.set(g,String(k));let f=y.toString();f&&(c+=`?${f}`)}let p={"Content-Type":"application/json",...o},l=a??this.apiKey??((d=this.getToken)==null?void 0:d.call(this));l&&(p["x-cms-token"]=l);let h=new AbortController,m=setTimeout(()=>h.abort(),this.timeout);try{let y=await fetch(c,{method:r,headers:p,body:n!=null?JSON.stringify(n):void 0,signal:u??h.signal});if(clearTimeout(m),y.ok){let f=await y.text();return f?JSON.parse(f):{}}throw await this.handleErrorResponse(y,e),new q("Unexpected error","unknown",y.status)}catch(y){throw clearTimeout(m),y instanceof q?y:y instanceof DOMException&&y.name==="AbortError"?new Z(`Request to ${e} timed out after ${this.timeout}ms.`):new Z(y instanceof Error?y.message:"Network request failed.")}}get(e,t){return this.request(e,{...t,method:"GET"})}post(e,t,r){return this.request(e,{...r,method:"POST",body:t})}patch(e,t,r){return this.request(e,{...r,method:"PATCH",body:t})}put(e,t,r){return this.request(e,{...r,method:"PUT",body:t})}delete(e,t){return this.request(e,{...t,method:"DELETE"})}async handleErrorResponse(e,t){let r={};try{r=await e.json()}catch{}let n=r.data??{},o=r.message??r.error??(typeof n.message=="string"?n.message:void 0)??(typeof r.data=="string"?r.data:void 0)??`Request failed: ${e.status} ${e.statusText} on ${t}`,i=typeof n.code=="string"?n.code:void 0;switch(e.status){case 401:case 403:throw new oe(o);case 404:throw new ce(t,"");case 422:{let a=Array.isArray(r.errors)?r.errors:[];throw new ae(o,a,i,r)}case 429:{let a=Number(e.headers.get("Retry-After")??"1")*1e3;throw new ue(a)}default:throw new q(o,"api_error",e.status,r)}}};var ee=class s{constructor(e,t,r){this.http=e;this.storeId=t;this.onTokenChange=r}getCurrentSession(){return this._currentSession}async loadSession(e,t,r){var a;t&&(this.sessionToken=t,(a=this.onTokenChange)==null||a.call(this,t));let n={skipAsyncWait:"false"};r!=null&&r.currency&&(n.currency=r.currency);let o=await this.http.get(`/api/v1/checkout-sessions/${e}/v2`,{params:n,token:this.sessionToken}),i=this.normalizeSession(o);return this._currentSession=i,i}async createSession(e){var u;let t=e.items.map(c=>({variantId:c.variantId,priceId:c.priceId,quantity:c.quantity})),r={storeId:this.storeId,lineItems:t};e.returnUrl&&(r.returnUrl=e.returnUrl);let n={};e.currency&&(n.currency=e.currency),e.customerEmail&&(n.email=e.customerEmail,n.firstName=e.customerFirstName,n.lastName=e.customerLastName),Object.keys(n).length>0&&(r.customer=n);let o=await this.http.post("/api/v1/checkout/session/init",r),a=new URL(o.checkoutUrl).searchParams.get("token")??"";return this.sessionToken=a,a&&((u=this.onTokenChange)==null||u.call(this,a)),{checkoutUrl:o.checkoutUrl,checkoutToken:o.checkoutToken,sessionToken:a,customerId:o.customerId}}async createSessionUrl(e){let t=await this.createSession({items:e.items,currency:e.currency,returnUrl:e.returnUrl,customerEmail:e.customerEmail,customerFirstName:e.customerFirstName,customerLastName:e.customerLastName}),r=e.origin??(typeof window<"u"?window.location.origin:""),n=e.checkoutPath??"/checkout",o=new URLSearchParams({checkoutToken:t.checkoutToken,sessionToken:t.sessionToken}),i=`${r}${n}?${o.toString()}`;return{...t,url:i}}static parseTokensFromUrl(e){if(typeof e>"u"&&typeof window>"u")return null;let t=e??window.location.href,r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get("checkoutToken");if(!n)return null;let o=r.searchParams.get("sessionToken")??r.searchParams.get("token")??"";return{checkoutToken:n,sessionToken:o}}parseTokensFromUrl(e){return s.parseTokensFromUrl(e)}async updateCart(e,t){let r=t.map(n=>({variantId:n.variantId,priceId:n.priceId,quantity:n.quantity}));return this.http.post(`/api/v1/checkout-sessions/${e}/line-items`,{lineItems:r},{token:this.sessionToken})}async updateCustomer(e,t){t.email&&(this.customerEmail=t.email),t.firstName&&(this.customerFirstName=t.firstName),t.lastName&&(this.customerLastName=t.lastName),t.phone&&(this.customerPhone=t.phone)}async updateAddress(e,t){let r=this.mapAddress(t.shippingAddress),n=this.mapAddress(t.billingAddress),o=r??n??{},i=n??r,a=!!(t.billingAddress&&t.shippingAddress);await this.http.post(`/api/v1/checkout-sessions/${e}/customer-and-session-info`,{checkoutSessionId:e,customerData:{email:this.customerEmail},shippingAddress:o,billingAddress:i??{},differentBillingAddress:a},{token:this.sessionToken})}async updateCustomerAndAddress(e,t){t.customer.email&&(this.customerEmail=t.customer.email),t.customer.firstName&&(this.customerFirstName=t.customer.firstName),t.customer.lastName&&(this.customerLastName=t.customer.lastName),t.customer.phone&&(this.customerPhone=t.customer.phone);let r=this.mapAddress(t.shippingAddress),n=this.mapAddress(t.billingAddress),o=r??n??{},i=n??r,a=!!(t.billingAddress&&t.shippingAddress);await this.http.post(`/api/v1/checkout-sessions/${e}/customer-and-session-info`,{checkoutSessionId:e,customerData:{email:this.customerEmail},shippingAddress:o,billingAddress:i??{},differentBillingAddress:a},{token:this.sessionToken})}mapAddress(e){if(e)return ut({firstName:e.firstName??this.customerFirstName,lastName:e.lastName??this.customerLastName,phone:e.phone??this.customerPhone,address1:e.line1,address2:e.line2,city:e.city,state:e.state,postal:e.postalCode,country:e.country})}async applyPromoCode(e,t){await this.http.post(`/api/v1/checkout-sessions/${e}/promotions/apply`,{checkoutSessionId:e,code:t},{token:this.sessionToken})}async removePromoCode(e,t){let r=t??"default";await this.http.delete(`/api/v1/checkout-sessions/${e}/promotions/${r}`,{token:this.sessionToken})}async getShippingRates(e){return((await this.http.get(`/api/v1/checkout-sessions/${e}/shipping-rates`,{token:this.sessionToken})).rates??[]).map(r=>this.normalizeShippingRate(r))}normalizeShippingRate(e){return{id:e.id,name:e.name??e.shippingRateName??"",description:e.description??void 0,amount:e.amount??0,currency:e.currency??"USD",estimatedDays:e.estimatedDays??e.estimatedDeliveryTime??void 0}}async selectShippingRate(e,t){await this.http.post(`/api/v1/checkout-sessions/${e}/shipping-rate`,{checkoutSessionId:e,shippingRateId:t},{token:this.sessionToken})}normalizeSession(e){var p;let t=e.checkoutSession,r=t.orderSummaries??[],n=e.summary??t.summary??r[0]??{},o=t.sessionLineItems??[],i=t.customer,a=(p=n.currency??t.selectedPresentmentCurrency)==null?void 0:p.toUpperCase(),u=o.map(l=>{let h=l.price,m=l.variant??(h==null?void 0:h.variant)??{},d=l.product??m.product??{},y=(h==null?void 0:h.currencyOptions)??{},f=(a?y[a]:void 0)??y[Object.keys(y)[0]],g=(f==null?void 0:f.amount)??0;return{id:l.id,variantId:l.variantId,priceId:l.priceId,productName:d.name??"",variantName:m.name??"",quantity:l.quantity??1,unitAmount:g,totalAmount:g*(l.quantity??1),currency:a??"USD",imageUrl:m.imageUrl??d.imageUrl??""}}),c=n.items??[];return{id:t.id,storeId:t.storeId,checkoutToken:t.checkoutToken,currency:a??"USD",items:u,totals:{subtotal:n.subtotalAmount??0,discount:n.totalPromotionAmount??0,shipping:n.shippingCost??0,tax:n.totalTaxAmount??0,total:n.totalAmount??c.reduce((l,h)=>l+(h.amount??0),0),currency:a??"USD"},customer:i?{id:i.id,email:i.email,firstName:i.firstName,lastName:i.lastName,phone:i.phone}:void 0,shippingAddress:this.normalizeAddress(t.shippingAddress),billingAddress:this.normalizeAddress(t.billingAddress),selectedShippingRateId:t.shippingRateId??null,metadata:t.metadata}}normalizeAddress(e){if(!e||typeof e!="object")return;let t=e,r={firstName:t.firstName,lastName:t.lastName,line1:t.line1??t.address1,line2:t.line2??t.address2,city:t.city,state:t.state,postalCode:t.postalCode??t.postal,country:t.country,phone:t.phone};return Object.values(r).some(n=>n!==void 0&&n!=="")?r:void 0}},Ne=ee.parseTokensFromUrl;function ut(s){let e={};for(let[t,r]of Object.entries(s))r!=null&&r!==""&&(e[t]=r);return Object.keys(e).length>0?e:void 0}function de(s){var t,r;if(!s)return;let e={firstName:s.givenName,lastName:s.familyName,line1:(t=s.addressLines)==null?void 0:t[0],line2:(r=s.addressLines)==null?void 0:r[1],city:s.locality,state:s.administrativeArea,postalCode:s.postalCode,country:s.countryCode,phone:s.phoneNumber};return _e(e)?e:void 0}function le(s){if(!s)return;let[e,...t]=(s.name??"").trim().split(/\s+/),r={firstName:e||void 0,lastName:t.length?t.join(" "):void 0,line1:s.address1,line2:[s.address2,s.address3].filter(Boolean).join(" ")||void 0,city:s.locality,state:s.administrativeArea,postalCode:s.postalCode,country:s.countryCode,phone:s.phoneNumber};return _e(r)?r:void 0}function _e(s){var e,t;return!!((e=s.line1)!=null&&e.trim()&&((t=s.country)!=null&&t.trim()))}var me=class{constructor(e,t,r,n){this.http=e;this.storeId=t;this.environment=r;this.checkout=n;this.lastPaymentSetup=null}async getPaymentSetup(e,t){if(t!=null&&t.paymentSetupConfig)return this.lastPaymentSetup=t.paymentSetupConfig,t.paymentSetupConfig;let r=this.readInjectedStepConfig();if(r)return this.lastPaymentSetup=r,r;let n=await this.http.get("/api/v1/payment-methods",{params:{checkoutSessionId:e}}),o={};for(let i of n.methods??[]){let a=i.provider?`${i.method}:${i.provider}`:i.method;o[a]=i}return this.lastPaymentSetup=o,o}async getExpressMethods(e,t){var o,i,a,u,c,p,l,h;let r=await this.getPaymentSetup(e,t),n={};for(let[m,d]of Object.entries(r)){if(!d.enabled)continue;if(m.startsWith("express_checkout:")&&d.methods){let g={available:!0,processorId:d.processorId,publishableKey:d.publishableKey,metadata:d.metadata};if((o=d.methods.apple_pay)!=null&&o.enabled){let k=typeof window<"u"&&"ApplePaySession"in window&&((a=(i=window.ApplePaySession)==null?void 0:i.canMakePayments)==null?void 0:a.call(i));n.applePay={...g,type:"apple_pay",available:!!k}}(u=d.methods.google_pay)!=null&&u.enabled&&(n.googlePay={...g,type:"google_pay"}),(c=d.methods.link)!=null&&c.enabled&&(n.link={...g,type:"link"}),(p=d.methods.klarna_express)!=null&&p.enabled&&(n.klarna={...g,type:"klarna_express"});continue}if(!d.express)continue;let y=d.method,f={type:y,available:!0,processorId:d.processorId,publishableKey:d.publishableKey,metadata:d.metadata};if(y==="apple_pay"||d.type==="apple_pay"){let g=typeof window<"u"&&"ApplePaySession"in window&&((h=(l=window.ApplePaySession)==null?void 0:l.canMakePayments)==null?void 0:h.call(l));n.applePay={...f,available:!!g}}else y==="google_pay"||d.type==="google_pay"?n.googlePay=f:y==="paypal"?n.paypal=f:y==="klarna"||y==="klarna_express"?n.klarna=f:y==="link"&&(n.link=f)}return n}async getStoreConfig(){let e=await this.http.get("/api/v1/checkout/config",{params:{storeId:this.storeId}});return e.config??e}async getEnabledMethods(e,t){let r=await this.getPaymentSetup(e,t);return Object.entries(r).filter(([,n])=>n.enabled).map(([n])=>n)}async tokenizeCard(e){let t=await this.loadCoreJs(),r=new t.Tokenizer({environment:this.environment});await r.initialize();let n={cardNumber:e.cardNumber,expiryDate:e.expiryDate,cvc:e.cvc};e.cardholderName&&(n.cardholderName=e.cardholderName);let o=await r.tokenizeCardRaw(n);return{tagadaToken:t.createTagadaToken(o,r.getProvider().getProviderName()),rawToken:o}}async createInstrument(e){return this.http.post("/api/v1/payment/create-instrument-from-token",{tagadaToken:e.tagadaToken})}async create3dsSession(e){return this.http.post("/api/public/v1/threeds/create-session",{provider:e.provider??"basis_theory",storeId:this.storeId,paymentInstrumentId:e.paymentInstrumentId,sessionData:e.sessionData})}async pay(e){return e.tagadaToken&&!e.paymentInstrumentId?this.http.post("/api/v1/payment/pay-with-token",{tagadaToken:e.tagadaToken,checkoutSessionId:e.checkoutSessionId,returnUrl:e.returnUrl,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,metadata:e.metadata}):this.http.post("/api/public/v1/checkout/pay-v2",{checkoutSessionId:e.checkoutSessionId,paymentInstrumentId:e.paymentInstrumentId,storeId:this.storeId,paymentFlowId:e.paymentFlowId,threedsSessionId:e.threedsSessionId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,metadata:e.metadata,returnUrl:e.returnUrl})}async payDirect(e){return this.http.post("/api/public/v1/checkout/pay-v2",{checkoutSessionId:e.checkoutSessionId,paymentInstrumentId:e.paymentInstrumentId??"",storeId:this.storeId,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,threedsSessionId:e.threedsSessionId,returnUrl:e.returnUrl})}async syncWalletContact(e,t){let{shippingAddress:r,billingAddress:n}=t;if(!r&&!n)return;if(!this.checkout)throw new Error("PaymentModule cannot persist the wallet contact: no CheckoutModule was provided. Build the SDK through createTagadaClient() rather than constructing PaymentModule directly.");let o={};t.email&&(o.email=t.email),t.phone&&(o.phone=t.phone),t.firstName&&(o.firstName=t.firstName),t.lastName&&(o.lastName=t.lastName),await this.checkout.updateCustomerAndAddress(e,{customer:o,shippingAddress:r,billingAddress:n})}async processApplePay(e){var a,u,c,p,l,h,m,d,y;await this.syncWalletContact(e.checkoutSessionId,{shippingAddress:de(e.shippingContact),billingAddress:de(e.billingContact),email:((a=e.shippingContact)==null?void 0:a.emailAddress)??((u=e.billingContact)==null?void 0:u.emailAddress),phone:((c=e.shippingContact)==null?void 0:c.phoneNumber)??((p=e.billingContact)==null?void 0:p.phoneNumber),firstName:((l=e.shippingContact)==null?void 0:l.givenName)??((h=e.billingContact)==null?void 0:h.givenName),lastName:((m=e.shippingContact)==null?void 0:m.familyName)??((d=e.billingContact)==null?void 0:d.familyName)});let t=e.merchantRegistrationId??((y=await this.resolveApplePayRegistration(e.checkoutSessionId))==null?void 0:y.merchantRegistrationId),r=await this.loadCoreJs(),n=new r.Tokenizer({environment:this.environment});await n.initialize();let o=await n.tokenizeApplePay(e.applePayToken,t),i=btoa(JSON.stringify(r.createTagadaDigitalWalletToken(o,"apple_pay")));return this.pay({checkoutSessionId:e.checkoutSessionId,tagadaToken:i,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:"apple_pay",isExpress:!0})}async resolveApplePayRegistration(e){if(typeof window>"u")return null;let t=window.location.hostname.toLowerCase().split(":")[0];t.startsWith("www.")&&(t=t.slice(4));let r=o=>{var i;for(let a of Object.values(o??{})){let u=(i=a==null?void 0:a.metadata)==null?void 0:i.applePayByok;if(!u||typeof u!="object")continue;let c=u[t];if(c!=null&&c.merchantRegistrationId)return{merchantRegistrationId:c.merchantRegistrationId,displayName:c.displayName}}return null},n=r(this.readInjectedStepConfig())??r(this.lastPaymentSetup);if(n)return n;if(this.lastPaymentSetup||this.readInjectedStepConfig()||!e)return null;try{return r(await this.getPaymentSetup(e))}catch{return null}}async processGooglePay(e){var i,a,u,c;await this.syncWalletContact(e.checkoutSessionId,{shippingAddress:le(e.shippingAddress),billingAddress:le(e.billingAddress),email:e.email??((i=e.shippingAddress)==null?void 0:i.emailAddress)??((a=e.billingAddress)==null?void 0:a.emailAddress),phone:((u=e.shippingAddress)==null?void 0:u.phoneNumber)??((c=e.billingAddress)==null?void 0:c.phoneNumber)});let t=await this.loadCoreJs(),r=new t.Tokenizer({environment:this.environment});await r.initialize();let n=await r.tokenizeGooglePay(e.googlePayToken),o=btoa(JSON.stringify(t.createTagadaDigitalWalletToken(n,"google_pay")));return this.pay({checkoutSessionId:e.checkoutSessionId,tagadaToken:o,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:"google_pay",isExpress:!0})}async processApm(e){return this.payDirect({checkoutSessionId:e.checkoutSessionId,paymentMethod:e.paymentMethod,processorId:e.processorId,paymentFlowId:e.paymentFlowId})}async processStripeExpress(e){return this.payDirect({checkoutSessionId:e.checkoutSessionId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:!0})}async processPayment(e){!e.returnUrl&&typeof window<"u"&&(e={...e,returnUrl:window.location.href});let t=await this.pay(e);return this.finalize(t,{returnUrl:e.returnUrl})}async finalize(e,t){var o,i;let r=e.payment,n=(t==null?void 0:t.returnUrl)??(typeof window<"u"?window.location.href:void 0);return r.status==="succeeded"?{status:"succeeded",payment:r,order:e.order}:r.status==="failed"||r.status==="declined"?{status:"failed",error:((o=r.requireActionData)==null?void 0:o.message)||((i=r.requireActionData)==null?void 0:i.errorCode)||`Payment ${r.status}`,payment:r}:r.requireAction&&r.requireAction!=="none"&&r.requireActionData?this.handlePaymentAction(r,{returnUrl:n}):this.pollUntilDone(r.id)}async resumeAfterRedirect(e){return this.pollUntilDone(e)}async maybeResumeFromUrl(e){if(typeof window>"u"&&!(e!=null&&e.url))return null;let t=(e==null?void 0:e.url)??window.location.href,r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get("paymentAction"),o=r.searchParams.get("paymentActionStatus"),i=r.searchParams.get("paymentId");if(n!=="requireAction"||o!=="completed"||!i)return null;let a=await this.resumeAfterRedirect(i);if((e==null?void 0:e.cleanUrl)!==!1&&typeof window<"u"&&!(e!=null&&e.url)){let u=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status","sessionId"].forEach(p=>u.delete(p));let c=u.toString();try{window.history.replaceState({},document.title,window.location.pathname+(c?"?"+c:""))}catch{}}return a}async getPaymentStatus(e){return this.http.get(`/api/v1/payments/${e}`)}async pollPaymentStatus(e,t){let r=(t==null?void 0:t.intervalMs)??1500,n=(t==null?void 0:t.timeoutMs)??6e4,o=Date.now();for(;Date.now()-o<n;){let i=await this.getPaymentStatus(e);if(i.status==="succeeded"||i.status==="failed"||i.status==="declined")return i;await new Promise(a=>setTimeout(a,r))}throw new Error(`Payment ${e} did not reach terminal status within ${n}ms.`)}async completeAfter3ds(e){return this.http.post("/api/v1/payments/complete-after-3ds",{paymentId:e})}async markActionProcessed(e){try{await this.http.post("/api/v1/payments/require-action/processed",{paymentId:e})}catch{}}async handlePaymentAction(e,t){let r=e.requireActionData;switch(await this.markActionProcessed(e.id),r.type){case"threeds_auth":return this.handleThreedsAuth(e,t);case"processor_auth":case"redirect_to_payment":return this.extractRedirect(e,r);case"redirect":return this.extractRedirect(e,r);case"error":return{status:"failed",error:r.message||r.errorCode||"Payment failed",payment:e};default:return this.extractRedirect(e,r)}}extractRedirect(e,t){var o,i;let r=(o=t.metadata)==null?void 0:o.redirect,n=(r==null?void 0:r.redirectUrl)||t.redirectUrl;return n?{status:"requires_redirect",redirectUrl:n,method:((i=r==null?void 0:r.method)==null?void 0:i.toUpperCase())||"GET",postData:r==null?void 0:r.data,paymentId:e.id}:{status:"failed",error:`Payment requires action (${t.type}) but no redirect URL was provided`,payment:e}}async handleThreedsAuth(e,t){var o,i;let r=(i=(o=e.requireActionData)==null?void 0:o.metadata)==null?void 0:i.threedsSession;if(!(r!=null&&r.externalSessionId))return this.extractRedirect(e,e.requireActionData);let n;try{n=await import("@tagadapay/core-js")}catch{return r.acsChallengeUrl?{status:"requires_redirect",redirectUrl:r.acsChallengeUrl,paymentId:e.id}:this.extractRedirect(e,e.requireActionData)}try{let a=new n.ThreedsManager({provider:"basis_theory"});return await a.initialize({apiKey:void 0}),await a.startChallenge({sessionId:r.externalSessionId,acsChallengeUrl:r.acsChallengeUrl,acsTransactionId:r.acsTransID,threeDSVersion:r.messageVersion}),await this.completeAfter3ds(e.id),this.pollUntilDone(e.id)}catch{return r.acsChallengeUrl?{status:"requires_redirect",redirectUrl:r.acsChallengeUrl,paymentId:e.id}:{status:"failed",error:"3D Secure authentication failed",payment:e}}}async pollUntilDone(e,t){let r=(t==null?void 0:t.intervalMs)??1500,n=(t==null?void 0:t.timeoutMs)??6e4,o=Date.now(),i=0;for(;Date.now()-o<n;){let a;try{a=await this.getPaymentStatus(e),i=0}catch{if(i++,i>=3)return{status:"failed",error:"Payment verification failed due to network errors"};await new Promise(u=>setTimeout(u,r));continue}if(a.status==="succeeded"||a.status==="pending"&&a.subStatus==="authorized")return{status:"succeeded",payment:a,order:a.order};if(a.status==="failed"||a.status==="declined")return{status:"failed",error:a.status,payment:a};if(a.requireAction&&a.requireAction!=="none"&&a.requireActionData&&!a.requireActionData.processed)return this.handlePaymentAction(a,{});await new Promise(u=>setTimeout(u,r))}return{status:"pending",paymentId:e}}readInjectedStepConfig(){if(typeof window>"u")return null;let e=window.__TGD_STEP_CONFIG__;if(!e)return null;try{let t=typeof e=="string"?JSON.parse(e):e;return(t==null?void 0:t.paymentSetupConfig)??null}catch{return null}}async loadCoreJs(){try{return await import("@tagadapay/core-js")}catch{throw new Error("This method requires @tagadapay/core-js. Install it: npm install @tagadapay/core-js")}}};var pe=class{constructor(e,t,r){this.http=e;this.storeId=t;this.payment=r}async getOffer(e){return this.http.get(`/api/v1/offers/${e}`)}async listOffers(e){var o;let t=`/api/v1/stores/${this.storeId}/offers`,r=[];if(e!=null&&e.type&&r.push(`type=${encodeURIComponent(e.type)}`),(o=e==null?void 0:e.ids)!=null&&o.length)for(let i of e.ids)r.push(`ids=${encodeURIComponent(i)}`);return r.length&&(t+=`?${r.join("&")}`),(await this.http.get(t)).offers??[]}async previewOffer(e){return this.http.post(`/api/v1/offers/${e.offerId}/preview`,{offerId:e.offerId,currency:e.currency??"",lineItems:e.lineItems})}async payPreviewedOffer(e){return this.http.post(`/api/v1/offers/${e.offerId}/pay-preview`,{offerId:e.offerId,currency:e.currency??"",lineItems:e.lineItems,returnUrl:e.returnUrl??(typeof window<"u"?window.location.href:""),mainOrderId:e.mainOrderId,paymentInstrumentId:e.paymentInstrumentId})}async processOfferPayment(e){if(!this.payment)throw new Error("OffersModule: no PaymentModule injected. Use createHeadlessClient() instead of constructing OffersModule directly.");let t=e.returnUrl??(typeof window<"u"?window.location.href:void 0),r=await this.payPreviewedOffer({...e,returnUrl:t});return this.payment.finalize({payment:r.payment,order:r.order},{returnUrl:t})}async toggleOrderBump(e){return this.http.post(`/api/v1/checkout-sessions/${e.checkoutSessionId}/toggle-order-bump`,{orderBumpOfferId:e.orderBumpOfferId,selected:e.selected})}async listPostPurchaseOffers(e){let t=await this.http.get(`/api/v1/post-purchase/${e}/offers`);return Array.isArray(t)?t:[]}async acceptPostPurchaseOffer(e){return this.http.post(`/api/v1/orders/${e.orderId}/post-purchase-offers/${e.offerId}/accept`,{items:e.items??[]})}async declinePostPurchaseOffer(e){return this.http.post(`/api/v1/orders/${e.orderId}/post-purchase-offers/${e.offerId}/decline`)}};var ge=class{constructor(e,t){this.http=e;this.storeId=t}async getProfile(e){return(await this.http.get(`/api/v1/customers/${e}`,{params:{storeId:this.storeId}})).customer}async getByEmail(e){try{return(await this.http.get("/api/v1/customers/by-email",{params:{email:e,storeId:this.storeId}})).customer}catch{return null}}async updateProfile(e,t){return(await this.http.patch(`/api/v1/customers/${e}`,{storeId:this.storeId,...t})).customer}async getOrders(e,t){return this.http.get(`/api/v1/customers/${e}/orders`,{params:{storeId:this.storeId,limit:t==null?void 0:t.limit,offset:t==null?void 0:t.offset}})}async getOrder(e,t){var u,c;let r=async()=>(await this.http.get(`/api/v1/orders/${e}`,{params:{storeId:this.storeId}})).order,n=await r();if(!(t!=null&&t.waitForRelatedOrders)||(u=n.relatedOrders)!=null&&u.length)return n;let o=t.timeoutMs??8e3,i=t.intervalMs??2e3,a=Date.now()+o;for(;Date.now()<a;)if(await new Promise(p=>setTimeout(p,Math.min(i,Math.max(0,a-Date.now())))),n=await r(),(c=n.relatedOrders)!=null&&c.length)return n;return n}async getSubscriptions(e){return(await this.http.get(`/api/v1/customers/${e}/subscriptions`,{params:{storeId:this.storeId}})).subscriptions}async getSubscription(e){return(await this.http.get(`/api/v1/subscriptions/${e}`,{params:{storeId:this.storeId}})).subscription}};var fe=class{constructor(e,t){this.http=e;this.storeId=t}async getProducts(e){var n,o;let t={storeId:this.storeId,includeVariants:!0,includePrices:!0};return(n=e==null?void 0:e.productIds)!=null&&n.length&&(t.productIds=e.productIds),(o=e==null?void 0:e.variantIds)!=null&&o.length&&(t.variantIds=e.variantIds),(await this.http.post("/api/v1/products",t)).items??[]}async getProduct(e){return(await this.getProducts({productIds:[e]}))[0]??null}};var ye=class{constructor(e,t,r,n){this.http=e;this.storeId=t;this.checkout=r;this.accountId=n}async navigate(e){var a;let t=this.checkout.getCurrentSession();if(!t)throw new q("No checkout session loaded. Call sdk.checkout.loadSession(...) before sdk.funnel.navigate(...).","no_cart_loaded");let r=e.accountId??this.accountId;if(!r)throw new q("accountId is required for funnel.navigate(). Set it on createHeadlessClient({ accountId }) or pass it per call.","missing_account_id");let n=e.currentUrl??(typeof globalThis<"u"?(a=globalThis.location)==null?void 0:a.href:void 0);await this.ensureCmsSession(t,r,e);let o=await this.initializeFunnel({funnelId:e.funnelId,stepId:e.stepId,accountId:r,currentUrl:n});return{url:await this.runNavigate({funnelSessionId:o,stepId:e.stepId,session:t,input:e,currentUrl:n}),funnelSessionId:o}}async ensureCmsSession(e,t,r){var i,a,u;if(this._cmsToken&&this._cmsSessionId&&this._cmsCustomerId)return;let n=await this.http.post("/api/v1/cms/session/anonymous",{storeId:this.storeId,role:"anonymous",draft:!1});this._cmsToken=n.token,this._cmsSessionId=n.sessionId;let o=await this.http.post("/api/v1/cms/session/v2/init",{storeId:this.storeId,accountId:t,customerId:"anon_placeholder",browserLocale:((i=r.customer)==null?void 0:i.locale)??dt(),userAgent:lt(),queryCurrency:((a=r.customer)==null?void 0:a.currency)??e.currency,queryLocale:(u=r.customer)==null?void 0:u.locale},{token:this._cmsToken});this._cmsCustomerId=o.customer.id}async initializeFunnel(e){return(await this.http.post("/api/v1/funnel/initialize",{cmsSession:{customerId:this._cmsCustomerId,sessionId:this._cmsSessionId,storeId:this.storeId,accountId:e.accountId},funnelId:e.funnelId,entryStepId:e.stepId,funnelStepId:e.stepId,currentUrl:e.currentUrl,draft:!1},{token:this._cmsToken})).context.sessionId}async runNavigate(e){var l,h,m,d;let{funnelSessionId:t,stepId:r,session:n,input:o,currentUrl:i}=e,a=n.items.map(y=>({variantId:y.variantId,priceId:y.priceId,quantity:y.quantity})),u=o.discountCodes??(n.promotionCode?[n.promotionCode]:void 0),c={email:((l=o.customer)==null?void 0:l.email)??((h=n.customer)==null?void 0:h.email),currency:((m=o.customer)==null?void 0:m.currency)??n.currency,locale:(d=o.customer)==null?void 0:d.locale};return(await this.http.post("/api/v1/funnel/navigate",{sessionId:t,currentUrl:i,funnelStepId:r,fireAndForget:!1,event:{type:"INIT_CHECKOUT",data:{checkoutInit:{cartToken:n.id,lineItems:a,customer:c,returnUrl:o.returnUrl,storeId:this.storeId,metadata:o.metadata,discountCodes:u,externalShipping:o.externalShipping}}}},{token:this._cmsToken})).result.url}};function dt(){return typeof navigator<"u"&&navigator.language?navigator.language:"en-US"}function lt(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"tagadapay-headless-sdk"}var he=class{constructor(e){this.http=e}async isRequiredForProduct(e,t){return this.http.get("/api/public/v1/rx/required-for-product",{params:{productId:e,clinicalNetworkId:t==null?void 0:t.clinicalNetworkId}})}async getCasesForOrder(e){return this.http.post("/api/public/v1/rx/cases/lookup",e)}async submitCase(e){return this.http.post("/api/public/v1/rx/cases/submit",e)}async getQuestionsForProduct(e){return this.http.get("/api/public/v1/rx/questions-for-product",{params:{productId:e}})}};var Re=class{constructor(e){let t=e.environment??"production",r=X.resolveBaseUrl(t,e.baseUrl);this.config={...e,environment:t,baseUrl:r,timeout:e.timeout??3e4},this.http=new X({baseUrl:r,timeout:this.config.timeout,apiKey:e.apiKey,getToken:()=>this._sessionToken});let n=o=>{this._sessionToken=o};this.checkout=new ee(this.http,this.config.storeId,n),this.payment=new me(this.http,this.config.storeId,t,this.checkout),this.offers=new pe(this.http,this.config.storeId,this.payment),this.customer=new ge(this.http,this.config.storeId),this.catalog=new fe(this.http,this.config.storeId),this.funnel=new ye(this.http,this.config.storeId,this.checkout,this.config.accountId),this.rx=new he(this.http)}setSessionToken(e){this._sessionToken=e}};function De(s){return new Re(s)}var qe=F("react/jsx-runtime"),Me=(0,Q.createContext)(null);function Fe({storeId:s,environment:e,apiKey:t,baseUrl:r,config:n,children:o}){let i=(0,Q.useMemo)(()=>De(n??{storeId:s,environment:e,apiKey:t,baseUrl:r}),[s,e,t,r,n]),a=(0,Q.useMemo)(()=>({client:i}),[i]);return(0,qe.jsx)(Me.Provider,{value:a,children:o})}function D(){let s=(0,Q.useContext)(Me);if(!s)throw new Error("useHeadlessClient must be used within <TagadaHeadlessProvider>");return s.client}var T=F("react");function Ge(s,e){let t=D(),[r,n]=(0,T.useState)(null),[o,i]=(0,T.useState)(!1),[a,u]=(0,T.useState)(null),c=(0,T.useCallback)(async()=>{if(s){i(!0),u(null);try{let C=await t.checkout.loadSession(s,e);n(C)}catch(C){u(C instanceof Error?C:new Error(String(C)))}finally{i(!1)}}},[t,s,e]);(0,T.useEffect)(()=>{c()},[c]);let p=(0,T.useCallback)(async C=>{i(!0),u(null);try{let P=await t.checkout.createSession(C),I=new URL(window.location.href);I.searchParams.set("checkoutToken",P.checkoutToken),I.searchParams.set("token",P.sessionToken),window.history.replaceState({},"",I.toString());let O=await t.checkout.loadSession(P.checkoutToken,P.sessionToken);n(O)}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}},[t]),l=(0,T.useCallback)(async C=>{u(null);try{return await t.checkout.createSessionUrl(C)}catch(P){let I=P instanceof Error?P:new Error(String(P));throw u(I),I}},[t]),h=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.updateCart(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]),m=(0,T.useCallback)(async C=>{r&&await t.checkout.updateCustomer(r.id,C)},[t,r]),d=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.updateAddress(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]),y=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.updateCustomerAndAddress(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]),f=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.applyPromoCode(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]),g=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.removePromoCode(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]),k=(0,T.useCallback)(async()=>r?t.checkout.getShippingRates(r.id):[],[t,r]),E=(0,T.useCallback)(async C=>{if(r){i(!0);try{await t.checkout.selectShippingRate(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{i(!1)}}},[t,r,c]);return{session:r,isLoading:o,error:a,refresh:c,createSession:p,createSessionUrl:l,updateCart:h,updateCustomer:m,updateAddress:d,updateCustomerAndAddress:y,applyPromo:f,removePromo:g,getShippingRates:k,selectShippingRate:E}}var b=F("react");var $e=new Set;function Pe(s){return $e.has(s)?!1:($e.add(s),!0)}function He(s){let e=D(),[t,r]=(0,b.useState)(null),[n,o]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),[u,c]=(0,b.useState)(!1),[p,l]=(0,b.useState)(null),[h,m]=(0,b.useState)(null),d=(0,b.useRef)(!1),y=(0,b.useRef)(!1),f=(0,b.useRef)(s);f.current=s,(0,b.useEffect)(()=>{if(typeof window>"u"||y.current)return;let v=new URLSearchParams(window.location.search),w=v.get("paymentAction"),S=v.get("paymentActionStatus"),U=v.get("paymentId");if(w!=="requireAction"||S!=="completed"||!U||(y.current=!0,!Pe(U)))return;c(!0),m(null),(async()=>{var R,A,H,Y;try{let _=await e.payment.resumeAfterRedirect(U),ke=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status"].forEach(tt=>ke.delete(tt));let et=ke.toString()?`${window.location.pathname}?${ke.toString()}`:window.location.pathname;window.history.replaceState({},document.title,et),_.status==="succeeded"?(A=(R=f.current)==null?void 0:R.onPaymentSuccess)==null||A.call(R,_):_.status==="failed"&&(m(new Error(_.error)),(Y=(H=f.current)==null?void 0:H.onPaymentFailed)==null||Y.call(H,_))}catch(_){m(_ instanceof Error?_:new Error(String(_)))}finally{c(!1)}})()},[e]);let g=(0,b.useCallback)(async(v,w)=>{var U;if(d.current)return;d.current=!0;let S=w!=null&&w.paymentSetupConfig?{paymentSetupConfig:w.paymentSetupConfig}:(U=f.current)!=null&&U.paymentSetupConfig?{paymentSetupConfig:f.current.paymentSetupConfig}:void 0;try{let[N,R,A]=await Promise.all([e.payment.getPaymentSetup(v,S),e.payment.getExpressMethods(v,S),e.payment.getStoreConfig()]);r(N),o(R),a(A)}catch(N){d.current=!1,m(N instanceof Error?N:new Error(String(N)))}},[e]),k=(0,b.useCallback)(async v=>{var w,S,U,N;c(!0),m(null);try{let R=await e.payment.processPayment(v);if(R.status==="requires_redirect"){if(R.method==="POST"&&R.postData){let A=document.createElement("form");A.method="POST",A.action=R.redirectUrl;for(let[H,Y]of Object.entries(R.postData)){let _=document.createElement("input");_.type="hidden",_.name=H,_.value=Y,A.appendChild(_)}document.body.appendChild(A),A.submit()}else window.location.href=R.redirectUrl;return R}return R.status==="succeeded"?(S=(w=f.current)==null?void 0:w.onPaymentSuccess)==null||S.call(w,R):R.status==="failed"&&(m(new Error(R.error)),(N=(U=f.current)==null?void 0:U.onPaymentFailed)==null||N.call(U,R)),R}catch(R){let A=R instanceof Error?R:new Error(String(R));return m(A),{status:"failed",error:A.message}}finally{c(!1)}},[e]),E=(0,b.useCallback)(v=>async()=>{c(!0),m(null);try{return await v()}catch(w){let S=w instanceof Error?w:new Error(String(w));throw m(S),S}finally{c(!1)}},[]),C=(0,b.useCallback)(async v=>{c(!0),m(null);try{let w=await e.payment.pay(v);return l(w),w}catch(w){let S=w instanceof Error?w:new Error(String(w));throw m(S),S}finally{c(!1)}},[e]),P=(0,b.useCallback)(v=>e.payment.tokenizeCard(v),[e]),I=(0,b.useCallback)(async v=>{let S=await E(()=>e.payment.processApplePay(v))();return l(S),S},[e,E]),O=(0,b.useCallback)(async v=>{let S=await E(()=>e.payment.processGooglePay(v))();return l(S),S},[e,E]),z=(0,b.useCallback)(async v=>{let S=await E(()=>e.payment.processApm(v))();return l(S),S},[e,E]),$=(0,b.useCallback)(v=>e.payment.pollPaymentStatus(v),[e]);return{paymentSetup:t,expressMethods:n,storeConfig:i,isProcessing:u,result:p,error:h,loadPaymentSetup:g,processPayment:k,pay:C,tokenizeCard:P,processApplePay:I,processGooglePay:O,processApm:z,pollStatus:$}}var x=F("react");function je(s){let e=D(),[t,r]=(0,x.useState)(null),[n,o]=(0,x.useState)(null),[i,a]=(0,x.useState)(!1),[u,c]=(0,x.useState)(null),p=(0,x.useRef)(s);p.current=s;let l=(0,x.useRef)(!1);(0,x.useEffect)(()=>{var w;if(typeof window>"u"||(w=p.current)!=null&&w.disableAutoResume||l.current)return;let I=new URLSearchParams(window.location.search),O=I.get("paymentAction"),z=I.get("paymentActionStatus"),$=I.get("paymentId");if(O!=="requireAction"||z!=="completed"||!$||(l.current=!0,!Pe($)))return;a(!0),c(null),(async()=>{var S,U,N,R;try{let A=await e.payment.resumeAfterRedirect($),H=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status"].forEach(_=>H.delete(_));let Y=H.toString()?`${window.location.pathname}?${H.toString()}`:window.location.pathname;window.history.replaceState({},document.title,Y),A.status==="succeeded"?(U=(S=p.current)==null?void 0:S.onOfferAccepted)==null||U.call(S,A):A.status==="failed"&&(c(new Error(A.error)),(R=(N=p.current)==null?void 0:N.onOfferDeclined)==null||R.call(N,A))}catch(A){c(A instanceof Error?A:new Error(String(A)))}finally{a(!1)}})()},[e]);let h=(0,x.useCallback)(async I=>{a(!0),c(null);try{return await I()}catch(O){let z=O instanceof Error?O:new Error(String(O));throw c(z),z}finally{a(!1)}},[]),m=(0,x.useCallback)(I=>h(async()=>{let O=await e.offers.getOffer(I);return r(O),O}),[e,h]),d=(0,x.useCallback)(I=>e.offers.listOffers(I),[e]),y=(0,x.useCallback)(I=>h(async()=>{let O=await e.offers.previewOffer(I);return o(O),O}),[e,h]),f=(0,x.useCallback)(I=>h(()=>e.offers.payPreviewedOffer(I)),[e,h]),g=(0,x.useCallback)(async I=>{var O,z,$,v;a(!0),c(null);try{let w=await e.offers.processOfferPayment(I);if(w.status==="requires_redirect"){if(w.method==="POST"&&w.postData){let S=document.createElement("form");S.method="POST",S.action=w.redirectUrl;for(let[U,N]of Object.entries(w.postData)){let R=document.createElement("input");R.type="hidden",R.name=U,R.value=N,S.appendChild(R)}document.body.appendChild(S),S.submit()}else window.location.href=w.redirectUrl;return w}return w.status==="succeeded"?(z=(O=p.current)==null?void 0:O.onOfferAccepted)==null||z.call(O,w):w.status==="failed"&&(c(new Error(w.error)),(v=($=p.current)==null?void 0:$.onOfferDeclined)==null||v.call($,w)),w}catch(w){let S=w instanceof Error?w:new Error(String(w));return c(S),{status:"failed",error:S.message}}finally{a(!1)}},[e]),k=(0,x.useCallback)(I=>e.offers.toggleOrderBump(I),[e]),E=(0,x.useCallback)(I=>e.offers.listPostPurchaseOffers(I),[e]),C=(0,x.useCallback)(I=>h(()=>e.offers.acceptPostPurchaseOffer(I)),[e,h]),P=(0,x.useCallback)(I=>h(()=>e.offers.declinePostPurchaseOffer(I)),[e,h]);return{offer:t,preview:n,isLoading:i,error:u,getOffer:m,listOffers:d,previewOffer:y,processOfferPayment:g,payPreviewedOffer:f,toggleOrderBump:k,listPostPurchaseOffers:E,acceptPostPurchaseOffer:C,declinePostPurchaseOffer:P}}var G=F("react");function Ke(s){let e=D(),[t,r]=(0,G.useState)(null),[n,o]=(0,G.useState)([]),[i,a]=(0,G.useState)([]),[u,c]=(0,G.useState)(!1),[p,l]=(0,G.useState)(null),h=(0,G.useCallback)(async f=>{c(!0),l(null);try{let g=await e.customer.getProfile(f);r(g)}catch(g){l(g instanceof Error?g:new Error(String(g)))}finally{c(!1)}},[e]),m=(0,G.useCallback)(async f=>{try{let g=await e.customer.getOrders(f);o(g.orders)}catch(g){l(g instanceof Error?g:new Error(String(g)))}},[e]),d=(0,G.useCallback)(async f=>{try{let g=await e.customer.getSubscriptions(f);a(g)}catch(g){l(g instanceof Error?g:new Error(String(g)))}},[e]),y=(0,G.useCallback)(async(f,g)=>{try{let k=await e.customer.updateProfile(f,g);r(k)}catch(k){l(k instanceof Error?k:new Error(String(k)))}},[e]);return(0,G.useEffect)(()=>{s&&h(s)},[s,h]),{customer:t,orders:n,subscriptions:i,isLoading:u,error:p,loadCustomer:h,loadOrders:m,loadSubscriptions:d,updateProfile:y}}var j=F("react");function Be(s,e){let t=D(),[r,n]=(0,j.useState)(null),[o,i]=(0,j.useState)(!1),[a,u]=(0,j.useState)(null),c=(e==null?void 0:e.watchRelatedOrders)??!0,p=(e==null?void 0:e.watchTimeoutMs)??8e3,l=(e==null?void 0:e.watchIntervalMs)??2e3,h=(0,j.useRef)(0),m=(0,j.useCallback)(async()=>{if(s)try{let d=await t.customer.getOrder(s);n(d)}catch(d){u(d instanceof Error?d:new Error(String(d)))}},[t,s]);return(0,j.useEffect)(()=>{if(!s)return;let d=++h.current,y=()=>h.current===d;return i(!0),u(null),(async()=>{var f,g;try{let k=await t.customer.getOrder(s);if(!y()||(n(k),i(!1),!c||(f=k.relatedOrders)!=null&&f.length))return;let E=Date.now()+p;for(;Date.now()<E&&y();){if(await new Promise(C=>setTimeout(C,l)),!y()||(k=await t.customer.getOrder(s),!y()))return;if((g=k.relatedOrders)!=null&&g.length){n(k);return}}}catch(k){if(!y())return;u(k instanceof Error?k:new Error(String(k))),i(!1)}})(),()=>{h.current++}},[t,s,c,p,l]),{order:r,relatedOrders:(r==null?void 0:r.relatedOrders)??[],isLoading:o,error:a,refresh:m}}var W=F("react");function ze(){let s=D(),[e,t]=(0,W.useState)([]),[r,n]=(0,W.useState)(!1),[o,i]=(0,W.useState)(null),a=(0,W.useCallback)(async c=>{n(!0),i(null);try{let p=await s.catalog.getProducts(c);return t(p),p}catch(p){let l=p instanceof Error?p:new Error(String(p));throw i(l),l}finally{n(!1)}},[s]),u=(0,W.useCallback)(async c=>{n(!0),i(null);try{return await s.catalog.getProduct(c)}catch(p){let l=p instanceof Error?p:new Error(String(p));throw i(l),l}finally{n(!1)}},[s]);return{products:e,isLoading:r,error:o,loadProducts:a,loadProduct:u}}var M=F("react");var mt=new Set(["approved","shipped","delivered","declined","cancelled","error"]);function Je(){let s=D(),[e,t]=(0,M.useState)([]),[r,n]=(0,M.useState)(null),[o,i]=(0,M.useState)(!1),[a,u]=(0,M.useState)(null),c=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>{c.current&&clearInterval(c.current)},[]);let p=(0,M.useCallback)(async(y,f)=>{i(!0),u(null);try{return await s.rx.isRequiredForProduct(y,f)}catch(g){let k=g instanceof Error?g:new Error(String(g));throw u(k),k}finally{i(!1)}},[s]),l=(0,M.useCallback)(async y=>{i(!0),u(null);try{return await s.rx.getQuestionsForProduct(y)}catch(f){let g=f instanceof Error?f:new Error(String(f));throw u(g),g}finally{i(!1)}},[s]),h=(0,M.useCallback)(async y=>{i(!0),u(null);try{let f=await s.rx.submitCase(y);return n(f),f}catch(f){let g=f instanceof Error?f:new Error(String(f));throw u(g),g}finally{i(!1)}},[s]),m=(0,M.useCallback)(async y=>{i(!0),u(null);try{let f=await s.rx.getCasesForOrder(y);return t(f.cases),f.cases}catch(f){let g=f instanceof Error?f:new Error(String(f));throw u(g),g}finally{i(!1)}},[s]),d=(0,M.useCallback)(({orderId:y,checkoutToken:f},g)=>{c.current&&clearInterval(c.current);let k=(g==null?void 0:g.intervalMs)??5e3,E=async()=>{var C;try{let P=await s.rx.getCasesForOrder({orderId:y,checkoutToken:f});t(P.cases),(C=g==null?void 0:g.onUpdate)==null||C.call(g,P.cases),P.cases.length>0&&P.cases.every(I=>mt.has(I.status))&&(c.current&&clearInterval(c.current),c.current=null)}catch(P){let I=P instanceof Error?P:new Error(String(P));u(I)}};return E(),c.current=setInterval(E,k),()=>{c.current&&clearInterval(c.current),c.current=null}},[s]);return{cases:e,lastSubmission:r,isLoading:o,error:a,isRequiredForProduct:p,getQuestionsForProduct:l,submitCase:h,fetchCasesForOrder:m,pollOrder:d}}var L=F("react");var Qe=!1,We=!1,we=[];function ve(){We=!0;for(let s of we)s();we.length=0}function te(s,e={}){var t,r;return We||(r=(t=window.google)==null?void 0:t.maps)!=null&&r.places?(ve(),Promise.resolve()):Qe?new Promise(n=>we.push(n)):(Qe=!0,new Promise((n,o)=>{if(we.push(n),document.querySelector('script[src*="maps.googleapis.com"]')){let c=()=>{var p,l;(l=(p=window.google)==null?void 0:p.maps)!=null&&l.places?ve():setTimeout(c,100)};c();return}let a=new URLSearchParams({key:s,libraries:"places",v:e.version??"weekly"});e.language&&a.set("language",e.language),e.region&&a.set("region",e.region);let u=document.createElement("script");u.src=`https://maps.googleapis.com/maps/api/js?${a}`,u.async=!0,u.defer=!0,u.onload=()=>ve(),u.onerror=()=>o(new Error("Failed to load Google Maps script")),document.head.appendChild(u)}))}var K=class s{static async searchPlaces(e,t={}){var n,o;if(!((o=(n=window.google)==null?void 0:n.maps)!=null&&o.places)||!e.trim())return[];let r=new window.google.maps.places.AutocompleteService;return new Promise(i=>{r.getPlacePredictions({input:e,types:t.types??["address"],componentRestrictions:t.componentRestrictions},(a,u)=>{var c,p,l;i(u===((l=(p=(c=window.google)==null?void 0:c.maps)==null?void 0:p.places)==null?void 0:l.PlacesServiceStatus.OK)&&a?a:[])})})}static async getPlaceDetails(e){var r,n;if(!((n=(r=window.google)==null?void 0:r.maps)!=null&&n.places))return null;let t=new window.google.maps.places.PlacesService(document.createElement("div"));return new Promise(o=>{t.getDetails({placeId:e,fields:["place_id","formatted_address","address_components","geometry"]},(i,a)=>{var u,c,p;o(a===((p=(c=(u=window.google)==null?void 0:u.maps)==null?void 0:c.places)==null?void 0:p.PlacesServiceStatus.OK)&&i?i:null)})})}static extractAddressComponents(e){let t={subpremise:"",streetNumber:"",route:"",locality:"",administrativeAreaLevel1:"",administrativeAreaLevel1Long:"",administrativeAreaLevel2:"",administrativeAreaLevel2Long:"",country:"",postalCode:"",fullStreetAddress:""},r="",n="",o="",i="",a="",u="",c="",p="";for(let m of e.address_components??[]){let d=m.types;d.includes("subpremise")&&(t.subpremise=m.long_name),d.includes("street_number")&&(t.streetNumber=m.long_name),d.includes("premise")&&(r=m.long_name),d.includes("route")&&(t.route=m.long_name),d.includes("neighborhood")&&(n=m.long_name),d.includes("sublocality_level_5")&&(o=m.long_name),d.includes("sublocality_level_4")&&(i=m.long_name),d.includes("sublocality_level_3")&&(a=m.long_name),d.includes("sublocality_level_2")&&(u=m.long_name),d.includes("sublocality_level_1")&&(c=m.long_name),d.includes("locality")&&(t.locality=m.long_name),d.includes("postal_town")&&(p=m.long_name),d.includes("administrative_area_level_2")&&(t.administrativeAreaLevel2=m.short_name,t.administrativeAreaLevel2Long=m.long_name),d.includes("administrative_area_level_1")&&(t.administrativeAreaLevel1=m.short_name,t.administrativeAreaLevel1Long=m.long_name),d.includes("country")&&(t.country=m.short_name),d.includes("postal_code")&&(t.postalCode=m.long_name)}t.locality||(t.locality=p||u||c||""),!t.administrativeAreaLevel1&&t.administrativeAreaLevel2&&(t.administrativeAreaLevel1=t.administrativeAreaLevel2Long||t.administrativeAreaLevel2,t.administrativeAreaLevel1Long=t.administrativeAreaLevel2Long);let l=t.streetNumber||r,h=t.route||o||i||a||n;if(t.subpremise&&l&&h)t.fullStreetAddress=`${t.subpremise}/${l} ${h}`;else if(l&&h)if(r&&i&&a){let m=`${a}-${i}-${r}`;u&&(m=`${m} ${u}`),t.fullStreetAddress=m}else t.fullStreetAddress=`${l} ${h}`;else h?t.fullStreetAddress=h:l&&(t.fullStreetAddress=l);return t.fullStreetAddress=t.fullStreetAddress.trim(),t}static extractFormattedAddress(e){let t=s.extractAddressComponents(e);return{address1:t.fullStreetAddress,city:t.locality,country:t.country,state:t.administrativeAreaLevel1,postal:t.postalCode}}};function Ve(s){let{apiKey:e,language:t,region:r,version:n,defer:o=!1}=s,[i,a]=(0,L.useState)([]),[u,c]=(0,L.useState)(!1),[p,l]=(0,L.useState)(!1),h=(0,L.useRef)(null),m=(0,L.useRef)(null),d=(0,L.useCallback)(()=>{te(e,{language:t,region:r,version:n}).then(()=>l(!0))},[e,t,r,n]);(0,L.useEffect)(()=>{!e||o||d()},[e,o,d]),(0,L.useEffect)(()=>{if(p&&m.current){let{input:C,country:P}=m.current;m.current=null,y(C,P)}},[p]);let y=(0,L.useCallback)((C,P)=>{if(!p){o&&(m.current={input:C,country:P},d());return}if(C.length<3){a([]);return}h.current&&clearTimeout(h.current),h.current=setTimeout(async()=>{c(!0);let I=await K.searchPlaces(C,{componentRestrictions:P?{country:P.toLowerCase()}:void 0});a(I),c(!1)},300)},[p,o,d]),f=(0,L.useCallback)(C=>K.getPlaceDetails(C),[]),g=(0,L.useCallback)(C=>K.extractAddressComponents(C),[]),k=(0,L.useCallback)(C=>K.extractFormattedAddress(C),[]),E=(0,L.useCallback)(()=>a([]),[]);return{predictions:i,isLoading:u,isScriptLoaded:p,searchPlaces:y,getPlaceDetails:f,extractAddressComponents:g,extractFormattedAddress:k,clearPredictions:E}}var J=F("react");var Ye="https://cvwnizdbugpz6jwk.public.blob.vercel-storage.com/geodata/v1",xe=["en","ru","de","da","fr","es","zh","hi","pt","ja","ar","it","he"],re=new Map,Ce=new Map,Ae=new Map,be=new Map;async function pt(s){let e=re.get(s);if(e)return e;let t=Ae.get(s);return t||(t=(async()=>{let r=`${Ye}/${s}/countries.json`,n=await fetch(r);if(!n.ok)throw new Error(`Geodata fetch failed: ${r} (${n.status})`);let o=await n.json();return re.set(s,o),Ae.delete(s),o})(),Ae.set(s,t),t)}async function gt(s){let e=Ce.get(s);if(e)return e;let t=be.get(s);return t||(t=(async()=>{let r=`${Ye}/${s}/regions.json`,n=await fetch(r);if(!n.ok)throw new Error(`Geodata fetch failed: ${r} (${n.status})`);let o=await n.json();return Ce.set(s,o),be.delete(s),o})(),be.set(s,t),t)}function ft(s){return re.get(s)||re.get("en")||{}}function yt(s){return Ce.get(s)||Ce.get("en")||{}}async function ne(s="en"){await Promise.all([pt(s),gt(s)])}var Ie=(s="en")=>{let e=ft(s);return Object.entries(e).map(([t,r])=>({code:t,name:r.n,iso3:r.i3,numeric:r.nu})).sort((t,r)=>t.name.localeCompare(r.name))},Oe=(s,e="en")=>{let r=yt(e)[s];return r?r.map(([n,o])=>({code:n,name:o,countryCode:s})).sort((n,o)=>n.name.localeCompare(o.name)):[]};function se(s){return re.has(s)}var B=class s{static ensureLoaded(e="en"){return ne(e)}static getCountries(e="en"){let t=Ie(e),r={};for(let n of t)r[n.code]={iso:n.code,iso3:n.iso3??"",numeric:n.numeric??0,name:n.name};return r}static getCountryOptions(e="en"){return Ie(e).map(t=>({value:t.code,label:t.name}))}static getRegions(e,t="en"){return Oe(e,t).map(r=>({iso:r.code,name:r.name}))}static getRegionOptions(e,t="en"){return s.getRegions(e,t).map(r=>({value:r.iso,label:r.name}))}static findRegion(e,t,r="en"){return s.getRegions(e,r).find(n=>n.iso===t)??null}static mapGoogleToISO(e,t,r,n="en"){let o=s.getRegions(r,n);if(o.length===0)return null;let i=o.find(a=>a.iso===e);return i||(i=o.find(a=>a.name.toLowerCase()===e.toLowerCase()),i)||(i=o.find(a=>a.name.toLowerCase()===t.toLowerCase()),i)?i:(i=o.find(a=>a.name.toLowerCase().includes(t.toLowerCase())||t.toLowerCase().includes(a.name.toLowerCase())),i??null)}static isLanguageLoaded(e){return se(e)}static getAvailableLanguages(){return xe}};function Se(s="en"){let[e,t]=(0,J.useState)(se(s));return(0,J.useEffect)(()=>{let r=!1;return ne(s).then(()=>{r||t(!0)}).catch(n=>console.error("[headless-sdk] Failed to load geodata:",n)),()=>{r=!0}},[s]),(0,J.useMemo)(()=>e?{countries:B.getCountries(s),getRegions:r=>B.getRegions(r,s),findRegion:(r,n)=>B.findRegion(r,n,s),mapGoogleToISO:(r,n,o)=>B.mapGoogleToISO(r,n,o,s),isLoaded:!0}:{countries:{},getRegions:()=>[],findRegion:()=>null,mapGoogleToISO:()=>null,isLoaded:!1},[s,e])}function Ze(s="en"){let{countries:e,isLoaded:t}=Se(s);return(0,J.useMemo)(()=>t?Object.values(e).map(r=>({value:r.iso,label:r.name})).sort((r,n)=>r.label.localeCompare(n.label)):[],[e,t])}function Xe(s,e="en"){let{getRegions:t,isLoaded:r}=Se(e);return(0,J.useMemo)(()=>!r||!s?[]:t(s).map(n=>({value:n.iso,label:n.name})).sort((n,o)=>n.label.localeCompare(o.label)),[s,t,r])}var ht={USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5",CAD:"C$",AUD:"A$",CHF:"CHF",CNY:"\xA5",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"z\u0142",CZK:"K\u010D",HUF:"Ft",RON:"lei",BGN:"\u043B\u0432",HRK:"kn",RUB:"\u20BD",UAH:"\u20B4",TRY:"\u20BA",BRL:"R$",MXN:"$",ZAR:"R",INR:"\u20B9",KRW:"\u20A9",THB:"\u0E3F",VND:"\u20AB",IDR:"Rp",MYR:"RM",SGD:"S$",PHP:"\u20B1",TWD:"NT$",HKD:"HK$",ILS:"\u20AA",AED:"\u062F.\u0625",SAR:"\u0631.\u0633",QAR:"\u0631.\u0642",KWD:"\u062F.\u0643",BHD:"\u062F.\u0628",OMR:"\u0631.\u0639.",EGP:"\xA3",NGN:"\u20A6",KES:"KSh",GHS:"\u20B5",COP:"$",ARS:"$",CLP:"$",PEN:"S/",CRC:"\u20A1",DOP:"RD$",JMD:"J$",BOB:"Bs",PYG:"\u20B2",GTQ:"Q",NIO:"C$",PAB:"B/.",PKR:"\u20A8",BDT:"\u09F3",LKR:"\u20A8",NPR:"\u20A8",GEL:"\u20BE",AMD:"\u058F",AZN:"\u20BC",KZT:"\u20B8"},Pt={USD:"US Dollar",EUR:"Euro",GBP:"British Pound",JPY:"Japanese Yen",CAD:"Canadian Dollar",AUD:"Australian Dollar",CHF:"Swiss Franc",CNY:"Chinese Yuan",SEK:"Swedish Krona",NOK:"Norwegian Krone",DKK:"Danish Krone",PLN:"Polish Zloty",CZK:"Czech Koruna",HUF:"Hungarian Forint",BRL:"Brazilian Real",MXN:"Mexican Peso",INR:"Indian Rupee",KRW:"South Korean Won",THB:"Thai Baht",SGD:"Singapore Dollar",HKD:"Hong Kong Dollar",TWD:"Taiwan Dollar",ILS:"Israeli Shekel",AED:"UAE Dirham",SAR:"Saudi Riyal",ZAR:"South African Rand",TRY:"Turkish Lira",RUB:"Russian Ruble",NGN:"Nigerian Naira"},wt=new Set(["JPY","KRW","VND","IDR","LAK","KHR","MMK","PYG"]),V=class s{static getSymbol(e){return ht[e]??e}static getName(e){return Pt[e]??e}static getDecimalPlaces(e){return wt.has(e)?0:2}static getCurrency(e){return{code:e,symbol:s.getSymbol(e),name:s.getName(e),decimalPlaces:s.getDecimalPlaces(e)}}};function Te(s,e="USD",t="en-US"){let r=V.getDecimalPlaces(e),n=s/(r===0?100:Math.pow(10,r));try{return new Intl.NumberFormat(t,{style:"currency",currency:e,minimumFractionDigits:r,maximumFractionDigits:r}).format(n)}catch{return`${V.getSymbol(e)}${n.toFixed(r)}`}}return ct(Ct);})();
|
|
6
|
+
"use strict";var TagadaHeadlessReactBundle=(()=>{var rt=Object.create;var oe=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var F=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var at=(s,e)=>{for(var t in e)oe(s,t,{get:e[t],enumerable:!0})},Ee=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of st(e))!ot.call(s,n)&&n!==t&&oe(s,n,{get:()=>e[n],enumerable:!(r=nt(e,n))||r.enumerable});return s};var Ue=(s,e,t)=>(t=s!=null?rt(it(s)):{},Ee(e||!s||!s.__esModule?oe(t,"default",{value:s,enumerable:!0}):t,s)),ct=s=>Ee(oe({},"__esModule",{value:!0}),s);var It={};at(It,{CurrencyUtils:()=>V,GoogleAutocompleteCore:()=>K,ISODataCore:()=>B,TagadaHeadlessProvider:()=>Fe,formatMoney:()=>Te,loadGoogleMapsScript:()=>re,parseTokensFromUrl:()=>Ne,useCatalog:()=>ze,useCheckout:()=>Ge,useCountryOptions:()=>Ze,useCustomer:()=>Ke,useGoogleAutocomplete:()=>Ve,useHeadlessClient:()=>D,useISOData:()=>Ie,useOffers:()=>je,useOrder:()=>Be,usePayment:()=>He,useRegionOptions:()=>Xe,useRx:()=>Je});var Q=F("react");var q=class extends Error{constructor(e,t,r,n){super(e),this.name="TagadaError",this.code=t,this.statusCode=r,this.details=n}},ae=class extends q{constructor(e="Authentication failed. Check your API key or checkout token."){super(e,"auth_error",401),this.name="TagadaAuthError"}},ce=class extends q{constructor(e,t=[],r,n){super(e,"validation_error",422,{errors:t,...n}),this.name="TagadaValidationError",this.errors=t,this.appCode=r}},Z=class extends q{constructor(e,t){super(`${e} "${t}" not found.`,"not_found",404),this.name="TagadaNotFoundError"}},ue=class extends q{constructor(e=1e3){super(`Rate limited. Retry after ${e}ms.`,"rate_limit",429),this.name="TagadaRateLimitError",this.retryAfterMs=e}};var X=class extends q{constructor(e="Network request failed. Check your connection."){super(e,"network_error"),this.name="TagadaNetworkError"}};var Le={production:"https://api.tagada.io",development:"https://api.tagada.dev",local:"http://localhost:3000"},ee=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.timeout=e.timeout,this.apiKey=e.apiKey,this.getToken=e.getToken}static resolveBaseUrl(e,t){return t??Le[e]??Le.production}async request(e,t={}){var l;let{method:r="GET",body:n,headers:i={},params:o,token:a,signal:u}=t,c=`${this.baseUrl}${e}`;if(o){let f=new URLSearchParams;for(let[g,I]of Object.entries(o))I!==void 0&&f.set(g,String(I));let y=f.toString();y&&(c+=`?${y}`)}let m={"Content-Type":"application/json",...i},d=a??this.apiKey??((l=this.getToken)==null?void 0:l.call(this));d&&(m["x-cms-token"]=d);let h=new AbortController,p=setTimeout(()=>h.abort(),this.timeout);try{let f=await fetch(c,{method:r,headers:m,body:n!=null?JSON.stringify(n):void 0,signal:u??h.signal});if(clearTimeout(p),f.ok){let y=await f.text();return y?JSON.parse(y):{}}throw await this.handleErrorResponse(f,e),new q("Unexpected error","unknown",f.status)}catch(f){throw clearTimeout(p),f instanceof q?f:f instanceof DOMException&&f.name==="AbortError"?new X(`Request to ${e} timed out after ${this.timeout}ms.`):new X(f instanceof Error?f.message:"Network request failed.")}}get(e,t){return this.request(e,{...t,method:"GET"})}post(e,t,r){return this.request(e,{...r,method:"POST",body:t})}patch(e,t,r){return this.request(e,{...r,method:"PATCH",body:t})}put(e,t,r){return this.request(e,{...r,method:"PUT",body:t})}delete(e,t){return this.request(e,{...t,method:"DELETE"})}async handleErrorResponse(e,t){let r={};try{r=await e.json()}catch{}let n=r.data??{},i=r.message??r.error??(typeof n.message=="string"?n.message:void 0)??(typeof r.data=="string"?r.data:void 0)??`Request failed: ${e.status} ${e.statusText} on ${t}`,o=typeof n.code=="string"?n.code:void 0;switch(e.status){case 401:case 403:throw new ae(i);case 404:throw new Z(t,"");case 422:{let a=Array.isArray(r.errors)?r.errors:[];throw new ce(i,a,o,r)}case 429:{let a=Number(e.headers.get("Retry-After")??"1")*1e3;throw new ue(a)}default:throw new q(i,"api_error",e.status,r)}}};var te=class s{constructor(e,t,r){this.http=e;this.storeId=t;this.onTokenChange=r}getCurrentSession(){return this._currentSession}async loadSession(e,t,r){var a;t&&(this.sessionToken=t,(a=this.onTokenChange)==null||a.call(this,t));let n={skipAsyncWait:"false"};r!=null&&r.currency&&(n.currency=r.currency);let i=await this.http.get(`/api/v1/checkout-sessions/${e}/v2`,{params:n,token:this.sessionToken}),o=this.normalizeSession(i);return this._currentSession=o,o}async createSession(e){var u,c,m;let t=e.items.map(d=>({variantId:d.variantId,priceId:d.priceId,quantity:d.quantity})),r={storeId:this.storeId,lineItems:t};e.returnUrl&&(r.returnUrl=e.returnUrl),(u=e.discountCodes)!=null&&u.length&&(r.discountCodes=e.discountCodes),e.metadata&&Object.keys(e.metadata).length>0&&(r.metadata=e.metadata),e.customerMetadata&&Object.keys(e.customerMetadata).length>0&&(r.customerMetadata=e.customerMetadata),(c=e.customerTags)!=null&&c.length&&(r.customerTags=e.customerTags);let n={};e.currency&&(n.currency=e.currency),e.customerEmail&&(n.email=e.customerEmail,n.firstName=e.customerFirstName,n.lastName=e.customerLastName),Object.keys(n).length>0&&(r.customer=n);let i=await this.http.post("/api/v1/checkout/session/init",r),a=new URL(i.checkoutUrl).searchParams.get("token")??"";return this.sessionToken=a,a&&((m=this.onTokenChange)==null||m.call(this,a)),{checkoutUrl:i.checkoutUrl,checkoutToken:i.checkoutToken,sessionToken:a,customerId:i.customerId}}async createSessionUrl(e){let t=await this.createSession({items:e.items,currency:e.currency,returnUrl:e.returnUrl,customerEmail:e.customerEmail,customerFirstName:e.customerFirstName,customerLastName:e.customerLastName}),r=e.origin??(typeof window<"u"?window.location.origin:""),n=e.checkoutPath??"/checkout",i=new URLSearchParams({checkoutToken:t.checkoutToken,sessionToken:t.sessionToken}),o=`${r}${n}?${i.toString()}`;return{...t,url:o}}static parseTokensFromUrl(e){if(typeof e>"u"&&typeof window>"u")return null;let t=e??window.location.href,r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get("checkoutToken");if(!n)return null;let i=r.searchParams.get("sessionToken")??r.searchParams.get("token")??"";return{checkoutToken:n,sessionToken:i}}parseTokensFromUrl(e){return s.parseTokensFromUrl(e)}async updateCart(e,t){let r=t.map(n=>({variantId:n.variantId,priceId:n.priceId,quantity:n.quantity}));return this.http.post(`/api/v1/checkout-sessions/${e}/line-items`,{lineItems:r},{token:this.sessionToken})}async updateCustomer(e,t){t.email&&(this.customerEmail=t.email),t.firstName&&(this.customerFirstName=t.firstName),t.lastName&&(this.customerLastName=t.lastName),t.phone&&(this.customerPhone=t.phone)}async updateAddress(e,t){let r=this.mapAddress(t.shippingAddress),n=this.mapAddress(t.billingAddress),i=r??n??{},o=n??r,a=!!(t.billingAddress&&t.shippingAddress);await this.http.post(`/api/v1/checkout-sessions/${e}/customer-and-session-info`,{checkoutSessionId:e,customerData:{email:this.customerEmail},shippingAddress:i,billingAddress:o??{},differentBillingAddress:a},{token:this.sessionToken})}async updateCustomerAndAddress(e,t){t.customer.email&&(this.customerEmail=t.customer.email),t.customer.firstName&&(this.customerFirstName=t.customer.firstName),t.customer.lastName&&(this.customerLastName=t.customer.lastName),t.customer.phone&&(this.customerPhone=t.customer.phone);let r=this.mapAddress(t.shippingAddress),n=this.mapAddress(t.billingAddress),i=r??n??{},o=n??r,a=!!(t.billingAddress&&t.shippingAddress);await this.http.post(`/api/v1/checkout-sessions/${e}/customer-and-session-info`,{checkoutSessionId:e,customerData:{email:this.customerEmail},shippingAddress:i,billingAddress:o??{},differentBillingAddress:a},{token:this.sessionToken})}mapAddress(e){if(e)return ut({firstName:e.firstName??this.customerFirstName,lastName:e.lastName??this.customerLastName,phone:e.phone??this.customerPhone,address1:e.line1,address2:e.line2,city:e.city,state:e.state,postal:e.postalCode,country:e.country})}async applyPromoCode(e,t){await this.http.post(`/api/v1/checkout-sessions/${e}/promotions/apply`,{checkoutSessionId:e,code:t},{token:this.sessionToken})}async removePromoCode(e,t){let r=t??"default";await this.http.delete(`/api/v1/checkout-sessions/${e}/promotions/${r}`,{token:this.sessionToken})}async getShippingRates(e){return((await this.http.get(`/api/v1/checkout-sessions/${e}/shipping-rates`,{token:this.sessionToken})).rates??[]).map(r=>this.normalizeShippingRate(r))}normalizeShippingRate(e){return{id:e.id,name:e.name??e.shippingRateName??"",description:e.description??void 0,amount:e.amount??0,currency:e.currency??"USD",estimatedDays:e.estimatedDays??e.estimatedDeliveryTime??void 0}}async selectShippingRate(e,t){await this.http.post(`/api/v1/checkout-sessions/${e}/shipping-rate`,{checkoutSessionId:e,shippingRateId:t},{token:this.sessionToken})}normalizeSession(e){var m;let t=e.checkoutSession,r=t.orderSummaries??[],n=e.summary??t.summary??r[0]??{},i=t.sessionLineItems??[],o=t.customer,a=(m=n.currency??t.selectedPresentmentCurrency)==null?void 0:m.toUpperCase(),u=i.map(d=>{let h=d.price,p=d.variant??(h==null?void 0:h.variant)??{},l=d.product??p.product??{},f=(h==null?void 0:h.currencyOptions)??{},y=(a?f[a]:void 0)??f[Object.keys(f)[0]],g=(y==null?void 0:y.amount)??0;return{id:d.id,variantId:d.variantId,priceId:d.priceId,productName:l.name??"",variantName:p.name??"",quantity:d.quantity??1,unitAmount:g,totalAmount:g*(d.quantity??1),currency:a??"USD",imageUrl:p.imageUrl??l.imageUrl??""}}),c=n.items??[];return{id:t.id,storeId:t.storeId,checkoutToken:t.checkoutToken,currency:a??"USD",items:u,totals:{subtotal:n.subtotalAmount??0,discount:n.totalPromotionAmount??0,shipping:n.shippingCost??0,tax:n.totalTaxAmount??0,total:n.totalAdjustedAmount??n.totalAmount??c.reduce((d,h)=>d+(h.amount??0),0),currency:a??"USD"},customer:o?{id:o.id,email:o.email,firstName:o.firstName,lastName:o.lastName,phone:o.phone}:void 0,shippingAddress:this.normalizeAddress(t.shippingAddress),billingAddress:this.normalizeAddress(t.billingAddress),selectedShippingRateId:t.shippingRateId??null,metadata:t.metadata}}normalizeAddress(e){if(!e||typeof e!="object")return;let t=e,r={firstName:t.firstName,lastName:t.lastName,line1:t.line1??t.address1,line2:t.line2??t.address2,city:t.city,state:t.state,postalCode:t.postalCode??t.postal,country:t.country,phone:t.phone};return Object.values(r).some(n=>n!==void 0&&n!=="")?r:void 0}},Ne=te.parseTokensFromUrl;function ut(s){let e={};for(let[t,r]of Object.entries(s))r!=null&&r!==""&&(e[t]=r);return Object.keys(e).length>0?e:void 0}function de(s){var t,r;if(!s)return;let e={firstName:s.givenName,lastName:s.familyName,line1:(t=s.addressLines)==null?void 0:t[0],line2:(r=s.addressLines)==null?void 0:r[1],city:s.locality,state:s.administrativeArea,postalCode:s.postalCode,country:s.countryCode,phone:s.phoneNumber};return _e(e)?e:void 0}function le(s){if(!s)return;let[e,...t]=(s.name??"").trim().split(/\s+/),r={firstName:e||void 0,lastName:t.length?t.join(" "):void 0,line1:s.address1,line2:[s.address2,s.address3].filter(Boolean).join(" ")||void 0,city:s.locality,state:s.administrativeArea,postalCode:s.postalCode,country:s.countryCode,phone:s.phoneNumber};return _e(r)?r:void 0}function _e(s){var e,t;return!!((e=s.line1)!=null&&e.trim()&&((t=s.country)!=null&&t.trim()))}var dt=new Set(["apple_pay","google_pay","paypal","klarna","klarna_express","link"]);function lt(s){var o;let e=s.type==="credit-card",t=e?"card":s.type,r=s.settings??{},n=r.processors,i=r.publishableKey;return{enabled:!0,method:t,provider:e?void 0:s.type,type:e?"card":s.type,label:s.title,logoUrl:s.iconUrl,express:dt.has(t),integrationId:e?void 0:s.id,processorId:(o=n==null?void 0:n[0])==null?void 0:o.processorId,publishableKey:typeof i=="string"?i:void 0,metadata:s.metadata??void 0}}var me=class{constructor(e,t,r,n){this.http=e;this.storeId=t;this.environment=r;this.checkout=n;this.lastPaymentSetup=null}async getPaymentSetup(e,t){if(t!=null&&t.paymentSetupConfig)return this.lastPaymentSetup=t.paymentSetupConfig,t.paymentSetupConfig;let r=this.readInjectedStepConfig();if(r)return this.lastPaymentSetup=r,r;try{let i=await this.http.get(`/api/v1/checkout-sessions/${e}/payment-setup`),o={...(i==null?void 0:i.config)??{}};return this.lastPaymentSetup=o,o}catch(i){if(!(i instanceof Z))throw i}let n=await this.getPaymentSetupFromPickerList(e);return this.lastPaymentSetup=n,n}async getPaymentSetupFromPickerList(e){let t=await this.http.get("/api/v1/payment-methods",{params:{checkoutSessionId:e}}),r=Array.isArray(t)?t.map(lt):(t==null?void 0:t.methods)??[],n={};for(let i of r){let o=i.provider&&i.provider!==i.method?`${i.method}:${i.provider}`:i.method;n[o]=i}return n}async getExpressMethods(e,t){var i,o,a,u,c,m,d,h;let r=await this.getPaymentSetup(e,t),n={};for(let[p,l]of Object.entries(r)){if(!l.enabled)continue;if(p.startsWith("express_checkout:")&&l.methods){let g={available:!0,processorId:l.processorId,publishableKey:l.publishableKey,metadata:l.metadata};if((i=l.methods.apple_pay)!=null&&i.enabled){let I=typeof window<"u"&&"ApplePaySession"in window&&((a=(o=window.ApplePaySession)==null?void 0:o.canMakePayments)==null?void 0:a.call(o));n.applePay={...g,type:"apple_pay",available:!!I}}(u=l.methods.google_pay)!=null&&u.enabled&&(n.googlePay={...g,type:"google_pay"}),(c=l.methods.link)!=null&&c.enabled&&(n.link={...g,type:"link"}),(m=l.methods.klarna_express)!=null&&m.enabled&&(n.klarna={...g,type:"klarna_express"});continue}if(!l.express)continue;let f=l.method,y={type:f,available:!0,processorId:l.processorId,publishableKey:l.publishableKey,metadata:l.metadata};if(f==="apple_pay"||l.type==="apple_pay"){let g=typeof window<"u"&&"ApplePaySession"in window&&((h=(d=window.ApplePaySession)==null?void 0:d.canMakePayments)==null?void 0:h.call(d));n.applePay={...y,available:!!g}}else f==="google_pay"||l.type==="google_pay"?n.googlePay=y:f==="paypal"?n.paypal=y:f==="klarna"||f==="klarna_express"?n.klarna=y:f==="link"&&(n.link=y)}return n}async getStoreConfig(){let e=await this.http.get("/api/v1/checkout/config",{params:{storeId:this.storeId}});return e.config??e}async getEnabledMethods(e,t){let r=await this.getPaymentSetup(e,t);return Object.entries(r).filter(([,n])=>n.enabled).map(([n])=>n)}async tokenizeCard(e){let t=await this.loadCoreJs(),r=new t.Tokenizer({environment:this.environment});await r.initialize();let n={cardNumber:e.cardNumber,expiryDate:e.expiryDate,cvc:e.cvc};e.cardholderName&&(n.cardholderName=e.cardholderName);let i=await r.tokenizeCardRaw(n);return{tagadaToken:t.createTagadaToken(i,r.getProvider().getProviderName()),rawToken:i}}async createInstrument(e){return this.http.post("/api/v1/payment/create-instrument-from-token",{tagadaToken:e.tagadaToken})}async create3dsSession(e){return this.http.post("/api/public/v1/threeds/create-session",{provider:e.provider??"basis_theory",storeId:this.storeId,paymentInstrumentId:e.paymentInstrumentId,sessionData:e.sessionData})}async pay(e){return e.tagadaToken&&!e.paymentInstrumentId?this.http.post("/api/v1/payment/pay-with-token",{tagadaToken:e.tagadaToken,checkoutSessionId:e.checkoutSessionId,returnUrl:e.returnUrl,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,metadata:e.metadata}):this.http.post("/api/public/v1/checkout/pay-v2",{checkoutSessionId:e.checkoutSessionId,paymentInstrumentId:e.paymentInstrumentId,storeId:this.storeId,paymentFlowId:e.paymentFlowId,threedsSessionId:e.threedsSessionId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,metadata:e.metadata,returnUrl:e.returnUrl})}async payDirect(e){return this.http.post("/api/public/v1/checkout/pay-v2",{checkoutSessionId:e.checkoutSessionId,paymentInstrumentId:e.paymentInstrumentId??"",storeId:this.storeId,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:e.isExpress,threedsSessionId:e.threedsSessionId,returnUrl:e.returnUrl})}async syncWalletContact(e,t){let{shippingAddress:r,billingAddress:n}=t;if(!r&&!n)return;if(!this.checkout)throw new Error("PaymentModule cannot persist the wallet contact: no CheckoutModule was provided. Build the SDK through createTagadaClient() rather than constructing PaymentModule directly.");let i={};t.email&&(i.email=t.email),t.phone&&(i.phone=t.phone),t.firstName&&(i.firstName=t.firstName),t.lastName&&(i.lastName=t.lastName),await this.checkout.updateCustomerAndAddress(e,{customer:i,shippingAddress:r,billingAddress:n})}async processApplePay(e){var a,u,c,m,d,h,p,l,f;await this.syncWalletContact(e.checkoutSessionId,{shippingAddress:de(e.shippingContact),billingAddress:de(e.billingContact),email:((a=e.shippingContact)==null?void 0:a.emailAddress)??((u=e.billingContact)==null?void 0:u.emailAddress),phone:((c=e.shippingContact)==null?void 0:c.phoneNumber)??((m=e.billingContact)==null?void 0:m.phoneNumber),firstName:((d=e.shippingContact)==null?void 0:d.givenName)??((h=e.billingContact)==null?void 0:h.givenName),lastName:((p=e.shippingContact)==null?void 0:p.familyName)??((l=e.billingContact)==null?void 0:l.familyName)});let t=e.merchantRegistrationId??((f=await this.resolveApplePayRegistration(e.checkoutSessionId))==null?void 0:f.merchantRegistrationId),r=await this.loadCoreJs(),n=new r.Tokenizer({environment:this.environment});await n.initialize();let i=await n.tokenizeApplePay(e.applePayToken,t),o=btoa(JSON.stringify(r.createTagadaDigitalWalletToken(i,"apple_pay")));return this.pay({checkoutSessionId:e.checkoutSessionId,tagadaToken:o,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:"apple_pay",isExpress:!0})}async resolveApplePayRegistration(e){if(typeof window>"u")return null;let t=window.location.hostname.toLowerCase().split(":")[0];t.startsWith("www.")&&(t=t.slice(4));let r=i=>{var o;for(let a of Object.values(i??{})){let u=(o=a==null?void 0:a.metadata)==null?void 0:o.applePayByok;if(!u||typeof u!="object")continue;let c=u[t];if(c!=null&&c.merchantRegistrationId)return{merchantRegistrationId:c.merchantRegistrationId,displayName:c.displayName}}return null},n=r(this.readInjectedStepConfig())??r(this.lastPaymentSetup);if(n)return n;if(this.lastPaymentSetup||this.readInjectedStepConfig()||!e)return null;try{return r(await this.getPaymentSetup(e))}catch{return null}}async processGooglePay(e){var o,a,u,c;await this.syncWalletContact(e.checkoutSessionId,{shippingAddress:le(e.shippingAddress),billingAddress:le(e.billingAddress),email:e.email??((o=e.shippingAddress)==null?void 0:o.emailAddress)??((a=e.billingAddress)==null?void 0:a.emailAddress),phone:((u=e.shippingAddress)==null?void 0:u.phoneNumber)??((c=e.billingAddress)==null?void 0:c.phoneNumber)});let t=await this.loadCoreJs(),r=new t.Tokenizer({environment:this.environment});await r.initialize();let n=await r.tokenizeGooglePay(e.googlePayToken),i=btoa(JSON.stringify(t.createTagadaDigitalWalletToken(n,"google_pay")));return this.pay({checkoutSessionId:e.checkoutSessionId,tagadaToken:i,paymentFlowId:e.paymentFlowId,processorId:e.processorId,paymentMethod:"google_pay",isExpress:!0})}async processApm(e){return this.payDirect({checkoutSessionId:e.checkoutSessionId,paymentMethod:e.paymentMethod,processorId:e.processorId,paymentFlowId:e.paymentFlowId})}async processStripeExpress(e){return this.payDirect({checkoutSessionId:e.checkoutSessionId,processorId:e.processorId,paymentMethod:e.paymentMethod,isExpress:!0})}async processPayment(e){!e.returnUrl&&typeof window<"u"&&(e={...e,returnUrl:window.location.href});let t=await this.pay(e);return this.finalize(t,{returnUrl:e.returnUrl})}async finalize(e,t){var i,o;let r=e.payment,n=(t==null?void 0:t.returnUrl)??(typeof window<"u"?window.location.href:void 0);return r.status==="succeeded"?{status:"succeeded",payment:r,order:e.order}:r.status==="failed"||r.status==="declined"?{status:"failed",error:((i=r.requireActionData)==null?void 0:i.message)||((o=r.requireActionData)==null?void 0:o.errorCode)||`Payment ${r.status}`,payment:r}:r.requireAction&&r.requireAction!=="none"&&r.requireActionData?this.handlePaymentAction(r,{returnUrl:n}):this.pollUntilDone(r.id)}async resumeAfterRedirect(e){return this.pollUntilDone(e)}async maybeResumeFromUrl(e){if(typeof window>"u"&&!(e!=null&&e.url))return null;let t=(e==null?void 0:e.url)??window.location.href,r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get("paymentAction"),i=r.searchParams.get("paymentActionStatus"),o=r.searchParams.get("paymentId");if(n!=="requireAction"||i!=="completed"||!o)return null;let a=await this.resumeAfterRedirect(o);if((e==null?void 0:e.cleanUrl)!==!1&&typeof window<"u"&&!(e!=null&&e.url)){let u=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status","sessionId"].forEach(m=>u.delete(m));let c=u.toString();try{window.history.replaceState({},document.title,window.location.pathname+(c?"?"+c:""))}catch{}}return a}async getPaymentStatus(e){return this.http.get(`/api/v1/payments/${e}`)}async pollPaymentStatus(e,t){let r=(t==null?void 0:t.intervalMs)??1500,n=(t==null?void 0:t.timeoutMs)??6e4,i=Date.now();for(;Date.now()-i<n;){let o=await this.getPaymentStatus(e);if(o.status==="succeeded"||o.status==="failed"||o.status==="declined")return o;await new Promise(a=>setTimeout(a,r))}throw new Error(`Payment ${e} did not reach terminal status within ${n}ms.`)}async completeAfter3ds(e){return this.http.post("/api/v1/payments/complete-after-3ds",{paymentId:e})}async markActionProcessed(e){try{await this.http.post("/api/v1/payments/require-action/processed",{paymentId:e})}catch{}}async handlePaymentAction(e,t){let r=e.requireActionData;switch(await this.markActionProcessed(e.id),r.type){case"threeds_auth":return this.handleThreedsAuth(e,t);case"processor_auth":case"redirect_to_payment":return this.extractRedirect(e,r);case"redirect":return this.extractRedirect(e,r);case"error":return{status:"failed",error:r.message||r.errorCode||"Payment failed",payment:e};default:return this.extractRedirect(e,r)}}extractRedirect(e,t){var i,o;let r=(i=t.metadata)==null?void 0:i.redirect,n=(r==null?void 0:r.redirectUrl)||t.redirectUrl;return n?{status:"requires_redirect",redirectUrl:n,method:((o=r==null?void 0:r.method)==null?void 0:o.toUpperCase())||"GET",postData:r==null?void 0:r.data,paymentId:e.id}:{status:"failed",error:`Payment requires action (${t.type}) but no redirect URL was provided`,payment:e}}async handleThreedsAuth(e,t){var i,o;let r=(o=(i=e.requireActionData)==null?void 0:i.metadata)==null?void 0:o.threedsSession;if(!(r!=null&&r.externalSessionId))return this.extractRedirect(e,e.requireActionData);let n;try{n=await import("@tagadapay/core-js")}catch{return r.acsChallengeUrl?{status:"requires_redirect",redirectUrl:r.acsChallengeUrl,paymentId:e.id}:this.extractRedirect(e,e.requireActionData)}try{let a=new n.ThreedsManager({provider:"basis_theory"});return await a.initialize({apiKey:void 0}),await a.startChallenge({sessionId:r.externalSessionId,acsChallengeUrl:r.acsChallengeUrl,acsTransactionId:r.acsTransID,threeDSVersion:r.messageVersion}),await this.completeAfter3ds(e.id),this.pollUntilDone(e.id)}catch{return r.acsChallengeUrl?{status:"requires_redirect",redirectUrl:r.acsChallengeUrl,paymentId:e.id}:{status:"failed",error:"3D Secure authentication failed",payment:e}}}async pollUntilDone(e,t){let r=(t==null?void 0:t.intervalMs)??1500,n=(t==null?void 0:t.timeoutMs)??6e4,i=Date.now(),o=0;for(;Date.now()-i<n;){let a;try{a=await this.getPaymentStatus(e),o=0}catch{if(o++,o>=3)return{status:"failed",error:"Payment verification failed due to network errors"};await new Promise(u=>setTimeout(u,r));continue}if(a.status==="succeeded"||a.status==="pending"&&a.subStatus==="authorized")return{status:"succeeded",payment:a,order:a.order};if(a.status==="failed"||a.status==="declined")return{status:"failed",error:a.status,payment:a};if(a.requireAction&&a.requireAction!=="none"&&a.requireActionData&&!a.requireActionData.processed)return this.handlePaymentAction(a,{});await new Promise(u=>setTimeout(u,r))}return{status:"pending",paymentId:e}}readInjectedStepConfig(){if(typeof window>"u")return null;let e=window.__TGD_STEP_CONFIG__;if(!e)return null;try{let t=typeof e=="string"?JSON.parse(e):e;return(t==null?void 0:t.paymentSetupConfig)??null}catch{return null}}async loadCoreJs(){try{return await import("@tagadapay/core-js")}catch{throw new Error("This method requires @tagadapay/core-js. Install it: npm install @tagadapay/core-js")}}};var pe=class{constructor(e,t,r){this.http=e;this.storeId=t;this.payment=r}async getOffer(e){return this.http.get(`/api/v1/offers/${e}`)}async listOffers(e){var i;let t=`/api/v1/stores/${this.storeId}/offers`,r=[];if(e!=null&&e.type&&r.push(`type=${encodeURIComponent(e.type)}`),(i=e==null?void 0:e.ids)!=null&&i.length)for(let o of e.ids)r.push(`ids=${encodeURIComponent(o)}`);return r.length&&(t+=`?${r.join("&")}`),(await this.http.get(t)).offers??[]}async previewOffer(e){return this.http.post(`/api/v1/offers/${e.offerId}/preview`,{offerId:e.offerId,currency:e.currency??"",lineItems:e.lineItems})}async payPreviewedOffer(e){return this.http.post(`/api/v1/offers/${e.offerId}/pay-preview`,{offerId:e.offerId,currency:e.currency??"",lineItems:e.lineItems,returnUrl:e.returnUrl??(typeof window<"u"?window.location.href:""),mainOrderId:e.mainOrderId,paymentInstrumentId:e.paymentInstrumentId})}async processOfferPayment(e){if(!this.payment)throw new Error("OffersModule: no PaymentModule injected. Use createHeadlessClient() instead of constructing OffersModule directly.");let t=e.returnUrl??(typeof window<"u"?window.location.href:void 0),r=await this.payPreviewedOffer({...e,returnUrl:t});return this.payment.finalize({payment:r.payment,order:r.order},{returnUrl:t})}async toggleOrderBump(e){return this.http.post(`/api/v1/checkout-sessions/${e.checkoutSessionId}/toggle-order-bump`,{orderBumpOfferId:e.orderBumpOfferId,selected:e.selected})}async listPostPurchaseOffers(e){let t=await this.http.get(`/api/v1/post-purchase/${e}/offers`);return Array.isArray(t)?t:[]}async acceptPostPurchaseOffer(e){return this.http.post(`/api/v1/orders/${e.orderId}/post-purchase-offers/${e.offerId}/accept`,{items:e.items??[]})}async declinePostPurchaseOffer(e){return this.http.post(`/api/v1/orders/${e.orderId}/post-purchase-offers/${e.offerId}/decline`)}};var ge=class{constructor(e,t){this.http=e;this.storeId=t}async getProfile(e){return(await this.http.get(`/api/v1/customers/${e}`,{params:{storeId:this.storeId}})).customer}async getByEmail(e){try{return(await this.http.get("/api/v1/customers/by-email",{params:{email:e,storeId:this.storeId}})).customer}catch{return null}}async updateProfile(e,t){return(await this.http.patch(`/api/v1/customers/${e}`,{storeId:this.storeId,...t})).customer}async getOrders(e,t){return this.http.get(`/api/v1/customers/${e}/orders`,{params:{storeId:this.storeId,limit:t==null?void 0:t.limit,offset:t==null?void 0:t.offset}})}async getOrder(e,t){var u,c;let r=async()=>(await this.http.get(`/api/v1/orders/${e}`,{params:{storeId:this.storeId}})).order,n=await r();if(!(t!=null&&t.waitForRelatedOrders)||(u=n.relatedOrders)!=null&&u.length)return n;let i=t.timeoutMs??8e3,o=t.intervalMs??2e3,a=Date.now()+i;for(;Date.now()<a;)if(await new Promise(m=>setTimeout(m,Math.min(o,Math.max(0,a-Date.now())))),n=await r(),(c=n.relatedOrders)!=null&&c.length)return n;return n}async getSubscriptions(e){return(await this.http.get(`/api/v1/customers/${e}/subscriptions`,{params:{storeId:this.storeId}})).subscriptions}async getSubscription(e){return(await this.http.get(`/api/v1/subscriptions/${e}`,{params:{storeId:this.storeId}})).subscription}};var fe=class{constructor(e,t){this.http=e;this.storeId=t}async getProducts(e){var n,i;let t={storeId:this.storeId,includeVariants:!0,includePrices:!0};return(n=e==null?void 0:e.productIds)!=null&&n.length&&(t.productIds=e.productIds),(i=e==null?void 0:e.variantIds)!=null&&i.length&&(t.variantIds=e.variantIds),(await this.http.post("/api/v1/products",t)).items??[]}async getProduct(e){return(await this.getProducts({productIds:[e]}))[0]??null}};var ye=class{constructor(e,t,r,n){this.http=e;this.storeId=t;this.checkout=r;this.accountId=n}async navigate(e){var a;let t=this.checkout.getCurrentSession();if(!t)throw new q("No checkout session loaded. Call sdk.checkout.loadSession(...) before sdk.funnel.navigate(...).","no_cart_loaded");let r=e.accountId??this.accountId;if(!r)throw new q("accountId is required for funnel.navigate(). Set it on createHeadlessClient({ accountId }) or pass it per call.","missing_account_id");let n=e.currentUrl??(typeof globalThis<"u"?(a=globalThis.location)==null?void 0:a.href:void 0);await this.ensureCmsSession(t,r,e);let i=await this.initializeFunnel({funnelId:e.funnelId,stepId:e.stepId,accountId:r,currentUrl:n});return{url:await this.runNavigate({funnelSessionId:i,stepId:e.stepId,session:t,input:e,currentUrl:n}),funnelSessionId:i}}async ensureCmsSession(e,t,r){var o,a,u;if(this._cmsToken&&this._cmsSessionId&&this._cmsCustomerId)return;let n=await this.http.post("/api/v1/cms/session/anonymous",{storeId:this.storeId,role:"anonymous",draft:!1});this._cmsToken=n.token,this._cmsSessionId=n.sessionId;let i=await this.http.post("/api/v1/cms/session/v2/init",{storeId:this.storeId,accountId:t,customerId:"anon_placeholder",browserLocale:((o=r.customer)==null?void 0:o.locale)??mt(),userAgent:pt(),queryCurrency:((a=r.customer)==null?void 0:a.currency)??e.currency,queryLocale:(u=r.customer)==null?void 0:u.locale},{token:this._cmsToken});this._cmsCustomerId=i.customer.id}async initializeFunnel(e){return(await this.http.post("/api/v1/funnel/initialize",{cmsSession:{customerId:this._cmsCustomerId,sessionId:this._cmsSessionId,storeId:this.storeId,accountId:e.accountId},funnelId:e.funnelId,entryStepId:e.stepId,funnelStepId:e.stepId,currentUrl:e.currentUrl,draft:!1},{token:this._cmsToken})).context.sessionId}async runNavigate(e){var d,h,p,l;let{funnelSessionId:t,stepId:r,session:n,input:i,currentUrl:o}=e,a=n.items.map(f=>({variantId:f.variantId,priceId:f.priceId,quantity:f.quantity})),u=i.discountCodes??(n.promotionCode?[n.promotionCode]:void 0),c={email:((d=i.customer)==null?void 0:d.email)??((h=n.customer)==null?void 0:h.email),currency:((p=i.customer)==null?void 0:p.currency)??n.currency,locale:(l=i.customer)==null?void 0:l.locale};return(await this.http.post("/api/v1/funnel/navigate",{sessionId:t,currentUrl:o,funnelStepId:r,fireAndForget:!1,event:{type:"INIT_CHECKOUT",data:{checkoutInit:{cartToken:n.id,lineItems:a,customer:c,returnUrl:i.returnUrl,storeId:this.storeId,metadata:i.metadata,discountCodes:u,externalShipping:i.externalShipping}}}},{token:this._cmsToken})).result.url}};function mt(){return typeof navigator<"u"&&navigator.language?navigator.language:"en-US"}function pt(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"tagadapay-headless-sdk"}var he=class{constructor(e){this.http=e}async isRequiredForProduct(e,t){return this.http.get("/api/public/v1/rx/required-for-product",{params:{productId:e,clinicalNetworkId:t==null?void 0:t.clinicalNetworkId}})}async getCasesForOrder(e){return this.http.post("/api/public/v1/rx/cases/lookup",e)}async submitCase(e){return this.http.post("/api/public/v1/rx/cases/submit",e)}async getQuestionsForProduct(e,t){return this.http.get("/api/public/v1/rx/questions-for-product",{params:t?{productId:e,variantId:t}:{productId:e}})}};var Re=class{constructor(e){let t=e.environment??"production",r=ee.resolveBaseUrl(t,e.baseUrl);this.config={...e,environment:t,baseUrl:r,timeout:e.timeout??3e4},this.http=new ee({baseUrl:r,timeout:this.config.timeout,apiKey:e.apiKey,getToken:()=>this._sessionToken});let n=i=>{this._sessionToken=i};this.checkout=new te(this.http,this.config.storeId,n),this.payment=new me(this.http,this.config.storeId,t,this.checkout),this.offers=new pe(this.http,this.config.storeId,this.payment),this.customer=new ge(this.http,this.config.storeId),this.catalog=new fe(this.http,this.config.storeId),this.funnel=new ye(this.http,this.config.storeId,this.checkout,this.config.accountId),this.rx=new he(this.http)}setSessionToken(e){this._sessionToken=e}};function De(s){return new Re(s)}var qe=F("react/jsx-runtime"),Me=(0,Q.createContext)(null);function Fe({storeId:s,environment:e,apiKey:t,baseUrl:r,config:n,children:i}){let o=(0,Q.useMemo)(()=>De(n??{storeId:s,environment:e,apiKey:t,baseUrl:r}),[s,e,t,r,n]),a=(0,Q.useMemo)(()=>({client:o}),[o]);return(0,qe.jsx)(Me.Provider,{value:a,children:i})}function D(){let s=(0,Q.useContext)(Me);if(!s)throw new Error("useHeadlessClient must be used within <TagadaHeadlessProvider>");return s.client}var T=F("react");function Ge(s,e){let t=D(),[r,n]=(0,T.useState)(null),[i,o]=(0,T.useState)(!1),[a,u]=(0,T.useState)(null),c=(0,T.useCallback)(async()=>{if(s){o(!0),u(null);try{let C=await t.checkout.loadSession(s,e);n(C)}catch(C){u(C instanceof Error?C:new Error(String(C)))}finally{o(!1)}}},[t,s,e]);(0,T.useEffect)(()=>{c()},[c]);let m=(0,T.useCallback)(async C=>{o(!0),u(null);try{let P=await t.checkout.createSession(C),S=new URL(window.location.href);S.searchParams.set("checkoutToken",P.checkoutToken),S.searchParams.set("token",P.sessionToken),window.history.replaceState({},"",S.toString());let x=await t.checkout.loadSession(P.checkoutToken,P.sessionToken);n(x)}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}},[t]),d=(0,T.useCallback)(async C=>{u(null);try{return await t.checkout.createSessionUrl(C)}catch(P){let S=P instanceof Error?P:new Error(String(P));throw u(S),S}},[t]),h=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.updateCart(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]),p=(0,T.useCallback)(async C=>{r&&await t.checkout.updateCustomer(r.id,C)},[t,r]),l=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.updateAddress(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]),f=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.updateCustomerAndAddress(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]),y=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.applyPromoCode(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]),g=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.removePromoCode(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]),I=(0,T.useCallback)(async()=>r?t.checkout.getShippingRates(r.id):[],[t,r]),E=(0,T.useCallback)(async C=>{if(r){o(!0);try{await t.checkout.selectShippingRate(r.id,C),await c()}catch(P){u(P instanceof Error?P:new Error(String(P)))}finally{o(!1)}}},[t,r,c]);return{session:r,isLoading:i,error:a,refresh:c,createSession:m,createSessionUrl:d,updateCart:h,updateCustomer:p,updateAddress:l,updateCustomerAndAddress:f,applyPromo:y,removePromo:g,getShippingRates:I,selectShippingRate:E}}var b=F("react");var $e=new Set;function Pe(s){return $e.has(s)?!1:($e.add(s),!0)}function He(s){let e=D(),[t,r]=(0,b.useState)(null),[n,i]=(0,b.useState)(null),[o,a]=(0,b.useState)(null),[u,c]=(0,b.useState)(!1),[m,d]=(0,b.useState)(null),[h,p]=(0,b.useState)(null),l=(0,b.useRef)(!1),f=(0,b.useRef)(!1),y=(0,b.useRef)(s);y.current=s,(0,b.useEffect)(()=>{if(typeof window>"u"||f.current)return;let v=new URLSearchParams(window.location.search),w=v.get("paymentAction"),k=v.get("paymentActionStatus"),L=v.get("paymentId");if(w!=="requireAction"||k!=="completed"||!L||(f.current=!0,!Pe(L)))return;c(!0),p(null),(async()=>{var R,A,H,Y;try{let _=await e.payment.resumeAfterRedirect(L),ke=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status"].forEach(tt=>ke.delete(tt));let et=ke.toString()?`${window.location.pathname}?${ke.toString()}`:window.location.pathname;window.history.replaceState({},document.title,et),_.status==="succeeded"?(A=(R=y.current)==null?void 0:R.onPaymentSuccess)==null||A.call(R,_):_.status==="failed"&&(p(new Error(_.error)),(Y=(H=y.current)==null?void 0:H.onPaymentFailed)==null||Y.call(H,_))}catch(_){p(_ instanceof Error?_:new Error(String(_)))}finally{c(!1)}})()},[e]);let g=(0,b.useCallback)(async(v,w)=>{var L;if(l.current)return;l.current=!0;let k=w!=null&&w.paymentSetupConfig?{paymentSetupConfig:w.paymentSetupConfig}:(L=y.current)!=null&&L.paymentSetupConfig?{paymentSetupConfig:y.current.paymentSetupConfig}:void 0;try{let[N,R,A]=await Promise.all([e.payment.getPaymentSetup(v,k),e.payment.getExpressMethods(v,k),e.payment.getStoreConfig()]);r(N),i(R),a(A)}catch(N){l.current=!1,p(N instanceof Error?N:new Error(String(N)))}},[e]),I=(0,b.useCallback)(async v=>{var w,k,L,N;c(!0),p(null);try{let R=await e.payment.processPayment(v);if(R.status==="requires_redirect"){if(R.method==="POST"&&R.postData){let A=document.createElement("form");A.method="POST",A.action=R.redirectUrl;for(let[H,Y]of Object.entries(R.postData)){let _=document.createElement("input");_.type="hidden",_.name=H,_.value=Y,A.appendChild(_)}document.body.appendChild(A),A.submit()}else window.location.href=R.redirectUrl;return R}return R.status==="succeeded"?(k=(w=y.current)==null?void 0:w.onPaymentSuccess)==null||k.call(w,R):R.status==="failed"&&(p(new Error(R.error)),(N=(L=y.current)==null?void 0:L.onPaymentFailed)==null||N.call(L,R)),R}catch(R){let A=R instanceof Error?R:new Error(String(R));return p(A),{status:"failed",error:A.message}}finally{c(!1)}},[e]),E=(0,b.useCallback)(v=>async()=>{c(!0),p(null);try{return await v()}catch(w){let k=w instanceof Error?w:new Error(String(w));throw p(k),k}finally{c(!1)}},[]),C=(0,b.useCallback)(async v=>{c(!0),p(null);try{let w=await e.payment.pay(v);return d(w),w}catch(w){let k=w instanceof Error?w:new Error(String(w));throw p(k),k}finally{c(!1)}},[e]),P=(0,b.useCallback)(v=>e.payment.tokenizeCard(v),[e]),S=(0,b.useCallback)(async v=>{let k=await E(()=>e.payment.processApplePay(v))();return d(k),k},[e,E]),x=(0,b.useCallback)(async v=>{let k=await E(()=>e.payment.processGooglePay(v))();return d(k),k},[e,E]),z=(0,b.useCallback)(async v=>{let k=await E(()=>e.payment.processApm(v))();return d(k),k},[e,E]),$=(0,b.useCallback)(v=>e.payment.pollPaymentStatus(v),[e]);return{paymentSetup:t,expressMethods:n,storeConfig:o,isProcessing:u,result:m,error:h,loadPaymentSetup:g,processPayment:I,pay:C,tokenizeCard:P,processApplePay:S,processGooglePay:x,processApm:z,pollStatus:$}}var O=F("react");function je(s){let e=D(),[t,r]=(0,O.useState)(null),[n,i]=(0,O.useState)(null),[o,a]=(0,O.useState)(!1),[u,c]=(0,O.useState)(null),m=(0,O.useRef)(s);m.current=s;let d=(0,O.useRef)(!1);(0,O.useEffect)(()=>{var w;if(typeof window>"u"||(w=m.current)!=null&&w.disableAutoResume||d.current)return;let S=new URLSearchParams(window.location.search),x=S.get("paymentAction"),z=S.get("paymentActionStatus"),$=S.get("paymentId");if(x!=="requireAction"||z!=="completed"||!$||(d.current=!0,!Pe($)))return;a(!0),c(null),(async()=>{var k,L,N,R;try{let A=await e.payment.resumeAfterRedirect($),H=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status"].forEach(_=>H.delete(_));let Y=H.toString()?`${window.location.pathname}?${H.toString()}`:window.location.pathname;window.history.replaceState({},document.title,Y),A.status==="succeeded"?(L=(k=m.current)==null?void 0:k.onOfferAccepted)==null||L.call(k,A):A.status==="failed"&&(c(new Error(A.error)),(R=(N=m.current)==null?void 0:N.onOfferDeclined)==null||R.call(N,A))}catch(A){c(A instanceof Error?A:new Error(String(A)))}finally{a(!1)}})()},[e]);let h=(0,O.useCallback)(async S=>{a(!0),c(null);try{return await S()}catch(x){let z=x instanceof Error?x:new Error(String(x));throw c(z),z}finally{a(!1)}},[]),p=(0,O.useCallback)(S=>h(async()=>{let x=await e.offers.getOffer(S);return r(x),x}),[e,h]),l=(0,O.useCallback)(S=>e.offers.listOffers(S),[e]),f=(0,O.useCallback)(S=>h(async()=>{let x=await e.offers.previewOffer(S);return i(x),x}),[e,h]),y=(0,O.useCallback)(S=>h(()=>e.offers.payPreviewedOffer(S)),[e,h]),g=(0,O.useCallback)(async S=>{var x,z,$,v;a(!0),c(null);try{let w=await e.offers.processOfferPayment(S);if(w.status==="requires_redirect"){if(w.method==="POST"&&w.postData){let k=document.createElement("form");k.method="POST",k.action=w.redirectUrl;for(let[L,N]of Object.entries(w.postData)){let R=document.createElement("input");R.type="hidden",R.name=L,R.value=N,k.appendChild(R)}document.body.appendChild(k),k.submit()}else window.location.href=w.redirectUrl;return w}return w.status==="succeeded"?(z=(x=m.current)==null?void 0:x.onOfferAccepted)==null||z.call(x,w):w.status==="failed"&&(c(new Error(w.error)),(v=($=m.current)==null?void 0:$.onOfferDeclined)==null||v.call($,w)),w}catch(w){let k=w instanceof Error?w:new Error(String(w));return c(k),{status:"failed",error:k.message}}finally{a(!1)}},[e]),I=(0,O.useCallback)(S=>e.offers.toggleOrderBump(S),[e]),E=(0,O.useCallback)(S=>e.offers.listPostPurchaseOffers(S),[e]),C=(0,O.useCallback)(S=>h(()=>e.offers.acceptPostPurchaseOffer(S)),[e,h]),P=(0,O.useCallback)(S=>h(()=>e.offers.declinePostPurchaseOffer(S)),[e,h]);return{offer:t,preview:n,isLoading:o,error:u,getOffer:p,listOffers:l,previewOffer:f,processOfferPayment:g,payPreviewedOffer:y,toggleOrderBump:I,listPostPurchaseOffers:E,acceptPostPurchaseOffer:C,declinePostPurchaseOffer:P}}var G=F("react");function Ke(s){let e=D(),[t,r]=(0,G.useState)(null),[n,i]=(0,G.useState)([]),[o,a]=(0,G.useState)([]),[u,c]=(0,G.useState)(!1),[m,d]=(0,G.useState)(null),h=(0,G.useCallback)(async y=>{c(!0),d(null);try{let g=await e.customer.getProfile(y);r(g)}catch(g){d(g instanceof Error?g:new Error(String(g)))}finally{c(!1)}},[e]),p=(0,G.useCallback)(async y=>{try{let g=await e.customer.getOrders(y);i(g.orders)}catch(g){d(g instanceof Error?g:new Error(String(g)))}},[e]),l=(0,G.useCallback)(async y=>{try{let g=await e.customer.getSubscriptions(y);a(g)}catch(g){d(g instanceof Error?g:new Error(String(g)))}},[e]),f=(0,G.useCallback)(async(y,g)=>{try{let I=await e.customer.updateProfile(y,g);r(I)}catch(I){d(I instanceof Error?I:new Error(String(I)))}},[e]);return(0,G.useEffect)(()=>{s&&h(s)},[s,h]),{customer:t,orders:n,subscriptions:o,isLoading:u,error:m,loadCustomer:h,loadOrders:p,loadSubscriptions:l,updateProfile:f}}var j=F("react");function Be(s,e){let t=D(),[r,n]=(0,j.useState)(null),[i,o]=(0,j.useState)(!1),[a,u]=(0,j.useState)(null),c=(e==null?void 0:e.watchRelatedOrders)??!0,m=(e==null?void 0:e.watchTimeoutMs)??8e3,d=(e==null?void 0:e.watchIntervalMs)??2e3,h=(0,j.useRef)(0),p=(0,j.useCallback)(async()=>{if(s)try{let l=await t.customer.getOrder(s);n(l)}catch(l){u(l instanceof Error?l:new Error(String(l)))}},[t,s]);return(0,j.useEffect)(()=>{if(!s)return;let l=++h.current,f=()=>h.current===l;return o(!0),u(null),(async()=>{var y,g;try{let I=await t.customer.getOrder(s);if(!f()||(n(I),o(!1),!c||(y=I.relatedOrders)!=null&&y.length))return;let E=Date.now()+m;for(;Date.now()<E&&f();){if(await new Promise(C=>setTimeout(C,d)),!f()||(I=await t.customer.getOrder(s),!f()))return;if((g=I.relatedOrders)!=null&&g.length){n(I);return}}}catch(I){if(!f())return;u(I instanceof Error?I:new Error(String(I))),o(!1)}})(),()=>{h.current++}},[t,s,c,m,d]),{order:r,relatedOrders:(r==null?void 0:r.relatedOrders)??[],isLoading:i,error:a,refresh:p}}var W=F("react");function ze(){let s=D(),[e,t]=(0,W.useState)([]),[r,n]=(0,W.useState)(!1),[i,o]=(0,W.useState)(null),a=(0,W.useCallback)(async c=>{n(!0),o(null);try{let m=await s.catalog.getProducts(c);return t(m),m}catch(m){let d=m instanceof Error?m:new Error(String(m));throw o(d),d}finally{n(!1)}},[s]),u=(0,W.useCallback)(async c=>{n(!0),o(null);try{return await s.catalog.getProduct(c)}catch(m){let d=m instanceof Error?m:new Error(String(m));throw o(d),d}finally{n(!1)}},[s]);return{products:e,isLoading:r,error:i,loadProducts:a,loadProduct:u}}var M=F("react");var gt=new Set(["approved","shipped","delivered","declined","cancelled","error"]);function Je(){let s=D(),[e,t]=(0,M.useState)([]),[r,n]=(0,M.useState)(null),[i,o]=(0,M.useState)(!1),[a,u]=(0,M.useState)(null),c=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>{c.current&&clearInterval(c.current)},[]);let m=(0,M.useCallback)(async(f,y)=>{o(!0),u(null);try{return await s.rx.isRequiredForProduct(f,y)}catch(g){let I=g instanceof Error?g:new Error(String(g));throw u(I),I}finally{o(!1)}},[s]),d=(0,M.useCallback)(async(f,y)=>{o(!0),u(null);try{return await s.rx.getQuestionsForProduct(f,y)}catch(g){let I=g instanceof Error?g:new Error(String(g));throw u(I),I}finally{o(!1)}},[s]),h=(0,M.useCallback)(async f=>{o(!0),u(null);try{let y=await s.rx.submitCase(f);return n(y),y}catch(y){let g=y instanceof Error?y:new Error(String(y));throw u(g),g}finally{o(!1)}},[s]),p=(0,M.useCallback)(async f=>{o(!0),u(null);try{let y=await s.rx.getCasesForOrder(f);return t(y.cases),y.cases}catch(y){let g=y instanceof Error?y:new Error(String(y));throw u(g),g}finally{o(!1)}},[s]),l=(0,M.useCallback)(({orderId:f,checkoutToken:y},g)=>{c.current&&clearInterval(c.current);let I=(g==null?void 0:g.intervalMs)??5e3,E=async()=>{var C;try{let P=await s.rx.getCasesForOrder({orderId:f,checkoutToken:y});t(P.cases),(C=g==null?void 0:g.onUpdate)==null||C.call(g,P.cases),P.cases.length>0&&P.cases.every(S=>gt.has(S.status))&&(c.current&&clearInterval(c.current),c.current=null)}catch(P){let S=P instanceof Error?P:new Error(String(P));u(S)}};return E(),c.current=setInterval(E,I),()=>{c.current&&clearInterval(c.current),c.current=null}},[s]);return{cases:e,lastSubmission:r,isLoading:i,error:a,isRequiredForProduct:m,getQuestionsForProduct:d,submitCase:h,fetchCasesForOrder:p,pollOrder:l}}var U=F("react");var Qe=!1,We=!1,we=[];function ve(){We=!0;for(let s of we)s();we.length=0}function re(s,e={}){var t,r;return We||(r=(t=window.google)==null?void 0:t.maps)!=null&&r.places?(ve(),Promise.resolve()):Qe?new Promise(n=>we.push(n)):(Qe=!0,new Promise((n,i)=>{if(we.push(n),document.querySelector('script[src*="maps.googleapis.com"]')){let c=()=>{var m,d;(d=(m=window.google)==null?void 0:m.maps)!=null&&d.places?ve():setTimeout(c,100)};c();return}let a=new URLSearchParams({key:s,libraries:"places",v:e.version??"weekly"});e.language&&a.set("language",e.language),e.region&&a.set("region",e.region);let u=document.createElement("script");u.src=`https://maps.googleapis.com/maps/api/js?${a}`,u.async=!0,u.defer=!0,u.onload=()=>ve(),u.onerror=()=>i(new Error("Failed to load Google Maps script")),document.head.appendChild(u)}))}var K=class s{static async searchPlaces(e,t={}){var n,i;if(!((i=(n=window.google)==null?void 0:n.maps)!=null&&i.places)||!e.trim())return[];let r=new window.google.maps.places.AutocompleteService;return new Promise(o=>{r.getPlacePredictions({input:e,types:t.types??["address"],componentRestrictions:t.componentRestrictions},(a,u)=>{var c,m,d;o(u===((d=(m=(c=window.google)==null?void 0:c.maps)==null?void 0:m.places)==null?void 0:d.PlacesServiceStatus.OK)&&a?a:[])})})}static async getPlaceDetails(e){var r,n;if(!((n=(r=window.google)==null?void 0:r.maps)!=null&&n.places))return null;let t=new window.google.maps.places.PlacesService(document.createElement("div"));return new Promise(i=>{t.getDetails({placeId:e,fields:["place_id","formatted_address","address_components","geometry"]},(o,a)=>{var u,c,m;i(a===((m=(c=(u=window.google)==null?void 0:u.maps)==null?void 0:c.places)==null?void 0:m.PlacesServiceStatus.OK)&&o?o:null)})})}static extractAddressComponents(e){let t={subpremise:"",streetNumber:"",route:"",locality:"",administrativeAreaLevel1:"",administrativeAreaLevel1Long:"",administrativeAreaLevel2:"",administrativeAreaLevel2Long:"",country:"",postalCode:"",fullStreetAddress:""},r="",n="",i="",o="",a="",u="",c="",m="";for(let p of e.address_components??[]){let l=p.types;l.includes("subpremise")&&(t.subpremise=p.long_name),l.includes("street_number")&&(t.streetNumber=p.long_name),l.includes("premise")&&(r=p.long_name),l.includes("route")&&(t.route=p.long_name),l.includes("neighborhood")&&(n=p.long_name),l.includes("sublocality_level_5")&&(i=p.long_name),l.includes("sublocality_level_4")&&(o=p.long_name),l.includes("sublocality_level_3")&&(a=p.long_name),l.includes("sublocality_level_2")&&(u=p.long_name),l.includes("sublocality_level_1")&&(c=p.long_name),l.includes("locality")&&(t.locality=p.long_name),l.includes("postal_town")&&(m=p.long_name),l.includes("administrative_area_level_2")&&(t.administrativeAreaLevel2=p.short_name,t.administrativeAreaLevel2Long=p.long_name),l.includes("administrative_area_level_1")&&(t.administrativeAreaLevel1=p.short_name,t.administrativeAreaLevel1Long=p.long_name),l.includes("country")&&(t.country=p.short_name),l.includes("postal_code")&&(t.postalCode=p.long_name)}t.locality||(t.locality=m||u||c||""),!t.administrativeAreaLevel1&&t.administrativeAreaLevel2&&(t.administrativeAreaLevel1=t.administrativeAreaLevel2Long||t.administrativeAreaLevel2,t.administrativeAreaLevel1Long=t.administrativeAreaLevel2Long);let d=t.streetNumber||r,h=t.route||i||o||a||n;if(t.subpremise&&d&&h)t.fullStreetAddress=`${t.subpremise}/${d} ${h}`;else if(d&&h)if(r&&o&&a){let p=`${a}-${o}-${r}`;u&&(p=`${p} ${u}`),t.fullStreetAddress=p}else t.fullStreetAddress=`${d} ${h}`;else h?t.fullStreetAddress=h:d&&(t.fullStreetAddress=d);return t.fullStreetAddress=t.fullStreetAddress.trim(),t}static extractFormattedAddress(e){let t=s.extractAddressComponents(e);return{address1:t.fullStreetAddress,city:t.locality,country:t.country,state:t.administrativeAreaLevel1,postal:t.postalCode}}};function Ve(s){let{apiKey:e,language:t,region:r,version:n,defer:i=!1}=s,[o,a]=(0,U.useState)([]),[u,c]=(0,U.useState)(!1),[m,d]=(0,U.useState)(!1),h=(0,U.useRef)(null),p=(0,U.useRef)(null),l=(0,U.useCallback)(()=>{re(e,{language:t,region:r,version:n}).then(()=>d(!0))},[e,t,r,n]);(0,U.useEffect)(()=>{!e||i||l()},[e,i,l]),(0,U.useEffect)(()=>{if(m&&p.current){let{input:C,country:P}=p.current;p.current=null,f(C,P)}},[m]);let f=(0,U.useCallback)((C,P)=>{if(!m){i&&(p.current={input:C,country:P},l());return}if(C.length<3){a([]);return}h.current&&clearTimeout(h.current),h.current=setTimeout(async()=>{c(!0);let S=await K.searchPlaces(C,{componentRestrictions:P?{country:P.toLowerCase()}:void 0});a(S),c(!1)},300)},[m,i,l]),y=(0,U.useCallback)(C=>K.getPlaceDetails(C),[]),g=(0,U.useCallback)(C=>K.extractAddressComponents(C),[]),I=(0,U.useCallback)(C=>K.extractFormattedAddress(C),[]),E=(0,U.useCallback)(()=>a([]),[]);return{predictions:o,isLoading:u,isScriptLoaded:m,searchPlaces:f,getPlaceDetails:y,extractAddressComponents:g,extractFormattedAddress:I,clearPredictions:E}}var J=F("react");var Ye="https://cvwnizdbugpz6jwk.public.blob.vercel-storage.com/geodata/v1",Oe=["en","ru","de","da","fr","es","zh","hi","pt","ja","ar","it","he"],ne=new Map,Ce=new Map,Ae=new Map,be=new Map;async function ft(s){let e=ne.get(s);if(e)return e;let t=Ae.get(s);return t||(t=(async()=>{let r=`${Ye}/${s}/countries.json`,n=await fetch(r);if(!n.ok)throw new Error(`Geodata fetch failed: ${r} (${n.status})`);let i=await n.json();return ne.set(s,i),Ae.delete(s),i})(),Ae.set(s,t),t)}async function yt(s){let e=Ce.get(s);if(e)return e;let t=be.get(s);return t||(t=(async()=>{let r=`${Ye}/${s}/regions.json`,n=await fetch(r);if(!n.ok)throw new Error(`Geodata fetch failed: ${r} (${n.status})`);let i=await n.json();return Ce.set(s,i),be.delete(s),i})(),be.set(s,t),t)}function ht(s){return ne.get(s)||ne.get("en")||{}}function Pt(s){return Ce.get(s)||Ce.get("en")||{}}async function se(s="en"){await Promise.all([ft(s),yt(s)])}var Se=(s="en")=>{let e=ht(s);return Object.entries(e).map(([t,r])=>({code:t,name:r.n,iso3:r.i3,numeric:r.nu})).sort((t,r)=>t.name.localeCompare(r.name))},xe=(s,e="en")=>{let r=Pt(e)[s];return r?r.map(([n,i])=>({code:n,name:i,countryCode:s})).sort((n,i)=>n.name.localeCompare(i.name)):[]};function ie(s){return ne.has(s)}var B=class s{static ensureLoaded(e="en"){return se(e)}static getCountries(e="en"){let t=Se(e),r={};for(let n of t)r[n.code]={iso:n.code,iso3:n.iso3??"",numeric:n.numeric??0,name:n.name};return r}static getCountryOptions(e="en"){return Se(e).map(t=>({value:t.code,label:t.name}))}static getRegions(e,t="en"){return xe(e,t).map(r=>({iso:r.code,name:r.name}))}static getRegionOptions(e,t="en"){return s.getRegions(e,t).map(r=>({value:r.iso,label:r.name}))}static findRegion(e,t,r="en"){return s.getRegions(e,r).find(n=>n.iso===t)??null}static mapGoogleToISO(e,t,r,n="en"){let i=s.getRegions(r,n);if(i.length===0)return null;let o=i.find(a=>a.iso===e);return o||(o=i.find(a=>a.name.toLowerCase()===e.toLowerCase()),o)||(o=i.find(a=>a.name.toLowerCase()===t.toLowerCase()),o)?o:(o=i.find(a=>a.name.toLowerCase().includes(t.toLowerCase())||t.toLowerCase().includes(a.name.toLowerCase())),o??null)}static isLanguageLoaded(e){return ie(e)}static getAvailableLanguages(){return Oe}};function Ie(s="en"){let[e,t]=(0,J.useState)(ie(s));return(0,J.useEffect)(()=>{let r=!1;return se(s).then(()=>{r||t(!0)}).catch(n=>console.error("[headless-sdk] Failed to load geodata:",n)),()=>{r=!0}},[s]),(0,J.useMemo)(()=>e?{countries:B.getCountries(s),getRegions:r=>B.getRegions(r,s),findRegion:(r,n)=>B.findRegion(r,n,s),mapGoogleToISO:(r,n,i)=>B.mapGoogleToISO(r,n,i,s),isLoaded:!0}:{countries:{},getRegions:()=>[],findRegion:()=>null,mapGoogleToISO:()=>null,isLoaded:!1},[s,e])}function Ze(s="en"){let{countries:e,isLoaded:t}=Ie(s);return(0,J.useMemo)(()=>t?Object.values(e).map(r=>({value:r.iso,label:r.name})).sort((r,n)=>r.label.localeCompare(n.label)):[],[e,t])}function Xe(s,e="en"){let{getRegions:t,isLoaded:r}=Ie(e);return(0,J.useMemo)(()=>!r||!s?[]:t(s).map(n=>({value:n.iso,label:n.name})).sort((n,i)=>n.label.localeCompare(i.label)),[s,t,r])}var wt={USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5",CAD:"C$",AUD:"A$",CHF:"CHF",CNY:"\xA5",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"z\u0142",CZK:"K\u010D",HUF:"Ft",RON:"lei",BGN:"\u043B\u0432",HRK:"kn",RUB:"\u20BD",UAH:"\u20B4",TRY:"\u20BA",BRL:"R$",MXN:"$",ZAR:"R",INR:"\u20B9",KRW:"\u20A9",THB:"\u0E3F",VND:"\u20AB",IDR:"Rp",MYR:"RM",SGD:"S$",PHP:"\u20B1",TWD:"NT$",HKD:"HK$",ILS:"\u20AA",AED:"\u062F.\u0625",SAR:"\u0631.\u0633",QAR:"\u0631.\u0642",KWD:"\u062F.\u0643",BHD:"\u062F.\u0628",OMR:"\u0631.\u0639.",EGP:"\xA3",NGN:"\u20A6",KES:"KSh",GHS:"\u20B5",COP:"$",ARS:"$",CLP:"$",PEN:"S/",CRC:"\u20A1",DOP:"RD$",JMD:"J$",BOB:"Bs",PYG:"\u20B2",GTQ:"Q",NIO:"C$",PAB:"B/.",PKR:"\u20A8",BDT:"\u09F3",LKR:"\u20A8",NPR:"\u20A8",GEL:"\u20BE",AMD:"\u058F",AZN:"\u20BC",KZT:"\u20B8"},Ct={USD:"US Dollar",EUR:"Euro",GBP:"British Pound",JPY:"Japanese Yen",CAD:"Canadian Dollar",AUD:"Australian Dollar",CHF:"Swiss Franc",CNY:"Chinese Yuan",SEK:"Swedish Krona",NOK:"Norwegian Krone",DKK:"Danish Krone",PLN:"Polish Zloty",CZK:"Czech Koruna",HUF:"Hungarian Forint",BRL:"Brazilian Real",MXN:"Mexican Peso",INR:"Indian Rupee",KRW:"South Korean Won",THB:"Thai Baht",SGD:"Singapore Dollar",HKD:"Hong Kong Dollar",TWD:"Taiwan Dollar",ILS:"Israeli Shekel",AED:"UAE Dirham",SAR:"Saudi Riyal",ZAR:"South African Rand",TRY:"Turkish Lira",RUB:"Russian Ruble",NGN:"Nigerian Naira"},St=new Set(["JPY","KRW","VND","IDR","LAK","KHR","MMK","PYG"]),V=class s{static getSymbol(e){return wt[e]??e}static getName(e){return Ct[e]??e}static getDecimalPlaces(e){return St.has(e)?0:2}static getCurrency(e){return{code:e,symbol:s.getSymbol(e),name:s.getName(e),decimalPlaces:s.getDecimalPlaces(e)}}};function Te(s,e="USD",t="en-US"){let r=V.getDecimalPlaces(e),n=s/(r===0?100:Math.pow(10,r));try{return new Intl.NumberFormat(t,{style:"currency",currency:e,minimumFractionDigits:r,maximumFractionDigits:r}).format(n)}catch{return`${V.getSymbol(e)}${n.toFixed(r)}`}}return ct(It);})();
|
|
7
7
|
if(typeof window!=="undefined"&&TagadaHeadlessReactBundle){ window.TagadaHeadlessReact=TagadaHeadlessReactBundle;}
|
|
8
8
|
//# sourceMappingURL=tagada-headless-react.min.js.map
|