runcheck 0.43.0 → 0.44.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.
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var n in r)f(e,n,{get:r[n],enumerable:!0})},P=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of b(r))!g.call(e,t)&&t!==n&&f(e,t,{get:()=>r[t],enumerable:!(i=R(r,t))||i.enumerable});return e};var w=e=>P(f({},"__esModule",{value:!0}),e);var W={};m(W,{rc_boolean_autofix:()=>A,rc_number_autofix:()=>S,rc_string_autofix:()=>I});module.exports=w(W);function k(e){return{...this,b:e}}function u(e,r){return r.startsWith("$")?r:`${e.n?`$${e.n}: `:""}${r}`}function c(e,r){e.l.push(u(e,r))}function o(e,r,n,i){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let t=i();if(t&&(t===!0||!t.errors)){let a=t===!0?r:t.data;return e.c&&!e.c(a)?[!1,[u(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.b;if(a!==void 0)return c(n,`Fallback used, errors -> ${y(t,n,e,r)}`),[!0,O(a)?a():a];if(e.j&&e._){let l=e._(r);if(l)return e.c&&!e.c(l.fixed)?[!1,[u(n,`Predicate failed for autofix in type '${e.e}'`)]]:(c(n,`Autofixed from error "${y(t,n,e,r)}"`),[!0,l.fixed])}}return[!1,t?t.errors:[u(n,T(e,r))]]}function y(e,r,n,i){return e?e.errors.map(t=>t.replace(r.n,"")).join("; "):T(n,i)}function x(e){return{...this,j:!0,_:e}}function $(e){return{...this,c:e}}function d(){return{...this,T:!0}}function T(e,r){return`Type '${j(r,!!e.g)}' is not assignable to '${e.e}'`}function E(){return{...this,p:!0,e:`${this.e}_or_null`}}function N(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var s={__rc_type:void 0,withFallback:k,where:$,optional:d,optionalKey:d,orNullish:N,withAutofix:x,orNull:E,b:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,g:!1,y:void 0,_:void 0,k:void 0,t:void 0,R:!1,h:!1,u:[]},C={...s,r(e,r){return o(this,e,r,()=>e===void 0)},e:"undefined"},K={...s,r(e,r){return o(this,e,r,()=>e===null)},e:"null"},q={...s,r(e,r){return o(this,e,r,()=>!0)},e:"any"},V={...s,r(e,r){return o(this,e,r,()=>!0)},e:"unknown"},p={...s,r(e,r){return o(this,e,r,()=>typeof e=="boolean")},e:"boolean"},_={...s,r(e,r){return o(this,e,r,()=>typeof e=="string")},e:"string"},h={...s,r(e,r){return o(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},F={...s,r(e,r){return o(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function j(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function O(e){return typeof e=="function"}var A=p.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),I=_.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),S=h.withAutofix(e=>{if(typeof e=="string"){let r=Number(e);if(!Number.isNaN(r))return{fixed:r}}return!1});0&&(module.exports={rc_boolean_autofix,rc_number_autofix,rc_string_autofix});
1
+ "use strict";var f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var n in r)f(e,n,{get:r[n],enumerable:!0})},P=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of b(r))!g.call(e,t)&&t!==n&&f(e,t,{get:()=>r[t],enumerable:!(o=R(r,t))||o.enumerable});return e};var w=e=>P(f({},"__esModule",{value:!0}),e);var W={};m(W,{rc_boolean_autofix:()=>A,rc_number_autofix:()=>S,rc_string_autofix:()=>I});module.exports=w(W);function k(e){return{...this,j:e}}function u(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function c(e,r){e.l.push(r.startsWith("$")?r:u(e,r))}function s(e,r,n,o){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let i=t===!0?r:t.data;return e.c&&!e.c(i)?[!1,[u(n,`Predicate failed for type '${e.e}'`)]]:[!0,i]}if(!n.i){let i=e.j;if(i!==void 0)return c(n,`Fallback used, errors -> ${y(t,n,e,r)}`),[!0,O(i)?i():i];if(e.g&&e.h){let l=e.h(r);if(l)return e.c&&!e.c(l.fixed)?[!1,[u(n,`Predicate failed for autofix in type '${e.e}'`)]]:(c(n,`Autofixed from error "${y(t,n,e,r)}"`),[!0,l.fixed])}}return[!1,t?t.errors:[u(n,T(e,r))]]}function y(e,r,n,o){return e?e.errors.map(t=>t.replace(r.n,"")).join("; "):T(n,o)}function x(e){return{...this,g:!0,h:e}}function $(e){return{...this,c:e}}function d(){return{...this,T:!0}}function T(e,r){return`Type '${j(r,!!e.k)}' is not assignable to '${e.e}'`}function E(){return{...this,p:!0,e:`${this.e}_or_null`}}function N(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var a={__rc_type:void 0,withFallback:k,where:$,optional:d,optionalKey:d,orNullish:N,withAutofix:x,orNull:E,R:void 0,j:void 0,c:void 0,T:!1,p:!1,d:!1,g:!1,k:!1,y:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},C={...a,r(e,r){return s(this,e,r,()=>e===void 0)},e:"undefined"},K={...a,r(e,r){return s(this,e,r,()=>e===null)},e:"null"},q={...a,r(e,r){return s(this,e,r,()=>!0)},e:"any"},V={...a,r(e,r){return s(this,e,r,()=>!0)},e:"unknown"},p={...a,r(e,r){return s(this,e,r,()=>typeof e=="boolean")},e:"boolean"},_={...a,r(e,r){return s(this,e,r,()=>typeof e=="string")},e:"string"},h={...a,r(e,r){return s(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},F={...a,r(e,r){return s(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function j(e,r){let n=typeof e,o=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(o==="string"||o==="number"||o==="boolean")?`${o}(${e})`:o}function O(e){return typeof e=="function"}var A=p.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),I=_.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),S=h.withAutofix(e=>{if(typeof e=="string"){let r=Number(e);if(!Number.isNaN(r))return{fixed:r}}return!1});0&&(module.exports={rc_boolean_autofix,rc_number_autofix,rc_string_autofix});
@@ -1 +1 @@
1
- import{q as f,r as t,s as o}from"./chunk-TS4C7BNK.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
1
+ import{q as f,r as t,s as o}from"./chunk-FXQPJI45.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
@@ -0,0 +1 @@
1
+ function V(e,r){return{...r,y:e}}function D(e){return x(e)&&"__rc_type"in e}function W(e){if(D(e))return e;if(x(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=W(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=W(o);return{...f,t:n,e:"object",_:!0,u:Object.entries(n),r(t,o){return y(this,t,o,()=>{if(!x(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let c=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[T]of this.u)s.has(T)?s.delete(T):c.push(p(o,`Key '${T}' is missing`));for(let T of s)c.push(p(o,`Key '${T}' is not defined in the object shape`));return{data:void 0,errors:c}}let l={},i=[],u=o.n,d=-1;for(let[c,T]of this.u){let h=c;d+=1;let g=`.${c}`,j=`${u}${g}`;o.n=j;let R,k=c;if(T.y&&(R=t[T.y],k=T.y),R===void 0&&(R=t[c],k=c),R===void 0&&r==="snake_case"){let O=v(c);R=t[O],k=O}s?.delete(k);let[P,_]=T.r(R,o);if(P)l[h]=_;else{for(let O of _)o.n=j,i.push(O);if(o.o){o.a=d;break}}}if(s&&s.size>0)for(let c of s)o.n=u,i.push(p(o,`Key '${c}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...l}}:{errors:!1,data:l}})}}}function M(e,r){return{...b(e,r),e:"extends_object",b:!0}}function z(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function L(e,r){return{...b(e,r),e:"strict_obj"}}function Q(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function J(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function Z(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function G(){return(e,r)=>b(e,r)}function H(e){return{...this,j:e}}function p(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function K(e,r){e.l.push(r.startsWith("$")?r:p(e,r))}function B(e,r){r.forEach(n=>K(e,n))}function y(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.j;if(a!==void 0)return K(n,`Fallback used, errors -> ${N(o,n,e,r)}`),[!0,I(a)?a():a];if(e.g&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(K(n,`Autofixed from error "${N(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,F(e,r))]]}function N(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):F(n,t)}function X(e){return{...this,g:!0,h:e}}function Y(e){return{...this,c:e}}function C(){return{...this,T:!0}}function F(e,r){return`Type '${w(r,!!e.k)}' is not assignable to '${e.e}'`}function ee(){return{...this,p:!0,e:`${this.e}_or_null`}}function re(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var f={__rc_type:void 0,withFallback:H,where:Y,optional:C,optionalKey:C,orNullish:re,withAutofix:X,orNull:ee,R:void 0,j:void 0,c:void 0,T:!1,p:!1,d:!1,g:!1,k:!1,y:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},fe={...f,r(e,r){return y(this,e,r,()=>e===void 0)},e:"undefined"},le={...f,r(e,r){return y(this,e,r,()=>e===null)},e:"null"},Te={...f,r(e,r){return y(this,e,r,()=>!0)},e:"any"},de={...f,r(e,r){return y(this,e,r,()=>!0)},e:"unknown"},pe={...f,r(e,r){return y(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Re={...f,r(e,r){return y(this,e,r,()=>typeof e=="string")},e:"string"},he={...f,r(e,r){return y(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},_e={...f,r(e,r){return y(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function be(e){return{...f,r(r,n){return y(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function je(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...f,r(r,n){return y(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var q=1;function ge(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...f,r(r,n){return y(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,l=[],i=0;for(let u of e){i+=1,u._&&(n.n=`${t}|union ${i}|`);let d=n.o;n.o=!0,n.a=0;let[c,T]=u.r(r,n),h=n.a;if(n.o=d,n.a=0,c)return!0;u._&&h!==-1?h>0?l.push(...T):(a<q&&o.push(...T),a+=1):s=!0}return n.n=t,l.length>0||o.length>0?((a>q||s)&&o.push(p(n,"not matches any other union member")),{errors:[...l,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function ke(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return y(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!==void 0?!0:{data:I(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`}}function Oe(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return y(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!=null?!0:{data:I(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`}}function ne(e,{checkKey:r,looseCheck:n}={}){return{...f,e:`record<string, ${e.e}>`,r(t,o){return y(this,t,o,()=>{if(!x(t))return!1;let a={},s=[],l=o.n;for(let[i,u]of Object.entries(t)){let d=`.${i}`,c=`${l}${d}`;if(o.n=c,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let T=t[i],[h,g]=e.r(u,o);if(h)a[i]=T;else{let j=g;for(let R of j)s.push(R);if(o.o)break}}if(s.length>0)if(n)B(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function me(e,{checkKey:r}={}){return ne(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.f,s=[],l=[],i=new Set,u=n.n,d=Array.isArray(r),c=-1;for(let T of e){c++;let h=d?r[c]:r,g=`[${c}]`,j=`${u}${g}`;n.n=j;let R=h.r(T,n),[k,P]=R;n.n=j;let _=o?.unique;if(k&&_){let m=P,A=typeof _=="string";A?m=P[_]:typeof _=="function"&&(m=_(P)),i.has(m)?(A&&(n.n=`${u}${g}.${_}`),R=[!1,[p(n,A?`Type '${h.t?.[_]?.e}' with value "${m}" is not unique`:typeof _=="function"?`Type '${h.e}' unique fn return with value "${m}" is not unique`:`${h.e} value is not unique`)]]):i.add(m)}let[O,$]=R;if(O)l.push($);else if(a){s.push($);continue}else return{errors:$,data:void 0}}if(s.length>0){if(l.length===0)return{errors:s.slice(0,5).flat(),data:void 0};B(n,s.flat())}return{errors:!1,data:l}}function xe(e,r){return{...f,e:`${e.e}[]`,R:e,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Pe(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function we(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.f;t.f=!0;let a=e.r(n,t);return t.f=o,a}}}function Ee(e,r){return{...f,R:e,e:`${e.e}[]`,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function $e(e){return{...f,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return y(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function S(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,f:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function Ae(e){return r=>S(r,e)}function Ke(e,r,n){let t=S(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function te(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,f:!1};return!!r.r(e,n)[0]}function Se(e){return r=>te(r,e)}function Ie(e){return{...f,e:"recursive",r(r,n){return e().r(r,n)}}}function U(e,r,n,t){let o=e.n,a=e.o,s=e.s,l=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=l,e.n=o,e.o=a,i}function We(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=U(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);return l?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function ve(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=U(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);if(l){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(d=>p(a,d))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ne(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function Ce(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return S(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${x(t)?t.message:""}`]}}}function I(e){return typeof e=="function"}export{V as a,b,M as c,z as d,L as e,Q as f,J as g,Z as h,G as i,p as j,y as k,f as l,fe as m,le as n,Te as o,de as p,pe as q,Re as r,he as s,_e as t,be as u,je as v,ge as w,ke as x,Oe as y,ne as z,me as A,xe as B,Pe as C,we as D,Ee as E,$e as F,S as G,Ae as H,Ke as I,te as J,Se as K,Ie as L,We as M,ve as N,Ne as O,x as P,v as Q,Ce as R};
package/dist/runcheck.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var S=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ne=(e,r)=>{for(var n in r)S(e,n,{get:r[n],enumerable:!0})},te=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ee(r))!re.call(e,o)&&o!==n&&S(e,o,{get:()=>r[o],enumerable:!(t=Y(r,o))||t.enumerable});return e};var oe=e=>te(S({},"__esModule",{value:!0}),e);var Ce={};ne(Ce,{defaultProps:()=>y,getWarningOrErrorWithPath:()=>p,isObject:()=>g,parse:()=>c,rc_any:()=>Te,rc_array:()=>me,rc_assert_is_valid:()=>Ne,rc_boolean:()=>pe,rc_date:()=>_e,rc_default:()=>ke,rc_disable_loose_array:()=>Pe,rc_get_obj_schema:()=>B,rc_instanceof:()=>be,rc_is_valid:()=>H,rc_literals:()=>je,rc_loose_array:()=>we,rc_loose_parse:()=>Ae,rc_loose_record:()=>xe,rc_null:()=>le,rc_nullish_default:()=>Oe,rc_number:()=>he,rc_obj_builder:()=>M,rc_obj_extends:()=>q,rc_obj_merge:()=>U,rc_obj_omit:()=>D,rc_obj_pick:()=>V,rc_obj_strict:()=>F,rc_object:()=>b,rc_parse:()=>$,rc_parse_json:()=>ve,rc_parser:()=>$e,rc_record:()=>G,rc_recursive:()=>Se,rc_rename_from_key:()=>v,rc_string:()=>Re,rc_transform:()=>Ie,rc_tuple:()=>Ee,rc_undefined:()=>fe,rc_union:()=>ge,rc_unknown:()=>de,rc_unsafe_transform:()=>We,rc_validator:()=>Ke,snakeCase:()=>I});module.exports=oe(Ce);function v(e,r){return{...r,f:e}}function se(e){return g(e)&&"__rc_type"in e}function C(e){if(se(e))return e;if(g(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=C(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=C(o);return{...y,t:n,e:"object",R:!0,u:Object.entries(n),r(t,o){return c(this,t,o,()=>{if(!g(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let f=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[T]of this.u)s.has(T)?s.delete(T):f.push(p(o,`Key '${T}' is missing`));for(let T of s)f.push(p(o,`Key '${T}' is not defined in the object shape`));return{data:void 0,errors:f}}let l={},i=[],u=o.n,d=-1;for(let[f,T]of this.u){let h=f;d+=1;let k=`.${f}`,j=`${u}${k}`;o.n=j;let R,O=f;if(T.f&&(R=t[T.f],O=T.f),R===void 0&&(R=t[f],O=f),R===void 0&&r==="snake_case"){let x=I(f);R=t[x],O=x}s?.delete(O);let[P,_]=T.r(R,o);if(P)l[h]=_;else{for(let x of _)o.n=j,i.push(x);if(o.o){o.a=d;break}}}if(s&&s.size>0)for(let f of s)o.n=u,i.push(p(o,`Key '${f}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this._?{errors:!1,data:{...t,...l}}:{errors:!1,data:l}})}}}function q(e,r){return{...b(e,r),e:"extends_object",_:!0}}function B(e){return e.t}function F(e,r){return{...b(e,r),e:"strict_obj"}}function U(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function V(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function D(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function M(){return(e,r)=>b(e,r)}function ae(e){return{...this,b:e}}function p(e,r){return r.startsWith("$")?r:`${e.n?`$${e.n}: `:""}${r}`}function W(e,r){e.l.push(p(e,r))}function J(e,r){r.forEach(n=>W(e,n))}function c(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.b;if(a!==void 0)return W(n,`Fallback used, errors -> ${z(o,n,e,r)}`),[!0,N(a)?a():a];if(e.j&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(W(n,`Autofixed from error "${z(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,Z(e,r))]]}function z(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):Z(n,t)}function ie(e){return{...this,j:!0,h:e}}function ue(e){return{...this,c:e}}function L(){return{...this,T:!0}}function Z(e,r){return`Type '${w(r,!!e.g)}' is not assignable to '${e.e}'`}function ce(){return{...this,p:!0,e:`${this.e}_or_null`}}function ye(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var y={__rc_type:void 0,withFallback:ae,where:ue,optional:L,optionalKey:L,orNullish:ye,withAutofix:ie,orNull:ce,b:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,g:!1,f:void 0,h:void 0,k:void 0,t:void 0,R:!1,_:!1,u:[]},fe={...y,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},le={...y,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},Te={...y,r(e,r){return c(this,e,r,()=>!0)},e:"any"},de={...y,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},pe={...y,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Re={...y,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},he={...y,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},_e={...y,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function be(e){return{...y,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function je(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...y,r(r,n){return c(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},g:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var Q=1;function ge(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...y,r(r,n){return c(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,l=[],i=0;for(let u of e){i+=1,u.R&&(n.n=`${t}|union ${i}|`);let d=n.o;n.o=!0,n.a=0;let[f,T]=u.r(r,n),h=n.a;if(n.o=d,n.a=0,f)return!0;u.R&&h!==-1?h>0?l.push(...T):(a<Q&&o.push(...T),a+=1):s=!0}return n.n=t,l.length>0||o.length>0?((a>Q||s)&&o.push(p(n,"not matches any other union member")),{errors:[...l,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function ke(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return c(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!==void 0?!0:{data:N(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`}}function Oe(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return c(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!=null?!0:{data:N(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`}}function G(e,{checkKey:r,looseCheck:n}={}){return{...y,e:`record<string, ${e.e}>`,r(t,o){return c(this,t,o,()=>{if(!g(t))return!1;let a={},s=[],l=o.n;for(let[i,u]of Object.entries(t)){let d=`.${i}`,f=`${l}${d}`;if(o.n=f,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let T=t[i],[h,k]=e.r(u,o);if(h)a[i]=T;else{let j=k;for(let R of j)s.push(R);if(o.o)break}}if(s.length>0)if(n)J(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function xe(e,{checkKey:r}={}){return G(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.y,s=[],l=[],i=new Set,u=n.n,d=Array.isArray(r),f=-1;for(let T of e){f++;let h=d?r[f]:r,k=`[${f}]`,j=`${u}${k}`;n.n=j;let R=h.r(T,n),[O,P]=R;n.n=j;let _=o?.unique;if(O&&_){let m=P,K=typeof _=="string";K?m=P[_]:typeof _=="function"&&(m=_(P)),i.has(m)?(K&&(n.n=`${u}${k}.${_}`),R=[!1,[p(n,K?`Type '${h.t?.[_]?.e}' with value "${m}" is not unique`:typeof _=="function"?`Type '${h.e}' unique fn return with value "${m}" is not unique`:`${h.e} value is not unique`)]]):i.add(m)}let[x,A]=R;if(x)l.push(A);else if(a){s.push(A);continue}else return{errors:A,data:void 0}}if(s.length>0){if(l.length===0)return{errors:s.slice(0,5).flat(),data:void 0};J(n,s.flat())}return{errors:!1,data:l}}function me(e,r){return{...y,e:`${e.e}[]`,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Pe(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.y;t.y=!0;let a=e.r(n,t);return t.y=o,a}}}function we(e,r){return{...y,e:`${e.e}[]`,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function Ee(e){return{...y,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function $(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,y:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function $e(e){return r=>$(r,e)}function Ae(e,r,n){let t=$(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function H(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,y:!1};return!!r.r(e,n)[0]}function Ke(e){return r=>H(r,e)}function Se(e){return{...y,e:"recursive",r(r,n){return e().r(r,n)}}}function X(e,r,n,t){let o=e.n,a=e.o,s=e.s,l=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=l,e.n=o,e.o=a,i}function Ie(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=X(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);return l?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function We(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=X(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);if(l){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(d=>p(a,d))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function Ne(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function ve(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return $(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${g(t)?t.message:""}`]}}}function N(e){return typeof e=="function"}0&&(module.exports={defaultProps,getWarningOrErrorWithPath,isObject,parse,rc_any,rc_array,rc_assert_is_valid,rc_boolean,rc_date,rc_default,rc_disable_loose_array,rc_get_obj_schema,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_loose_record,rc_null,rc_nullish_default,rc_number,rc_obj_builder,rc_obj_extends,rc_obj_merge,rc_obj_omit,rc_obj_pick,rc_obj_strict,rc_object,rc_parse,rc_parse_json,rc_parser,rc_record,rc_recursive,rc_rename_from_key,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_unsafe_transform,rc_validator,snakeCase});
1
+ "use strict";var S=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ne=(e,r)=>{for(var n in r)S(e,n,{get:r[n],enumerable:!0})},te=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ee(r))!re.call(e,o)&&o!==n&&S(e,o,{get:()=>r[o],enumerable:!(t=Y(r,o))||t.enumerable});return e};var oe=e=>te(S({},"__esModule",{value:!0}),e);var qe={};ne(qe,{defaultProps:()=>y,getWarningOrErrorWithPath:()=>p,isObject:()=>g,parse:()=>c,rc_any:()=>Te,rc_array:()=>xe,rc_assert_is_valid:()=>Ne,rc_boolean:()=>pe,rc_date:()=>_e,rc_default:()=>ke,rc_disable_loose_array:()=>we,rc_get_array_item_type:()=>Pe,rc_get_obj_schema:()=>B,rc_instanceof:()=>be,rc_is_valid:()=>H,rc_literals:()=>je,rc_loose_array:()=>Ee,rc_loose_parse:()=>Ke,rc_loose_record:()=>me,rc_null:()=>le,rc_nullish_default:()=>Oe,rc_number:()=>he,rc_obj_builder:()=>M,rc_obj_extends:()=>q,rc_obj_merge:()=>U,rc_obj_omit:()=>D,rc_obj_pick:()=>V,rc_obj_strict:()=>F,rc_object:()=>b,rc_parse:()=>$,rc_parse_json:()=>Ce,rc_parser:()=>Ae,rc_record:()=>G,rc_recursive:()=>Ie,rc_rename_from_key:()=>N,rc_string:()=>Re,rc_transform:()=>We,rc_tuple:()=>$e,rc_undefined:()=>fe,rc_union:()=>ge,rc_unknown:()=>de,rc_unsafe_transform:()=>ve,rc_validator:()=>Se,snakeCase:()=>I});module.exports=oe(qe);function N(e,r){return{...r,f:e}}function se(e){return g(e)&&"__rc_type"in e}function C(e){if(se(e))return e;if(g(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=C(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=C(o);return{...y,t:n,e:"object",h:!0,u:Object.entries(n),r(t,o){return c(this,t,o,()=>{if(!g(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let f=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[T]of this.u)s.has(T)?s.delete(T):f.push(p(o,`Key '${T}' is missing`));for(let T of s)f.push(p(o,`Key '${T}' is not defined in the object shape`));return{data:void 0,errors:f}}let l={},i=[],u=o.n,d=-1;for(let[f,T]of this.u){let h=f;d+=1;let k=`.${f}`,j=`${u}${k}`;o.n=j;let R,O=f;if(T.f&&(R=t[T.f],O=T.f),R===void 0&&(R=t[f],O=f),R===void 0&&r==="snake_case"){let m=I(f);R=t[m],O=m}s?.delete(O);let[P,_]=T.r(R,o);if(P)l[h]=_;else{for(let m of _)o.n=j,i.push(m);if(o.o){o.a=d;break}}}if(s&&s.size>0)for(let f of s)o.n=u,i.push(p(o,`Key '${f}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...l}}:{errors:!1,data:l}})}}}function q(e,r){return{...b(e,r),e:"extends_object",b:!0}}function B(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function F(e,r){return{...b(e,r),e:"strict_obj"}}function U(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function V(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function D(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function M(){return(e,r)=>b(e,r)}function ae(e){return{...this,j:e}}function p(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function W(e,r){e.l.push(r.startsWith("$")?r:p(e,r))}function J(e,r){r.forEach(n=>W(e,n))}function c(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.j;if(a!==void 0)return W(n,`Fallback used, errors -> ${z(o,n,e,r)}`),[!0,v(a)?a():a];if(e.g&&e._){let s=e._(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(W(n,`Autofixed from error "${z(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,Z(e,r))]]}function z(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):Z(n,t)}function ie(e){return{...this,g:!0,_:e}}function ue(e){return{...this,c:e}}function L(){return{...this,T:!0}}function Z(e,r){return`Type '${w(r,!!e.k)}' is not assignable to '${e.e}'`}function ce(){return{...this,p:!0,e:`${this.e}_or_null`}}function ye(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var y={__rc_type:void 0,withFallback:ae,where:ue,optional:L,optionalKey:L,orNullish:ye,withAutofix:ie,orNull:ce,R:void 0,j:void 0,c:void 0,T:!1,p:!1,d:!1,g:!1,k:!1,f:void 0,_:void 0,t:void 0,h:!1,b:!1,u:[]},fe={...y,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},le={...y,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},Te={...y,r(e,r){return c(this,e,r,()=>!0)},e:"any"},de={...y,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},pe={...y,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Re={...y,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},he={...y,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},_e={...y,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function be(e){return{...y,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function je(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...y,r(r,n){return c(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var Q=1;function ge(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...y,r(r,n){return c(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,l=[],i=0;for(let u of e){i+=1,u.h&&(n.n=`${t}|union ${i}|`);let d=n.o;n.o=!0,n.a=0;let[f,T]=u.r(r,n),h=n.a;if(n.o=d,n.a=0,f)return!0;u.h&&h!==-1?h>0?l.push(...T):(a<Q&&o.push(...T),a+=1):s=!0}return n.n=t,l.length>0||o.length>0?((a>Q||s)&&o.push(p(n,"not matches any other union member")),{errors:[...l,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function ke(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return c(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!==void 0?!0:{data:v(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`}}function Oe(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return c(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!=null?!0:{data:v(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`}}function G(e,{checkKey:r,looseCheck:n}={}){return{...y,e:`record<string, ${e.e}>`,r(t,o){return c(this,t,o,()=>{if(!g(t))return!1;let a={},s=[],l=o.n;for(let[i,u]of Object.entries(t)){let d=`.${i}`,f=`${l}${d}`;if(o.n=f,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let T=t[i],[h,k]=e.r(u,o);if(h)a[i]=T;else{let j=k;for(let R of j)s.push(R);if(o.o)break}}if(s.length>0)if(n)J(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function me(e,{checkKey:r}={}){return G(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.y,s=[],l=[],i=new Set,u=n.n,d=Array.isArray(r),f=-1;for(let T of e){f++;let h=d?r[f]:r,k=`[${f}]`,j=`${u}${k}`;n.n=j;let R=h.r(T,n),[O,P]=R;n.n=j;let _=o?.unique;if(O&&_){let x=P,K=typeof _=="string";K?x=P[_]:typeof _=="function"&&(x=_(P)),i.has(x)?(K&&(n.n=`${u}${k}.${_}`),R=[!1,[p(n,K?`Type '${h.t?.[_]?.e}' with value "${x}" is not unique`:typeof _=="function"?`Type '${h.e}' unique fn return with value "${x}" is not unique`:`${h.e} value is not unique`)]]):i.add(x)}let[m,A]=R;if(m)l.push(A);else if(a){s.push(A);continue}else return{errors:A,data:void 0}}if(s.length>0){if(l.length===0)return{errors:s.slice(0,5).flat(),data:void 0};J(n,s.flat())}return{errors:!1,data:l}}function xe(e,r){return{...y,e:`${e.e}[]`,R:e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Pe(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function we(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.y;t.y=!0;let a=e.r(n,t);return t.y=o,a}}}function Ee(e,r){return{...y,R:e,e:`${e.e}[]`,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function $e(e){return{...y,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function $(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,y:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function Ae(e){return r=>$(r,e)}function Ke(e,r,n){let t=$(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function H(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,y:!1};return!!r.r(e,n)[0]}function Se(e){return r=>H(r,e)}function Ie(e){return{...y,e:"recursive",r(r,n){return e().r(r,n)}}}function X(e,r,n,t){let o=e.n,a=e.o,s=e.s,l=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=l,e.n=o,e.o=a,i}function We(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=X(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);return l?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function ve(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=X(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);if(l){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(d=>p(a,d))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ne(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function Ce(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return $(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${g(t)?t.message:""}`]}}}function v(e){return typeof e=="function"}0&&(module.exports={defaultProps,getWarningOrErrorWithPath,isObject,parse,rc_any,rc_array,rc_assert_is_valid,rc_boolean,rc_date,rc_default,rc_disable_loose_array,rc_get_array_item_type,rc_get_obj_schema,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_loose_record,rc_null,rc_nullish_default,rc_number,rc_obj_builder,rc_obj_extends,rc_obj_merge,rc_obj_omit,rc_obj_pick,rc_obj_strict,rc_object,rc_parse,rc_parse_json,rc_parser,rc_record,rc_recursive,rc_rename_from_key,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_unsafe_transform,rc_validator,snakeCase});
@@ -22,7 +22,7 @@ type ObjOptions = {
22
22
  };
23
23
  declare function rc_object<T extends RcObject>(shape: T, { normalizeKeysFrom }?: ObjOptions): RcObjTypeReturn<T>;
24
24
  declare function rc_obj_extends<T extends RcObject>(shape: T, options?: ObjOptions): RcObjTypeReturn<T>;
25
- declare function rc_get_obj_schema<T extends RcObject>(type: RcObjTypeReturn<T>): T;
25
+ declare function rc_get_obj_shape<T extends RcObject>(type: RcObjTypeReturn<T>): T;
26
26
  /** return an error if the obj has more keys than the expected type */
27
27
  declare function rc_obj_strict<T extends RcObject>(shape: T, options?: ObjOptions): RcObjTypeReturn<T>;
28
28
  type AnyObj = Record<string, unknown>;
@@ -78,9 +78,10 @@ type RcBase<T, RequiredKey extends boolean> = {
78
78
  }) => RcType<T>;
79
79
  readonly _optional_key_?: RequiredKey;
80
80
  };
81
- declare function getWarningOrErrorWithPath(ctx: ParseResultCtx, message: string & {
81
+ type ErrorWithouPath = string & {
82
82
  __withPath?: never;
83
- }): ErrorWithPath;
83
+ };
84
+ declare function getWarningOrErrorWithPath(ctx: ParseResultCtx, message: ErrorWithouPath): ErrorWithPath;
84
85
  type IsValid<T> = boolean | {
85
86
  data: T;
86
87
  errors: false;
@@ -117,6 +118,7 @@ type ArrayOptions<T extends RcType<any>> = {
117
118
  unique?: RcInferType<T> extends Record<string, any> ? keyof RcInferType<T> | ((parsedItem: RcInferType<T>) => any) : boolean | ((parsedItem: RcInferType<T>) => any);
118
119
  };
119
120
  declare function rc_array<T extends RcType<any>>(type: T, options?: ArrayOptions<T>): RcType<RcInferType<T>[]>;
121
+ declare function rc_get_array_item_type<T>(type: RcType<T[]>): RcType<T>;
120
122
  declare function rc_disable_loose_array<T extends RcType<any>>(type: T, { nonRecursive }?: {
121
123
  nonRecursive?: boolean;
122
124
  }): T;
@@ -183,4 +185,4 @@ type Prettify<T> = T extends Record<string, any> ? {
183
185
  } : T;
184
186
  type RcPrettyInferType<T extends RcType<any>> = Prettify<RcInferType<T>>;
185
187
 
186
- export { RcBase, RcInferType, RcOptionalKeyType, RcParseResult, RcParser, RcPrettyInferType, RcType, defaultProps, getWarningOrErrorWithPath, isObject, parse, rc_any, rc_array, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_get_obj_schema, rc_instanceof, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_rename_from_key, rc_string, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_validator };
188
+ export { RcBase, RcInferType, RcOptionalKeyType, RcParseResult, RcParser, RcPrettyInferType, RcType, defaultProps, getWarningOrErrorWithPath, isObject, parse, rc_any, rc_array, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_get_array_item_type, rc_get_obj_shape as rc_get_obj_schema, rc_instanceof, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_rename_from_key, rc_string, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_validator };
package/dist/runcheck.js CHANGED
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-TS4C7BNK.js";export{l as defaultProps,j as getWarningOrErrorWithPath,O as isObject,k as parse,o as rc_any,B as rc_array,N as rc_assert_is_valid,q as rc_boolean,t as rc_date,x as rc_default,C as rc_disable_loose_array,d as rc_get_obj_schema,u as rc_instanceof,I as rc_is_valid,v as rc_literals,D as rc_loose_array,H as rc_loose_parse,A as rc_loose_record,n as rc_null,y as rc_nullish_default,s as rc_number,i as rc_obj_builder,c as rc_obj_extends,f as rc_obj_merge,h as rc_obj_omit,g as rc_obj_pick,e as rc_obj_strict,b as rc_object,F as rc_parse,Q as rc_parse_json,G as rc_parser,z as rc_record,K as rc_recursive,a as rc_rename_from_key,r as rc_string,L as rc_transform,E as rc_tuple,m as rc_undefined,w as rc_union,p as rc_unknown,M as rc_unsafe_transform,J as rc_validator,P as snakeCase};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-FXQPJI45.js";export{l as defaultProps,j as getWarningOrErrorWithPath,P as isObject,k as parse,o as rc_any,B as rc_array,O as rc_assert_is_valid,q as rc_boolean,t as rc_date,x as rc_default,D as rc_disable_loose_array,C as rc_get_array_item_type,d as rc_get_obj_schema,u as rc_instanceof,J as rc_is_valid,v as rc_literals,E as rc_loose_array,I as rc_loose_parse,A as rc_loose_record,n as rc_null,y as rc_nullish_default,s as rc_number,i as rc_obj_builder,c as rc_obj_extends,f as rc_obj_merge,h as rc_obj_omit,g as rc_obj_pick,e as rc_obj_strict,b as rc_object,G as rc_parse,R as rc_parse_json,H as rc_parser,z as rc_record,L as rc_recursive,a as rc_rename_from_key,r as rc_string,M as rc_transform,F as rc_tuple,m as rc_undefined,w as rc_union,p as rc_unknown,N as rc_unsafe_transform,K as rc_validator,Q as snakeCase};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "runcheck",
3
3
  "description": "A tiny (less than 2 KiB Gzipped) and treeshakable! lib for typescript runtime type checks with autofix support",
4
- "version": "0.43.0",
4
+ "version": "0.44.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"
@@ -1 +0,0 @@
1
- function V(e,r){return{...r,y:e}}function D(e){return m(e)&&"__rc_type"in e}function W(e){if(D(e))return e;if(m(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=W(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=W(o);return{...f,t:n,e:"object",R:!0,u:Object.entries(n),r(t,o){return y(this,t,o,()=>{if(!m(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let c=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[T]of this.u)s.has(T)?s.delete(T):c.push(p(o,`Key '${T}' is missing`));for(let T of s)c.push(p(o,`Key '${T}' is not defined in the object shape`));return{data:void 0,errors:c}}let l={},i=[],u=o.n,d=-1;for(let[c,T]of this.u){let h=c;d+=1;let g=`.${c}`,j=`${u}${g}`;o.n=j;let R,k=c;if(T.y&&(R=t[T.y],k=T.y),R===void 0&&(R=t[c],k=c),R===void 0&&r==="snake_case"){let O=N(c);R=t[O],k=O}s?.delete(k);let[P,_]=T.r(R,o);if(P)l[h]=_;else{for(let O of _)o.n=j,i.push(O);if(o.o){o.a=d;break}}}if(s&&s.size>0)for(let c of s)o.n=u,i.push(p(o,`Key '${c}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.h?{errors:!1,data:{...t,...l}}:{errors:!1,data:l}})}}}function M(e,r){return{...b(e,r),e:"extends_object",h:!0}}function z(e){return e.t}function L(e,r){return{...b(e,r),e:"strict_obj"}}function Q(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function J(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function Z(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function G(){return(e,r)=>b(e,r)}function H(e){return{...this,b:e}}function p(e,r){return r.startsWith("$")?r:`${e.n?`$${e.n}: `:""}${r}`}function K(e,r){e.l.push(p(e,r))}function B(e,r){r.forEach(n=>K(e,n))}function y(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.b;if(a!==void 0)return K(n,`Fallback used, errors -> ${v(o,n,e,r)}`),[!0,I(a)?a():a];if(e.j&&e._){let s=e._(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(K(n,`Autofixed from error "${v(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,F(e,r))]]}function v(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):F(n,t)}function X(e){return{...this,j:!0,_:e}}function Y(e){return{...this,c:e}}function C(){return{...this,T:!0}}function F(e,r){return`Type '${w(r,!!e.g)}' is not assignable to '${e.e}'`}function ee(){return{...this,p:!0,e:`${this.e}_or_null`}}function re(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var f={__rc_type:void 0,withFallback:H,where:Y,optional:C,optionalKey:C,orNullish:re,withAutofix:X,orNull:ee,b:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,g:!1,y:void 0,_:void 0,k:void 0,t:void 0,R:!1,h:!1,u:[]},fe={...f,r(e,r){return y(this,e,r,()=>e===void 0)},e:"undefined"},le={...f,r(e,r){return y(this,e,r,()=>e===null)},e:"null"},Te={...f,r(e,r){return y(this,e,r,()=>!0)},e:"any"},de={...f,r(e,r){return y(this,e,r,()=>!0)},e:"unknown"},pe={...f,r(e,r){return y(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Re={...f,r(e,r){return y(this,e,r,()=>typeof e=="string")},e:"string"},he={...f,r(e,r){return y(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},_e={...f,r(e,r){return y(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function be(e){return{...f,r(r,n){return y(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function je(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...f,r(r,n){return y(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},g:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var q=1;function ge(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...f,r(r,n){return y(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,l=[],i=0;for(let u of e){i+=1,u.R&&(n.n=`${t}|union ${i}|`);let d=n.o;n.o=!0,n.a=0;let[c,T]=u.r(r,n),h=n.a;if(n.o=d,n.a=0,c)return!0;u.R&&h!==-1?h>0?l.push(...T):(a<q&&o.push(...T),a+=1):s=!0}return n.n=t,l.length>0||o.length>0?((a>q||s)&&o.push(p(n,"not matches any other union member")),{errors:[...l,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function ke(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return y(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!==void 0?!0:{data:I(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`}}function Oe(e,r){return{...e,T:!1,d:!1,p:!1,r(n,t){return y(this,n,t,()=>{let o=e.r(n,t),[a,s]=o;return a?s!=null?!0:{data:I(r)?r():r,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`}}function ne(e,{checkKey:r,looseCheck:n}={}){return{...f,e:`record<string, ${e.e}>`,r(t,o){return y(this,t,o,()=>{if(!m(t))return!1;let a={},s=[],l=o.n;for(let[i,u]of Object.entries(t)){let d=`.${i}`,c=`${l}${d}`;if(o.n=c,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let T=t[i],[h,g]=e.r(u,o);if(h)a[i]=T;else{let j=g;for(let R of j)s.push(R);if(o.o)break}}if(s.length>0)if(n)B(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function xe(e,{checkKey:r}={}){return ne(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.f,s=[],l=[],i=new Set,u=n.n,d=Array.isArray(r),c=-1;for(let T of e){c++;let h=d?r[c]:r,g=`[${c}]`,j=`${u}${g}`;n.n=j;let R=h.r(T,n),[k,P]=R;n.n=j;let _=o?.unique;if(k&&_){let x=P,A=typeof _=="string";A?x=P[_]:typeof _=="function"&&(x=_(P)),i.has(x)?(A&&(n.n=`${u}${g}.${_}`),R=[!1,[p(n,A?`Type '${h.t?.[_]?.e}' with value "${x}" is not unique`:typeof _=="function"?`Type '${h.e}' unique fn return with value "${x}" is not unique`:`${h.e} value is not unique`)]]):i.add(x)}let[O,$]=R;if(O)l.push($);else if(a){s.push($);continue}else return{errors:$,data:void 0}}if(s.length>0){if(l.length===0)return{errors:s.slice(0,5).flat(),data:void 0};B(n,s.flat())}return{errors:!1,data:l}}function me(e,r){return{...f,e:`${e.e}[]`,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Pe(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.f;t.f=!0;let a=e.r(n,t);return t.f=o,a}}}function we(e,r){return{...f,e:`${e.e}[]`,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function Ee(e){return{...f,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return y(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function S(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,f:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function $e(e){return r=>S(r,e)}function Ae(e,r,n){let t=S(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function te(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,f:!1};return!!r.r(e,n)[0]}function Ke(e){return r=>te(r,e)}function Se(e){return{...f,e:"recursive",r(r,n){return e().r(r,n)}}}function U(e,r,n,t){let o=e.n,a=e.o,s=e.s,l=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=l,e.n=o,e.o=a,i}function Ie(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=U(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);return l?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function We(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,d]=U(a,n,o,t);if(u)return[!0,d];s=d}let[l,i]=e.r(o,a);if(l){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(d=>p(a,d))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function Ne(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function N(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function ve(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return S(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${m(t)?t.message:""}`]}}}function I(e){return typeof e=="function"}export{V as a,b,M as c,z as d,L as e,Q as f,J as g,Z as h,G as i,p as j,y as k,f as l,fe as m,le as n,Te as o,de as p,pe as q,Re as r,he as s,_e as t,be as u,je as v,ge as w,ke as x,Oe as y,ne as z,xe as A,me as B,Pe as C,we as D,Ee as E,S as F,$e as G,Ae as H,te as I,Ke as J,Se as K,Ie as L,We as M,Ne as N,m as O,N as P,ve as Q};