@gamaro.io/widget 0.6.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.
@@ -0,0 +1,39 @@
1
+ (function(k,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(k=typeof globalThis<"u"?globalThis:k||self,q(k.VersiqWidget={}))})(this,function(k){Object.defineProperty(k,Symbol.toStringTag,{value:"Module"});var q={instant:0,fast:150,base:250,slow:400,slower:600},M={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)"},ee="[Versiq]";function te(e,...t){console.error(ee,e,...t)}function Me(e,...t){console.warn(ee,e,...t)}function re(e,...t){console.info(ee,e,...t)}function ne(e,...t){console.debug(ee,e,...t)}function Qt(e){return e?ne:()=>{}}var Xt="versiq:",er=["https://gamaro.io"];function De(e,t){return t.includes(e)}function Le(e){const t=e.data;return typeof t=="object"&&t!==null&&typeof t.type=="string"&&t.type.startsWith(Xt)}function D(e,t,r){if(!e.contentWindow){Me("Cannot send command: iframe not ready");return}try{e.contentWindow.postMessage(t,r)}catch{Me("Failed to post message to iframe")}}function tr(e){const{allowedOrigins:t=er,onMessage:r,debug:n,sourceWindow:i}=e,a=o=>{if(!(i&&o.source&&o.source!==i)){if(!De(o.origin,t)){n&&ne("Ignored message from untrusted origin:",o.origin);return}if(Le(o)){if(n)try{ne("Received message:",JSON.parse(JSON.stringify(o.data)))}catch{ne("Received message:",o.data?.type??"[Unserializable]")}r(o.data,o.origin)}}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}}function rr(e){return btoa(JSON.stringify(e))}var ds=Object.freeze({status:"aborted"});function c(e,t,r){function n(s,u){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,u);const l=o.prototype,d=Object.keys(l);for(let p=0;p<d.length;p++){const h=d[p];h in s||(s[h]=l[h].bind(s))}}const i=r?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(s){var u;const l=r?.Parent?new a:this;n(l,s),(u=l._zod).deferred??(u.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var W=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ue=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},_e={};function L(e){return e&&Object.assign(_e,e),_e}function Fe(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 we(e,t){return typeof t=="bigint"?t.toString():t}function ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function ze(e){return e==null}function ke(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function nr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){const o=n.match(/\d?e-(\d?)/);o?.[1]&&(i=Number.parseInt(o[1]))}const a=r>i?r:i;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}var Ve=Symbol("evaluating");function g(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ve)return n===void 0&&(n=Ve,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function U(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function P(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function qe(e){return JSON.stringify(e)}function ir(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var We="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var or=ye(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function G(e){if(ie(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ie(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Je(e){return G(e)?{...e}:Array.isArray(e)?[...e]:e}var ar=new Set(["string","number","symbol"]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function f(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 sr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var cr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ur(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");return N(e,P(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=r.shape[a])}return U(this,"shape",i),i},checks:[]}))}function lr(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");return N(e,P(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return U(this,"shape",i),i},checks:[]}))}function dr(e,t){if(!G(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=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return N(e,P(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return U(this,"shape",n),n}}))}function fr(e,t){if(!G(t))throw new Error("Invalid input to safeExtend: expected a plain object");return N(e,P(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return U(this,"shape",r),r}}))}function hr(e,t){return N(e,P(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return U(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]}))}function pr(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return N(t,P(t._zod.def,{get shape(){const i=t._zod.def.shape,a={...i};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(a[o]=e?new e({type:"optional",innerType:i[o]}):i[o])}else for(const o in i)a[o]=e?new e({type:"optional",innerType:i[o]}):i[o];return U(this,"shape",a),a},checks:[]}))}function mr(e,t,r){return N(t,P(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(const a in n)i[a]=new e({type:"nonoptional",innerType:n[a]});return U(this,"shape",i),i}}))}function J(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 Be(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 F(e,t,r){const n={...e,path:e.path??[]};return e.message||(n.message=ae(e.inst?._zod.def?.error?.(e))??ae(t?.error?.(e))??ae(r.customError?.(e))??ae(r.localeError?.(e))??"Invalid input"),delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Ee(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function K(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var He=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,we,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ge=c("$ZodError",He),Ke=c("$ZodError",He,{Parent:Error});function gr(e,t=r=>r.message){const r={},n=[];for(const i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function vr(e,t=r=>r.message){const r={_errors:[]},n=i=>{for(const a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(o=>n({issues:o}));else if(a.code==="invalid_key")n({issues:a.issues});else if(a.code==="invalid_element")n({issues:a.issues});else if(a.path.length===0)r._errors.push(t(a));else{let o=r,s=0;for(;s<a.path.length;){const u=a.path[s];s!==a.path.length-1?o[u]=o[u]||{_errors:[]}:(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))),o=o[u],s++}}};return n(e),r}var Se=e=>(t,r,n,i)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new W;if(o.issues.length){const s=new(i?.Err??e)(o.issues.map(u=>F(u,a,L())));throw We(s,i?.callee),s}return o.value},$e=e=>async(t,r,n,i)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){const s=new(i?.Err??e)(o.issues.map(u=>F(u,a,L())));throw We(s,i?.callee),s}return o.value},se=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new W;return a.issues.length?{success:!1,error:new(e??Ge)(a.issues.map(o=>F(o,i,L())))}:{success:!0,data:a.value}},br=se(Ke),ce=e=>async(t,r,n)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(o=>F(o,i,L())))}:{success:!0,data:a.value}},_r=ce(Ke),wr=e=>(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Se(e)(t,r,i)},yr=e=>(t,r,n)=>Se(e)(t,r,n),zr=e=>async(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $e(e)(t,r,i)},kr=e=>async(t,r,n)=>$e(e)(t,r,n),Er=e=>(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return se(e)(t,r,i)},Sr=e=>(t,r,n)=>se(e)(t,r,n),$r=e=>async(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ce(e)(t,r,i)},Or=e=>async(t,r,n)=>ce(e)(t,r,n),Ir=/^[cC][^\s-]{8,}$/,Zr=/^[0-9a-z]+$/,Tr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ar=/^[0-9a-vA-V]{20}$/,Cr=/^[A-Za-z0-9]{27}$/,Pr=/^[a-zA-Z0-9_-]{21}$/,Nr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Rr=/^([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})$/,Ye=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)$/,xr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Mr(){return new RegExp(jr,"u")}var Dr=/^(?:(?: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])$/,Lr=/^(([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}|:))$/,Ur=/^((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])$/,Fr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qe=/^[A-Za-z0-9_-]*$/,qr=/^\+[1-9]\d{6,14}$/,Xe="(?:(?:\\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])))",Wr=new RegExp(`^${Xe}$`);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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Jr(e){return new RegExp(`^${et(e)}$`)}function Br(e){const t=et({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Xe}T(?:${n})$`)}var Hr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Gr=/^-?\d+$/,Kr=/^-?\d+(?:\.\d+)?$/,Yr=/^(?:true|false)$/i,Qr=/^[^A-Z]*$/,Xr=/^[^a-z]*$/,$=c("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tt={number:"number",bigint:"bigint",object:"date"},rt=c("$ZodCheckLessThan",(e,t)=>{$.init(e,t);const r=tt[typeof t.value];e._zod.onattach.push(n=>{const i=n._zod.bag,a=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin: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})}}),nt=c("$ZodCheckGreaterThan",(e,t)=>{$.init(e,t);const r=tt[typeof t.value];e._zod.onattach.push(n=>{const i=n._zod.bag,a=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin: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})}}),en=c("$ZodCheckMultipleOf",(e,t)=>{$.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),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"?r.value%t.value===BigInt(0):nr(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})}}),tn=c("$ZodCheckNumberFormat",(e,t)=>{$.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[i,a]=cr[t.format];e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,s.minimum=i,s.maximum=a,r&&(s.pattern=Gr)}),e._zod.check=o=>{const s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,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}):o.issues.push({input:s,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}}s<i&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),rn=c("$ZodCheckMaxLength",(e,t)=>{var r;$.init(e,t),(r=e._zod.def).when??(r.when=n=>{const i=n.value;return!ze(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{const i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const a=Ee(i);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),nn=c("$ZodCheckMinLength",(e,t)=>{var r;$.init(e,t),(r=e._zod.def).when??(r.when=n=>{const i=n.value;return!ze(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{const i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const a=Ee(i);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),on=c("$ZodCheckLengthEquals",(e,t)=>{var r;$.init(e,t),(r=e._zod.def).when??(r.when=n=>{const i=n.value;return!ze(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{const i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{const i=n.value,a=i.length;if(a===t.length)return;const o=Ee(i),s=a>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ue=c("$ZodCheckStringFormat",(e,t)=>{var r,n;$.init(e,t),e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),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=()=>{})}),an=c("$ZodCheckRegex",(e,t)=>{ue.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})}}),sn=c("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Qr),ue.init(e,t)}),cn=c("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Xr),ue.init(e,t)}),un=c("$ZodCheckIncludes",(e,t)=>{$.init(e,t);const r=oe(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{const a=i._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),ln=c("$ZodCheckStartsWith",(e,t)=>{$.init(e,t);const r=new RegExp(`^${oe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(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})}}),dn=c("$ZodCheckEndsWith",(e,t)=>{$.init(e,t);const r=new RegExp(`.*${oe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(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})}}),fn=c("$ZodCheckOverwrite",(e,t)=>{$.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),hn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
2
+ `).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?.args,r=[...(this?.content??[""]).map(n=>` ${n}`)];return new e(...t,r.join(`
3
+ `))}},pn={major:4,minor:3,patch:6},y=c("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const a of i._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(o,s,u)=>{let l=J(o),d;for(const p of s){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(l)continue;const h=o.issues.length,m=p._zod.check(o);if(m instanceof Promise&&u?.async===!1)throw new W;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,o.issues.length!==h&&(l||(l=J(o,h)))});else{if(o.issues.length===h)continue;l||(l=J(o,h))}}return d?d.then(()=>o):o},a=(o,s,u)=>{if(J(o))return o.aborted=!0,o;const l=i(s,n,u);if(l instanceof Promise){if(u.async===!1)throw new W;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if(s.direction==="backward"){const l=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>a(d,o,s)):a(l,o,s)}const u=e._zod.parse(o,s);if(u instanceof Promise){if(s.async===!1)throw new W;return u.then(l=>i(l,n,s))}return i(u,n,s)}}g(e,"~standard",()=>({validate:i=>{try{const a=br(e,i);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return _r(e,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),Oe=c("$ZodString",(e,t)=>{y.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Hr(e._zod.bag),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}}),b=c("$ZodStringFormat",(e,t)=>{ue.init(e,t),Oe.init(e,t)}),mn=c("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Rr),b.init(e,t)}),gn=c("$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=Ye(r))}else t.pattern??(t.pattern=Ye());b.init(e,t)}),vn=c("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xr),b.init(e,t)}),bn=c("$ZodURL",(e,t)=>{b.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),_n=c("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Mr()),b.init(e,t)}),wn=c("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Pr),b.init(e,t)}),yn=c("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ir),b.init(e,t)}),zn=c("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zr),b.init(e,t)}),kn=c("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Tr),b.init(e,t)}),En=c("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ar),b.init(e,t)}),Sn=c("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Cr),b.init(e,t)}),$n=c("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Br(t)),b.init(e,t)}),On=c("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Wr),b.init(e,t)}),In=c("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Jr(t)),b.init(e,t)}),Zn=c("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Nr),b.init(e,t)}),Tn=c("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Dr),b.init(e,t),e._zod.bag.format="ipv4"}),An=c("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Lr),b.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Cn=c("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ur),b.init(e,t)}),Pn=c("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Fr),b.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[i,a]=n;if(!a)throw new Error;const o=Number(a);if(`${o}`!==a)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function it(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Nn=c("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Vr),b.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{it(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Rn(e){if(!Qe.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return it(t.padEnd(Math.ceil(t.length/4)*4,"="))}var xn=c("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qe),b.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Rn(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),jn=c("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qr),b.init(e,t)});function Mn(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 Dn=c("$ZodJWT",(e,t)=>{b.init(e,t),e._zod.check=r=>{Mn(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ot=c("$ZodNumber",(e,t)=>{y.init(e,t),e._zod.pattern=e._zod.bag.pattern??Kr,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 a=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),r}}),Ln=c("$ZodNumberFormat",(e,t)=>{tn.init(e,t),ot.init(e,t)}),Un=c("$ZodBoolean",(e,t)=>{y.init(e,t),e._zod.pattern=Yr,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}}),Fn=c("$ZodUnknown",(e,t)=>{y.init(e,t),e._zod.parse=r=>r}),Vn=c("$ZodNever",(e,t)=>{y.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function at(e,t,r){e.issues.length&&t.issues.push(...Be(r,e.issues)),t.value[r]=e.value}var qn=c("$ZodArray",(e,t)=>{y.init(e,t),e._zod.parse=(r,n)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);const a=[];for(let o=0;o<i.length;o++){const s=i[o],u=t.element._zod.run({value:s,issues:[]},n);u instanceof Promise?a.push(u.then(l=>at(l,r,o))):at(u,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function le(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...Be(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function st(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=sr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ct(e,t,r,n,i,a){const o=[],s=i.keySet,u=i.catchall._zod,l=u.def.type,d=u.optout==="optional";for(const p in t){if(s.has(p))continue;if(l==="never"){o.push(p);continue}const h=u.run({value:t[p],issues:[]},n);h instanceof Promise?e.push(h.then(m=>le(m,r,p,t,d))):le(h,r,p,t,d)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var Wn=c("$ZodObject",(e,t)=>{if(y.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const s={...o};return Object.defineProperty(t,"shape",{value:s}),s}})}const r=ye(()=>st(t));g(e._zod,"propValues",()=>{const o=t.shape,s={};for(const u in o){const l=o[u]._zod;if(l.values){s[u]??(s[u]=new Set);for(const d of l.values)s[u].add(d)}}return s});const n=ie,i=t.catchall;let a;e._zod.parse=(o,s)=>{a??(a=r.value);const u=o.value;if(!n(u))return o.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),o;o.value={};const l=[],d=a.shape;for(const p of a.keys){const h=d[p],m=h._zod.optout==="optional",v=h._zod.run({value:u[p],issues:[]},s);v instanceof Promise?l.push(v.then(x=>le(x,o,p,u,m))):le(v,o,p,u,m)}return i?ct(l,u,o,s,r.value,e):l.length?Promise.all(l).then(()=>o):o}}),Jn=c("$ZodObjectJIT",(e,t)=>{Wn.init(e,t);const r=e._zod.parse,n=ye(()=>st(t)),i=h=>{const m=new hn(["shape","payload","ctx"]),v=n.value,x=C=>{const I=qe(C);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};m.write("const input = payload.value;");const X=Object.create(null);let j=0;for(const C of v.keys)X[C]=`key_${j++}`;m.write("const newResult = {};");for(const C of v.keys){const I=X[C],A=qe(C),ls=h[C]?._zod?.optout==="optional";m.write(`const ${I} = ${x(C)};`),ls?m.write(`
4
+ if (${I}.issues.length) {
5
+ if (${A} in input) {
6
+ payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${A}, ...iss.path] : [${A}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${I}.value === undefined) {
14
+ if (${A} in input) {
15
+ newResult[${A}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${A}] = ${I}.value;
19
+ }
20
+
21
+ `):m.write(`
22
+ if (${I}.issues.length) {
23
+ payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${A}, ...iss.path] : [${A}]
26
+ })));
27
+ }
28
+
29
+ if (${I}.value === undefined) {
30
+ if (${A} in input) {
31
+ newResult[${A}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${A}] = ${I}.value;
35
+ }
36
+
37
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");const us=m.compile();return(C,I)=>us(h,C,I)};let a;const o=ie,s=!_e.jitless,l=s&&or.value,d=t.catchall;let p;e._zod.parse=(h,m)=>{p??(p=n.value);const v=h.value;return o(v)?s&&l&&m?.async===!1&&m.jitless!==!0?(a||(a=i(t.shape)),h=a(h,m),d?ct([],v,h,m,p,e):h):r(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),h)}});function ut(e,t,r,n){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const i=e.filter(a=>!J(a));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(a=>a.issues.map(o=>F(o,n,L())))}),t)}var Bn=c("$ZodUnion",(e,t)=>{y.init(e,t),g(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),g(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),g(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),g(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${i.map(a=>ke(a.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(r)return n(i,a);let o=!1;const s=[];for(const u of t.options){const l=u._zod.run({value:i.value,issues:[]},a);if(l instanceof Promise)s.push(l),o=!0;else{if(l.issues.length===0)return l;s.push(l)}}return o?Promise.all(s).then(u=>ut(u,i,e,a)):ut(s,i,e,a)}}),Hn=c("$ZodIntersection",(e,t)=>{y.init(e,t),e._zod.parse=(r,n)=>{const i=r.value,a=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([s,u])=>lt(r,s,u)):lt(r,a,o)}});function Ie(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(G(e)&&G(t)){const r=Object.keys(t),n=Object.keys(e).filter(a=>r.indexOf(a)!==-1),i={...e,...t};for(const a of n){const o=Ie(e[a],t[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};i[a]=o.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],a=t[n],o=Ie(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function lt(e,t,r){const n=new Map;let i;for(const s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(const u of s.keys)n.has(u)||n.set(u,{}),n.get(u).l=!0}else e.issues.push(s);for(const s of r.issues)if(s.code==="unrecognized_keys")for(const u of s.keys)n.has(u)||n.set(u,{}),n.get(u).r=!0;else e.issues.push(s);const a=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(a.length&&i&&e.issues.push({...i,keys:a}),J(e))return e;const o=Ie(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gn=c("$ZodEnum",(e,t)=>{y.init(e,t);const r=Fe(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>ar.has(typeof i)).map(i=>typeof i=="string"?oe(i):i.toString()).join("|")})$`),e._zod.parse=(i,a)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:r,input:o,inst:e}),i}}),Kn=c("$ZodTransform",(e,t)=>{y.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ue(e.constructor.name);const i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(r.value=a,r));if(i instanceof Promise)throw new W;return r.value=i,r}});function dt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var ft=c("$ZodOptional",(e,t)=>{y.init(e,t),e._zod.optin="optional",e._zod.optout="optional",g(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),g(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ke(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>dt(a,r.value)):dt(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Yn=c("$ZodExactOptional",(e,t)=>{ft.init(e,t),g(e._zod,"values",()=>t.innerType._zod.values),g(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Qn=c("$ZodNullable",(e,t)=>{y.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ke(r.source)}|null)$`):void 0}),g(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Xn=c("$ZodDefault",(e,t)=>{y.init(e,t),e._zod.optin="optional",g(e._zod,"values",()=>t.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(a=>ht(a,t)):ht(i,t)}});function ht(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ei=c("$ZodPrefault",(e,t)=>{y.init(e,t),e._zod.optin="optional",g(e._zod,"values",()=>t.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))}),ti=c("$ZodNonOptional",(e,t)=>{y.init(e,t),g(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>pt(a,e)):pt(i,e)}});function pt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var ri=c("$ZodCatch",(e,t)=>{y.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(e._zod,"values",()=>t.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(r,n);return i instanceof Promise?i.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(o=>F(o,n,L()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>F(a,n,L()))},input:r.value}),r.issues=[]),r)}}),ni=c("$ZodPipe",(e,t)=>{y.init(e,t),g(e._zod,"values",()=>t.in._zod.values),g(e._zod,"optin",()=>t.in._zod.optin),g(e._zod,"optout",()=>t.out._zod.optout),g(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const a=t.out._zod.run(r,n);return a instanceof Promise?a.then(o=>de(o,t.in,n)):de(a,t.in,n)}const i=t.in._zod.run(r,n);return i instanceof Promise?i.then(a=>de(a,t.out,n)):de(i,t.out,n)}});function de(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var ii=c("$ZodReadonly",(e,t)=>{y.init(e,t),g(e._zod,"propValues",()=>t.innerType._zod.propValues),g(e._zod,"values",()=>t.innerType._zod.values),g(e._zod,"optin",()=>t.innerType?._zod?.optin),g(e._zod,"optout",()=>t.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(mt):mt(i)}});function mt(e){return e.value=Object.freeze(e.value),e}var oi=c("$ZodCustom",(e,t)=>{$.init(e,t),y.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(a=>gt(a,r,n,e));gt(i,r,n,e)}});function gt(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(K(i))}}var vt,ai=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 si(){return new ai}(vt=globalThis).__zod_globalRegistry??(vt.__zod_globalRegistry=si());var Y=globalThis.__zod_globalRegistry;function ci(e,t){return new e({type:"string",...f(t)})}function ui(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...f(t)})}function bt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...f(t)})}function li(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...f(t)})}function di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...f(t)})}function fi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...f(t)})}function hi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...f(t)})}function pi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...f(t)})}function mi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...f(t)})}function gi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...f(t)})}function vi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...f(t)})}function bi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...f(t)})}function _i(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...f(t)})}function wi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...f(t)})}function yi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...f(t)})}function zi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...f(t)})}function ki(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...f(t)})}function Ei(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...f(t)})}function Si(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...f(t)})}function $i(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...f(t)})}function Oi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...f(t)})}function Ii(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...f(t)})}function Zi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...f(t)})}function Ti(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...f(t)})}function Ai(e,t){return new e({type:"string",format:"date",check:"string_format",...f(t)})}function Ci(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...f(t)})}function Pi(e,t){return new e({type:"string",format:"duration",check:"string_format",...f(t)})}function Ni(e,t){return new e({type:"number",checks:[],...f(t)})}function Ri(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...f(t)})}function xi(e,t){return new e({type:"boolean",...f(t)})}function ji(e){return new e({type:"unknown"})}function Mi(e,t){return new e({type:"never",...f(t)})}function _t(e,t){return new rt({check:"less_than",...f(t),value:e,inclusive:!1})}function Ze(e,t){return new rt({check:"less_than",...f(t),value:e,inclusive:!0})}function wt(e,t){return new nt({check:"greater_than",...f(t),value:e,inclusive:!1})}function Te(e,t){return new nt({check:"greater_than",...f(t),value:e,inclusive:!0})}function yt(e,t){return new en({check:"multiple_of",...f(t),value:e})}function zt(e,t){return new rn({check:"max_length",...f(t),maximum:e})}function fe(e,t){return new nn({check:"min_length",...f(t),minimum:e})}function kt(e,t){return new on({check:"length_equals",...f(t),length:e})}function Di(e,t){return new an({check:"string_format",format:"regex",...f(t),pattern:e})}function Li(e){return new sn({check:"string_format",format:"lowercase",...f(e)})}function Ui(e){return new cn({check:"string_format",format:"uppercase",...f(e)})}function Fi(e,t){return new un({check:"string_format",format:"includes",...f(t),includes:e})}function Vi(e,t){return new ln({check:"string_format",format:"starts_with",...f(t),prefix:e})}function qi(e,t){return new dn({check:"string_format",format:"ends_with",...f(t),suffix:e})}function B(e){return new fn({check:"overwrite",tx:e})}function Wi(e){return B(t=>t.normalize(e))}function Ji(){return B(e=>e.trim())}function Bi(){return B(e=>e.toLowerCase())}function Hi(){return B(e=>e.toUpperCase())}function Gi(){return B(e=>ir(e))}function Ki(e,t,r){return new e({type:"array",element:t,...f(r)})}function Yi(e,t,r){const n=f(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Qi(e,t,r){return new e({type:"custom",check:"custom",fn:t,...f(r)})}function Xi(e){const t=eo(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(K(n,r.value,t._zod.def));else{const i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(K(i))}},e(r.value,r)));return t}function eo(e,t){const r=new $({check:"custom",...f(t)});return r._zod.check=e,r}function Et(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??Y,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function E(e,t,r={path:[],schemaPath:[]}){var n;const i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{const l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,l);else{const p=o.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,p,l)}const d=e._zod.parent;d&&(o.ref||(o.ref=d),E(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(o.schema,u),t.io==="input"&&S(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function St(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const o of e.seen.entries()){const s=e.metadataRegistry.get(o[0])?.id;if(s){const u=n.get(s);if(u&&u!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,o[0])}}const i=o=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(o[0])?.id,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};const h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${p("__shared")}#/${s}/${h}`}}if(o[1]===r)return{ref:"#"};const u=`#/${s}/`,l=o[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},a=o=>{if(o[1].schema.$ref)return;const s=o[1],{ref:u,defId:l}=i(o);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const p in d)delete d[p];d.$ref=u};if(e.cycles==="throw")for(const o of e.seen.entries()){const s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
38
+
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of e.seen.entries()){const s=o[1];if(t===o[0]){a(o);continue}if(e.external){const u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function $t(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=o=>{const s=e.seen.get(o);if(s.ref===null)return;const u=s.def??s.schema,l={...u},d=s.ref;if(s.ref=null,d){n(d);const h=e.seen.get(d),m=h.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)):Object.assign(u,m),Object.assign(u,l),o._zod.parent===d)for(const v in u)v==="$ref"||v==="allOf"||v in l||delete u[v];if(m.$ref&&h.def)for(const v in u)v==="$ref"||v==="allOf"||v in h.def&&JSON.stringify(u[v])===JSON.stringify(h.def[v])&&delete u[v]}const p=o._zod.parent;if(p&&p!==d){n(p);const h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:o,jsonSchema:u,path:s.path??[]})};for(const o of[...e.seen.entries()].reverse())n(o[0]);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 o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(o)}Object.assign(i,r.def??r.schema);const a=e.external?.defs??{};for(const o of e.seen.entries()){const s=o[1];s.def&&s.defId&&(a[s.defId]=s.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?i.$defs=a:i.definitions=a);try{const o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:he(t,"input",e.processors),output:he(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function S(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 S(n.element,r);if(n.type==="set")return S(n.valueType,r);if(n.type==="lazy")return S(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")return S(n.innerType,r);if(n.type==="intersection")return S(n.left,r)||S(n.right,r);if(n.type==="record"||n.type==="map")return S(n.keyType,r)||S(n.valueType,r);if(n.type==="pipe")return S(n.in,r)||S(n.out,r);if(n.type==="object"){for(const i in n.shape)if(S(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(const i of n.options)if(S(i,r))return!0;return!1}if(n.type==="tuple"){for(const i of n.items)if(S(i,r))return!0;return!!(n.rest&&S(n.rest,r))}return!1}var to=(e,t={})=>r=>{const n=Et({...r,processors:t});return E(e,n),St(n,e),$t(n,e)},he=(e,t,r={})=>n=>{const{libraryOptions:i,target:a}=n??{},o=Et({...i??{},target:a,io:t,processors:r});return E(e,o),St(o,e),$t(o,e)},ro={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},no=(e,t,r,n)=>{const i=r;i.type="string";const{minimum:a,maximum:o,format:s,patterns:u,contentEncoding:l}=e._zod.bag;if(typeof a=="number"&&(i.minLength=a),typeof o=="number"&&(i.maxLength=o),s&&(i.format=ro[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),l&&(i.contentEncoding=l),u&&u.size>0){const d=[...u];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},io=(e,t,r,n)=>{const i=r,{minimum:a,maximum:o,format:s,multipleOf:u,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof a=="number"&&(i.minimum=a,typeof d=="number"&&t.target!=="draft-04"&&(d>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o=="number"&&(i.maximum=o,typeof l=="number"&&t.target!=="draft-04"&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof u=="number"&&(i.multipleOf=u)},oo=(e,t,r,n)=>{r.type="boolean"},ao=(e,t,r,n)=>{r.not={}},so=(e,t,r,n)=>{},co=(e,t,r,n)=>{const i=e._zod.def,a=Fe(i.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},uo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},fo=(e,t,r,n)=>{const i=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=E(a.element,t,{...n,path:[...n.path,"items"]})},ho=(e,t,r,n)=>{const i=r,a=e._zod.def;i.type="object",i.properties={};const o=a.shape;for(const l in o)i.properties[l]=E(o[l],t,{...n,path:[...n.path,"properties",l]});const s=new Set(Object.keys(o)),u=new Set([...s].filter(l=>{const d=a.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));u.size>0&&(i.required=Array.from(u)),a.catchall?._zod.def.type==="never"?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=E(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},po=(e,t,r,n)=>{const i=e._zod.def,a=i.inclusive===!1,o=i.options.map((s,u)=>E(s,t,{...n,path:[...n.path,a?"oneOf":"anyOf",u]}));a?r.oneOf=o:r.anyOf=o},mo=(e,t,r,n)=>{const i=e._zod.def,a=E(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=E(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1;r.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},go=(e,t,r,n)=>{const i=e._zod.def,a=E(i.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},vo=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType},bo=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},_o=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},wo=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},yo=(e,t,r,n)=>{const i=e._zod.def,a=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;E(a,t,n);const o=t.seen.get(e);o.ref=a},zo=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType,r.readOnly=!0},Ot=(e,t,r,n)=>{const i=e._zod.def;E(i.innerType,t,n);const a=t.seen.get(e);a.ref=i.innerType},ko=c("ZodISODateTime",(e,t)=>{$n.init(e,t),w.init(e,t)});function Eo(e){return Ti(ko,e)}var So=c("ZodISODate",(e,t)=>{On.init(e,t),w.init(e,t)});function $o(e){return Ai(So,e)}var Oo=c("ZodISOTime",(e,t)=>{In.init(e,t),w.init(e,t)});function Io(e){return Ci(Oo,e)}var Zo=c("ZodISODuration",(e,t)=>{Zn.init(e,t),w.init(e,t)});function To(e){return Pi(Zo,e)}var It=(e,t)=>{Ge.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>vr(e,r)},flatten:{value:r=>gr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,we,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,we,2)}},isEmpty:{get(){return e.issues.length===0}}})},fs=c("ZodError",It),Z=c("ZodError",It,{Parent:Error}),Ao=Se(Z),Co=$e(Z),Po=se(Z),No=ce(Z),Ro=wr(Z),xo=yr(Z),jo=zr(Z),Mo=kr(Z),Do=Er(Z),Lo=Sr(Z),Uo=$r(Z),Fo=Or(Z),z=c("ZodType",(e,t)=>(y.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:he(e,"input"),output:he(e,"output")}}),e.toJSONSchema=to(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(P(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>N(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Ao(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Po(e,r,n),e.parseAsync=async(r,n)=>Co(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>No(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Ro(e,r,n),e.decode=(r,n)=>xo(e,r,n),e.encodeAsync=async(r,n)=>jo(e,r,n),e.decodeAsync=async(r,n)=>Mo(e,r,n),e.safeEncode=(r,n)=>Do(e,r,n),e.safeDecode=(r,n)=>Lo(e,r,n),e.safeEncodeAsync=async(r,n)=>Uo(e,r,n),e.safeDecodeAsync=async(r,n)=>Fo(e,r,n),e.refine=(r,n)=>e.check(Pa(r,n)),e.superRefine=r=>e.check(Na(r)),e.overwrite=r=>e.check(B(r)),e.optional=()=>xt(e),e.exactOptional=()=>wa(e),e.nullable=()=>jt(e),e.nullish=()=>xt(jt(e)),e.nonoptional=r=>$a(e,r),e.array=()=>Ae(e),e.or=r=>Nt([e,r]),e.and=r=>ga(e,r),e.transform=r=>Dt(e,ba(r)),e.default=r=>ka(e,r),e.prefault=r=>Sa(e,r),e.catch=r=>Ia(e,r),e.pipe=r=>Dt(e,r),e.readonly=()=>Aa(e),e.describe=r=>{const n=e.clone();return Y.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Y.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Y.get(e);const n=e.clone();return Y.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),Zt=c("_ZodString",(e,t)=>{Oe.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,i,a)=>no(e,n,i,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Di(...n)),e.includes=(...n)=>e.check(Fi(...n)),e.startsWith=(...n)=>e.check(Vi(...n)),e.endsWith=(...n)=>e.check(qi(...n)),e.min=(...n)=>e.check(fe(...n)),e.max=(...n)=>e.check(zt(...n)),e.length=(...n)=>e.check(kt(...n)),e.nonempty=(...n)=>e.check(fe(1,...n)),e.lowercase=n=>e.check(Li(n)),e.uppercase=n=>e.check(Ui(n)),e.trim=()=>e.check(Ji()),e.normalize=(...n)=>e.check(Wi(...n)),e.toLowerCase=()=>e.check(Bi()),e.toUpperCase=()=>e.check(Hi()),e.slugify=()=>e.check(Gi())}),Vo=c("ZodString",(e,t)=>{Oe.init(e,t),Zt.init(e,t),e.email=r=>e.check(ui(qo,r)),e.url=r=>e.check(pi(Wo,r)),e.jwt=r=>e.check(Zi(aa,r)),e.emoji=r=>e.check(mi(Jo,r)),e.guid=r=>e.check(bt(Tt,r)),e.uuid=r=>e.check(li(pe,r)),e.uuidv4=r=>e.check(di(pe,r)),e.uuidv6=r=>e.check(fi(pe,r)),e.uuidv7=r=>e.check(hi(pe,r)),e.nanoid=r=>e.check(gi(Bo,r)),e.guid=r=>e.check(bt(Tt,r)),e.cuid=r=>e.check(vi(Ho,r)),e.cuid2=r=>e.check(bi(Go,r)),e.ulid=r=>e.check(_i(Ko,r)),e.base64=r=>e.check($i(na,r)),e.base64url=r=>e.check(Oi(ia,r)),e.xid=r=>e.check(wi(Yo,r)),e.ksuid=r=>e.check(yi(Qo,r)),e.ipv4=r=>e.check(zi(Xo,r)),e.ipv6=r=>e.check(ki(ea,r)),e.cidrv4=r=>e.check(Ei(ta,r)),e.cidrv6=r=>e.check(Si(ra,r)),e.e164=r=>e.check(Ii(oa,r)),e.datetime=r=>e.check(Eo(r)),e.date=r=>e.check($o(r)),e.time=r=>e.check(Io(r)),e.duration=r=>e.check(To(r))});function _(e){return ci(Vo,e)}var w=c("ZodStringFormat",(e,t)=>{b.init(e,t),Zt.init(e,t)}),qo=c("ZodEmail",(e,t)=>{vn.init(e,t),w.init(e,t)}),Tt=c("ZodGUID",(e,t)=>{mn.init(e,t),w.init(e,t)}),pe=c("ZodUUID",(e,t)=>{gn.init(e,t),w.init(e,t)}),Wo=c("ZodURL",(e,t)=>{bn.init(e,t),w.init(e,t)}),Jo=c("ZodEmoji",(e,t)=>{_n.init(e,t),w.init(e,t)}),Bo=c("ZodNanoID",(e,t)=>{wn.init(e,t),w.init(e,t)}),Ho=c("ZodCUID",(e,t)=>{yn.init(e,t),w.init(e,t)}),Go=c("ZodCUID2",(e,t)=>{zn.init(e,t),w.init(e,t)}),Ko=c("ZodULID",(e,t)=>{kn.init(e,t),w.init(e,t)}),Yo=c("ZodXID",(e,t)=>{En.init(e,t),w.init(e,t)}),Qo=c("ZodKSUID",(e,t)=>{Sn.init(e,t),w.init(e,t)}),Xo=c("ZodIPv4",(e,t)=>{Tn.init(e,t),w.init(e,t)}),ea=c("ZodIPv6",(e,t)=>{An.init(e,t),w.init(e,t)}),ta=c("ZodCIDRv4",(e,t)=>{Cn.init(e,t),w.init(e,t)}),ra=c("ZodCIDRv6",(e,t)=>{Pn.init(e,t),w.init(e,t)}),na=c("ZodBase64",(e,t)=>{Nn.init(e,t),w.init(e,t)}),ia=c("ZodBase64URL",(e,t)=>{xn.init(e,t),w.init(e,t)}),oa=c("ZodE164",(e,t)=>{jn.init(e,t),w.init(e,t)}),aa=c("ZodJWT",(e,t)=>{Dn.init(e,t),w.init(e,t)}),At=c("ZodNumber",(e,t)=>{ot.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,i,a)=>io(e,n,i,a),e.gt=(n,i)=>e.check(wt(n,i)),e.gte=(n,i)=>e.check(Te(n,i)),e.min=(n,i)=>e.check(Te(n,i)),e.lt=(n,i)=>e.check(_t(n,i)),e.lte=(n,i)=>e.check(Ze(n,i)),e.max=(n,i)=>e.check(Ze(n,i)),e.int=n=>e.check(Ct(n)),e.safe=n=>e.check(Ct(n)),e.positive=n=>e.check(wt(0,n)),e.nonnegative=n=>e.check(Te(0,n)),e.negative=n=>e.check(_t(0,n)),e.nonpositive=n=>e.check(Ze(0,n)),e.multipleOf=(n,i)=>e.check(yt(n,i)),e.step=(n,i)=>e.check(yt(n,i)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function me(e){return Ni(At,e)}var sa=c("ZodNumberFormat",(e,t)=>{Ln.init(e,t),At.init(e,t)});function Ct(e){return Ri(sa,e)}var ca=c("ZodBoolean",(e,t)=>{Un.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>oo(e,r,n,i)});function R(e){return xi(ca,e)}var ua=c("ZodUnknown",(e,t)=>{Fn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>so(e,r,n,i)});function Pt(){return ji(ua)}var la=c("ZodNever",(e,t)=>{Vn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ao(e,r,n,i)});function da(e){return Mi(la,e)}var fa=c("ZodArray",(e,t)=>{qn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fo(e,r,n,i),e.element=t.element,e.min=(r,n)=>e.check(fe(r,n)),e.nonempty=r=>e.check(fe(1,r)),e.max=(r,n)=>e.check(zt(r,n)),e.length=(r,n)=>e.check(kt(r,n)),e.unwrap=()=>e.element});function Ae(e,t){return Ki(fa,e,t)}var ha=c("ZodObject",(e,t)=>{Jn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ho(e,r,n,i),g(e,"shape",()=>t.shape),e.keyof=()=>O(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pt()}),e.strict=()=>e.clone({...e._zod.def,catchall:da()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>dr(e,r),e.safeExtend=r=>fr(e,r),e.merge=r=>hr(e,r),e.pick=r=>ur(e,r),e.omit=r=>lr(e,r),e.partial=(...r)=>pr(Rt,e,r[0]),e.required=(...r)=>mr(Mt,e,r[0])});function T(e,t){const r={type:"object",shape:e??{},...f(t)};return new ha(r)}var pa=c("ZodUnion",(e,t)=>{Bn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>po(e,r,n,i),e.options=t.options});function Nt(e,t){return new pa({type:"union",options:e,...f(t)})}var ma=c("ZodIntersection",(e,t)=>{Hn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mo(e,r,n,i)});function ga(e,t){return new ma({type:"intersection",left:e,right:t})}var Ce=c("ZodEnum",(e,t)=>{Gn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,i,a)=>co(e,n,i,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{const a={};for(const o of n)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ce({...t,checks:[],...f(i),entries:a})},e.exclude=(n,i)=>{const a={...t.entries};for(const o of n)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new Ce({...t,checks:[],...f(i),entries:a})}});function O(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ce({type:"enum",entries:r,...f(t)})}var va=c("ZodTransform",(e,t)=>{Kn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lo(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ue(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(K(a,r.value,t));else{const o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(K(o))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then(a=>(r.value=a,r)):(r.value=i,r)}});function ba(e){return new va({type:"transform",transform:e})}var Rt=c("ZodOptional",(e,t)=>{ft.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ot(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function xt(e){return new Rt({type:"optional",innerType:e})}var _a=c("ZodExactOptional",(e,t)=>{Yn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ot(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function wa(e){return new _a({type:"optional",innerType:e})}var ya=c("ZodNullable",(e,t)=>{Qn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>go(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function jt(e){return new ya({type:"nullable",innerType:e})}var za=c("ZodDefault",(e,t)=>{Xn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ka(e,t){return new za({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Je(t)}})}var Ea=c("ZodPrefault",(e,t)=>{ei.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_o(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Sa(e,t){return new Ea({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Je(t)}})}var Mt=c("ZodNonOptional",(e,t)=>{ti.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function $a(e,t){return new Mt({type:"nonoptional",innerType:e,...f(t)})}var Oa=c("ZodCatch",(e,t)=>{ri.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ia(e,t){return new Oa({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Za=c("ZodPipe",(e,t)=>{ni.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yo(e,r,n,i),e.in=t.in,e.out=t.out});function Dt(e,t){return new Za({type:"pipe",in:e,out:t})}var Ta=c("ZodReadonly",(e,t)=>{ii.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>zo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Aa(e){return new Ta({type:"readonly",innerType:e})}var Lt=c("ZodCustom",(e,t)=>{oi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uo(e,r,n,i)});function Ca(e,t){return Yi(Lt,e??(()=>!0),t)}function Pa(e,t={}){return Qi(Lt,e,t)}function Na(e){return Xi(e)}var Pe=/^#[0-9a-fA-F]{6}$/,Ne="Color must be a 6-digit hex code (e.g. '#3B82F6'). Short hex, rgb(), and named colors are not supported.",ge=T({primaryColor:_().max(20).regex(Pe,Ne).describe("Primary brand color (hex format, e.g., '#3B82F6')").optional(),backgroundColor:_().max(20).regex(Pe,Ne).describe("Background color for the widget container").optional(),textColor:_().max(20).regex(Pe,Ne).describe("Text color").optional(),borderRadius:me().describe("Border radius in pixels").optional(),fontFamily:_().max(100).describe("Font family").optional(),colorScheme:O(["light","dark","auto"]).describe("Widget color scheme: 'light' (default), 'dark', or 'auto' (follows the visitor's prefers-color-scheme).").optional()}),hs=O(["mobile","tablet","desktop"]).describe("Viewport mode: mobile (<480px), tablet (480-768px), desktop (>768px)"),Re=O(["bottom-right","bottom-left","inline"]).describe("Widget position on the page"),Ra=T({mobile:me().min(0).max(1e3).describe("Max width for mobile viewport (default: 480)").optional(),tablet:me().min(0).max(2e3).describe("Max width for tablet viewport (default: 768)").optional()}),xa=T({enabled:R().describe("Enable responsive behavior (default: true)").optional(),breakpoints:Ra.describe("Custom breakpoint values").optional()}),ja=T({theme:ge.describe("Custom theme configuration").optional(),position:Re.describe("Widget position (default: 'bottom-right')").optional(),open:R().describe("Initial open state (default: false)").optional(),container:Nt([Ca(e=>e instanceof HTMLElement),_().max(200)]).describe("Container element for inline mode").optional(),baseUrl:_().url().max(200).describe("Base URL for the widget embed (default: production URL)").optional(),debug:R().describe("Enable debug logging").optional(),responsive:xa.describe("Responsive behavior configuration").optional(),showProfile:R().describe("Show profile panel in widget header (default: false)").optional(),language:_().max(10).describe("Language for UI labels (e.g., 'fr', 'en'). Defaults to browser language.").optional(),apiKey:_().max(100).describe("Publishable API key (pk_*) for application authentication"),email:_().email().max(255).describe("Pre-identified user email (host-attested identity)").optional(),userId:_().max(255).describe("Host-side unique user identifier").optional(),userHash:_().max(128).describe("HMAC-SHA256 of email (or userId), signed with identity secret").optional()}),Ma=T({theme:ge.describe("Full visual theme palette applied by the widget. Admin-configured, no client-side override.").optional(),position:Re.describe("Default launcher position. `inline` only applies when integrator supplies `data-container`.").optional(),language:_().max(10).describe("Locale forced for widget UI labels (ISO 639-1). Falls back to browser language when null.").optional(),showProfile:R().describe("Whether the widget header exposes the profile panel to end-users.").optional(),open:R().describe("Default open state on load. Host can still call `window.Versiq.open()` programmatically.").optional(),brand:T({title:_().max(60).describe("Custom widget header title. Falls back to a vertical-specific default (e.g. 'Versiq Chat' for B2B) when unset.").optional(),avatarUrl:_().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(),Ut=T({applicationId:_().uuid().describe("Application UUID"),applicationSlug:_().max(100).describe("Application slug (kebab-case)"),applicationName:_().max(200).describe("Application display name"),vertical:_().max(50).describe("Vertical resolved from Application config"),theme:ge.nullable().describe("Application theme"),allowedOrigins:Ae(_().max(200)).max(50).describe("Allowed origins for this application"),monitoring:R().describe("Monitoring enabled flag"),primaryObjective:T({id:_().uuid(),type:_(),label:_(),ctaLabel:_().nullable()}).nullable().describe("Primary conversion objective"),identityVerificationRequired:R().describe("Whether HMAC identity verification is required"),widget:Ma.nullable().describe("Admin-configured widget runtime config (theme, position, language, showProfile, open). Null when the application has not yet persisted a widget_config JSONB.")}),Da=O(["user","assistant"]).describe("Message sender role"),La=T({role:Da.describe("Message sender role"),content:_().max(1e4).describe("Message content (max 10000 characters)")}),Ua={INIT:"versiq:init",OPEN:"versiq:open",CLOSE:"versiq:close",RESET:"versiq:reset",SET_THEME:"versiq:setTheme",VIEWPORT:"versiq:viewport",IDENTIFY:"versiq:identify",READY:"versiq:ready",PROFILE_UPDATE:"versiq:profile-update",MESSAGE:"versiq:message",QUALIFIED:"versiq:qualified",ERROR:"versiq:error",QUOTA_WARNING:"versiq:quota-warning",QUOTA_EXCEEDED:"versiq:quota-exceeded",FUNNEL_STAGE_CHANGE:"versiq:funnel-stage-change",CTA_SHOWN:"versiq:cta-shown",CTA_CLICKED:"versiq:cta-clicked",LEAD_CAPTURED:"versiq:lead-captured",IDENTITY_VERIFIED:"versiq:identity-verified"},ps=T({reason:O(["timeout","error"]).describe("Why the iframe load failed (timeout vs. transport error)"),attempts:me().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)"),Fa=O(["prospect","partner","unknown"]).describe("Type of user"),Va=O(["ecommerce","real-estate","automotive","travel","recruitment","other"]).describe("Business sector"),qa=O(["startup","pme","eti","grand-groupe"]).describe("Company size category"),Wa=O(["< 10k","10k-50k","50k-200k","> 200k"]).describe("Monthly website traffic"),Ja=O(["lead-qualification","personalization","cart-abandonment","conversion","other"]).describe("Business objective"),Ba=O(["shopify","woocommerce","prestashop","custom","none"]).describe("E-commerce platform"),Ha=O(["immediate","1-month","3-months","exploring"]).describe("Implementation timeline"),Ga=O(["< 500","500-2000","2000-5000","> 5000"]).describe("Monthly budget range in EUR"),Ka=T({userType:Fa.optional().describe("User type: prospect, partner, or unknown"),sector:Va.optional().describe("Business sector"),companySize:qa.optional().describe("Company size range"),monthlyTraffic:Wa.optional().describe("Monthly website traffic"),objectives:Ae(Ja).max(5).describe("List of business objectives (max 5)").optional(),platform:Ba.optional().describe("E-commerce platform"),timeline:Ha.optional().describe("Project timeline"),budgetRange:Ga.optional().describe("Monthly budget range")}),V=class extends Error{constructor(e,t){super(e),this.code=t,this.name="ConfigFetchError"}},Ft=1e4;async function Vt(e,t,r){const n=t.endsWith("/")?t:`${t}/`,i=new URL("api/application/config",n),a=new AbortController,o=setTimeout(()=>a.abort(),Ft),s=r?AbortSignal.any([a.signal,r]):a.signal;let u;try{u=await fetch(i.toString(),{signal:s,headers:{"x-versiq-key":e}})}catch(p){throw clearTimeout(o),r?.aborted?new V("Config fetch aborted by caller","ABORTED"):p instanceof DOMException&&p.name==="AbortError"?new V(`Config fetch timed out after ${Ft}ms`,"TIMEOUT"):new V(`Network error fetching application config: ${p instanceof Error?p.message:String(p)}`,"NETWORK_ERROR")}if(clearTimeout(o),!u.ok){const p=await u.text().catch(()=>"");throw new V(`HTTP ${u.status} fetching application config: ${p}`,`HTTP_${u.status}`)}const l=await u.json(),d=Ut.safeParse(l);if(!d.success)throw new V(`Invalid application config response: ${d.error.message}`,"PARSE_ERROR");return d.data}var ms=5e3,Ya=[1e3,3e3],H=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 Qa(e,t){return new Promise((r,n)=>{if(t?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=()=>{clearTimeout(a),n(new DOMException("Aborted","AbortError"))},a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e);t?.addEventListener("abort",i,{once:!0})})}function Xa(e,t){return new Promise((r,n)=>{if(e.signal?.aborted){n(new DOMException("Aborted","AbortError"));return}const i=e.buildIframe(),a=e.timeoutMs??5e3;let o=!1,s=!1,u=!1,l=null,d=null,p=null,h=null,m=null;const v=()=>{l!==null&&(clearTimeout(l),l=null),d&&i.removeEventListener("load",d),p&&i.removeEventListener("error",p),h&&window.removeEventListener("message",h),m&&e.signal?.removeEventListener("abort",m)},x=()=>{v(),!o&&i.parentNode&&i.parentNode.removeChild(i)},X=()=>{s&&u&&!o&&(o=!0,v(),r(i))};if(d=()=>{s=!0,X()},p=()=>{x(),n(new H("error",t+1))},h=j=>{j.source&&(j.source&&j.source!==i.contentWindow||De(j.origin,e.allowedOrigins)&&Le(j)&&j.data.type===Ua.READY&&(u=!0,X()))},m=()=>{x(),n(new DOMException("Aborted","AbortError"))},i.addEventListener("load",d),i.addEventListener("error",p),window.addEventListener("message",h),e.signal?.addEventListener("abort",m,{once:!0}),l=setTimeout(()=>{x(),n(new H("timeout",t+1))},a),e.signal?.aborted){x(),n(new DOMException("Aborted","AbortError"));return}e.container.appendChild(i)})}async function es(e){const t=e.backoffMs??Ya,r=t.length+1;for(let n=0;n<r;n++){e.onStateChange?.({kind:"loading",attempt:n});try{const i=await Xa(e,n);return e.onStateChange?.({kind:"loaded",iframe:i}),i}catch(i){if(i instanceof DOMException&&i.name==="AbortError")throw i;const a=i instanceof H?i.reason:"error";if(n===r-1)throw e.onStateChange?.({kind:"failed",reason:a,attempts:r}),te(`Iframe load failed permanently after ${r} attempt(s) (reason: ${a})`),new H(a,r);const o=t[n]??1e3;e.onStateChange?.({kind:"retrying",attempt:n+1,reason:a}),re(`Iframe load attempt ${n+1} ${a==="timeout"?"timed out":"errored"}, retrying in ${o}ms`),await Qa(o,e.signal)}}throw new H("error",r)}var ts="0.1.0",ve="https://gamaro.io/app",rs=0,ns={mobile:480,tablet:768},qt={mobile:{width:"100vw",height:"100vh"},tablet:{width:"90vw",height:"80vh"},desktop:{width:"380px",height:"600px"}},is=100,os={position:"fixed",zIndex:"999999",border:"none",overflow:"hidden"},Q=`${q.slow}ms`,Wt=`${q.base}ms`,as=[`width ${Q} ${M.emphasized}`,`height ${Q} ${M.emphasized}`,`border-radius ${Q} ${M.emphasized}`,`box-shadow ${Q} ${M.emphasized}`,`transform ${Q} ${M.emphasized}`].join(", "),ss=[`opacity ${Wt} ${M.standard}`,`background ${Wt} ${M.standard}`].join(", ");function Jt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var be={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"}},cs={width:"100%",height:"100%",border:"none",backgroundColor:"transparent"},Bt=class{get applicationId(){return this._applicationId}constructor(e){this.version=ts,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.vertical="",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:ve,debug:!1,...e},this.instanceId=++rs,this.debugLog=Qt(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: ${Jt()?"none":ss}`].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??ve;this.fetchAbortController=new AbortController;const t=r=>Vt(this.config.apiKey,e,this.fetchAbortController?.signal).then(n=>this.applyServerConfig(n)).catch(n=>{const i=n instanceof V?n.code:"UNKNOWN_ERROR",a=n instanceof Error?n.message:"Unknown config fetch error";if(!(i==="ABORTED"||this.isDestroyed)){if(r===0&&this.isTransientFetchError(i))return re(`Config fetch failed transiently (${i}), retrying after 1s backoff`),new Promise(o=>setTimeout(()=>{this.isDestroyed||o(t(1))},1e3));te(`Config fetch failed — widget stays in degraded mode: ${a}`),this.emit("error",{code:i,message:a})}});t(0)}isTransientFetchError(e){return e==="NETWORK_ERROR"||e==="TIMEOUT"||e.startsWith("HTTP_5")}applyServerConfig(e){if(this.isDestroyed)return;this._applicationId=e.applicationId,this.vertical=e.vertical;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(()=>re(`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 es({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 H?(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=tr({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??ve;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=`versiq-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,os);const t=be[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=`versiq-widget-iframe-${this.instanceId}`,e.src=this.buildIframeUrl(),e.setAttribute("title","Versiq Chat Widget"),e.setAttribute("allow","clipboard-write; geolocation"),Object.assign(e.style,cs),e}buildIframeUrl(){const e=this.config.baseUrl??ve,t=new URL("/app/widget/embed",e);return this.vertical&&t.searchParams.set("vertical",this.vertical),this.config.theme&&t.searchParams.set("theme",rr(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={...ns,...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&&D(this.iframe,{type:"versiq:viewport",mode:e},this.resolveReadyOrigin()))},is)}getViewportMode(){return this.mobileMediaQuery?.matches?"mobile":this.tabletMediaQuery?.matches?"tablet":"desktop"}applyContainerTransition(){this.container&&(this.container.style.transition=Jt()?"none":as)}updateContainerForViewport(e){if(!this.container)return;this.applyContainerTransition();const t=qt[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=be[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=be[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"versiq:ready":if(this.isReady)break;this.isReady=!0,this.sendConfig(),this.emit("ready",void 0);break;case"versiq:profile-update":this.emit("profile-update",void 0);break;case"versiq:message":this.emit("message",e.message);break;case"versiq:qualified":this.emit("qualified",void 0);break;case"versiq:error":this.emit("error",{code:e.code,message:e.message});break;case"versiq:open":this.isOpen=!0,this.updateVisibility(),this.emit("open",void 0);break;case"versiq:close":this.isOpen=!1,this.updateVisibility(),this.emit("close",void 0);break;case"versiq:quota-warning":this.emit("quota-warning",{remaining:e.remaining,limit:e.limit});break;case"versiq:quota-exceeded":this.emit("quota-exceeded",void 0);break;case"versiq:identity-verified":this.emit("identity-verified",{email:e.email,userId:e.userId});break;case"versiq:funnel-stage-change":this.emit("funnel-stage-change",{stage:e.stage,previousStage:e.previousStage});break}}sendConfig(){if(!this.iframe||!this.isReady)return;const{container:e,...t}=this.config,r={type:"versiq:init",config:t};D(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=qt.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=be[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){te(`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&&D(this.iframe,{type:"versiq:open"},this.resolveReadyOrigin()))}close(){if(!this.isInitialized){this.pendingCommands.push(()=>this.close());return}this.iframe&&(this.isOpen=!1,this.updateVisibility(),this.isReady&&D(this.iframe,{type:"versiq:close"},this.resolveReadyOrigin()))}reset(){if(!this.isInitialized){this.pendingCommands.push(()=>this.reset());return}!this.iframe||!this.isReady||D(this.iframe,{type:"versiq: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&&D(this.iframe,{type:"versiq: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&&D(this.iframe,{type:"versiq: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,(a,o)=>{if(o instanceof HTMLElement)return`[HTMLElement: ${o.tagName}]`;if(typeof o=="object"&&o!==null){if(i.has(o))return"[Circular]";i.add(o)}return o}))}catch{return"[Unserializable]"}});this.debugLog(e,...r)}};function Ht(e){return new Bt(e)}var xe=new WeakSet;function Gt(e){const t=e.getAttribute("data-api-key")??void 0;if(!t)return te("Missing required data-api-key attribute on script tag"),null;const r=e.dataset.container,n=e.dataset.baseUrl,i=e.dataset.debug==="true",a=e.dataset.email,o=e.getAttribute("data-user-id")??void 0,s=e.getAttribute("data-user-hash")??void 0;return{apiKey:t,container:r,baseUrl:n,debug:i,...a&&{email:a},...o&&{userId:o},...s&&{userHash:s}}}function Kt(){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("versiq")||r.includes("widget"))return t}return null}function je(){const e=document.querySelectorAll("script[data-api-key]");if(e.length===0){const t=Kt();t&&t.hasAttribute("data-api-key")&&!xe.has(t)&&Yt(t);return}for(const t of e)Yt(t)}function Yt(e){if(xe.has(e))return;xe.add(e);const t=Gt(e);if(!t)return;const r=Ht(t);window.Versiq||(window.Versiq=r),window.VersiqApps||(window.VersiqApps=new Map),r.on("ready",()=>{r.applicationId&&window.VersiqApps&&window.VersiqApps.set(r.applicationId,r)}),re(`Widget v${r.version} initializing...`)}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",je):je()),k.ConfigFetchError=V,k.VersiqWidget=Bt,k.__autoInit=je,k.__getCurrentScript=Kt,k.__parseScriptAttributes=Gt,k.applicationConfigResponseSchema=Ut,k.b2bProfileSchema=Ka,k.createWidget=Ht,k.fetchApplicationConfig=Vt,k.themeConfigSchema=ge,k.widgetConfigSchema=ja,k.widgetMessageSchema=La,k.widgetPositionSchema=Re});
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@gamaro.io/widget",
3
+ "version": "0.6.0",
4
+ "description": "Gamaro Widget SDK - Embed conversational qualification into your website.",
5
+ "type": "module",
6
+ "main": "./dist/widget.umd.js",
7
+ "module": "./dist/widget.es.js",
8
+ "unpkg": "./dist/widget.umd.js",
9
+ "jsdelivr": "./dist/widget.umd.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/widget.es.js",
15
+ "require": "./dist/widget.umd.js"
16
+ },
17
+ "./widget.js": "./dist/widget.umd.js"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "sideEffects": false,
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "license": "SEE LICENSE IN LICENSE",
29
+ "author": "Sébastien Dolard <admin@gamaro.io>",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/sdolard/Toize.git",
33
+ "directory": "packages/widget"
34
+ },
35
+ "homepage": "https://github.com/sdolard/Toize/tree/main/packages/widget#readme",
36
+ "bugs": {
37
+ "url": "https://github.com/sdolard/Toize/issues"
38
+ },
39
+ "keywords": [
40
+ "widget",
41
+ "gamaro",
42
+ "qualification",
43
+ "embed",
44
+ "sdk",
45
+ "conversational"
46
+ ],
47
+ "engines": {
48
+ "node": ">=18.0.0"
49
+ },
50
+ "size-limit": [
51
+ {
52
+ "path": "dist/widget.umd.js",
53
+ "limit": "50 KB",
54
+ "gzip": true
55
+ }
56
+ ],
57
+ "dependencies": {
58
+ "zod": "4.3.6",
59
+ "@gamaro.io/core-types": "0.6.0"
60
+ },
61
+ "devDependencies": {
62
+ "@microsoft/api-extractor": "^7.58.12",
63
+ "@size-limit/file": "^11.2.0",
64
+ "@types/node": "^22.20.1",
65
+ "@vitest/coverage-v8": "^4.1.10",
66
+ "jsdom": "^26.1.0",
67
+ "size-limit": "^11.2.0",
68
+ "typescript": "^6.0.3",
69
+ "vite": "^8.1.5",
70
+ "vitest": "^4.1.10"
71
+ },
72
+ "scripts": {
73
+ "clean": "rm -rf dist",
74
+ "build": "pnpm clean && vite build && tsc -p tsconfig.build.json",
75
+ "dev": "vite build --watch",
76
+ "serve": "npx serve . -p 5500",
77
+ "typecheck": "tsc --noEmit",
78
+ "typecheck:ci": "pnpm typecheck",
79
+ "test": "vitest",
80
+ "test:ci": "vitest run",
81
+ "test:coverage": "vitest run --coverage",
82
+ "size": "size-limit",
83
+ "size:check": "size-limit",
84
+ "api-extractor:check": "api-extractor run --verbose -c api-extractor.json",
85
+ "api-extractor:local": "api-extractor run --local --verbose -c api-extractor.json"
86
+ }
87
+ }