@regojs/erp-sdk 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +3 -3
- package/dist/server/index.js +698 -1
- package/package.json +3 -3
- package/src/browser/vanilla/providers/regoProvider.ts +12 -4
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/vanilla/constants/enums.d.ts +0 -6
- package/dist/browser/vanilla/constants/index.d.ts +0 -1
- package/dist/browser/vanilla/index.d.ts +0 -8
- package/dist/browser/vanilla/providers/index.d.ts +0 -1
- package/dist/browser/vanilla/providers/regoProvider.d.ts +0 -16
- package/dist/browser/vanilla/types/index.d.ts +0 -1
- package/dist/browser/vanilla/types/regoProvider.d.ts +0 -19
- package/dist/browser/vanilla/validators/data.d.ts +0 -3
- package/dist/browser/vanilla/validators/fullData.d.ts +0 -7
- package/dist/browser/vanilla/validators/index.d.ts +0 -10
- package/dist/browser/vanilla/validators/metadata.d.ts +0 -3
- package/dist/browser/vanilla/validators/routes.d.ts +0 -6
- package/dist/browser/vanilla/validators/staticData.d.ts +0 -3
package/README.md
CHANGED
package/dist/browser/index.js
CHANGED
|
@@ -55,6 +55,6 @@ ${t.join(`
|
|
|
55
55
|
}
|
|
56
56
|
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},s,c=pe,u=!I.jitless,l=u&&cr.value,f=t.catchall,d;e._zod.parse=(m,h)=>{d??(d=n.value);let _=m.value;if(!c(_))return m.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),m;if(u&&l&&h?.async===!1&&h.jitless!==!0){if(!s)s=i(t.shape);if(m=s(m,h),!f)return m;return io([],_,m,h,d,e,h?.abortEarly===!0)}return r(m,h)}});function yn(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!F(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>U(s,n,T())))}),t}var co=p("$ZodUnion",(e,t)=>{k.init(e,t),x(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),x(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),x(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),x(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>Ze(i.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,s=[];for(let c of t.options){let u=c._zod.run({value:n.value,issues:[]},o);if(u instanceof Promise)s.push(u),i=!0;else{if(u.issues.length===0)return u;s.push(u)}}if(!i)return yn(s,n,e,o);return Promise.all(s).then((c)=>yn(c,n,e,o))}});var uo=p("$ZodIntersection",(e,t)=>{k.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([u,a])=>xn(r,u,a));return xn(r,i,s)}});function xt(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(X(e)&&X(t)){let r=Object.keys(t),n=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of n){if(i==="__proto__")continue;let s=xt(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=xt(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function xn(e,t,r){let n=new Map,o,i=new Map,s=(a,l)=>{let f;if(a.code==="unrecognized_keys"&&!a.path?.length)o??(o=a),f=a.keys;else if(a.code==="invalid_key"&&a.origin==="record"&&a.path?.length===1){let d=String(a.path[0]);if(!i.has(d))i.set(d,a);f=[d]}else return!1;for(let d of f){if(!n.has(d))n.set(d,{});n.get(d)[l]=!0}return!0};for(let a of t.issues)if(!s(a,"l"))e.issues.push(a);for(let a of r.issues)if(!s(a,"r"))e.issues.push(a);let c=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(c.length){let a=o?c.filter((l)=>o.keys.includes(l)):[];if(a.length)e.issues.push({...o,keys:a});for(let l of c)if(!a.includes(l)&&i.has(l))e.issues.push(i.get(l))}let u=xt(t.value,r.value);if(!u.valid){if(F(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}var ao=p("$ZodRecord",(e,t)=>{k.init(e,t);let r=I.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!X(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let s=[],c=t.keyType._zod.values;if(c&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let u=new Set;for(let l of c)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(u.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((h)=>U(h,o,T())),input:l,path:[l],inst:e});continue}let d=f.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:i[l],issues:[]},o);if(m instanceof Promise)s.push(m.then((h)=>{if(h.issues.length)n.issues.push(...K(l,h.issues));n.value[d]=h.value}));else{if(m.issues.length)n.issues.push(...K(l,m.issues));n.value[d]=m.value}}let a;for(let l in i)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else a=a??[],a.push(l);if(a&&a.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let u;for(let a of Reflect.ownKeys(i)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let l=t.keyType._zod.run({value:a,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&je.test(a)&&l.issues.length){let h=t.keyType._zod.run({value:Number(a),issues:[]},o);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(t.mode==="loose")n.value[a]=i[a];else if(c)u=u??[],u.push(a);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>U(h,o,T())),input:a,path:[a],inst:e});continue}let d=l.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:i[a],issues:[]},o);if(m instanceof Promise)s.push(m.then((h)=>{if(h.issues.length)n.issues.push(...K(a,h.issues));n.value[d]=h.value}));else{if(m.issues.length)n.issues.push(...K(a,m.issues));n.value[d]=m.value}}if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}if(s.length)return Promise.all(s).then(()=>n);return n}});var lo=p("$ZodEnum",(e,t)=>{k.init(e,t);let r=fe(t.entries),n=new Set(r);e._zod.values=n,x(e,"pattern",(o)=>{let i=fe(o.def.entries).filter((s)=>ur.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>re(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}});var po=p("$ZodTransform",(e,t)=>{k.init(e,t),e._zod.optin="optional",I.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new me(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(r.value=s,r));if(o instanceof Promise)throw new J;return r.value=o,r}});function bn(e,t){return e.value=t.issues.length?void 0:t.value,e}var $t=p("$ZodOptional",(e,t)=>{k.init(e,t),x(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",x(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),x(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ze(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>bn(r,i));return bn(r,o)}return t.innerType._zod.run(r,n)}}),fo=p("$ZodExactOptional",(e,t)=>{$t.init(e,t),x(e,"values",(r)=>r.def.innerType._zod.values),x(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),mo=p("$ZodNullable",(e,t)=>{k.init(e,t),x(e,"optin",(r)=>r.def.innerType._zod.optin),x(e,"optout",(r)=>r.def.innerType._zod.optout),x(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ze(n.source)}|null)$`):void 0}),x(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),ho=p("$ZodDefault",(e,t)=>{k.init(e,t),e._zod.optin="defaulted",x(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>vn(i,t));return vn(o,t)}});function vn(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var go=p("$ZodPrefault",(e,t)=>{k.init(e,t),e._zod.optin="defaulted",x(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),_o=p("$ZodNonOptional",(e,t)=>{k.init(e,t),x(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>$n(i,e));return $n(o,e)}});function $n(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function zn(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>U(o,n,T()))},input:e.value}),e}var yo=p("$ZodCatch",(e,t)=>{k.init(e,t),x(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),x(e,"optout",(r)=>r.def.innerType._zod.optout),x(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>zn(r,i,t,n));return zn(r,o,t,n)}});var xo=p("$ZodPipe",(e,t)=>{k.init(e,t),x(e,"values",(r)=>r.def.in._zod.values),x(e,"optin",(r)=>r.def.in._zod.optin),x(e,"optout",(r)=>r.def.out._zod.optout),x(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);if(i instanceof Promise)return i.then((s)=>Re(s,t.in,n));return Re(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Re(i,t.out,n));return Re(o,t.out,n)}});function Re(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var bo=p("$ZodReadonly",(e,t)=>{k.init(e,t),x(e,"propValues",(r)=>r.def.innerType._zod.propValues),x(e,"values",(r)=>r.def.innerType._zod.values),x(e,"optin",(r)=>r.def.innerType?._zod?.optin),x(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(wn);return wn(o)}});function wn(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var vo=p("$ZodCustom",(e,t)=>{E.init(e,t),k.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((i)=>kn(i,r,n,e));kn(o,r,n,e);return}});function kn(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(H(o))}}function Zn(e,t,r){if(e.issues.length)t.issues.push(...K(r,e.issues))}var Gs=p("$ZodProperties",(e,t)=>{k.init(e,t),E.init(e,t);let r=I.memoizer;r?.attach(e);let n,o=(i,s)=>{n??(n=Reflect.ownKeys(t.shape).map((a)=>[a,t.shape[a]]));let c=i.value,u;for(let[a,l]of n){let f=l._zod.run({value:c[a],issues:[]},s);if(f instanceof Promise)u??(u=[]),u.push(f.then((d)=>Zn(d,i,a)));else Zn(f,i,a)}if(u)return Promise.all(u).then(()=>{return});return};e._zod.parse=(i,s)=>{let c=i.value;if(c===null||typeof c!=="object"&&typeof c!=="function")return i.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),i;if(s.direction==="backward")s={...s,direction:"forward"};if(r)r.alloc(e,i,c,s);let u=o(i,s);return u instanceof Promise?u.then(()=>i):i},e._zod.check=(i)=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:e});return}return o(i,{})}},{*[Symbol.iterator](){yield this}});class zo extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var wt="~memo",$o=[];function wo(e){return e!==null&&(typeof e==="object"||typeof e==="function")}function zt(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ko=new WeakMap,_e=0,Je=1,ye=2;function Be(e,t,r){let n=ko.get(e);if(n!==void 0)return n?ye:_e;if(t.has(e))return ye;t.add(e);let o=_e,i=(l)=>{if(o!==ye&&l?._zod){let f=Be(l,t,r);if(f>o)o=f}},s=(l,f)=>{let d=_e;for(let m of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,m);if(f&&!h.enumerable)continue;let _=h.get?Je:h.value?._zod?Be(h.value,t,r):_e;if(_>d)d=_}return d},c=(l)=>{if(l>o)o=l},u=e._zod.def,a=u.type;switch(a){case"object":{let l=Pe(u);c(l?s(l,!0):Je),i(u.catchall);break}case"properties":c(s(u.shape,!1));break;case"array":i(u.element);break;case"tuple":for(let l of u.items)i(l);i(u.rest);break;case"record":case"map":i(u.keyType),i(u.valueType);break;case"set":i(u.valueType);break;case"union":for(let l of u.options)i(l);break;case"intersection":i(u.left),i(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(u.innerType);break;case"pipe":i(u.in),i(u.out);break;case"function":i(u.input),i(u.output);break;case"lazy":{let l=u._cachedInner??(r?e._zod.innerType:void 0);c(l?Be(l,t,!1):Je);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in u){let f=Object.getOwnPropertyDescriptor(u,l);if(!f||f.get)continue;let d=f.value;if(!d||typeof d!=="object")continue;if(d._zod)i(d);else if(Array.isArray(d))for(let m of d)i(m)}}return t.delete(e),Xs(e,o)}function Xs(e,t){if(t!==Je)ko.set(e,t===ye);return t}function Hs(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Fe,Ue=[],Ys={alloc(e,t,r){let n=Fe;if(!n)return r;Fe=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ue.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,i)=>{if(i.direction!=="backward"&&Qs(i,o.value))throw new zo;return r(o,i)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,c=(u,a)=>{if(r===void 0){let w=Be(e,new Set,!1);if(w===_e){if(e._zod.parse=s,e._zod.run===c)e._zod.run=s;return s(u,a)}if(w===ye||n)r=!0;else n=!0}let l=u.value;if(!wo(l))return s(u,a);let f=a[wt];if(!f)f={buckets:new WeakMap,backEdges:void 0},a[wt]=f;let d;if(o===a)d=i;else d=Hs(f,e),o=a,i=d;let m=d.get(l);if(m){if(u.value=m.value,m.issues){if(m.issues.length)u.issues.push(...zt(m.issues))}else u.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(m.value);return u}Fe=d;let h=Ue.length,_=s(u,a);Fe=void 0;let y=Ue.length>h?Ue.pop():void 0;if(_ instanceof Promise)return _.then((w)=>{if(y)y.issues=w.issues.length?zt(w.issues):$o;return w});if(y)y.issues=_.issues.length?zt(_.issues):$o;return _};if(e._zod.parse=c,e._zod.run===s)e._zod.run=c})}};function Zo(){return Ys}function Qs(e,t){let r=e[wt]?.backEdges;return r!==void 0&&wo(t)&&r.has(t)}var ec=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return n[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),c=dr(i.input),u=o(c,i.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${ot(i.values[0])}`;return`Invalid option: expected one of ${tt(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);if(c)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);if(c)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${c.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${tt(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((c)=>`'${c}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function kt(){return{localeError:ec()}}var Po;class So{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let 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 tc(){return new So}(Po=globalThis).__zod_globalRegistry??(Po.__zod_globalRegistry=tc());var Y=globalThis.__zod_globalRegistry;function Oo(e,t){return new e({type:"string",...g(t)})}function Io(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function Eo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function Ao(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function To(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function No(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Co(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function jo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Ro(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Do(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Mo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Lo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Fo(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Uo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Jo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Bo(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Vo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Ko(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Wo(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function qo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function Go(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Xo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ho(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Yo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Qo(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function ei(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function ti(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function ri(e){return new e({type:"unknown"})}function ni(e,t){return new e({type:"never",...g(t)})}function Ve(e,t){return new on({check:"max_length",...g(t),maximum:e})}function ne(e,t){return new sn({check:"min_length",...g(t),minimum:e})}function Ke(e,t){return new cn({check:"length_equals",...g(t),length:e})}function Zt(e,t){return new un({check:"string_format",format:"regex",...g(t),pattern:e})}function Pt(e){return new an({check:"string_format",format:"lowercase",...g(e)})}function St(e){return new ln({check:"string_format",format:"uppercase",...g(e)})}function Ot(e,t){return new pn({check:"string_format",format:"includes",...g(t),includes:e})}function It(e,t){return new fn({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Et(e,t){return new dn({check:"string_format",format:"ends_with",...g(t),suffix:e})}function q(e){return new mn({check:"overwrite",tx:e})}function At(e){return q((t)=>t.normalize(e))}function Tt(){return q((e)=>e.trim())}function Nt(){return q((e)=>e.toLowerCase())}function Ct(){return q((e)=>e.toUpperCase())}function jt(){return q((e)=>sr(e))}function oi(e,t,r){return new e({type:"array",element:t,...g(r)})}function ii(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function si(e,t){let r=rc((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(H(o,n.value,r._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=n.value;i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(H(i))}},e(n.value,n)),t);return r}function rc(e,t){let r=new E({check:"custom",...g(t)});return r._zod.check=e,r}function xe(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))j(e,n,r[n]);return e}function Dt(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{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,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function oe(e,t,r,n,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(r,i),!0}function Z(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let d=s.schema,m=t.processors[o.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,d,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;Z(f,t,l),t.seen.get(f).isParent=!0}}let u=t.metadataRegistry.get(e);if(u)xe(s.schema,u);if(t.io==="input"&&O(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(n=s.schema).default??(n.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function ci(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let u=n.get(c);if(u&&u!==s[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,s[0])}}let o=(s)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,d=e.external.uri??((h)=>h);if(f)return{ref:d(f)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${d("__shared")}#/${c}/${ci(m)}`}}let u="#",a=`${u}/${c}/`;if(s[1]===r&&!s[1].schema.id)return{ref:u};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:a+ci(l)}},i=(s)=>{if(s[1].schema.$ref)return;let c=s[1],{ref:u,defId:a}=o(s);if(c.def={...c.schema},a)c.defId=a;let l=c.schema;for(let f in l)delete l[f];l.$ref=u};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
57
57
|
|
|
58
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let a=e.external.registry.get(s[0])?.id;if(t!==s[0]&&a){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function li(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;li(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let i=n.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var pi=new Set(["type","properties","required","additionalProperties"]),ui=["oneOf","anyOf"];function ai(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Rt(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!pi.has(s))return null;t.push(i)}let r={},n=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let c=[];for(let a of t){let l=a.properties?.[s]??ai(a);if(l===null||l===void 0)continue;if(!c.some((f)=>JSON.stringify(f)===JSON.stringify(l)))c.push(l)}let u=c.length===1?c[0]:Rt(c)??{allOf:c};j(r,s,u)}for(let s of i.required??[])n.add(s)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let c=ai(s);if(c&&!i.some((u)=>JSON.stringify(u)===JSON.stringify(c)))i.push(c)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function nc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of pi)if(o in e)return;let r=t.filter((o)=>ui.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=Rt(t);else{let o=r[0],i=ui.find((u)=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;let s=t.filter((u)=>u!==o),c=o[i].map((u)=>Rt([...s,u]));if(c.some((u)=>!u))return;n={[i]:c}}if(!n)return;delete e.allOf,xe(e,n)}function Lt(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(c)=>{let u=e.seen.get(c);if(u.ref===null)return;let a=u.def??u.schema,l={...a},f=u.ref;if(u.ref=null,f){n(f);let m=e.seen.get(f),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))a.allOf=a.allOf??[],a.allOf.push(h);else xe(a,h);if(xe(a,l),c._zod.parent===f)for(let y in a){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete a[y]}if(h.$ref&&m.def)for(let y in a){if(y==="$ref"||y==="allOf")continue;if(y in m.def&&JSON.stringify(a[y])===JSON.stringify(m.def[y]))delete a[y]}}let d=c._zod.parent;if(d&&d!==f){n(d);let m=e.seen.get(d);if(m?.schema.$ref){if(a.$ref=m.schema.$ref,m.def)for(let h in a){if(h==="$ref"||h==="allOf")continue;if(h in m.def&&JSON.stringify(a[h])===JSON.stringify(m.def[h]))delete a[h]}}}e.override({zodSchema:c,jsonSchema:a,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())n(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())li(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let u of e.seen.values())for(let a of[u.schema,u.def]){let l=a?.allOf;if(!Array.isArray(l))continue;let f=c.get(l);if(f)f.push(a);else c.set(l,[a])}for(let u of e.intersections)for(let a of c.get(u)??[])nc(a)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}xe(o,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let u=c[1];if(u.def&&u.defId){if(u.def.id===u.defId)delete u.def.id;j(s,u.defId,u.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:be(t,"input",e.processors),output:be(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function O(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return O(n.element,r);if(n.type==="set")return O(n.valueType,r);if(n.type==="lazy")return O(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return O(n.innerType,r);if(n.type==="intersection")return O(n.left,r)||O(n.right,r);if(n.type==="record"||n.type==="map")return O(n.keyType,r)||O(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return O(n.in,r)||O(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(O(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(O(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(O(o,r))return!0;if(n.rest&&O(n.rest,r))return!0;return!1}return!1}var fi=(e,t={})=>(r)=>{let n=Dt({...r,processors:t});return Z(e,n),Mt(n,e),Lt(n,e)},be=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=Dt({...o??{},target:i,io:t,processors:r});return Z(e,s),Mt(s,e),Lt(s,e)};var ie=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},se=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},di=(e,t)=>{ie(e,"minimum",t),se(e,"maximum",t)},_i=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},yi=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},xi=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},bi=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},mi=(e,t)=>ie(e,"minimum",t.minimum),hi=(e,t)=>se(e,"maximum",t.maximum),gi=(e)=>(t,r)=>{bi(t,r.format);let[n,o]=e[r.format];ie(t,"minimum",n),se(t,"maximum",o)},oc={greater_than:(e,t)=>ie(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>se(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>_i(e,t.value),number_format:gi(it),bigint_format:gi(st),min_length:mi,max_length:hi,length_equals:(e,t)=>di(e,t.length),min_size:mi,max_size:hi,size_equals:(e,t)=>di(e,t.size),string_format:(e,t)=>{if(bi(e,t.format),t.pattern)yi(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>xi(e,t.mime)};function Q(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)oc[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ie(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ie(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)se(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)se(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)_i(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)xi(t,o.mime);for(let i of o.patterns??[])yi(t,i);return t}var ic={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sc=new Map([[vt,Wr],[Le,qr]]),vi=(e)=>sc.get(e)??e,$i=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:c,patterns:u,contentEncoding:a,laxFormat:l}=Q(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(c){if(o.format=ic[c]??c,o.format==="")delete o.format;if(c==="time"||l)delete o.format}if(a)o.contentEncoding=a;if(u&&u.size>0){let f=[...u].map(vi);if(f.length===1)o.pattern=f[0].source;else if(f.length>1)o.allOf=[...f.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}};var zi=(e,t,r,n)=>{r.not={}};var wi=(e,t,r,n)=>{};var ki=(e,t,r,n)=>{let o=e._zod.def,i=fe(o.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i};var Zi=(e,t,r,n)=>{oe(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Pi=(e,t,r,n)=>{oe(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Si=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:c}=Q(e);if(typeof s==="number")o.minItems=s;if(typeof c==="number")o.maxItems=c;o.type="array",o.items=Z(i.element,t,{...n,path:[...n.path,"items"]})};function We(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return We(t.out);if(t.type==="catch")return We(t.innerType);return e._zod.optin}var Oi=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&oe(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in s)j(o.properties,l,Z(s[l],t,{...n,path:[...n.path,"properties",l]}));let u=new Set(Object.keys(s)),a=new Set([...u].filter((l)=>{let f=i.shape[l];if(t.io==="input")return We(f)===void 0;else return f._zod.optout===void 0}));if(a.size>0)o.required=Array.from(a);if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=Z(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})};var Ii=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,u)=>Z(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",u]}));if(i)r.oneOf=s;else r.anyOf=s},Ei=(e,t,r,n)=>{let o=e._zod.def,i=Z(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=Z(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=(a)=>("allOf"in a)&&Object.keys(a).length===1,u=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=u,t.intersections.push(u)};function Ft(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let _=Ft(e,h,r);return _===h?t:_}for(let h of["anyOf","oneOf"]){let _=t[h];if(!Array.isArray(_))continue;let y=_.map((w)=>Ft(e,w,r));if(y.some((w,C)=>w!==_[C]))t={...t,[h]:y}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((h)=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((h)=>typeof h==="number"))return t;let{minimum:s,maximum:c,exclusiveMinimum:u,exclusiveMaximum:a,multipleOf:l,format:f,id:d,...m}=t;if(m.enum)m.enum=m.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!i)m.pattern=(n.includes("number")?je:gt).source;return m}var Ut=new WeakMap;function cc(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Ut.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Ft(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let i=o&&r.get(o.propertyNames);if(i)o.propertyNames=i}}var Ai=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,c=Q(s).patterns;if(i.mode==="loose"&&c&&c.size>0){let l=Z(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let f of c)j(o.patternProperties,vi(f).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=Z(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Ut.get(t);if(!l)l=[],Ut.set(t,l),t.deferred.push(()=>cc(t));l.push(e)}o.additionalProperties=Z(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let u=s._zod.values,a=t.io==="input"&&We(i.valueType)!==void 0;if(u&&!i.partial&&!a){let l=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)o.required=l.map(String)}},Ti=(e,t,r,n)=>{let o=e._zod.def,i=Z(o.innerType,t,n),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},Ni=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Jt=Symbol();function Ci(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(c,u)=>{if(typeof u!=="bigint")return u;return i=!0,null});if(!i)return JSON.parse(s);return oe(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Jt}var ji=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=Ci(o.defaultValue,e,t,r,n);if(s!==Jt)r.default=s},Ri=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Ci(o.defaultValue,e,t,r,n);if(s!==Jt)r._prefault=s},Di=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{oe(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},Mi=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;Z(s,t,n);let c=t.seen.get(e);c.ref=s},Li=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Bt=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var Fi=new WeakSet([Object.prototype,Error.prototype]);function qe(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var xc=(e,t)=>{br.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Fi.has(r))return;Fi.add(r),qe(r,"format",(n)=>(o)=>$r(n,o)),qe(r,"flatten",(n)=>(o)=>vr(n,o)),qe(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,de,2)}),qe(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,de,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var N=p("ZodError",xc,void 0,{Parent:Error});var Ui=Ae(N),Ji=Te(N),Bi=Ne(N),Vi=Ce(N),Ki=wr(N),Wi=kr(N),qi=Zr(N),Gi=Pr(N),Xi=Sr(N),Hi=Or(N),Yi=Ir(N),Qi=Er(N);function vc(){if(!I.localeError)T(kt())}function Xe(){if(!I.memoizer)T({memoizer:Zo()})}var P=p("ZodType",(e,t)=>(vc(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(A(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return L(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gu(e,t))},superRefine(e,t){return this.check(_u(e,t))},overwrite(e){return this.check(q(e))},optional(){return ts(this)},exactOptional(){return nu(this)},nullable(){return rs(this)},nullish(){return ts(rs(this))},nonoptional(e){return au(this,e)},array(){return Gc(this)},or(e){return Wt([this,e])},and(e){return Qc(this,e)},transform(e){return ns(this,ru(e))},default(e){return su(this,e)},prefault(e){return uu(this,e)},catch(e){return pu(this,e)},pipe(e){return ns(this,e)},readonly(){return mu(this)},describe(e){let t=this.clone();return Y.add(t,{description:e}),t},meta(...e){if(e.length===0)return Y.get(this);let t=this.clone();return Y.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ut(this,"~standard",{...bt(this),jsonSchema:{input:be(this,"input"),output:be(this,"output")}})},set "~standard"(e){V(this,"~standard",e)},parse:function e(t,r){return Ui(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ji(this,t,r,{callee:e})},safeParse(e,t){return Bi(this,e,t)},async safeParseAsync(e,t){return Vi(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){V(this,"spa",e)},validate(e,t){return ft(this,e,t)},validateAsync(e,t){return dt(this,e,t)},encode:function e(t,r){return Ki(this,t,r,{callee:e})},decode:function e(t,r){return Wi(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await qi(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Gi(this,t,r,{callee:e})},safeEncode(e,t){return Xi(this,e,t)},safeDecode(e,t){return Hi(this,e,t)},async safeEncodeAsync(e,t){return Yi(this,e,t)},async safeDecodeAsync(e,t){return Qi(this,e,t)},toJSONSchema(e){return fi(this,{})(e)},get description(){return Y.get(this)?.description},get _def(){return this._zod.def}}),os=p("_ZodString",(e,t)=>{Me.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$i(e,r,n,o)},$s({format:(e)=>Q(e).format??null,minLength:(e)=>Q(e).minimum??null,maxLength:(e)=>Q(e).maximum??null},{regex(...e){return this.check(Zt(...e))},includes(...e){return this.check(Ot(...e))},startsWith(...e){return this.check(It(...e))},endsWith(...e){return this.check(Et(...e))},min(...e){return this.check(ne(...e))},max(...e){return this.check(Ve(...e))},length(...e){return this.check(Ke(...e))},nonempty(...e){return this.check(ne(1,...e))},lowercase(e){return this.check(Pt(e))},uppercase(e){return this.check(St(e))},trim(){return this.check(Tt())},normalize(...e){return this.check(At(...e))},toLowerCase(){return this.check(Nt())},toUpperCase(){return this.check(Ct())},slugify(){return this.check(jt())}})),$c=p("ZodString",(e,t)=>{Me.init(e,t),os.init(e,t)},{email(e){return this.check(Io(Pc,e))},url(e){return this.check(jo(Oc,e))},jwt(e){return this.check(Ho(Bc,e))},emoji(e){return this.check(Ro(Ic,e))},guid(e){return this.check(Eo(Sc,e))},uuid(e){return this.check(Ao(Ge,e))},uuidv4(e){return this.check(To(Ge,e))},uuidv6(e){return this.check(No(Ge,e))},uuidv7(e){return this.check(Co(Ge,e))},nanoid(e){return this.check(Do(Ec,e))},cuid(e){return this.check(Mo(Ac,e))},cuid2(e){return this.check(Lo(Tc,e))},ulid(e){return this.check(Fo(Nc,e))},base64(e){return this.check(qo(Fc,e))},base64url(e){return this.check(Go(Uc,e))},xid(e){return this.check(Uo(Cc,e))},ksuid(e){return this.check(Jo(jc,e))},ipv4(e){return this.check(Bo(Rc,e))},ipv6(e){return this.check(Vo(Dc,e))},cidrv4(e){return this.check(Ko(Mc,e))},cidrv6(e){return this.check(Wo(Lc,e))},e164(e){return this.check(Xo(Jc,e))},datetime(e){return this.check(Yo(zc,e))},date(e){return this.check(Qo(wc,e))},time(e){return this.check(ei(kc,e))},duration(e){return this.check(ti(Zc,e))}});function D(e){return Oo($c,e)}var z=p("ZodStringFormat",(e,t)=>{v.init(e,t),os.init(e,t)}),zc=p("ZodISODateTime",(e,t)=>{Fn.init(e,t),z.init(e,t)}),wc=p("ZodISODate",(e,t)=>{Un.init(e,t),z.init(e,t)}),kc=p("ZodISOTime",(e,t)=>{Jn.init(e,t),z.init(e,t)}),Zc=p("ZodISODuration",(e,t)=>{Bn.init(e,t),z.init(e,t)}),Pc=p("ZodEmail",(e,t)=>{In.init(e,t),z.init(e,t)});var Sc=p("ZodGUID",(e,t)=>{Sn.init(e,t),z.init(e,t)});var Ge=p("ZodUUID",(e,t)=>{On.init(e,t),z.init(e,t)});var Oc=p("ZodURL",(e,t)=>{Tn.init(e,t),z.init(e,t)});var Ic=p("ZodEmoji",(e,t)=>{Nn.init(e,t),z.init(e,t)});var Ec=p("ZodNanoID",(e,t)=>{Cn.init(e,t),z.init(e,t)});var Ac=p("ZodCUID",(e,t)=>{jn.init(e,t),z.init(e,t)});var Tc=p("ZodCUID2",(e,t)=>{Rn.init(e,t),z.init(e,t)});var Nc=p("ZodULID",(e,t)=>{Dn.init(e,t),z.init(e,t)});var Cc=p("ZodXID",(e,t)=>{Mn.init(e,t),z.init(e,t)});var jc=p("ZodKSUID",(e,t)=>{Ln.init(e,t),z.init(e,t)});var Rc=p("ZodIPv4",(e,t)=>{Vn.init(e,t),z.init(e,t)});var Dc=p("ZodIPv6",(e,t)=>{Wn.init(e,t),z.init(e,t)});var Mc=p("ZodCIDRv4",(e,t)=>{qn.init(e,t),z.init(e,t)});var Lc=p("ZodCIDRv6",(e,t)=>{Gn.init(e,t),z.init(e,t)});var Fc=p("ZodBase64",(e,t)=>{Hn.init(e,t),z.init(e,t)});var Uc=p("ZodBase64URL",(e,t)=>{Yn.init(e,t),z.init(e,t)});var Jc=p("ZodE164",(e,t)=>{Qn.init(e,t),z.init(e,t)});var Bc=p("ZodJWT",(e,t)=>{eo.init(e,t),z.init(e,t)});var Vc=p("ZodUnknown",(e,t)=>{to.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wi(e,r,n,o)});function ee(){return ri(Vc)}var Kc=p("ZodNever",(e,t)=>{ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zi(e,r,n,o)});function Wc(e){return ni(Kc,e)}var qc=p("ZodArray",(e,t)=>{Xe(),no.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Si(e,r,n,o),e.element=t.element},{min(e,t){return this.check(ne(e,t))},nonempty(e){return this.check(ne(1,e))},max(e,t){return this.check(Ve(e,t))},length(e,t){return this.check(Ke(e,t))},unwrap(){return this.element}});function Gc(e,t){return oi(qc,e,t)}var Xc=p("ZodObject",(e,t)=>{Xe(),so.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oi(e,r,n,o),ks(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return eu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(A(this._zod.def,{catchall:e}))},passthrough(){return this.clone(A(this._zod.def,{catchall:ee()}))},loose(){return this.clone(A(this._zod.def,{catchall:ee()}))},strict(){return this.clone(A(this._zod.def,{catchall:Wc()}))},strip(){return this.clone(A(this._zod.def,{catchall:void 0}))},extend(e){return _s(this,e)},safeExtend(e){return ys(this,e)},merge(e){return xs(this,e)},pick(e){return hs(this,e)},omit(e){return gs(this,e)},partial(...e){return pr(is,this,e[0])},exactPartial(...e){return pr(ss,this,e[0],"exactPartial")},required(...e){return bs(cs,this,e[0])}});function He(e,t){let r={type:"object",shape:e??{},...g(t)};return new Xc(r)}var Hc=p("ZodUnion",(e,t)=>{co.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ii(e,r,n,o),e.options=t.options});function Wt(e,t){return new Hc({type:"union",options:e,...g(t)})}var Yc=p("ZodIntersection",(e,t)=>{uo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ei(e,r,n,o)});function Qc(e,t){return new Yc({type:"intersection",left:e,right:t})}var es=p("ZodRecord",(e,t)=>{Xe(),ao.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ai(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ce(e,t,r){if(!t||!t._zod)return new es({type:"record",keyType:D(),valueType:e,...g(t)});return new es({type:"record",keyType:e,valueType:t,...g(r)})}var Kt=p("ZodEnum",(e,t)=>{lo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ki(e,n,o,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Kt({...t,checks:[],...g(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Kt({...t,checks:[],...g(o),entries:i})}});function eu(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Kt({type:"enum",entries:r,...g(t)})}var tu=p("ZodTransform",(e,t)=>{Xe(),po.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pi(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new me(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(H(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(H(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function ru(e){return new tu({type:"transform",transform:e})}var is=p("ZodOptional",(e,t)=>{$t.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ts(e){return new is({type:"optional",innerType:e})}var ss=p("ZodExactOptional",(e,t)=>{fo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new ss({type:"optional",innerType:e})}var ou=p("ZodNullable",(e,t)=>{mo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ti(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rs(e){return new ou({type:"nullable",innerType:e})}var iu=p("ZodDefault",(e,t)=>{ho.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ji(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function su(e,t){return new iu({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():nt(t)}})}var cu=p("ZodPrefault",(e,t)=>{go.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ri(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function uu(e,t){return new cu({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():nt(t)}})}var cs=p("ZodNonOptional",(e,t)=>{_o.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ni(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function au(e,t){return new cs({type:"nonoptional",innerType:e,...g(t)})}var lu=p("ZodCatch",(e,t)=>{yo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Di(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pu(e,t){return new lu({type:"catch",innerType:e,catchValue:typeof t==="function"?t:hr(t)})}var fu=p("ZodPipe",(e,t)=>{xo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mi(e,r,n,o),e.in=t.in,e.out=t.out});function ns(e,t){return new fu({type:"pipe",in:e,out:t})}var du=p("ZodReadonly",(e,t)=>{bo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Li(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function mu(e){return new du({type:"readonly",innerType:e})}var hu=p("ZodCustom",(e,t)=>{vo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zi(e,r,n,o)});function gu(e,t={}){return ii(hu,e,t)}function _u(e,t){return si(e,t)}var ve=ce(D(),ee()).nullish();var $e=ce(D(),D().nullish()).nullish();var ze=Wt([ce(D(),ee()),ee().array()]).nullish();var qt=He({metadata:$e,data:ve,staticData:ze});var Gt=He({path:D().trim().nonempty(),component:D().trim().nonempty()});class Xt{window;#o;#t=new Map;#r=new Map;#n=new Map;#e=new Map;constructor(e){this.window=e;this.#a(),this.#i(),this.#u(),this.#s(),this.#c()}#i(){let e=this.window.document.body.querySelector(`script#${te.routes}[type="application/json"]`);if(!e)return;try{let t=e.textContent.trim(),r=JSON.parse(t);if(!Array.isArray(r))return;this.#o=r.map((n)=>{let o=Gt.safeParse(n);return!o.success?null:o.data}).filter((n)=>!!n)}catch(t){console.error("Error on parse routes:",t);return}}#s(){let e=this.window.document.body.querySelector(`script#${te.staticData}[type="application/json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=ze.safeParse(o);if(!i.success)return;this.#t.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse static data:",t);return}}#c(){let e=this.window.document.body.querySelector(`script#${te.data}[type="application/json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=ve.safeParse(o);if(!i.success)return;this.#r.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse data:",t);return}}#u(){let e=this.window.document.body.querySelector(`script#${te.metadata}[type="application/json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=$e.safeParse(o);if(!i.success)return;this.#n.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse metadata:",t);return}}#a(){let e=this.window.document.head.querySelector("title"),t=this.window.document.head.querySelector('meta[name="description"]'),r=this.window.document.head.querySelector('meta[name="keywords"]'),n=this.window.document.head.querySelector('link[rel="canonical"]'),o=this.window.document.head.querySelector('meta[property="og:type"]'),i=this.window.document.head.querySelector('meta[property="og:title"]'),s=this.window.document.head.querySelector('meta[property="og:description"]'),c=this.window.document.head.querySelector('meta[property="og:image"]'),u=this.window.document.head.querySelector('meta[property="og:url"]');if(e)this.#e.set("title",e);if(t)this.#e.set("description",t);if(r)this.#e.set("keywords",r);if(n)this.#e.set("canonical",n);if(o)this.#e.set("ogType",o);if(i)this.#e.set("ogTitle",i);if(s)this.#e.set("ogDescription",s);if(c)this.#e.set("ogImage",c);if(u)this.#e.set("ogUrl",u)}setMetadataToElement(...[e,t]){switch(e){case"title":{let r=this.#e.get(e);r&&"innerText"in r&&(r.innerText=t?.trim()||"");return}case"description":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"keywords":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"canonical":{this.#e.get(e)?.setAttribute("href",t?.trim()||"");return}case"ogType":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogDescription":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogImage":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogUrl":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}}}inferMetadata(e){for(let[t,r]of Object.entries(e))switch(t){case"title":{this.setMetadataToElement("title",r),this.setMetadataToElement("ogTitle",r);break}case"description":{this.setMetadataToElement("description",r),this.setMetadataToElement("ogDescription",r);break}case"image":{this.setMetadataToElement("ogImage",r);break}case"canonical":{this.setMetadataToElement("canonical",r);break}case"url":{this.setMetadataToElement("ogUrl",r);break}case"type":{this.setMetadataToElement("ogType",r);break}}}async fetchRoute({cache:e,...t}){let r="url"in t?`${t.url.pathname}${t.url.search}`:`${t.pathname}${t.search}`;if(e){let n=this.#r.get(r),o=this.#n.get(r),i=this.#t.get(r);if(n&&o&&i){if(o)this.inferMetadata(o);return Object.freeze({data:n,metadata:o,staticData:i})}}try{let n=new Headers;n.append("x-requested-with","XMLHttpRequest"),n.append("content-type","application/json");let o=await fetch(`${origin}${r}`,{method:"GET",headers:n});if(!o.ok)throw Error(`Can not fetch data [${r}]`);let i=await o.json(),s=qt.safeParse(i);if(!s.success)throw s.error;if(this.#r.set(r,s.data.data),this.#n.set(r,s.data.metadata),this.#t.set(r,s.data.staticData),s.data.metadata)this.inferMetadata(s.data.metadata);return Object.freeze(s.data)}catch(n){console.error("Error on fetch full route data:",n);return}}get routes(){return this.#o}get staticData(){let{pathname:e,search:t}=this.window.location;return this.#t.get(`${e}${t}`)}get data(){let{pathname:e,search:t}=this.window.location;return this.#r.get(`${e}${t}`)}get metadata(){let{pathname:e,search:t}=this.window.location;return this.#n.get(`${e}${t}`)}}export{us as Vanilla};
|
|
58
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let a=e.external.registry.get(s[0])?.id;if(t!==s[0]&&a){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function li(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;li(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let i=n.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var pi=new Set(["type","properties","required","additionalProperties"]),ui=["oneOf","anyOf"];function ai(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Rt(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!pi.has(s))return null;t.push(i)}let r={},n=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let c=[];for(let a of t){let l=a.properties?.[s]??ai(a);if(l===null||l===void 0)continue;if(!c.some((f)=>JSON.stringify(f)===JSON.stringify(l)))c.push(l)}let u=c.length===1?c[0]:Rt(c)??{allOf:c};j(r,s,u)}for(let s of i.required??[])n.add(s)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let c=ai(s);if(c&&!i.some((u)=>JSON.stringify(u)===JSON.stringify(c)))i.push(c)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function nc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of pi)if(o in e)return;let r=t.filter((o)=>ui.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=Rt(t);else{let o=r[0],i=ui.find((u)=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;let s=t.filter((u)=>u!==o),c=o[i].map((u)=>Rt([...s,u]));if(c.some((u)=>!u))return;n={[i]:c}}if(!n)return;delete e.allOf,xe(e,n)}function Lt(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(c)=>{let u=e.seen.get(c);if(u.ref===null)return;let a=u.def??u.schema,l={...a},f=u.ref;if(u.ref=null,f){n(f);let m=e.seen.get(f),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))a.allOf=a.allOf??[],a.allOf.push(h);else xe(a,h);if(xe(a,l),c._zod.parent===f)for(let y in a){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete a[y]}if(h.$ref&&m.def)for(let y in a){if(y==="$ref"||y==="allOf")continue;if(y in m.def&&JSON.stringify(a[y])===JSON.stringify(m.def[y]))delete a[y]}}let d=c._zod.parent;if(d&&d!==f){n(d);let m=e.seen.get(d);if(m?.schema.$ref){if(a.$ref=m.schema.$ref,m.def)for(let h in a){if(h==="$ref"||h==="allOf")continue;if(h in m.def&&JSON.stringify(a[h])===JSON.stringify(m.def[h]))delete a[h]}}}e.override({zodSchema:c,jsonSchema:a,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())n(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())li(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let u of e.seen.values())for(let a of[u.schema,u.def]){let l=a?.allOf;if(!Array.isArray(l))continue;let f=c.get(l);if(f)f.push(a);else c.set(l,[a])}for(let u of e.intersections)for(let a of c.get(u)??[])nc(a)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}xe(o,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let u=c[1];if(u.def&&u.defId){if(u.def.id===u.defId)delete u.def.id;j(s,u.defId,u.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:be(t,"input",e.processors),output:be(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function O(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return O(n.element,r);if(n.type==="set")return O(n.valueType,r);if(n.type==="lazy")return O(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return O(n.innerType,r);if(n.type==="intersection")return O(n.left,r)||O(n.right,r);if(n.type==="record"||n.type==="map")return O(n.keyType,r)||O(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return O(n.in,r)||O(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(O(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(O(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(O(o,r))return!0;if(n.rest&&O(n.rest,r))return!0;return!1}return!1}var fi=(e,t={})=>(r)=>{let n=Dt({...r,processors:t});return Z(e,n),Mt(n,e),Lt(n,e)},be=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=Dt({...o??{},target:i,io:t,processors:r});return Z(e,s),Mt(s,e),Lt(s,e)};var ie=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},se=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},di=(e,t)=>{ie(e,"minimum",t),se(e,"maximum",t)},_i=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},yi=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},xi=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},bi=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},mi=(e,t)=>ie(e,"minimum",t.minimum),hi=(e,t)=>se(e,"maximum",t.maximum),gi=(e)=>(t,r)=>{bi(t,r.format);let[n,o]=e[r.format];ie(t,"minimum",n),se(t,"maximum",o)},oc={greater_than:(e,t)=>ie(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>se(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>_i(e,t.value),number_format:gi(it),bigint_format:gi(st),min_length:mi,max_length:hi,length_equals:(e,t)=>di(e,t.length),min_size:mi,max_size:hi,size_equals:(e,t)=>di(e,t.size),string_format:(e,t)=>{if(bi(e,t.format),t.pattern)yi(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>xi(e,t.mime)};function Q(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)oc[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ie(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ie(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)se(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)se(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)_i(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)xi(t,o.mime);for(let i of o.patterns??[])yi(t,i);return t}var ic={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sc=new Map([[vt,Wr],[Le,qr]]),vi=(e)=>sc.get(e)??e,$i=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:c,patterns:u,contentEncoding:a,laxFormat:l}=Q(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(c){if(o.format=ic[c]??c,o.format==="")delete o.format;if(c==="time"||l)delete o.format}if(a)o.contentEncoding=a;if(u&&u.size>0){let f=[...u].map(vi);if(f.length===1)o.pattern=f[0].source;else if(f.length>1)o.allOf=[...f.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}};var zi=(e,t,r,n)=>{r.not={}};var wi=(e,t,r,n)=>{};var ki=(e,t,r,n)=>{let o=e._zod.def,i=fe(o.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i};var Zi=(e,t,r,n)=>{oe(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Pi=(e,t,r,n)=>{oe(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Si=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:c}=Q(e);if(typeof s==="number")o.minItems=s;if(typeof c==="number")o.maxItems=c;o.type="array",o.items=Z(i.element,t,{...n,path:[...n.path,"items"]})};function We(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return We(t.out);if(t.type==="catch")return We(t.innerType);return e._zod.optin}var Oi=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&oe(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in s)j(o.properties,l,Z(s[l],t,{...n,path:[...n.path,"properties",l]}));let u=new Set(Object.keys(s)),a=new Set([...u].filter((l)=>{let f=i.shape[l];if(t.io==="input")return We(f)===void 0;else return f._zod.optout===void 0}));if(a.size>0)o.required=Array.from(a);if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=Z(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})};var Ii=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,u)=>Z(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",u]}));if(i)r.oneOf=s;else r.anyOf=s},Ei=(e,t,r,n)=>{let o=e._zod.def,i=Z(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=Z(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=(a)=>("allOf"in a)&&Object.keys(a).length===1,u=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=u,t.intersections.push(u)};function Ft(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let _=Ft(e,h,r);return _===h?t:_}for(let h of["anyOf","oneOf"]){let _=t[h];if(!Array.isArray(_))continue;let y=_.map((w)=>Ft(e,w,r));if(y.some((w,C)=>w!==_[C]))t={...t,[h]:y}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((h)=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((h)=>typeof h==="number"))return t;let{minimum:s,maximum:c,exclusiveMinimum:u,exclusiveMaximum:a,multipleOf:l,format:f,id:d,...m}=t;if(m.enum)m.enum=m.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!i)m.pattern=(n.includes("number")?je:gt).source;return m}var Ut=new WeakMap;function cc(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Ut.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Ft(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let i=o&&r.get(o.propertyNames);if(i)o.propertyNames=i}}var Ai=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,c=Q(s).patterns;if(i.mode==="loose"&&c&&c.size>0){let l=Z(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let f of c)j(o.patternProperties,vi(f).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=Z(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Ut.get(t);if(!l)l=[],Ut.set(t,l),t.deferred.push(()=>cc(t));l.push(e)}o.additionalProperties=Z(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let u=s._zod.values,a=t.io==="input"&&We(i.valueType)!==void 0;if(u&&!i.partial&&!a){let l=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)o.required=l.map(String)}},Ti=(e,t,r,n)=>{let o=e._zod.def,i=Z(o.innerType,t,n),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},Ni=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Jt=Symbol();function Ci(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(c,u)=>{if(typeof u!=="bigint")return u;return i=!0,null});if(!i)return JSON.parse(s);return oe(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Jt}var ji=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=Ci(o.defaultValue,e,t,r,n);if(s!==Jt)r.default=s},Ri=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Ci(o.defaultValue,e,t,r,n);if(s!==Jt)r._prefault=s},Di=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{oe(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},Mi=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;Z(s,t,n);let c=t.seen.get(e);c.ref=s},Li=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Bt=(e,t,r,n)=>{let o=e._zod.def;Z(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var Fi=new WeakSet([Object.prototype,Error.prototype]);function qe(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var xc=(e,t)=>{br.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Fi.has(r))return;Fi.add(r),qe(r,"format",(n)=>(o)=>$r(n,o)),qe(r,"flatten",(n)=>(o)=>vr(n,o)),qe(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,de,2)}),qe(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,de,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var N=p("ZodError",xc,void 0,{Parent:Error});var Ui=Ae(N),Ji=Te(N),Bi=Ne(N),Vi=Ce(N),Ki=wr(N),Wi=kr(N),qi=Zr(N),Gi=Pr(N),Xi=Sr(N),Hi=Or(N),Yi=Ir(N),Qi=Er(N);function vc(){if(!I.localeError)T(kt())}function Xe(){if(!I.memoizer)T({memoizer:Zo()})}var P=p("ZodType",(e,t)=>(vc(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(A(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return L(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gu(e,t))},superRefine(e,t){return this.check(_u(e,t))},overwrite(e){return this.check(q(e))},optional(){return ts(this)},exactOptional(){return nu(this)},nullable(){return rs(this)},nullish(){return ts(rs(this))},nonoptional(e){return au(this,e)},array(){return Gc(this)},or(e){return Wt([this,e])},and(e){return Qc(this,e)},transform(e){return ns(this,ru(e))},default(e){return su(this,e)},prefault(e){return uu(this,e)},catch(e){return pu(this,e)},pipe(e){return ns(this,e)},readonly(){return mu(this)},describe(e){let t=this.clone();return Y.add(t,{description:e}),t},meta(...e){if(e.length===0)return Y.get(this);let t=this.clone();return Y.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ut(this,"~standard",{...bt(this),jsonSchema:{input:be(this,"input"),output:be(this,"output")}})},set "~standard"(e){V(this,"~standard",e)},parse:function e(t,r){return Ui(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ji(this,t,r,{callee:e})},safeParse(e,t){return Bi(this,e,t)},async safeParseAsync(e,t){return Vi(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){V(this,"spa",e)},validate(e,t){return ft(this,e,t)},validateAsync(e,t){return dt(this,e,t)},encode:function e(t,r){return Ki(this,t,r,{callee:e})},decode:function e(t,r){return Wi(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await qi(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Gi(this,t,r,{callee:e})},safeEncode(e,t){return Xi(this,e,t)},safeDecode(e,t){return Hi(this,e,t)},async safeEncodeAsync(e,t){return Yi(this,e,t)},async safeDecodeAsync(e,t){return Qi(this,e,t)},toJSONSchema(e){return fi(this,{})(e)},get description(){return Y.get(this)?.description},get _def(){return this._zod.def}}),os=p("_ZodString",(e,t)=>{Me.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$i(e,r,n,o)},$s({format:(e)=>Q(e).format??null,minLength:(e)=>Q(e).minimum??null,maxLength:(e)=>Q(e).maximum??null},{regex(...e){return this.check(Zt(...e))},includes(...e){return this.check(Ot(...e))},startsWith(...e){return this.check(It(...e))},endsWith(...e){return this.check(Et(...e))},min(...e){return this.check(ne(...e))},max(...e){return this.check(Ve(...e))},length(...e){return this.check(Ke(...e))},nonempty(...e){return this.check(ne(1,...e))},lowercase(e){return this.check(Pt(e))},uppercase(e){return this.check(St(e))},trim(){return this.check(Tt())},normalize(...e){return this.check(At(...e))},toLowerCase(){return this.check(Nt())},toUpperCase(){return this.check(Ct())},slugify(){return this.check(jt())}})),$c=p("ZodString",(e,t)=>{Me.init(e,t),os.init(e,t)},{email(e){return this.check(Io(Pc,e))},url(e){return this.check(jo(Oc,e))},jwt(e){return this.check(Ho(Bc,e))},emoji(e){return this.check(Ro(Ic,e))},guid(e){return this.check(Eo(Sc,e))},uuid(e){return this.check(Ao(Ge,e))},uuidv4(e){return this.check(To(Ge,e))},uuidv6(e){return this.check(No(Ge,e))},uuidv7(e){return this.check(Co(Ge,e))},nanoid(e){return this.check(Do(Ec,e))},cuid(e){return this.check(Mo(Ac,e))},cuid2(e){return this.check(Lo(Tc,e))},ulid(e){return this.check(Fo(Nc,e))},base64(e){return this.check(qo(Fc,e))},base64url(e){return this.check(Go(Uc,e))},xid(e){return this.check(Uo(Cc,e))},ksuid(e){return this.check(Jo(jc,e))},ipv4(e){return this.check(Bo(Rc,e))},ipv6(e){return this.check(Vo(Dc,e))},cidrv4(e){return this.check(Ko(Mc,e))},cidrv6(e){return this.check(Wo(Lc,e))},e164(e){return this.check(Xo(Jc,e))},datetime(e){return this.check(Yo(zc,e))},date(e){return this.check(Qo(wc,e))},time(e){return this.check(ei(kc,e))},duration(e){return this.check(ti(Zc,e))}});function D(e){return Oo($c,e)}var z=p("ZodStringFormat",(e,t)=>{v.init(e,t),os.init(e,t)}),zc=p("ZodISODateTime",(e,t)=>{Fn.init(e,t),z.init(e,t)}),wc=p("ZodISODate",(e,t)=>{Un.init(e,t),z.init(e,t)}),kc=p("ZodISOTime",(e,t)=>{Jn.init(e,t),z.init(e,t)}),Zc=p("ZodISODuration",(e,t)=>{Bn.init(e,t),z.init(e,t)}),Pc=p("ZodEmail",(e,t)=>{In.init(e,t),z.init(e,t)});var Sc=p("ZodGUID",(e,t)=>{Sn.init(e,t),z.init(e,t)});var Ge=p("ZodUUID",(e,t)=>{On.init(e,t),z.init(e,t)});var Oc=p("ZodURL",(e,t)=>{Tn.init(e,t),z.init(e,t)});var Ic=p("ZodEmoji",(e,t)=>{Nn.init(e,t),z.init(e,t)});var Ec=p("ZodNanoID",(e,t)=>{Cn.init(e,t),z.init(e,t)});var Ac=p("ZodCUID",(e,t)=>{jn.init(e,t),z.init(e,t)});var Tc=p("ZodCUID2",(e,t)=>{Rn.init(e,t),z.init(e,t)});var Nc=p("ZodULID",(e,t)=>{Dn.init(e,t),z.init(e,t)});var Cc=p("ZodXID",(e,t)=>{Mn.init(e,t),z.init(e,t)});var jc=p("ZodKSUID",(e,t)=>{Ln.init(e,t),z.init(e,t)});var Rc=p("ZodIPv4",(e,t)=>{Vn.init(e,t),z.init(e,t)});var Dc=p("ZodIPv6",(e,t)=>{Wn.init(e,t),z.init(e,t)});var Mc=p("ZodCIDRv4",(e,t)=>{qn.init(e,t),z.init(e,t)});var Lc=p("ZodCIDRv6",(e,t)=>{Gn.init(e,t),z.init(e,t)});var Fc=p("ZodBase64",(e,t)=>{Hn.init(e,t),z.init(e,t)});var Uc=p("ZodBase64URL",(e,t)=>{Yn.init(e,t),z.init(e,t)});var Jc=p("ZodE164",(e,t)=>{Qn.init(e,t),z.init(e,t)});var Bc=p("ZodJWT",(e,t)=>{eo.init(e,t),z.init(e,t)});var Vc=p("ZodUnknown",(e,t)=>{to.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wi(e,r,n,o)});function ee(){return ri(Vc)}var Kc=p("ZodNever",(e,t)=>{ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zi(e,r,n,o)});function Wc(e){return ni(Kc,e)}var qc=p("ZodArray",(e,t)=>{Xe(),no.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Si(e,r,n,o),e.element=t.element},{min(e,t){return this.check(ne(e,t))},nonempty(e){return this.check(ne(1,e))},max(e,t){return this.check(Ve(e,t))},length(e,t){return this.check(Ke(e,t))},unwrap(){return this.element}});function Gc(e,t){return oi(qc,e,t)}var Xc=p("ZodObject",(e,t)=>{Xe(),so.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oi(e,r,n,o),ks(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return eu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(A(this._zod.def,{catchall:e}))},passthrough(){return this.clone(A(this._zod.def,{catchall:ee()}))},loose(){return this.clone(A(this._zod.def,{catchall:ee()}))},strict(){return this.clone(A(this._zod.def,{catchall:Wc()}))},strip(){return this.clone(A(this._zod.def,{catchall:void 0}))},extend(e){return _s(this,e)},safeExtend(e){return ys(this,e)},merge(e){return xs(this,e)},pick(e){return hs(this,e)},omit(e){return gs(this,e)},partial(...e){return pr(is,this,e[0])},exactPartial(...e){return pr(ss,this,e[0],"exactPartial")},required(...e){return bs(cs,this,e[0])}});function He(e,t){let r={type:"object",shape:e??{},...g(t)};return new Xc(r)}var Hc=p("ZodUnion",(e,t)=>{co.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ii(e,r,n,o),e.options=t.options});function Wt(e,t){return new Hc({type:"union",options:e,...g(t)})}var Yc=p("ZodIntersection",(e,t)=>{uo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ei(e,r,n,o)});function Qc(e,t){return new Yc({type:"intersection",left:e,right:t})}var es=p("ZodRecord",(e,t)=>{Xe(),ao.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ai(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ce(e,t,r){if(!t||!t._zod)return new es({type:"record",keyType:D(),valueType:e,...g(t)});return new es({type:"record",keyType:e,valueType:t,...g(r)})}var Kt=p("ZodEnum",(e,t)=>{lo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ki(e,n,o,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Kt({...t,checks:[],...g(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Kt({...t,checks:[],...g(o),entries:i})}});function eu(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Kt({type:"enum",entries:r,...g(t)})}var tu=p("ZodTransform",(e,t)=>{Xe(),po.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pi(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new me(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(H(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(H(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function ru(e){return new tu({type:"transform",transform:e})}var is=p("ZodOptional",(e,t)=>{$t.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ts(e){return new is({type:"optional",innerType:e})}var ss=p("ZodExactOptional",(e,t)=>{fo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new ss({type:"optional",innerType:e})}var ou=p("ZodNullable",(e,t)=>{mo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ti(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rs(e){return new ou({type:"nullable",innerType:e})}var iu=p("ZodDefault",(e,t)=>{ho.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ji(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function su(e,t){return new iu({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():nt(t)}})}var cu=p("ZodPrefault",(e,t)=>{go.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ri(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function uu(e,t){return new cu({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():nt(t)}})}var cs=p("ZodNonOptional",(e,t)=>{_o.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ni(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function au(e,t){return new cs({type:"nonoptional",innerType:e,...g(t)})}var lu=p("ZodCatch",(e,t)=>{yo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Di(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pu(e,t){return new lu({type:"catch",innerType:e,catchValue:typeof t==="function"?t:hr(t)})}var fu=p("ZodPipe",(e,t)=>{xo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mi(e,r,n,o),e.in=t.in,e.out=t.out});function ns(e,t){return new fu({type:"pipe",in:e,out:t})}var du=p("ZodReadonly",(e,t)=>{bo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Li(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function mu(e){return new du({type:"readonly",innerType:e})}var hu=p("ZodCustom",(e,t)=>{vo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zi(e,r,n,o)});function gu(e,t={}){return ii(hu,e,t)}function _u(e,t){return si(e,t)}var ve=ce(D(),ee()).nullish();var $e=ce(D(),D().nullish()).nullish();var ze=Wt([ce(D(),ee()),ee().array()]).nullish();var qt=He({metadata:$e,data:ve,staticData:ze});var Gt=He({path:D().trim().nonempty(),component:D().trim().nonempty()});class Xt{window;#o;#t=new Map;#r=new Map;#n=new Map;#e=new Map;constructor(e){this.window=e;this.#a(),this.#i(),this.#u(),this.#s(),this.#c()}#i(){let e=this.window.document.body.querySelector(`script#${te.routes}[type="application/ld+json"]`);if(!e)return;try{let t=e.textContent.trim(),r=JSON.parse(t);if(!Array.isArray(r))return;this.#o=r.map((n)=>{let o=Gt.safeParse(n);return!o.success?null:o.data}).filter((n)=>!!n)}catch(t){console.error("Error on parse routes:",t);return}}#s(){let e=this.window.document.body.querySelector(`script#${te.staticData}[type="application/ld+json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=ze.safeParse(o);if(!i.success)return;this.#t.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse static data:",t);return}}#c(){let e=this.window.document.body.querySelector(`script#${te.data}[type="application/ld+json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=ve.safeParse(o);if(!i.success)return;this.#r.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse data:",t);return}}#u(){let e=this.window.document.body.querySelector(`script#${te.metadata}[type="application/ld+json"]`);if(!e)return;try{let{pathname:t,search:r}=this.window.location,n=e.textContent.trim(),o=JSON.parse(n),i=$e.safeParse(o);if(!i.success)return;this.#n.set(`${t}${r}`,i.data)}catch(t){console.error("Error on parse metadata:",t);return}}#a(){let e=this.window.document.head.querySelector("title"),t=this.window.document.head.querySelector('meta[name="description"]'),r=this.window.document.head.querySelector('meta[name="keywords"]'),n=this.window.document.head.querySelector('link[rel="canonical"]'),o=this.window.document.head.querySelector('meta[property="og:type"]'),i=this.window.document.head.querySelector('meta[property="og:title"]'),s=this.window.document.head.querySelector('meta[property="og:description"]'),c=this.window.document.head.querySelector('meta[property="og:image"]'),u=this.window.document.head.querySelector('meta[property="og:url"]');if(e)this.#e.set("title",e);if(t)this.#e.set("description",t);if(r)this.#e.set("keywords",r);if(n)this.#e.set("canonical",n);if(o)this.#e.set("ogType",o);if(i)this.#e.set("ogTitle",i);if(s)this.#e.set("ogDescription",s);if(c)this.#e.set("ogImage",c);if(u)this.#e.set("ogUrl",u)}setMetadataToElement(...[e,t]){switch(e){case"title":{let r=this.#e.get(e);r&&"innerText"in r&&(r.innerText=t?.trim()||"");return}case"description":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"keywords":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"canonical":{this.#e.get(e)?.setAttribute("href",t?.trim()||"");return}case"ogType":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogTitle":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogDescription":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogImage":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}case"ogUrl":{this.#e.get(e)?.setAttribute("content",t?.trim()||"");return}}}inferMetadata(e){for(let[t,r]of Object.entries(e))switch(t){case"title":{this.setMetadataToElement("title",r),this.setMetadataToElement("ogTitle",r);break}case"description":{this.setMetadataToElement("description",r),this.setMetadataToElement("ogDescription",r);break}case"image":{this.setMetadataToElement("ogImage",r);break}case"canonical":{this.setMetadataToElement("canonical",r);break}case"url":{this.setMetadataToElement("ogUrl",r);break}case"type":{this.setMetadataToElement("ogType",r);break}}}async fetchRoute({cache:e,...t}){let r="url"in t?`${t.url.pathname}${t.url.search}`:`${t.pathname}${t.search}`;if(e){let n=this.#r.get(r),o=this.#n.get(r),i=this.#t.get(r);if(n&&o&&i){if(o)this.inferMetadata(o);return Object.freeze({data:n,metadata:o,staticData:i})}}try{let n=new Headers;n.append("x-requested-with","XMLHttpRequest"),n.append("x-fetch-target","RegoRoute"),n.append("content-type","application/json");let o=await fetch(`${origin}${r}`,{method:"GET",headers:n});if(!o.ok)throw Error(`Can not fetch data [${r}]`);let i=await o.json(),s=qt.safeParse(i);if(!s.success)throw s.error;if(this.#r.set(r,s.data.data),this.#n.set(r,s.data.metadata),this.#t.set(r,s.data.staticData),s.data.metadata)this.inferMetadata(s.data.metadata);return Object.freeze(s.data)}catch(n){console.error("Error on fetch full route data:",n);return}}get routes(){return this.#o}get staticData(){let{pathname:e,search:t}=this.window.location;return this.#t.get(`${e}${t}`)}get data(){let{pathname:e,search:t}=this.window.location;return this.#r.get(`${e}${t}`)}get metadata(){let{pathname:e,search:t}=this.window.location;return this.#n.get(`${e}${t}`)}}export{us as Vanilla};
|
|
59
59
|
|
|
60
|
-
//# debugId=
|
|
60
|
+
//# debugId=C1E0A340300D163B64756E2164756E21
|