@gamaro.io/widget 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,22 +23,22 @@
23
23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
24
  * SOFTWARE.
25
25
  */
26
- (function(I,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(I=typeof globalThis<"u"?globalThis:I||self,Q(I.GamaroWidget={}))})(this,function(I){Object.defineProperty(I,Symbol.toStringTag,{value:"Module"});var Q={instant:0,fast:150,base:250,slow:400,slower:600},K={standard:"cubic-bezier(0.4, 0, 0.2, 1)",enter:"cubic-bezier(0, 0, 0.2, 1)",exit:"cubic-bezier(0.4, 0, 1, 1)",emphasized:"cubic-bezier(0.2, 0, 0, 1)"},ge="[Gamaro]";function ve(e,...t){console.error(ge,e,...t)}function kt(e,...t){console.warn(ge,e,...t)}function be(e,...t){console.info(ge,e,...t)}function _e(e,...t){console.debug(ge,e,...t)}function gn(e){return e?_e:()=>{}}var vn="gamaro:",bn=["https://gamaro.io"];function Ot(e,t){return t.includes(e)}function zt(e){const t=e.data;return typeof t=="object"&&t!==null&&typeof t.type=="string"&&t.type.startsWith(vn)}function G(e,t,r){if(!e.contentWindow){kt("Cannot send command: iframe not ready");return}try{e.contentWindow.postMessage(t,r)}catch{kt("Failed to post message to iframe")}}function _n(e){const{allowedOrigins:t=bn,onMessage:r,debug:n,sourceWindow:i}=e,o=s=>{if(!(i&&s.source&&s.source!==i)){if(!Ot(s.origin,t)){n&&_e("Ignored message from untrusted origin:",s.origin);return}if(zt(s)){if(n)try{const a=JSON.parse(JSON.stringify(s.data));_e("Received message:",a)}catch{_e("Received message:",s.data?.type??"[Unserializable]")}r(s.data,s.origin)}}};return window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}}function yn(e){return btoa(JSON.stringify(e))}function Le(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function St(e,t="|"){return e.map(r=>Pt(r)).join(t)}function Fe(e,t){return typeof t=="bigint"?t.toString():t}var wn=class{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Ue(e){return new wn(e)}function kn(e){return e==null}function We(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function On(e,t){const r=e/t,n=Math.round(r),i=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}function H(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Et(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function L(e){return Et(e._zod.def)??e._zod.def.shape}function $t(e,t,r){Object.defineProperty(e,t,{get(){const n=r();return H(this,t,n),n},enumerable:!0,configurable:!0})}function It(e,t,r){t in e?H(e,t,r):e[t]=r}function q(e,t,r,n){const i=L(t);for(const o of r){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?$t(e,o,()=>{const a=t._zod.def.shape[o];return n?n(a,o):a}):It(e,o,n?n(s.value,o):s.value))}}function zn(e,t){for(const r of Reflect.ownKeys(t)){const n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?$t(e,r,()=>t[r]):It(e,r,n.value))}}function C(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Sn(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var At="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var $n=Ue(()=>{if(j.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function se(e){if(ye(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ye(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Tt(e){return se(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var In=new Set(["string","number","symbol"]);function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Pt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function An(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Zt={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]},Tn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Pn(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return q(i,e,ke(e,t)),U(e,C(r,{shape:i,checks:[]}))}function ke(e,t){const r=L(e),n=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&n.push(i)}return n}function Zn(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(ke(e,t)),o={};return q(o,e,Reflect.ownKeys(L(e)).filter(s=>!i.has(s))),U(e,C(r,{shape:o,checks:[]}))}function Cn(e,t){if(!se(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=L(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return U(e,C(e._zod.def,{shape:Ct(e,t)}))}function Ct(e,t){const r={};return q(r,e,Reflect.ownKeys(L(e))),zn(r,t),r}function Rn(e,t){if(!se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return U(e,C(e._zod.def,{shape:Ct(e,t)}))}function Nn(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r={};return q(r,e,Reflect.ownKeys(L(e))),q(r,t,Reflect.ownKeys(L(t))),U(e,C(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Rt(e,t,r,n="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);const o=r?new Set(ke(t,r)):void 0,s={};return q(s,t,Reflect.ownKeys(L(t)),e&&((a,c)=>o&&!o.has(c)?a:new e({type:"optional",innerType:a}))),U(t,C(t._zod.def,{shape:s,checks:[]}))}function jn(e,t,r){const n=r?new Set(ke(t,r)):void 0,i={};return q(i,t,Reflect.ownKeys(L(t)),(o,s)=>n&&!n.has(s)?o:new e({type:"nonoptional",innerType:o})),U(t,C(t._zod.def,{shape:i}))}function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Mn(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Nt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ae(e){return typeof e=="string"?e:e?.message}function jt(e){const t=[];for(const r of e??[]){const n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;const i=n.maximum??n.length??n.size;i>=0&&t.push([i,r])}return t}function Be(e,t,r){var n;for(let i=t;i<e.length;i++)(n=e[i]).schema??(n.schema=r)}function ee(e,t,r){var n;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:ae(e.inst?._zod.def?.error?.(e))??ae(o?.(e))??ae(t?.error?.(e))??ae(r.customError?.(e))??ae(r.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}var Dn=/[\uD800-\uDBFF]/;function Je(e){const t=e.length;if(!Dn.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Ve(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function xn(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Ln(e,t){for(const r in t){const n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Fn(e,r,n.value)}}function W(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Mt(e,t,r){return W(e,t,r,!1)}function Dt(e,t){for(const r in e){const n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return W(this,r,n(this))},set(i){W(this,r,i)}})}return t}function Fn(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:W(this,t,r.bind(this))},set(n){W(this,t,n)}})}function Un(e,t){const r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ke,B=!1,Wn={configurable:!0,get(){B=!0}};function y(e,t,r){const n=Object.getPrototypeOf(e._zod);if(t in n&&Ke!==e._zod){Ke=void 0;return}Ke=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Wn);const i=B;B=!1;try{const o=r(this);return B?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),B=B||i,o}catch(o){throw delete this[t],B=B||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Bn(e,t,r,n){const i=Un(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,o),o.value=r(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:o})}})}var Jn="~constantCatch";function Vn(e){const t=()=>e;return t[Jn]=!0,t}var xt,Ge={value:void 0,enumerable:!1},Lt="captureStackTrace"in Error?Error:null;function Kn(e){const t=Lt;if(t){const r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Lt=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function l(e,t,r,n){const i={};function o(h){this.def=h,this.constr=d,this.traits=new Set}o.prototype=i;const s=r,a=s&&new WeakSet;function c(h,p){if(h._zod){if(h._zod.traits.has(e))return}else{Ge.value=new o(p);try{Object.defineProperty(h,"_zod",Ge)}finally{Ge.value=void 0}}if(h._zod.traits.add(e),t(h,p),a){const v=Object.getPrototypeOf(h),b=h._zod.constr.prototype;let _=v;for(;_&&_!==b;)_=Object.getPrototypeOf(_);const D=_??v;a.has(D)||(a.add(D),Ln(D,s))}const m=d.prototype;for(const v in m)Object.prototype.hasOwnProperty.call(m,v)&&(v in h||(h[v]=m[v].bind(h)))}const u=n?.Parent??Object;class f extends u{}Object.defineProperty(f,"name",{value:e});function d(h){const p=n?.Parent?Kn(f):this;c(p,h);const m=p._zod.deferred;if(m){for(const b of m)b();p._zod.deferred=void 0}const v=globalThis.__zod_globalConfig?.postProcessor;return v&&v(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:h=>n?.Parent&&h instanceof n.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Y=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ft=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(xt=globalThis).__zod_globalConfig??(xt.__zod_globalConfig={});var j=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(j,e),j}function Gn(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Fe,2)),e.message}function Hn(e){this._zod.message=e}var qn={get:Gn,set:Hn,enumerable:!0,configurable:!0},He={value:void 0,enumerable:!1},Ut=new WeakSet([Object.prototype,Error.prototype]),Wt=(e,t)=>{e.name="$ZodError",He.value=t,Object.defineProperty(e,"issues",He),He.value=void 0,Object.defineProperty(e,"message",qn);const r=Object.getPrototypeOf(e);Ut.has(r)||(Ut.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){const n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Yn=l("$ZodError",Wt),Ou=l("$ZodError",Wt,void 0,{Parent:Error});function Xn(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Qn(e,t=r=>r.message){const r={},n=[];for(const i of e.issues)i.path.length>0?Xn(r,i.path[0],()=>[]).push(t(i)):n.push(t(i));return{formErrors:n,fieldErrors:r}}function ei(e,t=r=>r.message){const r={_errors:[]},n=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;for(;u<a.length;){const f=a[u],d=u===a.length-1;if(f==="_errors"){d&&c._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(c,f)||Object.defineProperty(c,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=c[f];d&&h._errors.push(t(s)),c=h,u++}}}};return n(e),r}function Oe(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qe=e=>{const t=(r,n,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Y;if(a.issues.length){const c=new(o?.Err??e)(a.issues.map(u=>ee(u,s,J())));throw At(c,o?.callee??t),c}return a.value};return t},Ye=e=>{const t=async(r,n,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(o?.Err??e)(a.issues.map(u=>ee(u,s,J())));throw At(c,o?.callee??t),c}return a.value};return t},Xe=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Y;return o.issues.length?Bt(e,o.issues,i):{success:!0,data:o.value}};function Bt(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(i=>ee(i,r,J()))),t=void 0,r=void 0),n},set error(i){n=i,t=void 0,r=void 0}}}var Qe=e=>async(t,r,n)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?Bt(e,o.issues,i):{success:!0,data:o.value}},ti=Symbol.for("zod.compile.invalid"),ri=Symbol.for("zod.compile.fallback"),ni=((e,t,r)=>{const n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==ti)return!0;if(n.definite===!0&&r===void 0)return!1}return ii(e,t,r)});function ii(e,t,r){const n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(n[ri]=!0,o=i({value:t,issues:[]},n)):o=e._zod.run({value:t,issues:[]},n),o instanceof Promise)throw new Y;return o.issues.length===0}var oi=async(e,t,r)=>{const n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length===0},si=e=>{const t=qe(e),r=(n,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(n,i,a,Oe(r,s))};return r},ai=e=>{const t=qe(e),r=(n,i,o,s)=>t(n,i,o,Oe(r,s));return r},ci=e=>{const t=Ye(e),r=async(n,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(n,i,a,Oe(r,s))};return r},ui=e=>{const t=Ye(e),r=async(n,i,o,s)=>await t(n,i,o,Oe(r,s));return r},li=e=>(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return Xe(e)(t,r,i)},fi=e=>(t,r,n)=>Xe(e)(t,r,n),di=e=>async(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return Qe(e)(t,r,i)},hi=e=>async(t,r,n)=>Qe(e)(t,r,n),pi=/^[cC][0-9a-z]{6,}$/,mi=/^[0-9a-z]+$/,gi=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vi=/^[0-9a-vA-V]{20}$/,bi=/^[A-Za-z0-9]{27}$/,_i=/^[a-zA-Z0-9_-]{21}$/;function yi(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var wi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ki=/^([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})$/,Jt=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)$/,Oi=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zi="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Si(){return new RegExp(zi,"u")}var Ei=/^(?:(?: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])$/,$i=/^(([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}|:))$/,Ii=/^((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])$/,Ai=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ti=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pi=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Zi=/^https?$/,Ci=/^\+[1-9]\d{6,14}$/,Vt="(?:(?:\\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])))";function Ri(e){return new RegExp(`^${e}$`)}var Ni=Ri(Vt);function et(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ji(e){return new RegExp(`^${et(e)}$`)}function Mi(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${et({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${et({precision:e.precision})}`:r;return new RegExp(`^${Vt}T(?:${n})$`)}var Di=/^[\s\S]{0,}$/,xi=/^-?\d+(?:\.\d+)?$/,Li=/^(?:true|false)$/i,Fi=/^[^A-Z]*$/,Ui=/^[^a-z]*$/,P=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tt=e=>{const t=e.value;return!kn(t)&&t.length!==void 0},ze={number:"number",bigint:"bigint",object:"date"},Kt=l("$ZodCheckLessThan",(e,t)=>{P.init(e,t);const r=ze[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:ze[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gt=l("$ZodCheckGreaterThan",(e,t)=>{P.init(e,t);const r=ze[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:ze[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wi=l("$ZodCheckMultipleOf",(e,t)=>{P.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):On(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Bi=l("$ZodCheckNumberFormat",(e,t)=>{P.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Zt[t.format];e._zod.check=s=>{const a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckMaxLength",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length;if((typeof i=="string"&&o>t.maximum?Je(i):o)<=t.maximum)return;const s=Ve(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Vi=l("$ZodCheckMinLength",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?Je(i):o)>=t.minimum)return;const s=Ve(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ki=l("$ZodCheckLengthEquals",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?Je(i):o;if(s===t.length)return;const a=Ve(i),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Se=l("$ZodCheckStringFormat",(e,t)=>{var r,n;P.init(e,t),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Gi=l("$ZodCheckRegex",(e,t)=>{Se.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Fi),Se.init(e,t)}),qi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ui),Se.init(e,t)}),Yi=l("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const r=we(t.includes);t.pattern=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`: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})}}),Xi=l("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const r=new RegExp(`^${we(t.prefix)}.*`);t.pattern??(t.pattern=r),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})}}),Qi=l("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const r=new RegExp(`.*${we(t.suffix)}$`);t.pattern??(t.pattern=r),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})}}),eo=l("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),to=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
26
+ (function(I,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(I=typeof globalThis<"u"?globalThis:I||self,Q(I.GamaroWidget={}))})(this,function(I){Object.defineProperty(I,Symbol.toStringTag,{value:"Module"});var Q={instant:0,fast:150,base:250,slow:400,slower:600},K={standard:"cubic-bezier(0.4, 0, 0.2, 1)",enter:"cubic-bezier(0, 0, 0.2, 1)",exit:"cubic-bezier(0.4, 0, 1, 1)",emphasized:"cubic-bezier(0.2, 0, 0, 1)"},ge="[Gamaro]";function ve(e,...t){console.error(ge,e,...t)}function kt(e,...t){console.warn(ge,e,...t)}function be(e,...t){console.info(ge,e,...t)}function _e(e,...t){console.debug(ge,e,...t)}function mn(e){return e?_e:()=>{}}var gn="gamaro:",vn=["https://gamaro.io"];function Ot(e,t){return t.includes(e)}function zt(e){const t=e.data;return typeof t=="object"&&t!==null&&typeof t.type=="string"&&t.type.startsWith(gn)}function G(e,t,r){if(!e.contentWindow){kt("Cannot send command: iframe not ready");return}try{e.contentWindow.postMessage(t,r)}catch{kt("Failed to post message to iframe")}}function bn(e){const{allowedOrigins:t=vn,onMessage:r,debug:n,sourceWindow:i}=e,o=s=>{if(!(i&&s.source&&s.source!==i)){if(!Ot(s.origin,t)){n&&_e("Ignored message from untrusted origin:",s.origin);return}if(zt(s)){if(n)try{const a=JSON.parse(JSON.stringify(s.data));_e("Received message:",a)}catch{_e("Received message:",s.data?.type??"[Unserializable]")}r(s.data,s.origin)}}};return window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}}function _n(e){return btoa(JSON.stringify(e))}function Le(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function St(e,t="|"){return e.map(r=>Pt(r)).join(t)}function Fe(e,t){return typeof t=="bigint"?t.toString():t}var yn=class{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Ue(e){return new yn(e)}function wn(e){return e==null}function We(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function kn(e,t){const r=e/t,n=Math.round(r),i=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}function H(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function $t(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function L(e){return $t(e._zod.def)??e._zod.def.shape}function Et(e,t,r){Object.defineProperty(e,t,{get(){const n=r();return H(this,t,n),n},enumerable:!0,configurable:!0})}function It(e,t,r){t in e?H(e,t,r):e[t]=r}function q(e,t,r,n){const i=L(t);for(const o of r){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?Et(e,o,()=>{const a=t._zod.def.shape[o];return n?n(a,o):a}):It(e,o,n?n(s.value,o):s.value))}}function On(e,t){for(const r of Reflect.ownKeys(t)){const n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Et(e,r,()=>t[r]):It(e,r,n.value))}}function C(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function zn(e){return JSON.stringify(e)}function Sn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var At="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var $n=Ue(()=>{if(j.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function se(e){if(ye(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ye(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Tt(e){return se(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var En=new Set(["string","number","symbol"]);function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Pt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function In(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Zt={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]},An={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Tn(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return q(i,e,ke(e,t)),U(e,C(r,{shape:i,checks:[]}))}function ke(e,t){const r=L(e),n=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&n.push(i)}return n}function Pn(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(ke(e,t)),o={};return q(o,e,Reflect.ownKeys(L(e)).filter(s=>!i.has(s))),U(e,C(r,{shape:o,checks:[]}))}function Zn(e,t){if(!se(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=L(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return U(e,C(e._zod.def,{shape:Ct(e,t)}))}function Ct(e,t){const r={};return q(r,e,Reflect.ownKeys(L(e))),On(r,t),r}function Cn(e,t){if(!se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return U(e,C(e._zod.def,{shape:Ct(e,t)}))}function Rn(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r={};return q(r,e,Reflect.ownKeys(L(e))),q(r,t,Reflect.ownKeys(L(t))),U(e,C(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Rt(e,t,r,n="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);const o=r?new Set(ke(t,r)):void 0,s={};return q(s,t,Reflect.ownKeys(L(t)),e&&((a,c)=>o&&!o.has(c)?a:new e({type:"optional",innerType:a}))),U(t,C(t._zod.def,{shape:s,checks:[]}))}function Nn(e,t,r){const n=r?new Set(ke(t,r)):void 0,i={};return q(i,t,Reflect.ownKeys(L(t)),(o,s)=>n&&!n.has(s)?o:new e({type:"nonoptional",innerType:o})),U(t,C(t._zod.def,{shape:i}))}function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function jn(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Nt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ae(e){return typeof e=="string"?e:e?.message}function jt(e){const t=[];for(const r of e??[]){const n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;const i=n.maximum??n.length??n.size;i>=0&&t.push([i,r])}return t}function Be(e,t,r){var n;for(let i=t;i<e.length;i++)(n=e[i]).schema??(n.schema=r)}function ee(e,t,r){var n;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:ae(e.inst?._zod.def?.error?.(e))??ae(o?.(e))??ae(t?.error?.(e))??ae(r.customError?.(e))??ae(r.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}var Mn=/[\uD800-\uDBFF]/;function Je(e){const t=e.length;if(!Mn.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Ve(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Dn(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function xn(e,t){for(const r in t){const n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Ln(e,r,n.value)}}function W(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Mt(e,t,r){return W(e,t,r,!1)}function Dt(e,t){for(const r in e){const n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return W(this,r,n(this))},set(i){W(this,r,i)}})}return t}function Ln(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:W(this,t,r.bind(this))},set(n){W(this,t,n)}})}function Fn(e,t){const r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ke,B=!1,Un={configurable:!0,get(){B=!0}};function y(e,t,r){const n=Object.getPrototypeOf(e._zod);if(t in n&&Ke!==e._zod){Ke=void 0;return}Ke=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Un);const i=B;B=!1;try{const o=r(this);return B?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),B=B||i,o}catch(o){throw delete this[t],B=B||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Wn(e,t,r,n){const i=Fn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,o),o.value=r(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:o})}})}var Bn="~constantCatch";function Jn(e){const t=()=>e;return t[Bn]=!0,t}var xt,Ge={value:void 0,enumerable:!1},Lt="captureStackTrace"in Error?Error:null;function Vn(e){const t=Lt;if(t){const r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Lt=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function l(e,t,r,n){const i={};function o(h){this.def=h,this.constr=d,this.traits=new Set}o.prototype=i;const s=r,a=s&&new WeakSet;function c(h,p){if(h._zod){if(h._zod.traits.has(e))return}else{Ge.value=new o(p);try{Object.defineProperty(h,"_zod",Ge)}finally{Ge.value=void 0}}if(h._zod.traits.add(e),t(h,p),a){const v=Object.getPrototypeOf(h),b=h._zod.constr.prototype;let _=v;for(;_&&_!==b;)_=Object.getPrototypeOf(_);const D=_??v;a.has(D)||(a.add(D),xn(D,s))}const m=d.prototype;for(const v in m)Object.prototype.hasOwnProperty.call(m,v)&&(v in h||(h[v]=m[v].bind(h)))}const u=n?.Parent??Object;class f extends u{}Object.defineProperty(f,"name",{value:e});function d(h){const p=n?.Parent?Vn(f):this;c(p,h);const m=p._zod.deferred;if(m){for(const b of m)b();p._zod.deferred=void 0}const v=globalThis.__zod_globalConfig?.postProcessor;return v&&v(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:h=>n?.Parent&&h instanceof n.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Y=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ft=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(xt=globalThis).__zod_globalConfig??(xt.__zod_globalConfig={});var j=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(j,e),j}function Kn(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Fe,2)),e.message}function Gn(e){this._zod.message=e}var Hn={get:Kn,set:Gn,enumerable:!0,configurable:!0},He={value:void 0,enumerable:!1},Ut=new WeakSet([Object.prototype,Error.prototype]),qn=(e,t)=>{e.name="$ZodError",He.value=t,Object.defineProperty(e,"issues",He),He.value=void 0,Object.defineProperty(e,"message",Hn);const r=Object.getPrototypeOf(e);Ut.has(r)||(Ut.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){const n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Yn=l("$ZodError",qn);function Xn(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Qn(e,t=r=>r.message){const r={},n=[];for(const i of e.issues)i.path.length>0?Xn(r,i.path[0],()=>[]).push(t(i)):n.push(t(i));return{formErrors:n,fieldErrors:r}}function ei(e,t=r=>r.message){const r={_errors:[]},n=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;for(;u<a.length;){const f=a[u],d=u===a.length-1;if(f==="_errors"){d&&c._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(c,f)||Object.defineProperty(c,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=c[f];d&&h._errors.push(t(s)),c=h,u++}}}};return n(e),r}function Oe(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qe=e=>{const t=(r,n,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Y;if(a.issues.length){const c=new(o?.Err??e)(a.issues.map(u=>ee(u,s,J())));throw At(c,o?.callee??t),c}return a.value};return t},Ye=e=>{const t=async(r,n,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(o?.Err??e)(a.issues.map(u=>ee(u,s,J())));throw At(c,o?.callee??t),c}return a.value};return t},Xe=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Y;return o.issues.length?Wt(e,o.issues,i):{success:!0,data:o.value}};function Wt(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(i=>ee(i,r,J()))),t=void 0,r=void 0),n},set error(i){n=i,t=void 0,r=void 0}}}var Qe=e=>async(t,r,n)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?Wt(e,o.issues,i):{success:!0,data:o.value}},ti=Symbol.for("zod.compile.invalid"),ri=Symbol.for("zod.compile.fallback"),ni=((e,t,r)=>{const n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==ti)return!0;if(n.definite===!0&&r===void 0)return!1}return ii(e,t,r)});function ii(e,t,r){const n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(n[ri]=!0,o=i({value:t,issues:[]},n)):o=e._zod.run({value:t,issues:[]},n),o instanceof Promise)throw new Y;return o.issues.length===0}var oi=async(e,t,r)=>{const n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length===0},si=e=>{const t=qe(e),r=(n,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(n,i,a,Oe(r,s))};return r},ai=e=>{const t=qe(e),r=(n,i,o,s)=>t(n,i,o,Oe(r,s));return r},ci=e=>{const t=Ye(e),r=async(n,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(n,i,a,Oe(r,s))};return r},ui=e=>{const t=Ye(e),r=async(n,i,o,s)=>await t(n,i,o,Oe(r,s));return r},li=e=>(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return Xe(e)(t,r,i)},fi=e=>(t,r,n)=>Xe(e)(t,r,n),di=e=>async(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return Qe(e)(t,r,i)},hi=e=>async(t,r,n)=>Qe(e)(t,r,n),pi=/^[cC][0-9a-z]{6,}$/,mi=/^[0-9a-z]+$/,gi=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vi=/^[0-9a-vA-V]{20}$/,bi=/^[A-Za-z0-9]{27}$/,_i=/^[a-zA-Z0-9_-]{21}$/;function yi(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var wi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ki=/^([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})$/,Bt=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)$/,Oi=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zi="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Si(){return new RegExp(zi,"u")}var $i=/^(?:(?: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])$/,Ei=/^(([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}|:))$/,Ii=/^((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])$/,Ai=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ti=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pi=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Zi=/^https?$/,Ci=/^\+[1-9]\d{6,14}$/,Jt="(?:(?:\\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])))";function Ri(e){return new RegExp(`^${e}$`)}var Ni=Ri(Jt);function et(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ji(e){return new RegExp(`^${et(e)}$`)}function Mi(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${et({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${et({precision:e.precision})}`:r;return new RegExp(`^${Jt}T(?:${n})$`)}var Di=/^[\s\S]{0,}$/,xi=/^-?\d+(?:\.\d+)?$/,Li=/^(?:true|false)$/i,Fi=/^[^A-Z]*$/,Ui=/^[^a-z]*$/,P=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tt=e=>{const t=e.value;return!wn(t)&&t.length!==void 0},ze={number:"number",bigint:"bigint",object:"date"},Vt=l("$ZodCheckLessThan",(e,t)=>{P.init(e,t);const r=ze[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:ze[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Kt=l("$ZodCheckGreaterThan",(e,t)=>{P.init(e,t);const r=ze[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:ze[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wi=l("$ZodCheckMultipleOf",(e,t)=>{P.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):kn(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Bi=l("$ZodCheckNumberFormat",(e,t)=>{P.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Zt[t.format];e._zod.check=s=>{const a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckMaxLength",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length;if((typeof i=="string"&&o>t.maximum?Je(i):o)<=t.maximum)return;const s=Ve(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Vi=l("$ZodCheckMinLength",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?Je(i):o)>=t.minimum)return;const s=Ve(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ki=l("$ZodCheckLengthEquals",(e,t)=>{var r;P.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.check=n=>{const i=n.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?Je(i):o;if(s===t.length)return;const a=Ve(i),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Se=l("$ZodCheckStringFormat",(e,t)=>{var r,n;P.init(e,t),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Gi=l("$ZodCheckRegex",(e,t)=>{Se.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Fi),Se.init(e,t)}),qi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ui),Se.init(e,t)}),Yi=l("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const r=we(t.includes);t.pattern=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`: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})}}),Xi=l("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const r=new RegExp(`^${we(t.prefix)}.*`);t.pattern??(t.pattern=r),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})}}),Qi=l("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const r=new RegExp(`.*${we(t.suffix)}$`);t.pattern??(t.pattern=r),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})}}),eo=l("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),to=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
27
27
  `).filter(i=>i),r=Math.min(...t.map(i=>i.length-i.trimStart().length)),n=t.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of n)this.content.push(i)}compile(){const e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
28
28
  ${t.join(`
