@shoppexio/storefront 1.0.45 → 1.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/customer.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e;function t(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const i=o.prototype,s=Object.keys(i);for(let e=0;e<s.length;e++){const t=s[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class s extends i{}function o(e){var t;const i=n?.Parent?new s:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(e=globalThis).__zod_globalConfig??(e.__zod_globalConfig={});var i=globalThis.__zod_globalConfig;function s(e){return e&&Object.assign(i,e),i}function o(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 a(e,t){return"bigint"==typeof t?t.toString():t}function u(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function c(e){return null==e}function d(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var l=Symbol("evaluating");function p(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==l)return void 0===r&&(r=l,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function h(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function f(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function m(e){return JSON.stringify(e)}var _="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var y=u(()=>{if(i.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function g(e){if(!1===v(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!==v(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return g(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var w=new Set(["string","number","symbol"]);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function S(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 E={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 $(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 I(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 T(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function O(e){return"string"==typeof e?e:e?.message}function P(e,t,n){const r=e.message?e.message:O(e.inst?._zod.def?.error?.(e))??O(t?.error?.(e))??O(n.customError?.(e))??O(n.localeError?.(e))??"Invalid input",{inst:i,continue:s,input:o,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=o),a}function x(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function N(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var A=(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,a,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Z=t("$ZodError",A),q=t("$ZodError",A,{Parent:Error});var j=e=>(t,r,i,o)=>{const a=i?{...i,async:!1}:{async:!1},u=t._zod.run({value:r,issues:[]},a);if(u instanceof Promise)throw new n;if(u.issues.length){const t=new(o?.Err??e)(u.issues.map(e=>P(e,a,s())));throw _(t,o?.callee),t}return u.value},C=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>P(e,o,s())));throw _(t,i?.callee),t}return a.value},D=e=>(t,r,i)=>{const o=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new n;return a.issues.length?{success:!1,error:new(e??Z)(a.issues.map(e=>P(e,o,s())))}:{success:!0,data:a.value}},R=D(q),U=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>P(e,i,s())))}:{success:!0,data:o.value}},F=U(q),J=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return j(e)(t,n,i)},L=e=>(t,n,r)=>j(e)(t,n,r),M=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return C(e)(t,n,i)},V=e=>async(t,n,r)=>C(e)(t,n,r),K=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return D(e)(t,n,i)},W=e=>(t,n,r)=>D(e)(t,n,r),G=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return U(e)(t,n,i)},B=e=>async(t,n,r)=>U(e)(t,n,r),H=/^[cC][0-9a-z]{6,}$/,Y=/^[0-9a-z]+$/,X=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Q=/^[0-9a-vA-V]{20}$/,ee=/^[A-Za-z0-9]{27}$/,te=/^[a-zA-Z0-9_-]{21}$/,ne=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,re=/^([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})$/,ie=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)$/,se=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var oe=/^(?:(?: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])$/,ae=/^(([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}|:))$/,ue=/^((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])$/,de=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,le=/^[A-Za-z0-9_-]*$/,pe=/^https?$/,he=/^\+[1-9]\d{6,14}$/,fe="(?:(?:\\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])))",me=new RegExp(`^${fe}$`);function _e(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 ve=/^-?\d+$/,ye=/^-?\d+(?:\.\d+)?$/,ge=/^(?:true|false)$/i,be=/^[^A-Z]*$/,we=/^[^a-z]*$/,ze=t("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ke={number:"number",bigint:"bigint",object:"date"},Se=t("$ZodCheckLessThan",(e,t)=>{ze.init(e,t);const n=ke[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ee=t("$ZodCheckGreaterThan",(e,t)=>{ze.init(e,t);const n=ke[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$e=t("$ZodCheckMultipleOf",(e,t)=>{ze.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,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}(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})}}),Ie=t("$ZodCheckNumberFormat",(e,t)=>{ze.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,s]=E[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=s,n&&(r.pattern=ve)}),e._zod.check=o=>{const a=o.value;if(n){if(!Number.isInteger(a))return void o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<i&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Te=t("$ZodCheckMaxLength",(e,t)=>{var n;ze.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 r=n.value;if(r.length<=t.maximum)return;const i=x(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Oe=t("$ZodCheckMinLength",(e,t)=>{var n;ze.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 r=n.value;if(r.length>=t.minimum)return;const i=x(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pe=t("$ZodCheckLengthEquals",(e,t)=>{var n;ze.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 r=n.value,i=r.length;if(i===t.length)return;const s=x(r),o=i>t.length;n.issues.push({origin:s,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xe=t("$ZodCheckStringFormat",(e,t)=>{var n,r;ze.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})}):(r=e._zod).check??(r.check=()=>{})}),Ne=t("$ZodCheckRegex",(e,t)=>{xe.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})}}),Ae=t("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=be),xe.init(e,t)}),Ze=t("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=we),xe.init(e,t)}),qe=t("$ZodCheckIncludes",(e,t)=>{ze.init(e,t);const n=z(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),je=t("$ZodCheckStartsWith",(e,t)=>{ze.init(e,t);const n=new RegExp(`^${z(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})}}),Ce=t("$ZodCheckEndsWith",(e,t)=>{ze.init(e,t);const n=new RegExp(`.*${z(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})}}),De=t("$ZodCheckOverwrite",(e,t)=>{ze.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Re=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)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const i of r)this.content.push(i)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},Ue={major:4,minor:4,patch:3},Fe=t("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ue;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const n of i)for(const t of n._zod.onattach)t(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let i,s=$(e);for(const o of t){if(o._zod.def.when){if(I(e))continue;if(!o._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,a=o._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new n;if(i||a instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(s||(s=$(e,t)))});else{if(e.issues.length===t)continue;s||(s=$(e,t))}}return i?i.then(()=>e):e},r=(r,s,o)=>{if($(r))return r.aborted=!0,r;const a=t(s,i,o);if(a instanceof Promise){if(!1===o.async)throw new n;return a.then(t=>e._zod.parse(t,o))}return e._zod.parse(a,o)};e._zod.run=(s,o)=>{if(o.skipChecks)return e._zod.parse(s,o);if("backward"===o.direction){const t=e._zod.parse({value:s.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,s,o)):r(t,s,o)}const a=e._zod.parse(s,o);if(a instanceof Promise){if(!1===o.async)throw new n;return a.then(e=>t(e,i,o))}return t(a,i,o)}}p(e,"~standard",()=>({validate:t=>{try{const n=R(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return F(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Je=t("$ZodString",(e,t)=>{var n;Fe.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,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Le=t("$ZodStringFormat",(e,t)=>{xe.init(e,t),Je.init(e,t)}),Me=t("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=re),Le.init(e,t)}),Ve=t("$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=ie(e))}else t.pattern??(t.pattern=ie());Le.init(e,t)}),Ke=t("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=se),Le.init(e,t)}),We=t("$ZodURL",(e,t)=>{Le.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===pe.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ge=t("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Le.init(e,t)}),Be=t("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=te),Le.init(e,t)}),He=t("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=H),Le.init(e,t)}),Ye=t("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Y),Le.init(e,t)}),Xe=t("$ZodULID",(e,t)=>{t.pattern??(t.pattern=X),Le.init(e,t)}),Qe=t("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Q),Le.init(e,t)}),et=t("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ee),Le.init(e,t)}),tt=t("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=_e({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${fe}T(?:${r})$`)}(t)),Le.init(e,t)}),nt=t("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=me),Le.init(e,t)}),rt=t("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_e(t)}$`)),Le.init(e,t)}),it=t("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ne),Le.init(e,t)}),st=t("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oe),Le.init(e,t),e._zod.bag.format="ipv4"}),ot=t("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ae),Le.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})}}}),at=t("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ue),Le.init(e,t)}),ut=t("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ce),Le.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;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 dt=t("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=de),Le.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 lt=t("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=le),Le.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!le.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})}}),pt=t("$ZodE164",(e,t)=>{t.pattern??(t.pattern=he),Le.init(e,t)});var ht=t("$ZodJWT",(e,t)=>{Le.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=t("$ZodNumber",(e,t)=>{Fe.init(e,t),e._zod.pattern=e._zod.bag.pattern??ye,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),mt=t("$ZodNumberFormat",(e,t)=>{Ie.init(e,t),ft.init(e,t)}),_t=t("$ZodBoolean",(e,t)=>{Fe.init(e,t),e._zod.pattern=ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),vt=t("$ZodUnknown",(e,t)=>{Fe.init(e,t),e._zod.parse=e=>e}),yt=t("$ZodNever",(e,t)=>{Fe.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function gt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}var bt=t("$ZodArray",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let e=0;e<i.length;e++){const o=i[e],a=t.element._zod.run({value:o,issues:[]},r);a instanceof Promise?s.push(a.then(t=>gt(t,n,e))):gt(a,n,e)}return s.length?Promise.all(s).then(()=>n):n}});function wt(e,t,n,r,i,s){const o=n in r;if(e.issues.length){if(i&&s&&!o)return;t.issues.push(...T(n,e.issues))}o||i?void 0===e.value?o&&(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 zt(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function kt(e,t,n,r,i,s){const o=[],a=i.keySet,u=i.catchall._zod,c=u.def.type,d="optional"===u.optin,l="optional"===u.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===c){o.push(p);continue}const i=u.run({value:t[p],issues:[]},r);i instanceof Promise?e.push(i.then(e=>wt(e,n,p,t,d,l))):wt(i,n,p,t,d,l)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var St=t("$ZodObject",(e,t)=>{if(Fe.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=u(()=>zt(t));p(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n});const r=v,i=t.catchall;let s;e._zod.parse=(t,o)=>{s??(s=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const u=[],c=s.shape;for(const e of s.keys){const n=c[e],r="optional"===n._zod.optin,i="optional"===n._zod.optout,s=n._zod.run({value:a[e],issues:[]},o);s instanceof Promise?u.push(s.then(n=>wt(n,t,e,a,r,i))):wt(s,t,e,a,r,i)}return i?kt(u,a,t,o,n.value,e):u.length?Promise.all(u).then(()=>t):t}}),Et=t("$ZodObjectJIT",(e,t)=>{St.init(e,t);const n=e._zod.parse,r=u(()=>zt(t));let s;const o=v,a=!i.jitless,c=a&&y.value,d=t.catchall;let l;e._zod.parse=(i,u)=>{l??(l=r.value);const p=i.value;return o(p)?a&&c&&!1===u?.async&&!0!==u.jitless?(s||(s=(e=>{const t=new Re(["shape","payload","ctx"]),n=r.value,i=e=>{const t=m(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let o=0;for(const r of n.keys)s[r]="key_"+o++;t.write("const newResult = {};");for(const r of n.keys){const n=s[r],o=m(r),a=e[r],u="optional"===a?._zod?.optin,c="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(r)};`),u&&c?t.write(`\n if (${n}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):u?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${o} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\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: [${o}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${o}] = undefined;\n } else {\n newResult[${o}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),i=s(i,u),d?kt([],p,i,u,l,e):i):n(i,u):(i.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),i)}});function $t(e,t,n,r){for(const s of e)if(0===s.issues.length)return t.value=s.value,t;const i=e.filter(e=>!$(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>P(e,r,s())))}),t)}var It=t("$ZodUnion",(e,t)=>{Fe.init(e,t),p(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),p(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),p(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),p(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=>d(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),s=!0;else{if(0===t.issues.length)return t;o.push(t)}}return s?Promise.all(o).then(t=>$t(t,r,e,i)):$t(o,r,e,i)}}),Tt=t("$ZodIntersection",(e,t)=>{Fe.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([t,n])=>Pt(e,t,n)):Pt(e,i,s)}});function Ot(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(g(e)&&g(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const s of r){const n=Ot(e[s],t[s]);if(!n.valid)return{valid:!1,mergeErrorPath:[s,...n.mergeErrorPath]};i[s]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=Ot(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Pt(e,t,n){const r=new Map;let i;for(const a of t.issues)if("unrecognized_keys"===a.code){i??(i=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length&&i&&e.issues.push({...i,keys:s}),$(e))return e;const o=Ot(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var xt=t("$ZodRecord",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!g(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],a=t.keyType._zod.values;if(a){n.value={};const u=new Set;for(const d of a)if("string"==typeof d||"number"==typeof d||"symbol"==typeof d){u.add("number"==typeof d?d.toString():d);const a=t.keyType._zod.run({value:d,issues:[]},r);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=>P(e,r,s())),input:d,path:[d],inst:e});continue}const c=a.value,l=t.valueType._zod.run({value:i[d],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...T(d,e.issues)),n.value[c]=e.value})):(l.issues.length&&n.issues.push(...T(d,l.issues)),n.value[c]=l.value)}let c;for(const e in i)u.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let u=t.keyType._zod.run({value:a,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&ye.test(a)&&u.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(u=e)}if(u.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(e=>P(e,r,s())),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:i[a],issues:[]},r);c instanceof Promise?o.push(c.then(e=>{e.issues.length&&n.issues.push(...T(a,e.issues)),n.value[u.value]=e.value})):(c.issues.length&&n.issues.push(...T(a,c.issues)),n.value[u.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Nt=t("$ZodEnum",(e,t)=>{Fe.init(e,t);const n=o(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>w.has(typeof e)).map(e=>"string"==typeof e?z(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const s=t.value;return r.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),At=t("$ZodLiteral",(e,t)=>{if(Fe.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?z(e):e?z(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Zt=t("$ZodTransform",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.parse=(i,s)=>{if("backward"===s.direction)throw new r(e.constructor.name);const o=t.transform(i.value,i);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i.fallback=!0,i));if(o instanceof Promise)throw new n;return i.value=o,i.fallback=!0,i}});function qt(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var jt=t("$ZodOptional",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",p(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),p(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${d(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>qt(e,r)):qt(i,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ct=t("$ZodExactOptional",(e,t)=>{jt.init(e,t),p(e._zod,"values",()=>t.innerType._zod.values),p(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Dt=t("$ZodNullable",(e,t)=>{Fe.init(e,t),p(e._zod,"optin",()=>t.innerType._zod.optin),p(e._zod,"optout",()=>t.innerType._zod.optout),p(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${d(e.source)}|null)$`):void 0}),p(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)}),Rt=t("$ZodDefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(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 r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ut(e,t)):Ut(r,t)}});function Ut(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Ft=t("$ZodPrefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(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))}),Jt=t("$ZodNonOptional",(e,t)=>{Fe.init(e,t),p(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,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Lt(t,e)):Lt(i,e)}});function Lt(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 Mt=t("$ZodCatch",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(e._zod,"optout",()=>t.innerType._zod.optout),p(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>P(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>P(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Vt=t("$ZodPipe",(e,t)=>{Fe.init(e,t),p(e._zod,"values",()=>t.in._zod.values),p(e._zod,"optin",()=>t.in._zod.optin),p(e._zod,"optout",()=>t.out._zod.optout),p(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Kt(e,t.in,n)):Kt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kt(e,t.out,n)):Kt(r,t.out,n)}});function Kt(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 Wt=t("$ZodReadonly",(e,t)=>{Fe.init(e,t),p(e._zod,"propValues",()=>t.innerType._zod.propValues),p(e._zod,"values",()=>t.innerType._zod.values),p(e._zod,"optin",()=>t.innerType?._zod?.optin),p(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gt):Gt(r)}});function Gt(e){return e.value=Object.freeze(e.value),e}var Bt,Ht=t("$ZodCustom",(e,t)=>{ze.init(e,t),Fe.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Yt(t,n,r,e));Yt(i,n,r,e)}});function Yt(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}var Xt=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 r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(Bt=globalThis).__zod_globalRegistry??(Bt.__zod_globalRegistry=new Xt);var Qt=globalThis.__zod_globalRegistry;function en(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function tn(e,t){return new Se({check:"less_than",...S(t),value:e,inclusive:!1})}function nn(e,t){return new Se({check:"less_than",...S(t),value:e,inclusive:!0})}function rn(e,t){return new Ee({check:"greater_than",...S(t),value:e,inclusive:!1})}function sn(e,t){return new Ee({check:"greater_than",...S(t),value:e,inclusive:!0})}function on(e,t){return new $e({check:"multiple_of",...S(t),value:e})}function an(e,t){return new Te({check:"max_length",...S(t),maximum:e})}function un(e,t){return new Oe({check:"min_length",...S(t),minimum:e})}function cn(e,t){return new Pe({check:"length_equals",...S(t),length:e})}function dn(e){return new De({check:"overwrite",tx:e})}function ln(e,t){const n=new ze({check:"custom",...S(t)});return n._zod.check=e,n}function pn(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??Qt,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 hn(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{const n=o.schema,s=t.processors[i.type];if(!s)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);s(e,t,n,r)}const s=e._zod.parent;s&&(o.ref||(o.ref=s),hn(s,t,r),t.seen.get(s).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(o.schema,u),"input"===t.io&&_n(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const t=e.metadataRegistry.get(s[0])?.id;if(t){const e=r.get(t);if(e&&e!==s[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,s[0])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:s}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const s=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=s,{defId:s,ref:`${i("__shared")}#/${r}/${s}`}}if(t[1]===n)return{ref:"#"};const i=`#/${r}/`,s=t[1].schema.id??"__schema"+e.counter++;return{defId:s,ref:i+s}})(t);r.def={...r.schema},s&&(r.defId=s);const o=r.schema;for(const e in o)delete o[e];o.$ref=i};if("throw"===e.cycles)for(const s of e.seen.entries()){const e=s[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 s of e.seen.entries()){const n=s[1];if(t!==s[0]){if(e.external){const n=e.external.registry.get(s[0])?.id;if(t!==s[0]&&n){i(s);continue}}(e.metadataRegistry.get(s[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(s)}else i(s)}}function mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,s={...i},o=n.ref;if(n.ref=null,o){r(o);const n=e.seen.get(o),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,s),t._zod.parent===o)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in s||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==o){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const u of[...e.seen.entries()].reverse())r(u[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;void 0!==s&&i.id===s&&delete i.id;const o=e.external?.defs??{};for(const u of e.seen.entries()){const e=u[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?i.$defs=o:i.definitions=o);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:vn(t,"input",e.processors),output:vn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function _n(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return _n(r.element,n);if("set"===r.type)return _n(r.valueType,n);if("lazy"===r.type)return _n(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return _n(r.innerType,n);if("intersection"===r.type)return _n(r.left,n)||_n(r.right,n);if("record"===r.type||"map"===r.type)return _n(r.keyType,n)||_n(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(_n(r.in,n)||_n(r.out,n));if("object"===r.type){for(const e in r.shape)if(_n(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(_n(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(_n(e,n))return!0;return!(!r.rest||!_n(r.rest,n))}return!1}var vn=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=pn({...i??{},target:s,io:t,processors:n});return hn(e,o),fn(o,e),mn(o,e)},yn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gn=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);t.seen.get(e).ref=i.innerType},bn=t("ZodISODateTime",(e,t)=>{tt.init(e,t),Gn.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,...S(t)})}(bn,e)}var zn=t("ZodISODate",(e,t)=>{nt.init(e,t),Gn.init(e,t)});function kn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}(zn,e)}var Sn=t("ZodISOTime",(e,t)=>{rt.init(e,t),Gn.init(e,t)});function En(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}(Sn,e)}var $n=t("ZodISODuration",(e,t)=>{it.init(e,t),Gn.init(e,t)});function In(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}($n,e)}var Tn=(e,t)=>{Z.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if("invalid_key"===s.code)r({issues:s.issues},[...i,...s.path]);else if("invalid_element"===s.code)r({issues:s.issues},[...i,...s.path]);else{const e=[...i,...s.path];if(0===e.length)n._errors.push(t(s));else{let r=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(s))),r=r[n],i++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,a,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,a,2)}},isEmpty:{get:()=>0===e.issues.length}})},On=t("ZodError",Tn,{Parent:Error}),Pn=j(On),xn=C(On),Nn=D(On),An=U(On),Zn=J(On),qn=L(On),jn=M(On),Cn=V(On),Dn=K(On),Rn=W(On),Un=G(On),Fn=B(On),Jn=new WeakMap;function Ln(e,t,n){const r=Object.getPrototypeOf(e);let i=Jn.get(r);if(i||(i=new Set,Jn.set(r,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,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 Mn=t("ZodType",(e,t)=>(Fe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vn(e,"input"),output:vn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=pn({...n,processors:t});return hn(e,r),fn(r,e),mn(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Nn(e,t,n),e.parseAsync=async(t,n)=>xn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>An(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Zn(e,t,n),e.decode=(t,n)=>qn(e,t,n),e.encodeAsync=async(t,n)=>jn(e,t,n),e.decodeAsync=async(t,n)=>Cn(e,t,n),e.safeEncode=(t,n)=>Dn(e,t,n),e.safeDecode=(t,n)=>Rn(e,t,n),e.safeEncodeAsync=async(t,n)=>Un(e,t,n),e.safeDecodeAsync=async(t,n)=>Fn(e,t,n),Ln(e,"ZodType",{check(...e){const t=this.def;return this.clone(f(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 k(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,...S(n)})}(Br,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=ln(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(N(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(N(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(dn(e))},optional(){return Dr(this)},exactOptional(){return new Rr({type:"optional",innerType:this})},nullable(){return Fr(this)},nullish(){return Dr(Fr(this))},nonoptional(e){return function(e,t){return new Mr({type:"nonoptional",innerType:e,...S(t)})}(this,e)},array(){return Er(this)},or(e){return Or([this,e])},and(e){return new Pr({type:"intersection",left:this,right:e})},transform(e){return Wr(this,new jr({type:"transform",transform:e}))},default(e){return t=e,new Jr({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():b(t)}});var t},prefault(e){return t=e,new Lr({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():b(t)}});var t},catch(e){return new Vr({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Wr(this,e)},readonly(){return new Gr({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Qt.add(t,{description:e}),t},meta(...e){if(0===e.length)return Qt.get(this);const t=this.clone();return Qt.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:()=>Qt.get(e)?.description,configurable:!0}),e)),Vn=t("_ZodString",(e,t)=>{Je.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:s,format:o,patterns:a,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof s&&(r.maxLength=s),o&&(r.format=yn[o]??o,""===r.format&&delete r.format,"time"===o&&delete r.format),u&&(r.contentEncoding=u),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.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,Ln(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ne({check:"string_format",format:"regex",...S(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new qe({check:"string_format",format:"includes",...S(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new je({check:"string_format",format:"starts_with",...S(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Ce({check:"string_format",format:"ends_with",...S(t),suffix:e})}(...e))},min(...e){return this.check(un(...e))},max(...e){return this.check(an(...e))},length(...e){return this.check(cn(...e))},nonempty(...e){return this.check(un(1,...e))},lowercase(e){return this.check(function(e){return new Ae({check:"string_format",format:"lowercase",...S(e)})}(e))},uppercase(e){return this.check(function(e){return new Ze({check:"string_format",format:"uppercase",...S(e)})}(e))},trim(){return this.check(dn(e=>e.trim()))},normalize(...e){return this.check(function(e){return dn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(dn(e=>e.toLowerCase()))},toUpperCase(){return this.check(dn(e=>e.toUpperCase()))},slugify(){return this.check(dn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Kn=t("ZodString",(e,t)=>{Je.init(e,t),Vn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}(Bn,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}(Xn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}(hr,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}(Qn,t)),e.guid=t=>e.check(en(Hn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}(Yn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}(Yn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}(Yn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}(Yn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}(er,t)),e.guid=t=>e.check(en(Hn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}(tr,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}(nr,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}(rr,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}(dr,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}(lr,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}(ir,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}(sr,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}(or,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}(ar,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}(ur,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}(cr,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}(pr,t)),e.datetime=t=>e.check(wn(t)),e.date=t=>e.check(kn(t)),e.time=t=>e.check(En(t)),e.duration=t=>e.check(In(t))});function Wn(e){return function(e,t){return new e({type:"string",...S(t)})}(Kn,e)}var Gn=t("ZodStringFormat",(e,t)=>{Le.init(e,t),Vn.init(e,t)}),Bn=t("ZodEmail",(e,t)=>{Ke.init(e,t),Gn.init(e,t)}),Hn=t("ZodGUID",(e,t)=>{Me.init(e,t),Gn.init(e,t)}),Yn=t("ZodUUID",(e,t)=>{Ve.init(e,t),Gn.init(e,t)}),Xn=t("ZodURL",(e,t)=>{We.init(e,t),Gn.init(e,t)}),Qn=t("ZodEmoji",(e,t)=>{Ge.init(e,t),Gn.init(e,t)}),er=t("ZodNanoID",(e,t)=>{Be.init(e,t),Gn.init(e,t)}),tr=t("ZodCUID",(e,t)=>{He.init(e,t),Gn.init(e,t)}),nr=t("ZodCUID2",(e,t)=>{Ye.init(e,t),Gn.init(e,t)}),rr=t("ZodULID",(e,t)=>{Xe.init(e,t),Gn.init(e,t)}),ir=t("ZodXID",(e,t)=>{Qe.init(e,t),Gn.init(e,t)}),sr=t("ZodKSUID",(e,t)=>{et.init(e,t),Gn.init(e,t)}),or=t("ZodIPv4",(e,t)=>{st.init(e,t),Gn.init(e,t)}),ar=t("ZodIPv6",(e,t)=>{ot.init(e,t),Gn.init(e,t)}),ur=t("ZodCIDRv4",(e,t)=>{at.init(e,t),Gn.init(e,t)}),cr=t("ZodCIDRv6",(e,t)=>{ut.init(e,t),Gn.init(e,t)}),dr=t("ZodBase64",(e,t)=>{dt.init(e,t),Gn.init(e,t)}),lr=t("ZodBase64URL",(e,t)=>{lt.init(e,t),Gn.init(e,t)}),pr=t("ZodE164",(e,t)=>{pt.init(e,t),Gn.init(e,t)}),hr=t("ZodJWT",(e,t)=>{ht.init(e,t),Gn.init(e,t)}),fr=t("ZodNumber",(e,t)=>{ft.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:i,maximum:s,format:o,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;"string"==typeof o&&o.includes("int")?r.type="integer":r.type="number";const d="number"==typeof c&&c>=(i??Number.NEGATIVE_INFINITY),l="number"==typeof u&&u<=(s??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof i&&(r.minimum=i),l?p?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u:"number"==typeof s&&(r.maximum=s),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),Ln(e,"ZodNumber",{gt(e,t){return this.check(rn(e,t))},gte(e,t){return this.check(sn(e,t))},min(e,t){return this.check(sn(e,t))},lt(e,t){return this.check(tn(e,t))},lte(e,t){return this.check(nn(e,t))},max(e,t){return this.check(nn(e,t))},int(e){return this.check(vr(e))},safe(e){return this.check(vr(e))},positive(e){return this.check(rn(0,e))},nonnegative(e){return this.check(sn(0,e))},negative(e){return this.check(tn(0,e))},nonpositive(e){return this.check(nn(0,e))},multipleOf(e,t){return this.check(on(e,t))},step(e,t){return this.check(on(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 mr(e){return function(e,t){return new e({type:"number",checks:[],...S(t)})}(fr,e)}var _r=t("ZodNumberFormat",(e,t)=>{mt.init(e,t),fr.init(e,t)});function vr(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}(_r,e)}var yr=t("ZodBoolean",(e,t)=>{_t.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function gr(e){return function(e,t){return new e({type:"boolean",...S(t)})}(yr,e)}var br=t("ZodUnknown",(e,t)=>{vt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function wr(){return new br({type:"unknown"})}var zr=t("ZodNever",(e,t)=>{yt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function kr(e){return function(e,t){return new e({type:"never",...S(t)})}(zr,e)}var Sr=t("ZodArray",(e,t)=>{bt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(i.minItems=o),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=hn(s.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Ln(e,"ZodArray",{min(e,t){return this.check(un(e,t))},nonempty(e){return this.check(un(1,e))},max(e,t){return this.check(an(e,t))},length(e,t){return this.check(cn(e,t))},unwrap(){return this.element}})});function Er(e,t){return function(e,t,n){return new e({type:"array",element:t,...S(n)})}(Sr,e,t)}var $r=t("ZodObject",(e,t)=>{Et.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const c in o)i.properties[c]=hn(o[c],t,{...r,path:[...r.path,"properties",c]});const a=new Set(Object.keys(o)),u=new Set([...a].filter(e=>{const n=s.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));u.size>0&&(i.required=Array.from(u)),"never"===s.catchall?._zod.def.type?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=hn(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),p(e,"shape",()=>t.shape),Ln(e,"ZodObject",{keyof(){return Ar(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:wr()})},loose(){return this.clone({...this._zod.def,catchall:wr()})},strict(){return this.clone({...this._zod.def,catchall:kr()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!g(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 k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return h(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!g(t))throw new Error("Invalid input to safeExtend: expected a plain object");return k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return h(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 k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return h(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,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return k(e,f(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return h(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return k(e,f(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return h(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return k(t,f(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return h(this,"shape",i),i},checks:[]}))}(Cr,this,e[0])},required(...e){return t=Mr,n=this,r=e[0],k(n,f(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(r)for(const n in r){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return h(this,"shape",i),i}}));var t,n,r}})});function Ir(e,t){const n={type:"object",shape:e??{},...S(t)};return new $r(n)}var Tr=t("ZodUnion",(e,t)=>{It.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=!1===i.inclusive,o=i.options.map((e,n)=>hn(e,t,{...r,path:[...r.path,s?"oneOf":"anyOf",n]}));s?n.oneOf=o:n.anyOf=o})(e,t,n,r),e.options=t.options});function Or(e,t){return new Tr({type:"union",options:e,...S(t)})}var Pr=t("ZodIntersection",(e,t)=>{Tt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=hn(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=hn(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]]})(e,t,n,r)});var xr=t("ZodRecord",(e,t)=>{xt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag?.patterns;if("loose"===s.mode&&a&&a.size>0){const e=hn(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const t of a)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=hn(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=hn(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const e=[...u].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});var Nr=t("ZodEnum",(e,t)=>{Nt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=o(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const i={};for(const s of e){if(!n.has(s))throw new Error(`Key ${s} not found in enum`);i[s]=t.entries[s]}return new Nr({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Nr({...t,checks:[],...S(r),entries:i})}});function Ar(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Nr({type:"enum",entries:n,...S(t)})}var Zr=t("ZodLiteral",(e,t)=>{At.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,i=[];for(const s of r.values)if(void 0===s){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof s){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qr(e,t){return new Zr({type:"literal",values:Array.isArray(e)?e:[e],...S(t)})}var jr=t("ZodTransform",(e,t)=>{Zt.init(e,t),Mn.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,i)=>{if("backward"===i.direction)throw new r(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(N(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(N(t))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=s,n.fallback=!0,n)}});var Cr=t("ZodOptional",(e,t)=>{jt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Dr(e){return new Cr({type:"optional",innerType:e})}var Rr=t("ZodExactOptional",(e,t)=>{Ct.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ur=t("ZodNullable",(e,t)=>{Dt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=hn(i.innerType,t,r),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fr(e){return new Ur({type:"nullable",innerType:e})}var Jr=t("ZodDefault",(e,t)=>{Rt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Lr=t("ZodPrefault",(e,t)=>{Ft.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Mr=t("ZodNonOptional",(e,t)=>{Jt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Vr=t("ZodCatch",(e,t)=>{Mt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let s;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Kr=t("ZodPipe",(e,t)=>{Vt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o="input"===t.io?s?i.out:i.in:i.out;hn(o,t,r),t.seen.get(e).ref=o})(e,t,0,r),e.in=t.in,e.out=t.out});function Wr(e,t){return new Kr({type:"pipe",in:e,out:t})}var Gr=t("ZodReadonly",(e,t)=>{Wt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Br=t("ZodCustom",(e,t)=>{Ht.init(e,t),Mn.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 Hr,Yr,Xr,Qr=Wn().nullable(),ei=(Hr=Wn(),(Yr=wr())&&Yr._zod?new xr({type:"record",keyType:Hr,valueType:Yr,...S(Xr)}):new xr({type:"record",keyType:Wn(),valueType:Hr,...S(Yr)})),ti=Ir({logo_url:Qr,primary_color:Wn(),secondary_color:Wn(),accent_color:Wn()}),ni=Ir({customer:Ir({id:Qr,email:Wn(),name:Wn(),avatar_url:Qr,joined_at:Qr}),shop:Ir({id:Wn(),slug:Wn(),name:Wn(),currency:Wn(),branding:ti}),token:Qr}),ri=Ir({attachment_image_id:Ir({cloudflare_image_id:Qr}).nullable()}),ii=Ir({attachment_imageId:Ir({cloudflareImageId:Qr}).nullable()}),si=Ir({uniqid:Wn(),status:Wn(),total:Wn(),total_display:Qr,currency:Wn(),created_at:Wn(),line_items:Er(Ir({product_title:Qr,quantity:mr(),product:ri.nullable()}))}),oi=Ir({uniqid:Wn(),status:Wn(),total:Wn(),totalDisplay:Qr,currency:Wn(),createdAt:Wn(),lineItems:Er(Ir({productTitle:Qr,quantity:mr(),product:ii.nullable()}))}),ai=Ir({invoices:Er(oi),pagination:Ir({page:mr(),limit:mr(),total:mr(),has_more:gr()})}),ui=Ir({gateway:Wn(),displayName:Qr,cryptoGateway:Qr.optional(),blockchain:Qr,cryptoAddress:Qr,apmMethod:Qr}),ci=Ir({id:Wn(),uniqid:Wn(),status:Wn(),statusDetails:Qr,total:Wn(),totalDisplay:Qr,subtotal:Wn(),discount:Wn(),discountDisplay:Qr,tax:Wn(),taxPercentage:Wn(),currency:Wn(),createdAt:Wn(),updatedAt:Wn(),gatewayUpdatedAt:Qr,customFields:ei.nullable(),balancePaidAmount:Wn(),currentPaymentAttemptId:Qr,lineItems:Er(Ir({id:Wn(),productTitle:Wn(),productType:Wn(),variantTitle:Qr,unitPrice:Wn(),quantity:mr(),total:Wn(),deliveryText:Qr,deliverySummary:Ir({codes:Er(Wn()),links:Er(Ir({label:Wn(),value:Wn(),href:Qr.optional()})),notes:Er(Wn()),serials:Er(Ir({value:Wn(),is_replacement:gr(),is_replaced:gr()}))}).nullable(),deliveredAt:Qr,deliveryStatus:Ar(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:ei.nullable(),product:Ir({uniqid:Wn(),slug:Qr,serviceText:Qr,attachment_imageId:Ir({cloudflareImageId:Qr}).nullable()}).nullable()})),currentPayment:ui.nullable(),payments:Er(ui)}),di=Ir({quote:Ir({enabled:gr(),currency:Wn(),min_amount:Wn(),max_amount:Qr,bonus_tiers:Er(Ir({min_amount:Wn(),bonus_percent:mr()}))})}),li=Ir({invoice_id:Wn(),url:Wn()}),pi=Ir({id:Wn(),type:Wn(),status:Wn(),amount:Qr,currency:Qr,coupon_code:Qr,reason:Wn(),trigger_reference_type:Wn(),trigger_reference_id:Wn(),created_at:mr(),fulfilled_at:mr().nullable(),expires_at:mr().nullable()}),hi=Ir({summary:Ir({available:Wn(),pending:Wn(),lifetime_earned:Wn(),redeemed:Qr,currency:Wn()}),activity:Er(pi),earned_after_invoice:Er(pi),pending_after_invoice:Er(pi)}),fi=Ir({id:Wn(),uniqid:Wn(),label:Qr,code:Wn(),url:Qr,status:Ar(["pending","active","inactive","rejected"]),is_primary:gr(),total_clicks:mr(),total_sales:mr(),total_revenue:Wn(),is_active:gr(),is_approved:gr(),requested_affiliate_revenue_percent:mr().nullable(),requested_affiliate_customer_discount_percent:mr().nullable(),affiliate_revenue_percent_override:mr().nullable(),affiliate_customer_discount_percent_override:mr().nullable(),effective_commission_percent:mr(),effective_customer_discount_percent:mr(),commission_shareback_percent:mr(),commission_shareback_enabled:gr(),max_commission_shareback_percent:mr(),created_at:Qr,updated_at:Qr}),mi=Ir({customer:Ir({id:Wn(),email:Wn(),name:Qr}).nullable(),state:Wn(),can_create_custom_links:gr(),custom_link_request_disabled_reason:Qr,custom_links_require_approval:gr(),affiliate_codes_accepted_at_checkout:gr(),cash_payout_enabled:gr(),links:Er(fi),preferred_payout:Ir({asset:Wn(),network:Wn(),address:Wn()}).nullable(),balance_currency:Wn(),balances:Ir({pending:Wn(),available:Wn(),requested:Wn(),converted:Wn(),paid:Wn(),approved_total:Wn()}),commissions:Er(Ir({id:Wn(),invoice_id:Wn(),commission_amount:Wn(),base_amount:Wn(),discount_amount:Wn(),status:Wn(),created_at:Qr,paid_at:Qr,converted_at:Qr})),claims:Er(Ir({id:Wn(),type:Wn(),status:Wn(),amount:Wn(),currency:Wn(),allocations:Er(Ir({source_type:Wn(),commission_id:Qr,adjustment_id:Qr,amount:Wn()})),wallet_transaction_id:Qr,payout_asset:Qr,payout_network:Qr,payout_address:Qr,note:Qr,metadata:wr(),completed_at:Qr,rejected_at:Qr,cancelled_at:Qr,created_at:Qr,updated_at:Qr}))}),_i=Ir({uniqid:Wn(),status:Wn(),gateway:Wn(),current_period_start:Wn(),current_period_end:Wn(),trial_end:Qr,cancel_at_period_end:gr(),canceled_at:Qr,created_at:Wn(),plan:Ir({id:Wn(),uniqid:Wn(),name:Wn(),price:Wn(),currency:Wn(),interval:Wn(),interval_count:mr(),trial_days:mr()}).nullable(),payment_method:Ir({id:Wn(),gateway:Wn(),type:Wn(),card_brand:Qr,card_last4:Qr,card_exp_month:mr().nullable(),card_exp_year:mr().nullable(),is_default:gr()}).nullable(),actions:Ir({can_pause:gr(),can_resume:gr(),can_cancel:gr(),can_manage_payment_method:gr()})}),vi=Ir({enabled:gr(),account:Ir({points_balance:mr(),lifetime_points:mr()}).nullable(),settings:Ir({earn_rate_per_usd:mr(),redeem_value_per_point:mr(),min_redeem_points:mr()}).nullable(),transactions:Er(Ir({type:Ar(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:mr(),balance_after:mr(),description:Qr,created_at:Wn()}))}),yi=Ir({redeemed_points:mr(),wallet_amount:Wn(),currency:Wn(),points_balance:mr(),replayed:gr()}),gi=Ir({uniqid:Wn(),invoice_uniqid:Wn(),product_title:Wn(),period_days:mr(),starts_at:Wn(),expires_at:Wn(),status:Ar(["ACTIVE","EXPIRED","VOIDED"]),claim_status:Ar(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:Wn()}),bi=Ir({warranties:Er(gi)}),wi=Ir({warranty:gi.extend({claim_status:qr("REQUESTED")})}),zi=Ir({customer:Ir({id:Wn(),email:Wn(),name:Wn(),joined_at:Qr})}),ki=Ir({avatar_url:Qr}),Si=Ir({global_unsubscribed:gr(),lists:Er(Ir({id:Wn(),name:Wn(),description:Qr,subscribed:gr()}))}),Ei=Ir({updated:gr()}),$i=Ir({order_created_emails:gr(),order_completed_emails:gr(),payment_issue_emails:gr()}),Ii=Ir({favorites:Er(Ir({product_uniqid:Wn(),title:Wn(),slug:Qr,image_url:Qr,price_display:mr(),unavailable:gr(),created_at:Wn()}))}),Ti=Or([Ir({added:qr(!0)}),Ir({removed:qr(!0)})]),Oi=Ir({license:Ir({uniqid:Wn(),hardware_id:Qr})}),Pi=Ir({invoice_id:Wn(),checkout_url:Wn(),preferred_gateways:Er(Wn()),license:Ir({uniqid:Wn(),product_title:Wn()})}),xi=Ir({invoices:Er(Ir({id:Wn(),uniqid:Wn(),total:Wn(),currency:Wn(),status:Wn(),gateway:Wn(),created_at:Wn(),completed_at:Wn()}))}),Ni=Ir({subscription:Ir({id:Wn(),status:Wn(),cancel_at_period_end:gr(),cancel_reason:Qr,canceled_at:Qr})}),Ai=Ir({subscription:Ir({id:Wn(),status:Wn()})}),Zi=Ir({ticket:Ir({uniqid:Wn(),title:Wn(),status:Wn(),invoice_id:Qr,created_at:Wn(),updated_at:Wn(),messages:Er(Ir({id:Wn(),role:Ar(["CUSTOMER","SHOP","SYSTEM"]),message:Wn(),created_at:Wn()}))})}),qi=Ir({uniqid:Wn()}),ji=Ir({affiliate_link:Ir({id:Wn(),customer_id:Wn(),label:Qr,code:Wn(),url:Qr,status:Ar(["pending","approved","rejected"]),requested_affiliate_revenue_percent:mr().nullable(),requested_affiliate_customer_discount_percent:mr().nullable(),created_at:Wn(),updated_at:Wn()})}),Ci=Ir({check:Wn(),passed:gr(),reason:Qr.optional()}),Di=Ir({eligible:gr(),decision:Ar(["ELIGIBLE","DENIED","NO_RULE"]),reason:Qr,eligibility_checks:Er(Ci)}),Ri=Ir({request_id:Wn(),event_id:Qr,decision:Ar(["ISSUED_REPLACEMENT","FALLBACK_REFUND","FALLBACK_CREDIT","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED"]),status_label:Ar(["ISSUED","REFUNDED","CREDITED","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED","PENDING"]),reason:Qr,eligibility_checks:Er(Ci)}),Ui=Ir({id:Wn(),name:Qr,discount_percent:mr().nullable()}),Fi=Ir({id:Wn(),status:Ar(["INVITED","APPLIED","ACTIVE","SUSPENDED","REJECTED"]),tier:Ui.nullable(),application_note:Qr,lifetime_revenue:Wn(),lifetime_orders:mr(),approved_at:Qr,created_at:Wn()}),Ji=Ir({program_enabled:gr(),enrollment_mode:Ar(["MANUAL","APPLICATION","OPEN"]),application_message:Qr,require_application_note:gr(),reseller:Fi.nullable()}),Li=Ir({reseller:Fi}),Mi=Ar(["variant","product","tier"]),Vi=Ir({variant_id:Wn(),title:Wn(),stock:mr(),supplier_backed:gr(),orderable:gr(),base_price:Wn(),unit_price:Wn(),discount_percent:mr(),applied_override:Mi}),Ki=Ir({tier:Ui,catalog:Ir({currency:Wn(),total:mr(),page:mr(),per_page:mr(),items:Er(Ir({product_id:Wn(),uniqid:Wn(),title:Wn(),type:Wn(),stock:mr(),supplier_backed:gr(),orderable:gr(),volume_discount_enabled:gr(),base_price:Wn(),unit_price:Wn(),discount_percent:mr(),applied_override:Mi,variants:Er(Vi)}))})}),Wi=Ir({quote:Ir({currency:Wn(),tier:Ui,items:Er(Ir({product_id:Wn(),product_title:Wn(),product_type:Wn(),variant_id:Qr,variant_title:Qr,quantity:mr(),base_price:Wn(),discount_percent:mr(),unit_price:Wn(),line_total:Wn(),applied_override:Mi,volume_discount_applied:Wn()})),subtotal:Wn(),volume_discount_total:Wn(),total:Wn(),savings:Wn()})}),Gi=Ir({orders:Ir({total:mr(),page:mr(),per_page:mr(),items:Er(Ir({uniqid:Wn(),status:Wn(),currency:Wn(),total:Wn(),item_count:mr(),created_at:Wn()}))})}),Bi=Ir({order:Ir({uniqid:Wn(),status:Wn(),currency:Wn(),total:Wn(),item_count:mr(),created_at:Wn(),tier_name:Wn(),tier_discount_percent:mr(),partially_delivered:gr(),refunded_amount:Qr,lines:Er(Ir({product_id:Qr,product_title:Wn(),variant_id:Qr,variant_title:Qr,quantity:mr(),unit_price:Wn(),total:Wn(),delivered:gr(),delivered_at:Qr,serials:Er(Wn())}))})}),Hi=Ir({wallet:Ir({currency:Wn(),balance:Wn(),hold_balance:Wn(),available:Wn(),is_active:gr()})}),Yi=Ir({api_keys:Er(Ir({id:Wn(),name:Wn(),key_last4:Wn(),last_used_at:Qr,revoked_at:Qr,created_at:Wn()}))}),Xi=Ir({topup:Ir({uniqid:Wn(),url:Wn()})}),Qi=Ir({shop:Ir({id:Wn(),slug:Wn(),name:Wn(),currency:Wn(),branding:ti}),customer:Ir({email:Wn(),name:Wn()}),stats:Ir({invoices_count:mr(),licenses_count:mr(),deliverables_count:mr(),tickets_count:mr()}),wallet:Ir({available:Wn(),total:Wn(),hold:Wn(),currency:Wn(),enabled:gr()}).nullable(),rewards:hi,affiliate:mi,invoices:Er(si),subscriptions:Er(_i),licenses:Er(Ir({uniqid:Wn(),invoice_id:Wn(),status:Wn(),license_key:Wn(),hardware_id:Qr,expires_at:mr().nullable(),renewable:gr(),product:Ir({title:Wn().optional()}).optional()})),deliverables:Er(Ir({id:Wn(),invoice_uniqid:Wn(),product_title:Wn(),kind:Ar(["file","serial","license"]),label:Wn(),value:Wn(),href:Qr,created_at:Wn()})),tickets:Er(Ir({uniqid:Wn(),title:Wn(),status:Wn(),updated_at:Wn(),created_at:Qr}))}),es=class extends Error{constructor(e,t,n){super(t),this.status=e,this.code=n,this.name="HeadlessCustomerError"}};function ts(e){if(!e)return null;try{const t=JSON.parse(e);if(!function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(t)||"string"!=typeof t.accessToken||!t.accessToken.startsWith("hcs_")||"string"!=typeof t.expiresAt||"number"!=typeof t.savedAt||!Number.isFinite(t.savedAt))return null;const n=Date.parse(t.expiresAt);return!Number.isFinite(n)||n<=Date.now()?null:{accessToken:t.accessToken,expiresAt:t.expiresAt,savedAt:t.savedAt}}catch{return null}}function ns(e){if(!e)return null;const t=e.match(/filename\*=UTF-8''([^;]+)/i);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}return e.match(/filename="([^"]+)"/i)?.[1]??null}function rs(e){try{return"undefined"==typeof window?null:window[e]}catch{return null}}var is=class{constructor(e){if(this.memorySession=null,!e.shop.trim())throw new Error("HeadlessCustomerClient requires a shop.");if(!e.publishableKey.trim())throw new Error("HeadlessCustomerClient requires a publishableKey.");if(this.shop=e.shop.trim(),this.publishableKey=e.publishableKey.trim(),this.base=(e.apiBaseUrl??"https://api.shoppex.io").replace(/\/+$/,""),this.fetchImpl=e.fetchImpl??globalThis.fetch?.bind(globalThis),!this.fetchImpl)throw new Error("No fetch implementation available; pass fetchImpl.");this.storage=e.storage??rs("sessionStorage"),this.persistentStorage=e.persistentStorage??rs("localStorage"),this.storageKey=`shoppex_headless_customer_session:${this.shop}`}getSession(){const e=this.memorySession?[this.memorySession]:[];if(this.storage)try{const t=ts(this.storage.getItem(this.storageKey));t&&e.push(t)}catch{}if(this.persistentStorage)try{const t=ts(this.persistentStorage.getItem(this.storageKey));t&&e.push(t)}catch{}const t=e.sort((e,t)=>t.savedAt-e.savedAt)[0]??null;return t?(this.memorySession=t,{accessToken:t.accessToken,expiresAt:t.expiresAt}):(this.clearSession(),null)}clearSession(){this.memorySession=null;try{this.storage?.removeItem(this.storageKey)}catch{}try{this.persistentStorage?.removeItem(this.storageKey)}catch{}}saveSession(e,t){const n={...e,savedAt:Date.now()};this.memorySession=n;const r=t?this.persistentStorage:this.storage,i=t?this.storage:this.persistentStorage;try{r?.setItem(this.storageKey,JSON.stringify(n))}catch{}try{i?.removeItem(this.storageKey)}catch{}}url(e,t={}){const n=new URL(`${this.base}/v1/customer${e}`);n.searchParams.set("shop",this.shop);for(const[r,i]of Object.entries(t))void 0!==i&&""!==i&&n.searchParams.set(r,i);return n.toString()}async request(e,t={}){if(void 0!==t.body&&void 0!==t.formData)throw new Error("Customer requests cannot send JSON and FormData together.");const n=t.authenticated?this.getSession():null;if(t.authenticated&&!n)throw new es(401,"Customer session is missing or expired.","UNAUTHORIZED");const r={accept:"application/json","x-shoppex-publishable-key":this.publishableKey,...void 0===t.body?{}:{"content-type":"application/json"},...n?{authorization:`Bearer ${n.accessToken}`}:{}},i=t.formData??(void 0===t.body?void 0:JSON.stringify(t.body)),s=await this.fetchImpl(this.url(e,t.query),{method:t.method??"GET",headers:r,...void 0===i?{}:{body:i},cache:"no-store"});let o=null;try{o=await s.json()}catch{}if(!s.ok||!o||o.error)throw 401===s.status&&t.authenticated&&this.clearSession(),new es(s.status,o?.error??`Request failed (${s.status})`,o?.error_code??null);if(!t.schema)return o.data;const a=t.schema.safeParse(o.data);if(!a.success)throw new es(s.status,"Customer API response did not match the expected contract.");return a.data}async requestFile(e,t={},n={}){const r=this.getSession();if(!r)throw new es(401,"Customer session is missing or expired.","UNAUTHORIZED");const i=await this.fetchImpl(this.url(e,t),{method:"GET",headers:{"x-shoppex-publishable-key":this.publishableKey,authorization:`Bearer ${r.accessToken}`},cache:"no-store"});if(!i.ok){401===i.status&&this.clearSession();let e=`Download failed (${i.status})`;try{const t=await i.json();t.error&&(e=t.error)}catch{}throw new es(i.status,e)}const s=i.headers.get("content-type");if(n.rejectHtml&&s?.toLowerCase().startsWith("text/html"))throw new es(502,"Shoppex returned an unsafe aggregate download response.","UNSAFE_DOWNLOAD_RESPONSE");return{blob:await i.blob(),filename:ns(i.headers.get("content-disposition")),contentType:s}}requestOtp(e){return this.request("/auth/otp/request",{method:"POST",body:{shop:this.shop,email:e}})}async verifyOtp(e,t,n={}){const r=await this.request("/auth/otp/verify",{method:"POST",body:{shop:this.shop,email:e,otp:t,remember_me:n.rememberMe??!1}}),i="string"==typeof r?.expires_at?Date.parse(r.expires_at):NaN;if("string"!=typeof r?.access_token||!r.access_token.startsWith("hcs_")||"string"!=typeof r.expires_at||!Number.isFinite(i)||i<=Date.now())throw new es(200,"Customer API response did not match the expected contract.");const s={accessToken:r.access_token,expiresAt:r.expires_at};return this.saveSession(s,n.rememberMe??!1),s}async me(){const e=await this.request("/me",{authenticated:!0,schema:ni});if(null!==e.token)throw new es(200,"Customer API response did not match the expected contract.");return{customer:e.customer,shop:e.shop}}dashboard(){return this.request("/dashboard",{authenticated:!0,schema:Qi})}updateProfile(e){return this.request("/profile",{method:"POST",authenticated:!0,body:{name:e.name},schema:zi})}updateAvatar(e){const t=new FormData;return t.append("file",e),this.request("/profile/avatar",{method:"POST",authenticated:!0,formData:t,schema:ki})}removeAvatar(){return this.request("/profile/avatar",{method:"DELETE",authenticated:!0,schema:ki})}emailPreferences(){return this.request("/email-marketing/preferences",{authenticated:!0,schema:Si})}updateEmailPreferences(e){return this.request("/email-marketing/preferences",{method:"PATCH",authenticated:!0,body:{...void 0===e.globalUnsubscribed?{}:{global_unsubscribed:e.globalUnsubscribed},list_subscriptions:(e.listSubscriptions??[]).map(e=>({list_id:e.listId,subscribed:e.subscribed}))},schema:Ei})}notificationPreferences(){return this.request("/notification-preferences",{authenticated:!0,schema:$i})}updateNotificationPreferences(e){return this.request("/notification-preferences",{method:"PATCH",authenticated:!0,body:{...void 0===e.orderCreatedEmails?{}:{order_created_emails:e.orderCreatedEmails},...void 0===e.orderCompletedEmails?{}:{order_completed_emails:e.orderCompletedEmails},...void 0===e.paymentIssueEmails?{}:{payment_issue_emails:e.paymentIssueEmails}},schema:$i})}orders(e={}){return this.request("/invoices",{authenticated:!0,schema:ai,query:{page:void 0===e.page?void 0:String(e.page),limit:void 0===e.limit?void 0:String(e.limit),status:e.status,q:e.search}})}async order(e){const t=await this.request(`/invoice/${encodeURIComponent(e)}`,{authenticated:!0,schema:ci});return{...t,lineItems:t.lineItems.map(e=>({...e,deliverySummary:e.deliverySummary?{...e.deliverySummary,links:e.deliverySummary.links.map(e=>{const t=function(e){if(!e)return null;try{const t=new URL(e,"https://headless-customer.invalid");if(!/^\/api\/customer\/invoice\/[^/]+\/download$/.test(t.pathname))return null;const n=t.searchParams.get("file_index");if(null===n||!/^\d+$/.test(n))return null;const r=Number(n);return Number.isSafeInteger(r)?r:null}catch{return null}}(e.href);return null===t?e:{...e,href:null,downloadIndex:t}})}:null}))}}invoicePdf(e){return this.requestFile(`/invoices/${encodeURIComponent(e)}/pdf`)}replacementEligibility(e,t){return this.request(`/invoices/${encodeURIComponent(e)}/replacement-eligibility`,{authenticated:!0,query:{line_item_id:t},schema:Di})}requestReplacement(e,t){return this.request(`/invoices/${encodeURIComponent(e)}/replacement-requests`,{method:"POST",authenticated:!0,body:{line_item_id:t.lineItemId??null,reason:t.reason,...t.idempotencyKey?{idempotency_key:t.idempotencyKey}:{}},schema:Ri})}async download(e,t){if(!Number.isSafeInteger(t)||t<0)throw new es(400,"download requires a non-negative integer fileIndex from order().deliverySummary.links.","INVALID_FILE_INDEX");return this.requestFile(`/invoice/${encodeURIComponent(e)}/download`,{file_index:String(t)},{rejectHtml:!0})}resetLicenseHwid(e){return this.request(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",authenticated:!0,body:{},schema:Oi})}renewLicense(e){return this.request(`/licenses/${encodeURIComponent(e)}/renew`,{method:"POST",authenticated:!0,body:{shop:this.shop},schema:Pi})}walletTopupQuote(){return this.request("/wallet/topup-quote",{authenticated:!0,schema:di})}createWalletTopup(e){return this.request("/wallet/topup",{method:"POST",authenticated:!0,body:{amount:e},schema:li})}subscriptionBillingHistory(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/billing-history`,{authenticated:!0,schema:xi})}cancelSubscription(e,t={}){return this.request(`/subscriptions/${encodeURIComponent(e)}/cancel`,{method:"POST",authenticated:!0,body:{...void 0===t.cancelAtPeriodEnd?{}:{cancel_at_period_end:t.cancelAtPeriodEnd},...void 0===t.reason?{}:{reason:t.reason}},schema:Ni})}pauseSubscription(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",authenticated:!0,body:{},schema:Ai})}resumeSubscription(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",authenticated:!0,body:{},schema:Ai})}loyalty(){return this.request("/loyalty",{authenticated:!0,schema:vi})}redeemLoyaltyPoints(e){return this.request("/loyalty/redeem",{method:"POST",authenticated:!0,body:{points:e.points,idempotency_key:e.idempotencyKey},schema:yi})}warranties(e){return this.request("/warranties",{authenticated:!0,query:{invoice:e},schema:bi})}claimWarranty(e,t){return this.request(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",authenticated:!0,body:t?{message:t}:{},schema:wi})}favorites(){return this.request("/favorites",{authenticated:!0,schema:Ii})}addFavorite(e){return this.request(`/favorites/${encodeURIComponent(e)}`,{method:"PUT",authenticated:!0,schema:Ti})}removeFavorite(e){return this.request(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE",authenticated:!0,schema:Ti})}affiliate(){return this.request("/affiliate",{authenticated:!0,schema:mi})}createAffiliateLink(e){return this.request("/affiliate/links",{method:"POST",authenticated:!0,body:{shop:this.shop,code:e.code,label:e.label,...void 0===e.requestedRevenuePercent?{}:{requested_affiliate_revenue_percent:e.requestedRevenuePercent},...void 0===e.requestedCustomerDiscountPercent?{}:{requested_affiliate_customer_discount_percent:e.requestedCustomerDiscountPercent}},schema:ji})}createTicket(e){return this.request("/tickets",{method:"POST",authenticated:!0,body:{...void 0===e.title?{}:{title:e.title},message:e.message,...void 0===e.invoiceId?{}:{invoice_id:e.invoiceId}},schema:qi})}ticket(e){return this.request(`/tickets/${encodeURIComponent(e)}`,{authenticated:!0,schema:Zi})}async replyToTicket(e,t){await this.request(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",authenticated:!0,body:{message:t}})}reseller(){return this.request("/reseller",{authenticated:!0,schema:Ji})}applyForReseller(e){return this.request("/reseller/apply",{method:"POST",authenticated:!0,body:void 0===e?{}:{note:e},schema:Li})}enrollAsReseller(){return this.request("/reseller/enroll",{method:"POST",authenticated:!0,body:{},schema:Li})}acceptResellerInvite(e){return this.request("/reseller/accept-invite",{method:"POST",authenticated:!0,body:{token:e},schema:Li})}resellerCatalog(e={}){return this.request("/reseller/catalog",{authenticated:!0,query:{search:e.search,page:void 0===e.page?void 0:String(e.page),per_page:void 0===e.perPage?void 0:String(e.perPage)},schema:Ki})}quoteResellerOrder(e){return this.request("/reseller/orders/quote",{method:"POST",authenticated:!0,body:{items:e.map(e=>({product_id:e.productId,...void 0===e.variantId?{}:{variant_id:e.variantId},quantity:e.quantity}))},schema:Wi})}resellerOrders(e={}){return this.request("/reseller/orders",{authenticated:!0,query:{page:void 0===e.page?void 0:String(e.page),per_page:void 0===e.perPage?void 0:String(e.perPage)},schema:Gi})}resellerOrder(e){return this.request(`/reseller/orders/${encodeURIComponent(e)}`,{authenticated:!0,schema:Bi})}resellerWallet(){return this.request("/reseller/wallet",{authenticated:!0,schema:Hi})}resellerTopupQuote(){return this.request("/reseller/wallet/topup-quote",{authenticated:!0,schema:di})}createResellerTopup(e){return this.request("/reseller/wallet/topup",{method:"POST",authenticated:!0,body:{amount:e},schema:Xi})}resellerApiKeys(){return this.request("/reseller/api-keys",{authenticated:!0,schema:Yi})}async logout(){if(this.getSession()){try{await this.request("/auth/logout",{method:"POST",authenticated:!0})}catch(e){if(e instanceof es&&401===e.status)return;throw e}this.clearSession()}}};exports.HeadlessCustomerClient=is,exports.HeadlessCustomerError=es,exports.createCustomerClient=function(e){return new is(e)};
1
+ var e;function t(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const i=o.prototype,s=Object.keys(i);for(let e=0;e<s.length;e++){const t=s[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class s extends i{}function o(e){var t;const i=n?.Parent?new s:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(e=globalThis).__zod_globalConfig??(e.__zod_globalConfig={});var i=globalThis.__zod_globalConfig;function s(e){return e&&Object.assign(i,e),i}function o(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 a(e,t){return"bigint"==typeof t?t.toString():t}function u(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function c(e){return null==e}function d(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var l=Symbol("evaluating");function p(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==l)return void 0===r&&(r=l,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function h(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function f(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function m(e){return JSON.stringify(e)}var _="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var y=u(()=>{if(i.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function g(e){if(!1===v(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!==v(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return g(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var w=new Set(["string","number","symbol"]);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function S(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 E={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 $(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 I(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 T(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function O(e){return"string"==typeof e?e:e?.message}function x(e,t,n){const r=e.message?e.message:O(e.inst?._zod.def?.error?.(e))??O(t?.error?.(e))??O(n.customError?.(e))??O(n.localeError?.(e))??"Invalid input",{inst:i,continue:s,input:o,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=o),a}function P(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function N(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var A=(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,a,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Z=t("$ZodError",A),q=t("$ZodError",A,{Parent:Error});var j=e=>(t,r,i,o)=>{const a=i?{...i,async:!1}:{async:!1},u=t._zod.run({value:r,issues:[]},a);if(u instanceof Promise)throw new n;if(u.issues.length){const t=new(o?.Err??e)(u.issues.map(e=>x(e,a,s())));throw _(t,o?.callee),t}return u.value},C=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>x(e,o,s())));throw _(t,i?.callee),t}return a.value},D=e=>(t,r,i)=>{const o=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new n;return a.issues.length?{success:!1,error:new(e??Z)(a.issues.map(e=>x(e,o,s())))}:{success:!0,data:a.value}},R=D(q),U=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>x(e,i,s())))}:{success:!0,data:o.value}},F=U(q),J=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return j(e)(t,n,i)},L=e=>(t,n,r)=>j(e)(t,n,r),M=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return C(e)(t,n,i)},V=e=>async(t,n,r)=>C(e)(t,n,r),K=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return D(e)(t,n,i)},W=e=>(t,n,r)=>D(e)(t,n,r),G=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return U(e)(t,n,i)},B=e=>async(t,n,r)=>U(e)(t,n,r),H=/^[cC][0-9a-z]{6,}$/,Y=/^[0-9a-z]+$/,X=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Q=/^[0-9a-vA-V]{20}$/,ee=/^[A-Za-z0-9]{27}$/,te=/^[a-zA-Z0-9_-]{21}$/,ne=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,re=/^([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})$/,ie=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)$/,se=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var oe=/^(?:(?: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])$/,ae=/^(([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}|:))$/,ue=/^((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])$/,de=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,le=/^[A-Za-z0-9_-]*$/,pe=/^https?$/,he=/^\+[1-9]\d{6,14}$/,fe="(?:(?:\\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])))",me=new RegExp(`^${fe}$`);function _e(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 ve=/^-?\d+$/,ye=/^-?\d+(?:\.\d+)?$/,ge=/^(?:true|false)$/i,be=/^[^A-Z]*$/,we=/^[^a-z]*$/,ze=t("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ke={number:"number",bigint:"bigint",object:"date"},Se=t("$ZodCheckLessThan",(e,t)=>{ze.init(e,t);const n=ke[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ee=t("$ZodCheckGreaterThan",(e,t)=>{ze.init(e,t);const n=ke[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$e=t("$ZodCheckMultipleOf",(e,t)=>{ze.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,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}(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})}}),Ie=t("$ZodCheckNumberFormat",(e,t)=>{ze.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,s]=E[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=s,n&&(r.pattern=ve)}),e._zod.check=o=>{const a=o.value;if(n){if(!Number.isInteger(a))return void o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<i&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Te=t("$ZodCheckMaxLength",(e,t)=>{var n;ze.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 r=n.value;if(r.length<=t.maximum)return;const i=P(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Oe=t("$ZodCheckMinLength",(e,t)=>{var n;ze.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 r=n.value;if(r.length>=t.minimum)return;const i=P(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xe=t("$ZodCheckLengthEquals",(e,t)=>{var n;ze.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 r=n.value,i=r.length;if(i===t.length)return;const s=P(r),o=i>t.length;n.issues.push({origin:s,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Pe=t("$ZodCheckStringFormat",(e,t)=>{var n,r;ze.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})}):(r=e._zod).check??(r.check=()=>{})}),Ne=t("$ZodCheckRegex",(e,t)=>{Pe.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})}}),Ae=t("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=be),Pe.init(e,t)}),Ze=t("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=we),Pe.init(e,t)}),qe=t("$ZodCheckIncludes",(e,t)=>{ze.init(e,t);const n=z(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),je=t("$ZodCheckStartsWith",(e,t)=>{ze.init(e,t);const n=new RegExp(`^${z(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})}}),Ce=t("$ZodCheckEndsWith",(e,t)=>{ze.init(e,t);const n=new RegExp(`.*${z(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})}}),De=t("$ZodCheckOverwrite",(e,t)=>{ze.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Re=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)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const i of r)this.content.push(i)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},Ue={major:4,minor:4,patch:3},Fe=t("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ue;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const n of i)for(const t of n._zod.onattach)t(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let i,s=$(e);for(const o of t){if(o._zod.def.when){if(I(e))continue;if(!o._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,a=o._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new n;if(i||a instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(s||(s=$(e,t)))});else{if(e.issues.length===t)continue;s||(s=$(e,t))}}return i?i.then(()=>e):e},r=(r,s,o)=>{if($(r))return r.aborted=!0,r;const a=t(s,i,o);if(a instanceof Promise){if(!1===o.async)throw new n;return a.then(t=>e._zod.parse(t,o))}return e._zod.parse(a,o)};e._zod.run=(s,o)=>{if(o.skipChecks)return e._zod.parse(s,o);if("backward"===o.direction){const t=e._zod.parse({value:s.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,s,o)):r(t,s,o)}const a=e._zod.parse(s,o);if(a instanceof Promise){if(!1===o.async)throw new n;return a.then(e=>t(e,i,o))}return t(a,i,o)}}p(e,"~standard",()=>({validate:t=>{try{const n=R(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return F(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Je=t("$ZodString",(e,t)=>{var n;Fe.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,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Le=t("$ZodStringFormat",(e,t)=>{Pe.init(e,t),Je.init(e,t)}),Me=t("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=re),Le.init(e,t)}),Ve=t("$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=ie(e))}else t.pattern??(t.pattern=ie());Le.init(e,t)}),Ke=t("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=se),Le.init(e,t)}),We=t("$ZodURL",(e,t)=>{Le.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===pe.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ge=t("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Le.init(e,t)}),Be=t("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=te),Le.init(e,t)}),He=t("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=H),Le.init(e,t)}),Ye=t("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Y),Le.init(e,t)}),Xe=t("$ZodULID",(e,t)=>{t.pattern??(t.pattern=X),Le.init(e,t)}),Qe=t("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Q),Le.init(e,t)}),et=t("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ee),Le.init(e,t)}),tt=t("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=_e({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${fe}T(?:${r})$`)}(t)),Le.init(e,t)}),nt=t("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=me),Le.init(e,t)}),rt=t("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_e(t)}$`)),Le.init(e,t)}),it=t("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ne),Le.init(e,t)}),st=t("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oe),Le.init(e,t),e._zod.bag.format="ipv4"}),ot=t("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ae),Le.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})}}}),at=t("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ue),Le.init(e,t)}),ut=t("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ce),Le.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;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 dt=t("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=de),Le.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 lt=t("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=le),Le.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!le.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})}}),pt=t("$ZodE164",(e,t)=>{t.pattern??(t.pattern=he),Le.init(e,t)});var ht=t("$ZodJWT",(e,t)=>{Le.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=t("$ZodNumber",(e,t)=>{Fe.init(e,t),e._zod.pattern=e._zod.bag.pattern??ye,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),mt=t("$ZodNumberFormat",(e,t)=>{Ie.init(e,t),ft.init(e,t)}),_t=t("$ZodBoolean",(e,t)=>{Fe.init(e,t),e._zod.pattern=ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),vt=t("$ZodUnknown",(e,t)=>{Fe.init(e,t),e._zod.parse=e=>e}),yt=t("$ZodNever",(e,t)=>{Fe.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function gt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}var bt=t("$ZodArray",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let e=0;e<i.length;e++){const o=i[e],a=t.element._zod.run({value:o,issues:[]},r);a instanceof Promise?s.push(a.then(t=>gt(t,n,e))):gt(a,n,e)}return s.length?Promise.all(s).then(()=>n):n}});function wt(e,t,n,r,i,s){const o=n in r;if(e.issues.length){if(i&&s&&!o)return;t.issues.push(...T(n,e.issues))}o||i?void 0===e.value?o&&(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 zt(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function kt(e,t,n,r,i,s){const o=[],a=i.keySet,u=i.catchall._zod,c=u.def.type,d="optional"===u.optin,l="optional"===u.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===c){o.push(p);continue}const i=u.run({value:t[p],issues:[]},r);i instanceof Promise?e.push(i.then(e=>wt(e,n,p,t,d,l))):wt(i,n,p,t,d,l)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var St=t("$ZodObject",(e,t)=>{if(Fe.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=u(()=>zt(t));p(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n});const r=v,i=t.catchall;let s;e._zod.parse=(t,o)=>{s??(s=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const u=[],c=s.shape;for(const e of s.keys){const n=c[e],r="optional"===n._zod.optin,i="optional"===n._zod.optout,s=n._zod.run({value:a[e],issues:[]},o);s instanceof Promise?u.push(s.then(n=>wt(n,t,e,a,r,i))):wt(s,t,e,a,r,i)}return i?kt(u,a,t,o,n.value,e):u.length?Promise.all(u).then(()=>t):t}}),Et=t("$ZodObjectJIT",(e,t)=>{St.init(e,t);const n=e._zod.parse,r=u(()=>zt(t));let s;const o=v,a=!i.jitless,c=a&&y.value,d=t.catchall;let l;e._zod.parse=(i,u)=>{l??(l=r.value);const p=i.value;return o(p)?a&&c&&!1===u?.async&&!0!==u.jitless?(s||(s=(e=>{const t=new Re(["shape","payload","ctx"]),n=r.value,i=e=>{const t=m(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let o=0;for(const r of n.keys)s[r]="key_"+o++;t.write("const newResult = {};");for(const r of n.keys){const n=s[r],o=m(r),a=e[r],u="optional"===a?._zod?.optin,c="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(r)};`),u&&c?t.write(`\n if (${n}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):u?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${o} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\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: [${o}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${o}] = undefined;\n } else {\n newResult[${o}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),i=s(i,u),d?kt([],p,i,u,l,e):i):n(i,u):(i.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),i)}});function $t(e,t,n,r){for(const s of e)if(0===s.issues.length)return t.value=s.value,t;const i=e.filter(e=>!$(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>x(e,r,s())))}),t)}var It=t("$ZodUnion",(e,t)=>{Fe.init(e,t),p(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),p(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),p(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),p(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=>d(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),s=!0;else{if(0===t.issues.length)return t;o.push(t)}}return s?Promise.all(o).then(t=>$t(t,r,e,i)):$t(o,r,e,i)}}),Tt=t("$ZodIntersection",(e,t)=>{Fe.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([t,n])=>xt(e,t,n)):xt(e,i,s)}});function Ot(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(g(e)&&g(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const s of r){const n=Ot(e[s],t[s]);if(!n.valid)return{valid:!1,mergeErrorPath:[s,...n.mergeErrorPath]};i[s]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=Ot(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xt(e,t,n){const r=new Map;let i;for(const a of t.issues)if("unrecognized_keys"===a.code){i??(i=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length&&i&&e.issues.push({...i,keys:s}),$(e))return e;const o=Ot(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Pt=t("$ZodRecord",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!g(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],a=t.keyType._zod.values;if(a){n.value={};const u=new Set;for(const d of a)if("string"==typeof d||"number"==typeof d||"symbol"==typeof d){u.add("number"==typeof d?d.toString():d);const a=t.keyType._zod.run({value:d,issues:[]},r);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=>x(e,r,s())),input:d,path:[d],inst:e});continue}const c=a.value,l=t.valueType._zod.run({value:i[d],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...T(d,e.issues)),n.value[c]=e.value})):(l.issues.length&&n.issues.push(...T(d,l.issues)),n.value[c]=l.value)}let c;for(const e in i)u.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let u=t.keyType._zod.run({value:a,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&ye.test(a)&&u.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(u=e)}if(u.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(e=>x(e,r,s())),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:i[a],issues:[]},r);c instanceof Promise?o.push(c.then(e=>{e.issues.length&&n.issues.push(...T(a,e.issues)),n.value[u.value]=e.value})):(c.issues.length&&n.issues.push(...T(a,c.issues)),n.value[u.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Nt=t("$ZodEnum",(e,t)=>{Fe.init(e,t);const n=o(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>w.has(typeof e)).map(e=>"string"==typeof e?z(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const s=t.value;return r.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),At=t("$ZodLiteral",(e,t)=>{if(Fe.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?z(e):e?z(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Zt=t("$ZodTransform",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.parse=(i,s)=>{if("backward"===s.direction)throw new r(e.constructor.name);const o=t.transform(i.value,i);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i.fallback=!0,i));if(o instanceof Promise)throw new n;return i.value=o,i.fallback=!0,i}});function qt(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var jt=t("$ZodOptional",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",p(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),p(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${d(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>qt(e,r)):qt(i,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ct=t("$ZodExactOptional",(e,t)=>{jt.init(e,t),p(e._zod,"values",()=>t.innerType._zod.values),p(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Dt=t("$ZodNullable",(e,t)=>{Fe.init(e,t),p(e._zod,"optin",()=>t.innerType._zod.optin),p(e._zod,"optout",()=>t.innerType._zod.optout),p(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${d(e.source)}|null)$`):void 0}),p(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)}),Rt=t("$ZodDefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(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 r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ut(e,t)):Ut(r,t)}});function Ut(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Ft=t("$ZodPrefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(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))}),Jt=t("$ZodNonOptional",(e,t)=>{Fe.init(e,t),p(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,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Lt(t,e)):Lt(i,e)}});function Lt(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 Mt=t("$ZodCatch",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",p(e._zod,"optout",()=>t.innerType._zod.optout),p(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>x(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>x(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Vt=t("$ZodPipe",(e,t)=>{Fe.init(e,t),p(e._zod,"values",()=>t.in._zod.values),p(e._zod,"optin",()=>t.in._zod.optin),p(e._zod,"optout",()=>t.out._zod.optout),p(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Kt(e,t.in,n)):Kt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kt(e,t.out,n)):Kt(r,t.out,n)}});function Kt(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 Wt=t("$ZodReadonly",(e,t)=>{Fe.init(e,t),p(e._zod,"propValues",()=>t.innerType._zod.propValues),p(e._zod,"values",()=>t.innerType._zod.values),p(e._zod,"optin",()=>t.innerType?._zod?.optin),p(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gt):Gt(r)}});function Gt(e){return e.value=Object.freeze(e.value),e}var Bt,Ht=t("$ZodCustom",(e,t)=>{ze.init(e,t),Fe.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Yt(t,n,r,e));Yt(i,n,r,e)}});function Yt(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}var Xt=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 r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(Bt=globalThis).__zod_globalRegistry??(Bt.__zod_globalRegistry=new Xt);var Qt=globalThis.__zod_globalRegistry;function en(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function tn(e,t){return new Se({check:"less_than",...S(t),value:e,inclusive:!1})}function nn(e,t){return new Se({check:"less_than",...S(t),value:e,inclusive:!0})}function rn(e,t){return new Ee({check:"greater_than",...S(t),value:e,inclusive:!1})}function sn(e,t){return new Ee({check:"greater_than",...S(t),value:e,inclusive:!0})}function on(e,t){return new $e({check:"multiple_of",...S(t),value:e})}function an(e,t){return new Te({check:"max_length",...S(t),maximum:e})}function un(e,t){return new Oe({check:"min_length",...S(t),minimum:e})}function cn(e,t){return new xe({check:"length_equals",...S(t),length:e})}function dn(e){return new De({check:"overwrite",tx:e})}function ln(e,t){const n=new ze({check:"custom",...S(t)});return n._zod.check=e,n}function pn(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??Qt,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 hn(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{const n=o.schema,s=t.processors[i.type];if(!s)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);s(e,t,n,r)}const s=e._zod.parent;s&&(o.ref||(o.ref=s),hn(s,t,r),t.seen.get(s).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(o.schema,u),"input"===t.io&&_n(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const t=e.metadataRegistry.get(s[0])?.id;if(t){const e=r.get(t);if(e&&e!==s[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,s[0])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:s}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const s=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=s,{defId:s,ref:`${i("__shared")}#/${r}/${s}`}}if(t[1]===n)return{ref:"#"};const i=`#/${r}/`,s=t[1].schema.id??"__schema"+e.counter++;return{defId:s,ref:i+s}})(t);r.def={...r.schema},s&&(r.defId=s);const o=r.schema;for(const e in o)delete o[e];o.$ref=i};if("throw"===e.cycles)for(const s of e.seen.entries()){const e=s[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 s of e.seen.entries()){const n=s[1];if(t!==s[0]){if(e.external){const n=e.external.registry.get(s[0])?.id;if(t!==s[0]&&n){i(s);continue}}(e.metadataRegistry.get(s[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(s)}else i(s)}}function mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,s={...i},o=n.ref;if(n.ref=null,o){r(o);const n=e.seen.get(o),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,s),t._zod.parent===o)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in s||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==o){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const u of[...e.seen.entries()].reverse())r(u[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;void 0!==s&&i.id===s&&delete i.id;const o=e.external?.defs??{};for(const u of e.seen.entries()){const e=u[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?i.$defs=o:i.definitions=o);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:vn(t,"input",e.processors),output:vn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function _n(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return _n(r.element,n);if("set"===r.type)return _n(r.valueType,n);if("lazy"===r.type)return _n(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return _n(r.innerType,n);if("intersection"===r.type)return _n(r.left,n)||_n(r.right,n);if("record"===r.type||"map"===r.type)return _n(r.keyType,n)||_n(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(_n(r.in,n)||_n(r.out,n));if("object"===r.type){for(const e in r.shape)if(_n(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(_n(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(_n(e,n))return!0;return!(!r.rest||!_n(r.rest,n))}return!1}var vn=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=pn({...i??{},target:s,io:t,processors:n});return hn(e,o),fn(o,e),mn(o,e)},yn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gn=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);t.seen.get(e).ref=i.innerType},bn=t("ZodISODateTime",(e,t)=>{tt.init(e,t),Gn.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,...S(t)})}(bn,e)}var zn=t("ZodISODate",(e,t)=>{nt.init(e,t),Gn.init(e,t)});function kn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}(zn,e)}var Sn=t("ZodISOTime",(e,t)=>{rt.init(e,t),Gn.init(e,t)});function En(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}(Sn,e)}var $n=t("ZodISODuration",(e,t)=>{it.init(e,t),Gn.init(e,t)});function In(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}($n,e)}var Tn=(e,t)=>{Z.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if("invalid_key"===s.code)r({issues:s.issues},[...i,...s.path]);else if("invalid_element"===s.code)r({issues:s.issues},[...i,...s.path]);else{const e=[...i,...s.path];if(0===e.length)n._errors.push(t(s));else{let r=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(s))),r=r[n],i++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,a,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,a,2)}},isEmpty:{get:()=>0===e.issues.length}})},On=t("ZodError",Tn,{Parent:Error}),xn=j(On),Pn=C(On),Nn=D(On),An=U(On),Zn=J(On),qn=L(On),jn=M(On),Cn=V(On),Dn=K(On),Rn=W(On),Un=G(On),Fn=B(On),Jn=new WeakMap;function Ln(e,t,n){const r=Object.getPrototypeOf(e);let i=Jn.get(r);if(i||(i=new Set,Jn.set(r,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,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 Mn=t("ZodType",(e,t)=>(Fe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vn(e,"input"),output:vn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=pn({...n,processors:t});return hn(e,r),fn(r,e),mn(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>xn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Nn(e,t,n),e.parseAsync=async(t,n)=>Pn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>An(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Zn(e,t,n),e.decode=(t,n)=>qn(e,t,n),e.encodeAsync=async(t,n)=>jn(e,t,n),e.decodeAsync=async(t,n)=>Cn(e,t,n),e.safeEncode=(t,n)=>Dn(e,t,n),e.safeDecode=(t,n)=>Rn(e,t,n),e.safeEncodeAsync=async(t,n)=>Un(e,t,n),e.safeDecodeAsync=async(t,n)=>Fn(e,t,n),Ln(e,"ZodType",{check(...e){const t=this.def;return this.clone(f(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 k(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,...S(n)})}(Br,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=ln(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(N(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(N(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(dn(e))},optional(){return Dr(this)},exactOptional(){return new Rr({type:"optional",innerType:this})},nullable(){return Fr(this)},nullish(){return Dr(Fr(this))},nonoptional(e){return function(e,t){return new Mr({type:"nonoptional",innerType:e,...S(t)})}(this,e)},array(){return Er(this)},or(e){return Or([this,e])},and(e){return new xr({type:"intersection",left:this,right:e})},transform(e){return Wr(this,new jr({type:"transform",transform:e}))},default(e){return t=e,new Jr({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():b(t)}});var t},prefault(e){return t=e,new Lr({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():b(t)}});var t},catch(e){return new Vr({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Wr(this,e)},readonly(){return new Gr({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Qt.add(t,{description:e}),t},meta(...e){if(0===e.length)return Qt.get(this);const t=this.clone();return Qt.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:()=>Qt.get(e)?.description,configurable:!0}),e)),Vn=t("_ZodString",(e,t)=>{Je.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:s,format:o,patterns:a,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof s&&(r.maxLength=s),o&&(r.format=yn[o]??o,""===r.format&&delete r.format,"time"===o&&delete r.format),u&&(r.contentEncoding=u),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.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,Ln(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ne({check:"string_format",format:"regex",...S(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new qe({check:"string_format",format:"includes",...S(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new je({check:"string_format",format:"starts_with",...S(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Ce({check:"string_format",format:"ends_with",...S(t),suffix:e})}(...e))},min(...e){return this.check(un(...e))},max(...e){return this.check(an(...e))},length(...e){return this.check(cn(...e))},nonempty(...e){return this.check(un(1,...e))},lowercase(e){return this.check(function(e){return new Ae({check:"string_format",format:"lowercase",...S(e)})}(e))},uppercase(e){return this.check(function(e){return new Ze({check:"string_format",format:"uppercase",...S(e)})}(e))},trim(){return this.check(dn(e=>e.trim()))},normalize(...e){return this.check(function(e){return dn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(dn(e=>e.toLowerCase()))},toUpperCase(){return this.check(dn(e=>e.toUpperCase()))},slugify(){return this.check(dn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Kn=t("ZodString",(e,t)=>{Je.init(e,t),Vn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}(Bn,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}(Xn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}(hr,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}(Qn,t)),e.guid=t=>e.check(en(Hn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}(Yn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}(Yn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}(Yn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}(Yn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}(er,t)),e.guid=t=>e.check(en(Hn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}(tr,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}(nr,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}(rr,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}(dr,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}(lr,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}(ir,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}(sr,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}(or,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}(ar,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}(ur,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}(cr,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}(pr,t)),e.datetime=t=>e.check(wn(t)),e.date=t=>e.check(kn(t)),e.time=t=>e.check(En(t)),e.duration=t=>e.check(In(t))});function Wn(e){return function(e,t){return new e({type:"string",...S(t)})}(Kn,e)}var Gn=t("ZodStringFormat",(e,t)=>{Le.init(e,t),Vn.init(e,t)}),Bn=t("ZodEmail",(e,t)=>{Ke.init(e,t),Gn.init(e,t)}),Hn=t("ZodGUID",(e,t)=>{Me.init(e,t),Gn.init(e,t)}),Yn=t("ZodUUID",(e,t)=>{Ve.init(e,t),Gn.init(e,t)}),Xn=t("ZodURL",(e,t)=>{We.init(e,t),Gn.init(e,t)}),Qn=t("ZodEmoji",(e,t)=>{Ge.init(e,t),Gn.init(e,t)}),er=t("ZodNanoID",(e,t)=>{Be.init(e,t),Gn.init(e,t)}),tr=t("ZodCUID",(e,t)=>{He.init(e,t),Gn.init(e,t)}),nr=t("ZodCUID2",(e,t)=>{Ye.init(e,t),Gn.init(e,t)}),rr=t("ZodULID",(e,t)=>{Xe.init(e,t),Gn.init(e,t)}),ir=t("ZodXID",(e,t)=>{Qe.init(e,t),Gn.init(e,t)}),sr=t("ZodKSUID",(e,t)=>{et.init(e,t),Gn.init(e,t)}),or=t("ZodIPv4",(e,t)=>{st.init(e,t),Gn.init(e,t)}),ar=t("ZodIPv6",(e,t)=>{ot.init(e,t),Gn.init(e,t)}),ur=t("ZodCIDRv4",(e,t)=>{at.init(e,t),Gn.init(e,t)}),cr=t("ZodCIDRv6",(e,t)=>{ut.init(e,t),Gn.init(e,t)}),dr=t("ZodBase64",(e,t)=>{dt.init(e,t),Gn.init(e,t)}),lr=t("ZodBase64URL",(e,t)=>{lt.init(e,t),Gn.init(e,t)}),pr=t("ZodE164",(e,t)=>{pt.init(e,t),Gn.init(e,t)}),hr=t("ZodJWT",(e,t)=>{ht.init(e,t),Gn.init(e,t)}),fr=t("ZodNumber",(e,t)=>{ft.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:i,maximum:s,format:o,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;"string"==typeof o&&o.includes("int")?r.type="integer":r.type="number";const d="number"==typeof c&&c>=(i??Number.NEGATIVE_INFINITY),l="number"==typeof u&&u<=(s??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof i&&(r.minimum=i),l?p?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u:"number"==typeof s&&(r.maximum=s),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),Ln(e,"ZodNumber",{gt(e,t){return this.check(rn(e,t))},gte(e,t){return this.check(sn(e,t))},min(e,t){return this.check(sn(e,t))},lt(e,t){return this.check(tn(e,t))},lte(e,t){return this.check(nn(e,t))},max(e,t){return this.check(nn(e,t))},int(e){return this.check(vr(e))},safe(e){return this.check(vr(e))},positive(e){return this.check(rn(0,e))},nonnegative(e){return this.check(sn(0,e))},negative(e){return this.check(tn(0,e))},nonpositive(e){return this.check(nn(0,e))},multipleOf(e,t){return this.check(on(e,t))},step(e,t){return this.check(on(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 mr(e){return function(e,t){return new e({type:"number",checks:[],...S(t)})}(fr,e)}var _r=t("ZodNumberFormat",(e,t)=>{mt.init(e,t),fr.init(e,t)});function vr(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}(_r,e)}var yr=t("ZodBoolean",(e,t)=>{_t.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function gr(e){return function(e,t){return new e({type:"boolean",...S(t)})}(yr,e)}var br=t("ZodUnknown",(e,t)=>{vt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function wr(){return new br({type:"unknown"})}var zr=t("ZodNever",(e,t)=>{yt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function kr(e){return function(e,t){return new e({type:"never",...S(t)})}(zr,e)}var Sr=t("ZodArray",(e,t)=>{bt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(i.minItems=o),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=hn(s.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Ln(e,"ZodArray",{min(e,t){return this.check(un(e,t))},nonempty(e){return this.check(un(1,e))},max(e,t){return this.check(an(e,t))},length(e,t){return this.check(cn(e,t))},unwrap(){return this.element}})});function Er(e,t){return function(e,t,n){return new e({type:"array",element:t,...S(n)})}(Sr,e,t)}var $r=t("ZodObject",(e,t)=>{Et.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const c in o)i.properties[c]=hn(o[c],t,{...r,path:[...r.path,"properties",c]});const a=new Set(Object.keys(o)),u=new Set([...a].filter(e=>{const n=s.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));u.size>0&&(i.required=Array.from(u)),"never"===s.catchall?._zod.def.type?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=hn(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),p(e,"shape",()=>t.shape),Ln(e,"ZodObject",{keyof(){return Ar(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:wr()})},loose(){return this.clone({...this._zod.def,catchall:wr()})},strict(){return this.clone({...this._zod.def,catchall:kr()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!g(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 k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return h(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!g(t))throw new Error("Invalid input to safeExtend: expected a plain object");return k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return h(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 k(e,f(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return h(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,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return k(e,f(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return h(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return k(e,f(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return h(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return k(t,f(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return h(this,"shape",i),i},checks:[]}))}(Cr,this,e[0])},required(...e){return t=Mr,n=this,r=e[0],k(n,f(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(r)for(const n in r){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return h(this,"shape",i),i}}));var t,n,r}})});function Ir(e,t){const n={type:"object",shape:e??{},...S(t)};return new $r(n)}var Tr=t("ZodUnion",(e,t)=>{It.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=!1===i.inclusive,o=i.options.map((e,n)=>hn(e,t,{...r,path:[...r.path,s?"oneOf":"anyOf",n]}));s?n.oneOf=o:n.anyOf=o})(e,t,n,r),e.options=t.options});function Or(e,t){return new Tr({type:"union",options:e,...S(t)})}var xr=t("ZodIntersection",(e,t)=>{Tt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=hn(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=hn(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]]})(e,t,n,r)});var Pr=t("ZodRecord",(e,t)=>{Pt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag?.patterns;if("loose"===s.mode&&a&&a.size>0){const e=hn(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const t of a)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=hn(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=hn(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const e=[...u].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});var Nr=t("ZodEnum",(e,t)=>{Nt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=o(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const i={};for(const s of e){if(!n.has(s))throw new Error(`Key ${s} not found in enum`);i[s]=t.entries[s]}return new Nr({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Nr({...t,checks:[],...S(r),entries:i})}});function Ar(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Nr({type:"enum",entries:n,...S(t)})}var Zr=t("ZodLiteral",(e,t)=>{At.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,i=[];for(const s of r.values)if(void 0===s){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof s){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qr(e,t){return new Zr({type:"literal",values:Array.isArray(e)?e:[e],...S(t)})}var jr=t("ZodTransform",(e,t)=>{Zt.init(e,t),Mn.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,i)=>{if("backward"===i.direction)throw new r(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(N(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(N(t))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=s,n.fallback=!0,n)}});var Cr=t("ZodOptional",(e,t)=>{jt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Dr(e){return new Cr({type:"optional",innerType:e})}var Rr=t("ZodExactOptional",(e,t)=>{Ct.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ur=t("ZodNullable",(e,t)=>{Dt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=hn(i.innerType,t,r),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fr(e){return new Ur({type:"nullable",innerType:e})}var Jr=t("ZodDefault",(e,t)=>{Rt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Lr=t("ZodPrefault",(e,t)=>{Ft.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Mr=t("ZodNonOptional",(e,t)=>{Jt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Vr=t("ZodCatch",(e,t)=>{Mt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let s;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Kr=t("ZodPipe",(e,t)=>{Vt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o="input"===t.io?s?i.out:i.in:i.out;hn(o,t,r),t.seen.get(e).ref=o})(e,t,0,r),e.in=t.in,e.out=t.out});function Wr(e,t){return new Kr({type:"pipe",in:e,out:t})}var Gr=t("ZodReadonly",(e,t)=>{Wt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Br=t("ZodCustom",(e,t)=>{Ht.init(e,t),Mn.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 Hr,Yr,Xr,Qr=Wn().nullable(),ei=(Hr=Wn(),(Yr=wr())&&Yr._zod?new Pr({type:"record",keyType:Hr,valueType:Yr,...S(Xr)}):new Pr({type:"record",keyType:Wn(),valueType:Hr,...S(Yr)})),ti=Ir({logo_url:Qr,primary_color:Wn(),secondary_color:Wn(),accent_color:Wn()}),ni=Ir({customer:Ir({id:Qr,email:Wn(),name:Wn(),avatar_url:Qr,joined_at:Qr}),shop:Ir({id:Wn(),slug:Wn(),name:Wn(),currency:Wn(),branding:ti}),token:Qr}),ri=Ir({attachment_image_id:Ir({cloudflare_image_id:Qr}).nullable()}),ii=Ir({attachment_imageId:Ir({cloudflareImageId:Qr}).nullable()}),si=Ir({uniqid:Wn(),status:Wn(),total:Wn(),total_display:Qr,currency:Wn(),created_at:Wn(),line_items:Er(Ir({product_title:Qr,quantity:mr(),product:ri.nullable()}))}),oi=Ir({uniqid:Wn(),status:Wn(),total:Wn(),totalDisplay:Qr,currency:Wn(),createdAt:Wn(),lineItems:Er(Ir({productTitle:Qr,quantity:mr(),product:ii.nullable()}))}),ai=Ir({invoices:Er(oi),pagination:Ir({page:mr(),limit:mr(),total:mr(),has_more:gr()})}),ui=Ir({gateway:Wn(),displayName:Qr,cryptoGateway:Qr.optional(),blockchain:Qr,cryptoAddress:Qr,apmMethod:Qr}),ci=Ir({id:Wn(),uniqid:Wn(),status:Wn(),statusDetails:Qr,total:Wn(),totalDisplay:Qr,subtotal:Wn(),discount:Wn(),discountDisplay:Qr,tax:Wn(),taxPercentage:Wn(),currency:Wn(),createdAt:Wn(),updatedAt:Wn(),gatewayUpdatedAt:Qr,customFields:ei.nullable(),balancePaidAmount:Wn(),currentPaymentAttemptId:Qr,lineItems:Er(Ir({id:Wn(),productTitle:Wn(),productType:Wn(),variantTitle:Qr,unitPrice:Wn(),quantity:mr(),total:Wn(),deliveryText:Qr,deliverySummary:Ir({codes:Er(Wn()),links:Er(Ir({label:Wn(),value:Wn(),href:Qr.optional()})),notes:Er(Wn()),serials:Er(Ir({value:Wn(),is_replacement:gr(),is_replaced:gr()}))}).nullable(),deliveredAt:Qr,deliveryStatus:Ar(["PENDING","AWAITING_FULFILLMENT","DELIVERED","FAILED"]),customFields:ei.nullable(),product:Ir({uniqid:Wn(),slug:Qr,serviceText:Qr,attachment_imageId:Ir({cloudflareImageId:Qr}).nullable()}).nullable()})),currentPayment:ui.nullable(),payments:Er(ui)}),di=Ir({quote:Ir({enabled:gr(),currency:Wn(),min_amount:Wn(),max_amount:Qr,bonus_tiers:Er(Ir({min_amount:Wn(),bonus_percent:mr()}))})}),li=Ir({invoice_id:Wn(),url:Wn()}),pi=Ir({id:Wn(),type:Wn(),status:Wn(),amount:Qr,currency:Qr,coupon_code:Qr,reason:Wn(),trigger_reference_type:Wn(),trigger_reference_id:Wn(),created_at:mr(),fulfilled_at:mr().nullable(),expires_at:mr().nullable()}),hi=Ir({summary:Ir({available:Wn(),pending:Wn(),lifetime_earned:Wn(),redeemed:Qr,currency:Wn()}),activity:Er(pi),earned_after_invoice:Er(pi),pending_after_invoice:Er(pi)}),fi=Ir({id:Wn(),uniqid:Wn(),label:Qr,code:Wn(),url:Qr,status:Ar(["pending","active","inactive","rejected"]),is_primary:gr(),total_clicks:mr(),total_sales:mr(),total_revenue:Wn(),is_active:gr(),is_approved:gr(),requested_affiliate_revenue_percent:mr().nullable(),requested_affiliate_customer_discount_percent:mr().nullable(),affiliate_revenue_percent_override:mr().nullable(),affiliate_customer_discount_percent_override:mr().nullable(),effective_commission_percent:mr(),effective_customer_discount_percent:mr(),commission_shareback_percent:mr(),commission_shareback_enabled:gr(),max_commission_shareback_percent:mr(),created_at:Qr,updated_at:Qr}),mi=Ir({customer:Ir({id:Wn(),email:Wn(),name:Qr}).nullable(),state:Wn(),can_create_custom_links:gr(),custom_link_request_disabled_reason:Qr,custom_links_require_approval:gr(),affiliate_codes_accepted_at_checkout:gr(),cash_payout_enabled:gr(),links:Er(fi),preferred_payout:Ir({asset:Wn(),network:Wn(),address:Wn()}).nullable(),balance_currency:Wn(),balances:Ir({pending:Wn(),available:Wn(),requested:Wn(),converted:Wn(),paid:Wn(),approved_total:Wn()}),commissions:Er(Ir({id:Wn(),invoice_id:Wn(),commission_amount:Wn(),base_amount:Wn(),discount_amount:Wn(),status:Wn(),created_at:Qr,paid_at:Qr,converted_at:Qr})),claims:Er(Ir({id:Wn(),type:Wn(),status:Wn(),amount:Wn(),currency:Wn(),allocations:Er(Ir({source_type:Wn(),commission_id:Qr,adjustment_id:Qr,amount:Wn()})),wallet_transaction_id:Qr,payout_asset:Qr,payout_network:Qr,payout_address:Qr,note:Qr,metadata:wr(),completed_at:Qr,rejected_at:Qr,cancelled_at:Qr,created_at:Qr,updated_at:Qr}))}),_i=Ir({uniqid:Wn(),status:Wn(),gateway:Wn(),current_period_start:Wn(),current_period_end:Wn(),trial_end:Qr,cancel_at_period_end:gr(),canceled_at:Qr,created_at:Wn(),plan:Ir({id:Wn(),uniqid:Wn(),name:Wn(),price:Wn(),currency:Wn(),interval:Wn(),interval_count:mr(),trial_days:mr()}).nullable(),payment_method:Ir({id:Wn(),gateway:Wn(),type:Wn(),card_brand:Qr,card_last4:Qr,card_exp_month:mr().nullable(),card_exp_year:mr().nullable(),is_default:gr()}).nullable(),actions:Ir({can_pause:gr(),can_resume:gr(),can_cancel:gr(),can_manage_payment_method:gr()})}),vi=Ir({enabled:gr(),account:Ir({points_balance:mr(),lifetime_points:mr()}).nullable(),settings:Ir({earn_rate_per_usd:mr(),redeem_value_per_point:mr(),min_redeem_points:mr()}).nullable(),transactions:Er(Ir({type:Ar(["EARN_ORDER","EARN_REVIEW","REDEEM","ADJUST"]),points:mr(),balance_after:mr(),description:Qr,created_at:Wn()}))}),yi=Ir({redeemed_points:mr(),wallet_amount:Wn(),currency:Wn(),points_balance:mr(),replayed:gr()}),gi=Ir({uniqid:Wn(),invoice_uniqid:Wn(),product_title:Wn(),period_days:mr(),starts_at:Wn(),expires_at:Wn(),status:Ar(["ACTIVE","EXPIRED","VOIDED"]),claim_status:Ar(["REQUESTED","APPROVED","DENIED"]).nullable(),created_at:Wn()}),bi=Ir({warranties:Er(gi)}),wi=Ir({warranty:gi.extend({claim_status:qr("REQUESTED")})}),zi=Ir({customer:Ir({id:Wn(),email:Wn(),name:Wn(),joined_at:Qr})}),ki=Ir({avatar_url:Qr}),Si=Ir({global_unsubscribed:gr(),lists:Er(Ir({id:Wn(),name:Wn(),description:Qr,subscribed:gr()}))}),Ei=Ir({updated:gr()}),$i=Ir({order_created_emails:gr(),order_completed_emails:gr(),payment_issue_emails:gr()}),Ii=Ir({favorites:Er(Ir({product_uniqid:Wn(),title:Wn(),slug:Qr,image_url:Qr,price_display:mr(),unavailable:gr(),created_at:Wn()}))}),Ti=Or([Ir({added:qr(!0)}),Ir({removed:qr(!0)})]),Oi=Ir({license:Ir({uniqid:Wn(),hardware_id:Qr})}),xi=Ir({invoice_id:Wn(),checkout_url:Wn(),preferred_gateways:Er(Wn()),license:Ir({uniqid:Wn(),product_title:Wn()})}),Pi=Ir({invoices:Er(Ir({id:Wn(),uniqid:Wn(),total:Wn(),currency:Wn(),status:Wn(),gateway:Wn(),created_at:Wn(),completed_at:Wn()}))}),Ni=Ir({subscription:Ir({id:Wn(),status:Wn(),cancel_at_period_end:gr(),cancel_reason:Qr,canceled_at:Qr})}),Ai=Ir({subscription:Ir({id:Wn(),status:Wn()})}),Zi=Ir({ticket:Ir({uniqid:Wn(),title:Wn(),status:Wn(),invoice_id:Qr,created_at:Wn(),updated_at:Wn(),messages:Er(Ir({id:Wn(),role:Ar(["CUSTOMER","SHOP","SYSTEM"]),message:Wn(),created_at:Wn()}))})}),qi=Ir({uniqid:Wn()}),ji=Ir({affiliate_link:Ir({id:Wn(),customer_id:Wn(),label:Qr,code:Wn(),url:Qr,status:Ar(["pending","approved","rejected"]),requested_affiliate_revenue_percent:mr().nullable(),requested_affiliate_customer_discount_percent:mr().nullable(),created_at:Wn(),updated_at:Wn()})}),Ci=Ir({check:Wn(),passed:gr(),reason:Qr.optional()}),Di=Ir({eligible:gr(),decision:Ar(["ELIGIBLE","DENIED","NO_RULE"]),reason:Qr,eligibility_checks:Er(Ci)}),Ri=Ir({request_id:Wn(),event_id:Qr,decision:Ar(["ISSUED_REPLACEMENT","FALLBACK_REFUND","FALLBACK_CREDIT","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED"]),status_label:Ar(["ISSUED","REFUNDED","CREDITED","QUEUED_MANUAL","DENIED","EXHAUSTED","FAILED","PENDING"]),reason:Qr,eligibility_checks:Er(Ci)}),Ui=Ir({id:Wn(),name:Qr,discount_percent:mr().nullable()}),Fi=Ir({id:Wn(),status:Ar(["INVITED","APPLIED","ACTIVE","SUSPENDED","REJECTED"]),tier:Ui.nullable(),application_note:Qr,lifetime_revenue:Wn(),lifetime_orders:mr(),approved_at:Qr,created_at:Wn()}),Ji=Ir({program_enabled:gr(),enrollment_mode:Ar(["MANUAL","APPLICATION","OPEN"]),application_message:Qr,require_application_note:gr(),reseller:Fi.nullable()}),Li=Ir({reseller:Fi}),Mi=Ar(["variant","product","tier"]),Vi=Ir({variant_id:Wn(),title:Wn(),stock:mr(),supplier_backed:gr(),orderable:gr(),base_price:Wn(),unit_price:Wn(),discount_percent:mr(),applied_override:Mi}),Ki=Ir({tier:Ui,catalog:Ir({currency:Wn(),total:mr(),page:mr(),per_page:mr(),items:Er(Ir({product_id:Wn(),uniqid:Wn(),title:Wn(),type:Wn(),stock:mr(),supplier_backed:gr(),orderable:gr(),volume_discount_enabled:gr(),base_price:Wn(),unit_price:Wn(),discount_percent:mr(),applied_override:Mi,variants:Er(Vi)}))})}),Wi=Ir({quote:Ir({currency:Wn(),tier:Ui,items:Er(Ir({product_id:Wn(),product_title:Wn(),product_type:Wn(),variant_id:Qr,variant_title:Qr,quantity:mr(),base_price:Wn(),discount_percent:mr(),unit_price:Wn(),line_total:Wn(),applied_override:Mi,volume_discount_applied:Wn()})),subtotal:Wn(),volume_discount_total:Wn(),total:Wn(),savings:Wn()})}),Gi=Ir({orders:Ir({total:mr(),page:mr(),per_page:mr(),items:Er(Ir({uniqid:Wn(),status:Wn(),currency:Wn(),total:Wn(),item_count:mr(),created_at:Wn()}))})}),Bi=Ir({order:Ir({uniqid:Wn(),status:Wn(),currency:Wn(),total:Wn(),item_count:mr(),created_at:Wn(),tier_name:Wn(),tier_discount_percent:mr(),partially_delivered:gr(),refunded_amount:Qr,lines:Er(Ir({product_id:Qr,product_title:Wn(),variant_id:Qr,variant_title:Qr,quantity:mr(),unit_price:Wn(),total:Wn(),delivered:gr(),delivered_at:Qr,serials:Er(Wn())}))})}),Hi=Ir({wallet:Ir({currency:Wn(),balance:Wn(),hold_balance:Wn(),available:Wn(),is_active:gr()})}),Yi=Ir({api_keys:Er(Ir({id:Wn(),name:Wn(),key_last4:Wn(),last_used_at:Qr,revoked_at:Qr,created_at:Wn()}))}),Xi=Ir({topup:Ir({uniqid:Wn(),url:Wn()})}),Qi=Ir({shop:Ir({id:Wn(),slug:Wn(),name:Wn(),currency:Wn(),branding:ti}),customer:Ir({email:Wn(),name:Wn()}),stats:Ir({invoices_count:mr(),licenses_count:mr(),deliverables_count:mr(),tickets_count:mr()}),wallet:Ir({available:Wn(),total:Wn(),hold:Wn(),currency:Wn(),enabled:gr()}).nullable(),rewards:hi,affiliate:mi,invoices:Er(si),subscriptions:Er(_i),licenses:Er(Ir({uniqid:Wn(),invoice_id:Wn(),status:Wn(),license_key:Wn(),hardware_id:Qr,expires_at:mr().nullable(),renewable:gr(),product:Ir({title:Wn().optional()}).optional()})),deliverables:Er(Ir({id:Wn(),invoice_uniqid:Wn(),product_title:Wn(),kind:Ar(["file","serial","license"]),label:Wn(),value:Wn(),href:Qr,created_at:Wn()})),tickets:Er(Ir({uniqid:Wn(),title:Wn(),status:Wn(),updated_at:Wn(),created_at:Qr}))}),es=class extends Error{constructor(e,t,n){super(t),this.status=e,this.code=n,this.name="HeadlessCustomerError"}};function ts(e){if(!e)return null;try{const t=JSON.parse(e);if(!function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(t)||"string"!=typeof t.accessToken||!t.accessToken.startsWith("hcs_")||"string"!=typeof t.expiresAt||"number"!=typeof t.savedAt||!Number.isFinite(t.savedAt))return null;const n=Date.parse(t.expiresAt);return!Number.isFinite(n)||n<=Date.now()?null:{accessToken:t.accessToken,expiresAt:t.expiresAt,savedAt:t.savedAt}}catch{return null}}function ns(e){if(!e)return null;const t=e.match(/filename\*=UTF-8''([^;]+)/i);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}return e.match(/filename="([^"]+)"/i)?.[1]??null}function rs(e){if(!e?.startsWith("/api/customer/"))return null;try{const t=new URL(e,"https://headless-customer.invalid");if(!/^\/api\/customer\/invoice\/[^/]+\/download$/.test(t.pathname))return null;const n=t.searchParams.get("file_index");if(null===n||!/^\d+$/.test(n))return null;const r=Number(n);return Number.isSafeInteger(r)?r:null}catch{return null}}function is(e){try{return"undefined"==typeof window?null:window[e]}catch{return null}}var ss=class{constructor(e){if(this.memorySession=null,!e.shop.trim())throw new Error("HeadlessCustomerClient requires a shop.");if(!e.publishableKey.trim())throw new Error("HeadlessCustomerClient requires a publishableKey.");if(this.shop=e.shop.trim(),this.publishableKey=e.publishableKey.trim(),this.base=(e.apiBaseUrl??"https://api.shoppex.io").replace(/\/+$/,""),this.fetchImpl=e.fetchImpl??globalThis.fetch?.bind(globalThis),!this.fetchImpl)throw new Error("No fetch implementation available; pass fetchImpl.");this.storage=e.storage??is("sessionStorage"),this.persistentStorage=e.persistentStorage??is("localStorage"),this.storageKey=`shoppex_headless_customer_session:${this.shop}`}getSession(){const e=this.memorySession?[this.memorySession]:[];if(this.storage)try{const t=ts(this.storage.getItem(this.storageKey));t&&e.push(t)}catch{}if(this.persistentStorage)try{const t=ts(this.persistentStorage.getItem(this.storageKey));t&&e.push(t)}catch{}const t=e.sort((e,t)=>t.savedAt-e.savedAt)[0]??null;return t?(this.memorySession=t,{accessToken:t.accessToken,expiresAt:t.expiresAt}):(this.clearSession(),null)}clearSession(){this.memorySession=null;try{this.storage?.removeItem(this.storageKey)}catch{}try{this.persistentStorage?.removeItem(this.storageKey)}catch{}}saveSession(e,t){const n={...e,savedAt:Date.now()};this.memorySession=n;const r=t?this.persistentStorage:this.storage,i=t?this.storage:this.persistentStorage;try{r?.setItem(this.storageKey,JSON.stringify(n))}catch{}try{i?.removeItem(this.storageKey)}catch{}}url(e,t={}){const n=new URL(`${this.base}/v1/customer${e}`);n.searchParams.set("shop",this.shop);for(const[r,i]of Object.entries(t))void 0!==i&&""!==i&&n.searchParams.set(r,i);return n.toString()}async request(e,t={}){if(void 0!==t.body&&void 0!==t.formData)throw new Error("Customer requests cannot send JSON and FormData together.");const n=t.authenticated?this.getSession():null;if(t.authenticated&&!n)throw new es(401,"Customer session is missing or expired.","UNAUTHORIZED");const r={accept:"application/json","x-shoppex-publishable-key":this.publishableKey,...void 0===t.body?{}:{"content-type":"application/json"},...n?{authorization:`Bearer ${n.accessToken}`}:{}},i=t.formData??(void 0===t.body?void 0:JSON.stringify(t.body)),s=await this.fetchImpl(this.url(e,t.query),{method:t.method??"GET",headers:r,...void 0===i?{}:{body:i},cache:"no-store"});let o=null;try{o=await s.json()}catch{}if(!s.ok||!o||o.error)throw 401===s.status&&t.authenticated&&this.clearSession(),new es(s.status,o?.error??`Request failed (${s.status})`,o?.error_code??null);if(!t.schema)return o.data;const a=t.schema.safeParse(o.data);if(!a.success)throw new es(s.status,"Customer API response did not match the expected contract.");return a.data}async requestFile(e,t={},n={}){const r=this.getSession();if(!r)throw new es(401,"Customer session is missing or expired.","UNAUTHORIZED");const i=await this.fetchImpl(this.url(e,t),{method:"GET",headers:{"x-shoppex-publishable-key":this.publishableKey,authorization:`Bearer ${r.accessToken}`},cache:"no-store"});if(!i.ok){401===i.status&&this.clearSession();let e=`Download failed (${i.status})`;try{const t=await i.json();t.error&&(e=t.error)}catch{}throw new es(i.status,e)}const s=i.headers.get("content-type");if(n.rejectHtml&&s?.toLowerCase().startsWith("text/html"))throw new es(502,"Shoppex returned an unsafe aggregate download response.","UNSAFE_DOWNLOAD_RESPONSE");return{blob:await i.blob(),filename:ns(i.headers.get("content-disposition")),contentType:s}}requestOtp(e){return this.request("/auth/otp/request",{method:"POST",body:{shop:this.shop,email:e}})}async verifyOtp(e,t,n={}){const r=await this.request("/auth/otp/verify",{method:"POST",body:{shop:this.shop,email:e,otp:t,remember_me:n.rememberMe??!1}}),i="string"==typeof r?.expires_at?Date.parse(r.expires_at):NaN;if("string"!=typeof r?.access_token||!r.access_token.startsWith("hcs_")||"string"!=typeof r.expires_at||!Number.isFinite(i)||i<=Date.now())throw new es(200,"Customer API response did not match the expected contract.");const s={accessToken:r.access_token,expiresAt:r.expires_at};return this.saveSession(s,n.rememberMe??!1),s}async me(){const e=await this.request("/me",{authenticated:!0,schema:ni});if(null!==e.token)throw new es(200,"Customer API response did not match the expected contract.");return{customer:e.customer,shop:e.shop}}async dashboard(){const e=await this.request("/dashboard",{authenticated:!0,schema:Qi});return{...e,deliverables:e.deliverables.map(e=>{const t=rs(e.href);return null===t?e:{...e,href:null,downloadIndex:t}})}}updateProfile(e){return this.request("/profile",{method:"POST",authenticated:!0,body:{name:e.name},schema:zi})}updateAvatar(e){const t=new FormData;return t.append("file",e),this.request("/profile/avatar",{method:"POST",authenticated:!0,formData:t,schema:ki})}removeAvatar(){return this.request("/profile/avatar",{method:"DELETE",authenticated:!0,schema:ki})}emailPreferences(){return this.request("/email-marketing/preferences",{authenticated:!0,schema:Si})}updateEmailPreferences(e){return this.request("/email-marketing/preferences",{method:"PATCH",authenticated:!0,body:{...void 0===e.globalUnsubscribed?{}:{global_unsubscribed:e.globalUnsubscribed},list_subscriptions:(e.listSubscriptions??[]).map(e=>({list_id:e.listId,subscribed:e.subscribed}))},schema:Ei})}notificationPreferences(){return this.request("/notification-preferences",{authenticated:!0,schema:$i})}updateNotificationPreferences(e){return this.request("/notification-preferences",{method:"PATCH",authenticated:!0,body:{...void 0===e.orderCreatedEmails?{}:{order_created_emails:e.orderCreatedEmails},...void 0===e.orderCompletedEmails?{}:{order_completed_emails:e.orderCompletedEmails},...void 0===e.paymentIssueEmails?{}:{payment_issue_emails:e.paymentIssueEmails}},schema:$i})}orders(e={}){return this.request("/invoices",{authenticated:!0,schema:ai,query:{page:void 0===e.page?void 0:String(e.page),limit:void 0===e.limit?void 0:String(e.limit),status:e.status,q:e.search}})}async order(e){const t=await this.request(`/invoice/${encodeURIComponent(e)}`,{authenticated:!0,schema:ci});return{...t,lineItems:t.lineItems.map(e=>({...e,deliverySummary:e.deliverySummary?{...e.deliverySummary,links:e.deliverySummary.links.map(e=>{const t=rs(e.href);return null===t?e:{...e,href:null,downloadIndex:t}})}:null}))}}invoicePdf(e){return this.requestFile(`/invoices/${encodeURIComponent(e)}/pdf`)}replacementEligibility(e,t){return this.request(`/invoices/${encodeURIComponent(e)}/replacement-eligibility`,{authenticated:!0,query:{line_item_id:t},schema:Di})}requestReplacement(e,t){return this.request(`/invoices/${encodeURIComponent(e)}/replacement-requests`,{method:"POST",authenticated:!0,body:{line_item_id:t.lineItemId??null,reason:t.reason,...t.idempotencyKey?{idempotency_key:t.idempotencyKey}:{}},schema:Ri})}async download(e,t){if(!Number.isSafeInteger(t)||t<0)throw new es(400,"download requires a non-negative integer fileIndex from order().deliverySummary.links.","INVALID_FILE_INDEX");return this.requestFile(`/invoice/${encodeURIComponent(e)}/download`,{file_index:String(t)},{rejectHtml:!0})}resetLicenseHwid(e){return this.request(`/licenses/${encodeURIComponent(e)}/reset-hwid`,{method:"POST",authenticated:!0,body:{},schema:Oi})}renewLicense(e){return this.request(`/licenses/${encodeURIComponent(e)}/renew`,{method:"POST",authenticated:!0,body:{shop:this.shop},schema:xi})}walletTopupQuote(){return this.request("/wallet/topup-quote",{authenticated:!0,schema:di})}createWalletTopup(e){return this.request("/wallet/topup",{method:"POST",authenticated:!0,body:{amount:e},schema:li})}subscriptionBillingHistory(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/billing-history`,{authenticated:!0,schema:Pi})}cancelSubscription(e,t={}){return this.request(`/subscriptions/${encodeURIComponent(e)}/cancel`,{method:"POST",authenticated:!0,body:{...void 0===t.cancelAtPeriodEnd?{}:{cancel_at_period_end:t.cancelAtPeriodEnd},...void 0===t.reason?{}:{reason:t.reason}},schema:Ni})}pauseSubscription(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/pause`,{method:"POST",authenticated:!0,body:{},schema:Ai})}resumeSubscription(e){return this.request(`/subscriptions/${encodeURIComponent(e)}/resume`,{method:"POST",authenticated:!0,body:{},schema:Ai})}loyalty(){return this.request("/loyalty",{authenticated:!0,schema:vi})}redeemLoyaltyPoints(e){return this.request("/loyalty/redeem",{method:"POST",authenticated:!0,body:{points:e.points,idempotency_key:e.idempotencyKey},schema:yi})}warranties(e){return this.request("/warranties",{authenticated:!0,query:{invoice:e},schema:bi})}claimWarranty(e,t){return this.request(`/warranties/${encodeURIComponent(e)}/claim`,{method:"POST",authenticated:!0,body:t?{message:t}:{},schema:wi})}favorites(){return this.request("/favorites",{authenticated:!0,schema:Ii})}addFavorite(e){return this.request(`/favorites/${encodeURIComponent(e)}`,{method:"PUT",authenticated:!0,schema:Ti})}removeFavorite(e){return this.request(`/favorites/${encodeURIComponent(e)}`,{method:"DELETE",authenticated:!0,schema:Ti})}affiliate(){return this.request("/affiliate",{authenticated:!0,schema:mi})}createAffiliateLink(e){return this.request("/affiliate/links",{method:"POST",authenticated:!0,body:{shop:this.shop,code:e.code,label:e.label,...void 0===e.requestedRevenuePercent?{}:{requested_affiliate_revenue_percent:e.requestedRevenuePercent},...void 0===e.requestedCustomerDiscountPercent?{}:{requested_affiliate_customer_discount_percent:e.requestedCustomerDiscountPercent}},schema:ji})}createTicket(e){return this.request("/tickets",{method:"POST",authenticated:!0,body:{...void 0===e.title?{}:{title:e.title},message:e.message,...void 0===e.invoiceId?{}:{invoice_id:e.invoiceId}},schema:qi})}ticket(e){return this.request(`/tickets/${encodeURIComponent(e)}`,{authenticated:!0,schema:Zi})}async replyToTicket(e,t){await this.request(`/tickets/${encodeURIComponent(e)}/reply`,{method:"POST",authenticated:!0,body:{message:t}})}reseller(){return this.request("/reseller",{authenticated:!0,schema:Ji})}applyForReseller(e){return this.request("/reseller/apply",{method:"POST",authenticated:!0,body:void 0===e?{}:{note:e},schema:Li})}enrollAsReseller(){return this.request("/reseller/enroll",{method:"POST",authenticated:!0,body:{},schema:Li})}acceptResellerInvite(e){return this.request("/reseller/accept-invite",{method:"POST",authenticated:!0,body:{token:e},schema:Li})}resellerCatalog(e={}){return this.request("/reseller/catalog",{authenticated:!0,query:{search:e.search,page:void 0===e.page?void 0:String(e.page),per_page:void 0===e.perPage?void 0:String(e.perPage)},schema:Ki})}quoteResellerOrder(e){return this.request("/reseller/orders/quote",{method:"POST",authenticated:!0,body:{items:e.map(e=>({product_id:e.productId,...void 0===e.variantId?{}:{variant_id:e.variantId},quantity:e.quantity}))},schema:Wi})}resellerOrders(e={}){return this.request("/reseller/orders",{authenticated:!0,query:{page:void 0===e.page?void 0:String(e.page),per_page:void 0===e.perPage?void 0:String(e.perPage)},schema:Gi})}resellerOrder(e){return this.request(`/reseller/orders/${encodeURIComponent(e)}`,{authenticated:!0,schema:Bi})}resellerWallet(){return this.request("/reseller/wallet",{authenticated:!0,schema:Hi})}resellerTopupQuote(){return this.request("/reseller/wallet/topup-quote",{authenticated:!0,schema:di})}createResellerTopup(e){return this.request("/reseller/wallet/topup",{method:"POST",authenticated:!0,body:{amount:e},schema:Xi})}resellerApiKeys(){return this.request("/reseller/api-keys",{authenticated:!0,schema:Yi})}async logout(){if(this.getSession()){try{await this.request("/auth/logout",{method:"POST",authenticated:!0})}catch(e){if(e instanceof es&&401===e.status)return;throw e}this.clearSession()}}};exports.HeadlessCustomerClient=ss,exports.HeadlessCustomerError=es,exports.createCustomerClient=function(e){return new ss(e)};
2
2
  //# sourceMappingURL=customer.cjs.map