@shoppexio/storefront 1.0.41 → 1.0.43

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,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shoppex={})}(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=new Map,n=new Map,o={hits:0,misses:0};function r(){t.clear(),n.clear()}function i(e,n,o){const r=Date.now();t.set(e,{data:n,ttl:o,updatedAt:r,expiresAt:r+o})}async function a(e,r,a,s=()=>!0){const l=function(e){const n=t.get(e);return n||null}(e);if(l&&!function(e){return Date.now()>e.expiresAt}(l))return o.hits+=1,l.data;if(l&&a.staleWhileRevalidate){if(o.hits+=1,!n.has(e)){const t=(async()=>{try{const t=await r();return s(t)&&i(e,t,a.ttl),t}finally{n.delete(e)}})();n.set(e,t)}return l.data}if(n.has(e))return n.get(e);o.misses+=1;const u=(async()=>{try{const t=await r();return s(t)&&i(e,t,a.ttl),t}finally{n.delete(e)}})();return n.set(e,u),u}var s=class e extends Error{constructor(t,n,o){super(t),this.name="ShoppexError",this.code=n,this.statusCode=o,Object.setPrototypeOf(this,e.prototype)}},l=class e extends s{constructor(){super("SDK not initialized. Call shoppex.init() first.","NOT_INITIALIZED"),this.name="NotInitializedError",Object.setPrototypeOf(this,e.prototype)}},u=class e extends s{constructor(t,n){super(t,"NETWORK_ERROR",n),this.name="NetworkError",Object.setPrototypeOf(this,e.prototype)}},c=class e extends s{constructor(t,n,o,r){super(t,n,o),this.name="ApiError",this.errorParams=r,Object.setPrototypeOf(this,e.prototype)}},d=class e extends s{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:r,bodySerializer:i,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:O=i??b,pathSerializer:E,body:x,middleware:z=[],...T}=d||{};let A=t;p&&(A=w(p)??t);let I="function"==typeof r?r:y(r);k&&(I="function"==typeof k?k:y({..."object"==typeof r?r:{},...k}));const P=E||a||g,C=void 0===x?void 0:O(x,v(s,_,h.header)),$=v(void 0===C||C instanceof FormData?{}:{"Content-Type":"application/json"},s,_,h.header),N=[...c,...z],R={redirect:"follow",...u,...T,body:C,headers:$};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(N.length){U=Math.random().toString(36).slice(2,11),q=Object.freeze({baseUrl:A,fetch:f,parseAs:S,querySerializer:I,bodySerializer:O,pathSerializer:P});for(const t of N)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(Z){let t=Z;if(N.length)for(let n=N.length-1;n>=0;n--){const o=N[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(N.length)for(let t=N.length-1;t>=0;t--){const n=N[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 M=await D.text();try{M=JSON.parse(M)}catch{}return{error:M,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=[],r={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 r=o.join(",");switch(n.style){case"form":return`${e}=${r}`;case"label":return`.${r}`;case"matrix":return`;${e}=${r}`;default:return r}}for(const a in t){const r="deepObject"===n.style?`${e}[${a}]`:a;o.push(m(r,t[a],n))}const i=o.join(r);return"label"===n.style||"matrix"===n.style?`${r}${i}`:i}function h(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",r=(!0===n.allowReserved?t:t.map(e=>encodeURIComponent(e))).join(o);switch(n.style){case"simple":return r;case"label":return`.${r}`;case"matrix":return`;${e}=${r}`;default:return`${e}=${r}`}}const o={simple:",",label:".",matrix:";"}[n.style]||"&",r=[];for(const i of t)"simple"===n.style||"label"===n.style?r.push(!0===n.allowReserved?i:encodeURIComponent(i)):r.push(m(e,i,n));return"label"===n.style||"matrix"===n.style?`${o}${r.join(o)}`:r.join(o)}function y(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const o in t){const r=t[o];if(null!=r)if(Array.isArray(r)){if(0===r.length)continue;n.push(h(o,r,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof r?n.push(m(o,r,e)):n.push(_(o,r,{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),r=!1,i="simple";if(e.endsWith("*")&&(r=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(i="label",e=e.substring(1)):e.startsWith(";")&&(i="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:i,explode:r})):n="object"!=typeof a?"matrix"!==i?n.replace(o,"label"===i?`.${encodeURIComponent(a)}`:encodeURIComponent(a)):n.replace(o,`;${m(e,a)}`):n.replace(o,_(e,a,{style:i,explode:r}))}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 O(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const r=a.prototype,i=Object.keys(r);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=r[t].bind(n))}}const r=n?.Parent??Object;class i extends r{}function a(e){var t;const r=n?.Parent?new i:this;o(r,e),(t=r._zod).deferred??(t.deferred=[]);for(const n of r._zod.deferred)n();return r}return Object.defineProperty(i,"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 E=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 C(e){return null==e}function $(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var N=Symbol("evaluating");function R(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==N)return void 0===o&&(o=N,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 M=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 Z(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 Z(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var B=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 V={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 H(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:r,continue:i,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=O("$ZodError",ne),re=O("$ZodError",ne,{Parent:Error});var ie=e=>(t,n,o,r)=>{const i=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;if(a.issues.length){const t=new(r?.Err??e)(a.issues.map(e=>Q(e,i,T())));throw j(t,r?.callee),t}return a.value},ae=e=>async(t,n,o,r)=>{const i=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(r?.Err??e)(a.issues.map(e=>Q(e,i,T())));throw j(t,r?.callee),t}return a.value},se=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new E;return i.issues.length?{success:!1,error:new(e??oe)(i.issues.map(e=>Q(e,r,T())))}:{success:!0,data:i.value}},le=se(re),ue=e=>async(t,n,o)=>{const r=o?{...o,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>Q(e,r,T())))}:{success:!0,data:i.value}},ce=ue(re),de=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ie(e)(t,n,r)},pe=e=>(t,n,o)=>ie(e)(t,n,o),fe=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ae(e)(t,n,r)},me=e=>async(t,n,o)=>ae(e)(t,n,o),_e=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return se(e)(t,n,r)},he=e=>(t,n,o)=>se(e)(t,n,o),ye=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ue(e)(t,n,r)},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}$/,Oe=/^[a-zA-Z0-9_-]{21}$/,Ee=/^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])$/,Ce=/^(([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])$/,$e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ne=/^[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=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+$/,Me=/^-?\d+(?:\.\d+)?$/,Ze=/^(?:true|false)$/i,Fe=/^[^A-Z]*$/,Be=/^[^a-z]*$/,Je=O("$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=O("$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})}}),Ve=O("$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})}}),He=O("$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),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<r?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=O("$ZodCheckNumberFormat",(e,t)=>{Je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,i]=V[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=r,o.maximum=i,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<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Ke=O("$ZodCheckMaxLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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 r=ee(o);n.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xe=O("$ZodCheckMinLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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 r=ee(o);n.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Qe=O("$ZodCheckLengthEquals",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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,r=o.length;if(r===t.length)return;const i=ee(o),a=r>t.length;n.issues.push({origin:i,...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=O("$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=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=O("$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=O("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Fe),et.init(e,t)}),ot=O("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Be),et.init(e,t)}),rt=O("$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=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})}}),it=O("$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=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=O("$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=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=O("$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 r of o)this.content.push(r)}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=O("$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 r of o)for(const t of r._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,r=H(e);for(const i of t){if(i._zod.def.when){if(G(e))continue;if(!i._zod.def.when(e))continue}else if(r)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new E;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(r||(r=H(e,t)))});else{if(e.issues.length===t)continue;r||(r=H(e,t))}}return o?o.then(()=>e):e},n=(n,r,i)=>{if(H(n))return n.aborted=!0,n;const a=t(r,o,i);if(a instanceof Promise){if(!1===i.async)throw new E;return a.then(t=>e._zod.parse(t,i))}return e._zod.parse(a,i)};e._zod.run=(r,i)=>{if(i.skipChecks)return e._zod.parse(r,i);if("backward"===i.direction){const t=e._zod.parse({value:r.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,i)):n(t,r,i)}const a=e._zod.parse(r,i);if(a instanceof Promise){if(!1===i.async)throw new E;return a.then(e=>t(e,o,i))}return t(a,o,i)}}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=O("$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=O("$ZodStringFormat",(e,t)=>{et.init(e,t),dt.init(e,t)}),ft=O("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xe),pt.init(e,t)}),mt=O("$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=O("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Te),pt.init(e,t)}),ht=O("$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 r=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),yt=O("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pt.init(e,t)}),gt=O("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Oe),pt.init(e,t)}),bt=O("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=be),pt.init(e,t)}),vt=O("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ve),pt.init(e,t)}),wt=O("$ZodULID",(e,t)=>{t.pattern??(t.pattern=we),pt.init(e,t)}),St=O("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Se),pt.init(e,t)}),kt=O("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ke),pt.init(e,t)}),Ot=O("$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)}),Et=O("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=De),pt.init(e,t)}),xt=O("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${je(t)}$`)),pt.init(e,t)}),zt=O("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ee),pt.init(e,t)}),Tt=O("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ae),pt.init(e,t),e._zod.bag.format="ipv4"}),At=O("$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=O("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pe),pt.init(e,t)}),Pt=O("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ce),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 Ct(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 $t=O("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$e),pt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ct(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Nt=O("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ne),pt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Ne.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Ct(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=O("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ue),pt.init(e,t)});var Ut=O("$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 r=JSON.parse(atob(o));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.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=O("$ZodNumber",(e,t)=>{ct.init(e,t),e._zod.pattern=e._zod.bag.pattern??Me,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const r=n.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),Dt=O("$ZodNumberFormat",(e,t)=>{Ge.init(e,t),qt.init(e,t)}),jt=O("$ZodBoolean",(e,t)=>{ct.init(e,t),e._zod.pattern=Ze,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const r=n.value;return"boolean"==typeof r||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Lt=O("$ZodUnknown",(e,t)=>{ct.init(e,t),e._zod.parse=e=>e}),Mt=O("$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 Zt(e,t,n){e.issues.length&&t.issues.push(...K(n,e.issues)),t.value[n]=e.value}var Ft=O("$ZodArray",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let e=0;e<r.length;e++){const a=r[e],s=t.element._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(t=>Zt(t,n,e))):Zt(s,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function Bt(e,t,n,o,r,i){const a=n in o;if(e.issues.length){if(r&&i&&!a)return;t.issues.push(...K(n,e.issues))}a||r?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 r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": 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,r,i){const a=[],s=r.keySet,l=r.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 r=l.run({value:t[p],issues:[]},o);r instanceof Promise?e.push(r.then(e=>Bt(e,n,p,t,c,d))):Bt(r,n,p,t,c,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Wt=O("$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]=new Set);for(const e of o.values)n[t].add(e)}}return n});const o=L,r=t.catchall;let i;e._zod.parse=(t,a)=>{i??(i=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=i.shape;for(const e of i.keys){const n=u[e],o="optional"===n._zod.optin,r="optional"===n._zod.optout,i=n._zod.run({value:s[e],issues:[]},a);i instanceof Promise?l.push(i.then(n=>Bt(n,t,e,s,o,r))):Bt(i,t,e,s,o,r)}return r?Yt(l,s,t,a,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Vt=O("$ZodObjectJIT",(e,t)=>{Wt.init(e,t);const n=e._zod.parse,o=P(()=>Jt(t));let r;const i=L,a=!z.jitless,s=a&&M.value,l=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=o.value);const p=c.value;return i(p)?a&&s&&!1===d?.async&&!0!==d.jitless?(r||(r=(e=>{const t=new lt(["shape","payload","ctx"]),n=o.value,r=e=>{const t=D(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let a=0;for(const o of n.keys)i[o]="key_"+a++;t.write("const newResult = {};");for(const o of n.keys){const n=i[o],a=D(o),s=e[o],l="optional"===s?._zod?.optin,u="optional"===s?._zod?.optout;t.write(`const ${n} = ${r(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=r(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 Ht(e,t,n,o){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const r=e.filter(e=>!H(e));return 1===r.length?(t.value=r[0].value,r[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=O("$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=>$(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(o,r)=>{if(n)return n(o,r);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>Ht(t,o,e,r)):Ht(a,o,e,r)}}),Kt=O("$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]=new Set);for(const o of n)e[t].add(o)}}return e});const o=P(()=>{const e=t.options,n=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=(r,i)=>{const a=r.value;if(!L(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback||"backward"===i.direction?n(r,i):(r.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}),r)}}),Xt=O("$ZodIntersection",(e,t)=>{ct.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,r=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([t,n])=>en(e,t,n)):en(e,r,i)}});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(Z(e)&&Z(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const i of o){const n=Qt(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};r[i]=n.data}return{valid:!0,data:r}}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 r=Qt(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function en(e,t,n){const o=new Map;let r;for(const s of t.issues)if("unrecognized_keys"===s.code){r??(r=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 i=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&r&&e.issues.push({...r,keys:i}),H(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=O("$ZodRecord",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Z(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=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:r[u],issues:[]},o);c instanceof Promise?i.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 r)s.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(r)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(r,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&&Me.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]=r[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:r[a],issues:[]},o);l instanceof Promise?i.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 i.length?Promise.all(i).then(()=>n):n}}),nn=O("$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,r)=>{const i=t.value;return o.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),on=O("$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,r)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),rn=O("$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 r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(e=>(n.value=e,n.fallback=!0,n));if(r instanceof Promise)throw new E;return n.value=r,n.fallback=!0,n}});function an(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var sn=O("$ZodOptional",(e,t)=>{ct.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=e.value,r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>an(e,o)):an(r,o)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),ln=O("$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=O("$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(`^(${$(e.source)}|null)$`):void 0}),R(e._zod,"values",()=>t.innerType._zod.values?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=O("$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=O("$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=O("$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 r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(t=>mn(t,e)):mn(r,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=O("$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=O("$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=O("$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(bn):bn(o)}});function bn(e){return e.value=Object.freeze(e.value),e}var vn,wn=O("$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,r=t.fn(o);if(r instanceof Promise)return r.then(t=>Sn(t,n,o,e));Sn(r,n,o,e)}});function Sn(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 kn=class{constructor(){this._map=new WeakMap,this._idmap=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=new WeakMap,this._idmap=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)}};(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=new kn);var On=globalThis.__zod_globalRegistry;function En(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...W(t)})}function xn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...W(t)})}function zn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...W(t)})}function Tn(e,t){return new We({check:"less_than",...W(t),value:e,inclusive:!1})}function An(e,t){return new We({check:"less_than",...W(t),value:e,inclusive:!0})}function In(e,t){return new Ve({check:"greater_than",...W(t),value:e,inclusive:!1})}function Pn(e,t){return new Ve({check:"greater_than",...W(t),value:e,inclusive:!0})}function Cn(e,t){return new He({check:"multiple_of",...W(t),value:e})}function $n(e,t){return new Ke({check:"max_length",...W(t),maximum:e})}function Nn(e,t){return new Xe({check:"min_length",...W(t),minimum:e})}function Rn(e,t){return new Qe({check:"length_equals",...W(t),length:e})}function Un(e){return new st({check:"overwrite",tx:e})}function qn(e,t){const n=new Je({check:"custom",...W(t)});return n._zod.check=e,n}function Dn(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:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function jn(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.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,i=t.processors[r.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);i(e,t,n,o)}const i=e._zod.parent;i&&(a.ref||(a.ref=i),jn(i,t,o),t.seen.get(i).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),"input"===t.io&&Zn(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 Ln(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=o.get(t);if(e&&e!==i[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,i[0])}}const r=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:r,defId:i}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,r=e.external.uri??(e=>e);if(n)return{ref:r(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${r("__shared")}#/${o}/${i}`}}if(t[1]===n)return{ref:"#"};const r=`#/${o}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:r+i}})(t);o.def={...o.schema},i&&(o.defId=i);const a=o.schema;for(const e in a)delete a[e];a.$ref=r};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[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 i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){r(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&r(i)}else r(i)}}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 r=n.def??n.schema,i={...r},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(r,s):(r.allOf=r.allOf??[],r.allOf.push(s)),Object.assign(r,i),t._zod.parent===a)for(const e in r)"$ref"!==e&&"allOf"!==e&&(e in i||delete r[e]);if(s.$ref&&n.def)for(const e in r)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(r[e])===JSON.stringify(n.def[e])&&delete r[e]}const s=t._zod.parent;if(s&&s!==a){o(s);const t=e.seen.get(s);if(t?.schema.$ref&&(r.$ref=t.schema.$ref,t.def))for(const e in r)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(r[e])===JSON.stringify(t.def[e])&&delete r[e]}e.override({zodSchema:t,jsonSchema:r,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const r={};if("draft-2020-12"===e.target?r.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?r.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?r.$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");r.$id=e.external.uri(n)}Object.assign(r,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&r.id===i&&delete r.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?r.$defs=a:r.definitions=a);try{const n=JSON.parse(JSON.stringify(r));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Fn(t,"input",e.processors),output:Fn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function Zn(e,t){const n=t??{seen: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 Zn(o.element,n);if("set"===o.type)return Zn(o.valueType,n);if("lazy"===o.type)return Zn(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 Zn(o.innerType,n);if("intersection"===o.type)return Zn(o.left,n)||Zn(o.right,n);if("record"===o.type||"map"===o.type)return Zn(o.keyType,n)||Zn(o.valueType,n);if("pipe"===o.type)return!!e._zod.traits.has("$ZodCodec")||(Zn(o.in,n)||Zn(o.out,n));if("object"===o.type){for(const e in o.shape)if(Zn(o.shape[e],n))return!0;return!1}if("union"===o.type){for(const e of o.options)if(Zn(e,n))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(Zn(e,n))return!0;return!(!o.rest||!Zn(o.rest,n))}return!1}var Fn=(e,t,n={})=>o=>{const{libraryOptions:r,target:i}=o??{},a=Dn({...r??{},target:i,io:t,processors:n});return jn(e,a),Ln(a,e),Mn(a,e)},Bn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jn=(e,t,n,o)=>{const r=e._zod.def;jn(r.innerType,t,o);t.seen.get(e).ref=r.innerType},Yn=O("ZodISODateTime",(e,t)=>{Ot.init(e,t),wo.init(e,t)});function Wn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...W(t)})}(Yn,e)}var Vn=O("ZodISODate",(e,t)=>{Et.init(e,t),wo.init(e,t)});function Hn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...W(t)})}(Vn,e)}var Gn=O("ZodISOTime",(e,t)=>{xt.init(e,t),wo.init(e,t)});function Kn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...W(t)})}(Gn,e)}var Xn=O("ZodISODuration",(e,t)=>{zt.init(e,t),wo.init(e,t)});function Qn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...W(t)})}(Xn,e)}var eo=(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,r=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>o({issues:e},[...r,...i.path]));else if("invalid_key"===i.code)o({issues:i.issues},[...r,...i.path]);else if("invalid_element"===i.code)o({issues:i.issues},[...r,...i.path]);else{const e=[...r,...i.path];if(0===e.length)n._errors.push(t(i));else{let o=n,r=0;for(;r<e.length;){const n=e[r];r!==e.length-1?o[n]=o[n]||{_errors:[]}:(o[n]=o[n]||{_errors:[]},o[n]._errors.push(t(i))),o=o[n],r++}}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));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}})},to=O("ZodError",eo,{Parent:Error}),no=ie(to),oo=ae(to),ro=se(to),io=ue(to),ao=de(to),so=pe(to),lo=fe(to),uo=me(to),co=_e(to),po=he(to),fo=ye(to),mo=ge(to),_o=new WeakMap;function ho(e,t,n){const o=Object.getPrototypeOf(e);let r=_o.get(o);if(r||(r=new Set,_o.set(o,r)),!r.has(t)){r.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 yo=O("ZodType",(e,t)=>(ct.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Fn(e,"input"),output:Fn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const o=Dn({...n,processors:t});return jn(e,o),Ln(o,e),Mn(o,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>no(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ro(e,t,n),e.parseAsync=async(t,n)=>oo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>io(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ao(e,t,n),e.decode=(t,n)=>so(e,t,n),e.encodeAsync=async(t,n)=>lo(e,t,n),e.decodeAsync=async(t,n)=>uo(e,t,n),e.safeEncode=(t,n)=>co(e,t,n),e.safeDecode=(t,n)=>po(e,t,n),e.safeEncodeAsync=async(t,n)=>fo(e,t,n),e.safeDecodeAsync=async(t,n)=>mo(e,t,n),ho(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)})}(xr,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=qn(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(Un(e))},optional(){return _r(this)},exactOptional(){return new hr({type:"optional",innerType:this})},nullable(){return gr(this)},nullish(){return _r(gr(this))},nonoptional(e){return function(e,t){return new wr({type:"nonoptional",innerType:e,...W(t)})}(this,e)},array(){return Qo(this)},or(e){return or([this,e])},and(e){return new ar({type:"intersection",left:this,right:e})},transform(e){return Or(this,new fr({type:"transform",transform:e}))},default(e){return t=e,new br({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},prefault(e){return t=e,new vr({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},catch(e){return new Sr({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Or(this,e)},readonly(){return new Er({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)),go=O("_ZodString",(e,t)=>{dt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n;o.type="string";const{minimum:r,maximum:i,format:a,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof r&&(o.minLength=r),"number"==typeof i&&(o.maxLength=i),a&&(o.format=Bn[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,ho(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 rt({check:"string_format",format:"includes",...W(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new it({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(Nn(...e))},max(...e){return this.check($n(...e))},length(...e){return this.check(Rn(...e))},nonempty(...e){return this.check(Nn(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(Un(e=>e.trim()))},normalize(...e){return this.check(function(e){return Un(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(Un(e=>e.toLowerCase()))},toUpperCase(){return this.check(Un(e=>e.toUpperCase()))},slugify(){return this.check(Un(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),bo=O("ZodString",(e,t)=>{dt.init(e,t),go.init(e,t),e.email=t=>e.check(En(So,t)),e.url=t=>e.check(zn(xo,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)})}(zo,t)),e.guid=t=>e.check(xn(Oo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}(Eo,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)})}(Eo,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)})}(Eo,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)})}(Eo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}(To,t)),e.guid=t=>e.check(xn(Oo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}(Ao,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}(Io,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}(Po,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}(Do,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}(jo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}(Co,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}($o,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}(No,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}(Ro,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}(Uo,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}(qo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}(Lo,t)),e.datetime=t=>e.check(Wn(t)),e.date=t=>e.check(Hn(t)),e.time=t=>e.check(Kn(t)),e.duration=t=>e.check(Qn(t))});function vo(e){return function(e,t){return new e({type:"string",...W(t)})}(bo,e)}var wo=O("ZodStringFormat",(e,t)=>{pt.init(e,t),go.init(e,t)}),So=O("ZodEmail",(e,t)=>{_t.init(e,t),wo.init(e,t)});function ko(e){return En(So,e)}var Oo=O("ZodGUID",(e,t)=>{ft.init(e,t),wo.init(e,t)}),Eo=O("ZodUUID",(e,t)=>{mt.init(e,t),wo.init(e,t)}),xo=O("ZodURL",(e,t)=>{ht.init(e,t),wo.init(e,t)});var zo=O("ZodEmoji",(e,t)=>{yt.init(e,t),wo.init(e,t)}),To=O("ZodNanoID",(e,t)=>{gt.init(e,t),wo.init(e,t)}),Ao=O("ZodCUID",(e,t)=>{bt.init(e,t),wo.init(e,t)}),Io=O("ZodCUID2",(e,t)=>{vt.init(e,t),wo.init(e,t)}),Po=O("ZodULID",(e,t)=>{wt.init(e,t),wo.init(e,t)}),Co=O("ZodXID",(e,t)=>{St.init(e,t),wo.init(e,t)}),$o=O("ZodKSUID",(e,t)=>{kt.init(e,t),wo.init(e,t)}),No=O("ZodIPv4",(e,t)=>{Tt.init(e,t),wo.init(e,t)}),Ro=O("ZodIPv6",(e,t)=>{At.init(e,t),wo.init(e,t)}),Uo=O("ZodCIDRv4",(e,t)=>{It.init(e,t),wo.init(e,t)}),qo=O("ZodCIDRv6",(e,t)=>{Pt.init(e,t),wo.init(e,t)}),Do=O("ZodBase64",(e,t)=>{$t.init(e,t),wo.init(e,t)}),jo=O("ZodBase64URL",(e,t)=>{Nt.init(e,t),wo.init(e,t)}),Lo=O("ZodE164",(e,t)=>{Rt.init(e,t),wo.init(e,t)}),Mo=O("ZodJWT",(e,t)=>{Ut.init(e,t),wo.init(e,t)}),Zo=O("ZodNumber",(e,t)=>{qt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:r,maximum:i,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>=(r??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(i??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 r&&(o.minimum=r),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof i&&(o.maximum=i),"number"==typeof s&&(o.multipleOf=s)})(e,t,n),ho(e,"ZodNumber",{gt(e,t){return this.check(In(e,t))},gte(e,t){return this.check(Pn(e,t))},min(e,t){return this.check(Pn(e,t))},lt(e,t){return this.check(Tn(e,t))},lte(e,t){return this.check(An(e,t))},max(e,t){return this.check(An(e,t))},int(e){return this.check(Jo(e))},safe(e){return this.check(Jo(e))},positive(e){return this.check(In(0,e))},nonnegative(e){return this.check(Pn(0,e))},negative(e){return this.check(Tn(0,e))},nonpositive(e){return this.check(An(0,e))},multipleOf(e,t){return this.check(Cn(e,t))},step(e,t){return this.check(Cn(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 Fo(e){return function(e,t){return new e({type:"number",checks:[],...W(t)})}(Zo,e)}var Bo=O("ZodNumberFormat",(e,t)=>{Dt.init(e,t),Zo.init(e,t)});function Jo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}(Bo,e)}var Yo=O("ZodBoolean",(e,t)=>{jt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Wo(e){return function(e,t){return new e({type:"boolean",...W(t)})}(Yo,e)}var Vo=O("ZodUnknown",(e,t)=>{Lt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Ho(){return new Vo({type:"unknown"})}var Go=O("ZodNever",(e,t)=>{Mt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Ko(e){return function(e,t){return new e({type:"never",...W(t)})}(Go,e)}var Xo=O("ZodArray",(e,t)=>{Ft.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(r.minItems=a),"number"==typeof s&&(r.maxItems=s),r.type="array",r.items=jn(i.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,ho(e,"ZodArray",{min(e,t){return this.check(Nn(e,t))},nonempty(e){return this.check(Nn(1,e))},max(e,t){return this.check($n(e,t))},length(e,t){return this.check(Rn(e,t))},unwrap(){return this.element}})});function Qo(e,t){return function(e,t,n){return new e({type:"array",element:t,...W(n)})}(Xo,e,t)}var er=O("ZodObject",(e,t)=>{Vt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",r.properties={};const a=i.shape;for(const u in a)r.properties[u]=jn(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(r.required=Array.from(l)),"never"===i.catchall?._zod.def.type?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=jn(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)})(e,t,n,o),R(e,"shape",()=>t.shape),ho(e,"ZodObject",{keyof(){return cr(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ho()})},loose(){return this.clone({...this._zod.def,catchall:Ho()})},strict(){return this.clone({...this._zod.def,catchall:Ko()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!Z(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(!Z(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,r={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(r[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)r[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return U(this,"shape",r),r},checks:[]}))}(mr,this,e[0])},required(...e){return t=wr,n=this,o=e[0],Y(n,q(n._zod.def,{get shape(){const e=n._zod.def.shape,r={...e};if(o)for(const n in o){if(!(n in r))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(r[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)r[n]=new t({type:"nonoptional",innerType:e[n]});return U(this,"shape",r),r}}));var t,n,o}})});function tr(e,t){const n={type:"object",shape:e??{},...W(t)};return new er(n)}var nr=O("ZodUnion",(e,t)=>{Gt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=!1===r.inclusive,a=r.options.map((e,n)=>jn(e,t,{...o,path:[...o.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function or(e,t){return new nr({type:"union",options:e,...W(t)})}var rr=O("ZodDiscriminatedUnion",(e,t)=>{nr.init(e,t),Kt.init(e,t)});function ir(e,t,n){return new rr({type:"union",options:t,discriminator:e,...W(n)})}var ar=O("ZodIntersection",(e,t)=>{Xt.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=jn(r.left,t,{...o,path:[...o.path,"allOf",0]}),a=jn(r.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]})(e,t,n,o)});var sr=O("ZodRecord",(e,t)=>{tn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if("loose"===i.mode&&s&&s.size>0){const e=jn(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const t of s)r.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(r.propertyNames=jn(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=jn(i.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&&(r.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function lr(e,t,n){return t&&t._zod?new sr({type:"record",keyType:e,valueType:t,...W(n)}):new sr({type:"record",keyType:vo(),valueType:e,...W(t)})}var ur=O("ZodEnum",(e,t)=>{nn.init(e,t),yo.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 r={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);r[i]=t.entries[i]}return new ur({...t,checks:[],...W(o),entries:r})},e.exclude=(e,o)=>{const r={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete r[t]}return new ur({...t,checks:[],...W(o),entries:r})}});function cr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ur({type:"enum",entries:n,...W(t)})}var dr=O("ZodLiteral",(e,t)=>{on.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,r=[];for(const i of o.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");r.push(Number(i))}else r.push(i);if(0===r.length);else if(1===r.length){const e=r[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),r.every(e=>"boolean"==typeof e)&&(n.type="boolean"),r.every(e=>null===e)&&(n.type="null"),n.enum=r})(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 pr(e,t){return new dr({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}var fr=O("ZodTransform",(e,t)=>{rn.init(e,t),yo.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 r=t.transform(n.value,n);return r instanceof Promise?r.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});var mr=O("ZodOptional",(e,t)=>{sn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function _r(e){return new mr({type:"optional",innerType:e})}var hr=O("ZodExactOptional",(e,t)=>{ln.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>Jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var yr=O("ZodNullable",(e,t)=>{un.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=jn(r.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function gr(e){return new yr({type:"nullable",innerType:e})}var br=O("ZodDefault",(e,t)=>{cn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;jn(r.innerType,t,o),t.seen.get(e).ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var vr=O("ZodPrefault",(e,t)=>{pn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;jn(r.innerType,t,o),t.seen.get(e).ref=r.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var wr=O("ZodNonOptional",(e,t)=>{fn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;jn(r.innerType,t,o),t.seen.get(e).ref=r.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var Sr=O("ZodCatch",(e,t)=>{_n.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;let i;jn(r.innerType,t,o),t.seen.get(e).ref=r.innerType;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var kr=O("ZodPipe",(e,t)=>{hn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=r.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?r.out:r.in:r.out;jn(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function Or(e,t){return new kr({type:"pipe",in:e,out:t})}var Er=O("ZodReadonly",(e,t)=>{gn.init(e,t),yo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;jn(r.innerType,t,o),t.seen.get(e).ref=r.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var xr=O("ZodCustom",(e,t)=>{wn.init(e,t),yo.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)});var zr,Tr=cr(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),Ar=cr(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),Ir=cr(["BROADCAST","AUTOMATION"]),Pr=cr(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),Cr=(tr({email:ko(),name:vo().trim().min(1).nullable().optional(),customer_id:vo().uuid().nullable().optional(),tags:Qo(vo().trim().min(1)).default([]),consent_basis:Tr.default("UNKNOWN"),source:vo().trim().min(1).default("dashboard")}),tr({name:vo().trim().min(1),subject:vo().trim().min(1),preheader:vo().nullable().optional(),mjml_source:vo().trim().min(1),builder_project_json:lr(vo(),Ho()).nullable().optional(),thumbnail_url:zn(xo,zr).nullable().optional()}),tr({mjml_source:vo().trim().min(1),sample_variables:lr(vo(),Ho()).optional()}),tr({recipient_email:ko(),sample_variables:lr(vo(),Ho()).optional()}),tr({marketing_enabled:Wo().optional(),default_from_name:vo().trim().min(1).nullable().optional(),default_from_email:ko().nullable().optional(),default_reply_to_email:ko().nullable().optional(),physical_address:vo().trim().min(1).nullable().optional(),physical_address_line2:vo().trim().min(1).nullable().optional(),physical_city:vo().trim().min(1).nullable().optional(),physical_postal_code:vo().trim().min(1).nullable().optional(),physical_country:vo().trim().length(2).nullable().optional(),daily_limit:Fo().int().positive().optional(),monthly_soft_cap:Fo().int().positive().optional()}),tr({type:Ir.default("BROADCAST"),name:vo().trim().min(1),subject:vo().trim().min(1),template_id:vo().uuid(),list_id:vo().uuid().nullable().optional(),segment_id:vo().uuid().nullable().optional(),from_name:vo().trim().min(1),from_email:ko(),reply_to_email:ko().nullable().optional(),schedule_at:vo().datetime().nullable().optional(),target_emails:Qo(ko()).max(0,"Direct recipient entry is disabled. Use lists or segments built from Shoppex customers and paid order buyers.").default([]),idempotency_key:vo().trim().min(1).nullable().optional()}),tr({name:vo().trim().min(1),subject:vo().trim().min(1),template_id:vo().uuid(),from_name:vo().trim().min(1),from_email:ko(),reply_to_email:ko().nullable().optional(),trigger:Pr,delay_seconds:Fo().int().min(0).default(0),conditions:lr(vo(),Ho()).default({})}),tr({trigger:Pr,email:ko(),customer_id:vo().uuid().nullable().optional(),name:vo().trim().min(1).nullable().optional(),consent_basis:Tr.default("UNKNOWN"),variables:lr(vo(),Ho()).default({}),idempotency_key:vo().trim().min(1).nullable().optional()}),tr({email:ko(),reason:Ar.default("ADMIN_BLOCK"),notes:vo().nullable().optional()}),["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"]),$r=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],Nr=["NOWPAYMENTS_WHITELABEL"],Rr={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"]},Ur=Object.keys(Rr),qr=[...Rr.USDT,...Rr.USDC,...Rr.DAI],Dr=[...Cr,...qr],jr=["BITCOIN_LN"],Lr=[...$r,...Nr],Mr=[...Dr,...jr],Zr=Dr,Fr=(new Set(["SHOPPEXPAY"]),new Set(Cr)),Br=new Set(qr),Jr=(new Set(Dr),new Set(jr),new Set($r),new Set(Nr),new Set(Lr),new Set(Mr),new Set(Ur),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","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Yr(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Yr("COIN_GATEWAY_KEYS",Cr),Yr("TOKEN_GATEWAY_KEYS",qr),Yr("CRYPTO_GATEWAY_KEYS",Dr),Yr("LEGACY_CRYPTO_GATEWAY_KEYS",jr),Yr("CRYPTO_PROVIDER_KEYS",$r),Yr("MANAGED_CRYPTO_PROVIDER_KEYS",Nr),Yr("CRYPTO_PROVIDER_GATEWAY_KEYS",Lr),Yr("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Zr),Yr("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"]),Yr("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 dc of Dr)if(!Fr.has(dc)&&!Br.has(dc))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${dc}`);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=>function(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"}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 Jr[n]??n}(e))),new Set(["WHITE_LABEL","NATIVE"]);var Wr=[...Lr,"NATIVE"],Vr=(new Set(Wr),tr({set:Wo()})),Hr=tr({status:cr(["READY","NEEDS_ATTENTION"]).optional(),code:vo().optional(),message:vo().optional(),checked_at:vo().optional()}),Gr=(tr({provider:vo(),type:vo(),enabled:Wo(),connected:Wo(),credentials:lr(vo(),Vr),public_config:lr(vo(),Ho()),webhook:lr(vo(),Ho()).optional(),health:Hr.optional()}),"#2563eb"),Kr=["comfortable","compact"],Xr=["top","side","background"],Qr=cr(["checkout","payment_link","embed"]),ei=cr(["current","clean-light","clean-dark","v2","v3"]),ti=cr(Kr),ni=cr(["light","dark","system"]),oi=cr(Xr),ri=cr(["ghost","outlined","filled"]),ii=cr(["sheet","fullscreen","center"]),ai=cr(["visible","hidden"]),si=(cr(["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"]),cr(["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"]),vo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),li=vo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),ui=vo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),ci=cr(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),di=vo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),pi=vo().url(),fi=tr({brand:tr({logoUrl:pi.optional().nullable(),logoDarkUrl:pi.optional().nullable(),logoMaxHeight:Fo().int().min(16).max(80).optional(),faviconUrl:pi.optional().nullable()}).strict().optional(),color:tr({brand:si.optional(),brandContrast:si.optional(),background:si.optional(),surface:si.optional(),surfaceRaised:si.optional(),text:si.optional(),textMuted:si.optional(),border:si.optional(),focus:si.optional(),success:si.optional(),warning:si.optional(),error:si.optional()}).strict().optional(),typography:tr({fontFamily:ci.optional(),googleFontFamily:di.optional(),baseSize:Fo().int().min(12).max(18).optional()}).strict().optional(),shape:tr({buttonRadius:Fo().int().min(0).max(24).optional(),inputRadius:Fo().int().min(0).max(24).optional(),cardRadius:Fo().int().min(0).max(28).optional()}).strict().optional(),spacing:tr({density:ti.optional(),controlHeight:Fo().int().min(36).max(56).optional()}).strict().optional(),component:tr({primaryButton:tr({background:si.optional(),text:si.optional()}).strict().optional(),input:tr({background:si.optional(),border:si.optional(),focusRing:li.optional()}).strict().optional(),summary:tr({background:si.optional()}).strict().optional(),paymentMethod:tr({background:li.optional(),cardBackground:li.optional(),border:li.optional(),selectedBackground:li.optional()}).strict().optional(),productCard:tr({background:li.optional(),border:li.optional(),shadow:ui.optional()}).strict().optional(),productImage:tr({background:li.optional(),border:li.optional(),icon:li.optional()}).strict().optional(),brandAvatar:tr({background:li.optional(),text:si.optional(),border:li.optional()}).strict().optional(),pill:tr({background:li.optional(),border:li.optional(),text:si.optional()}).strict().optional(),errorBanner:tr({background:li.optional(),border:li.optional(),text:si.optional()}).strict().optional(),warningBanner:tr({background:li.optional(),border:li.optional(),text:si.optional()}).strict().optional(),radio:tr({idleRing:li.optional(),checkedFill:si.optional(),checkedIcon:si.optional()}).strict().optional(),divider:tr({color:li.optional()}).strict().optional()}).strict().optional(),paymentLink:tr({heroImageUrl:pi.optional().nullable(),heroPosition:oi.optional()}).strict().optional(),embed:tr({launcher:tr({background:li.optional(),text:si.optional(),radius:Fo().int().min(0).max(28).optional(),paddingX:Fo().int().min(8).max(32).optional(),paddingY:Fo().int().min(6).max(24).optional(),shadow:ui.optional()}).strict().optional(),productCard:tr({background:li.optional(),border:li.optional(),imageRadius:Fo().int().min(0).max(24).optional(),padding:Fo().int().min(8).max(32).optional()}).strict().optional(),cart:tr({background:li.optional(),rowBorder:li.optional(),itemSpacing:Fo().int().min(4).max(28).optional()}).strict().optional(),modal:tr({background:li.optional(),radius:Fo().int().min(0).max(32).optional(),maxWidth:Fo().int().min(360).max(960).optional(),shadow:ui.optional()}).strict().optional(),backdrop:tr({color:li.optional(),blur:Fo().int().min(0).max(24).optional(),opacity:Fo().min(0).max(1).optional()}).strict().optional(),skeleton:tr({background:li.optional(),shimmer:li.optional()}).strict().optional(),spinner:tr({color:li.optional()}).strict().optional(),closeButton:tr({style:ri.optional()}).strict().optional(),mobile:tr({layout:ii.optional()}).strict().optional(),content:tr({productDescription:ai.optional(),termsShortcut:ai.optional()}).strict().optional()}).strict().optional()}).strict(),mi=tr({mode:ni.default("system"),fontSource:cr(["curated"]).default("curated")}).strict(),_i=cr(["standalone","bundle","pointer"]),hi=tr({name:vo().trim().min(1).max(80),fingerprint:vo().trim().min(1).max(128)}).strict(),yi=tr({type:pr("shoppex.style_theme"),surface:pr("checkout"),format_version:or([pr(1),pr(2)]),name:vo().trim().min(1).max(80),description:vo().trim().max(240).optional(),embed_design:ei.default("current"),token_schema_version:pr(1),tokens:fi.default({}),custom_css:vo().max(2e4).default(""),settings:mi.default({mode:"system",fontSource:"curated"}),_meta:lr(vo(),Ho()).optional()}).strict(),gi=(tr({type:pr("shoppex.style_theme"),surface:Qr,format_version:or([pr(1),pr(2)]),name:vo().trim().min(1).max(80),description:vo().trim().max(240).optional(),embed_design:ei.default("current"),token_schema_version:pr(1),tokens:fi.default({}),custom_css:vo().max(2e4).default(""),settings:mi.default({mode:"system",fontSource:"curated"}),share_mode:_i.default("standalone"),parent_hint:hi.optional(),bundled_parent:yi.optional(),_meta:lr(vo(),Ho()).optional()}).strict(),tr({theme_id:vo().uuid().nullable(),surface:Qr,embed_design:ei,token_schema_version:pr(1),revision:Fo().int().min(1),tokens:fi,custom_css:vo(),css_variables:lr(vo(),vo())}).strict(),tr({theme_id:vo().uuid().nullable(),parent_theme_id:vo().uuid().nullable(),surface:pr("embed"),embed_design:ei,token_schema_version:pr(1),revision:Fo().int().min(1),parent_revision:Fo().int().min(1).nullable(),tokens:fi,custom_css:vo(),css_variables:lr(vo(),vo())}).strict(),tr({shop_id:vo().uuid(),product_id:vo().uuid().nullable(),product_group_id:vo().uuid().nullable(),payment_link_id:vo().uuid().nullable(),invoice_id:vo().nullable()}).strict(),tr({embed_runtime:vo().min(16).max(128),embed_design:ei,revision:Fo().int().min(1),parent_revision:Fo().int().min(1).nullable(),theme_id:vo().uuid().nullable(),css_variables:lr(vo(),vo()),custom_css:vo()}).strict(),tr({embed_design:ei.optional(),embed_style_revision:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}(Zo,e)}().int().min(1).optional(),embed_runtime:vo().min(16).max(128).optional(),preview:Wo().optional()}).strict(),cr(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),cr(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),bi=(cr(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),vo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),vi=cr(["static","marquee"]),wi=cr(["brand_blue","emerald","sunset","rose","charcoal","custom"]),Si=cr(["hide","message"]),ki=cr(["compact","comfortable"]),Oi=cr(["subtle","outline","solid"]),Ei=cr(["minimal","boxed"]),xi=cr(["indigo","emerald","amber","rose","slate","custom"]),zi=cr(["compact","feature","alert"]),Ti=cr(["compact","comfortable"]),Ai=cr(["subtle","outline","solid"]),Ii=cr(["sparkles","megaphone","gift","truck","shield","support","none"]),Pi=cr(["show","hide"]),Ci=cr(["midnight","ocean","ember","forest","custom"]),$i=cr(["delay","exit_intent"]),Ni=vo().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 "/"'),Ri=vo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Ui=tr({text:vo().trim().min(1,"Text is required").max(160,"Text must be 160 characters or fewer"),linkLabel:vo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Ni.optional().nullable(),dismissible:Wo().default(!1),displayMode:vi.default("marquee"),themePreset:wi.default("custom"),animationSpeedSeconds:Fo().int().min(8).max(40).default(30),backgroundColor:bi.default("#111827"),textColor:bi.default("#f9fafb")}),qi=tr({text:vo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Ri,linkLabel:vo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Ni.optional().nullable(),dismissible:Wo().default(!1),themePreset:wi.default("brand_blue"),expiredBehavior:Si.default("hide"),expiredMessage:vo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:ki.default("compact"),ctaStyle:Oi.default("subtle"),timerStyle:Ei.default("boxed"),backgroundColor:bi.default("#111827"),textColor:bi.default("#f9fafb")}),Di=tr({eyebrow:vo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:vo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:vo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),linkLabel:vo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Ni.optional().nullable(),themePreset:xi.default("indigo"),layoutStyle:zi.default("feature"),density:Ti.default("comfortable"),ctaStyle:Ai.default("outline"),icon:Ii.default("sparkles"),iconVisibility:Pi.default("show"),backgroundColor:bi.default("#111827"),textColor:bi.default("#f9fafb"),accentColor:bi.default("#818cf8")}),ji=tr({title:vo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer").default("Recent purchases"),lookbackHours:Fo().int().min(1).max(168).default(24),cooldownSeconds:Fo().int().min(5).max(300).default(20),maxItems:Fo().int().min(1).max(20).default(8),anonymizeMode:cr(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:Qo(vo().min(1)).max(50).default([])}),Li=tr({eyebrow:vo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:vo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:vo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),couponCode:vo().trim().min(2,"Coupon code is required").max(40,"Coupon code must be 40 characters or fewer"),primaryButtonLabel:vo().trim().min(1,"Primary button label is required").max(24,"Primary button label must be 24 characters or fewer").default("Copy code"),secondaryButtonLabel:vo().trim().min(1,"Secondary button label is required").max(24,"Secondary button label must be 24 characters or fewer").default("Maybe later"),disclaimer:vo().trim().max(100,"Disclaimer must be 100 characters or fewer").optional().nullable(),themePreset:Ci.default("midnight"),trigger:$i.default("delay"),delaySeconds:Fo().int().min(0).max(60).default(6),showOncePerSession:Wo().default(!0),reminderHours:Fo().int().min(1).max(720).default(24),backgroundColor:bi.default("#111827"),textColor:bi.default("#f8fafc"),accentColor:bi.default("#7c9cff"),heroImageUrl:Ni.optional().nullable(),discountDisplay:vo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Ri.optional().nullable()}),Mi=cr(["hidden","optional"]),Zi=tr({headline:vo().trim().min(1,"Headline is required").max(60,"Headline must be 60 characters or fewer").default("Chat with us"),greeting:vo().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:vo().trim().min(1,"Placeholder is required").max(80,"Placeholder must be 80 characters or fewer").default("Type your message…"),contactFields:Mi.default("optional"),accentColor:bi.default("#111827"),launcherIconColor:bi.default("#f9fafb")}),Fi=tr({type:pr("announcement_bar"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:Ui}),Bi=tr({type:pr("recent_purchase_popup"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:ji}),Ji=tr({type:pr("countdown_bar"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:qi}),Yi=tr({type:pr("promo_info_card"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:Di}),Wi=tr({type:pr("coupon_popup_modal"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:Li}),Vi=tr({type:pr("live_chat"),slot:gi,enabled:Wo().default(!0),sortOrder:Fo().int().min(0).max(999).default(0),config:Zi}),Hi=(ir("type",[Fi,Ji,Yi,Bi,Wi,Vi]),ir("type",[Fi.extend({id:vo().min(1)}),Ji.extend({id:vo().min(1)}),Yi.extend({id:vo().min(1)}),Bi.extend({id:vo().min(1)}),Wi.extend({id:vo().min(1)}),Vi.extend({id:vo().min(1)})]),new Set(["amount","currency","invoice_id","customer_email","id","email","price","price_usd","product_name","quantity"].map(e=>e.toLowerCase())),lr(vo(),Ho())),Gi=or([vo(),Fo()]),Ki=tr({kind:cr(["address","redirect","embed_pending"]),gateway:vo(),checkout_url:vo().nullable().optional(),address:vo().optional(),amount:vo().optional(),qr_code:vo().optional(),expires_at:vo().optional(),payment_id:vo().optional(),confirmations_needed:Fo().optional()}).passthrough(),Xi=tr({default_value:vo().optional(),min_length:Fo().optional(),name:vo(),placeholder:vo().optional(),regex:vo().optional(),required:Wo(),type:vo()}),Qi=tr({id:vo(),price:Fo(),quantity:Fo(),title:vo()}),ea=tr({currency:vo(),description:vo(),id:vo(),price:Fo(),title:vo(),uniqid:vo()}),ta=tr({addons:Qo(Qi).optional(),available_addons:Qo(Ho()).optional(),cloudflare_image_id:vo().nullable(),created_at:vo().optional(),currency:vo(),custom_fields:Hi.nullable().optional(),custom_fields_config:Qo(Xi).nullable().optional(),delivery_instruction:Ho().optional(),delivery_instruction_config:Ho().optional(),delivery_instruction_label:Ho().optional(),delivery_text:vo().nullable().optional(),delivery_time:Fo().nullable().optional(),delivery_time_unit:cr(["minutes","hours","days"]).nullable().optional(),description:vo().nullable(),discount_percent:Fo().optional(),discount_display:Fo().optional(),discounted_total_display:Fo().optional(),gateways:Qo(vo()).nullable().optional(),id:vo().optional(),image_name:vo().nullable(),image_storage:vo().nullable().optional(),line_item_id:vo().nullable().optional(),pay_what_you_want:Wo().optional(),price:vo().optional(),price_display:Gi,quantity:Fo(),quantity_max:Fo().optional(),quantity_min:Fo().optional(),recurring_interval:vo().nullable().optional(),recurring_interval_count:Fo().nullable().optional(),redirect_link:vo().nullable().optional(),redirect_time:Fo().nullable().optional(),service_text:vo().nullable().optional(),setup_cost:vo().optional(),slug:vo().nullable().optional(),storefront_url:vo().nullable().optional(),status:vo().nullable().optional(),subtype:vo().nullable().optional(),terms_of_service:vo().nullable().optional(),title:vo(),total:Fo(),trial_period:Fo().nullable().optional(),type:vo().nullable().optional(),uniqid:vo().nullable(),unit_price:Fo().optional(),unit_price_display:Gi.optional(),unit_quantity:Fo(),updated_at:vo().optional(),variant_title:vo().nullable().optional(),video_link:vo().nullable().optional(),volume_discounts:Ho().optional(),warranty_days:Fo().nullable().optional(),warranty_text:vo().nullable().optional()}),na=tr({amount:Fo(),gateway:vo()}),oa=tr({custom_tip_enabled:Wo().optional(),enabled:Wo(),preset_percentages:Qo(Fo()).optional()}),ra=tr({allow_partial_payment:Wo().optional(),auto_apply:Wo().optional(),available:vo(),currency:vo()}),ia=tr({affiliate_code:vo().nullable().optional(),already_paid:Gi.nullable().optional(),amount_due:Gi.nullable().optional(),currency:vo().nullable().optional(),discount:Gi.nullable().optional(),discount_label:vo().nullable().optional(),gateway_fee:Gi.nullable().optional(),platform_fee:Gi.nullable().optional(),subtotal:Gi.nullable().optional(),tip:Gi.nullable().optional(),total:Gi.nullable().optional()}),aa=tr({active:Wo(),expires_at:vo()}),sa=tr({faq_url:vo().nullable(),support_email:vo().nullable(),support_url:vo().nullable(),telegram_invite:vo().nullable(),discord_invite_url:vo().nullable()}),la=tr({currency:vo().nullable().optional(),enabled:Wo(),max_amount:Fo().nullable().optional(),min_amount:Fo().nullable().optional(),reason:cr(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),ua=tr({delivered_items:Qo(Ho()),downloads:Qo(Ho()),external_urls:Qo(Ho()),license_keys:Qo(Ho()),tracking_codes:Qo(Ho())}),ca=tr({active:Wo().optional(),attempt_id:vo().optional(),buyer_actionable:Wo().nullable().optional(),crypto_currency:vo().nullable().optional(),currency:vo().optional(),expected_amount:vo().nullable().optional(),expected_crypto_amount:vo().nullable().optional(),last_checked_at:vo().optional(),missing_amount:vo().nullable().optional(),missing_crypto_amount:vo().nullable().optional(),provider_reference:vo().nullable().optional(),provider_status:vo().nullable().optional(),received_amount:vo().nullable().optional(),received_fiat_estimate:vo().nullable().optional(),received_crypto_amount:vo().nullable().optional(),shortfall_percent:vo().nullable().optional(),buyer_action_reason:cr(["BELOW_MINIMUM_COLLECTIBLE","PROVIDER_SESSION_CLOSED","PROVIDER_TOP_UP_UNSUPPORTED","MERCHANT_REVIEW_REQUIRED"]).nullable().optional()}),da=tr({created_at:vo().nullable(),details:vo().nullable(),id:vo(),invoice_id:vo(),status:vo().nullable()}),pa=tr({billing_address_mode:cr(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:vo().nullable().optional(),display_name:vo().nullable().optional(),gateway:vo(),hide_provider_attribution:Wo().optional(),icon_url:vo().nullable().optional(),terms_mode:cr(["INHERIT","REQUIRED","DISABLED"]).optional()}),fa=tr({custom_fields:Qo(Ho()).optional(),description:vo().nullable(),display_order:Fo(),icon_preset:vo().nullable(),icon_url:vo().nullable(),id:vo(),instructions:vo().nullable(),is_active:Wo().optional(),name:vo(),payment_type:cr(["INSTRUCTIONS","REDIRECT"]),redirect_url:vo().nullable(),require_proof:Wo(),proof_type:cr(["TEXT","IMAGE","BOTH"]).optional(),void_after_hours:Fo()}),ma=tr({email:tr({masked:vo().nullable(),persisted:Wo(),required_for_provider_session:Wo().optional()})}),_a=tr({amount:vo().nullable(),confirmations:Fo().nullable(),created_at:Fo().optional(),hash:vo().nullable(),status:vo().optional()}),ha=tr({conf:tr({partial:Fo().optional(),void:Fo(),waiting_for_confirmations:Fo().optional()}),gateways:Qo(vo())}),ya=tr({invoice_payable:Wo(),resumable:Wo(),resumable_gateway:vo().nullable(),gateway:vo().nullable().optional(),crypto_gateway:vo().nullable().optional(),processor:vo().nullable().optional(),flow_type:vo().nullable().optional(),status:vo().nullable().optional(),provider_reference:vo().nullable().optional(),provider_reference_type:vo().nullable().optional(),capture_id:vo().nullable().optional(),manual_confirmation_pending:Wo().optional(),payment_method_switch_locked:Wo().optional(),awaiting_payment_method:Wo().optional(),started_at:Fo().nullable().optional(),completed_at:Fo().nullable().optional()}),ga=ya.extend({gateway:vo().nullable(),flow_type:vo().nullable(),status:vo().nullable(),manual_confirmation_pending:Wo(),payment_method_switch_locked:Wo()}),ba=tr({theme_id:vo().nullable(),surface:cr(["checkout","payment_link","embed"]),embed_design:cr(["current","clean-light","clean-dark","v2","v3"]),token_schema_version:pr(1),revision:Fo(),tokens:Hi,custom_css:vo(),css_variables:lr(vo(),vo())}),va=tr({link_id:vo(),source_gateway:vo().nullable(),invoice_uniqid:vo(),deprioritize_source_gateway:Wo().optional()}),wa=tr({enabled:Wo(),required:Wo(),connected:Wo()}),Sa=tr({gateway:vo().nullable().optional(),active_type:vo().nullable().optional(),percent_amount:Gi.nullable().optional(),fixed_amount:Gi.nullable().optional(),fixed_currency:vo().nullable().optional()}),ka=tr({id:vo(),type:cr(["WALLET_CREDIT","COUPON"]),status:cr(["PENDING","FULFILLED","FAILED","REVOKED"]),amount:vo().nullable(),currency:vo().nullable(),coupon_code:vo().nullable(),reason:cr(["ORDER_COMPLETED","ORDER_COUNT_REACHED","SPEND_AMOUNT_REACHED","POSITIVE_REVIEW_LEFT","FIRST_PURCHASE_COMPLETED"]),trigger_reference_type:vo(),trigger_reference_id:vo(),created_at:Fo(),fulfilled_at:Fo().nullable(),expires_at:Fo().nullable()}),Oa=tr({summary:tr({available:vo(),pending:vo(),lifetime_earned:vo(),redeemed:vo().nullable(),currency:vo()}),activity:Qo(ka),earned_after_invoice:Qo(ka),pending_after_invoice:Qo(ka)}),Ea=tr({already_paid_amount:Gi.nullable().optional(),apm_method:vo().nullable().optional(),blockchain:vo().nullable(),buyer_identity:ma.nullable().optional(),checkout_tipping:oa.nullable().optional(),country_regulations:vo().nullable().optional(),coupon_applied:Wo().optional(),crypto_mode:vo().nullable().optional(),crypto_transactions:Qo(_a).optional(),currency:vo().nullable(),custom_fields:Hi.nullable().optional(),custom_gateways:Qo(fa).optional(),customer_balance:ra.nullable().optional(),customer_email_masked:vo().nullable().optional(),dark_mode:or([pr(0),pr(1)]).optional(),delivery:ua.optional(),delivery_info:ua.optional(),discount:Fo().optional(),discount_display:Gi.optional(),eligible_gateways:Qo(vo()).optional(),environment:vo().optional(),fee_breakdown:Hi.nullable().optional(),gateway:vo().nullable(),gateway_data:Hi.nullable().optional(),gateway_eligibility:lr(vo(),la).optional(),gateway_fee_previews:Qo(na).optional(),gateways_available:Qo(vo()),license:or([Hi,pr(!1)]).optional(),name:vo().nullable(),paddle_token:vo().nullable().optional(),paddle_transaction_id:Ho().optional(),payment_link_id:vo().nullable().optional(),payment_method_overrides:Qo(pa).optional(),payment_session_state:ya.nullable().optional(),polling:aa,pricing_breakdown:ia.nullable().optional(),product:Qo(ta).optional(),quantity:Fo().nullable(),rates_snapshot:lr(vo(),Fo()).optional(),remaining_amount:Gi.nullable().optional(),selected_gateway:vo().nullable().optional(),shop_checkout_ambient_color:vo().nullable().optional(),shop_cloudflare_image_id:vo().nullable(),shop_domain:vo().nullable().optional(),shop_force_paypal_email_delivery:or([pr(0),pr(1)]).optional(),shop_image_name:vo().nullable(),shop_image_storage:vo().nullable().optional(),shop_payment_gateways_fees:Qo(Hi).optional(),shop_paypal_credit_card:or([pr(0),pr(1)]).optional(),shop_return_url:vo().nullable().optional(),shop_slug:vo().nullable().optional(),shop_terms_enabled:Wo().optional(),shop_terms_of_service:vo().nullable().optional(),shop_terms_url:vo().nullable().optional(),shop_privacy_policy_url:vo().nullable().optional(),shop_refund_policy_url:vo().nullable().optional(),shop_walletconnect_id:vo().nullable().optional(),status:vo().nullable(),status_history:Qo(da).optional(),status_history_legacy:Qo(da).optional(),status_history_raw:Qo(da).optional(),stripe_publishable_key:vo().nullable().optional(),stripe_user_id:vo().nullable().optional(),subtotal:Fo().optional(),subtype:vo().nullable().optional(),support:sa.optional(),theme:vo().optional(),tip_amount:Gi.nullable().optional(),tip_amount_display:Gi.nullable().optional(),tip_metadata:Ho().optional(),total:Gi,total_conversions:Hi.optional(),total_display:Gi,type:vo().nullable(),underpayment:ca.nullable().optional(),underpayment_status:vo().nullable().optional(),uniqid:vo(),void_times:Qo(ha).optional(),addons:Ho().optional(),affiliate_data:Ho().optional(),affiliate_revenue_customer_id:vo().nullable().optional(),bill_info:Ho().optional(),binance_checkout_url:vo().nullable().optional(),binance_invoice_id:vo().nullable().optional(),binance_qrcode:vo().nullable().optional(),bundle_config:Ho().optional(),bundles:Ho().optional(),cashapp_cashtag:vo().nullable().optional(),cashapp_note:vo().nullable().optional(),cashapp_qrcode:vo().nullable().optional(),created_at:vo().optional(),crypto_address:vo().nullable().optional(),crypto_amount:Gi.optional(),crypto_confirmations_needed:Fo().nullable().optional(),crypto_exchange_rate:Gi.nullable().optional(),crypto_received:Gi.optional(),crypto_uri:vo().nullable().optional(),developer_invoice:Ho().optional(),developer_return_url:vo().nullable().optional(),developer_title:vo().nullable().optional(),exchange_rate:Gi.nullable().optional(),external_order_id:vo().nullable().optional(),lex_order_id:vo().nullable().optional(),lex_payment_method:vo().nullable().optional(),paydash_payment_id:vo().nullable().optional(),paypal_apm:vo().nullable().optional(),paypal_email_delivery:Wo().optional(),paypal_fee:Gi.nullable().optional(),paypal_order_id:vo().nullable().optional(),paypal_payer_email:vo().nullable().optional(),paypal_subscription_id:vo().nullable().optional(),paypal_subscription_link:vo().nullable().optional(),perfectmoney_id:vo().nullable().optional(),product_addons:Ho().optional(),product_id:vo().nullable().optional(),product_title:vo().nullable().optional(),product_type:vo().nullable().optional(),product_variants:Ho().optional(),recurring_billing_id:vo().nullable().optional(),skrill_link:vo().nullable().optional(),skrill_sid:vo().nullable().optional(),status_details:Ho().optional(),stripe_apm:vo().nullable().optional(),stripe_client_secret:vo().nullable().optional(),stripe_id:vo().nullable().optional(),stripe_price_id:vo().nullable().optional(),subscription:Ho().optional(),subscription_id:vo().nullable().optional(),sumup_id:vo().nullable().optional(),telegram_stars_payment_link:vo().nullable().optional(),telegram_stars_payment_note:vo().nullable().optional(),updated_at:vo().optional(),virtual_payments_id:vo().nullable().optional(),void_details:Ho().optional()}).catchall(Ho()),xa=ta.extend({available_addons:Qo(ea).optional(),delivery_instructions:vo().nullable().optional(),delivery_instructions_config:tr({enabled:pr(!0),required:Wo(),label:vo(),placeholder:vo().nullable().optional(),help_text:vo().nullable().optional(),max_length:Fo()}).nullable().optional(),delivery_instructions_label:vo().nullable().optional(),image_url:vo().nullable().optional(),redirectLink:vo().nullable().optional(),redirectTime:Fo().nullable().optional(),serviceText:vo().nullable().optional()}),za=(tr({data:tr({invoice:Ea.extend({uniqid:vo().uuid(),shop_id:or([vo(),Fo()]).nullable(),customer_email:vo().nullable(),checkout_style:ba.nullable().optional(),coupon_id:vo().nullable().optional(),discount_breakdown:Hi.nullable().optional(),affiliate_code:vo().nullable().optional(),country:vo().nullable().optional(),paypal_email:vo().nullable().optional(),pandabase_available_payment_methods:Qo(vo()).optional(),payment_rescue:va.nullable().optional(),discord_integration:wa.nullable().optional(),payment_session_state:ga.nullable().optional(),shop_payment_gateways_fees:Qo(Sa).optional(),product:Qo(xa).optional(),products:Qo(xa).optional(),rewards:Oa.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:vo().nullable(),checkout_url:vo().nullable(),selected_gateway:vo().nullable(),session_started:Wo(),payment_session:Ki.nullable(),completion_access_grant:vo().nullable()}).passthrough()}).passthrough(),{maximumFractionDigits:3});function Ta(e){if(!Number.isFinite(e))return e;const t=e<0?-1:1,n=Aa(Math.abs(e),2),o=Math.round(n);return 0===o?0:t*Aa(o,-2)}function Aa(e,t){const[n,o="0"]=String(e).split("e");return Number(`${n}e${Number(o)+t}`)}var Ia=vo().nullable(),Pa=lr(vo(),Ho()),Ca=tr({logo_url:Ia,primary_color:vo(),secondary_color:vo(),accent_color:vo()}),$a=tr({attachment_image_id:tr({cloudflare_image_id:Ia}).nullable()}),Na=tr({attachment_imageId:tr({cloudflareImageId:Ia}).nullable()}),Ra=tr({uniqid:vo(),status:vo(),total:vo(),total_display:Ia,currency:vo(),created_at:vo(),line_items:Qo(tr({product_title:Ia,quantity:Fo(),product:$a.nullable()}))}),Ua=tr({uniqid:vo(),status:vo(),total:vo(),totalDisplay:Ia,currency:vo(),createdAt:vo(),lineItems:Qo(tr({productTitle:Ia,quantity:Fo(),product:Na.nullable()}))}),qa=tr({invoices:Qo(Ua),pagination:tr({page:Fo(),limit:Fo(),total:Fo(),has_more:Wo()})}),Da=tr({gateway:vo(),displayName:Ia,cryptoGateway:Ia.optional(),blockchain:Ia,cryptoAddress:Ia,apmMethod:Ia}),ja=tr({id:vo(),uniqid:vo(),status:vo(),statusDetails:Ia,total:vo(),totalDisplay:Ia,subtotal:vo(),discount:vo(),discountDisplay:Ia,tax:vo(),taxPercentage:vo(),currency:vo(),createdAt:vo(),updatedAt:vo(),gatewayUpdatedAt:Ia,customFields:Pa.nullable(),balancePaidAmount:vo(),currentPaymentAttemptId:Ia,lineItems:Qo(tr({id:vo(),productTitle:vo(),productType:vo(),variantTitle:Ia,unitPrice:vo(),quantity:Fo(),total:vo(),deliveryText:Ia,deliverySummary:tr({codes:Qo(vo()),links:Qo(tr({label:vo(),value:vo(),href:Ia.optional()})),notes:Qo(vo()),serials:Qo(tr({value:vo(),is_replacement:Wo(),is_replaced:Wo()}))}).nullable(),deliveredAt:Ia,deliveryStatus:cr(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:Pa.nullable(),product:tr({uniqid:vo(),slug:Ia,serviceText:Ia,attachment_imageId:tr({cloudflareImageId:Ia}).nullable()}).nullable()})),currentPayment:Da.nullable(),payments:Qo(Da)}),La=(tr({quote:tr({enabled:Wo(),currency:vo(),min_amount:vo(),max_amount:Ia,bonus_tiers:Qo(tr({min_amount:vo(),bonus_percent:Fo()}))})}),tr({invoice_id:vo(),url:vo()}),tr({id:vo(),type:vo(),status:vo(),amount:Ia,currency:Ia,coupon_code:Ia,reason:vo(),trigger_reference_type:vo(),trigger_reference_id:vo(),created_at:Fo(),fulfilled_at:Fo().nullable(),expires_at:Fo().nullable()})),Ma=tr({summary:tr({available:vo(),pending:vo(),lifetime_earned:vo(),redeemed:Ia,currency:vo()}),activity:Qo(La),earned_after_invoice:Qo(La),pending_after_invoice:Qo(La)}),Za=tr({id:vo(),uniqid:vo(),label:Ia,code:vo(),url:Ia,status:cr(["pending","active","inactive","rejected"]),is_primary:Wo(),total_clicks:Fo(),total_sales:Fo(),total_revenue:vo(),is_active:Wo(),is_approved:Wo(),requested_affiliate_revenue_percent:Fo().nullable(),requested_affiliate_customer_discount_percent:Fo().nullable(),affiliate_revenue_percent_override:Fo().nullable(),affiliate_customer_discount_percent_override:Fo().nullable(),effective_commission_percent:Fo(),effective_customer_discount_percent:Fo(),commission_shareback_percent:Fo(),commission_shareback_enabled:Wo(),max_commission_shareback_percent:Fo(),created_at:Ia,updated_at:Ia}),Fa=tr({customer:tr({id:vo(),email:vo(),name:Ia}).nullable(),state:vo(),can_create_custom_links:Wo(),custom_link_request_disabled_reason:Ia,custom_links_require_approval:Wo(),affiliate_codes_accepted_at_checkout:Wo(),cash_payout_enabled:Wo(),links:Qo(Za),preferred_payout:tr({asset:vo(),network:vo(),address:vo()}).nullable(),balance_currency:vo(),balances:tr({pending:vo(),available:vo(),requested:vo(),converted:vo(),paid:vo(),approved_total:vo()}),commissions:Qo(tr({id:vo(),invoice_id:vo(),commission_amount:vo(),base_amount:vo(),discount_amount:vo(),status:vo(),created_at:Ia,paid_at:Ia,converted_at:Ia})),claims:Qo(tr({id:vo(),type:vo(),status:vo(),amount:vo(),currency:vo(),allocations:Qo(tr({source_type:vo(),commission_id:Ia,adjustment_id:Ia,amount:vo()})),wallet_transaction_id:Ia,payout_asset:Ia,payout_network:Ia,payout_address:Ia,note:Ia,metadata:Ho(),completed_at:Ia,rejected_at:Ia,cancelled_at:Ia,created_at:Ia,updated_at:Ia}))}),Ba=tr({uniqid:vo(),status:vo(),gateway:vo(),current_period_start:vo(),current_period_end:vo(),trial_end:Ia,cancel_at_period_end:Wo(),canceled_at:Ia,created_at:vo(),plan:tr({id:vo(),uniqid:vo(),name:vo(),price:vo(),currency:vo(),interval:vo(),interval_count:Fo(),trial_days:Fo()}).nullable(),payment_method:tr({id:vo(),gateway:vo(),type:vo(),card_brand:Ia,card_last4:Ia,card_exp_month:Fo().nullable(),card_exp_year:Fo().nullable(),is_default:Wo()}).nullable(),actions:tr({can_pause:Wo(),can_resume:Wo(),can_cancel:Wo(),can_manage_payment_method:Wo()})}),Ja=tr({enabled:Wo(),account:tr({points_balance:Fo(),lifetime_points:Fo()}).nullable(),settings:tr({earn_rate_per_usd:Fo(),redeem_value_per_point:Fo(),min_redeem_points:Fo()}).nullable(),transactions:Qo(tr({type:cr(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:Fo(),balance_after:Fo(),description:Ia,created_at:vo()}))}),Ya=tr({redeemed_points:Fo(),wallet_amount:vo(),currency:vo(),points_balance:Fo(),replayed:Wo()}),Wa=tr({uniqid:vo(),invoice_uniqid:vo(),product_title:vo(),period_days:Fo(),starts_at:vo(),expires_at:vo(),status:cr(["ACTIVE","EXPIRED","VOIDED"]),claim_status:cr(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:vo()}),Va=tr({warranties:Qo(Wa)}),Ha=tr({warranty:Wa.extend({claim_status:pr("REQUESTED")})}),Ga=tr({shop:tr({id:vo(),slug:vo(),name:vo(),currency:vo(),branding:Ca}),customer:tr({email:vo(),name:vo()}),stats:tr({invoices_count:Fo(),licenses_count:Fo(),deliverables_count:Fo(),tickets_count:Fo()}),wallet:tr({available:vo(),total:vo(),hold:vo(),currency:vo(),enabled:Wo()}).nullable(),rewards:Ma,affiliate:Fa,invoices:Qo(Ra),subscriptions:Qo(Ba),licenses:Qo(tr({uniqid:vo(),invoice_id:vo(),status:vo(),license_key:vo(),hardware_id:Ia,expires_at:Fo().nullable(),renewable:Wo(),product:tr({title:vo().optional()}).optional()})),deliverables:Qo(tr({id:vo(),invoice_uniqid:vo(),product_title:vo(),kind:cr(["file","serial","license"]),label:vo(),value:vo(),href:Ia,created_at:vo()})),tickets:Qo(tr({uniqid:vo(),title:vo(),status:vo(),updated_at:vo(),created_at:Ia}))});var Ka=null,Xa=null;var Qa=null,es=null;function ts(e,t){const n=t?.shopId?.trim();es=n||null;const o=Qa?.locale;return o!==(Qa={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}).locale&&r(),Ka=null,Xa=null,Qa}function ns(){if(!Qa)throw new l;return Qa}function os(){return null!==Qa}function rs(e){es=e}function is(){return es}function as(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}var ss=-1;function ls(e,t,n){return!0!==t?e:!0===n?ss:0!==e?e:ss}function us(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):null}function cs(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 ds(e){return ls(us(e?.stock)??ss,e?.orderable,e?.supplier_backed)}function ps(e){if(!e)return ss;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return ls(us(e.stock)??ss,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=>ds(e)):(Array.isArray(e.variants)?e.variants:[]).map(e=>ds(e))}(e);return t.length>0?t.some(e=>e<0)?ss:ls(t.reduce((e,t)=>e+Math.max(t,0),0),e.orderable,e.supplier_backed):ls(us(e.stock)??ss,e.orderable,e.supplier_backed)}function fs(e){return!!function(e){return!!e&&(cs(e.on_hold)||cs(e.onHold)||cs(e.is_on_hold)||cs(e.isOnHold))}(e)||0===ps(e)}function ms(e){return!fs(e)}function _s(e=[]){const t=new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function hs(e,t=[]){const n=t instanceof Map?t:_s(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function ys(e=[]){return Array.from(_s(e).values())}function gs(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function bs(e){return e.trim().toLowerCase()}function vs(e,t){const n=gs(t).toLowerCase();n&&e.push(n)}function ws(e){const t=[];vs(t,e.title),vs(t,e.slug??void 0),vs(t,e.description);for(const n of e.product_highlights??[])vs(t,n);for(const n of e.variants??[])vs(t,n.title);for(const n of e.price_variants??[])vs(t,n.title??n.label);return t}function Ss(e,t){const n=bs(t);return!!n&&ws(e).some(e=>e.includes(n))}function ks(e,t){const n=bs(t);if(!n)return!1;const o=gs(e.title).toLowerCase(),r=gs(e.slug??e.name??void 0).toLowerCase(),i=gs(e.description).toLowerCase();return o.includes(n)||r.includes(n)||i.includes(n)}function Os(e,t){return 0!==e.length&&(!t||e.some(e=>ms(e)))}function Es(e,t,n,o){const r=bs(n);if(!r)return[];const i=!0===o?.hideOutOfStock,a=new Set,s=new Set,l=[],u=_s(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!ks(d,r))continue;const t=hs(d,u);if(Os(t,i)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=ys(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&Ss(d,r)&&(i&&!ms(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function xs(e,t,n,o){const r=Es(e,t,n,o),i=new Set,a=[],s=e=>{e?.uniqid&&!i.has(e.uniqid)&&(o?.hideOutOfStock&&!ms(e)||(i.add(e.uniqid),a.push(e)))};for(const l of r)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 zs(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 Ts(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}var As=/:([A-Za-z0-9_]+)/g;function Is(e,t){return e.replace(As,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const r=String(o).trim();if(!r)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(r)})}function Ps(e){return`shoppex_${e}`}function Cs(e){try{const t=localStorage.getItem(Ps(e));return t?JSON.parse(t):null}catch{return null}}function $s(e,t){try{localStorage.setItem(Ps(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function Ns(e){try{localStorage.removeItem(Ps(e))}catch{}}function Rs(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=Cs(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 $s(t,o),o}async function Us(e){if(!os())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=Cs(t);return"number"==typeof o&&n-o<15e3||($s(t,n),!1)}(e))return;const t=ns(),n=is(),o=n?Is("/v1/storefront/shops/id/:id/ping",{id:n}):Is("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),r=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:Rs(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)}}),i=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([r],{type:"application/json"});if(navigator.sendBeacon(i,e))return}await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0})}catch{}}var qs=1e4;async function Ds(e){return new Promise(t=>setTimeout(t,e))}async function js(e,t={}){const n=t.baseUrl?null:ns(),o=n??(os()?ns():null),{method:r="GET",body:i,timeout:l=qs,retries:d,baseUrl:p,cache:f}=t,m=d??("GET"===r?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(),l),n=await fetch(_,{method:r,headers:h,body:i?JSON.stringify(i):void 0,signal:e.signal});clearTimeout(t);const o=await Ls(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,r=Zs(o.data);if(r.code)throw new c(t,r.code,n.status,r.errorParams);throw new u(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 u("Invalid API response",n.status);return Ms(o.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new u("Request timeout",408));const o=n instanceof s?n.statusCode:void 0;if(y={message:n.message,statusCode:o,isTransport:void 0===o||408===o,...n instanceof c?{code:n.code,...n.errorParams?{errorParams:n.errorParams}:{}}:{}},n instanceof c&&void 0!==o&&o>=400&&o<500&&408!==o)break;if(t<m){await Ds(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"===r&&f&&f.ttl>0?await a(f.key??`GET:${_}`,g,{ttl:f.ttl,staleWhileRevalidate:f.staleWhileRevalidate},e=>e.success):await g(),v=y;return!b.success&&v?.isTransport&&await Us({endpoint:e,method:r,message:b.message??v.message,statusCode:v.statusCode,attemptCount:m+1,requestUrl:_,responseReceived:void 0!==v.statusCode&&408!==v.statusCode}),b}async function Ls(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 Ms(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}`,...Zs(e)}}function Zs(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 Fs(e,t){return js(e,{...t,method:"GET"})}async function Bs(e,t,n){return js(e,{...n,method:"POST",body:t})}var Js=3e5;async function Ys(){const e=ns(),t=await Fs(Is("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:Js,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&rs(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function Ws(e){const t=ns(),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()}`:"",r=await Fs(`${Is("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:Js,staleWhileRevalidate:!0}});return r.success&&r.data?(r.data.shop?.id&&rs(r.data.shop.id),{success:!0,data:{shop:r.data.shop,products:r.data.products??[],products_pagination:r.data.products_pagination??null,groups:r.data.groups??[],items:r.data.items??[],categories:r.data.categories??[],addons:r.data.addons??{items:[]}}}):{success:!1,message:r.message}}var Vs=12e4;function Hs(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 Gs(){const e=ns(),t=await Fs(Is("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:Vs,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:ys(t.data.products.map(Hs))}:{success:!1,message:t.message,data:[]}}var Ks="shoppex:affiliate_code:v1";function Xs(){return Date.now()}function Qs(e){const t=e?.trim().toLowerCase();return t||null}function el(e,t=30){const n=Qs(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(Ks,JSON.stringify(e))}catch{}}({code:n,expiresAt:Xs()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(tl(),null);var o}function tl(){if("undefined"!=typeof window)try{window.localStorage.removeItem(Ks)}catch{}}function nl(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(Ks);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<=Xs()?(tl(),null):Qs(e.code):null}async function ol(e){const t=Qs(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=ns(),o=await Bs("/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:Qs(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 rl(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 il(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:rl(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 al(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:il(e)}}function sl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function ll(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return sl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return sl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}var ul={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function cl(e){return`${ul[e]}_${ns().storeSlug}`}function dl(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 pl(e){if(!Number.isFinite(e))throw new d("quantity must be a finite number");return Math.floor(e)}function fl(e){const t=e?.trim().toUpperCase();return t||null}function ml(){const e=Cs(cl("coupon"));if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,n="string"==typeof t.code?fl(t.code):null,o="COUPON"===t.source||"AFFILIATE"===t.source?t.source:null;return n&&o?{code:n,source:o}:null}function _l(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():"",r="string"==typeof e.variant_id?e.variant_id.trim():"",i=Number(e.quantity);if(!o||!r||!Number.isFinite(i)||i<1)continue;const a={line_id:"",product_id:o,variant_id:r,quantity:Math.floor(i)};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),Ol(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||il(a),t.push(al(a))}return t}function hl(){return Cs(cl("meta"))}function yl(){return ml()?.code??null}function gl(){return ml()?.source??null}function bl(e,t="COUPON"){const n=fl(e);return n?($s(cl("coupon"),{code:n,source:t}),n):(Ns(cl("coupon")),null)}function vl(){Ns(cl("coupon"))}function wl(e){const t=_l(e);$s(cl("cart"),t);const n=Date.now(),o=hl(),r={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:dl(t)};$s(cl("meta"),r),0===t.length&&vl()}function Sl(e,t){const n=_l(e);$s(cl("cart"),n);const o=Date.now(),r=t??hl(),i={created_at:r?.created_at??o,last_modified:o,version:r?.version??1,checksum:dl(n)};$s(cl("meta"),i)}function kl(){return _l(Cs(cl("cart")))}function Ol(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 El(){Ns(cl("cart")),Ns(cl("meta")),vl(),Al=null,Il+=1}function xl(){const e=kl();$s(cl("cartBackup"),e);const t=ml();t?$s(cl("couponBackup"),t):Ns(cl("couponBackup"));const n=hl();if(n)$s(cl("metaBackup"),n);else{const t=Date.now();$s(cl("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:dl(e)})}}function zl(){const e=kl(),t=hl(),n=dl(e);return t?t.checksum===n:(Sl(e,null),!0)}function Tl(){const e=yl();return"AFFILIATE"===gl()&&e?e.trim().toLowerCase():nl()}var Al=null,Il=0;function Pl(){return Al}var Cl="Your cart changed while checkout was starting. Please review it and try again.";function $l(e,t){return void 0!==t&&JSON.stringify(e)!==t}function Nl(e){const t=e?.trim();return t||null}function Rl(e){const t=e?.trim();return t||null}function Ul(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 ql(e){return sl(e.currency)??ll()??sl(ns().currency)}function Dl(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(jl(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 jl(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 Ll(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),r=new URL(o);if(t.origin!==r.origin)return null;const i=t.pathname.replace(/\/+$/,""),a=`${r.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!i.startsWith(a))return null;const s=i.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 Ml(e,t){const n=Rl(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 Zl(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 r=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!r&&o&&n&&(r=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&&r?{invoiceId:o,checkoutUrl:r,rewards:e?.rewards??n?.rewards??null}:null}function Fl(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function Bl(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()??nl()}function Jl(e){const t=yl(),n=gl();return{coupon:void 0===e.coupon?"COUPON"===n?t:null:Nl(e.coupon),affiliateCode:Bl(e,void 0===e.coupon&&"AFFILIATE"===n?t:null)}}function Yl(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 Wl(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 Vl(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function Hl(e,t){const n=e,o=Wl(n.rating)??Wl(n.score)??0,r=Vl(n.comment,n.message),i=Vl(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=Vl(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...r?{comment:r}:{},...i?{author:i}:{},created_at:s}}async function Gl(e){const t=ns(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,r=await Fs(`${Is("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return r.success&&r.data?{success:!0,data:{...r.data,feedback:r.data.feedback.map(Hl)}}:{success:!1,message:r.message}}function Kl(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Xl(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 Ql(e){const t="string"==typeof e.error_code&&e.error_code.length>0?e.error_code:null;return t?{code:t,...Kl(e.error_params)?{errorParams:e.error_params}:{}}:{}}async function eu(e,t={}){const n=t.method??"GET",o={Accept:"application/json"};void 0!==t.body&&(o["Content-Type"]="application/json");const r=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:r,credentials:"same-origin",cache:"no-store"});if(204===a.status)return a.ok?{success:!0,status:a.status}:{success:!1,status:a.status,message:Xl({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=Kl(i=s)&&"number"==typeof i.status&&"data"in i?i: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:Xl(l,a),...Ql(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 i}function tu(e){return eu("/auth/otp/request",{method:"POST",body:{email:e}})}function nu(e,t){return eu("/auth/otp/verify",{method:"POST",body:{email:e,otp:t}})}function ou(){return eu("/auth/logout",{method:"POST"})}function ru(){return eu("/me")}function iu(){return eu("/dashboard",{schema:Ga})}function au(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),eu("/invoices"+(t.size>0?`?${t.toString()}`:""),{schema:qa})}function su(e){return eu(`/invoice/${encodeURIComponent(e)}`,{schema:ja})}function lu(){return eu("/loyalty",{schema:Ja})}function uu(e){return eu("/loyalty/redeem",{method:"POST",body:{points:e.points,idempotency_key:e.idempotencyKey},schema:Ya})}function cu(e){return eu("/warranties"+(e?`?invoice=${encodeURIComponent(e)}`:""),{schema:Va})}function du(e,t){return eu(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",body:t?{message:t}:{},schema:Ha})}function pu(e){return eu(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",body:{}})}function fu(e){return eu(`/subscriptions/${encodeURIComponent(e)}/billing-history`)}function mu(e,t={}){return eu(`/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 _u(e){return eu(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",body:{}})}function hu(e){return eu(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",body:{}})}function yu(){return eu("/favorites")}function gu(e){return eu(`/favorites/${encodeURIComponent(e)}`,{method:"PUT"})}function bu(e){return eu(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE"})}function vu(){return eu("/affiliate")}function wu(e){return eu("/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 Su(e){return eu(`/tickets/${encodeURIComponent(e)}`)}function ku(e,t){return eu(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",body:{message:t}})}function Ou(e){return eu("/profile",{method:"POST",body:{name:e.name}})}function Eu(e){const t=new FormData;return t.append("file",e),eu("/profile/avatar",{method:"POST",formData:t})}function xu(){return eu("/profile/avatar",{method:"DELETE"})}function zu(){return eu("/email-marketing/preferences")}function Tu(e){return eu("/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 Au(){return eu("/sessions")}function Iu(e){return eu(`/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Pu(){return eu("/sessions?others=true",{method:"DELETE"})}function Cu(){return eu("/reseller")}function $u(e){return eu("/reseller/apply",{method:"POST",body:void 0===e?{}:{note:e}})}function Nu(){return eu("/reseller/enroll",{method:"POST",body:{}})}function Ru(e){return eu("/reseller/accept-invite",{method:"POST",body:{token:e}})}function Uu(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)),eu("/reseller/catalog"+(t.size>0?`?${t.toString()}`:""))}function qu(e){return eu("/reseller/orders/quote",{method:"POST",body:{items:e}})}function Du(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)),eu("/reseller/orders"+(t.size>0?`?${t.toString()}`:""))}function ju(e){return eu(`/reseller/orders/${encodeURIComponent(e)}`)}function Lu(){return eu("/reseller/wallet")}function Mu(){return eu("/reseller/api-keys")}function Zu(e){const t=e.trim();return t||null}var Fu=3e5;var Bu=3e5;async function Ju(){const e=ns(),t=await Fs(Is("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:Bu,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function Yu(e){const t=ns(),n=await Fs(Is("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:Bu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function Wu(e){return Yu(e)}async function Vu(e){const t=ns(),n=await Fs(Is("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:Bu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function Hu(e){return function(e){const t=S[e];return[t.title,...t.aliases]}(e)}var Gu=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Ku(e){return`shoppex:utm:${e}`}function Xu(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 Gu){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(Ku(e),JSON.stringify(n))}catch{}}(e,t),t;const n=function(e){try{const t=window.localStorage.getItem(Ku(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(Ku(e)),{};const o={};for(const e of Gu){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 Qu(e,t){if(!os())return;if("undefined"==typeof document)return;const n=ns(),o=Rs(n.storeSlug);try{const r=Is("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${r}`,{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:Xu(n.storeSlug)})})}catch{}}async function ec(){if(!os())return{success:!1,message:"SDK not initialized"};const e=ns(),t=is();return Fs(t?Is("/v1/storefront/shops/id/:id/recent-sales",{id:t}):Is("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function tc(){if(!os())return{success:!1,message:"SDK not initialized"};const e=ns(),t=is();return Fs(t?Is("/v1/storefront/shops/id/:id/online-users",{id:t}):Is("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function nc(){if(!os())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=ns(),t=is();return Bs(t?Is("/v1/storefront/shops/id/:id/ping",{id:t}):Is("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:Rs(e.storeSlug)??void 0,utm:Xu(e.storeSlug)},{retries:0,timeout:5e3})}function oc(e,t){const n=ns();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD",...za})}function rc(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ic(e){return rc(e)&&rc(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:rc(e.theme.content)?e.theme.content:{},layout:rc(e.theme.layout)?e.theme.layout:{},style_slots:rc(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...rc(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function ac(e){const t=await Fs(Is("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?rc(n=t.data)?{settings:rc(n.settings)?n.settings:{},builder_settings:ic(n.builder_settings),content:rc(n.content)?n.content:{},style_slots:rc(n.style_slots)?n.style_slots:{}}:null:null;var n}async function sc(e){const t=await ac(e);return t?t.settings:null}function lc(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,r]of Object.entries(o))t[n][e]=r.default}return t}function uc(e,t){const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]={...n[o],...r});return n}var cc={init:function(e,t){"string"==typeof e?ts(e,t):ts(e.storeId,e)},isInitialized:os,getConfig:ns,client:function(e){const t=ns().apiBaseUrl??"https://api.shoppex.io";if(Ka&&Xa===t&&!e)return Ka;const n=function(e,t){return f({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(Ka=n,Xa=t),n},getStore:Ys,getStorefront:Ws,getStoreLogoUrl:async function(){const e=await Ys();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await Ys();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(),r=t??(os()?ns().apiBaseUrl:"https://api.shoppex.io"),i=await Fs(Is("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:r,cache:{key:`store:domain:${o}`,ttl:Js,staleWhileRevalidate:!0}});return i.success&&i.data?.shop?(i.data.shop.id&&rs(i.data.shop.id),{success:!0,data:i.data.shop}):{success:!1,message:i.message??"Failed to resolve store"}},getProducts:Gs,getStorefrontProductsPage:async function(e){const t=ns(),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()}`:"",r=await Fs(`${Is("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${i=e?.category,void 0===i?"category:unset":null===i?"category:null":`category:${i}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:Vs,staleWhileRevalidate:!0}});var i;return r.success&&r.data?{success:!0,data:{products:r.data.products.map(Hs),pagination:r.data.pagination??null}}:{success:!1,message:r.message}},getProduct:async function(e){let t=is();if(!t){const e=await Ys();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await Fs(`${Is("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:Vs,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:Hs(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await Gs();if(!e.success||!e.data)return{success:!1,message:e.message};const t=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:kl,getCartItemCount:function(){return kl().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:yl,getCartCouponSource:gl,setCartCoupon:bl,clearCartCoupon:vl,addToCart:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const r=pl(n);if(r<1)throw new d("quantity must be at least 1");const i=kl(),a=il({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=i.findIndex(e=>e.line_id===a);if(s>=0)i[s].quantity+=r,o?.addons&&(i[s].addons=o.addons),o?.custom_fields&&(i[s].custom_fields=o.custom_fields),o?.price_variant_id&&(i[s].price_variant_id=o.price_variant_id),o?.price_data&&(i[s].price_data=o.price_data),void 0!==o?.pay_what_you_want_price&&(i[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)}(i[s],o),Ol(i[s]);else{const n={line_id:a,product_id:e,variant_id:t,quantity:r,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};Ol(n),i.push(n)}wl(i)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const r=pl(n);if(r<1)throw new d("quantity must be at least 1");const i=kl(),a=il({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=i.length-1;l>=0;l-=1)i[l].product_id===e&&i[l].variant_id===t&&i.splice(l,1);const s={line_id:a,product_id:e,variant_id:t,quantity:r,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};Ol(s),i.push(s),wl(i)},updateCartItem:function(e,t){const n=kl(),o=e.trim();if(!o)throw new d("line_id is required");const r=n.findIndex(e=>e.line_id===o);if(r<0)throw new d("Item not found in cart");const i=JSON.stringify(n);if(void 0!==t.quantity){const e=pl(t.quantity);if(e<1)return n.splice(r,1),void wl(n);n[r].quantity=e}void 0!==t.addons&&(n[r].addons=t.addons),void 0!==t.custom_fields&&(n[r].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[r].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[r].price_data=t.price_data),void 0!==t.pay_what_you_want_price&&(n[r].pay_what_you_want_price=t.pay_what_you_want_price),void 0!==t.max_quantity&&(null===t.max_quantity?delete n[r].max_quantity:n[r].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(null===t.min_quantity?delete n[r].min_quantity:n[r].min_quantity=t.min_quantity),Ol(n[r]);const a=il(n[r]),s=n.findIndex((e,t)=>t!==r&&e.line_id===a);s>=0?(n[s].quantity+=n[r].quantity,Ol(n[s]),n.splice(r,1)):n[r].line_id=a,JSON.stringify(n)!==i&&wl(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new d("line_id is required");wl(kl().filter(e=>e.line_id!==t))},clearCart:El,createCartBackup:xl,restoreCartFromBackup:function(){const e=_l(Cs(cl("cartBackup"))),t=Cs(cl("metaBackup")),n=Cs(cl("couponBackup"));if(e&&e.length>0){if(Sl(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?bl(e.code,t):vl()}else vl();return!0}return!1},mergeBaskets:function(e){const t=kl();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 r;try{r=pl(n.quantity)}catch{continue}if(r<1)continue;const i=al({...n,line_id:n.line_id??il(n),product_id:e,variant_id:o,quantity:r}),a=t.findIndex(e=>e.line_id===i.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,r),Ol(t[a])):(Ol(i),t.push(i))}return wl(t),t},moveBasketItem:function(e,t,n,o){const r=kl(),i=r.findIndex(n=>n.product_id===e&&n.variant_id===t);if(i<0)throw new d("Item not found in cart");const[a]=r.splice(i,1),s=il({...a,product_id:n,variant_id:o}),l=r.findIndex(e=>e.line_id===s);if(l>=0)r[l].quantity+=a.quantity,Ol(r[l]);else{const e=al({...a,product_id:n,variant_id:o,line_id:s});Ol(e),r.push(e)}wl(r)},getCartStats:function(){const e=kl(),t=zl(),n=hl(),o=Cs(cl("cartBackup"))??[],r=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),i=e.reduce((e,t)=>e+Ta((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:Ta(i),total_price_is_estimate:e.length>0&&!r}},validateCartIntegrity:zl,quoteCart:async function(e,t){const n=Il+=1,o=function(e){const t=ns(),n=fl(e)??yl()??void 0;return{store_slug:t.storeSlug,items:kl(),coupon:n}}(e),r=sl(t)??ll()??sl(ns().currency),i=await Bs("/v1/storefront/cart/quote",{shop_slug:o.store_slug,cart:o.items,coupon:o.coupon,affiliate_code:Tl()??void 0,currency:r??void 0});return n!==Il||i.success&&(Al="string"==typeof i.data?.quote_token?i.data.quote_token:null),i},resolveCartLineId:function(e,t,n=kl()){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=Fl(e,t),{autoRedirect:o=!0,email:r}=n,i=Jl(n),a=i.coupon,s=Rl(r),l=i.affiliateCode,u=ql(n),c=kl();if(0===c.length)return{success:!1,message:"Cart is empty"};if($l(c,n.expectedCart))return{success:!1,message:Cl};xl();const d=ns(),p=Ul(n),f=await Bs(p.endpoint,{shop_slug:d.storeSlug,cart:Yl(c),email:s,coupon:a,currency:u,affiliate_code:l,quote_token:Pl()??void 0},{retries:0,baseUrl:p.baseUrl});if(!f.success||!f.data)return jl(f.message)&&El(),{success:!1,message:Dl(f.message),...f.code?{code:f.code}:{}};const m=Zl(f.data,d.checkoutBaseUrl);if(!m)return{success:!1,message:"Failed to create invoice"};const{invoiceId:_}=m,h=Ll(m.checkoutUrl,d.checkoutBaseUrl,_);if(!h)return{success:!1,message:"Failed to create invoice"};const y=Ml(h,{email:s,locale:n.locale??d.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=y,El()),{success:!0,redirectUrl:y,invoiceId:_,rewards:m.rewards}},buildCheckoutUrl:async function(e,t){const n=Fl(e,t),{email:o}=n,r=Jl(n),i=r.coupon,a=Rl(o),s=r.affiliateCode,l=ql(n),u=kl();if(0===u.length)throw new Error("Cart is empty");if($l(u,n.expectedCart))throw new Error(Cl);const c=ns(),d=Ul(n),p=await Bs(d.endpoint,{shop_slug:c.storeSlug,cart:Yl(u),email:a,coupon:i,currency:l,affiliate_code:s,quote_token:Pl()??void 0},{retries:0,baseUrl:d.baseUrl});if(!p.success||!p.data)throw jl(p.message)&&El(),new Error(Dl(p.message));const f=Zl(p.data,c.checkoutBaseUrl);if(!f)throw new Error("Failed to create invoice");const m=Ll(f.checkoutUrl,c.checkoutBaseUrl,f.invoiceId);if(!m)throw new Error("Failed to create invoice");return Ml(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=Qs(t),!t)return null;if(el(t),os())try{const e=ns(),n=await Bs("/v1/storefront/affiliates/attribution",{shop_slug:e.storeSlug,code:t},{retries:0});return n.success&&n.data?.accepted&&n.data?.affiliate_code?(el(n.data.affiliate_code),n.data.affiliate_code):(tl(),null)}catch{return t}return t},validateAffiliateCode:ol,applyAffiliateCode:async function(e){const t=await ol(e);return t.success&&t.data?.affiliate_code&&el(t.data.affiliate_code),t},getAffiliateCode:nl,setAffiliateCode:el,clearAffiliateCode:tl,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},r="string"==typeof t?t:t?.productId,i="string"==typeof t?void 0:t?.variantId;if(i&&!r)return{success:!1,message:"productId is required when variantId is provided"};if(r)o.product_id=r,i&&(o.variant_id=i);else{const e=kl();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=is();if(e)return e;const t=await Ys();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 Bs("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=new Set;let n=null;for(;;){const o=await Gl(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...o.data.feedback);const r=o.data.pagination;if(!r?.has_more||!r.next_cursor)break;if(t.has(r.next_cursor))break;t.add(r.next_cursor),n=r.next_cursor}return{success:!0,data:e}},getShopReviewsPage:Gl,requestOtp:tu,verifyOtp:nu,logout:ou,me:ru,dashboard:iu,orders:au,order:su,loyalty:lu,redeemLoyaltyPoints:uu,warranties:cu,claimWarranty:du,resetLicenseHwid:pu,subscriptionBillingHistory:fu,cancelSubscription:mu,pauseSubscription:_u,resumeSubscription:hu,favorites:yu,addFavorite:gu,removeFavorite:bu,affiliate:vu,createTicket:wu,ticket:Su,replyToTicket:ku,updateProfile:Ou,updateAvatar:Eu,removeAvatar:xu,emailPreferences:zu,updateEmailPreferences:Tu,sessions:Au,revokeSession:Iu,revokeAllSessions:Pu,reseller:Cu,applyForReseller:$u,enrollAsReseller:Nu,acceptResellerInvite:Ru,resellerCatalog:Uu,quoteResellerOrder:qu,resellerOrders:Du,resellerOrder:ju,resellerWallet:Lu,resellerApiKeys:Mu,searchProducts:async function(e,t){if(!os())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ws();return o.success&&o.data?{success:!0,data:xs(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(!os())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ws();return o.success&&o.data?{success:!0,data:Es(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=Zu(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await Fs(Is("/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=Zu(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await Fs(Is("/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=ns(),t=await Fs(Is("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:Fu,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=ns(),n=await Fs(Is("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:Fu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:Ju,getMenu:Wu,getMenuBySlot:Vu,getMenuByTitle:Yu,getMenuSlotTitles:Hu,trackPageView:Qu,getStorefrontOnlineUsers:tc,getStorefrontRecentSales:ec,touchStorefrontPresence:nc,createFormatter:oc,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?oc(t,n).format(0):oc(t,n).format(o)},clearCache:r,invalidateCache:function(e){for(const n of t.keys())(n===e||n.startsWith(e))&&t.delete(n)},getCacheStats:function(){return{hits:o.hits,misses:o.misses,pendingRequests:n.size,entries:t.size}},fetchPublishedBuilderSettings:ac,fetchPublishedThemeSettings:sc,resolveDefaults:lc,mergeSettings:uc};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=cc)}e.ApiError=c,e.CATALOG_UNIT_PRICE_DECIMAL_PLACES=3,e.CATALOG_UNIT_PRICE_FORMAT_OPTIONS=za,e.CartError=d,e.NetworkError=u,e.NotInitializedError=l,e.PAYABLE_AMOUNT_DECIMAL_PLACES=2,e.ShoppexError=s,e.ValidationError=class e extends s{constructor(t,n){super(t,"VALIDATION_ERROR"),this.name="ValidationError",this.invalidFields=n,Object.setPrototypeOf(this,e.prototype)}},e.acceptResellerInvite=Ru,e.addFavorite=gu,e.affiliate=vu,e.applyForReseller=$u,e.buildStorefrontContactMessage=Ts,e.buildStorefrontCustomFieldPayload=function(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(as(o)&&(n[e.name]="true"));const r=o.trim();r.length>0&&(n[e.name]=r)}),n},e.buildStorefrontProductLookup=_s,e.cancelSubscription=mu,e.claimWarranty=du,e.collectProductSearchHaystack=ws,e.computeCartLineId=il,e.createTicket=wu,e.dashboard=iu,e.default=cc,e.shoppex=cc,e.emailPreferences=zu,e.enrollAsReseller=Nu,e.ensureCartLineId=al,e.favorites=yu,e.fetchPublishedBuilderSettings=ac,e.fetchPublishedThemeSettings=sc,e.filterProductsBySearchQuery=function(e,t,n){const o=bs(t);if(!o)return[];let r=e.filter(e=>Ss(e,o));return n?.hideOutOfStock&&(r=r.filter(e=>ms(e))),null!=n?.maxResults?r.slice(0,n.maxResults):r},e.getMenu=Wu,e.getMenuBySlot=Vu,e.getMenuByTitle=Yu,e.getMenuSlotTitles=Hu,e.getMenus=Ju,e.getMergedStorefrontProducts=ys,e.getShopReviewsPage=Gl,e.getStorefrontGroupProducts=hs,e.getStorefrontOnlineUsers=tc,e.getStorefrontRecentSales=ec,e.groupMatchesSearchQuery=ks,e.isProductInStock=ms,e.isProductOutOfStock=fs,e.isStorefrontCheckboxCustomFieldValueChecked=as,e.isVariantOutOfStock=function(e){return 0===ds(e)},e.logout=ou,e.loyalty=lu,e.me=ru,e.mergeSettings=uc,e.normalizeSearchQuery=bs,e.normalizeStorefrontCustomFields=function(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)},e.order=su,e.orders=au,e.pauseSubscription=_u,e.productMatchesSearchQuery=Ss,e.quoteResellerOrder=qu,e.redeemLoyaltyPoints=uu,e.removeAvatar=xu,e.removeFavorite=bu,e.replyToTicket=ku,e.requestOtp=tu,e.reseller=Cu,e.resellerApiKeys=Mu,e.resellerCatalog=Uu,e.resellerOrder=ju,e.resellerOrders=Du,e.resellerWallet=Lu,e.resetLicenseHwid=pu,e.resolveDefaults=lc,e.resolveDisplayStock=ps,e.resolveStorefrontApiBaseUrl=zs,e.resolveStorefrontSocialLinks=function(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}},e.resolveVariantStockValue=ds,e.resumeSubscription=hu,e.revokeAllSessions=Pu,e.revokeSession=Iu,e.roundPayableAmount=Ta,e.searchMergedStorefrontCatalog=xs,e.searchMergedStorefrontCatalogItems=Es,e.sessions=Au,e.stripHtmlFromText=gs,e.submitStorefrontContactTicket=async function(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()??"",r=o.length>=2?o.slice(0,30):"Contact Request",i=Ts({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=zs({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:r,message:i,...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}},e.subscriptionBillingHistory=fu,e.ticket=Su,e.touchStorefrontPresence=nc,e.trackPageView=Qu,e.updateAvatar=Eu,e.updateEmailPreferences=Tu,e.updateProfile=Ou,e.validateStorefrontCustomFieldValue=function(e,t){if("checkbox"===e.type)return e.required&&!as(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},e.verifyOtp=nu,e.warranties=cu});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shoppex={})}(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=new Map,n=new Map,o={hits:0,misses:0};function r(){t.clear(),n.clear()}function i(e,n,o){const r=Date.now();t.set(e,{data:n,ttl:o,updatedAt:r,expiresAt:r+o})}async function a(e,r,a,s=()=>!0){const l=function(e){const n=t.get(e);return n||null}(e);if(l&&!function(e){return Date.now()>e.expiresAt}(l))return o.hits+=1,l.data;if(l&&a.staleWhileRevalidate){if(o.hits+=1,!n.has(e)){const t=(async()=>{try{const t=await r();return s(t)&&i(e,t,a.ttl),t}finally{n.delete(e)}})();n.set(e,t)}return l.data}if(n.has(e))return n.get(e);o.misses+=1;const u=(async()=>{try{const t=await r();return s(t)&&i(e,t,a.ttl),t}finally{n.delete(e)}})();return n.set(e,u),u}var s=class e extends Error{constructor(t,n,o){super(t),this.name="ShoppexError",this.code=n,this.statusCode=o,Object.setPrototypeOf(this,e.prototype)}},l=class e extends s{constructor(){super("SDK not initialized. Call shoppex.init() first.","NOT_INITIALIZED"),this.name="NotInitializedError",Object.setPrototypeOf(this,e.prototype)}},u=class e extends s{constructor(t,n){super(t,"NETWORK_ERROR",n),this.name="NetworkError",Object.setPrototypeOf(this,e.prototype)}},c=class e extends s{constructor(t,n,o,r){super(t,n,o),this.name="ApiError",this.errorParams=r,Object.setPrototypeOf(this,e.prototype)}},d=class e extends s{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:r,bodySerializer:i,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:O=i??b,pathSerializer:E,body:x,middleware:z=[],...T}=d||{};let A=t;p&&(A=w(p)??t);let I="function"==typeof r?r:y(r);k&&(I="function"==typeof k?k:y({..."object"==typeof r?r:{},...k}));const P=E||a||g,C=void 0===x?void 0:O(x,v(s,_,h.header)),$=v(void 0===C||C instanceof FormData?{}:{"Content-Type":"application/json"},s,_,h.header),N=[...c,...z],R={redirect:"follow",...u,...T,body:C,headers:$};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(N.length){U=Math.random().toString(36).slice(2,11),q=Object.freeze({baseUrl:A,fetch:f,parseAs:S,querySerializer:I,bodySerializer:O,pathSerializer:P});for(const t of N)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(Z){let t=Z;if(N.length)for(let n=N.length-1;n>=0;n--){const o=N[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(N.length)for(let t=N.length-1;t>=0;t--){const n=N[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 M=await D.text();try{M=JSON.parse(M)}catch{}return{error:M,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=[],r={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 r=o.join(",");switch(n.style){case"form":return`${e}=${r}`;case"label":return`.${r}`;case"matrix":return`;${e}=${r}`;default:return r}}for(const a in t){const r="deepObject"===n.style?`${e}[${a}]`:a;o.push(m(r,t[a],n))}const i=o.join(r);return"label"===n.style||"matrix"===n.style?`${r}${i}`:i}function h(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",r=(!0===n.allowReserved?t:t.map(e=>encodeURIComponent(e))).join(o);switch(n.style){case"simple":return r;case"label":return`.${r}`;case"matrix":return`;${e}=${r}`;default:return`${e}=${r}`}}const o={simple:",",label:".",matrix:";"}[n.style]||"&",r=[];for(const i of t)"simple"===n.style||"label"===n.style?r.push(!0===n.allowReserved?i:encodeURIComponent(i)):r.push(m(e,i,n));return"label"===n.style||"matrix"===n.style?`${o}${r.join(o)}`:r.join(o)}function y(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const o in t){const r=t[o];if(null!=r)if(Array.isArray(r)){if(0===r.length)continue;n.push(h(o,r,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof r?n.push(m(o,r,e)):n.push(_(o,r,{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),r=!1,i="simple";if(e.endsWith("*")&&(r=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(i="label",e=e.substring(1)):e.startsWith(";")&&(i="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:i,explode:r})):n="object"!=typeof a?"matrix"!==i?n.replace(o,"label"===i?`.${encodeURIComponent(a)}`:encodeURIComponent(a)):n.replace(o,`;${m(e,a)}`):n.replace(o,_(e,a,{style:i,explode:r}))}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 O(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const r=a.prototype,i=Object.keys(r);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=r[t].bind(n))}}const r=n?.Parent??Object;class i extends r{}function a(e){var t;const r=n?.Parent?new i:this;o(r,e),(t=r._zod).deferred??(t.deferred=[]);for(const n of r._zod.deferred)n();return r}return Object.defineProperty(i,"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 E=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 C(e){return null==e}function $(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var N=Symbol("evaluating");function R(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==N)return void 0===o&&(o=N,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 M=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 Z(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 Z(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var B=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 V={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 H(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:r,continue:i,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=O("$ZodError",ne),re=O("$ZodError",ne,{Parent:Error});var ie=e=>(t,n,o,r)=>{const i=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;if(a.issues.length){const t=new(r?.Err??e)(a.issues.map(e=>Q(e,i,T())));throw j(t,r?.callee),t}return a.value},ae=e=>async(t,n,o,r)=>{const i=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(r?.Err??e)(a.issues.map(e=>Q(e,i,T())));throw j(t,r?.callee),t}return a.value},se=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new E;return i.issues.length?{success:!1,error:new(e??oe)(i.issues.map(e=>Q(e,r,T())))}:{success:!0,data:i.value}},le=se(re),ue=e=>async(t,n,o)=>{const r=o?{...o,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>Q(e,r,T())))}:{success:!0,data:i.value}},ce=ue(re),de=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ie(e)(t,n,r)},pe=e=>(t,n,o)=>ie(e)(t,n,o),fe=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ae(e)(t,n,r)},me=e=>async(t,n,o)=>ae(e)(t,n,o),_e=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return se(e)(t,n,r)},he=e=>(t,n,o)=>se(e)(t,n,o),ye=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return ue(e)(t,n,r)},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}$/,Oe=/^[a-zA-Z0-9_-]{21}$/,Ee=/^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])$/,Ce=/^(([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])$/,$e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ne=/^[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=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+$/,Me=/^-?\d+(?:\.\d+)?$/,Ze=/^(?:true|false)$/i,Fe=/^[^A-Z]*$/,Be=/^[^a-z]*$/,Je=O("$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=O("$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})}}),Ve=O("$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})}}),He=O("$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),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<r?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=O("$ZodCheckNumberFormat",(e,t)=>{Je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,i]=V[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=r,o.maximum=i,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<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Ke=O("$ZodCheckMaxLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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 r=ee(o);n.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xe=O("$ZodCheckMinLength",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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 r=ee(o);n.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Qe=O("$ZodCheckLengthEquals",(e,t)=>{var n;Je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!C(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,r=o.length;if(r===t.length)return;const i=ee(o),a=r>t.length;n.issues.push({origin:i,...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=O("$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=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=O("$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=O("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Fe),et.init(e,t)}),ot=O("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Be),et.init(e,t)}),rt=O("$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=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})}}),it=O("$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=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=O("$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=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=O("$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 r of o)this.content.push(r)}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=O("$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 r of o)for(const t of r._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,r=H(e);for(const i of t){if(i._zod.def.when){if(G(e))continue;if(!i._zod.def.when(e))continue}else if(r)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new E;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(r||(r=H(e,t)))});else{if(e.issues.length===t)continue;r||(r=H(e,t))}}return o?o.then(()=>e):e},n=(n,r,i)=>{if(H(n))return n.aborted=!0,n;const a=t(r,o,i);if(a instanceof Promise){if(!1===i.async)throw new E;return a.then(t=>e._zod.parse(t,i))}return e._zod.parse(a,i)};e._zod.run=(r,i)=>{if(i.skipChecks)return e._zod.parse(r,i);if("backward"===i.direction){const t=e._zod.parse({value:r.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,i)):n(t,r,i)}const a=e._zod.parse(r,i);if(a instanceof Promise){if(!1===i.async)throw new E;return a.then(e=>t(e,o,i))}return t(a,o,i)}}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=O("$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=O("$ZodStringFormat",(e,t)=>{et.init(e,t),dt.init(e,t)}),ft=O("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xe),pt.init(e,t)}),mt=O("$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=O("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Te),pt.init(e,t)}),ht=O("$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 r=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),yt=O("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pt.init(e,t)}),gt=O("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Oe),pt.init(e,t)}),bt=O("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=be),pt.init(e,t)}),vt=O("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ve),pt.init(e,t)}),wt=O("$ZodULID",(e,t)=>{t.pattern??(t.pattern=we),pt.init(e,t)}),St=O("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Se),pt.init(e,t)}),kt=O("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ke),pt.init(e,t)}),Ot=O("$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)}),Et=O("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=De),pt.init(e,t)}),xt=O("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${je(t)}$`)),pt.init(e,t)}),zt=O("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ee),pt.init(e,t)}),Tt=O("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ae),pt.init(e,t),e._zod.bag.format="ipv4"}),At=O("$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=O("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pe),pt.init(e,t)}),Pt=O("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ce),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 Ct(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 $t=O("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$e),pt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ct(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Nt=O("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ne),pt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Ne.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Ct(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=O("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ue),pt.init(e,t)});var Ut=O("$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 r=JSON.parse(atob(o));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.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=O("$ZodNumber",(e,t)=>{ct.init(e,t),e._zod.pattern=e._zod.bag.pattern??Me,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const r=n.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),Dt=O("$ZodNumberFormat",(e,t)=>{Ge.init(e,t),qt.init(e,t)}),jt=O("$ZodBoolean",(e,t)=>{ct.init(e,t),e._zod.pattern=Ze,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const r=n.value;return"boolean"==typeof r||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Lt=O("$ZodUnknown",(e,t)=>{ct.init(e,t),e._zod.parse=e=>e}),Mt=O("$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 Zt(e,t,n){e.issues.length&&t.issues.push(...K(n,e.issues)),t.value[n]=e.value}var Ft=O("$ZodArray",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let e=0;e<r.length;e++){const a=r[e],s=t.element._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(t=>Zt(t,n,e))):Zt(s,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function Bt(e,t,n,o,r,i){const a=n in o;if(e.issues.length){if(r&&i&&!a)return;t.issues.push(...K(n,e.issues))}a||r?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 r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": 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,r,i){const a=[],s=r.keySet,l=r.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 r=l.run({value:t[p],issues:[]},o);r instanceof Promise?e.push(r.then(e=>Bt(e,n,p,t,c,d))):Bt(r,n,p,t,c,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Wt=O("$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]=new Set);for(const e of o.values)n[t].add(e)}}return n});const o=L,r=t.catchall;let i;e._zod.parse=(t,a)=>{i??(i=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=i.shape;for(const e of i.keys){const n=u[e],o="optional"===n._zod.optin,r="optional"===n._zod.optout,i=n._zod.run({value:s[e],issues:[]},a);i instanceof Promise?l.push(i.then(n=>Bt(n,t,e,s,o,r))):Bt(i,t,e,s,o,r)}return r?Yt(l,s,t,a,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Vt=O("$ZodObjectJIT",(e,t)=>{Wt.init(e,t);const n=e._zod.parse,o=P(()=>Jt(t));let r;const i=L,a=!z.jitless,s=a&&M.value,l=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=o.value);const p=c.value;return i(p)?a&&s&&!1===d?.async&&!0!==d.jitless?(r||(r=(e=>{const t=new lt(["shape","payload","ctx"]),n=o.value,r=e=>{const t=D(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let a=0;for(const o of n.keys)i[o]="key_"+a++;t.write("const newResult = {};");for(const o of n.keys){const n=i[o],a=D(o),s=e[o],l="optional"===s?._zod?.optin,u="optional"===s?._zod?.optout;t.write(`const ${n} = ${r(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=r(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 Ht(e,t,n,o){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const r=e.filter(e=>!H(e));return 1===r.length?(t.value=r[0].value,r[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=O("$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=>$(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(o,r)=>{if(n)return n(o,r);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>Ht(t,o,e,r)):Ht(a,o,e,r)}}),Kt=O("$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]=new Set);for(const o of n)e[t].add(o)}}return e});const o=P(()=>{const e=t.options,n=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=(r,i)=>{const a=r.value;if(!L(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback||"backward"===i.direction?n(r,i):(r.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}),r)}}),Xt=O("$ZodIntersection",(e,t)=>{ct.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,r=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([t,n])=>en(e,t,n)):en(e,r,i)}});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(Z(e)&&Z(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const i of o){const n=Qt(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};r[i]=n.data}return{valid:!0,data:r}}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 r=Qt(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function en(e,t,n){const o=new Map;let r;for(const s of t.issues)if("unrecognized_keys"===s.code){r??(r=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 i=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&r&&e.issues.push({...r,keys:i}),H(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=O("$ZodRecord",(e,t)=>{ct.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Z(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=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:r[u],issues:[]},o);c instanceof Promise?i.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 r)s.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(r)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(r,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&&Me.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]=r[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:r[a],issues:[]},o);l instanceof Promise?i.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 i.length?Promise.all(i).then(()=>n):n}}),nn=O("$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,r)=>{const i=t.value;return o.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),on=O("$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,r)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),rn=O("$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 r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(e=>(n.value=e,n.fallback=!0,n));if(r instanceof Promise)throw new E;return n.value=r,n.fallback=!0,n}});function an(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var sn=O("$ZodOptional",(e,t)=>{ct.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=e.value,r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>an(e,o)):an(r,o)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),ln=O("$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=O("$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(`^(${$(e.source)}|null)$`):void 0}),R(e._zod,"values",()=>t.innerType._zod.values?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=O("$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=O("$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=O("$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 r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(t=>mn(t,e)):mn(r,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=O("$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=O("$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=O("$ZodPreprocess",(e,t)=>{hn.init(e,t)}),bn=O("$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=O("$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,r=t.fn(o);if(r instanceof Promise)return r.then(t=>kn(t,n,o,e));kn(r,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 On=class{constructor(){this._map=new WeakMap,this._idmap=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=new WeakMap,this._idmap=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 On);var En=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 Ve({check:"greater_than",...W(t),value:e,inclusive:!1})}function Cn(e,t){return new Ve({check:"greater_than",...W(t),value:e,inclusive:!0})}function $n(e,t){return new He({check:"multiple_of",...W(t),value:e})}function Nn(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??En,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen: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 r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.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,i=t.processors[r.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);i(e,t,n,o)}const i=e._zod.parent;i&&(a.ref||(a.ref=i),Ln(i,t,o),t.seen.get(i).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 Mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=o.get(t);if(e&&e!==i[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,i[0])}}const r=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:r,defId:i}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,r=e.external.uri??(e=>e);if(n)return{ref:r(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${r("__shared")}#/${o}/${i}`}}if(t[1]===n)return{ref:"#"};const r=`#/${o}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:r+i}})(t);o.def={...o.schema},i&&(o.defId=i);const a=o.schema;for(const e in a)delete a[e];a.$ref=r};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[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 i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){r(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&r(i)}else r(i)}}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=t=>{const n=e.seen.get(t);if(null===n.ref)return;const r=n.def??n.schema,i={...r},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(r,s):(r.allOf=r.allOf??[],r.allOf.push(s)),Object.assign(r,i),t._zod.parent===a)for(const e in r)"$ref"!==e&&"allOf"!==e&&(e in i||delete r[e]);if(s.$ref&&n.def)for(const e in r)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(r[e])===JSON.stringify(n.def[e])&&delete r[e]}const s=t._zod.parent;if(s&&s!==a){o(s);const t=e.seen.get(s);if(t?.schema.$ref&&(r.$ref=t.schema.$ref,t.def))for(const e in r)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(r[e])===JSON.stringify(t.def[e])&&delete r[e]}e.override({zodSchema:t,jsonSchema:r,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const r={};if("draft-2020-12"===e.target?r.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?r.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?r.$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");r.$id=e.external.uri(n)}Object.assign(r,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&r.id===i&&delete r.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?r.$defs=a:r.definitions=a);try{const n=JSON.parse(JSON.stringify(r));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: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:r,target:i}=o??{},a=jn({...r??{},target:i,io:t,processors:n});return Ln(e,a),Mn(a,e),Zn(a,e)},Jn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yn=(e,t,n,o)=>{const r=e._zod.def;Ln(r.innerType,t,o);t.seen.get(e).ref=r.innerType},Wn=O("ZodISODateTime",(e,t)=>{Ot.init(e,t),So.init(e,t)});function Vn(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 Hn=O("ZodISODate",(e,t)=>{Et.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)})}(Hn,e)}var Kn=O("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=O("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,r=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>o({issues:e},[...r,...i.path]));else if("invalid_key"===i.code)o({issues:i.issues},[...r,...i.path]);else if("invalid_element"===i.code)o({issues:i.issues},[...r,...i.path]);else{const e=[...r,...i.path];if(0===e.length)n._errors.push(t(i));else{let o=n,r=0;for(;r<e.length;){const n=e[r];r!==e.length-1?o[n]=o[n]||{_errors:[]}:(o[n]=o[n]||{_errors:[]},o[n]._errors.push(t(i))),o=o[n],r++}}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));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=O("ZodError",to,{Parent:Error}),oo=ie(no),ro=ae(no),io=se(no),ao=ue(no),so=de(no),lo=pe(no),uo=fe(no),co=me(no),po=_e(no),fo=he(no),mo=ye(no),_o=ge(no),ho=new WeakMap;function yo(e,t,n){const o=Object.getPrototypeOf(e);let r=ho.get(o);if(r||(r=new Set,ho.set(o,r)),!r.has(t)){r.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=O("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),Mn(o,e),Zn(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)=>io(e,t,n),e.parseAsync=async(t,n)=>ro(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)})}(Ar,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=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 yr(this)},exactOptional(){return new gr({type:"optional",innerType:this})},nullable(){return vr(this)},nullish(){return yr(vr(this))},nonoptional(e){return function(e,t){return new kr({type:"nonoptional",innerType:e,...W(t)})}(this,e)},array(){return er(this)},or(e){return rr([this,e])},and(e){return new sr({type:"intersection",left:this,right:e})},transform(e){return xr(this,_r(e))},default(e){return t=e,new wr({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},prefault(e){return t=e,new Sr({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():F(t)}});var t},catch(e){return new Or({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return xr(this,e)},readonly(){return new Tr({type:"readonly",innerType:this})},describe(e){const t=this.clone();return En.add(t,{description:e}),t},meta(...e){if(0===e.length)return En.get(this);const t=this.clone();return En.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:()=>En.get(e)?.description,configurable:!0}),e)),bo=O("_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:r,maximum:i,format:a,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof r&&(o.minLength=r),"number"==typeof i&&(o.maxLength=i),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 rt({check:"string_format",format:"includes",...W(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new it({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(Nn(...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(qn(e=>e.trim()))},normalize(...e){return this.check(function(e){return qn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(qn(e=>e.toLowerCase()))},toUpperCase(){return this.check(qn(e=>e.toUpperCase()))},slugify(){return this.check(qn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),vo=O("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)})}(Zo,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(Eo,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(Eo,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)})}(Co,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)})}($o,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}(No,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)})}(Mo,t)),e.datetime=t=>e.check(Vn(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=O("ZodStringFormat",(e,t)=>{pt.init(e,t),bo.init(e,t)}),ko=O("ZodEmail",(e,t)=>{_t.init(e,t),So.init(e,t)});function Oo(e){return xn(ko,e)}var Eo=O("ZodGUID",(e,t)=>{ft.init(e,t),So.init(e,t)}),xo=O("ZodUUID",(e,t)=>{mt.init(e,t),So.init(e,t)}),zo=O("ZodURL",(e,t)=>{ht.init(e,t),So.init(e,t)});var To=O("ZodEmoji",(e,t)=>{yt.init(e,t),So.init(e,t)}),Ao=O("ZodNanoID",(e,t)=>{gt.init(e,t),So.init(e,t)}),Io=O("ZodCUID",(e,t)=>{bt.init(e,t),So.init(e,t)}),Po=O("ZodCUID2",(e,t)=>{vt.init(e,t),So.init(e,t)}),Co=O("ZodULID",(e,t)=>{wt.init(e,t),So.init(e,t)}),$o=O("ZodXID",(e,t)=>{St.init(e,t),So.init(e,t)}),No=O("ZodKSUID",(e,t)=>{kt.init(e,t),So.init(e,t)}),Ro=O("ZodIPv4",(e,t)=>{Tt.init(e,t),So.init(e,t)}),Uo=O("ZodIPv6",(e,t)=>{At.init(e,t),So.init(e,t)}),qo=O("ZodCIDRv4",(e,t)=>{It.init(e,t),So.init(e,t)}),Do=O("ZodCIDRv6",(e,t)=>{Pt.init(e,t),So.init(e,t)}),jo=O("ZodBase64",(e,t)=>{$t.init(e,t),So.init(e,t)}),Lo=O("ZodBase64URL",(e,t)=>{Nt.init(e,t),So.init(e,t)}),Mo=O("ZodE164",(e,t)=>{Rt.init(e,t),So.init(e,t)}),Zo=O("ZodJWT",(e,t)=>{Ut.init(e,t),So.init(e,t)}),Fo=O("ZodNumber",(e,t)=>{qt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:r,maximum:i,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>=(r??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(i??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 r&&(o.minimum=r),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof i&&(o.maximum=i),"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(Cn(e,t))},min(e,t){return this.check(Cn(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(Cn(0,e))},negative(e){return this.check(An(0,e))},nonpositive(e){return this.check(In(0,e))},multipleOf(e,t){return this.check($n(e,t))},step(e,t){return this.check($n(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=O("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=O("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 Vo(e){return function(e,t){return new e({type:"boolean",...W(t)})}(Wo,e)}var Ho=O("ZodUnknown",(e,t)=>{Lt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Go(){return new Ho({type:"unknown"})}var Ko=O("ZodNever",(e,t)=>{Mt.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=O("ZodArray",(e,t)=>{Ft.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(r.minItems=a),"number"==typeof s&&(r.maxItems=s),r.type="array",r.items=Ln(i.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(Nn(e,t))},length(e,t){return this.check(Un(e,t))},unwrap(){return this.element}})});function er(e,t){return function(e,t,n){return new e({type:"array",element:t,...W(n)})}(Qo,e,t)}var tr=O("ZodObject",(e,t)=>{Vt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",r.properties={};const a=i.shape;for(const u in a)r.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=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(r.required=Array.from(l)),"never"===i.catchall?._zod.def.type?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=Ln(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)})(e,t,n,o),R(e,"shape",()=>t.shape),yo(e,"ZodObject",{keyof(){return dr(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(!Z(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(!Z(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,r={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(r[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)r[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return U(this,"shape",r),r},checks:[]}))}(hr,this,e[0])},required(...e){return t=kr,n=this,o=e[0],Y(n,q(n._zod.def,{get shape(){const e=n._zod.def.shape,r={...e};if(o)for(const n in o){if(!(n in r))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(r[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)r[n]=new t({type:"nonoptional",innerType:e[n]});return U(this,"shape",r),r}}));var t,n,o}})});function nr(e,t){const n={type:"object",shape:e??{},...W(t)};return new tr(n)}var or=O("ZodUnion",(e,t)=>{Gt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=!1===r.inclusive,a=r.options.map((e,n)=>Ln(e,t,{...o,path:[...o.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function rr(e,t){return new or({type:"union",options:e,...W(t)})}var ir=O("ZodDiscriminatedUnion",(e,t)=>{or.init(e,t),Kt.init(e,t)});function ar(e,t,n){return new ir({type:"union",options:t,discriminator:e,...W(n)})}var sr=O("ZodIntersection",(e,t)=>{Xt.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=Ln(r.left,t,{...o,path:[...o.path,"allOf",0]}),a=Ln(r.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]})(e,t,n,o)});var lr=O("ZodRecord",(e,t)=>{tn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if("loose"===i.mode&&s&&s.size>0){const e=Ln(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const t of s)r.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(r.propertyNames=Ln(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=Ln(i.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&&(r.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ur(e,t,n){return t&&t._zod?new lr({type:"record",keyType:e,valueType:t,...W(n)}):new lr({type:"record",keyType:wo(),valueType:e,...W(t)})}var cr=O("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 r={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);r[i]=t.entries[i]}return new cr({...t,checks:[],...W(o),entries:r})},e.exclude=(e,o)=>{const r={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete r[t]}return new cr({...t,checks:[],...W(o),entries:r})}});function dr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new cr({type:"enum",entries:n,...W(t)})}var pr=O("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,r=[];for(const i of o.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");r.push(Number(i))}else r.push(i);if(0===r.length);else if(1===r.length){const e=r[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),r.every(e=>"boolean"==typeof e)&&(n.type="boolean"),r.every(e=>null===e)&&(n.type="null"),n.enum=r})(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 fr(e,t){return new pr({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}var mr=O("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 r=t.transform(n.value,n);return r instanceof Promise?r.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function _r(e){return new mr({type:"transform",transform:e})}var hr=O("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 yr(e){return new hr({type:"optional",innerType:e})}var gr=O("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 br=O("ZodNullable",(e,t)=>{un.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=Ln(r.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function vr(e){return new br({type:"nullable",innerType:e})}var wr=O("ZodDefault",(e,t)=>{cn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;Ln(r.innerType,t,o),t.seen.get(e).ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Sr=O("ZodPrefault",(e,t)=>{pn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;Ln(r.innerType,t,o),t.seen.get(e).ref=r.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var kr=O("ZodNonOptional",(e,t)=>{fn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;Ln(r.innerType,t,o),t.seen.get(e).ref=r.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var Or=O("ZodCatch",(e,t)=>{_n.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;let i;Ln(r.innerType,t,o),t.seen.get(e).ref=r.innerType;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Er=O("ZodPipe",(e,t)=>{hn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def,i=r.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?r.out:r.in:r.out;Ln(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function xr(e,t){return new Er({type:"pipe",in:e,out:t})}var zr=O("ZodPreprocess",(e,t)=>{Er.init(e,t),gn.init(e,t)}),Tr=O("ZodReadonly",(e,t)=>{bn.init(e,t),go.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const r=e._zod.def;Ln(r.innerType,t,o),t.seen.get(e).ref=r.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var Ar=O("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 Ir(e,t){return new zr({type:"pipe",in:_r(e),out:t})}var Pr,Cr=dr(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),$r=dr(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),Nr=dr(["BROADCAST","AUTOMATION"]),Rr=dr(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),Ur=(nr({email:Oo(),name:wo().trim().min(1).nullable().optional(),customer_id:wo().uuid().nullable().optional(),tags:er(wo().trim().min(1)).default([]),consent_basis:Cr.default("UNKNOWN"),source:wo().trim().min(1).default("dashboard")}),nr({name:wo().trim().min(1),subject:wo().trim().min(1),preheader:wo().nullable().optional(),mjml_source:wo().trim().min(1),builder_project_json:ur(wo(),Go()).nullable().optional(),thumbnail_url:Tn(zo,Pr).nullable().optional()}),nr({mjml_source:wo().trim().min(1),sample_variables:ur(wo(),Go()).optional()}),nr({recipient_email:Oo(),sample_variables:ur(wo(),Go()).optional()}),nr({marketing_enabled:Vo().optional(),default_from_name:wo().trim().min(1).nullable().optional(),default_from_email:Oo().nullable().optional(),default_reply_to_email:Oo().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()}),nr({type:Nr.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:Oo(),reply_to_email:Oo().nullable().optional(),schedule_at:wo().datetime().nullable().optional(),target_emails:er(Oo()).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()}),nr({name:wo().trim().min(1),subject:wo().trim().min(1),template_id:wo().uuid(),from_name:wo().trim().min(1),from_email:Oo(),reply_to_email:Oo().nullable().optional(),trigger:Rr,delay_seconds:Bo().int().min(0).default(0),conditions:ur(wo(),Go()).default({})}),nr({trigger:Rr,email:Oo(),customer_id:wo().uuid().nullable().optional(),name:wo().trim().min(1).nullable().optional(),consent_basis:Cr.default("UNKNOWN"),variables:ur(wo(),Go()).default({}),idempotency_key:wo().trim().min(1).nullable().optional()}),nr({email:Oo(),reason:$r.default("ADMIN_BLOCK"),notes:wo().nullable().optional()}),["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"]),qr=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],Dr=["NOWPAYMENTS_WHITELABEL"],jr={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"]},Lr=Object.keys(jr),Mr=[...jr.USDT,...jr.USDC,...jr.DAI],Zr=[...Ur,...Mr],Fr=["BITCOIN_LN"],Br=[...qr,...Dr],Jr=[...Zr,...Fr],Yr=Zr,Wr=(new Set(["SHOPPEXPAY"]),new Set(Ur)),Vr=new Set(Mr),Hr=(new Set(Zr),new Set(Fr),new Set(qr),new Set(Dr),new Set(Br),new Set(Jr),new Set(Lr),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","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Gr(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Gr("COIN_GATEWAY_KEYS",Ur),Gr("TOKEN_GATEWAY_KEYS",Mr),Gr("CRYPTO_GATEWAY_KEYS",Zr),Gr("LEGACY_CRYPTO_GATEWAY_KEYS",Fr),Gr("CRYPTO_PROVIDER_KEYS",qr),Gr("MANAGED_CRYPTO_PROVIDER_KEYS",Dr),Gr("CRYPTO_PROVIDER_GATEWAY_KEYS",Br),Gr("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Yr),Gr("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"]),Gr("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 hc of Zr)if(!Wr.has(hc)&&!Vr.has(hc))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${hc}`);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=>function(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"}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 Hr[n]??n}(e))),new Set(["WHITE_LABEL","NATIVE"]);var Kr=[...Br,"NATIVE"],Xr=(new Set(Kr),nr({set:Vo()})),Qr=nr({status:dr(["READY","NEEDS_ATTENTION"]).optional(),code:wo().optional(),message:wo().optional(),checked_at:wo().optional()}),ei=(nr({provider:wo(),type:wo(),enabled:Vo(),connected:Vo(),credentials:ur(wo(),Xr),public_config:ur(wo(),Go()),webhook:ur(wo(),Go()).optional(),health:Qr.optional()}),"#2563eb"),ti=["comfortable","compact"],ni=["top","side","background"],oi=dr(["checkout","payment_link","embed"]),ri=dr(ti),ii=dr(["light","dark","system"]),ai=dr(ni),si=dr(["ghost","outlined","filled"]),li=dr(["sheet","fullscreen","center"]),ui=dr(["visible","hidden"]),ci=(dr(["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"]),dr(["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")),di=wo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),pi=wo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),fi=dr(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),mi=wo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),_i=wo().url(),hi=nr({brand:nr({logoUrl:_i.optional().nullable(),logoDarkUrl:_i.optional().nullable(),logoMaxHeight:Bo().int().min(16).max(80).optional(),faviconUrl:_i.optional().nullable()}).strict().optional(),color:nr({brand:ci.optional(),brandContrast:ci.optional(),background:ci.optional(),surface:ci.optional(),surfaceRaised:ci.optional(),text:ci.optional(),textMuted:ci.optional(),border:ci.optional(),focus:ci.optional(),success:ci.optional(),warning:ci.optional(),error:ci.optional()}).strict().optional(),typography:nr({fontFamily:fi.optional(),googleFontFamily:mi.optional(),baseSize:Bo().int().min(12).max(18).optional()}).strict().optional(),shape:nr({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:nr({density:ri.optional(),controlHeight:Bo().int().min(36).max(56).optional()}).strict().optional(),component:nr({primaryButton:nr({background:ci.optional(),text:ci.optional()}).strict().optional(),input:nr({background:ci.optional(),border:ci.optional(),focusRing:di.optional()}).strict().optional(),summary:nr({background:ci.optional()}).strict().optional(),paymentMethod:nr({background:di.optional(),cardBackground:di.optional(),border:di.optional(),selectedBackground:di.optional()}).strict().optional(),productCard:nr({background:di.optional(),border:di.optional(),shadow:pi.optional()}).strict().optional(),productImage:nr({background:di.optional(),border:di.optional(),icon:di.optional()}).strict().optional(),brandAvatar:nr({background:di.optional(),text:ci.optional(),border:di.optional()}).strict().optional(),pill:nr({background:di.optional(),border:di.optional(),text:ci.optional()}).strict().optional(),errorBanner:nr({background:di.optional(),border:di.optional(),text:ci.optional()}).strict().optional(),warningBanner:nr({background:di.optional(),border:di.optional(),text:ci.optional()}).strict().optional(),radio:nr({idleRing:di.optional(),checkedFill:ci.optional(),checkedIcon:ci.optional()}).strict().optional(),divider:nr({color:di.optional()}).strict().optional()}).strict().optional(),paymentLink:nr({heroImageUrl:_i.optional().nullable(),heroPosition:ai.optional()}).strict().optional(),embed:nr({launcher:nr({background:di.optional(),text:ci.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:pi.optional()}).strict().optional(),productCard:nr({background:di.optional(),border:di.optional(),imageRadius:Bo().int().min(0).max(24).optional(),padding:Bo().int().min(8).max(32).optional()}).strict().optional(),cart:nr({background:di.optional(),rowBorder:di.optional(),itemSpacing:Bo().int().min(4).max(28).optional()}).strict().optional(),modal:nr({background:di.optional(),radius:Bo().int().min(0).max(32).optional(),maxWidth:Bo().int().min(360).max(960).optional(),shadow:pi.optional()}).strict().optional(),backdrop:nr({color:di.optional(),blur:Bo().int().min(0).max(24).optional(),opacity:Bo().min(0).max(1).optional()}).strict().optional(),skeleton:nr({background:di.optional(),shimmer:di.optional()}).strict().optional(),spinner:nr({color:di.optional()}).strict().optional(),closeButton:nr({style:si.optional()}).strict().optional(),mobile:nr({layout:li.optional()}).strict().optional(),content:nr({productDescription:ui.optional(),termsShortcut:ui.optional()}).strict().optional()}).strict().optional()}).strict(),yi=nr({mode:ii.default("system"),fontSource:dr(["curated"]).default("curated")}).strict(),gi=dr(["standalone","bundle","pointer"]),bi=nr({name:wo().trim().min(1).max(80),fingerprint:wo().trim().min(1).max(128)}).strict(),vi=["embed_design"];function wi(e){if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=e;if(!vi.some(e=>e in t))return e;const n={...t};for(const o of vi)delete n[o];return n}var Si=Ir(wi,nr({type:fr("shoppex.style_theme"),surface:fr("checkout"),format_version:rr([fr(1),fr(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fr(1),tokens:hi.default({}),custom_css:wo().max(2e4).default(""),settings:yi.default({mode:"system",fontSource:"curated"}),_meta:ur(wo(),Go()).optional()}).strict()),ki=(Ir(wi,nr({type:fr("shoppex.style_theme"),surface:oi,format_version:rr([fr(1),fr(2)]),name:wo().trim().min(1).max(80),description:wo().trim().max(240).optional(),token_schema_version:fr(1),tokens:hi.default({}),custom_css:wo().max(2e4).default(""),settings:yi.default({mode:"system",fontSource:"curated"}),share_mode:gi.default("standalone"),parent_hint:bi.optional(),bundled_parent:Si.optional(),_meta:ur(wo(),Go()).optional()}).strict()),nr({theme_id:wo().uuid().nullable(),surface:oi,token_schema_version:fr(1),revision:Bo().int().min(1),tokens:hi,custom_css:wo(),css_variables:ur(wo(),wo())}).strict(),nr({theme_id:wo().uuid().nullable(),parent_theme_id:wo().uuid().nullable(),surface:fr("embed"),token_schema_version:fr(1),revision:Bo().int().min(1),parent_revision:Bo().int().min(1).nullable(),tokens:hi,custom_css:wo(),css_variables:ur(wo(),wo())}).strict(),nr({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(),nr({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:ur(wo(),wo()),custom_css:wo()}).strict(),nr({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:Vo().optional()}).strict(),dr(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal","live_chat"]),dr(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),Oi=(dr(["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")),Ei=dr(["static","marquee"]),xi=dr(["brand_blue","emerald","sunset","rose","charcoal","custom"]),zi=dr(["hide","message"]),Ti=dr(["compact","comfortable"]),Ai=dr(["subtle","outline","solid"]),Ii=dr(["minimal","boxed"]),Pi=dr(["indigo","emerald","amber","rose","slate","custom"]),Ci=dr(["compact","feature","alert"]),$i=dr(["compact","comfortable"]),Ni=dr(["subtle","outline","solid"]),Ri=dr(["sparkles","megaphone","gift","truck","shield","support","none"]),Ui=dr(["show","hide"]),qi=dr(["midnight","ocean","ember","forest","custom"]),Di=dr(["delay","exit_intent"]),ji=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 "/"'),Li=wo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Mi=nr({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:ji.optional().nullable(),dismissible:Vo().default(!1),displayMode:Ei.default("marquee"),themePreset:xi.default("custom"),animationSpeedSeconds:Bo().int().min(8).max(40).default(30),backgroundColor:Oi.default("#111827"),textColor:Oi.default("#f9fafb")}),Zi=nr({text:wo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Li,linkLabel:wo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:ji.optional().nullable(),dismissible:Vo().default(!1),themePreset:xi.default("brand_blue"),expiredBehavior:zi.default("hide"),expiredMessage:wo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:Ti.default("compact"),ctaStyle:Ai.default("subtle"),timerStyle:Ii.default("boxed"),backgroundColor:Oi.default("#111827"),textColor:Oi.default("#f9fafb")}),Fi=nr({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:ji.optional().nullable(),themePreset:Pi.default("indigo"),layoutStyle:Ci.default("feature"),density:$i.default("comfortable"),ctaStyle:Ni.default("outline"),icon:Ri.default("sparkles"),iconVisibility:Ui.default("show"),backgroundColor:Oi.default("#111827"),textColor:Oi.default("#f9fafb"),accentColor:Oi.default("#818cf8")}),Bi=nr({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:dr(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:er(wo().min(1)).max(50).default([])}),Ji=nr({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:qi.default("midnight"),trigger:Di.default("delay"),delaySeconds:Bo().int().min(0).max(60).default(6),showOncePerSession:Vo().default(!0),reminderHours:Bo().int().min(1).max(720).default(24),backgroundColor:Oi.default("#111827"),textColor:Oi.default("#f8fafc"),accentColor:Oi.default("#7c9cff"),heroImageUrl:ji.optional().nullable(),discountDisplay:wo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Li.optional().nullable()}),Yi=dr(["hidden","optional"]),Wi=nr({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:Yi.default("optional"),accentColor:Oi.default("#111827"),launcherIconColor:Oi.default("#f9fafb")}),Vi=nr({type:fr("announcement_bar"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Mi}),Hi=nr({type:fr("recent_purchase_popup"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Bi}),Gi=nr({type:fr("countdown_bar"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Zi}),Ki=nr({type:fr("promo_info_card"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Fi}),Xi=nr({type:fr("coupon_popup_modal"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Ji}),Qi=nr({type:fr("live_chat"),slot:ki,enabled:Vo().default(!0),sortOrder:Bo().int().min(0).max(999).default(0),config:Wi}),ea=(ar("type",[Vi,Gi,Ki,Hi,Xi,Qi]),ar("type",[Vi.extend({id:wo().min(1)}),Gi.extend({id:wo().min(1)}),Ki.extend({id:wo().min(1)}),Hi.extend({id:wo().min(1)}),Xi.extend({id:wo().min(1)}),Qi.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())),ur(wo(),Go())),ta=rr([wo(),Bo()]),na=nr({kind:dr(["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(),oa=nr({default_value:wo().optional(),min_length:Bo().optional(),name:wo(),placeholder:wo().optional(),regex:wo().optional(),required:Vo(),type:wo()}),ra=nr({id:wo(),price:Bo(),quantity:Bo(),title:wo()}),ia=nr({currency:wo(),description:wo(),id:wo(),price:Bo(),title:wo(),uniqid:wo()}),aa=nr({addons:er(ra).optional(),available_addons:er(Go()).optional(),cloudflare_image_id:wo().nullable(),created_at:wo().optional(),currency:wo(),custom_fields:ea.nullable().optional(),custom_fields_config:er(oa).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:dr(["minutes","hours","days"]).nullable().optional(),description:wo().nullable(),discount_percent:Bo().optional(),discount_display:Bo().optional(),discounted_total_display:Bo().optional(),gateways:er(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:Vo().optional(),price:wo().optional(),price_display:ta,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:ta.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()}),sa=nr({amount:Bo(),gateway:wo()}),la=nr({custom_tip_enabled:Vo().optional(),enabled:Vo(),preset_percentages:er(Bo()).optional()}),ua=nr({allow_partial_payment:Vo().optional(),auto_apply:Vo().optional(),available:wo(),currency:wo()}),ca=nr({affiliate_code:wo().nullable().optional(),already_paid:ta.nullable().optional(),amount_due:ta.nullable().optional(),currency:wo().nullable().optional(),discount:ta.nullable().optional(),discount_label:wo().nullable().optional(),gateway_fee:ta.nullable().optional(),platform_fee:ta.nullable().optional(),subtotal:ta.nullable().optional(),tip:ta.nullable().optional(),total:ta.nullable().optional()}),da=nr({active:Vo(),expires_at:wo()}),pa=nr({faq_url:wo().nullable(),support_email:wo().nullable(),support_url:wo().nullable(),telegram_invite:wo().nullable(),discord_invite_url:wo().nullable()}),fa=nr({currency:wo().nullable().optional(),enabled:Vo(),max_amount:Bo().nullable().optional(),min_amount:Bo().nullable().optional(),reason:dr(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),ma=nr({delivered_items:er(Go()),downloads:er(Go()),external_urls:er(Go()),license_keys:er(Go()),tracking_codes:er(Go())}),_a=nr({active:Vo().optional(),attempt_id:wo().optional(),buyer_actionable:Vo().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:dr(["BELOW_MINIMUM_COLLECTIBLE","PROVIDER_SESSION_CLOSED","PROVIDER_TOP_UP_UNSUPPORTED","MERCHANT_REVIEW_REQUIRED"]).nullable().optional()}),ha=nr({created_at:wo().nullable(),details:wo().nullable(),id:wo(),invoice_id:wo(),status:wo().nullable()}),ya=nr({billing_address_mode:dr(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:wo().nullable().optional(),display_name:wo().nullable().optional(),gateway:wo(),hide_provider_attribution:Vo().optional(),icon_url:wo().nullable().optional(),terms_mode:dr(["INHERIT","REQUIRED","DISABLED"]).optional()}),ga=nr({custom_fields:er(Go()).optional(),description:wo().nullable(),display_order:Bo(),icon_preset:wo().nullable(),icon_url:wo().nullable(),id:wo(),instructions:wo().nullable(),is_active:Vo().optional(),name:wo(),payment_type:dr(["INSTRUCTIONS","REDIRECT"]),redirect_url:wo().nullable(),require_proof:Vo(),proof_type:dr(["TEXT","IMAGE","BOTH"]).optional(),void_after_hours:Bo()}),ba=nr({email:nr({masked:wo().nullable(),persisted:Vo(),required_for_provider_session:Vo().optional()})}),va=nr({amount:wo().nullable(),confirmations:Bo().nullable(),created_at:Bo().optional(),hash:wo().nullable(),status:wo().optional()}),wa=nr({conf:nr({partial:Bo().optional(),void:Bo(),waiting_for_confirmations:Bo().optional()}),gateways:er(wo())}),Sa=nr({invoice_payable:Vo(),resumable:Vo(),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:Vo().optional(),payment_method_switch_locked:Vo().optional(),awaiting_payment_method:Vo().optional(),started_at:Bo().nullable().optional(),completed_at:Bo().nullable().optional()}),ka=Sa.extend({gateway:wo().nullable(),flow_type:wo().nullable(),status:wo().nullable(),manual_confirmation_pending:Vo(),payment_method_switch_locked:Vo()}),Oa=nr({theme_id:wo().nullable(),surface:dr(["checkout","payment_link","embed"]),token_schema_version:fr(1),revision:Bo(),tokens:ea,custom_css:wo(),css_variables:ur(wo(),wo())}),Ea=nr({link_id:wo(),source_gateway:wo().nullable(),invoice_uniqid:wo(),deprioritize_source_gateway:Vo().optional()}),xa=nr({enabled:Vo(),required:Vo(),connected:Vo()}),za=nr({gateway:wo().nullable().optional(),active_type:wo().nullable().optional(),percent_amount:ta.nullable().optional(),fixed_amount:ta.nullable().optional(),fixed_currency:wo().nullable().optional()}),Ta=nr({id:wo(),type:dr(["WALLET_CREDIT","COUPON"]),status:dr(["PENDING","FULFILLED","FAILED","REVOKED"]),amount:wo().nullable(),currency:wo().nullable(),coupon_code:wo().nullable(),reason:dr(["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()}),Aa=nr({summary:nr({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:wo().nullable(),currency:wo()}),activity:er(Ta),earned_after_invoice:er(Ta),pending_after_invoice:er(Ta)}),Ia=nr({already_paid_amount:ta.nullable().optional(),apm_method:wo().nullable().optional(),blockchain:wo().nullable(),buyer_identity:ba.nullable().optional(),checkout_tipping:la.nullable().optional(),country_regulations:wo().nullable().optional(),coupon_applied:Vo().optional(),crypto_mode:wo().nullable().optional(),crypto_transactions:er(va).optional(),currency:wo().nullable(),custom_fields:ea.nullable().optional(),custom_gateways:er(ga).optional(),customer_balance:ua.nullable().optional(),customer_email_masked:wo().nullable().optional(),dark_mode:rr([fr(0),fr(1)]).optional(),delivery:ma.optional(),delivery_info:ma.optional(),discount:Bo().optional(),discount_display:ta.optional(),eligible_gateways:er(wo()).optional(),environment:wo().optional(),fee_breakdown:ea.nullable().optional(),gateway:wo().nullable(),gateway_data:ea.nullable().optional(),gateway_eligibility:ur(wo(),fa).optional(),gateway_fee_previews:er(sa).optional(),gateways_available:er(wo()),license:rr([ea,fr(!1)]).optional(),name:wo().nullable(),paddle_token:wo().nullable().optional(),paddle_transaction_id:Go().optional(),payment_link_id:wo().nullable().optional(),payment_method_overrides:er(ya).optional(),payment_session_state:Sa.nullable().optional(),polling:da,pricing_breakdown:ca.nullable().optional(),product:er(aa).optional(),quantity:Bo().nullable(),rates_snapshot:ur(wo(),Bo()).optional(),remaining_amount:ta.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:rr([fr(0),fr(1)]).optional(),shop_image_name:wo().nullable(),shop_image_storage:wo().nullable().optional(),shop_payment_gateways_fees:er(ea).optional(),shop_paypal_credit_card:rr([fr(0),fr(1)]).optional(),shop_return_url:wo().nullable().optional(),shop_slug:wo().nullable().optional(),shop_terms_enabled:Vo().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:er(ha).optional(),status_history_legacy:er(ha).optional(),status_history_raw:er(ha).optional(),stripe_publishable_key:wo().nullable().optional(),stripe_user_id:wo().nullable().optional(),subtotal:Bo().optional(),subtype:wo().nullable().optional(),support:pa.optional(),theme:wo().optional(),tip_amount:ta.nullable().optional(),tip_amount_display:ta.nullable().optional(),tip_metadata:Go().optional(),total:ta,total_conversions:ea.optional(),total_display:ta,type:wo().nullable(),underpayment:_a.nullable().optional(),underpayment_status:wo().nullable().optional(),uniqid:wo(),void_times:er(wa).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:ta.optional(),crypto_confirmations_needed:Bo().nullable().optional(),crypto_exchange_rate:ta.nullable().optional(),crypto_received:ta.optional(),crypto_uri:wo().nullable().optional(),developer_invoice:Go().optional(),developer_return_url:wo().nullable().optional(),developer_title:wo().nullable().optional(),exchange_rate:ta.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:Vo().optional(),paypal_fee:ta.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()),Pa=aa.extend({available_addons:er(ia).optional(),delivery_instructions:wo().nullable().optional(),delivery_instructions_config:nr({enabled:fr(!0),required:Vo(),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()}),Ca=(nr({data:nr({invoice:Ia.extend({uniqid:wo().uuid(),shop_id:rr([wo(),Bo()]).nullable(),customer_email:wo().nullable(),checkout_style:Oa.nullable().optional(),coupon_id:wo().nullable().optional(),discount_breakdown:ea.nullable().optional(),affiliate_code:wo().nullable().optional(),country:wo().nullable().optional(),paypal_email:wo().nullable().optional(),pandabase_available_payment_methods:er(wo()).optional(),payment_rescue:Ea.nullable().optional(),discord_integration:xa.nullable().optional(),payment_session_state:ka.nullable().optional(),shop_payment_gateways_fees:er(za).optional(),product:er(Pa).optional(),products:er(Pa).optional(),rewards:Aa.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:Vo(),payment_session:na.nullable(),completion_access_grant:wo().nullable()}).passthrough()}).passthrough(),{maximumFractionDigits:3});function $a(e){if(!Number.isFinite(e))return e;const t=e<0?-1:1,n=Na(Math.abs(e),2),o=Math.round(n);return 0===o?0:t*Na(o,-2)}function Na(e,t){const[n,o="0"]=String(e).split("e");return Number(`${n}e${Number(o)+t}`)}var Ra=wo().nullable(),Ua=ur(wo(),Go()),qa=nr({logo_url:Ra,primary_color:wo(),secondary_color:wo(),accent_color:wo()}),Da=(nr({customer:nr({id:Ra,email:wo(),name:wo(),avatar_url:Ra,joined_at:Ra}),shop:nr({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:qa}),token:Ra}),nr({attachment_image_id:nr({cloudflare_image_id:Ra}).nullable()})),ja=nr({attachment_imageId:nr({cloudflareImageId:Ra}).nullable()}),La=nr({uniqid:wo(),status:wo(),total:wo(),total_display:Ra,currency:wo(),created_at:wo(),line_items:er(nr({product_title:Ra,quantity:Bo(),product:Da.nullable()}))}),Ma=nr({uniqid:wo(),status:wo(),total:wo(),totalDisplay:Ra,currency:wo(),createdAt:wo(),lineItems:er(nr({productTitle:Ra,quantity:Bo(),product:ja.nullable()}))}),Za=nr({invoices:er(Ma),pagination:nr({page:Bo(),limit:Bo(),total:Bo(),has_more:Vo()})}),Fa=nr({gateway:wo(),displayName:Ra,cryptoGateway:Ra.optional(),blockchain:Ra,cryptoAddress:Ra,apmMethod:Ra}),Ba=nr({id:wo(),uniqid:wo(),status:wo(),statusDetails:Ra,total:wo(),totalDisplay:Ra,subtotal:wo(),discount:wo(),discountDisplay:Ra,tax:wo(),taxPercentage:wo(),currency:wo(),createdAt:wo(),updatedAt:wo(),gatewayUpdatedAt:Ra,customFields:Ua.nullable(),balancePaidAmount:wo(),currentPaymentAttemptId:Ra,lineItems:er(nr({id:wo(),productTitle:wo(),productType:wo(),variantTitle:Ra,unitPrice:wo(),quantity:Bo(),total:wo(),deliveryText:Ra,deliverySummary:nr({codes:er(wo()),links:er(nr({label:wo(),value:wo(),href:Ra.optional()})),notes:er(wo()),serials:er(nr({value:wo(),is_replacement:Vo(),is_replaced:Vo()}))}).nullable(),deliveredAt:Ra,deliveryStatus:dr(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:Ua.nullable(),product:nr({uniqid:wo(),slug:Ra,serviceText:Ra,attachment_imageId:nr({cloudflareImageId:Ra}).nullable()}).nullable()})),currentPayment:Fa.nullable(),payments:er(Fa)}),Ja=(nr({quote:nr({enabled:Vo(),currency:wo(),min_amount:wo(),max_amount:Ra,bonus_tiers:er(nr({min_amount:wo(),bonus_percent:Bo()}))})}),nr({invoice_id:wo(),url:wo()}),nr({id:wo(),type:wo(),status:wo(),amount:Ra,currency:Ra,coupon_code:Ra,reason:wo(),trigger_reference_type:wo(),trigger_reference_id:wo(),created_at:Bo(),fulfilled_at:Bo().nullable(),expires_at:Bo().nullable()})),Ya=nr({summary:nr({available:wo(),pending:wo(),lifetime_earned:wo(),redeemed:Ra,currency:wo()}),activity:er(Ja),earned_after_invoice:er(Ja),pending_after_invoice:er(Ja)}),Wa=nr({id:wo(),uniqid:wo(),label:Ra,code:wo(),url:Ra,status:dr(["pending","active","inactive","rejected"]),is_primary:Vo(),total_clicks:Bo(),total_sales:Bo(),total_revenue:wo(),is_active:Vo(),is_approved:Vo(),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:Vo(),max_commission_shareback_percent:Bo(),created_at:Ra,updated_at:Ra}),Va=nr({customer:nr({id:wo(),email:wo(),name:Ra}).nullable(),state:wo(),can_create_custom_links:Vo(),custom_link_request_disabled_reason:Ra,custom_links_require_approval:Vo(),affiliate_codes_accepted_at_checkout:Vo(),cash_payout_enabled:Vo(),links:er(Wa),preferred_payout:nr({asset:wo(),network:wo(),address:wo()}).nullable(),balance_currency:wo(),balances:nr({pending:wo(),available:wo(),requested:wo(),converted:wo(),paid:wo(),approved_total:wo()}),commissions:er(nr({id:wo(),invoice_id:wo(),commission_amount:wo(),base_amount:wo(),discount_amount:wo(),status:wo(),created_at:Ra,paid_at:Ra,converted_at:Ra})),claims:er(nr({id:wo(),type:wo(),status:wo(),amount:wo(),currency:wo(),allocations:er(nr({source_type:wo(),commission_id:Ra,adjustment_id:Ra,amount:wo()})),wallet_transaction_id:Ra,payout_asset:Ra,payout_network:Ra,payout_address:Ra,note:Ra,metadata:Go(),completed_at:Ra,rejected_at:Ra,cancelled_at:Ra,created_at:Ra,updated_at:Ra}))}),Ha=nr({uniqid:wo(),status:wo(),gateway:wo(),current_period_start:wo(),current_period_end:wo(),trial_end:Ra,cancel_at_period_end:Vo(),canceled_at:Ra,created_at:wo(),plan:nr({id:wo(),uniqid:wo(),name:wo(),price:wo(),currency:wo(),interval:wo(),interval_count:Bo(),trial_days:Bo()}).nullable(),payment_method:nr({id:wo(),gateway:wo(),type:wo(),card_brand:Ra,card_last4:Ra,card_exp_month:Bo().nullable(),card_exp_year:Bo().nullable(),is_default:Vo()}).nullable(),actions:nr({can_pause:Vo(),can_resume:Vo(),can_cancel:Vo(),can_manage_payment_method:Vo()})}),Ga=nr({enabled:Vo(),account:nr({points_balance:Bo(),lifetime_points:Bo()}).nullable(),settings:nr({earn_rate_per_usd:Bo(),redeem_value_per_point:Bo(),min_redeem_points:Bo()}).nullable(),transactions:er(nr({type:dr(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:Bo(),balance_after:Bo(),description:Ra,created_at:wo()}))}),Ka=nr({redeemed_points:Bo(),wallet_amount:wo(),currency:wo(),points_balance:Bo(),replayed:Vo()}),Xa=nr({uniqid:wo(),invoice_uniqid:wo(),product_title:wo(),period_days:Bo(),starts_at:wo(),expires_at:wo(),status:dr(["ACTIVE","EXPIRED","VOIDED"]),claim_status:dr(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:wo()}),Qa=nr({warranties:er(Xa)}),es=nr({warranty:Xa.extend({claim_status:fr("REQUESTED")})}),ts=nr({shop:nr({id:wo(),slug:wo(),name:wo(),currency:wo(),branding:qa}),customer:nr({email:wo(),name:wo()}),stats:nr({invoices_count:Bo(),licenses_count:Bo(),deliverables_count:Bo(),tickets_count:Bo()}),wallet:nr({available:wo(),total:wo(),hold:wo(),currency:wo(),enabled:Vo()}).nullable(),rewards:Ya,affiliate:Va,invoices:er(La),subscriptions:er(Ha),licenses:er(nr({uniqid:wo(),invoice_id:wo(),status:wo(),license_key:wo(),hardware_id:Ra,expires_at:Bo().nullable(),renewable:Vo(),product:nr({title:wo().optional()}).optional()})),deliverables:er(nr({id:wo(),invoice_uniqid:wo(),product_title:wo(),kind:dr(["file","serial","license"]),label:wo(),value:wo(),href:Ra,created_at:wo()})),tickets:er(nr({uniqid:wo(),title:wo(),status:wo(),updated_at:wo(),created_at:Ra}))});var ns=null,os=null;var rs=null,is=null;function as(e,t){const n=t?.shopId?.trim();is=n||null;const o=rs?.locale;return o!==(rs={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}).locale&&r(),ns=null,os=null,rs}function ss(){if(!rs)throw new l;return rs}function ls(){return null!==rs}function us(e){is=e}function cs(){return is}function ds(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}var ps=-1;function fs(e,t,n){return!0!==t?e:!0===n?ps:0!==e?e:ps}function ms(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 hs(e){return fs(ms(e?.stock)??ps,e?.orderable,e?.supplier_backed)}function ys(e){if(!e)return ps;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return fs(ms(e.stock)??ps,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=>hs(e)):(Array.isArray(e.variants)?e.variants:[]).map(e=>hs(e))}(e);return t.length>0?t.some(e=>e<0)?ps:fs(t.reduce((e,t)=>e+Math.max(t,0),0),e.orderable,e.supplier_backed):fs(ms(e.stock)??ps,e.orderable,e.supplier_backed)}function gs(e){return!!function(e){return!!e&&(_s(e.on_hold)||_s(e.onHold)||_s(e.is_on_hold)||_s(e.isOnHold))}(e)||0===ys(e)}function bs(e){return!gs(e)}function vs(e=[]){const t=new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function ws(e,t=[]){const n=t instanceof Map?t:vs(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function Ss(e=[]){return Array.from(vs(e).values())}function ks(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function Os(e){return e.trim().toLowerCase()}function Es(e,t){const n=ks(t).toLowerCase();n&&e.push(n)}function xs(e){const t=[];Es(t,e.title),Es(t,e.slug??void 0),Es(t,e.description);for(const n of e.product_highlights??[])Es(t,n);for(const n of e.variants??[])Es(t,n.title);for(const n of e.price_variants??[])Es(t,n.title??n.label);return t}function zs(e,t){const n=Os(t);return!!n&&xs(e).some(e=>e.includes(n))}function Ts(e,t){const n=Os(t);if(!n)return!1;const o=ks(e.title).toLowerCase(),r=ks(e.slug??e.name??void 0).toLowerCase(),i=ks(e.description).toLowerCase();return o.includes(n)||r.includes(n)||i.includes(n)}function As(e,t){return 0!==e.length&&(!t||e.some(e=>bs(e)))}function Is(e,t,n,o){const r=Os(n);if(!r)return[];const i=!0===o?.hideOutOfStock,a=new Set,s=new Set,l=[],u=vs(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!Ts(d,r))continue;const t=ws(d,u);if(As(t,i)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=Ss(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&zs(d,r)&&(i&&!bs(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function Ps(e,t,n,o){const r=Is(e,t,n,o),i=new Set,a=[],s=e=>{e?.uniqid&&!i.has(e.uniqid)&&(o?.hideOutOfStock&&!bs(e)||(i.add(e.uniqid),a.push(e)))};for(const l of r)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 Cs(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 $s(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}var Ns=/:([A-Za-z0-9_]+)/g;function Rs(e,t){return e.replace(Ns,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const r=String(o).trim();if(!r)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(r)})}function Us(e){return`shoppex_${e}`}function qs(e){try{const t=localStorage.getItem(Us(e));return t?JSON.parse(t):null}catch{return null}}function Ds(e,t){try{localStorage.setItem(Us(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function js(e){try{localStorage.removeItem(Us(e))}catch{}}function Ls(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=qs(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 Ds(t,o),o}async function Ms(e){if(!ls())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=qs(t);return"number"==typeof o&&n-o<15e3||(Ds(t,n),!1)}(e))return;const t=ss(),n=cs(),o=n?Rs("/v1/storefront/shops/id/:id/ping",{id:n}):Rs("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),r=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:Ls(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)}}),i=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([r],{type:"application/json"});if(navigator.sendBeacon(i,e))return}await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0})}catch{}}var Zs=1e4;async function Fs(e){return new Promise(t=>setTimeout(t,e))}async function Bs(e,t={}){const n=t.baseUrl?null:ss(),o=n??(ls()?ss():null),{method:r="GET",body:i,timeout:l=Zs,retries:d,baseUrl:p,cache:f}=t,m=d??("GET"===r?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(),l),n=await fetch(_,{method:r,headers:h,body:i?JSON.stringify(i):void 0,signal:e.signal});clearTimeout(t);const o=await Js(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,r=Ws(o.data);if(r.code)throw new c(t,r.code,n.status,r.errorParams);throw new u(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 u("Invalid API response",n.status);return Ys(o.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new u("Request timeout",408));const o=n instanceof s?n.statusCode:void 0;if(y={message:n.message,statusCode:o,isTransport:void 0===o||408===o,...n instanceof c?{code:n.code,...n.errorParams?{errorParams:n.errorParams}:{}}:{}},n instanceof c&&void 0!==o&&o>=400&&o<500&&408!==o)break;if(t<m){await Fs(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"===r&&f&&f.ttl>0?await a(f.key??`GET:${_}`,g,{ttl:f.ttl,staleWhileRevalidate:f.staleWhileRevalidate},e=>e.success):await g(),v=y;return!b.success&&v?.isTransport&&await Ms({endpoint:e,method:r,message:b.message??v.message,statusCode:v.statusCode,attemptCount:m+1,requestUrl:_,responseReceived:void 0!==v.statusCode&&408!==v.statusCode}),b}async function Js(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 Ys(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}`,...Ws(e)}}function Ws(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 Vs(e,t){return Bs(e,{...t,method:"GET"})}async function Hs(e,t,n){return Bs(e,{...n,method:"POST",body:t})}var Gs=3e5;async function Ks(){const e=ss(),t=await Vs(Rs("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:Gs,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&us(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function Xs(e){const t=ss(),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()}`:"",r=await Vs(`${Rs("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:Gs,staleWhileRevalidate:!0}});return r.success&&r.data?(r.data.shop?.id&&us(r.data.shop.id),{success:!0,data:{shop:r.data.shop,products:r.data.products??[],products_pagination:r.data.products_pagination??null,groups:r.data.groups??[],items:r.data.items??[],categories:r.data.categories??[],addons:r.data.addons??{items:[]}}}):{success:!1,message:r.message}}var Qs=12e4;function el(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 tl(){const e=ss(),t=await Vs(Rs("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:Qs,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:Ss(t.data.products.map(el))}:{success:!1,message:t.message,data:[]}}var nl="shoppex:affiliate_code:v1";function ol(){return Date.now()}function rl(e){const t=e?.trim().toLowerCase();return t||null}function il(e,t=30){const n=rl(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(nl,JSON.stringify(e))}catch{}}({code:n,expiresAt:ol()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(al(),null);var o}function al(){if("undefined"!=typeof window)try{window.localStorage.removeItem(nl)}catch{}}function sl(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(nl);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<=ol()?(al(),null):rl(e.code):null}async function ll(e){const t=rl(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=ss(),o=await Hs("/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:rl(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 ul(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 cl(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:ul(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 dl(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:cl(e)}}function pl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function fl(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return pl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return pl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}var ml={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function _l(e){return`${ml[e]}_${ss().storeSlug}`}function hl(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 yl(e){if(!Number.isFinite(e))throw new d("quantity must be a finite number");return Math.floor(e)}function gl(e){const t=e?.trim().toUpperCase();return t||null}function bl(){const e=qs(_l("coupon"));if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,n="string"==typeof t.code?gl(t.code):null,o="COUPON"===t.source||"AFFILIATE"===t.source?t.source:null;return n&&o?{code:n,source:o}:null}function vl(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():"",r="string"==typeof e.variant_id?e.variant_id.trim():"",i=Number(e.quantity);if(!o||!r||!Number.isFinite(i)||i<1)continue;const a={line_id:"",product_id:o,variant_id:r,quantity:Math.floor(i)};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),Al(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||cl(a),t.push(dl(a))}return t}function wl(){return qs(_l("meta"))}function Sl(){return bl()?.code??null}function kl(){return bl()?.source??null}function Ol(e,t="COUPON"){const n=gl(e);return n?(Ds(_l("coupon"),{code:n,source:t}),n):(js(_l("coupon")),null)}function El(){js(_l("coupon"))}function xl(e){const t=vl(e);Ds(_l("cart"),t);const n=Date.now(),o=wl(),r={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:hl(t)};Ds(_l("meta"),r),0===t.length&&El()}function zl(e,t){const n=vl(e);Ds(_l("cart"),n);const o=Date.now(),r=t??wl(),i={created_at:r?.created_at??o,last_modified:o,version:r?.version??1,checksum:hl(n)};Ds(_l("meta"),i)}function Tl(){return vl(qs(_l("cart")))}function Al(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 Il(){js(_l("cart")),js(_l("meta")),El(),Nl=null,Rl+=1}function Pl(){const e=Tl();Ds(_l("cartBackup"),e);const t=bl();t?Ds(_l("couponBackup"),t):js(_l("couponBackup"));const n=wl();if(n)Ds(_l("metaBackup"),n);else{const t=Date.now();Ds(_l("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:hl(e)})}}function Cl(){const e=Tl(),t=wl(),n=hl(e);return t?t.checksum===n:(zl(e,null),!0)}function $l(){const e=Sl();return"AFFILIATE"===kl()&&e?e.trim().toLowerCase():sl()}var Nl=null,Rl=0;function Ul(){return Nl}var ql="Your cart changed while checkout was starting. Please review it and try again.";function Dl(e,t){return void 0!==t&&JSON.stringify(e)!==t}function jl(e){const t=e?.trim();return t||null}function Ll(e){const t=e?.trim();return t||null}function Ml(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 Zl(e){return pl(e.currency)??fl()??pl(ss().currency)}function Fl(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(Bl(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 Bl(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 Jl(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),r=new URL(o);if(t.origin!==r.origin)return null;const i=t.pathname.replace(/\/+$/,""),a=`${r.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!i.startsWith(a))return null;const s=i.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 Yl(e,t){const n=Ll(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 Wl(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 r=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!r&&o&&n&&(r=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&&r?{invoiceId:o,checkoutUrl:r,rewards:e?.rewards??n?.rewards??null}:null}function Vl(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function Hl(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()??sl()}function Gl(e){const t=Sl(),n=kl();return{coupon:void 0===e.coupon?"COUPON"===n?t:null:jl(e.coupon),affiliateCode:Hl(e,void 0===e.coupon&&"AFFILIATE"===n?t:null)}}function Kl(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 Xl(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 Ql(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function eu(e,t){const n=e,o=Xl(n.rating)??Xl(n.score)??0,r=Ql(n.comment,n.message),i=Ql(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=Ql(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...r?{comment:r}:{},...i?{author:i}:{},created_at:s}}async function tu(e){const t=ss(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,r=await Vs(`${Rs("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return r.success&&r.data?{success:!0,data:{...r.data,feedback:r.data.feedback.map(eu)}}:{success:!1,message:r.message}}function nu(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ou(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 ru(e){const t="string"==typeof e.error_code&&e.error_code.length>0?e.error_code:null;return t?{code:t,...nu(e.error_params)?{errorParams:e.error_params}:{}}:{}}async function iu(e,t={}){const n=t.method??"GET",o={Accept:"application/json"};void 0!==t.body&&(o["Content-Type"]="application/json");const r=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:r,credentials:"same-origin",cache:"no-store"});if(204===a.status)return a.ok?{success:!0,status:a.status}:{success:!1,status:a.status,message:ou({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=nu(i=s)&&"number"==typeof i.status&&"data"in i?i: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:ou(l,a),...ru(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 i}function au(e){return iu("/auth/otp/request",{method:"POST",body:{email:e}})}function su(e,t){return iu("/auth/otp/verify",{method:"POST",body:{email:e,otp:t}})}function lu(){return iu("/auth/logout",{method:"POST"})}function uu(){return iu("/me")}function cu(){return iu("/dashboard",{schema:ts})}function du(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),iu("/invoices"+(t.size>0?`?${t.toString()}`:""),{schema:Za})}function pu(e){return iu(`/invoice/${encodeURIComponent(e)}`,{schema:Ba})}function fu(){return iu("/loyalty",{schema:Ga})}function mu(e){return iu("/loyalty/redeem",{method:"POST",body:{points:e.points,idempotency_key:e.idempotencyKey},schema:Ka})}function _u(e){return iu("/warranties"+(e?`?invoice=${encodeURIComponent(e)}`:""),{schema:Qa})}function hu(e,t){return iu(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",body:t?{message:t}:{},schema:es})}function yu(e){return iu(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",body:{}})}function gu(e){return iu(`/subscriptions/${encodeURIComponent(e)}/billing-history`)}function bu(e,t={}){return iu(`/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 vu(e){return iu(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",body:{}})}function wu(e){return iu(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",body:{}})}function Su(){return iu("/favorites")}function ku(e){return iu(`/favorites/${encodeURIComponent(e)}`,{method:"PUT"})}function Ou(e){return iu(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE"})}function Eu(){return iu("/affiliate")}function xu(e){return iu("/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 zu(e){return iu(`/tickets/${encodeURIComponent(e)}`)}function Tu(e,t){return iu(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",body:{message:t}})}function Au(e){return iu("/profile",{method:"POST",body:{name:e.name}})}function Iu(e){const t=new FormData;return t.append("file",e),iu("/profile/avatar",{method:"POST",formData:t})}function Pu(){return iu("/profile/avatar",{method:"DELETE"})}function Cu(){return iu("/email-marketing/preferences")}function $u(e){return iu("/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 Nu(){return iu("/sessions")}function Ru(e){return iu(`/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Uu(){return iu("/sessions?others=true",{method:"DELETE"})}function qu(){return iu("/reseller")}function Du(e){return iu("/reseller/apply",{method:"POST",body:void 0===e?{}:{note:e}})}function ju(){return iu("/reseller/enroll",{method:"POST",body:{}})}function Lu(e){return iu("/reseller/accept-invite",{method:"POST",body:{token:e}})}function Mu(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)),iu("/reseller/catalog"+(t.size>0?`?${t.toString()}`:""))}function Zu(e){return iu("/reseller/orders/quote",{method:"POST",body:{items:e}})}function Fu(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)),iu("/reseller/orders"+(t.size>0?`?${t.toString()}`:""))}function Bu(e){return iu(`/reseller/orders/${encodeURIComponent(e)}`)}function Ju(){return iu("/reseller/wallet")}function Yu(){return iu("/reseller/api-keys")}function Wu(e){const t=e.trim();return t||null}var Vu=3e5;var Hu=3e5;async function Gu(){const e=ss(),t=await Vs(Rs("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:Hu,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function Ku(e){const t=ss(),n=await Vs(Rs("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:Hu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function Xu(e){return Ku(e)}async function Qu(e){const t=ss(),n=await Vs(Rs("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:Hu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function ec(e){return function(e){const t=S[e];return[t.title,...t.aliases]}(e)}var tc=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function nc(e){return`shoppex:utm:${e}`}function oc(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 tc){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(nc(e),JSON.stringify(n))}catch{}}(e,t),t;const n=function(e){try{const t=window.localStorage.getItem(nc(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(nc(e)),{};const o={};for(const e of tc){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 rc(e,t){if(!ls())return;if("undefined"==typeof document)return;const n=ss(),o=Ls(n.storeSlug);try{const r=Rs("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${r}`,{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:oc(n.storeSlug)})})}catch{}}async function ic(){if(!ls())return{success:!1,message:"SDK not initialized"};const e=ss(),t=cs();return Vs(t?Rs("/v1/storefront/shops/id/:id/recent-sales",{id:t}):Rs("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function ac(){if(!ls())return{success:!1,message:"SDK not initialized"};const e=ss(),t=cs();return Vs(t?Rs("/v1/storefront/shops/id/:id/online-users",{id:t}):Rs("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function sc(){if(!ls())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=ss(),t=cs();return Hs(t?Rs("/v1/storefront/shops/id/:id/ping",{id:t}):Rs("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:Ls(e.storeSlug)??void 0,utm:oc(e.storeSlug)},{retries:0,timeout:5e3})}function lc(e,t){const n=ss();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD",...Ca})}function uc(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function cc(e){return uc(e)&&uc(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:uc(e.theme.content)?e.theme.content:{},layout:uc(e.theme.layout)?e.theme.layout:{},style_slots:uc(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...uc(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function dc(e){const t=await Vs(Rs("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?uc(n=t.data)?{settings:uc(n.settings)?n.settings:{},builder_settings:cc(n.builder_settings),content:uc(n.content)?n.content:{},style_slots:uc(n.style_slots)?n.style_slots:{}}:null:null;var n}async function pc(e){const t=await dc(e);return t?t.settings:null}function fc(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,r]of Object.entries(o))t[n][e]=r.default}return t}function mc(e,t){const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]={...n[o],...r});return n}var _c={init:function(e,t){"string"==typeof e?as(e,t):as(e.storeId,e)},isInitialized:ls,getConfig:ss,client:function(e){const t=ss().apiBaseUrl??"https://api.shoppex.io";if(ns&&os===t&&!e)return ns;const n=function(e,t){return f({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(ns=n,os=t),n},getStore:Ks,getStorefront:Xs,getStoreLogoUrl:async function(){const e=await Ks();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await Ks();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(),r=t??(ls()?ss().apiBaseUrl:"https://api.shoppex.io"),i=await Vs(Rs("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:r,cache:{key:`store:domain:${o}`,ttl:Gs,staleWhileRevalidate:!0}});return i.success&&i.data?.shop?(i.data.shop.id&&us(i.data.shop.id),{success:!0,data:i.data.shop}):{success:!1,message:i.message??"Failed to resolve store"}},getProducts:tl,getStorefrontProductsPage:async function(e){const t=ss(),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()}`:"",r=await Vs(`${Rs("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${i=e?.category,void 0===i?"category:unset":null===i?"category:null":`category:${i}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:Qs,staleWhileRevalidate:!0}});var i;return r.success&&r.data?{success:!0,data:{products:r.data.products.map(el),pagination:r.data.pagination??null}}:{success:!1,message:r.message}},getProduct:async function(e){let t=cs();if(!t){const e=await Ks();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await Vs(`${Rs("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:Qs,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:el(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await tl();if(!e.success||!e.data)return{success:!1,message:e.message};const t=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:Tl,getCartItemCount:function(){return Tl().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:Sl,getCartCouponSource:kl,setCartCoupon:Ol,clearCartCoupon:El,addToCart:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const r=yl(n);if(r<1)throw new d("quantity must be at least 1");const i=Tl(),a=cl({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=i.findIndex(e=>e.line_id===a);if(s>=0)i[s].quantity+=r,o?.addons&&(i[s].addons=o.addons),o?.custom_fields&&(i[s].custom_fields=o.custom_fields),o?.price_variant_id&&(i[s].price_variant_id=o.price_variant_id),o?.price_data&&(i[s].price_data=o.price_data),void 0!==o?.pay_what_you_want_price&&(i[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)}(i[s],o),Al(i[s]);else{const n={line_id:a,product_id:e,variant_id:t,quantity:r,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};Al(n),i.push(n)}xl(i)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new d("product_id and variant_id are required");const r=yl(n);if(r<1)throw new d("quantity must be at least 1");const i=Tl(),a=cl({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=i.length-1;l>=0;l-=1)i[l].product_id===e&&i[l].variant_id===t&&i.splice(l,1);const s={line_id:a,product_id:e,variant_id:t,quantity:r,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};Al(s),i.push(s),xl(i)},updateCartItem:function(e,t){const n=Tl(),o=e.trim();if(!o)throw new d("line_id is required");const r=n.findIndex(e=>e.line_id===o);if(r<0)throw new d("Item not found in cart");const i=JSON.stringify(n);if(void 0!==t.quantity){const e=yl(t.quantity);if(e<1)return n.splice(r,1),void xl(n);n[r].quantity=e}void 0!==t.addons&&(n[r].addons=t.addons),void 0!==t.custom_fields&&(n[r].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[r].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[r].price_data=t.price_data),void 0!==t.pay_what_you_want_price&&(n[r].pay_what_you_want_price=t.pay_what_you_want_price),void 0!==t.max_quantity&&(null===t.max_quantity?delete n[r].max_quantity:n[r].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(null===t.min_quantity?delete n[r].min_quantity:n[r].min_quantity=t.min_quantity),Al(n[r]);const a=cl(n[r]),s=n.findIndex((e,t)=>t!==r&&e.line_id===a);s>=0?(n[s].quantity+=n[r].quantity,Al(n[s]),n.splice(r,1)):n[r].line_id=a,JSON.stringify(n)!==i&&xl(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new d("line_id is required");xl(Tl().filter(e=>e.line_id!==t))},clearCart:Il,createCartBackup:Pl,restoreCartFromBackup:function(){const e=vl(qs(_l("cartBackup"))),t=qs(_l("metaBackup")),n=qs(_l("couponBackup"));if(e&&e.length>0){if(zl(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?Ol(e.code,t):El()}else El();return!0}return!1},mergeBaskets:function(e){const t=Tl();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 r;try{r=yl(n.quantity)}catch{continue}if(r<1)continue;const i=dl({...n,line_id:n.line_id??cl(n),product_id:e,variant_id:o,quantity:r}),a=t.findIndex(e=>e.line_id===i.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,r),Al(t[a])):(Al(i),t.push(i))}return xl(t),t},moveBasketItem:function(e,t,n,o){const r=Tl(),i=r.findIndex(n=>n.product_id===e&&n.variant_id===t);if(i<0)throw new d("Item not found in cart");const[a]=r.splice(i,1),s=cl({...a,product_id:n,variant_id:o}),l=r.findIndex(e=>e.line_id===s);if(l>=0)r[l].quantity+=a.quantity,Al(r[l]);else{const e=dl({...a,product_id:n,variant_id:o,line_id:s});Al(e),r.push(e)}xl(r)},getCartStats:function(){const e=Tl(),t=Cl(),n=wl(),o=qs(_l("cartBackup"))??[],r=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),i=e.reduce((e,t)=>e+$a((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:$a(i),total_price_is_estimate:e.length>0&&!r}},validateCartIntegrity:Cl,quoteCart:async function(e,t){const n=Rl+=1,o=function(e){const t=ss(),n=gl(e)??Sl()??void 0;return{store_slug:t.storeSlug,items:Tl(),coupon:n}}(e),r=pl(t)??fl()??pl(ss().currency),i=await Hs("/v1/storefront/cart/quote",{shop_slug:o.store_slug,cart:o.items,coupon:o.coupon,affiliate_code:$l()??void 0,currency:r??void 0});return n!==Rl||i.success&&(Nl="string"==typeof i.data?.quote_token?i.data.quote_token:null),i},resolveCartLineId:function(e,t,n=Tl()){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=Vl(e,t),{autoRedirect:o=!0,email:r}=n,i=Gl(n),a=i.coupon,s=Ll(r),l=i.affiliateCode,u=Zl(n),c=Tl();if(0===c.length)return{success:!1,message:"Cart is empty"};if(Dl(c,n.expectedCart))return{success:!1,message:ql};Pl();const d=ss(),p=Ml(n),f=await Hs(p.endpoint,{shop_slug:d.storeSlug,cart:Kl(c),email:s,coupon:a,currency:u,affiliate_code:l,quote_token:Ul()??void 0},{retries:0,baseUrl:p.baseUrl});if(!f.success||!f.data)return Bl(f.message)&&Il(),{success:!1,message:Fl(f.message),...f.code?{code:f.code}:{}};const m=Wl(f.data,d.checkoutBaseUrl);if(!m)return{success:!1,message:"Failed to create invoice"};const{invoiceId:_}=m,h=Jl(m.checkoutUrl,d.checkoutBaseUrl,_);if(!h)return{success:!1,message:"Failed to create invoice"};const y=Yl(h,{email:s,locale:n.locale??d.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=y,Il()),{success:!0,redirectUrl:y,invoiceId:_,rewards:m.rewards}},buildCheckoutUrl:async function(e,t){const n=Vl(e,t),{email:o}=n,r=Gl(n),i=r.coupon,a=Ll(o),s=r.affiliateCode,l=Zl(n),u=Tl();if(0===u.length)throw new Error("Cart is empty");if(Dl(u,n.expectedCart))throw new Error(ql);const c=ss(),d=Ml(n),p=await Hs(d.endpoint,{shop_slug:c.storeSlug,cart:Kl(u),email:a,coupon:i,currency:l,affiliate_code:s,quote_token:Ul()??void 0},{retries:0,baseUrl:d.baseUrl});if(!p.success||!p.data)throw Bl(p.message)&&Il(),new Error(Fl(p.message));const f=Wl(p.data,c.checkoutBaseUrl);if(!f)throw new Error("Failed to create invoice");const m=Jl(f.checkoutUrl,c.checkoutBaseUrl,f.invoiceId);if(!m)throw new Error("Failed to create invoice");return Yl(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=rl(t),!t)return null;if(il(t),ls())try{const e=ss(),n=await Hs("/v1/storefront/affiliates/attribution",{shop_slug:e.storeSlug,code:t},{retries:0});return n.success&&n.data?.accepted&&n.data?.affiliate_code?(il(n.data.affiliate_code),n.data.affiliate_code):(al(),null)}catch{return t}return t},validateAffiliateCode:ll,applyAffiliateCode:async function(e){const t=await ll(e);return t.success&&t.data?.affiliate_code&&il(t.data.affiliate_code),t},getAffiliateCode:sl,setAffiliateCode:il,clearAffiliateCode:al,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},r="string"==typeof t?t:t?.productId,i="string"==typeof t?void 0:t?.variantId;if(i&&!r)return{success:!1,message:"productId is required when variantId is provided"};if(r)o.product_id=r,i&&(o.variant_id=i);else{const e=Tl();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=cs();if(e)return e;const t=await Ks();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 Hs("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=new Set;let n=null;for(;;){const o=await tu(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...o.data.feedback);const r=o.data.pagination;if(!r?.has_more||!r.next_cursor)break;if(t.has(r.next_cursor))break;t.add(r.next_cursor),n=r.next_cursor}return{success:!0,data:e}},getShopReviewsPage:tu,requestOtp:au,verifyOtp:su,logout:lu,me:uu,dashboard:cu,orders:du,order:pu,loyalty:fu,redeemLoyaltyPoints:mu,warranties:_u,claimWarranty:hu,resetLicenseHwid:yu,subscriptionBillingHistory:gu,cancelSubscription:bu,pauseSubscription:vu,resumeSubscription:wu,favorites:Su,addFavorite:ku,removeFavorite:Ou,affiliate:Eu,createTicket:xu,ticket:zu,replyToTicket:Tu,updateProfile:Au,updateAvatar:Iu,removeAvatar:Pu,emailPreferences:Cu,updateEmailPreferences:$u,sessions:Nu,revokeSession:Ru,revokeAllSessions:Uu,reseller:qu,applyForReseller:Du,enrollAsReseller:ju,acceptResellerInvite:Lu,resellerCatalog:Mu,quoteResellerOrder:Zu,resellerOrders:Fu,resellerOrder:Bu,resellerWallet:Ju,resellerApiKeys:Yu,searchProducts:async function(e,t){if(!ls())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Xs();return o.success&&o.data?{success:!0,data:Ps(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(!ls())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Xs();return o.success&&o.data?{success:!0,data:Is(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=Wu(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await Vs(Rs("/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=Wu(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await Vs(Rs("/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=ss(),t=await Vs(Rs("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:Vu,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=ss(),n=await Vs(Rs("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:Vu,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:Gu,getMenu:Xu,getMenuBySlot:Qu,getMenuByTitle:Ku,getMenuSlotTitles:ec,trackPageView:rc,getStorefrontOnlineUsers:ac,getStorefrontRecentSales:ic,touchStorefrontPresence:sc,createFormatter:lc,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?lc(t,n).format(0):lc(t,n).format(o)},clearCache:r,invalidateCache:function(e){for(const n of t.keys())(n===e||n.startsWith(e))&&t.delete(n)},getCacheStats:function(){return{hits:o.hits,misses:o.misses,pendingRequests:n.size,entries:t.size}},fetchPublishedBuilderSettings:dc,fetchPublishedThemeSettings:pc,resolveDefaults:fc,mergeSettings:mc};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=_c)}e.ApiError=c,e.CATALOG_UNIT_PRICE_DECIMAL_PLACES=3,e.CATALOG_UNIT_PRICE_FORMAT_OPTIONS=Ca,e.CartError=d,e.NetworkError=u,e.NotInitializedError=l,e.PAYABLE_AMOUNT_DECIMAL_PLACES=2,e.ShoppexError=s,e.ValidationError=class e extends s{constructor(t,n){super(t,"VALIDATION_ERROR"),this.name="ValidationError",this.invalidFields=n,Object.setPrototypeOf(this,e.prototype)}},e.acceptResellerInvite=Lu,e.addFavorite=ku,e.affiliate=Eu,e.applyForReseller=Du,e.buildStorefrontContactMessage=$s,e.buildStorefrontCustomFieldPayload=function(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(ds(o)&&(n[e.name]="true"));const r=o.trim();r.length>0&&(n[e.name]=r)}),n},e.buildStorefrontProductLookup=vs,e.cancelSubscription=bu,e.claimWarranty=hu,e.collectProductSearchHaystack=xs,e.computeCartLineId=cl,e.createTicket=xu,e.dashboard=cu,e.default=_c,e.shoppex=_c,e.emailPreferences=Cu,e.enrollAsReseller=ju,e.ensureCartLineId=dl,e.favorites=Su,e.fetchPublishedBuilderSettings=dc,e.fetchPublishedThemeSettings=pc,e.filterProductsBySearchQuery=function(e,t,n){const o=Os(t);if(!o)return[];let r=e.filter(e=>zs(e,o));return n?.hideOutOfStock&&(r=r.filter(e=>bs(e))),null!=n?.maxResults?r.slice(0,n.maxResults):r},e.getMenu=Xu,e.getMenuBySlot=Qu,e.getMenuByTitle=Ku,e.getMenuSlotTitles=ec,e.getMenus=Gu,e.getMergedStorefrontProducts=Ss,e.getShopReviewsPage=tu,e.getStorefrontGroupProducts=ws,e.getStorefrontOnlineUsers=ac,e.getStorefrontRecentSales=ic,e.groupMatchesSearchQuery=Ts,e.isProductInStock=bs,e.isProductOutOfStock=gs,e.isStorefrontCheckboxCustomFieldValueChecked=ds,e.isVariantOutOfStock=function(e){return 0===hs(e)},e.logout=lu,e.loyalty=fu,e.me=uu,e.mergeSettings=mc,e.normalizeSearchQuery=Os,e.normalizeStorefrontCustomFields=function(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)},e.order=pu,e.orders=du,e.pauseSubscription=vu,e.productMatchesSearchQuery=zs,e.quoteResellerOrder=Zu,e.redeemLoyaltyPoints=mu,e.removeAvatar=Pu,e.removeFavorite=Ou,e.replyToTicket=Tu,e.requestOtp=au,e.reseller=qu,e.resellerApiKeys=Yu,e.resellerCatalog=Mu,e.resellerOrder=Bu,e.resellerOrders=Fu,e.resellerWallet=Ju,e.resetLicenseHwid=yu,e.resolveDefaults=fc,e.resolveDisplayStock=ys,e.resolveStorefrontApiBaseUrl=Cs,e.resolveStorefrontSocialLinks=function(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}},e.resolveVariantStockValue=hs,e.resumeSubscription=wu,e.revokeAllSessions=Uu,e.revokeSession=Ru,e.roundPayableAmount=$a,e.searchMergedStorefrontCatalog=Ps,e.searchMergedStorefrontCatalogItems=Is,e.sessions=Nu,e.stripHtmlFromText=ks,e.submitStorefrontContactTicket=async function(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()??"",r=o.length>=2?o.slice(0,30):"Contact Request",i=$s({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=Cs({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:r,message:i,...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}},e.subscriptionBillingHistory=gu,e.ticket=zu,e.touchStorefrontPresence=sc,e.trackPageView=rc,e.updateAvatar=Iu,e.updateEmailPreferences=$u,e.updateProfile=Au,e.validateStorefrontCustomFieldValue=function(e,t){if("checkbox"===e.type)return e.required&&!ds(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},e.verifyOtp=su,e.warranties=_u});
2
2
  //# sourceMappingURL=shoppex.umd.js.map