text: !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Gubu=e()}}((function(){var e={},t={};Object.defineProperty(t,"__esModule",{value:!0}),t.Gubu=void 0;const n=Symbol.for("gubu$"),r={gubu$:n,v$:"2.0.1"},l=Symbol.for("gubu$nil");class i{constructor(e,t,n,r){this.match=!1,this.dI=0,this.nI=2,this.cI=-1,this.pI=0,this.sI=-1,this.valType="never",this.isRoot=!1,this.key="",this.type="never",this.stop=!0,this.nextSibling=!0,this.fromDefault=!1,this.ignoreVal=void 0,this.err=[],this.parents=[],this.keys=[],this.path=[],this.root=e,this.vals=[e,-1],this.node=t,this.nodes=[t,-1],this.ctx=n||{},this.match=!!r}next(){this.stop=!1,this.fromDefault=!1,this.ignoreVal=void 0,this.isRoot=0===this.pI;let e=this.nodes[this.pI];for(;+e;)this.pI=+e,e=this.nodes[this.pI],this.dI--;e?(this.node=e,this.updateVal(this.vals[this.pI]),this.key=this.keys[this.pI],this.cI=this.pI,this.sI=this.pI+1,this.parent=this.parents[this.pI],this.nextSibling=!0,this.type=this.node.t,this.path[this.dI]=this.key,this.oval=this.val):this.stop=!0}updateVal(e){this.val=e,this.valType=typeof this.val,"number"===this.valType&&isNaN(this.val)&&(this.valType="nan"),this.isRoot&&!this.match&&(this.root=this.val)}}class o extends TypeError{constructor(e,t,n){super(t.map(e=>e.t).join("\n")),this.gubu=!0,this.name="GubuError",this.code=e,this.desc=()=>({name:"GubuError",code:e,err:t,ctx:n})}toJSON(){return{...this,err:this.desc().err,name:this.name,message:this.message}}}const u={String:!0,Number:!0,Boolean:!0,Object:!0,Array:!0,Function:!0,Symbol:!0,BigInt:!0},s={string:"",number:0,boolean:!1,object:{},array:[],symbol:Symbol(""),bigint:BigInt(0),null:null};function a(e,t){var i,o,a,p,c;if(f===e)e=void 0;else if(null!=e&&(null===(i=e.$)||void 0===i?void 0:i.gubu$)){if(n===e.$.gubu$)return e.d=null==t?e.d:t,e;if(!0===e.$.gubu$){let r={...e};return r.$={v$:"2.0.1",...r.$,gubu$:n},r.v=null!=r.v&&"object"==typeof r.v?{...r.v}:r.v,r.t=r.t||typeof r.v,"function"===r.t&&u[r.v.name]&&(r.t=r.v.name.toLowerCase(),r.v=H(s[r.t])),r.r=!!r.r,r.p=!!r.p,r.d=null==t?null==r.d?-1:r.d:t,r.b=r.b||[],r.a=r.a||[],r.u=r.u||{},r}}let h=null===e?"null":typeof e,d=e,v=l,b=!1,m={},g=[],$=[];if("object"===(h="undefined"===h?"any":h))Array.isArray(d)?(h="array",1===d.length&&(v=d[0],d=[])):null!=d&&Function!==d.constructor&&Object!==d.constructor&&null!=d.constructor?(h="instance",m.n=d.constructor.name,m.i=d.constructor):0===Object.keys(d).length&&(v=y());else if("function"===h)if(u[e.name])h=e.name.toLowerCase(),b=!0,d=H(s[h]),"Object"===e.name&&(v=y());else if(d.gubu===r||!0===(null===(o=d.$)||void 0===o?void 0:o.gubu)){let e=d.node?d.node():d;h=e.t,d=e.v,b=e.r,m={...e.u},g=[...e.a],$=[...e.b]}else void 0===d.prototype&&Function===d.constructor||Function===(null===(a=d.prototype)||void 0===a?void 0:a.constructor)||(h="instance",b=!0,m.n=null===(c=null===(p=d.prototype)||void 0===p?void 0:p.constructor)||void 0===c?void 0:c.name,m.i=d);else"number"===h&&isNaN(d)?h="nan":"string"===h&&""===d&&(m.empty=!0);let I=null==d||"object"!==h&&"array"!==h?d:{...d};return{$:r,t:h,v:I,n:null!=I&&"object"==typeof I?Object.keys(I).length:0,c:v,r:b,p:!1,d:null==t?-1:t,u:m,a:g,b:$}}function f(t,u){const s=null==u?{}:u;s.name=null==s.name?"G"+(""+Math.random()).substring(2,8):""+s.name;let f=a(t,0);function c(e,t,n){let r=new i(e,f,t,n);for(;r.next(),!r.stop;){let e=r.node,t=!1;if(0<e.b.length)for(let l=0;l<e.b.length;l++){let n=p(e.b[l],r);e=r.node,void 0!==n.done&&(t=n.done)}if(!t)if("never"===r.type)r.err.push(M("never",r,1070));else if("object"===r.type){let t;if(e.r&&void 0===r.val?(r.ignoreVal=!0,r.err.push(M("required",r,1010))):void 0===r.val||null!==r.val&&"object"===r.valType&&!Array.isArray(r.val)?e.p&&null==r.val||(r.updateVal(r.val||(r.fromDefault=!0,{})),t=r.val):(r.err.push(M("type",r,1020)),t=Array.isArray(r.val)?r.val:{}),null!=(t=null==t&&!1===r.ctx.err?{}:t)){let n=!1,i=Object.keys(e.v),o=r.nI;if(0<i.length){n=!0,r.pI=o;for(let n of i){let l=e.v[n]=a(e.v[n],1+r.dI);r.nodes[r.nI]=l,r.vals[r.nI]=t[n],r.parents[r.nI]=t,r.keys[r.nI]=n,r.nI++}}let u=Object.keys(t).filter(t=>void 0===e.v[t]);if(0<u.length)if(l===e.c)r.ignoreVal=!0,r.err.push(M("closed",r,1100,void 0,{k:u}));else{n=!0,r.pI=o;for(let n of u){let l=e.c=a(e.c,1+r.dI);r.nodes[r.nI]=l,r.vals[r.nI]=t[n],r.parents[r.nI]=t,r.keys[r.nI]=n,r.nI++}}n&&(r.dI++,r.nodes[r.nI++]=r.sI,r.nextSibling=!1)}}else if("array"===r.type)if(e.r&&void 0===r.val)r.ignoreVal=!0,r.err.push(M("required",r,1030));else if(void 0===r.val||Array.isArray(r.val)){if(!e.p||null!=r.val){r.updateVal(r.val||(r.fromDefault=!0,[]));let t=0<r.val.length,n=l!==e.c,i=Object.keys(e.v).filter(e=>!isNaN(+e)),o=0<i.length;if(t||o){r.pI=r.nI;let l=0;if(o)if(i.length<r.val.length&&!n)r.ignoreVal=!0,r.err.push(M("closed",r,1090,void 0,{k:i.length}));else for(;l<i.length;l++){let t=e.v[l]=a(e.v[l],1+r.dI);r.nodes[r.nI]=t,r.vals[r.nI]=r.val[l],r.parents[r.nI]=r.val,r.keys[r.nI]=""+l,r.nI++}if(n&&t){let t=e.c=a(e.c,1+r.dI);for(;l<r.val.length;l++)r.nodes[r.nI]=t,r.vals[r.nI]=r.val[l],r.parents[r.nI]=r.val,r.keys[r.nI]=""+l,r.nI++}r.ignoreVal||(r.dI++,r.nodes[r.nI++]=r.sI,r.nextSibling=!1)}}}else r.err.push(M("type",r,1040));else if("any"===r.type||"list"===r.type||void 0===r.val||r.type===r.valType||"instance"===r.type&&e.u.i&&r.val instanceof e.u.i||"null"===r.type&&null===r.val)if(void 0===r.val){let t=r.path[r.dI];!e.r||"undefined"===r.type&&r.parent.hasOwnProperty(t)?void 0!==e.v&&!e.p||"undefined"===r.type?(r.updateVal(e.v),r.fromDefault=!0):"any"===r.type&&(r.ignoreVal=void 0===r.ignoreVal||r.ignoreVal):(r.ignoreVal=!0,r.err.push(M("required",r,1060)))}else"string"!==r.type||""!==r.val||e.u.empty||r.err.push(M("required",r,1080));else r.err.push(M("type",r,1050));if(0<e.a.length)for(let l=0;l<e.a.length;l++){let n=p(e.a[l],r);e=r.node,void 0!==n.done&&(t=n.done)}let n=r.node.p?!1!==r.ignoreVal:!!r.ignoreVal;!r.match&&null!=r.parent&&!t&&!n&&(r.parent[r.key]=r.val),r.nextSibling&&(r.pI=r.sI)}if(0<r.err.length)if(Array.isArray(r.ctx.err))r.ctx.err.push(...r.err);else if(!r.match&&!1!==r.ctx.err)throw new o("shape",r.err,r.ctx);return r.match?0===r.err.length:r.root}function h(e,t){return c(e,t,!1)}h.valid=function(e,t){let n=t||{};return n.err=n.err||[],c(e,n,!1),0===n.err.length},h.match=(e,t)=>c(e,t=t||{},!0),h.error=(e,t)=>{let n=t||{};return n.err=n.err||[],c(e,n,!1),n.err},h.spec=()=>(h(void 0,{err:!1}),JSON.parse(q(f,(e,t)=>n===t||t,!1,!0))),h.node=()=>(h.spec(),f);let d="";return h.toString=()=>(d=G(""===d?q(f&&f.$&&(n===f.$.gubu$||!0===f.$.gubu$)?f.v:f):d),`[Gubu ${s.name} ${d}]`),e.inspect&&e.inspect.custom&&(h[e.inspect.custom]=h.toString),h.gubu=r,h}function p(e,t){var n;let r,l={},i=!1;try{i=!(void 0!==t.val||null===(n=e.gubu$)||void 0===n||!n.Check)||e(t.val,l,t)}catch(u){r=u}let o=Array.isArray(l.err)?0<l.err.length:null!=l.err;if(!i||o){if(void 0===t.val&&(t.node.p||!t.node.r)&&!0!==l.done)return delete l.err,l;let n=l.why||"check",i=c(t);if("string"==typeof l.err)t.err.push(B(t,l.err));else if("object"==typeof l.err)t.err.push(...[l.err].flat().map(e=>(e.p=null==e.p?i:e.p,e.m=null==e.m?2010:e.m,e)));else{let l=e.name;null!=l&&""!=l||(l=G(e.toString().replace(/[ \t\r\n]+/g," "))),t.err.push(M(n,t,1045,void 0,{thrown:r},l))}l.done=null==l.done||l.done}return l.hasOwnProperty("uval")?(t.updateVal(l.uval),t.ignoreVal=!1):void 0===l.val||Number.isNaN(l.val)||(t.updateVal(l.val),t.ignoreVal=!1),void 0!==l.node&&(t.node=l.node),void 0!==l.type&&(t.type=l.type),l}function c(e){return e.path.slice(1,e.dI+1).filter(e=>null!=e).join(".")}const h=function(e){let t=C(this,e);return t.r=!0,t.p=!1,void 0===e&&1===arguments.length&&(t.t="undefined",t.v=void 0),t},d=function(e){let t=C(this,e);return t.r=!1,t.p=!0,t},v=function(e){let t=C(this,e);return t.u.empty=!0,t},y=function(e){let t=C(this,e);return t.t="any",void 0!==e&&(t.v=e),t},b=function(e){let t=C(this,e);return t.t="never",t},m=function(...e){let t=C();t.t="list",t.r=!0;let n=e.map(e=>J(e));return t.u.list=e,t.b.push((function(t,r,l){let i=!0;for(let e of n){let n={...l.ctx,err:[]};e(t,n),0<n.err.length&&(i=!1)}return i||(r.why="all",r.err=[B(l,'Value "$VALUE" for property "$PATH" does not satisfy all of: '+e.map(e=>q(e,null,!0)).join(", "))]),i})),t},g=function(...e){let t=C();t.t="list",t.r=!0;let n=e.map(e=>J(e));return t.u.list=e,t.b.push((function(t,r,l){let i=!1;for(let e of n){let n={...l.ctx,err:[]},o=e.match(t,n);o&&(r.val=e(t,n)),i||(i=o)}return i||(r.why="some",r.err=[B(l,'Value "$VALUE" for property "$PATH" does not satisfy any of: '+e.map(e=>q(e,null,!0)).join(", "))]),i})),t},$=function(...e){let t=C();t.t="list",t.r=!0;let n=e.map(e=>J(e));return t.u.list=e,t.b.push((function(t,r,l){let i=0;for(let e of n){let n={...l.ctx,err:[]};if(e.match(t,n)){i++,r.val=e(t,n);break}}return 1!==i&&(r.why="one",r.err=[B(l,'Value "$VALUE" for property "$PATH" does not satisfy one of: '+e.map(e=>q(e,null,!0)).join(", "))]),!0})),t},I=function(...e){let t=C();return t.b.push((function(t,n,r){for(let l=0;l<e.length;l++)if(t===e[l])return!0;return n.err=B(r,`Value "$VALUE" for property "$PATH" must be exactly one of: ${r.node.s}.`),n.done=!0,!1})),t.s=e.map(e=>q(e,null,!0)).join(", "),t},A=function(e,t){let n=C(this,t);return n.b.push(e),n},k=function(e,t){let n=C(this,t);return n.a.push(e),n},x=function(e,t){let n=C(this,t);if("function"==typeof e){let t=e;t.gubu$=t.gubu$||{},t.gubu$.Check=!0,n.b.push(e),n.s=(null==n.s?"":n.s+";")+q(e,null,!0),n.r=!0}else if("object"==typeof e){if(Object.prototype.toString.call(e).includes("RegExp")){let t=t=>null!=t&&!Number.isNaN(t)&&!!String(t).match(e);Object.defineProperty(t,"name",{value:String(e)}),Object.defineProperty(t,"gubu$",{value:{Check:!0}}),n.b.push(t),n.s=q(e),n.r=!0}}else"string"==typeof e&&(n.t=e,n.r=!0);return n},j=function(e){let t=C(this,e);return t.c=y(),t},V=function(e){let t=C(this,e);return"array"===t.t&&l!==t.c&&0===t.n?(t.v=[t.c],t.c=l):t.c=l,t},w=function(e,t){let n=C(this,t),r="string"==typeof e?e:("object"==typeof e&&e||{}).name;return null!=r&&""!=r&&n.b.push((function(e,t,n){return(n.ctx.ref=n.ctx.ref||{})[r]=n.node,!0})),n},S=function(e,t){let n=C(this,t),r="object"==typeof e&&e||{},l="string"==typeof e?e:r.name,i=!!r.fill;return null!=l&&""!=l&&n.b.push((function(e,t,n){if(void 0!==e||i){let e=n.ctx.ref=n.ctx.ref||{};if(void 0!==e[l]){let n={...e[l]};n.t=n.t||"never",t.node=n,t.type=n.t}}return!0})),n},O=function(e,t){let n=C(this,t),r="object"==typeof e&&e||{},l="string"==typeof e?e:r.name,i="boolean"==typeof r.keep?r.keep:void 0,o=Array.isArray(r.claim)?r.claim:[];if(null!=l&&""!=l){let e=(e,t,n)=>{if(void 0===e&&0<o.length){n.ctx.Rename=n.ctx.Rename||{},n.ctx.Rename.fromDefault=n.ctx.Rename.fromDefault||{};for(let e of o){let r=n.ctx.Rename.fromDefault[e]||{};if(void 0!==n.parent[e]&&!r.yes){t.val=n.parent[e],n.match||(n.parent[l]=t.val),t.node=r.node;for(let e=0;e<n.err.length;e++)n.err[e].k===r.key&&(n.err.splice(e,1),e--);if(i){let t=n.cI+1;n.nodes.splice(t,0,a(r.dval)),n.vals.splice(t,0,void 0),n.parents.splice(t,0,n.parent),n.keys.splice(t,0,e),n.nI++,n.pI++}else delete n.parent[e];break}}void 0===t.val&&(t.val=n.node.v)}return!0};Object.defineProperty(e,"name",{value:"Rename:"+l}),n.b.push(e);let t=(e,t,n)=>(n.parent[l]=e,n.match||i||n.key===l||Array.isArray(n.parent)&&!1!==i||(delete n.parent[n.key],t.done=!0),n.ctx.Rename=n.ctx.Rename||{},n.ctx.Rename.fromDefault=n.ctx.Rename.fromDefault||{},n.ctx.Rename.fromDefault[l]={yes:n.fromDefault,key:n.key,dval:n.node.v,node:n.node},!0);Object.defineProperty(t,"name",{value:"Rename:"+l}),n.a.push(t)}return n};function N(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.length)?e.length:null!=e&&"object"==typeof e?Object.keys(e).length:NaN}function G(e,t){let n=String(e),r=null==t||isNaN(t)?30:t<0?0:~~t,l=null==e?0:n.length,i=null==e?"":n.substring(0,l);return(i=r<l?i.substring(0,r-3)+"...":i).substring(0,r)}const R=function(e,t){let n=C(this,t);return n.b.push((function(t,n,r){let l=N(t);if(e<=l)return!0;let i="number"==typeof t?"":"length ";return n.err=B(r,`Value "$VALUE" for property "$PATH" must be a minimum ${i}of ${e} (was ${l}).`),!1})),n.s="Min("+e+(null==t?"":","+q(t))+")",n},E=function(e,t){let n=C(this,t);return n.b.push((function(t,n,r){let l=N(t);if(l<=e)return!0;let i="number"==typeof t?"":"length ";return n.err=B(r,`Value "$VALUE" for property "$PATH" must be a maximum ${i}of ${e} (was ${l}).`),!1})),n.s="Max("+e+(null==t?"":","+q(t))+")",n},P=function(e,t){let n=C(this,t);return n.b.push((function(t,n,r){let l=N(t);if(e<l)return!0;let i="number"==typeof t?"be":"have length";return n.err=B(r,`Value "$VALUE" for property "$PATH" must ${i} above ${e} (was ${l}).`),!1})),n.s="Above("+e+(null==t?"":","+q(t))+")",n},D=function(e,t){let n=C(this,t);return n.b.push((function(t,n,r){let l=N(t);if(l<e)return!0;let i="number"==typeof t?"be":"have length";return n.err=B(r,`Value "$VALUE" for property "$PATH" must ${i} below ${e} (was ${l}).`),!1})),n.s="Below("+e+(null==t?"":","+q(t))+")",n},T=function(e,t){let n=C(null==t?this:t),r=a(e);return n.c=r,n};function C(e,t){let n=a(null==e||e.window===e||e.global===e?t:e);return Object.assign(n,{Above:P,After:k,Any:y,Before:A,Below:D,Check:x,Closed:V,Open:j,Define:w,Empty:v,Exact:I,Max:E,Min:R,Never:b,Refer:S,Rename:O,Required:h,Skip:d,Value:T})}function B(e,t,n,r){return M(n||"check",e,4e3,t,r)}function M(e,t,n,r,l,i){let o={k:t.key,n:t.node,v:t.val,p:c(t),w:e,m:n,t:"",u:l||{}},u=G((void 0===t.val?"":q(t.val)).replace(/"/g,""));if(null==r||""===r){let n=u.startsWith("[")?"array":u.startsWith("{")?"object":"value",r=u.startsWith("[")||Array.isArray(t.parents[t.pI])?"index":"property",s="is",a=null==l?void 0:l.k;a=Array.isArray(a)?(r=1<a.length?(s="are","properties"):r,a.join(", ")):a,o.t="Validation failed for "+(0<o.p.length?`${r} "${o.p}" with `:"")+`${n} "${u}" because `+("type"===e?"instance"===t.node.t?`the ${n} is not an instance of ${t.node.u.n} `:`the ${n} is not of type ${t.node.t}`:"required"===e?""===t.val?"an empty string is not allowed":`the ${n} is required`:"closed"===e?`the ${r} "${a}" ${s} not allowed`:"never"===e?"no value is allowed":`check "${null==i?e:i}" failed`)+(o.u.thrown?" (threw: "+o.u.thrown.message+")":".")}else o.t=r.replace(/\$VALUE/g,u).replace(/\$PATH/g,o.p);return o}function L(e){return null!=e.s&&""!==e.s?e.s:e.r||void 0===e.v?e.t:e.v}function q(e,t,r,l){let i;l||!e||!e.$||n!==e.$.gubu$&&!0!==e.$.gubu$||(e=L(e));try{i=JSON.stringify(e,(e,r)=>{var i,o;if(t&&(r=t(e,r)),null!=r&&"object"==typeof r&&r.constructor&&"Object"!==r.constructor.name&&"Array"!==r.constructor.name)r="function"==typeof r.toString?r.toString():r.constructor.name;else if("function"==typeof r)r="function"==typeof f[r.name]&&isNaN(+e)?void 0:null!=r.name&&""!==r.name?r.name:G(r.toString().replace(/[ \t\r\n]+/g," "));else if("bigint"==typeof r)r=String(r.toString());else{if(Number.isNaN(r))return"NaN";!0===l||!0!==(null===(i=null==r?void 0:r.$)||void 0===i?void 0:i.gubu$)&&n!==(null===(o=null==r?void 0:r.$)||void 0===o?void 0:o.gubu$)||(r=L(r))}return r}),i=String(i)}catch(o){i=JSON.stringify(String(e))}return!0===r&&(i=i.replace(/^"/,"").replace(/"$/,"")),i}function H(e){return null==e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}const U=e=>a({...e,$:{gubu$:!0}});if("undefined"!=typeof window){let e=[{b:P,n:"Above"},{b:k,n:"After"},{b:m,n:"All"},{b:y,n:"Any"},{b:A,n:"Before"},{b:D,n:"Below"},{b:x,n:"Check"},{b:V,n:"Closed"},{b:j,n:"Open"},{b:w,n:"Define"},{b:v,n:"Empty"},{b:I,n:"Exact"},{b:E,n:"Max"},{b:R,n:"Min"},{b:b,n:"Never"},{b:$,n:"One"},{b:S,n:"Refer"},{b:O,n:"Rename"},{b:h,n:"Required"},{b:d,n:"Skip"},{b:g,n:"Some"},{b:T,n:"Value"}];for(let t of e)Object.defineProperty(t.b,"name",{value:t.n})}Object.assign(f,{Above:P,After:k,All:m,Any:y,Before:A,Below:D,Check:x,Closed:V,Open:j,Define:w,Empty:v,Exact:I,Max:E,Min:R,Never:b,One:$,Refer:S,Rename:O,Required:h,Skip:d,Some:g,Value:T,GAbove:P,GAfter:k,GAll:m,GAny:y,GBefore:A,GBelow:D,GCheck:x,GClosed:V,GOpen:j,GDefine:w,GEmpty:v,GExact:I,GMax:E,GMin:R,GNever:b,GOne:$,GRefer:S,GRename:O,GRequired:h,GSkip:d,GSome:g,GValue:T,G$:U,buildize:C,makeErr:B,stringify:q,truncate:G,nodize:a}),Object.defineProperty(f,"name",{value:"gubu"});const J=f;t.Gubu=J;const{Gubu:F}=t;return F}));