29
29
  `)}
30
- };`)(...Object.values(this.closed))}},ro={major:4,minor:6,patch:6},S=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ro;const n=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,c,u)=>{if(a.memo)return a;let f=F(a),d;for(const h of c){if(h._zod.def.when){if(Mn(a)||!h._zod.def.when(a))continue}else if(f)continue;const p=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new Y;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Be(a.issues,p,e),f||(f=F(a,p)))});else{if(a.issues.length===p)continue;Be(a.issues,p,e),f||(f=F(a,p))}}return d?d.then(()=>a):a},s=(a,c,u)=>{if(F(a))return a.aborted=!0,a;const f=o(c,i,u);if(f instanceof Promise){if(u.async===!1)throw new Y;return f.then(d=>e._zod.parse(d,u))}return e._zod.parse(f,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const f=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(d=>s(d,a,c)):s(f,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Y;return u.then(f=>o(f,i,c))}return o(u,i,c)}}},{get"~standard"(){return Mt(this,"~standard",qt(this))},set"~standard"(e){W(this,"~standard",e)}}),Ht=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ee(r,t,J()))}:{value:e.value};async function no(e,t){const r={async:!0};return Ht(await e._zod.run({value:t,issues:[]},r),r)}function qt(e){return{validate:t=>{const r={async:!1};try{const n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Ht(n,r)}catch{}return no(e,t)},vendor:"zod",version:1}}var rt=l("$ZodString",(e,t)=>{S.init(e,t),e._zod.pattern=t.pattern??Di,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),k=l("$ZodStringFormat",(e,t)=>{Se.init(e,t),rt.init(e,t)}),io=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ki),k.init(e,t)}),oo=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Jt(r))}else t.pattern??(t.pattern=Jt());k.init(e,t)}),so=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Oi),k.init(e,t)}),zu=1,Su=2;function Yt(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ao(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Yt(e)||2:co(e,t)}function co(e,t){if(!t.normalize&&t.protocol?.source===Zi.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<"u"){const r=URL;if(typeof r.parse=="function")return r.parse(e)??2}return new URL(e)}catch{return 2}}var uo=/[\t\n\r]/g;function Xt(e){return e.replace(uo,"")}function lo(e,t){return t.lastIndex=0,t.test(e.hostname)}function fo(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ho=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),i=ao(n,t);if(i===1){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(i===2){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(i===!0){r.value=Xt(n);return}t.hostname&&!lo(i,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!fo(i,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?i.href:Xt(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),po=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Si()),k.init(e,t)}),mo=l("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?_i:yi(t.length)),k.init(e,t)}),go=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pi),k.init(e,t)}),vo=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mi),k.init(e,t)}),bo=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gi),k.init(e,t)}),_o=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vi),k.init(e,t)}),yo=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bi),k.init(e,t)}),wo=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Mi(t)),k.init(e,t)}),ko=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ni),k.init(e,t)}),Oo=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ji(t)),k.init(e,t)}),zo=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wi),k.init(e,t)}),So=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ei),k.init(e,t)}),Eo=/^[0-9a-fA-F:.]+$/;function Qt(e){return Eo.test(e)?Yt(`http://[${e}]`):!1}var $o=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$i),k.init(e,t),e._zod.check=r=>{Qt(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),Io=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ii),k.init(e,t)});function Ao(e){const t=e.split("/");if(t.length!==2)return!1;const[r,n]=t;if(!n)return!1;const i=Number(n);return`${i}`!==n||i<0||i>128?!1:Qt(r)}var To=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ai),k.init(e,t),e._zod.check=r=>{Ao(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function er(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var tr=/^[0-9a-zA-Z+/]*={0,2}$/,Po=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tr),k.init(e,t),e._zod.check=r=>{er(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),nt=/^[A-Za-z0-9_-]*$/;function Zo(e){if(!nt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return er(t.padEnd(Math.ceil(t.length/4)*4,"="))}var Co=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nt),k.init(e,t),e._zod.check=r=>{Zo(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Ro=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ci),k.init(e,t)});function No(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var jo=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=r=>{No(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),rr=l("$ZodNumber",(e,t)=>{S.init(e,t),e._zod.pattern=xi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Mo=l("$ZodNumberFormat",(e,t)=>{Bi.init(e,t),rr.init(e,t)}),Do=l("$ZodBoolean",(e,t)=>{S.init(e,t),e._zod.pattern=Li,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),xo=l("$ZodUnknown",(e,t)=>{S.init(e,t),e._zod.parse=r=>r}),Lo=l("$ZodNever",(e,t)=>{S.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Fo(e,t){const r=jt(e._zod.def.checks);if(!r.length)return;const n=Math.min(...r.map(o=>o[0])),i=e._zod.parse;e._zod.parse=(o,s)=>{const a=t(o.value);if(a>n&&!s?.skipChecks&&s?.direction!=="backward"){for(const[c,u]of jt(e._zod.def.checks))if(a>c&&u._zod.def.when(o)){const f=o.issues.length;return u._zod.check(o),o.issues[f].continue=!1,Be(o.issues,f,e),o}}return i(o,s)}}var Uo=e=>Array.isArray(e)?e.length:-1;function nr(e,t,r){e.issues.length&&t.issues.push(...Nt(r,e.issues)),t.value[r]=e.value}var Wo=l("$ZodArray",(e,t)=>{S.init(e,t);const r=j.memoizer;r?.attach(e),e._zod.parse=(n,i)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=r?r.alloc(e,n,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let c=0;c<o.length;c++){const u=o[c],f=t.element._zod.run({value:u,issues:[]},i);if(f instanceof Promise)s.push(f.then(d=>nr(d,n,c)));else if(nr(f,n,c),a&&f.issues.length!==0&&F(f))break}return s.length?Promise.all(s).then(()=>n):n},Fo(e,Uo)});function Ee(e,t,r,n,i,o){const s=r in n,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...Nt(r,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Bo=[];function ir(e){const t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Bo,i=n.length?[...t,...n]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=An(e.shape);return{...e,allKeys:i,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function or(e,t,r,n,i,o,s){const a=[],c=i.keySet,u=i.catchall._zod,f=u.def.type,d=u.optin,h=u.optout;let p=0;for(const m in t){if(s&&r.issues.length!==p){if(F(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){f==="never"&&a.push(m);continue}if(f==="never"){a.push(m);continue}const v=u.run({value:t[m],issues:[]},n);v instanceof Promise?e.push(v.then(b=>Ee(b,r,m,t,d,h))):Ee(v,r,m,t,d,h)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Jo=l("$ZodObject",(e,t)=>{S.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){const u=()=>{const f={...n};return Object.defineProperty(t,"shape",{value:f}),u.raw=f,f};u.raw=n,Object.defineProperty(t,"shape",{get:u})}const i=Ue(()=>ir(t));y(e,"propValues",u=>{const f=u.def.shape,d={};for(const h in f){const p=f[h]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,h)||H(d,h,new Set);for(const m of p.values)d[h].add(m);p.optin!==void 0&&d[h].add(void 0)}}return d});const o=ye,s=t.catchall;let a;const c=j.memoizer;c?.attach(e),e._zod.parse=(u,f)=>{a??(a=i.value);const d=u.value;if(!o(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},f):{};const h=[],p=a.shape,m=f?.abortEarly;let v=u.issues.length;for(const b of a.allKeys){if(m&&u.issues.length!==v){if(F(u,v))break;v=u.issues.length}if(b==="__proto__")continue;const _=p[b],D=_._zod.optin,pe=_._zod.optout,me=_._zod.run({value:d[b],issues:[]},f);me instanceof Promise?h.push(me.then($=>Ee($,u,b,d,D,pe))):Ee(me,u,b,d,D,pe)}return s?or(h,d,u,f,i.value,e,m===!0):h.length?Promise.all(h).then(()=>u):u}}),Vo=l("$ZodObjectJIT",(e,t)=>{Jo.init(e,t);const r=e._zod.parse,n=Ue(()=>ir(t)),i=j.memoizer,o=p=>{const m=n.value,v=m.symbolKeys,b=new to(["payload","ctx"],{shape:p,inst:e,memo:i,syms:v}),_=$=>`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`,D=($,w)=>`
31
- let ${$}_ab = false;
32
- for (let i = 0; i < ${$}.issues.length; i++) {
33
- const iss = ${$}.issues[i];
30
+ };`)(...Object.values(this.closed))}},ro={major:4,minor:6,patch:6},S=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ro;const n=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,c,u)=>{if(a.memo)return a;let f=F(a),d;for(const h of c){if(h._zod.def.when){if(jn(a)||!h._zod.def.when(a))continue}else if(f)continue;const p=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new Y;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Be(a.issues,p,e),f||(f=F(a,p)))});else{if(a.issues.length===p)continue;Be(a.issues,p,e),f||(f=F(a,p))}}return d?d.then(()=>a):a},s=(a,c,u)=>{if(F(a))return a.aborted=!0,a;const f=o(c,i,u);if(f instanceof Promise){if(u.async===!1)throw new Y;return f.then(d=>e._zod.parse(d,u))}return e._zod.parse(f,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const f=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(d=>s(d,a,c)):s(f,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Y;return u.then(f=>o(f,i,c))}return o(u,i,c)}}},{get"~standard"(){return Mt(this,"~standard",Ht(this))},set"~standard"(e){W(this,"~standard",e)}}),Gt=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ee(r,t,J()))}:{value:e.value};async function no(e,t){const r={async:!0};return Gt(await e._zod.run({value:t,issues:[]},r),r)}function Ht(e){return{validate:t=>{const r={async:!1};try{const n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Gt(n,r)}catch{}return no(e,t)},vendor:"zod",version:1}}var rt=l("$ZodString",(e,t)=>{S.init(e,t),e._zod.pattern=t.pattern??Di,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),k=l("$ZodStringFormat",(e,t)=>{Se.init(e,t),rt.init(e,t)}),io=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ki),k.init(e,t)}),oo=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Bt(r))}else t.pattern??(t.pattern=Bt());k.init(e,t)}),so=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Oi),k.init(e,t)}),Ou=1,zu=2;function qt(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ao(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?qt(e)||2:co(e,t)}function co(e,t){if(!t.normalize&&t.protocol?.source===Zi.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<"u"){const r=URL;if(typeof r.parse=="function")return r.parse(e)??2}return new URL(e)}catch{return 2}}var uo=/[\t\n\r]/g;function Yt(e){return e.replace(uo,"")}function lo(e,t){return t.lastIndex=0,t.test(e.hostname)}function fo(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ho=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),i=ao(n,t);if(i===1){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(i===2){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(i===!0){r.value=Yt(n);return}t.hostname&&!lo(i,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!fo(i,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?i.href:Yt(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),po=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Si()),k.init(e,t)}),mo=l("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?_i:yi(t.length)),k.init(e,t)}),go=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pi),k.init(e,t)}),vo=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mi),k.init(e,t)}),bo=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gi),k.init(e,t)}),_o=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vi),k.init(e,t)}),yo=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bi),k.init(e,t)}),wo=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Mi(t)),k.init(e,t)}),ko=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ni),k.init(e,t)}),Oo=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ji(t)),k.init(e,t)}),zo=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wi),k.init(e,t)}),So=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$i),k.init(e,t)}),$o=/^[0-9a-fA-F:.]+$/;function Xt(e){return $o.test(e)?qt(`http://[${e}]`):!1}var Eo=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ei),k.init(e,t),e._zod.check=r=>{Xt(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),Io=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ii),k.init(e,t)});function Ao(e){const t=e.split("/");if(t.length!==2)return!1;const[r,n]=t;if(!n)return!1;const i=Number(n);return`${i}`!==n||i<0||i>128?!1:Xt(r)}var To=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ai),k.init(e,t),e._zod.check=r=>{Ao(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Qt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var er=/^[0-9a-zA-Z+/]*={0,2}$/,Po=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=er),k.init(e,t),e._zod.check=r=>{Qt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),nt=/^[A-Za-z0-9_-]*$/;function Zo(e){if(!nt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return Qt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var Co=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nt),k.init(e,t),e._zod.check=r=>{Zo(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Ro=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ci),k.init(e,t)});function No(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var jo=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=r=>{No(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),tr=l("$ZodNumber",(e,t)=>{S.init(e,t),e._zod.pattern=xi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Mo=l("$ZodNumberFormat",(e,t)=>{Bi.init(e,t),tr.init(e,t)}),Do=l("$ZodBoolean",(e,t)=>{S.init(e,t),e._zod.pattern=Li,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),xo=l("$ZodUnknown",(e,t)=>{S.init(e,t),e._zod.parse=r=>r}),Lo=l("$ZodNever",(e,t)=>{S.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Fo(e,t){const r=jt(e._zod.def.checks);if(!r.length)return;const n=Math.min(...r.map(o=>o[0])),i=e._zod.parse;e._zod.parse=(o,s)=>{const a=t(o.value);if(a>n&&!s?.skipChecks&&s?.direction!=="backward"){for(const[c,u]of jt(e._zod.def.checks))if(a>c&&u._zod.def.when(o)){const f=o.issues.length;return u._zod.check(o),o.issues[f].continue=!1,Be(o.issues,f,e),o}}return i(o,s)}}var Uo=e=>Array.isArray(e)?e.length:-1;function rr(e,t,r){e.issues.length&&t.issues.push(...Nt(r,e.issues)),t.value[r]=e.value}var Wo=l("$ZodArray",(e,t)=>{S.init(e,t);const r=j.memoizer;r?.attach(e),e._zod.parse=(n,i)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=r?r.alloc(e,n,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let c=0;c<o.length;c++){const u=o[c],f=t.element._zod.run({value:u,issues:[]},i);if(f instanceof Promise)s.push(f.then(d=>rr(d,n,c)));else if(rr(f,n,c),a&&f.issues.length!==0&&F(f))break}return s.length?Promise.all(s).then(()=>n):n},Fo(e,Uo)});function $e(e,t,r,n,i,o){const s=r in n,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...Nt(r,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Bo=[];function nr(e){const t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Bo,i=n.length?[...t,...n]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=In(e.shape);return{...e,allKeys:i,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function ir(e,t,r,n,i,o,s){const a=[],c=i.keySet,u=i.catchall._zod,f=u.def.type,d=u.optin,h=u.optout;let p=0;for(const m in t){if(s&&r.issues.length!==p){if(F(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){f==="never"&&a.push(m);continue}if(f==="never"){a.push(m);continue}const v=u.run({value:t[m],issues:[]},n);v instanceof Promise?e.push(v.then(b=>$e(b,r,m,t,d,h))):$e(v,r,m,t,d,h)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Jo=l("$ZodObject",(e,t)=>{S.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){const u=()=>{const f={...n};return Object.defineProperty(t,"shape",{value:f}),u.raw=f,f};u.raw=n,Object.defineProperty(t,"shape",{get:u})}const i=Ue(()=>nr(t));y(e,"propValues",u=>{const f=u.def.shape,d={};for(const h in f){const p=f[h]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,h)||H(d,h,new Set);for(const m of p.values)d[h].add(m);p.optin!==void 0&&d[h].add(void 0)}}return d});const o=ye,s=t.catchall;let a;const c=j.memoizer;c?.attach(e),e._zod.parse=(u,f)=>{a??(a=i.value);const d=u.value;if(!o(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},f):{};const h=[],p=a.shape,m=f?.abortEarly;let v=u.issues.length;for(const b of a.allKeys){if(m&&u.issues.length!==v){if(F(u,v))break;v=u.issues.length}if(b==="__proto__")continue;const _=p[b],D=_._zod.optin,pe=_._zod.optout,me=_._zod.run({value:d[b],issues:[]},f);me instanceof Promise?h.push(me.then(E=>$e(E,u,b,d,D,pe))):$e(me,u,b,d,D,pe)}return s?ir(h,d,u,f,i.value,e,m===!0):h.length?Promise.all(h).then(()=>u):u}}),Vo=l("$ZodObjectJIT",(e,t)=>{Jo.init(e,t);const r=e._zod.parse,n=Ue(()=>nr(t)),i=j.memoizer,o=p=>{const m=n.value,v=m.symbolKeys,b=new to(["payload","ctx"],{shape:p,inst:e,memo:i,syms:v}),_=E=>`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`,D=(E,w)=>`
31
+ let ${E}_ab = false;
32
+ for (let i = 0; i < ${E}.issues.length; i++) {
33
+ const iss = ${E}.issues[i];
34
34
  iss.path = iss.path ? [${w}, ...iss.path] : [${w}];
35
35
  payload.issues.push(iss);
36
- if (iss.continue !== true) ${$}_ab = true;
36
+ if (iss.continue !== true) ${E}_ab = true;
37
37
  }
38
- if (${$}_ab && ctx && ctx.abortEarly) {
38
+ if (${E}_ab && ctx && ctx.abortEarly) {
39
39
  payload.value = newResult;
40
40
  return payload;
41
- }`;b.write("const input = payload.value;");const pe=Object.create(null);let me=0;for(const $ of m.allKeys)pe[$]=`key_${me++}`;b.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const $ of m.allKeys){if($==="__proto__")continue;const w=pe[$],x=typeof $=="symbol"?`syms[${v.indexOf($)}]`:Sn($),yt=`${x} in input`,pn=p[$],wt=pn?._zod?.optin,mn=wt!==void 0,wu=pn?._zod?.optout==="optional";if(b.write(`const ${w} = ${_(x)};`),mn&&wu){const ku=wt==="optional"?`${w}_present`:`${w}.value !== undefined || ${w}_present`;b.write(`
41
+ }`;b.write("const input = payload.value;");const pe=Object.create(null);let me=0;for(const E of m.allKeys)pe[E]=`key_${me++}`;b.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const E of m.allKeys){if(E==="__proto__")continue;const w=pe[E],x=typeof E=="symbol"?`syms[${v.indexOf(E)}]`:zn(E),yt=`${x} in input`,hn=p[E],wt=hn?._zod?.optin,pn=wt!==void 0,wu=hn?._zod?.optout==="optional";if(b.write(`const ${w} = ${_(x)};`),pn&&wu){const ku=wt==="optional"?`${w}_present`:`${w}.value !== undefined || ${w}_present`;b.write(`
42
42
  const ${w}_present = ${yt};
43
43
  if (!${w}.issues.length || ${w}_present) {
44
44
  if (${w}.issues.length) {${D(w,x)}
@@ -49,7 +49,7 @@ ${t.join(`
49
49
  }
50
50
  }
51
51
 
52
- `)}else mn?(b.write(`
52
+ `)}else pn?(b.write(`
53
53
  if (${w}.issues.length) {${D(w,x)}
54
54
  }
55
55
  `),wt==="defaulted"?b.write(`newResult[${x}] = ${w}.value;`):b.write(`
@@ -77,6 +77,6 @@ ${t.join(`
77
77
  newResult[${x}] = ${w}.value;
78
78
  }
79
79
 
80
- `)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let s;const a=ye,c=!j.jitless,f=c&&$n.value,d=t.catchall;let h;e._zod.parse=(p,m)=>{h??(h=n.value);const v=p.value;return a(v)?c&&f&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),p=s(p,m),d?or([],v,p,m,h,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),p)}});function sr(e,t,r,n){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!F(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>ee(s,n,J())))}),t)}var Ko=l("$ZodUnion",(e,t)=>{S.init(e,t),y(e,"optin",n=>n.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":n.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),y(e,"optout",n=>n.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),y(e,"values",n=>{if(n.def.options.every(i=>i._zod.values))return new Set(n.def.options.flatMap(i=>Array.from(i._zod.values)))}),y(e,"pattern",n=>{if(n.def.options.every(i=>i._zod.pattern)){const i=n.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>We(o.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>sr(a,n,e,i)):sr(s,n,e,i)}}),Go=l("$ZodIntersection",(e,t)=>{S.init(e,t),e._zod.parse=(r,n)=>{const i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([a,c])=>ar(r,a,c)):ar(r,o,s)}});function it(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(se(e)&&se(t)){const r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of n){if(o==="__proto__")continue;const s=it(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const i=e[n],o=t[n],s=it(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ar(e,t,r){const n=new Map;let i;const o=new Map,s=(u,f)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)i??(i=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const h=String(u.path[0]);o.has(h)||o.set(h,u),d=[h]}else return!1;for(const h of d)n.has(h)||n.set(h,{}),n.get(h)[f]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of r.issues)s(u,"r")||e.issues.push(u);const a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){const u=i?a.filter(f=>i.keys.includes(f)):[];u.length&&e.issues.push({...i,keys:u});for(const f of a)!u.includes(f)&&o.has(f)&&e.issues.push(o.get(f))}const c=it(t.value,r.value);if(!c.valid){if(F(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ho=l("$ZodEnum",(e,t)=>{S.init(e,t);const r=Le(t.entries),n=new Set(r);e._zod.values=n,y(e,"pattern",i=>{const o=Le(i.def.entries).filter(s=>In.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>we(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:e}),i}}),qo=l("$ZodTransform",(e,t)=>{S.init(e,t),e._zod.optin="optional",j.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ft(e.constructor.name);const i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(r.value=o,r));if(i instanceof Promise)throw new Y;return r.value=i,r}});function cr(e,t){return e.value=t.issues.length?void 0:t.value,e}var ur=l("$ZodOptional",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",y(e,"values",r=>{const n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),y(e,"pattern",r=>{const n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;const i=t.innerType._zod.run({value:r.value,issues:[]},n);return i instanceof Promise?i.then(o=>cr(r,o)):cr(r,i)}return t.innerType._zod.run(r,n)}}),Yo=l("$ZodExactOptional",(e,t)=>{ur.init(e,t),y(e,"values",r=>r.def.innerType._zod.values),y(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Xo=l("$ZodNullable",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin),y(e,"optout",r=>r.def.innerType._zod.optout),y(e,"pattern",r=>{const n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)}|null)$`):void 0}),y(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Qo=l("$ZodDefault",(e,t)=>{S.init(e,t),e._zod.optin="defaulted",y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>lr(o,t)):lr(i,t)}});function lr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var es=l("$ZodPrefault",(e,t)=>{S.init(e,t),e._zod.optin="defaulted",y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),ts=l("$ZodNonOptional",(e,t)=>{S.init(e,t),y(e,"values",r=>{const n=r.def.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(r,n)=>{const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>fr(o,e)):fr(i,e)}});function fr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function dr(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>ee(i,n,J()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var rs=l("$ZodCatch",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),y(e,"optout",r=>r.def.innerType._zod.optout),y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const i=t.innerType._zod.run({value:r.value,issues:[]},n);return i instanceof Promise?i.then(o=>dr(r,o,t,n)):dr(r,i,t,n)}}),ns=l("$ZodPipe",(e,t)=>{S.init(e,t),y(e,"values",r=>r.def.in._zod.values),y(e,"optin",r=>r.def.in._zod.optin),y(e,"optout",r=>r.def.out._zod.optout),y(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const o=t.out._zod.run(r,n);return o instanceof Promise?o.then(s=>$e(s,t.in,n)):$e(o,t.in,n)}const i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>$e(o,t.out,n)):$e(i,t.out,n)}});function $e(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var is=l("$ZodReadonly",(e,t)=>{S.init(e,t),y(e,"propValues",r=>r.def.innerType._zod.propValues),y(e,"values",r=>r.def.innerType._zod.values),y(e,"optin",r=>r.def.innerType?._zod?.optin),y(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(hr):hr(i)}});function hr(e){return e.memo||(e.value=Object.freeze(e.value)),e}var os=l("$ZodCustom",(e,t)=>{P.init(e,t),S.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>pr(o,r,n,e));pr(i,r,n,e)}});function pr(e,t,r,n){if(!e){const i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ce(i))}}var ss=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ot="~memo",mr=[];function gr(e){return e!==null&&typeof e=="object"}function st(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var vr=new WeakMap,ue=0,Ie=1,le=2;function Ae(e,t,r){const n=vr.get(e);if(n!==void 0)return n?le:ue;if(t.has(e))return le;t.add(e);let i=ue;const o=u=>{if(i!==le&&u?._zod){const f=Ae(u,t,r);f>i&&(i=f)}},s=(u,f)=>{let d=ue;for(const h of Reflect.ownKeys(u)){const p=Object.getOwnPropertyDescriptor(u,h);if(f&&!p.enumerable)continue;const m=p.get?Ie:p.value?._zod?Ae(p.value,t,r):ue;m>d&&(d=m)}return d},a=u=>{u>i&&(i=u)},c=e._zod.def;switch(c.type){case"object":{const u=Et(c);a(u?s(u,!0):Ie),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const u=c._cachedInner??(r?e._zod.innerType:void 0);a(u?Ae(u,t,!1):Ie);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const u in c){const f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;const d=f.value;if(!(!d||typeof d!="object")){if(d._zod)o(d);else if(Array.isArray(d))for(const h of d)o(h)}}}return t.delete(e),as(e,i)}function as(e,t){return t!==Ie&&vr.set(e,t===le),t}function cs(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Te,Pe=[],us={alloc(e,t,r){const n=Te;if(!n)return r;Te=void 0;const i={value:r,issues:null};return n.set(t.value,i),Pe.push(i),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const r=e._zod.parse,n=(i,o)=>{if(o.direction!=="backward"&&fs(o,i.value))throw new ss;return r(i,o)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,u)=>{if(r===void 0){const _=Ae(e,new Set,!1);if(_===ue)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);_===le||n?r=!0:n=!0}const f=c.value;if(!gr(f))return s(c,u);let d=u[ot];d||(d={buckets:new WeakMap,backEdges:void 0},u[ot]=d);let h;i===u?h=o:(h=cs(d,e),i=u,o=h);const p=h.get(f);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...st(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;Te=h;const m=Pe.length,v=s(c,u);Te=void 0;const b=Pe.length>m?Pe.pop():void 0;return v instanceof Promise?v.then(_=>(b&&(b.issues=_.issues.length?st(_.issues):mr),_)):(b&&(b.issues=v.issues.length?st(v.issues):mr),v)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function ls(){return us}function fs(e,t){const r=e[ot]?.backEdges;return r!==void 0&&gr(t)&&r.has(t)}var ds=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):n[o]??o}return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${i(o.expected)}, received ${i(xn(o.input),o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${Pt(o.values[0])}`:`Invalid option: expected one of ${St(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${St(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(s=>`'${s}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function hs(){return{localeError:ds()}}var br,ps=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ms(){return new ps}(br=globalThis).__zod_globalRegistry??(br.__zod_globalRegistry=ms());var fe=globalThis.__zod_globalRegistry;function _r(e){return e.checks&&(e.checks=[...e.checks]),e}function gs(e,t){return new e(_r({type:"string",...g(t)}))}function vs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function bs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function ys(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function ws(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function ks(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Os(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function zs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Ss(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Es(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function $s(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Is(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function As(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Ts(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Ps(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Zs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Cs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Rs(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Ns(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function js(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Ms(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ds(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function xs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Ls(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Fs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Us(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ws(e,t){return new e(_r({type:"number",checks:[],...g(t)}))}function Bs(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Js(e,t){return new e({type:"boolean",...g(t)})}function Vs(e){return new e({type:"unknown"})}function Ks(e,t){return new e({type:"never",...g(t)})}function yr(e,t){return new Kt({check:"less_than",...g(t),value:e,inclusive:!1})}function at(e,t){return new Kt({check:"less_than",...g(t),value:e,inclusive:!0})}function wr(e,t){return new Gt({check:"greater_than",...g(t),value:e,inclusive:!1})}function ct(e,t){return new Gt({check:"greater_than",...g(t),value:e,inclusive:!0})}function kr(e,t){return new Wi({check:"multiple_of",...g(t),value:e})}function Or(e,t){return new Ji({check:"max_length",...g(t),maximum:e})}function Ze(e,t){return new Vi({check:"min_length",...g(t),minimum:e})}function zr(e,t){return new Ki({check:"length_equals",...g(t),length:e})}function Gs(e,t){return new Gi({check:"string_format",format:"regex",...g(t),pattern:e})}function Hs(e){return new Hi({check:"string_format",format:"lowercase",...g(e)})}function qs(e){return new qi({check:"string_format",format:"uppercase",...g(e)})}function Ys(e,t){return new Yi({check:"string_format",format:"includes",...g(t),includes:e})}function Xs(e,t){return new Xi({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Qs(e,t){return new Qi({check:"string_format",format:"ends_with",...g(t),suffix:e})}function te(e){return new eo({check:"overwrite",tx:e})}function ea(e){return te(t=>t.normalize(e))}function ta(){return te(e=>e.trim())}function ra(){return te(e=>e.toLowerCase())}function na(){return te(e=>e.toUpperCase())}function ia(){return te(e=>En(e))}function oa(e,t,r){return new e({type:"array",element:t,...g(r)})}function sa(e,t,r){const n=g(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function aa(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function ca(e,t){const r=ua(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(ce(i,n.value,r._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(ce(o))}},e(n.value,n)),t);return r}function ua(e,t){const r=new P({check:"custom",...g(t)});return r._zod.check=e,r}function de(e,...t){for(const r of t)for(const n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&H(e,n,r[n]);return e}function Sr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??fe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function re(e,t,r,n,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(r,o),!0}function A(e,t,r={path:[],schemaPath:[]}){var n;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const d=s.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,u)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),A(f,t,u),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&de(s.schema,c),t.io==="input"&&T(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Er(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $r(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const n=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}const i=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,h=e.external.uri??(m=>m);if(d)return{ref:h(d)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${h("__shared")}#/${a}/${Er(p)}`}}const c="#",u=`${c}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:c};const f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+Er(f)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=i(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const d in f)delete f[d];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
80
+ `)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let s;const a=ye,c=!j.jitless,f=c&&$n.value,d=t.catchall;let h;e._zod.parse=(p,m)=>{h??(h=n.value);const v=p.value;return a(v)?c&&f&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),p=s(p,m),d?ir([],v,p,m,h,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),p)}});function or(e,t,r,n){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!F(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>ee(s,n,J())))}),t)}var Ko=l("$ZodUnion",(e,t)=>{S.init(e,t),y(e,"optin",n=>n.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":n.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),y(e,"optout",n=>n.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),y(e,"values",n=>{if(n.def.options.every(i=>i._zod.values))return new Set(n.def.options.flatMap(i=>Array.from(i._zod.values)))}),y(e,"pattern",n=>{if(n.def.options.every(i=>i._zod.pattern)){const i=n.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>We(o.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>or(a,n,e,i)):or(s,n,e,i)}}),Go=l("$ZodIntersection",(e,t)=>{S.init(e,t),e._zod.parse=(r,n)=>{const i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([a,c])=>sr(r,a,c)):sr(r,o,s)}});function it(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(se(e)&&se(t)){const r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of n){if(o==="__proto__")continue;const s=it(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const i=e[n],o=t[n],s=it(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function sr(e,t,r){const n=new Map;let i;const o=new Map,s=(u,f)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)i??(i=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const h=String(u.path[0]);o.has(h)||o.set(h,u),d=[h]}else return!1;for(const h of d)n.has(h)||n.set(h,{}),n.get(h)[f]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of r.issues)s(u,"r")||e.issues.push(u);const a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){const u=i?a.filter(f=>i.keys.includes(f)):[];u.length&&e.issues.push({...i,keys:u});for(const f of a)!u.includes(f)&&o.has(f)&&e.issues.push(o.get(f))}const c=it(t.value,r.value);if(!c.valid){if(F(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ho=l("$ZodEnum",(e,t)=>{S.init(e,t);const r=Le(t.entries),n=new Set(r);e._zod.values=n,y(e,"pattern",i=>{const o=Le(i.def.entries).filter(s=>En.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>we(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:e}),i}}),qo=l("$ZodTransform",(e,t)=>{S.init(e,t),e._zod.optin="optional",j.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ft(e.constructor.name);const i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(r.value=o,r));if(i instanceof Promise)throw new Y;return r.value=i,r}});function ar(e,t){return e.value=t.issues.length?void 0:t.value,e}var cr=l("$ZodOptional",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",y(e,"values",r=>{const n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),y(e,"pattern",r=>{const n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;const i=t.innerType._zod.run({value:r.value,issues:[]},n);return i instanceof Promise?i.then(o=>ar(r,o)):ar(r,i)}return t.innerType._zod.run(r,n)}}),Yo=l("$ZodExactOptional",(e,t)=>{cr.init(e,t),y(e,"values",r=>r.def.innerType._zod.values),y(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Xo=l("$ZodNullable",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin),y(e,"optout",r=>r.def.innerType._zod.optout),y(e,"pattern",r=>{const n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)}|null)$`):void 0}),y(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Qo=l("$ZodDefault",(e,t)=>{S.init(e,t),e._zod.optin="defaulted",y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>ur(o,t)):ur(i,t)}});function ur(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var es=l("$ZodPrefault",(e,t)=>{S.init(e,t),e._zod.optin="defaulted",y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),ts=l("$ZodNonOptional",(e,t)=>{S.init(e,t),y(e,"values",r=>{const n=r.def.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(r,n)=>{const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>lr(o,e)):lr(i,e)}});function lr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function fr(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>ee(i,n,J()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var rs=l("$ZodCatch",(e,t)=>{S.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),y(e,"optout",r=>r.def.innerType._zod.optout),y(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const i=t.innerType._zod.run({value:r.value,issues:[]},n);return i instanceof Promise?i.then(o=>fr(r,o,t,n)):fr(r,i,t,n)}}),ns=l("$ZodPipe",(e,t)=>{S.init(e,t),y(e,"values",r=>r.def.in._zod.values),y(e,"optin",r=>r.def.in._zod.optin),y(e,"optout",r=>r.def.out._zod.optout),y(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const o=t.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Ee(s,t.in,n)):Ee(o,t.in,n)}const i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Ee(o,t.out,n)):Ee(i,t.out,n)}});function Ee(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var is=l("$ZodReadonly",(e,t)=>{S.init(e,t),y(e,"propValues",r=>r.def.innerType._zod.propValues),y(e,"values",r=>r.def.innerType._zod.values),y(e,"optin",r=>r.def.innerType?._zod?.optin),y(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(dr):dr(i)}});function dr(e){return e.memo||(e.value=Object.freeze(e.value)),e}var os=l("$ZodCustom",(e,t)=>{P.init(e,t),S.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>hr(o,r,n,e));hr(i,r,n,e)}});function hr(e,t,r,n){if(!e){const i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ce(i))}}var ss=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ot="~memo",pr=[];function mr(e){return e!==null&&typeof e=="object"}function st(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var gr=new WeakMap,ue=0,Ie=1,le=2;function Ae(e,t,r){const n=gr.get(e);if(n!==void 0)return n?le:ue;if(t.has(e))return le;t.add(e);let i=ue;const o=u=>{if(i!==le&&u?._zod){const f=Ae(u,t,r);f>i&&(i=f)}},s=(u,f)=>{let d=ue;for(const h of Reflect.ownKeys(u)){const p=Object.getOwnPropertyDescriptor(u,h);if(f&&!p.enumerable)continue;const m=p.get?Ie:p.value?._zod?Ae(p.value,t,r):ue;m>d&&(d=m)}return d},a=u=>{u>i&&(i=u)},c=e._zod.def;switch(c.type){case"object":{const u=$t(c);a(u?s(u,!0):Ie),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const u=c._cachedInner??(r?e._zod.innerType:void 0);a(u?Ae(u,t,!1):Ie);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const u in c){const f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;const d=f.value;if(!(!d||typeof d!="object")){if(d._zod)o(d);else if(Array.isArray(d))for(const h of d)o(h)}}}return t.delete(e),as(e,i)}function as(e,t){return t!==Ie&&gr.set(e,t===le),t}function cs(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Te,Pe=[],us={alloc(e,t,r){const n=Te;if(!n)return r;Te=void 0;const i={value:r,issues:null};return n.set(t.value,i),Pe.push(i),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const r=e._zod.parse,n=(i,o)=>{if(o.direction!=="backward"&&fs(o,i.value))throw new ss;return r(i,o)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,u)=>{if(r===void 0){const _=Ae(e,new Set,!1);if(_===ue)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);_===le||n?r=!0:n=!0}const f=c.value;if(!mr(f))return s(c,u);let d=u[ot];d||(d={buckets:new WeakMap,backEdges:void 0},u[ot]=d);let h;i===u?h=o:(h=cs(d,e),i=u,o=h);const p=h.get(f);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...st(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;Te=h;const m=Pe.length,v=s(c,u);Te=void 0;const b=Pe.length>m?Pe.pop():void 0;return v instanceof Promise?v.then(_=>(b&&(b.issues=_.issues.length?st(_.issues):pr),_)):(b&&(b.issues=v.issues.length?st(v.issues):pr),v)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function ls(){return us}function fs(e,t){const r=e[ot]?.backEdges;return r!==void 0&&mr(t)&&r.has(t)}var ds=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):n[o]??o}return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${i(o.expected)}, received ${i(Dn(o.input),o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${Pt(o.values[0])}`:`Invalid option: expected one of ${St(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${St(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(s=>`'${s}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function hs(){return{localeError:ds()}}var vr,ps=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ms(){return new ps}(vr=globalThis).__zod_globalRegistry??(vr.__zod_globalRegistry=ms());var fe=globalThis.__zod_globalRegistry;function br(e){return e.checks&&(e.checks=[...e.checks]),e}function gs(e,t){return new e(br({type:"string",...g(t)}))}function vs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function bs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function ys(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function ws(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function ks(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Os(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function zs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Ss(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function $s(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Es(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Is(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function As(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Ts(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Ps(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Zs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Cs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Rs(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Ns(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function js(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Ms(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ds(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function xs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Ls(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Fs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Us(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ws(e,t){return new e(br({type:"number",checks:[],...g(t)}))}function Bs(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Js(e,t){return new e({type:"boolean",...g(t)})}function Vs(e){return new e({type:"unknown"})}function Ks(e,t){return new e({type:"never",...g(t)})}function _r(e,t){return new Vt({check:"less_than",...g(t),value:e,inclusive:!1})}function at(e,t){return new Vt({check:"less_than",...g(t),value:e,inclusive:!0})}function yr(e,t){return new Kt({check:"greater_than",...g(t),value:e,inclusive:!1})}function ct(e,t){return new Kt({check:"greater_than",...g(t),value:e,inclusive:!0})}function wr(e,t){return new Wi({check:"multiple_of",...g(t),value:e})}function kr(e,t){return new Ji({check:"max_length",...g(t),maximum:e})}function Ze(e,t){return new Vi({check:"min_length",...g(t),minimum:e})}function Or(e,t){return new Ki({check:"length_equals",...g(t),length:e})}function Gs(e,t){return new Gi({check:"string_format",format:"regex",...g(t),pattern:e})}function Hs(e){return new Hi({check:"string_format",format:"lowercase",...g(e)})}function qs(e){return new qi({check:"string_format",format:"uppercase",...g(e)})}function Ys(e,t){return new Yi({check:"string_format",format:"includes",...g(t),includes:e})}function Xs(e,t){return new Xi({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Qs(e,t){return new Qi({check:"string_format",format:"ends_with",...g(t),suffix:e})}function te(e){return new eo({check:"overwrite",tx:e})}function ea(e){return te(t=>t.normalize(e))}function ta(){return te(e=>e.trim())}function ra(){return te(e=>e.toLowerCase())}function na(){return te(e=>e.toUpperCase())}function ia(){return te(e=>Sn(e))}function oa(e,t,r){return new e({type:"array",element:t,...g(r)})}function sa(e,t,r){const n=g(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function aa(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function ca(e,t){const r=ua(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(ce(i,n.value,r._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(ce(o))}},e(n.value,n)),t);return r}function ua(e,t){const r=new P({check:"custom",...g(t)});return r._zod.check=e,r}function de(e,...t){for(const r of t)for(const n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&H(e,n,r[n]);return e}function zr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??fe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function re(e,t,r,n,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(r,o),!0}function A(e,t,r={path:[],schemaPath:[]}){var n;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const d=s.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,u)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),A(f,t,u),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&de(s.schema,c),t.io==="input"&&T(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Sr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $r(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const n=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}const i=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,h=e.external.uri??(m=>m);if(d)return{ref:h(d)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${h("__shared")}#/${a}/${Sr(p)}`}}const c="#",u=`${c}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:c};const f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+Sr(f)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=i(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const d in f)delete f[d];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
81
81
 
82
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ir(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const r=[];for(const n of t){if(!n||typeof n!="object")return;Ir(n);const i=Object.keys(n);if(i.length!==1||i[0]!=="type")return;const o=n.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;r.includes(s)||r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Ar=new Set(["type","properties","required","additionalProperties"]),Tr=["oneOf","anyOf"];function Pr(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ut(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Ar.has(s))return null;t.push(o)}const r={},n=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;const a=[];for(const u of t){const f=u.properties?.[s]??Pr(u);f!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(f))||a.push(f))}const c=a.length===1?a[0]:ut(a)??{allOf:a};H(r,s,c)}for(const s of o.required??[])n.add(s)}const i={type:"object",properties:r};if(n.size&&(i.required=[...n]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=Pr(s);a&&!o.some(c=>JSON.stringify(c)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function la(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Ar)if(i in e)return;const r=t.filter(i=>Tr.some(o=>Array.isArray(i[o])));let n=null;if(!r.length)n=ut(t);else{const i=r[0],o=Tr.find(c=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;const s=t.filter(c=>c!==i),a=i[o].map(c=>ut([...s,c]));if(a.some(c=>!c))return;n={[o]:a}}n&&(delete e.allOf,de(e,n))}function Zr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,f={...u},d=c.ref;if(c.ref=null,d){n(d);const p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):de(u,m),de(u,f),a._zod.parent===d)for(const v in u)v==="$ref"||v==="allOf"||v in f||delete u[v];if(m.$ref&&p.def)for(const v in u)v==="$ref"||v==="allOf"||v in p.def&&JSON.stringify(u[v])===JSON.stringify(p.def[v])&&delete u[v]}const h=a._zod.parent;if(h&&h!==d){n(h);const p=e.seen.get(h);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())Ir(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const f=u?.allOf;if(!Array.isArray(f))continue;const d=a.get(f);d?d.push(u):a.set(f,[u])}for(const c of e.intersections)for(const u of a.get(c)??[])la(u)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}de(i,r.defId?r.schema:r.def??r.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,H(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ce(t,"input",e.processors),output:Ce(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return T(n.element,r);if(n.type==="set")return T(n.valueType,r);if(n.type==="lazy")return T(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return T(n.innerType,r);if(n.type==="intersection")return T(n.left,r)||T(n.right,r);if(n.type==="record"||n.type==="map")return T(n.keyType,r)||T(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:T(n.in,r)||T(n.out,r);if(n.type==="object"){for(const i in n.shape)if(T(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(T(i,r))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(T(i,r))return!0;return!!(n.rest&&T(n.rest,r))}return!1}var fa=(e,t={})=>r=>{const n=Sr({...r,processors:t});return A(e,n),$r(n,e),Zr(n,e)},Ce=(e,t,r={})=>n=>{const{libraryOptions:i,target:o}=n??{},s=Sr({...i??{},target:o,io:t,processors:r});return A(e,s),$r(s,e),Zr(s,e)},ne=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},ie=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Cr=(e,t)=>{ne(e,"minimum",t),ie(e,"maximum",t)},Rr=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Nr=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},jr=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Mr=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Dr=(e,t)=>ne(e,"minimum",t.minimum),xr=(e,t)=>ie(e,"maximum",t.maximum),Lr=e=>(t,r)=>{Mr(t,r.format);const[n,i]=e[r.format];ne(t,"minimum",n),ie(t,"maximum",i)},da={greater_than:(e,t)=>ne(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ie(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Rr(e,t.value),number_format:Lr(Zt),bigint_format:Lr(Tn),min_length:Dr,max_length:xr,length_equals:(e,t)=>Cr(e,t.length),min_size:Dr,max_size:xr,size_equals:(e,t)=>Cr(e,t.size),string_format:(e,t)=>{Mr(e,t.format),t.pattern&&Nr(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>jr(e,t.mime)};function M(e){const t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(const o of n)da[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&ne(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&ne(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&ie(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&ie(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Rr(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&jr(t,i.mime);for(const o of i.patterns??[])Nr(t,o);return t}var ha={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pa=new Map([[tr,Ti],[nt,Pi]]),ma=e=>pa.get(e)??e,ga=(e,t,r,n)=>{const i=r;i.type="string";const{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:f}=M(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=ha[a]??a,i.format===""&&delete i.format,(a==="time"||f)&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c].map(ma);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},va=(e,t,r,n)=>{const i=r,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:f}=M(e);i.type=f?"integer":"number";const d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof o=="number"&&(i.minimum=o),h?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof s=="number"&&(i.maximum=s),a){const m=new Set;for(const _ of a)Number.isFinite(_)&&_!==0?m.add(Math.abs(_)):re(e,t,i,n,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);const[v,...b]=m;v!==void 0&&(i.multipleOf=v),b.length&&(i.allOf=[...i.allOf??[],...b.map(_=>({multipleOf:_}))])}},ba=(e,t,r,n)=>{r.type="boolean"},_a=(e,t,r,n)=>{r.not={}},ya=(e,t,r,n)=>{},wa=(e,t,r,n)=>{const i=e._zod.def,o=Le(i.entries);if(o.length===0){r.not={};return}o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},ka=(e,t,r,n)=>{re(e,t,r,n,"Custom types cannot be represented in JSON Schema")},Oa=(e,t,r,n)=>{re(e,t,r,n,"Transforms cannot be represented in JSON Schema")},za=(e,t,r,n)=>{const i=r,o=e._zod.def,{minimum:s,maximum:a}=M(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=A(o.element,t,{...n,path:[...n.path,"items"]})};function lt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?lt(t.out):t.type==="catch"?lt(t.innerType):e._zod.optin}var Sa=(e,t,r,n)=>{const i=r,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&re(e,t,i,n,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)H(i.properties,c,A(s[c],t,{...n,path:[...n.path,"properties",c]}));const a=[];for(const c of Object.keys(s)){const u=o.shape[c];(t.io==="input"?lt(u)===void 0:u._zod.optout===void 0)&&a.push(c)}a.length>0&&(i.required=a),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=A(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Ea=(e,t,r,n)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>A(a,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},$a=(e,t,r,n)=>{const i=e._zod.def,o=A(i.left,t,{...n,path:[...n.path,"allOf",0]}),s=A(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c,t.intersections.push(c)},Ia=(e,t,r,n)=>{const i=e._zod.def,o=A(i.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Aa=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType},ft=Symbol();function Fr(e,t,r,n,i){let o=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(re(t,r,n,i,"BigInt defaults cannot be represented in JSON Schema"),ft):JSON.parse(s)}var Ta=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType;const s=Fr(i.defaultValue,e,t,r,n);s!==ft&&(r.default=s)},Pa=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=Fr(i.defaultValue,e,t,r,n);s!==ft&&(r._prefault=s)},Za=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{re(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},Ca=(e,t,r,n)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;A(s,t,n);const a=t.seen.get(e);a.ref=s},Ra=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},Ur=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType},Wr=new WeakSet([Object.prototype,Error.prototype]);function Re(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Na=(e,t)=>{Yn.init(e,t),e.name="ZodError";const r=Object.getPrototypeOf(e);Wr.has(r)||(Wr.add(r),Re(r,"format",n=>i=>ei(n,i)),Re(r,"flatten",n=>i=>Qn(n,i)),Re(r,"addIssue",n=>i=>{n.issues.push(i),n.message=JSON.stringify(n.issues,Fe,2)}),Re(r,"addIssues",n=>i=>{n.issues.push(...i),n.message=JSON.stringify(n.issues,Fe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},R=l("ZodError",Na,void 0,{Parent:Error}),ja=qe(R),Ma=Ye(R),Da=Xe(R),xa=Qe(R),La=si(R),Fa=ai(R),Ua=ci(R),Wa=ui(R),Ba=li(R),Ja=fi(R),Va=di(R),Ka=hi(R);function Ga(){j.localeError||J(hs())}function dt(){j.memoizer||J({memoizer:ls()})}var E=l("ZodType",(e,t)=>(Ga(),S.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(C(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return U(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wc(e,t))},superRefine(e,t){return this.check(Bc(e,t))},overwrite(e){return this.check(te(e))},optional(){return qr(this)},exactOptional(){return Tc(this)},nullable(){return Xr(this)},nullish(){return qr(Xr(this))},nonoptional(e){return jc(this,e)},array(){return ht(this)},or(e){return Gr([this,e])},and(e){return $c(this,e)},transform(e){return en(this,Ac(e))},default(e){return Cc(this,e)},prefault(e){return Nc(this,e)},catch(e){return Dc(this,e)},pipe(e){return en(this,e)},readonly(){return Fc(this)},describe(e){const t=this.clone();return fe.add(t,{description:e}),t},meta(...e){if(e.length===0)return fe.get(this);const t=this.clone();return fe.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Mt(this,"~standard",{...qt(this),jsonSchema:{input:Ce(this,"input"),output:Ce(this,"output")}})},set"~standard"(e){W(this,"~standard",e)},parse:function e(t,r){return ja(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ma(this,t,r,{callee:e})},safeParse(e,t){return Da(this,e,t)},async safeParseAsync(e,t){return xa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){W(this,"spa",e)},validate(e,t){return ni(this,e,t)},validateAsync(e,t){return oi(this,e,t)},encode:function e(t,r){return La(this,t,r,{callee:e})},decode:function e(t,r){return Fa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ua(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Wa(this,t,r,{callee:e})},safeEncode(e,t){return Ba(this,e,t)},safeDecode(e,t){return Ja(this,e,t)},async safeEncodeAsync(e,t){return Va(this,e,t)},async safeDecodeAsync(e,t){return Ka(this,e,t)},toJSONSchema(e){return fa(this,{})(e)},get description(){return fe.get(this)?.description},get _def(){return this._zod.def}}),Br=l("_ZodString",(e,t)=>{rt.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ga(e,r,n,i)},Dt({format:e=>M(e).format??null,minLength:e=>M(e).minimum??null,maxLength:e=>M(e).maximum??null},{regex(...e){return this.check(Gs(...e))},includes(...e){return this.check(Ys(...e))},startsWith(...e){return this.check(Xs(...e))},endsWith(...e){return this.check(Qs(...e))},min(...e){return this.check(Ze(...e))},max(...e){return this.check(Or(...e))},length(...e){return this.check(zr(...e))},nonempty(...e){return this.check(Ze(1,...e))},lowercase(e){return this.check(Hs(e))},uppercase(e){return this.check(qs(e))},trim(){return this.check(ta())},normalize(...e){return this.check(ea(...e))},toLowerCase(){return this.check(ra())},toUpperCase(){return this.check(na())},slugify(){return this.check(ia())}})),Ha=l("ZodString",(e,t)=>{rt.init(e,t),Br.init(e,t)},{email(e){return this.check(vs(ec,e))},url(e){return this.check(Os(rc,e))},jwt(e){return this.check(Ds(vc,e))},emoji(e){return this.check(zs(nc,e))},guid(e){return this.check(bs(tc,e))},uuid(e){return this.check(_s(Ne,e))},uuidv4(e){return this.check(ys(Ne,e))},uuidv6(e){return this.check(ws(Ne,e))},uuidv7(e){return this.check(ks(Ne,e))},nanoid(e){return this.check(Ss(ic,e))},cuid(e){return this.check(Es(oc,e))},cuid2(e){return this.check($s(sc,e))},ulid(e){return this.check(Is(ac,e))},base64(e){return this.check(Ns(pc,e))},base64url(e){return this.check(js(mc,e))},xid(e){return this.check(As(cc,e))},ksuid(e){return this.check(Ts(uc,e))},ipv4(e){return this.check(Ps(lc,e))},ipv6(e){return this.check(Zs(fc,e))},cidrv4(e){return this.check(Cs(dc,e))},cidrv6(e){return this.check(Rs(hc,e))},e164(e){return this.check(Ms(gc,e))},datetime(e){return this.check(xs(qa,e))},date(e){return this.check(Ls(Ya,e))},time(e){return this.check(Fs(Xa,e))},duration(e){return this.check(Us(Qa,e))}});function O(e){return gs(Ha,e)}var z=l("ZodStringFormat",(e,t)=>{k.init(e,t),Br.init(e,t)}),qa=l("ZodISODateTime",(e,t)=>{wo.init(e,t),z.init(e,t)}),Ya=l("ZodISODate",(e,t)=>{ko.init(e,t),z.init(e,t)}),Xa=l("ZodISOTime",(e,t)=>{Oo.init(e,t),z.init(e,t)}),Qa=l("ZodISODuration",(e,t)=>{zo.init(e,t),z.init(e,t)}),ec=l("ZodEmail",(e,t)=>{so.init(e,t),z.init(e,t)}),tc=l("ZodGUID",(e,t)=>{io.init(e,t),z.init(e,t)}),Ne=l("ZodUUID",(e,t)=>{oo.init(e,t),z.init(e,t)}),rc=l("ZodURL",(e,t)=>{ho.init(e,t),z.init(e,t)}),nc=l("ZodEmoji",(e,t)=>{po.init(e,t),z.init(e,t)}),ic=l("ZodNanoID",(e,t)=>{mo.init(e,t),z.init(e,t)}),oc=l("ZodCUID",(e,t)=>{go.init(e,t),z.init(e,t)}),sc=l("ZodCUID2",(e,t)=>{vo.init(e,t),z.init(e,t)}),ac=l("ZodULID",(e,t)=>{bo.init(e,t),z.init(e,t)}),cc=l("ZodXID",(e,t)=>{_o.init(e,t),z.init(e,t)}),uc=l("ZodKSUID",(e,t)=>{yo.init(e,t),z.init(e,t)}),lc=l("ZodIPv4",(e,t)=>{So.init(e,t),z.init(e,t)}),fc=l("ZodIPv6",(e,t)=>{$o.init(e,t),z.init(e,t)}),dc=l("ZodCIDRv4",(e,t)=>{Io.init(e,t),z.init(e,t)}),hc=l("ZodCIDRv6",(e,t)=>{To.init(e,t),z.init(e,t)}),pc=l("ZodBase64",(e,t)=>{Po.init(e,t),z.init(e,t)}),mc=l("ZodBase64URL",(e,t)=>{Co.init(e,t),z.init(e,t)}),gc=l("ZodE164",(e,t)=>{Ro.init(e,t),z.init(e,t)}),vc=l("ZodJWT",(e,t)=>{jo.init(e,t),z.init(e,t)}),Jr=l("ZodNumber",(e,t)=>{rr.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>va(e,r,n,i),e.isFinite=!0},Dt({minValue:e=>{const{minimum:t,exclusiveMinimum:r}=M(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:r}=M(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:r}=M(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>M(e).format??null},{gt(e,t){return this.check(wr(e,t))},gte(e,t){return this.check(ct(e,t))},min(e,t){return this.check(ct(e,t))},lt(e,t){return this.check(yr(e,t))},lte(e,t){return this.check(at(e,t))},max(e,t){return this.check(at(e,t))},int(e){return this.check(Vr(e))},safe(e){return this.check(Vr(e))},positive(e){return this.check(wr(0,e))},nonnegative(e){return this.check(ct(0,e))},negative(e){return this.check(yr(0,e))},nonpositive(e){return this.check(at(0,e))},multipleOf(e,t){return this.check(kr(e,t))},step(e,t){return this.check(kr(e,t))},finite(){return this}}));function je(e){return Ws(Jr,e)}var bc=l("ZodNumberFormat",(e,t)=>{Mo.init(e,t),Jr.init(e,t)});function Vr(e){return Bs(bc,e)}var _c=l("ZodBoolean",(e,t)=>{Do.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ba(e,r,n,i)});function V(e){return Js(_c,e)}var yc=l("ZodUnknown",(e,t)=>{xo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ya(e,r,n,i)});function Kr(){return Vs(yc)}var wc=l("ZodNever",(e,t)=>{Lo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_a(e,r,n,i)});function kc(e){return Ks(wc,e)}var Oc=l("ZodArray",(e,t)=>{dt(),Wo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>za(e,r,n,i),e.element=t.element},{min(e,t){return this.check(Ze(e,t))},nonempty(e){return this.check(Ze(1,e))},max(e,t){return this.check(Or(e,t))},length(e,t){return this.check(zr(e,t))},unwrap(){return this.element}});function ht(e,t){return oa(Oc,e,t)}var zc=l("ZodObject",(e,t)=>{dt(),Vo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sa(e,r,n,i),Bn(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C(this._zod.def,{catchall:Kr()}))},loose(){return this.clone(C(this._zod.def,{catchall:Kr()}))},strict(){return this.clone(C(this._zod.def,{catchall:kc()}))},strip(){return this.clone(C(this._zod.def,{catchall:void 0}))},extend(e){return Cn(this,e)},safeExtend(e){return Rn(this,e)},merge(e){return Nn(this,e)},pick(e){return Pn(this,e)},omit(e){return Zn(this,e)},partial(...e){return Rt(Hr,this,e[0])},exactPartial(...e){return Rt(Yr,this,e[0],"exactPartial")},required(...e){return jn(Qr,this,e[0])}});function N(e,t){const r={type:"object",shape:e??{},...g(t)};return new zc(r)}var Sc=l("ZodUnion",(e,t)=>{Ko.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ea(e,r,n,i),e.options=t.options});function Gr(e,t){return new Sc({type:"union",options:e,...g(t)})}var Ec=l("ZodIntersection",(e,t)=>{Go.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$a(e,r,n,i)});function $c(e,t){return new Ec({type:"intersection",left:e,right:t})}var pt=l("ZodEnum",(e,t)=>{Ho.init(e,t),E.init(e,t),e._zod.processJSONSchema=(n,i,o)=>wa(e,n,i,o),e.enum=t.entries,e.options=[...e._zod.values];const r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{const o={};for(const s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new pt({...t,checks:[],...g(i),entries:o})},e.exclude=(n,i)=>{const o={...t.entries};for(const s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new pt({...t,checks:[],...g(i),entries:o})}});function Z(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new pt({type:"enum",entries:r,...g(t)})}var Ic=l("ZodTransform",(e,t)=>{dt(),qo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oa(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ft(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(ce(o,r.value,t));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ce(s))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function Ac(e){return new Ic({type:"transform",transform:e})}var Hr=l("ZodOptional",(e,t)=>{ur.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ur(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function qr(e){return new Hr({type:"optional",innerType:e})}var Yr=l("ZodExactOptional",(e,t)=>{Yo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ur(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new Yr({type:"optional",innerType:e})}var Pc=l("ZodNullable",(e,t)=>{Xo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ia(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Xr(e){return new Pc({type:"nullable",innerType:e})}var Zc=l("ZodDefault",(e,t)=>{Qo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ta(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Cc(e,t){return new Zc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var Rc=l("ZodPrefault",(e,t)=>{es.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pa(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Nc(e,t){return new Rc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var Qr=l("ZodNonOptional",(e,t)=>{ts.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Aa(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function jc(e,t){return new Qr({type:"nonoptional",innerType:e,...g(t)})}var Mc=l("ZodCatch",(e,t)=>{rs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Za(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Dc(e,t){return new Mc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Vn(t)})}var xc=l("ZodPipe",(e,t)=>{ns.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ca(e,r,n,i),e.in=t.in,e.out=t.out});function en(e,t){return new xc({type:"pipe",in:e,out:t})}var Lc=l("ZodReadonly",(e,t)=>{is.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ra(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Lc({type:"readonly",innerType:e})}var tn=l("ZodCustom",(e,t)=>{os.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ka(e,r,n,i)});function Uc(e,t){return sa(tn,e??(()=>!0),t)}function Wc(e,t={}){return aa(tn,e,t)}function Bc(e,t){return ca(e,t)}var mt=/^#[0-9a-fA-F]{6}$/,gt="Color must be a 6-digit hex code (e.g. '#3B82F6'). Short hex, rgb(), and named colors are not supported.",Me=N({primaryColor:O().max(20).regex(mt,gt).describe("Primary brand color (hex format, e.g., '#3B82F6')").optional(),backgroundColor:O().max(20).regex(mt,gt).describe("Background color for the widget container").optional(),textColor:O().max(20).regex(mt,gt).describe("Text color").optional(),borderRadius:je().describe("Border radius in pixels").optional(),fontFamily:O().max(100).describe("Font family").optional(),colorScheme:Z(["light","dark","auto"]).describe("Widget color scheme: 'light' (default), 'dark', or 'auto' (follows the visitor's prefers-color-scheme).").optional()}),Eu=Z(["mobile","tablet","desktop"]).describe("Viewport mode: mobile (<480px), tablet (480-768px), desktop (>768px)"),vt=Z(["bottom-right","bottom-left","inline"]).describe("Widget position on the page"),Jc=N({mobile:je().min(0).max(1e3).describe("Max width for mobile viewport (default: 480)").optional(),tablet:je().min(0).max(2e3).describe("Max width for tablet viewport (default: 768)").optional()}),Vc=N({enabled:V().describe("Enable responsive behavior (default: true)").optional(),breakpoints:Jc.describe("Custom breakpoint values").optional()}),$u=300,Kc=N({theme:Me.describe("Custom theme configuration").optional(),position:vt.describe("Widget position (default: 'bottom-right')").optional(),open:V().describe("Initial open state (default: false)").optional(),container:Gr([Uc(e=>e instanceof HTMLElement),O().max(200)]).describe("Container element for inline mode").optional(),baseUrl:O().url().max(200).describe("Base URL for the widget embed (default: production URL)").optional(),debug:V().describe("Enable debug logging").optional(),responsive:Vc.describe("Responsive behavior configuration").optional(),showProfile:V().describe("Force the profile panel visible in the widget header from the start of the conversation. The panel already shows on its own once the visitor's profile has data, regardless of this flag (default: false).").optional(),language:O().max(10).describe("Language for UI labels (e.g., 'fr', 'en'). Defaults to browser language.").optional(),apiKey:O().max(100).describe("Publishable API key (pk_*) for application authentication"),email:O().email().max(255).describe("Pre-identified user email (host-attested identity)").optional(),userId:O().max(255).describe("Host-side unique user identifier").optional(),userHash:O().max(128).describe("HMAC-SHA256 of email (or userId), signed with identity secret").optional(),initialMessage:O().max(300).describe("Auto-sent first visitor message, injected once via postMessage when the widget is ready (e.g. a demo deep-link). Never carried on the iframe URL. The authoritative bound is enforced again at the embed's trust boundary (useEmbedChatHandlers' INIT handler), this schema is not the sole enforcement point.").optional()}),Gc=N({theme:Me.describe("Full visual theme palette applied by the widget. Admin-configured, no client-side override.").optional(),position:vt.describe("Default launcher position. `inline` only applies when integrator supplies `data-container`.").optional(),language:O().max(10).describe("Locale forced for widget UI labels (ISO 639-1). Falls back to browser language when null.").optional(),showProfile:V().describe("Forces the profile panel visible from the start of the conversation. The panel already shows on its own once the visitor's profile has data, regardless of this flag.").optional(),open:V().describe("Default open state on load. Host can still call `window.Gamaro.open()` programmatically.").optional(),brand:N({title:O().max(60).describe("Custom widget header title. Falls back to a vertical-specific default (e.g. 'Gamaro Chat' for B2B) when unset.").optional(),avatarUrl:O().url().max(2048).describe("Public URL of the custom widget avatar (PNG or JPEG). MUST originate from the branding-upload endpoint — arbitrary external URLs are rejected at the API boundary.").optional()}).strict().describe("White-label branding overrides (issue #1083 Piste 5). Both fields are optional.").optional()}).strict(),rn=N({applicationId:O().uuid().describe("Application UUID"),applicationSlug:O().max(100).describe("Application slug (kebab-case)"),applicationName:O().max(200).describe("Application display name"),theme:Me.nullable().describe("Application theme"),allowedOrigins:ht(O().max(200)).max(50).describe("Allowed origins for this application"),monitoring:V().describe("Monitoring enabled flag"),primaryObjective:N({id:O().uuid(),type:O(),label:O(),ctaLabel:O().nullable()}).nullable().describe("Primary conversion objective"),identityVerificationRequired:V().describe("Whether HMAC identity verification is required"),widget:Gc.nullable().describe("Admin-configured widget runtime config (theme, position, language, showProfile, open). Null when the application has not yet persisted a widget_config JSONB.")}),Hc=Z(["user","assistant"]).describe("Message sender role"),qc=N({role:Hc.describe("Message sender role"),content:O().max(1e4).describe("Message content (max 10000 characters)")}),Yc={INIT:"gamaro:init",OPEN:"gamaro:open",CLOSE:"gamaro:close",RESET:"gamaro:reset",SET_THEME:"gamaro:setTheme",VIEWPORT:"gamaro:viewport",IDENTIFY:"gamaro:identify",READY:"gamaro:ready",PROFILE_UPDATE:"gamaro:profile-update",MESSAGE:"gamaro:message",QUALIFIED:"gamaro:qualified",ERROR:"gamaro:error",QUOTA_WARNING:"gamaro:quota-warning",QUOTA_EXCEEDED:"gamaro:quota-exceeded",FUNNEL_STAGE_CHANGE:"gamaro:funnel-stage-change",CTA_SHOWN:"gamaro:cta-shown",CTA_CLICKED:"gamaro:cta-clicked",LEAD_CAPTURED:"gamaro:lead-captured",IDENTITY_VERIFIED:"gamaro:identity-verified"},Iu=N({reason:Z(["timeout","error"]).describe("Why the iframe load failed (timeout vs. transport error)"),attempts:je().int().min(1).describe("Total attempts made before giving up (e.g. 3 = 1 + 2 retries)")}).describe("Payload emitted with the widget-unavailable SDK event (#867)"),Xc=Z(["prospect","partner","unknown"]).describe("Type of user"),Qc=Z(["ecommerce","real-estate","automotive","travel","recruitment","other"]).describe("Business sector"),eu=Z(["startup","pme","eti","grand-groupe"]).describe("Company size category"),tu=Z(["< 10k","10k-50k","50k-200k","> 200k"]).describe("Monthly website traffic"),ru=Z(["lead-qualification","personalization","cart-abandonment","conversion","other"]).describe("Business objective"),nu=Z(["shopify","woocommerce","prestashop","custom","none"]).describe("E-commerce platform"),iu=Z(["immediate","1-month","3-months","exploring"]).describe("Implementation timeline"),ou=Z(["< 500","500-2000","2000-5000","> 5000"]).describe("Monthly budget range in EUR"),su=N({userType:Xc.optional().describe("User type: prospect, partner, or unknown"),sector:Qc.optional().describe("Business sector"),companySize:eu.optional().describe("Company size range"),monthlyTraffic:tu.optional().describe("Monthly website traffic"),objectives:ht(ru).max(5).describe("List of business objectives (max 5)").optional(),platform:nu.optional().describe("E-commerce platform"),timeline:iu.optional().describe("Project timeline"),budgetRange:ou.optional().describe("Monthly budget range")}),X=class extends Error{constructor(e,t){super(e),this.code=t,this.name="ConfigFetchError"}},nn=1e4;async function on(e,t,r){const n=t.endsWith("/")?t:`${t}/`,i=new URL("api/application/config",n),o=new AbortController,s=setTimeout(()=>o.abort(),nn),a=r?AbortSignal.any([o.signal,r]):o.signal;let c;try{c=await fetch(i.toString(),{signal:a,headers:{"x-gamaro-key":e}})}catch(d){throw clearTimeout(s),r?.aborted?new X("Config fetch aborted by caller","ABORTED"):d instanceof DOMException&&d.name==="AbortError"?new X(`Config fetch timed out after ${nn}ms`,"TIMEOUT"):new X(`Network error fetching application config: ${d instanceof Error?d.message:String(d)}`,"NETWORK_ERROR")}if(clearTimeout(s),!c.ok){const d=await c.text().catch(()=>"");throw new X(`HTTP ${c.status} fetching application config: ${d}`,`HTTP_${c.status}`)}const u=await c.json(),f=rn.safeParse(u);if(!f.success)throw new X(`Invalid application config response: ${f.error.message}`,"PARSE_ERROR");return f.data}var Au=5e3,au=[1e3,3e3],oe=class extends Error{constructor(e,t){super(`Iframe load failed after ${t} attempt(s): ${e}`),this.reason=e,this.attempts=t,this.name="IframeLoadError"}};function cu(e,t){return new Promise((r,n)=>{if(t?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=()=>{clearTimeout(o),n(new DOMException("Aborted","AbortError"))},o=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e);t?.addEventListener("abort",i,{once:!0})})}function uu(e,t){return new Promise((r,n)=>{if(e.signal?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=e.buildIframe(),o=e.timeoutMs??5e3;let s=!1,a=!1,c=!1,u=null,f=null,d=null,h=null,p=null;const m=()=>{u!==null&&(clearTimeout(u),u=null),f&&i.removeEventListener("load",f),d&&i.removeEventListener("error",d),h&&window.removeEventListener("message",h),p&&e.signal?.removeEventListener("abort",p)},v=()=>{m(),!s&&i.parentNode&&i.parentNode.removeChild(i)},b=()=>{a&&c&&!s&&(s=!0,m(),r(i))};if(f=()=>{a=!0,b()},d=()=>{v(),n(new oe("error",t+1))},h=_=>{_.source&&(_.source&&_.source!==i.contentWindow||Ot(_.origin,e.allowedOrigins)&&zt(_)&&_.data.type===Yc.READY&&(c=!0,b()))},p=()=>{v(),n(new DOMException("Aborted","AbortError"))},i.addEventListener("load",f),i.addEventListener("error",d),window.addEventListener("message",h),e.signal?.addEventListener("abort",p,{once:!0}),u=setTimeout(()=>{v(),n(new oe("timeout",t+1))},o),e.signal?.aborted){v(),n(new DOMException("Aborted","AbortError"));return}e.container.appendChild(i)})}async function lu(e){const t=e.backoffMs??au,r=t.length+1;for(let n=0;n<r;n++){e.onStateChange?.({kind:"loading",attempt:n});try{const i=await uu(e,n);return e.onStateChange?.({kind:"loaded",iframe:i}),i}catch(i){if(i instanceof DOMException&&i.name==="AbortError")throw i;const o=i instanceof oe?i.reason:"error";if(n===r-1)throw e.onStateChange?.({kind:"failed",reason:o,attempts:r}),ve(`Iframe load failed permanently after ${r} attempt(s) (reason: ${o})`),new oe(o,r);const s=t[n]??1e3;e.onStateChange?.({kind:"retrying",attempt:n+1,reason:o}),be(`Iframe load attempt ${n+1} ${o==="timeout"?"timed out":"errored"}, retrying in ${s}ms`),await cu(s,e.signal)}}throw new oe("error",r)}var fu="0.1.0",De="https://gamaro.io/app",du=[1e3,2e3,3e3,4e3],hu=.3,pu=0,mu={mobile:480,tablet:768},sn={mobile:{width:"100vw",height:"100vh"},tablet:{width:"90vw",height:"80vh"},desktop:{width:"380px",height:"600px"}},gu=100,vu={position:"fixed",zIndex:"999999",border:"none",overflow:"hidden"},he=`${Q.slow}ms`,an=`${Q.base}ms`,bu=[`width ${he} ${K.emphasized}`,`height ${he} ${K.emphasized}`,`border-radius ${he} ${K.emphasized}`,`box-shadow ${he} ${K.emphasized}`,`transform ${he} ${K.emphasized}`].join(", "),_u=[`opacity ${an} ${K.standard}`,`background ${an} ${K.standard}`].join(", ");function cn(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var xe={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"}},yu={width:"100%",height:"100%",border:"none",backgroundColor:"transparent"},un=class{get applicationId(){return this._applicationId}constructor(e){this.version=fu,this.iframe=null,this.container=null,this.skeletonButton=null,this.isOpen=!1,this.isReady=!1,this.isInitialized=!1,this.isDestroyed=!1,this.fetchAbortController=null,this.iframeLoadAbortController=null,this._applicationId="",this.pendingCommands=[],this.eventHandlers=new Map,this.cleanupListener=null,this.currentViewportMode="desktop",this.mobileMediaQuery=null,this.tabletMediaQuery=null,this.debounceTimer=null,this.viewportChangeHandler=null,this.originalConfig={...e},this.config={position:"bottom-right",open:!1,baseUrl:De,debug:!1,...e},this.instanceId=++pu,this.debugLog=gn(this.config.debug??!1),this.renderSkeleton(),this.resolveConfig()}renderSkeleton(){this.config.position!=="inline"&&(this.container=this.createContainer(),this.renderSkeletonInto(this.container),document.body.appendChild(this.container))}renderSkeletonInto(e){const t=document.createElement("button");return t.type="button",t.setAttribute("aria-label","Loading widget…"),t.style.cssText=["width: 100%","height: 100%","border: none","border-radius: 50%","background: #9ca3af","cursor: default","opacity: 0.6",`transition: ${cn()?"none":_u}`].join(";"),e.appendChild(t),this.skeletonButton=t,t}setSkeletonStateUnavailable(){this.skeletonButton&&(this.skeletonButton.dataset.state="unavailable",this.skeletonButton.style.transition="none",this.skeletonButton.style.opacity="0.4",this.skeletonButton.style.cursor="not-allowed",this.skeletonButton.setAttribute("aria-label","Widget temporarily unavailable"))}resolveConfig(){const e=this.config.baseUrl??De;this.fetchAbortController=new AbortController;const t=r=>on(this.config.apiKey,e,this.fetchAbortController?.signal).then(n=>this.applyServerConfig(n)).catch(n=>{const i=n instanceof X?n.code:"UNKNOWN_ERROR",o=n instanceof Error?n.message:"Unknown config fetch error";if(i==="ABORTED"||this.isDestroyed)return;const s=du[r];if(s!==void 0&&this.isTransientFetchError(i)){const a=s*(1+(Math.random()*2-1)*hu);return be(`Config fetch failed transiently (${i}), retrying in ${Math.round(a)}ms`),new Promise(c=>setTimeout(()=>{this.isDestroyed||c(t(r+1))},a))}ve(`Config fetch failed — widget stays in degraded mode: ${o}`),this.emit("error",{code:i,message:o})});t(0)}isTransientFetchError(e){return e==="NETWORK_ERROR"||e==="TIMEOUT"||e.startsWith("HTTP_5")}applyServerConfig(e){if(this.isDestroyed)return;this._applicationId=e.applicationId;const t=e.widget??{};this.config={...this.config,theme:{...e.theme??{},...t.theme??{},...this.originalConfig.theme??{}},position:this.originalConfig.position??t.position??this.config.position,language:this.originalConfig.language??t.language??this.config.language,showProfile:this.originalConfig.showProfile??t.showProfile??this.config.showProfile,open:this.originalConfig.open??t.open??this.config.open},this.init().then(()=>be(`Widget v${this.version} ready (app: ${e.applicationSlug})`))}flushPendingCommands(){const e=this.pendingCommands;this.pendingCommands=[],e.forEach(t=>t())}async init(){if(this.isDestroyed)return;this.container?.remove(),this.skeletonButton=null,this.container=this.createContainer();let e=null;this.config.position!=="inline"&&(e=this.renderSkeletonInto(this.container)),this.attachContainerToDom(),this.iframeLoadAbortController=new AbortController;let t;try{t=await lu({buildIframe:()=>this.createIframe(),container:this.container,allowedOrigins:[this.resolveReadyOrigin()],signal:this.iframeLoadAbortController.signal,onStateChange:r=>{r.kind==="failed"&&this.setSkeletonStateUnavailable()}})}catch(r){if(this.isDestroyed||r instanceof DOMException&&r.name==="AbortError")return;r instanceof oe?(this.emit("widget-unavailable",{reason:r.reason,attempts:r.attempts}),this.emit("error",{code:"IFRAME_UNAVAILABLE",message:`Iframe load failed after ${r.attempts} attempt(s): ${r.reason}`})):this.emit("error",{code:"IFRAME_UNAVAILABLE",message:r instanceof Error?r.message:String(r)});return}if(this.isDestroyed){t.remove();return}this.iframe=t,e?.remove(),this.skeletonButton=null,this.isReady=!0,this.sendConfig(),this.emit("ready",void 0),this.cleanupListener=_n({onMessage:r=>this.handleMessage(r),debug:this.config.debug,sourceWindow:this.iframe.contentWindow,allowedOrigins:[this.resolveReadyOrigin()]}),this.config.open&&(this.isOpen=!0,this.updateVisibility()),this.setupViewportListener(),this.isInitialized=!0,this.flushPendingCommands(),this.log("Widget initialized",this.config)}resolveReadyOrigin(){const e=this.config.baseUrl??De;try{return new URL(e).origin}catch{return e}}attachContainerToDom(){this.container&&(this.config.position==="inline"&&this.config.container?(typeof this.config.container=="string"?document.querySelector(this.config.container):this.config.container)?.appendChild(this.container):document.body.appendChild(this.container))}createContainer(){const e=document.createElement("div");if(e.id=`gamaro-widget-container-${this.instanceId}`,this.config.position==="inline")Object.assign(e.style,{position:"relative",width:"100%",height:"100%",border:"none",borderRadius:"16px",overflow:"hidden",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.1)"});else{Object.assign(e.style,vu);const t=xe[this.config.position??"bottom-right"];Object.assign(e.style,t),e.style.width="60px",e.style.height="60px",e.style.borderRadius="50%"}return e}createIframe(){const e=document.createElement("iframe");return e.id=`gamaro-widget-iframe-${this.instanceId}`,e.src=this.buildIframeUrl(),e.setAttribute("title","Gamaro Chat Widget"),e.setAttribute("allow","clipboard-write; geolocation"),Object.assign(e.style,yu),e}buildIframeUrl(){const e=this.config.baseUrl??De,t=new URL("/app/widget/embed",e);return this.config.theme&&t.searchParams.set("theme",yn(this.config.theme)),this.config.position==="inline"&&t.searchParams.set("mode","inline"),this.config.open&&t.searchParams.set("open","true"),this.config.showProfile&&t.searchParams.set("showProfile","true"),this.config.language&&t.searchParams.set("language",this.config.language),this.config.apiKey&&t.searchParams.set("apiKey",this.config.apiKey),t.searchParams.set("hostOrigin",window.location.origin),t.toString()}setupViewportListener(){if(this.config.position==="inline"||this.config.responsive?.enabled===!1)return;const e={...mu,...this.config.responsive?.breakpoints};this.mobileMediaQuery=window.matchMedia(`(max-width: ${e.mobile}px)`),this.tabletMediaQuery=window.matchMedia(`(max-width: ${e.tablet}px)`),this.viewportChangeHandler=()=>this.handleViewportChange(),this.mobileMediaQuery.addEventListener("change",this.viewportChangeHandler),this.tabletMediaQuery.addEventListener("change",this.viewportChangeHandler),this.currentViewportMode=this.getViewportMode(),this.log("Initial viewport mode:",this.currentViewportMode)}handleViewportChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{const e=this.getViewportMode();e!==this.currentViewportMode&&(this.currentViewportMode=e,this.log("Viewport changed:",e),this.isOpen&&this.updateContainerForViewport(e),this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:viewport",mode:e},this.resolveReadyOrigin()))},gu)}getViewportMode(){return this.mobileMediaQuery?.matches?"mobile":this.tabletMediaQuery?.matches?"tablet":"desktop"}applyContainerTransition(){this.container&&(this.container.style.transition=cn()?"none":bu)}updateContainerForViewport(e){if(!this.container)return;this.applyContainerTransition();const t=sn[e];if(e==="mobile")Object.assign(this.container.style,{width:t.width,height:t.height,inset:"0",bottom:"auto",right:"auto",left:"auto",borderRadius:"0",maxWidth:"none",transform:"none"});else if(e==="tablet"){const r=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:t.width,height:t.height,inset:"auto",maxWidth:"500px",borderRadius:"16px",left:"50%",right:"auto",transform:"translateX(-50%)",bottom:r.bottom??"20px"})}else{const r=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:t.width,height:t.height,inset:"auto",maxWidth:"none",borderRadius:"16px",transform:"none",...r})}}handleMessage(e){switch(this.log("Received event:",e),e.type){case"gamaro:ready":if(this.isReady)break;this.isReady=!0,this.sendConfig(),this.emit("ready",void 0);break;case"gamaro:profile-update":this.emit("profile-update",void 0);break;case"gamaro:message":this.emit("message",e.message);break;case"gamaro:qualified":this.emit("qualified",void 0);break;case"gamaro:error":this.emit("error",{code:e.code,message:e.message});break;case"gamaro:open":this.isOpen=!0,this.updateVisibility(),this.emit("open",void 0);break;case"gamaro:close":this.isOpen=!1,this.updateVisibility(),this.emit("close",void 0);break;case"gamaro:quota-warning":this.emit("quota-warning",{remaining:e.remaining,limit:e.limit});break;case"gamaro:quota-exceeded":this.emit("quota-exceeded",void 0);break;case"gamaro:identity-verified":this.emit("identity-verified",{email:e.email,userId:e.userId});break;case"gamaro:funnel-stage-change":this.emit("funnel-stage-change",{stage:e.stage,previousStage:e.previousStage});break;case"gamaro:cta-shown":case"gamaro:cta-clicked":{const{ctaType:t,objectiveId:r}=e;this.emit(e.type==="gamaro:cta-shown"?"cta-shown":"cta-clicked",{ctaType:t,...r&&{objectiveId:r}});break}case"gamaro:lead-captured":this.emit("lead-captured",{hasEmail:e.hasEmail,hasPhone:e.hasPhone})}}sendConfig(){if(!this.iframe||!this.isReady)return;const{container:e,...t}=this.config,r={type:"gamaro:init",config:t};G(this.iframe,r,this.resolveReadyOrigin())}updateVisibility(){if(this.container&&this.config.position!=="inline")if(this.applyContainerTransition(),this.isOpen){if(this.config.responsive?.enabled!==!1)this.updateContainerForViewport(this.currentViewportMode);else{const e=sn.desktop;this.container.style.width=e.width,this.container.style.height=e.height,this.container.style.borderRadius="16px"}this.container.style.boxShadow="0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05)"}else{const e=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:"60px",height:"60px",borderRadius:"50%",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",inset:"auto",maxWidth:"none",transform:"none",...e})}}emit(e,t){const r=this.eventHandlers.get(e);r&&r.forEach(n=>{try{n(t)}catch(i){ve(`Error in event handler for "${e}":`,i)}})}open(){if(!this.isInitialized){this.pendingCommands.push(()=>this.open());return}this.iframe&&(this.isOpen=!0,this.updateVisibility(),this.isReady&&G(this.iframe,{type:"gamaro:open"},this.resolveReadyOrigin()))}close(){if(!this.isInitialized){this.pendingCommands.push(()=>this.close());return}this.iframe&&(this.isOpen=!1,this.updateVisibility(),this.isReady&&G(this.iframe,{type:"gamaro:close"},this.resolveReadyOrigin()))}reset(){if(!this.isInitialized){this.pendingCommands.push(()=>this.reset());return}!this.iframe||!this.isReady||G(this.iframe,{type:"gamaro:reset"},this.resolveReadyOrigin())}identify(e){if(this.config={...this.config,email:e.email,userId:e.userId,userHash:e.userHash},!this.isInitialized){this.pendingCommands.push(()=>this.identify(e));return}this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:identify",email:e.email,userId:e.userId,userHash:e.userHash},this.resolveReadyOrigin())}setTheme(e){if(this.config.theme={...this.config.theme,...e},!this.isInitialized){this.pendingCommands.push(()=>this.setTheme(e));return}this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:setTheme",theme:this.config.theme},this.resolveReadyOrigin())}setColorScheme(e){this.setTheme({colorScheme:e})}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){const r=this.eventHandlers.get(e);r&&r.delete(t)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.fetchAbortController?.abort(),this.fetchAbortController=null,this.iframeLoadAbortController?.abort(),this.iframeLoadAbortController=null,this.cleanupListener?.(),this.viewportChangeHandler&&(this.mobileMediaQuery?.removeEventListener("change",this.viewportChangeHandler),this.tabletMediaQuery?.removeEventListener("change",this.viewportChangeHandler),this.viewportChangeHandler=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.container?.remove(),this.iframe=null,this.container=null,this.skeletonButton=null,this.mobileMediaQuery=null,this.tabletMediaQuery=null,this.eventHandlers.clear(),this.pendingCommands=[])}log(e,...t){const r=t.map(n=>{if(n==null||typeof n!="object")return n;if(n instanceof HTMLElement)return`[HTMLElement: ${n.tagName}]`;try{const i=new WeakSet;return JSON.parse(JSON.stringify(n,(o,s)=>{if(s instanceof HTMLElement)return`[HTMLElement: ${s.tagName}]`;if(typeof s=="object"&&s!==null){if(i.has(s))return"[Circular]";i.add(s)}return s}))}catch{return"[Unserializable]"}});this.debugLog(e,...r)}};function ln(e){return new un(e)}var bt=new WeakSet;function fn(e){const t=e.getAttribute("data-api-key")??void 0;if(!t)return ve("Missing required data-api-key attribute on script tag"),null;const r=e.dataset.container,n=e.dataset.baseUrl,i=e.dataset.debug==="true",o=e.dataset.email,s=e.getAttribute("data-user-id")??void 0,a=e.getAttribute("data-user-hash")??void 0;return{apiKey:t,container:r,baseUrl:n,debug:i,...o&&{email:o},...s&&{userId:s},...a&&{userHash:a}}}function dn(){if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;const e=document.querySelectorAll("script[src]");for(const t of e){const r=t.src.toLowerCase();if(r.includes("gamaro")||r.includes("widget"))return t}return null}function _t(){const e=document.querySelectorAll("script[data-api-key]");if(e.length===0){const t=dn();t&&t.hasAttribute("data-api-key")&&!bt.has(t)&&hn(t);return}for(const t of e)hn(t)}function hn(e){if(bt.has(e))return;bt.add(e);const t=fn(e);if(!t)return;const r=ln(t);window.Gamaro||(window.Gamaro=r),window.GamaroApps||(window.GamaroApps=new Map),r.on("ready",()=>{r.applicationId&&window.GamaroApps&&window.GamaroApps.set(r.applicationId,r)}),be(`Widget v${r.version} initializing...`)}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_t):_t()),I.ConfigFetchError=X,I.GamaroWidget=un,I.__autoInit=_t,I.__getCurrentScript=dn,I.__parseScriptAttributes=fn,I.applicationConfigResponseSchema=rn,I.b2bProfileSchema=su,I.createWidget=ln,I.fetchApplicationConfig=on,I.themeConfigSchema=Me,I.widgetConfigSchema=Kc,I.widgetMessageSchema=qc,I.widgetPositionSchema=vt});
82
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Er(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const r=[];for(const n of t){if(!n||typeof n!="object")return;Er(n);const i=Object.keys(n);if(i.length!==1||i[0]!=="type")return;const o=n.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;r.includes(s)||r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Ir=new Set(["type","properties","required","additionalProperties"]),Ar=["oneOf","anyOf"];function Tr(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ut(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Ir.has(s))return null;t.push(o)}const r={},n=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;const a=[];for(const u of t){const f=u.properties?.[s]??Tr(u);f!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(f))||a.push(f))}const c=a.length===1?a[0]:ut(a)??{allOf:a};H(r,s,c)}for(const s of o.required??[])n.add(s)}const i={type:"object",properties:r};if(n.size&&(i.required=[...n]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=Tr(s);a&&!o.some(c=>JSON.stringify(c)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function la(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Ir)if(i in e)return;const r=t.filter(i=>Ar.some(o=>Array.isArray(i[o])));let n=null;if(!r.length)n=ut(t);else{const i=r[0],o=Ar.find(c=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;const s=t.filter(c=>c!==i),a=i[o].map(c=>ut([...s,c]));if(a.some(c=>!c))return;n={[o]:a}}n&&(delete e.allOf,de(e,n))}function Pr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,f={...u},d=c.ref;if(c.ref=null,d){n(d);const p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):de(u,m),de(u,f),a._zod.parent===d)for(const v in u)v==="$ref"||v==="allOf"||v in f||delete u[v];if(m.$ref&&p.def)for(const v in u)v==="$ref"||v==="allOf"||v in p.def&&JSON.stringify(u[v])===JSON.stringify(p.def[v])&&delete u[v]}const h=a._zod.parent;if(h&&h!==d){n(h);const p=e.seen.get(h);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())Er(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const f=u?.allOf;if(!Array.isArray(f))continue;const d=a.get(f);d?d.push(u):a.set(f,[u])}for(const c of e.intersections)for(const u of a.get(c)??[])la(u)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}de(i,r.defId?r.schema:r.def??r.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,H(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ce(t,"input",e.processors),output:Ce(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return T(n.element,r);if(n.type==="set")return T(n.valueType,r);if(n.type==="lazy")return T(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return T(n.innerType,r);if(n.type==="intersection")return T(n.left,r)||T(n.right,r);if(n.type==="record"||n.type==="map")return T(n.keyType,r)||T(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:T(n.in,r)||T(n.out,r);if(n.type==="object"){for(const i in n.shape)if(T(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(T(i,r))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(T(i,r))return!0;return!!(n.rest&&T(n.rest,r))}return!1}var fa=(e,t={})=>r=>{const n=zr({...r,processors:t});return A(e,n),$r(n,e),Pr(n,e)},Ce=(e,t,r={})=>n=>{const{libraryOptions:i,target:o}=n??{},s=zr({...i??{},target:o,io:t,processors:r});return A(e,s),$r(s,e),Pr(s,e)},ne=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},ie=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Zr=(e,t)=>{ne(e,"minimum",t),ie(e,"maximum",t)},Cr=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Rr=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Nr=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},jr=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Mr=(e,t)=>ne(e,"minimum",t.minimum),Dr=(e,t)=>ie(e,"maximum",t.maximum),xr=e=>(t,r)=>{jr(t,r.format);const[n,i]=e[r.format];ne(t,"minimum",n),ie(t,"maximum",i)},da={greater_than:(e,t)=>ne(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ie(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Cr(e,t.value),number_format:xr(Zt),bigint_format:xr(An),min_length:Mr,max_length:Dr,length_equals:(e,t)=>Zr(e,t.length),min_size:Mr,max_size:Dr,size_equals:(e,t)=>Zr(e,t.size),string_format:(e,t)=>{jr(e,t.format),t.pattern&&Rr(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Nr(e,t.mime)};function M(e){const t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(const o of n)da[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&ne(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&ne(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&ie(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&ie(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Cr(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Nr(t,i.mime);for(const o of i.patterns??[])Rr(t,o);return t}var ha={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pa=new Map([[er,Ti],[nt,Pi]]),ma=e=>pa.get(e)??e,ga=(e,t,r,n)=>{const i=r;i.type="string";const{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:f}=M(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=ha[a]??a,i.format===""&&delete i.format,(a==="time"||f)&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c].map(ma);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},va=(e,t,r,n)=>{const i=r,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:f}=M(e);i.type=f?"integer":"number";const d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof o=="number"&&(i.minimum=o),h?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof s=="number"&&(i.maximum=s),a){const m=new Set;for(const _ of a)Number.isFinite(_)&&_!==0?m.add(Math.abs(_)):re(e,t,i,n,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);const[v,...b]=m;v!==void 0&&(i.multipleOf=v),b.length&&(i.allOf=[...i.allOf??[],...b.map(_=>({multipleOf:_}))])}},ba=(e,t,r,n)=>{r.type="boolean"},_a=(e,t,r,n)=>{r.not={}},ya=(e,t,r,n)=>{},wa=(e,t,r,n)=>{const i=e._zod.def,o=Le(i.entries);if(o.length===0){r.not={};return}o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},ka=(e,t,r,n)=>{re(e,t,r,n,"Custom types cannot be represented in JSON Schema")},Oa=(e,t,r,n)=>{re(e,t,r,n,"Transforms cannot be represented in JSON Schema")},za=(e,t,r,n)=>{const i=r,o=e._zod.def,{minimum:s,maximum:a}=M(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=A(o.element,t,{...n,path:[...n.path,"items"]})};function lt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?lt(t.out):t.type==="catch"?lt(t.innerType):e._zod.optin}var Sa=(e,t,r,n)=>{const i=r,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&re(e,t,i,n,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)H(i.properties,c,A(s[c],t,{...n,path:[...n.path,"properties",c]}));const a=[];for(const c of Object.keys(s)){const u=o.shape[c];(t.io==="input"?lt(u)===void 0:u._zod.optout===void 0)&&a.push(c)}a.length>0&&(i.required=a),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=A(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},$a=(e,t,r,n)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>A(a,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},Ea=(e,t,r,n)=>{const i=e._zod.def,o=A(i.left,t,{...n,path:[...n.path,"allOf",0]}),s=A(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c,t.intersections.push(c)},Ia=(e,t,r,n)=>{const i=e._zod.def,o=A(i.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Aa=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType},ft=Symbol();function Lr(e,t,r,n,i){let o=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(re(t,r,n,i,"BigInt defaults cannot be represented in JSON Schema"),ft):JSON.parse(s)}var Ta=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType;const s=Lr(i.defaultValue,e,t,r,n);s!==ft&&(r.default=s)},Pa=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=Lr(i.defaultValue,e,t,r,n);s!==ft&&(r._prefault=s)},Za=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{re(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},Ca=(e,t,r,n)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;A(s,t,n);const a=t.seen.get(e);a.ref=s},Ra=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},Fr=(e,t,r,n)=>{const i=e._zod.def;A(i.innerType,t,n);const o=t.seen.get(e);o.ref=i.innerType},Ur=new WeakSet([Object.prototype,Error.prototype]);function Re(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Na=(e,t)=>{Yn.init(e,t),e.name="ZodError";const r=Object.getPrototypeOf(e);Ur.has(r)||(Ur.add(r),Re(r,"format",n=>i=>ei(n,i)),Re(r,"flatten",n=>i=>Qn(n,i)),Re(r,"addIssue",n=>i=>{n.issues.push(i),n.message=JSON.stringify(n.issues,Fe,2)}),Re(r,"addIssues",n=>i=>{n.issues.push(...i),n.message=JSON.stringify(n.issues,Fe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},R=l("ZodError",Na,void 0,{Parent:Error}),ja=qe(R),Ma=Ye(R),Da=Xe(R),xa=Qe(R),La=si(R),Fa=ai(R),Ua=ci(R),Wa=ui(R),Ba=li(R),Ja=fi(R),Va=di(R),Ka=hi(R);function Ga(){j.localeError||J(hs())}function dt(){j.memoizer||J({memoizer:ls()})}var $=l("ZodType",(e,t)=>(Ga(),S.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(C(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return U(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wc(e,t))},superRefine(e,t){return this.check(Bc(e,t))},overwrite(e){return this.check(te(e))},optional(){return Hr(this)},exactOptional(){return Tc(this)},nullable(){return Yr(this)},nullish(){return Hr(Yr(this))},nonoptional(e){return jc(this,e)},array(){return ht(this)},or(e){return Kr([this,e])},and(e){return Ec(this,e)},transform(e){return Qr(this,Ac(e))},default(e){return Cc(this,e)},prefault(e){return Nc(this,e)},catch(e){return Dc(this,e)},pipe(e){return Qr(this,e)},readonly(){return Fc(this)},describe(e){const t=this.clone();return fe.add(t,{description:e}),t},meta(...e){if(e.length===0)return fe.get(this);const t=this.clone();return fe.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Mt(this,"~standard",{...Ht(this),jsonSchema:{input:Ce(this,"input"),output:Ce(this,"output")}})},set"~standard"(e){W(this,"~standard",e)},parse:function e(t,r){return ja(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ma(this,t,r,{callee:e})},safeParse(e,t){return Da(this,e,t)},async safeParseAsync(e,t){return xa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){W(this,"spa",e)},validate(e,t){return ni(this,e,t)},validateAsync(e,t){return oi(this,e,t)},encode:function e(t,r){return La(this,t,r,{callee:e})},decode:function e(t,r){return Fa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ua(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Wa(this,t,r,{callee:e})},safeEncode(e,t){return Ba(this,e,t)},safeDecode(e,t){return Ja(this,e,t)},async safeEncodeAsync(e,t){return Va(this,e,t)},async safeDecodeAsync(e,t){return Ka(this,e,t)},toJSONSchema(e){return fa(this,{})(e)},get description(){return fe.get(this)?.description},get _def(){return this._zod.def}}),Wr=l("_ZodString",(e,t)=>{rt.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ga(e,r,n,i)},Dt({format:e=>M(e).format??null,minLength:e=>M(e).minimum??null,maxLength:e=>M(e).maximum??null},{regex(...e){return this.check(Gs(...e))},includes(...e){return this.check(Ys(...e))},startsWith(...e){return this.check(Xs(...e))},endsWith(...e){return this.check(Qs(...e))},min(...e){return this.check(Ze(...e))},max(...e){return this.check(kr(...e))},length(...e){return this.check(Or(...e))},nonempty(...e){return this.check(Ze(1,...e))},lowercase(e){return this.check(Hs(e))},uppercase(e){return this.check(qs(e))},trim(){return this.check(ta())},normalize(...e){return this.check(ea(...e))},toLowerCase(){return this.check(ra())},toUpperCase(){return this.check(na())},slugify(){return this.check(ia())}})),Ha=l("ZodString",(e,t)=>{rt.init(e,t),Wr.init(e,t)},{email(e){return this.check(vs(ec,e))},url(e){return this.check(Os(rc,e))},jwt(e){return this.check(Ds(vc,e))},emoji(e){return this.check(zs(nc,e))},guid(e){return this.check(bs(tc,e))},uuid(e){return this.check(_s(Ne,e))},uuidv4(e){return this.check(ys(Ne,e))},uuidv6(e){return this.check(ws(Ne,e))},uuidv7(e){return this.check(ks(Ne,e))},nanoid(e){return this.check(Ss(ic,e))},cuid(e){return this.check($s(oc,e))},cuid2(e){return this.check(Es(sc,e))},ulid(e){return this.check(Is(ac,e))},base64(e){return this.check(Ns(pc,e))},base64url(e){return this.check(js(mc,e))},xid(e){return this.check(As(cc,e))},ksuid(e){return this.check(Ts(uc,e))},ipv4(e){return this.check(Ps(lc,e))},ipv6(e){return this.check(Zs(fc,e))},cidrv4(e){return this.check(Cs(dc,e))},cidrv6(e){return this.check(Rs(hc,e))},e164(e){return this.check(Ms(gc,e))},datetime(e){return this.check(xs(qa,e))},date(e){return this.check(Ls(Ya,e))},time(e){return this.check(Fs(Xa,e))},duration(e){return this.check(Us(Qa,e))}});function O(e){return gs(Ha,e)}var z=l("ZodStringFormat",(e,t)=>{k.init(e,t),Wr.init(e,t)}),qa=l("ZodISODateTime",(e,t)=>{wo.init(e,t),z.init(e,t)}),Ya=l("ZodISODate",(e,t)=>{ko.init(e,t),z.init(e,t)}),Xa=l("ZodISOTime",(e,t)=>{Oo.init(e,t),z.init(e,t)}),Qa=l("ZodISODuration",(e,t)=>{zo.init(e,t),z.init(e,t)}),ec=l("ZodEmail",(e,t)=>{so.init(e,t),z.init(e,t)}),tc=l("ZodGUID",(e,t)=>{io.init(e,t),z.init(e,t)}),Ne=l("ZodUUID",(e,t)=>{oo.init(e,t),z.init(e,t)}),rc=l("ZodURL",(e,t)=>{ho.init(e,t),z.init(e,t)}),nc=l("ZodEmoji",(e,t)=>{po.init(e,t),z.init(e,t)}),ic=l("ZodNanoID",(e,t)=>{mo.init(e,t),z.init(e,t)}),oc=l("ZodCUID",(e,t)=>{go.init(e,t),z.init(e,t)}),sc=l("ZodCUID2",(e,t)=>{vo.init(e,t),z.init(e,t)}),ac=l("ZodULID",(e,t)=>{bo.init(e,t),z.init(e,t)}),cc=l("ZodXID",(e,t)=>{_o.init(e,t),z.init(e,t)}),uc=l("ZodKSUID",(e,t)=>{yo.init(e,t),z.init(e,t)}),lc=l("ZodIPv4",(e,t)=>{So.init(e,t),z.init(e,t)}),fc=l("ZodIPv6",(e,t)=>{Eo.init(e,t),z.init(e,t)}),dc=l("ZodCIDRv4",(e,t)=>{Io.init(e,t),z.init(e,t)}),hc=l("ZodCIDRv6",(e,t)=>{To.init(e,t),z.init(e,t)}),pc=l("ZodBase64",(e,t)=>{Po.init(e,t),z.init(e,t)}),mc=l("ZodBase64URL",(e,t)=>{Co.init(e,t),z.init(e,t)}),gc=l("ZodE164",(e,t)=>{Ro.init(e,t),z.init(e,t)}),vc=l("ZodJWT",(e,t)=>{jo.init(e,t),z.init(e,t)}),Br=l("ZodNumber",(e,t)=>{tr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>va(e,r,n,i),e.isFinite=!0},Dt({minValue:e=>{const{minimum:t,exclusiveMinimum:r}=M(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:r}=M(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:r}=M(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>M(e).format??null},{gt(e,t){return this.check(yr(e,t))},gte(e,t){return this.check(ct(e,t))},min(e,t){return this.check(ct(e,t))},lt(e,t){return this.check(_r(e,t))},lte(e,t){return this.check(at(e,t))},max(e,t){return this.check(at(e,t))},int(e){return this.check(Jr(e))},safe(e){return this.check(Jr(e))},positive(e){return this.check(yr(0,e))},nonnegative(e){return this.check(ct(0,e))},negative(e){return this.check(_r(0,e))},nonpositive(e){return this.check(at(0,e))},multipleOf(e,t){return this.check(wr(e,t))},step(e,t){return this.check(wr(e,t))},finite(){return this}}));function je(e){return Ws(Br,e)}var bc=l("ZodNumberFormat",(e,t)=>{Mo.init(e,t),Br.init(e,t)});function Jr(e){return Bs(bc,e)}var _c=l("ZodBoolean",(e,t)=>{Do.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ba(e,r,n,i)});function V(e){return Js(_c,e)}var yc=l("ZodUnknown",(e,t)=>{xo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ya(e,r,n,i)});function Vr(){return Vs(yc)}var wc=l("ZodNever",(e,t)=>{Lo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_a(e,r,n,i)});function kc(e){return Ks(wc,e)}var Oc=l("ZodArray",(e,t)=>{dt(),Wo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>za(e,r,n,i),e.element=t.element},{min(e,t){return this.check(Ze(e,t))},nonempty(e){return this.check(Ze(1,e))},max(e,t){return this.check(kr(e,t))},length(e,t){return this.check(Or(e,t))},unwrap(){return this.element}});function ht(e,t){return oa(Oc,e,t)}var zc=l("ZodObject",(e,t)=>{dt(),Vo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sa(e,r,n,i),Wn(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C(this._zod.def,{catchall:Vr()}))},loose(){return this.clone(C(this._zod.def,{catchall:Vr()}))},strict(){return this.clone(C(this._zod.def,{catchall:kc()}))},strip(){return this.clone(C(this._zod.def,{catchall:void 0}))},extend(e){return Zn(this,e)},safeExtend(e){return Cn(this,e)},merge(e){return Rn(this,e)},pick(e){return Tn(this,e)},omit(e){return Pn(this,e)},partial(...e){return Rt(Gr,this,e[0])},exactPartial(...e){return Rt(qr,this,e[0],"exactPartial")},required(...e){return Nn(Xr,this,e[0])}});function N(e,t){const r={type:"object",shape:e??{},...g(t)};return new zc(r)}var Sc=l("ZodUnion",(e,t)=>{Ko.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$a(e,r,n,i),e.options=t.options});function Kr(e,t){return new Sc({type:"union",options:e,...g(t)})}var $c=l("ZodIntersection",(e,t)=>{Go.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ea(e,r,n,i)});function Ec(e,t){return new $c({type:"intersection",left:e,right:t})}var pt=l("ZodEnum",(e,t)=>{Ho.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,i,o)=>wa(e,n,i,o),e.enum=t.entries,e.options=[...e._zod.values];const r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{const o={};for(const s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new pt({...t,checks:[],...g(i),entries:o})},e.exclude=(n,i)=>{const o={...t.entries};for(const s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new pt({...t,checks:[],...g(i),entries:o})}});function Z(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new pt({type:"enum",entries:r,...g(t)})}var Ic=l("ZodTransform",(e,t)=>{dt(),qo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oa(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ft(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(ce(o,r.value,t));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ce(s))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function Ac(e){return new Ic({type:"transform",transform:e})}var Gr=l("ZodOptional",(e,t)=>{cr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Fr(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Hr(e){return new Gr({type:"optional",innerType:e})}var qr=l("ZodExactOptional",(e,t)=>{Yo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Fr(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new qr({type:"optional",innerType:e})}var Pc=l("ZodNullable",(e,t)=>{Xo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ia(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Yr(e){return new Pc({type:"nullable",innerType:e})}var Zc=l("ZodDefault",(e,t)=>{Qo.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ta(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Cc(e,t){return new Zc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var Rc=l("ZodPrefault",(e,t)=>{es.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pa(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Nc(e,t){return new Rc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var Xr=l("ZodNonOptional",(e,t)=>{ts.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Aa(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function jc(e,t){return new Xr({type:"nonoptional",innerType:e,...g(t)})}var Mc=l("ZodCatch",(e,t)=>{rs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Za(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Dc(e,t){return new Mc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Jn(t)})}var xc=l("ZodPipe",(e,t)=>{ns.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ca(e,r,n,i),e.in=t.in,e.out=t.out});function Qr(e,t){return new xc({type:"pipe",in:e,out:t})}var Lc=l("ZodReadonly",(e,t)=>{is.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ra(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Lc({type:"readonly",innerType:e})}var en=l("ZodCustom",(e,t)=>{os.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ka(e,r,n,i)});function Uc(e,t){return sa(en,e??(()=>!0),t)}function Wc(e,t={}){return aa(en,e,t)}function Bc(e,t){return ca(e,t)}var mt=/^#[0-9a-fA-F]{6}$/,gt="Color must be a 6-digit hex code (e.g. '#3B82F6'). Short hex, rgb(), and named colors are not supported.",Me=N({primaryColor:O().max(20).regex(mt,gt).describe("Primary brand color (hex format, e.g., '#3B82F6')").optional(),backgroundColor:O().max(20).regex(mt,gt).describe("Background color for the widget container").optional(),textColor:O().max(20).regex(mt,gt).describe("Text color").optional(),borderRadius:je().describe("Border radius in pixels").optional(),fontFamily:O().max(100).describe("Font family").optional(),colorScheme:Z(["light","dark","auto"]).describe("Widget color scheme: 'light' (default), 'dark', or 'auto' (follows the visitor's prefers-color-scheme).").optional()}),Su=Z(["mobile","tablet","desktop"]).describe("Viewport mode: mobile (<480px), tablet (480-768px), desktop (>768px)"),vt=Z(["bottom-right","bottom-left","inline"]).describe("Widget position on the page"),Jc=N({mobile:je().min(0).max(1e3).describe("Max width for mobile viewport (default: 480)").optional(),tablet:je().min(0).max(2e3).describe("Max width for tablet viewport (default: 768)").optional()}),Vc=N({enabled:V().describe("Enable responsive behavior (default: true)").optional(),breakpoints:Jc.describe("Custom breakpoint values").optional()}),$u=300,Kc=N({theme:Me.describe("Custom theme configuration").optional(),position:vt.describe("Widget position (default: 'bottom-right')").optional(),open:V().describe("Initial open state (default: false)").optional(),container:Kr([Uc(e=>e instanceof HTMLElement),O().max(200)]).describe("Container element for inline mode").optional(),baseUrl:O().url().max(200).describe("Base URL for the widget embed (default: production URL)").optional(),debug:V().describe("Enable debug logging").optional(),responsive:Vc.describe("Responsive behavior configuration").optional(),showProfile:V().describe("Force the profile panel visible in the widget header from the start of the conversation. The panel already shows on its own once the visitor's profile has data, regardless of this flag (default: false).").optional(),language:O().max(10).describe("Language for UI labels (e.g., 'fr', 'en'). Defaults to browser language.").optional(),apiKey:O().max(100).describe("Publishable API key (pk_*) for application authentication"),email:O().email().max(255).describe("Pre-identified user email (host-attested identity)").optional(),userId:O().max(255).describe("Host-side unique user identifier").optional(),userHash:O().max(128).describe("HMAC-SHA256 of email (or userId), signed with identity secret").optional(),initialMessage:O().max(300).describe("Auto-sent first visitor message, injected once via postMessage when the widget is ready (e.g. a demo deep-link). Never carried on the iframe URL. The authoritative bound is enforced again at the embed's trust boundary (useEmbedChatHandlers' INIT handler), this schema is not the sole enforcement point.").optional()}),Gc=N({theme:Me.describe("Full visual theme palette applied by the widget. Admin-configured, no client-side override.").optional(),position:vt.describe("Default launcher position. `inline` only applies when integrator supplies `data-container`.").optional(),language:O().max(10).describe("Locale forced for widget UI labels (ISO 639-1). Falls back to browser language when null.").optional(),showProfile:V().describe("Forces the profile panel visible from the start of the conversation. The panel already shows on its own once the visitor's profile has data, regardless of this flag.").optional(),open:V().describe("Default open state on load. Host can still call `window.Gamaro.open()` programmatically.").optional(),brand:N({title:O().max(60).describe("Custom widget header title. Falls back to a vertical-specific default (e.g. 'Gamaro Chat' for B2B) when unset.").optional(),avatarUrl:O().url().max(2048).describe("Public URL of the custom widget avatar (PNG or JPEG). MUST originate from the branding-upload endpoint — arbitrary external URLs are rejected at the API boundary.").optional()}).strict().describe("White-label branding overrides (issue #1083 Piste 5). Both fields are optional.").optional()}).strict(),tn=N({applicationId:O().uuid().describe("Application UUID"),applicationSlug:O().max(100).describe("Application slug (kebab-case)"),applicationName:O().max(200).describe("Application display name"),theme:Me.nullable().describe("Application theme"),allowedOrigins:ht(O().max(200)).max(50).describe("Allowed origins for this application"),monitoring:V().describe("Monitoring enabled flag"),primaryObjective:N({id:O().uuid(),type:O(),label:O(),ctaLabel:O().nullable()}).nullable().describe("Primary conversion objective"),identityVerificationRequired:V().describe("Whether HMAC identity verification is required"),widget:Gc.nullable().describe("Admin-configured widget runtime config (theme, position, language, showProfile, open). Null when the application has not yet persisted a widget_config JSONB.")}),Hc=Z(["user","assistant"]).describe("Message sender role"),qc=N({role:Hc.describe("Message sender role"),content:O().max(1e4).describe("Message content (max 10000 characters)")}),Yc={INIT:"gamaro:init",OPEN:"gamaro:open",CLOSE:"gamaro:close",RESET:"gamaro:reset",SET_THEME:"gamaro:setTheme",VIEWPORT:"gamaro:viewport",IDENTIFY:"gamaro:identify",READY:"gamaro:ready",PROFILE_UPDATE:"gamaro:profile-update",MESSAGE:"gamaro:message",QUALIFIED:"gamaro:qualified",ERROR:"gamaro:error",QUOTA_WARNING:"gamaro:quota-warning",QUOTA_EXCEEDED:"gamaro:quota-exceeded",FUNNEL_STAGE_CHANGE:"gamaro:funnel-stage-change",CTA_SHOWN:"gamaro:cta-shown",CTA_CLICKED:"gamaro:cta-clicked",LEAD_CAPTURED:"gamaro:lead-captured",IDENTITY_VERIFIED:"gamaro:identity-verified"},Eu=N({reason:Z(["timeout","error"]).describe("Why the iframe load failed (timeout vs. transport error)"),attempts:je().int().min(1).describe("Total attempts made before giving up (e.g. 3 = 1 + 2 retries)")}).describe("Payload emitted with the widget-unavailable SDK event (#867)"),Xc=Z(["prospect","partner","unknown"]).describe("Type of user"),Qc=Z(["ecommerce","real-estate","automotive","travel","recruitment","other"]).describe("Business sector"),eu=Z(["startup","pme","eti","grand-groupe"]).describe("Company size category"),tu=Z(["< 10k","10k-50k","50k-200k","> 200k"]).describe("Monthly website traffic"),ru=Z(["lead-qualification","personalization","cart-abandonment","conversion","other"]).describe("Business objective"),nu=Z(["shopify","woocommerce","prestashop","custom","none"]).describe("E-commerce platform"),iu=Z(["immediate","1-month","3-months","exploring"]).describe("Implementation timeline"),ou=Z(["< 500","500-2000","2000-5000","> 5000"]).describe("Monthly budget range in EUR"),su=N({userType:Xc.optional().describe("User type: prospect, partner, or unknown"),sector:Qc.optional().describe("Business sector"),companySize:eu.optional().describe("Company size range"),monthlyTraffic:tu.optional().describe("Monthly website traffic"),objectives:ht(ru).max(5).describe("List of business objectives (max 5)").optional(),platform:nu.optional().describe("E-commerce platform"),timeline:iu.optional().describe("Project timeline"),budgetRange:ou.optional().describe("Monthly budget range")}),X=class extends Error{constructor(e,t){super(e),this.code=t,this.name="ConfigFetchError"}},rn=1e4;async function nn(e,t,r){const n=t.endsWith("/")?t:`${t}/`,i=new URL("api/application/config",n),o=new AbortController,s=setTimeout(()=>o.abort(),rn),a=r?AbortSignal.any([o.signal,r]):o.signal;let c;try{c=await fetch(i.toString(),{signal:a,headers:{"x-gamaro-key":e}})}catch(d){throw clearTimeout(s),r?.aborted?new X("Config fetch aborted by caller","ABORTED"):d instanceof DOMException&&d.name==="AbortError"?new X(`Config fetch timed out after ${rn}ms`,"TIMEOUT"):new X(`Network error fetching application config: ${d instanceof Error?d.message:String(d)}`,"NETWORK_ERROR")}if(clearTimeout(s),!c.ok){const d=await c.text().catch(()=>"");throw new X(`HTTP ${c.status} fetching application config: ${d}`,`HTTP_${c.status}`)}const u=await c.json(),f=tn.safeParse(u);if(!f.success)throw new X(`Invalid application config response: ${f.error.message}`,"PARSE_ERROR");return f.data}var Iu=5e3,au=[1e3,3e3],oe=class extends Error{constructor(e,t){super(`Iframe load failed after ${t} attempt(s): ${e}`),this.reason=e,this.attempts=t,this.name="IframeLoadError"}};function cu(e,t){return new Promise((r,n)=>{if(t?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=()=>{clearTimeout(o),n(new DOMException("Aborted","AbortError"))},o=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e);t?.addEventListener("abort",i,{once:!0})})}function uu(e,t){return new Promise((r,n)=>{if(e.signal?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=e.buildIframe(),o=e.timeoutMs??5e3;let s=!1,a=!1,c=!1,u=null,f=null,d=null,h=null,p=null;const m=()=>{u!==null&&(clearTimeout(u),u=null),f&&i.removeEventListener("load",f),d&&i.removeEventListener("error",d),h&&window.removeEventListener("message",h),p&&e.signal?.removeEventListener("abort",p)},v=()=>{m(),!s&&i.parentNode&&i.parentNode.removeChild(i)},b=()=>{a&&c&&!s&&(s=!0,m(),r(i))};if(f=()=>{a=!0,b()},d=()=>{v(),n(new oe("error",t+1))},h=_=>{_.source&&(_.source&&_.source!==i.contentWindow||Ot(_.origin,e.allowedOrigins)&&zt(_)&&_.data.type===Yc.READY&&(c=!0,b()))},p=()=>{v(),n(new DOMException("Aborted","AbortError"))},i.addEventListener("load",f),i.addEventListener("error",d),window.addEventListener("message",h),e.signal?.addEventListener("abort",p,{once:!0}),u=setTimeout(()=>{v(),n(new oe("timeout",t+1))},o),e.signal?.aborted){v(),n(new DOMException("Aborted","AbortError"));return}e.container.appendChild(i)})}async function lu(e){const t=e.backoffMs??au,r=t.length+1;for(let n=0;n<r;n++){e.onStateChange?.({kind:"loading",attempt:n});try{const i=await uu(e,n);return e.onStateChange?.({kind:"loaded",iframe:i}),i}catch(i){if(i instanceof DOMException&&i.name==="AbortError")throw i;const o=i instanceof oe?i.reason:"error";if(n===r-1)throw e.onStateChange?.({kind:"failed",reason:o,attempts:r}),ve(`Iframe load failed permanently after ${r} attempt(s) (reason: ${o})`),new oe(o,r);const s=t[n]??1e3;e.onStateChange?.({kind:"retrying",attempt:n+1,reason:o}),be(`Iframe load attempt ${n+1} ${o==="timeout"?"timed out":"errored"}, retrying in ${s}ms`),await cu(s,e.signal)}}throw new oe("error",r)}var fu="0.1.0",De="https://gamaro.io/app",du=[1e3,2e3,3e3,4e3],hu=.3,pu=0,mu={mobile:480,tablet:768},on={mobile:{width:"100vw",height:"100vh"},tablet:{width:"90vw",height:"80vh"},desktop:{width:"380px",height:"600px"}},gu=100,vu={position:"fixed",zIndex:"999999",border:"none",overflow:"hidden"},he=`${Q.slow}ms`,sn=`${Q.base}ms`,bu=[`width ${he} ${K.emphasized}`,`height ${he} ${K.emphasized}`,`border-radius ${he} ${K.emphasized}`,`box-shadow ${he} ${K.emphasized}`,`transform ${he} ${K.emphasized}`].join(", "),_u=[`opacity ${sn} ${K.standard}`,`background ${sn} ${K.standard}`].join(", ");function an(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var xe={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"}},yu={width:"100%",height:"100%",border:"none",backgroundColor:"transparent"},cn=class{get applicationId(){return this._applicationId}constructor(e){this.version=fu,this.iframe=null,this.container=null,this.skeletonButton=null,this.isOpen=!1,this.isReady=!1,this.isInitialized=!1,this.isDestroyed=!1,this.fetchAbortController=null,this.iframeLoadAbortController=null,this._applicationId="",this.pendingCommands=[],this.eventHandlers=new Map,this.cleanupListener=null,this.currentViewportMode="desktop",this.mobileMediaQuery=null,this.tabletMediaQuery=null,this.debounceTimer=null,this.viewportChangeHandler=null,this.originalConfig={...e},this.config={position:"bottom-right",open:!1,baseUrl:De,debug:!1,...e},this.instanceId=++pu,this.debugLog=mn(this.config.debug??!1),this.renderSkeleton(),this.resolveConfig()}renderSkeleton(){this.config.position!=="inline"&&(this.container=this.createContainer(),this.renderSkeletonInto(this.container),document.body.appendChild(this.container))}renderSkeletonInto(e){const t=document.createElement("button");return t.type="button",t.setAttribute("aria-label","Loading widget…"),t.style.cssText=["width: 100%","height: 100%","border: none","border-radius: 50%","background: #9ca3af","cursor: default","opacity: 0.6",`transition: ${an()?"none":_u}`].join(";"),e.appendChild(t),this.skeletonButton=t,t}setSkeletonStateUnavailable(){this.skeletonButton&&(this.skeletonButton.dataset.state="unavailable",this.skeletonButton.style.transition="none",this.skeletonButton.style.opacity="0.4",this.skeletonButton.style.cursor="not-allowed",this.skeletonButton.setAttribute("aria-label","Widget temporarily unavailable"))}resolveConfig(){const e=this.config.baseUrl??De;this.fetchAbortController=new AbortController;const t=r=>nn(this.config.apiKey,e,this.fetchAbortController?.signal).then(n=>this.applyServerConfig(n)).catch(n=>{const i=n instanceof X?n.code:"UNKNOWN_ERROR",o=n instanceof Error?n.message:"Unknown config fetch error";if(i==="ABORTED"||this.isDestroyed)return;const s=du[r];if(s!==void 0&&this.isTransientFetchError(i)){const a=s*(1+(Math.random()*2-1)*hu);return be(`Config fetch failed transiently (${i}), retrying in ${Math.round(a)}ms`),new Promise(c=>setTimeout(()=>{this.isDestroyed||c(t(r+1))},a))}ve(`Config fetch failed — widget stays in degraded mode: ${o}`),this.emit("error",{code:i,message:o})});t(0)}isTransientFetchError(e){return e==="NETWORK_ERROR"||e==="TIMEOUT"||e.startsWith("HTTP_5")}applyServerConfig(e){if(this.isDestroyed)return;this._applicationId=e.applicationId;const t=e.widget??{};this.config={...this.config,theme:{...e.theme??{},...t.theme??{},...this.originalConfig.theme??{}},position:this.originalConfig.position??t.position??this.config.position,language:this.originalConfig.language??t.language??this.config.language,showProfile:this.originalConfig.showProfile??t.showProfile??this.config.showProfile,open:this.originalConfig.open??t.open??this.config.open},this.init().then(()=>be(`Widget v${this.version} ready (app: ${e.applicationSlug})`))}flushPendingCommands(){const e=this.pendingCommands;this.pendingCommands=[],e.forEach(t=>t())}async init(){if(this.isDestroyed)return;this.container?.remove(),this.skeletonButton=null,this.container=this.createContainer();let e=null;this.config.position!=="inline"&&(e=this.renderSkeletonInto(this.container)),this.attachContainerToDom(),this.iframeLoadAbortController=new AbortController;let t;try{t=await lu({buildIframe:()=>this.createIframe(),container:this.container,allowedOrigins:[this.resolveReadyOrigin()],signal:this.iframeLoadAbortController.signal,onStateChange:r=>{r.kind==="failed"&&this.setSkeletonStateUnavailable()}})}catch(r){if(this.isDestroyed||r instanceof DOMException&&r.name==="AbortError")return;r instanceof oe?(this.emit("widget-unavailable",{reason:r.reason,attempts:r.attempts}),this.emit("error",{code:"IFRAME_UNAVAILABLE",message:`Iframe load failed after ${r.attempts} attempt(s): ${r.reason}`})):this.emit("error",{code:"IFRAME_UNAVAILABLE",message:r instanceof Error?r.message:String(r)});return}if(this.isDestroyed){t.remove();return}this.iframe=t,e?.remove(),this.skeletonButton=null,this.isReady=!0,this.sendConfig(),this.emit("ready",void 0),this.cleanupListener=bn({onMessage:r=>this.handleMessage(r),debug:this.config.debug,sourceWindow:this.iframe.contentWindow,allowedOrigins:[this.resolveReadyOrigin()]}),this.config.open&&(this.isOpen=!0,this.updateVisibility()),this.setupViewportListener(),this.isInitialized=!0,this.flushPendingCommands(),this.log("Widget initialized",this.config)}resolveReadyOrigin(){const e=this.config.baseUrl??De;try{return new URL(e).origin}catch{return e}}attachContainerToDom(){this.container&&(this.config.position==="inline"&&this.config.container?(typeof this.config.container=="string"?document.querySelector(this.config.container):this.config.container)?.appendChild(this.container):document.body.appendChild(this.container))}createContainer(){const e=document.createElement("div");if(e.id=`gamaro-widget-container-${this.instanceId}`,this.config.position==="inline")Object.assign(e.style,{position:"relative",width:"100%",height:"100%",border:"none",borderRadius:"16px",overflow:"hidden",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.1)"});else{Object.assign(e.style,vu);const t=xe[this.config.position??"bottom-right"];Object.assign(e.style,t),e.style.width="60px",e.style.height="60px",e.style.borderRadius="50%"}return e}createIframe(){const e=document.createElement("iframe");return e.id=`gamaro-widget-iframe-${this.instanceId}`,e.src=this.buildIframeUrl(),e.setAttribute("title","Gamaro Chat Widget"),e.setAttribute("allow","clipboard-write; geolocation"),Object.assign(e.style,yu),e}buildIframeUrl(){const e=this.config.baseUrl??De,t=new URL("/app/widget/embed",e);return this.config.theme&&t.searchParams.set("theme",_n(this.config.theme)),this.config.position==="inline"&&t.searchParams.set("mode","inline"),this.config.open&&t.searchParams.set("open","true"),this.config.showProfile&&t.searchParams.set("showProfile","true"),this.config.language&&t.searchParams.set("language",this.config.language),this.config.apiKey&&t.searchParams.set("apiKey",this.config.apiKey),t.searchParams.set("hostOrigin",window.location.origin),t.toString()}setupViewportListener(){if(this.config.position==="inline"||this.config.responsive?.enabled===!1)return;const e={...mu,...this.config.responsive?.breakpoints};this.mobileMediaQuery=window.matchMedia(`(max-width: ${e.mobile}px)`),this.tabletMediaQuery=window.matchMedia(`(max-width: ${e.tablet}px)`),this.viewportChangeHandler=()=>this.handleViewportChange(),this.mobileMediaQuery.addEventListener("change",this.viewportChangeHandler),this.tabletMediaQuery.addEventListener("change",this.viewportChangeHandler),this.currentViewportMode=this.getViewportMode(),this.log("Initial viewport mode:",this.currentViewportMode)}handleViewportChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{const e=this.getViewportMode();e!==this.currentViewportMode&&(this.currentViewportMode=e,this.log("Viewport changed:",e),this.isOpen&&this.updateContainerForViewport(e),this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:viewport",mode:e},this.resolveReadyOrigin()))},gu)}getViewportMode(){return this.mobileMediaQuery?.matches?"mobile":this.tabletMediaQuery?.matches?"tablet":"desktop"}applyContainerTransition(){this.container&&(this.container.style.transition=an()?"none":bu)}updateContainerForViewport(e){if(!this.container)return;this.applyContainerTransition();const t=on[e];if(e==="mobile")Object.assign(this.container.style,{width:t.width,height:t.height,inset:"0",bottom:"auto",right:"auto",left:"auto",borderRadius:"0",maxWidth:"none",transform:"none"});else if(e==="tablet"){const r=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:t.width,height:t.height,inset:"auto",maxWidth:"500px",borderRadius:"16px",left:"50%",right:"auto",transform:"translateX(-50%)",bottom:r.bottom??"20px"})}else{const r=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:t.width,height:t.height,inset:"auto",maxWidth:"none",borderRadius:"16px",transform:"none",...r})}}handleMessage(e){switch(this.log("Received event:",e),e.type){case"gamaro:ready":if(this.isReady)break;this.isReady=!0,this.sendConfig(),this.emit("ready",void 0);break;case"gamaro:profile-update":this.emit("profile-update",void 0);break;case"gamaro:message":this.emit("message",e.message);break;case"gamaro:qualified":this.emit("qualified",void 0);break;case"gamaro:error":this.emit("error",{code:e.code,message:e.message});break;case"gamaro:open":this.isOpen=!0,this.updateVisibility(),this.emit("open",void 0);break;case"gamaro:close":this.isOpen=!1,this.updateVisibility(),this.emit("close",void 0);break;case"gamaro:quota-warning":this.emit("quota-warning",{remaining:e.remaining,limit:e.limit});break;case"gamaro:quota-exceeded":this.emit("quota-exceeded",void 0);break;case"gamaro:identity-verified":this.emit("identity-verified",{email:e.email,userId:e.userId});break;case"gamaro:funnel-stage-change":this.emit("funnel-stage-change",{stage:e.stage,previousStage:e.previousStage});break;case"gamaro:cta-shown":case"gamaro:cta-clicked":{const{ctaType:t,objectiveId:r}=e;this.emit(e.type==="gamaro:cta-shown"?"cta-shown":"cta-clicked",{ctaType:t,...r&&{objectiveId:r}});break}case"gamaro:lead-captured":this.emit("lead-captured",{hasEmail:e.hasEmail,hasPhone:e.hasPhone})}}sendConfig(){if(!this.iframe||!this.isReady)return;const{container:e,...t}=this.config,r={type:"gamaro:init",config:t};G(this.iframe,r,this.resolveReadyOrigin())}updateVisibility(){if(this.container&&this.config.position!=="inline")if(this.applyContainerTransition(),this.isOpen){if(this.config.responsive?.enabled!==!1)this.updateContainerForViewport(this.currentViewportMode);else{const e=on.desktop;this.container.style.width=e.width,this.container.style.height=e.height,this.container.style.borderRadius="16px"}this.container.style.boxShadow="0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05)"}else{const e=xe[this.config.position??"bottom-right"];Object.assign(this.container.style,{width:"60px",height:"60px",borderRadius:"50%",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",inset:"auto",maxWidth:"none",transform:"none",...e})}}emit(e,t){const r=this.eventHandlers.get(e);r&&r.forEach(n=>{try{n(t)}catch(i){ve(`Error in event handler for "${e}":`,i)}})}open(){if(!this.isInitialized){this.pendingCommands.push(()=>this.open());return}this.iframe&&(this.isOpen=!0,this.updateVisibility(),this.isReady&&G(this.iframe,{type:"gamaro:open"},this.resolveReadyOrigin()))}close(){if(!this.isInitialized){this.pendingCommands.push(()=>this.close());return}this.iframe&&(this.isOpen=!1,this.updateVisibility(),this.isReady&&G(this.iframe,{type:"gamaro:close"},this.resolveReadyOrigin()))}reset(){if(!this.isInitialized){this.pendingCommands.push(()=>this.reset());return}!this.iframe||!this.isReady||G(this.iframe,{type:"gamaro:reset"},this.resolveReadyOrigin())}identify(e){if(this.config={...this.config,email:e.email,userId:e.userId,userHash:e.userHash},!this.isInitialized){this.pendingCommands.push(()=>this.identify(e));return}this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:identify",email:e.email,userId:e.userId,userHash:e.userHash},this.resolveReadyOrigin())}setTheme(e){if(this.config.theme={...this.config.theme,...e},!this.isInitialized){this.pendingCommands.push(()=>this.setTheme(e));return}this.iframe&&this.isReady&&G(this.iframe,{type:"gamaro:setTheme",theme:this.config.theme},this.resolveReadyOrigin())}setColorScheme(e){this.setTheme({colorScheme:e})}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){const r=this.eventHandlers.get(e);r&&r.delete(t)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.fetchAbortController?.abort(),this.fetchAbortController=null,this.iframeLoadAbortController?.abort(),this.iframeLoadAbortController=null,this.cleanupListener?.(),this.viewportChangeHandler&&(this.mobileMediaQuery?.removeEventListener("change",this.viewportChangeHandler),this.tabletMediaQuery?.removeEventListener("change",this.viewportChangeHandler),this.viewportChangeHandler=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.container?.remove(),this.iframe=null,this.container=null,this.skeletonButton=null,this.mobileMediaQuery=null,this.tabletMediaQuery=null,this.eventHandlers.clear(),this.pendingCommands=[])}log(e,...t){const r=t.map(n=>{if(n==null||typeof n!="object")return n;if(n instanceof HTMLElement)return`[HTMLElement: ${n.tagName}]`;try{const i=new WeakSet;return JSON.parse(JSON.stringify(n,(o,s)=>{if(s instanceof HTMLElement)return`[HTMLElement: ${s.tagName}]`;if(typeof s=="object"&&s!==null){if(i.has(s))return"[Circular]";i.add(s)}return s}))}catch{return"[Unserializable]"}});this.debugLog(e,...r)}};function un(e){return new cn(e)}var bt=new WeakSet;function ln(e){const t=e.getAttribute("data-api-key")??void 0;if(!t)return ve("Missing required data-api-key attribute on script tag"),null;const r=e.dataset.container,n=e.dataset.baseUrl,i=e.dataset.debug==="true",o=e.dataset.email,s=e.getAttribute("data-user-id")??void 0,a=e.getAttribute("data-user-hash")??void 0;return{apiKey:t,container:r,baseUrl:n,debug:i,...o&&{email:o},...s&&{userId:s},...a&&{userHash:a}}}function fn(){if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;const e=document.querySelectorAll("script[src]");for(const t of e){const r=t.src.toLowerCase();if(r.includes("gamaro")||r.includes("widget"))return t}return null}function _t(){const e=document.querySelectorAll("script[data-api-key]");if(e.length===0){const t=fn();t&&t.hasAttribute("data-api-key")&&!bt.has(t)&&dn(t);return}for(const t of e)dn(t)}function dn(e){if(bt.has(e))return;bt.add(e);const t=ln(e);if(!t)return;const r=un(t);window.Gamaro||(window.Gamaro=r),window.GamaroApps||(window.GamaroApps=new Map),r.on("ready",()=>{r.applicationId&&window.GamaroApps&&window.GamaroApps.set(r.applicationId,r)}),be(`Widget v${r.version} initializing...`)}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_t):_t()),I.ConfigFetchError=X,I.GamaroWidget=cn,I.__autoInit=_t,I.__getCurrentScript=fn,I.__parseScriptAttributes=ln,I.applicationConfigResponseSchema=tn,I.b2bProfileSchema=su,I.createWidget=un,I.fetchApplicationConfig=nn,I.themeConfigSchema=Me,I.widgetConfigSchema=Kc,I.widgetMessageSchema=qc,I.widgetPositionSchema=vt});