@shoppexio/storefront 1.0.47 → 1.0.49

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.
@@ -1,3 +1,3 @@
1
1
  var e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Map,n={hits:0,misses:0};function o(){e.clear(),t.clear()}function i(t,n,o){const i=Date.now();e.set(t,{data:n,ttl:o,updatedAt:i,expiresAt:i+o})}async function r(o,r,a,s=()=>!0){const l=function(t){const n=e.get(t);return n||null}(o);if(l&&!function(e){return Date.now()>e.expiresAt}(l))return n.hits+=1,l.data;if(l&&a.staleWhileRevalidate){if(n.hits+=1,!t.has(o)){const e=(async()=>{try{const e=await r();return s(e)&&i(o,e,a.ttl),e}finally{t.delete(o)}})();t.set(o,e)}return l.data}if(t.has(o))return t.get(o);n.misses+=1;const u=(async()=>{try{const e=await r();return s(e)&&i(o,e,a.ttl),e}finally{t.delete(o)}})();return t.set(o,u),u}var a=class e extends Error{constructor(t,n,o){super(t),this.name="ShoppexError",this.code=n,this.statusCode=o,Object.setPrototypeOf(this,e.prototype)}},s=class e extends a{constructor(){super("SDK not initialized. Call shoppex.init() first.","NOT_INITIALIZED"),this.name="NotInitializedError",Object.setPrototypeOf(this,e.prototype)}},l=class e extends a{constructor(t,n){super(t,"NETWORK_ERROR",n),this.name="NetworkError",Object.setPrototypeOf(this,e.prototype)}},u=class e extends a{constructor(t,n,o,i){super(t,n,o),this.name="ApiError",this.errorParams=i,Object.setPrototypeOf(this,e.prototype)}},c=class e extends a{constructor(t,n){super(t,"VALIDATION_ERROR"),this.name="ValidationError",this.invalidFields=n,Object.setPrototypeOf(this,e.prototype)}},d=class e extends a{constructor(t){super(t,"BASKET_ERROR"),this.name="CartError",Object.setPrototypeOf(this,e.prototype)}},p=/\{[^{}]+\}/g;function f(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:o=globalThis.fetch,querySerializer:i,bodySerializer:r,pathSerializer:a,headers:s,requestInitExt:l,...u}={...e};l="object"==typeof process&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici?l:void 0,t=w(t);const c=[];async function d(e,d){const{baseUrl:p,fetch:f=o,Request:m=n,headers:_,params:h={},parseAs:S="json",querySerializer:k,bodySerializer:E=r??b,pathSerializer:O,body:x,middleware:z=[],...T}=d||{};let A=t;p&&(A=w(p)??t);let I="function"==typeof i?i:y(i);k&&(I="function"==typeof k?k:y({..."object"==typeof i?i:{},...k}));const P=O||a||g,$=void 0===x?void 0:E(x,v(s,_,h.header)),N=v(void 0===$||$ instanceof FormData?{}:{"Content-Type":"application/json"},s,_,h.header),C=[...c,...z],R={redirect:"follow",...u,...T,body:$,headers:N};let U,q,D,j=new m(function(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let o=t.querySerializer(t.params.query??{});o.startsWith("?")&&(o=o.substring(1));o&&(n+=`?${o}`);return n}(e,{baseUrl:A,params:h,querySerializer:I,pathSerializer:P}),R);for(const t in T)t in j||(j[t]=T[t]);if(C.length){U=Math.random().toString(36).slice(2,11),q=Object.freeze({baseUrl:A,fetch:f,parseAs:S,querySerializer:I,bodySerializer:E,pathSerializer:P});for(const t of C)if(t&&"object"==typeof t&&"function"==typeof t.onRequest){const n=await t.onRequest({request:j,schemaPath:e,params:h,options:q,id:U});if(n){if(!(n instanceof m)){if(n instanceof Response){D=n;break}throw new Error("onRequest: must return new Request() or Response() when modifying the request")}j=n}}}if(!D){try{D=await f(j,l)}catch(M){let t=M;if(C.length)for(let n=C.length-1;n>=0;n--){const o=C[n];if(o&&"object"==typeof o&&"function"==typeof o.onError){const n=await o.onError({request:j,error:t,schemaPath:e,params:h,options:q,id:U});if(n){if(n instanceof Response){t=void 0,D=n;break}if(n instanceof Error){t=n;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(t)throw t}if(C.length)for(let t=C.length-1;t>=0;t--){const n=C[t];if(n&&"object"==typeof n&&"function"==typeof n.onResponse){const t=await n.onResponse({request:j,response:D,schemaPath:e,params:h,options:q,id:U});if(t){if(!(t instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");D=t}}}}const L=D.headers.get("Content-Length");if(204===D.status||"HEAD"===j.method||"0"===L&&!D.headers.get("Transfer-Encoding")?.includes("chunked"))return D.ok?{data:void 0,response:D}:{error:void 0,response:D};if(D.ok){const e=async()=>{if("stream"===S)return D.body;if("json"===S&&!L){const e=await D.text();return e?JSON.parse(e):void 0}return await D[S]()};return{data:await e(),response:D}}let Z=await D.text();try{Z=JSON.parse(Z)}catch{}return{error:Z,response:D}}return{request:(e,t,n)=>d(t,{...n,method:e.toUpperCase()}),GET:(e,t)=>d(e,{...t,method:"GET"}),PUT:(e,t)=>d(e,{...t,method:"PUT"}),POST:(e,t)=>d(e,{...t,method:"POST"}),DELETE:(e,t)=>d(e,{...t,method:"DELETE"}),OPTIONS:(e,t)=>d(e,{...t,method:"OPTIONS"}),HEAD:(e,t)=>d(e,{...t,method:"HEAD"}),PATCH:(e,t)=>d(e,{...t,method:"PATCH"}),TRACE:(e,t)=>d(e,{...t,method:"TRACE"}),use(...e){for(const t of e)if(t){if("object"!=typeof t||!("onRequest"in t||"onResponse"in t||"onError"in t))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");c.push(t)}},eject(...e){for(const t of e){const e=c.indexOf(t);-1!==e&&c.splice(e,1)}}}}function m(e,t,n){if(null==t)return"";if("object"==typeof t)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${!0===n?.allowReserved?t:encodeURIComponent(t)}`}function _(e,t,n){if(!t||"object"!=typeof t)return"";const o=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if("deepObject"!==n.style&&!1===n.explode){for(const e in t)o.push(e,!0===n.allowReserved?t[e]:encodeURIComponent(t[e]));const i=o.join(",");switch(n.style){case"form":return`${e}=${i}`;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return i}}for(const a in t){const i="deepObject"===n.style?`${e}[${a}]`:a;o.push(m(i,t[a],n))}const r=o.join(i);return"label"===n.style||"matrix"===n.style?`${i}${r}`:r}function h(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",i=(!0===n.allowReserved?t:t.map(e=>encodeURIComponent(e))).join(o);switch(n.style){case"simple":return i;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return`${e}=${i}`}}const o={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const r of t)"simple"===n.style||"label"===n.style?i.push(!0===n.allowReserved?r:encodeURIComponent(r)):i.push(m(e,r,n));return"label"===n.style||"matrix"===n.style?`${o}${i.join(o)}`:i.join(o)}function y(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const o in t){const i=t[o];if(null!=i)if(Array.isArray(i)){if(0===i.length)continue;n.push(h(o,i,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof i?n.push(m(o,i,e)):n.push(_(o,i,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}))}return n.join("&")}}function g(e,t){let n=e;for(const o of e.match(p)??[]){let e=o.substring(1,o.length-1),i=!1,r="simple";if(e.endsWith("*")&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(r="label",e=e.substring(1)):e.startsWith(";")&&(r="matrix",e=e.substring(1)),!t||void 0===t[e]||null===t[e])continue;const a=t[e];Array.isArray(a)?n=n.replace(o,h(e,a,{style:r,explode:i})):n="object"!=typeof a?"matrix"!==r?n.replace(o,"label"===r?`.${encodeURIComponent(a)}`:encodeURIComponent(a)):n.replace(o,`;${m(e,a)}`):n.replace(o,_(e,a,{style:r,explode:i}))}return n}function b(e,t){return e instanceof FormData?e:t&&"application/x-www-form-urlencoded"===(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])?new URLSearchParams(e).toString():JSON.stringify(e)}function v(...e){const t=new Headers;for(const n of e){if(!n||"object"!=typeof n)continue;const e=n instanceof Headers?n.entries():Object.entries(n);for(const[n,o]of e)if(null===o)t.delete(n);else if(Array.isArray(o))for(const e of o)t.append(n,e);else void 0!==o&&t.set(n,o)}return t}function w(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var S={header:{title:"Header",aliases:["Header Menu"]},footer:{title:"Footer",aliases:["Footer Links","Legal Links"]}};var k;Object.keys(S);function E(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:a,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const i=a.prototype,r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class r extends i{}function a(e){var t;const i=n?.Parent?new r:this;o(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var O=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},x=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(k=globalThis).__zod_globalConfig??(k.__zod_globalConfig={});var z=globalThis.__zod_globalConfig;function T(e){return e&&Object.assign(z,e),z}function A(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function I(e,t){return"bigint"==typeof t?t.toString():t}function P(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $(e){return null==e}function N(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var C=/* @__PURE__*/Symbol("evaluating");function R(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==C)return void 0===o&&(o=C,o=n()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function U(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function q(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function D(e){return JSON.stringify(e)}var j="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function L(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var Z=/* @__PURE__*/P(()=>{if(z.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function M(e){if(!1===L(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==L(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function F(e){return M(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var B=/* @__PURE__*/new Set(["string","number","symbol"]);function J(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y(e,t,n){const o=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(o._zod.parent=e),o}function W(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var H={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function V(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function G(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function K(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function X(e){return"string"==typeof e?e:e?.message}function Q(e,t,n){const o=e.message?e.message:X(e.inst?._zod.def?.error?.(e))??X(t?.error?.(e))??X(n.customError?.(e))??X(n.localeError?.(e))??"Invalid input",{inst:i,continue:r,input:a,...s}=e;return s.path??(s.path=[]),s.message=o,t?.reportInput&&(s.input=a),s}function ee(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function te(...e){const[t,n,o]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:o}:{...t}}var ne=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,I,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},oe=E("$ZodError",ne),ie=E("$ZodError",ne,{Parent:Error});var re=e=>(t,n,o,i)=>{const r=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise)throw new O;if(a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>Q(e,r,T())));throw j(t,i?.callee),t}return a.value},ae=e=>async(t,n,o,i)=>{const r=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>Q(e,r,T())));throw j(t,i?.callee),t}return a.value},se=e=>(t,n,o)=>{const i=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new O;return r.issues.length?{success:!1,error:new(e??oe)(r.issues.map(e=>Q(e,i,T())))}:{success:!0,data:r.value}},le=/* @__PURE__*/se(ie),ue=e=>async(t,n,o)=>{const i=o?{...o,async:!0}:{async:!0};let r=t._zod.run({value:n,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>Q(e,i,T())))}:{success:!0,data:r.value}},ce=/* @__PURE__*/ue(ie),de=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return re(e)(t,n,i)},pe=e=>(t,n,o)=>re(e)(t,n,o),fe=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ae(e)(t,n,i)},me=e=>async(t,n,o)=>ae(e)(t,n,o),_e=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return se(e)(t,n,i)},he=e=>(t,n,o)=>se(e)(t,n,o),ye=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ue(e)(t,n,i)},ge=e=>async(t,n,o)=>ue(e)(t,n,o),be=/^[cC][0-9a-z]{6,}$/,ve=/^[0-9a-z]+$/,we=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Se=/^[0-9a-vA-V]{20}$/,ke=/^[A-Za-z0-9]{27}$/,Ee=/^[a-zA-Z0-9_-]{21}$/,Oe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ze=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Te=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Ae=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ie=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Pe=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ne=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ce=/^[A-Za-z0-9_-]*$/,Re=/^https?$/,Ue=/^\+[1-9]\d{6,14}$/,qe="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",De=/*@__PURE__*/new RegExp(`^${qe}$`);function je(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var Le=/^-?\d+$/,Ze=/^-?\d+(?:\.\d+)?$/,Me=/^(?:true|false)$/i,Fe=/^[^A-Z]*$/,Be=/^[^a-z]*$/,Je=/*@__PURE__*/E("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ye={number:"number",bigint:"bigint",object:"date"},We=/*@__PURE__*/E("$ZodCheckLessThan",(e,t)=>{Je.init(e,t);const n=Ye[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),He=/*@__PURE__*/E("$ZodCheckGreaterThan",(e,t)=>{Je.init(e,t);const n=Ye[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ve=/*@__PURE__*/E("$ZodCheckMultipleOf",(e,t)=>{Je.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value!==BigInt(0):0!==function(e,t){const n=e/t,o=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<i?0:n-o}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ge=/*@__PURE__*/E("$ZodCheckNumberFormat",(e,t)=>{Je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[i,r]=H[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=r,n&&(o.pattern=Le)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>r&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Ke=/*@__PURE__*/E("$ZodCheckMaxLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!$(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=ee(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xe=/*@__PURE__*/E("$ZodCheckMinLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!$(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=ee(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Qe=/*@__PURE__*/E("$ZodCheckLengthEquals",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!$(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const r=ee(o),a=i>t.length;n.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),et=/*@__PURE__*/E("$ZodCheckStringFormat",(e,t)=>{var n,o;Je.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=/* @__PURE__ */new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),tt=/*@__PURE__*/E("$ZodCheckRegex",(e,t)=>{et.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),nt=/*@__PURE__*/E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Fe),et.init(e,t)}),ot=/*@__PURE__*/E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Be),et.init(e,t)}),it=/*@__PURE__*/E("$ZodCheckIncludes",(e,t)=>{Je.init(e,t);const n=J(t.includes),o=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),rt=/*@__PURE__*/E("$ZodCheckStartsWith",(e,t)=>{Je.init(e,t);const n=new RegExp(`^${J(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),at=/*@__PURE__*/E("$ZodCheckEndsWith",(e,t)=>{Je.init(e,t);const n=new RegExp(`.*${J(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),st=/*@__PURE__*/E("$ZodCheckOverwrite",(e,t)=>{Je.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),lt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),o=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const i of o)this.content.push(i)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},ut={major:4,minor:4,patch:3},ct=/*@__PURE__*/E("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ut;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const i of o)for(const t of i._zod.onattach)t(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let o,i=V(e);for(const r of t){if(r._zod.def.when){if(G(e))continue;if(!r._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=r._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new O;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=V(e,t)))});else{if(e.issues.length===t)continue;i||(i=V(e,t))}}return o?o.then(()=>e):e},n=(n,i,r)=>{if(V(n))return n.aborted=!0,n;const a=t(i,o,r);if(a instanceof Promise){if(!1===r.async)throw new O;return a.then(t=>e._zod.parse(t,r))}return e._zod.parse(a,r)};e._zod.run=(i,r)=>{if(r.skipChecks)return e._zod.parse(i,r);if("backward"===r.direction){const t=e._zod.parse({value:i.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,r)):n(t,i,r)}const a=e._zod.parse(i,r);if(a instanceof Promise){if(!1===r.async)throw new O;return a.then(e=>t(e,o,r))}return t(a,o,r)}}R(e,"~standard",()=>({validate:t=>{try{const n=le(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return ce(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),dt=/*@__PURE__*/E("$ZodString",(e,t)=>{var n;ct.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),pt=/*@__PURE__*/E("$ZodStringFormat",(e,t)=>{et.init(e,t),dt.init(e,t)}),ft=/*@__PURE__*/E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xe),pt.init(e,t)}),mt=/*@__PURE__*/E("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ze(e))}else t.pattern??(t.pattern=ze());pt.init(e,t)}),_t=/*@__PURE__*/E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Te),pt.init(e,t)}),ht=/*@__PURE__*/E("$ZodURL",(e,t)=>{pt.init(e,t),e._zod.check=n=>{try{const o=n.value.trim();if(!t.normalize&&t.protocol?.source===Re.source&&!/^https?:\/\//i.test(o))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),yt=/*@__PURE__*/E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pt.init(e,t)}),gt=/*@__PURE__*/E("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ee),pt.init(e,t)}),bt=/*@__PURE__*/E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=be),pt.init(e,t)}),vt=/*@__PURE__*/E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ve),pt.init(e,t)}),wt=/*@__PURE__*/E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=we),pt.init(e,t)}),St=/*@__PURE__*/E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Se),pt.init(e,t)}),kt=/*@__PURE__*/E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ke),pt.init(e,t)}),Et=/*@__PURE__*/E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=je({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${qe}T(?:${o})$`)}(t)),pt.init(e,t)}),Ot=/*@__PURE__*/E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=De),pt.init(e,t)}),xt=/*@__PURE__*/E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${je(t)}$`)),pt.init(e,t)}),zt=/*@__PURE__*/E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Oe),pt.init(e,t)}),Tt=/*@__PURE__*/E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ae),pt.init(e,t),e._zod.bag.format="ipv4"}),At=/*@__PURE__*/E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ie),pt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),It=/*@__PURE__*/E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pe),pt.init(e,t)}),Pt=/*@__PURE__*/E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$e),pt.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(2!==o.length)throw new Error;const[e,t]=o;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function $t(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Nt=/*@__PURE__*/E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ne),pt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{$t(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Ct=/*@__PURE__*/E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ce),pt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Ce.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return $t(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Rt=/*@__PURE__*/E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ue),pt.init(e,t)});var Ut=/*@__PURE__*/E("$ZodJWT",(e,t)=>{pt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[o]=n;if(!o)return!1;const i=JSON.parse(atob(o));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),qt=/*@__PURE__*/E("$ZodNumber",(e,t)=>{ct.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ze,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const r="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...r?{received:r}:{}}),n}}),Dt=/*@__PURE__*/E("$ZodNumberFormat",(e,t)=>{Ge.init(e,t),qt.init(e,t)}),jt=/*@__PURE__*/E("$ZodBoolean",(e,t)=>{ct.init(e,t),e._zod.pattern=Me,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(r){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),Lt=/*@__PURE__*/E("$ZodUnknown",(e,t)=>{ct.init(e,t),e._zod.parse=e=>e}),Zt=/*@__PURE__*/E("$ZodNever",(e,t)=>{ct.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Mt(e,t,n){e.issues.length&&t.issues.push(...K(n,e.issues)),t.value[n]=e.value}var Ft=/*@__PURE__*/E("$ZodArray",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const r=[];for(let e=0;e<i.length;e++){const a=i[e],s=t.element._zod.run({value:a,issues:[]},o);s instanceof Promise?r.push(s.then(t=>Mt(t,n,e))):Mt(s,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function Bt(e,t,n,o,i,r){const a=n in o;if(e.issues.length){if(i&&r&&!a)return;t.issues.push(...K(n,e.issues))}a||i?void 0===e.value?a&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function Jt(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=(o=e.shape,Object.keys(o).filter(e=>"optional"===o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Yt(e,t,n,o,i,r){const a=[],s=i.keySet,l=i.catchall._zod,u=l.def.type,c="optional"===l.optin,d="optional"===l.optout;for(const p in t){if("__proto__"===p)continue;if(s.has(p))continue;if("never"===u){a.push(p);continue}const i=l.run({value:t[p],issues:[]},o);i instanceof Promise?e.push(i.then(e=>Bt(e,n,p,t,c,d))):Bt(i,n,p,t,c,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}var Wt=/*@__PURE__*/E("$ZodObject",(e,t)=>{if(ct.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=P(()=>Jt(t));R(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const o=e[t]._zod;if(o.values){n[t]??(n[t]=/* @__PURE__ */new Set);for(const e of o.values)n[t].add(e)}}return n});const o=L,i=t.catchall;let r;e._zod.parse=(t,a)=>{r??(r=n.value);const s=t.value;if(!o(s))return t.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),t;t.value={};const l=[],u=r.shape;for(const e of r.keys){const n=u[e],o="optional"===n._zod.optin,i="optional"===n._zod.optout,r=n._zod.run({value:s[e],issues:[]},a);r instanceof Promise?l.push(r.then(n=>Bt(n,t,e,s,o,i))):Bt(r,t,e,s,o,i)}return i?Yt(l,s,t,a,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Ht=/*@__PURE__*/E("$ZodObjectJIT",(e,t)=>{Wt.init(e,t);const n=e._zod.parse,o=P(()=>Jt(t));let i;const r=L,a=!z.jitless,s=a&&Z.value,l=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=o.value);const p=c.value;return r(p)?a&&s&&!1===d?.async&&!0!==d.jitless?(i||(i=(e=>{const t=new lt(["shape","payload","ctx"]),n=o.value,i=e=>{const t=D(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let a=0;for(const o of n.keys)r[o]="key_"+a++;t.write("const newResult = {};");for(const o of n.keys){const n=r[o],a=D(o),s=e[o],l="optional"===s?._zod?.optin,u="optional"===s?._zod?.optout;t.write(`const ${n} = ${i(o)};`),l&&u?t.write(`\n if (${n}.issues.length) {\n if (${a} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):l?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${a} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${a}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${a}] = undefined;\n } else {\n newResult[${a}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),c=i(c,d),l?Yt([],p,c,d,u,e):c):n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function Vt(e,t,n,o){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const i=e.filter(e=>!V(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Q(e,o,T())))}),t)}var Gt=/*@__PURE__*/E("$ZodUnion",(e,t)=>{ct.init(e,t),R(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),R(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),R(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),R(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>N(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(o,i)=>{if(n)return n(o,i);let r=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),r=!0;else{if(0===t.issues.length)return t;a.push(t)}}return r?Promise.all(a).then(t=>Vt(t,o,e,i)):Vt(a,o,e,i)}}),Kt=/*@__PURE__*/E("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Gt.init(e,t);const n=e._zod.parse;R(e._zod,"propValues",()=>{const e={};for(const n of t.options){const o=n._zod.propValues;if(!o||0===Object.keys(o).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(o)){e[t]||(e[t]=/* @__PURE__ */new Set);for(const o of n)e[t].add(o)}}return e});const o=P(()=>{const e=t.options,n=/* @__PURE__ */new Map;for(const o of e){const e=o._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,o)}}return n});e._zod.parse=(i,r)=>{const a=i.value;if(!L(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(i,r):t.unionFallback||"backward"===r.direction?n(i,r):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),Xt=/*@__PURE__*/E("$ZodIntersection",(e,t)=>{ct.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,i=t.left._zod.run({value:o,issues:[]},n),r=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([t,n])=>en(e,t,n)):en(e,i,r)}});function Qt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(M(e)&&M(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const r of o){const n=Qt(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};i[r]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const i=Qt(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function en(e,t,n){const o=/* @__PURE__ */new Map;let i;for(const s of t.issues)if("unrecognized_keys"===s.code){i??(i=s);for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(s);for(const s of n.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(s);const r=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&i&&e.issues.push({...i,keys:r}),V(e))return e;const a=Qt(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var tn=/*@__PURE__*/E("$ZodRecord",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!M(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const r=[],a=t.keyType._zod.values;if(a){n.value={};const s=/* @__PURE__ */new Set;for(const u of a)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){s.add("number"==typeof u?u.toString():u);const a=t.keyType._zod.run({value:u,issues:[]},o);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>Q(e,o,T())),input:u,path:[u],inst:e});continue}const l=a.value,c=t.valueType._zod.run({value:i[u],issues:[]},o);c instanceof Promise?r.push(c.then(e=>{e.issues.length&&n.issues.push(...K(u,e.issues)),n.value[l]=e.value})):(c.issues.length&&n.issues.push(...K(u,c.issues)),n.value[l]=c.value)}let l;for(const e in i)s.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let s=t.keyType._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&Ze.test(a)&&s.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},o);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>Q(e,o,T())),input:a,path:[a],inst:e});continue}const l=t.valueType._zod.run({value:i[a],issues:[]},o);l instanceof Promise?r.push(l.then(e=>{e.issues.length&&n.issues.push(...K(a,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(...K(a,l.issues)),n.value[s.value]=l.value)}}return r.length?Promise.all(r).then(()=>n):n}}),nn=/*@__PURE__*/E("$ZodEnum",(e,t)=>{ct.init(e,t);const n=A(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(e=>B.has(typeof e)).map(e=>"string"==typeof e?J(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const r=t.value;return o.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),on=/*@__PURE__*/E("$ZodLiteral",(e,t)=>{if(ct.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?J(e):e?J(e.toString()):String(e)).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),rn=/*@__PURE__*/E("$ZodTransform",(e,t)=>{ct.init(e,t),e._zod.optin="optional",e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new x(e.constructor.name);const i=t.transform(n.value,n);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new O;return n.value=i,n.fallback=!0,n}});function an(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var sn=/*@__PURE__*/E("$ZodOptional",(e,t)=>{ct.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${N(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>an(e,o)):an(i,o)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),ln=/*@__PURE__*/E("$ZodExactOptional",(e,t)=>{sn.init(e,t),R(e._zod,"values",()=>t.innerType._zod.values),R(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),un=/*@__PURE__*/E("$ZodNullable",(e,t)=>{ct.init(e,t),R(e._zod,"optin",()=>t.innerType._zod.optin),R(e._zod,"optout",()=>t.innerType._zod.optout),R(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${N(e.source)}|null)$`):void 0}),R(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),cn=/*@__PURE__*/E("$ZodDefault",(e,t)=>{ct.init(e,t),e._zod.optin="optional",R(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>dn(e,t)):dn(o,t)}});function dn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var pn=/*@__PURE__*/E("$ZodPrefault",(e,t)=>{ct.init(e,t),e._zod.optin="optional",R(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),fn=/*@__PURE__*/E("$ZodNonOptional",(e,t)=>{ct.init(e,t),R(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,o)=>{const i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then(t=>mn(t,e)):mn(i,e)}});function mn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var _n=/*@__PURE__*/E("$ZodCatch",(e,t)=>{ct.init(e,t),e._zod.optin="optional",R(e._zod,"optout",()=>t.innerType._zod.optout),R(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>Q(e,n,T()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>Q(e,n,T()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),hn=/*@__PURE__*/E("$ZodPipe",(e,t)=>{ct.init(e,t),R(e._zod,"values",()=>t.in._zod.values),R(e._zod,"optin",()=>t.in._zod.optin),R(e._zod,"optout",()=>t.out._zod.optout),R(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const o=t.out._zod.run(e,n);return o instanceof Promise?o.then(e=>yn(e,t.in,n)):yn(o,t.in,n)}const o=t.in._zod.run(e,n);return o instanceof Promise?o.then(e=>yn(e,t.out,n)):yn(o,t.out,n)}});function yn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var gn=/*@__PURE__*/E("$ZodPreprocess",(e,t)=>{hn.init(e,t)}),bn=/*@__PURE__*/E("$ZodReadonly",(e,t)=>{ct.init(e,t),R(e._zod,"propValues",()=>t.innerType._zod.propValues),R(e._zod,"values",()=>t.innerType._zod.values),R(e._zod,"optin",()=>t.innerType?._zod?.optin),R(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(vn):vn(o)}});function vn(e){return e.value=Object.freeze(e.value),e}var wn,Sn=/*@__PURE__*/E("$ZodCustom",(e,t)=>{Je.init(e,t),ct.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const o=n.value,i=t.fn(o);if(i instanceof Promise)return i.then(t=>kn(t,n,o,e));kn(i,n,o,e)}});function kn(e,t,n,o){if(!e){const e={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),t.issues.push(te(e))}}var En=class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(wn=globalThis).__zod_globalRegistry??(wn.__zod_globalRegistry=new En);var On=globalThis.__zod_globalRegistry;function xn(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...W(t)})}function zn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...W(t)})}function Tn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...W(t)})}function An(e,t){return new We({check:"less_than",...W(t),value:e,inclusive:!1})}function In(e,t){return new We({check:"less_than",...W(t),value:e,inclusive:!0})}function Pn(e,t){return new He({check:"greater_than",...W(t),value:e,inclusive:!1})}function $n(e,t){return new He({check:"greater_than",...W(t),value:e,inclusive:!0})}function Nn(e,t){return new Ve({check:"multiple_of",...W(t),value:e})}function Cn(e,t){return new Ke({check:"max_length",...W(t),maximum:e})}function Rn(e,t){return new Xe({check:"min_length",...W(t),minimum:e})}function Un(e,t){return new Qe({check:"length_equals",...W(t),length:e})}function qn(e){return new st({check:"overwrite",tx:e})}function Dn(e,t){const n=new Je({check:"custom",...W(t)});return n._zod.check=e,n}function jn(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??On,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:/* @__PURE__ */new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ln(e,t,n={path:[],schemaPath:[]}){var o;const i=e._zod.def,r=t.seen.get(e);if(r)return r.count++,n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const o={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,o);else{const n=a.schema,r=t.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,t,n,o)}const r=e._zod.parent;r&&(a.ref||(a.ref=r),Ln(r,t,o),t.seen.get(r).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),"input"===t.io&&Fn(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Zn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=/* @__PURE__ */new Map;for(const r of e.seen.entries()){const t=e.metadataRegistry.get(r[0])?.id;if(t){const e=o.get(t);if(e&&e!==r[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(t,r[0])}}const i=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:i,defId:r}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${i("__shared")}#/${o}/${r}`}}if(t[1]===n)return{ref:"#"};const i=`#/${o}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:i+r}})(t);o.def={...o.schema},r&&(o.defId=r);const a=o.schema;for(const e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(const r of e.seen.entries()){const e=r[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const n=r[1];if(t!==r[0]){if(e.external){const n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){i(r);continue}}(e.metadataRegistry.get(r[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(r)}else i(r)}}function Mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,r={...i},a=n.ref;if(n.ref=null,a){o(a);const n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,s):(i.allOf=i.allOf??[],i.allOf.push(s)),Object.assign(i,r),t._zod.parent===a)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in r||delete i[e]);if(s.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const s=t._zod.parent;if(s&&s!==a){o(s);const t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const r=e.metadataRegistry.get(t)?.id;void 0!==r&&i.id===r&&delete i.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?i.$defs=a:i.definitions=a);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Bn(t,"input",e.processors),output:Bn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function Fn(e,t){const n=t??{seen:/* @__PURE__ */new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return Fn(o.element,n);if("set"===o.type)return Fn(o.valueType,n);if("lazy"===o.type)return Fn(o.getter(),n);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return Fn(o.innerType,n);if("intersection"===o.type)return Fn(o.left,n)||Fn(o.right,n);if("record"===o.type||"map"===o.type)return Fn(o.keyType,n)||Fn(o.valueType,n);if("pipe"===o.type)return!!e._zod.traits.has("$ZodCodec")||(Fn(o.in,n)||Fn(o.out,n));if("object"===o.type){for(const e in o.shape)if(Fn(o.shape[e],n))return!0;return!1}if("union"===o.type){for(const e of o.options)if(Fn(e,n))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(Fn(e,n))return!0;return!(!o.rest||!Fn(o.rest,n))}return!1}var Bn=(e,t,n={})=>o=>{const{libraryOptions:i,target:r}=o??{},a=jn({...i??{},target:r,io:t,processors:n});return Ln(e,a),Zn(a,e),Mn(a,e)},Jn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yn=(e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o);t.seen.get(e).ref=i.innerType},Wn=/*@__PURE__*/E("ZodISODateTime",(e,t)=>{Et.init(e,t),So.init(e,t)});function Hn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...W(t)})}(Wn,e)}var Vn=/*@__PURE__*/E("ZodISODate",(e,t)=>{Ot.init(e,t),So.init(e,t)});function Gn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...W(t)})}(Vn,e)}var Kn=/*@__PURE__*/E("ZodISOTime",(e,t)=>{xt.init(e,t),So.init(e,t)});function Xn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...W(t)})}(Kn,e)}var Qn=/*@__PURE__*/E("ZodISODuration",(e,t)=>{zt.init(e,t),So.init(e,t)});function eo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...W(t)})}(Qn,e)}var to=(e,t)=>{oe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},o=(e,i=[])=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map(e=>o({issues:e},[...i,...r.path]));else if("invalid_key"===r.code)o({issues:r.issues},[...i,...r.path]);else if("invalid_element"===r.code)o({issues:r.issues},[...i,...r.path]);else{const e=[...i,...r.path];if(0===e.length)n._errors.push(t(r));else{let o=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?o[n]=o[n]||{_errors:[]}:(o[n]=o[n]||{_errors:[]},o[n]._errors.push(t(r))),o=o[n],i++}}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):o.push(t(i));return{formErrors:o,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,I,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,I,2)}},isEmpty:{get:()=>0===e.issues.length}})},no=/*@__PURE__*/E("ZodError",to,{Parent:Error}),oo=/* @__PURE__ */re(no),io=/* @__PURE__ */ae(no),ro=/* @__PURE__ */se(no),ao=/* @__PURE__ */ue(no),so=/* @__PURE__ */de(no),lo=/* @__PURE__ */pe(no),uo=/* @__PURE__ */fe(no),co=/* @__PURE__ */me(no),po=/* @__PURE__ */_e(no),fo=/* @__PURE__ */he(no),mo=/* @__PURE__ */ye(no),_o=/* @__PURE__ */ge(no),ho=/* @__PURE__ */new WeakMap;function yo(e,t,n){const o=Object.getPrototypeOf(e);let i=ho.get(o);if(i||(i=/* @__PURE__ */new Set,ho.set(o,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(o,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var go=/*@__PURE__*/E("ZodType",(e,t)=>(ct.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Bn(e,"input"),output:Bn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const o=jn({...n,processors:t});return Ln(e,o),Zn(o,e),Mn(o,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>oo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ro(e,t,n),e.parseAsync=async(t,n)=>io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ao(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>so(e,t,n),e.decode=(t,n)=>lo(e,t,n),e.encodeAsync=async(t,n)=>uo(e,t,n),e.decodeAsync=async(t,n)=>co(e,t,n),e.safeEncode=(t,n)=>po(e,t,n),e.safeDecode=(t,n)=>fo(e,t,n),e.safeEncodeAsync=async(t,n)=>mo(e,t,n),e.safeDecodeAsync=async(t,n)=>_o(e,t,n),yo(e,"ZodType",{check(...e){const t=this.def;return this.clone(q(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Y(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...W(n)})}(Ai,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */Dn(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(te(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(te(o))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(qn(e))},optional(){return yi(this)},exactOptional(){return new gi({type:"optional",innerType:this})},nullable(){return vi(this)},nullish(){return yi(vi(this))},nonoptional(e){return function(e,t){return new ki({type:"nonoptional",innerType:e,...W(t)})}(this,e)},array(){return ei(this)},or(e){return ii([this,e])},and(e){return new si({type:"intersection",left:this,right:e})},transform(e){return xi(this,_i(e))},default(e){return t=e,new wi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},prefault(e){return t=e,new Si({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},catch(e){return new Ei({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return xi(this,e)},readonly(){return new Ti({type:"readonly",innerType:this})},describe(e){const t=this.clone();return On.add(t,{description:e}),t},meta(...e){if(0===e.length)return On.get(this);const t=this.clone();return On.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>On.get(e)?.description,configurable:!0}),e)),bo=/*@__PURE__*/E("_ZodString",(e,t)=>{dt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:a,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof r&&(o.maxLength=r),a&&(o.format=Jn[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),l&&(o.contentEncoding=l),s&&s.size>0){const e=[...s];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,yo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new tt({check:"string_format",format:"regex",...W(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new it({check:"string_format",format:"includes",...W(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new rt({check:"string_format",format:"starts_with",...W(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new at({check:"string_format",format:"ends_with",...W(t),suffix:e})}(...e))},min(...e){return this.check(Rn(...e))},max(...e){return this.check(Cn(...e))},length(...e){return this.check(Un(...e))},nonempty(...e){return this.check(Rn(1,...e))},lowercase(e){return this.check(function(e){return new nt({check:"string_format",format:"lowercase",...W(e)})}(e))},uppercase(e){return this.check(function(e){return new ot({check:"string_format",format:"uppercase",...W(e)})}(e))},trim(){return this.check(/* @__PURE__ */qn(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
- return qn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */qn(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */qn(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */qn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),vo=/*@__PURE__*/E("ZodString",(e,t)=>{dt.init(e,t),bo.init(e,t),e.email=t=>e.check(xn(ko,t)),e.url=t=>e.check(Tn(zo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...W(t)})}(Mo,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...W(t)})}(To,t)),e.guid=t=>e.check(zn(Oo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}(xo,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...W(t)})}(xo,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...W(t)})}(xo,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...W(t)})}(xo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}(Ao,t)),e.guid=t=>e.check(zn(Oo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}(Io,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}(Po,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}($o,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}(jo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}(Lo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}(No,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}(Co,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}(Ro,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}(Uo,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}(qo,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}(Do,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}(Zo,t)),e.datetime=t=>e.check(Hn(t)),e.date=t=>e.check(Gn(t)),e.time=t=>e.check(Xn(t)),e.duration=t=>e.check(eo(t))});function wo(e){return function(e,t){return new e({type:"string",...W(t)})}(vo,e)}var So=/*@__PURE__*/E("ZodStringFormat",(e,t)=>{pt.init(e,t),bo.init(e,t)}),ko=/*@__PURE__*/E("ZodEmail",(e,t)=>{_t.init(e,t),So.init(e,t)});function Eo(e){return xn(ko,e)}var Oo=/*@__PURE__*/E("ZodGUID",(e,t)=>{ft.init(e,t),So.init(e,t)}),xo=/*@__PURE__*/E("ZodUUID",(e,t)=>{mt.init(e,t),So.init(e,t)}),zo=/*@__PURE__*/E("ZodURL",(e,t)=>{ht.init(e,t),So.init(e,t)});var To=/*@__PURE__*/E("ZodEmoji",(e,t)=>{yt.init(e,t),So.init(e,t)}),Ao=/*@__PURE__*/E("ZodNanoID",(e,t)=>{gt.init(e,t),So.init(e,t)}),Io=/*@__PURE__*/E("ZodCUID",(e,t)=>{bt.init(e,t),So.init(e,t)}),Po=/*@__PURE__*/E("ZodCUID2",(e,t)=>{vt.init(e,t),So.init(e,t)}),$o=/*@__PURE__*/E("ZodULID",(e,t)=>{wt.init(e,t),So.init(e,t)}),No=/*@__PURE__*/E("ZodXID",(e,t)=>{St.init(e,t),So.init(e,t)}),Co=/*@__PURE__*/E("ZodKSUID",(e,t)=>{kt.init(e,t),So.init(e,t)}),Ro=/*@__PURE__*/E("ZodIPv4",(e,t)=>{Tt.init(e,t),So.init(e,t)}),Uo=/*@__PURE__*/E("ZodIPv6",(e,t)=>{At.init(e,t),So.init(e,t)}),qo=/*@__PURE__*/E("ZodCIDRv4",(e,t)=>{It.init(e,t),So.init(e,t)}),Do=/*@__PURE__*/E("ZodCIDRv6",(e,t)=>{Pt.init(e,t),So.init(e,t)}),jo=/*@__PURE__*/E("ZodBase64",(e,t)=>{Nt.init(e,t),So.init(e,t)}),Lo=/*@__PURE__*/E("ZodBase64URL",(e,t)=>{Ct.init(e,t),So.init(e,t)}),Zo=/*@__PURE__*/E("ZodE164",(e,t)=>{Rt.init(e,t),So.init(e,t)}),Mo=/*@__PURE__*/E("ZodJWT",(e,t)=>{Ut.init(e,t),So.init(e,t)}),Fo=/*@__PURE__*/E("ZodNumber",(e,t)=>{qt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:i,maximum:r,format:a,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const c="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(r??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;c?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:"number"==typeof i&&(o.minimum=i),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof r&&(o.maximum=r),"number"==typeof s&&(o.multipleOf=s)})(e,t,n),yo(e,"ZodNumber",{gt(e,t){return this.check(Pn(e,t))},gte(e,t){return this.check($n(e,t))},min(e,t){return this.check($n(e,t))},lt(e,t){return this.check(An(e,t))},lte(e,t){return this.check(In(e,t))},max(e,t){return this.check(In(e,t))},int(e){return this.check(Yo(e))},safe(e){return this.check(Yo(e))},positive(e){return this.check(Pn(0,e))},nonnegative(e){return this.check($n(0,e))},negative(e){return this.check(An(0,e))},nonpositive(e){return this.check(In(0,e))},multipleOf(e,t){return this.check(Nn(e,t))},step(e,t){return this.check(Nn(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Bo(e){return function(e,t){return new e({type:"number",checks:[],...W(t)})}(Fo,e)}var Jo=/*@__PURE__*/E("ZodNumberFormat",(e,t)=>{Dt.init(e,t),Fo.init(e,t)});function Yo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}(Jo,e)}var Wo=/*@__PURE__*/E("ZodBoolean",(e,t)=>{jt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Ho(e){return function(e,t){return new e({type:"boolean",...W(t)})}(Wo,e)}var Vo=/*@__PURE__*/E("ZodUnknown",(e,t)=>{Lt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Go(){return new Vo({type:"unknown"})}var Ko=/*@__PURE__*/E("ZodNever",(e,t)=>{Zt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Xo(e){return function(e,t){return new e({type:"never",...W(t)})}(Ko,e)}var Qo=/*@__PURE__*/E("ZodArray",(e,t)=>{Ft.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=Ln(r.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,yo(e,"ZodArray",{min(e,t){return this.check(Rn(e,t))},nonempty(e){return this.check(Rn(1,e))},max(e,t){return this.check(Cn(e,t))},length(e,t){return this.check(Un(e,t))},unwrap(){return this.element}})});function ei(e,t){return function(e,t,n){return new e({type:"array",element:t,...W(n)})}(Qo,e,t)}var ti=/*@__PURE__*/E("ZodObject",(e,t)=>{Ht.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object",i.properties={};const a=r.shape;for(const u in a)i.properties[u]=Ln(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===r.catchall?._zod.def.type?i.additionalProperties=!1:r.catchall?r.catchall&&(i.additionalProperties=Ln(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,o),R(e,"shape",()=>t.shape),yo(e,"ZodObject",{keyof(){return di(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Go()})},loose(){return this.clone({...this._zod.def,catchall:Go()})},strict(){return this.clone({...this._zod.def,catchall:Xo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!M(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return U(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!M(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return U(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return U(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return Y(e,q(e._zod.def,{get shape(){const e={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(e[o]=n.shape[o])}return U(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return Y(e,q(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete o[e]}return U(this,"shape",o),o},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return Y(t,q(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return U(this,"shape",i),i},checks:[]}))}(hi,this,e[0])},required(...e){return t=ki,n=this,o=e[0],Y(n,q(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(o)for(const n in o){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return U(this,"shape",i),i}}));var t,n,o}})});function ni(e,t){const n={type:"object",shape:e??{},...W(t)};return new ti(n)}var oi=/*@__PURE__*/E("ZodUnion",(e,t)=>{Gt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=!1===i.inclusive,a=i.options.map((e,n)=>Ln(e,t,{...o,path:[...o.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function ii(e,t){return new oi({type:"union",options:e,...W(t)})}var ri=/*@__PURE__*/E("ZodDiscriminatedUnion",(e,t)=>{oi.init(e,t),Kt.init(e,t)});function ai(e,t,n){return new ri({type:"union",options:t,discriminator:e,...W(n)})}var si=/*@__PURE__*/E("ZodIntersection",(e,t)=>{Xt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Ln(i.left,t,{...o,path:[...o.path,"allOf",0]}),a=Ln(i.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(r)?r.allOf:[r],...s(a)?a.allOf:[a]]})(e,t,n,o)});var li=/*@__PURE__*/E("ZodRecord",(e,t)=>{tn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object";const a=r.keyType,s=a._zod.bag?.patterns;if("loose"===r.mode&&s&&s.size>0){const e=Ln(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});i.patternProperties={};for(const t of s)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=Ln(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),i.additionalProperties=Ln(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=a._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ui(e,t,n){return t&&t._zod?new li({type:"record",keyType:e,valueType:t,...W(n)}):new li({type:"record",keyType:wo(),valueType:e,...W(t)})}var ci=/*@__PURE__*/E("ZodEnum",(e,t)=>{nn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=A(e._zod.def.entries);o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=o})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new ci({...t,checks:[],...W(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new ci({...t,checks:[],...W(o),entries:i})}});function di(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ci({type:"enum",entries:n,...W(t)})}var pi=/*@__PURE__*/E("ZodLiteral",(e,t)=>{on.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,i=[];for(const r of o.values)if(void 0===r){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof r){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(r))}else i.push(r);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function fi(e,t){return new pi({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}var mi=/*@__PURE__*/E("ZodTransform",(e,t)=>{rn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new x(e.constructor.name);n.addIssue=o=>{if("string"==typeof o)n.issues.push(te(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(te(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function _i(e){return new mi({type:"transform",transform:e})}var hi=/*@__PURE__*/E("ZodOptional",(e,t)=>{sn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Yn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function yi(e){return new hi({type:"optional",innerType:e})}var gi=/*@__PURE__*/E("ZodExactOptional",(e,t)=>{ln.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Yn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var bi=/*@__PURE__*/E("ZodNullable",(e,t)=>{un.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Ln(i.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function vi(e){return new bi({type:"nullable",innerType:e})}var wi=/*@__PURE__*/E("ZodDefault",(e,t)=>{cn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Si=/*@__PURE__*/E("ZodPrefault",(e,t)=>{pn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var ki=/*@__PURE__*/E("ZodNonOptional",(e,t)=>{fn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var Ei=/*@__PURE__*/E("ZodCatch",(e,t)=>{_n.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;let r;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Oi=/*@__PURE__*/E("ZodPipe",(e,t)=>{hn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=i.in._zod.traits.has("$ZodTransform"),a="input"===t.io?r?i.out:i.in:i.out;Ln(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function xi(e,t){return new Oi({type:"pipe",in:e,out:t})}var zi=/*@__PURE__*/E("ZodPreprocess",(e,t)=>{Oi.init(e,t),gn.init(e,t)}),Ti=/*@__PURE__*/E("ZodReadonly",(e,t)=>{bn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var Ai=/*@__PURE__*/E("ZodCustom",(e,t)=>{Sn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Ii(e,t){return new zi({type:"pipe",in:_i(e),out:t})}var Pi,$i=di(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),Ni=di(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),Ci=di(["BROADCAST","AUTOMATION"]),Ri=di(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),Ui=(ni({email:Eo(),name:wo().trim().min(1).nullable().optional(),customer_id:wo().uuid().nullable().optional(),tags:ei(wo().trim().min(1)).default([]),consent_basis:$i.default("UNKNOWN"),source:wo().trim().min(1).default("dashboard")}),ni({name:wo().trim().min(1),subject:wo().trim().min(1),preheader:wo().nullable().optional(),mjml_source:wo().trim().min(1),builder_project_json:ui(wo(),Go()).nullable().optional(),thumbnail_url:Tn(zo,Pi).nullable().optional()}),ni({mjml_source:wo().trim().min(1),sample_variables:ui(wo(),Go()).optional()}),ni({recipient_email:Eo(),sample_variables:ui(wo(),Go()).optional()}),ni({marketing_enabled:Ho().optional(),default_from_name:wo().trim().min(1).nullable().optional(),default_from_email:Eo().nullable().optional(),default_reply_to_email:Eo().nullable().optional(),physical_address:wo().trim().min(1).nullable().optional(),physical_address_line2:wo().trim().min(1).nullable().optional(),physical_city:wo().trim().min(1).nullable().optional(),physical_postal_code:wo().trim().min(1).nullable().optional(),physical_country:wo().trim().length(2).nullable().optional(),daily_limit:Bo().int().positive().optional(),monthly_soft_cap:Bo().int().positive().optional()}),ni({type:Ci.default("BROADCAST"),name:wo().trim().min(1),subject:wo().trim().min(1),template_id:wo().uuid(),list_id:wo().uuid().nullable().optional(),segment_id:wo().uuid().nullable().optional(),from_name:wo().trim().min(1),from_email:Eo(),reply_to_email:Eo().nullable().optional(),schedule_at:wo().datetime().nullable().optional(),target_emails:ei(Eo()).max(0,"Direct recipient entry is disabled. Use lists or segments built from Shoppex customers and paid order buyers.").default([]),idempotency_key:wo().trim().min(1).nullable().optional()}),ni({name:wo().trim().min(1),subject:wo().trim().min(1),template_id:wo().uuid(),from_name:wo().trim().min(1),from_email:Eo(),reply_to_email:Eo().nullable().optional(),trigger:Ri,delay_seconds:Bo().int().min(0).default(0),conditions:ui(wo(),Go()).default({})}),ni({trigger:Ri,email:Eo(),customer_id:wo().uuid().nullable().optional(),name:wo().trim().min(1).nullable().optional(),consent_basis:$i.default("UNKNOWN"),variables:ui(wo(),Go()).default({}),idempotency_key:wo().trim().min(1).nullable().optional()}),ni({email:Eo(),reason:Ni.default("ADMIN_BLOCK"),notes:wo().nullable().optional()}),/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);var qi=["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"],Di=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],ji=["NOWPAYMENTS_WHITELABEL"],Li={USDT:["USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL"],USDC:["USDC_ERC20","USDC_TRC20","USDC_BEP20","USDC_POLYGON","USDC_SOL"],DAI:["DAI_ERC20"]},Zi=Object.keys(Li),Mi=[...Li.USDT,...Li.USDC,...Li.DAI],Fi=[...qi,...Mi],Bi=["BITCOIN_LN"],Ji=[...Di,...ji],Yi=[...Fi,...Bi],Wi=Fi,Hi=(new Set(["SHOPPEXPAY"]),new Set(qi)),Vi=new Set(Mi),Gi=(new Set(Fi),new Set(Bi),new Set(Di),new Set(ji),new Set(Ji),new Set(Yi),new Set(Zi),new Set(["STRIPE","PAYPAL","PAYPAL_FF","MOLLIE","AUTHORIZENET","NMI","SQUARE","SUMUP","SHOPIFY","PANDABASE","DEBLOMASSI","SHOPPEXPAY","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","CASHAPP","VENMO","CRYPTO","CUSTOMER_BALANCE","EXTERNAL","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Ki(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Ki("COIN_GATEWAY_KEYS",qi),Ki("TOKEN_GATEWAY_KEYS",Mi),Ki("CRYPTO_GATEWAY_KEYS",Fi),Ki("LEGACY_CRYPTO_GATEWAY_KEYS",Bi),Ki("CRYPTO_PROVIDER_KEYS",Di),Ki("MANAGED_CRYPTO_PROVIDER_KEYS",ji),Ki("CRYPTO_PROVIDER_GATEWAY_KEYS",Ji),Ki("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Wi),Ki("DEFAULT_CRYPTOMUS_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL","USDC_ERC20","USDC_BEP20","USDC_POLYGON","DAI_ERC20"]),Ki("DEFAULT_OXAPAY_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDC_ERC20"]);for(const qc of Fi)if(!Hi.has(qc)&&!Vi.has(qc))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${qc}`);function Xi(e){const t=e.trim();if(!t)return"";if(/^manual:/i.test(t)){const e=t.slice(t.indexOf(":")+1).trim();return e?`MANUAL:${e}`:"MANUAL"}if(/^external:/i.test(t)){const e=function(e){const t=e.trim();if(!/^external:/i.test(t))return null;const n=t.slice(t.indexOf(":")+1).trim().toLowerCase();return Ui.test(n)?n:null}(t);return e?`EXTERNAL:${e}`:t.toUpperCase()}let n=t.toUpperCase();const o=n.match(/^(USDT|USDC|DAI):([A-Z0-9_]+)$/);if(o){const[,e,t]=o;n=`${e}_${"MATIC"===t?"POLYGON":t}`}return Gi[n]??n}new Set(["STRIPE","PAYPAL","PAYPAL_FF","SKRILL","CASHAPP","CASH_APP","PERFECT_MONEY","SQUARE","SUMUP","SHOPIFY","PANDABASE","DEBLOMASSI","SHOPPEXPAY","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","VENMO","MOLLIE","AUTHORIZENET","NMI"].map(e=>Xi(e))),new Set(["WHITE_LABEL","NATIVE"]);var Qi=[...Ji,"NATIVE"],er=(new Set(Qi),ni({set:Ho()})),tr=ni({status:di(["READY","NEEDS_ATTENTION"]).optional(),code:wo().optional(),message:wo().optional(),checked_at:wo().optional()}),nr=(ni({provider:wo(),type:wo(),enabled:Ho(),connected:Ho(),credentials:ui(wo(),er),public_config:ui(wo(),Go()),webhook:ui(wo(),Go()).optional(),health:tr.optional()}),"#2563eb"),or=["comfortable","compact"],ir=["top","side","background"],rr=di(["checkout","payment_link","embed"]),ar=di(or),sr=di(["light","dark","system"]),lr=di(ir),ur=di(["ghost","outlined","filled"]),cr=di(["sheet","fullscreen","center"]),dr=di(["visible","hidden"]),pr=(di(["checkout.shell","checkout.panel","checkout.header","brand.logo","product.card","product.image","product.title","product.description","product.price","product.quantity","product.addon","paymentLink.hero","summary.panel","summary.line","summary.total","form.field","form.label","form.help","coupon.input","input.base","input.error","button.primary","button.secondary","payment.methods","payment.method","payment.method.icon","payment.method.label","payment.method.meta","payment.method.fee","payment.method.indicator","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.launcher","embed.launcher.icon","embed.productCard","embed.productCard.image","embed.productCard.title","embed.productCard.price","embed.cart","embed.cart.row","embed.cart.summary","embed.modal","embed.modal.header","embed.modal.close","embed.skeleton","embed.loader","embed.branding"]),di(["product.title","product.price","summary.total","payment.method.label","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.modal.close","embed.branding"]),wo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),fr=wo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),mr=wo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),_r=di(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),hr=wo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),yr=wo().url(),gr=ni({brand:ni({logoUrl:yr.optional().nullable(),logoDarkUrl:yr.optional().nullable(),logoMaxHeight:Bo().int().min(16).max(80).optional(),faviconUrl:yr.optional().nullable()}).strict().optional(),color:ni({brand:pr.optional(),brandContrast:pr.optional(),background:pr.optional(),surface:pr.optional(),surfaceRaised:pr.optional(),text:pr.optional(),textMuted:pr.optional(),border:pr.optional(),focus:pr.optional(),success:pr.optional(),warning:pr.optional(),error:pr.optional()}).strict().optional(),typography:ni({fontFamily:_r.optional(),googleFontFamily:hr.optional(),baseSize:Bo().int().min(12).max(18).optional()}).strict().optional(),shape:ni({buttonRadius:Bo().int().min(0).max(24).optional(),inputRadius:Bo().int().min(0).max(24).optional(),cardRadius:Bo().int().min(0).max(28).optional()}).strict().optional(),spacing:ni({density:ar.optional(),controlHeight:Bo().int().min(36).max(56).optional()}).strict().optional(),component:ni({primaryButton:ni({background:pr.optional(),text:pr.optional()}).strict().optional(),input:ni({background:pr.optional(),border:pr.optional(),focusRing:fr.optional()}).strict().optional(),summary:ni({background:pr.optional()}).strict().optional(),paymentMethod:ni({background:fr.optional(),cardBackground:fr.optional(),border:fr.optional(),selectedBackground:fr.optional()}).strict().optional(),productCard:ni({background:fr.optional(),border:fr.optional(),shadow:mr.optional()}).strict().optional(),productImage:ni({background:fr.optional(),border:fr.optional(),icon:fr.optional()}).strict().optional(),brandAvatar:ni({background:fr.optional(),text:pr.optional(),border:fr.optional()}).strict().optional(),pill:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),errorBanner:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),warningBanner:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),radio:ni({idleRing:fr.optional(),checkedFill:pr.optional(),checkedIcon:pr.optional()}).strict().optional(),divider:ni({color:fr.optional()}).strict().optional()}).strict().optional(),paymentLink:ni({heroImageUrl:yr.optional().nullable(),heroPosition:lr.optional()}).strict().optional(),embed:ni({launcher:ni({background:fr.optional(),text:pr.optional(),radius:Bo().int().min(0).max(28).optional(),paddingX:Bo().int().min(8).max(32).optional(),paddingY:Bo().int().min(6).max(24).optional(),shadow:mr.optional()}).strict().optional(),productCard:ni({background:fr.optional(),border:fr.optional(),imageRadius:Bo().int().min(0).max(24).optional(),padding:Bo().int().min(8).max(32).optional()}).strict().optional(),cart:ni({background:fr.optional(),rowBorder:fr.optional(),itemSpacing:Bo().int().min(4).max(28).optional()}).strict().optional(),modal:ni({background:fr.optional(),radius:Bo().int().min(0).max(32).optional(),maxWidth:Bo().int().min(360).max(960).optional(),shadow:mr.optional()}).strict().optional(),backdrop:ni({color:fr.optional(),blur:Bo().int().min(0).max(24).optional(),opacity:Bo().min(0).max(1).optional()}).strict().optional(),skeleton:ni({background:fr.optional(),shimmer:fr.optional()}).strict().optional(),spinner:ni({color:fr.optional()}).strict().optional(),closeButton:ni({style:ur.optional()}).strict().optional(),mobile:ni({layout:cr.optional()}).strict().optional(),content:ni({productDescription:dr.optional(),termsShortcut:dr.optional()}).strict().optional()}).strict().optional()}).strict(),br=ni({mode:sr.default("system"),fontSource:di(["curated"]).default("curated")}).strict(),vr=di(["standalone","bundle","pointer"]),wr=ni({name:wo().trim().min(1).max(80),fingerprint:wo().trim().min(1).max(128)}).strict(),Sr=["embed_design"];function kr(e){if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=e;if(!Sr.some(e=>e in t))return e;const n={...t};for(const o of Sr)delete n[o];return n}var Er=Ii(kr,ni({type:fi("shoppex.style_theme"),surface:fi("checkout"),format_version:ii([fi(1),fi(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fi(1),tokens:gr.default({}),custom_css:wo().max(2e4).default(""),settings:br.default({mode:"system",fontSource:"curated"}),_meta:ui(wo(),Go()).optional()}).strict()),Or=(Ii(kr,ni({type:fi("shoppex.style_theme"),surface:rr,format_version:ii([fi(1),fi(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fi(1),tokens:gr.default({}),custom_css:wo().max(2e4).default(""),settings:br.default({mode:"system",fontSource:"curated"}),share_mode:vr.default("standalone"),parent_hint:wr.optional(),bundled_parent:Er.optional(),_meta:ui(wo(),Go()).optional()}).strict()),ni({theme_id:wo().uuid().nullable(),surface:rr,token_schema_version:fi(1),revision:Bo().int().min(1),tokens:gr,custom_css:wo(),css_variables:ui(wo(),wo())}).strict(),ni({theme_id:wo().uuid().nullable(),parent_theme_id:wo().uuid().nullable(),surface:fi("embed"),token_schema_version:fi(1),revision:Bo().int().min(1),parent_revision:Bo().int().min(1).nullable(),tokens:gr,custom_css:wo(),css_variables:ui(wo(),wo())}).strict(),ni({shop_id:wo().uuid(),product_id:wo().uuid().nullable(),product_group_id:wo().uuid().nullable(),payment_link_id:wo().uuid().nullable(),invoice_id:wo().nullable()}).strict(),ni({embed_runtime:wo().min(16).max(128),revision:Bo().int().min(1),parent_revision:Bo().int().min(1).nullable(),theme_id:wo().uuid().nullable(),css_variables:ui(wo(),wo()),custom_css:wo()}).strict(),ni({embed_style_revision:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}(Fo,e)}().int().min(1).optional(),embed_runtime:wo().min(16).max(128).optional(),preview:Ho().optional()}).strict(),di(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),di(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),xr=(di(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),wo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),zr=di(["static","marquee"]),Tr=di(["brand_blue","emerald","sunset","rose","charcoal","custom"]),Ar=di(["hide","message"]),Ir=di(["compact","comfortable"]),Pr=di(["subtle","outline","solid"]),$r=di(["minimal","boxed"]),Nr=di(["indigo","emerald","amber","rose","slate","custom"]),Cr=di(["compact","feature","alert"]),Rr=di(["compact","comfortable"]),Ur=di(["subtle","outline","solid"]),qr=di(["sparkles","megaphone","gift","truck","shield","support","none"]),Dr=di(["show","hide"]),jr=di(["midnight","ocean","ember","forest","custom"]),Lr=di(["delay","exit_intent"]),Zr=wo().trim().refine(e=>{if(e.startsWith("/"))return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}},'Use a valid absolute URL or a path starting with "/"'),Mr=wo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Fr=ni({text:wo().trim().min(1,"Text is required").max(160,"Text must be 160 characters or fewer"),linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),dismissible:Ho().default(!1),displayMode:zr.default("marquee"),themePreset:Tr.default("custom"),animationSpeedSeconds:Bo().int().min(8).max(40).default(30),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb")}),Br=ni({text:wo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Mr,linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),dismissible:Ho().default(!1),themePreset:Tr.default("brand_blue"),expiredBehavior:Ar.default("hide"),expiredMessage:wo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:Ir.default("compact"),ctaStyle:Pr.default("subtle"),timerStyle:$r.default("boxed"),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb")}),Jr=ni({eyebrow:wo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:wo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),themePreset:Nr.default("indigo"),layoutStyle:Cr.default("feature"),density:Rr.default("comfortable"),ctaStyle:Ur.default("outline"),icon:qr.default("sparkles"),iconVisibility:Dr.default("show"),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb"),accentColor:xr.default("#818cf8")}),Yr=ni({title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer").default("Recent purchases"),lookbackHours:Bo().int().min(1).max(168).default(24),cooldownSeconds:Bo().int().min(5).max(300).default(20),maxItems:Bo().int().min(1).max(20).default(8),anonymizeMode:di(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:ei(wo().min(1)).max(50).default([])}),Wr=ni({eyebrow:wo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:wo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),couponCode:wo().trim().min(2,"Coupon code is required").max(40,"Coupon code must be 40 characters or fewer"),primaryButtonLabel:wo().trim().min(1,"Primary button label is required").max(24,"Primary button label must be 24 characters or fewer").default("Copy code"),secondaryButtonLabel:wo().trim().min(1,"Secondary button label is required").max(24,"Secondary button label must be 24 characters or fewer").default("Maybe later"),disclaimer:wo().trim().max(100,"Disclaimer must be 100 characters or fewer").optional().nullable(),themePreset:jr.default("midnight"),trigger:Lr.default("delay"),delaySeconds:Bo().int().min(0).max(60).default(6),showOncePerSession:Ho().default(!0),reminderHours:Bo().int().min(1).max(720).default(24),backgroundColor:xr.default("#111827"),textColor:xr.default("#f8fafc"),accentColor:xr.default("#7c9cff"),heroImageUrl:Zr.optional().nullable(),discountDisplay:wo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Mr.optional().nullable()}),Hr=di(["hidden","optional"]),Vr=ni({headline:wo().trim().min(1,"Headline is required").max(60,"Headline must be 60 characters or fewer").default("Chat with us"),greeting:wo().trim().min(1,"Greeting is required").max(240,"Greeting must be 240 characters or fewer").default("Hi! Send us a message and we will reply as soon as possible."),inputPlaceholder:wo().trim().min(1,"Placeholder is required").max(80,"Placeholder must be 80 characters or fewer").default("Type your message…"),contactFields:Hr.default("optional"),accentColor:xr.default("#111827"),launcherIconColor:xr.default("#f9fafb")}),Gr=ni({type:fi("announcement_bar"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Fr}),Kr=ni({type:fi("recent_purchase_popup"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Yr}),Xr=ni({type:fi("countdown_bar"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Br}),Qr=ni({type:fi("promo_info_card"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Jr}),ea=ni({type:fi("coupon_popup_modal"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Wr}),ta=ni({type:fi("live_chat"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Vr}),na=(ai("type",[Gr,Xr,Qr,Kr,ea,ta]),ai("type",[Gr.extend({id:wo().min(1)}),Xr.extend({id:wo().min(1)}),Qr.extend({id:wo().min(1)}),Kr.extend({id:wo().min(1)}),ea.extend({id:wo().min(1)}),ta.extend({id:wo().min(1)})]),new Set(["amount","currency","invoice_id","customer_email","id","email","price","price_usd","product_name","quantity"].map(e=>e.toLowerCase())),wo().regex(/^[A-Z]{3}$/,"Currency must be a three-letter uppercase code.")),oa=wo().url().refine(e=>"https:"===new URL(e).protocol,"URL must use HTTPS."),ia=ni({version:fi("2026-08-14")}),ra=(ia.extend({type:fi("payment.session.create"),data:ni({attempt_id:wo().uuid(),invoice_id:wo().uuid(),amount_minor:Bo().int().safe().positive(),currency:na,customer_email:wo().email().nullable(),description:wo().min(1).max(500),success_url:oa,cancel_url:oa,event_url:oa})}),ia.extend({provider_reference:wo().trim().min(1).max(255),checkout_url:oa,expires_at:Hn({offset:!0}).nullable().optional()}),ia.extend({type:di(["payment.processing","payment.succeeded","payment.failed"]),data:ni({attempt_id:wo().uuid(),provider_reference:wo().trim().min(1).max(255),amount_minor:Bo().int().safe().positive(),currency:na,occurred_at:Hn({offset:!0}).nullable().optional()})}),ia.extend({type:fi("adapter.conformance.run"),data:ni({challenge_id:wo().uuid(),mode:di(["standard","timeout"]),expected_event:ni({attempt_id:wo().uuid(),provider_reference:wo().trim().min(1).max(255),amount_minor:Bo().int().safe().positive(),currency:na})})}),ni({scenario:di(["valid_event","amount_mismatch","duplicate_event_first","duplicate_event_retry"]),webhook_id:wo().trim().min(1).max(255),webhook_timestamp:wo().trim().min(1).max(32),webhook_signature:wo().trim().min(1).max(1024),raw_body:wo().min(1).max(4096)})),aa=(ia.extend({type:fi("adapter.conformance.result"),data:ni({challenge_id:wo().uuid(),samples:ei(ra).length(4)})}),ui(wo(),Go())),sa=ii([wo(),Bo()]),la=ni({kind:di(["address","redirect","embed_pending"]),gateway:wo(),checkout_url:wo().nullable().optional(),address:wo().optional(),amount:wo().optional(),qr_code:wo().optional(),expires_at:wo().optional(),payment_id:wo().optional(),confirmations_needed:Bo().optional()}).passthrough(),ua=ni({default_value:wo().optional(),min_length:Bo().optional(),name:wo(),placeholder:wo().optional(),regex:wo().optional(),required:Ho(),type:wo()}),ca=ni({id:wo(),price:Bo(),quantity:Bo(),title:wo()}),da=ni({currency:wo(),description:wo(),id:wo(),price:Bo(),title:wo(),uniqid:wo()}),pa=ni({addons:ei(ca).optional(),available_addons:ei(Go()).optional(),cloudflare_image_id:wo().nullable(),created_at:wo().optional(),currency:wo(),custom_fields:aa.nullable().optional(),custom_fields_config:ei(ua).nullable().optional(),delivery_instruction:Go().optional(),delivery_instruction_config:Go().optional(),delivery_instruction_label:Go().optional(),delivery_text:wo().nullable().optional(),delivery_time:Bo().nullable().optional(),delivery_time_unit:di(["minutes","hours","days"]).nullable().optional(),description:wo().nullable(),discount_percent:Bo().optional(),discount_display:Bo().optional(),discounted_total_display:Bo().optional(),gateways:ei(wo()).nullable().optional(),id:wo().optional(),image_name:wo().nullable(),image_storage:wo().nullable().optional(),line_item_id:wo().nullable().optional(),pay_what_you_want:Ho().optional(),price:wo().optional(),price_display:sa,quantity:Bo(),quantity_max:Bo().optional(),quantity_min:Bo().optional(),recurring_interval:wo().nullable().optional(),recurring_interval_count:Bo().nullable().optional(),redirect_link:wo().nullable().optional(),redirect_time:Bo().nullable().optional(),service_text:wo().nullable().optional(),setup_cost:wo().optional(),slug:wo().nullable().optional(),storefront_url:wo().nullable().optional(),status:wo().nullable().optional(),subtype:wo().nullable().optional(),terms_of_service:wo().nullable().optional(),title:wo(),total:Bo(),trial_period:Bo().nullable().optional(),type:wo().nullable().optional(),uniqid:wo().nullable(),unit_price:Bo().optional(),unit_price_display:sa.optional(),unit_quantity:Bo(),updated_at:wo().optional(),variant_title:wo().nullable().optional(),video_link:wo().nullable().optional(),volume_discounts:Go().optional(),warranty_days:Bo().nullable().optional(),warranty_text:wo().nullable().optional()}),fa=ni({amount:Bo(),gateway:wo()}),ma=ni({custom_tip_enabled:Ho().optional(),enabled:Ho(),preset_percentages:ei(Bo()).optional()}),_a=ni({allow_partial_payment:Ho().optional(),auto_apply:Ho().optional(),available:wo(),currency:wo()}),ha=ni({affiliate_code:wo().nullable().optional(),already_paid:sa.nullable().optional(),amount_due:sa.nullable().optional(),currency:wo().nullable().optional(),discount:sa.nullable().optional(),discount_label:wo().nullable().optional(),gateway_fee:sa.nullable().optional(),platform_fee:sa.nullable().optional(),subtotal:sa.nullable().optional(),tip:sa.nullable().optional(),total:sa.nullable().optional()}),ya=ni({active:Ho(),expires_at:wo()}),ga=ni({faq_url:wo().nullable(),support_email:wo().nullable(),support_url:wo().nullable(),telegram_invite:wo().nullable(),discord_invite_url:wo().nullable()}),ba=ni({currency:wo().nullable().optional(),enabled:Ho(),max_amount:Bo().nullable().optional(),min_amount:Bo().nullable().optional(),reason:di(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),va=ni({delivered_items:ei(Go()),downloads:ei(Go()),external_urls:ei(Go()),license_keys:ei(Go()),tracking_codes:ei(Go())}),wa=ni({active:Ho().optional(),attempt_id:wo().optional(),buyer_actionable:Ho().nullable().optional(),crypto_currency:wo().nullable().optional(),currency:wo().optional(),expected_amount:wo().nullable().optional(),expected_crypto_amount:wo().nullable().optional(),last_checked_at:wo().optional(),missing_amount:wo().nullable().optional(),missing_crypto_amount:wo().nullable().optional(),provider_reference:wo().nullable().optional(),provider_status:wo().nullable().optional(),received_amount:wo().nullable().optional(),received_fiat_estimate:wo().nullable().optional(),received_crypto_amount:wo().nullable().optional(),shortfall_percent:wo().nullable().optional(),buyer_action_reason:di(["BELOW_MINIMUM_COLLECTIBLE","PROVIDER_SESSION_CLOSED","PROVIDER_TOP_UP_UNSUPPORTED","MERCHANT_REVIEW_REQUIRED"]).nullable().optional()}),Sa=ni({created_at:wo().nullable(),details:wo().nullable(),id:wo(),invoice_id:wo(),status:wo().nullable()}),ka=ni({billing_address_mode:di(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:wo().nullable().optional(),display_name:wo().nullable().optional(),gateway:wo(),hide_provider_attribution:Ho().optional(),icon_url:wo().nullable().optional(),terms_mode:di(["INHERIT","REQUIRED","DISABLED"]).optional()}),Ea=ni({custom_fields:ei(Go()).optional(),description:wo().nullable(),display_order:Bo(),icon_preset:wo().nullable(),icon_url:wo().nullable(),id:wo(),instructions:wo().nullable(),is_active:Ho().optional(),name:wo(),payment_type:di(["INSTRUCTIONS","REDIRECT"]),redirect_url:wo().nullable(),require_proof:Ho(),proof_type:di(["TEXT","IMAGE","BOTH"]).optional(),void_after_hours:Bo()}),Oa=ni({description:wo().nullable(),display_order:Bo(),icon_url:wo().nullable(),id:wo(),name:wo()}),xa=ni({email:ni({masked:wo().nullable(),persisted:Ho(),required_for_provider_session:Ho().optional()})}),za=ni({amount:wo().nullable(),confirmations:Bo().nullable(),created_at:Bo().optional(),hash:wo().nullable(),status:wo().optional()}),Ta=ni({conf:ni({partial:Bo().optional(),void:Bo(),waiting_for_confirmations:Bo().optional()}),gateways:ei(wo())}),Aa=ni({invoice_payable:Ho(),resumable:Ho(),resumable_gateway:wo().nullable(),gateway:wo().nullable().optional(),crypto_gateway:wo().nullable().optional(),processor:wo().nullable().optional(),flow_type:wo().nullable().optional(),status:wo().nullable().optional(),provider_reference:wo().nullable().optional(),provider_reference_type:wo().nullable().optional(),capture_id:wo().nullable().optional(),manual_confirmation_pending:Ho().optional(),payment_method_switch_locked:Ho().optional(),awaiting_payment_method:Ho().optional(),started_at:Bo().nullable().optional(),completed_at:Bo().nullable().optional()}),Ia=Aa.extend({gateway:wo().nullable(),flow_type:wo().nullable(),status:wo().nullable(),manual_confirmation_pending:Ho(),payment_method_switch_locked:Ho()}),Pa=ni({theme_id:wo().nullable(),surface:di(["checkout","payment_link","embed"]),token_schema_version:fi(1),revision:Bo(),tokens:aa,custom_css:wo(),css_variables:ui(wo(),wo())}),$a=ni({link_id:wo(),source_gateway:wo().nullable(),invoice_uniqid:wo(),deprioritize_source_gateway:Ho().optional()}),Na=ni({enabled:Ho(),required:Ho(),connected:Ho()}),Ca=ni({gateway:wo().nullable().optional(),active_type:wo().nullable().optional(),percent_amount:sa.nullable().optional(),fixed_amount:sa.nullable().optional(),fixed_currency:wo().nullable().optional()}),Ra=ni({id:wo(),type:di(["WALLET_CREDIT","COUPON"]),status:di(["PENDING","FULFILLED","FAILED","REVOKED"]),amount:wo().nullable(),currency:wo().nullable(),coupon_code:wo().nullable(),reason:di(["ORDER_COMPLETED","ORDER_COUNT_REACHED","SPEND_AMOUNT_REACHED","POSITIVE_REVIEW_LEFT","FIRST_PURCHASE_COMPLETED"]),trigger_reference_type:wo(),trigger_reference_id:wo(),created_at:Bo(),fulfilled_at:Bo().nullable(),expires_at:Bo().nullable()}),Ua=ni({summary:ni({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:wo().nullable(),currency:wo()}),activity:ei(Ra),earned_after_invoice:ei(Ra),pending_after_invoice:ei(Ra)}),qa=ni({already_paid_amount:sa.nullable().optional(),apm_method:wo().nullable().optional(),blockchain:wo().nullable(),buyer_identity:xa.nullable().optional(),checkout_tipping:ma.nullable().optional(),country_regulations:wo().nullable().optional(),coupon_applied:Ho().optional(),crypto_mode:wo().nullable().optional(),crypto_transactions:ei(za).optional(),currency:wo().nullable(),custom_fields:aa.nullable().optional(),custom_gateways:ei(Ea).optional(),external_payment_adapters:ei(Oa).optional(),customer_balance:_a.nullable().optional(),customer_email_masked:wo().nullable().optional(),dark_mode:ii([fi(0),fi(1)]).optional(),delivery:va.optional(),delivery_info:va.optional(),discount:Bo().optional(),discount_display:sa.optional(),eligible_gateways:ei(wo()).optional(),environment:wo().optional(),fee_breakdown:aa.nullable().optional(),gateway:wo().nullable(),gateway_data:aa.nullable().optional(),gateway_eligibility:ui(wo(),ba).optional(),gateway_fee_previews:ei(fa).optional(),gateways_available:ei(wo()),license:ii([aa,fi(!1)]).optional(),name:wo().nullable(),paddle_token:wo().nullable().optional(),paddle_transaction_id:Go().optional(),payment_link_id:wo().nullable().optional(),payment_method_overrides:ei(ka).optional(),payment_session_state:Aa.nullable().optional(),polling:ya,pricing_breakdown:ha.nullable().optional(),product:ei(pa).optional(),quantity:Bo().nullable(),rates_snapshot:ui(wo(),Bo()).optional(),remaining_amount:sa.nullable().optional(),selected_gateway:wo().nullable().optional(),shop_checkout_ambient_color:wo().nullable().optional(),shop_cloudflare_image_id:wo().nullable(),shop_domain:wo().nullable().optional(),shop_force_paypal_email_delivery:ii([fi(0),fi(1)]).optional(),shop_image_name:wo().nullable(),shop_image_storage:wo().nullable().optional(),shop_payment_gateways_fees:ei(aa).optional(),shop_paypal_credit_card:ii([fi(0),fi(1)]).optional(),shop_return_url:wo().nullable().optional(),shop_slug:wo().nullable().optional(),shop_terms_enabled:Ho().optional(),shop_terms_of_service:wo().nullable().optional(),shop_terms_url:wo().nullable().optional(),shop_privacy_policy_url:wo().nullable().optional(),shop_refund_policy_url:wo().nullable().optional(),shop_walletconnect_id:wo().nullable().optional(),status:wo().nullable(),status_history:ei(Sa).optional(),status_history_legacy:ei(Sa).optional(),status_history_raw:ei(Sa).optional(),stripe_publishable_key:wo().nullable().optional(),stripe_user_id:wo().nullable().optional(),subtotal:Bo().optional(),subtype:wo().nullable().optional(),support:ga.optional(),theme:wo().optional(),tip_amount:sa.nullable().optional(),tip_amount_display:sa.nullable().optional(),tip_metadata:Go().optional(),total:sa,total_conversions:aa.optional(),total_display:sa,type:wo().nullable(),underpayment:wa.nullable().optional(),underpayment_status:wo().nullable().optional(),uniqid:wo(),void_times:ei(Ta).optional(),addons:Go().optional(),affiliate_data:Go().optional(),affiliate_revenue_customer_id:wo().nullable().optional(),bill_info:Go().optional(),binance_checkout_url:wo().nullable().optional(),binance_invoice_id:wo().nullable().optional(),binance_qrcode:wo().nullable().optional(),bundle_config:Go().optional(),bundles:Go().optional(),cashapp_cashtag:wo().nullable().optional(),cashapp_note:wo().nullable().optional(),cashapp_qrcode:wo().nullable().optional(),created_at:wo().optional(),crypto_address:wo().nullable().optional(),crypto_amount:sa.optional(),crypto_confirmations_needed:Bo().nullable().optional(),crypto_exchange_rate:sa.nullable().optional(),crypto_received:sa.optional(),crypto_uri:wo().nullable().optional(),developer_invoice:Go().optional(),developer_return_url:wo().nullable().optional(),developer_title:wo().nullable().optional(),exchange_rate:sa.nullable().optional(),external_order_id:wo().nullable().optional(),lex_order_id:wo().nullable().optional(),lex_payment_method:wo().nullable().optional(),paydash_payment_id:wo().nullable().optional(),paypal_apm:wo().nullable().optional(),paypal_email_delivery:Ho().optional(),paypal_fee:sa.nullable().optional(),paypal_order_id:wo().nullable().optional(),paypal_payer_email:wo().nullable().optional(),paypal_subscription_id:wo().nullable().optional(),paypal_subscription_link:wo().nullable().optional(),perfectmoney_id:wo().nullable().optional(),product_addons:Go().optional(),product_id:wo().nullable().optional(),product_title:wo().nullable().optional(),product_type:wo().nullable().optional(),product_variants:Go().optional(),recurring_billing_id:wo().nullable().optional(),skrill_link:wo().nullable().optional(),skrill_sid:wo().nullable().optional(),status_details:Go().optional(),stripe_apm:wo().nullable().optional(),stripe_client_secret:wo().nullable().optional(),stripe_id:wo().nullable().optional(),stripe_price_id:wo().nullable().optional(),subscription:Go().optional(),subscription_id:wo().nullable().optional(),sumup_id:wo().nullable().optional(),telegram_stars_payment_link:wo().nullable().optional(),telegram_stars_payment_note:wo().nullable().optional(),updated_at:wo().optional(),virtual_payments_id:wo().nullable().optional(),void_details:Go().optional()}).catchall(Go()),Da=pa.extend({available_addons:ei(da).optional(),delivery_instructions:wo().nullable().optional(),delivery_instructions_config:ni({enabled:fi(!0),required:Ho(),label:wo(),placeholder:wo().nullable().optional(),help_text:wo().nullable().optional(),max_length:Bo()}).nullable().optional(),delivery_instructions_label:wo().nullable().optional(),image_url:wo().nullable().optional(),redirectLink:wo().nullable().optional(),redirectTime:Bo().nullable().optional(),serviceText:wo().nullable().optional()}),ja=(ni({data:ni({invoice:qa.extend({uniqid:wo().uuid(),shop_id:ii([wo(),Bo()]).nullable(),customer_email:wo().nullable(),checkout_style:Pa.nullable().optional(),coupon_id:wo().nullable().optional(),discount_breakdown:aa.nullable().optional(),affiliate_code:wo().nullable().optional(),country:wo().nullable().optional(),paypal_email:wo().nullable().optional(),pandabase_available_payment_methods:ei(wo()).optional(),payment_rescue:$a.nullable().optional(),discord_integration:Na.nullable().optional(),payment_session_state:Ia.nullable().optional(),shop_payment_gateways_fees:ei(Ca).optional(),product:ei(Da).optional(),products:ei(Da).optional(),rewards:Ua.nullable().optional()}).superRefine((e,t)=>{void 0===e.product&&void 0===e.products&&t.addIssue({code:"custom",message:"Embed checkout invoice must include product or products.",path:["product"]})}),invoice_url:wo().nullable(),checkout_url:wo().nullable(),selected_gateway:wo().nullable(),session_started:Ho(),payment_session:la.nullable(),completion_access_grant:wo().nullable()}).passthrough()}).passthrough(),3),La=2,Za={maximumFractionDigits:3};function Ma(e){if(!Number.isFinite(e))return e;const t=e<0?-1:1,n=Fa(Math.abs(e),2),o=Math.round(n);return 0===o?0:t*Fa(o,-2)}function Fa(e,t){const[n,o="0"]=String(e).split("e");return Number(`${n}e${Number(o)+t}`)}var Ba=wo().nullable(),Ja=ui(wo(),Go()),Ya=ni({logo_url:Ba,primary_color:wo(),secondary_color:wo(),accent_color:wo()}),Wa=(ni({customer:ni({id:Ba,email:wo(),name:wo(),avatar_url:Ba,joined_at:Ba}),shop:ni({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:Ya}),token:Ba}),ni({attachment_image_id:ni({cloudflare_image_id:Ba}).nullable()})),Ha=ni({attachment_imageId:ni({cloudflareImageId:Ba}).nullable()}),Va=ni({uniqid:wo(),status:wo(),total:wo(),total_display:Ba,currency:wo(),created_at:wo(),line_items:ei(ni({product_title:Ba,quantity:Bo(),product:Wa.nullable()}))}),Ga=ni({uniqid:wo(),status:wo(),total:wo(),totalDisplay:Ba,currency:wo(),createdAt:wo(),lineItems:ei(ni({productTitle:Ba,quantity:Bo(),product:Ha.nullable()}))}),Ka=ni({invoices:ei(Ga),pagination:ni({page:Bo(),limit:Bo(),total:Bo(),has_more:Ho()})}),Xa=(ni({can_review:Ho(),already_submitted:Ho(),feedback_uniqid:Ba,product_title:Ba,score:Bo().nullable(),is_automated:Ho(),message:Ba,submitted_at:Ba}),ni({gateway:wo(),displayName:Ba,cryptoGateway:Ba.optional(),blockchain:Ba,cryptoAddress:Ba,apmMethod:Ba})),Qa=ni({id:wo(),uniqid:wo(),status:wo(),statusDetails:Ba,total:wo(),totalDisplay:Ba,subtotal:wo(),discount:wo(),discountDisplay:Ba,tax:wo(),taxPercentage:wo(),currency:wo(),createdAt:wo(),updatedAt:wo(),gatewayUpdatedAt:Ba,customFields:Ja.nullable(),balancePaidAmount:wo(),currentPaymentAttemptId:Ba,lineItems:ei(ni({id:wo(),productTitle:wo(),productType:wo(),variantTitle:Ba,unitPrice:wo(),quantity:Bo(),total:wo(),deliveryText:Ba,deliverySummary:ni({codes:ei(wo()),links:ei(ni({label:wo(),value:wo(),href:Ba.optional()})),notes:ei(wo()),serials:ei(ni({value:wo(),is_replacement:Ho(),is_replaced:Ho()}))}).nullable(),deliveredAt:Ba,deliveryStatus:di(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:Ja.nullable(),product:ni({uniqid:wo(),slug:Ba,serviceText:Ba,attachment_imageId:ni({cloudflareImageId:Ba}).nullable()}).nullable()})),currentPayment:Xa.nullable(),payments:ei(Xa)}),es=(ni({quote:ni({enabled:Ho(),currency:wo(),min_amount:wo(),max_amount:Ba,bonus_tiers:ei(ni({min_amount:wo(),bonus_percent:Bo()}))})}),ni({invoice_id:wo(),url:wo()}),ni({id:wo(),type:wo(),status:wo(),amount:Ba,currency:Ba,coupon_code:Ba,reason:wo(),trigger_reference_type:wo(),trigger_reference_id:wo(),created_at:Bo(),fulfilled_at:Bo().nullable(),expires_at:Bo().nullable()})),ts=ni({summary:ni({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:Ba,currency:wo()}),activity:ei(es),earned_after_invoice:ei(es),pending_after_invoice:ei(es)}),ns=ni({id:wo(),uniqid:wo(),label:Ba,code:wo(),url:Ba,status:di(["pending","active","inactive","rejected"]),is_primary:Ho(),total_clicks:Bo(),total_sales:Bo(),total_revenue:wo(),is_active:Ho(),is_approved:Ho(),requested_affiliate_revenue_percent:Bo().nullable(),requested_affiliate_customer_discount_percent:Bo().nullable(),affiliate_revenue_percent_override:Bo().nullable(),affiliate_customer_discount_percent_override:Bo().nullable(),effective_commission_percent:Bo(),effective_customer_discount_percent:Bo(),commission_shareback_percent:Bo(),commission_shareback_enabled:Ho(),max_commission_shareback_percent:Bo(),created_at:Ba,updated_at:Ba}),os=ni({customer:ni({id:wo(),email:wo(),name:Ba}).nullable(),state:wo(),can_create_custom_links:Ho(),custom_link_request_disabled_reason:Ba,custom_links_require_approval:Ho(),affiliate_codes_accepted_at_checkout:Ho(),cash_payout_enabled:Ho(),links:ei(ns),preferred_payout:ni({asset:wo(),network:wo(),address:wo()}).nullable(),balance_currency:wo(),balances:ni({pending:wo(),available:wo(),requested:wo(),converted:wo(),paid:wo(),approved_total:wo()}),commissions:ei(ni({id:wo(),invoice_id:wo(),commission_amount:wo(),base_amount:wo(),discount_amount:wo(),status:wo(),created_at:Ba,paid_at:Ba,converted_at:Ba})),claims:ei(ni({id:wo(),type:wo(),status:wo(),amount:wo(),currency:wo(),allocations:ei(ni({source_type:wo(),commission_id:Ba,adjustment_id:Ba,amount:wo()})),wallet_transaction_id:Ba,payout_asset:Ba,payout_network:Ba,payout_address:Ba,note:Ba,metadata:Go(),completed_at:Ba,rejected_at:Ba,cancelled_at:Ba,created_at:Ba,updated_at:Ba}))}),is=ni({uniqid:wo(),status:wo(),gateway:wo(),current_period_start:wo(),current_period_end:wo(),trial_end:Ba,cancel_at_period_end:Ho(),canceled_at:Ba,created_at:wo(),plan:ni({id:wo(),uniqid:wo(),name:wo(),price:wo(),currency:wo(),interval:wo(),interval_count:Bo(),trial_days:Bo()}).nullable(),payment_method:ni({id:wo(),gateway:wo(),type:wo(),card_brand:Ba,card_last4:Ba,card_exp_month:Bo().nullable(),card_exp_year:Bo().nullable(),is_default:Ho()}).nullable(),actions:ni({can_pause:Ho(),can_resume:Ho(),can_cancel:Ho(),can_manage_payment_method:Ho()})}),rs=ni({enabled:Ho(),account:ni({points_balance:Bo(),lifetime_points:Bo()}).nullable(),settings:ni({earn_rate_per_usd:Bo(),redeem_value_per_point:Bo(),min_redeem_points:Bo()}).nullable(),transactions:ei(ni({type:di(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:Bo(),balance_after:Bo(),description:Ba,created_at:wo()}))}),as=ni({redeemed_points:Bo(),wallet_amount:wo(),currency:wo(),points_balance:Bo(),replayed:Ho()}),ss=ni({uniqid:wo(),invoice_uniqid:wo(),product_title:wo(),period_days:Bo(),starts_at:wo(),expires_at:wo(),status:di(["ACTIVE","EXPIRED","VOIDED"]),claim_status:di(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:wo()}),ls=ni({warranties:ei(ss)}),us=ni({warranty:ss.extend({claim_status:fi("REQUESTED")})}),cs=(ni({customer:ni({id:wo(),email:wo(),name:wo(),joined_at:Ba})}),ni({avatar_url:Ba}),ni({global_unsubscribed:Ho(),lists:ei(ni({id:wo(),name:wo(),description:Ba,subscribed:Ho()}))}),ni({updated:Ho()}),ni({order_created_emails:Ho(),order_completed_emails:Ho(),payment_issue_emails:Ho()}),ni({favorites:ei(ni({product_uniqid:wo(),title:wo(),slug:Ba,image_url:Ba,price_display:Bo(),unavailable:Ho(),created_at:wo()}))}),ii([ni({added:fi(!0)}),ni({removed:fi(!0)})]),ni({license:ni({uniqid:wo(),hardware_id:Ba})}),ni({invoice_id:wo(),checkout_url:wo(),preferred_gateways:ei(wo()),license:ni({uniqid:wo(),product_title:wo()})}),ni({invoices:ei(ni({id:wo(),uniqid:wo(),total:wo(),currency:wo(),status:wo(),gateway:wo(),created_at:wo(),completed_at:wo()}))}),ni({subscription:ni({id:wo(),status:wo(),cancel_at_period_end:Ho(),cancel_reason:Ba,canceled_at:Ba})}),ni({subscription:ni({id:wo(),status:wo()})}),ni({ticket:ni({uniqid:wo(),title:wo(),status:wo(),invoice_id:Ba,created_at:wo(),updated_at:wo(),messages:ei(ni({id:wo(),role:di(["CUSTOMER","SHOP","SYSTEM"]),message:wo(),created_at:wo()}))})}),ni({uniqid:wo()}),ni({affiliate_link:ni({id:wo(),customer_id:wo(),label:Ba,code:wo(),url:Ba,status:di(["pending","approved","rejected"]),requested_affiliate_revenue_percent:Bo().nullable(),requested_affiliate_customer_discount_percent:Bo().nullable(),created_at:wo(),updated_at:wo()})}),ni({check:wo(),passed:Ho(),reason:Ba.optional()})),ds=(ni({eligible:Ho(),decision:di(["ELIGIBLE","DENIED","NO_RULE"]),reason:Ba,eligibility_checks:ei(cs)}),ni({request_id:wo(),event_id:Ba,decision:di(["ISSUED_REPLACEMENT","FALLBACK_REFUND","FALLBACK_CREDIT","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED"]),status_label:di(["ISSUED","REFUNDED","CREDITED","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED","PENDING"]),reason:Ba,eligibility_checks:ei(cs)}),ni({id:wo(),name:Ba,discount_percent:Bo().nullable()})),ps=ni({id:wo(),status:di(["INVITED","APPLIED","ACTIVE","SUSPENDED","REJECTED"]),tier:ds.nullable(),application_note:Ba,lifetime_revenue:wo(),lifetime_orders:Bo(),approved_at:Ba,created_at:wo()}),fs=(ni({program_enabled:Ho(),enrollment_mode:di(["MANUAL","APPLICATION","OPEN"]),application_message:Ba,require_application_note:Ho(),reseller:ps.nullable()}),ni({reseller:ps}),di(["variant","product","tier"])),ms=ni({variant_id:wo(),title:wo(),stock:Bo(),supplier_backed:Ho(),orderable:Ho(),base_price:wo(),unit_price:wo(),discount_percent:Bo(),applied_override:fs}),_s=(ni({tier:ds,catalog:ni({currency:wo(),total:Bo(),page:Bo(),per_page:Bo(),items:ei(ni({product_id:wo(),uniqid:wo(),title:wo(),type:wo(),stock:Bo(),supplier_backed:Ho(),orderable:Ho(),volume_discount_enabled:Ho(),base_price:wo(),unit_price:wo(),discount_percent:Bo(),applied_override:fs,variants:ei(ms)}))})}),ni({quote:ni({currency:wo(),tier:ds,items:ei(ni({product_id:wo(),product_title:wo(),product_type:wo(),variant_id:Ba,variant_title:Ba,quantity:Bo(),base_price:wo(),discount_percent:Bo(),unit_price:wo(),line_total:wo(),applied_override:fs,volume_discount_applied:wo()})),subtotal:wo(),volume_discount_total:wo(),total:wo(),savings:wo()})}),ni({orders:ni({total:Bo(),page:Bo(),per_page:Bo(),items:ei(ni({uniqid:wo(),status:wo(),currency:wo(),total:wo(),item_count:Bo(),created_at:wo()}))})}),ni({order:ni({uniqid:wo(),status:wo(),currency:wo(),total:wo(),item_count:Bo(),created_at:wo(),tier_name:wo(),tier_discount_percent:Bo(),partially_delivered:Ho(),refunded_amount:Ba,lines:ei(ni({product_id:Ba,product_title:wo(),variant_id:Ba,variant_title:Ba,quantity:Bo(),unit_price:wo(),total:wo(),delivered:Ho(),delivered_at:Ba,serials:ei(wo())}))})}),ni({wallet:ni({currency:wo(),balance:wo(),hold_balance:wo(),available:wo(),is_active:Ho()})}),ni({api_keys:ei(ni({id:wo(),name:wo(),key_last4:wo(),last_used_at:Ba,revoked_at:Ba,created_at:wo()}))}),ni({topup:ni({uniqid:wo(),url:wo()})}),ni({shop:ni({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:Ya}),customer:ni({email:wo(),name:wo()}),stats:ni({invoices_count:Bo(),licenses_count:Bo(),deliverables_count:Bo(),tickets_count:Bo()}),wallet:ni({available:wo(),total:wo(),hold:wo(),currency:wo(),enabled:Ho()}).nullable(),rewards:ts,affiliate:os,invoices:ei(Va),subscriptions:ei(is),licenses:ei(ni({uniqid:wo(),invoice_id:wo(),status:wo(),license_key:wo(),hardware_id:Ba,expires_at:Bo().nullable(),renewable:Ho(),product:ni({title:wo().optional()}).optional()})),deliverables:ei(ni({id:wo(),invoice_uniqid:wo(),product_title:wo(),kind:di(["file","serial","license"]),label:wo(),value:wo(),href:Ba,created_at:wo()})),tickets:ei(ni({uniqid:wo(),title:wo(),status:wo(),updated_at:wo(),created_at:Ba}))}));var hs=null,ys=null;var gs=null,bs=null;function vs(e,t){const n=t?.shopId?.trim();bs=n||null;const i=gs?.locale;return i!==(gs={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}).locale&&o(),hs=null,ys=null,gs}function ws(){if(!gs)throw new s;return gs}function Ss(){return null!==gs}function ks(e){bs=e}function Es(){return bs}function Os(e){return function(e){if(Array.isArray(e))return e;if("string"==typeof e){try{const t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const e=t.custom_fields??t.customFields;return Array.isArray(e)?e:[]}}catch{return[]}return[]}if(e&&"object"==typeof e){const t=e.custom_fields??e.customFields;return Array.isArray(t)?t:[]}return[]}(e).filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)).map(e=>{const t="string"==typeof e.type?e.type.trim().toLowerCase():"text",n=t.length>0?t:"text",o=[e.default_value,e.default,e.value].find(e=>"string"==typeof e&&e.trim().length>0);return{name:"string"==typeof e.name?e.name.trim():"",type:n,required:!0===e.required||"true"===e.required||1===e.required||"1"===e.required,defaultValue:"string"==typeof o?o:"",placeholder:"string"==typeof e.placeholder?e.placeholder:"",regex:"string"==typeof e.regex?e.regex:void 0}}).filter(e=>e.name.length>0&&"hidden"!==e.type)}function xs(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}function zs(e,t){if("checkbox"===e.type)return e.required&&!xs(t)?`${e.name} is required.`:null;const n=t.trim();if(e.required&&!n)return`${e.name} is required.`;if(e.regex&&n)try{if(!new RegExp(e.regex).test(n))return`${e.name} has an invalid format.`}catch{return null}return null}function Ts(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(xs(o)&&(n[e.name]="true"));const i=o.trim();i.length>0&&(n[e.name]=i)}),n}var As=-1;function Is(e,t,n){return!0!==t?e:!0===n?As:0!==e?e:As}function Ps(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):null}function $s(e){if(!0===e)return!0;if("number"==typeof e&&Number.isFinite(e))return 0!==e;if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"1"===t}return!1}function Ns(e){return Is(Ps(e?.stock)??As,e?.orderable,e?.supplier_backed)}function Cs(e){if(!e)return As;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return Is(Ps(e.stock)??As,e.orderable,e.supplier_backed);const t=function(e){const t=Array.isArray(e.price_variants)?e.price_variants:[];return t.length>0?t.map(e=>Ns(e)):(Array.isArray(e.variants)?e.variants:[]).map(e=>Ns(e))}(e);return t.length>0?t.some(e=>e<0)?As:Is(t.reduce((e,t)=>e+Math.max(t,0),0),e.orderable,e.supplier_backed):Is(Ps(e.stock)??As,e.orderable,e.supplier_backed)}function Rs(e){return!!function(e){return!!e&&($s(e.on_hold)||$s(e.onHold)||$s(e.is_on_hold)||$s(e.isOnHold))}(e)||0===Cs(e)}function Us(e){return!Rs(e)}function qs(e){return 0===Ns(e)}function Ds(e=[]){const t=/* @__PURE__ */new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function js(e,t=[]){const n=t instanceof Map?t:Ds(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function Ls(e=[]){return Array.from(Ds(e).values())}function Zs(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function Ms(e){return e.trim().toLowerCase()}function Fs(e,t){const n=Zs(t).toLowerCase();n&&e.push(n)}function Bs(e){const t=[];Fs(t,e.title),Fs(t,e.slug??void 0),Fs(t,e.description);for(const n of e.product_highlights??[])Fs(t,n);for(const n of e.variants??[])Fs(t,n.title);for(const n of e.price_variants??[])Fs(t,n.title??n.label);return t}function Js(e,t){const n=Ms(t);return!!n&&Bs(e).some(e=>e.includes(n))}function Ys(e,t){const n=Ms(t);if(!n)return!1;const o=Zs(e.title).toLowerCase(),i=Zs(e.slug??e.name??void 0).toLowerCase(),r=Zs(e.description).toLowerCase();return o.includes(n)||i.includes(n)||r.includes(n)}function Ws(e,t,n){const o=Ms(t);if(!o)return[];let i=e.filter(e=>Js(e,o));return n?.hideOutOfStock&&(i=i.filter(e=>Us(e))),null!=n?.maxResults?i.slice(0,n.maxResults):i}function Hs(e,t){return 0!==e.length&&(!t||e.some(e=>Us(e)))}function Vs(e,t,n,o){const i=Ms(n);if(!i)return[];const r=!0===o?.hideOutOfStock,a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=[],u=Ds(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!Ys(d,i))continue;const t=js(d,u);if(Hs(t,r)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=Ls(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&Js(d,i)&&(r&&!Us(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function Gs(e,t,n,o){const i=Vs(e,t,n,o),r=/* @__PURE__ */new Set,a=[],s=e=>{e?.uniqid&&!r.has(e.uniqid)&&(o?.hideOutOfStock&&!Us(e)||(r.add(e.uniqid),a.push(e)))};for(const l of i)if("product"!==l.type)for(const e of l.products)s(e);else s(l.product);return null!=o?.maxResults?a.slice(0,o.maxResults):a}function Ks(e){if(e?.apiBaseUrl?.trim())return e.apiBaseUrl.replace(/\/+$/,"");const t=e?.hostname??("undefined"!=typeof window?window.location.hostname:"");if(t&&!function(e){if("localhost"===e||"127.0.0.1"===e||"::1"===e||e.endsWith(".localhost"))return!0;if(/^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e))return!0;if(/^192\.168\.\d{1,3}\.\d{1,3}$/.test(e))return!0;const t=e.match(/^172\.(\d{1,2})\.\d{1,3}\.\d{1,3}$/);if(t){const e=Number(t[1]);return e>=16&&e<=31}return!1}(t))return"https://api.shoppex.io";if("undefined"!=typeof window){const e=window.apiBaseUrl;if("string"==typeof e&&e.trim())return e.replace(/\/+$/,"")}return"http://localhost:3001".replace(/\/+$/,"")}function Xs(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}async function Qs(e){const t=e.shopSlug.trim();if(!t)throw new Error("Store data is not ready yet. Please try again in a moment.");const n=e.email.trim().toLowerCase(),o=e.title?.trim()??"",i=o.length>=2?o.slice(0,30):"Contact Request",r=Xs({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=Ks({apiBaseUrl:e.apiBaseUrl}),l=await fetch(`${s}/v1/storefront/shops/name/${encodeURIComponent(t)}/tickets`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({email:n,title:i,message:r,...a?{invoice_id:a}:{}})}),u=await l.json().catch(()=>null);if(!l.ok)throw new Error(u?.message||u?.error||"Failed to send your message.");const c=u?.data?.uniqid;if(!c)throw new Error("Ticket created, but the response was incomplete.");return{uniqid:c}}function el(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}}var tl=/:([A-Za-z0-9_]+)/g;function nl(e,t){return e.replace(tl,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const i=String(o).trim();if(!i)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(i)})}function ol(e){return`shoppex_${e}`}function il(e){try{const t=localStorage.getItem(ol(e));return t?JSON.parse(t):null}catch{return null}}function rl(e,t){try{localStorage.setItem(ol(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function al(e){try{localStorage.removeItem(ol(e))}catch{}}function sl(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=il(t);if(n&&n.trim())return n;const o="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`spx_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return rl(t,o),o}async function ll(e){if(!Ss())return;if("undefined"==typeof window)return;if(function(e){const t=`client_error_${function(e){return[e.method,e.endpoint,e.statusCode??"none",e.message.trim().toLowerCase(),e.responseReceived?"response":"no-response"].join("|")}(e)}`,n=Date.now(),o=il(t);return"number"==typeof o&&n-o<15e3||(rl(t,n),!1)}(e))return;const t=ws(),n=Es(),o=n?nl("/v1/storefront/shops/id/:id/ping",{id:n}):nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),i=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:sl(t.storeSlug)??void 0,client_error:{source:e.source??"sdk",phase:e.phase??"request",endpoint:e.endpoint,method:e.method,message:e.message,status_code:e.statusCode,attempt_count:e.attemptCount,response_received:e.responseReceived??!1,page_url:e.pageUrl??window.location.href,request_url:e.requestUrl,online:e.online??("undefined"!=typeof navigator?navigator.onLine:void 0),visibility_state:e.visibilityState??("undefined"!=typeof document?document.visibilityState:void 0)}}),r=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([i],{type:"application/json"});if(navigator.sendBeacon(r,e))return}await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0})}catch{}}var ul=1e4;async function cl(e){return new Promise(t=>setTimeout(t,e))}async function dl(e,t={}){const n=t.baseUrl?null:ws(),o=n??(Ss()?ws():null),{method:i="GET",body:s,timeout:c=ul,retries:d,baseUrl:p,cache:f}=t,m=d??("GET"===i?2:0),_=`${p??n?.apiBaseUrl??""}${e}`,h={"Content-Type":"application/json",Accept:"application/json"};"string"==typeof o?.locale&&o.locale.trim()&&(h["x-shoppex-locale"]=o.locale.trim());let y=null;const g=async()=>{for(let t=0;t<=m;t++)try{const e=new AbortController,t=setTimeout(()=>e.abort(),c),n=await fetch(_,{method:i,headers:h,body:s?JSON.stringify(s):void 0,signal:e.signal});clearTimeout(t);const o=await pl(n);if(!n.ok){const e=n.statusText?`HTTP ${n.status}: ${n.statusText}`:`HTTP ${n.status}`,t=(o.data&&"object"==typeof o.data&&"error"in o.data&&"string"==typeof o.data.error?o.data.error:null)??(o.data&&"object"==typeof o.data&&"message"in o.data&&"string"==typeof o.data.message?o.data.message:null)??o.rawText??e,i=ml(o.data);if(i.code)throw new u(t,i.code,n.status,i.errorParams);throw new l(t,n.status)}if(204===n.status&&null===o.data)return{success:!0};if(!o.data||"object"!=typeof o.data||!("status"in o.data))throw new l("Invalid API response",n.status);return fl(o.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new l("Request timeout",408));const o=n instanceof a?n.statusCode:void 0;if(y={message:n.message,statusCode:o,isTransport:void 0===o||408===o,...n instanceof u?{code:n.code,...n.errorParams?{errorParams:n.errorParams}:{}}:{}},n instanceof u&&void 0!==o&&o>=400&&o<500&&408!==o)break;if(t<m){await cl(500*Math.pow(2,t));continue}}return{success:!1,message:y?.message??"Unknown error",...y?.code?{code:y.code}:{},...y?.errorParams?{errorParams:y.errorParams}:{}}},b="GET"===i&&f&&f.ttl>0?await r(f.key??`GET:${_}`,g,{ttl:f.ttl,staleWhileRevalidate:f.staleWhileRevalidate},e=>e.success):await g(),v=y;return!b.success&&v?.isTransport&&await ll({endpoint:e,method:i,message:b.message??v.message,statusCode:v.statusCode,attemptCount:m+1,requestUrl:_,responseReceived:void 0!==v.statusCode&&408!==v.statusCode}),b}async function pl(e){const t=e;if("function"!=typeof t.text){if("function"==typeof t.json)try{return{data:await t.json(),rawText:null}}catch{return{data:null,rawText:null}}return{data:null,rawText:null}}try{const e=await t.text();if(!e)return{data:null,rawText:null};try{return{data:JSON.parse(e),rawText:null}}catch{const t=e.trim();return{data:null,rawText:t.length>0?t:null}}}catch{return{data:null,rawText:null}}}function fl(e){return e.status>=200&&e.status<300?{success:!0,data:e.data,...e.message?{message:e.message}:{}}:{success:!1,message:e.error??e.message??`Request failed with status ${e.status}`,...ml(e)}}function ml(e){if(!e||"object"!=typeof e)return{};const t=e,n="string"==typeof t.error_code&&t.error_code.length>0?t.error_code:null;if(!n)return{};const o=t.error_params;return{code:n,...o&&"object"==typeof o&&!Array.isArray(o)?{errorParams:o}:{}}}async function _l(e,t){return dl(e,{...t,method:"GET"})}async function hl(e,t,n){return dl(e,{...n,method:"POST",body:t})}var yl=3e5;async function gl(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:yl,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&ks(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function bl(e){const t=ws(),n=new URLSearchParams;Number.isFinite(e?.productsLimit)&&n.set("products_limit",String(Math.max(1,Math.floor(e?.productsLimit??0)))),"string"==typeof e?.productsCursor&&e.productsCursor.trim().length>0&&n.set("products_cursor",e.productsCursor);const o=n.size>0?`?${n.toString()}`:"",i=await _l(`${nl("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:yl,staleWhileRevalidate:!0}});return i.success&&i.data?(i.data.shop?.id&&ks(i.data.shop.id),{success:!0,data:{shop:i.data.shop,products:i.data.products??[],products_pagination:i.data.products_pagination??null,groups:i.data.groups??[],items:i.data.items??[],categories:i.data.categories??[],addons:i.data.addons??{items:[]}}}):{success:!1,message:i.message}}var vl=12e4;function wl(e){if(e.variants&&e.variants.length>0)return e;const t=e.price_variants;return Array.isArray(t)&&0!==t.length?{...e,variants:t.map(e=>function(e){return{id:e.id,title:e.title??e.label??"",price:"number"==typeof e.price?e.price:Number(e.price)||0,stock:"number"==typeof e.stock?e.stock:void 0,orderable:"boolean"==typeof e.orderable?e.orderable:void 0,supplier_backed:"boolean"==typeof e.supplier_backed?e.supplier_backed:void 0,quantity_min:e.quantity_min,quantity_max:e.quantity_max,quantityMin:e.quantityMin,quantityMax:e.quantityMax,image_id:e.image_id,imageId:e.imageId,cloudflare_image_id:e.cloudflare_image_id,cloudflareImageId:e.cloudflareImageId,image_url:e.image_url,imageUrl:e.imageUrl}}(e))}:e}async function Sl(){const e=ws(),t=await _l(nl("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:vl,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:Ls(t.data.products.map(wl))}:{success:!1,message:t.message,data:[]}}var kl="shoppex:affiliate_code:v1";function El(){return Date.now()}function Ol(e){const t=e?.trim().toLowerCase();return t||null}function xl(e,t=30){const n=Ol(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(kl,JSON.stringify(e))}catch{}}({code:n,expiresAt:El()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(zl(),null);var o}function zl(){if("undefined"!=typeof window)try{window.localStorage.removeItem(kl)}catch{}}function Tl(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(kl);if(!e)return null;const t=JSON.parse(e);return t&&"string"==typeof t.code&&"number"==typeof t.expiresAt?t:null}catch{return null}}();return e?e.expiresAt<=El()?(zl(),null):Ol(e.code):null}async function Al(e){const t=Ol(e);if(!t)return{success:!1,data:{valid:!1,affiliate_code:null,discount_active:!1,discount_percent:0},message:"Affiliate code is required"};const n=ws(),o=await hl("/v1/storefront/affiliates/resolve",{shop_slug:n.storeSlug,code:t},{retries:0});if(!o.success)return o;if(!o.data?.valid||!o.data.affiliate_code){const e=!1===o.data?.program_enabled;return{success:!1,data:{valid:!1,...void 0!==o.data?.program_enabled?{program_enabled:o.data.program_enabled}:{},affiliate_code:null,discount_active:!1,discount_percent:0},message:o.message??(e?"Affiliate program is disabled for this shop.":"Invalid affiliate code.")}}return{success:!0,data:{valid:!0,...void 0!==o.data.program_enabled?{program_enabled:o.data.program_enabled}:{},affiliate_code:Ol(o.data.affiliate_code),discount_active:Boolean(o.data.discount_active),discount_percent:Number(o.data.discount_percent??0)},...o.message?{message:o.message}:{}}}function Il(e){if(!e)return{};const t=Object.entries(e).filter(([,e])=>"string"==typeof e).sort(([e],[t])=>e.localeCompare(t));return Object.fromEntries(t)}function Pl(e){const t={product_id:e.product_id,variant_id:e.variant_id,price_variant_id:e.price_variant_id??null,addons:(n=e.addons,n?.length?[...n].map(e=>({id:e.id,quantity:e.quantity??1})).sort((e,t)=>e.id.localeCompare(t.id)):[]),custom_fields:Il(e.custom_fields),unit_price:"number"==typeof e.price_data?.unit_price&&Number.isFinite(e.price_data.unit_price)?e.price_data.unit_price:null,pay_what_you_want_price:"number"==typeof e.pay_what_you_want_price&&Number.isFinite(e.pay_what_you_want_price)?e.pay_what_you_want_price:null};var n;return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(t))}function $l(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:Pl(e)}}function Nl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function Cl(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return Nl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return Nl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}var Rl={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function Ul(e){return`${Rl[e]}_${ws().storeSlug}`}function ql(e){return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(e))}function Dl(e){if(!Number.isFinite(e))throw new d("quantity must be a finite number");return Math.floor(e)}function jl(e){const t=e?.trim().toUpperCase();return t||null}function Ll(){const e=il(Ul("coupon"));if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,n="string"==typeof t.code?jl(t.code):null,o="COUPON"===t.source||"AFFILIATE"===t.source?t.source:null;return n&&o?{code:n,source:o}:null}function Zl(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n,o="string"==typeof e.product_id?e.product_id.trim():"",i="string"==typeof e.variant_id?e.variant_id.trim():"",r=Number(e.quantity);if(!o||!i||!Number.isFinite(r)||r<1)continue;const a={line_id:"",product_id:o,variant_id:i,quantity:Math.floor(r)};if("string"==typeof e.price_variant_id&&(a.price_variant_id=e.price_variant_id),e.price_data&&"object"==typeof e.price_data){const t=e.price_data;"number"==typeof t.unit_price&&Number.isFinite(t.unit_price)&&(a.price_data={unit_price:t.unit_price})}"number"==typeof e.pay_what_you_want_price&&Number.isFinite(e.pay_what_you_want_price)&&(a.pay_what_you_want_price=e.pay_what_you_want_price),Array.isArray(e.addons)&&(a.addons=e.addons),e.custom_fields&&"object"==typeof e.custom_fields&&!Array.isArray(e.custom_fields)&&(a.custom_fields=e.custom_fields),"string"==typeof e.title&&(a.title=e.title),"string"==typeof e.variant_title&&(a.variant_title=e.variant_title),"string"==typeof e.image_url&&(a.image_url=e.image_url),Array.isArray(e.addon_labels)&&(a.addon_labels=e.addon_labels.filter(e=>"string"==typeof e)),"number"==typeof e.max_quantity&&Number.isFinite(e.max_quantity)&&(a.max_quantity=e.max_quantity),"number"==typeof e.min_quantity&&Number.isFinite(e.min_quantity)&&(a.min_quantity=e.min_quantity),Gl(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||Pl(a),t.push($l(a))}return t}function Ml(){return il(Ul("meta"))}function Fl(){return Ll()?.code??null}function Bl(){return Ll()?.source??null}function Jl(e,t="COUPON"){const n=jl(e);return n?(rl(Ul("coupon"),{code:n,source:t}),n):(al(Ul("coupon")),null)}function Yl(){al(Ul("coupon"))}function Wl(e){const t=Zl(e);rl(Ul("cart"),t);const n=Date.now(),o=Ml(),i={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:ql(t)};rl(Ul("meta"),i),0===t.length&&Yl()}function Hl(e,t){const n=Zl(e);rl(Ul("cart"),n);const o=Date.now(),i=t??Ml(),r={created_at:i?.created_at??o,last_modified:o,version:i?.version??1,checksum:ql(n)};rl(Ul("meta"),r)}function Vl(){return Zl(il(Ul("cart")))}function Gl(e){const t=e.min_quantity;"number"==typeof t&&Number.isFinite(t)&&e.quantity<t&&(e.quantity=Math.floor(t));const n=e.max_quantity;"number"==typeof n&&Number.isFinite(n)&&e.quantity>n&&(e.quantity=Math.floor(n)),e.quantity<1&&(e.quantity=1)}function Kl(){al(Ul("cart")),al(Ul("meta")),Yl(),tu=null,nu+=1}function Xl(){const e=Vl();rl(Ul("cartBackup"),e);const t=Ll();t?rl(Ul("couponBackup"),t):al(Ul("couponBackup"));const n=Ml();if(n)rl(Ul("metaBackup"),n);else{const t=Date.now();rl(Ul("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:ql(e)})}}function Ql(){const e=Vl(),t=Ml(),n=ql(e);return t?t.checksum===n:(Hl(e,null),!0)}function eu(){const e=Fl();return"AFFILIATE"===Bl()&&e?e.trim().toLowerCase():Tl()}var tu=null,nu=0;function ou(){return tu}var iu="Your cart changed while checkout was starting. Please review it and try again.";function ru(e,t){return void 0!==t&&JSON.stringify(e)!==t}function au(e){const t=e?.trim();return t||null}function su(e){const t=e?.trim();return t||null}function lu(e){return"/dashboard/api/checkout"===e.customerCheckoutPath&&"undefined"!=typeof window&&"string"==typeof window.location?.origin?{endpoint:e.customerCheckoutPath,baseUrl:window.location.origin}:{endpoint:"/v1/storefront/invoices/from-cart"}}function uu(e){return Nl(e.currency)??Cl()??Nl(ws().currency)}function cu(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(du(t))return"Your cart is outdated. Please add the products again.";const n=t.match(/^HTTP\s+(\d{3})(?::\s*(.*))?$/i);if(n){const e=Number(n[1]),t=n[2]?.trim();return t&&t.length>0?`Checkout failed: ${t}`:e>=500?"Checkout is temporarily unavailable. Please try again.":400===e?"Checkout failed. Please check your details and try again.":401===e||403===e?"Checkout is currently unavailable for this request.":"Checkout failed. Please try again."}return/^internal server error$/i.test(t)?"Checkout is temporarily unavailable. Please try again.":t}function du(e){const t=e?.trim().toLowerCase()??"";return!!t&&(t.includes("product not found")||t.includes("product not available")||t.includes("products are no longer available")||t.includes("outdated product"))}function pu(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),i=new URL(o);if(t.origin!==i.origin)return null;const r=t.pathname.replace(/\/+$/,""),a=`${i.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!r.startsWith(a))return null;const s=r.slice(a.length);if(!s||s.includes("/"))return null;if(n){const e=n.trim();if(!e||decodeURIComponent(s)!==e)return null}return t.toString()}catch{return null}}function fu(e,t){const n=su(t.email),o="string"==typeof t.locale?t.locale.trim():"";if(!n&&!o)return e;try{const t=new URL(e);if(o&&t.searchParams.set("locale",o),n){const e=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash);e.set("shoppex_prefill_email",n),t.hash=e.toString()}return t.toString()}catch{return e}}function mu(e,t){const n=e?.invoice,o=e?.invoiceId?.trim()||e?.invoice_id?.trim()||e?.uniqid?.trim()||n?.invoiceId?.trim()||n?.invoice_id?.trim()||n?.uniqid?.trim();let i=e?.checkoutUrl?.trim()||e?.checkout_url?.trim()||e?.url_branded?.trim()||e?.url?.trim()||n?.checkoutUrl?.trim()||n?.checkout_url?.trim()||n?.url_branded?.trim()||n?.url?.trim();return!i&&o&&n&&(i=function(e,t){const n=e?.trim();if(!n)return null;try{const e=new URL(n);return e.pathname=`${e.pathname.replace(/\/+$/,"")}/invoice/${encodeURIComponent(t)}`.replace(/\/{2,}/g,"/"),e.search="",e.hash="",e.toString()}catch{return null}}(t,o)??void 0),o&&i?{invoiceId:o,checkoutUrl:i,rewards:e?.rewards??n?.rewards??null}:null}function _u(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function hu(e,t){const n=e.affiliateCode??e.referralCode;if("string"==typeof n){const e=n.trim().toLowerCase();return e.length>0?e:null}return t?.trim().toLowerCase()??Tl()}function yu(e){const t=Fl(),n=Bl();return{coupon:void 0===e.coupon?"COUPON"===n?t:null:au(e.coupon),affiliateCode:hu(e,void 0===e.coupon&&"AFFILIATE"===n?t:null)}}function gu(e){const t=e=>{const t=e?.trim();return t?"default"===t.toLowerCase()?null:t:null};return e.map(e=>({product_id:e.product_id,variant_id:t(e.variant_id),quantity:e.quantity,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1})),custom_fields:e.custom_fields,price_variant_id:e.price_variant_id||null,pay_what_you_want_price:e.pay_what_you_want_price}))}function bu(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function vu(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function wu(e,t){const n=e,o=bu(n.rating)??bu(n.score)??0,i=vu(n.comment,n.message),r=vu(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=vu(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...i?{comment:i}:{},...r?{author:r}:{},created_at:s}}async function Su(e){const t=ws(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,i=await _l(`${nl("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return i.success&&i.data?{success:!0,data:{...i.data,feedback:i.data.feedback.map(wu)}}:{success:!1,message:i.message}}function ku(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Eu(e,t){return"string"==typeof e.error&&e.error.length>0?e.error:"string"==typeof e.message&&e.message.length>0?e.message:t.statusText?`HTTP ${t.status}: ${t.statusText}`:`HTTP ${t.status}`}function Ou(e){const t="string"==typeof e.error_code&&e.error_code.length>0?e.error_code:null;return t?{code:t,...ku(e.error_params)?{errorParams:e.error_params}:{}}:{}}async function xu(e,t={}){const n=t.method??"GET",o={Accept:"application/json"};void 0!==t.body&&(o["Content-Type"]="application/json");const i=t.formData??(void 0!==t.body?JSON.stringify(t.body):void 0);try{const a=await fetch(`/api/customer${e}`,{method:n,headers:o,body:i,credentials:"same-origin",cache:"no-store"});if(204===a.status)return a.ok?{success:!0,status:a.status}:{success:!1,status:a.status,message:Eu({status:a.status,data:null},a)};let s;try{s=await a.json()}catch{return{success:!1,status:a.status,message:"Invalid customer API response"}}const l=ku(r=s)&&"number"==typeof r.status&&"data"in r?r:null;if(!l)return{success:!1,status:a.status,message:"Invalid customer API response"};if(!a.ok||l.status<200||l.status>=300)return{success:!1,status:a.status,message:Eu(l,a),...Ou(l)};const u="string"==typeof l.message&&l.message.length>0?{message:l.message}:{};if(!t.schema)return{success:!0,data:l.data,...u};const c=t.schema.safeParse(l.data);return c.success?{success:!0,data:c.data,...u}:{success:!1,message:"Customer API response did not match the expected contract"}}catch(a){return{success:!1,message:a instanceof Error?a.message:String(a)}}var r}function zu(e){return xu("/auth/otp/request",{method:"POST",body:{email:e}})}function Tu(e,t){return xu("/auth/otp/verify",{method:"POST",body:{email:e,otp:t}})}function Au(){return xu("/auth/logout",{method:"POST"})}function Iu(){return xu("/me")}function Pu(){return xu("/dashboard",{schema:_s})}function $u(e={}){const t=new URLSearchParams;return void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.limit&&t.set("limit",String(e.limit)),e.status&&t.set("status",e.status),e.search&&t.set("q",e.search),xu("/invoices"+(t.size>0?`?${t.toString()}`:""),{schema:Ka})}function Nu(e){return xu(`/invoice/${encodeURIComponent(e)}`,{schema:Qa})}function Cu(){return xu("/loyalty",{schema:rs})}function Ru(e){return xu("/loyalty/redeem",{method:"POST",body:{points:e.points,idempotency_key:e.idempotencyKey},schema:as})}function Uu(e){return xu("/warranties"+(e?`?invoice=${encodeURIComponent(e)}`:""),{schema:ls})}function qu(e,t){return xu(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",body:t?{message:t}:{},schema:us})}function Du(e){return xu(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",body:{}})}function ju(e){return xu(`/subscriptions/${encodeURIComponent(e)}/billing-history`)}function Lu(e,t={}){return xu(`/subscriptions/${encodeURIComponent(e)}/cancel`,{method:"POST",body:{...void 0!==t.cancel_at_period_end?{cancel_at_period_end:t.cancel_at_period_end}:{},...void 0!==t.reason?{reason:t.reason}:{}}})}function Zu(e){return xu(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",body:{}})}function Mu(e){return xu(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",body:{}})}function Fu(){return xu("/favorites")}function Bu(e){return xu(`/favorites/${encodeURIComponent(e)}`,{method:"PUT"})}function Ju(e){return xu(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE"})}function Yu(){return xu("/affiliate")}function Wu(e){return xu("/tickets",{method:"POST",body:{...void 0!==e.title?{title:e.title}:{},message:e.message,...void 0!==e.invoice_id?{invoice_id:e.invoice_id}:{}}})}function Hu(e){return xu(`/tickets/${encodeURIComponent(e)}`)}function Vu(e,t){return xu(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",body:{message:t}})}function Gu(e){return xu("/profile",{method:"POST",body:{name:e.name}})}function Ku(e){const t=new FormData;return t.append("file",e),xu("/profile/avatar",{method:"POST",formData:t})}function Xu(){return xu("/profile/avatar",{method:"DELETE"})}function Qu(){return xu("/email-marketing/preferences")}function ec(e){return xu("/email-marketing/preferences",{method:"PATCH",body:{...void 0!==e.global_unsubscribed?{global_unsubscribed:e.global_unsubscribed}:{},...void 0!==e.list_subscriptions?{list_subscriptions:e.list_subscriptions}:{}}})}function tc(){return xu("/sessions")}function nc(e){return xu(`/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function oc(){return xu("/sessions?others=true",{method:"DELETE"})}function ic(){return xu("/reseller")}function rc(e){return xu("/reseller/apply",{method:"POST",body:void 0===e?{}:{note:e}})}function ac(){return xu("/reseller/enroll",{method:"POST",body:{}})}function sc(e){return xu("/reseller/accept-invite",{method:"POST",body:{token:e}})}function lc(e={}){const t=new URLSearchParams;return void 0!==e.search&&t.set("search",e.search),void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.per_page&&t.set("per_page",String(e.per_page)),xu("/reseller/catalog"+(t.size>0?`?${t.toString()}`:""))}function uc(e){return xu("/reseller/orders/quote",{method:"POST",body:{items:e}})}function cc(e={}){const t=new URLSearchParams;return void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.per_page&&t.set("per_page",String(e.per_page)),xu("/reseller/orders"+(t.size>0?`?${t.toString()}`:""))}function dc(e){return xu(`/reseller/orders/${encodeURIComponent(e)}`)}function pc(){return xu("/reseller/wallet")}function fc(){return xu("/reseller/api-keys")}function mc(e){const t=e.trim();return t||null}var _c=3e5;var hc=3e5;async function yc(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:hc,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function gc(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:hc,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function bc(e){return gc(e)}async function vc(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:hc,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function wc(e){return function(e){const t=S[e];return[t.title,...t.aliases]}(e)}var Sc=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function kc(e){return`shoppex:utm:${e}`}function Ec(e){if("undefined"==typeof window||void 0===window.location)return;const t=function(e){let t;try{t=new URLSearchParams(e)}catch{return{}}const n={};for(const o of Sc){const e=t.get(o)?.trim();e&&(n[o]=e.slice(0,255))}return n}(window.location.search);if(Object.keys(t).length>0)return function(e,t){try{const n={utm:t,at:Date.now()};window.localStorage.setItem(kc(e),JSON.stringify(n))}catch{}}(e,t),t;const n=function(e){try{const t=window.localStorage.getItem(kc(e));if(!t)return{};const n=JSON.parse(t);if(!n||"number"!=typeof n.at||"object"!=typeof n.utm)return{};if(Date.now()-n.at>2592e6)return window.localStorage.removeItem(kc(e)),{};const o={};for(const e of Sc){const t=n.utm?.[e];"string"==typeof t&&t.length>0&&(o[e]=t.slice(0,255))}return o}catch{return{}}}(e);return Object.keys(n).length>0?n:void 0}async function Oc(e,t){if(!Ss())return;if("undefined"==typeof document)return;const n=ws(),o=sl(n.storeSlug);try{const i=nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referer:document.referrer||void 0,cart_value:e??void 0,item_count:t??void 0,connection_id:o??void 0,utm:Ec(n.storeSlug)})})}catch{}}async function xc(){if(!Ss())return{success:!1,message:"SDK not initialized"};const e=ws(),t=Es();return _l(t?nl("/v1/storefront/shops/id/:id/recent-sales",{id:t}):nl("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function zc(){if(!Ss())return{success:!1,message:"SDK not initialized"};const e=ws(),t=Es();return _l(t?nl("/v1/storefront/shops/id/:id/online-users",{id:t}):nl("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function Tc(){if(!Ss())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=ws(),t=Es();return hl(t?nl("/v1/storefront/shops/id/:id/ping",{id:t}):nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:sl(e.storeSlug)??void 0,utm:Ec(e.storeSlug)},{retries:0,timeout:5e3})}function Ac(e,t){const n=ws();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD",...Za})}function Ic(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Pc(e){return Ic(e)&&Ic(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:Ic(e.theme.content)?e.theme.content:{},layout:Ic(e.theme.layout)?e.theme.layout:{},style_slots:Ic(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...Ic(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function $c(e){const t=await _l(nl("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?Ic(n=t.data)?{settings:Ic(n.settings)?n.settings:{},builder_settings:Pc(n.builder_settings),content:Ic(n.content)?n.content:{},style_slots:Ic(n.style_slots)?n.style_slots:{}}:null:null;var n}async function Nc(e){const t=await $c(e);return t?t.settings:null}function Cc(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,i]of Object.entries(o))t[n][e]=i.default}return t}function Rc(e,t){const n={...e};for(const[o,i]of Object.entries(t))i&&(n[o]={...n[o],...i});return n}var Uc={init:function(e,t){"string"==typeof e?vs(e,t):vs(e.storeId,e)},isInitialized:Ss,getConfig:ws,client:function(e){const t=ws().apiBaseUrl??"https://api.shoppex.io";if(hs&&ys===t&&!e)return hs;const n=function(e,t){return f({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(hs=n,ys=t),n},getStore:gl,getStorefront:bl,getStoreLogoUrl:async function(){const e=await gl();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await gl();return e.success&&e.data?.banner?e.data.banner:null},resolveStoreByDomain:async function(e,t){const n=e??("undefined"!=typeof window?window.location.hostname:"");if(!n)return{success:!1,message:"Domain is required to resolve store"};const o=n.replace(/^https?:\/\//,"").split("/")[0].trim(),i=t??(Ss()?ws().apiBaseUrl:"https://api.shoppex.io"),r=await _l(nl("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:i,cache:{key:`store:domain:${o}`,ttl:yl,staleWhileRevalidate:!0}});return r.success&&r.data?.shop?(r.data.shop.id&&ks(r.data.shop.id),{success:!0,data:r.data.shop}):{success:!1,message:r.message??"Failed to resolve store"}},getProducts:Sl,getStorefrontProductsPage:async function(e){const t=ws(),n=new URLSearchParams;"string"==typeof e?.cursor&&e.cursor.trim().length>0&&n.set("cursor",e.cursor),Number.isFinite(e?.limit)&&n.set("limit",String(Math.max(1,Math.floor(e?.limit??0)))),"string"==typeof e?.sort&&e.sort.trim().length>0&&n.set("sort",e.sort.trim()),"string"==typeof e?.category&&e.category.trim().length>0&&n.set("category",e.category.trim()),!0===e?.hideOutOfStock&&n.set("hide_out_of_stock","true");const o=n.size>0?`?${n.toString()}`:"",i=await _l(`${nl("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${r=e?.category,void 0===r?"category:unset":null===r?"category:null":`category:${r}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:vl,staleWhileRevalidate:!0}});var r;return i.success&&i.data?{success:!0,data:{products:i.data.products.map(wl),pagination:i.data.pagination??null}}:{success:!1,message:i.message}},getProduct:async function(e){let t=Es();if(!t){const e=await gl();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await _l(`${nl("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:vl,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:wl(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await Sl();if(!e.success||!e.data)return{success:!1,message:e.message};const t=/* @__PURE__ */new Set;for(const n of e.data)if(n.categories)for(const e of n.categories)"string"==typeof e?t.add(e):e&&"object"==typeof e&&"uniqid"in e&&t.add(e.uniqid);return{success:!0,data:Array.from(t)}},getCart:Vl,getCartItemCount:function(){return Vl().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:Fl,getCartCouponSource:Bl,setCartCoupon:Jl,clearCartCoupon:Yl,addToCart:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const i=Dl(n);if(i<1)throw new d("quantity must be at least 1");const r=Vl(),a=Pl({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price}),s=r.findIndex(e=>e.line_id===a);if(s>=0)r[s].quantity+=i,o?.addons&&(r[s].addons=o.addons),o?.custom_fields&&(r[s].custom_fields=o.custom_fields),o?.price_variant_id&&(r[s].price_variant_id=o.price_variant_id),o?.price_data&&(r[s].price_data=o.price_data),void 0!==o?.pay_what_you_want_price&&(r[s].pay_what_you_want_price=o.pay_what_you_want_price),function(e,t){if(t?.replace_display_snapshot)return e.title=t.title,e.variant_title=t.variant_title,e.image_url=t.image_url,e.addon_labels=t.addon_labels,e.max_quantity=t.max_quantity,void(e.min_quantity=t.min_quantity);void 0!==t?.title&&(e.title=t.title);void 0!==t?.variant_title&&(e.variant_title=t.variant_title);void 0!==t?.image_url&&(e.image_url=t.image_url);void 0!==t?.addon_labels&&(e.addon_labels=t.addon_labels);void 0!==t?.max_quantity&&(e.max_quantity=t.max_quantity);void 0!==t?.min_quantity&&(e.min_quantity=t.min_quantity)}(r[s],o),Gl(r[s]);else{const n={line_id:a,product_id:e,variant_id:t,quantity:i,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Gl(n),r.push(n)}Wl(r)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const i=Dl(n);if(i<1)throw new d("quantity must be at least 1");const r=Vl(),a=Pl({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price});for(let l=r.length-1;l>=0;l-=1)r[l].product_id===e&&r[l].variant_id===t&&r.splice(l,1);const s={line_id:a,product_id:e,variant_id:t,quantity:i,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Gl(s),r.push(s),Wl(r)},updateCartItem:function(e,t){const n=Vl(),o=e.trim();if(!o)throw new d("line_id is required");const i=n.findIndex(e=>e.line_id===o);if(i<0)throw new d("Item not found in cart");const r=JSON.stringify(n);if(void 0!==t.quantity){const e=Dl(t.quantity);if(e<1)return n.splice(i,1),void Wl(n);n[i].quantity=e}void 0!==t.addons&&(n[i].addons=t.addons),void 0!==t.custom_fields&&(n[i].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[i].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[i].price_data=t.price_data),void 0!==t.pay_what_you_want_price&&(n[i].pay_what_you_want_price=t.pay_what_you_want_price),void 0!==t.max_quantity&&(null===t.max_quantity?delete n[i].max_quantity:n[i].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(null===t.min_quantity?delete n[i].min_quantity:n[i].min_quantity=t.min_quantity),Gl(n[i]);const a=Pl(n[i]),s=n.findIndex((e,t)=>t!==i&&e.line_id===a);s>=0?(n[s].quantity+=n[i].quantity,Gl(n[s]),n.splice(i,1)):n[i].line_id=a,JSON.stringify(n)!==r&&Wl(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new d("line_id is required");Wl(Vl().filter(e=>e.line_id!==t))},clearCart:Kl,createCartBackup:Xl,restoreCartFromBackup:function(){const e=Zl(il(Ul("cartBackup"))),t=il(Ul("metaBackup")),n=il(Ul("couponBackup"));if(e&&e.length>0){if(Hl(e,t),n&&"object"==typeof n&&!Array.isArray(n)){const e=n,t="COUPON"===e.source||"AFFILIATE"===e.source?e.source:null;"string"==typeof e.code&&t?Jl(e.code,t):Yl()}else Yl();return!0}return!1},mergeBaskets:function(e){const t=Vl();for(const n of e){const e="string"==typeof n.product_id?n.product_id.trim():"",o="string"==typeof n.variant_id?n.variant_id.trim():"";if(!e||!o)continue;let i;try{i=Dl(n.quantity)}catch{continue}if(i<1)continue;const r=$l({...n,line_id:n.line_id??Pl(n),product_id:e,variant_id:o,quantity:i}),a=t.findIndex(e=>e.line_id===r.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,i),Gl(t[a])):(Gl(r),t.push(r))}return Wl(t),t},moveBasketItem:function(e,t,n,o){const i=Vl(),r=i.findIndex(n=>n.product_id===e&&n.variant_id===t);if(r<0)throw new d("Item not found in cart");const[a]=i.splice(r,1),s=Pl({...a,product_id:n,variant_id:o}),l=i.findIndex(e=>e.line_id===s);if(l>=0)i[l].quantity+=a.quantity,Gl(i[l]);else{const e=$l({...a,product_id:n,variant_id:o,line_id:s});Gl(e),i.push(e)}Wl(i)},getCartStats:function(){const e=Vl(),t=Ql(),n=Ml(),o=il(Ul("cartBackup"))??[],i=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),r=e.reduce((e,t)=>e+Ma((t.price_data?.unit_price??0)*t.quantity),0);return{item_count:e.length,total_quantity:e.reduce((e,t)=>e+t.quantity,0),last_modified:n?.last_modified??0,version:n?.version??0,has_backup:o.length>0,integrity_valid:t,total_price:Ma(r),total_price_is_estimate:e.length>0&&!i}},validateCartIntegrity:Ql,quoteCart:async function(e,t){const n=nu+=1,o=function(e){const t=ws(),n=jl(e)??Fl()??void 0;return{store_slug:t.storeSlug,items:Vl(),coupon:n}}(e),i=Nl(t)??Cl()??Nl(ws().currency),r=await hl("/v1/storefront/cart/quote",{shop_slug:o.store_slug,cart:o.items,coupon:o.coupon,affiliate_code:eu()??void 0,currency:i??void 0});return n!==nu||r.success&&(tu="string"==typeof r.data?.quote_token?r.data.quote_token:null),r},resolveCartLineId:function(e,t,n=Vl()){const o=n.filter(n=>n.product_id===e&&n.variant_id===t);if(0===o.length)throw new d(`No cart line found for ${e}/${t}`);return o[0].line_id},checkout:async function(e,t){const n=_u(e,t),{autoRedirect:o=!0,email:i}=n,r=yu(n),a=r.coupon,s=su(i),l=r.affiliateCode,u=uu(n),c=Vl();if(0===c.length)return{success:!1,message:"Cart is empty"};if(ru(c,n.expectedCart))return{success:!1,message:iu};Xl();const d=ws(),p=lu(n),f=await hl(p.endpoint,{shop_slug:d.storeSlug,cart:gu(c),email:s,coupon:a,currency:u,affiliate_code:l,quote_token:ou()??void 0},{retries:0,baseUrl:p.baseUrl});if(!f.success||!f.data)return du(f.message)&&Kl(),{success:!1,message:cu(f.message),...f.code?{code:f.code}:{}};const m=mu(f.data,d.checkoutBaseUrl);if(!m)return{success:!1,message:"Failed to create invoice"};const{invoiceId:_}=m,h=pu(m.checkoutUrl,d.checkoutBaseUrl,_);if(!h)return{success:!1,message:"Failed to create invoice"};const y=fu(h,{email:s,locale:n.locale??d.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=y,Kl()),{success:!0,redirectUrl:y,invoiceId:_,rewards:m.rewards}},buildCheckoutUrl:async function(e,t){const n=_u(e,t),{email:o}=n,i=yu(n),r=i.coupon,a=su(o),s=i.affiliateCode,l=uu(n),u=Vl();if(0===u.length)throw new Error("Cart is empty");if(ru(u,n.expectedCart))throw new Error(iu);const c=ws(),d=lu(n),p=await hl(d.endpoint,{shop_slug:c.storeSlug,cart:gu(u),email:a,coupon:r,currency:l,affiliate_code:s,quote_token:ou()??void 0},{retries:0,baseUrl:d.baseUrl});if(!p.success||!p.data)throw du(p.message)&&Kl(),new Error(cu(p.message));const f=mu(p.data,c.checkoutBaseUrl);if(!f)throw new Error("Failed to create invoice");const m=pu(f.checkoutUrl,c.checkoutBaseUrl,f.invoiceId);if(!m)throw new Error("Failed to create invoice");return fu(m,{email:a,locale:n.locale??c.locale})},buildCheckoutUrlSync:function(){throw new Error("buildCheckoutUrlSync is deprecated. Use buildCheckoutUrl (async) instead.")},captureAffiliateFromUrl:async function(e="ref"){if("undefined"==typeof window)return null;let t=null;try{const n=new URL(window.location.href).searchParams.get(e);t=n?n.trim():null}catch{t=null}if(t=Ol(t),!t)return null;if(xl(t),Ss())try{const e=ws(),n=await hl("/v1/storefront/affiliates/attribution",{shop_slug:e.storeSlug,code:t},{retries:0});return n.success&&n.data?.accepted&&n.data?.affiliate_code?(xl(n.data.affiliate_code),n.data.affiliate_code):(zl(),null)}catch{return t}return t},validateAffiliateCode:Al,applyAffiliateCode:async function(e){const t=await Al(e);return t.success&&t.data?.affiliate_code&&xl(t.data.affiliate_code),t},getAffiliateCode:Tl,setAffiliateCode:xl,clearAffiliateCode:zl,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},i="string"==typeof t?t:t?.productId,r="string"==typeof t?void 0:t?.variantId;if(r&&!i)return{success:!1,message:"productId is required when variantId is provided"};if(i)o.product_id=i,r&&(o.variant_id=r);else{const e=Vl();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=Es();if(e)return e;const t=await gl();return t.success&&t.data?.id?t.data.id:null}();if(!t)return{success:!1,message:"Failed to resolve store"};o.cart=JSON.stringify({shop_id:t,products:e.map(e=>({uniqid:e.product_id,quantity:e.quantity,variant_id:e.variant_id,price_variant_id:e.price_variant_id,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1}))}))})}return await hl("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=/* @__PURE__ */new Set;let n=null;for(;;){const o=await Su(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...o.data.feedback);const i=o.data.pagination;if(!i?.has_more||!i.next_cursor)break;if(t.has(i.next_cursor))break;t.add(i.next_cursor),n=i.next_cursor}return{success:!0,data:e}},getShopReviewsPage:Su,requestOtp:zu,verifyOtp:Tu,logout:Au,me:Iu,dashboard:Pu,orders:$u,order:Nu,loyalty:Cu,redeemLoyaltyPoints:Ru,warranties:Uu,claimWarranty:qu,resetLicenseHwid:Du,subscriptionBillingHistory:ju,cancelSubscription:Lu,pauseSubscription:Zu,resumeSubscription:Mu,favorites:Fu,addFavorite:Bu,removeFavorite:Ju,affiliate:Yu,createTicket:Wu,ticket:Hu,replyToTicket:Vu,updateProfile:Gu,updateAvatar:Ku,removeAvatar:Xu,emailPreferences:Qu,updateEmailPreferences:ec,sessions:tc,revokeSession:nc,revokeAllSessions:oc,reseller:ic,applyForReseller:rc,enrollAsReseller:ac,acceptResellerInvite:sc,resellerCatalog:lc,quoteResellerOrder:uc,resellerOrders:cc,resellerOrder:dc,resellerWallet:pc,resellerApiKeys:fc,searchProducts:async function(e,t){if(!Ss())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await bl();return o.success&&o.data?{success:!0,data:Gs(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},searchCatalogItems:async function(e,t){if(!Ss())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await bl();return o.success&&o.data?{success:!0,data:Vs(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},getInvoice:async function(e){const t=mc(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await _l(nl("/v1/storefront/invoices/unique/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?{success:!0,data:n.data.invoice}:{success:!1,message:"Invalid invoice response"}:{success:!1,message:n.message}},getInvoiceStatus:async function(e){const t=mc(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await _l(nl("/v1/storefront/invoices/status/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?.status?{success:!0,data:{status:n.data.invoice.status}}:{success:!1,message:"Invalid invoice status response"}:{success:!1,message:n.message}},getPages:async function(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:_c,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:_c,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:yc,getMenu:bc,getMenuBySlot:vc,getMenuByTitle:gc,getMenuSlotTitles:wc,trackPageView:Oc,getStorefrontOnlineUsers:zc,getStorefrontRecentSales:xc,touchStorefrontPresence:Tc,createFormatter:Ac,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?Ac(t,n).format(0):Ac(t,n).format(o)},clearCache:o,invalidateCache:function(t){for(const n of e.keys())(n===t||n.startsWith(t))&&e.delete(n)},getCacheStats:function(){return{hits:n.hits,misses:n.misses,pendingRequests:t.size,entries:e.size}},fetchPublishedBuilderSettings:$c,fetchPublishedThemeSettings:Nc,resolveDefaults:Cc,mergeSettings:Rc};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=Uc)}export{u as ApiError,ja as CATALOG_UNIT_PRICE_DECIMAL_PLACES,Za as CATALOG_UNIT_PRICE_FORMAT_OPTIONS,d as CartError,l as NetworkError,s as NotInitializedError,La as PAYABLE_AMOUNT_DECIMAL_PLACES,a as ShoppexError,c as ValidationError,sc as acceptResellerInvite,Bu as addFavorite,Yu as affiliate,rc as applyForReseller,Xs as buildStorefrontContactMessage,Ts as buildStorefrontCustomFieldPayload,Ds as buildStorefrontProductLookup,Lu as cancelSubscription,qu as claimWarranty,Bs as collectProductSearchHaystack,Pl as computeCartLineId,Wu as createTicket,Pu as dashboard,Uc as default,Uc as shoppex,Qu as emailPreferences,ac as enrollAsReseller,$l as ensureCartLineId,Fu as favorites,$c as fetchPublishedBuilderSettings,Nc as fetchPublishedThemeSettings,Ws as filterProductsBySearchQuery,bc as getMenu,vc as getMenuBySlot,gc as getMenuByTitle,wc as getMenuSlotTitles,yc as getMenus,Ls as getMergedStorefrontProducts,Su as getShopReviewsPage,js as getStorefrontGroupProducts,zc as getStorefrontOnlineUsers,xc as getStorefrontRecentSales,Ys as groupMatchesSearchQuery,Us as isProductInStock,Rs as isProductOutOfStock,xs as isStorefrontCheckboxCustomFieldValueChecked,qs as isVariantOutOfStock,Au as logout,Cu as loyalty,Iu as me,Rc as mergeSettings,Ms as normalizeSearchQuery,Os as normalizeStorefrontCustomFields,Nu as order,$u as orders,Zu as pauseSubscription,Js as productMatchesSearchQuery,uc as quoteResellerOrder,Ru as redeemLoyaltyPoints,Xu as removeAvatar,Ju as removeFavorite,Vu as replyToTicket,zu as requestOtp,ic as reseller,fc as resellerApiKeys,lc as resellerCatalog,dc as resellerOrder,cc as resellerOrders,pc as resellerWallet,Du as resetLicenseHwid,Cc as resolveDefaults,Cs as resolveDisplayStock,Ks as resolveStorefrontApiBaseUrl,el as resolveStorefrontSocialLinks,Ns as resolveVariantStockValue,Mu as resumeSubscription,oc as revokeAllSessions,nc as revokeSession,Ma as roundPayableAmount,Gs as searchMergedStorefrontCatalog,Vs as searchMergedStorefrontCatalogItems,tc as sessions,Zs as stripHtmlFromText,Qs as submitStorefrontContactTicket,ju as subscriptionBillingHistory,Hu as ticket,Tc as touchStorefrontPresence,Oc as trackPageView,Ku as updateAvatar,ec as updateEmailPreferences,Gu as updateProfile,zs as validateStorefrontCustomFieldValue,Tu as verifyOtp,Uu as warranties};
2
+ return qn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */qn(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */qn(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */qn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),vo=/*@__PURE__*/E("ZodString",(e,t)=>{dt.init(e,t),bo.init(e,t),e.email=t=>e.check(xn(ko,t)),e.url=t=>e.check(Tn(zo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...W(t)})}(Mo,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...W(t)})}(To,t)),e.guid=t=>e.check(zn(Oo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}(xo,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...W(t)})}(xo,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...W(t)})}(xo,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...W(t)})}(xo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}(Ao,t)),e.guid=t=>e.check(zn(Oo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}(Io,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}(Po,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}($o,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}(jo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}(Lo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}(No,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}(Co,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}(Ro,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}(Uo,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}(qo,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}(Do,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}(Zo,t)),e.datetime=t=>e.check(Hn(t)),e.date=t=>e.check(Gn(t)),e.time=t=>e.check(Xn(t)),e.duration=t=>e.check(eo(t))});function wo(e){return function(e,t){return new e({type:"string",...W(t)})}(vo,e)}var So=/*@__PURE__*/E("ZodStringFormat",(e,t)=>{pt.init(e,t),bo.init(e,t)}),ko=/*@__PURE__*/E("ZodEmail",(e,t)=>{_t.init(e,t),So.init(e,t)});function Eo(e){return xn(ko,e)}var Oo=/*@__PURE__*/E("ZodGUID",(e,t)=>{ft.init(e,t),So.init(e,t)}),xo=/*@__PURE__*/E("ZodUUID",(e,t)=>{mt.init(e,t),So.init(e,t)}),zo=/*@__PURE__*/E("ZodURL",(e,t)=>{ht.init(e,t),So.init(e,t)});var To=/*@__PURE__*/E("ZodEmoji",(e,t)=>{yt.init(e,t),So.init(e,t)}),Ao=/*@__PURE__*/E("ZodNanoID",(e,t)=>{gt.init(e,t),So.init(e,t)}),Io=/*@__PURE__*/E("ZodCUID",(e,t)=>{bt.init(e,t),So.init(e,t)}),Po=/*@__PURE__*/E("ZodCUID2",(e,t)=>{vt.init(e,t),So.init(e,t)}),$o=/*@__PURE__*/E("ZodULID",(e,t)=>{wt.init(e,t),So.init(e,t)}),No=/*@__PURE__*/E("ZodXID",(e,t)=>{St.init(e,t),So.init(e,t)}),Co=/*@__PURE__*/E("ZodKSUID",(e,t)=>{kt.init(e,t),So.init(e,t)}),Ro=/*@__PURE__*/E("ZodIPv4",(e,t)=>{Tt.init(e,t),So.init(e,t)}),Uo=/*@__PURE__*/E("ZodIPv6",(e,t)=>{At.init(e,t),So.init(e,t)}),qo=/*@__PURE__*/E("ZodCIDRv4",(e,t)=>{It.init(e,t),So.init(e,t)}),Do=/*@__PURE__*/E("ZodCIDRv6",(e,t)=>{Pt.init(e,t),So.init(e,t)}),jo=/*@__PURE__*/E("ZodBase64",(e,t)=>{Nt.init(e,t),So.init(e,t)}),Lo=/*@__PURE__*/E("ZodBase64URL",(e,t)=>{Ct.init(e,t),So.init(e,t)}),Zo=/*@__PURE__*/E("ZodE164",(e,t)=>{Rt.init(e,t),So.init(e,t)}),Mo=/*@__PURE__*/E("ZodJWT",(e,t)=>{Ut.init(e,t),So.init(e,t)}),Fo=/*@__PURE__*/E("ZodNumber",(e,t)=>{qt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:i,maximum:r,format:a,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const c="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(r??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;c?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:"number"==typeof i&&(o.minimum=i),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof r&&(o.maximum=r),"number"==typeof s&&(o.multipleOf=s)})(e,t,n),yo(e,"ZodNumber",{gt(e,t){return this.check(Pn(e,t))},gte(e,t){return this.check($n(e,t))},min(e,t){return this.check($n(e,t))},lt(e,t){return this.check(An(e,t))},lte(e,t){return this.check(In(e,t))},max(e,t){return this.check(In(e,t))},int(e){return this.check(Yo(e))},safe(e){return this.check(Yo(e))},positive(e){return this.check(Pn(0,e))},nonnegative(e){return this.check($n(0,e))},negative(e){return this.check(An(0,e))},nonpositive(e){return this.check(In(0,e))},multipleOf(e,t){return this.check(Nn(e,t))},step(e,t){return this.check(Nn(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Bo(e){return function(e,t){return new e({type:"number",checks:[],...W(t)})}(Fo,e)}var Jo=/*@__PURE__*/E("ZodNumberFormat",(e,t)=>{Dt.init(e,t),Fo.init(e,t)});function Yo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}(Jo,e)}var Wo=/*@__PURE__*/E("ZodBoolean",(e,t)=>{jt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Ho(e){return function(e,t){return new e({type:"boolean",...W(t)})}(Wo,e)}var Vo=/*@__PURE__*/E("ZodUnknown",(e,t)=>{Lt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Go(){return new Vo({type:"unknown"})}var Ko=/*@__PURE__*/E("ZodNever",(e,t)=>{Zt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Xo(e){return function(e,t){return new e({type:"never",...W(t)})}(Ko,e)}var Qo=/*@__PURE__*/E("ZodArray",(e,t)=>{Ft.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=Ln(r.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,yo(e,"ZodArray",{min(e,t){return this.check(Rn(e,t))},nonempty(e){return this.check(Rn(1,e))},max(e,t){return this.check(Cn(e,t))},length(e,t){return this.check(Un(e,t))},unwrap(){return this.element}})});function ei(e,t){return function(e,t,n){return new e({type:"array",element:t,...W(n)})}(Qo,e,t)}var ti=/*@__PURE__*/E("ZodObject",(e,t)=>{Ht.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object",i.properties={};const a=r.shape;for(const u in a)i.properties[u]=Ln(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===r.catchall?._zod.def.type?i.additionalProperties=!1:r.catchall?r.catchall&&(i.additionalProperties=Ln(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,o),R(e,"shape",()=>t.shape),yo(e,"ZodObject",{keyof(){return di(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Go()})},loose(){return this.clone({...this._zod.def,catchall:Go()})},strict(){return this.clone({...this._zod.def,catchall:Xo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!M(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return U(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!M(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return U(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return Y(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return U(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return Y(e,q(e._zod.def,{get shape(){const e={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(e[o]=n.shape[o])}return U(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return Y(e,q(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete o[e]}return U(this,"shape",o),o},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return Y(t,q(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return U(this,"shape",i),i},checks:[]}))}(hi,this,e[0])},required(...e){return t=ki,n=this,o=e[0],Y(n,q(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(o)for(const n in o){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return U(this,"shape",i),i}}));var t,n,o}})});function ni(e,t){const n={type:"object",shape:e??{},...W(t)};return new ti(n)}var oi=/*@__PURE__*/E("ZodUnion",(e,t)=>{Gt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=!1===i.inclusive,a=i.options.map((e,n)=>Ln(e,t,{...o,path:[...o.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function ii(e,t){return new oi({type:"union",options:e,...W(t)})}var ri=/*@__PURE__*/E("ZodDiscriminatedUnion",(e,t)=>{oi.init(e,t),Kt.init(e,t)});function ai(e,t,n){return new ri({type:"union",options:t,discriminator:e,...W(n)})}var si=/*@__PURE__*/E("ZodIntersection",(e,t)=>{Xt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Ln(i.left,t,{...o,path:[...o.path,"allOf",0]}),a=Ln(i.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(r)?r.allOf:[r],...s(a)?a.allOf:[a]]})(e,t,n,o)});var li=/*@__PURE__*/E("ZodRecord",(e,t)=>{tn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object";const a=r.keyType,s=a._zod.bag?.patterns;if("loose"===r.mode&&s&&s.size>0){const e=Ln(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});i.patternProperties={};for(const t of s)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=Ln(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),i.additionalProperties=Ln(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=a._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ui(e,t,n){return t&&t._zod?new li({type:"record",keyType:e,valueType:t,...W(n)}):new li({type:"record",keyType:wo(),valueType:e,...W(t)})}var ci=/*@__PURE__*/E("ZodEnum",(e,t)=>{nn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=A(e._zod.def.entries);o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=o})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new ci({...t,checks:[],...W(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new ci({...t,checks:[],...W(o),entries:i})}});function di(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ci({type:"enum",entries:n,...W(t)})}var pi=/*@__PURE__*/E("ZodLiteral",(e,t)=>{on.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,i=[];for(const r of o.values)if(void 0===r){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof r){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(r))}else i.push(r);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function fi(e,t){return new pi({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}var mi=/*@__PURE__*/E("ZodTransform",(e,t)=>{rn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new x(e.constructor.name);n.addIssue=o=>{if("string"==typeof o)n.issues.push(te(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(te(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function _i(e){return new mi({type:"transform",transform:e})}var hi=/*@__PURE__*/E("ZodOptional",(e,t)=>{sn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Yn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function yi(e){return new hi({type:"optional",innerType:e})}var gi=/*@__PURE__*/E("ZodExactOptional",(e,t)=>{ln.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Yn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var bi=/*@__PURE__*/E("ZodNullable",(e,t)=>{un.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Ln(i.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function vi(e){return new bi({type:"nullable",innerType:e})}var wi=/*@__PURE__*/E("ZodDefault",(e,t)=>{cn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Si=/*@__PURE__*/E("ZodPrefault",(e,t)=>{pn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var ki=/*@__PURE__*/E("ZodNonOptional",(e,t)=>{fn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var Ei=/*@__PURE__*/E("ZodCatch",(e,t)=>{_n.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;let r;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Oi=/*@__PURE__*/E("ZodPipe",(e,t)=>{hn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=i.in._zod.traits.has("$ZodTransform"),a="input"===t.io?r?i.out:i.in:i.out;Ln(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function xi(e,t){return new Oi({type:"pipe",in:e,out:t})}var zi=/*@__PURE__*/E("ZodPreprocess",(e,t)=>{Oi.init(e,t),gn.init(e,t)}),Ti=/*@__PURE__*/E("ZodReadonly",(e,t)=>{bn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Ln(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var Ai=/*@__PURE__*/E("ZodCustom",(e,t)=>{Sn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Ii(e,t){return new zi({type:"pipe",in:_i(e),out:t})}var Pi,$i=di(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),Ni=di(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),Ci=di(["BROADCAST","AUTOMATION"]),Ri=di(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),Ui=(ni({email:Eo(),name:wo().trim().min(1).nullable().optional(),customer_id:wo().uuid().nullable().optional(),tags:ei(wo().trim().min(1)).default([]),consent_basis:$i.default("UNKNOWN"),source:wo().trim().min(1).default("dashboard")}),ni({name:wo().trim().min(1),subject:wo().trim().min(1),preheader:wo().nullable().optional(),mjml_source:wo().trim().min(1),builder_project_json:ui(wo(),Go()).nullable().optional(),thumbnail_url:Tn(zo,Pi).nullable().optional()}),ni({mjml_source:wo().trim().min(1),sample_variables:ui(wo(),Go()).optional()}),ni({recipient_email:Eo(),sample_variables:ui(wo(),Go()).optional()}),ni({marketing_enabled:Ho().optional(),default_from_name:wo().trim().min(1).nullable().optional(),default_from_email:Eo().nullable().optional(),default_reply_to_email:Eo().nullable().optional(),physical_address:wo().trim().min(1).nullable().optional(),physical_address_line2:wo().trim().min(1).nullable().optional(),physical_city:wo().trim().min(1).nullable().optional(),physical_postal_code:wo().trim().min(1).nullable().optional(),physical_country:wo().trim().length(2).nullable().optional(),daily_limit:Bo().int().positive().optional(),monthly_soft_cap:Bo().int().positive().optional()}),ni({type:Ci.default("BROADCAST"),name:wo().trim().min(1),subject:wo().trim().min(1),template_id:wo().uuid(),list_id:wo().uuid().nullable().optional(),segment_id:wo().uuid().nullable().optional(),from_name:wo().trim().min(1),from_email:Eo(),reply_to_email:Eo().nullable().optional(),schedule_at:wo().datetime().nullable().optional(),target_emails:ei(Eo()).max(0,"Direct recipient entry is disabled. Use lists or segments built from Shoppex customers and paid order buyers.").default([]),idempotency_key:wo().trim().min(1).nullable().optional()}),ni({name:wo().trim().min(1),subject:wo().trim().min(1),template_id:wo().uuid(),from_name:wo().trim().min(1),from_email:Eo(),reply_to_email:Eo().nullable().optional(),trigger:Ri,delay_seconds:Bo().int().min(0).default(0),conditions:ui(wo(),Go()).default({})}),ni({trigger:Ri,email:Eo(),customer_id:wo().uuid().nullable().optional(),name:wo().trim().min(1).nullable().optional(),consent_basis:$i.default("UNKNOWN"),variables:ui(wo(),Go()).default({}),idempotency_key:wo().trim().min(1).nullable().optional()}),ni({email:Eo(),reason:Ni.default("ADMIN_BLOCK"),notes:wo().nullable().optional()}),/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);var qi=["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"],Di=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],ji=["NOWPAYMENTS_WHITELABEL"],Li={USDT:["USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL"],USDC:["USDC_ERC20","USDC_TRC20","USDC_BEP20","USDC_POLYGON","USDC_SOL"],DAI:["DAI_ERC20"]},Zi=Object.keys(Li),Mi=[...Li.USDT,...Li.USDC,...Li.DAI],Fi=[...qi,...Mi],Bi=["BITCOIN_LN"],Ji=[...Di,...ji],Yi=[...Fi,...Bi],Wi=Fi,Hi=(new Set(["SHOPPEXPAY"]),new Set(qi)),Vi=new Set(Mi),Gi=(new Set(Fi),new Set(Bi),new Set(Di),new Set(ji),new Set(Ji),new Set(Yi),new Set(Zi),new Set(["STRIPE","PAYPAL","PAYPAL_FF","MOLLIE","AUTHORIZENET","NMI","SQUARE","SUMUP","SHOPIFY","PANDABASE","DEBLOMASSI","SHOPPEXPAY","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","CASHAPP","VENMO","CRYPTO","CUSTOMER_BALANCE","EXTERNAL","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Ki(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Ki("COIN_GATEWAY_KEYS",qi),Ki("TOKEN_GATEWAY_KEYS",Mi),Ki("CRYPTO_GATEWAY_KEYS",Fi),Ki("LEGACY_CRYPTO_GATEWAY_KEYS",Bi),Ki("CRYPTO_PROVIDER_KEYS",Di),Ki("MANAGED_CRYPTO_PROVIDER_KEYS",ji),Ki("CRYPTO_PROVIDER_GATEWAY_KEYS",Ji),Ki("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Wi),Ki("DEFAULT_CRYPTOMUS_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL","USDC_ERC20","USDC_BEP20","USDC_POLYGON","DAI_ERC20"]),Ki("DEFAULT_OXAPAY_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDC_ERC20"]);for(const qc of Fi)if(!Hi.has(qc)&&!Vi.has(qc))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${qc}`);function Xi(e){const t=e.trim();if(!t)return"";if(/^manual:/i.test(t)){const e=t.slice(t.indexOf(":")+1).trim();return e?`MANUAL:${e}`:"MANUAL"}if(/^external:/i.test(t)){const e=function(e){const t=e.trim();if(!/^external:/i.test(t))return null;const n=t.slice(t.indexOf(":")+1).trim().toLowerCase();return Ui.test(n)?n:null}(t);return e?`EXTERNAL:${e}`:t.toUpperCase()}let n=t.toUpperCase();const o=n.match(/^(USDT|USDC|DAI):([A-Z0-9_]+)$/);if(o){const[,e,t]=o;n=`${e}_${"MATIC"===t?"POLYGON":t}`}return Gi[n]??n}new Set(["STRIPE","PAYPAL","PAYPAL_FF","SKRILL","CASHAPP","CASH_APP","PERFECT_MONEY","SQUARE","SUMUP","SHOPIFY","PANDABASE","DEBLOMASSI","SHOPPEXPAY","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","VENMO","MOLLIE","AUTHORIZENET","NMI"].map(e=>Xi(e))),new Set(["WHITE_LABEL","NATIVE"]);var Qi=[...Ji,"NATIVE"],er=(new Set(Qi),ni({set:Ho()})),tr=ni({status:di(["READY","NEEDS_ATTENTION"]).optional(),code:wo().optional(),message:wo().optional(),checked_at:wo().optional()}),nr=(ni({provider:wo(),type:wo(),enabled:Ho(),connected:Ho(),credentials:ui(wo(),er),public_config:ui(wo(),Go()),webhook:ui(wo(),Go()).optional(),health:tr.optional()}),"#2563eb"),or=["comfortable","compact"],ir=["top","side","background"],rr=di(["checkout","payment_link","embed"]),ar=di(or),sr=di(["light","dark","system"]),lr=di(ir),ur=di(["ghost","outlined","filled"]),cr=di(["sheet","fullscreen","center"]),dr=di(["visible","hidden"]),pr=(di(["checkout.shell","checkout.panel","checkout.header","brand.logo","product.card","product.image","product.title","product.description","product.price","product.quantity","product.addon","paymentLink.hero","summary.panel","summary.line","summary.total","form.field","form.label","form.help","coupon.input","input.base","input.error","button.primary","button.secondary","payment.methods","payment.method","payment.method.icon","payment.method.label","payment.method.meta","payment.method.fee","payment.method.indicator","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.launcher","embed.launcher.icon","embed.productCard","embed.productCard.image","embed.productCard.title","embed.productCard.price","embed.cart","embed.cart.row","embed.cart.summary","embed.modal","embed.modal.header","embed.modal.close","embed.skeleton","embed.loader","embed.branding"]),di(["product.title","product.price","summary.total","payment.method.label","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.modal.close","embed.branding"]),wo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),fr=wo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),mr=wo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),_r=di(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),hr=wo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),yr=wo().url(),gr=ni({brand:ni({logoUrl:yr.optional().nullable(),logoDarkUrl:yr.optional().nullable(),logoMaxHeight:Bo().int().min(16).max(80).optional(),faviconUrl:yr.optional().nullable()}).strict().optional(),color:ni({brand:pr.optional(),brandContrast:pr.optional(),background:pr.optional(),surface:pr.optional(),surfaceRaised:pr.optional(),text:pr.optional(),textMuted:pr.optional(),border:pr.optional(),focus:pr.optional(),success:pr.optional(),warning:pr.optional(),error:pr.optional()}).strict().optional(),typography:ni({fontFamily:_r.optional(),googleFontFamily:hr.optional(),baseSize:Bo().int().min(12).max(18).optional()}).strict().optional(),shape:ni({buttonRadius:Bo().int().min(0).max(24).optional(),inputRadius:Bo().int().min(0).max(24).optional(),cardRadius:Bo().int().min(0).max(28).optional()}).strict().optional(),spacing:ni({density:ar.optional(),controlHeight:Bo().int().min(36).max(56).optional()}).strict().optional(),component:ni({primaryButton:ni({background:pr.optional(),text:pr.optional()}).strict().optional(),input:ni({background:pr.optional(),border:pr.optional(),focusRing:fr.optional()}).strict().optional(),summary:ni({background:pr.optional()}).strict().optional(),paymentMethod:ni({background:fr.optional(),cardBackground:fr.optional(),border:fr.optional(),selectedBackground:fr.optional()}).strict().optional(),productCard:ni({background:fr.optional(),border:fr.optional(),shadow:mr.optional()}).strict().optional(),productImage:ni({background:fr.optional(),border:fr.optional(),icon:fr.optional()}).strict().optional(),brandAvatar:ni({background:fr.optional(),text:pr.optional(),border:fr.optional()}).strict().optional(),pill:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),errorBanner:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),warningBanner:ni({background:fr.optional(),border:fr.optional(),text:pr.optional()}).strict().optional(),radio:ni({idleRing:fr.optional(),checkedFill:pr.optional(),checkedIcon:pr.optional()}).strict().optional(),divider:ni({color:fr.optional()}).strict().optional()}).strict().optional(),paymentLink:ni({heroImageUrl:yr.optional().nullable(),heroPosition:lr.optional()}).strict().optional(),embed:ni({launcher:ni({background:fr.optional(),text:pr.optional(),radius:Bo().int().min(0).max(28).optional(),paddingX:Bo().int().min(8).max(32).optional(),paddingY:Bo().int().min(6).max(24).optional(),shadow:mr.optional()}).strict().optional(),productCard:ni({background:fr.optional(),border:fr.optional(),imageRadius:Bo().int().min(0).max(24).optional(),padding:Bo().int().min(8).max(32).optional()}).strict().optional(),cart:ni({background:fr.optional(),rowBorder:fr.optional(),itemSpacing:Bo().int().min(4).max(28).optional()}).strict().optional(),modal:ni({background:fr.optional(),radius:Bo().int().min(0).max(32).optional(),maxWidth:Bo().int().min(360).max(960).optional(),shadow:mr.optional()}).strict().optional(),backdrop:ni({color:fr.optional(),blur:Bo().int().min(0).max(24).optional(),opacity:Bo().min(0).max(1).optional()}).strict().optional(),skeleton:ni({background:fr.optional(),shimmer:fr.optional()}).strict().optional(),spinner:ni({color:fr.optional()}).strict().optional(),closeButton:ni({style:ur.optional()}).strict().optional(),mobile:ni({layout:cr.optional()}).strict().optional(),content:ni({productDescription:dr.optional(),termsShortcut:dr.optional()}).strict().optional()}).strict().optional()}).strict(),br=ni({mode:sr.default("system"),fontSource:di(["curated"]).default("curated")}).strict(),vr=di(["standalone","bundle","pointer"]),wr=ni({name:wo().trim().min(1).max(80),fingerprint:wo().trim().min(1).max(128)}).strict(),Sr=["embed_design"];function kr(e){if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=e;if(!Sr.some(e=>e in t))return e;const n={...t};for(const o of Sr)delete n[o];return n}var Er=Ii(kr,ni({type:fi("shoppex.style_theme"),surface:fi("checkout"),format_version:ii([fi(1),fi(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fi(1),tokens:gr.default({}),custom_css:wo().max(2e4).default(""),settings:br.default({mode:"system",fontSource:"curated"}),_meta:ui(wo(),Go()).optional()}).strict()),Or=(Ii(kr,ni({type:fi("shoppex.style_theme"),surface:rr,format_version:ii([fi(1),fi(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fi(1),tokens:gr.default({}),custom_css:wo().max(2e4).default(""),settings:br.default({mode:"system",fontSource:"curated"}),share_mode:vr.default("standalone"),parent_hint:wr.optional(),bundled_parent:Er.optional(),_meta:ui(wo(),Go()).optional()}).strict()),ni({theme_id:wo().uuid().nullable(),surface:rr,token_schema_version:fi(1),revision:Bo().int().min(1),tokens:gr,custom_css:wo(),css_variables:ui(wo(),wo())}).strict(),ni({theme_id:wo().uuid().nullable(),parent_theme_id:wo().uuid().nullable(),surface:fi("embed"),token_schema_version:fi(1),revision:Bo().int().min(1),parent_revision:Bo().int().min(1).nullable(),tokens:gr,custom_css:wo(),css_variables:ui(wo(),wo())}).strict(),ni({shop_id:wo().uuid(),product_id:wo().uuid().nullable(),product_group_id:wo().uuid().nullable(),payment_link_id:wo().uuid().nullable(),invoice_id:wo().nullable()}).strict(),ni({embed_runtime:wo().min(16).max(128),revision:Bo().int().min(1),parent_revision:Bo().int().min(1).nullable(),theme_id:wo().uuid().nullable(),css_variables:ui(wo(),wo()),custom_css:wo()}).strict(),ni({embed_style_revision:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}(Fo,e)}().int().min(1).optional(),embed_runtime:wo().min(16).max(128).optional(),preview:Ho().optional()}).strict(),di(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),di(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),xr=(di(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),wo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),zr=di(["static","marquee"]),Tr=di(["brand_blue","emerald","sunset","rose","charcoal","custom"]),Ar=di(["hide","message"]),Ir=di(["compact","comfortable"]),Pr=di(["subtle","outline","solid"]),$r=di(["minimal","boxed"]),Nr=di(["indigo","emerald","amber","rose","slate","custom"]),Cr=di(["compact","feature","alert"]),Rr=di(["compact","comfortable"]),Ur=di(["subtle","outline","solid"]),qr=di(["sparkles","megaphone","gift","truck","shield","support","none"]),Dr=di(["show","hide"]),jr=di(["midnight","ocean","ember","forest","custom"]),Lr=di(["delay","exit_intent"]),Zr=wo().trim().refine(e=>{if(e.startsWith("/"))return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}},'Use a valid absolute URL or a path starting with "/"'),Mr=wo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Fr=ni({text:wo().trim().min(1,"Text is required").max(160,"Text must be 160 characters or fewer"),linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),dismissible:Ho().default(!1),displayMode:zr.default("marquee"),themePreset:Tr.default("custom"),animationSpeedSeconds:Bo().int().min(8).max(40).default(30),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb")}),Br=ni({text:wo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Mr,linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),dismissible:Ho().default(!1),themePreset:Tr.default("brand_blue"),expiredBehavior:Ar.default("hide"),expiredMessage:wo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:Ir.default("compact"),ctaStyle:Pr.default("subtle"),timerStyle:$r.default("boxed"),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb")}),Jr=ni({eyebrow:wo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:wo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Zr.optional().nullable(),themePreset:Nr.default("indigo"),layoutStyle:Cr.default("feature"),density:Rr.default("comfortable"),ctaStyle:Ur.default("outline"),icon:qr.default("sparkles"),iconVisibility:Dr.default("show"),backgroundColor:xr.default("#111827"),textColor:xr.default("#f9fafb"),accentColor:xr.default("#818cf8")}),Yr=ni({title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer").default("Recent purchases"),lookbackHours:Bo().int().min(1).max(168).default(24),cooldownSeconds:Bo().int().min(5).max(300).default(20),maxItems:Bo().int().min(1).max(20).default(8),anonymizeMode:di(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:ei(wo().min(1)).max(50).default([])}),Wr=ni({eyebrow:wo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:wo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:wo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),couponCode:wo().trim().min(2,"Coupon code is required").max(40,"Coupon code must be 40 characters or fewer"),primaryButtonLabel:wo().trim().min(1,"Primary button label is required").max(24,"Primary button label must be 24 characters or fewer").default("Copy code"),secondaryButtonLabel:wo().trim().min(1,"Secondary button label is required").max(24,"Secondary button label must be 24 characters or fewer").default("Maybe later"),disclaimer:wo().trim().max(100,"Disclaimer must be 100 characters or fewer").optional().nullable(),themePreset:jr.default("midnight"),trigger:Lr.default("delay"),delaySeconds:Bo().int().min(0).max(60).default(6),showOncePerSession:Ho().default(!0),reminderHours:Bo().int().min(1).max(720).default(24),backgroundColor:xr.default("#111827"),textColor:xr.default("#f8fafc"),accentColor:xr.default("#7c9cff"),heroImageUrl:Zr.optional().nullable(),discountDisplay:wo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Mr.optional().nullable()}),Hr=di(["hidden","optional"]),Vr=ni({headline:wo().trim().min(1,"Headline is required").max(60,"Headline must be 60 characters or fewer").default("Chat with us"),greeting:wo().trim().min(1,"Greeting is required").max(240,"Greeting must be 240 characters or fewer").default("Hi! Send us a message and we will reply as soon as possible."),inputPlaceholder:wo().trim().min(1,"Placeholder is required").max(80,"Placeholder must be 80 characters or fewer").default("Type your message…"),contactFields:Hr.default("optional"),accentColor:xr.default("#111827"),launcherIconColor:xr.default("#f9fafb")}),Gr=ni({type:fi("announcement_bar"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Fr}),Kr=ni({type:fi("recent_purchase_popup"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Yr}),Xr=ni({type:fi("countdown_bar"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Br}),Qr=ni({type:fi("promo_info_card"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Jr}),ea=ni({type:fi("coupon_popup_modal"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Wr}),ta=ni({type:fi("live_chat"),slot:Or,enabled:Ho().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Vr}),na=(ai("type",[Gr,Xr,Qr,Kr,ea,ta]),ai("type",[Gr.extend({id:wo().min(1)}),Xr.extend({id:wo().min(1)}),Qr.extend({id:wo().min(1)}),Kr.extend({id:wo().min(1)}),ea.extend({id:wo().min(1)}),ta.extend({id:wo().min(1)})]),new Set(["amount","currency","invoice_id","customer_email","id","email","price","price_usd","product_name","quantity"].map(e=>e.toLowerCase())),wo().regex(/^[A-Z]{3}$/,"Currency must be a three-letter uppercase code.")),oa=wo().url().refine(e=>"https:"===new URL(e).protocol,"URL must use HTTPS."),ia=ni({version:fi("2026-08-14")}),ra=(ia.extend({type:fi("payment.session.create"),data:ni({attempt_id:wo().uuid(),invoice_id:wo().uuid(),amount_minor:Bo().int().safe().positive(),currency:na,customer_email:wo().email().nullable(),description:wo().min(1).max(500),success_url:oa,cancel_url:oa,event_url:oa})}),ia.extend({provider_reference:wo().trim().min(1).max(255),checkout_url:oa,expires_at:Hn({offset:!0}).nullable().optional()}),ia.extend({type:di(["payment.processing","payment.succeeded","payment.failed"]),data:ni({attempt_id:wo().uuid(),provider_reference:wo().trim().min(1).max(255),amount_minor:Bo().int().safe().positive(),currency:na,occurred_at:Hn({offset:!0}).nullable().optional()})}),ia.extend({type:fi("adapter.conformance.run"),data:ni({challenge_id:wo().uuid(),mode:di(["standard","timeout"]),expected_event:ni({attempt_id:wo().uuid(),provider_reference:wo().trim().min(1).max(255),amount_minor:Bo().int().safe().positive(),currency:na})})}),ni({scenario:di(["valid_event","amount_mismatch","duplicate_event_first","duplicate_event_retry"]),webhook_id:wo().trim().min(1).max(255),webhook_timestamp:wo().trim().min(1).max(32),webhook_signature:wo().trim().min(1).max(1024),raw_body:wo().min(1).max(4096)})),aa=(ia.extend({type:fi("adapter.conformance.result"),data:ni({challenge_id:wo().uuid(),samples:ei(ra).length(4)})}),ui(wo(),Go())),sa=ii([wo(),Bo()]),la=ni({kind:di(["address","redirect","embed_pending"]),gateway:wo(),checkout_url:wo().nullable().optional(),address:wo().optional(),amount:wo().optional(),qr_code:wo().optional(),expires_at:wo().optional(),payment_id:wo().optional(),confirmations_needed:Bo().optional()}).passthrough(),ua=ni({default_value:wo().optional(),min_length:Bo().optional(),name:wo(),placeholder:wo().optional(),regex:wo().optional(),required:Ho(),type:wo()}),ca=ni({id:wo(),price:Bo(),quantity:Bo(),title:wo()}),da=ni({currency:wo(),description:wo(),id:wo(),price:Bo(),title:wo(),uniqid:wo()}),pa=ni({addons:ei(ca).optional(),available_addons:ei(Go()).optional(),cloudflare_image_id:wo().nullable(),created_at:wo().optional(),currency:wo(),custom_fields:aa.nullable().optional(),custom_fields_config:ei(ua).nullable().optional(),delivery_instruction:Go().optional(),delivery_instruction_config:Go().optional(),delivery_instruction_label:Go().optional(),delivery_text:wo().nullable().optional(),delivery_time:Bo().nullable().optional(),delivery_time_unit:di(["minutes","hours","days"]).nullable().optional(),description:wo().nullable(),discount_percent:Bo().optional(),discount_display:Bo().optional(),discounted_total_display:Bo().optional(),gateways:ei(wo()).nullable().optional(),id:wo().optional(),image_name:wo().nullable(),image_storage:wo().nullable().optional(),line_item_id:wo().nullable().optional(),pay_what_you_want:Ho().optional(),price:wo().optional(),price_display:sa,quantity:Bo(),quantity_max:Bo().optional(),quantity_min:Bo().optional(),recurring_interval:wo().nullable().optional(),recurring_interval_count:Bo().nullable().optional(),redirect_link:wo().nullable().optional(),redirect_time:Bo().nullable().optional(),service_text:wo().nullable().optional(),setup_cost:wo().optional(),slug:wo().nullable().optional(),storefront_url:wo().nullable().optional(),status:wo().nullable().optional(),subtype:wo().nullable().optional(),terms_of_service:wo().nullable().optional(),title:wo(),total:Bo(),trial_period:Bo().nullable().optional(),type:wo().nullable().optional(),uniqid:wo().nullable(),unit_price:Bo().optional(),unit_price_display:sa.optional(),unit_quantity:Bo(),updated_at:wo().optional(),variant_title:wo().nullable().optional(),video_link:wo().nullable().optional(),volume_discounts:Go().optional(),warranty_days:Bo().nullable().optional(),warranty_text:wo().nullable().optional(),warranty_period_days:Bo().nullable().optional()}),fa=ni({amount:Bo(),gateway:wo()}),ma=ni({custom_tip_enabled:Ho().optional(),enabled:Ho(),preset_percentages:ei(Bo()).optional()}),_a=ni({allow_partial_payment:Ho().optional(),auto_apply:Ho().optional(),available:wo(),currency:wo()}),ha=ni({affiliate_code:wo().nullable().optional(),already_paid:sa.nullable().optional(),amount_due:sa.nullable().optional(),currency:wo().nullable().optional(),discount:sa.nullable().optional(),discount_label:wo().nullable().optional(),gateway_fee:sa.nullable().optional(),platform_fee:sa.nullable().optional(),processing_fee:sa.nullable().optional(),subtotal:sa.nullable().optional(),tip:sa.nullable().optional(),total:sa.nullable().optional()}),ya=ni({active:Ho(),expires_at:wo()}),ga=ni({faq_url:wo().nullable(),support_email:wo().nullable(),support_url:wo().nullable(),telegram_invite:wo().nullable(),discord_invite_url:wo().nullable()}),ba=ni({currency:wo().nullable().optional(),enabled:Ho(),max_amount:Bo().nullable().optional(),min_amount:Bo().nullable().optional(),reason:di(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),va=ni({delivered_items:ei(Go()),downloads:ei(Go()),external_urls:ei(Go()),license_keys:ei(Go()),tracking_codes:ei(Go())}),wa=ni({active:Ho().optional(),attempt_id:wo().optional(),buyer_actionable:Ho().nullable().optional(),crypto_currency:wo().nullable().optional(),currency:wo().optional(),expected_amount:wo().nullable().optional(),expected_crypto_amount:wo().nullable().optional(),last_checked_at:wo().optional(),missing_amount:wo().nullable().optional(),missing_crypto_amount:wo().nullable().optional(),provider_reference:wo().nullable().optional(),provider_status:wo().nullable().optional(),received_amount:wo().nullable().optional(),received_fiat_estimate:wo().nullable().optional(),received_crypto_amount:wo().nullable().optional(),shortfall_percent:wo().nullable().optional(),buyer_action_reason:di(["BELOW_MINIMUM_COLLECTIBLE","PROVIDER_SESSION_CLOSED","PROVIDER_TOP_UP_UNSUPPORTED","MERCHANT_REVIEW_REQUIRED"]).nullable().optional()}),Sa=ni({created_at:wo().nullable(),details:wo().nullable(),id:wo(),invoice_id:wo(),status:wo().nullable()}),ka=ni({billing_address_mode:di(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:wo().nullable().optional(),display_name:wo().nullable().optional(),gateway:wo(),hide_provider_attribution:Ho().optional(),icon_url:wo().nullable().optional(),terms_mode:di(["INHERIT","REQUIRED","DISABLED"]).optional()}),Ea=ni({custom_fields:ei(Go()).optional(),description:wo().nullable(),display_order:Bo(),icon_preset:wo().nullable(),icon_url:wo().nullable(),id:wo(),instructions:wo().nullable(),is_active:Ho().optional(),name:wo(),payment_type:di(["INSTRUCTIONS","REDIRECT"]),redirect_url:wo().nullable(),require_proof:Ho(),proof_type:di(["TEXT","IMAGE","BOTH"]).optional(),void_after_hours:Bo()}),Oa=ni({description:wo().nullable(),display_order:Bo(),icon_url:wo().nullable(),id:wo(),name:wo()}),xa=ni({email:ni({masked:wo().nullable(),persisted:Ho(),required_for_provider_session:Ho().optional()})}),za=ni({amount:wo().nullable(),confirmations:Bo().nullable(),created_at:Bo().optional(),hash:wo().nullable(),status:wo().optional()}),Ta=ni({conf:ni({partial:Bo().optional(),void:Bo(),waiting_for_confirmations:Bo().optional()}),gateways:ei(wo())}),Aa=ni({invoice_payable:Ho(),resumable:Ho(),resumable_gateway:wo().nullable(),gateway:wo().nullable().optional(),crypto_gateway:wo().nullable().optional(),processor:wo().nullable().optional(),flow_type:wo().nullable().optional(),status:wo().nullable().optional(),provider_reference:wo().nullable().optional(),provider_reference_type:wo().nullable().optional(),capture_id:wo().nullable().optional(),manual_confirmation_pending:Ho().optional(),payment_method_switch_locked:Ho().optional(),awaiting_payment_method:Ho().optional(),started_at:Bo().nullable().optional(),completed_at:Bo().nullable().optional()}),Ia=Aa.extend({gateway:wo().nullable(),flow_type:wo().nullable(),status:wo().nullable(),manual_confirmation_pending:Ho(),payment_method_switch_locked:Ho()}),Pa=ni({theme_id:wo().nullable(),surface:di(["checkout","payment_link","embed"]),token_schema_version:fi(1),revision:Bo(),tokens:aa,custom_css:wo(),css_variables:ui(wo(),wo())}),$a=ni({link_id:wo(),source_gateway:wo().nullable(),invoice_uniqid:wo(),deprioritize_source_gateway:Ho().optional()}),Na=ni({enabled:Ho(),required:Ho(),connected:Ho()}),Ca=ni({gateway:wo().nullable().optional(),active_type:wo().nullable().optional(),percent_amount:sa.nullable().optional(),fixed_amount:sa.nullable().optional(),fixed_currency:wo().nullable().optional()}),Ra=ni({id:wo(),type:di(["WALLET_CREDIT","COUPON"]),status:di(["PENDING","FULFILLED","FAILED","REVOKED"]),amount:wo().nullable(),currency:wo().nullable(),coupon_code:wo().nullable(),reason:di(["ORDER_COMPLETED","ORDER_COUNT_REACHED","SPEND_AMOUNT_REACHED","POSITIVE_REVIEW_LEFT","FIRST_PURCHASE_COMPLETED"]),trigger_reference_type:wo(),trigger_reference_id:wo(),created_at:Bo(),fulfilled_at:Bo().nullable(),expires_at:Bo().nullable()}),Ua=ni({summary:ni({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:wo().nullable(),currency:wo()}),activity:ei(Ra),earned_after_invoice:ei(Ra),pending_after_invoice:ei(Ra)}),qa=ni({already_paid_amount:sa.nullable().optional(),apm_method:wo().nullable().optional(),blockchain:wo().nullable(),buyer_identity:xa.nullable().optional(),checkout_tipping:ma.nullable().optional(),country_regulations:wo().nullable().optional(),coupon_applied:Ho().optional(),crypto_mode:wo().nullable().optional(),crypto_transactions:ei(za).optional(),currency:wo().nullable(),custom_fields:aa.nullable().optional(),custom_gateways:ei(Ea).optional(),external_payment_adapters:ei(Oa).optional(),customer_balance:_a.nullable().optional(),customer_email_masked:wo().nullable().optional(),dark_mode:ii([fi(0),fi(1)]).optional(),delivery:va.optional(),delivery_info:va.optional(),discount:Bo().optional(),discount_display:sa.optional(),eligible_gateways:ei(wo()).optional(),environment:wo().optional(),fee_breakdown:aa.nullable().optional(),gateway:wo().nullable(),gateway_data:aa.nullable().optional(),gateway_eligibility:ui(wo(),ba).optional(),gateway_fee_previews:ei(fa).optional(),gateways_available:ei(wo()),license:ii([aa,fi(!1)]).optional(),name:wo().nullable(),paddle_token:wo().nullable().optional(),paddle_transaction_id:Go().optional(),payment_link_id:wo().nullable().optional(),payment_method_overrides:ei(ka).optional(),payment_session_state:Aa.nullable().optional(),polling:ya,pricing_breakdown:ha.nullable().optional(),product:ei(pa).optional(),quantity:Bo().nullable(),rates_snapshot:ui(wo(),Bo()).optional(),remaining_amount:sa.nullable().optional(),selected_gateway:wo().nullable().optional(),shop_checkout_ambient_color:wo().nullable().optional(),shop_cloudflare_image_id:wo().nullable(),shop_domain:wo().nullable().optional(),shop_force_paypal_email_delivery:ii([fi(0),fi(1)]).optional(),shop_image_name:wo().nullable(),shop_image_storage:wo().nullable().optional(),shop_payment_gateways_fees:ei(aa).optional(),shop_paypal_credit_card:ii([fi(0),fi(1)]).optional(),shop_return_url:wo().nullable().optional(),shop_slug:wo().nullable().optional(),shop_terms_enabled:Ho().optional(),shop_terms_of_service:wo().nullable().optional(),shop_terms_url:wo().nullable().optional(),shop_privacy_policy_url:wo().nullable().optional(),shop_refund_policy_url:wo().nullable().optional(),shop_walletconnect_id:wo().nullable().optional(),status:wo().nullable(),status_history:ei(Sa).optional(),status_history_legacy:ei(Sa).optional(),status_history_raw:ei(Sa).optional(),stripe_publishable_key:wo().nullable().optional(),stripe_user_id:wo().nullable().optional(),subtotal:Bo().optional(),subtype:wo().nullable().optional(),support:ga.optional(),theme:wo().optional(),tip_amount:sa.nullable().optional(),tip_amount_display:sa.nullable().optional(),tip_metadata:Go().optional(),total:sa,total_conversions:aa.optional(),total_display:sa,type:wo().nullable(),underpayment:wa.nullable().optional(),underpayment_status:wo().nullable().optional(),uniqid:wo(),void_times:ei(Ta).optional(),addons:Go().optional(),affiliate_data:Go().optional(),affiliate_revenue_customer_id:wo().nullable().optional(),bill_info:Go().optional(),binance_checkout_url:wo().nullable().optional(),binance_invoice_id:wo().nullable().optional(),binance_qrcode:wo().nullable().optional(),bundle_config:Go().optional(),bundles:Go().optional(),cashapp_cashtag:wo().nullable().optional(),cashapp_note:wo().nullable().optional(),cashapp_qrcode:wo().nullable().optional(),created_at:wo().optional(),crypto_address:wo().nullable().optional(),crypto_amount:sa.optional(),crypto_confirmations_needed:Bo().nullable().optional(),crypto_exchange_rate:sa.nullable().optional(),crypto_received:sa.optional(),crypto_uri:wo().nullable().optional(),developer_invoice:Go().optional(),developer_return_url:wo().nullable().optional(),developer_title:wo().nullable().optional(),exchange_rate:sa.nullable().optional(),external_order_id:wo().nullable().optional(),lex_order_id:wo().nullable().optional(),lex_payment_method:wo().nullable().optional(),paydash_payment_id:wo().nullable().optional(),paypal_apm:wo().nullable().optional(),paypal_email_delivery:Ho().optional(),paypal_fee:sa.nullable().optional(),paypal_order_id:wo().nullable().optional(),paypal_payer_email:wo().nullable().optional(),paypal_subscription_id:wo().nullable().optional(),paypal_subscription_link:wo().nullable().optional(),perfectmoney_id:wo().nullable().optional(),product_addons:Go().optional(),product_id:wo().nullable().optional(),product_title:wo().nullable().optional(),product_type:wo().nullable().optional(),product_variants:Go().optional(),recurring_billing_id:wo().nullable().optional(),skrill_link:wo().nullable().optional(),skrill_sid:wo().nullable().optional(),status_details:Go().optional(),stripe_apm:wo().nullable().optional(),stripe_client_secret:wo().nullable().optional(),stripe_id:wo().nullable().optional(),stripe_price_id:wo().nullable().optional(),subscription:Go().optional(),subscription_id:wo().nullable().optional(),sumup_id:wo().nullable().optional(),telegram_stars_payment_link:wo().nullable().optional(),telegram_stars_payment_note:wo().nullable().optional(),updated_at:wo().optional(),virtual_payments_id:wo().nullable().optional(),void_details:Go().optional()}).catchall(Go()),Da=pa.extend({available_addons:ei(da).optional(),delivery_instructions:wo().nullable().optional(),delivery_instructions_config:ni({enabled:fi(!0),required:Ho(),label:wo(),placeholder:wo().nullable().optional(),help_text:wo().nullable().optional(),max_length:Bo()}).nullable().optional(),delivery_instructions_label:wo().nullable().optional(),image_url:wo().nullable().optional(),redirectLink:wo().nullable().optional(),redirectTime:Bo().nullable().optional(),serviceText:wo().nullable().optional()}),ja=(ni({data:ni({invoice:qa.extend({uniqid:wo().uuid(),shop_id:ii([wo(),Bo()]).nullable(),customer_email:wo().nullable(),checkout_style:Pa.nullable().optional(),coupon_id:wo().nullable().optional(),discount_breakdown:aa.nullable().optional(),affiliate_code:wo().nullable().optional(),country:wo().nullable().optional(),paypal_email:wo().nullable().optional(),pandabase_available_payment_methods:ei(wo()).optional(),payment_rescue:$a.nullable().optional(),discord_integration:Na.nullable().optional(),payment_session_state:Ia.nullable().optional(),shop_payment_gateways_fees:ei(Ca).optional(),product:ei(Da).optional(),products:ei(Da).optional(),rewards:Ua.nullable().optional()}).superRefine((e,t)=>{void 0===e.product&&void 0===e.products&&t.addIssue({code:"custom",message:"Embed checkout invoice must include product or products.",path:["product"]})}),invoice_url:wo().nullable(),checkout_url:wo().nullable(),selected_gateway:wo().nullable(),session_started:Ho(),payment_session:la.nullable(),completion_access_grant:wo().nullable()}).passthrough()}).passthrough(),3),La=2,Za={maximumFractionDigits:3};function Ma(e){if(!Number.isFinite(e))return e;const t=e<0?-1:1,n=Fa(Math.abs(e),2),o=Math.round(n);return 0===o?0:t*Fa(o,-2)}function Fa(e,t){const[n,o="0"]=String(e).split("e");return Number(`${n}e${Number(o)+t}`)}var Ba=wo().nullable(),Ja=ui(wo(),Go()),Ya=ni({logo_url:Ba,primary_color:wo(),secondary_color:wo(),accent_color:wo()}),Wa=(ni({customer:ni({id:Ba,email:wo(),name:wo(),avatar_url:Ba,joined_at:Ba}),shop:ni({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:Ya}),token:Ba}),ni({attachment_image_id:ni({cloudflare_image_id:Ba}).nullable()})),Ha=ni({attachment_imageId:ni({cloudflareImageId:Ba}).nullable()}),Va=ni({uniqid:wo(),status:wo(),total:wo(),total_display:Ba,currency:wo(),created_at:wo(),line_items:ei(ni({product_title:Ba,quantity:Bo(),product:Wa.nullable()}))}),Ga=ni({uniqid:wo(),status:wo(),total:wo(),totalDisplay:Ba,currency:wo(),createdAt:wo(),lineItems:ei(ni({productTitle:Ba,quantity:Bo(),product:Ha.nullable()}))}),Ka=ni({invoices:ei(Ga),pagination:ni({page:Bo(),limit:Bo(),total:Bo(),has_more:Ho()})}),Xa=(ni({can_review:Ho(),already_submitted:Ho(),feedback_uniqid:Ba,product_title:Ba,score:ii([fi(1),fi(3),fi(5)]).nullable(),is_automated:Ho(),message:Ba,submitted_at:Ba}),ni({gateway:wo(),displayName:Ba,cryptoGateway:Ba.optional(),blockchain:Ba,cryptoAddress:Ba,apmMethod:Ba})),Qa=ni({id:wo(),uniqid:wo(),status:wo(),statusDetails:Ba,total:wo(),totalDisplay:Ba,subtotal:wo(),discount:wo(),discountDisplay:Ba,tax:wo(),taxPercentage:wo(),currency:wo(),createdAt:wo(),updatedAt:wo(),gatewayUpdatedAt:Ba,customFields:Ja.nullable(),balancePaidAmount:wo(),tipAmountDisplay:wo(),pricingBreakdown:ni({subtotal:wo(),discount:wo(),discount_label:di(["Coupon","Discount"]),affiliate_code:Ba,tip:wo(),gateway_fee:wo(),platform_fee:wo(),processing_fee:wo(),already_paid:wo(),total:wo(),amount_due:wo(),currency:wo()}),currentPaymentAttemptId:Ba,lineItems:ei(ni({id:wo(),productTitle:wo(),productType:wo(),variantTitle:Ba,unitPrice:wo(),quantity:Bo(),total:wo(),deliveryText:Ba,deliverySummary:ni({codes:ei(wo()),links:ei(ni({label:wo(),value:wo(),href:Ba.optional()})),notes:ei(wo()),serials:ei(ni({value:wo(),is_replacement:Ho(),is_replaced:Ho()}))}).nullable(),deliveredAt:Ba,deliveryStatus:di(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:Ja.nullable(),product:ni({uniqid:wo(),slug:Ba,serviceText:Ba,attachment_imageId:ni({cloudflareImageId:Ba}).nullable()}).nullable()})),currentPayment:Xa.nullable(),payments:ei(Xa)}),es=(ni({quote:ni({enabled:Ho(),currency:wo(),min_amount:wo(),max_amount:Ba,bonus_tiers:ei(ni({min_amount:wo(),bonus_percent:Bo()}))})}),ni({invoice_id:wo(),url:wo()}),ni({id:wo(),type:wo(),status:wo(),amount:Ba,currency:Ba,coupon_code:Ba,reason:wo(),trigger_reference_type:wo(),trigger_reference_id:wo(),created_at:Bo(),fulfilled_at:Bo().nullable(),expires_at:Bo().nullable()})),ts=ni({summary:ni({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:Ba,currency:wo()}),activity:ei(es),earned_after_invoice:ei(es),pending_after_invoice:ei(es)}),ns=ni({id:wo(),uniqid:wo(),label:Ba,code:wo(),url:Ba,status:di(["pending","active","inactive","rejected"]),is_primary:Ho(),total_clicks:Bo(),total_sales:Bo(),total_revenue:wo(),is_active:Ho(),is_approved:Ho(),requested_affiliate_revenue_percent:Bo().nullable(),requested_affiliate_customer_discount_percent:Bo().nullable(),affiliate_revenue_percent_override:Bo().nullable(),affiliate_customer_discount_percent_override:Bo().nullable(),effective_commission_percent:Bo(),effective_customer_discount_percent:Bo(),commission_shareback_percent:Bo(),commission_shareback_enabled:Ho(),max_commission_shareback_percent:Bo(),created_at:Ba,updated_at:Ba}),os=ni({customer:ni({id:wo(),email:wo(),name:Ba}).nullable(),state:wo(),can_create_custom_links:Ho(),custom_link_request_disabled_reason:Ba,custom_links_require_approval:Ho(),affiliate_codes_accepted_at_checkout:Ho(),cash_payout_enabled:Ho(),links:ei(ns),preferred_payout:ni({asset:wo(),network:wo(),address:wo()}).nullable(),balance_currency:wo(),balances:ni({pending:wo(),available:wo(),requested:wo(),converted:wo(),paid:wo(),approved_total:wo()}),commissions:ei(ni({id:wo(),invoice_id:wo(),commission_amount:wo(),base_amount:wo(),discount_amount:wo(),status:wo(),created_at:Ba,paid_at:Ba,converted_at:Ba})),claims:ei(ni({id:wo(),type:wo(),status:wo(),amount:wo(),currency:wo(),allocations:ei(ni({source_type:wo(),commission_id:Ba,adjustment_id:Ba,amount:wo()})),wallet_transaction_id:Ba,payout_asset:Ba,payout_network:Ba,payout_address:Ba,note:Ba,metadata:Go(),completed_at:Ba,rejected_at:Ba,cancelled_at:Ba,created_at:Ba,updated_at:Ba}))}),is=ni({uniqid:wo(),status:wo(),gateway:wo(),current_period_start:wo(),current_period_end:wo(),trial_end:Ba,cancel_at_period_end:Ho(),canceled_at:Ba,created_at:wo(),plan:ni({id:wo(),uniqid:wo(),name:wo(),price:wo(),currency:wo(),interval:wo(),interval_count:Bo(),trial_days:Bo()}).nullable(),payment_method:ni({id:wo(),gateway:wo(),type:wo(),card_brand:Ba,card_last4:Ba,card_exp_month:Bo().nullable(),card_exp_year:Bo().nullable(),is_default:Ho()}).nullable(),actions:ni({can_pause:Ho(),can_resume:Ho(),can_cancel:Ho(),can_manage_payment_method:Ho()})}),rs=ni({enabled:Ho(),account:ni({points_balance:Bo(),lifetime_points:Bo()}).nullable(),settings:ni({earn_rate_per_usd:Bo(),redeem_value_per_point:Bo(),min_redeem_points:Bo()}).nullable(),transactions:ei(ni({type:di(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:Bo(),balance_after:Bo(),description:Ba,created_at:wo()}))}),as=ni({redeemed_points:Bo(),wallet_amount:wo(),currency:wo(),points_balance:Bo(),replayed:Ho()}),ss=ni({uniqid:wo(),invoice_uniqid:wo(),product_title:wo(),period_days:Bo(),starts_at:wo(),expires_at:wo(),status:di(["ACTIVE","EXPIRED","VOIDED"]),claim_status:di(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:wo()}),ls=ni({warranties:ei(ss)}),us=ni({warranty:ss.extend({claim_status:fi("REQUESTED")})}),cs=(ni({customer:ni({id:wo(),email:wo(),name:wo(),joined_at:Ba})}),ni({avatar_url:Ba}),ni({global_unsubscribed:Ho(),lists:ei(ni({id:wo(),name:wo(),description:Ba,subscribed:Ho()}))}),ni({updated:Ho()}),ni({order_created_emails:Ho(),order_completed_emails:Ho(),payment_issue_emails:Ho()}),ni({favorites:ei(ni({product_uniqid:wo(),title:wo(),slug:Ba,image_url:Ba,price_display:Bo(),unavailable:Ho(),created_at:wo()}))}),ii([ni({added:fi(!0)}),ni({removed:fi(!0)})]),ni({license:ni({uniqid:wo(),hardware_id:Ba})}),ni({invoice_id:wo(),checkout_url:wo(),preferred_gateways:ei(wo()),license:ni({uniqid:wo(),product_title:wo()})}),ni({invoices:ei(ni({id:wo(),uniqid:wo(),total:wo(),currency:wo(),status:wo(),gateway:wo(),created_at:wo(),completed_at:wo()}))}),ni({subscription:ni({id:wo(),status:wo(),cancel_at_period_end:Ho(),cancel_reason:Ba,canceled_at:Ba})}),ni({subscription:ni({id:wo(),status:wo()})}),ni({ticket:ni({uniqid:wo(),title:wo(),status:wo(),invoice_id:Ba,created_at:wo(),updated_at:wo(),messages:ei(ni({id:wo(),role:di(["CUSTOMER","SHOP","SYSTEM"]),message:wo(),created_at:wo()}))})}),ni({uniqid:wo()}),ni({affiliate_link:ni({id:wo(),customer_id:wo(),label:Ba,code:wo(),url:Ba,status:di(["pending","approved","rejected"]),requested_affiliate_revenue_percent:Bo().nullable(),requested_affiliate_customer_discount_percent:Bo().nullable(),created_at:wo(),updated_at:wo()})}),ni({check:wo(),passed:Ho(),reason:Ba.optional()})),ds=(ni({eligible:Ho(),decision:di(["ELIGIBLE","DENIED","NO_RULE"]),reason:Ba,eligibility_checks:ei(cs)}),ni({request_id:wo(),event_id:Ba,decision:di(["ISSUED_REPLACEMENT","FALLBACK_REFUND","FALLBACK_CREDIT","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED"]),status_label:di(["ISSUED","REFUNDED","CREDITED","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED","PENDING"]),reason:Ba,eligibility_checks:ei(cs)}),ni({id:wo(),name:Ba,discount_percent:Bo().nullable()})),ps=ni({id:wo(),status:di(["INVITED","APPLIED","ACTIVE","SUSPENDED","REJECTED"]),tier:ds.nullable(),application_note:Ba,lifetime_revenue:wo(),lifetime_orders:Bo(),approved_at:Ba,created_at:wo()}),fs=(ni({program_enabled:Ho(),enrollment_mode:di(["MANUAL","APPLICATION","OPEN"]),application_message:Ba,require_application_note:Ho(),reseller:ps.nullable()}),ni({reseller:ps}),di(["variant","product","tier"])),ms=ni({variant_id:wo(),title:wo(),stock:Bo(),supplier_backed:Ho(),orderable:Ho(),base_price:wo(),unit_price:wo(),discount_percent:Bo(),applied_override:fs}),_s=(ni({tier:ds,catalog:ni({currency:wo(),total:Bo(),page:Bo(),per_page:Bo(),items:ei(ni({product_id:wo(),uniqid:wo(),title:wo(),type:wo(),stock:Bo(),supplier_backed:Ho(),orderable:Ho(),volume_discount_enabled:Ho(),base_price:wo(),unit_price:wo(),discount_percent:Bo(),applied_override:fs,variants:ei(ms)}))})}),ni({quote:ni({currency:wo(),tier:ds,items:ei(ni({product_id:wo(),product_title:wo(),product_type:wo(),variant_id:Ba,variant_title:Ba,quantity:Bo(),base_price:wo(),discount_percent:Bo(),unit_price:wo(),line_total:wo(),applied_override:fs,volume_discount_applied:wo()})),subtotal:wo(),volume_discount_total:wo(),total:wo(),savings:wo()})}),ni({orders:ni({total:Bo(),page:Bo(),per_page:Bo(),items:ei(ni({uniqid:wo(),status:wo(),currency:wo(),total:wo(),item_count:Bo(),created_at:wo()}))})}),ni({order:ni({uniqid:wo(),status:wo(),currency:wo(),total:wo(),item_count:Bo(),created_at:wo(),tier_name:wo(),tier_discount_percent:Bo(),partially_delivered:Ho(),refunded_amount:Ba,lines:ei(ni({product_id:Ba,product_title:wo(),variant_id:Ba,variant_title:Ba,quantity:Bo(),unit_price:wo(),total:wo(),delivered:Ho(),delivered_at:Ba,serials:ei(wo())}))})}),ni({wallet:ni({currency:wo(),balance:wo(),hold_balance:wo(),available:wo(),is_active:Ho()})}),ni({api_keys:ei(ni({id:wo(),name:wo(),key_last4:wo(),last_used_at:Ba,revoked_at:Ba,created_at:wo()}))}),ni({topup:ni({uniqid:wo(),url:wo()})}),ni({shop:ni({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:Ya}),customer:ni({email:wo(),name:wo()}),stats:ni({invoices_count:Bo(),licenses_count:Bo(),deliverables_count:Bo(),tickets_count:Bo()}),wallet:ni({available:wo(),total:wo(),hold:wo(),currency:wo(),enabled:Ho()}).nullable(),rewards:ts,affiliate:os,invoices:ei(Va),subscriptions:ei(is),licenses:ei(ni({uniqid:wo(),invoice_id:wo(),status:wo(),license_key:wo(),hardware_id:Ba,expires_at:Bo().nullable(),renewable:Ho(),product:ni({title:wo().optional()}).optional()})),deliverables:ei(ni({id:wo(),invoice_uniqid:wo(),product_title:wo(),kind:di(["file","serial","license"]),label:wo(),value:wo(),href:Ba,created_at:wo()})),tickets:ei(ni({uniqid:wo(),title:wo(),status:wo(),updated_at:wo(),created_at:Ba}))}));var hs=null,ys=null;var gs=null,bs=null;function vs(e,t){const n=t?.shopId?.trim();bs=n||null;const i=gs?.locale;return i!==(gs={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}).locale&&o(),hs=null,ys=null,gs}function ws(){if(!gs)throw new s;return gs}function Ss(){return null!==gs}function ks(e){bs=e}function Es(){return bs}function Os(e){return function(e){if(Array.isArray(e))return e;if("string"==typeof e){try{const t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const e=t.custom_fields??t.customFields;return Array.isArray(e)?e:[]}}catch{return[]}return[]}if(e&&"object"==typeof e){const t=e.custom_fields??e.customFields;return Array.isArray(t)?t:[]}return[]}(e).filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)).map(e=>{const t="string"==typeof e.type?e.type.trim().toLowerCase():"text",n=t.length>0?t:"text",o=[e.default_value,e.default,e.value].find(e=>"string"==typeof e&&e.trim().length>0);return{name:"string"==typeof e.name?e.name.trim():"",type:n,required:!0===e.required||"true"===e.required||1===e.required||"1"===e.required,defaultValue:"string"==typeof o?o:"",placeholder:"string"==typeof e.placeholder?e.placeholder:"",regex:"string"==typeof e.regex?e.regex:void 0}}).filter(e=>e.name.length>0&&"hidden"!==e.type)}function xs(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}function zs(e,t){if("checkbox"===e.type)return e.required&&!xs(t)?`${e.name} is required.`:null;const n=t.trim();if(e.required&&!n)return`${e.name} is required.`;if(e.regex&&n)try{if(!new RegExp(e.regex).test(n))return`${e.name} has an invalid format.`}catch{return null}return null}function Ts(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(xs(o)&&(n[e.name]="true"));const i=o.trim();i.length>0&&(n[e.name]=i)}),n}var As=-1;function Is(e,t,n){return!0!==t?e:!0===n?As:0!==e?e:As}function Ps(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):null}function $s(e){if(!0===e)return!0;if("number"==typeof e&&Number.isFinite(e))return 0!==e;if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"1"===t}return!1}function Ns(e){return Is(Ps(e?.stock)??As,e?.orderable,e?.supplier_backed)}function Cs(e){if(!e)return As;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return Is(Ps(e.stock)??As,e.orderable,e.supplier_backed);const t=function(e){const t=Array.isArray(e.price_variants)?e.price_variants:[];return t.length>0?t.map(e=>Ns(e)):(Array.isArray(e.variants)?e.variants:[]).map(e=>Ns(e))}(e);return t.length>0?t.some(e=>e<0)?As:Is(t.reduce((e,t)=>e+Math.max(t,0),0),e.orderable,e.supplier_backed):Is(Ps(e.stock)??As,e.orderable,e.supplier_backed)}function Rs(e){return!!function(e){return!!e&&($s(e.on_hold)||$s(e.onHold)||$s(e.is_on_hold)||$s(e.isOnHold))}(e)||0===Cs(e)}function Us(e){return!Rs(e)}function qs(e){return 0===Ns(e)}function Ds(e=[]){const t=/* @__PURE__ */new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function js(e,t=[]){const n=t instanceof Map?t:Ds(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function Ls(e=[]){return Array.from(Ds(e).values())}function Zs(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function Ms(e){return e.trim().toLowerCase()}function Fs(e,t){const n=Zs(t).toLowerCase();n&&e.push(n)}function Bs(e){const t=[];Fs(t,e.title),Fs(t,e.slug??void 0),Fs(t,e.description);for(const n of e.product_highlights??[])Fs(t,n);for(const n of e.variants??[])Fs(t,n.title);for(const n of e.price_variants??[])Fs(t,n.title??n.label);return t}function Js(e,t){const n=Ms(t);return!!n&&Bs(e).some(e=>e.includes(n))}function Ys(e,t){const n=Ms(t);if(!n)return!1;const o=Zs(e.title).toLowerCase(),i=Zs(e.slug??e.name??void 0).toLowerCase(),r=Zs(e.description).toLowerCase();return o.includes(n)||i.includes(n)||r.includes(n)}function Ws(e,t,n){const o=Ms(t);if(!o)return[];let i=e.filter(e=>Js(e,o));return n?.hideOutOfStock&&(i=i.filter(e=>Us(e))),null!=n?.maxResults?i.slice(0,n.maxResults):i}function Hs(e,t){return 0!==e.length&&(!t||e.some(e=>Us(e)))}function Vs(e,t,n,o){const i=Ms(n);if(!i)return[];const r=!0===o?.hideOutOfStock,a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=[],u=Ds(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!Ys(d,i))continue;const t=js(d,u);if(Hs(t,r)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=Ls(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&Js(d,i)&&(r&&!Us(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function Gs(e,t,n,o){const i=Vs(e,t,n,o),r=/* @__PURE__ */new Set,a=[],s=e=>{e?.uniqid&&!r.has(e.uniqid)&&(o?.hideOutOfStock&&!Us(e)||(r.add(e.uniqid),a.push(e)))};for(const l of i)if("product"!==l.type)for(const e of l.products)s(e);else s(l.product);return null!=o?.maxResults?a.slice(0,o.maxResults):a}function Ks(e){if(e?.apiBaseUrl?.trim())return e.apiBaseUrl.replace(/\/+$/,"");const t=e?.hostname??("undefined"!=typeof window?window.location.hostname:"");if(t&&!function(e){if("localhost"===e||"127.0.0.1"===e||"::1"===e||e.endsWith(".localhost"))return!0;if(/^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e))return!0;if(/^192\.168\.\d{1,3}\.\d{1,3}$/.test(e))return!0;const t=e.match(/^172\.(\d{1,2})\.\d{1,3}\.\d{1,3}$/);if(t){const e=Number(t[1]);return e>=16&&e<=31}return!1}(t))return"https://api.shoppex.io";if("undefined"!=typeof window){const e=window.apiBaseUrl;if("string"==typeof e&&e.trim())return e.replace(/\/+$/,"")}return"http://localhost:3001".replace(/\/+$/,"")}function Xs(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}async function Qs(e){const t=e.shopSlug.trim();if(!t)throw new Error("Store data is not ready yet. Please try again in a moment.");const n=e.email.trim().toLowerCase(),o=e.title?.trim()??"",i=o.length>=2?o.slice(0,30):"Contact Request",r=Xs({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=Ks({apiBaseUrl:e.apiBaseUrl}),l=await fetch(`${s}/v1/storefront/shops/name/${encodeURIComponent(t)}/tickets`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({email:n,title:i,message:r,...a?{invoice_id:a}:{}})}),u=await l.json().catch(()=>null);if(!l.ok)throw new Error(u?.message||u?.error||"Failed to send your message.");const c=u?.data?.uniqid;if(!c)throw new Error("Ticket created, but the response was incomplete.");return{uniqid:c}}function el(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}}var tl=/:([A-Za-z0-9_]+)/g;function nl(e,t){return e.replace(tl,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const i=String(o).trim();if(!i)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(i)})}function ol(e){return`shoppex_${e}`}function il(e){try{const t=localStorage.getItem(ol(e));return t?JSON.parse(t):null}catch{return null}}function rl(e,t){try{localStorage.setItem(ol(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function al(e){try{localStorage.removeItem(ol(e))}catch{}}function sl(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=il(t);if(n&&n.trim())return n;const o="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`spx_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return rl(t,o),o}async function ll(e){if(!Ss())return;if("undefined"==typeof window)return;if(function(e){const t=`client_error_${function(e){return[e.method,e.endpoint,e.statusCode??"none",e.message.trim().toLowerCase(),e.responseReceived?"response":"no-response"].join("|")}(e)}`,n=Date.now(),o=il(t);return"number"==typeof o&&n-o<15e3||(rl(t,n),!1)}(e))return;const t=ws(),n=Es(),o=n?nl("/v1/storefront/shops/id/:id/ping",{id:n}):nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),i=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:sl(t.storeSlug)??void 0,client_error:{source:e.source??"sdk",phase:e.phase??"request",endpoint:e.endpoint,method:e.method,message:e.message,status_code:e.statusCode,attempt_count:e.attemptCount,response_received:e.responseReceived??!1,page_url:e.pageUrl??window.location.href,request_url:e.requestUrl,online:e.online??("undefined"!=typeof navigator?navigator.onLine:void 0),visibility_state:e.visibilityState??("undefined"!=typeof document?document.visibilityState:void 0)}}),r=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([i],{type:"application/json"});if(navigator.sendBeacon(r,e))return}await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0})}catch{}}var ul=1e4;async function cl(e){return new Promise(t=>setTimeout(t,e))}async function dl(e,t={}){const n=t.baseUrl?null:ws(),o=n??(Ss()?ws():null),{method:i="GET",body:s,timeout:c=ul,retries:d,baseUrl:p,cache:f}=t,m=d??("GET"===i?2:0),_=`${p??n?.apiBaseUrl??""}${e}`,h={"Content-Type":"application/json",Accept:"application/json"};"string"==typeof o?.locale&&o.locale.trim()&&(h["x-shoppex-locale"]=o.locale.trim());let y=null;const g=async()=>{for(let t=0;t<=m;t++)try{const e=new AbortController,t=setTimeout(()=>e.abort(),c),n=await fetch(_,{method:i,headers:h,body:s?JSON.stringify(s):void 0,signal:e.signal});clearTimeout(t);const o=await pl(n);if(!n.ok){const e=n.statusText?`HTTP ${n.status}: ${n.statusText}`:`HTTP ${n.status}`,t=(o.data&&"object"==typeof o.data&&"error"in o.data&&"string"==typeof o.data.error?o.data.error:null)??(o.data&&"object"==typeof o.data&&"message"in o.data&&"string"==typeof o.data.message?o.data.message:null)??o.rawText??e,i=ml(o.data);if(i.code)throw new u(t,i.code,n.status,i.errorParams);throw new l(t,n.status)}if(204===n.status&&null===o.data)return{success:!0};if(!o.data||"object"!=typeof o.data||!("status"in o.data))throw new l("Invalid API response",n.status);return fl(o.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new l("Request timeout",408));const o=n instanceof a?n.statusCode:void 0;if(y={message:n.message,statusCode:o,isTransport:void 0===o||408===o,...n instanceof u?{code:n.code,...n.errorParams?{errorParams:n.errorParams}:{}}:{}},n instanceof u&&void 0!==o&&o>=400&&o<500&&408!==o)break;if(t<m){await cl(500*Math.pow(2,t));continue}}return{success:!1,message:y?.message??"Unknown error",...y?.code?{code:y.code}:{},...y?.errorParams?{errorParams:y.errorParams}:{}}},b="GET"===i&&f&&f.ttl>0?await r(f.key??`GET:${_}`,g,{ttl:f.ttl,staleWhileRevalidate:f.staleWhileRevalidate},e=>e.success):await g(),v=y;return!b.success&&v?.isTransport&&await ll({endpoint:e,method:i,message:b.message??v.message,statusCode:v.statusCode,attemptCount:m+1,requestUrl:_,responseReceived:void 0!==v.statusCode&&408!==v.statusCode}),b}async function pl(e){const t=e;if("function"!=typeof t.text){if("function"==typeof t.json)try{return{data:await t.json(),rawText:null}}catch{return{data:null,rawText:null}}return{data:null,rawText:null}}try{const e=await t.text();if(!e)return{data:null,rawText:null};try{return{data:JSON.parse(e),rawText:null}}catch{const t=e.trim();return{data:null,rawText:t.length>0?t:null}}}catch{return{data:null,rawText:null}}}function fl(e){return e.status>=200&&e.status<300?{success:!0,data:e.data,...e.message?{message:e.message}:{}}:{success:!1,message:e.error??e.message??`Request failed with status ${e.status}`,...ml(e)}}function ml(e){if(!e||"object"!=typeof e)return{};const t=e,n="string"==typeof t.error_code&&t.error_code.length>0?t.error_code:null;if(!n)return{};const o=t.error_params;return{code:n,...o&&"object"==typeof o&&!Array.isArray(o)?{errorParams:o}:{}}}async function _l(e,t){return dl(e,{...t,method:"GET"})}async function hl(e,t,n){return dl(e,{...n,method:"POST",body:t})}var yl=3e5;async function gl(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:yl,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&ks(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function bl(e){const t=ws(),n=new URLSearchParams;Number.isFinite(e?.productsLimit)&&n.set("products_limit",String(Math.max(1,Math.floor(e?.productsLimit??0)))),"string"==typeof e?.productsCursor&&e.productsCursor.trim().length>0&&n.set("products_cursor",e.productsCursor);const o=n.size>0?`?${n.toString()}`:"",i=await _l(`${nl("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:yl,staleWhileRevalidate:!0}});return i.success&&i.data?(i.data.shop?.id&&ks(i.data.shop.id),{success:!0,data:{shop:i.data.shop,products:i.data.products??[],products_pagination:i.data.products_pagination??null,groups:i.data.groups??[],items:i.data.items??[],categories:i.data.categories??[],addons:i.data.addons??{items:[]}}}):{success:!1,message:i.message}}var vl=12e4;function wl(e){if(e.variants&&e.variants.length>0)return e;const t=e.price_variants;return Array.isArray(t)&&0!==t.length?{...e,variants:t.map(e=>function(e){return{id:e.id,title:e.title??e.label??"",price:"number"==typeof e.price?e.price:Number(e.price)||0,stock:"number"==typeof e.stock?e.stock:void 0,orderable:"boolean"==typeof e.orderable?e.orderable:void 0,supplier_backed:"boolean"==typeof e.supplier_backed?e.supplier_backed:void 0,quantity_min:e.quantity_min,quantity_max:e.quantity_max,quantityMin:e.quantityMin,quantityMax:e.quantityMax,image_id:e.image_id,imageId:e.imageId,cloudflare_image_id:e.cloudflare_image_id,cloudflareImageId:e.cloudflareImageId,image_url:e.image_url,imageUrl:e.imageUrl}}(e))}:e}async function Sl(){const e=ws(),t=await _l(nl("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:vl,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:Ls(t.data.products.map(wl))}:{success:!1,message:t.message,data:[]}}var kl="shoppex:affiliate_code:v1";function El(){return Date.now()}function Ol(e){const t=e?.trim().toLowerCase();return t||null}function xl(e,t=30){const n=Ol(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(kl,JSON.stringify(e))}catch{}}({code:n,expiresAt:El()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(zl(),null);var o}function zl(){if("undefined"!=typeof window)try{window.localStorage.removeItem(kl)}catch{}}function Tl(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(kl);if(!e)return null;const t=JSON.parse(e);return t&&"string"==typeof t.code&&"number"==typeof t.expiresAt?t:null}catch{return null}}();return e?e.expiresAt<=El()?(zl(),null):Ol(e.code):null}async function Al(e){const t=Ol(e);if(!t)return{success:!1,data:{valid:!1,affiliate_code:null,discount_active:!1,discount_percent:0},message:"Affiliate code is required"};const n=ws(),o=await hl("/v1/storefront/affiliates/resolve",{shop_slug:n.storeSlug,code:t},{retries:0});if(!o.success)return o;if(!o.data?.valid||!o.data.affiliate_code){const e=!1===o.data?.program_enabled;return{success:!1,data:{valid:!1,...void 0!==o.data?.program_enabled?{program_enabled:o.data.program_enabled}:{},affiliate_code:null,discount_active:!1,discount_percent:0},message:o.message??(e?"Affiliate program is disabled for this shop.":"Invalid affiliate code.")}}return{success:!0,data:{valid:!0,...void 0!==o.data.program_enabled?{program_enabled:o.data.program_enabled}:{},affiliate_code:Ol(o.data.affiliate_code),discount_active:Boolean(o.data.discount_active),discount_percent:Number(o.data.discount_percent??0)},...o.message?{message:o.message}:{}}}function Il(e){if(!e)return{};const t=Object.entries(e).filter(([,e])=>"string"==typeof e).sort(([e],[t])=>e.localeCompare(t));return Object.fromEntries(t)}function Pl(e){const t={product_id:e.product_id,variant_id:e.variant_id,price_variant_id:e.price_variant_id??null,addons:(n=e.addons,n?.length?[...n].map(e=>({id:e.id,quantity:e.quantity??1})).sort((e,t)=>e.id.localeCompare(t.id)):[]),custom_fields:Il(e.custom_fields),unit_price:"number"==typeof e.price_data?.unit_price&&Number.isFinite(e.price_data.unit_price)?e.price_data.unit_price:null,pay_what_you_want_price:"number"==typeof e.pay_what_you_want_price&&Number.isFinite(e.pay_what_you_want_price)?e.pay_what_you_want_price:null};var n;return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(t))}function $l(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:Pl(e)}}function Nl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function Cl(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return Nl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return Nl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}var Rl={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function Ul(e){return`${Rl[e]}_${ws().storeSlug}`}function ql(e){return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(e))}function Dl(e){if(!Number.isFinite(e))throw new d("quantity must be a finite number");return Math.floor(e)}function jl(e){const t=e?.trim().toUpperCase();return t||null}function Ll(){const e=il(Ul("coupon"));if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,n="string"==typeof t.code?jl(t.code):null,o="COUPON"===t.source||"AFFILIATE"===t.source?t.source:null;return n&&o?{code:n,source:o}:null}function Zl(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n,o="string"==typeof e.product_id?e.product_id.trim():"",i="string"==typeof e.variant_id?e.variant_id.trim():"",r=Number(e.quantity);if(!o||!i||!Number.isFinite(r)||r<1)continue;const a={line_id:"",product_id:o,variant_id:i,quantity:Math.floor(r)};if("string"==typeof e.price_variant_id&&(a.price_variant_id=e.price_variant_id),e.price_data&&"object"==typeof e.price_data){const t=e.price_data;"number"==typeof t.unit_price&&Number.isFinite(t.unit_price)&&(a.price_data={unit_price:t.unit_price})}"number"==typeof e.pay_what_you_want_price&&Number.isFinite(e.pay_what_you_want_price)&&(a.pay_what_you_want_price=e.pay_what_you_want_price),Array.isArray(e.addons)&&(a.addons=e.addons),e.custom_fields&&"object"==typeof e.custom_fields&&!Array.isArray(e.custom_fields)&&(a.custom_fields=e.custom_fields),"string"==typeof e.title&&(a.title=e.title),"string"==typeof e.variant_title&&(a.variant_title=e.variant_title),"string"==typeof e.image_url&&(a.image_url=e.image_url),Array.isArray(e.addon_labels)&&(a.addon_labels=e.addon_labels.filter(e=>"string"==typeof e)),"number"==typeof e.max_quantity&&Number.isFinite(e.max_quantity)&&(a.max_quantity=e.max_quantity),"number"==typeof e.min_quantity&&Number.isFinite(e.min_quantity)&&(a.min_quantity=e.min_quantity),Gl(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||Pl(a),t.push($l(a))}return t}function Ml(){return il(Ul("meta"))}function Fl(){return Ll()?.code??null}function Bl(){return Ll()?.source??null}function Jl(e,t="COUPON"){const n=jl(e);return n?(rl(Ul("coupon"),{code:n,source:t}),n):(al(Ul("coupon")),null)}function Yl(){al(Ul("coupon"))}function Wl(e){const t=Zl(e);rl(Ul("cart"),t);const n=Date.now(),o=Ml(),i={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:ql(t)};rl(Ul("meta"),i),0===t.length&&Yl()}function Hl(e,t){const n=Zl(e);rl(Ul("cart"),n);const o=Date.now(),i=t??Ml(),r={created_at:i?.created_at??o,last_modified:o,version:i?.version??1,checksum:ql(n)};rl(Ul("meta"),r)}function Vl(){return Zl(il(Ul("cart")))}function Gl(e){const t=e.min_quantity;"number"==typeof t&&Number.isFinite(t)&&e.quantity<t&&(e.quantity=Math.floor(t));const n=e.max_quantity;"number"==typeof n&&Number.isFinite(n)&&e.quantity>n&&(e.quantity=Math.floor(n)),e.quantity<1&&(e.quantity=1)}function Kl(){al(Ul("cart")),al(Ul("meta")),Yl(),tu=null,nu+=1}function Xl(){const e=Vl();rl(Ul("cartBackup"),e);const t=Ll();t?rl(Ul("couponBackup"),t):al(Ul("couponBackup"));const n=Ml();if(n)rl(Ul("metaBackup"),n);else{const t=Date.now();rl(Ul("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:ql(e)})}}function Ql(){const e=Vl(),t=Ml(),n=ql(e);return t?t.checksum===n:(Hl(e,null),!0)}function eu(){const e=Fl();return"AFFILIATE"===Bl()&&e?e.trim().toLowerCase():Tl()}var tu=null,nu=0;function ou(){return tu}var iu="Your cart changed while checkout was starting. Please review it and try again.";function ru(e,t){return void 0!==t&&JSON.stringify(e)!==t}function au(e){const t=e?.trim();return t||null}function su(e){const t=e?.trim();return t||null}function lu(e){return"/dashboard/api/checkout"===e.customerCheckoutPath&&"undefined"!=typeof window&&"string"==typeof window.location?.origin?{endpoint:e.customerCheckoutPath,baseUrl:window.location.origin}:{endpoint:"/v1/storefront/invoices/from-cart"}}function uu(e){return Nl(e.currency)??Cl()??Nl(ws().currency)}function cu(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(du(t))return"Your cart is outdated. Please add the products again.";const n=t.match(/^HTTP\s+(\d{3})(?::\s*(.*))?$/i);if(n){const e=Number(n[1]),t=n[2]?.trim();return t&&t.length>0?`Checkout failed: ${t}`:e>=500?"Checkout is temporarily unavailable. Please try again.":400===e?"Checkout failed. Please check your details and try again.":401===e||403===e?"Checkout is currently unavailable for this request.":"Checkout failed. Please try again."}return/^internal server error$/i.test(t)?"Checkout is temporarily unavailable. Please try again.":t}function du(e){const t=e?.trim().toLowerCase()??"";return!!t&&(t.includes("product not found")||t.includes("product not available")||t.includes("products are no longer available")||t.includes("outdated product"))}function pu(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),i=new URL(o);if(t.origin!==i.origin)return null;const r=t.pathname.replace(/\/+$/,""),a=`${i.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!r.startsWith(a))return null;const s=r.slice(a.length);if(!s||s.includes("/"))return null;if(n){const e=n.trim();if(!e||decodeURIComponent(s)!==e)return null}return t.toString()}catch{return null}}function fu(e,t){const n=su(t.email),o="string"==typeof t.locale?t.locale.trim():"";if(!n&&!o)return e;try{const t=new URL(e);if(o&&t.searchParams.set("locale",o),n){const e=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash);e.set("shoppex_prefill_email",n),t.hash=e.toString()}return t.toString()}catch{return e}}function mu(e,t){const n=e?.invoice,o=e?.invoiceId?.trim()||e?.invoice_id?.trim()||e?.uniqid?.trim()||n?.invoiceId?.trim()||n?.invoice_id?.trim()||n?.uniqid?.trim();let i=e?.checkoutUrl?.trim()||e?.checkout_url?.trim()||e?.url_branded?.trim()||e?.url?.trim()||n?.checkoutUrl?.trim()||n?.checkout_url?.trim()||n?.url_branded?.trim()||n?.url?.trim();return!i&&o&&n&&(i=function(e,t){const n=e?.trim();if(!n)return null;try{const e=new URL(n);return e.pathname=`${e.pathname.replace(/\/+$/,"")}/invoice/${encodeURIComponent(t)}`.replace(/\/{2,}/g,"/"),e.search="",e.hash="",e.toString()}catch{return null}}(t,o)??void 0),o&&i?{invoiceId:o,checkoutUrl:i,rewards:e?.rewards??n?.rewards??null}:null}function _u(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function hu(e,t){const n=e.affiliateCode??e.referralCode;if("string"==typeof n){const e=n.trim().toLowerCase();return e.length>0?e:null}return t?.trim().toLowerCase()??Tl()}function yu(e){const t=Fl(),n=Bl();return{coupon:void 0===e.coupon?"COUPON"===n?t:null:au(e.coupon),affiliateCode:hu(e,void 0===e.coupon&&"AFFILIATE"===n?t:null)}}function gu(e){const t=e=>{const t=e?.trim();return t?"default"===t.toLowerCase()?null:t:null};return e.map(e=>({product_id:e.product_id,variant_id:t(e.variant_id),quantity:e.quantity,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1})),custom_fields:e.custom_fields,price_variant_id:e.price_variant_id||null,pay_what_you_want_price:e.pay_what_you_want_price}))}function bu(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function vu(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function wu(e,t){const n=e,o=bu(n.rating)??bu(n.score)??0,i=vu(n.comment,n.message),r=vu(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=vu(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...i?{comment:i}:{},...r?{author:r}:{},created_at:s}}async function Su(e){const t=ws(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,i=await _l(`${nl("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return i.success&&i.data?{success:!0,data:{...i.data,feedback:i.data.feedback.map(wu)}}:{success:!1,message:i.message}}function ku(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Eu(e,t){return"string"==typeof e.error&&e.error.length>0?e.error:"string"==typeof e.message&&e.message.length>0?e.message:t.statusText?`HTTP ${t.status}: ${t.statusText}`:`HTTP ${t.status}`}function Ou(e){const t="string"==typeof e.error_code&&e.error_code.length>0?e.error_code:null;return t?{code:t,...ku(e.error_params)?{errorParams:e.error_params}:{}}:{}}async function xu(e,t={}){const n=t.method??"GET",o={Accept:"application/json"};void 0!==t.body&&(o["Content-Type"]="application/json");const i=t.formData??(void 0!==t.body?JSON.stringify(t.body):void 0);try{const a=await fetch(`/api/customer${e}`,{method:n,headers:o,body:i,credentials:"same-origin",cache:"no-store"});if(204===a.status)return a.ok?{success:!0,status:a.status}:{success:!1,status:a.status,message:Eu({status:a.status,data:null},a)};let s;try{s=await a.json()}catch{return{success:!1,status:a.status,message:"Invalid customer API response"}}const l=ku(r=s)&&"number"==typeof r.status&&"data"in r?r:null;if(!l)return{success:!1,status:a.status,message:"Invalid customer API response"};if(!a.ok||l.status<200||l.status>=300)return{success:!1,status:a.status,message:Eu(l,a),...Ou(l)};const u="string"==typeof l.message&&l.message.length>0?{message:l.message}:{};if(!t.schema)return{success:!0,data:l.data,...u};const c=t.schema.safeParse(l.data);return c.success?{success:!0,data:c.data,...u}:{success:!1,message:"Customer API response did not match the expected contract"}}catch(a){return{success:!1,message:a instanceof Error?a.message:String(a)}}var r}function zu(e){return xu("/auth/otp/request",{method:"POST",body:{email:e}})}function Tu(e,t){return xu("/auth/otp/verify",{method:"POST",body:{email:e,otp:t}})}function Au(){return xu("/auth/logout",{method:"POST"})}function Iu(){return xu("/me")}function Pu(){return xu("/dashboard",{schema:_s})}function $u(e={}){const t=new URLSearchParams;return void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.limit&&t.set("limit",String(e.limit)),e.status&&t.set("status",e.status),e.search&&t.set("q",e.search),xu("/invoices"+(t.size>0?`?${t.toString()}`:""),{schema:Ka})}function Nu(e){return xu(`/invoice/${encodeURIComponent(e)}`,{schema:Qa})}function Cu(){return xu("/loyalty",{schema:rs})}function Ru(e){return xu("/loyalty/redeem",{method:"POST",body:{points:e.points,idempotency_key:e.idempotencyKey},schema:as})}function Uu(e){return xu("/warranties"+(e?`?invoice=${encodeURIComponent(e)}`:""),{schema:ls})}function qu(e,t){return xu(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",body:t?{message:t}:{},schema:us})}function Du(e){return xu(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",body:{}})}function ju(e){return xu(`/subscriptions/${encodeURIComponent(e)}/billing-history`)}function Lu(e,t={}){return xu(`/subscriptions/${encodeURIComponent(e)}/cancel`,{method:"POST",body:{...void 0!==t.cancel_at_period_end?{cancel_at_period_end:t.cancel_at_period_end}:{},...void 0!==t.reason?{reason:t.reason}:{}}})}function Zu(e){return xu(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",body:{}})}function Mu(e){return xu(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",body:{}})}function Fu(){return xu("/favorites")}function Bu(e){return xu(`/favorites/${encodeURIComponent(e)}`,{method:"PUT"})}function Ju(e){return xu(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE"})}function Yu(){return xu("/affiliate")}function Wu(e){return xu("/tickets",{method:"POST",body:{...void 0!==e.title?{title:e.title}:{},message:e.message,...void 0!==e.invoice_id?{invoice_id:e.invoice_id}:{}}})}function Hu(e){return xu(`/tickets/${encodeURIComponent(e)}`)}function Vu(e,t){return xu(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",body:{message:t}})}function Gu(e){return xu("/profile",{method:"POST",body:{name:e.name}})}function Ku(e){const t=new FormData;return t.append("file",e),xu("/profile/avatar",{method:"POST",formData:t})}function Xu(){return xu("/profile/avatar",{method:"DELETE"})}function Qu(){return xu("/email-marketing/preferences")}function ec(e){return xu("/email-marketing/preferences",{method:"PATCH",body:{...void 0!==e.global_unsubscribed?{global_unsubscribed:e.global_unsubscribed}:{},...void 0!==e.list_subscriptions?{list_subscriptions:e.list_subscriptions}:{}}})}function tc(){return xu("/sessions")}function nc(e){return xu(`/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function oc(){return xu("/sessions?others=true",{method:"DELETE"})}function ic(){return xu("/reseller")}function rc(e){return xu("/reseller/apply",{method:"POST",body:void 0===e?{}:{note:e}})}function ac(){return xu("/reseller/enroll",{method:"POST",body:{}})}function sc(e){return xu("/reseller/accept-invite",{method:"POST",body:{token:e}})}function lc(e={}){const t=new URLSearchParams;return void 0!==e.search&&t.set("search",e.search),void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.per_page&&t.set("per_page",String(e.per_page)),xu("/reseller/catalog"+(t.size>0?`?${t.toString()}`:""))}function uc(e){return xu("/reseller/orders/quote",{method:"POST",body:{items:e}})}function cc(e={}){const t=new URLSearchParams;return void 0!==e.page&&t.set("page",String(e.page)),void 0!==e.per_page&&t.set("per_page",String(e.per_page)),xu("/reseller/orders"+(t.size>0?`?${t.toString()}`:""))}function dc(e){return xu(`/reseller/orders/${encodeURIComponent(e)}`)}function pc(){return xu("/reseller/wallet")}function fc(){return xu("/reseller/api-keys")}function mc(e){const t=e.trim();return t||null}var _c=3e5;var hc=3e5;async function yc(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:hc,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function gc(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:hc,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function bc(e){return gc(e)}async function vc(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:hc,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function wc(e){return function(e){const t=S[e];return[t.title,...t.aliases]}(e)}var Sc=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function kc(e){return`shoppex:utm:${e}`}function Ec(e){if("undefined"==typeof window||void 0===window.location)return;const t=function(e){let t;try{t=new URLSearchParams(e)}catch{return{}}const n={};for(const o of Sc){const e=t.get(o)?.trim();e&&(n[o]=e.slice(0,255))}return n}(window.location.search);if(Object.keys(t).length>0)return function(e,t){try{const n={utm:t,at:Date.now()};window.localStorage.setItem(kc(e),JSON.stringify(n))}catch{}}(e,t),t;const n=function(e){try{const t=window.localStorage.getItem(kc(e));if(!t)return{};const n=JSON.parse(t);if(!n||"number"!=typeof n.at||"object"!=typeof n.utm)return{};if(Date.now()-n.at>2592e6)return window.localStorage.removeItem(kc(e)),{};const o={};for(const e of Sc){const t=n.utm?.[e];"string"==typeof t&&t.length>0&&(o[e]=t.slice(0,255))}return o}catch{return{}}}(e);return Object.keys(n).length>0?n:void 0}async function Oc(e,t){if(!Ss())return;if("undefined"==typeof document)return;const n=ws(),o=sl(n.storeSlug);try{const i=nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referer:document.referrer||void 0,cart_value:e??void 0,item_count:t??void 0,connection_id:o??void 0,utm:Ec(n.storeSlug)})})}catch{}}async function xc(){if(!Ss())return{success:!1,message:"SDK not initialized"};const e=ws(),t=Es();return _l(t?nl("/v1/storefront/shops/id/:id/recent-sales",{id:t}):nl("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function zc(){if(!Ss())return{success:!1,message:"SDK not initialized"};const e=ws(),t=Es();return _l(t?nl("/v1/storefront/shops/id/:id/online-users",{id:t}):nl("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function Tc(){if(!Ss())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=ws(),t=Es();return hl(t?nl("/v1/storefront/shops/id/:id/ping",{id:t}):nl("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:sl(e.storeSlug)??void 0,utm:Ec(e.storeSlug)},{retries:0,timeout:5e3})}function Ac(e,t){const n=ws();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD",...Za})}function Ic(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Pc(e){return Ic(e)&&Ic(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:Ic(e.theme.content)?e.theme.content:{},layout:Ic(e.theme.layout)?e.theme.layout:{},style_slots:Ic(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...Ic(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function $c(e){const t=await _l(nl("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?Ic(n=t.data)?{settings:Ic(n.settings)?n.settings:{},builder_settings:Pc(n.builder_settings),content:Ic(n.content)?n.content:{},style_slots:Ic(n.style_slots)?n.style_slots:{}}:null:null;var n}async function Nc(e){const t=await $c(e);return t?t.settings:null}function Cc(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,i]of Object.entries(o))t[n][e]=i.default}return t}function Rc(e,t){const n={...e};for(const[o,i]of Object.entries(t))i&&(n[o]={...n[o],...i});return n}var Uc={init:function(e,t){"string"==typeof e?vs(e,t):vs(e.storeId,e)},isInitialized:Ss,getConfig:ws,client:function(e){const t=ws().apiBaseUrl??"https://api.shoppex.io";if(hs&&ys===t&&!e)return hs;const n=function(e,t){return f({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(hs=n,ys=t),n},getStore:gl,getStorefront:bl,getStoreLogoUrl:async function(){const e=await gl();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await gl();return e.success&&e.data?.banner?e.data.banner:null},resolveStoreByDomain:async function(e,t){const n=e??("undefined"!=typeof window?window.location.hostname:"");if(!n)return{success:!1,message:"Domain is required to resolve store"};const o=n.replace(/^https?:\/\//,"").split("/")[0].trim(),i=t??(Ss()?ws().apiBaseUrl:"https://api.shoppex.io"),r=await _l(nl("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:i,cache:{key:`store:domain:${o}`,ttl:yl,staleWhileRevalidate:!0}});return r.success&&r.data?.shop?(r.data.shop.id&&ks(r.data.shop.id),{success:!0,data:r.data.shop}):{success:!1,message:r.message??"Failed to resolve store"}},getProducts:Sl,getStorefrontProductsPage:async function(e){const t=ws(),n=new URLSearchParams;"string"==typeof e?.cursor&&e.cursor.trim().length>0&&n.set("cursor",e.cursor),Number.isFinite(e?.limit)&&n.set("limit",String(Math.max(1,Math.floor(e?.limit??0)))),"string"==typeof e?.sort&&e.sort.trim().length>0&&n.set("sort",e.sort.trim()),"string"==typeof e?.category&&e.category.trim().length>0&&n.set("category",e.category.trim()),!0===e?.hideOutOfStock&&n.set("hide_out_of_stock","true");const o=n.size>0?`?${n.toString()}`:"",i=await _l(`${nl("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${r=e?.category,void 0===r?"category:unset":null===r?"category:null":`category:${r}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:vl,staleWhileRevalidate:!0}});var r;return i.success&&i.data?{success:!0,data:{products:i.data.products.map(wl),pagination:i.data.pagination??null}}:{success:!1,message:i.message}},getProduct:async function(e){let t=Es();if(!t){const e=await gl();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await _l(`${nl("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:vl,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:wl(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await Sl();if(!e.success||!e.data)return{success:!1,message:e.message};const t=/* @__PURE__ */new Set;for(const n of e.data)if(n.categories)for(const e of n.categories)"string"==typeof e?t.add(e):e&&"object"==typeof e&&"uniqid"in e&&t.add(e.uniqid);return{success:!0,data:Array.from(t)}},getCart:Vl,getCartItemCount:function(){return Vl().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:Fl,getCartCouponSource:Bl,setCartCoupon:Jl,clearCartCoupon:Yl,addToCart:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const i=Dl(n);if(i<1)throw new d("quantity must be at least 1");const r=Vl(),a=Pl({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price}),s=r.findIndex(e=>e.line_id===a);if(s>=0)r[s].quantity+=i,o?.addons&&(r[s].addons=o.addons),o?.custom_fields&&(r[s].custom_fields=o.custom_fields),o?.price_variant_id&&(r[s].price_variant_id=o.price_variant_id),o?.price_data&&(r[s].price_data=o.price_data),void 0!==o?.pay_what_you_want_price&&(r[s].pay_what_you_want_price=o.pay_what_you_want_price),function(e,t){if(t?.replace_display_snapshot)return e.title=t.title,e.variant_title=t.variant_title,e.image_url=t.image_url,e.addon_labels=t.addon_labels,e.max_quantity=t.max_quantity,void(e.min_quantity=t.min_quantity);void 0!==t?.title&&(e.title=t.title);void 0!==t?.variant_title&&(e.variant_title=t.variant_title);void 0!==t?.image_url&&(e.image_url=t.image_url);void 0!==t?.addon_labels&&(e.addon_labels=t.addon_labels);void 0!==t?.max_quantity&&(e.max_quantity=t.max_quantity);void 0!==t?.min_quantity&&(e.min_quantity=t.min_quantity)}(r[s],o),Gl(r[s]);else{const n={line_id:a,product_id:e,variant_id:t,quantity:i,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Gl(n),r.push(n)}Wl(r)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const i=Dl(n);if(i<1)throw new d("quantity must be at least 1");const r=Vl(),a=Pl({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price});for(let l=r.length-1;l>=0;l-=1)r[l].product_id===e&&r[l].variant_id===t&&r.splice(l,1);const s={line_id:a,product_id:e,variant_id:t,quantity:i,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,pay_what_you_want_price:o?.pay_what_you_want_price,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Gl(s),r.push(s),Wl(r)},updateCartItem:function(e,t){const n=Vl(),o=e.trim();if(!o)throw new d("line_id is required");const i=n.findIndex(e=>e.line_id===o);if(i<0)throw new d("Item not found in cart");const r=JSON.stringify(n);if(void 0!==t.quantity){const e=Dl(t.quantity);if(e<1)return n.splice(i,1),void Wl(n);n[i].quantity=e}void 0!==t.addons&&(n[i].addons=t.addons),void 0!==t.custom_fields&&(n[i].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[i].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[i].price_data=t.price_data),void 0!==t.pay_what_you_want_price&&(n[i].pay_what_you_want_price=t.pay_what_you_want_price),void 0!==t.max_quantity&&(null===t.max_quantity?delete n[i].max_quantity:n[i].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(null===t.min_quantity?delete n[i].min_quantity:n[i].min_quantity=t.min_quantity),Gl(n[i]);const a=Pl(n[i]),s=n.findIndex((e,t)=>t!==i&&e.line_id===a);s>=0?(n[s].quantity+=n[i].quantity,Gl(n[s]),n.splice(i,1)):n[i].line_id=a,JSON.stringify(n)!==r&&Wl(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new d("line_id is required");Wl(Vl().filter(e=>e.line_id!==t))},clearCart:Kl,createCartBackup:Xl,restoreCartFromBackup:function(){const e=Zl(il(Ul("cartBackup"))),t=il(Ul("metaBackup")),n=il(Ul("couponBackup"));if(e&&e.length>0){if(Hl(e,t),n&&"object"==typeof n&&!Array.isArray(n)){const e=n,t="COUPON"===e.source||"AFFILIATE"===e.source?e.source:null;"string"==typeof e.code&&t?Jl(e.code,t):Yl()}else Yl();return!0}return!1},mergeBaskets:function(e){const t=Vl();for(const n of e){const e="string"==typeof n.product_id?n.product_id.trim():"",o="string"==typeof n.variant_id?n.variant_id.trim():"";if(!e||!o)continue;let i;try{i=Dl(n.quantity)}catch{continue}if(i<1)continue;const r=$l({...n,line_id:n.line_id??Pl(n),product_id:e,variant_id:o,quantity:i}),a=t.findIndex(e=>e.line_id===r.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,i),Gl(t[a])):(Gl(r),t.push(r))}return Wl(t),t},moveBasketItem:function(e,t,n,o){const i=Vl(),r=i.findIndex(n=>n.product_id===e&&n.variant_id===t);if(r<0)throw new d("Item not found in cart");const[a]=i.splice(r,1),s=Pl({...a,product_id:n,variant_id:o}),l=i.findIndex(e=>e.line_id===s);if(l>=0)i[l].quantity+=a.quantity,Gl(i[l]);else{const e=$l({...a,product_id:n,variant_id:o,line_id:s});Gl(e),i.push(e)}Wl(i)},getCartStats:function(){const e=Vl(),t=Ql(),n=Ml(),o=il(Ul("cartBackup"))??[],i=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),r=e.reduce((e,t)=>e+Ma((t.price_data?.unit_price??0)*t.quantity),0);return{item_count:e.length,total_quantity:e.reduce((e,t)=>e+t.quantity,0),last_modified:n?.last_modified??0,version:n?.version??0,has_backup:o.length>0,integrity_valid:t,total_price:Ma(r),total_price_is_estimate:e.length>0&&!i}},validateCartIntegrity:Ql,quoteCart:async function(e,t){const n=nu+=1,o=function(e){const t=ws(),n=jl(e)??Fl()??void 0;return{store_slug:t.storeSlug,items:Vl(),coupon:n}}(e),i=Nl(t)??Cl()??Nl(ws().currency),r=await hl("/v1/storefront/cart/quote",{shop_slug:o.store_slug,cart:o.items,coupon:o.coupon,affiliate_code:eu()??void 0,currency:i??void 0});return n!==nu||r.success&&(tu="string"==typeof r.data?.quote_token?r.data.quote_token:null),r},resolveCartLineId:function(e,t,n=Vl()){const o=n.filter(n=>n.product_id===e&&n.variant_id===t);if(0===o.length)throw new d(`No cart line found for ${e}/${t}`);return o[0].line_id},checkout:async function(e,t){const n=_u(e,t),{autoRedirect:o=!0,email:i}=n,r=yu(n),a=r.coupon,s=su(i),l=r.affiliateCode,u=uu(n),c=Vl();if(0===c.length)return{success:!1,message:"Cart is empty"};if(ru(c,n.expectedCart))return{success:!1,message:iu};Xl();const d=ws(),p=lu(n),f=await hl(p.endpoint,{shop_slug:d.storeSlug,cart:gu(c),email:s,coupon:a,currency:u,affiliate_code:l,quote_token:ou()??void 0},{retries:0,baseUrl:p.baseUrl});if(!f.success||!f.data)return du(f.message)&&Kl(),{success:!1,message:cu(f.message),...f.code?{code:f.code}:{}};const m=mu(f.data,d.checkoutBaseUrl);if(!m)return{success:!1,message:"Failed to create invoice"};const{invoiceId:_}=m,h=pu(m.checkoutUrl,d.checkoutBaseUrl,_);if(!h)return{success:!1,message:"Failed to create invoice"};const y=fu(h,{email:s,locale:n.locale??d.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=y,Kl()),{success:!0,redirectUrl:y,invoiceId:_,rewards:m.rewards}},buildCheckoutUrl:async function(e,t){const n=_u(e,t),{email:o}=n,i=yu(n),r=i.coupon,a=su(o),s=i.affiliateCode,l=uu(n),u=Vl();if(0===u.length)throw new Error("Cart is empty");if(ru(u,n.expectedCart))throw new Error(iu);const c=ws(),d=lu(n),p=await hl(d.endpoint,{shop_slug:c.storeSlug,cart:gu(u),email:a,coupon:r,currency:l,affiliate_code:s,quote_token:ou()??void 0},{retries:0,baseUrl:d.baseUrl});if(!p.success||!p.data)throw du(p.message)&&Kl(),new Error(cu(p.message));const f=mu(p.data,c.checkoutBaseUrl);if(!f)throw new Error("Failed to create invoice");const m=pu(f.checkoutUrl,c.checkoutBaseUrl,f.invoiceId);if(!m)throw new Error("Failed to create invoice");return fu(m,{email:a,locale:n.locale??c.locale})},buildCheckoutUrlSync:function(){throw new Error("buildCheckoutUrlSync is deprecated. Use buildCheckoutUrl (async) instead.")},captureAffiliateFromUrl:async function(e="ref"){if("undefined"==typeof window)return null;let t=null;try{const n=new URL(window.location.href).searchParams.get(e);t=n?n.trim():null}catch{t=null}if(t=Ol(t),!t)return null;if(xl(t),Ss())try{const e=ws(),n=await hl("/v1/storefront/affiliates/attribution",{shop_slug:e.storeSlug,code:t},{retries:0});return n.success&&n.data?.accepted&&n.data?.affiliate_code?(xl(n.data.affiliate_code),n.data.affiliate_code):(zl(),null)}catch{return t}return t},validateAffiliateCode:Al,applyAffiliateCode:async function(e){const t=await Al(e);return t.success&&t.data?.affiliate_code&&xl(t.data.affiliate_code),t},getAffiliateCode:Tl,setAffiliateCode:xl,clearAffiliateCode:zl,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},i="string"==typeof t?t:t?.productId,r="string"==typeof t?void 0:t?.variantId;if(r&&!i)return{success:!1,message:"productId is required when variantId is provided"};if(i)o.product_id=i,r&&(o.variant_id=r);else{const e=Vl();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=Es();if(e)return e;const t=await gl();return t.success&&t.data?.id?t.data.id:null}();if(!t)return{success:!1,message:"Failed to resolve store"};o.cart=JSON.stringify({shop_id:t,products:e.map(e=>({uniqid:e.product_id,quantity:e.quantity,variant_id:e.variant_id,price_variant_id:e.price_variant_id,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1}))}))})}return await hl("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=/* @__PURE__ */new Set;let n=null;for(;;){const o=await Su(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...o.data.feedback);const i=o.data.pagination;if(!i?.has_more||!i.next_cursor)break;if(t.has(i.next_cursor))break;t.add(i.next_cursor),n=i.next_cursor}return{success:!0,data:e}},getShopReviewsPage:Su,requestOtp:zu,verifyOtp:Tu,logout:Au,me:Iu,dashboard:Pu,orders:$u,order:Nu,loyalty:Cu,redeemLoyaltyPoints:Ru,warranties:Uu,claimWarranty:qu,resetLicenseHwid:Du,subscriptionBillingHistory:ju,cancelSubscription:Lu,pauseSubscription:Zu,resumeSubscription:Mu,favorites:Fu,addFavorite:Bu,removeFavorite:Ju,affiliate:Yu,createTicket:Wu,ticket:Hu,replyToTicket:Vu,updateProfile:Gu,updateAvatar:Ku,removeAvatar:Xu,emailPreferences:Qu,updateEmailPreferences:ec,sessions:tc,revokeSession:nc,revokeAllSessions:oc,reseller:ic,applyForReseller:rc,enrollAsReseller:ac,acceptResellerInvite:sc,resellerCatalog:lc,quoteResellerOrder:uc,resellerOrders:cc,resellerOrder:dc,resellerWallet:pc,resellerApiKeys:fc,searchProducts:async function(e,t){if(!Ss())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await bl();return o.success&&o.data?{success:!0,data:Gs(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},searchCatalogItems:async function(e,t){if(!Ss())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await bl();return o.success&&o.data?{success:!0,data:Vs(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},getInvoice:async function(e){const t=mc(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await _l(nl("/v1/storefront/invoices/unique/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?{success:!0,data:n.data.invoice}:{success:!1,message:"Invalid invoice response"}:{success:!1,message:n.message}},getInvoiceStatus:async function(e){const t=mc(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await _l(nl("/v1/storefront/invoices/status/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?.status?{success:!0,data:{status:n.data.invoice.status}}:{success:!1,message:"Invalid invoice status response"}:{success:!1,message:n.message}},getPages:async function(){const e=ws(),t=await _l(nl("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:_c,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=ws(),n=await _l(nl("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:_c,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:yc,getMenu:bc,getMenuBySlot:vc,getMenuByTitle:gc,getMenuSlotTitles:wc,trackPageView:Oc,getStorefrontOnlineUsers:zc,getStorefrontRecentSales:xc,touchStorefrontPresence:Tc,createFormatter:Ac,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?Ac(t,n).format(0):Ac(t,n).format(o)},clearCache:o,invalidateCache:function(t){for(const n of e.keys())(n===t||n.startsWith(t))&&e.delete(n)},getCacheStats:function(){return{hits:n.hits,misses:n.misses,pendingRequests:t.size,entries:e.size}},fetchPublishedBuilderSettings:$c,fetchPublishedThemeSettings:Nc,resolveDefaults:Cc,mergeSettings:Rc};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=Uc)}export{u as ApiError,ja as CATALOG_UNIT_PRICE_DECIMAL_PLACES,Za as CATALOG_UNIT_PRICE_FORMAT_OPTIONS,d as CartError,l as NetworkError,s as NotInitializedError,La as PAYABLE_AMOUNT_DECIMAL_PLACES,a as ShoppexError,c as ValidationError,sc as acceptResellerInvite,Bu as addFavorite,Yu as affiliate,rc as applyForReseller,Xs as buildStorefrontContactMessage,Ts as buildStorefrontCustomFieldPayload,Ds as buildStorefrontProductLookup,Lu as cancelSubscription,qu as claimWarranty,Bs as collectProductSearchHaystack,Pl as computeCartLineId,Wu as createTicket,Pu as dashboard,Uc as default,Uc as shoppex,Qu as emailPreferences,ac as enrollAsReseller,$l as ensureCartLineId,Fu as favorites,$c as fetchPublishedBuilderSettings,Nc as fetchPublishedThemeSettings,Ws as filterProductsBySearchQuery,bc as getMenu,vc as getMenuBySlot,gc as getMenuByTitle,wc as getMenuSlotTitles,yc as getMenus,Ls as getMergedStorefrontProducts,Su as getShopReviewsPage,js as getStorefrontGroupProducts,zc as getStorefrontOnlineUsers,xc as getStorefrontRecentSales,Ys as groupMatchesSearchQuery,Us as isProductInStock,Rs as isProductOutOfStock,xs as isStorefrontCheckboxCustomFieldValueChecked,qs as isVariantOutOfStock,Au as logout,Cu as loyalty,Iu as me,Rc as mergeSettings,Ms as normalizeSearchQuery,Os as normalizeStorefrontCustomFields,Nu as order,$u as orders,Zu as pauseSubscription,Js as productMatchesSearchQuery,uc as quoteResellerOrder,Ru as redeemLoyaltyPoints,Xu as removeAvatar,Ju as removeFavorite,Vu as replyToTicket,zu as requestOtp,ic as reseller,fc as resellerApiKeys,lc as resellerCatalog,dc as resellerOrder,cc as resellerOrders,pc as resellerWallet,Du as resetLicenseHwid,Cc as resolveDefaults,Cs as resolveDisplayStock,Ks as resolveStorefrontApiBaseUrl,el as resolveStorefrontSocialLinks,Ns as resolveVariantStockValue,Mu as resumeSubscription,oc as revokeAllSessions,nc as revokeSession,Ma as roundPayableAmount,Gs as searchMergedStorefrontCatalog,Vs as searchMergedStorefrontCatalogItems,tc as sessions,Zs as stripHtmlFromText,Qs as submitStorefrontContactTicket,ju as subscriptionBillingHistory,Hu as ticket,Tc as touchStorefrontPresence,Oc as trackPageView,Ku as updateAvatar,ec as updateEmailPreferences,Gu as updateProfile,zs as validateStorefrontCustomFieldValue,Tu as verifyOtp,Uu as warranties};
3
3
  //# sourceMappingURL=shoppex.esm.js.map