@kelceyp/caw-server 0.0.24 → 0.0.26
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/dist/main.js +11 -11
- package/dist/public_html/main.js +61 -61
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -256,8 +256,8 @@ return fn.apply(this, arguments)
|
|
|
256
256
|
* Copyright(c) 2013 Roman Shtylman
|
|
257
257
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
258
258
|
* MIT Licensed
|
|
259
|
-
*/var y86=xa(),u86=gR(),KD=SG(),m86=Tr(),p86=yR(),lG=dP()("express:application"),c86=Ar(),B86=F("http"),U86=Wq().compileETag,l86=Wq().compileQueryParser,F86=Wq().compileTrust,i86=y7()("express"),Q86=IO(),$D=xO(),d86=F("path").resolve,KJ=RP(),n86=Object.prototype.hasOwnProperty,YD=Array.prototype.slice,
|
|
260
|
-
Please see the 3.x to 4.x migration guide for details on how to update your app.`)}})};
|
|
259
|
+
*/var y86=xa(),u86=gR(),KD=SG(),m86=Tr(),p86=yR(),lG=dP()("express:application"),c86=Ar(),B86=F("http"),U86=Wq().compileETag,l86=Wq().compileQueryParser,F86=Wq().compileTrust,i86=y7()("express"),Q86=IO(),$D=xO(),d86=F("path").resolve,KJ=RP(),n86=Object.prototype.hasOwnProperty,YD=Array.prototype.slice,v4=Vs=ks.exports={},qD="@@symbol:trust_proxy_default";v4.init=function $(){this.cache={},this.engines={},this.settings={},this.defaultConfiguration()};v4.defaultConfiguration=function $(){var K="development";if(this.enable("x-powered-by"),this.set("etag","weak"),this.set("env",K),this.set("query parser","extended"),this.set("subdomain offset",2),this.set("trust proxy",!1),Object.defineProperty(this.settings,qD,{configurable:!0,value:!0}),lG("booting in %s mode",K),this.on("mount",function q(Y){if(this.settings[qD]===!0&&typeof Y.settings["trust proxy fn"]==="function")delete this.settings["trust proxy"],delete this.settings["trust proxy fn"];KJ(this.request,Y.request),KJ(this.response,Y.response),KJ(this.engines,Y.engines),KJ(this.settings,Y.settings)}),this.locals=Object.create(null),this.mountpath="/",this.locals.settings=this.settings,this.set("view",c86),this.set("views",d86("views")),this.set("jsonp callback name","callback"),K==="production")this.enable("view cache");Object.defineProperty(this,"router",{get:function(){throw new Error(`'app.router' is deprecated!
|
|
260
|
+
Please see the 3.x to 4.x migration guide for details on how to update your app.`)}})};v4.lazyrouter=function $(){if(!this._router)this._router=new u86({caseSensitive:this.enabled("case sensitive routing"),strict:this.enabled("strict routing")}),this._router.use(p86(this.get("query parser fn"))),this._router.use(m86.init(this))};v4.handle=function $(K,q,Y){var z=this._router,P=Y||y86(K,q,{env:this.get("env"),onerror:o86.bind(this)});if(!z){lG("no routes defined on app"),P();return}z.handle(K,q,P)};v4.use=function $(K){var q=0,Y="/";if(typeof K!=="function"){var z=K;while(Array.isArray(z)&&z.length!==0)z=z[0];if(typeof z!=="function")q=1,Y=K}var P=Q86(YD.call(arguments,q));if(P.length===0)throw new TypeError("app.use() requires a middleware function");this.lazyrouter();var J=this._router;return P.forEach(function(W){if(!W||!W.handle||!W.set)return J.use(Y,W);lG(".use app under %s",Y),W.mountpath=Y,W.parent=this,J.use(Y,function H(Z,O,w){var X=Z.app;W.handle(Z,O,function(T){KJ(Z,X.request),KJ(O,X.response),w(T)})}),W.emit("mount",this)},this),this};v4.route=function $(K){return this.lazyrouter(),this._router.route(K)};v4.engine=function $(K,q){if(typeof q!=="function")throw new Error("callback function required");var Y=K[0]!=="."?"."+K:K;return this.engines[Y]=q,this};v4.param=function $(K,q){if(this.lazyrouter(),Array.isArray(K)){for(var Y=0;Y<K.length;Y++)this.param(K[Y],q);return this}return this._router.param(K,q),this};v4.set=function $(K,q){if(arguments.length===1){var Y=this.settings;while(Y&&Y!==Object.prototype){if(n86.call(Y,K))return Y[K];Y=Object.getPrototypeOf(Y)}return}switch(lG('set "%s" to %o',K,q),this.settings[K]=q,K){case"etag":this.set("etag fn",U86(q));break;case"query parser":this.set("query parser fn",l86(q));break;case"trust proxy":this.set("trust proxy fn",F86(q)),Object.defineProperty(this.settings,qD,{configurable:!0,value:!1});break}return this};v4.path=function $(){return this.parent?this.parent.path()+this.mountpath:""};v4.enabled=function $(K){return Boolean(this.set(K))};v4.disabled=function $(K){return!this.set(K)};v4.enable=function $(K){return this.set(K,!0)};v4.disable=function $(K){return this.set(K,!1)};KD.forEach(function($){v4[$]=function(K){if($==="get"&&arguments.length===1)return this.set(K);this.lazyrouter();var q=this._router.route(K);return q[$].apply(q,YD.call(arguments,1)),this}});v4.all=function $(K){this.lazyrouter();var q=this._router.route(K),Y=YD.call(arguments,1);for(var z=0;z<KD.length;z++)q[KD[z]].apply(q,Y);return this};v4.del=i86.function(v4.delete,"app.del: Use app.delete instead");v4.render=function $(K,q,Y){var z=this.cache,P=Y,J=this.engines,W=q,H={},Z;if(typeof q==="function")P=q,W={};if($D(H,this.locals),W._locals)$D(H,W._locals);if($D(H,W),H.cache==null)H.cache=this.enabled("view cache");if(H.cache)Z=z[K];if(!Z){var O=this.get("view");if(Z=new O(K,{defaultEngine:this.get("view engine"),root:this.get("views"),engines:J}),!Z.path){var w=Array.isArray(Z.root)&&Z.root.length>1?'directories "'+Z.root.slice(0,-1).join('", "')+'" or "'+Z.root[Z.root.length-1]+'"':'directory "'+Z.root+'"',X=new Error('Failed to lookup view "'+K+'" in views '+w);return X.view=Z,P(X)}if(H.cache)z[K]=Z}a86(Z,H,P)};v4.listen=function $(){var K=B86.createServer(this);return K.listen.apply(K,arguments)};function o86($){if(this.get("env")!=="test")console.error($.stack||$.toString())}function a86($,K,q){try{$.render(K,q)}catch(Y){q(Y)}}});var Rs=j((RX1,zD)=>{zD.exports=Cs;zD.exports.preferredCharsets=Cs;var r86=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function s86($){var K=$.split(",");for(var q=0,Y=0;q<K.length;q++){var z=t86(K[q].trim(),q);if(z)K[Y++]=z}return K.length=Y,K}function t86($,K){var q=r86.exec($);if(!q)return null;var Y=q[1],z=1;if(q[2]){var P=q[2].split(";");for(var J=0;J<P.length;J++){var W=P[J].trim().split("=");if(W[0]==="q"){z=parseFloat(W[1]);break}}}return{charset:Y,q:z,i:K}}function e86($,K,q){var Y={o:-1,q:0,s:0};for(var z=0;z<K.length;z++){var P=$66($,K[z],q);if(P&&(Y.s-P.s||Y.q-P.q||Y.o-P.o)<0)Y=P}return Y}function $66($,K,q){var Y=0;if(K.charset.toLowerCase()===$.toLowerCase())Y|=1;else if(K.charset!=="*")return null;return{i:q,o:K.i,q:K.q,s:Y}}function Cs($,K){var q=s86($===void 0?"*":$||"");if(!K)return q.filter(hs).sort(Ns).map(K66);var Y=K.map(function z(P,J){return e86(P,q,J)});return Y.filter(hs).sort(Ns).map(function z(P){return K[Y.indexOf(P)]})}function Ns($,K){return K.q-$.q||K.s-$.s||$.o-K.o||$.i-K.i||0}function K66($){return $.charset}function hs($){return $.q>0}});var Is=j((DX1,PD)=>{PD.exports=Ls;PD.exports.preferredEncodings=Ls;var q66=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function Y66($){var K=$.split(","),q=!1,Y=1;for(var z=0,P=0;z<K.length;z++){var J=z66(K[z].trim(),z);if(J)K[P++]=J,q=q||Es("identity",J),Y=Math.min(Y,J.q||1)}if(!q)K[P++]={encoding:"identity",q:Y,i:z};return K.length=P,K}function z66($,K){var q=q66.exec($);if(!q)return null;var Y=q[1],z=1;if(q[2]){var P=q[2].split(";");for(var J=0;J<P.length;J++){var W=P[J].trim().split("=");if(W[0]==="q"){z=parseFloat(W[1]);break}}}return{encoding:Y,q:z,i:K}}function P66($,K,q){var Y={o:-1,q:0,s:0};for(var z=0;z<K.length;z++){var P=Es($,K[z],q);if(P&&(Y.s-P.s||Y.q-P.q||Y.o-P.o)<0)Y=P}return Y}function Es($,K,q){var Y=0;if(K.encoding.toLowerCase()===$.toLowerCase())Y|=1;else if(K.encoding!=="*")return null;return{i:q,o:K.i,q:K.q,s:Y}}function Ls($,K){var q=Y66($||"");if(!K)return q.filter(Ss).sort(Ds).map(J66);var Y=K.map(function z(P,J){return P66(P,q,J)});return Y.filter(Ss).sort(Ds).map(function z(P){return K[Y.indexOf(P)]})}function Ds($,K){return K.q-$.q||K.s-$.s||$.o-K.o||$.i-K.i||0}function J66($){return $.encoding}function Ss($){return $.q>0}});var us=j((SX1,JD)=>{JD.exports=ys;JD.exports.preferredLanguages=ys;var W66=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;function H66($){var K=$.split(",");for(var q=0,Y=0;q<K.length;q++){var z=gs(K[q].trim(),q);if(z)K[Y++]=z}return K.length=Y,K}function gs($,K){var q=W66.exec($);if(!q)return null;var Y=q[1],z=q[2],P=Y;if(z)P+="-"+z;var J=1;if(q[3]){var W=q[3].split(";");for(var H=0;H<W.length;H++){var Z=W[H].split("=");if(Z[0]==="q")J=parseFloat(Z[1])}}return{prefix:Y,suffix:z,q:J,i:K,full:P}}function Z66($,K,q){var Y={o:-1,q:0,s:0};for(var z=0;z<K.length;z++){var P=O66($,K[z],q);if(P&&(Y.s-P.s||Y.q-P.q||Y.o-P.o)<0)Y=P}return Y}function O66($,K,q){var Y=gs($);if(!Y)return null;var z=0;if(K.full.toLowerCase()===Y.full.toLowerCase())z|=4;else if(K.prefix.toLowerCase()===Y.full.toLowerCase())z|=2;else if(K.full.toLowerCase()===Y.prefix.toLowerCase())z|=1;else if(K.full!=="*")return null;return{i:q,o:K.i,q:K.q,s:z}}function ys($,K){var q=H66($===void 0?"*":$||"");if(!K)return q.filter(bs).sort(xs).map(w66);var Y=K.map(function z(P,J){return Z66(P,q,J)});return Y.filter(bs).sort(xs).map(function z(P){return K[Y.indexOf(P)]})}function xs($,K){return K.q-$.q||K.s-$.s||$.o-K.o||$.i-K.i||0}function w66($){return $.full}function bs($){return $.q>0}});var ls=j((EX1,WD)=>{WD.exports=Bs;WD.exports.preferredMediaTypes=Bs;var X66=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function T66($){var K=f66($);for(var q=0,Y=0;q<K.length;q++){var z=cs(K[q].trim(),q);if(z)K[Y++]=z}return K.length=Y,K}function cs($,K){var q=X66.exec($);if(!q)return null;var Y=Object.create(null),z=1,P=q[2],J=q[1];if(q[3]){var W=A66(q[3]).map(_66);for(var H=0;H<W.length;H++){var Z=W[H],O=Z[0].toLowerCase(),w=Z[1],X=w&&w[0]==='"'&&w[w.length-1]==='"'?w.substr(1,w.length-2):w;if(O==="q"){z=parseFloat(X);break}Y[O]=X}}return{type:J,subtype:P,params:Y,q:z,i:K}}function j66($,K,q){var Y={o:-1,q:0,s:0};for(var z=0;z<K.length;z++){var P=v66($,K[z],q);if(P&&(Y.s-P.s||Y.q-P.q||Y.o-P.o)<0)Y=P}return Y}function v66($,K,q){var Y=cs($),z=0;if(!Y)return null;if(K.type.toLowerCase()==Y.type.toLowerCase())z|=4;else if(K.type!="*")return null;if(K.subtype.toLowerCase()==Y.subtype.toLowerCase())z|=2;else if(K.subtype!="*")return null;var P=Object.keys(K.params);if(P.length>0)if(P.every(function(J){return K.params[J]=="*"||(K.params[J]||"").toLowerCase()==(Y.params[J]||"").toLowerCase()}))z|=1;else return null;return{i:q,o:K.i,q:K.q,s:z}}function Bs($,K){var q=T66($===void 0?"*/*":$||"");if(!K)return q.filter(ps).sort(ms).map(G66);var Y=K.map(function z(P,J){return j66(P,q,J)});return Y.filter(ps).sort(ms).map(function z(P){return K[Y.indexOf(P)]})}function ms($,K){return K.q-$.q||K.s-$.s||$.o-K.o||$.i-K.i||0}function G66($){return $.type+"/"+$.subtype}function ps($){return $.q>0}function Us($){var K=0,q=0;while((q=$.indexOf('"',q))!==-1)K++,q++;return K}function _66($){var K=$.indexOf("="),q,Y;if(K===-1)q=$;else q=$.substr(0,K),Y=$.substr(K+1);return[q,Y]}function f66($){var K=$.split(",");for(var q=1,Y=0;q<K.length;q++)if(Us(K[Y])%2==0)K[++Y]=K[q];else K[Y]+=","+K[q];return K.length=Y+1,K}function A66($){var K=$.split(";");for(var q=1,Y=0;q<K.length;q++)if(Us(K[Y])%2==0)K[++Y]=K[q];else K[Y]+=";"+K[q];K.length=Y+1;for(var q=0;q<K.length;q++)K[q]=K[q].trim();return K}});var Fs=j((LX1,HD)=>{/*!
|
|
261
261
|
* negotiator
|
|
262
262
|
* Copyright(c) 2012 Federico Romero
|
|
263
263
|
* Copyright(c) 2012-2014 Isaac Z. Schlueter
|
|
@@ -342,14 +342,14 @@ ${q}`,$}return $}function HJ6($){return Yz8.isObject($)&&Yz8.isString($.stack)}}
|
|
|
342
342
|
`+PJ8.repeat(" ",K+this.position-z+Y.length)+"^"};Xx.prototype.toString=function $(K){var q,Y="";if(this.name)Y+='in "'+this.name+'" ';if(Y+="at line "+(this.line+1)+", column "+(this.column+1),!K){if(q=this.getSnippet(),q)Y+=`:
|
|
343
343
|
`+q}return Y};JJ8.exports=Xx});var D4=j((Sy1,ZJ8)=>{var HJ8=JW(),KZ6=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],qZ6=["scalar","sequence","mapping"];function YZ6($){var K={};if($!==null)Object.keys($).forEach(function(q){$[q].forEach(function(Y){K[String(Y)]=q})});return K}function zZ6($,K){if(K=K||{},Object.keys(K).forEach(function(q){if(KZ6.indexOf(q)===-1)throw new HJ8('Unknown option "'+q+'" is met in definition of "'+$+'" YAML type.')}),this.tag=$,this.kind=K.kind||null,this.resolve=K.resolve||function(){return!0},this.construct=K.construct||function(q){return q},this.instanceOf=K.instanceOf||null,this.predicate=K.predicate||null,this.represent=K.represent||null,this.defaultStyle=K.defaultStyle||null,this.styleAliases=YZ6(K.styleAliases||null),qZ6.indexOf(this.kind)===-1)throw new HJ8('Unknown kind "'+this.kind+'" is specified for "'+$+'" YAML type.')}ZJ8.exports=zZ6});var Bz=j((Ey1,wJ8)=>{var OJ8=cz(),vf=JW(),PZ6=D4();function Tx($,K,q){var Y=[];return $.include.forEach(function(z){q=Tx(z,K,q)}),$[K].forEach(function(z){q.forEach(function(P,J){if(P.tag===z.tag&&P.kind===z.kind)Y.push(J)}),q.push(z)}),q.filter(function(z,P){return Y.indexOf(P)===-1})}function JZ6(){var $={scalar:{},sequence:{},mapping:{},fallback:{}},K,q;function Y(z){$[z.kind][z.tag]=$.fallback[z.tag]=z}for(K=0,q=arguments.length;K<q;K+=1)arguments[K].forEach(Y);return $}function WW($){this.include=$.include||[],this.implicit=$.implicit||[],this.explicit=$.explicit||[],this.implicit.forEach(function(K){if(K.loadKind&&K.loadKind!=="scalar")throw new vf("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=Tx(this,"implicit",[]),this.compiledExplicit=Tx(this,"explicit",[]),this.compiledTypeMap=JZ6(this.compiledImplicit,this.compiledExplicit)}WW.DEFAULT=null;WW.create=function $(){var K,q;switch(arguments.length){case 1:K=WW.DEFAULT,q=arguments[0];break;case 2:K=arguments[0],q=arguments[1];break;default:throw new vf("Wrong number of arguments for Schema.create function")}if(K=OJ8.toArray(K),q=OJ8.toArray(q),!K.every(function(Y){return Y instanceof WW}))throw new vf("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!q.every(function(Y){return Y instanceof PZ6}))throw new vf("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new WW({include:K,explicit:q})};wJ8.exports=WW});var TJ8=j((Ly1,XJ8)=>{var WZ6=D4();XJ8.exports=new WZ6("tag:yaml.org,2002:str",{kind:"scalar",construct:function($){return $!==null?$:""}})});var vJ8=j((Iy1,jJ8)=>{var HZ6=D4();jJ8.exports=new HZ6("tag:yaml.org,2002:seq",{kind:"sequence",construct:function($){return $!==null?$:[]}})});var _J8=j((xy1,GJ8)=>{var ZZ6=D4();GJ8.exports=new ZZ6("tag:yaml.org,2002:map",{kind:"mapping",construct:function($){return $!==null?$:{}}})});var Gf=j((by1,fJ8)=>{var OZ6=Bz();fJ8.exports=new OZ6({explicit:[TJ8(),vJ8(),_J8()]})});var VJ8=j((gy1,AJ8)=>{var wZ6=D4();function XZ6($){if($===null)return!0;var K=$.length;return K===1&&$==="~"||K===4&&($==="null"||$==="Null"||$==="NULL")}function TZ6(){return null}function jZ6($){return $===null}AJ8.exports=new wZ6("tag:yaml.org,2002:null",{kind:"scalar",resolve:XZ6,construct:TZ6,predicate:jZ6,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var MJ8=j((yy1,kJ8)=>{var vZ6=D4();function GZ6($){if($===null)return!1;var K=$.length;return K===4&&($==="true"||$==="True"||$==="TRUE")||K===5&&($==="false"||$==="False"||$==="FALSE")}function _Z6($){return $==="true"||$==="True"||$==="TRUE"}function fZ6($){return Object.prototype.toString.call($)==="[object Boolean]"}kJ8.exports=new vZ6("tag:yaml.org,2002:bool",{kind:"scalar",resolve:GZ6,construct:_Z6,predicate:fZ6,represent:{lowercase:function($){return $?"true":"false"},uppercase:function($){return $?"TRUE":"FALSE"},camelcase:function($){return $?"True":"False"}},defaultStyle:"lowercase"})});var hJ8=j((uy1,NJ8)=>{var AZ6=cz(),VZ6=D4();function kZ6($){return 48<=$&&$<=57||65<=$&&$<=70||97<=$&&$<=102}function MZ6($){return 48<=$&&$<=55}function NZ6($){return 48<=$&&$<=57}function hZ6($){if($===null)return!1;var K=$.length,q=0,Y=!1,z;if(!K)return!1;if(z=$[q],z==="-"||z==="+")z=$[++q];if(z==="0"){if(q+1===K)return!0;if(z=$[++q],z==="b"){q++;for(;q<K;q++){if(z=$[q],z==="_")continue;if(z!=="0"&&z!=="1")return!1;Y=!0}return Y&&z!=="_"}if(z==="x"){q++;for(;q<K;q++){if(z=$[q],z==="_")continue;if(!kZ6($.charCodeAt(q)))return!1;Y=!0}return Y&&z!=="_"}for(;q<K;q++){if(z=$[q],z==="_")continue;if(!MZ6($.charCodeAt(q)))return!1;Y=!0}return Y&&z!=="_"}if(z==="_")return!1;for(;q<K;q++){if(z=$[q],z==="_")continue;if(z===":")break;if(!NZ6($.charCodeAt(q)))return!1;Y=!0}if(!Y||z==="_")return!1;if(z!==":")return!0;return/^(:[0-5]?[0-9])+$/.test($.slice(q))}function CZ6($){var K=$,q=1,Y,z,P=[];if(K.indexOf("_")!==-1)K=K.replace(/_/g,"");if(Y=K[0],Y==="-"||Y==="+"){if(Y==="-")q=-1;K=K.slice(1),Y=K[0]}if(K==="0")return 0;if(Y==="0"){if(K[1]==="b")return q*parseInt(K.slice(2),2);if(K[1]==="x")return q*parseInt(K,16);return q*parseInt(K,8)}if(K.indexOf(":")!==-1)return K.split(":").forEach(function(J){P.unshift(parseInt(J,10))}),K=0,z=1,P.forEach(function(J){K+=J*z,z*=60}),q*K;return q*parseInt(K,10)}function RZ6($){return Object.prototype.toString.call($)==="[object Number]"&&($%1===0&&!AZ6.isNegativeZero($))}NJ8.exports=new VZ6("tag:yaml.org,2002:int",{kind:"scalar",resolve:hZ6,construct:CZ6,predicate:RZ6,represent:{binary:function($){return $>=0?"0b"+$.toString(2):"-0b"+$.toString(2).slice(1)},octal:function($){return $>=0?"0"+$.toString(8):"-0"+$.toString(8).slice(1)},decimal:function($){return $.toString(10)},hexadecimal:function($){return $>=0?"0x"+$.toString(16).toUpperCase():"-0x"+$.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var DJ8=j((my1,RJ8)=>{var CJ8=cz(),DZ6=D4(),SZ6=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function EZ6($){if($===null)return!1;if(!SZ6.test($)||$[$.length-1]==="_")return!1;return!0}function LZ6($){var K,q,Y,z;if(K=$.replace(/_/g,"").toLowerCase(),q=K[0]==="-"?-1:1,z=[],"+-".indexOf(K[0])>=0)K=K.slice(1);if(K===".inf")return q===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(K===".nan")return NaN;else if(K.indexOf(":")>=0)return K.split(":").forEach(function(P){z.unshift(parseFloat(P,10))}),K=0,Y=1,z.forEach(function(P){K+=P*Y,Y*=60}),q*K;return q*parseFloat(K,10)}var IZ6=/^[-+]?[0-9]+e/;function xZ6($,K){var q;if(isNaN($))switch(K){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===$)switch(K){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===$)switch(K){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(CJ8.isNegativeZero($))return"-0.0";return q=$.toString(10),IZ6.test(q)?q.replace("e",".e"):q}function bZ6($){return Object.prototype.toString.call($)==="[object Number]"&&($%1!==0||CJ8.isNegativeZero($))}RJ8.exports=new DZ6("tag:yaml.org,2002:float",{kind:"scalar",resolve:EZ6,construct:LZ6,predicate:bZ6,represent:xZ6,defaultStyle:"lowercase"})});var jx=j((py1,SJ8)=>{var gZ6=Bz();SJ8.exports=new gZ6({include:[Gf()],implicit:[VJ8(),MJ8(),hJ8(),DJ8()]})});var vx=j((cy1,EJ8)=>{var yZ6=Bz();EJ8.exports=new yZ6({include:[jx()]})});var bJ8=j((By1,xJ8)=>{var uZ6=D4(),LJ8=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),IJ8=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function mZ6($){if($===null)return!1;if(LJ8.exec($)!==null)return!0;if(IJ8.exec($)!==null)return!0;return!1}function pZ6($){var K,q,Y,z,P,J,W,H=0,Z=null,O,w,X;if(K=LJ8.exec($),K===null)K=IJ8.exec($);if(K===null)throw new Error("Date resolve error");if(q=+K[1],Y=+K[2]-1,z=+K[3],!K[4])return new Date(Date.UTC(q,Y,z));if(P=+K[4],J=+K[5],W=+K[6],K[7]){H=K[7].slice(0,3);while(H.length<3)H+="0";H=+H}if(K[9]){if(O=+K[10],w=+(K[11]||0),Z=(O*60+w)*60000,K[9]==="-")Z=-Z}if(X=new Date(Date.UTC(q,Y,z,P,J,W,H)),Z)X.setTime(X.getTime()-Z);return X}function cZ6($){return $.toISOString()}xJ8.exports=new uZ6("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:mZ6,construct:pZ6,instanceOf:Date,represent:cZ6})});var yJ8=j((Uy1,gJ8)=>{var BZ6=D4();function UZ6($){return $==="<<"||$===null}gJ8.exports=new BZ6("tag:yaml.org,2002:merge",{kind:"scalar",resolve:UZ6})});var mJ8=j((ly1,uJ8)=>{var Uz;try{Gx=F,Uz=Gx("buffer").Buffer}catch($){}var Gx,lZ6=D4(),_x=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
344
344
|
\r`;function FZ6($){if($===null)return!1;var K,q,Y=0,z=$.length,P=_x;for(q=0;q<z;q++){if(K=P.indexOf($.charAt(q)),K>64)continue;if(K<0)return!1;Y+=6}return Y%8===0}function iZ6($){var K,q,Y=$.replace(/[\r\n=]/g,""),z=Y.length,P=_x,J=0,W=[];for(K=0;K<z;K++){if(K%4===0&&K)W.push(J>>16&255),W.push(J>>8&255),W.push(J&255);J=J<<6|P.indexOf(Y.charAt(K))}if(q=z%4*6,q===0)W.push(J>>16&255),W.push(J>>8&255),W.push(J&255);else if(q===18)W.push(J>>10&255),W.push(J>>2&255);else if(q===12)W.push(J>>4&255);if(Uz)return Uz.from?Uz.from(W):new Uz(W);return W}function QZ6($){var K="",q=0,Y,z,P=$.length,J=_x;for(Y=0;Y<P;Y++){if(Y%3===0&&Y)K+=J[q>>18&63],K+=J[q>>12&63],K+=J[q>>6&63],K+=J[q&63];q=(q<<8)+$[Y]}if(z=P%3,z===0)K+=J[q>>18&63],K+=J[q>>12&63],K+=J[q>>6&63],K+=J[q&63];else if(z===2)K+=J[q>>10&63],K+=J[q>>4&63],K+=J[q<<2&63],K+=J[64];else if(z===1)K+=J[q>>2&63],K+=J[q<<4&63],K+=J[64],K+=J[64];return K}function dZ6($){return Uz&&Uz.isBuffer($)}uJ8.exports=new lZ6("tag:yaml.org,2002:binary",{kind:"scalar",resolve:FZ6,construct:iZ6,predicate:dZ6,represent:QZ6})});var cJ8=j((iy1,pJ8)=>{var nZ6=D4(),oZ6=Object.prototype.hasOwnProperty,aZ6=Object.prototype.toString;function rZ6($){if($===null)return!0;var K=[],q,Y,z,P,J,W=$;for(q=0,Y=W.length;q<Y;q+=1){if(z=W[q],J=!1,aZ6.call(z)!=="[object Object]")return!1;for(P in z)if(oZ6.call(z,P))if(!J)J=!0;else return!1;if(!J)return!1;if(K.indexOf(P)===-1)K.push(P);else return!1}return!0}function sZ6($){return $!==null?$:[]}pJ8.exports=new nZ6("tag:yaml.org,2002:omap",{kind:"sequence",resolve:rZ6,construct:sZ6})});var UJ8=j((Qy1,BJ8)=>{var tZ6=D4(),eZ6=Object.prototype.toString;function $O6($){if($===null)return!0;var K,q,Y,z,P,J=$;P=new Array(J.length);for(K=0,q=J.length;K<q;K+=1){if(Y=J[K],eZ6.call(Y)!=="[object Object]")return!1;if(z=Object.keys(Y),z.length!==1)return!1;P[K]=[z[0],Y[z[0]]]}return!0}function KO6($){if($===null)return[];var K,q,Y,z,P,J=$;P=new Array(J.length);for(K=0,q=J.length;K<q;K+=1)Y=J[K],z=Object.keys(Y),P[K]=[z[0],Y[z[0]]];return P}BJ8.exports=new tZ6("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$O6,construct:KO6})});var FJ8=j((dy1,lJ8)=>{var qO6=D4(),YO6=Object.prototype.hasOwnProperty;function zO6($){if($===null)return!0;var K,q=$;for(K in q)if(YO6.call(q,K)){if(q[K]!==null)return!1}return!0}function PO6($){return $!==null?$:{}}lJ8.exports=new qO6("tag:yaml.org,2002:set",{kind:"mapping",resolve:zO6,construct:PO6})});var HW=j((ny1,iJ8)=>{var JO6=Bz();iJ8.exports=new JO6({include:[vx()],implicit:[bJ8(),yJ8()],explicit:[mJ8(),cJ8(),UJ8(),FJ8()]})});var dJ8=j((oy1,QJ8)=>{var WO6=D4();function HO6(){return!0}function ZO6(){return}function OO6(){return""}function wO6($){return typeof $==="undefined"}QJ8.exports=new WO6("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:HO6,construct:ZO6,predicate:wO6,represent:OO6})});var oJ8=j((ay1,nJ8)=>{var XO6=D4();function TO6($){if($===null)return!1;if($.length===0)return!1;var K=$,q=/\/([gim]*)$/.exec($),Y="";if(K[0]==="/"){if(q)Y=q[1];if(Y.length>3)return!1;if(K[K.length-Y.length-1]!=="/")return!1}return!0}function jO6($){var K=$,q=/\/([gim]*)$/.exec($),Y="";if(K[0]==="/"){if(q)Y=q[1];K=K.slice(1,K.length-Y.length-1)}return new RegExp(K,Y)}function vO6($){var K="/"+$.source+"/";if($.global)K+="g";if($.multiline)K+="m";if($.ignoreCase)K+="i";return K}function GO6($){return Object.prototype.toString.call($)==="[object RegExp]"}nJ8.exports=new XO6("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:TO6,construct:jO6,predicate:GO6,represent:vO6})});var rJ8=j((ry1,aJ8)=>{var _f;try{fx=F,_f=fx("esprima")}catch($){if(typeof window!=="undefined")_f=window.esprima}var fx,_O6=D4();function fO6($){if($===null)return!1;try{var K="("+$+")",q=_f.parse(K,{range:!0});if(q.type!=="Program"||q.body.length!==1||q.body[0].type!=="ExpressionStatement"||q.body[0].expression.type!=="ArrowFunctionExpression"&&q.body[0].expression.type!=="FunctionExpression")return!1;return!0}catch(Y){return!1}}function AO6($){var K="("+$+")",q=_f.parse(K,{range:!0}),Y=[],z;if(q.type!=="Program"||q.body.length!==1||q.body[0].type!=="ExpressionStatement"||q.body[0].expression.type!=="ArrowFunctionExpression"&&q.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");if(q.body[0].expression.params.forEach(function(P){Y.push(P.name)}),z=q.body[0].expression.body.range,q.body[0].expression.body.type==="BlockStatement")return new Function(Y,K.slice(z[0]+1,z[1]-1));return new Function(Y,"return "+K.slice(z[0],z[1]))}function VO6($){return $.toString()}function kO6($){return Object.prototype.toString.call($)==="[object Function]"}aJ8.exports=new _O6("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:fO6,construct:AO6,predicate:kO6,represent:VO6})});var MX=j((ty1,tJ8)=>{var sJ8=Bz();tJ8.exports=sJ8.DEFAULT=new sJ8({include:[HW()],explicit:[dJ8(),oJ8(),rJ8()]})});var fW8=j((QO6,NX)=>{var ZK=cz(),PW8=JW(),MO6=WJ8(),JW8=HW(),NO6=MX(),nq=Object.prototype.hasOwnProperty,ff=1,WW8=2,HW8=3,Af=4,Ax=1,hO6=2,eJ8=3,CO6=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,RO6=/[\x85\u2028\u2029]/,DO6=/[,\[\]\{\}]/,ZW8=/^(?:!|!!|![a-z\-]+!)$/i,OW8=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function $W8($){return Object.prototype.toString.call($)}function Y5($){return $===10||$===13}function lz($){return $===9||$===32}function k$($){return $===9||$===32||$===10||$===13}function ZW($){return $===44||$===91||$===93||$===123||$===125}function SO6($){var K;if(48<=$&&$<=57)return $-48;if(K=$|32,97<=K&&K<=102)return K-97+10;return-1}function EO6($){if($===120)return 2;if($===117)return 4;if($===85)return 8;return 0}function LO6($){if(48<=$&&$<=57)return $-48;return-1}function KW8($){return $===48?"\x00":$===97?"\x07":$===98?"\b":$===116?"\t":$===9?"\t":$===110?`
|
|
345
|
-
`:$===118?"\v":$===102?"\f":$===114?"\r":$===101?"\x1B":$===32?" ":$===34?'"':$===47?"/":$===92?"\\":$===78?"
":$===95?" ":$===76?"\u2028":$===80?"\u2029":""}function IO6($){if($<=65535)return String.fromCharCode($);return String.fromCharCode(($-65536>>10)+55296,($-65536&1023)+56320)}function wW8($,K,q){if(K==="__proto__")Object.defineProperty($,K,{configurable:!0,enumerable:!0,writable:!0,value:q});else $[K]=q}var XW8=new Array(256),TW8=new Array(256);for(Qq=0;Qq<256;Qq++)XW8[Qq]=KW8(Qq)?1:0,TW8[Qq]=KW8(Qq);var Qq;function xO6($,K){this.input=$,this.filename=K.filename||null,this.schema=K.schema||NO6,this.onWarning=K.onWarning||null,this.legacy=K.legacy||!1,this.json=K.json||!1,this.listener=K.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=$.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function jW8($,K){return new PW8(K,new MO6($.filename,$.input,$.position,$.line,$.position-$.lineStart))}function l8($,K){throw jW8($,K)}function Vf($,K){if($.onWarning)$.onWarning.call(null,jW8($,K))}var qW8={YAML:function $(K,q,Y){var z,P,J;if(K.version!==null)l8(K,"duplication of %YAML directive");if(Y.length!==1)l8(K,"YAML directive accepts exactly one argument");if(z=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]),z===null)l8(K,"ill-formed argument of the YAML directive");if(P=parseInt(z[1],10),J=parseInt(z[2],10),P!==1)l8(K,"unacceptable YAML version of the document");if(K.version=Y[0],K.checkLineBreaks=J<2,J!==1&&J!==2)Vf(K,"unsupported YAML version of the document")},TAG:function $(K,q,Y){var z,P;if(Y.length!==2)l8(K,"TAG directive accepts exactly two arguments");if(z=Y[0],P=Y[1],!ZW8.test(z))l8(K,"ill-formed tag handle (first argument) of the TAG directive");if(nq.call(K.tagMap,z))l8(K,'there is a previously declared suffix for "'+z+'" tag handle');if(!OW8.test(P))l8(K,"ill-formed tag prefix (second argument) of the TAG directive");K.tagMap[z]=P}};function dq($,K,q,Y){var z,P,J,W;if(K<q){if(W=$.input.slice(K,q),Y){for(z=0,P=W.length;z<P;z+=1)if(J=W.charCodeAt(z),!(J===9||32<=J&&J<=1114111))l8($,"expected valid JSON character")}else if(CO6.test(W))l8($,"the stream contains non-printable characters");$.result+=W}}function YW8($,K,q,Y){var z,P,J,W;if(!ZK.isObject(q))l8($,"cannot merge mappings; the provided source object is unacceptable");z=Object.keys(q);for(J=0,W=z.length;J<W;J+=1)if(P=z[J],!nq.call(K,P))wW8(K,P,q[P]),Y[P]=!0}function OW($,K,q,Y,z,P,J,W){var H,Z;if(Array.isArray(z)){z=Array.prototype.slice.call(z);for(H=0,Z=z.length;H<Z;H+=1){if(Array.isArray(z[H]))l8($,"nested arrays are not supported inside keys");if(typeof z==="object"&&$W8(z[H])==="[object Object]")z[H]="[object Object]"}}if(typeof z==="object"&&$W8(z)==="[object Object]")z="[object Object]";if(z=String(z),K===null)K={};if(Y==="tag:yaml.org,2002:merge")if(Array.isArray(P))for(H=0,Z=P.length;H<Z;H+=1)YW8($,K,P[H],q);else YW8($,K,P,q);else{if(!$.json&&!nq.call(q,z)&&nq.call(K,z))$.line=J||$.line,$.position=W||$.position,l8($,"duplicated mapping key");wW8(K,z,P),delete q[z]}return K}function Vx($){var K=$.input.charCodeAt($.position);if(K===10)$.position++;else if(K===13){if($.position++,$.input.charCodeAt($.position)===10)$.position++}else l8($,"a line break is expected");$.line+=1,$.lineStart=$.position}function
|
|
346
|
-
`,K-1)}function bO6($,K,q){var Y,z,P,J,W,H,Z,O,w=$.kind,X=$.result,T;if(T=$.input.charCodeAt($.position),k$(T)||ZW(T)||T===35||T===38||T===42||T===33||T===124||T===62||T===39||T===34||T===37||T===64||T===96)return!1;if(T===63||T===45){if(z=$.input.charCodeAt($.position+1),k$(z)||q&&ZW(z))return!1}$.kind="scalar",$.result="",P=J=$.position,W=!1;while(T!==0){if(T===58){if(z=$.input.charCodeAt($.position+1),k$(z)||q&&ZW(z))break}else if(T===35){if(Y=$.input.charCodeAt($.position-1),k$(Y))break}else if($.position===$.lineStart&&kf($)||q&&ZW(T))break;else if(Y5(T))if(H=$.line,Z=$.lineStart,O=$.lineIndent,
|
|
345
|
+
`:$===118?"\v":$===102?"\f":$===114?"\r":$===101?"\x1B":$===32?" ":$===34?'"':$===47?"/":$===92?"\\":$===78?"
":$===95?" ":$===76?"\u2028":$===80?"\u2029":""}function IO6($){if($<=65535)return String.fromCharCode($);return String.fromCharCode(($-65536>>10)+55296,($-65536&1023)+56320)}function wW8($,K,q){if(K==="__proto__")Object.defineProperty($,K,{configurable:!0,enumerable:!0,writable:!0,value:q});else $[K]=q}var XW8=new Array(256),TW8=new Array(256);for(Qq=0;Qq<256;Qq++)XW8[Qq]=KW8(Qq)?1:0,TW8[Qq]=KW8(Qq);var Qq;function xO6($,K){this.input=$,this.filename=K.filename||null,this.schema=K.schema||NO6,this.onWarning=K.onWarning||null,this.legacy=K.legacy||!1,this.json=K.json||!1,this.listener=K.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=$.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function jW8($,K){return new PW8(K,new MO6($.filename,$.input,$.position,$.line,$.position-$.lineStart))}function l8($,K){throw jW8($,K)}function Vf($,K){if($.onWarning)$.onWarning.call(null,jW8($,K))}var qW8={YAML:function $(K,q,Y){var z,P,J;if(K.version!==null)l8(K,"duplication of %YAML directive");if(Y.length!==1)l8(K,"YAML directive accepts exactly one argument");if(z=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]),z===null)l8(K,"ill-formed argument of the YAML directive");if(P=parseInt(z[1],10),J=parseInt(z[2],10),P!==1)l8(K,"unacceptable YAML version of the document");if(K.version=Y[0],K.checkLineBreaks=J<2,J!==1&&J!==2)Vf(K,"unsupported YAML version of the document")},TAG:function $(K,q,Y){var z,P;if(Y.length!==2)l8(K,"TAG directive accepts exactly two arguments");if(z=Y[0],P=Y[1],!ZW8.test(z))l8(K,"ill-formed tag handle (first argument) of the TAG directive");if(nq.call(K.tagMap,z))l8(K,'there is a previously declared suffix for "'+z+'" tag handle');if(!OW8.test(P))l8(K,"ill-formed tag prefix (second argument) of the TAG directive");K.tagMap[z]=P}};function dq($,K,q,Y){var z,P,J,W;if(K<q){if(W=$.input.slice(K,q),Y){for(z=0,P=W.length;z<P;z+=1)if(J=W.charCodeAt(z),!(J===9||32<=J&&J<=1114111))l8($,"expected valid JSON character")}else if(CO6.test(W))l8($,"the stream contains non-printable characters");$.result+=W}}function YW8($,K,q,Y){var z,P,J,W;if(!ZK.isObject(q))l8($,"cannot merge mappings; the provided source object is unacceptable");z=Object.keys(q);for(J=0,W=z.length;J<W;J+=1)if(P=z[J],!nq.call(K,P))wW8(K,P,q[P]),Y[P]=!0}function OW($,K,q,Y,z,P,J,W){var H,Z;if(Array.isArray(z)){z=Array.prototype.slice.call(z);for(H=0,Z=z.length;H<Z;H+=1){if(Array.isArray(z[H]))l8($,"nested arrays are not supported inside keys");if(typeof z==="object"&&$W8(z[H])==="[object Object]")z[H]="[object Object]"}}if(typeof z==="object"&&$W8(z)==="[object Object]")z="[object Object]";if(z=String(z),K===null)K={};if(Y==="tag:yaml.org,2002:merge")if(Array.isArray(P))for(H=0,Z=P.length;H<Z;H+=1)YW8($,K,P[H],q);else YW8($,K,P,q);else{if(!$.json&&!nq.call(q,z)&&nq.call(K,z))$.line=J||$.line,$.position=W||$.position,l8($,"duplicated mapping key");wW8(K,z,P),delete q[z]}return K}function Vx($){var K=$.input.charCodeAt($.position);if(K===10)$.position++;else if(K===13){if($.position++,$.input.charCodeAt($.position)===10)$.position++}else l8($,"a line break is expected");$.line+=1,$.lineStart=$.position}function _4($,K,q){var Y=0,z=$.input.charCodeAt($.position);while(z!==0){while(lz(z))z=$.input.charCodeAt(++$.position);if(K&&z===35)do z=$.input.charCodeAt(++$.position);while(z!==10&&z!==13&&z!==0);if(Y5(z)){Vx($),z=$.input.charCodeAt($.position),Y++,$.lineIndent=0;while(z===32)$.lineIndent++,z=$.input.charCodeAt(++$.position)}else break}if(q!==-1&&Y!==0&&$.lineIndent<q)Vf($,"deficient indentation");return Y}function kf($){var K=$.position,q;if(q=$.input.charCodeAt(K),(q===45||q===46)&&q===$.input.charCodeAt(K+1)&&q===$.input.charCodeAt(K+2)){if(K+=3,q=$.input.charCodeAt(K),q===0||k$(q))return!0}return!1}function kx($,K){if(K===1)$.result+=" ";else if(K>1)$.result+=ZK.repeat(`
|
|
346
|
+
`,K-1)}function bO6($,K,q){var Y,z,P,J,W,H,Z,O,w=$.kind,X=$.result,T;if(T=$.input.charCodeAt($.position),k$(T)||ZW(T)||T===35||T===38||T===42||T===33||T===124||T===62||T===39||T===34||T===37||T===64||T===96)return!1;if(T===63||T===45){if(z=$.input.charCodeAt($.position+1),k$(z)||q&&ZW(z))return!1}$.kind="scalar",$.result="",P=J=$.position,W=!1;while(T!==0){if(T===58){if(z=$.input.charCodeAt($.position+1),k$(z)||q&&ZW(z))break}else if(T===35){if(Y=$.input.charCodeAt($.position-1),k$(Y))break}else if($.position===$.lineStart&&kf($)||q&&ZW(T))break;else if(Y5(T))if(H=$.line,Z=$.lineStart,O=$.lineIndent,_4($,!1,-1),$.lineIndent>=K){W=!0,T=$.input.charCodeAt($.position);continue}else{$.position=J,$.line=H,$.lineStart=Z,$.lineIndent=O;break}if(W)dq($,P,J,!1),kx($,$.line-H),P=J=$.position,W=!1;if(!lz(T))J=$.position+1;T=$.input.charCodeAt(++$.position)}if(dq($,P,J,!1),$.result)return!0;return $.kind=w,$.result=X,!1}function gO6($,K){var q,Y,z;if(q=$.input.charCodeAt($.position),q!==39)return!1;$.kind="scalar",$.result="",$.position++,Y=z=$.position;while((q=$.input.charCodeAt($.position))!==0)if(q===39)if(dq($,Y,$.position,!0),q=$.input.charCodeAt(++$.position),q===39)Y=$.position,$.position++,z=$.position;else return!0;else if(Y5(q))dq($,Y,z,!0),kx($,_4($,!1,K)),Y=z=$.position;else if($.position===$.lineStart&&kf($))l8($,"unexpected end of the document within a single quoted scalar");else $.position++,z=$.position;l8($,"unexpected end of the stream within a single quoted scalar")}function yO6($,K){var q,Y,z,P,J,W;if(W=$.input.charCodeAt($.position),W!==34)return!1;$.kind="scalar",$.result="",$.position++,q=Y=$.position;while((W=$.input.charCodeAt($.position))!==0)if(W===34)return dq($,q,$.position,!0),$.position++,!0;else if(W===92){if(dq($,q,$.position,!0),W=$.input.charCodeAt(++$.position),Y5(W))_4($,!1,K);else if(W<256&&XW8[W])$.result+=TW8[W],$.position++;else if((J=EO6(W))>0){z=J,P=0;for(;z>0;z--)if(W=$.input.charCodeAt(++$.position),(J=SO6(W))>=0)P=(P<<4)+J;else l8($,"expected hexadecimal character");$.result+=IO6(P),$.position++}else l8($,"unknown escape sequence");q=Y=$.position}else if(Y5(W))dq($,q,Y,!0),kx($,_4($,!1,K)),q=Y=$.position;else if($.position===$.lineStart&&kf($))l8($,"unexpected end of the document within a double quoted scalar");else $.position++,Y=$.position;l8($,"unexpected end of the stream within a double quoted scalar")}function uO6($,K){var q=!0,Y,z=$.tag,P,J=$.anchor,W,H,Z,O,w,X={},T,G,v,f;if(f=$.input.charCodeAt($.position),f===91)H=93,w=!1,P=[];else if(f===123)H=125,w=!0,P={};else return!1;if($.anchor!==null)$.anchorMap[$.anchor]=P;f=$.input.charCodeAt(++$.position);while(f!==0){if(_4($,!0,K),f=$.input.charCodeAt($.position),f===H)return $.position++,$.tag=z,$.anchor=J,$.kind=w?"mapping":"sequence",$.result=P,!0;else if(!q)l8($,"missed comma between flow collection entries");if(G=T=v=null,Z=O=!1,f===63){if(W=$.input.charCodeAt($.position+1),k$(W))Z=O=!0,$.position++,_4($,!0,K)}if(Y=$.line,wW($,K,ff,!1,!0),G=$.tag,T=$.result,_4($,!0,K),f=$.input.charCodeAt($.position),(O||$.line===Y)&&f===58)Z=!0,f=$.input.charCodeAt(++$.position),_4($,!0,K),wW($,K,ff,!1,!0),v=$.result;if(w)OW($,P,X,G,T,v);else if(Z)P.push(OW($,null,X,G,T,v));else P.push(T);if(_4($,!0,K),f=$.input.charCodeAt($.position),f===44)q=!0,f=$.input.charCodeAt(++$.position);else q=!1}l8($,"unexpected end of the stream within a flow collection")}function mO6($,K){var q,Y,z=Ax,P=!1,J=!1,W=K,H=0,Z=!1,O,w;if(w=$.input.charCodeAt($.position),w===124)Y=!1;else if(w===62)Y=!0;else return!1;$.kind="scalar",$.result="";while(w!==0)if(w=$.input.charCodeAt(++$.position),w===43||w===45)if(Ax===z)z=w===43?eJ8:hO6;else l8($,"repeat of a chomping mode identifier");else if((O=LO6(w))>=0)if(O===0)l8($,"bad explicit indentation width of a block scalar; it cannot be less than one");else if(!J)W=K+O-1,J=!0;else l8($,"repeat of an indentation width identifier");else break;if(lz(w)){do w=$.input.charCodeAt(++$.position);while(lz(w));if(w===35)do w=$.input.charCodeAt(++$.position);while(!Y5(w)&&w!==0)}while(w!==0){Vx($),$.lineIndent=0,w=$.input.charCodeAt($.position);while((!J||$.lineIndent<W)&&w===32)$.lineIndent++,w=$.input.charCodeAt(++$.position);if(!J&&$.lineIndent>W)W=$.lineIndent;if(Y5(w)){H++;continue}if($.lineIndent<W){if(z===eJ8)$.result+=ZK.repeat(`
|
|
347
347
|
`,P?1+H:H);else if(z===Ax){if(P)$.result+=`
|
|
348
348
|
`}break}if(Y)if(lz(w))Z=!0,$.result+=ZK.repeat(`
|
|
349
349
|
`,P?1+H:H);else if(Z)Z=!1,$.result+=ZK.repeat(`
|
|
350
350
|
`,H+1);else if(H===0){if(P)$.result+=" "}else $.result+=ZK.repeat(`
|
|
351
351
|
`,H);else $.result+=ZK.repeat(`
|
|
352
|
-
`,P?1+H:H);P=!0,J=!0,H=0,q=$.position;while(!Y5(w)&&w!==0)w=$.input.charCodeAt(++$.position);dq($,q,$.position,!1)}return!0}function zW8($,K){var q,Y=$.tag,z=$.anchor,P=[],J,W=!1,H;if($.anchor!==null)$.anchorMap[$.anchor]=P;H=$.input.charCodeAt($.position);while(H!==0){if(H!==45)break;if(J=$.input.charCodeAt($.position+1),!k$(J))break;if(W=!0,$.position++,
|
|
352
|
+
`,P?1+H:H);P=!0,J=!0,H=0,q=$.position;while(!Y5(w)&&w!==0)w=$.input.charCodeAt(++$.position);dq($,q,$.position,!1)}return!0}function zW8($,K){var q,Y=$.tag,z=$.anchor,P=[],J,W=!1,H;if($.anchor!==null)$.anchorMap[$.anchor]=P;H=$.input.charCodeAt($.position);while(H!==0){if(H!==45)break;if(J=$.input.charCodeAt($.position+1),!k$(J))break;if(W=!0,$.position++,_4($,!0,-1)){if($.lineIndent<=K){P.push(null),H=$.input.charCodeAt($.position);continue}}if(q=$.line,wW($,K,HW8,!1,!0),P.push($.result),_4($,!0,-1),H=$.input.charCodeAt($.position),($.line===q||$.lineIndent>K)&&H!==0)l8($,"bad indentation of a sequence entry");else if($.lineIndent<K)break}if(W)return $.tag=Y,$.anchor=z,$.kind="sequence",$.result=P,!0;return!1}function pO6($,K,q){var Y,z,P,J,W=$.tag,H=$.anchor,Z={},O={},w=null,X=null,T=null,G=!1,v=!1,f;if($.anchor!==null)$.anchorMap[$.anchor]=Z;f=$.input.charCodeAt($.position);while(f!==0){if(Y=$.input.charCodeAt($.position+1),P=$.line,J=$.position,(f===63||f===58)&&k$(Y)){if(f===63){if(G)OW($,Z,O,w,X,null),w=X=T=null;v=!0,G=!0,z=!0}else if(G)G=!1,z=!0;else l8($,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");$.position+=1,f=Y}else if(wW($,q,WW8,!1,!0))if($.line===P){f=$.input.charCodeAt($.position);while(lz(f))f=$.input.charCodeAt(++$.position);if(f===58){if(f=$.input.charCodeAt(++$.position),!k$(f))l8($,"a whitespace character is expected after the key-value separator within a block mapping");if(G)OW($,Z,O,w,X,null),w=X=T=null;v=!0,G=!1,z=!1,w=$.tag,X=$.result}else if(v)l8($,"can not read an implicit mapping pair; a colon is missed");else return $.tag=W,$.anchor=H,!0}else if(v)l8($,"can not read a block mapping entry; a multiline key may not be an implicit key");else return $.tag=W,$.anchor=H,!0;else break;if($.line===P||$.lineIndent>K){if(wW($,K,Af,!0,z))if(G)X=$.result;else T=$.result;if(!G)OW($,Z,O,w,X,T,P,J),w=X=T=null;_4($,!0,-1),f=$.input.charCodeAt($.position)}if($.lineIndent>K&&f!==0)l8($,"bad indentation of a mapping entry");else if($.lineIndent<K)break}if(G)OW($,Z,O,w,X,null);if(v)$.tag=W,$.anchor=H,$.kind="mapping",$.result=Z;return v}function cO6($){var K,q=!1,Y=!1,z,P,J;if(J=$.input.charCodeAt($.position),J!==33)return!1;if($.tag!==null)l8($,"duplication of a tag property");if(J=$.input.charCodeAt(++$.position),J===60)q=!0,J=$.input.charCodeAt(++$.position);else if(J===33)Y=!0,z="!!",J=$.input.charCodeAt(++$.position);else z="!";if(K=$.position,q){do J=$.input.charCodeAt(++$.position);while(J!==0&&J!==62);if($.position<$.length)P=$.input.slice(K,$.position),J=$.input.charCodeAt(++$.position);else l8($,"unexpected end of the stream within a verbatim tag")}else{while(J!==0&&!k$(J)){if(J===33)if(!Y){if(z=$.input.slice(K-1,$.position+1),!ZW8.test(z))l8($,"named tag handle cannot contain such characters");Y=!0,K=$.position+1}else l8($,"tag suffix cannot contain exclamation marks");J=$.input.charCodeAt(++$.position)}if(P=$.input.slice(K,$.position),DO6.test(P))l8($,"tag suffix cannot contain flow indicator characters")}if(P&&!OW8.test(P))l8($,"tag name cannot contain such characters: "+P);if(q)$.tag=P;else if(nq.call($.tagMap,z))$.tag=$.tagMap[z]+P;else if(z==="!")$.tag="!"+P;else if(z==="!!")$.tag="tag:yaml.org,2002:"+P;else l8($,'undeclared tag handle "'+z+'"');return!0}function BO6($){var K,q;if(q=$.input.charCodeAt($.position),q!==38)return!1;if($.anchor!==null)l8($,"duplication of an anchor property");q=$.input.charCodeAt(++$.position),K=$.position;while(q!==0&&!k$(q)&&!ZW(q))q=$.input.charCodeAt(++$.position);if($.position===K)l8($,"name of an anchor node must contain at least one character");return $.anchor=$.input.slice(K,$.position),!0}function UO6($){var K,q,Y;if(Y=$.input.charCodeAt($.position),Y!==42)return!1;Y=$.input.charCodeAt(++$.position),K=$.position;while(Y!==0&&!k$(Y)&&!ZW(Y))Y=$.input.charCodeAt(++$.position);if($.position===K)l8($,"name of an alias node must contain at least one character");if(q=$.input.slice(K,$.position),!nq.call($.anchorMap,q))l8($,'unidentified alias "'+q+'"');return $.result=$.anchorMap[q],_4($,!0,-1),!0}function wW($,K,q,Y,z){var P,J,W,H=1,Z=!1,O=!1,w,X,T,G,v;if($.listener!==null)$.listener("open",$);if($.tag=null,$.anchor=null,$.kind=null,$.result=null,P=J=W=Af===q||HW8===q,Y){if(_4($,!0,-1)){if(Z=!0,$.lineIndent>K)H=1;else if($.lineIndent===K)H=0;else if($.lineIndent<K)H=-1}}if(H===1)while(cO6($)||BO6($))if(_4($,!0,-1)){if(Z=!0,W=P,$.lineIndent>K)H=1;else if($.lineIndent===K)H=0;else if($.lineIndent<K)H=-1}else W=!1;if(W)W=Z||z;if(H===1||Af===q){if(ff===q||WW8===q)G=K;else G=K+1;if(v=$.position-$.lineStart,H===1)if(W&&(zW8($,v)||pO6($,v,G))||uO6($,G))O=!0;else{if(J&&mO6($,G)||gO6($,G)||yO6($,G))O=!0;else if(UO6($)){if(O=!0,$.tag!==null||$.anchor!==null)l8($,"alias node should not have any properties")}else if(bO6($,G,ff===q)){if(O=!0,$.tag===null)$.tag="?"}if($.anchor!==null)$.anchorMap[$.anchor]=$.result}else if(H===0)O=W&&zW8($,v)}if($.tag!==null&&$.tag!=="!")if($.tag==="?"){if($.result!==null&&$.kind!=="scalar")l8($,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+$.kind+'"');for(w=0,X=$.implicitTypes.length;w<X;w+=1)if(T=$.implicitTypes[w],T.resolve($.result)){if($.result=T.construct($.result),$.tag=T.tag,$.anchor!==null)$.anchorMap[$.anchor]=$.result;break}}else if(nq.call($.typeMap[$.kind||"fallback"],$.tag)){if(T=$.typeMap[$.kind||"fallback"][$.tag],$.result!==null&&T.kind!==$.kind)l8($,"unacceptable node kind for !<"+$.tag+'> tag; it should be "'+T.kind+'", not "'+$.kind+'"');if(!T.resolve($.result))l8($,"cannot resolve a node with !<"+$.tag+"> explicit tag");else if($.result=T.construct($.result),$.anchor!==null)$.anchorMap[$.anchor]=$.result}else l8($,"unknown tag !<"+$.tag+">");if($.listener!==null)$.listener("close",$);return $.tag!==null||$.anchor!==null||O}function lO6($){var K=$.position,q,Y,z,P=!1,J;$.version=null,$.checkLineBreaks=$.legacy,$.tagMap={},$.anchorMap={};while((J=$.input.charCodeAt($.position))!==0){if(_4($,!0,-1),J=$.input.charCodeAt($.position),$.lineIndent>0||J!==37)break;P=!0,J=$.input.charCodeAt(++$.position),q=$.position;while(J!==0&&!k$(J))J=$.input.charCodeAt(++$.position);if(Y=$.input.slice(q,$.position),z=[],Y.length<1)l8($,"directive name must not be less than one character in length");while(J!==0){while(lz(J))J=$.input.charCodeAt(++$.position);if(J===35){do J=$.input.charCodeAt(++$.position);while(J!==0&&!Y5(J));break}if(Y5(J))break;q=$.position;while(J!==0&&!k$(J))J=$.input.charCodeAt(++$.position);z.push($.input.slice(q,$.position))}if(J!==0)Vx($);if(nq.call(qW8,Y))qW8[Y]($,Y,z);else Vf($,'unknown document directive "'+Y+'"')}if(_4($,!0,-1),$.lineIndent===0&&$.input.charCodeAt($.position)===45&&$.input.charCodeAt($.position+1)===45&&$.input.charCodeAt($.position+2)===45)$.position+=3,_4($,!0,-1);else if(P)l8($,"directives end mark is expected");if(wW($,$.lineIndent-1,Af,!1,!0),_4($,!0,-1),$.checkLineBreaks&&RO6.test($.input.slice(K,$.position)))Vf($,"non-ASCII line breaks are interpreted as content");if($.documents.push($.result),$.position===$.lineStart&&kf($)){if($.input.charCodeAt($.position)===46)$.position+=3,_4($,!0,-1);return}if($.position<$.length-1)l8($,"end of the stream or a document separator is expected");else return}function vW8($,K){if($=String($),K=K||{},$.length!==0){if($.charCodeAt($.length-1)!==10&&$.charCodeAt($.length-1)!==13)$+=`
|
|
353
353
|
`;if($.charCodeAt(0)===65279)$=$.slice(1)}var q=new xO6($,K),Y=$.indexOf("\x00");if(Y!==-1)q.position=Y,l8(q,"null byte is not allowed in input");q.input+="\x00";while(q.input.charCodeAt(q.position)===32)q.lineIndent+=1,q.position+=1;while(q.position<q.length-1)lO6(q);return q.documents}function GW8($,K,q){if(K!==null&&typeof K==="object"&&typeof q==="undefined")q=K,K=null;var Y=vW8($,q);if(typeof K!=="function")return Y;for(var z=0,P=Y.length;z<P;z+=1)K(Y[z])}function _W8($,K){var q=vW8($,K);if(q.length===0)return;else if(q.length===1)return q[0];throw new PW8("expected a single document in the stream, but found more")}function FO6($,K,q){if(typeof K==="object"&&K!==null&&typeof q==="undefined")q=K,K=null;return GW8($,K,ZK.extend({schema:JW8},q))}function iO6($,K){return _W8($,ZK.extend({schema:JW8},K))}QO6.loadAll=GW8;QO6.load=_W8;QO6.safeLoadAll=FO6;QO6.safeLoad=iO6});var UW8=j((Lw6,Cx)=>{var CX=cz(),RX=JW(),rO6=MX(),sO6=HW(),RW8=Object.prototype.toString,DW8=Object.prototype.hasOwnProperty,tO6=9,hX=10,eO6=13,$w6=32,Kw6=33,qw6=34,SW8=35,Yw6=37,zw6=38,Pw6=39,Jw6=42,EW8=44,Ww6=45,LW8=58,Hw6=61,Zw6=62,Ow6=63,ww6=64,IW8=91,xW8=93,Xw6=96,bW8=123,Tw6=124,gW8=125,A3={};A3[0]="\\0";A3[7]="\\a";A3[8]="\\b";A3[9]="\\t";A3[10]="\\n";A3[11]="\\v";A3[12]="\\f";A3[13]="\\r";A3[27]="\\e";A3[34]="\\\"";A3[92]="\\\\";A3[133]="\\N";A3[160]="\\_";A3[8232]="\\L";A3[8233]="\\P";var jw6=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function vw6($,K){var q,Y,z,P,J,W,H;if(K===null)return{};q={},Y=Object.keys(K);for(z=0,P=Y.length;z<P;z+=1){if(J=Y[z],W=String(K[J]),J.slice(0,2)==="!!")J="tag:yaml.org,2002:"+J.slice(2);if(H=$.compiledTypeMap.fallback[J],H&&DW8.call(H.styleAliases,W))W=H.styleAliases[W];q[J]=W}return q}function AW8($){var K,q,Y;if(K=$.toString(16).toUpperCase(),$<=255)q="x",Y=2;else if($<=65535)q="u",Y=4;else if($<=4294967295)q="U",Y=8;else throw new RX("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+q+CX.repeat("0",Y-K.length)+K}function Gw6($){this.schema=$.schema||rO6,this.indent=Math.max(1,$.indent||2),this.noArrayIndent=$.noArrayIndent||!1,this.skipInvalid=$.skipInvalid||!1,this.flowLevel=CX.isNothing($.flowLevel)?-1:$.flowLevel,this.styleMap=vw6(this.schema,$.styles||null),this.sortKeys=$.sortKeys||!1,this.lineWidth=$.lineWidth||80,this.noRefs=$.noRefs||!1,this.noCompatMode=$.noCompatMode||!1,this.condenseFlow=$.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function VW8($,K){var q=CX.repeat(" ",K),Y=0,z=-1,P="",J,W=$.length;while(Y<W){if(z=$.indexOf(`
|
|
354
354
|
`,Y),z===-1)J=$.slice(Y),Y=W;else J=$.slice(Y,z+1),Y=z+1;if(J.length&&J!==`
|
|
355
355
|
`)P+=q;P+=J}return P}function Mx($,K){return`
|
|
@@ -384,7 +384,7 @@ See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-contr
|
|
|
384
384
|
`+this.lexer.showPosition()+`
|
|
385
385
|
Expecting `+X8.join(", ")+", got '"+(this.terminals_[M]||M)+"'";else N8="Parse error on line "+(w+1)+": Unexpected "+(M==1?"end of input":"'"+(this.terminals_[M]||M)+"'");this.parseError(N8,{text:this.lexer.match,token:this.terminals_[M]||M,line:this.lexer.yylineno,loc:f,expected:X8})}}if(D[0]instanceof Array&&D.length>1)throw new Error("Parse Error: multiple actions possible at state: "+I+", token: "+M);switch(D[0]){case 1:if(J.push(M),W.push(this.lexer.yytext),H.push(this.lexer.yylloc),J.push(D[1]),M=null,!R){if(X=this.lexer.yyleng,O=this.lexer.yytext,w=this.lexer.yylineno,f=this.lexer.yylloc,T>0)T--}else M=R,R=null;break;case 2:if(B=this.productions_[D[1]][1],h.$=W[W.length-B],h._$={first_line:H[H.length-(B||1)].first_line,last_line:H[H.length-1].last_line,first_column:H[H.length-(B||1)].first_column,last_column:H[H.length-1].last_column},A)h._$.range=[H[H.length-(B||1)].range[0],H[H.length-1].range[1]];if(b=this.performAction.call(h,O,X,w,this.yy,D[1],W,H),typeof b!=="undefined")return b;if(B)J=J.slice(0,-1*B*2),W=W.slice(0,-1*B),H=H.slice(0,-1*B);J.push(this.productions_[D[1]][0]),W.push(h.$),H.push(h._$),i=Z[J[J.length-2]][J[J.length-1]],J.push(i);break;case 3:return!0}}return!0}},K=function(){var Y={EOF:1,parseError:function z(P,J){if(this.yy.parser)this.yy.parser.parseError(P,J);else throw new Error(P)},setInput:function z(P){if(this._input=P,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges)this.yylloc.range=[0,0];return this.offset=0,this},input:function z(){var P=this._input[0];this.yytext+=P,this.yyleng++,this.offset++,this.match+=P,this.matched+=P;var J=P.match(/(?:\r\n?|\n).*/g);if(J)this.yylineno++,this.yylloc.last_line++;else this.yylloc.last_column++;if(this.options.ranges)this.yylloc.range[1]++;return this._input=this._input.slice(1),P},unput:function z(P){var J=P.length,W=P.split(/(?:\r\n?|\n)/g);this._input=P+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-J-1),this.offset-=J;var H=this.match.split(/(?:\r\n?|\n)/g);if(this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),W.length-1)this.yylineno-=W.length-1;var Z=this.yylloc.range;if(this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:W?(W.length===H.length?this.yylloc.first_column:0)+H[H.length-W.length].length-W[0].length:this.yylloc.first_column-J},this.options.ranges)this.yylloc.range=[Z[0],Z[0]+this.yyleng-J];return this},more:function z(){return this._more=!0,this},less:function z(P){this.unput(this.match.slice(P))},pastInput:function z(){var P=this.matched.substr(0,this.matched.length-this.match.length);return(P.length>20?"...":"")+P.substr(-20).replace(/\n/g,"")},upcomingInput:function z(){var P=this.match;if(P.length<20)P+=this._input.substr(0,20-P.length);return(P.substr(0,20)+(P.length>20?"...":"")).replace(/\n/g,"")},showPosition:function z(){var P=this.pastInput(),J=new Array(P.length+1).join("-");return P+this.upcomingInput()+`
|
|
386
386
|
`+J+"^"},next:function z(){if(this.done)return this.EOF;if(!this._input)this.done=!0;var P,J,W,H,Z,O;if(!this._more)this.yytext="",this.match="";var w=this._currentRules();for(var X=0;X<w.length;X++)if(W=this._input.match(this.rules[w[X]]),W&&(!J||W[0].length>J[0].length)){if(J=W,H=X,!this.options.flex)break}if(J){if(O=J[0].match(/(?:\r\n?|\n).*/g),O)this.yylineno+=O.length;if(this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:O?O[O.length-1].length-O[O.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+J[0].length},this.yytext+=J[0],this.match+=J[0],this.matches=J,this.yyleng=this.yytext.length,this.options.ranges)this.yylloc.range=[this.offset,this.offset+=this.yyleng];if(this._more=!1,this._input=this._input.slice(J[0].length),this.matched+=J[0],P=this.performAction.call(this,this.yy,this,w[H],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input)this.done=!1;if(P)return P;else return}if(this._input==="")return this.EOF;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
387
|
-
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function z(){var P=this.next();if(typeof P!=="undefined")return P;else return this.lex()},begin:function z(P){this.conditionStack.push(P)},popState:function z(){return this.conditionStack.pop()},_currentRules:function z(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function z(){return this.conditionStack[this.conditionStack.length-2]},pushState:function z(P){this.begin(P)}};return Y.options={},Y.performAction=function z(P,J,W,H){function Z(w,X){return J.yytext=J.yytext.substring(w,J.yyleng-X+w)}var O=H;switch(W){case 0:if(J.yytext.slice(-2)==="\\\\")Z(0,1),this.begin("mu");else if(J.yytext.slice(-1)==="\\")Z(0,1),this.begin("emu");else this.begin("mu");if(J.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;break;case 3:return this.begin("raw"),15;break;case 4:if(this.popState(),this.conditionStack[this.conditionStack.length-1]==="raw")return 15;else return Z(5,9),"END_RAW_BLOCK";break;case 5:return 15;case 6:return this.popState(),14;break;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;break;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:return this.popState(),44;break;case 16:return this.popState(),44;break;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(J.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;break;case 23:return 48;case 24:return 73;case 25:return 72;case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;break;case 30:return this.popState(),33;break;case 31:return J.yytext=Z(1,2).replace(/\\"/g,'"'),80;break;case 32:return J.yytext=Z(1,2).replace(/\\'/g,"'"),80;break;case 33:return 85;case 34:return 82;case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return J.yytext=J.yytext.replace(/\\([\\\]])/g,"$1"),72;break;case 43:return"INVALID";case 44:return 5}},Y.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],Y.conditions={mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}},Y}();$.lexer=K;function q(){this.yy={}}return q.prototype=$,$.Parser=q,new q}();jZ8.default=hv6;vZ8.exports=jZ8.default});var bf=j((AZ8,VZ8)=>{AZ8.__esModule=!0;function Dv6($){return $&&$.__esModule?$:{default:$}}var Sv6=T7(),rx=Dv6(Sv6);function If(){this.parents=[]}If.prototype={constructor:If,mutating:!1,acceptKey:function $(K,q){var Y=this.accept(K[q]);if(this.mutating){if(Y&&!If.prototype[Y.type])throw new rx.default('Unexpected node type "'+Y.type+'" found when accepting '+q+" on "+K.type);K[q]=Y}},acceptRequired:function $(K,q){if(this.acceptKey(K,q),!K[q])throw new rx.default(K.type+" requires "+q)},acceptArray:function $(K){for(var q=0,Y=K.length;q<Y;q++)if(this.acceptKey(K,q),!K[q])K.splice(q,1),q--,Y--},accept:function $(K){if(!K)return;if(!this[K.type])throw new rx.default("Unknown type: "+K.type,K);if(this.current)this.parents.unshift(this.current);this.current=K;var q=this[K.type](K);if(this.current=this.parents.shift(),!this.mutating||q)return q;else if(q!==!1)return K},Program:function $(K){this.acceptArray(K.body)},MustacheStatement:xf,Decorator:xf,BlockStatement:_Z8,DecoratorBlock:_Z8,PartialStatement:fZ8,PartialBlockStatement:function $(K){fZ8.call(this,K),this.acceptKey(K,"program")},ContentStatement:function $(){},CommentStatement:function $(){},SubExpression:xf,PathExpression:function $(){},StringLiteral:function $(){},NumberLiteral:function $(){},BooleanLiteral:function $(){},UndefinedLiteral:function $(){},NullLiteral:function $(){},Hash:function $(K){this.acceptArray(K.pairs)},HashPair:function $(K){this.acceptRequired(K,"value")}};function xf($){this.acceptRequired($,"path"),this.acceptArray($.params),this.acceptKey($,"hash")}function _Z8($){xf.call(this,$),this.acceptKey($,"program"),this.acceptKey($,"inverse")}function fZ8($){this.acceptRequired($,"name"),this.acceptArray($.params),this.acceptKey($,"hash")}AZ8.default=If;VZ8.exports=AZ8.default});var NZ8=j((kZ8,MZ8)=>{kZ8.__esModule=!0;function Iv6($){return $&&$.__esModule?$:{default:$}}var xv6=bf(),bv6=Iv6(xv6);function z5(){var $=arguments.length<=0||arguments[0]===void 0?{}:arguments[0];this.options=$}z5.prototype=new bv6.default;z5.prototype.Program=function($){var K=!this.options.ignoreStandalone,q=!this.isRootSeen;this.isRootSeen=!0;var Y=$.body;for(var z=0,P=Y.length;z<P;z++){var J=Y[z],W=this.accept(J);if(!W)continue;var H=sx(Y,z,q),Z=tx(Y,z,q),O=W.openStandalone&&H,w=W.closeStandalone&&Z,X=W.inlineStandalone&&H&&Z;if(W.close)dz(Y,z,!0);if(W.open)oq(Y,z,!0);if(K&&X){if(dz(Y,z),oq(Y,z)){if(J.type==="PartialStatement")J.indent=/([ \t]+$)/.exec(Y[z-1].original)[1]}}if(K&&O)dz((J.program||J.inverse).body),oq(Y,z);if(K&&w)dz(Y,z),oq((J.inverse||J.program).body)}return $};z5.prototype.BlockStatement=z5.prototype.DecoratorBlock=z5.prototype.PartialBlockStatement=function($){this.accept($.program),this.accept($.inverse);var K=$.program||$.inverse,q=$.program&&$.inverse,Y=q,z=q;if(q&&q.chained){Y=q.body[0].program;while(z.chained)z=z.body[z.body.length-1].program}var P={open:$.openStrip.open,close:$.closeStrip.close,openStandalone:tx(K.body),closeStandalone:sx((Y||K).body)};if($.openStrip.close)dz(K.body,null,!0);if(q){var J=$.inverseStrip;if(J.open)oq(K.body,null,!0);if(J.close)dz(Y.body,null,!0);if($.closeStrip.open)oq(z.body,null,!0);if(!this.options.ignoreStandalone&&sx(K.body)&&tx(Y.body))oq(K.body),dz(Y.body)}else if($.closeStrip.open)oq(K.body,null,!0);return P};z5.prototype.Decorator=z5.prototype.MustacheStatement=function($){return $.strip};z5.prototype.PartialStatement=z5.prototype.CommentStatement=function($){var K=$.strip||{};return{inlineStandalone:!0,open:K.open,close:K.close}};function sx($,K,q){if(K===void 0)K=$.length;var Y=$[K-1],z=$[K-2];if(!Y)return q;if(Y.type==="ContentStatement")return(z||!q?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(Y.original)}function tx($,K,q){if(K===void 0)K=-1;var Y=$[K+1],z=$[K+2];if(!Y)return q;if(Y.type==="ContentStatement")return(z||!q?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(Y.original)}function dz($,K,q){var Y=$[K==null?0:K+1];if(!Y||Y.type!=="ContentStatement"||!q&&Y.rightStripped)return;var z=Y.value;Y.value=Y.value.replace(q?/^\s+/:/^[ \t]*\r?\n?/,""),Y.rightStripped=Y.value!==z}function oq($,K,q){var Y=$[K==null?$.length-1:K-1];if(!Y||Y.type!=="ContentStatement"||!q&&Y.leftStripped)return;var z=Y.value;return Y.value=Y.value.replace(q?/\s+$/:/[ \t]+$/,""),Y.leftStripped=Y.value!==z,Y.leftStripped}kZ8.default=z5;MZ8.exports=kZ8.default});var hZ8=j((ov6)=>{ov6.__esModule=!0;ov6.SourceLocation=pv6;ov6.id=cv6;ov6.stripFlags=Bv6;ov6.stripComment=Uv6;ov6.preparePath=lv6;ov6.prepareMustache=Fv6;ov6.prepareRawBlock=iv6;ov6.prepareBlock=Qv6;ov6.prepareProgram=dv6;ov6.preparePartialBlock=nv6;function uv6($){return $&&$.__esModule?$:{default:$}}var mv6=T7(),ex=uv6(mv6);function $b($,K){if(K=K.path?K.path.original:K,$.path.original!==K){var q={loc:$.path.loc};throw new ex.default($.path.original+" doesn't match "+K,q)}}function pv6($,K){this.source=$,this.start={line:K.first_line,column:K.first_column},this.end={line:K.last_line,column:K.last_column}}function cv6($){if(/^\[.*\]$/.test($))return $.substring(1,$.length-1);else return $}function Bv6($,K){return{open:$.charAt(2)==="~",close:K.charAt(K.length-3)==="~"}}function Uv6($){return $.replace(/^\{\{~?!-?-?/,"").replace(/-?-?~?\}\}$/,"")}function lv6($,K,q){q=this.locInfo(q);var Y=$?"@":"",z=[],P=0;for(var J=0,W=K.length;J<W;J++){var H=K[J].part,Z=K[J].original!==H;if(Y+=(K[J].separator||"")+H,!Z&&(H===".."||H==="."||H==="this")){if(z.length>0)throw new ex.default("Invalid path: "+Y,{loc:q});else if(H==="..")P++}else z.push(H)}return{type:"PathExpression",data:$,depth:P,parts:z,original:Y,loc:q}}function Fv6($,K,q,Y,z,P){var J=Y.charAt(3)||Y.charAt(2),W=J!=="{"&&J!=="&",H=/\*/.test(Y);return{type:H?"Decorator":"MustacheStatement",path:$,params:K,hash:q,escaped:W,strip:z,loc:this.locInfo(P)}}function iv6($,K,q,Y){$b($,q),Y=this.locInfo(Y);var z={type:"Program",body:K,strip:{},loc:Y};return{type:"BlockStatement",path:$.path,params:$.params,hash:$.hash,program:z,openStrip:{},inverseStrip:{},closeStrip:{},loc:Y}}function Qv6($,K,q,Y,z,P){if(Y&&Y.path)$b($,Y);var J=/\*/.test($.open);K.blockParams=$.blockParams;var W=void 0,H=void 0;if(q){if(J)throw new ex.default("Unexpected inverse block on decorator",q);if(q.chain)q.program.body[0].closeStrip=Y.strip;H=q.strip,W=q.program}if(z)z=W,W=K,K=z;return{type:J?"DecoratorBlock":"BlockStatement",path:$.path,params:$.params,hash:$.hash,program:K,inverse:W,openStrip:$.strip,inverseStrip:H,closeStrip:Y&&Y.strip,loc:this.locInfo(P)}}function dv6($,K){if(!K&&$.length){var q=$[0].loc,Y=$[$.length-1].loc;if(q&&Y)K={source:q.source,start:{line:q.start.line,column:q.start.column},end:{line:Y.end.line,column:Y.end.column}}}return{type:"Program",body:$,strip:{},loc:K}}function nv6($,K,q,Y){return $b($,q),{type:"PartialBlockStatement",name:$.path,params:$.params,hash:$.hash,program:K,openStrip:$.strip,closeStrip:q&&q.strip,loc:this.locInfo(Y)}}});var DZ8=j((jG6)=>{jG6.__esModule=!0;jG6.parseWithoutProcessing=RZ8;jG6.parse=TG6;function JG6($){if($&&$.__esModule)return $;else{var K={};if($!=null){for(var q in $)if(Object.prototype.hasOwnProperty.call($,q))K[q]=$[q]}return K.default=$,K}}function CZ8($){return $&&$.__esModule?$:{default:$}}var WG6=GZ8(),Kb=CZ8(WG6),HG6=NZ8(),ZG6=CZ8(HG6),OG6=hZ8(),wG6=JG6(OG6),XG6=o3();jG6.parser=Kb.default;var gf={};XG6.extend(gf,wG6);function RZ8($,K){if($.type==="Program")return $;Kb.default.yy=gf,gf.locInfo=function(Y){return new gf.SourceLocation(K&&K.srcName,Y)};var q=Kb.default.parse($);return q}function TG6($,K){var q=RZ8($,K),Y=new ZG6.default(K);return Y.accept(q)}});var IZ8=j((hG6)=>{hG6.__esModule=!0;hG6.Compiler=qb;hG6.precompile=MG6;hG6.compile=NG6;function EZ8($){return $&&$.__esModule?$:{default:$}}var AG6=T7(),xX=EZ8(AG6),bX=o3(),VG6=ax(),IX=EZ8(VG6),kG6=[].slice;function qb(){}qb.prototype={compiler:qb,equals:function $(K){var q=this.opcodes.length;if(K.opcodes.length!==q)return!1;for(var Y=0;Y<q;Y++){var z=this.opcodes[Y],P=K.opcodes[Y];if(z.opcode!==P.opcode||!LZ8(z.args,P.args))return!1}q=this.children.length;for(var Y=0;Y<q;Y++)if(!this.children[Y].equals(K.children[Y]))return!1;return!0},guid:0,compile:function $(K,q){return this.sourceNode=[],this.opcodes=[],this.children=[],this.options=q,this.stringParams=q.stringParams,this.trackIds=q.trackIds,q.blockParams=q.blockParams||[],q.knownHelpers=bX.extend(Object.create(null),{helperMissing:!0,blockHelperMissing:!0,each:!0,if:!0,unless:!0,with:!0,log:!0,lookup:!0},q.knownHelpers),this.accept(K)},compileProgram:function $(K){var q=new this.compiler,Y=q.compile(K,this.options),z=this.guid++;return this.usePartial=this.usePartial||Y.usePartial,this.children[z]=Y,this.useDepths=this.useDepths||Y.useDepths,z},accept:function $(K){if(!this[K.type])throw new xX.default("Unknown type: "+K.type,K);this.sourceNode.unshift(K);var q=this[K.type](K);return this.sourceNode.shift(),q},Program:function $(K){this.options.blockParams.unshift(K.blockParams);var q=K.body,Y=q.length;for(var z=0;z<Y;z++)this.accept(q[z]);return this.options.blockParams.shift(),this.isSimple=Y===1,this.blockParams=K.blockParams?K.blockParams.length:0,this},BlockStatement:function $(K){SZ8(K);var{program:q,inverse:Y}=K;q=q&&this.compileProgram(q),Y=Y&&this.compileProgram(Y);var z=this.classifySexpr(K);if(z==="helper")this.helperSexpr(K,q,Y);else if(z==="simple")this.simpleSexpr(K),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),this.opcode("emptyHash"),this.opcode("blockValue",K.path.original);else this.ambiguousSexpr(K,q,Y),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue");this.opcode("append")},DecoratorBlock:function $(K){var q=K.program&&this.compileProgram(K.program),Y=this.setupFullMustacheParams(K,q,void 0),z=K.path;this.useDecorators=!0,this.opcode("registerDecorator",Y.length,z.original)},PartialStatement:function $(K){this.usePartial=!0;var q=K.program;if(q)q=this.compileProgram(K.program);var Y=K.params;if(Y.length>1)throw new xX.default("Unsupported number of partial arguments: "+Y.length,K);else if(!Y.length)if(this.options.explicitPartialContext)this.opcode("pushLiteral","undefined");else Y.push({type:"PathExpression",parts:[],depth:0});var z=K.name.original,P=K.name.type==="SubExpression";if(P)this.accept(K.name);this.setupFullMustacheParams(K,q,void 0,!0);var J=K.indent||"";if(this.options.preventIndent&&J)this.opcode("appendContent",J),J="";this.opcode("invokePartial",P,z,J),this.opcode("append")},PartialBlockStatement:function $(K){this.PartialStatement(K)},MustacheStatement:function $(K){if(this.SubExpression(K),K.escaped&&!this.options.noEscape)this.opcode("appendEscaped");else this.opcode("append")},Decorator:function $(K){this.DecoratorBlock(K)},ContentStatement:function $(K){if(K.value)this.opcode("appendContent",K.value)},CommentStatement:function $(){},SubExpression:function $(K){SZ8(K);var q=this.classifySexpr(K);if(q==="simple")this.simpleSexpr(K);else if(q==="helper")this.helperSexpr(K);else this.ambiguousSexpr(K)},ambiguousSexpr:function $(K,q,Y){var z=K.path,P=z.parts[0],J=q!=null||Y!=null;this.opcode("getContext",z.depth),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),z.strict=!0,this.accept(z),this.opcode("invokeAmbiguous",P,J)},simpleSexpr:function $(K){var q=K.path;q.strict=!0,this.accept(q),this.opcode("resolvePossibleLambda")},helperSexpr:function $(K,q,Y){var z=this.setupFullMustacheParams(K,q,Y),P=K.path,J=P.parts[0];if(this.options.knownHelpers[J])this.opcode("invokeKnownHelper",z.length,J);else if(this.options.knownHelpersOnly)throw new xX.default("You specified knownHelpersOnly, but used the unknown helper "+J,K);else P.strict=!0,P.falsy=!0,this.accept(P),this.opcode("invokeHelper",z.length,P.original,IX.default.helpers.simpleId(P))},PathExpression:function $(K){this.addDepth(K.depth),this.opcode("getContext",K.depth);var q=K.parts[0],Y=IX.default.helpers.scopedId(K),z=!K.depth&&!Y&&this.blockParamIndex(q);if(z)this.opcode("lookupBlockParam",z,K.parts);else if(!q)this.opcode("pushContext");else if(K.data)this.options.data=!0,this.opcode("lookupData",K.depth,K.parts,K.strict);else this.opcode("lookupOnContext",K.parts,K.falsy,K.strict,Y)},StringLiteral:function $(K){this.opcode("pushString",K.value)},NumberLiteral:function $(K){this.opcode("pushLiteral",K.value)},BooleanLiteral:function $(K){this.opcode("pushLiteral",K.value)},UndefinedLiteral:function $(){this.opcode("pushLiteral","undefined")},NullLiteral:function $(){this.opcode("pushLiteral","null")},Hash:function $(K){var q=K.pairs,Y=0,z=q.length;this.opcode("pushHash");for(;Y<z;Y++)this.pushParam(q[Y].value);while(Y--)this.opcode("assignToHash",q[Y].key);this.opcode("popHash")},opcode:function $(K){this.opcodes.push({opcode:K,args:kG6.call(arguments,1),loc:this.sourceNode[0].loc})},addDepth:function $(K){if(!K)return;this.useDepths=!0},classifySexpr:function $(K){var q=IX.default.helpers.simpleId(K.path),Y=q&&!!this.blockParamIndex(K.path.parts[0]),z=!Y&&IX.default.helpers.helperExpression(K),P=!Y&&(z||q);if(P&&!z){var J=K.path.parts[0],W=this.options;if(W.knownHelpers[J])z=!0;else if(W.knownHelpersOnly)P=!1}if(z)return"helper";else if(P)return"ambiguous";else return"simple"},pushParams:function $(K){for(var q=0,Y=K.length;q<Y;q++)this.pushParam(K[q])},pushParam:function $(K){var q=K.value!=null?K.value:K.original||"";if(this.stringParams){if(q.replace)q=q.replace(/^(\.?\.\/)*/g,"").replace(/\//g,".");if(K.depth)this.addDepth(K.depth);if(this.opcode("getContext",K.depth||0),this.opcode("pushStringParam",q,K.type),K.type==="SubExpression")this.accept(K)}else{if(this.trackIds){var Y=void 0;if(K.parts&&!IX.default.helpers.scopedId(K)&&!K.depth)Y=this.blockParamIndex(K.parts[0]);if(Y){var z=K.parts.slice(1).join(".");this.opcode("pushId","BlockParam",Y,z)}else{if(q=K.original||q,q.replace)q=q.replace(/^this(?:\.|$)/,"").replace(/^\.\//,"").replace(/^\.$/,"");this.opcode("pushId",K.type,q)}}this.accept(K)}},setupFullMustacheParams:function $(K,q,Y,z){var P=K.params;if(this.pushParams(P),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),K.hash)this.accept(K.hash);else this.opcode("emptyHash",z);return P},blockParamIndex:function $(K){for(var q=0,Y=this.options.blockParams.length;q<Y;q++){var z=this.options.blockParams[q],P=z&&bX.indexOf(z,K);if(z&&P>=0)return[q,P]}}};function MG6($,K,q){if($==null||typeof $!=="string"&&$.type!=="Program")throw new xX.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+$);if(K=K||{},!("data"in K))K.data=!0;if(K.compat)K.useDepths=!0;var Y=q.parse($,K),z=new q.Compiler().compile(Y,K);return new q.JavaScriptCompiler().compile(z,K)}function NG6($,K,q){if(K===void 0)K={};if($==null||typeof $!=="string"&&$.type!=="Program")throw new xX.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+$);if(K=bX.extend({},K),!("data"in K))K.data=!0;if(K.compat)K.useDepths=!0;var Y=void 0;function z(){var J=q.parse($,K),W=new q.Compiler().compile(J,K),H=new q.JavaScriptCompiler().compile(W,K,void 0,!0);return q.template(H)}function P(J,W){if(!Y)Y=z();return Y.call(this,J,W)}return P._setup=function(J){if(!Y)Y=z();return Y._setup(J)},P._child=function(J,W,H,Z){if(!Y)Y=z();return Y._child(J,W,H,Z)},P}function LZ8($,K){if($===K)return!0;if(bX.isArray($)&&bX.isArray(K)&&$.length===K.length){for(var q=0;q<$.length;q++)if(!LZ8($[q],K[q]))return!1;return!0}}function SZ8($){if(!$.path.parts){var K=$.path;$.path={type:"PathExpression",data:!1,depth:0,parts:[K.original+""],original:K.original+"",loc:K.loc}}}});var bZ8=j((EG6)=>{var xZ8="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");EG6.encode=function($){if(0<=$&&$<xZ8.length)return xZ8[$];throw new TypeError("Must be between 0 and 63: "+$)};EG6.decode=function($){var K=65,q=90,Y=97,z=122,P=48,J=57,W=43,H=47,Z=26,O=52;if(K<=$&&$<=q)return $-K;if(Y<=$&&$<=z)return $-Y+Z;if(P<=$&&$<=J)return $-P+O;if($==W)return 62;if($==H)return 63;return-1}});var zb=j((gG6)=>{var gZ8=bZ8(),Yb=5,yZ8=1<<Yb,uZ8=yZ8-1,mZ8=yZ8;function xG6($){return $<0?(-$<<1)+1:($<<1)+0}function bG6($){var K=($&1)===1,q=$>>1;return K?-q:q}gG6.encode=function $(K){var q="",Y,z=xG6(K);do{if(Y=z&uZ8,z>>>=Yb,z>0)Y|=mZ8;q+=gZ8.encode(Y)}while(z>0);return q};gG6.decode=function $(K,q,Y){var z=K.length,P=0,J=0,W,H;do{if(q>=z)throw new Error("Expected more digits in base 64 VLQ value.");if(H=gZ8.decode(K.charCodeAt(q++)),H===-1)throw new Error("Invalid base64 digit: "+K.charAt(q-1));W=!!(H&mZ8),H&=uZ8,P=P+(H<<J),J+=Yb}while(W);Y.value=bG6(P),Y.rest=q}});var fW=j((nG6)=>{function mG6($,K,q){if(K in $)return $[K];else if(arguments.length===3)return q;else throw new Error('"'+K+'" is a required argument.')}nG6.getArg=mG6;var pZ8=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,pG6=/^data:.+\,.+$/;function gX($){var K=$.match(pZ8);if(!K)return null;return{scheme:K[1],auth:K[2],host:K[3],port:K[4],path:K[5]}}nG6.urlParse=gX;function GW($){var K="";if($.scheme)K+=$.scheme+":";if(K+="//",$.auth)K+=$.auth+"@";if($.host)K+=$.host;if($.port)K+=":"+$.port;if($.path)K+=$.path;return K}nG6.urlGenerate=GW;function Pb($){var K=$,q=gX($);if(q){if(!q.path)return $;K=q.path}var Y=nG6.isAbsolute(K),z=K.split(/\/+/);for(var P,J=0,W=z.length-1;W>=0;W--)if(P=z[W],P===".")z.splice(W,1);else if(P==="..")J++;else if(J>0)if(P==="")z.splice(W+1,J),J=0;else z.splice(W,2),J--;if(K=z.join("/"),K==="")K=Y?"/":".";if(q)return q.path=K,GW(q);return K}nG6.normalize=Pb;function cZ8($,K){if($==="")$=".";if(K==="")K=".";var q=gX(K),Y=gX($);if(Y)$=Y.path||"/";if(q&&!q.scheme){if(Y)q.scheme=Y.scheme;return GW(q)}if(q||K.match(pG6))return K;if(Y&&!Y.host&&!Y.path)return Y.host=K,GW(Y);var z=K.charAt(0)==="/"?K:Pb($.replace(/\/+$/,"")+"/"+K);if(Y)return Y.path=z,GW(Y);return z}nG6.join=cZ8;nG6.isAbsolute=function($){return $.charAt(0)==="/"||pZ8.test($)};function cG6($,K){if($==="")$=".";$=$.replace(/\/$/,"");var q=0;while(K.indexOf($+"/")!==0){var Y=$.lastIndexOf("/");if(Y<0)return K;if($=$.slice(0,Y),$.match(/^([^\/]+:\/)?\/*$/))return K;++q}return Array(q+1).join("../")+K.substr($.length+1)}nG6.relative=cG6;var BZ8=function(){var $=Object.create(null);return!("__proto__"in $)}();function UZ8($){return $}function BG6($){if(lZ8($))return"$"+$;return $}nG6.toSetString=BZ8?UZ8:BG6;function UG6($){if(lZ8($))return $.slice(1);return $}nG6.fromSetString=BZ8?UZ8:UG6;function lZ8($){if(!$)return!1;var K=$.length;if(K<9)return!1;if($.charCodeAt(K-1)!==95||$.charCodeAt(K-2)!==95||$.charCodeAt(K-3)!==111||$.charCodeAt(K-4)!==116||$.charCodeAt(K-5)!==111||$.charCodeAt(K-6)!==114||$.charCodeAt(K-7)!==112||$.charCodeAt(K-8)!==95||$.charCodeAt(K-9)!==95)return!1;for(var q=K-10;q>=0;q--)if($.charCodeAt(q)!==36)return!1;return!0}function lG6($,K,q){var Y=_W($.source,K.source);if(Y!==0)return Y;if(Y=$.originalLine-K.originalLine,Y!==0)return Y;if(Y=$.originalColumn-K.originalColumn,Y!==0||q)return Y;if(Y=$.generatedColumn-K.generatedColumn,Y!==0)return Y;if(Y=$.generatedLine-K.generatedLine,Y!==0)return Y;return _W($.name,K.name)}nG6.compareByOriginalPositions=lG6;function FG6($,K,q){var Y=$.generatedLine-K.generatedLine;if(Y!==0)return Y;if(Y=$.generatedColumn-K.generatedColumn,Y!==0||q)return Y;if(Y=_W($.source,K.source),Y!==0)return Y;if(Y=$.originalLine-K.originalLine,Y!==0)return Y;if(Y=$.originalColumn-K.originalColumn,Y!==0)return Y;return _W($.name,K.name)}nG6.compareByGeneratedPositionsDeflated=FG6;function _W($,K){if($===K)return 0;if($===null)return 1;if(K===null)return-1;if($>K)return 1;return-1}function iG6($,K){var q=$.generatedLine-K.generatedLine;if(q!==0)return q;if(q=$.generatedColumn-K.generatedColumn,q!==0)return q;if(q=_W($.source,K.source),q!==0)return q;if(q=$.originalLine-K.originalLine,q!==0)return q;if(q=$.originalColumn-K.originalColumn,q!==0)return q;return _W($.name,K.name)}nG6.compareByGeneratedPositionsInflated=iG6;function QG6($){return JSON.parse($.replace(/^\)]}'[^\n]*\n/,""))}nG6.parseSourceMapInput=QG6;function dG6($,K,q){if(K=K||"",$){if($[$.length-1]!=="/"&&K[0]!=="/")$+="/";K=$+K}if(q){var Y=gX(q);if(!Y)throw new Error("sourceMapURL could not be parsed");if(Y.path){var z=Y.path.lastIndexOf("/");if(z>=0)Y.path=Y.path.substring(0,z+1)}K=cZ8(GW(Y),K)}return Pb(K)}nG6.computeSourceURL=dG6});var Hb=j((H06)=>{var Jb=fW(),Wb=Object.prototype.hasOwnProperty,nz=typeof Map!=="undefined";function TK(){this._array=[],this._set=nz?new Map:Object.create(null)}TK.fromArray=function $(K,q){var Y=new TK;for(var z=0,P=K.length;z<P;z++)Y.add(K[z],q);return Y};TK.prototype.size=function $(){return nz?this._set.size:Object.getOwnPropertyNames(this._set).length};TK.prototype.add=function $(K,q){var Y=nz?K:Jb.toSetString(K),z=nz?this.has(K):Wb.call(this._set,Y),P=this._array.length;if(!z||q)this._array.push(K);if(!z)if(nz)this._set.set(K,P);else this._set[Y]=P};TK.prototype.has=function $(K){if(nz)return this._set.has(K);else{var q=Jb.toSetString(K);return Wb.call(this._set,q)}};TK.prototype.indexOf=function $(K){if(nz){var q=this._set.get(K);if(q>=0)return q}else{var Y=Jb.toSetString(K);if(Wb.call(this._set,Y))return this._set[Y]}throw new Error('"'+K+'" is not in the set.')};TK.prototype.at=function $(K){if(K>=0&&K<this._array.length)return this._array[K];throw new Error("No element indexed by "+K)};TK.prototype.toArray=function $(){return this._array.slice()};H06.ArraySet=TK});var iZ8=j((w06)=>{var FZ8=fW();function O06($,K){var q=$.generatedLine,Y=K.generatedLine,z=$.generatedColumn,P=K.generatedColumn;return Y>q||Y==q&&P>=z||FZ8.compareByGeneratedPositionsInflated($,K)<=0}function yf(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}yf.prototype.unsortedForEach=function $(K,q){this._array.forEach(K,q)};yf.prototype.add=function $(K){if(O06(this._last,K))this._last=K,this._array.push(K);else this._sorted=!1,this._array.push(K)};yf.prototype.toArray=function $(){if(!this._sorted)this._array.sort(FZ8.compareByGeneratedPositionsInflated),this._sorted=!0;return this._array};w06.MappingList=yf});var Zb=j((j06)=>{var yX=zb(),A4=fW(),uf=Hb().ArraySet,T06=iZ8().MappingList;function j7($){if(!$)$={};this._file=A4.getArg($,"file",null),this._sourceRoot=A4.getArg($,"sourceRoot",null),this._skipValidation=A4.getArg($,"skipValidation",!1),this._sources=new uf,this._names=new uf,this._mappings=new T06,this._sourcesContents=null}j7.prototype._version=3;j7.fromSourceMap=function $(K){var q=K.sourceRoot,Y=new j7({file:K.file,sourceRoot:q});return K.eachMapping(function(z){var P={generated:{line:z.generatedLine,column:z.generatedColumn}};if(z.source!=null){if(P.source=z.source,q!=null)P.source=A4.relative(q,P.source);if(P.original={line:z.originalLine,column:z.originalColumn},z.name!=null)P.name=z.name}Y.addMapping(P)}),K.sources.forEach(function(z){var P=z;if(q!==null)P=A4.relative(q,z);if(!Y._sources.has(P))Y._sources.add(P);var J=K.sourceContentFor(z);if(J!=null)Y.setSourceContent(z,J)}),Y};j7.prototype.addMapping=function $(K){var q=A4.getArg(K,"generated"),Y=A4.getArg(K,"original",null),z=A4.getArg(K,"source",null),P=A4.getArg(K,"name",null);if(!this._skipValidation)this._validateMapping(q,Y,z,P);if(z!=null){if(z=String(z),!this._sources.has(z))this._sources.add(z)}if(P!=null){if(P=String(P),!this._names.has(P))this._names.add(P)}this._mappings.add({generatedLine:q.line,generatedColumn:q.column,originalLine:Y!=null&&Y.line,originalColumn:Y!=null&&Y.column,source:z,name:P})};j7.prototype.setSourceContent=function $(K,q){var Y=K;if(this._sourceRoot!=null)Y=A4.relative(this._sourceRoot,Y);if(q!=null){if(!this._sourcesContents)this._sourcesContents=Object.create(null);this._sourcesContents[A4.toSetString(Y)]=q}else if(this._sourcesContents){if(delete this._sourcesContents[A4.toSetString(Y)],Object.keys(this._sourcesContents).length===0)this._sourcesContents=null}};j7.prototype.applySourceMap=function $(K,q,Y){var z=q;if(q==null){if(K.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);z=K.file}var P=this._sourceRoot;if(P!=null)z=A4.relative(P,z);var J=new uf,W=new uf;this._mappings.unsortedForEach(function(H){if(H.source===z&&H.originalLine!=null){var Z=K.originalPositionFor({line:H.originalLine,column:H.originalColumn});if(Z.source!=null){if(H.source=Z.source,Y!=null)H.source=A4.join(Y,H.source);if(P!=null)H.source=A4.relative(P,H.source);if(H.originalLine=Z.line,H.originalColumn=Z.column,Z.name!=null)H.name=Z.name}}var O=H.source;if(O!=null&&!J.has(O))J.add(O);var w=H.name;if(w!=null&&!W.has(w))W.add(w)},this),this._sources=J,this._names=W,K.sources.forEach(function(H){var Z=K.sourceContentFor(H);if(Z!=null){if(Y!=null)H=A4.join(Y,H);if(P!=null)H=A4.relative(P,H);this.setSourceContent(H,Z)}},this)};j7.prototype._validateMapping=function $(K,q,Y,z){if(q&&typeof q.line!=="number"&&typeof q.column!=="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(K&&"line"in K&&"column"in K&&K.line>0&&K.column>=0&&!q&&!Y&&!z)return;else if(K&&"line"in K&&"column"in K&&q&&"line"in q&&"column"in q&&K.line>0&&K.column>=0&&q.line>0&&q.column>=0&&Y)return;else throw new Error("Invalid mapping: "+JSON.stringify({generated:K,source:Y,original:q,name:z}))};j7.prototype._serializeMappings=function $(){var K=0,q=1,Y=0,z=0,P=0,J=0,W="",H,Z,O,w,X=this._mappings.toArray();for(var T=0,G=X.length;T<G;T++){if(Z=X[T],H="",Z.generatedLine!==q){K=0;while(Z.generatedLine!==q)H+=";",q++}else if(T>0){if(!A4.compareByGeneratedPositionsInflated(Z,X[T-1]))continue;H+=","}if(H+=yX.encode(Z.generatedColumn-K),K=Z.generatedColumn,Z.source!=null){if(w=this._sources.indexOf(Z.source),H+=yX.encode(w-J),J=w,H+=yX.encode(Z.originalLine-1-z),z=Z.originalLine-1,H+=yX.encode(Z.originalColumn-Y),Y=Z.originalColumn,Z.name!=null)O=this._names.indexOf(Z.name),H+=yX.encode(O-P),P=O}W+=H}return W};j7.prototype._generateSourcesContent=function $(K,q){return K.map(function(Y){if(!this._sourcesContents)return null;if(q!=null)Y=A4.relative(q,Y);var z=A4.toSetString(Y);return Object.prototype.hasOwnProperty.call(this._sourcesContents,z)?this._sourcesContents[z]:null},this)};j7.prototype.toJSON=function $(){var K={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null)K.file=this._file;if(this._sourceRoot!=null)K.sourceRoot=this._sourceRoot;if(this._sourcesContents)K.sourcesContent=this._generateSourcesContent(K.sources,K.sourceRoot);return K};j7.prototype.toString=function $(){return JSON.stringify(this.toJSON())};j06.SourceMapGenerator=j7});var dZ8=j((G06)=>{G06.GREATEST_LOWER_BOUND=1;G06.LEAST_UPPER_BOUND=2;function Ob($,K,q,Y,z,P){var J=Math.floor((K-$)/2)+$,W=z(q,Y[J],!0);if(W===0)return J;else if(W>0){if(K-J>1)return Ob(J,K,q,Y,z,P);if(P==G06.LEAST_UPPER_BOUND)return K<Y.length?K:-1;else return J}else{if(J-$>1)return Ob($,J,q,Y,z,P);if(P==G06.LEAST_UPPER_BOUND)return J;else return $<0?-1:$}}G06.search=function $(K,q,Y,z){if(q.length===0)return-1;var P=Ob(-1,q.length,K,q,Y,z||G06.GREATEST_LOWER_BOUND);if(P<0)return-1;while(P-1>=0){if(Y(q[P],q[P-1],!0)!==0)break;--P}return P}});var nZ8=j((A06)=>{function Xb($,K,q){var Y=$[K];$[K]=$[q],$[q]=Y}function f06($,K){return Math.round($+Math.random()*(K-$))}function Tb($,K,q,Y){if(q<Y){var z=f06(q,Y),P=q-1;Xb($,z,Y);var J=$[Y];for(var W=q;W<Y;W++)if(K($[W],J)<=0)P+=1,Xb($,P,W);Xb($,P+1,W);var H=P+1;Tb($,K,q,H-1),Tb($,K,H+1,Y)}}A06.quickSort=function($,K){Tb($,K,0,$.length-1)}});var aZ8=j((M06)=>{var L8=fW(),jb=dZ8(),AW=Hb().ArraySet,k06=zb(),uX=nZ8().quickSort;function N1($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);return q.sections!=null?new P9(q,K):new q3(q,K)}N1.fromSourceMap=function($,K){return q3.fromSourceMap($,K)};N1.prototype._version=3;N1.prototype.__generatedMappings=null;Object.defineProperty(N1.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){if(!this.__generatedMappings)this._parseMappings(this._mappings,this.sourceRoot);return this.__generatedMappings}});N1.prototype.__originalMappings=null;Object.defineProperty(N1.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){if(!this.__originalMappings)this._parseMappings(this._mappings,this.sourceRoot);return this.__originalMappings}});N1.prototype._charIsMappingSeparator=function $(K,q){var Y=K.charAt(q);return Y===";"||Y===","};N1.prototype._parseMappings=function $(K,q){throw new Error("Subclasses must implement _parseMappings")};N1.GENERATED_ORDER=1;N1.ORIGINAL_ORDER=2;N1.GREATEST_LOWER_BOUND=1;N1.LEAST_UPPER_BOUND=2;N1.prototype.eachMapping=function $(K,q,Y){var z=q||null,P=Y||N1.GENERATED_ORDER,J;switch(P){case N1.GENERATED_ORDER:J=this._generatedMappings;break;case N1.ORIGINAL_ORDER:J=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var W=this.sourceRoot;J.map(function(H){var Z=H.source===null?null:this._sources.at(H.source);return Z=L8.computeSourceURL(W,Z,this._sourceMapURL),{source:Z,generatedLine:H.generatedLine,generatedColumn:H.generatedColumn,originalLine:H.originalLine,originalColumn:H.originalColumn,name:H.name===null?null:this._names.at(H.name)}},this).forEach(K,z)};N1.prototype.allGeneratedPositionsFor=function $(K){var q=L8.getArg(K,"line"),Y={source:L8.getArg(K,"source"),originalLine:q,originalColumn:L8.getArg(K,"column",0)};if(Y.source=this._findSourceIndex(Y.source),Y.source<0)return[];var z=[],P=this._findMapping(Y,this._originalMappings,"originalLine","originalColumn",L8.compareByOriginalPositions,jb.LEAST_UPPER_BOUND);if(P>=0){var J=this._originalMappings[P];if(K.column===void 0){var W=J.originalLine;while(J&&J.originalLine===W)z.push({line:L8.getArg(J,"generatedLine",null),column:L8.getArg(J,"generatedColumn",null),lastColumn:L8.getArg(J,"lastGeneratedColumn",null)}),J=this._originalMappings[++P]}else{var H=J.originalColumn;while(J&&J.originalLine===q&&J.originalColumn==H)z.push({line:L8.getArg(J,"generatedLine",null),column:L8.getArg(J,"generatedColumn",null),lastColumn:L8.getArg(J,"lastGeneratedColumn",null)}),J=this._originalMappings[++P]}}return z};M06.SourceMapConsumer=N1;function q3($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);var Y=L8.getArg(q,"version"),z=L8.getArg(q,"sources"),P=L8.getArg(q,"names",[]),J=L8.getArg(q,"sourceRoot",null),W=L8.getArg(q,"sourcesContent",null),H=L8.getArg(q,"mappings"),Z=L8.getArg(q,"file",null);if(Y!=this._version)throw new Error("Unsupported version: "+Y);if(J)J=L8.normalize(J);z=z.map(String).map(L8.normalize).map(function(O){return J&&L8.isAbsolute(J)&&L8.isAbsolute(O)?L8.relative(J,O):O}),this._names=AW.fromArray(P.map(String),!0),this._sources=AW.fromArray(z,!0),this._absoluteSources=this._sources.toArray().map(function(O){return L8.computeSourceURL(J,O,K)}),this.sourceRoot=J,this.sourcesContent=W,this._mappings=H,this._sourceMapURL=K,this.file=Z}q3.prototype=Object.create(N1.prototype);q3.prototype.consumer=N1;q3.prototype._findSourceIndex=function($){var K=$;if(this.sourceRoot!=null)K=L8.relative(this.sourceRoot,K);if(this._sources.has(K))return this._sources.indexOf(K);var q;for(q=0;q<this._absoluteSources.length;++q)if(this._absoluteSources[q]==$)return q;return-1};q3.fromSourceMap=function $(K,q){var Y=Object.create(q3.prototype),z=Y._names=AW.fromArray(K._names.toArray(),!0),P=Y._sources=AW.fromArray(K._sources.toArray(),!0);Y.sourceRoot=K._sourceRoot,Y.sourcesContent=K._generateSourcesContent(Y._sources.toArray(),Y.sourceRoot),Y.file=K._file,Y._sourceMapURL=q,Y._absoluteSources=Y._sources.toArray().map(function(T){return L8.computeSourceURL(Y.sourceRoot,T,q)});var J=K._mappings.toArray().slice(),W=Y.__generatedMappings=[],H=Y.__originalMappings=[];for(var Z=0,O=J.length;Z<O;Z++){var w=J[Z],X=new oZ8;if(X.generatedLine=w.generatedLine,X.generatedColumn=w.generatedColumn,w.source){if(X.source=P.indexOf(w.source),X.originalLine=w.originalLine,X.originalColumn=w.originalColumn,w.name)X.name=z.indexOf(w.name);H.push(X)}W.push(X)}return uX(Y.__originalMappings,L8.compareByOriginalPositions),Y};q3.prototype._version=3;Object.defineProperty(q3.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function oZ8(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}q3.prototype._parseMappings=function $(K,q){var Y=1,z=0,P=0,J=0,W=0,H=0,Z=K.length,O=0,w={},X={},T=[],G=[],v,f,A,C,V;while(O<Z)if(K.charAt(O)===";")Y++,O++,z=0;else if(K.charAt(O)===",")O++;else{v=new oZ8,v.generatedLine=Y;for(C=O;C<Z;C++)if(this._charIsMappingSeparator(K,C))break;if(f=K.slice(O,C),A=w[f],A)O+=f.length;else{A=[];while(O<C)k06.decode(K,O,X),V=X.value,O=X.rest,A.push(V);if(A.length===2)throw new Error("Found a source, but no line and column");if(A.length===3)throw new Error("Found a source and line, but no column");w[f]=A}if(v.generatedColumn=z+A[0],z=v.generatedColumn,A.length>1){if(v.source=W+A[1],W+=A[1],v.originalLine=P+A[2],P=v.originalLine,v.originalLine+=1,v.originalColumn=J+A[3],J=v.originalColumn,A.length>4)v.name=H+A[4],H+=A[4]}if(G.push(v),typeof v.originalLine==="number")T.push(v)}uX(G,L8.compareByGeneratedPositionsDeflated),this.__generatedMappings=G,uX(T,L8.compareByOriginalPositions),this.__originalMappings=T};q3.prototype._findMapping=function $(K,q,Y,z,P,J){if(K[Y]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+K[Y]);if(K[z]<0)throw new TypeError("Column must be greater than or equal to 0, got "+K[z]);return jb.search(K,q,P,J)};q3.prototype.computeColumnSpans=function $(){for(var K=0;K<this._generatedMappings.length;++K){var q=this._generatedMappings[K];if(K+1<this._generatedMappings.length){var Y=this._generatedMappings[K+1];if(q.generatedLine===Y.generatedLine){q.lastGeneratedColumn=Y.generatedColumn-1;continue}}q.lastGeneratedColumn=1/0}};q3.prototype.originalPositionFor=function $(K){var q={generatedLine:L8.getArg(K,"line"),generatedColumn:L8.getArg(K,"column")},Y=this._findMapping(q,this._generatedMappings,"generatedLine","generatedColumn",L8.compareByGeneratedPositionsDeflated,L8.getArg(K,"bias",N1.GREATEST_LOWER_BOUND));if(Y>=0){var z=this._generatedMappings[Y];if(z.generatedLine===q.generatedLine){var P=L8.getArg(z,"source",null);if(P!==null)P=this._sources.at(P),P=L8.computeSourceURL(this.sourceRoot,P,this._sourceMapURL);var J=L8.getArg(z,"name",null);if(J!==null)J=this._names.at(J);return{source:P,line:L8.getArg(z,"originalLine",null),column:L8.getArg(z,"originalColumn",null),name:J}}}return{source:null,line:null,column:null,name:null}};q3.prototype.hasContentsOfAllSources=function $(){if(!this.sourcesContent)return!1;return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(K){return K==null})};q3.prototype.sourceContentFor=function $(K,q){if(!this.sourcesContent)return null;var Y=this._findSourceIndex(K);if(Y>=0)return this.sourcesContent[Y];var z=K;if(this.sourceRoot!=null)z=L8.relative(this.sourceRoot,z);var P;if(this.sourceRoot!=null&&(P=L8.urlParse(this.sourceRoot))){var J=z.replace(/^file:\/\//,"");if(P.scheme=="file"&&this._sources.has(J))return this.sourcesContent[this._sources.indexOf(J)];if((!P.path||P.path=="/")&&this._sources.has("/"+z))return this.sourcesContent[this._sources.indexOf("/"+z)]}if(q)return null;else throw new Error('"'+z+'" is not in the SourceMap.')};q3.prototype.generatedPositionFor=function $(K){var q=L8.getArg(K,"source");if(q=this._findSourceIndex(q),q<0)return{line:null,column:null,lastColumn:null};var Y={source:q,originalLine:L8.getArg(K,"line"),originalColumn:L8.getArg(K,"column")},z=this._findMapping(Y,this._originalMappings,"originalLine","originalColumn",L8.compareByOriginalPositions,L8.getArg(K,"bias",N1.GREATEST_LOWER_BOUND));if(z>=0){var P=this._originalMappings[z];if(P.source===Y.source)return{line:L8.getArg(P,"generatedLine",null),column:L8.getArg(P,"generatedColumn",null),lastColumn:L8.getArg(P,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}};M06.BasicSourceMapConsumer=q3;function P9($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);var Y=L8.getArg(q,"version"),z=L8.getArg(q,"sections");if(Y!=this._version)throw new Error("Unsupported version: "+Y);this._sources=new AW,this._names=new AW;var P={line:-1,column:0};this._sections=z.map(function(J){if(J.url)throw new Error("Support for url field in sections not implemented.");var W=L8.getArg(J,"offset"),H=L8.getArg(W,"line"),Z=L8.getArg(W,"column");if(H<P.line||H===P.line&&Z<P.column)throw new Error("Section offsets must be ordered and non-overlapping.");return P=W,{generatedOffset:{generatedLine:H+1,generatedColumn:Z+1},consumer:new N1(L8.getArg(J,"map"),K)}})}P9.prototype=Object.create(N1.prototype);P9.prototype.constructor=N1;P9.prototype._version=3;Object.defineProperty(P9.prototype,"sources",{get:function(){var $=[];for(var K=0;K<this._sections.length;K++)for(var q=0;q<this._sections[K].consumer.sources.length;q++)$.push(this._sections[K].consumer.sources[q]);return $}});P9.prototype.originalPositionFor=function $(K){var q={generatedLine:L8.getArg(K,"line"),generatedColumn:L8.getArg(K,"column")},Y=jb.search(q,this._sections,function(P,J){var W=P.generatedLine-J.generatedOffset.generatedLine;if(W)return W;return P.generatedColumn-J.generatedOffset.generatedColumn}),z=this._sections[Y];if(!z)return{source:null,line:null,column:null,name:null};return z.consumer.originalPositionFor({line:q.generatedLine-(z.generatedOffset.generatedLine-1),column:q.generatedColumn-(z.generatedOffset.generatedLine===q.generatedLine?z.generatedOffset.generatedColumn-1:0),bias:K.bias})};P9.prototype.hasContentsOfAllSources=function $(){return this._sections.every(function(K){return K.consumer.hasContentsOfAllSources()})};P9.prototype.sourceContentFor=function $(K,q){for(var Y=0;Y<this._sections.length;Y++){var z=this._sections[Y],P=z.consumer.sourceContentFor(K,!0);if(P)return P}if(q)return null;else throw new Error('"'+K+'" is not in the SourceMap.')};P9.prototype.generatedPositionFor=function $(K){for(var q=0;q<this._sections.length;q++){var Y=this._sections[q];if(Y.consumer._findSourceIndex(L8.getArg(K,"source"))===-1)continue;var z=Y.consumer.generatedPositionFor(K);if(z){var P={line:z.line+(Y.generatedOffset.generatedLine-1),column:z.column+(Y.generatedOffset.generatedLine===z.line?Y.generatedOffset.generatedColumn-1:0)};return P}}return{line:null,column:null}};P9.prototype._parseMappings=function $(K,q){this.__generatedMappings=[],this.__originalMappings=[];for(var Y=0;Y<this._sections.length;Y++){var z=this._sections[Y],P=z.consumer._generatedMappings;for(var J=0;J<P.length;J++){var W=P[J],H=z.consumer._sources.at(W.source);H=L8.computeSourceURL(z.consumer.sourceRoot,H,this._sourceMapURL),this._sources.add(H),H=this._sources.indexOf(H);var Z=null;if(W.name)Z=z.consumer._names.at(W.name),this._names.add(Z),Z=this._names.indexOf(Z);var O={source:H,generatedLine:W.generatedLine+(z.generatedOffset.generatedLine-1),generatedColumn:W.generatedColumn+(z.generatedOffset.generatedLine===W.generatedLine?z.generatedOffset.generatedColumn-1:0),originalLine:W.originalLine,originalColumn:W.originalColumn,name:Z};if(this.__generatedMappings.push(O),typeof O.originalLine==="number")this.__originalMappings.push(O)}}uX(this.__generatedMappings,L8.compareByGeneratedPositionsDeflated),uX(this.__originalMappings,L8.compareByOriginalPositions)};M06.IndexedSourceMapConsumer=P9});var rZ8=j((E06)=>{var R06=Zb().SourceMapGenerator,mf=fW(),D06=/(\r?\n)/,S06=10,VW="$$$isSourceNode$$$";function Q$($,K,q,Y,z){if(this.children=[],this.sourceContents={},this.line=$==null?null:$,this.column=K==null?null:K,this.source=q==null?null:q,this.name=z==null?null:z,this[VW]=!0,Y!=null)this.add(Y)}Q$.fromStringWithSourceMap=function $(K,q,Y){var z=new Q$,P=K.split(D06),J=0,W=function(){var X=G(),T=G()||"";return X+T;function G(){return J<P.length?P[J++]:void 0}},H=1,Z=0,O=null;if(q.eachMapping(function(X){if(O!==null)if(H<X.generatedLine)w(O,W()),H++,Z=0;else{var T=P[J]||"",G=T.substr(0,X.generatedColumn-Z);P[J]=T.substr(X.generatedColumn-Z),Z=X.generatedColumn,w(O,G),O=X;return}while(H<X.generatedLine)z.add(W()),H++;if(Z<X.generatedColumn){var T=P[J]||"";z.add(T.substr(0,X.generatedColumn)),P[J]=T.substr(X.generatedColumn),Z=X.generatedColumn}O=X},this),J<P.length){if(O)w(O,W());z.add(P.splice(J).join(""))}return q.sources.forEach(function(X){var T=q.sourceContentFor(X);if(T!=null){if(Y!=null)X=mf.join(Y,X);z.setSourceContent(X,T)}}),z;function w(X,T){if(X===null||X.source===void 0)z.add(T);else{var G=Y?mf.join(Y,X.source):X.source;z.add(new Q$(X.originalLine,X.originalColumn,G,T,X.name))}}};Q$.prototype.add=function $(K){if(Array.isArray(K))K.forEach(function(q){this.add(q)},this);else if(K[VW]||typeof K==="string"){if(K)this.children.push(K)}else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+K);return this};Q$.prototype.prepend=function $(K){if(Array.isArray(K))for(var q=K.length-1;q>=0;q--)this.prepend(K[q]);else if(K[VW]||typeof K==="string")this.children.unshift(K);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+K);return this};Q$.prototype.walk=function $(K){var q;for(var Y=0,z=this.children.length;Y<z;Y++)if(q=this.children[Y],q[VW])q.walk(K);else if(q!=="")K(q,{source:this.source,line:this.line,column:this.column,name:this.name})};Q$.prototype.join=function $(K){var q,Y,z=this.children.length;if(z>0){q=[];for(Y=0;Y<z-1;Y++)q.push(this.children[Y]),q.push(K);q.push(this.children[Y]),this.children=q}return this};Q$.prototype.replaceRight=function $(K,q){var Y=this.children[this.children.length-1];if(Y[VW])Y.replaceRight(K,q);else if(typeof Y==="string")this.children[this.children.length-1]=Y.replace(K,q);else this.children.push("".replace(K,q));return this};Q$.prototype.setSourceContent=function $(K,q){this.sourceContents[mf.toSetString(K)]=q};Q$.prototype.walkSourceContents=function $(K){for(var q=0,Y=this.children.length;q<Y;q++)if(this.children[q][VW])this.children[q].walkSourceContents(K);var z=Object.keys(this.sourceContents);for(var q=0,Y=z.length;q<Y;q++)K(mf.fromSetString(z[q]),this.sourceContents[z[q]])};Q$.prototype.toString=function $(){var K="";return this.walk(function(q){K+=q}),K};Q$.prototype.toStringWithSourceMap=function $(K){var q={code:"",line:1,column:0},Y=new R06(K),z=!1,P=null,J=null,W=null,H=null;return this.walk(function(Z,O){if(q.code+=Z,O.source!==null&&O.line!==null&&O.column!==null){if(P!==O.source||J!==O.line||W!==O.column||H!==O.name)Y.addMapping({source:O.source,original:{line:O.line,column:O.column},generated:{line:q.line,column:q.column},name:O.name});P=O.source,J=O.line,W=O.column,H=O.name,z=!0}else if(z)Y.addMapping({generated:{line:q.line,column:q.column}}),P=null,z=!1;for(var w=0,X=Z.length;w<X;w++)if(Z.charCodeAt(w)===S06){if(q.line++,q.column=0,w+1===X)P=null,z=!1;else if(z)Y.addMapping({source:O.source,original:{line:O.line,column:O.column},generated:{line:q.line,column:q.column},name:O.name})}else q.column++}),this.walkSourceContents(function(Z,O){Y.setSourceContent(Z,O)}),{code:q.code,map:Y}};E06.SourceNode=Q$});var sZ8=j((I06)=>{I06.SourceMapGenerator=Zb().SourceMapGenerator;I06.SourceMapConsumer=aZ8().SourceMapConsumer;I06.SourceNode=rZ8().SourceNode});var KO8=j((eZ8,$O8)=>{eZ8.__esModule=!0;var Gb=o3(),oz=void 0;try{if(typeof define!=="function"||!define.amd)_b=sZ8(),oz=_b.SourceNode}catch($){}var _b;if(!oz)oz=function($,K,q,Y){if(this.src="",Y)this.add(Y)},oz.prototype={add:function $(K){if(Gb.isArray(K))K=K.join("");this.src+=K},prepend:function $(K){if(Gb.isArray(K))K=K.join("");this.src=K+this.src},toStringWithSourceMap:function $(){return{code:this.toString()}},toString:function $(){return this.src}};function vb($,K,q){if(Gb.isArray($)){var Y=[];for(var z=0,P=$.length;z<P;z++)Y.push(K.wrap($[z],q));return Y}else if(typeof $==="boolean"||typeof $==="number")return $+"";return $}function tZ8($){this.srcFile=$,this.source=[]}tZ8.prototype={isEmpty:function $(){return!this.source.length},prepend:function $(K,q){this.source.unshift(this.wrap(K,q))},push:function $(K,q){this.source.push(this.wrap(K,q))},merge:function $(){var K=this.empty();return this.each(function(q){K.add([" ",q,`
|
|
387
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function z(){var P=this.next();if(typeof P!=="undefined")return P;else return this.lex()},begin:function z(P){this.conditionStack.push(P)},popState:function z(){return this.conditionStack.pop()},_currentRules:function z(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function z(){return this.conditionStack[this.conditionStack.length-2]},pushState:function z(P){this.begin(P)}};return Y.options={},Y.performAction=function z(P,J,W,H){function Z(w,X){return J.yytext=J.yytext.substring(w,J.yyleng-X+w)}var O=H;switch(W){case 0:if(J.yytext.slice(-2)==="\\\\")Z(0,1),this.begin("mu");else if(J.yytext.slice(-1)==="\\")Z(0,1),this.begin("emu");else this.begin("mu");if(J.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;break;case 3:return this.begin("raw"),15;break;case 4:if(this.popState(),this.conditionStack[this.conditionStack.length-1]==="raw")return 15;else return Z(5,9),"END_RAW_BLOCK";break;case 5:return 15;case 6:return this.popState(),14;break;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;break;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:return this.popState(),44;break;case 16:return this.popState(),44;break;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(J.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;break;case 23:return 48;case 24:return 73;case 25:return 72;case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;break;case 30:return this.popState(),33;break;case 31:return J.yytext=Z(1,2).replace(/\\"/g,'"'),80;break;case 32:return J.yytext=Z(1,2).replace(/\\'/g,"'"),80;break;case 33:return 85;case 34:return 82;case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return J.yytext=J.yytext.replace(/\\([\\\]])/g,"$1"),72;break;case 43:return"INVALID";case 44:return 5}},Y.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],Y.conditions={mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}},Y}();$.lexer=K;function q(){this.yy={}}return q.prototype=$,$.Parser=q,new q}();jZ8.default=hv6;vZ8.exports=jZ8.default});var bf=j((AZ8,VZ8)=>{AZ8.__esModule=!0;function Dv6($){return $&&$.__esModule?$:{default:$}}var Sv6=T7(),rx=Dv6(Sv6);function If(){this.parents=[]}If.prototype={constructor:If,mutating:!1,acceptKey:function $(K,q){var Y=this.accept(K[q]);if(this.mutating){if(Y&&!If.prototype[Y.type])throw new rx.default('Unexpected node type "'+Y.type+'" found when accepting '+q+" on "+K.type);K[q]=Y}},acceptRequired:function $(K,q){if(this.acceptKey(K,q),!K[q])throw new rx.default(K.type+" requires "+q)},acceptArray:function $(K){for(var q=0,Y=K.length;q<Y;q++)if(this.acceptKey(K,q),!K[q])K.splice(q,1),q--,Y--},accept:function $(K){if(!K)return;if(!this[K.type])throw new rx.default("Unknown type: "+K.type,K);if(this.current)this.parents.unshift(this.current);this.current=K;var q=this[K.type](K);if(this.current=this.parents.shift(),!this.mutating||q)return q;else if(q!==!1)return K},Program:function $(K){this.acceptArray(K.body)},MustacheStatement:xf,Decorator:xf,BlockStatement:_Z8,DecoratorBlock:_Z8,PartialStatement:fZ8,PartialBlockStatement:function $(K){fZ8.call(this,K),this.acceptKey(K,"program")},ContentStatement:function $(){},CommentStatement:function $(){},SubExpression:xf,PathExpression:function $(){},StringLiteral:function $(){},NumberLiteral:function $(){},BooleanLiteral:function $(){},UndefinedLiteral:function $(){},NullLiteral:function $(){},Hash:function $(K){this.acceptArray(K.pairs)},HashPair:function $(K){this.acceptRequired(K,"value")}};function xf($){this.acceptRequired($,"path"),this.acceptArray($.params),this.acceptKey($,"hash")}function _Z8($){xf.call(this,$),this.acceptKey($,"program"),this.acceptKey($,"inverse")}function fZ8($){this.acceptRequired($,"name"),this.acceptArray($.params),this.acceptKey($,"hash")}AZ8.default=If;VZ8.exports=AZ8.default});var NZ8=j((kZ8,MZ8)=>{kZ8.__esModule=!0;function Iv6($){return $&&$.__esModule?$:{default:$}}var xv6=bf(),bv6=Iv6(xv6);function z5(){var $=arguments.length<=0||arguments[0]===void 0?{}:arguments[0];this.options=$}z5.prototype=new bv6.default;z5.prototype.Program=function($){var K=!this.options.ignoreStandalone,q=!this.isRootSeen;this.isRootSeen=!0;var Y=$.body;for(var z=0,P=Y.length;z<P;z++){var J=Y[z],W=this.accept(J);if(!W)continue;var H=sx(Y,z,q),Z=tx(Y,z,q),O=W.openStandalone&&H,w=W.closeStandalone&&Z,X=W.inlineStandalone&&H&&Z;if(W.close)dz(Y,z,!0);if(W.open)oq(Y,z,!0);if(K&&X){if(dz(Y,z),oq(Y,z)){if(J.type==="PartialStatement")J.indent=/([ \t]+$)/.exec(Y[z-1].original)[1]}}if(K&&O)dz((J.program||J.inverse).body),oq(Y,z);if(K&&w)dz(Y,z),oq((J.inverse||J.program).body)}return $};z5.prototype.BlockStatement=z5.prototype.DecoratorBlock=z5.prototype.PartialBlockStatement=function($){this.accept($.program),this.accept($.inverse);var K=$.program||$.inverse,q=$.program&&$.inverse,Y=q,z=q;if(q&&q.chained){Y=q.body[0].program;while(z.chained)z=z.body[z.body.length-1].program}var P={open:$.openStrip.open,close:$.closeStrip.close,openStandalone:tx(K.body),closeStandalone:sx((Y||K).body)};if($.openStrip.close)dz(K.body,null,!0);if(q){var J=$.inverseStrip;if(J.open)oq(K.body,null,!0);if(J.close)dz(Y.body,null,!0);if($.closeStrip.open)oq(z.body,null,!0);if(!this.options.ignoreStandalone&&sx(K.body)&&tx(Y.body))oq(K.body),dz(Y.body)}else if($.closeStrip.open)oq(K.body,null,!0);return P};z5.prototype.Decorator=z5.prototype.MustacheStatement=function($){return $.strip};z5.prototype.PartialStatement=z5.prototype.CommentStatement=function($){var K=$.strip||{};return{inlineStandalone:!0,open:K.open,close:K.close}};function sx($,K,q){if(K===void 0)K=$.length;var Y=$[K-1],z=$[K-2];if(!Y)return q;if(Y.type==="ContentStatement")return(z||!q?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(Y.original)}function tx($,K,q){if(K===void 0)K=-1;var Y=$[K+1],z=$[K+2];if(!Y)return q;if(Y.type==="ContentStatement")return(z||!q?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(Y.original)}function dz($,K,q){var Y=$[K==null?0:K+1];if(!Y||Y.type!=="ContentStatement"||!q&&Y.rightStripped)return;var z=Y.value;Y.value=Y.value.replace(q?/^\s+/:/^[ \t]*\r?\n?/,""),Y.rightStripped=Y.value!==z}function oq($,K,q){var Y=$[K==null?$.length-1:K-1];if(!Y||Y.type!=="ContentStatement"||!q&&Y.leftStripped)return;var z=Y.value;return Y.value=Y.value.replace(q?/\s+$/:/[ \t]+$/,""),Y.leftStripped=Y.value!==z,Y.leftStripped}kZ8.default=z5;MZ8.exports=kZ8.default});var hZ8=j((ov6)=>{ov6.__esModule=!0;ov6.SourceLocation=pv6;ov6.id=cv6;ov6.stripFlags=Bv6;ov6.stripComment=Uv6;ov6.preparePath=lv6;ov6.prepareMustache=Fv6;ov6.prepareRawBlock=iv6;ov6.prepareBlock=Qv6;ov6.prepareProgram=dv6;ov6.preparePartialBlock=nv6;function uv6($){return $&&$.__esModule?$:{default:$}}var mv6=T7(),ex=uv6(mv6);function $b($,K){if(K=K.path?K.path.original:K,$.path.original!==K){var q={loc:$.path.loc};throw new ex.default($.path.original+" doesn't match "+K,q)}}function pv6($,K){this.source=$,this.start={line:K.first_line,column:K.first_column},this.end={line:K.last_line,column:K.last_column}}function cv6($){if(/^\[.*\]$/.test($))return $.substring(1,$.length-1);else return $}function Bv6($,K){return{open:$.charAt(2)==="~",close:K.charAt(K.length-3)==="~"}}function Uv6($){return $.replace(/^\{\{~?!-?-?/,"").replace(/-?-?~?\}\}$/,"")}function lv6($,K,q){q=this.locInfo(q);var Y=$?"@":"",z=[],P=0;for(var J=0,W=K.length;J<W;J++){var H=K[J].part,Z=K[J].original!==H;if(Y+=(K[J].separator||"")+H,!Z&&(H===".."||H==="."||H==="this")){if(z.length>0)throw new ex.default("Invalid path: "+Y,{loc:q});else if(H==="..")P++}else z.push(H)}return{type:"PathExpression",data:$,depth:P,parts:z,original:Y,loc:q}}function Fv6($,K,q,Y,z,P){var J=Y.charAt(3)||Y.charAt(2),W=J!=="{"&&J!=="&",H=/\*/.test(Y);return{type:H?"Decorator":"MustacheStatement",path:$,params:K,hash:q,escaped:W,strip:z,loc:this.locInfo(P)}}function iv6($,K,q,Y){$b($,q),Y=this.locInfo(Y);var z={type:"Program",body:K,strip:{},loc:Y};return{type:"BlockStatement",path:$.path,params:$.params,hash:$.hash,program:z,openStrip:{},inverseStrip:{},closeStrip:{},loc:Y}}function Qv6($,K,q,Y,z,P){if(Y&&Y.path)$b($,Y);var J=/\*/.test($.open);K.blockParams=$.blockParams;var W=void 0,H=void 0;if(q){if(J)throw new ex.default("Unexpected inverse block on decorator",q);if(q.chain)q.program.body[0].closeStrip=Y.strip;H=q.strip,W=q.program}if(z)z=W,W=K,K=z;return{type:J?"DecoratorBlock":"BlockStatement",path:$.path,params:$.params,hash:$.hash,program:K,inverse:W,openStrip:$.strip,inverseStrip:H,closeStrip:Y&&Y.strip,loc:this.locInfo(P)}}function dv6($,K){if(!K&&$.length){var q=$[0].loc,Y=$[$.length-1].loc;if(q&&Y)K={source:q.source,start:{line:q.start.line,column:q.start.column},end:{line:Y.end.line,column:Y.end.column}}}return{type:"Program",body:$,strip:{},loc:K}}function nv6($,K,q,Y){return $b($,q),{type:"PartialBlockStatement",name:$.path,params:$.params,hash:$.hash,program:K,openStrip:$.strip,closeStrip:q&&q.strip,loc:this.locInfo(Y)}}});var DZ8=j((jG6)=>{jG6.__esModule=!0;jG6.parseWithoutProcessing=RZ8;jG6.parse=TG6;function JG6($){if($&&$.__esModule)return $;else{var K={};if($!=null){for(var q in $)if(Object.prototype.hasOwnProperty.call($,q))K[q]=$[q]}return K.default=$,K}}function CZ8($){return $&&$.__esModule?$:{default:$}}var WG6=GZ8(),Kb=CZ8(WG6),HG6=NZ8(),ZG6=CZ8(HG6),OG6=hZ8(),wG6=JG6(OG6),XG6=o3();jG6.parser=Kb.default;var gf={};XG6.extend(gf,wG6);function RZ8($,K){if($.type==="Program")return $;Kb.default.yy=gf,gf.locInfo=function(Y){return new gf.SourceLocation(K&&K.srcName,Y)};var q=Kb.default.parse($);return q}function TG6($,K){var q=RZ8($,K),Y=new ZG6.default(K);return Y.accept(q)}});var IZ8=j((hG6)=>{hG6.__esModule=!0;hG6.Compiler=qb;hG6.precompile=MG6;hG6.compile=NG6;function EZ8($){return $&&$.__esModule?$:{default:$}}var AG6=T7(),xX=EZ8(AG6),bX=o3(),VG6=ax(),IX=EZ8(VG6),kG6=[].slice;function qb(){}qb.prototype={compiler:qb,equals:function $(K){var q=this.opcodes.length;if(K.opcodes.length!==q)return!1;for(var Y=0;Y<q;Y++){var z=this.opcodes[Y],P=K.opcodes[Y];if(z.opcode!==P.opcode||!LZ8(z.args,P.args))return!1}q=this.children.length;for(var Y=0;Y<q;Y++)if(!this.children[Y].equals(K.children[Y]))return!1;return!0},guid:0,compile:function $(K,q){return this.sourceNode=[],this.opcodes=[],this.children=[],this.options=q,this.stringParams=q.stringParams,this.trackIds=q.trackIds,q.blockParams=q.blockParams||[],q.knownHelpers=bX.extend(Object.create(null),{helperMissing:!0,blockHelperMissing:!0,each:!0,if:!0,unless:!0,with:!0,log:!0,lookup:!0},q.knownHelpers),this.accept(K)},compileProgram:function $(K){var q=new this.compiler,Y=q.compile(K,this.options),z=this.guid++;return this.usePartial=this.usePartial||Y.usePartial,this.children[z]=Y,this.useDepths=this.useDepths||Y.useDepths,z},accept:function $(K){if(!this[K.type])throw new xX.default("Unknown type: "+K.type,K);this.sourceNode.unshift(K);var q=this[K.type](K);return this.sourceNode.shift(),q},Program:function $(K){this.options.blockParams.unshift(K.blockParams);var q=K.body,Y=q.length;for(var z=0;z<Y;z++)this.accept(q[z]);return this.options.blockParams.shift(),this.isSimple=Y===1,this.blockParams=K.blockParams?K.blockParams.length:0,this},BlockStatement:function $(K){SZ8(K);var{program:q,inverse:Y}=K;q=q&&this.compileProgram(q),Y=Y&&this.compileProgram(Y);var z=this.classifySexpr(K);if(z==="helper")this.helperSexpr(K,q,Y);else if(z==="simple")this.simpleSexpr(K),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),this.opcode("emptyHash"),this.opcode("blockValue",K.path.original);else this.ambiguousSexpr(K,q,Y),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue");this.opcode("append")},DecoratorBlock:function $(K){var q=K.program&&this.compileProgram(K.program),Y=this.setupFullMustacheParams(K,q,void 0),z=K.path;this.useDecorators=!0,this.opcode("registerDecorator",Y.length,z.original)},PartialStatement:function $(K){this.usePartial=!0;var q=K.program;if(q)q=this.compileProgram(K.program);var Y=K.params;if(Y.length>1)throw new xX.default("Unsupported number of partial arguments: "+Y.length,K);else if(!Y.length)if(this.options.explicitPartialContext)this.opcode("pushLiteral","undefined");else Y.push({type:"PathExpression",parts:[],depth:0});var z=K.name.original,P=K.name.type==="SubExpression";if(P)this.accept(K.name);this.setupFullMustacheParams(K,q,void 0,!0);var J=K.indent||"";if(this.options.preventIndent&&J)this.opcode("appendContent",J),J="";this.opcode("invokePartial",P,z,J),this.opcode("append")},PartialBlockStatement:function $(K){this.PartialStatement(K)},MustacheStatement:function $(K){if(this.SubExpression(K),K.escaped&&!this.options.noEscape)this.opcode("appendEscaped");else this.opcode("append")},Decorator:function $(K){this.DecoratorBlock(K)},ContentStatement:function $(K){if(K.value)this.opcode("appendContent",K.value)},CommentStatement:function $(){},SubExpression:function $(K){SZ8(K);var q=this.classifySexpr(K);if(q==="simple")this.simpleSexpr(K);else if(q==="helper")this.helperSexpr(K);else this.ambiguousSexpr(K)},ambiguousSexpr:function $(K,q,Y){var z=K.path,P=z.parts[0],J=q!=null||Y!=null;this.opcode("getContext",z.depth),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),z.strict=!0,this.accept(z),this.opcode("invokeAmbiguous",P,J)},simpleSexpr:function $(K){var q=K.path;q.strict=!0,this.accept(q),this.opcode("resolvePossibleLambda")},helperSexpr:function $(K,q,Y){var z=this.setupFullMustacheParams(K,q,Y),P=K.path,J=P.parts[0];if(this.options.knownHelpers[J])this.opcode("invokeKnownHelper",z.length,J);else if(this.options.knownHelpersOnly)throw new xX.default("You specified knownHelpersOnly, but used the unknown helper "+J,K);else P.strict=!0,P.falsy=!0,this.accept(P),this.opcode("invokeHelper",z.length,P.original,IX.default.helpers.simpleId(P))},PathExpression:function $(K){this.addDepth(K.depth),this.opcode("getContext",K.depth);var q=K.parts[0],Y=IX.default.helpers.scopedId(K),z=!K.depth&&!Y&&this.blockParamIndex(q);if(z)this.opcode("lookupBlockParam",z,K.parts);else if(!q)this.opcode("pushContext");else if(K.data)this.options.data=!0,this.opcode("lookupData",K.depth,K.parts,K.strict);else this.opcode("lookupOnContext",K.parts,K.falsy,K.strict,Y)},StringLiteral:function $(K){this.opcode("pushString",K.value)},NumberLiteral:function $(K){this.opcode("pushLiteral",K.value)},BooleanLiteral:function $(K){this.opcode("pushLiteral",K.value)},UndefinedLiteral:function $(){this.opcode("pushLiteral","undefined")},NullLiteral:function $(){this.opcode("pushLiteral","null")},Hash:function $(K){var q=K.pairs,Y=0,z=q.length;this.opcode("pushHash");for(;Y<z;Y++)this.pushParam(q[Y].value);while(Y--)this.opcode("assignToHash",q[Y].key);this.opcode("popHash")},opcode:function $(K){this.opcodes.push({opcode:K,args:kG6.call(arguments,1),loc:this.sourceNode[0].loc})},addDepth:function $(K){if(!K)return;this.useDepths=!0},classifySexpr:function $(K){var q=IX.default.helpers.simpleId(K.path),Y=q&&!!this.blockParamIndex(K.path.parts[0]),z=!Y&&IX.default.helpers.helperExpression(K),P=!Y&&(z||q);if(P&&!z){var J=K.path.parts[0],W=this.options;if(W.knownHelpers[J])z=!0;else if(W.knownHelpersOnly)P=!1}if(z)return"helper";else if(P)return"ambiguous";else return"simple"},pushParams:function $(K){for(var q=0,Y=K.length;q<Y;q++)this.pushParam(K[q])},pushParam:function $(K){var q=K.value!=null?K.value:K.original||"";if(this.stringParams){if(q.replace)q=q.replace(/^(\.?\.\/)*/g,"").replace(/\//g,".");if(K.depth)this.addDepth(K.depth);if(this.opcode("getContext",K.depth||0),this.opcode("pushStringParam",q,K.type),K.type==="SubExpression")this.accept(K)}else{if(this.trackIds){var Y=void 0;if(K.parts&&!IX.default.helpers.scopedId(K)&&!K.depth)Y=this.blockParamIndex(K.parts[0]);if(Y){var z=K.parts.slice(1).join(".");this.opcode("pushId","BlockParam",Y,z)}else{if(q=K.original||q,q.replace)q=q.replace(/^this(?:\.|$)/,"").replace(/^\.\//,"").replace(/^\.$/,"");this.opcode("pushId",K.type,q)}}this.accept(K)}},setupFullMustacheParams:function $(K,q,Y,z){var P=K.params;if(this.pushParams(P),this.opcode("pushProgram",q),this.opcode("pushProgram",Y),K.hash)this.accept(K.hash);else this.opcode("emptyHash",z);return P},blockParamIndex:function $(K){for(var q=0,Y=this.options.blockParams.length;q<Y;q++){var z=this.options.blockParams[q],P=z&&bX.indexOf(z,K);if(z&&P>=0)return[q,P]}}};function MG6($,K,q){if($==null||typeof $!=="string"&&$.type!=="Program")throw new xX.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+$);if(K=K||{},!("data"in K))K.data=!0;if(K.compat)K.useDepths=!0;var Y=q.parse($,K),z=new q.Compiler().compile(Y,K);return new q.JavaScriptCompiler().compile(z,K)}function NG6($,K,q){if(K===void 0)K={};if($==null||typeof $!=="string"&&$.type!=="Program")throw new xX.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+$);if(K=bX.extend({},K),!("data"in K))K.data=!0;if(K.compat)K.useDepths=!0;var Y=void 0;function z(){var J=q.parse($,K),W=new q.Compiler().compile(J,K),H=new q.JavaScriptCompiler().compile(W,K,void 0,!0);return q.template(H)}function P(J,W){if(!Y)Y=z();return Y.call(this,J,W)}return P._setup=function(J){if(!Y)Y=z();return Y._setup(J)},P._child=function(J,W,H,Z){if(!Y)Y=z();return Y._child(J,W,H,Z)},P}function LZ8($,K){if($===K)return!0;if(bX.isArray($)&&bX.isArray(K)&&$.length===K.length){for(var q=0;q<$.length;q++)if(!LZ8($[q],K[q]))return!1;return!0}}function SZ8($){if(!$.path.parts){var K=$.path;$.path={type:"PathExpression",data:!1,depth:0,parts:[K.original+""],original:K.original+"",loc:K.loc}}}});var bZ8=j((EG6)=>{var xZ8="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");EG6.encode=function($){if(0<=$&&$<xZ8.length)return xZ8[$];throw new TypeError("Must be between 0 and 63: "+$)};EG6.decode=function($){var K=65,q=90,Y=97,z=122,P=48,J=57,W=43,H=47,Z=26,O=52;if(K<=$&&$<=q)return $-K;if(Y<=$&&$<=z)return $-Y+Z;if(P<=$&&$<=J)return $-P+O;if($==W)return 62;if($==H)return 63;return-1}});var zb=j((gG6)=>{var gZ8=bZ8(),Yb=5,yZ8=1<<Yb,uZ8=yZ8-1,mZ8=yZ8;function xG6($){return $<0?(-$<<1)+1:($<<1)+0}function bG6($){var K=($&1)===1,q=$>>1;return K?-q:q}gG6.encode=function $(K){var q="",Y,z=xG6(K);do{if(Y=z&uZ8,z>>>=Yb,z>0)Y|=mZ8;q+=gZ8.encode(Y)}while(z>0);return q};gG6.decode=function $(K,q,Y){var z=K.length,P=0,J=0,W,H;do{if(q>=z)throw new Error("Expected more digits in base 64 VLQ value.");if(H=gZ8.decode(K.charCodeAt(q++)),H===-1)throw new Error("Invalid base64 digit: "+K.charAt(q-1));W=!!(H&mZ8),H&=uZ8,P=P+(H<<J),J+=Yb}while(W);Y.value=bG6(P),Y.rest=q}});var fW=j((nG6)=>{function mG6($,K,q){if(K in $)return $[K];else if(arguments.length===3)return q;else throw new Error('"'+K+'" is a required argument.')}nG6.getArg=mG6;var pZ8=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,pG6=/^data:.+\,.+$/;function gX($){var K=$.match(pZ8);if(!K)return null;return{scheme:K[1],auth:K[2],host:K[3],port:K[4],path:K[5]}}nG6.urlParse=gX;function GW($){var K="";if($.scheme)K+=$.scheme+":";if(K+="//",$.auth)K+=$.auth+"@";if($.host)K+=$.host;if($.port)K+=":"+$.port;if($.path)K+=$.path;return K}nG6.urlGenerate=GW;function Pb($){var K=$,q=gX($);if(q){if(!q.path)return $;K=q.path}var Y=nG6.isAbsolute(K),z=K.split(/\/+/);for(var P,J=0,W=z.length-1;W>=0;W--)if(P=z[W],P===".")z.splice(W,1);else if(P==="..")J++;else if(J>0)if(P==="")z.splice(W+1,J),J=0;else z.splice(W,2),J--;if(K=z.join("/"),K==="")K=Y?"/":".";if(q)return q.path=K,GW(q);return K}nG6.normalize=Pb;function cZ8($,K){if($==="")$=".";if(K==="")K=".";var q=gX(K),Y=gX($);if(Y)$=Y.path||"/";if(q&&!q.scheme){if(Y)q.scheme=Y.scheme;return GW(q)}if(q||K.match(pG6))return K;if(Y&&!Y.host&&!Y.path)return Y.host=K,GW(Y);var z=K.charAt(0)==="/"?K:Pb($.replace(/\/+$/,"")+"/"+K);if(Y)return Y.path=z,GW(Y);return z}nG6.join=cZ8;nG6.isAbsolute=function($){return $.charAt(0)==="/"||pZ8.test($)};function cG6($,K){if($==="")$=".";$=$.replace(/\/$/,"");var q=0;while(K.indexOf($+"/")!==0){var Y=$.lastIndexOf("/");if(Y<0)return K;if($=$.slice(0,Y),$.match(/^([^\/]+:\/)?\/*$/))return K;++q}return Array(q+1).join("../")+K.substr($.length+1)}nG6.relative=cG6;var BZ8=function(){var $=Object.create(null);return!("__proto__"in $)}();function UZ8($){return $}function BG6($){if(lZ8($))return"$"+$;return $}nG6.toSetString=BZ8?UZ8:BG6;function UG6($){if(lZ8($))return $.slice(1);return $}nG6.fromSetString=BZ8?UZ8:UG6;function lZ8($){if(!$)return!1;var K=$.length;if(K<9)return!1;if($.charCodeAt(K-1)!==95||$.charCodeAt(K-2)!==95||$.charCodeAt(K-3)!==111||$.charCodeAt(K-4)!==116||$.charCodeAt(K-5)!==111||$.charCodeAt(K-6)!==114||$.charCodeAt(K-7)!==112||$.charCodeAt(K-8)!==95||$.charCodeAt(K-9)!==95)return!1;for(var q=K-10;q>=0;q--)if($.charCodeAt(q)!==36)return!1;return!0}function lG6($,K,q){var Y=_W($.source,K.source);if(Y!==0)return Y;if(Y=$.originalLine-K.originalLine,Y!==0)return Y;if(Y=$.originalColumn-K.originalColumn,Y!==0||q)return Y;if(Y=$.generatedColumn-K.generatedColumn,Y!==0)return Y;if(Y=$.generatedLine-K.generatedLine,Y!==0)return Y;return _W($.name,K.name)}nG6.compareByOriginalPositions=lG6;function FG6($,K,q){var Y=$.generatedLine-K.generatedLine;if(Y!==0)return Y;if(Y=$.generatedColumn-K.generatedColumn,Y!==0||q)return Y;if(Y=_W($.source,K.source),Y!==0)return Y;if(Y=$.originalLine-K.originalLine,Y!==0)return Y;if(Y=$.originalColumn-K.originalColumn,Y!==0)return Y;return _W($.name,K.name)}nG6.compareByGeneratedPositionsDeflated=FG6;function _W($,K){if($===K)return 0;if($===null)return 1;if(K===null)return-1;if($>K)return 1;return-1}function iG6($,K){var q=$.generatedLine-K.generatedLine;if(q!==0)return q;if(q=$.generatedColumn-K.generatedColumn,q!==0)return q;if(q=_W($.source,K.source),q!==0)return q;if(q=$.originalLine-K.originalLine,q!==0)return q;if(q=$.originalColumn-K.originalColumn,q!==0)return q;return _W($.name,K.name)}nG6.compareByGeneratedPositionsInflated=iG6;function QG6($){return JSON.parse($.replace(/^\)]}'[^\n]*\n/,""))}nG6.parseSourceMapInput=QG6;function dG6($,K,q){if(K=K||"",$){if($[$.length-1]!=="/"&&K[0]!=="/")$+="/";K=$+K}if(q){var Y=gX(q);if(!Y)throw new Error("sourceMapURL could not be parsed");if(Y.path){var z=Y.path.lastIndexOf("/");if(z>=0)Y.path=Y.path.substring(0,z+1)}K=cZ8(GW(Y),K)}return Pb(K)}nG6.computeSourceURL=dG6});var Hb=j((H06)=>{var Jb=fW(),Wb=Object.prototype.hasOwnProperty,nz=typeof Map!=="undefined";function TK(){this._array=[],this._set=nz?new Map:Object.create(null)}TK.fromArray=function $(K,q){var Y=new TK;for(var z=0,P=K.length;z<P;z++)Y.add(K[z],q);return Y};TK.prototype.size=function $(){return nz?this._set.size:Object.getOwnPropertyNames(this._set).length};TK.prototype.add=function $(K,q){var Y=nz?K:Jb.toSetString(K),z=nz?this.has(K):Wb.call(this._set,Y),P=this._array.length;if(!z||q)this._array.push(K);if(!z)if(nz)this._set.set(K,P);else this._set[Y]=P};TK.prototype.has=function $(K){if(nz)return this._set.has(K);else{var q=Jb.toSetString(K);return Wb.call(this._set,q)}};TK.prototype.indexOf=function $(K){if(nz){var q=this._set.get(K);if(q>=0)return q}else{var Y=Jb.toSetString(K);if(Wb.call(this._set,Y))return this._set[Y]}throw new Error('"'+K+'" is not in the set.')};TK.prototype.at=function $(K){if(K>=0&&K<this._array.length)return this._array[K];throw new Error("No element indexed by "+K)};TK.prototype.toArray=function $(){return this._array.slice()};H06.ArraySet=TK});var iZ8=j((w06)=>{var FZ8=fW();function O06($,K){var q=$.generatedLine,Y=K.generatedLine,z=$.generatedColumn,P=K.generatedColumn;return Y>q||Y==q&&P>=z||FZ8.compareByGeneratedPositionsInflated($,K)<=0}function yf(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}yf.prototype.unsortedForEach=function $(K,q){this._array.forEach(K,q)};yf.prototype.add=function $(K){if(O06(this._last,K))this._last=K,this._array.push(K);else this._sorted=!1,this._array.push(K)};yf.prototype.toArray=function $(){if(!this._sorted)this._array.sort(FZ8.compareByGeneratedPositionsInflated),this._sorted=!0;return this._array};w06.MappingList=yf});var Zb=j((j06)=>{var yX=zb(),f4=fW(),uf=Hb().ArraySet,T06=iZ8().MappingList;function j7($){if(!$)$={};this._file=f4.getArg($,"file",null),this._sourceRoot=f4.getArg($,"sourceRoot",null),this._skipValidation=f4.getArg($,"skipValidation",!1),this._sources=new uf,this._names=new uf,this._mappings=new T06,this._sourcesContents=null}j7.prototype._version=3;j7.fromSourceMap=function $(K){var q=K.sourceRoot,Y=new j7({file:K.file,sourceRoot:q});return K.eachMapping(function(z){var P={generated:{line:z.generatedLine,column:z.generatedColumn}};if(z.source!=null){if(P.source=z.source,q!=null)P.source=f4.relative(q,P.source);if(P.original={line:z.originalLine,column:z.originalColumn},z.name!=null)P.name=z.name}Y.addMapping(P)}),K.sources.forEach(function(z){var P=z;if(q!==null)P=f4.relative(q,z);if(!Y._sources.has(P))Y._sources.add(P);var J=K.sourceContentFor(z);if(J!=null)Y.setSourceContent(z,J)}),Y};j7.prototype.addMapping=function $(K){var q=f4.getArg(K,"generated"),Y=f4.getArg(K,"original",null),z=f4.getArg(K,"source",null),P=f4.getArg(K,"name",null);if(!this._skipValidation)this._validateMapping(q,Y,z,P);if(z!=null){if(z=String(z),!this._sources.has(z))this._sources.add(z)}if(P!=null){if(P=String(P),!this._names.has(P))this._names.add(P)}this._mappings.add({generatedLine:q.line,generatedColumn:q.column,originalLine:Y!=null&&Y.line,originalColumn:Y!=null&&Y.column,source:z,name:P})};j7.prototype.setSourceContent=function $(K,q){var Y=K;if(this._sourceRoot!=null)Y=f4.relative(this._sourceRoot,Y);if(q!=null){if(!this._sourcesContents)this._sourcesContents=Object.create(null);this._sourcesContents[f4.toSetString(Y)]=q}else if(this._sourcesContents){if(delete this._sourcesContents[f4.toSetString(Y)],Object.keys(this._sourcesContents).length===0)this._sourcesContents=null}};j7.prototype.applySourceMap=function $(K,q,Y){var z=q;if(q==null){if(K.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);z=K.file}var P=this._sourceRoot;if(P!=null)z=f4.relative(P,z);var J=new uf,W=new uf;this._mappings.unsortedForEach(function(H){if(H.source===z&&H.originalLine!=null){var Z=K.originalPositionFor({line:H.originalLine,column:H.originalColumn});if(Z.source!=null){if(H.source=Z.source,Y!=null)H.source=f4.join(Y,H.source);if(P!=null)H.source=f4.relative(P,H.source);if(H.originalLine=Z.line,H.originalColumn=Z.column,Z.name!=null)H.name=Z.name}}var O=H.source;if(O!=null&&!J.has(O))J.add(O);var w=H.name;if(w!=null&&!W.has(w))W.add(w)},this),this._sources=J,this._names=W,K.sources.forEach(function(H){var Z=K.sourceContentFor(H);if(Z!=null){if(Y!=null)H=f4.join(Y,H);if(P!=null)H=f4.relative(P,H);this.setSourceContent(H,Z)}},this)};j7.prototype._validateMapping=function $(K,q,Y,z){if(q&&typeof q.line!=="number"&&typeof q.column!=="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(K&&"line"in K&&"column"in K&&K.line>0&&K.column>=0&&!q&&!Y&&!z)return;else if(K&&"line"in K&&"column"in K&&q&&"line"in q&&"column"in q&&K.line>0&&K.column>=0&&q.line>0&&q.column>=0&&Y)return;else throw new Error("Invalid mapping: "+JSON.stringify({generated:K,source:Y,original:q,name:z}))};j7.prototype._serializeMappings=function $(){var K=0,q=1,Y=0,z=0,P=0,J=0,W="",H,Z,O,w,X=this._mappings.toArray();for(var T=0,G=X.length;T<G;T++){if(Z=X[T],H="",Z.generatedLine!==q){K=0;while(Z.generatedLine!==q)H+=";",q++}else if(T>0){if(!f4.compareByGeneratedPositionsInflated(Z,X[T-1]))continue;H+=","}if(H+=yX.encode(Z.generatedColumn-K),K=Z.generatedColumn,Z.source!=null){if(w=this._sources.indexOf(Z.source),H+=yX.encode(w-J),J=w,H+=yX.encode(Z.originalLine-1-z),z=Z.originalLine-1,H+=yX.encode(Z.originalColumn-Y),Y=Z.originalColumn,Z.name!=null)O=this._names.indexOf(Z.name),H+=yX.encode(O-P),P=O}W+=H}return W};j7.prototype._generateSourcesContent=function $(K,q){return K.map(function(Y){if(!this._sourcesContents)return null;if(q!=null)Y=f4.relative(q,Y);var z=f4.toSetString(Y);return Object.prototype.hasOwnProperty.call(this._sourcesContents,z)?this._sourcesContents[z]:null},this)};j7.prototype.toJSON=function $(){var K={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null)K.file=this._file;if(this._sourceRoot!=null)K.sourceRoot=this._sourceRoot;if(this._sourcesContents)K.sourcesContent=this._generateSourcesContent(K.sources,K.sourceRoot);return K};j7.prototype.toString=function $(){return JSON.stringify(this.toJSON())};j06.SourceMapGenerator=j7});var dZ8=j((G06)=>{G06.GREATEST_LOWER_BOUND=1;G06.LEAST_UPPER_BOUND=2;function Ob($,K,q,Y,z,P){var J=Math.floor((K-$)/2)+$,W=z(q,Y[J],!0);if(W===0)return J;else if(W>0){if(K-J>1)return Ob(J,K,q,Y,z,P);if(P==G06.LEAST_UPPER_BOUND)return K<Y.length?K:-1;else return J}else{if(J-$>1)return Ob($,J,q,Y,z,P);if(P==G06.LEAST_UPPER_BOUND)return J;else return $<0?-1:$}}G06.search=function $(K,q,Y,z){if(q.length===0)return-1;var P=Ob(-1,q.length,K,q,Y,z||G06.GREATEST_LOWER_BOUND);if(P<0)return-1;while(P-1>=0){if(Y(q[P],q[P-1],!0)!==0)break;--P}return P}});var nZ8=j((A06)=>{function Xb($,K,q){var Y=$[K];$[K]=$[q],$[q]=Y}function f06($,K){return Math.round($+Math.random()*(K-$))}function Tb($,K,q,Y){if(q<Y){var z=f06(q,Y),P=q-1;Xb($,z,Y);var J=$[Y];for(var W=q;W<Y;W++)if(K($[W],J)<=0)P+=1,Xb($,P,W);Xb($,P+1,W);var H=P+1;Tb($,K,q,H-1),Tb($,K,H+1,Y)}}A06.quickSort=function($,K){Tb($,K,0,$.length-1)}});var aZ8=j((M06)=>{var L8=fW(),jb=dZ8(),AW=Hb().ArraySet,k06=zb(),uX=nZ8().quickSort;function N1($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);return q.sections!=null?new P9(q,K):new q3(q,K)}N1.fromSourceMap=function($,K){return q3.fromSourceMap($,K)};N1.prototype._version=3;N1.prototype.__generatedMappings=null;Object.defineProperty(N1.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){if(!this.__generatedMappings)this._parseMappings(this._mappings,this.sourceRoot);return this.__generatedMappings}});N1.prototype.__originalMappings=null;Object.defineProperty(N1.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){if(!this.__originalMappings)this._parseMappings(this._mappings,this.sourceRoot);return this.__originalMappings}});N1.prototype._charIsMappingSeparator=function $(K,q){var Y=K.charAt(q);return Y===";"||Y===","};N1.prototype._parseMappings=function $(K,q){throw new Error("Subclasses must implement _parseMappings")};N1.GENERATED_ORDER=1;N1.ORIGINAL_ORDER=2;N1.GREATEST_LOWER_BOUND=1;N1.LEAST_UPPER_BOUND=2;N1.prototype.eachMapping=function $(K,q,Y){var z=q||null,P=Y||N1.GENERATED_ORDER,J;switch(P){case N1.GENERATED_ORDER:J=this._generatedMappings;break;case N1.ORIGINAL_ORDER:J=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var W=this.sourceRoot;J.map(function(H){var Z=H.source===null?null:this._sources.at(H.source);return Z=L8.computeSourceURL(W,Z,this._sourceMapURL),{source:Z,generatedLine:H.generatedLine,generatedColumn:H.generatedColumn,originalLine:H.originalLine,originalColumn:H.originalColumn,name:H.name===null?null:this._names.at(H.name)}},this).forEach(K,z)};N1.prototype.allGeneratedPositionsFor=function $(K){var q=L8.getArg(K,"line"),Y={source:L8.getArg(K,"source"),originalLine:q,originalColumn:L8.getArg(K,"column",0)};if(Y.source=this._findSourceIndex(Y.source),Y.source<0)return[];var z=[],P=this._findMapping(Y,this._originalMappings,"originalLine","originalColumn",L8.compareByOriginalPositions,jb.LEAST_UPPER_BOUND);if(P>=0){var J=this._originalMappings[P];if(K.column===void 0){var W=J.originalLine;while(J&&J.originalLine===W)z.push({line:L8.getArg(J,"generatedLine",null),column:L8.getArg(J,"generatedColumn",null),lastColumn:L8.getArg(J,"lastGeneratedColumn",null)}),J=this._originalMappings[++P]}else{var H=J.originalColumn;while(J&&J.originalLine===q&&J.originalColumn==H)z.push({line:L8.getArg(J,"generatedLine",null),column:L8.getArg(J,"generatedColumn",null),lastColumn:L8.getArg(J,"lastGeneratedColumn",null)}),J=this._originalMappings[++P]}}return z};M06.SourceMapConsumer=N1;function q3($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);var Y=L8.getArg(q,"version"),z=L8.getArg(q,"sources"),P=L8.getArg(q,"names",[]),J=L8.getArg(q,"sourceRoot",null),W=L8.getArg(q,"sourcesContent",null),H=L8.getArg(q,"mappings"),Z=L8.getArg(q,"file",null);if(Y!=this._version)throw new Error("Unsupported version: "+Y);if(J)J=L8.normalize(J);z=z.map(String).map(L8.normalize).map(function(O){return J&&L8.isAbsolute(J)&&L8.isAbsolute(O)?L8.relative(J,O):O}),this._names=AW.fromArray(P.map(String),!0),this._sources=AW.fromArray(z,!0),this._absoluteSources=this._sources.toArray().map(function(O){return L8.computeSourceURL(J,O,K)}),this.sourceRoot=J,this.sourcesContent=W,this._mappings=H,this._sourceMapURL=K,this.file=Z}q3.prototype=Object.create(N1.prototype);q3.prototype.consumer=N1;q3.prototype._findSourceIndex=function($){var K=$;if(this.sourceRoot!=null)K=L8.relative(this.sourceRoot,K);if(this._sources.has(K))return this._sources.indexOf(K);var q;for(q=0;q<this._absoluteSources.length;++q)if(this._absoluteSources[q]==$)return q;return-1};q3.fromSourceMap=function $(K,q){var Y=Object.create(q3.prototype),z=Y._names=AW.fromArray(K._names.toArray(),!0),P=Y._sources=AW.fromArray(K._sources.toArray(),!0);Y.sourceRoot=K._sourceRoot,Y.sourcesContent=K._generateSourcesContent(Y._sources.toArray(),Y.sourceRoot),Y.file=K._file,Y._sourceMapURL=q,Y._absoluteSources=Y._sources.toArray().map(function(T){return L8.computeSourceURL(Y.sourceRoot,T,q)});var J=K._mappings.toArray().slice(),W=Y.__generatedMappings=[],H=Y.__originalMappings=[];for(var Z=0,O=J.length;Z<O;Z++){var w=J[Z],X=new oZ8;if(X.generatedLine=w.generatedLine,X.generatedColumn=w.generatedColumn,w.source){if(X.source=P.indexOf(w.source),X.originalLine=w.originalLine,X.originalColumn=w.originalColumn,w.name)X.name=z.indexOf(w.name);H.push(X)}W.push(X)}return uX(Y.__originalMappings,L8.compareByOriginalPositions),Y};q3.prototype._version=3;Object.defineProperty(q3.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function oZ8(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}q3.prototype._parseMappings=function $(K,q){var Y=1,z=0,P=0,J=0,W=0,H=0,Z=K.length,O=0,w={},X={},T=[],G=[],v,f,A,C,V;while(O<Z)if(K.charAt(O)===";")Y++,O++,z=0;else if(K.charAt(O)===",")O++;else{v=new oZ8,v.generatedLine=Y;for(C=O;C<Z;C++)if(this._charIsMappingSeparator(K,C))break;if(f=K.slice(O,C),A=w[f],A)O+=f.length;else{A=[];while(O<C)k06.decode(K,O,X),V=X.value,O=X.rest,A.push(V);if(A.length===2)throw new Error("Found a source, but no line and column");if(A.length===3)throw new Error("Found a source and line, but no column");w[f]=A}if(v.generatedColumn=z+A[0],z=v.generatedColumn,A.length>1){if(v.source=W+A[1],W+=A[1],v.originalLine=P+A[2],P=v.originalLine,v.originalLine+=1,v.originalColumn=J+A[3],J=v.originalColumn,A.length>4)v.name=H+A[4],H+=A[4]}if(G.push(v),typeof v.originalLine==="number")T.push(v)}uX(G,L8.compareByGeneratedPositionsDeflated),this.__generatedMappings=G,uX(T,L8.compareByOriginalPositions),this.__originalMappings=T};q3.prototype._findMapping=function $(K,q,Y,z,P,J){if(K[Y]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+K[Y]);if(K[z]<0)throw new TypeError("Column must be greater than or equal to 0, got "+K[z]);return jb.search(K,q,P,J)};q3.prototype.computeColumnSpans=function $(){for(var K=0;K<this._generatedMappings.length;++K){var q=this._generatedMappings[K];if(K+1<this._generatedMappings.length){var Y=this._generatedMappings[K+1];if(q.generatedLine===Y.generatedLine){q.lastGeneratedColumn=Y.generatedColumn-1;continue}}q.lastGeneratedColumn=1/0}};q3.prototype.originalPositionFor=function $(K){var q={generatedLine:L8.getArg(K,"line"),generatedColumn:L8.getArg(K,"column")},Y=this._findMapping(q,this._generatedMappings,"generatedLine","generatedColumn",L8.compareByGeneratedPositionsDeflated,L8.getArg(K,"bias",N1.GREATEST_LOWER_BOUND));if(Y>=0){var z=this._generatedMappings[Y];if(z.generatedLine===q.generatedLine){var P=L8.getArg(z,"source",null);if(P!==null)P=this._sources.at(P),P=L8.computeSourceURL(this.sourceRoot,P,this._sourceMapURL);var J=L8.getArg(z,"name",null);if(J!==null)J=this._names.at(J);return{source:P,line:L8.getArg(z,"originalLine",null),column:L8.getArg(z,"originalColumn",null),name:J}}}return{source:null,line:null,column:null,name:null}};q3.prototype.hasContentsOfAllSources=function $(){if(!this.sourcesContent)return!1;return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(K){return K==null})};q3.prototype.sourceContentFor=function $(K,q){if(!this.sourcesContent)return null;var Y=this._findSourceIndex(K);if(Y>=0)return this.sourcesContent[Y];var z=K;if(this.sourceRoot!=null)z=L8.relative(this.sourceRoot,z);var P;if(this.sourceRoot!=null&&(P=L8.urlParse(this.sourceRoot))){var J=z.replace(/^file:\/\//,"");if(P.scheme=="file"&&this._sources.has(J))return this.sourcesContent[this._sources.indexOf(J)];if((!P.path||P.path=="/")&&this._sources.has("/"+z))return this.sourcesContent[this._sources.indexOf("/"+z)]}if(q)return null;else throw new Error('"'+z+'" is not in the SourceMap.')};q3.prototype.generatedPositionFor=function $(K){var q=L8.getArg(K,"source");if(q=this._findSourceIndex(q),q<0)return{line:null,column:null,lastColumn:null};var Y={source:q,originalLine:L8.getArg(K,"line"),originalColumn:L8.getArg(K,"column")},z=this._findMapping(Y,this._originalMappings,"originalLine","originalColumn",L8.compareByOriginalPositions,L8.getArg(K,"bias",N1.GREATEST_LOWER_BOUND));if(z>=0){var P=this._originalMappings[z];if(P.source===Y.source)return{line:L8.getArg(P,"generatedLine",null),column:L8.getArg(P,"generatedColumn",null),lastColumn:L8.getArg(P,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}};M06.BasicSourceMapConsumer=q3;function P9($,K){var q=$;if(typeof $==="string")q=L8.parseSourceMapInput($);var Y=L8.getArg(q,"version"),z=L8.getArg(q,"sections");if(Y!=this._version)throw new Error("Unsupported version: "+Y);this._sources=new AW,this._names=new AW;var P={line:-1,column:0};this._sections=z.map(function(J){if(J.url)throw new Error("Support for url field in sections not implemented.");var W=L8.getArg(J,"offset"),H=L8.getArg(W,"line"),Z=L8.getArg(W,"column");if(H<P.line||H===P.line&&Z<P.column)throw new Error("Section offsets must be ordered and non-overlapping.");return P=W,{generatedOffset:{generatedLine:H+1,generatedColumn:Z+1},consumer:new N1(L8.getArg(J,"map"),K)}})}P9.prototype=Object.create(N1.prototype);P9.prototype.constructor=N1;P9.prototype._version=3;Object.defineProperty(P9.prototype,"sources",{get:function(){var $=[];for(var K=0;K<this._sections.length;K++)for(var q=0;q<this._sections[K].consumer.sources.length;q++)$.push(this._sections[K].consumer.sources[q]);return $}});P9.prototype.originalPositionFor=function $(K){var q={generatedLine:L8.getArg(K,"line"),generatedColumn:L8.getArg(K,"column")},Y=jb.search(q,this._sections,function(P,J){var W=P.generatedLine-J.generatedOffset.generatedLine;if(W)return W;return P.generatedColumn-J.generatedOffset.generatedColumn}),z=this._sections[Y];if(!z)return{source:null,line:null,column:null,name:null};return z.consumer.originalPositionFor({line:q.generatedLine-(z.generatedOffset.generatedLine-1),column:q.generatedColumn-(z.generatedOffset.generatedLine===q.generatedLine?z.generatedOffset.generatedColumn-1:0),bias:K.bias})};P9.prototype.hasContentsOfAllSources=function $(){return this._sections.every(function(K){return K.consumer.hasContentsOfAllSources()})};P9.prototype.sourceContentFor=function $(K,q){for(var Y=0;Y<this._sections.length;Y++){var z=this._sections[Y],P=z.consumer.sourceContentFor(K,!0);if(P)return P}if(q)return null;else throw new Error('"'+K+'" is not in the SourceMap.')};P9.prototype.generatedPositionFor=function $(K){for(var q=0;q<this._sections.length;q++){var Y=this._sections[q];if(Y.consumer._findSourceIndex(L8.getArg(K,"source"))===-1)continue;var z=Y.consumer.generatedPositionFor(K);if(z){var P={line:z.line+(Y.generatedOffset.generatedLine-1),column:z.column+(Y.generatedOffset.generatedLine===z.line?Y.generatedOffset.generatedColumn-1:0)};return P}}return{line:null,column:null}};P9.prototype._parseMappings=function $(K,q){this.__generatedMappings=[],this.__originalMappings=[];for(var Y=0;Y<this._sections.length;Y++){var z=this._sections[Y],P=z.consumer._generatedMappings;for(var J=0;J<P.length;J++){var W=P[J],H=z.consumer._sources.at(W.source);H=L8.computeSourceURL(z.consumer.sourceRoot,H,this._sourceMapURL),this._sources.add(H),H=this._sources.indexOf(H);var Z=null;if(W.name)Z=z.consumer._names.at(W.name),this._names.add(Z),Z=this._names.indexOf(Z);var O={source:H,generatedLine:W.generatedLine+(z.generatedOffset.generatedLine-1),generatedColumn:W.generatedColumn+(z.generatedOffset.generatedLine===W.generatedLine?z.generatedOffset.generatedColumn-1:0),originalLine:W.originalLine,originalColumn:W.originalColumn,name:Z};if(this.__generatedMappings.push(O),typeof O.originalLine==="number")this.__originalMappings.push(O)}}uX(this.__generatedMappings,L8.compareByGeneratedPositionsDeflated),uX(this.__originalMappings,L8.compareByOriginalPositions)};M06.IndexedSourceMapConsumer=P9});var rZ8=j((E06)=>{var R06=Zb().SourceMapGenerator,mf=fW(),D06=/(\r?\n)/,S06=10,VW="$$$isSourceNode$$$";function Q$($,K,q,Y,z){if(this.children=[],this.sourceContents={},this.line=$==null?null:$,this.column=K==null?null:K,this.source=q==null?null:q,this.name=z==null?null:z,this[VW]=!0,Y!=null)this.add(Y)}Q$.fromStringWithSourceMap=function $(K,q,Y){var z=new Q$,P=K.split(D06),J=0,W=function(){var X=G(),T=G()||"";return X+T;function G(){return J<P.length?P[J++]:void 0}},H=1,Z=0,O=null;if(q.eachMapping(function(X){if(O!==null)if(H<X.generatedLine)w(O,W()),H++,Z=0;else{var T=P[J]||"",G=T.substr(0,X.generatedColumn-Z);P[J]=T.substr(X.generatedColumn-Z),Z=X.generatedColumn,w(O,G),O=X;return}while(H<X.generatedLine)z.add(W()),H++;if(Z<X.generatedColumn){var T=P[J]||"";z.add(T.substr(0,X.generatedColumn)),P[J]=T.substr(X.generatedColumn),Z=X.generatedColumn}O=X},this),J<P.length){if(O)w(O,W());z.add(P.splice(J).join(""))}return q.sources.forEach(function(X){var T=q.sourceContentFor(X);if(T!=null){if(Y!=null)X=mf.join(Y,X);z.setSourceContent(X,T)}}),z;function w(X,T){if(X===null||X.source===void 0)z.add(T);else{var G=Y?mf.join(Y,X.source):X.source;z.add(new Q$(X.originalLine,X.originalColumn,G,T,X.name))}}};Q$.prototype.add=function $(K){if(Array.isArray(K))K.forEach(function(q){this.add(q)},this);else if(K[VW]||typeof K==="string"){if(K)this.children.push(K)}else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+K);return this};Q$.prototype.prepend=function $(K){if(Array.isArray(K))for(var q=K.length-1;q>=0;q--)this.prepend(K[q]);else if(K[VW]||typeof K==="string")this.children.unshift(K);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+K);return this};Q$.prototype.walk=function $(K){var q;for(var Y=0,z=this.children.length;Y<z;Y++)if(q=this.children[Y],q[VW])q.walk(K);else if(q!=="")K(q,{source:this.source,line:this.line,column:this.column,name:this.name})};Q$.prototype.join=function $(K){var q,Y,z=this.children.length;if(z>0){q=[];for(Y=0;Y<z-1;Y++)q.push(this.children[Y]),q.push(K);q.push(this.children[Y]),this.children=q}return this};Q$.prototype.replaceRight=function $(K,q){var Y=this.children[this.children.length-1];if(Y[VW])Y.replaceRight(K,q);else if(typeof Y==="string")this.children[this.children.length-1]=Y.replace(K,q);else this.children.push("".replace(K,q));return this};Q$.prototype.setSourceContent=function $(K,q){this.sourceContents[mf.toSetString(K)]=q};Q$.prototype.walkSourceContents=function $(K){for(var q=0,Y=this.children.length;q<Y;q++)if(this.children[q][VW])this.children[q].walkSourceContents(K);var z=Object.keys(this.sourceContents);for(var q=0,Y=z.length;q<Y;q++)K(mf.fromSetString(z[q]),this.sourceContents[z[q]])};Q$.prototype.toString=function $(){var K="";return this.walk(function(q){K+=q}),K};Q$.prototype.toStringWithSourceMap=function $(K){var q={code:"",line:1,column:0},Y=new R06(K),z=!1,P=null,J=null,W=null,H=null;return this.walk(function(Z,O){if(q.code+=Z,O.source!==null&&O.line!==null&&O.column!==null){if(P!==O.source||J!==O.line||W!==O.column||H!==O.name)Y.addMapping({source:O.source,original:{line:O.line,column:O.column},generated:{line:q.line,column:q.column},name:O.name});P=O.source,J=O.line,W=O.column,H=O.name,z=!0}else if(z)Y.addMapping({generated:{line:q.line,column:q.column}}),P=null,z=!1;for(var w=0,X=Z.length;w<X;w++)if(Z.charCodeAt(w)===S06){if(q.line++,q.column=0,w+1===X)P=null,z=!1;else if(z)Y.addMapping({source:O.source,original:{line:O.line,column:O.column},generated:{line:q.line,column:q.column},name:O.name})}else q.column++}),this.walkSourceContents(function(Z,O){Y.setSourceContent(Z,O)}),{code:q.code,map:Y}};E06.SourceNode=Q$});var sZ8=j((I06)=>{I06.SourceMapGenerator=Zb().SourceMapGenerator;I06.SourceMapConsumer=aZ8().SourceMapConsumer;I06.SourceNode=rZ8().SourceNode});var KO8=j((eZ8,$O8)=>{eZ8.__esModule=!0;var Gb=o3(),oz=void 0;try{if(typeof define!=="function"||!define.amd)_b=sZ8(),oz=_b.SourceNode}catch($){}var _b;if(!oz)oz=function($,K,q,Y){if(this.src="",Y)this.add(Y)},oz.prototype={add:function $(K){if(Gb.isArray(K))K=K.join("");this.src+=K},prepend:function $(K){if(Gb.isArray(K))K=K.join("");this.src=K+this.src},toStringWithSourceMap:function $(){return{code:this.toString()}},toString:function $(){return this.src}};function vb($,K,q){if(Gb.isArray($)){var Y=[];for(var z=0,P=$.length;z<P;z++)Y.push(K.wrap($[z],q));return Y}else if(typeof $==="boolean"||typeof $==="number")return $+"";return $}function tZ8($){this.srcFile=$,this.source=[]}tZ8.prototype={isEmpty:function $(){return!this.source.length},prepend:function $(K,q){this.source.unshift(this.wrap(K,q))},push:function $(K,q){this.source.push(this.wrap(K,q))},merge:function $(){var K=this.empty();return this.each(function(q){K.add([" ",q,`
|
|
388
388
|
`])}),K},each:function $(K){for(var q=0,Y=this.source.length;q<Y;q++)K(this.source[q])},empty:function $(){var K=this.currentLocation||{start:{}};return new oz(K.start.line,K.start.column,this.srcFile)},wrap:function $(K){var q=arguments.length<=1||arguments[1]===void 0?this.currentLocation||{start:{}}:arguments[1];if(K instanceof oz)return K;return K=vb(K,this,q),new oz(q.start.line,q.start.column,this.srcFile,K)},functionCall:function $(K,q,Y){return Y=this.generateList(Y),this.wrap([K,q?"."+q+"(":"(",Y,")"])},quotedString:function $(K){return'"'+(K+"").replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+'"'},objectLiteral:function $(K){var q=this,Y=[];Object.keys(K).forEach(function(P){var J=vb(K[P],q);if(J!=="undefined")Y.push([q.quotedString(P),":",J])});var z=this.generateList(Y);return z.prepend("{"),z.add("}"),z},generateList:function $(K){var q=this.empty();for(var Y=0,z=K.length;Y<z;Y++){if(Y)q.add(",");q.add(vb(K[Y],this))}return q},generateArray:function $(K){var q=this.generateList(K);return q.prepend("["),q.add("]"),q}};eZ8.default=tZ8;$O8.exports=eZ8.default});var WO8=j((PO8,JO8)=>{PO8.__esModule=!0;function zO8($){return $&&$.__esModule?$:{default:$}}var qO8=Ef(),m06=T7(),fb=zO8(m06),p06=o3(),c06=KO8(),YO8=zO8(c06);function kW($){this.value=$}function MW(){}MW.prototype={nameLookup:function $(K,q){return this.internalNameLookup(K,q)},depthedLookup:function $(K){return[this.aliasable("container.lookup"),"(depths, ",JSON.stringify(K),")"]},compilerInfo:function $(){var K=qO8.COMPILER_REVISION,q=qO8.REVISION_CHANGES[K];return[K,q]},appendToBuffer:function $(K,q,Y){if(!p06.isArray(K))K=[K];if(K=this.source.wrap(K,q),this.environment.isSimple)return["return ",K,";"];else if(Y)return["buffer += ",K,";"];else return K.appendToBuffer=!0,K},initializeBuffer:function $(){return this.quotedString("")},internalNameLookup:function $(K,q){return this.lookupPropertyFunctionIsUsed=!0,["lookupProperty(",K,",",JSON.stringify(q),")"]},lookupPropertyFunctionIsUsed:!1,compile:function $(K,q,Y,z){this.environment=K,this.options=q,this.stringParams=this.options.stringParams,this.trackIds=this.options.trackIds,this.precompile=!z,this.name=this.environment.name,this.isChild=!!Y,this.context=Y||{decorators:[],programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(K,q),this.useDepths=this.useDepths||K.useDepths||K.useDecorators||this.options.compat,this.useBlockParams=this.useBlockParams||K.useBlockParams;var P=K.opcodes,J=void 0,W=void 0,H=void 0,Z=void 0;for(H=0,Z=P.length;H<Z;H++)J=P[H],this.source.currentLocation=J.loc,W=W||J.loc,this[J.opcode].apply(this,J.args);if(this.source.currentLocation=W,this.pushSource(""),this.stackSlot||this.inlineStack.length||this.compileStack.length)throw new fb.default("Compile completed with content left on stack");if(!this.decorators.isEmpty())if(this.useDecorators=!0,this.decorators.prepend(["var decorators = container.decorators, ",this.lookupPropertyFunctionVarDeclaration(),`;
|
|
389
389
|
`]),this.decorators.push("return fn;"),z)this.decorators=Function.apply(this,["fn","props","container","depth0","data","blockParams","depths",this.decorators.merge()]);else this.decorators.prepend(`function(fn, props, container, depth0, data, blockParams, depths) {
|
|
390
390
|
`),this.decorators.push(`}
|
|
@@ -401,11 +401,11 @@ Expecting `+X8.join(", ")+", got '"+(this.terminals_[M]||M)+"'";else N8="Parse e
|
|
|
401
401
|
`,K};Y4.prototype.Program=function($){var K="",q=$.body,Y=void 0,z=void 0;if($.blockParams){var P="BLOCK PARAMS: [";for(Y=0,z=$.blockParams.length;Y<z;Y++)P+=" "+$.blockParams[Y];P+=" ]",K+=this.pad(P)}for(Y=0,z=q.length;Y<z;Y++)K+=this.accept(q[Y]);return this.padding--,K};Y4.prototype.MustacheStatement=function($){return this.pad("{{ "+this.SubExpression($)+" }}")};Y4.prototype.Decorator=function($){return this.pad("{{ DIRECTIVE "+this.SubExpression($)+" }}")};Y4.prototype.BlockStatement=Y4.prototype.DecoratorBlock=function($){var K="";if(K+=this.pad(($.type==="DecoratorBlock"?"DIRECTIVE ":"")+"BLOCK:"),this.padding++,K+=this.pad(this.SubExpression($)),$.program)K+=this.pad("PROGRAM:"),this.padding++,K+=this.accept($.program),this.padding--;if($.inverse){if($.program)this.padding++;if(K+=this.pad("{{^}}"),this.padding++,K+=this.accept($.inverse),this.padding--,$.program)this.padding--}return this.padding--,K};Y4.prototype.PartialStatement=function($){var K="PARTIAL:"+$.name.original;if($.params[0])K+=" "+this.accept($.params[0]);if($.hash)K+=" "+this.accept($.hash);return this.pad("{{> "+K+" }}")};Y4.prototype.PartialBlockStatement=function($){var K="PARTIAL BLOCK:"+$.name.original;if($.params[0])K+=" "+this.accept($.params[0]);if($.hash)K+=" "+this.accept($.hash);return K+=" "+this.pad("PROGRAM:"),this.padding++,K+=this.accept($.program),this.padding--,this.pad("{{> "+K+" }}")};Y4.prototype.ContentStatement=function($){return this.pad("CONTENT[ '"+$.value+"' ]")};Y4.prototype.CommentStatement=function($){return this.pad("{{! '"+$.value+"' }}")};Y4.prototype.SubExpression=function($){var K=$.params,q=[],Y=void 0;for(var z=0,P=K.length;z<P;z++)q.push(this.accept(K[z]));return K="["+q.join(", ")+"]",Y=$.hash?" "+this.accept($.hash):"",this.accept($.path)+" "+K+Y};Y4.prototype.PathExpression=function($){var K=$.parts.join("/");return($.data?"@":"")+"PATH:"+K};Y4.prototype.StringLiteral=function($){return'"'+$.value+'"'};Y4.prototype.NumberLiteral=function($){return"NUMBER{"+$.value+"}"};Y4.prototype.BooleanLiteral=function($){return"BOOLEAN{"+$.value+"}"};Y4.prototype.UndefinedLiteral=function(){return"UNDEFINED"};Y4.prototype.NullLiteral=function(){return"NULL"};Y4.prototype.Hash=function($){var K=$.pairs,q=[];for(var Y=0,z=K.length;Y<z;Y++)q.push(this.accept(K[Y]));return"HASH{"+q.join(", ")+"}"};Y4.prototype.HashPair=function($){return $.key+"="+this.accept($.value)}});var kb=j((xu1,vO8)=>{var pf=wO8().default,jO8=XO8();pf.PrintVisitor=jO8.PrintVisitor;pf.print=jO8.print;vO8.exports=pf;function TO8($,K){var q=F("fs"),Y=q.readFileSync(K,"utf8");$.exports=pf.compile(Y)}if(F.extensions)F.extensions[".handlebars"]=TO8,F.extensions[".hbs"]=TO8});var NO8=j((du1,MO8)=>{var f_6=typeof process==="object"&&process&&process.platform==="win32";MO8.exports=f_6?{sep:"\\"}:{sep:"/"}});var SO8=j((nu1,DO8)=>{DO8.exports=CO8;function CO8($,K,q){if($ instanceof RegExp)$=hO8($,q);if(K instanceof RegExp)K=hO8(K,q);var Y=RO8($,K,q);return Y&&{start:Y[0],end:Y[1],pre:q.slice(0,Y[0]),body:q.slice(Y[0]+$.length,Y[1]),post:q.slice(Y[1]+K.length)}}function hO8($,K){var q=K.match($);return q?q[0]:null}CO8.range=RO8;function RO8($,K,q){var Y,z,P,J,W,H=q.indexOf($),Z=q.indexOf(K,H+1),O=H;if(H>=0&&Z>0){if($===K)return[H,Z];Y=[],P=q.length;while(O>=0&&!W){if(O==H)Y.push(O),H=q.indexOf($,O+1);else if(Y.length==1)W=[Y.pop(),Z];else{if(z=Y.pop(),z<P)P=z,J=Z;Z=q.indexOf(K,O+1)}O=H<Z&&H>=0?H:Z}if(Y.length)W=[P,J]}return W}});var Rb=j((ou1,yO8)=>{var EO8=SO8();yO8.exports=k_6;var LO8="\x00SLASH"+Math.random()+"\x00",IO8="\x00OPEN"+Math.random()+"\x00",Cb="\x00CLOSE"+Math.random()+"\x00",xO8="\x00COMMA"+Math.random()+"\x00",bO8="\x00PERIOD"+Math.random()+"\x00";function hb($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function A_6($){return $.split("\\\\").join(LO8).split("\\{").join(IO8).split("\\}").join(Cb).split("\\,").join(xO8).split("\\.").join(bO8)}function V_6($){return $.split(LO8).join("\\").split(IO8).join("{").split(Cb).join("}").split(xO8).join(",").split(bO8).join(".")}function gO8($){if(!$)return[""];var K=[],q=EO8("{","}",$);if(!q)return $.split(",");var{pre:Y,body:z,post:P}=q,J=Y.split(",");J[J.length-1]+="{"+z+"}";var W=gO8(P);if(P.length)J[J.length-1]+=W.shift(),J.push.apply(J,W);return K.push.apply(K,J),K}function k_6($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return cX(A_6($),!0).map(V_6)}function M_6($){return"{"+$+"}"}function N_6($){return/^-?0\d/.test($)}function h_6($,K){return $<=K}function C_6($,K){return $>=K}function cX($,K){var q=[],Y=EO8("{","}",$);if(!Y)return[$];var z=Y.pre,P=Y.post.length?cX(Y.post,!1):[""];if(/\$$/.test(Y.pre))for(var J=0;J<P.length;J++){var W=z+"{"+Y.body+"}"+P[J];q.push(W)}else{var H=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(Y.body),Z=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(Y.body),O=H||Z,w=Y.body.indexOf(",")>=0;if(!O&&!w){if(Y.post.match(/,(?!,).*\}/))return $=Y.pre+"{"+Y.body+Cb+Y.post,cX($);return[$]}var X;if(O)X=Y.body.split(/\.\./);else if(X=gO8(Y.body),X.length===1){if(X=cX(X[0],!1).map(M_6),X.length===1)return P.map(function(h){return Y.pre+X[0]+h})}var T;if(O){var G=hb(X[0]),v=hb(X[1]),f=Math.max(X[0].length,X[1].length),A=X.length==3?Math.abs(hb(X[2])):1,C=h_6,V=v<G;if(V)A*=-1,C=C_6;var M=X.some(N_6);T=[];for(var R=G;C(R,v);R+=A){var I;if(Z){if(I=String.fromCharCode(R),I==="\\")I=""}else if(I=String(R),M){var D=f-I.length;if(D>0){var m=new Array(D+1).join("0");if(R<0)I="-"+m+I.slice(1);else I=m+I}}T.push(I)}}else{T=[];for(var b=0;b<X.length;b++)T.push.apply(T,cX(X[b],!1))}for(var b=0;b<T.length;b++)for(var J=0;J<P.length;J++){var W=z+T[b]+P[J];if(!K||O||W)q.push(W)}}return q}});var UO8=j((au1,Ib)=>{var d$=Ib.exports=($,K,q={})=>{if(Uf(K),!q.nocomment&&K.charAt(0)==="#")return!1;return new BX(K,q).match($)};Ib.exports=d$;var Eb=NO8();d$.sep=Eb.sep;var J9=Symbol("globstar **");d$.GLOBSTAR=J9;var R_6=Rb(),uO8={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},Lb="[^/]",Db=Lb+"*?",D_6="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",S_6="(?:(?!(?:\\/|^)\\.).)*?",cO8=($)=>$.split("").reduce((K,q)=>{return K[q]=!0,K},{}),mO8=cO8("().*{}+?[]^$\\!"),E_6=cO8("[.("),pO8=/\/+/;d$.filter=($,K={})=>(q,Y,z)=>d$(q,$,K);var aq=($,K={})=>{let q={};return Object.keys($).forEach((Y)=>q[Y]=$[Y]),Object.keys(K).forEach((Y)=>q[Y]=K[Y]),q};d$.defaults=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return d$;let K=d$,q=(Y,z,P)=>K(Y,z,aq($,P));return q.Minimatch=class Y extends K.Minimatch{constructor(z,P){super(z,aq($,P))}},q.Minimatch.defaults=(Y)=>K.defaults(aq($,Y)).Minimatch,q.filter=(Y,z)=>K.filter(Y,aq($,z)),q.defaults=(Y)=>K.defaults(aq($,Y)),q.makeRe=(Y,z)=>K.makeRe(Y,aq($,z)),q.braceExpand=(Y,z)=>K.braceExpand(Y,aq($,z)),q.match=(Y,z,P)=>K.match(Y,z,aq($,P)),q};d$.braceExpand=($,K)=>BO8($,K);var BO8=($,K={})=>{if(Uf($),K.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return R_6($)},L_6=65536,Uf=($)=>{if(typeof $!=="string")throw new TypeError("invalid pattern");if($.length>L_6)throw new TypeError("pattern is too long")},Sb=Symbol("subparse");d$.makeRe=($,K)=>new BX($,K||{}).makeRe();d$.match=($,K,q={})=>{let Y=new BX(K,q);if($=$.filter((z)=>Y.match(z)),Y.options.nonull&&!$.length)$.push(K);return $};var I_6=($)=>$.replace(/\\(.)/g,"$1"),x_6=($)=>$.replace(/\\([^-\]])/g,"$1"),b_6=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),g_6=($)=>$.replace(/[[\]\\]/g,"\\$&");class BX{constructor($,K){if(Uf($),!K)K={};if(this.options=K,this.set=[],this.pattern=$,this.windowsPathsNoEscape=!!K.windowsPathsNoEscape||K.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!K.partial,this.make()}debug(){}make(){let $=this.pattern,K=this.options;if(!K.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}this.parseNegate();let q=this.globSet=this.braceExpand();if(K.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,q),q=this.globParts=q.map((Y)=>Y.split(pO8)),this.debug(this.pattern,q),q=q.map((Y,z,P)=>Y.map(this.parse,this)),this.debug(this.pattern,q),q=q.filter((Y)=>Y.indexOf(!1)===-1),this.debug(this.pattern,q),this.set=q}parseNegate(){if(this.options.nonegate)return;let $=this.pattern,K=!1,q=0;for(let Y=0;Y<$.length&&$.charAt(Y)==="!";Y++)K=!K,q++;if(q)this.pattern=$.slice(q);this.negate=K}matchOne($,K,q){var Y=this.options;this.debug("matchOne",{this:this,file:$,pattern:K}),this.debug("matchOne",$.length,K.length);for(var z=0,P=0,J=$.length,W=K.length;z<J&&P<W;z++,P++){this.debug("matchOne loop");var H=K[P],Z=$[z];if(this.debug(K,H,Z),H===!1)return!1;if(H===J9){this.debug("GLOBSTAR",[K,H,Z]);var O=z,w=P+1;if(w===W){this.debug("** at the end");for(;z<J;z++)if($[z]==="."||$[z]===".."||!Y.dot&&$[z].charAt(0)===".")return!1;return!0}while(O<J){var X=$[O];if(this.debug(`
|
|
402
402
|
globstar while`,$,O,K,w,X),this.matchOne($.slice(O),K.slice(w),q))return this.debug("globstar found match!",O,J,X),!0;else{if(X==="."||X===".."||!Y.dot&&X.charAt(0)==="."){this.debug("dot detected!",$,O,K,w);break}this.debug("globstar swallow a segment, and continue"),O++}}if(q){if(this.debug(`
|
|
403
403
|
>>> no match, partial?`,$,O,K,w),O===J)return!0}return!1}var T;if(typeof H==="string")T=Z===H,this.debug("string match",H,Z,T);else T=Z.match(H),this.debug("pattern match",H,Z,T);if(!T)return!1}if(z===J&&P===W)return!0;else if(z===J)return q;else if(P===W)return z===J-1&&$[z]==="";throw new Error("wtf?")}braceExpand(){return BO8(this.pattern,this.options)}parse($,K){Uf($);let q=this.options;if($==="**")if(!q.noglobstar)return J9;else $="*";if($==="")return"";let Y="",z=!1,P=!1,J=[],W=[],H,Z=!1,O=-1,w=-1,X,T,G,v=$.charAt(0)===".",f=q.dot||v,A=()=>v?"":f?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",C=(I)=>I.charAt(0)==="."?"":q.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",V=()=>{if(H){switch(H){case"*":Y+=Db,z=!0;break;case"?":Y+=Lb,z=!0;break;default:Y+="\\"+H;break}this.debug("clearStateChar %j %j",H,Y),H=!1}};for(let I=0,D;I<$.length&&(D=$.charAt(I));I++){if(this.debug("%s %s %s %j",$,I,Y,D),P){if(D==="/")return!1;if(mO8[D])Y+="\\";Y+=D,P=!1;continue}switch(D){case"/":return!1;case"\\":if(Z&&$.charAt(I+1)==="-"){Y+=D;continue}V(),P=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",$,I,Y,D),Z){if(this.debug(" in class"),D==="!"&&I===w+1)D="^";Y+=D;continue}if(this.debug("call clearStateChar %j",H),V(),H=D,q.noext)V();continue;case"(":{if(Z){Y+="(";continue}if(!H){Y+="\\(";continue}let m={type:H,start:I-1,reStart:Y.length,open:uO8[H].open,close:uO8[H].close};if(this.debug(this.pattern,"\t",m),J.push(m),Y+=m.open,m.start===0&&m.type!=="!")v=!0,Y+=C($.slice(I+1));this.debug("plType %j %j",H,Y),H=!1;continue}case")":{let m=J[J.length-1];if(Z||!m){Y+="\\)";continue}if(J.pop(),V(),z=!0,T=m,Y+=T.close,T.type==="!")W.push(Object.assign(T,{reEnd:Y.length}));continue}case"|":{let m=J[J.length-1];if(Z||!m){Y+="\\|";continue}if(V(),Y+="|",m.start===0&&m.type!=="!")v=!0,Y+=C($.slice(I+1));continue}case"[":if(V(),Z){Y+="\\"+D;continue}Z=!0,w=I,O=Y.length,Y+=D;continue;case"]":if(I===w+1||!Z){Y+="\\"+D;continue}X=$.substring(w+1,I);try{RegExp("["+g_6(x_6(X))+"]"),Y+=D}catch(m){Y=Y.substring(0,O)+"(?:$.)"}z=!0,Z=!1;continue;default:if(V(),mO8[D]&&!(D==="^"&&Z))Y+="\\";Y+=D;break}}if(Z)X=$.slice(w+1),G=this.parse(X,Sb),Y=Y.substring(0,O)+"\\["+G[0],z=z||G[1];for(T=J.pop();T;T=J.pop()){let I;I=Y.slice(T.reStart+T.open.length),this.debug("setting tail",Y,T),I=I.replace(/((?:\\{2}){0,64})(\\?)\|/g,(m,b,h)=>{if(!h)h="\\";return b+b+h+"|"}),this.debug(`tail=%j
|
|
404
|
-
%s`,I,I,T,Y);let D=T.type==="*"?Db:T.type==="?"?Lb:"\\"+T.type;z=!0,Y=Y.slice(0,T.reStart)+D+"\\("+I}if(V(),P)Y+="\\\\";let M=E_6[Y.charAt(0)];for(let I=W.length-1;I>-1;I--){let D=W[I],m=Y.slice(0,D.reStart),b=Y.slice(D.reStart,D.reEnd-8),h=Y.slice(D.reEnd),L=Y.slice(D.reEnd-8,D.reEnd)+h,B=m.split(")").length,i=m.split("(").length-B,X8=h;for(let h8=0;h8<i;h8++)X8=X8.replace(/\)[+*?]?/,"");h=X8;let N8=h===""&&K!==Sb?"(?:$|\\/)":"";Y=m+b+h+N8+L}if(Y!==""&&z)Y="(?=.)"+Y;if(M)Y=A()+Y;if(K===Sb)return[Y,z];if(q.nocase&&!z)z=$.toUpperCase()!==$.toLowerCase();if(!z)return I_6($);let R=q.nocase?"i":"";try{return Object.assign(new RegExp("^"+Y+"$",R),{_glob:$,_src:Y})}catch(I){return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let K=this.options,q=K.noglobstar?Db:K.dot?D_6:S_6,Y=K.nocase?"i":"",z=$.map((P)=>{return P=P.map((J)=>typeof J==="string"?b_6(J):J===J9?J9:J._src).reduce((J,W)=>{if(!(J[J.length-1]===J9&&W===J9))J.push(W);return J},[]),P.forEach((J,W)=>{if(J!==J9||P[W-1]===J9)return;if(W===0)if(P.length>1)P[W+1]="(?:\\/|"+q+"\\/)?"+P[W+1];else P[W]=q;else if(W===P.length-1)P[W-1]+="(?:\\/|"+q+")?";else P[W-1]+="(?:\\/|\\/"+q+"\\/)"+P[W+1],P[W+1]=J9}),P.filter((J)=>J!==J9).join("/")}).join("|");if(z="^(?:"+z+")$",this.negate)z="^(?!"+z+").*$";try{this.regexp=new RegExp(z,Y)}catch(P){this.regexp=!1}return this.regexp}match($,K=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&K)return!0;let q=this.options;if(Eb.sep!=="/")$=$.split(Eb.sep).join("/");$=$.split(pO8),this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let z;for(let P=$.length-1;P>=0;P--)if(z=$[P],z)break;for(let P=0;P<Y.length;P++){let J=Y[P],W=$;if(q.matchBase&&J.length===1)W=[z];if(this.matchOne(W,J,K)){if(q.flipNegate)return!0;return!this.negate}}if(q.flipNegate)return!1;return this.negate}static defaults($){return d$.defaults($).Minimatch}}d$.Minimatch=BX});var dO8=j((ru1,QO8)=>{QO8.exports=iO8;var bb=F("fs"),{EventEmitter:y_6}=F("events"),{Minimatch:xb}=UO8(),{resolve:u_6}=F("path");function m_6($,K){return new Promise((q,Y)=>{bb.readdir($,{withFileTypes:!0},(z,P)=>{if(z)switch(z.code){case"ENOTDIR":if(K)Y(z);else q([]);break;case"ENOTSUP":case"ENOENT":case"ENAMETOOLONG":case"UNKNOWN":q([]);break;case"ELOOP":default:Y(z);break}else q(P)})})}function lO8($,K){return new Promise((q,Y)=>{(K?bb.stat:bb.lstat)($,(P,J)=>{if(P)switch(P.code){case"ENOENT":if(K)q(lO8($,!1));else q(null);break;default:q(null);break}else q(J)})})}async function*FO8($,K,q,Y,z,P){let J=await m_6(K+$,P);for(let W of J){let H=W.name;if(H===void 0)H=W,Y=!0;let Z=$+"/"+H,O=Z.slice(1),w=K+"/"+O,X=null;if(Y||q)X=await lO8(w,q);if(!X&&W.name!==void 0)X=W;if(X===null)X={isDirectory:()=>!1};if(X.isDirectory()){if(!z(O))yield{relative:O,absolute:w,stats:X},yield*FO8(Z,K,q,Y,z,!1)}else yield{relative:O,absolute:w,stats:X}}}async function*p_6($,K,q,Y){yield*FO8("",$,K,q,Y,!0)}function c_6($){return{pattern:$.pattern,dot:!!$.dot,noglobstar:!!$.noglobstar,matchBase:!!$.matchBase,nocase:!!$.nocase,ignore:$.ignore,skip:$.skip,follow:!!$.follow,stat:!!$.stat,nodir:!!$.nodir,mark:!!$.mark,silent:!!$.silent,absolute:!!$.absolute}}class gb extends y_6{constructor($,K,q){super();if(typeof K==="function")q=K,K=null;if(this.options=c_6(K||{}),this.matchers=[],this.options.pattern){let Y=Array.isArray(this.options.pattern)?this.options.pattern:[this.options.pattern];this.matchers=Y.map((z)=>new xb(z,{dot:this.options.dot,noglobstar:this.options.noglobstar,matchBase:this.options.matchBase,nocase:this.options.nocase}))}if(this.ignoreMatchers=[],this.options.ignore){let Y=Array.isArray(this.options.ignore)?this.options.ignore:[this.options.ignore];this.ignoreMatchers=Y.map((z)=>new xb(z,{dot:!0}))}if(this.skipMatchers=[],this.options.skip){let Y=Array.isArray(this.options.skip)?this.options.skip:[this.options.skip];this.skipMatchers=Y.map((z)=>new xb(z,{dot:!0}))}if(this.iterator=p_6(u_6($||"."),this.options.follow,this.options.stat,this._shouldSkipDirectory.bind(this)),this.paused=!1,this.inactive=!1,this.aborted=!1,q)this._matches=[],this.on("match",(Y)=>this._matches.push(this.options.absolute?Y.absolute:Y.relative)),this.on("error",(Y)=>q(Y)),this.on("end",()=>q(null,this._matches));setTimeout(()=>this._next(),0)}_shouldSkipDirectory($){return this.skipMatchers.some((K)=>K.match($))}_fileMatches($,K){let q=$+(K?"/":"");return(this.matchers.length===0||this.matchers.some((Y)=>Y.match(q)))&&!this.ignoreMatchers.some((Y)=>Y.match(q))&&(!this.options.nodir||!K)}_next(){if(!this.paused&&!this.aborted)this.iterator.next().then(($)=>{if(!$.done){let K=$.value.stats.isDirectory();if(this._fileMatches($.value.relative,K)){let q=$.value.relative,Y=$.value.absolute;if(this.options.mark&&K)q+="/",Y+="/";if(this.options.stat)this.emit("match",{relative:q,absolute:Y,stat:$.value.stats});else this.emit("match",{relative:q,absolute:Y})}this._next(this.iterator)}else this.emit("end")}).catch(($)=>{if(this.abort(),this.emit("error",$),!$.code&&!this.options.silent)console.error($)});else this.inactive=!0}abort(){this.aborted=!0}pause(){this.paused=!0}resume(){if(this.paused=!1,this.inactive)this.inactive=!1,this._next()}}function iO8($,K,q){return new gb($,K,q)}iO8.ReaddirGlob=gb});var oO8=j((lf,nO8)=>{(function($,K){typeof lf==="object"&&typeof nO8!=="undefined"?K(lf):typeof define==="function"&&define.amd?define(["exports"],K):($=typeof globalThis!=="undefined"?globalThis:$||self,K($.async={}))})(lf,function($){function K(S,...x){return(...g)=>S(...x,...g)}function q(S){return function(...x){var g=x.pop();return S.call(this,x,g)}}var Y=typeof queueMicrotask==="function"&&queueMicrotask,z=typeof setImmediate==="function"&&setImmediate,P=typeof process==="object"&&typeof process.nextTick==="function";function J(S){setTimeout(S,0)}function W(S){return(x,...g)=>S(()=>x(...g))}var H;if(Y)H=queueMicrotask;else if(z)H=setImmediate;else if(P)H=process.nextTick;else H=J;var Z=W(H);function O(S){if(T(S))return function(...x){let g=x.pop(),l=S.apply(this,x);return w(l,g)};return q(function(x,g){var l;try{l=S.apply(this,x)}catch(e){return g(e)}if(l&&typeof l.then==="function")return w(l,g);else g(null,l)})}function w(S,x){return S.then((g)=>{X(x,null,g)},(g)=>{X(x,g&&(g instanceof Error||g.message)?g:new Error(g))})}function X(S,x,g){try{S(x,g)}catch(l){Z((e)=>{throw e},l)}}function T(S){return S[Symbol.toStringTag]==="AsyncFunction"}function G(S){return S[Symbol.toStringTag]==="AsyncGenerator"}function v(S){return typeof S[Symbol.asyncIterator]==="function"}function f(S){if(typeof S!=="function")throw new Error("expected a function");return T(S)?O(S):S}function A(S,x){if(!x)x=S.length;if(!x)throw new Error("arity is undefined");function g(...l){if(typeof l[x-1]==="function")return S.apply(this,l);return new Promise((e,q8)=>{l[x-1]=(J8,...Z8)=>{if(J8)return q8(J8);e(Z8.length>1?Z8:Z8[0])},S.apply(this,l)})}return g}function C(S){return function x(g,...l){return A(function(q8){var J8=this;return S(g,(Z8,T8)=>{f(Z8).apply(J8,l.concat(T8))},q8)})}}function V(S,x,g,l){x=x||[];var e=[],q8=0,J8=f(g);return S(x,(Z8,T8,y8)=>{var C6=q8++;J8(Z8,(c6,L6)=>{e[C6]=L6,y8(c6)})},(Z8)=>{l(Z8,e)})}function M(S){return S&&typeof S.length==="number"&&S.length>=0&&S.length%1===0}let R={};function I(S){function x(...g){if(S===null)return;var l=S;S=null,l.apply(this,g)}return Object.assign(x,S),x}function D(S){return S[Symbol.iterator]&&S[Symbol.iterator]()}function m(S){var x=-1,g=S.length;return function l(){return++x<g?{value:S[x],key:x}:null}}function b(S){var x=-1;return function g(){var l=S.next();if(l.done)return null;return x++,{value:l.value,key:x}}}function h(S){var x=S?Object.keys(S):[],g=-1,l=x.length;return function e(){var q8=x[++g];if(q8==="__proto__")return e();return g<l?{value:S[q8],key:q8}:null}}function L(S){if(M(S))return m(S);var x=D(S);return x?b(x):h(S)}function B(S){return function(...x){if(S===null)throw new Error("Callback was already called.");var g=S;S=null,g.apply(this,x)}}function i(S,x,g,l){let e=!1,q8=!1,J8=!1,Z8=0,T8=0;function y8(){if(Z8>=x||J8||e)return;J8=!0,S.next().then(({value:L6,done:t$})=>{if(q8||e)return;if(J8=!1,t$){if(e=!0,Z8<=0)l(null);return}Z8++,g(L6,T8,C6),T8++,y8()}).catch(c6)}function C6(L6,t$){if(Z8-=1,q8)return;if(L6)return c6(L6);if(L6===!1){e=!0,q8=!0;return}if(t$===R||e&&Z8<=0)return e=!0,l(null);y8()}function c6(L6){if(q8)return;J8=!1,e=!0,l(L6)}y8()}var X8=(S)=>{return(x,g,l)=>{if(l=I(l),S<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!x)return l(null);if(G(x))return i(x,S,g,l);if(v(x))return i(x[Symbol.asyncIterator](),S,g,l);var e=L(x),q8=!1,J8=!1,Z8=0,T8=!1;function y8(c6,L6){if(J8)return;if(Z8-=1,c6)q8=!0,l(c6);else if(c6===!1)q8=!0,J8=!0;else if(L6===R||q8&&Z8<=0)return q8=!0,l(null);else if(!T8)C6()}function C6(){T8=!0;while(Z8<S&&!q8){var c6=e();if(c6===null){if(q8=!0,Z8<=0)l(null);return}Z8+=1,g(c6.value,c6.key,B(y8))}T8=!1}C6()}};function N8(S,x,g,l){return X8(x)(S,f(g),l)}var h8=A(N8,4);function c8(S,x,g){g=I(g);var l=0,e=0,{length:q8}=S,J8=!1;if(q8===0)g(null);function Z8(T8,y8){if(T8===!1)J8=!0;if(J8===!0)return;if(T8)g(T8);else if(++e===q8||y8===R)g(null)}for(;l<q8;l++)x(S[l],l,B(Z8))}function E8(S,x,g){return h8(S,1/0,x,g)}function g8(S,x,g){var l=M(S)?c8:E8;return l(S,f(x),g)}var t8=A(g8,3);function v4(S,x,g){return V(t8,S,x,g)}var g3=A(v4,3),v8=C(g3);function r(S,x,g){return h8(S,1,x,g)}var a=A(r,3);function s(S,x,g){return V(a,S,x,g)}var K8=A(s,3),P8=C(K8);let H8=Symbol("promiseCallback");function O8(){let S,x;function g(l,...e){if(l)return x(l);S(e.length>1?e:e[0])}return g[H8]=new Promise((l,e)=>{S=l,x=e}),g}function A8(S,x,g){if(typeof x!=="number")g=x,x=null;g=I(g||O8());var l=Object.keys(S).length;if(!l)return g(null);if(!x)x=l;var e={},q8=0,J8=!1,Z8=!1,T8=Object.create(null),y8=[],C6=[],c6={};Object.keys(S).forEach((x8)=>{var U8=S[x8];if(!Array.isArray(U8)){L6(x8,[U8]),C6.push(x8);return}var I6=U8.slice(0,U8.length-1),b1=I6.length;if(b1===0){L6(x8,U8),C6.push(x8);return}c6[x8]=b1,I6.forEach((p4)=>{if(!S[p4])throw new Error("async.auto task `"+x8+"` has a non-existent dependency `"+p4+"` in "+I6.join(", "));MP(p4,()=>{if(b1--,b1===0)L6(x8,U8)})})}),B6(),t$();function L6(x8,U8){y8.push(()=>iZ(x8,U8))}function t$(){if(J8)return;if(y8.length===0&&q8===0)return g(null,e);while(y8.length&&q8<x){var x8=y8.shift();x8()}}function MP(x8,U8){var I6=T8[x8];if(!I6)I6=T8[x8]=[];I6.push(U8)}function bY(x8){var U8=T8[x8]||[];U8.forEach((I6)=>I6()),t$()}function iZ(x8,U8){if(Z8)return;var I6=B((p4,...e$)=>{if(q8--,p4===!1){J8=!0;return}if(e$.length<2)[e$]=e$;if(p4){var NP={};if(Object.keys(e).forEach((gY)=>{NP[gY]=e[gY]}),NP[x8]=e$,Z8=!0,T8=Object.create(null),J8)return;g(p4,NP)}else e[x8]=e$,bY(x8)});q8++;var b1=f(U8[U8.length-1]);if(U8.length>1)b1(e,I6);else b1(I6)}function B6(){var x8,U8=0;while(C6.length)x8=C6.pop(),U8++,B8(x8).forEach((I6)=>{if(--c6[I6]===0)C6.push(I6)});if(U8!==l)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function B8(x8){var U8=[];return Object.keys(S).forEach((I6)=>{let b1=S[I6];if(Array.isArray(b1)&&b1.indexOf(x8)>=0)U8.push(I6)}),U8}return g[H8]}var A6=/^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/,E6=/^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/,$1=/,/,y3=/(=.+)?(\s*)$/;function g7(S){let x="",g=0,l=S.indexOf("*/");while(g<S.length)if(S[g]==="/"&&S[g+1]==="/"){let e=S.indexOf(`
|
|
404
|
+
%s`,I,I,T,Y);let D=T.type==="*"?Db:T.type==="?"?Lb:"\\"+T.type;z=!0,Y=Y.slice(0,T.reStart)+D+"\\("+I}if(V(),P)Y+="\\\\";let M=E_6[Y.charAt(0)];for(let I=W.length-1;I>-1;I--){let D=W[I],m=Y.slice(0,D.reStart),b=Y.slice(D.reStart,D.reEnd-8),h=Y.slice(D.reEnd),L=Y.slice(D.reEnd-8,D.reEnd)+h,B=m.split(")").length,i=m.split("(").length-B,X8=h;for(let h8=0;h8<i;h8++)X8=X8.replace(/\)[+*?]?/,"");h=X8;let N8=h===""&&K!==Sb?"(?:$|\\/)":"";Y=m+b+h+N8+L}if(Y!==""&&z)Y="(?=.)"+Y;if(M)Y=A()+Y;if(K===Sb)return[Y,z];if(q.nocase&&!z)z=$.toUpperCase()!==$.toLowerCase();if(!z)return I_6($);let R=q.nocase?"i":"";try{return Object.assign(new RegExp("^"+Y+"$",R),{_glob:$,_src:Y})}catch(I){return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let K=this.options,q=K.noglobstar?Db:K.dot?D_6:S_6,Y=K.nocase?"i":"",z=$.map((P)=>{return P=P.map((J)=>typeof J==="string"?b_6(J):J===J9?J9:J._src).reduce((J,W)=>{if(!(J[J.length-1]===J9&&W===J9))J.push(W);return J},[]),P.forEach((J,W)=>{if(J!==J9||P[W-1]===J9)return;if(W===0)if(P.length>1)P[W+1]="(?:\\/|"+q+"\\/)?"+P[W+1];else P[W]=q;else if(W===P.length-1)P[W-1]+="(?:\\/|"+q+")?";else P[W-1]+="(?:\\/|\\/"+q+"\\/)"+P[W+1],P[W+1]=J9}),P.filter((J)=>J!==J9).join("/")}).join("|");if(z="^(?:"+z+")$",this.negate)z="^(?!"+z+").*$";try{this.regexp=new RegExp(z,Y)}catch(P){this.regexp=!1}return this.regexp}match($,K=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&K)return!0;let q=this.options;if(Eb.sep!=="/")$=$.split(Eb.sep).join("/");$=$.split(pO8),this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let z;for(let P=$.length-1;P>=0;P--)if(z=$[P],z)break;for(let P=0;P<Y.length;P++){let J=Y[P],W=$;if(q.matchBase&&J.length===1)W=[z];if(this.matchOne(W,J,K)){if(q.flipNegate)return!0;return!this.negate}}if(q.flipNegate)return!1;return this.negate}static defaults($){return d$.defaults($).Minimatch}}d$.Minimatch=BX});var dO8=j((ru1,QO8)=>{QO8.exports=iO8;var bb=F("fs"),{EventEmitter:y_6}=F("events"),{Minimatch:xb}=UO8(),{resolve:u_6}=F("path");function m_6($,K){return new Promise((q,Y)=>{bb.readdir($,{withFileTypes:!0},(z,P)=>{if(z)switch(z.code){case"ENOTDIR":if(K)Y(z);else q([]);break;case"ENOTSUP":case"ENOENT":case"ENAMETOOLONG":case"UNKNOWN":q([]);break;case"ELOOP":default:Y(z);break}else q(P)})})}function lO8($,K){return new Promise((q,Y)=>{(K?bb.stat:bb.lstat)($,(P,J)=>{if(P)switch(P.code){case"ENOENT":if(K)q(lO8($,!1));else q(null);break;default:q(null);break}else q(J)})})}async function*FO8($,K,q,Y,z,P){let J=await m_6(K+$,P);for(let W of J){let H=W.name;if(H===void 0)H=W,Y=!0;let Z=$+"/"+H,O=Z.slice(1),w=K+"/"+O,X=null;if(Y||q)X=await lO8(w,q);if(!X&&W.name!==void 0)X=W;if(X===null)X={isDirectory:()=>!1};if(X.isDirectory()){if(!z(O))yield{relative:O,absolute:w,stats:X},yield*FO8(Z,K,q,Y,z,!1)}else yield{relative:O,absolute:w,stats:X}}}async function*p_6($,K,q,Y){yield*FO8("",$,K,q,Y,!0)}function c_6($){return{pattern:$.pattern,dot:!!$.dot,noglobstar:!!$.noglobstar,matchBase:!!$.matchBase,nocase:!!$.nocase,ignore:$.ignore,skip:$.skip,follow:!!$.follow,stat:!!$.stat,nodir:!!$.nodir,mark:!!$.mark,silent:!!$.silent,absolute:!!$.absolute}}class gb extends y_6{constructor($,K,q){super();if(typeof K==="function")q=K,K=null;if(this.options=c_6(K||{}),this.matchers=[],this.options.pattern){let Y=Array.isArray(this.options.pattern)?this.options.pattern:[this.options.pattern];this.matchers=Y.map((z)=>new xb(z,{dot:this.options.dot,noglobstar:this.options.noglobstar,matchBase:this.options.matchBase,nocase:this.options.nocase}))}if(this.ignoreMatchers=[],this.options.ignore){let Y=Array.isArray(this.options.ignore)?this.options.ignore:[this.options.ignore];this.ignoreMatchers=Y.map((z)=>new xb(z,{dot:!0}))}if(this.skipMatchers=[],this.options.skip){let Y=Array.isArray(this.options.skip)?this.options.skip:[this.options.skip];this.skipMatchers=Y.map((z)=>new xb(z,{dot:!0}))}if(this.iterator=p_6(u_6($||"."),this.options.follow,this.options.stat,this._shouldSkipDirectory.bind(this)),this.paused=!1,this.inactive=!1,this.aborted=!1,q)this._matches=[],this.on("match",(Y)=>this._matches.push(this.options.absolute?Y.absolute:Y.relative)),this.on("error",(Y)=>q(Y)),this.on("end",()=>q(null,this._matches));setTimeout(()=>this._next(),0)}_shouldSkipDirectory($){return this.skipMatchers.some((K)=>K.match($))}_fileMatches($,K){let q=$+(K?"/":"");return(this.matchers.length===0||this.matchers.some((Y)=>Y.match(q)))&&!this.ignoreMatchers.some((Y)=>Y.match(q))&&(!this.options.nodir||!K)}_next(){if(!this.paused&&!this.aborted)this.iterator.next().then(($)=>{if(!$.done){let K=$.value.stats.isDirectory();if(this._fileMatches($.value.relative,K)){let q=$.value.relative,Y=$.value.absolute;if(this.options.mark&&K)q+="/",Y+="/";if(this.options.stat)this.emit("match",{relative:q,absolute:Y,stat:$.value.stats});else this.emit("match",{relative:q,absolute:Y})}this._next(this.iterator)}else this.emit("end")}).catch(($)=>{if(this.abort(),this.emit("error",$),!$.code&&!this.options.silent)console.error($)});else this.inactive=!0}abort(){this.aborted=!0}pause(){this.paused=!0}resume(){if(this.paused=!1,this.inactive)this.inactive=!1,this._next()}}function iO8($,K,q){return new gb($,K,q)}iO8.ReaddirGlob=gb});var oO8=j((lf,nO8)=>{(function($,K){typeof lf==="object"&&typeof nO8!=="undefined"?K(lf):typeof define==="function"&&define.amd?define(["exports"],K):($=typeof globalThis!=="undefined"?globalThis:$||self,K($.async={}))})(lf,function($){function K(S,...x){return(...g)=>S(...x,...g)}function q(S){return function(...x){var g=x.pop();return S.call(this,x,g)}}var Y=typeof queueMicrotask==="function"&&queueMicrotask,z=typeof setImmediate==="function"&&setImmediate,P=typeof process==="object"&&typeof process.nextTick==="function";function J(S){setTimeout(S,0)}function W(S){return(x,...g)=>S(()=>x(...g))}var H;if(Y)H=queueMicrotask;else if(z)H=setImmediate;else if(P)H=process.nextTick;else H=J;var Z=W(H);function O(S){if(T(S))return function(...x){let g=x.pop(),l=S.apply(this,x);return w(l,g)};return q(function(x,g){var l;try{l=S.apply(this,x)}catch(e){return g(e)}if(l&&typeof l.then==="function")return w(l,g);else g(null,l)})}function w(S,x){return S.then((g)=>{X(x,null,g)},(g)=>{X(x,g&&(g instanceof Error||g.message)?g:new Error(g))})}function X(S,x,g){try{S(x,g)}catch(l){Z((e)=>{throw e},l)}}function T(S){return S[Symbol.toStringTag]==="AsyncFunction"}function G(S){return S[Symbol.toStringTag]==="AsyncGenerator"}function v(S){return typeof S[Symbol.asyncIterator]==="function"}function f(S){if(typeof S!=="function")throw new Error("expected a function");return T(S)?O(S):S}function A(S,x){if(!x)x=S.length;if(!x)throw new Error("arity is undefined");function g(...l){if(typeof l[x-1]==="function")return S.apply(this,l);return new Promise((e,q8)=>{l[x-1]=(J8,...Z8)=>{if(J8)return q8(J8);e(Z8.length>1?Z8:Z8[0])},S.apply(this,l)})}return g}function C(S){return function x(g,...l){return A(function(q8){var J8=this;return S(g,(Z8,T8)=>{f(Z8).apply(J8,l.concat(T8))},q8)})}}function V(S,x,g,l){x=x||[];var e=[],q8=0,J8=f(g);return S(x,(Z8,T8,y8)=>{var C6=q8++;J8(Z8,(c6,L6)=>{e[C6]=L6,y8(c6)})},(Z8)=>{l(Z8,e)})}function M(S){return S&&typeof S.length==="number"&&S.length>=0&&S.length%1===0}let R={};function I(S){function x(...g){if(S===null)return;var l=S;S=null,l.apply(this,g)}return Object.assign(x,S),x}function D(S){return S[Symbol.iterator]&&S[Symbol.iterator]()}function m(S){var x=-1,g=S.length;return function l(){return++x<g?{value:S[x],key:x}:null}}function b(S){var x=-1;return function g(){var l=S.next();if(l.done)return null;return x++,{value:l.value,key:x}}}function h(S){var x=S?Object.keys(S):[],g=-1,l=x.length;return function e(){var q8=x[++g];if(q8==="__proto__")return e();return g<l?{value:S[q8],key:q8}:null}}function L(S){if(M(S))return m(S);var x=D(S);return x?b(x):h(S)}function B(S){return function(...x){if(S===null)throw new Error("Callback was already called.");var g=S;S=null,g.apply(this,x)}}function i(S,x,g,l){let e=!1,q8=!1,J8=!1,Z8=0,T8=0;function y8(){if(Z8>=x||J8||e)return;J8=!0,S.next().then(({value:L6,done:t$})=>{if(q8||e)return;if(J8=!1,t$){if(e=!0,Z8<=0)l(null);return}Z8++,g(L6,T8,C6),T8++,y8()}).catch(c6)}function C6(L6,t$){if(Z8-=1,q8)return;if(L6)return c6(L6);if(L6===!1){e=!0,q8=!0;return}if(t$===R||e&&Z8<=0)return e=!0,l(null);y8()}function c6(L6){if(q8)return;J8=!1,e=!0,l(L6)}y8()}var X8=(S)=>{return(x,g,l)=>{if(l=I(l),S<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!x)return l(null);if(G(x))return i(x,S,g,l);if(v(x))return i(x[Symbol.asyncIterator](),S,g,l);var e=L(x),q8=!1,J8=!1,Z8=0,T8=!1;function y8(c6,L6){if(J8)return;if(Z8-=1,c6)q8=!0,l(c6);else if(c6===!1)q8=!0,J8=!0;else if(L6===R||q8&&Z8<=0)return q8=!0,l(null);else if(!T8)C6()}function C6(){T8=!0;while(Z8<S&&!q8){var c6=e();if(c6===null){if(q8=!0,Z8<=0)l(null);return}Z8+=1,g(c6.value,c6.key,B(y8))}T8=!1}C6()}};function N8(S,x,g,l){return X8(x)(S,f(g),l)}var h8=A(N8,4);function c8(S,x,g){g=I(g);var l=0,e=0,{length:q8}=S,J8=!1;if(q8===0)g(null);function Z8(T8,y8){if(T8===!1)J8=!0;if(J8===!0)return;if(T8)g(T8);else if(++e===q8||y8===R)g(null)}for(;l<q8;l++)x(S[l],l,B(Z8))}function E8(S,x,g){return h8(S,1/0,x,g)}function g8(S,x,g){var l=M(S)?c8:E8;return l(S,f(x),g)}var t8=A(g8,3);function V4(S,x,g){return V(t8,S,x,g)}var g3=A(V4,3),v8=C(g3);function r(S,x,g){return h8(S,1,x,g)}var a=A(r,3);function s(S,x,g){return V(a,S,x,g)}var K8=A(s,3),P8=C(K8);let H8=Symbol("promiseCallback");function O8(){let S,x;function g(l,...e){if(l)return x(l);S(e.length>1?e:e[0])}return g[H8]=new Promise((l,e)=>{S=l,x=e}),g}function A8(S,x,g){if(typeof x!=="number")g=x,x=null;g=I(g||O8());var l=Object.keys(S).length;if(!l)return g(null);if(!x)x=l;var e={},q8=0,J8=!1,Z8=!1,T8=Object.create(null),y8=[],C6=[],c6={};Object.keys(S).forEach((x8)=>{var U8=S[x8];if(!Array.isArray(U8)){L6(x8,[U8]),C6.push(x8);return}var I6=U8.slice(0,U8.length-1),b1=I6.length;if(b1===0){L6(x8,U8),C6.push(x8);return}c6[x8]=b1,I6.forEach((p4)=>{if(!S[p4])throw new Error("async.auto task `"+x8+"` has a non-existent dependency `"+p4+"` in "+I6.join(", "));MP(p4,()=>{if(b1--,b1===0)L6(x8,U8)})})}),B6(),t$();function L6(x8,U8){y8.push(()=>iZ(x8,U8))}function t$(){if(J8)return;if(y8.length===0&&q8===0)return g(null,e);while(y8.length&&q8<x){var x8=y8.shift();x8()}}function MP(x8,U8){var I6=T8[x8];if(!I6)I6=T8[x8]=[];I6.push(U8)}function bY(x8){var U8=T8[x8]||[];U8.forEach((I6)=>I6()),t$()}function iZ(x8,U8){if(Z8)return;var I6=B((p4,...e$)=>{if(q8--,p4===!1){J8=!0;return}if(e$.length<2)[e$]=e$;if(p4){var NP={};if(Object.keys(e).forEach((gY)=>{NP[gY]=e[gY]}),NP[x8]=e$,Z8=!0,T8=Object.create(null),J8)return;g(p4,NP)}else e[x8]=e$,bY(x8)});q8++;var b1=f(U8[U8.length-1]);if(U8.length>1)b1(e,I6);else b1(I6)}function B6(){var x8,U8=0;while(C6.length)x8=C6.pop(),U8++,B8(x8).forEach((I6)=>{if(--c6[I6]===0)C6.push(I6)});if(U8!==l)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function B8(x8){var U8=[];return Object.keys(S).forEach((I6)=>{let b1=S[I6];if(Array.isArray(b1)&&b1.indexOf(x8)>=0)U8.push(I6)}),U8}return g[H8]}var A6=/^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/,E6=/^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/,$1=/,/,y3=/(=.+)?(\s*)$/;function g7(S){let x="",g=0,l=S.indexOf("*/");while(g<S.length)if(S[g]==="/"&&S[g+1]==="/"){let e=S.indexOf(`
|
|
405
405
|
`,g);g=e===-1?S.length:e}else if(l!==-1&&S[g]==="/"&&S[g+1]==="*"){let e=S.indexOf("*/",g);if(e!==-1)g=e+2,l=S.indexOf("*/",g);else x+=S[g],g++}else x+=S[g],g++;return x}function tK(S){let x=g7(S.toString()),g=x.match(A6);if(!g)g=x.match(E6);if(!g)throw new Error(`could not parse args in autoInject
|
|
406
406
|
Source:
|
|
407
407
|
`+x);let[,l]=g;return l.replace(/\s/g,"").split($1).map((e)=>e.replace(y3,"").trim())}function V8(S,x){var g={};return Object.keys(S).forEach((l)=>{var e=S[l],q8,J8=T(e),Z8=!J8&&e.length===1||J8&&e.length===0;if(Array.isArray(e))q8=[...e],e=q8.pop(),g[l]=q8.concat(q8.length>0?T8:e);else if(Z8)g[l]=e;else{if(q8=tK(e),e.length===0&&!J8&&q8.length===0)throw new Error("autoInject task functions require explicit parameters.");if(!J8)q8.pop();g[l]=q8.concat(T8)}function T8(y8,C6){var c6=q8.map((L6)=>y8[L6]);c6.push(C6),f(e)(...c6)}}),A8(g,x)}class R8{constructor(){this.head=this.tail=null,this.length=0}removeLink(S){if(S.prev)S.prev.next=S.next;else this.head=S.next;if(S.next)S.next.prev=S.prev;else this.tail=S.prev;return S.prev=S.next=null,this.length-=1,S}empty(){while(this.head)this.shift();return this}insertAfter(S,x){if(x.prev=S,x.next=S.next,S.next)S.next.prev=x;else this.tail=x;S.next=x,this.length+=1}insertBefore(S,x){if(x.prev=S.prev,x.next=S,S.prev)S.prev.next=x;else this.head=x;S.prev=x,this.length+=1}unshift(S){if(this.head)this.insertBefore(this.head,S);else c(this,S)}push(S){if(this.tail)this.insertAfter(this.tail,S);else c(this,S)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){var S=this.head;while(S)yield S.data,S=S.next}remove(S){var x=this.head;while(x){var{next:g}=x;if(S(x))this.removeLink(x);x=g}return this}}function c(S,x){S.length=1,S.head=S.tail=x}function o(S,x,g){if(x==null)x=1;else if(x===0)throw new RangeError("Concurrency must not be zero");var l=f(S),e=0,q8=[];let J8={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};function Z8(B8,x8){J8[B8].push(x8)}function T8(B8,x8){let U8=(...I6)=>{y8(B8,U8),x8(...I6)};J8[B8].push(U8)}function y8(B8,x8){if(!B8)return Object.keys(J8).forEach((U8)=>J8[U8]=[]);if(!x8)return J8[B8]=[];J8[B8]=J8[B8].filter((U8)=>U8!==x8)}function C6(B8,...x8){J8[B8].forEach((U8)=>U8(...x8))}var c6=!1;function L6(B8,x8,U8,I6){if(I6!=null&&typeof I6!=="function")throw new Error("task callback must be a function");B6.started=!0;var b1,p4;function e$(gY,...QZ){if(gY)return U8?p4(gY):b1();if(QZ.length<=1)return b1(QZ[0]);b1(QZ)}var NP=B6._createTaskItem(B8,U8?e$:I6||e$);if(x8)B6._tasks.unshift(NP);else B6._tasks.push(NP);if(!c6)c6=!0,Z(()=>{c6=!1,B6.process()});if(U8||!I6)return new Promise((gY,QZ)=>{b1=gY,p4=QZ})}function t$(B8){return function(x8,...U8){e-=1;for(var I6=0,b1=B8.length;I6<b1;I6++){var p4=B8[I6],e$=q8.indexOf(p4);if(e$===0)q8.shift();else if(e$>0)q8.splice(e$,1);if(p4.callback(x8,...U8),x8!=null)C6("error",x8,p4.data)}if(e<=B6.concurrency-B6.buffer)C6("unsaturated");if(B6.idle())C6("drain");B6.process()}}function MP(B8){if(B8.length===0&&B6.idle())return Z(()=>C6("drain")),!0;return!1}let bY=(B8)=>(x8)=>{if(!x8)return new Promise((U8,I6)=>{T8(B8,(b1,p4)=>{if(b1)return I6(b1);U8(p4)})});y8(B8),Z8(B8,x8)};var iZ=!1,B6={_tasks:new R8,_createTaskItem(B8,x8){return{data:B8,callback:x8}},*[Symbol.iterator](){yield*B6._tasks[Symbol.iterator]()},concurrency:x,payload:g,buffer:x/4,started:!1,paused:!1,push(B8,x8){if(Array.isArray(B8)){if(MP(B8))return;return B8.map((U8)=>L6(U8,!1,!1,x8))}return L6(B8,!1,!1,x8)},pushAsync(B8,x8){if(Array.isArray(B8)){if(MP(B8))return;return B8.map((U8)=>L6(U8,!1,!0,x8))}return L6(B8,!1,!0,x8)},kill(){y8(),B6._tasks.empty()},unshift(B8,x8){if(Array.isArray(B8)){if(MP(B8))return;return B8.map((U8)=>L6(U8,!0,!1,x8))}return L6(B8,!0,!1,x8)},unshiftAsync(B8,x8){if(Array.isArray(B8)){if(MP(B8))return;return B8.map((U8)=>L6(U8,!0,!0,x8))}return L6(B8,!0,!0,x8)},remove(B8){B6._tasks.remove(B8)},process(){if(iZ)return;iZ=!0;while(!B6.paused&&e<B6.concurrency&&B6._tasks.length){var B8=[],x8=[],U8=B6._tasks.length;if(B6.payload)U8=Math.min(U8,B6.payload);for(var I6=0;I6<U8;I6++){var b1=B6._tasks.shift();B8.push(b1),q8.push(b1),x8.push(b1.data)}if(e+=1,B6._tasks.length===0)C6("empty");if(e===B6.concurrency)C6("saturated");var p4=B(t$(B8));l(x8,p4)}iZ=!1},length(){return B6._tasks.length},running(){return e},workersList(){return q8},idle(){return B6._tasks.length+e===0},pause(){B6.paused=!0},resume(){if(B6.paused===!1)return;B6.paused=!1,Z(B6.process)}};return Object.defineProperties(B6,{saturated:{writable:!1,value:bY("saturated")},unsaturated:{writable:!1,value:bY("unsaturated")},empty:{writable:!1,value:bY("empty")},drain:{writable:!1,value:bY("drain")},error:{writable:!1,value:bY("error")}}),B6}function E(S,x){return o(S,1,x)}function u(S,x,g){return o(S,x,g)}function y(S,x,g,l){l=I(l);var e=f(g);return a(S,(q8,J8,Z8)=>{e(x,q8,(T8,y8)=>{x=y8,Z8(T8)})},(q8)=>l(q8,x))}var Q=A(y,4);function d(...S){var x=S.map(f);return function(...g){var l=this,e=g[g.length-1];if(typeof e=="function")g.pop();else e=O8();return Q(x,g,(q8,J8,Z8)=>{J8.apply(l,q8.concat((T8,...y8)=>{Z8(T8,y8)}))},(q8,J8)=>e(q8,...J8)),e[H8]}}function $8(...S){return d(...S.reverse())}function W8(S,x,g,l){return V(X8(x),S,g,l)}var z8=A(W8,4);function w8(S,x,g,l){var e=f(g);return z8(S,x,(q8,J8)=>{e(q8,(Z8,...T8)=>{if(Z8)return J8(Z8);return J8(Z8,T8)})},(q8,J8)=>{var Z8=[];for(var T8=0;T8<J8.length;T8++)if(J8[T8])Z8=Z8.concat(...J8[T8]);return l(q8,Z8)})}var k8=A(w8,4);function m8(S,x,g){return k8(S,1/0,x,g)}var Q8=A(m8,3);function h6(S,x,g){return k8(S,1,x,g)}var o8=A(h6,3);function d6(...S){return function(...x){var g=x.pop();return g(null,...S)}}function n6(S,x){return(g,l,e,q8)=>{var J8=!1,Z8;let T8=f(e);g(l,(y8,C6,c6)=>{T8(y8,(L6,t$)=>{if(L6||L6===!1)return c6(L6);if(S(t$)&&!Z8)return J8=!0,Z8=x(!0,y8),c6(null,R);c6()})},(y8)=>{if(y8)return q8(y8);q8(null,J8?Z8:x(!1))})}}function L$(S,x,g){return n6((l)=>l,(l,e)=>e)(t8,S,x,g)}var u3=A(L$,3);function xY(S,x,g,l){return n6((e)=>e,(e,q8)=>q8)(X8(x),S,g,l)}var kP=A(xY,4);function hv(S,x,g){return n6((l)=>l,(l,e)=>e)(X8(1),S,x,g)}var i5=A(hv,3);function Ji(S){return(x,...g)=>f(x)(...g,(l,...e)=>{if(typeof console==="object"){if(l){if(console.error)console.error(l)}else if(console[S])e.forEach((q8)=>console[S](q8))}})}var Wi=Ji("dir");function tF8(S,x,g){g=B(g);var l=f(S),e=f(x),q8;function J8(T8,...y8){if(T8)return g(T8);if(T8===!1)return;q8=y8,e(...y8,Z8)}function Z8(T8,y8){if(T8)return g(T8);if(T8===!1)return;if(!y8)return g(null,...q8);l(J8)}return Z8(null,!0)}var BZ=A(tF8,3);function Hi(S,x,g){let l=f(x);return BZ(S,(...e)=>{let q8=e.pop();l(...e,(J8,Z8)=>q8(J8,!Z8))},g)}function Zi(S){return(x,g,l)=>S(x,l)}function eF8(S,x,g){return t8(S,Zi(f(x)),g)}var Cv=A(eF8,3);function $i8(S,x,g,l){return X8(x)(S,Zi(f(g)),l)}var UZ=A($i8,4);function Ki8(S,x,g){return UZ(S,1,x,g)}var lZ=A(Ki8,3);function sh(S){if(T(S))return S;return function(...x){var g=x.pop(),l=!0;x.push((...e)=>{if(l)Z(()=>g(...e));else g(...e)}),S.apply(this,x),l=!1}}function qi8(S,x,g){return n6((l)=>!l,(l)=>!l)(t8,S,x,g)}var Rv=A(qi8,3);function Yi8(S,x,g,l){return n6((e)=>!e,(e)=>!e)(X8(x),S,g,l)}var Dv=A(Yi8,4);function zi8(S,x,g){return n6((l)=>!l,(l)=>!l)(a,S,x,g)}var Sv=A(zi8,3);function Pi8(S,x,g,l){var e=new Array(x.length);S(x,(q8,J8,Z8)=>{g(q8,(T8,y8)=>{e[J8]=!!y8,Z8(T8)})},(q8)=>{if(q8)return l(q8);var J8=[];for(var Z8=0;Z8<x.length;Z8++)if(e[Z8])J8.push(x[Z8]);l(null,J8)})}function Ji8(S,x,g,l){var e=[];S(x,(q8,J8,Z8)=>{g(q8,(T8,y8)=>{if(T8)return Z8(T8);if(y8)e.push({index:J8,value:q8});Z8(T8)})},(q8)=>{if(q8)return l(q8);l(null,e.sort((J8,Z8)=>J8.index-Z8.index).map((J8)=>J8.value))})}function Ev(S,x,g,l){var e=M(x)?Pi8:Ji8;return e(S,x,f(g),l)}function Wi8(S,x,g){return Ev(t8,S,x,g)}var Lv=A(Wi8,3);function Hi8(S,x,g,l){return Ev(X8(x),S,g,l)}var Iv=A(Hi8,4);function Zi8(S,x,g){return Ev(a,S,x,g)}var xv=A(Zi8,3);function Oi8(S,x){var g=B(x),l=f(sh(S));function e(q8){if(q8)return g(q8);if(q8===!1)return;l(e)}return e()}var Oi=A(Oi8,2);function wi8(S,x,g,l){var e=f(g);return z8(S,x,(q8,J8)=>{e(q8,(Z8,T8)=>{if(Z8)return J8(Z8);return J8(Z8,{key:T8,val:q8})})},(q8,J8)=>{var Z8={},{hasOwnProperty:T8}=Object.prototype;for(var y8=0;y8<J8.length;y8++)if(J8[y8]){var{key:C6}=J8[y8],{val:c6}=J8[y8];if(T8.call(Z8,C6))Z8[C6].push(c6);else Z8[C6]=[c6]}return l(q8,Z8)})}var bv=A(wi8,4);function wi(S,x,g){return bv(S,1/0,x,g)}function Xi(S,x,g){return bv(S,1,x,g)}var Ti=Ji("log");function Xi8(S,x,g,l){l=I(l);var e={},q8=f(g);return X8(x)(S,(J8,Z8,T8)=>{q8(J8,Z8,(y8,C6)=>{if(y8)return T8(y8);e[Z8]=C6,T8(y8)})},(J8)=>l(J8,e))}var gv=A(Xi8,4);function ji(S,x,g){return gv(S,1/0,x,g)}function vi(S,x,g){return gv(S,1,x,g)}function Gi(S,x=(g)=>g){var g=Object.create(null),l=Object.create(null),e=f(S),q8=q((J8,Z8)=>{var T8=x(...J8);if(T8 in g)Z(()=>Z8(null,...g[T8]));else if(T8 in l)l[T8].push(Z8);else l[T8]=[Z8],e(...J8,(y8,...C6)=>{if(!y8)g[T8]=C6;var c6=l[T8];delete l[T8];for(var L6=0,t$=c6.length;L6<t$;L6++)c6[L6](y8,...C6)})});return q8.memo=g,q8.unmemoized=S,q8}var yv;if(P)yv=process.nextTick;else if(z)yv=setImmediate;else yv=J;var _i=W(yv),th=A((S,x,g)=>{var l=M(x)?[]:{};S(x,(e,q8,J8)=>{f(e)((Z8,...T8)=>{if(T8.length<2)[T8]=T8;l[q8]=T8,J8(Z8)})},(e)=>g(e,l))},3);function fi(S,x){return th(t8,S,x)}function Ai(S,x,g){return th(X8(x),S,g)}function eh(S,x){var g=f(S);return o((l,e)=>{g(l[0],e)},x,1)}class Vi{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(S){let x;while(S>0&&$C(this.heap[S],this.heap[x=ki(S)])){let g=this.heap[S];this.heap[S]=this.heap[x],this.heap[x]=g,S=x}}percDown(S){let x;while((x=Ti8(S))<this.heap.length){if(x+1<this.heap.length&&$C(this.heap[x+1],this.heap[x]))x=x+1;if($C(this.heap[S],this.heap[x]))break;let g=this.heap[S];this.heap[S]=this.heap[x],this.heap[x]=g,S=x}}push(S){S.pushCount=++this.pushCount,this.heap.push(S),this.percUp(this.heap.length-1)}unshift(S){return this.heap.push(S)}shift(){let[S]=this.heap;return this.heap[0]=this.heap[this.heap.length-1],this.heap.pop(),this.percDown(0),S}toArray(){return[...this]}*[Symbol.iterator](){for(let S=0;S<this.heap.length;S++)yield this.heap[S].data}remove(S){let x=0;for(let g=0;g<this.heap.length;g++)if(!S(this.heap[g]))this.heap[x]=this.heap[g],x++;this.heap.splice(x);for(let g=ki(this.heap.length-1);g>=0;g--)this.percDown(g);return this}}function Ti8(S){return(S<<1)+1}function ki(S){return(S+1>>1)-1}function $C(S,x){if(S.priority!==x.priority)return S.priority<x.priority;else return S.pushCount<x.pushCount}function Mi(S,x){var g=eh(S,x),{push:l,pushAsync:e}=g;g._tasks=new Vi,g._createTaskItem=({data:J8,priority:Z8},T8)=>{return{data:J8,priority:Z8,callback:T8}};function q8(J8,Z8){if(!Array.isArray(J8))return{data:J8,priority:Z8};return J8.map((T8)=>{return{data:T8,priority:Z8}})}return g.push=function(J8,Z8=0,T8){return l(q8(J8,Z8),T8)},g.pushAsync=function(J8,Z8=0,T8){return e(q8(J8,Z8),T8)},delete g.unshift,delete g.unshiftAsync,g}function ji8(S,x){if(x=I(x),!Array.isArray(S))return x(new TypeError("First argument to race must be an array of functions"));if(!S.length)return x();for(var g=0,l=S.length;g<l;g++)f(S[g])(x)}var Ni=A(ji8,2);function uv(S,x,g,l){var e=[...S].reverse();return Q(e,x,g,l)}function mv(S){var x=f(S);return q(function g(l,e){return l.push((q8,...J8)=>{let Z8={};if(q8)Z8.error=q8;if(J8.length>0){var T8=J8;if(J8.length<=1)[T8]=J8;Z8.value=T8}e(null,Z8)}),x.apply(this,l)})}function hi(S){var x;if(Array.isArray(S))x=S.map(mv);else x={},Object.keys(S).forEach((g)=>{x[g]=mv.call(this,S[g])});return x}function KC(S,x,g,l){let e=f(g);return Ev(S,x,(q8,J8)=>{e(q8,(Z8,T8)=>{J8(Z8,!T8)})},l)}function vi8(S,x,g){return KC(t8,S,x,g)}var Ci=A(vi8,3);function Gi8(S,x,g,l){return KC(X8(x),S,g,l)}var Ri=A(Gi8,4);function _i8(S,x,g){return KC(a,S,x,g)}var Di=A(_i8,3);function Si(S){return function(){return S}}let qC=5,Ei=0;function pv(S,x,g){var l={times:qC,intervalFunc:Si(Ei)};if(arguments.length<3&&typeof S==="function")g=x||O8(),x=S;else fi8(l,S),g=g||O8();if(typeof x!=="function")throw new Error("Invalid arguments for async.retry");var e=f(x),q8=1;function J8(){e((Z8,...T8)=>{if(Z8===!1)return;if(Z8&&q8++<l.times&&(typeof l.errorFilter!="function"||l.errorFilter(Z8)))setTimeout(J8,l.intervalFunc(q8-1));else g(Z8,...T8)})}return J8(),g[H8]}function fi8(S,x){if(typeof x==="object")S.times=+x.times||qC,S.intervalFunc=typeof x.interval==="function"?x.interval:Si(+x.interval||Ei),S.errorFilter=x.errorFilter;else if(typeof x==="number"||typeof x==="string")S.times=+x||qC;else throw new Error("Invalid arguments for async.retry")}function Li(S,x){if(!x)x=S,S=null;let g=S&&S.arity||x.length;if(T(x))g+=1;var l=f(x);return q((e,q8)=>{if(e.length<g-1||q8==null)e.push(q8),q8=O8();function J8(Z8){l(...e,Z8)}if(S)pv(S,J8,q8);else pv(J8,q8);return q8[H8]})}function Ii(S,x){return th(a,S,x)}function Ai8(S,x,g){return n6(Boolean,(l)=>l)(t8,S,x,g)}var cv=A(Ai8,3);function Vi8(S,x,g,l){return n6(Boolean,(e)=>e)(X8(x),S,g,l)}var Bv=A(Vi8,4);function ki8(S,x,g){return n6(Boolean,(l)=>l)(a,S,x,g)}var Uv=A(ki8,3);function Mi8(S,x,g){var l=f(x);return g3(S,(q8,J8)=>{l(q8,(Z8,T8)=>{if(Z8)return J8(Z8);J8(Z8,{value:q8,criteria:T8})})},(q8,J8)=>{if(q8)return g(q8);g(null,J8.sort(e).map((Z8)=>Z8.value))});function e(q8,J8){var Z8=q8.criteria,T8=J8.criteria;return Z8<T8?-1:Z8>T8?1:0}}var xi=A(Mi8,3);function bi(S,x,g){var l=f(S);return q((e,q8)=>{var J8=!1,Z8;function T8(){var y8=S.name||"anonymous",C6=new Error('Callback function "'+y8+'" timed out.');if(C6.code="ETIMEDOUT",g)C6.info=g;J8=!0,q8(C6)}e.push((...y8)=>{if(!J8)q8(...y8),clearTimeout(Z8)}),Z8=setTimeout(T8,x),l(...e)})}function Ni8(S){var x=Array(S);while(S--)x[S]=S;return x}function lv(S,x,g,l){var e=f(g);return z8(Ni8(S),x,e,l)}function gi(S,x,g){return lv(S,1/0,x,g)}function yi(S,x,g){return lv(S,1,x,g)}function ui(S,x,g,l){if(arguments.length<=3&&typeof x==="function")l=g,g=x,x=Array.isArray(S)?[]:{};l=I(l||O8());var e=f(g);return t8(S,(q8,J8,Z8)=>{e(x,q8,J8,Z8)},(q8)=>l(q8,x)),l[H8]}function hi8(S,x){var g=null,l;return lZ(S,(e,q8)=>{f(e)((J8,...Z8)=>{if(J8===!1)return q8(J8);if(Z8.length<2)[l]=Z8;else l=Z8;g=J8,q8(J8?null:{})})},()=>x(g,l))}var mi=A(hi8);function pi(S){return(...x)=>{return(S.unmemoized||S)(...x)}}function Ci8(S,x,g){g=B(g);var l=f(x),e=f(S),q8=[];function J8(T8,...y8){if(T8)return g(T8);if(q8=y8,T8===!1)return;e(Z8)}function Z8(T8,y8){if(T8)return g(T8);if(T8===!1)return;if(!y8)return g(null,...q8);l(J8)}return e(Z8)}var FZ=A(Ci8,3);function ci(S,x,g){let l=f(S);return FZ((e)=>l((q8,J8)=>e(q8,!J8)),x,g)}function Ri8(S,x){if(x=I(x),!Array.isArray(S))return x(new Error("First argument to waterfall must be an array of functions"));if(!S.length)return x();var g=0;function l(q8){var J8=f(S[g++]);J8(...q8,B(e))}function e(q8,...J8){if(q8===!1)return;if(q8||g===S.length)return x(q8,...J8);l(J8)}l([])}var Bi=A(Ri8),Di8={apply:K,applyEach:v8,applyEachSeries:P8,asyncify:O,auto:A8,autoInject:V8,cargo:E,cargoQueue:u,compose:$8,concat:Q8,concatLimit:k8,concatSeries:o8,constant:d6,detect:u3,detectLimit:kP,detectSeries:i5,dir:Wi,doUntil:Hi,doWhilst:BZ,each:Cv,eachLimit:UZ,eachOf:t8,eachOfLimit:h8,eachOfSeries:a,eachSeries:lZ,ensureAsync:sh,every:Rv,everyLimit:Dv,everySeries:Sv,filter:Lv,filterLimit:Iv,filterSeries:xv,forever:Oi,groupBy:wi,groupByLimit:bv,groupBySeries:Xi,log:Ti,map:g3,mapLimit:z8,mapSeries:K8,mapValues:ji,mapValuesLimit:gv,mapValuesSeries:vi,memoize:Gi,nextTick:_i,parallel:fi,parallelLimit:Ai,priorityQueue:Mi,queue:eh,race:Ni,reduce:Q,reduceRight:uv,reflect:mv,reflectAll:hi,reject:Ci,rejectLimit:Ri,rejectSeries:Di,retry:pv,retryable:Li,seq:d,series:Ii,setImmediate:Z,some:cv,someLimit:Bv,someSeries:Uv,sortBy:xi,timeout:bi,times:gi,timesLimit:lv,timesSeries:yi,transform:ui,tryEach:mi,unmemoize:pi,until:ci,waterfall:Bi,whilst:FZ,all:Rv,allLimit:Dv,allSeries:Sv,any:cv,anyLimit:Bv,anySeries:Uv,find:u3,findLimit:kP,findSeries:i5,flatMap:Q8,flatMapLimit:k8,flatMapSeries:o8,forEach:Cv,forEachSeries:lZ,forEachLimit:UZ,forEachOf:t8,forEachOfSeries:a,forEachOfLimit:h8,inject:Q,foldl:Q,foldr:uv,select:Lv,selectLimit:Iv,selectSeries:xv,wrapSync:O,during:FZ,doDuring:BZ};$.all=Rv,$.allLimit=Dv,$.allSeries=Sv,$.any=cv,$.anyLimit=Bv,$.anySeries=Uv,$.apply=K,$.applyEach=v8,$.applyEachSeries=P8,$.asyncify=O,$.auto=A8,$.autoInject=V8,$.cargo=E,$.cargoQueue=u,$.compose=$8,$.concat=Q8,$.concatLimit=k8,$.concatSeries=o8,$.constant=d6,$.default=Di8,$.detect=u3,$.detectLimit=kP,$.detectSeries=i5,$.dir=Wi,$.doDuring=BZ,$.doUntil=Hi,$.doWhilst=BZ,$.during=FZ,$.each=Cv,$.eachLimit=UZ,$.eachOf=t8,$.eachOfLimit=h8,$.eachOfSeries=a,$.eachSeries=lZ,$.ensureAsync=sh,$.every=Rv,$.everyLimit=Dv,$.everySeries=Sv,$.filter=Lv,$.filterLimit=Iv,$.filterSeries=xv,$.find=u3,$.findLimit=kP,$.findSeries=i5,$.flatMap=Q8,$.flatMapLimit=k8,$.flatMapSeries=o8,$.foldl=Q,$.foldr=uv,$.forEach=Cv,$.forEachLimit=UZ,$.forEachOf=t8,$.forEachOfLimit=h8,$.forEachOfSeries=a,$.forEachSeries=lZ,$.forever=Oi,$.groupBy=wi,$.groupByLimit=bv,$.groupBySeries=Xi,$.inject=Q,$.log=Ti,$.map=g3,$.mapLimit=z8,$.mapSeries=K8,$.mapValues=ji,$.mapValuesLimit=gv,$.mapValuesSeries=vi,$.memoize=Gi,$.nextTick=_i,$.parallel=fi,$.parallelLimit=Ai,$.priorityQueue=Mi,$.queue=eh,$.race=Ni,$.reduce=Q,$.reduceRight=uv,$.reflect=mv,$.reflectAll=hi,$.reject=Ci,$.rejectLimit=Ri,$.rejectSeries=Di,$.retry=pv,$.retryable=Li,$.select=Lv,$.selectLimit=Iv,$.selectSeries=xv,$.seq=d,$.series=Ii,$.setImmediate=Z,$.some=cv,$.someLimit=Bv,$.someSeries=Uv,$.sortBy=xi,$.timeout=bi,$.times=gi,$.timesLimit=lv,$.timesSeries=yi,$.transform=ui,$.tryEach=mi,$.unmemoize=pi,$.until=ci,$.waterfall=Bi,$.whilst=FZ,$.wrapSync=O,Object.defineProperty($,"__esModule",{value:!0})})});var rO8=j((su1,aO8)=>{var rq=F("constants"),B_6=process.cwd,Ff=null,U_6=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!Ff)Ff=B_6.call(process);return Ff};try{process.cwd()}catch($){}if(typeof process.chdir==="function"){if(Qf=process.chdir,process.chdir=function($){Ff=null,Qf.call(process,$)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,Qf)}var Qf;aO8.exports=l_6;function l_6($){if(rq.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))K($);if(!$.lutimes)q($);if($.chown=P($.chown),$.fchown=P($.fchown),$.lchown=P($.lchown),$.chmod=Y($.chmod),$.fchmod=Y($.fchmod),$.lchmod=Y($.lchmod),$.chownSync=J($.chownSync),$.fchownSync=J($.fchownSync),$.lchownSync=J($.lchownSync),$.chmodSync=z($.chmodSync),$.fchmodSync=z($.fchmodSync),$.lchmodSync=z($.lchmodSync),$.stat=W($.stat),$.fstat=W($.fstat),$.lstat=W($.lstat),$.statSync=H($.statSync),$.fstatSync=H($.fstatSync),$.lstatSync=H($.lstatSync),$.chmod&&!$.lchmod)$.lchmod=function(O,w,X){if(X)process.nextTick(X)},$.lchmodSync=function(){};if($.chown&&!$.lchown)$.lchown=function(O,w,X,T){if(T)process.nextTick(T)},$.lchownSync=function(){};if(U_6==="win32")$.rename=typeof $.rename!=="function"?$.rename:function(O){function w(X,T,G){var v=Date.now(),f=0;O(X,T,function A(C){if(C&&(C.code==="EACCES"||C.code==="EPERM"||C.code==="EBUSY")&&Date.now()-v<60000){if(setTimeout(function(){$.stat(T,function(V,M){if(V&&V.code==="ENOENT")O(X,T,A);else G(C)})},f),f<100)f+=10;return}if(G)G(C)})}if(Object.setPrototypeOf)Object.setPrototypeOf(w,O);return w}($.rename);$.read=typeof $.read!=="function"?$.read:function(O){function w(X,T,G,v,f,A){var C;if(A&&typeof A==="function"){var V=0;C=function(M,R,I){if(M&&M.code==="EAGAIN"&&V<10)return V++,O.call($,X,T,G,v,f,C);A.apply(this,arguments)}}return O.call($,X,T,G,v,f,C)}if(Object.setPrototypeOf)Object.setPrototypeOf(w,O);return w}($.read),$.readSync=typeof $.readSync!=="function"?$.readSync:function(O){return function(w,X,T,G,v){var f=0;while(!0)try{return O.call($,w,X,T,G,v)}catch(A){if(A.code==="EAGAIN"&&f<10){f++;continue}throw A}}}($.readSync);function K(O){O.lchmod=function(w,X,T){O.open(w,rq.O_WRONLY|rq.O_SYMLINK,X,function(G,v){if(G){if(T)T(G);return}O.fchmod(v,X,function(f){O.close(v,function(A){if(T)T(f||A)})})})},O.lchmodSync=function(w,X){var T=O.openSync(w,rq.O_WRONLY|rq.O_SYMLINK,X),G=!0,v;try{v=O.fchmodSync(T,X),G=!1}finally{if(G)try{O.closeSync(T)}catch(f){}else O.closeSync(T)}return v}}function q(O){if(rq.hasOwnProperty("O_SYMLINK")&&O.futimes)O.lutimes=function(w,X,T,G){O.open(w,rq.O_SYMLINK,function(v,f){if(v){if(G)G(v);return}O.futimes(f,X,T,function(A){O.close(f,function(C){if(G)G(A||C)})})})},O.lutimesSync=function(w,X,T){var G=O.openSync(w,rq.O_SYMLINK),v,f=!0;try{v=O.futimesSync(G,X,T),f=!1}finally{if(f)try{O.closeSync(G)}catch(A){}else O.closeSync(G)}return v};else if(O.futimes)O.lutimes=function(w,X,T,G){if(G)process.nextTick(G)},O.lutimesSync=function(){}}function Y(O){if(!O)return O;return function(w,X,T){return O.call($,w,X,function(G){if(Z(G))G=null;if(T)T.apply(this,arguments)})}}function z(O){if(!O)return O;return function(w,X){try{return O.call($,w,X)}catch(T){if(!Z(T))throw T}}}function P(O){if(!O)return O;return function(w,X,T,G){return O.call($,w,X,T,function(v){if(Z(v))v=null;if(G)G.apply(this,arguments)})}}function J(O){if(!O)return O;return function(w,X,T){try{return O.call($,w,X,T)}catch(G){if(!Z(G))throw G}}}function W(O){if(!O)return O;return function(w,X,T){if(typeof X==="function")T=X,X=null;function G(v,f){if(f){if(f.uid<0)f.uid+=4294967296;if(f.gid<0)f.gid+=4294967296}if(T)T.apply(this,arguments)}return X?O.call($,w,X,G):O.call($,w,G)}}function H(O){if(!O)return O;return function(w,X){var T=X?O.call($,w,X):O.call($,w);if(T){if(T.uid<0)T.uid+=4294967296;if(T.gid<0)T.gid+=4294967296}return T}}function Z(O){if(!O)return!0;if(O.code==="ENOSYS")return!0;var w=!process.getuid||process.getuid()!==0;if(w){if(O.code==="EINVAL"||O.code==="EPERM")return!0}return!1}}});var eO8=j((tu1,tO8)=>{var sO8=F("stream").Stream;tO8.exports=F_6;function F_6($){return{ReadStream:K,WriteStream:q};function K(Y,z){if(!(this instanceof K))return new K(Y,z);sO8.call(this);var P=this;this.path=Y,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,z=z||{};var J=Object.keys(z);for(var W=0,H=J.length;W<H;W++){var Z=J[W];this[Z]=z[Z]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){P._read()});return}$.open(this.path,this.flags,this.mode,function(O,w){if(O){P.emit("error",O),P.readable=!1;return}P.fd=w,P.emit("open",w),P._read()})}function q(Y,z){if(!(this instanceof q))return new q(Y,z);sO8.call(this),this.path=Y,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,z=z||{};var P=Object.keys(z);for(var J=0,W=P.length;J<W;J++){var H=P[J];this[H]=z[H]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=$.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var Kw8=j((eu1,$w8)=>{$w8.exports=Q_6;var i_6=Object.getPrototypeOf||function($){return $.__proto__};function Q_6($){if($===null||typeof $!=="object")return $;if($ instanceof Object)var K={__proto__:i_6($)};else var K=Object.create(null);return Object.getOwnPropertyNames($).forEach(function(q){Object.defineProperty(K,q,Object.getOwnPropertyDescriptor($,q))}),K}});var cb=j(($m1,pb)=>{var Q1=F("fs"),d_6=rO8(),n_6=eO8(),o_6=Kw8(),df=F("util"),Y3,of;if(typeof Symbol==="function"&&typeof Symbol.for==="function")Y3=Symbol.for("graceful-fs.queue"),of=Symbol.for("graceful-fs.previous");else Y3="___graceful-fs.queue",of="___graceful-fs.previous";function a_6(){}function Yw8($,K){Object.defineProperty($,Y3,{get:function(){return K}})}var az=a_6;if(df.debuglog)az=df.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))az=function(){var $=df.format.apply(df,arguments);$="GFS4: "+$.split(/\n/).join(`
|
|
408
|
-
GFS4: `),console.error($)};if(!Q1[Y3]){if(yb=global[Y3]||[],Yw8(Q1,yb),Q1.close=function($){function K(q,Y){return $.call(Q1,q,function(z){if(!z)qw8();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty(K,of,{value:$}),K}(Q1.close),Q1.closeSync=function($){function K(q){$.apply(Q1,arguments),qw8()}return Object.defineProperty(K,of,{value:$}),K}(Q1.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){az(Q1[Y3]),F("assert").equal(Q1[Y3].length,0)})}var yb;if(!global[Y3])Yw8(global,Q1[Y3]);pb.exports=ub(o_6(Q1));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Q1.__patched)pb.exports=ub(Q1),Q1.__patched=!0;function ub($){d_6($),$.gracefulify=ub,$.createReadStream=R,$.createWriteStream=I;var K=$.readFile;$.readFile=q;function q(b,h,L){if(typeof h==="function")L=h,h=null;return B(b,h,L);function B(i,X8,N8,h8){return K(i,X8,function(c8){if(c8&&(c8.code==="EMFILE"||c8.code==="ENFILE"))hW([B,[i,X8,N8],c8,h8||Date.now(),Date.now()]);else if(typeof N8==="function")N8.apply(this,arguments)})}}var Y=$.writeFile;$.writeFile=z;function z(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return Y(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var P=$.appendFile;if(P)$.appendFile=J;function J(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return P(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var W=$.copyFile;if(W)$.copyFile=H;function H(b,h,L,B){if(typeof L==="function")B=L,L=0;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return W(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var Z=$.readdir;$.readdir=w;var O=/^v[0-5]\./;function w(b,h,L){if(typeof h==="function")L=h,h=null;var B=O.test(process.version)?function X8(N8,h8,c8,E8){return Z(N8,i(N8,h8,c8,E8))}:function X8(N8,h8,c8,E8){return Z(N8,h8,i(N8,h8,c8,E8))};return B(b,h,L);function i(X8,N8,h8,c8){return function(E8,g8){if(E8&&(E8.code==="EMFILE"||E8.code==="ENFILE"))hW([B,[X8,N8,h8],E8,c8||Date.now(),Date.now()]);else{if(g8&&g8.sort)g8.sort();if(typeof h8==="function")h8.call(this,E8,g8)}}}}if(process.version.substr(0,4)==="v0.8"){var X=n_6($);A=X.ReadStream,V=X.WriteStream}var T=$.ReadStream;if(T)A.prototype=Object.create(T.prototype),A.prototype.open=C;var G=$.WriteStream;if(G)V.prototype=Object.create(G.prototype),V.prototype.open=M;Object.defineProperty($,"ReadStream",{get:function(){return A},set:function(b){A=b},enumerable:!0,configurable:!0}),Object.defineProperty($,"WriteStream",{get:function(){return V},set:function(b){V=b},enumerable:!0,configurable:!0});var v=A;Object.defineProperty($,"FileReadStream",{get:function(){return v},set:function(b){v=b},enumerable:!0,configurable:!0});var f=V;Object.defineProperty($,"FileWriteStream",{get:function(){return f},set:function(b){f=b},enumerable:!0,configurable:!0});function A(b,h){if(this instanceof A)return T.apply(this,arguments),this;else return A.apply(Object.create(A.prototype),arguments)}function C(){var b=this;m(b.path,b.flags,b.mode,function(h,L){if(h){if(b.autoClose)b.destroy();b.emit("error",h)}else b.fd=L,b.emit("open",L),b.read()})}function V(b,h){if(this instanceof V)return G.apply(this,arguments),this;else return V.apply(Object.create(V.prototype),arguments)}function M(){var b=this;m(b.path,b.flags,b.mode,function(h,L){if(h)b.destroy(),b.emit("error",h);else b.fd=L,b.emit("open",L)})}function R(b,h){return new $.ReadStream(b,h)}function I(b,h){return new $.WriteStream(b,h)}var D=$.open;$.open=m;function m(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return D(X8,N8,h8,function(g8,t8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}return $}function hW($){az("ENQUEUE",$[0].name,$[1]),Q1[Y3].push($),mb()}var nf;function qw8(){var $=Date.now();for(var K=0;K<Q1[Y3].length;++K)if(Q1[Y3][K].length>2)Q1[Y3][K][3]=$,Q1[Y3][K][4]=$;mb()}function mb(){if(clearTimeout(nf),nf=void 0,Q1[Y3].length===0)return;var $=Q1[Y3].shift(),K=$[0],q=$[1],Y=$[2],z=$[3],P=$[4];if(z===void 0)az("RETRY",K.name,q),K.apply(null,q);else if(Date.now()-z>=60000){az("TIMEOUT",K.name,q);var J=q.pop();if(typeof J==="function")J.call(null,Y)}else{var W=Date.now()-P,H=Math.max(P-z,1),Z=Math.min(H*1.2,100);if(W>=Z)az("RETRY",K.name,q),K.apply(null,q.concat([z]));else Q1[Y3].push($)}if(nf===void 0)nf=setTimeout(mb,0)}});var af=j((Km1,zw8)=>{var P5=($)=>$!==null&&typeof $==="object"&&typeof $.pipe==="function";P5.writable=($)=>P5($)&&$.writable!==!1&&typeof $._write==="function"&&typeof $._writableState==="object";P5.readable=($)=>P5($)&&$.readable!==!1&&typeof $._read==="function"&&typeof $._readableState==="object";P5.duplex=($)=>P5.writable($)&&P5.readable($);P5.transform=($)=>P5.duplex($)&&typeof $._transform==="function";zw8.exports=P5});var UX=j((qm1,Bb)=>{if(typeof process==="undefined"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)Bb.exports={nextTick:r_6};else Bb.exports=process;function r_6($,K,q,Y){if(typeof $!=="function")throw new TypeError('"callback" argument must be a function');var z=arguments.length,P,J;switch(z){case 0:case 1:return process.nextTick($);case 2:return process.nextTick(function W(){$.call(null,K)});case 3:return process.nextTick(function W(){$.call(null,K,q)});case 4:return process.nextTick(function W(){$.call(null,K,q,Y)});default:P=new Array(z-1),J=0;while(J<P.length)P[J++]=arguments[J];return process.nextTick(function W(){$.apply(null,P)})}}});var Jw8=j((Ym1,Pw8)=>{var s_6={}.toString;Pw8.exports=Array.isArray||function($){return s_6.call($)=="[object Array]"}});var lX=j((Ub,Hw8)=>{var rf=F("buffer"),jK=rf.Buffer;function Ww8($,K){for(var q in $)K[q]=$[q]}if(jK.from&&jK.alloc&&jK.allocUnsafe&&jK.allocUnsafeSlow)Hw8.exports=rf;else Ww8(rf,Ub),Ub.Buffer=CW;function CW($,K,q){return jK($,K,q)}Ww8(jK,CW);CW.from=function($,K,q){if(typeof $==="number")throw new TypeError("Argument must not be a number");return jK($,K,q)};CW.alloc=function($,K,q){if(typeof $!=="number")throw new TypeError("Argument must be a number");var Y=jK($);if(K!==void 0)if(typeof q==="string")Y.fill(K,q);else Y.fill(K);else Y.fill(0);return Y};CW.allocUnsafe=function($){if(typeof $!=="number")throw new TypeError("Argument must be a number");return jK($)};CW.allocUnsafeSlow=function($){if(typeof $!=="number")throw new TypeError("Argument must be a number");return rf.SlowBuffer($)}});var RW=j((Xf6)=>{function t_6($){if(Array.isArray)return Array.isArray($);return sf($)==="[object Array]"}Xf6.isArray=t_6;function e_6($){return typeof $==="boolean"}Xf6.isBoolean=e_6;function $f6($){return $===null}Xf6.isNull=$f6;function Kf6($){return $==null}Xf6.isNullOrUndefined=Kf6;function qf6($){return typeof $==="number"}Xf6.isNumber=qf6;function Yf6($){return typeof $==="string"}Xf6.isString=Yf6;function zf6($){return typeof $==="symbol"}Xf6.isSymbol=zf6;function Pf6($){return $===void 0}Xf6.isUndefined=Pf6;function Jf6($){return sf($)==="[object RegExp]"}Xf6.isRegExp=Jf6;function Wf6($){return typeof $==="object"&&$!==null}Xf6.isObject=Wf6;function Hf6($){return sf($)==="[object Date]"}Xf6.isDate=Hf6;function Zf6($){return sf($)==="[object Error]"||$ instanceof Error}Xf6.isError=Zf6;function Of6($){return typeof $==="function"}Xf6.isFunction=Of6;function wf6($){return $===null||typeof $==="boolean"||typeof $==="number"||typeof $==="string"||typeof $==="symbol"||typeof $==="undefined"}Xf6.isPrimitive=wf6;Xf6.isBuffer=F("buffer").Buffer.isBuffer;function sf($){return Object.prototype.toString.call($)}});var Ow8=j((Pm1,lb)=>{function Sf6($,K){if(!($ instanceof K))throw new TypeError("Cannot call a class as a function")}var Zw8=lX().Buffer,FX=F("util");function Ef6($,K,q){$.copy(K,q)}lb.exports=function(){function $(){Sf6(this,$),this.head=null,this.tail=null,this.length=0}return $.prototype.push=function K(q){var Y={data:q,next:null};if(this.length>0)this.tail.next=Y;else this.head=Y;this.tail=Y,++this.length},$.prototype.unshift=function K(q){var Y={data:q,next:this.head};if(this.length===0)this.tail=Y;this.head=Y,++this.length},$.prototype.shift=function K(){if(this.length===0)return;var q=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,q},$.prototype.clear=function K(){this.head=this.tail=null,this.length=0},$.prototype.join=function K(q){if(this.length===0)return"";var Y=this.head,z=""+Y.data;while(Y=Y.next)z+=q+Y.data;return z},$.prototype.concat=function K(q){if(this.length===0)return Zw8.alloc(0);var Y=Zw8.allocUnsafe(q>>>0),z=this.head,P=0;while(z)Ef6(z.data,Y,P),P+=z.data.length,z=z.next;return Y},$}();if(FX&&FX.inspect&&FX.inspect.custom)lb.exports.prototype[FX.inspect.custom]=function(){var $=FX.inspect({length:this.length});return this.constructor.name+" "+$}});var Fb=j((Jm1,ww8)=>{var tf=UX();function Lf6($,K){var q=this,Y=this._readableState&&this._readableState.destroyed,z=this._writableState&&this._writableState.destroyed;if(Y||z){if(K)K($);else if($){if(!this._writableState)tf.nextTick(ef,this,$);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,tf.nextTick(ef,this,$)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy($||null,function(P){if(!K&&P){if(!q._writableState)tf.nextTick(ef,q,P);else if(!q._writableState.errorEmitted)q._writableState.errorEmitted=!0,tf.nextTick(ef,q,P)}else if(K)K(P)}),this}function If6(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function ef($,K){$.emit("error",K)}ww8.exports={destroy:Lf6,undestroy:If6}});var Tw8=j((Wm1,Xw8)=>{Xw8.exports=F("util").deprecate});var Qb=j((Hm1,kw8)=>{var rz=UX();kw8.exports=V4;function vw8($){var K=this;this.next=null,this.entry=null,this.finish=function(){af6(K,$)}}var xf6=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:rz.nextTick,DW;V4.WritableState=QX;var Gw8=Object.create(RW());Gw8.inherits=$q();var bf6={deprecate:Tw8()},_w8=F("stream"),KA=lX().Buffer,gf6=(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:{}).Uint8Array||function(){};function yf6($){return KA.from($)}function uf6($){return KA.isBuffer($)||$ instanceof gf6}var fw8=Fb();Gw8.inherits(V4,_w8);function mf6(){}function QX($,K){DW=DW||sz(),$=$||{};var q=K instanceof DW;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.writableObjectMode;var{highWaterMark:Y,writableHighWaterMark:z}=$,P=this.objectMode?16:16384;if(Y||Y===0)this.highWaterMark=Y;else if(q&&(z||z===0))this.highWaterMark=z;else this.highWaterMark=P;this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var J=$.decodeStrings===!1;this.decodeStrings=!J,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(W){if6(K,W)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new vw8(this)}QX.prototype.getBuffer=function $(){var K=this.bufferedRequest,q=[];while(K)q.push(K),K=K.next;return q};(function(){try{Object.defineProperty(QX.prototype,"buffer",{get:bf6.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch($){}})();var $A;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")$A=Function.prototype[Symbol.hasInstance],Object.defineProperty(V4,Symbol.hasInstance,{value:function($){if($A.call(this,$))return!0;if(this!==V4)return!1;return $&&$._writableState instanceof QX}});else $A=function($){return $ instanceof this};function V4($){if(DW=DW||sz(),!$A.call(V4,this)&&!(this instanceof DW))return new V4($);if(this._writableState=new QX($,this),this.writable=!0,$){if(typeof $.write==="function")this._write=$.write;if(typeof $.writev==="function")this._writev=$.writev;if(typeof $.destroy==="function")this._destroy=$.destroy;if(typeof $.final==="function")this._final=$.final}_w8.call(this)}V4.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function pf6($,K){var q=new Error("write after end");$.emit("error",q),rz.nextTick(K,q)}function cf6($,K,q,Y){var z=!0,P=!1;if(q===null)P=new TypeError("May not write null values to stream");else if(typeof q!=="string"&&q!==void 0&&!K.objectMode)P=new TypeError("Invalid non-string/buffer chunk");if(P)$.emit("error",P),rz.nextTick(Y,P),z=!1;return z}V4.prototype.write=function($,K,q){var Y=this._writableState,z=!1,P=!Y.objectMode&&uf6($);if(P&&!KA.isBuffer($))$=yf6($);if(typeof K==="function")q=K,K=null;if(P)K="buffer";else if(!K)K=Y.defaultEncoding;if(typeof q!=="function")q=mf6;if(Y.ended)pf6(this,q);else if(P||cf6(this,Y,$,q))Y.pendingcb++,z=Uf6(this,Y,P,$,K,q);return z};V4.prototype.cork=function(){var $=this._writableState;$.corked++};V4.prototype.uncork=function(){var $=this._writableState;if($.corked){if($.corked--,!$.writing&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest)Aw8(this,$)}};V4.prototype.setDefaultEncoding=function $(K){if(typeof K==="string")K=K.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((K+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+K);return this._writableState.defaultEncoding=K,this};function Bf6($,K,q){if(!$.objectMode&&$.decodeStrings!==!1&&typeof K==="string")K=KA.from(K,q);return K}Object.defineProperty(V4.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Uf6($,K,q,Y,z,P){if(!q){var J=Bf6(K,Y,z);if(Y!==J)q=!0,z="buffer",Y=J}var W=K.objectMode?1:Y.length;K.length+=W;var H=K.length<K.highWaterMark;if(!H)K.needDrain=!0;if(K.writing||K.corked){var Z=K.lastBufferedRequest;if(K.lastBufferedRequest={chunk:Y,encoding:z,isBuf:q,callback:P,next:null},Z)Z.next=K.lastBufferedRequest;else K.bufferedRequest=K.lastBufferedRequest;K.bufferedRequestCount+=1}else ib($,K,!1,W,Y,z,P);return H}function ib($,K,q,Y,z,P,J){if(K.writelen=Y,K.writecb=J,K.writing=!0,K.sync=!0,q)$._writev(z,K.onwrite);else $._write(z,P,K.onwrite);K.sync=!1}function lf6($,K,q,Y,z){if(--K.pendingcb,q)rz.nextTick(z,Y),rz.nextTick(iX,$,K),$._writableState.errorEmitted=!0,$.emit("error",Y);else z(Y),$._writableState.errorEmitted=!0,$.emit("error",Y),iX($,K)}function Ff6($){$.writing=!1,$.writecb=null,$.length-=$.writelen,$.writelen=0}function if6($,K){var q=$._writableState,Y=q.sync,z=q.writecb;if(Ff6(q),K)lf6($,q,Y,K,z);else{var P=Vw8(q);if(!P&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest)Aw8($,q);if(Y)xf6(jw8,$,q,P,z);else jw8($,q,P,z)}}function jw8($,K,q,Y){if(!q)Qf6($,K);K.pendingcb--,Y(),iX($,K)}function Qf6($,K){if(K.length===0&&K.needDrain)K.needDrain=!1,$.emit("drain")}function Aw8($,K){K.bufferProcessing=!0;var q=K.bufferedRequest;if($._writev&&q&&q.next){var Y=K.bufferedRequestCount,z=new Array(Y),P=K.corkedRequestsFree;P.entry=q;var J=0,W=!0;while(q){if(z[J]=q,!q.isBuf)W=!1;q=q.next,J+=1}if(z.allBuffers=W,ib($,K,!0,K.length,z,"",P.finish),K.pendingcb++,K.lastBufferedRequest=null,P.next)K.corkedRequestsFree=P.next,P.next=null;else K.corkedRequestsFree=new vw8(K);K.bufferedRequestCount=0}else{while(q){var{chunk:H,encoding:Z,callback:O}=q,w=K.objectMode?1:H.length;if(ib($,K,!1,w,H,Z,O),q=q.next,K.bufferedRequestCount--,K.writing)break}if(q===null)K.lastBufferedRequest=null}K.bufferedRequest=q,K.bufferProcessing=!1}V4.prototype._write=function($,K,q){q(new Error("_write() is not implemented"))};V4.prototype._writev=null;V4.prototype.end=function($,K,q){var Y=this._writableState;if(typeof $==="function")q=$,$=null,K=null;else if(typeof K==="function")q=K,K=null;if($!==null&&$!==void 0)this.write($,K);if(Y.corked)Y.corked=1,this.uncork();if(!Y.ending)of6(this,Y,q)};function Vw8($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function df6($,K){$._final(function(q){if(K.pendingcb--,q)$.emit("error",q);K.prefinished=!0,$.emit("prefinish"),iX($,K)})}function nf6($,K){if(!K.prefinished&&!K.finalCalled)if(typeof $._final==="function")K.pendingcb++,K.finalCalled=!0,rz.nextTick(df6,$,K);else K.prefinished=!0,$.emit("prefinish")}function iX($,K){var q=Vw8(K);if(q){if(nf6($,K),K.pendingcb===0)K.finished=!0,$.emit("finish")}return q}function of6($,K,q){if(K.ending=!0,iX($,K),q)if(K.finished)rz.nextTick(q);else $.once("finish",q);K.ended=!0,$.writable=!1}function af6($,K,q){var Y=$.entry;$.entry=null;while(Y){var z=Y.callback;K.pendingcb--,z(q),Y=Y.next}K.corkedRequestsFree.next=$}Object.defineProperty(V4.prototype,"destroyed",{get:function(){if(this._writableState===void 0)return!1;return this._writableState.destroyed},set:function($){if(!this._writableState)return;this._writableState.destroyed=$}});V4.prototype.destroy=fw8.destroy;V4.prototype._undestroy=fw8.undestroy;V4.prototype._destroy=function($,K){this.end(),K($)}});var sz=j((Zm1,Cw8)=>{var Mw8=UX(),rf6=Object.keys||function($){var K=[];for(var q in $)K.push(q);return K};Cw8.exports=vK;var Nw8=Object.create(RW());Nw8.inherits=$q();var hw8=nb(),db=Qb();Nw8.inherits(vK,hw8);{qA=rf6(db.prototype);for(dX=0;dX<qA.length;dX++)if(nX=qA[dX],!vK.prototype[nX])vK.prototype[nX]=db.prototype[nX]}var qA,nX,dX;function vK($){if(!(this instanceof vK))return new vK($);if(hw8.call(this,$),db.call(this,$),$&&$.readable===!1)this.readable=!1;if($&&$.writable===!1)this.writable=!1;if(this.allowHalfOpen=!0,$&&$.allowHalfOpen===!1)this.allowHalfOpen=!1;this.once("end",sf6)}Object.defineProperty(vK.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function sf6(){if(this.allowHalfOpen||this._writableState.ended)return;Mw8.nextTick(tf6,this)}function tf6($){$.end()}Object.defineProperty(vK.prototype,"destroyed",{get:function(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set:function($){if(this._readableState===void 0||this._writableState===void 0)return;this._readableState.destroyed=$,this._writableState.destroyed=$}});vK.prototype._destroy=function($,K){this.push(null),this.end(),Mw8.nextTick(K,$)}});var rb=j((XA6)=>{var ab=lX().Buffer,Rw8=ab.isEncoding||function($){switch($=""+$,$&&$.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function ef6($){if(!$)return"utf8";var K;while(!0)switch($){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return $;default:if(K)return;$=(""+$).toLowerCase(),K=!0}}function $A6($){var K=ef6($);if(typeof K!=="string"&&(ab.isEncoding===Rw8||!Rw8($)))throw new Error("Unknown encoding: "+$);return K||$}XA6.StringDecoder=oX;function oX($){this.encoding=$A6($);var K;switch(this.encoding){case"utf16le":this.text=JA6,this.end=WA6,K=4;break;case"utf8":this.fillLast=YA6,K=4;break;case"base64":this.text=HA6,this.end=ZA6,K=3;break;default:this.write=OA6,this.end=wA6;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=ab.allocUnsafe(K)}oX.prototype.write=function($){if($.length===0)return"";var K,q;if(this.lastNeed){if(K=this.fillLast($),K===void 0)return"";q=this.lastNeed,this.lastNeed=0}else q=0;if(q<$.length)return K?K+this.text($,q):this.text($,q);return K||""};oX.prototype.end=PA6;oX.prototype.text=zA6;oX.prototype.fillLast=function($){if(this.lastNeed<=$.length)return $.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,this.lastTotal-this.lastNeed,0,$.length),this.lastNeed-=$.length};function ob($){if($<=127)return 0;else if($>>5===6)return 2;else if($>>4===14)return 3;else if($>>3===30)return 4;return $>>6===2?-1:-2}function KA6($,K,q){var Y=K.length-1;if(Y<q)return 0;var z=ob(K[Y]);if(z>=0){if(z>0)$.lastNeed=z-1;return z}if(--Y<q||z===-2)return 0;if(z=ob(K[Y]),z>=0){if(z>0)$.lastNeed=z-2;return z}if(--Y<q||z===-2)return 0;if(z=ob(K[Y]),z>=0){if(z>0)if(z===2)z=0;else $.lastNeed=z-3;return z}return 0}function qA6($,K,q){if((K[0]&192)!==128)return $.lastNeed=0,"�";if($.lastNeed>1&&K.length>1){if((K[1]&192)!==128)return $.lastNeed=1,"�";if($.lastNeed>2&&K.length>2){if((K[2]&192)!==128)return $.lastNeed=2,"�"}}}function YA6($){var K=this.lastTotal-this.lastNeed,q=qA6(this,$,K);if(q!==void 0)return q;if(this.lastNeed<=$.length)return $.copy(this.lastChar,K,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,K,0,$.length),this.lastNeed-=$.length}function zA6($,K){var q=KA6(this,$,K);if(!this.lastNeed)return $.toString("utf8",K);this.lastTotal=q;var Y=$.length-(q-this.lastNeed);return $.copy(this.lastChar,0,Y),$.toString("utf8",K,Y)}function PA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed)return K+"�";return K}function JA6($,K){if(($.length-K)%2===0){var q=$.toString("utf16le",K);if(q){var Y=q.charCodeAt(q.length-1);if(Y>=55296&&Y<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1],q.slice(0,-1)}return q}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=$[$.length-1],$.toString("utf16le",K,$.length-1)}function WA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed){var q=this.lastTotal-this.lastNeed;return K+this.lastChar.toString("utf16le",0,q)}return K}function HA6($,K){var q=($.length-K)%3;if(q===0)return $.toString("base64",K);if(this.lastNeed=3-q,this.lastTotal=3,q===1)this.lastChar[0]=$[$.length-1];else this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1];return $.toString("base64",K,$.length-q)}function ZA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed)return K+this.lastChar.toString("base64",0,3-this.lastNeed);return K}function OA6($){return $.toString(this.encoding)}function wA6($){return $&&$.length?this.write($):""}});var nb=j((Xm1,pw8)=>{var EW=UX();pw8.exports=h1;var jA6=Jw8(),aX;h1.ReadableState=bw8;var wm1=F("events").EventEmitter,Lw8=function($,K){return $.listeners(K).length},Kg=F("stream"),rX=lX().Buffer,vA6=(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:{}).Uint8Array||function(){};function GA6($){return rX.from($)}function _A6($){return rX.isBuffer($)||$ instanceof vA6}var Iw8=Object.create(RW());Iw8.inherits=$q();var sb=F("util"),Q6=void 0;if(sb&&sb.debuglog)Q6=sb.debuglog("stream");else Q6=function(){};var fA6=Ow8(),xw8=Fb(),SW;Iw8.inherits(h1,Kg);var tb=["error","close","destroy","pause","resume"];function AA6($,K,q){if(typeof $.prependListener==="function")return $.prependListener(K,q);if(!$._events||!$._events[K])$.on(K,q);else if(jA6($._events[K]))$._events[K].unshift(q);else $._events[K]=[q,$._events[K]]}function bw8($,K){aX=aX||sz(),$=$||{};var q=K instanceof aX;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.readableObjectMode;var{highWaterMark:Y,readableHighWaterMark:z}=$,P=this.objectMode?16:16384;if(Y||Y===0)this.highWaterMark=Y;else if(q&&(z||z===0))this.highWaterMark=z;else this.highWaterMark=P;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new fA6,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=$.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,$.encoding){if(!SW)SW=rb().StringDecoder;this.decoder=new SW($.encoding),this.encoding=$.encoding}}function h1($){if(aX=aX||sz(),!(this instanceof h1))return new h1($);if(this._readableState=new bw8($,this),this.readable=!0,$){if(typeof $.read==="function")this._read=$.read;if(typeof $.destroy==="function")this._destroy=$.destroy}Kg.call(this)}Object.defineProperty(h1.prototype,"destroyed",{get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function($){if(!this._readableState)return;this._readableState.destroyed=$}});h1.prototype.destroy=xw8.destroy;h1.prototype._undestroy=xw8.undestroy;h1.prototype._destroy=function($,K){this.push(null),K($)};h1.prototype.push=function($,K){var q=this._readableState,Y;if(!q.objectMode){if(typeof $==="string"){if(K=K||q.defaultEncoding,K!==q.encoding)$=rX.from($,K),K="";Y=!0}}else Y=!0;return gw8(this,$,K,!1,Y)};h1.prototype.unshift=function($){return gw8(this,$,null,!0,!1)};function gw8($,K,q,Y,z){var P=$._readableState;if(K===null)P.reading=!1,NA6($,P);else{var J;if(!z)J=VA6(P,K);if(J)$.emit("error",J);else if(P.objectMode||K&&K.length>0){if(typeof K!=="string"&&!P.objectMode&&Object.getPrototypeOf(K)!==rX.prototype)K=GA6(K);if(Y)if(P.endEmitted)$.emit("error",new Error("stream.unshift() after end event"));else eb($,P,K,!0);else if(P.ended)$.emit("error",new Error("stream.push() after EOF"));else if(P.reading=!1,P.decoder&&!q)if(K=P.decoder.write(K),P.objectMode||K.length!==0)eb($,P,K,!1);else yw8($,P);else eb($,P,K,!1)}else if(!Y)P.reading=!1}return kA6(P)}function eb($,K,q,Y){if(K.flowing&&K.length===0&&!K.sync)$.emit("data",q),$.read(0);else{if(K.length+=K.objectMode?1:q.length,Y)K.buffer.unshift(q);else K.buffer.push(q);if(K.needReadable)YA($)}yw8($,K)}function VA6($,K){var q;if(!_A6(K)&&typeof K!=="string"&&K!==void 0&&!$.objectMode)q=new TypeError("Invalid non-string/buffer chunk");return q}function kA6($){return!$.ended&&($.needReadable||$.length<$.highWaterMark||$.length===0)}h1.prototype.isPaused=function(){return this._readableState.flowing===!1};h1.prototype.setEncoding=function($){if(!SW)SW=rb().StringDecoder;return this._readableState.decoder=new SW($),this._readableState.encoding=$,this};var Dw8=8388608;function MA6($){if($>=Dw8)$=Dw8;else $--,$|=$>>>1,$|=$>>>2,$|=$>>>4,$|=$>>>8,$|=$>>>16,$++;return $}function Sw8($,K){if($<=0||K.length===0&&K.ended)return 0;if(K.objectMode)return 1;if($!==$)if(K.flowing&&K.length)return K.buffer.head.data.length;else return K.length;if($>K.highWaterMark)K.highWaterMark=MA6($);if($<=K.length)return $;if(!K.ended)return K.needReadable=!0,0;return K.length}h1.prototype.read=function($){Q6("read",$),$=parseInt($,10);var K=this._readableState,q=$;if($!==0)K.emittedReadable=!1;if($===0&&K.needReadable&&(K.length>=K.highWaterMark||K.ended)){if(Q6("read: emitReadable",K.length,K.ended),K.length===0&&K.ended)$g(this);else YA(this);return null}if($=Sw8($,K),$===0&&K.ended){if(K.length===0)$g(this);return null}var Y=K.needReadable;if(Q6("need readable",Y),K.length===0||K.length-$<K.highWaterMark)Y=!0,Q6("length less than watermark",Y);if(K.ended||K.reading)Y=!1,Q6("reading or ended",Y);else if(Y){if(Q6("do read"),K.reading=!0,K.sync=!0,K.length===0)K.needReadable=!0;if(this._read(K.highWaterMark),K.sync=!1,!K.reading)$=Sw8(q,K)}var z;if($>0)z=uw8($,K);else z=null;if(z===null)K.needReadable=!0,$=0;else K.length-=$;if(K.length===0){if(!K.ended)K.needReadable=!0;if(q!==$&&K.ended)$g(this)}if(z!==null)this.emit("data",z);return z};function NA6($,K){if(K.ended)return;if(K.decoder){var q=K.decoder.end();if(q&&q.length)K.buffer.push(q),K.length+=K.objectMode?1:q.length}K.ended=!0,YA($)}function YA($){var K=$._readableState;if(K.needReadable=!1,!K.emittedReadable)if(Q6("emitReadable",K.flowing),K.emittedReadable=!0,K.sync)EW.nextTick(Ew8,$);else Ew8($)}function Ew8($){Q6("emit readable"),$.emit("readable"),qg($)}function yw8($,K){if(!K.readingMore)K.readingMore=!0,EW.nextTick(hA6,$,K)}function hA6($,K){var q=K.length;while(!K.reading&&!K.flowing&&!K.ended&&K.length<K.highWaterMark)if(Q6("maybeReadMore read 0"),$.read(0),q===K.length)break;else q=K.length;K.readingMore=!1}h1.prototype._read=function($){this.emit("error",new Error("_read() is not implemented"))};h1.prototype.pipe=function($,K){var q=this,Y=this._readableState;switch(Y.pipesCount){case 0:Y.pipes=$;break;case 1:Y.pipes=[Y.pipes,$];break;default:Y.pipes.push($);break}Y.pipesCount+=1,Q6("pipe count=%d opts=%j",Y.pipesCount,K);var z=(!K||K.end!==!1)&&$!==process.stdout&&$!==process.stderr,P=z?W:f;if(Y.endEmitted)EW.nextTick(P);else q.once("end",P);$.on("unpipe",J);function J(A,C){if(Q6("onunpipe"),A===q){if(C&&C.hasUnpiped===!1)C.hasUnpiped=!0,O()}}function W(){Q6("onend"),$.end()}var H=CA6(q);$.on("drain",H);var Z=!1;function O(){if(Q6("cleanup"),$.removeListener("close",G),$.removeListener("finish",v),$.removeListener("drain",H),$.removeListener("error",T),$.removeListener("unpipe",J),q.removeListener("end",W),q.removeListener("end",f),q.removeListener("data",X),Z=!0,Y.awaitDrain&&(!$._writableState||$._writableState.needDrain))H()}var w=!1;q.on("data",X);function X(A){Q6("ondata"),w=!1;var C=$.write(A);if(C===!1&&!w){if((Y.pipesCount===1&&Y.pipes===$||Y.pipesCount>1&&mw8(Y.pipes,$)!==-1)&&!Z)Q6("false write response, pause",Y.awaitDrain),Y.awaitDrain++,w=!0;q.pause()}}function T(A){if(Q6("onerror",A),f(),$.removeListener("error",T),Lw8($,"error")===0)$.emit("error",A)}AA6($,"error",T);function G(){$.removeListener("finish",v),f()}$.once("close",G);function v(){Q6("onfinish"),$.removeListener("close",G),f()}$.once("finish",v);function f(){Q6("unpipe"),q.unpipe($)}if($.emit("pipe",q),!Y.flowing)Q6("pipe resume"),q.resume();return $};function CA6($){return function(){var K=$._readableState;if(Q6("pipeOnDrain",K.awaitDrain),K.awaitDrain)K.awaitDrain--;if(K.awaitDrain===0&&Lw8($,"data"))K.flowing=!0,qg($)}}h1.prototype.unpipe=function($){var K=this._readableState,q={hasUnpiped:!1};if(K.pipesCount===0)return this;if(K.pipesCount===1){if($&&$!==K.pipes)return this;if(!$)$=K.pipes;if(K.pipes=null,K.pipesCount=0,K.flowing=!1,$)$.emit("unpipe",this,q);return this}if(!$){var{pipes:Y,pipesCount:z}=K;K.pipes=null,K.pipesCount=0,K.flowing=!1;for(var P=0;P<z;P++)Y[P].emit("unpipe",this,{hasUnpiped:!1});return this}var J=mw8(K.pipes,$);if(J===-1)return this;if(K.pipes.splice(J,1),K.pipesCount-=1,K.pipesCount===1)K.pipes=K.pipes[0];return $.emit("unpipe",this,q),this};h1.prototype.on=function($,K){var q=Kg.prototype.on.call(this,$,K);if($==="data"){if(this._readableState.flowing!==!1)this.resume()}else if($==="readable"){var Y=this._readableState;if(!Y.endEmitted&&!Y.readableListening){if(Y.readableListening=Y.needReadable=!0,Y.emittedReadable=!1,!Y.reading)EW.nextTick(RA6,this);else if(Y.length)YA(this)}}return q};h1.prototype.addListener=h1.prototype.on;function RA6($){Q6("readable nexttick read 0"),$.read(0)}h1.prototype.resume=function(){var $=this._readableState;if(!$.flowing)Q6("resume"),$.flowing=!0,DA6(this,$);return this};function DA6($,K){if(!K.resumeScheduled)K.resumeScheduled=!0,EW.nextTick(SA6,$,K)}function SA6($,K){if(!K.reading)Q6("resume read 0"),$.read(0);if(K.resumeScheduled=!1,K.awaitDrain=0,$.emit("resume"),qg($),K.flowing&&!K.reading)$.read(0)}h1.prototype.pause=function(){if(Q6("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)Q6("pause"),this._readableState.flowing=!1,this.emit("pause");return this};function qg($){var K=$._readableState;Q6("flow",K.flowing);while(K.flowing&&$.read()!==null);}h1.prototype.wrap=function($){var K=this,q=this._readableState,Y=!1;$.on("end",function(){if(Q6("wrapped end"),q.decoder&&!q.ended){var J=q.decoder.end();if(J&&J.length)K.push(J)}K.push(null)}),$.on("data",function(J){if(Q6("wrapped data"),q.decoder)J=q.decoder.write(J);if(q.objectMode&&(J===null||J===void 0))return;else if(!q.objectMode&&(!J||!J.length))return;var W=K.push(J);if(!W)Y=!0,$.pause()});for(var z in $)if(this[z]===void 0&&typeof $[z]==="function")this[z]=function(J){return function(){return $[J].apply($,arguments)}}(z);for(var P=0;P<tb.length;P++)$.on(tb[P],this.emit.bind(this,tb[P]));return this._read=function(J){if(Q6("wrapped _read",J),Y)Y=!1,$.resume()},this};Object.defineProperty(h1.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});h1._fromList=uw8;function uw8($,K){if(K.length===0)return null;var q;if(K.objectMode)q=K.buffer.shift();else if(!$||$>=K.length){if(K.decoder)q=K.buffer.join("");else if(K.buffer.length===1)q=K.buffer.head.data;else q=K.buffer.concat(K.length);K.buffer.clear()}else q=EA6($,K.buffer,K.decoder);return q}function EA6($,K,q){var Y;if($<K.head.data.length)Y=K.head.data.slice(0,$),K.head.data=K.head.data.slice($);else if($===K.head.data.length)Y=K.shift();else Y=q?LA6($,K):IA6($,K);return Y}function LA6($,K){var q=K.head,Y=1,z=q.data;$-=z.length;while(q=q.next){var P=q.data,J=$>P.length?P.length:$;if(J===P.length)z+=P;else z+=P.slice(0,$);if($-=J,$===0){if(J===P.length)if(++Y,q.next)K.head=q.next;else K.head=K.tail=null;else K.head=q,q.data=P.slice(J);break}++Y}return K.length-=Y,z}function IA6($,K){var q=rX.allocUnsafe($),Y=K.head,z=1;Y.data.copy(q),$-=Y.data.length;while(Y=Y.next){var P=Y.data,J=$>P.length?P.length:$;if(P.copy(q,q.length-$,0,J),$-=J,$===0){if(J===P.length)if(++z,Y.next)K.head=Y.next;else K.head=K.tail=null;else K.head=Y,Y.data=P.slice(J);break}++z}return K.length-=z,q}function $g($){var K=$._readableState;if(K.length>0)throw new Error('"endReadable()" called on non-empty stream');if(!K.endEmitted)K.ended=!0,EW.nextTick(xA6,K,$)}function xA6($,K){if(!$.endEmitted&&$.length===0)$.endEmitted=!0,K.readable=!1,K.emit("end")}function mw8($,K){for(var q=0,Y=$.length;q<Y;q++)if($[q]===K)return q;return-1}});var Yg=j((Tm1,Uw8)=>{Uw8.exports=GK;var zA=sz(),Bw8=Object.create(RW());Bw8.inherits=$q();Bw8.inherits(GK,zA);function bA6($,K){var q=this._transformState;q.transforming=!1;var Y=q.writecb;if(!Y)return this.emit("error",new Error("write callback called multiple times"));if(q.writechunk=null,q.writecb=null,K!=null)this.push(K);Y($);var z=this._readableState;if(z.reading=!1,z.needReadable||z.length<z.highWaterMark)this._read(z.highWaterMark)}function GK($){if(!(this instanceof GK))return new GK($);if(zA.call(this,$),this._transformState={afterTransform:bA6.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,$){if(typeof $.transform==="function")this._transform=$.transform;if(typeof $.flush==="function")this._flush=$.flush}this.on("prefinish",gA6)}function gA6(){var $=this;if(typeof this._flush==="function")this._flush(function(K,q){cw8($,K,q)});else cw8(this,null,null)}GK.prototype.push=function($,K){return this._transformState.needTransform=!1,zA.prototype.push.call(this,$,K)};GK.prototype._transform=function($,K,q){throw new Error("_transform() is not implemented")};GK.prototype._write=function($,K,q){var Y=this._transformState;if(Y.writecb=q,Y.writechunk=$,Y.writeencoding=K,!Y.transforming){var z=this._readableState;if(Y.needTransform||z.needReadable||z.length<z.highWaterMark)this._read(z.highWaterMark)}};GK.prototype._read=function($){var K=this._transformState;if(K.writechunk!==null&&K.writecb&&!K.transforming)K.transforming=!0,this._transform(K.writechunk,K.writeencoding,K.afterTransform);else K.needTransform=!0};GK.prototype._destroy=function($,K){var q=this;zA.prototype._destroy.call(this,$,function(Y){K(Y),q.emit("close")})};function cw8($,K,q){if(K)return $.emit("error",K);if(q!=null)$.push(q);if($._writableState.length)throw new Error("Calling transform done when ws.length != 0");if($._transformState.transforming)throw new Error("Calling transform done when still transforming");return $.push(null)}});var Qw8=j((jm1,iw8)=>{iw8.exports=sX;var lw8=Yg(),Fw8=Object.create(RW());Fw8.inherits=$q();Fw8.inherits(sX,lw8);function sX($){if(!(this instanceof sX))return new sX($);lw8.call(this,$)}sX.prototype._transform=function($,K,q){q(null,$)}});var dw8=j((z3,PA)=>{var J5=F("stream");if(process.env.READABLE_STREAM==="disable"&&J5)PA.exports=J5,z3=PA.exports=J5.Readable,z3.Readable=J5.Readable,z3.Writable=J5.Writable,z3.Duplex=J5.Duplex,z3.Transform=J5.Transform,z3.PassThrough=J5.PassThrough,z3.Stream=J5;else z3=PA.exports=nb(),z3.Stream=J5||z3,z3.Readable=z3,z3.Writable=Qb(),z3.Duplex=sz(),z3.Transform=Yg(),z3.PassThrough=Qw8()});var ow8=j((vm1,nw8)=>{nw8.exports=dw8().PassThrough});var tw8=j((Gm1,sw8)=>{var aw8=F("util"),HA=ow8();sw8.exports={Readable:JA,Writable:WA};aw8.inherits(JA,HA);aw8.inherits(WA,HA);function rw8($,K,q){$[K]=function(){return delete $[K],q.apply(this,arguments),this[K].apply(this,arguments)}}function JA($,K){if(!(this instanceof JA))return new JA($,K);HA.call(this,K),rw8(this,"_read",function(){var q=$.call(this,K),Y=this.emit.bind(this,"error");q.on("error",Y),q.pipe(this)}),this.emit("readable")}function WA($,K){if(!(this instanceof WA))return new WA($,K);HA.call(this,K),rw8(this,"_write",function(){var q=$.call(this,K),Y=this.emit.bind(this,"error");q.on("error",Y),this.pipe(q)}),this.emit("writable")}});var zg=j((_m1,ew8)=>{/*!
|
|
408
|
+
GFS4: `),console.error($)};if(!Q1[Y3]){if(yb=global[Y3]||[],Yw8(Q1,yb),Q1.close=function($){function K(q,Y){return $.call(Q1,q,function(z){if(!z)qw8();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty(K,of,{value:$}),K}(Q1.close),Q1.closeSync=function($){function K(q){$.apply(Q1,arguments),qw8()}return Object.defineProperty(K,of,{value:$}),K}(Q1.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){az(Q1[Y3]),F("assert").equal(Q1[Y3].length,0)})}var yb;if(!global[Y3])Yw8(global,Q1[Y3]);pb.exports=ub(o_6(Q1));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Q1.__patched)pb.exports=ub(Q1),Q1.__patched=!0;function ub($){d_6($),$.gracefulify=ub,$.createReadStream=R,$.createWriteStream=I;var K=$.readFile;$.readFile=q;function q(b,h,L){if(typeof h==="function")L=h,h=null;return B(b,h,L);function B(i,X8,N8,h8){return K(i,X8,function(c8){if(c8&&(c8.code==="EMFILE"||c8.code==="ENFILE"))hW([B,[i,X8,N8],c8,h8||Date.now(),Date.now()]);else if(typeof N8==="function")N8.apply(this,arguments)})}}var Y=$.writeFile;$.writeFile=z;function z(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return Y(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var P=$.appendFile;if(P)$.appendFile=J;function J(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return P(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var W=$.copyFile;if(W)$.copyFile=H;function H(b,h,L,B){if(typeof L==="function")B=L,L=0;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return W(X8,N8,h8,function(g8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}var Z=$.readdir;$.readdir=w;var O=/^v[0-5]\./;function w(b,h,L){if(typeof h==="function")L=h,h=null;var B=O.test(process.version)?function X8(N8,h8,c8,E8){return Z(N8,i(N8,h8,c8,E8))}:function X8(N8,h8,c8,E8){return Z(N8,h8,i(N8,h8,c8,E8))};return B(b,h,L);function i(X8,N8,h8,c8){return function(E8,g8){if(E8&&(E8.code==="EMFILE"||E8.code==="ENFILE"))hW([B,[X8,N8,h8],E8,c8||Date.now(),Date.now()]);else{if(g8&&g8.sort)g8.sort();if(typeof h8==="function")h8.call(this,E8,g8)}}}}if(process.version.substr(0,4)==="v0.8"){var X=n_6($);A=X.ReadStream,V=X.WriteStream}var T=$.ReadStream;if(T)A.prototype=Object.create(T.prototype),A.prototype.open=C;var G=$.WriteStream;if(G)V.prototype=Object.create(G.prototype),V.prototype.open=M;Object.defineProperty($,"ReadStream",{get:function(){return A},set:function(b){A=b},enumerable:!0,configurable:!0}),Object.defineProperty($,"WriteStream",{get:function(){return V},set:function(b){V=b},enumerable:!0,configurable:!0});var v=A;Object.defineProperty($,"FileReadStream",{get:function(){return v},set:function(b){v=b},enumerable:!0,configurable:!0});var f=V;Object.defineProperty($,"FileWriteStream",{get:function(){return f},set:function(b){f=b},enumerable:!0,configurable:!0});function A(b,h){if(this instanceof A)return T.apply(this,arguments),this;else return A.apply(Object.create(A.prototype),arguments)}function C(){var b=this;m(b.path,b.flags,b.mode,function(h,L){if(h){if(b.autoClose)b.destroy();b.emit("error",h)}else b.fd=L,b.emit("open",L),b.read()})}function V(b,h){if(this instanceof V)return G.apply(this,arguments),this;else return V.apply(Object.create(V.prototype),arguments)}function M(){var b=this;m(b.path,b.flags,b.mode,function(h,L){if(h)b.destroy(),b.emit("error",h);else b.fd=L,b.emit("open",L)})}function R(b,h){return new $.ReadStream(b,h)}function I(b,h){return new $.WriteStream(b,h)}var D=$.open;$.open=m;function m(b,h,L,B){if(typeof L==="function")B=L,L=null;return i(b,h,L,B);function i(X8,N8,h8,c8,E8){return D(X8,N8,h8,function(g8,t8){if(g8&&(g8.code==="EMFILE"||g8.code==="ENFILE"))hW([i,[X8,N8,h8,c8],g8,E8||Date.now(),Date.now()]);else if(typeof c8==="function")c8.apply(this,arguments)})}}return $}function hW($){az("ENQUEUE",$[0].name,$[1]),Q1[Y3].push($),mb()}var nf;function qw8(){var $=Date.now();for(var K=0;K<Q1[Y3].length;++K)if(Q1[Y3][K].length>2)Q1[Y3][K][3]=$,Q1[Y3][K][4]=$;mb()}function mb(){if(clearTimeout(nf),nf=void 0,Q1[Y3].length===0)return;var $=Q1[Y3].shift(),K=$[0],q=$[1],Y=$[2],z=$[3],P=$[4];if(z===void 0)az("RETRY",K.name,q),K.apply(null,q);else if(Date.now()-z>=60000){az("TIMEOUT",K.name,q);var J=q.pop();if(typeof J==="function")J.call(null,Y)}else{var W=Date.now()-P,H=Math.max(P-z,1),Z=Math.min(H*1.2,100);if(W>=Z)az("RETRY",K.name,q),K.apply(null,q.concat([z]));else Q1[Y3].push($)}if(nf===void 0)nf=setTimeout(mb,0)}});var af=j((Km1,zw8)=>{var P5=($)=>$!==null&&typeof $==="object"&&typeof $.pipe==="function";P5.writable=($)=>P5($)&&$.writable!==!1&&typeof $._write==="function"&&typeof $._writableState==="object";P5.readable=($)=>P5($)&&$.readable!==!1&&typeof $._read==="function"&&typeof $._readableState==="object";P5.duplex=($)=>P5.writable($)&&P5.readable($);P5.transform=($)=>P5.duplex($)&&typeof $._transform==="function";zw8.exports=P5});var UX=j((qm1,Bb)=>{if(typeof process==="undefined"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)Bb.exports={nextTick:r_6};else Bb.exports=process;function r_6($,K,q,Y){if(typeof $!=="function")throw new TypeError('"callback" argument must be a function');var z=arguments.length,P,J;switch(z){case 0:case 1:return process.nextTick($);case 2:return process.nextTick(function W(){$.call(null,K)});case 3:return process.nextTick(function W(){$.call(null,K,q)});case 4:return process.nextTick(function W(){$.call(null,K,q,Y)});default:P=new Array(z-1),J=0;while(J<P.length)P[J++]=arguments[J];return process.nextTick(function W(){$.apply(null,P)})}}});var Jw8=j((Ym1,Pw8)=>{var s_6={}.toString;Pw8.exports=Array.isArray||function($){return s_6.call($)=="[object Array]"}});var lX=j((Ub,Hw8)=>{var rf=F("buffer"),jK=rf.Buffer;function Ww8($,K){for(var q in $)K[q]=$[q]}if(jK.from&&jK.alloc&&jK.allocUnsafe&&jK.allocUnsafeSlow)Hw8.exports=rf;else Ww8(rf,Ub),Ub.Buffer=CW;function CW($,K,q){return jK($,K,q)}Ww8(jK,CW);CW.from=function($,K,q){if(typeof $==="number")throw new TypeError("Argument must not be a number");return jK($,K,q)};CW.alloc=function($,K,q){if(typeof $!=="number")throw new TypeError("Argument must be a number");var Y=jK($);if(K!==void 0)if(typeof q==="string")Y.fill(K,q);else Y.fill(K);else Y.fill(0);return Y};CW.allocUnsafe=function($){if(typeof $!=="number")throw new TypeError("Argument must be a number");return jK($)};CW.allocUnsafeSlow=function($){if(typeof $!=="number")throw new TypeError("Argument must be a number");return rf.SlowBuffer($)}});var RW=j((Xf6)=>{function t_6($){if(Array.isArray)return Array.isArray($);return sf($)==="[object Array]"}Xf6.isArray=t_6;function e_6($){return typeof $==="boolean"}Xf6.isBoolean=e_6;function $f6($){return $===null}Xf6.isNull=$f6;function Kf6($){return $==null}Xf6.isNullOrUndefined=Kf6;function qf6($){return typeof $==="number"}Xf6.isNumber=qf6;function Yf6($){return typeof $==="string"}Xf6.isString=Yf6;function zf6($){return typeof $==="symbol"}Xf6.isSymbol=zf6;function Pf6($){return $===void 0}Xf6.isUndefined=Pf6;function Jf6($){return sf($)==="[object RegExp]"}Xf6.isRegExp=Jf6;function Wf6($){return typeof $==="object"&&$!==null}Xf6.isObject=Wf6;function Hf6($){return sf($)==="[object Date]"}Xf6.isDate=Hf6;function Zf6($){return sf($)==="[object Error]"||$ instanceof Error}Xf6.isError=Zf6;function Of6($){return typeof $==="function"}Xf6.isFunction=Of6;function wf6($){return $===null||typeof $==="boolean"||typeof $==="number"||typeof $==="string"||typeof $==="symbol"||typeof $==="undefined"}Xf6.isPrimitive=wf6;Xf6.isBuffer=F("buffer").Buffer.isBuffer;function sf($){return Object.prototype.toString.call($)}});var Ow8=j((Pm1,lb)=>{function Sf6($,K){if(!($ instanceof K))throw new TypeError("Cannot call a class as a function")}var Zw8=lX().Buffer,FX=F("util");function Ef6($,K,q){$.copy(K,q)}lb.exports=function(){function $(){Sf6(this,$),this.head=null,this.tail=null,this.length=0}return $.prototype.push=function K(q){var Y={data:q,next:null};if(this.length>0)this.tail.next=Y;else this.head=Y;this.tail=Y,++this.length},$.prototype.unshift=function K(q){var Y={data:q,next:this.head};if(this.length===0)this.tail=Y;this.head=Y,++this.length},$.prototype.shift=function K(){if(this.length===0)return;var q=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,q},$.prototype.clear=function K(){this.head=this.tail=null,this.length=0},$.prototype.join=function K(q){if(this.length===0)return"";var Y=this.head,z=""+Y.data;while(Y=Y.next)z+=q+Y.data;return z},$.prototype.concat=function K(q){if(this.length===0)return Zw8.alloc(0);var Y=Zw8.allocUnsafe(q>>>0),z=this.head,P=0;while(z)Ef6(z.data,Y,P),P+=z.data.length,z=z.next;return Y},$}();if(FX&&FX.inspect&&FX.inspect.custom)lb.exports.prototype[FX.inspect.custom]=function(){var $=FX.inspect({length:this.length});return this.constructor.name+" "+$}});var Fb=j((Jm1,ww8)=>{var tf=UX();function Lf6($,K){var q=this,Y=this._readableState&&this._readableState.destroyed,z=this._writableState&&this._writableState.destroyed;if(Y||z){if(K)K($);else if($){if(!this._writableState)tf.nextTick(ef,this,$);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,tf.nextTick(ef,this,$)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy($||null,function(P){if(!K&&P){if(!q._writableState)tf.nextTick(ef,q,P);else if(!q._writableState.errorEmitted)q._writableState.errorEmitted=!0,tf.nextTick(ef,q,P)}else if(K)K(P)}),this}function If6(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function ef($,K){$.emit("error",K)}ww8.exports={destroy:Lf6,undestroy:If6}});var Tw8=j((Wm1,Xw8)=>{Xw8.exports=F("util").deprecate});var Qb=j((Hm1,kw8)=>{var rz=UX();kw8.exports=A4;function vw8($){var K=this;this.next=null,this.entry=null,this.finish=function(){af6(K,$)}}var xf6=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:rz.nextTick,DW;A4.WritableState=QX;var Gw8=Object.create(RW());Gw8.inherits=$q();var bf6={deprecate:Tw8()},_w8=F("stream"),KA=lX().Buffer,gf6=(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:{}).Uint8Array||function(){};function yf6($){return KA.from($)}function uf6($){return KA.isBuffer($)||$ instanceof gf6}var fw8=Fb();Gw8.inherits(A4,_w8);function mf6(){}function QX($,K){DW=DW||sz(),$=$||{};var q=K instanceof DW;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.writableObjectMode;var{highWaterMark:Y,writableHighWaterMark:z}=$,P=this.objectMode?16:16384;if(Y||Y===0)this.highWaterMark=Y;else if(q&&(z||z===0))this.highWaterMark=z;else this.highWaterMark=P;this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var J=$.decodeStrings===!1;this.decodeStrings=!J,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(W){if6(K,W)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new vw8(this)}QX.prototype.getBuffer=function $(){var K=this.bufferedRequest,q=[];while(K)q.push(K),K=K.next;return q};(function(){try{Object.defineProperty(QX.prototype,"buffer",{get:bf6.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch($){}})();var $A;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")$A=Function.prototype[Symbol.hasInstance],Object.defineProperty(A4,Symbol.hasInstance,{value:function($){if($A.call(this,$))return!0;if(this!==A4)return!1;return $&&$._writableState instanceof QX}});else $A=function($){return $ instanceof this};function A4($){if(DW=DW||sz(),!$A.call(A4,this)&&!(this instanceof DW))return new A4($);if(this._writableState=new QX($,this),this.writable=!0,$){if(typeof $.write==="function")this._write=$.write;if(typeof $.writev==="function")this._writev=$.writev;if(typeof $.destroy==="function")this._destroy=$.destroy;if(typeof $.final==="function")this._final=$.final}_w8.call(this)}A4.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function pf6($,K){var q=new Error("write after end");$.emit("error",q),rz.nextTick(K,q)}function cf6($,K,q,Y){var z=!0,P=!1;if(q===null)P=new TypeError("May not write null values to stream");else if(typeof q!=="string"&&q!==void 0&&!K.objectMode)P=new TypeError("Invalid non-string/buffer chunk");if(P)$.emit("error",P),rz.nextTick(Y,P),z=!1;return z}A4.prototype.write=function($,K,q){var Y=this._writableState,z=!1,P=!Y.objectMode&&uf6($);if(P&&!KA.isBuffer($))$=yf6($);if(typeof K==="function")q=K,K=null;if(P)K="buffer";else if(!K)K=Y.defaultEncoding;if(typeof q!=="function")q=mf6;if(Y.ended)pf6(this,q);else if(P||cf6(this,Y,$,q))Y.pendingcb++,z=Uf6(this,Y,P,$,K,q);return z};A4.prototype.cork=function(){var $=this._writableState;$.corked++};A4.prototype.uncork=function(){var $=this._writableState;if($.corked){if($.corked--,!$.writing&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest)Aw8(this,$)}};A4.prototype.setDefaultEncoding=function $(K){if(typeof K==="string")K=K.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((K+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+K);return this._writableState.defaultEncoding=K,this};function Bf6($,K,q){if(!$.objectMode&&$.decodeStrings!==!1&&typeof K==="string")K=KA.from(K,q);return K}Object.defineProperty(A4.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Uf6($,K,q,Y,z,P){if(!q){var J=Bf6(K,Y,z);if(Y!==J)q=!0,z="buffer",Y=J}var W=K.objectMode?1:Y.length;K.length+=W;var H=K.length<K.highWaterMark;if(!H)K.needDrain=!0;if(K.writing||K.corked){var Z=K.lastBufferedRequest;if(K.lastBufferedRequest={chunk:Y,encoding:z,isBuf:q,callback:P,next:null},Z)Z.next=K.lastBufferedRequest;else K.bufferedRequest=K.lastBufferedRequest;K.bufferedRequestCount+=1}else ib($,K,!1,W,Y,z,P);return H}function ib($,K,q,Y,z,P,J){if(K.writelen=Y,K.writecb=J,K.writing=!0,K.sync=!0,q)$._writev(z,K.onwrite);else $._write(z,P,K.onwrite);K.sync=!1}function lf6($,K,q,Y,z){if(--K.pendingcb,q)rz.nextTick(z,Y),rz.nextTick(iX,$,K),$._writableState.errorEmitted=!0,$.emit("error",Y);else z(Y),$._writableState.errorEmitted=!0,$.emit("error",Y),iX($,K)}function Ff6($){$.writing=!1,$.writecb=null,$.length-=$.writelen,$.writelen=0}function if6($,K){var q=$._writableState,Y=q.sync,z=q.writecb;if(Ff6(q),K)lf6($,q,Y,K,z);else{var P=Vw8(q);if(!P&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest)Aw8($,q);if(Y)xf6(jw8,$,q,P,z);else jw8($,q,P,z)}}function jw8($,K,q,Y){if(!q)Qf6($,K);K.pendingcb--,Y(),iX($,K)}function Qf6($,K){if(K.length===0&&K.needDrain)K.needDrain=!1,$.emit("drain")}function Aw8($,K){K.bufferProcessing=!0;var q=K.bufferedRequest;if($._writev&&q&&q.next){var Y=K.bufferedRequestCount,z=new Array(Y),P=K.corkedRequestsFree;P.entry=q;var J=0,W=!0;while(q){if(z[J]=q,!q.isBuf)W=!1;q=q.next,J+=1}if(z.allBuffers=W,ib($,K,!0,K.length,z,"",P.finish),K.pendingcb++,K.lastBufferedRequest=null,P.next)K.corkedRequestsFree=P.next,P.next=null;else K.corkedRequestsFree=new vw8(K);K.bufferedRequestCount=0}else{while(q){var{chunk:H,encoding:Z,callback:O}=q,w=K.objectMode?1:H.length;if(ib($,K,!1,w,H,Z,O),q=q.next,K.bufferedRequestCount--,K.writing)break}if(q===null)K.lastBufferedRequest=null}K.bufferedRequest=q,K.bufferProcessing=!1}A4.prototype._write=function($,K,q){q(new Error("_write() is not implemented"))};A4.prototype._writev=null;A4.prototype.end=function($,K,q){var Y=this._writableState;if(typeof $==="function")q=$,$=null,K=null;else if(typeof K==="function")q=K,K=null;if($!==null&&$!==void 0)this.write($,K);if(Y.corked)Y.corked=1,this.uncork();if(!Y.ending)of6(this,Y,q)};function Vw8($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function df6($,K){$._final(function(q){if(K.pendingcb--,q)$.emit("error",q);K.prefinished=!0,$.emit("prefinish"),iX($,K)})}function nf6($,K){if(!K.prefinished&&!K.finalCalled)if(typeof $._final==="function")K.pendingcb++,K.finalCalled=!0,rz.nextTick(df6,$,K);else K.prefinished=!0,$.emit("prefinish")}function iX($,K){var q=Vw8(K);if(q){if(nf6($,K),K.pendingcb===0)K.finished=!0,$.emit("finish")}return q}function of6($,K,q){if(K.ending=!0,iX($,K),q)if(K.finished)rz.nextTick(q);else $.once("finish",q);K.ended=!0,$.writable=!1}function af6($,K,q){var Y=$.entry;$.entry=null;while(Y){var z=Y.callback;K.pendingcb--,z(q),Y=Y.next}K.corkedRequestsFree.next=$}Object.defineProperty(A4.prototype,"destroyed",{get:function(){if(this._writableState===void 0)return!1;return this._writableState.destroyed},set:function($){if(!this._writableState)return;this._writableState.destroyed=$}});A4.prototype.destroy=fw8.destroy;A4.prototype._undestroy=fw8.undestroy;A4.prototype._destroy=function($,K){this.end(),K($)}});var sz=j((Zm1,Cw8)=>{var Mw8=UX(),rf6=Object.keys||function($){var K=[];for(var q in $)K.push(q);return K};Cw8.exports=vK;var Nw8=Object.create(RW());Nw8.inherits=$q();var hw8=nb(),db=Qb();Nw8.inherits(vK,hw8);{qA=rf6(db.prototype);for(dX=0;dX<qA.length;dX++)if(nX=qA[dX],!vK.prototype[nX])vK.prototype[nX]=db.prototype[nX]}var qA,nX,dX;function vK($){if(!(this instanceof vK))return new vK($);if(hw8.call(this,$),db.call(this,$),$&&$.readable===!1)this.readable=!1;if($&&$.writable===!1)this.writable=!1;if(this.allowHalfOpen=!0,$&&$.allowHalfOpen===!1)this.allowHalfOpen=!1;this.once("end",sf6)}Object.defineProperty(vK.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function sf6(){if(this.allowHalfOpen||this._writableState.ended)return;Mw8.nextTick(tf6,this)}function tf6($){$.end()}Object.defineProperty(vK.prototype,"destroyed",{get:function(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set:function($){if(this._readableState===void 0||this._writableState===void 0)return;this._readableState.destroyed=$,this._writableState.destroyed=$}});vK.prototype._destroy=function($,K){this.push(null),this.end(),Mw8.nextTick(K,$)}});var rb=j((XA6)=>{var ab=lX().Buffer,Rw8=ab.isEncoding||function($){switch($=""+$,$&&$.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function ef6($){if(!$)return"utf8";var K;while(!0)switch($){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return $;default:if(K)return;$=(""+$).toLowerCase(),K=!0}}function $A6($){var K=ef6($);if(typeof K!=="string"&&(ab.isEncoding===Rw8||!Rw8($)))throw new Error("Unknown encoding: "+$);return K||$}XA6.StringDecoder=oX;function oX($){this.encoding=$A6($);var K;switch(this.encoding){case"utf16le":this.text=JA6,this.end=WA6,K=4;break;case"utf8":this.fillLast=YA6,K=4;break;case"base64":this.text=HA6,this.end=ZA6,K=3;break;default:this.write=OA6,this.end=wA6;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=ab.allocUnsafe(K)}oX.prototype.write=function($){if($.length===0)return"";var K,q;if(this.lastNeed){if(K=this.fillLast($),K===void 0)return"";q=this.lastNeed,this.lastNeed=0}else q=0;if(q<$.length)return K?K+this.text($,q):this.text($,q);return K||""};oX.prototype.end=PA6;oX.prototype.text=zA6;oX.prototype.fillLast=function($){if(this.lastNeed<=$.length)return $.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,this.lastTotal-this.lastNeed,0,$.length),this.lastNeed-=$.length};function ob($){if($<=127)return 0;else if($>>5===6)return 2;else if($>>4===14)return 3;else if($>>3===30)return 4;return $>>6===2?-1:-2}function KA6($,K,q){var Y=K.length-1;if(Y<q)return 0;var z=ob(K[Y]);if(z>=0){if(z>0)$.lastNeed=z-1;return z}if(--Y<q||z===-2)return 0;if(z=ob(K[Y]),z>=0){if(z>0)$.lastNeed=z-2;return z}if(--Y<q||z===-2)return 0;if(z=ob(K[Y]),z>=0){if(z>0)if(z===2)z=0;else $.lastNeed=z-3;return z}return 0}function qA6($,K,q){if((K[0]&192)!==128)return $.lastNeed=0,"�";if($.lastNeed>1&&K.length>1){if((K[1]&192)!==128)return $.lastNeed=1,"�";if($.lastNeed>2&&K.length>2){if((K[2]&192)!==128)return $.lastNeed=2,"�"}}}function YA6($){var K=this.lastTotal-this.lastNeed,q=qA6(this,$,K);if(q!==void 0)return q;if(this.lastNeed<=$.length)return $.copy(this.lastChar,K,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,K,0,$.length),this.lastNeed-=$.length}function zA6($,K){var q=KA6(this,$,K);if(!this.lastNeed)return $.toString("utf8",K);this.lastTotal=q;var Y=$.length-(q-this.lastNeed);return $.copy(this.lastChar,0,Y),$.toString("utf8",K,Y)}function PA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed)return K+"�";return K}function JA6($,K){if(($.length-K)%2===0){var q=$.toString("utf16le",K);if(q){var Y=q.charCodeAt(q.length-1);if(Y>=55296&&Y<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1],q.slice(0,-1)}return q}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=$[$.length-1],$.toString("utf16le",K,$.length-1)}function WA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed){var q=this.lastTotal-this.lastNeed;return K+this.lastChar.toString("utf16le",0,q)}return K}function HA6($,K){var q=($.length-K)%3;if(q===0)return $.toString("base64",K);if(this.lastNeed=3-q,this.lastTotal=3,q===1)this.lastChar[0]=$[$.length-1];else this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1];return $.toString("base64",K,$.length-q)}function ZA6($){var K=$&&$.length?this.write($):"";if(this.lastNeed)return K+this.lastChar.toString("base64",0,3-this.lastNeed);return K}function OA6($){return $.toString(this.encoding)}function wA6($){return $&&$.length?this.write($):""}});var nb=j((Xm1,pw8)=>{var EW=UX();pw8.exports=h1;var jA6=Jw8(),aX;h1.ReadableState=bw8;var wm1=F("events").EventEmitter,Lw8=function($,K){return $.listeners(K).length},Kg=F("stream"),rX=lX().Buffer,vA6=(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:{}).Uint8Array||function(){};function GA6($){return rX.from($)}function _A6($){return rX.isBuffer($)||$ instanceof vA6}var Iw8=Object.create(RW());Iw8.inherits=$q();var sb=F("util"),Q6=void 0;if(sb&&sb.debuglog)Q6=sb.debuglog("stream");else Q6=function(){};var fA6=Ow8(),xw8=Fb(),SW;Iw8.inherits(h1,Kg);var tb=["error","close","destroy","pause","resume"];function AA6($,K,q){if(typeof $.prependListener==="function")return $.prependListener(K,q);if(!$._events||!$._events[K])$.on(K,q);else if(jA6($._events[K]))$._events[K].unshift(q);else $._events[K]=[q,$._events[K]]}function bw8($,K){aX=aX||sz(),$=$||{};var q=K instanceof aX;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.readableObjectMode;var{highWaterMark:Y,readableHighWaterMark:z}=$,P=this.objectMode?16:16384;if(Y||Y===0)this.highWaterMark=Y;else if(q&&(z||z===0))this.highWaterMark=z;else this.highWaterMark=P;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new fA6,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=$.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,$.encoding){if(!SW)SW=rb().StringDecoder;this.decoder=new SW($.encoding),this.encoding=$.encoding}}function h1($){if(aX=aX||sz(),!(this instanceof h1))return new h1($);if(this._readableState=new bw8($,this),this.readable=!0,$){if(typeof $.read==="function")this._read=$.read;if(typeof $.destroy==="function")this._destroy=$.destroy}Kg.call(this)}Object.defineProperty(h1.prototype,"destroyed",{get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function($){if(!this._readableState)return;this._readableState.destroyed=$}});h1.prototype.destroy=xw8.destroy;h1.prototype._undestroy=xw8.undestroy;h1.prototype._destroy=function($,K){this.push(null),K($)};h1.prototype.push=function($,K){var q=this._readableState,Y;if(!q.objectMode){if(typeof $==="string"){if(K=K||q.defaultEncoding,K!==q.encoding)$=rX.from($,K),K="";Y=!0}}else Y=!0;return gw8(this,$,K,!1,Y)};h1.prototype.unshift=function($){return gw8(this,$,null,!0,!1)};function gw8($,K,q,Y,z){var P=$._readableState;if(K===null)P.reading=!1,NA6($,P);else{var J;if(!z)J=VA6(P,K);if(J)$.emit("error",J);else if(P.objectMode||K&&K.length>0){if(typeof K!=="string"&&!P.objectMode&&Object.getPrototypeOf(K)!==rX.prototype)K=GA6(K);if(Y)if(P.endEmitted)$.emit("error",new Error("stream.unshift() after end event"));else eb($,P,K,!0);else if(P.ended)$.emit("error",new Error("stream.push() after EOF"));else if(P.reading=!1,P.decoder&&!q)if(K=P.decoder.write(K),P.objectMode||K.length!==0)eb($,P,K,!1);else yw8($,P);else eb($,P,K,!1)}else if(!Y)P.reading=!1}return kA6(P)}function eb($,K,q,Y){if(K.flowing&&K.length===0&&!K.sync)$.emit("data",q),$.read(0);else{if(K.length+=K.objectMode?1:q.length,Y)K.buffer.unshift(q);else K.buffer.push(q);if(K.needReadable)YA($)}yw8($,K)}function VA6($,K){var q;if(!_A6(K)&&typeof K!=="string"&&K!==void 0&&!$.objectMode)q=new TypeError("Invalid non-string/buffer chunk");return q}function kA6($){return!$.ended&&($.needReadable||$.length<$.highWaterMark||$.length===0)}h1.prototype.isPaused=function(){return this._readableState.flowing===!1};h1.prototype.setEncoding=function($){if(!SW)SW=rb().StringDecoder;return this._readableState.decoder=new SW($),this._readableState.encoding=$,this};var Dw8=8388608;function MA6($){if($>=Dw8)$=Dw8;else $--,$|=$>>>1,$|=$>>>2,$|=$>>>4,$|=$>>>8,$|=$>>>16,$++;return $}function Sw8($,K){if($<=0||K.length===0&&K.ended)return 0;if(K.objectMode)return 1;if($!==$)if(K.flowing&&K.length)return K.buffer.head.data.length;else return K.length;if($>K.highWaterMark)K.highWaterMark=MA6($);if($<=K.length)return $;if(!K.ended)return K.needReadable=!0,0;return K.length}h1.prototype.read=function($){Q6("read",$),$=parseInt($,10);var K=this._readableState,q=$;if($!==0)K.emittedReadable=!1;if($===0&&K.needReadable&&(K.length>=K.highWaterMark||K.ended)){if(Q6("read: emitReadable",K.length,K.ended),K.length===0&&K.ended)$g(this);else YA(this);return null}if($=Sw8($,K),$===0&&K.ended){if(K.length===0)$g(this);return null}var Y=K.needReadable;if(Q6("need readable",Y),K.length===0||K.length-$<K.highWaterMark)Y=!0,Q6("length less than watermark",Y);if(K.ended||K.reading)Y=!1,Q6("reading or ended",Y);else if(Y){if(Q6("do read"),K.reading=!0,K.sync=!0,K.length===0)K.needReadable=!0;if(this._read(K.highWaterMark),K.sync=!1,!K.reading)$=Sw8(q,K)}var z;if($>0)z=uw8($,K);else z=null;if(z===null)K.needReadable=!0,$=0;else K.length-=$;if(K.length===0){if(!K.ended)K.needReadable=!0;if(q!==$&&K.ended)$g(this)}if(z!==null)this.emit("data",z);return z};function NA6($,K){if(K.ended)return;if(K.decoder){var q=K.decoder.end();if(q&&q.length)K.buffer.push(q),K.length+=K.objectMode?1:q.length}K.ended=!0,YA($)}function YA($){var K=$._readableState;if(K.needReadable=!1,!K.emittedReadable)if(Q6("emitReadable",K.flowing),K.emittedReadable=!0,K.sync)EW.nextTick(Ew8,$);else Ew8($)}function Ew8($){Q6("emit readable"),$.emit("readable"),qg($)}function yw8($,K){if(!K.readingMore)K.readingMore=!0,EW.nextTick(hA6,$,K)}function hA6($,K){var q=K.length;while(!K.reading&&!K.flowing&&!K.ended&&K.length<K.highWaterMark)if(Q6("maybeReadMore read 0"),$.read(0),q===K.length)break;else q=K.length;K.readingMore=!1}h1.prototype._read=function($){this.emit("error",new Error("_read() is not implemented"))};h1.prototype.pipe=function($,K){var q=this,Y=this._readableState;switch(Y.pipesCount){case 0:Y.pipes=$;break;case 1:Y.pipes=[Y.pipes,$];break;default:Y.pipes.push($);break}Y.pipesCount+=1,Q6("pipe count=%d opts=%j",Y.pipesCount,K);var z=(!K||K.end!==!1)&&$!==process.stdout&&$!==process.stderr,P=z?W:f;if(Y.endEmitted)EW.nextTick(P);else q.once("end",P);$.on("unpipe",J);function J(A,C){if(Q6("onunpipe"),A===q){if(C&&C.hasUnpiped===!1)C.hasUnpiped=!0,O()}}function W(){Q6("onend"),$.end()}var H=CA6(q);$.on("drain",H);var Z=!1;function O(){if(Q6("cleanup"),$.removeListener("close",G),$.removeListener("finish",v),$.removeListener("drain",H),$.removeListener("error",T),$.removeListener("unpipe",J),q.removeListener("end",W),q.removeListener("end",f),q.removeListener("data",X),Z=!0,Y.awaitDrain&&(!$._writableState||$._writableState.needDrain))H()}var w=!1;q.on("data",X);function X(A){Q6("ondata"),w=!1;var C=$.write(A);if(C===!1&&!w){if((Y.pipesCount===1&&Y.pipes===$||Y.pipesCount>1&&mw8(Y.pipes,$)!==-1)&&!Z)Q6("false write response, pause",Y.awaitDrain),Y.awaitDrain++,w=!0;q.pause()}}function T(A){if(Q6("onerror",A),f(),$.removeListener("error",T),Lw8($,"error")===0)$.emit("error",A)}AA6($,"error",T);function G(){$.removeListener("finish",v),f()}$.once("close",G);function v(){Q6("onfinish"),$.removeListener("close",G),f()}$.once("finish",v);function f(){Q6("unpipe"),q.unpipe($)}if($.emit("pipe",q),!Y.flowing)Q6("pipe resume"),q.resume();return $};function CA6($){return function(){var K=$._readableState;if(Q6("pipeOnDrain",K.awaitDrain),K.awaitDrain)K.awaitDrain--;if(K.awaitDrain===0&&Lw8($,"data"))K.flowing=!0,qg($)}}h1.prototype.unpipe=function($){var K=this._readableState,q={hasUnpiped:!1};if(K.pipesCount===0)return this;if(K.pipesCount===1){if($&&$!==K.pipes)return this;if(!$)$=K.pipes;if(K.pipes=null,K.pipesCount=0,K.flowing=!1,$)$.emit("unpipe",this,q);return this}if(!$){var{pipes:Y,pipesCount:z}=K;K.pipes=null,K.pipesCount=0,K.flowing=!1;for(var P=0;P<z;P++)Y[P].emit("unpipe",this,{hasUnpiped:!1});return this}var J=mw8(K.pipes,$);if(J===-1)return this;if(K.pipes.splice(J,1),K.pipesCount-=1,K.pipesCount===1)K.pipes=K.pipes[0];return $.emit("unpipe",this,q),this};h1.prototype.on=function($,K){var q=Kg.prototype.on.call(this,$,K);if($==="data"){if(this._readableState.flowing!==!1)this.resume()}else if($==="readable"){var Y=this._readableState;if(!Y.endEmitted&&!Y.readableListening){if(Y.readableListening=Y.needReadable=!0,Y.emittedReadable=!1,!Y.reading)EW.nextTick(RA6,this);else if(Y.length)YA(this)}}return q};h1.prototype.addListener=h1.prototype.on;function RA6($){Q6("readable nexttick read 0"),$.read(0)}h1.prototype.resume=function(){var $=this._readableState;if(!$.flowing)Q6("resume"),$.flowing=!0,DA6(this,$);return this};function DA6($,K){if(!K.resumeScheduled)K.resumeScheduled=!0,EW.nextTick(SA6,$,K)}function SA6($,K){if(!K.reading)Q6("resume read 0"),$.read(0);if(K.resumeScheduled=!1,K.awaitDrain=0,$.emit("resume"),qg($),K.flowing&&!K.reading)$.read(0)}h1.prototype.pause=function(){if(Q6("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)Q6("pause"),this._readableState.flowing=!1,this.emit("pause");return this};function qg($){var K=$._readableState;Q6("flow",K.flowing);while(K.flowing&&$.read()!==null);}h1.prototype.wrap=function($){var K=this,q=this._readableState,Y=!1;$.on("end",function(){if(Q6("wrapped end"),q.decoder&&!q.ended){var J=q.decoder.end();if(J&&J.length)K.push(J)}K.push(null)}),$.on("data",function(J){if(Q6("wrapped data"),q.decoder)J=q.decoder.write(J);if(q.objectMode&&(J===null||J===void 0))return;else if(!q.objectMode&&(!J||!J.length))return;var W=K.push(J);if(!W)Y=!0,$.pause()});for(var z in $)if(this[z]===void 0&&typeof $[z]==="function")this[z]=function(J){return function(){return $[J].apply($,arguments)}}(z);for(var P=0;P<tb.length;P++)$.on(tb[P],this.emit.bind(this,tb[P]));return this._read=function(J){if(Q6("wrapped _read",J),Y)Y=!1,$.resume()},this};Object.defineProperty(h1.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});h1._fromList=uw8;function uw8($,K){if(K.length===0)return null;var q;if(K.objectMode)q=K.buffer.shift();else if(!$||$>=K.length){if(K.decoder)q=K.buffer.join("");else if(K.buffer.length===1)q=K.buffer.head.data;else q=K.buffer.concat(K.length);K.buffer.clear()}else q=EA6($,K.buffer,K.decoder);return q}function EA6($,K,q){var Y;if($<K.head.data.length)Y=K.head.data.slice(0,$),K.head.data=K.head.data.slice($);else if($===K.head.data.length)Y=K.shift();else Y=q?LA6($,K):IA6($,K);return Y}function LA6($,K){var q=K.head,Y=1,z=q.data;$-=z.length;while(q=q.next){var P=q.data,J=$>P.length?P.length:$;if(J===P.length)z+=P;else z+=P.slice(0,$);if($-=J,$===0){if(J===P.length)if(++Y,q.next)K.head=q.next;else K.head=K.tail=null;else K.head=q,q.data=P.slice(J);break}++Y}return K.length-=Y,z}function IA6($,K){var q=rX.allocUnsafe($),Y=K.head,z=1;Y.data.copy(q),$-=Y.data.length;while(Y=Y.next){var P=Y.data,J=$>P.length?P.length:$;if(P.copy(q,q.length-$,0,J),$-=J,$===0){if(J===P.length)if(++z,Y.next)K.head=Y.next;else K.head=K.tail=null;else K.head=Y,Y.data=P.slice(J);break}++z}return K.length-=z,q}function $g($){var K=$._readableState;if(K.length>0)throw new Error('"endReadable()" called on non-empty stream');if(!K.endEmitted)K.ended=!0,EW.nextTick(xA6,K,$)}function xA6($,K){if(!$.endEmitted&&$.length===0)$.endEmitted=!0,K.readable=!1,K.emit("end")}function mw8($,K){for(var q=0,Y=$.length;q<Y;q++)if($[q]===K)return q;return-1}});var Yg=j((Tm1,Uw8)=>{Uw8.exports=GK;var zA=sz(),Bw8=Object.create(RW());Bw8.inherits=$q();Bw8.inherits(GK,zA);function bA6($,K){var q=this._transformState;q.transforming=!1;var Y=q.writecb;if(!Y)return this.emit("error",new Error("write callback called multiple times"));if(q.writechunk=null,q.writecb=null,K!=null)this.push(K);Y($);var z=this._readableState;if(z.reading=!1,z.needReadable||z.length<z.highWaterMark)this._read(z.highWaterMark)}function GK($){if(!(this instanceof GK))return new GK($);if(zA.call(this,$),this._transformState={afterTransform:bA6.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,$){if(typeof $.transform==="function")this._transform=$.transform;if(typeof $.flush==="function")this._flush=$.flush}this.on("prefinish",gA6)}function gA6(){var $=this;if(typeof this._flush==="function")this._flush(function(K,q){cw8($,K,q)});else cw8(this,null,null)}GK.prototype.push=function($,K){return this._transformState.needTransform=!1,zA.prototype.push.call(this,$,K)};GK.prototype._transform=function($,K,q){throw new Error("_transform() is not implemented")};GK.prototype._write=function($,K,q){var Y=this._transformState;if(Y.writecb=q,Y.writechunk=$,Y.writeencoding=K,!Y.transforming){var z=this._readableState;if(Y.needTransform||z.needReadable||z.length<z.highWaterMark)this._read(z.highWaterMark)}};GK.prototype._read=function($){var K=this._transformState;if(K.writechunk!==null&&K.writecb&&!K.transforming)K.transforming=!0,this._transform(K.writechunk,K.writeencoding,K.afterTransform);else K.needTransform=!0};GK.prototype._destroy=function($,K){var q=this;zA.prototype._destroy.call(this,$,function(Y){K(Y),q.emit("close")})};function cw8($,K,q){if(K)return $.emit("error",K);if(q!=null)$.push(q);if($._writableState.length)throw new Error("Calling transform done when ws.length != 0");if($._transformState.transforming)throw new Error("Calling transform done when still transforming");return $.push(null)}});var Qw8=j((jm1,iw8)=>{iw8.exports=sX;var lw8=Yg(),Fw8=Object.create(RW());Fw8.inherits=$q();Fw8.inherits(sX,lw8);function sX($){if(!(this instanceof sX))return new sX($);lw8.call(this,$)}sX.prototype._transform=function($,K,q){q(null,$)}});var dw8=j((z3,PA)=>{var J5=F("stream");if(process.env.READABLE_STREAM==="disable"&&J5)PA.exports=J5,z3=PA.exports=J5.Readable,z3.Readable=J5.Readable,z3.Writable=J5.Writable,z3.Duplex=J5.Duplex,z3.Transform=J5.Transform,z3.PassThrough=J5.PassThrough,z3.Stream=J5;else z3=PA.exports=nb(),z3.Stream=J5||z3,z3.Readable=z3,z3.Writable=Qb(),z3.Duplex=sz(),z3.Transform=Yg(),z3.PassThrough=Qw8()});var ow8=j((vm1,nw8)=>{nw8.exports=dw8().PassThrough});var tw8=j((Gm1,sw8)=>{var aw8=F("util"),HA=ow8();sw8.exports={Readable:JA,Writable:WA};aw8.inherits(JA,HA);aw8.inherits(WA,HA);function rw8($,K,q){$[K]=function(){return delete $[K],q.apply(this,arguments),this[K].apply(this,arguments)}}function JA($,K){if(!(this instanceof JA))return new JA($,K);HA.call(this,K),rw8(this,"_read",function(){var q=$.call(this,K),Y=this.emit.bind(this,"error");q.on("error",Y),q.pipe(this)}),this.emit("readable")}function WA($,K){if(!(this instanceof WA))return new WA($,K);HA.call(this,K),rw8(this,"_write",function(){var q=$.call(this,K),Y=this.emit.bind(this,"error");q.on("error",Y),this.pipe(q)}),this.emit("writable")}});var zg=j((_m1,ew8)=>{/*!
|
|
409
409
|
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
|
410
410
|
*
|
|
411
411
|
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
@@ -446,7 +446,7 @@ globstar while`,$,w,K,X,T),this.matchOne($.slice(w),K.slice(X),q))return this.de
|
|
|
446
446
|
|| ${J} === "boolean" || ${z} === null`).assign(W,z6._`[${z}]`)}}}function Fq1({gen:$,parentData:K,parentDataProperty:q},Y){$.if(z6._`${K} !== undefined`,()=>$.assign(z6._`${K}[${q}]`,Y))}function PF($,K,q,Y=xZ.Correct){let z=Y===xZ.Correct?z6.operators.EQ:z6.operators.NEQ,P;switch($){case"null":return z6._`${K} ${z} null`;case"array":P=z6._`Array.isArray(${K})`;break;case"object":P=z6._`${K} && typeof ${K} == "object" && !Array.isArray(${K})`;break;case"integer":P=J(z6._`!(${K} % 1) && !isNaN(${K})`);break;case"number":P=J();break;default:return z6._`typeof ${K} ${z} ${$}`}return Y===xZ.Correct?P:z6.not(P);function J(W=z6.nil){return z6.and(z6._`typeof ${K} == "number"`,W,q?z6._`isFinite(${K})`:z6.nil)}}np8.checkDataType=PF;function JF($,K,q,Y){if($.length===1)return PF($[0],K,q,Y);let z,P=ip8.toHash($);if(P.array&&P.object){let J=z6._`typeof ${K} != "object"`;z=P.null?J:z6._`!${K} || ${J}`,delete P.null,delete P.array,delete P.object}else z=z6.nil;if(P.number)delete P.integer;for(let J in P)z=z6.and(z,PF(J,K,q,Y));return z}np8.checkDataTypes=JF;var iq1={message:({schema:$})=>`must be ${$}`,params:({schema:$,schemaValue:K})=>typeof $=="string"?z6._`{type: ${$}}`:z6._`{type: ${K}}`};function WF($){let K=Qq1($);pq1.reportError(K,iq1)}np8.reportTypeError=WF;function Qq1($){let{gen:K,data:q,schema:Y}=$,z=ip8.schemaRefOrVal($,Y,"type");return{gen:K,keyword:"type",data:q,schema:Y.type,schemaCode:z,schemaValue:z,parentSchema:Y,params:{},it:$}}});var tp8=j((rp8)=>{Object.defineProperty(rp8,"__esModule",{value:!0});rp8.assignDefaults=void 0;var bZ=O6(),tq1=p6();function eq1($,K){let{properties:q,items:Y}=$.schema;if(K==="object"&&q)for(let z in q)ap8($,z,q[z].default);else if(K==="array"&&Array.isArray(Y))Y.forEach((z,P)=>ap8($,P,z.default))}rp8.assignDefaults=eq1;function ap8($,K,q){let{gen:Y,compositeRule:z,data:P,opts:J}=$;if(q===void 0)return;let W=bZ._`${P}${bZ.getProperty(K)}`;if(z){tq1.checkStrictMode($,`default is ignored for: ${W}`);return}let H=bZ._`${W} === undefined`;if(J.useDefaults==="empty")H=bZ._`${H} || ${W} === null || ${W} === ""`;Y.if(H,bZ._`${W} = ${bZ.stringify(q)}`)}});var I7=j((Kc8)=>{Object.defineProperty(Kc8,"__esModule",{value:!0});Kc8.validateUnion=Kc8.validateArray=Kc8.usePattern=Kc8.callValidateCode=Kc8.schemaProperties=Kc8.allSchemaProperties=Kc8.noPropertyInData=Kc8.propertyInData=Kc8.isOwnProperty=Kc8.hasPropFunc=Kc8.reportMissingProp=Kc8.checkMissingProp=Kc8.checkReportMissingProp=void 0;var x1=O6(),HF=p6(),SY=oK(),$Y1=p6();function KY1($,K){let{gen:q,data:Y,it:z}=$;q.if(OF(q,Y,K,z.opts.ownProperties),()=>{$.setParams({missingProperty:x1._`${K}`},!0),$.error()})}Kc8.checkReportMissingProp=KY1;function qY1({gen:$,data:K,it:{opts:q}},Y,z){return x1.or(...Y.map((P)=>x1.and(OF($,K,P,q.ownProperties),x1._`${z} = ${P}`)))}Kc8.checkMissingProp=qY1;function YY1($,K){$.setParams({missingProperty:K},!0),$.error()}Kc8.reportMissingProp=YY1;function ep8($){return $.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:x1._`Object.prototype.hasOwnProperty`})}Kc8.hasPropFunc=ep8;function ZF($,K,q){return x1._`${ep8($)}.call(${K}, ${q})`}Kc8.isOwnProperty=ZF;function zY1($,K,q,Y){let z=x1._`${K}${x1.getProperty(q)} !== undefined`;return Y?x1._`${z} && ${ZF($,K,q)}`:z}Kc8.propertyInData=zY1;function OF($,K,q,Y){let z=x1._`${K}${x1.getProperty(q)} === undefined`;return Y?x1.or(z,x1.not(ZF($,K,q))):z}Kc8.noPropertyInData=OF;function $c8($){return $?Object.keys($).filter((K)=>K!=="__proto__"):[]}Kc8.allSchemaProperties=$c8;function PY1($,K){return $c8(K).filter((q)=>!HF.alwaysValidSchema($,K[q]))}Kc8.schemaProperties=PY1;function JY1({schemaCode:$,data:K,it:{gen:q,topSchemaRef:Y,schemaPath:z,errorPath:P},it:J},W,H,Z){let O=Z?x1._`${$}, ${K}, ${Y}${z}`:K,w=[[SY.default.instancePath,x1.strConcat(SY.default.instancePath,P)],[SY.default.parentData,J.parentData],[SY.default.parentDataProperty,J.parentDataProperty],[SY.default.rootData,SY.default.rootData]];if(J.opts.dynamicRef)w.push([SY.default.dynamicAnchors,SY.default.dynamicAnchors]);let X=x1._`${O}, ${q.object(...w)}`;return H!==x1.nil?x1._`${W}.call(${H}, ${X})`:x1._`${W}(${X})`}Kc8.callValidateCode=JY1;var WY1=x1._`new RegExp`;function HY1({gen:$,it:{opts:K}},q){let Y=K.unicodeRegExp?"u":"",{regExp:z}=K.code,P=z(q,Y);return $.scopeValue("pattern",{key:P.toString(),ref:P,code:x1._`${z.code==="new RegExp"?WY1:$Y1.useFunc($,z)}(${q}, ${Y})`})}Kc8.usePattern=HY1;function ZY1($){let{gen:K,data:q,keyword:Y,it:z}=$,P=K.name("valid");if(z.allErrors){let W=K.let("valid",!0);return J(()=>K.assign(W,!1)),W}return K.var(P,!0),J(()=>K.break()),P;function J(W){let H=K.const("len",x1._`${q}.length`);K.forRange("i",0,H,(Z)=>{$.subschema({keyword:Y,dataProp:Z,dataPropType:HF.Type.Num},P),K.if(x1.not(P),W)})}}Kc8.validateArray=ZY1;function OY1($){let{gen:K,schema:q,keyword:Y,it:z}=$;if(!Array.isArray(q))throw new Error("ajv implementation error");if(q.some((H)=>HF.alwaysValidSchema(z,H))&&!z.opts.unevaluated)return;let J=K.let("valid",!1),W=K.name("_valid");K.block(()=>q.forEach((H,Z)=>{let O=$.subschema({keyword:Y,schemaProp:Z,compositeRule:!0},W);if(K.assign(J,x1._`${J} || ${W}`),!$.mergeValidEvaluated(O,W))K.if(x1.not(J))})),$.result(J,()=>$.reset(),()=>$.error(!0))}Kc8.validateUnion=OY1});var Wc8=j((Pc8)=>{Object.defineProperty(Pc8,"__esModule",{value:!0});Pc8.validateKeywordUsage=Pc8.validSchemaType=Pc8.funcKeywordCode=Pc8.macroKeywordCode=void 0;var W$=O6(),GP=oK(),NY1=I7(),hY1=qv();function CY1($,K){let{gen:q,keyword:Y,schema:z,parentSchema:P,it:J}=$,W=K.macro.call(J.self,z,P,J),H=zc8(q,Y,W);if(J.opts.validateSchema!==!1)J.self.validateSchema(W,!0);let Z=q.name("valid");$.subschema({schema:W,schemaPath:W$.nil,errSchemaPath:`${J.errSchemaPath}/${Y}`,topSchemaRef:H,compositeRule:!0},Z),$.pass(Z,()=>$.error(!0))}Pc8.macroKeywordCode=CY1;function RY1($,K){var q;let{gen:Y,keyword:z,schema:P,parentSchema:J,$data:W,it:H}=$;SY1(H,K);let Z=!W&&K.compile?K.compile.call(H.self,P,J,H):K.validate,O=zc8(Y,z,Z),w=Y.let("valid");$.block$data(w,X),$.ok((q=K.valid)!==null&&q!==void 0?q:w);function X(){if(K.errors===!1){if(v(),K.modifying)Yc8($);f(()=>$.error())}else{let A=K.async?T():G();if(K.modifying)Yc8($);f(()=>DY1($,A))}}function T(){let A=Y.let("ruleErrs",null);return Y.try(()=>v(W$._`await `),(C)=>Y.assign(w,!1).if(W$._`${C} instanceof ${H.ValidationError}`,()=>Y.assign(A,W$._`${C}.errors`),()=>Y.throw(C))),A}function G(){let A=W$._`${O}.errors`;return Y.assign(A,null),v(W$.nil),A}function v(A=K.async?W$._`await `:W$.nil){let C=H.opts.passContext?GP.default.this:GP.default.self,V=!(("compile"in K)&&!W||K.schema===!1);Y.assign(w,W$._`${A}${NY1.callValidateCode($,O,C,V)}`,K.modifying)}function f(A){var C;Y.if(W$.not((C=K.valid)!==null&&C!==void 0?C:w),A)}}Pc8.funcKeywordCode=RY1;function Yc8($){let{gen:K,data:q,it:Y}=$;K.if(Y.parentData,()=>K.assign(q,W$._`${Y.parentData}[${Y.parentDataProperty}]`))}function DY1($,K){let{gen:q}=$;q.if(W$._`Array.isArray(${K})`,()=>{q.assign(GP.default.vErrors,W$._`${GP.default.vErrors} === null ? ${K} : ${GP.default.vErrors}.concat(${K})`).assign(GP.default.errors,W$._`${GP.default.vErrors}.length`),hY1.extendErrors($)},()=>$.error())}function SY1({schemaEnv:$},K){if(K.async&&!$.$async)throw new Error("async keyword in sync schema")}function zc8($,K,q){if(q===void 0)throw new Error(`keyword "${K}" failed to compile`);return $.scopeValue("keyword",typeof q=="function"?{ref:q}:{ref:q,code:W$.stringify(q)})}function EY1($,K,q=!1){return!K.length||K.some((Y)=>Y==="array"?Array.isArray($):Y==="object"?$&&typeof $=="object"&&!Array.isArray($):typeof $==Y||q&&typeof $=="undefined")}Pc8.validSchemaType=EY1;function LY1({schema:$,opts:K,self:q,errSchemaPath:Y},z,P){if(Array.isArray(z.keyword)?!z.keyword.includes(P):z.keyword!==P)throw new Error("ajv implementation error");let J=z.dependencies;if(J===null||J===void 0?void 0:J.some((W)=>!Object.prototype.hasOwnProperty.call($,W)))throw new Error(`parent schema must have dependencies of ${P}: ${J.join(",")}`);if(z.validateSchema){if(!z.validateSchema($[P])){let H=`keyword "${P}" value is invalid at path "${Y}": `+q.errorsText(z.validateSchema.errors);if(K.validateSchema==="log")q.logger.error(H);else throw new Error(H)}}}Pc8.validateKeywordUsage=LY1});var wc8=j((Zc8)=>{Object.defineProperty(Zc8,"__esModule",{value:!0});Zc8.extendSubschemaMode=Zc8.extendSubschemaData=Zc8.getSubschema=void 0;var U5=O6(),Hc8=p6();function gY1($,{keyword:K,schemaProp:q,schema:Y,schemaPath:z,errSchemaPath:P,topSchemaRef:J}){if(K!==void 0&&Y!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(K!==void 0){let W=$.schema[K];return q===void 0?{schema:W,schemaPath:U5._`${$.schemaPath}${U5.getProperty(K)}`,errSchemaPath:`${$.errSchemaPath}/${K}`}:{schema:W[q],schemaPath:U5._`${$.schemaPath}${U5.getProperty(K)}${U5.getProperty(q)}`,errSchemaPath:`${$.errSchemaPath}/${K}/${Hc8.escapeFragment(q)}`}}if(Y!==void 0){if(z===void 0||P===void 0||J===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:Y,schemaPath:z,topSchemaRef:J,errSchemaPath:P}}throw new Error('either "keyword" or "schema" must be passed')}Zc8.getSubschema=gY1;function yY1($,K,{dataProp:q,dataPropType:Y,data:z,dataTypes:P,propertyName:J}){if(z!==void 0&&q!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:W}=K;if(q!==void 0){let{errorPath:Z,dataPathArr:O,opts:w}=K,X=W.let("data",U5._`${K.data}${U5.getProperty(q)}`,!0);H(X),$.errorPath=U5.str`${Z}${Hc8.getErrorPath(q,Y,w.jsPropertySyntax)}`,$.parentDataProperty=U5._`${q}`,$.dataPathArr=[...O,$.parentDataProperty]}if(z!==void 0){let Z=z instanceof U5.Name?z:W.let("data",z,!0);if(H(Z),J!==void 0)$.propertyName=J}if(P)$.dataTypes=P;function H(Z){$.data=Z,$.dataLevel=K.dataLevel+1,$.dataTypes=[],K.definedProperties=new Set,$.parentData=K.data,$.dataNames=[...K.dataNames,Z]}}Zc8.extendSubschemaData=yY1;function uY1($,{jtdDiscriminator:K,jtdMetadata:q,compositeRule:Y,createErrors:z,allErrors:P}){if(Y!==void 0)$.compositeRule=Y;if(z!==void 0)$.createErrors=z;if(P!==void 0)$.allErrors=P;$.jtdDiscriminator=K,$.jtdMetadata=q}Zc8.extendSubschemaMode=uY1});var wF=j((P34,Xc8)=>{Xc8.exports=function $(K,q){if(K===q)return!0;if(K&&q&&typeof K=="object"&&typeof q=="object"){if(K.constructor!==q.constructor)return!1;var Y,z,P;if(Array.isArray(K)){if(Y=K.length,Y!=q.length)return!1;for(z=Y;z--!==0;)if(!$(K[z],q[z]))return!1;return!0}if(K.constructor===RegExp)return K.source===q.source&&K.flags===q.flags;if(K.valueOf!==Object.prototype.valueOf)return K.valueOf()===q.valueOf();if(K.toString!==Object.prototype.toString)return K.toString()===q.toString();if(P=Object.keys(K),Y=P.length,Y!==Object.keys(q).length)return!1;for(z=Y;z--!==0;)if(!Object.prototype.hasOwnProperty.call(q,P[z]))return!1;for(z=Y;z--!==0;){var J=P[z];if(!$(K[J],q[J]))return!1}return!0}return K!==K&&q!==q}});var jc8=j((J34,Tc8)=>{var EY=Tc8.exports=function($,K,q){if(typeof K=="function")q=K,K={};q=K.cb||q;var Y=typeof q=="function"?q:q.pre||function(){},z=q.post||function(){};Ah(K,Y,z,$,"",$)};EY.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};EY.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};EY.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};EY.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Ah($,K,q,Y,z,P,J,W,H,Z){if(Y&&typeof Y=="object"&&!Array.isArray(Y)){K(Y,z,P,J,W,H,Z);for(var O in Y){var w=Y[O];if(Array.isArray(w)){if(O in EY.arrayKeywords)for(var X=0;X<w.length;X++)Ah($,K,q,w[X],z+"/"+O+"/"+X,P,z,O,Y,X)}else if(O in EY.propsKeywords){if(w&&typeof w=="object")for(var T in w)Ah($,K,q,w[T],z+"/"+O+"/"+cY1(T),P,z,O,Y,T)}else if(O in EY.keywords||$.allKeys&&!(O in EY.skipKeywords))Ah($,K,q,w,z+"/"+O,P,z,O,Y)}q(Y,z,P,J,W,H,Z)}}function cY1($){return $.replace(/~/g,"~0").replace(/\//g,"~1")}});var zv=j((fc8)=>{Object.defineProperty(fc8,"__esModule",{value:!0});fc8.getSchemaRefs=fc8.resolveUrl=fc8.normalizeId=fc8._getFullPath=fc8.getFullPath=fc8.inlineRef=void 0;var BY1=p6(),UY1=wF(),lY1=jc8(),FY1=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function iY1($,K=!0){if(typeof $=="boolean")return!0;if(K===!0)return!XF($);if(!K)return!1;return vc8($)<=K}fc8.inlineRef=iY1;var QY1=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function XF($){for(let K in $){if(QY1.has(K))return!0;let q=$[K];if(Array.isArray(q)&&q.some(XF))return!0;if(typeof q=="object"&&XF(q))return!0}return!1}function vc8($){let K=0;for(let q in $){if(q==="$ref")return 1/0;if(K++,FY1.has(q))continue;if(typeof $[q]=="object")BY1.eachItem($[q],(Y)=>K+=vc8(Y));if(K===1/0)return 1/0}return K}function Gc8($,K="",q){if(q!==!1)K=gZ(K);let Y=$.parse(K);return _c8($,Y)}fc8.getFullPath=Gc8;function _c8($,K){return $.serialize(K).split("#")[0]+"#"}fc8._getFullPath=_c8;var dY1=/#\/?$/;function gZ($){return $?$.replace(dY1,""):""}fc8.normalizeId=gZ;function nY1($,K,q){return q=gZ(q),$.resolve(K,q)}fc8.resolveUrl=nY1;var oY1=/^[a-z_][-a-z0-9._]*$/i;function aY1($,K){if(typeof $=="boolean")return{};let{schemaId:q,uriResolver:Y}=this.opts,z=gZ($[q]||K),P={"":z},J=Gc8(Y,z,!1),W={},H=new Set;return lY1($,{allKeys:!0},(w,X,T,G)=>{if(G===void 0)return;let v=J+X,f=P[G];if(typeof w[q]=="string")f=A.call(this,w[q]);C.call(this,w.$anchor),C.call(this,w.$dynamicAnchor),P[X]=f;function A(V){let M=this.opts.uriResolver.resolve;if(V=gZ(f?M(f,V):V),H.has(V))throw O(V);H.add(V);let R=this.refs[V];if(typeof R=="string")R=this.refs[R];if(typeof R=="object")Z(w,R.schema,V);else if(V!==gZ(v))if(V[0]==="#")Z(w,W[V],V),W[V]=w;else this.refs[V]=v;return V}function C(V){if(typeof V=="string"){if(!oY1.test(V))throw new Error(`invalid anchor "${V}"`);A.call(this,`#${V}`)}}}),W;function Z(w,X,T){if(X!==void 0&&!UY1(w,X))throw O(T)}function O(w){return new Error(`reference "${w}" resolves to more than one schema`)}}fc8.getSchemaRefs=aY1});var Wv=j((gc8)=>{Object.defineProperty(gc8,"__esModule",{value:!0});gc8.getData=gc8.KeywordCxt=gc8.validateFunctionCode=void 0;var hc8=mp8(),Vc8=Yv(),jF=zF(),Vh=Yv(),Kz1=tp8(),Jv=Wc8(),TF=wc8(),u8=O6(),n8=oK(),qz1=zv(),aK=p6(),Pv=qv();function Yz1($){if(Dc8($)){if(Sc8($),Rc8($)){Jz1($);return}}Cc8($,()=>hc8.topBoolOrEmptySchema($))}gc8.validateFunctionCode=Yz1;function Cc8({gen:$,validateName:K,schema:q,schemaEnv:Y,opts:z},P){if(z.code.es5)$.func(K,u8._`${n8.default.data}, ${n8.default.valCxt}`,Y.$async,()=>{$.code(u8._`"use strict"; ${kc8(q,z)}`),Pz1($,z),$.code(P)});else $.func(K,u8._`${n8.default.data}, ${zz1(z)}`,Y.$async,()=>$.code(kc8(q,z)).code(P))}function zz1($){return u8._`{${n8.default.instancePath}="", ${n8.default.parentData}, ${n8.default.parentDataProperty}, ${n8.default.rootData}=${n8.default.data}${$.dynamicRef?u8._`, ${n8.default.dynamicAnchors}={}`:u8.nil}}={}`}function Pz1($,K){$.if(n8.default.valCxt,()=>{if($.var(n8.default.instancePath,u8._`${n8.default.valCxt}.${n8.default.instancePath}`),$.var(n8.default.parentData,u8._`${n8.default.valCxt}.${n8.default.parentData}`),$.var(n8.default.parentDataProperty,u8._`${n8.default.valCxt}.${n8.default.parentDataProperty}`),$.var(n8.default.rootData,u8._`${n8.default.valCxt}.${n8.default.rootData}`),K.dynamicRef)$.var(n8.default.dynamicAnchors,u8._`${n8.default.valCxt}.${n8.default.dynamicAnchors}`)},()=>{if($.var(n8.default.instancePath,u8._`""`),$.var(n8.default.parentData,u8._`undefined`),$.var(n8.default.parentDataProperty,u8._`undefined`),$.var(n8.default.rootData,n8.default.data),K.dynamicRef)$.var(n8.default.dynamicAnchors,u8._`{}`)})}function Jz1($){let{schema:K,opts:q,gen:Y}=$;Cc8($,()=>{if(q.$comment&&K.$comment)Lc8($);if(wz1($),Y.let(n8.default.vErrors,null),Y.let(n8.default.errors,0),q.unevaluated)Wz1($);Ec8($),jz1($)});return}function Wz1($){let{gen:K,validateName:q}=$;$.evaluated=K.const("evaluated",u8._`${q}.evaluated`),K.if(u8._`${$.evaluated}.dynamicProps`,()=>K.assign(u8._`${$.evaluated}.props`,u8._`undefined`)),K.if(u8._`${$.evaluated}.dynamicItems`,()=>K.assign(u8._`${$.evaluated}.items`,u8._`undefined`))}function kc8($,K){let q=typeof $=="object"&&$[K.schemaId];return q&&(K.code.source||K.code.process)?u8._`/*# sourceURL=${q} */`:u8.nil}function Hz1($,K){if(Dc8($)){if(Sc8($),Rc8($)){Zz1($,K);return}}hc8.boolOrEmptySchema($,K)}function Rc8({schema:$,self:K}){if(typeof $=="boolean")return!$;for(let q in $)if(K.RULES.all[q])return!0;return!1}function Dc8($){return typeof $.schema!="boolean"}function Zz1($,K){let{schema:q,gen:Y,opts:z}=$;if(z.$comment&&q.$comment)Lc8($);Xz1($),Tz1($);let P=Y.const("_errs",n8.default.errors);Ec8($,P),Y.var(K,u8._`${P} === ${n8.default.errors}`)}function Sc8($){aK.checkUnknownRules($),Oz1($)}function Ec8($,K){if($.opts.jtd)return Mc8($,[],!1,K);let q=Vc8.getSchemaTypes($.schema),Y=Vc8.coerceAndCheckDataType($,q);Mc8($,q,!Y,K)}function Oz1($){let{schema:K,errSchemaPath:q,opts:Y,self:z}=$;if(K.$ref&&Y.ignoreKeywordsWithRef&&aK.schemaHasRulesButRef(K,z.RULES))z.logger.warn(`$ref: keywords ignored in schema at path "${q}"`)}function wz1($){let{schema:K,opts:q}=$;if(K.default!==void 0&&q.useDefaults&&q.strictSchema)aK.checkStrictMode($,"default is ignored in the schema root")}function Xz1($){let K=$.schema[$.opts.schemaId];if(K)$.baseId=qz1.resolveUrl($.opts.uriResolver,$.baseId,K)}function Tz1($){if($.schema.$async&&!$.schemaEnv.$async)throw new Error("async schema in sync schema")}function Lc8({gen:$,schemaEnv:K,schema:q,errSchemaPath:Y,opts:z}){let P=q.$comment;if(z.$comment===!0)$.code(u8._`${n8.default.self}.logger.log(${P})`);else if(typeof z.$comment=="function"){let J=u8.str`${Y}/$comment`,W=$.scopeValue("root",{ref:K.root});$.code(u8._`${n8.default.self}.opts.$comment(${P}, ${J}, ${W}.schema)`)}}function jz1($){let{gen:K,schemaEnv:q,validateName:Y,ValidationError:z,opts:P}=$;if(q.$async)K.if(u8._`${n8.default.errors} === 0`,()=>K.return(n8.default.data),()=>K.throw(u8._`new ${z}(${n8.default.vErrors})`));else{if(K.assign(u8._`${Y}.errors`,n8.default.vErrors),P.unevaluated)vz1($);K.return(u8._`${n8.default.errors} === 0`)}}function vz1({gen:$,evaluated:K,props:q,items:Y}){if(q instanceof u8.Name)$.assign(u8._`${K}.props`,q);if(Y instanceof u8.Name)$.assign(u8._`${K}.items`,Y)}function Mc8($,K,q,Y){let{gen:z,schema:P,data:J,allErrors:W,opts:H,self:Z}=$,{RULES:O}=Z;if(P.$ref&&(H.ignoreKeywordsWithRef||!aK.schemaHasRulesButRef(P,O))){z.block(()=>xc8($,"$ref",O.all.$ref.definition));return}if(!H.jtd)Gz1($,K);z.block(()=>{for(let X of O.rules)w(X);w(O.post)});function w(X){if(!jF.shouldUseGroup(P,X))return;if(X.type){if(z.if(Vh.checkDataType(X.type,J,H.strictNumbers)),Nc8($,X),K.length===1&&K[0]===X.type&&q)z.else(),Vh.reportTypeError($);z.endIf()}else Nc8($,X);if(!W)z.if(u8._`${n8.default.errors} === ${Y||0}`)}}function Nc8($,K){let{gen:q,schema:Y,opts:{useDefaults:z}}=$;if(z)Kz1.assignDefaults($,K.type);q.block(()=>{for(let P of K.rules)if(jF.shouldUseRule(Y,P))xc8($,P.keyword,P.definition,K.type)})}function Gz1($,K){if($.schemaEnv.meta||!$.opts.strictTypes)return;if(_z1($,K),!$.opts.allowUnionTypes)fz1($,K);Az1($,$.dataTypes)}function _z1($,K){if(!K.length)return;if(!$.dataTypes.length){$.dataTypes=K;return}K.forEach((q)=>{if(!Ic8($.dataTypes,q))vF($,`type "${q}" not allowed by context "${$.dataTypes.join(",")}"`)}),kz1($,K)}function fz1($,K){if(K.length>1&&!(K.length===2&&K.includes("null")))vF($,"use allowUnionTypes to allow union type keyword")}function Az1($,K){let q=$.self.RULES.all;for(let Y in q){let z=q[Y];if(typeof z=="object"&&jF.shouldUseRule($.schema,z)){let{type:P}=z.definition;if(P.length&&!P.some((J)=>Vz1(K,J)))vF($,`missing type "${P.join(",")}" for keyword "${Y}"`)}}}function Vz1($,K){return $.includes(K)||K==="number"&&$.includes("integer")}function Ic8($,K){return $.includes(K)||K==="integer"&&$.includes("number")}function kz1($,K){let q=[];for(let Y of $.dataTypes)if(Ic8(K,Y))q.push(Y);else if(K.includes("integer")&&Y==="number")q.push("integer");$.dataTypes=q}function vF($,K){let q=$.schemaEnv.baseId+$.errSchemaPath;K+=` at "${q}" (strictTypes)`,aK.checkStrictMode($,K,$.opts.strictTypes)}class GF{constructor($,K,q){if(Jv.validateKeywordUsage($,K,q),this.gen=$.gen,this.allErrors=$.allErrors,this.keyword=q,this.data=$.data,this.schema=$.schema[q],this.$data=K.$data&&$.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=aK.schemaRefOrVal($,this.schema,q,this.$data),this.schemaType=K.schemaType,this.parentSchema=$.schema,this.params={},this.it=$,this.def=K,this.$data)this.schemaCode=$.gen.const("vSchema",bc8(this.$data,$));else if(this.schemaCode=this.schemaValue,!Jv.validSchemaType(this.schema,K.schemaType,K.allowUndefined))throw new Error(`${q} value must be ${JSON.stringify(K.schemaType)}`);if("code"in K?K.trackErrors:K.errors!==!1)this.errsCount=$.gen.const("_errs",n8.default.errors)}result($,K,q){this.failResult(u8.not($),K,q)}failResult($,K,q){if(this.gen.if($),q)q();else this.error();if(K){if(this.gen.else(),K(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass($,K){this.failResult(u8.not($),void 0,K)}fail($){if($===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if($),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data($){if(!this.$data)return this.fail($);let{schemaCode:K}=this;this.fail(u8._`${K} !== undefined && (${u8.or(this.invalid$data(),$)})`)}error($,K,q){if(K){this.setParams(K),this._error($,q),this.setParams({});return}this._error($,q)}_error($,K){($?Pv.reportExtraError:Pv.reportError)(this,this.def.error,K)}$dataError(){Pv.reportError(this,this.def.$dataError||Pv.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');Pv.resetErrorsCount(this.gen,this.errsCount)}ok($){if(!this.allErrors)this.gen.if($)}setParams($,K){if(K)Object.assign(this.params,$);else this.params=$}block$data($,K,q=u8.nil){this.gen.block(()=>{this.check$data($,q),K()})}check$data($=u8.nil,K=u8.nil){if(!this.$data)return;let{gen:q,schemaCode:Y,schemaType:z,def:P}=this;if(q.if(u8.or(u8._`${Y} === undefined`,K)),$!==u8.nil)q.assign($,!0);if(z.length||P.validateSchema){if(q.elseIf(this.invalid$data()),this.$dataError(),$!==u8.nil)q.assign($,!1)}q.else()}invalid$data(){let{gen:$,schemaCode:K,schemaType:q,def:Y,it:z}=this;return u8.or(P(),J());function P(){if(q.length){if(!(K instanceof u8.Name))throw new Error("ajv implementation error");let W=Array.isArray(q)?q:[q];return u8._`${Vh.checkDataTypes(W,K,z.opts.strictNumbers,Vh.DataType.Wrong)}`}return u8.nil}function J(){if(Y.validateSchema){let W=$.scopeValue("validate$data",{ref:Y.validateSchema});return u8._`!${W}(${K})`}return u8.nil}}subschema($,K){let q=TF.getSubschema(this.it,$);TF.extendSubschemaData(q,this.it,$),TF.extendSubschemaMode(q,$);let Y={...this.it,...q,items:void 0,props:void 0};return Hz1(Y,K),Y}mergeEvaluated($,K){let{it:q,gen:Y}=this;if(!q.opts.unevaluated)return;if(q.props!==!0&&$.props!==void 0)q.props=aK.mergeEvaluated.props(Y,$.props,q.props,K);if(q.items!==!0&&$.items!==void 0)q.items=aK.mergeEvaluated.items(Y,$.items,q.items,K)}mergeValidEvaluated($,K){let{it:q,gen:Y}=this;if(q.opts.unevaluated&&(q.props!==!0||q.items!==!0))return Y.if(K,()=>this.mergeEvaluated($,u8.Name)),!0}}gc8.KeywordCxt=GF;function xc8($,K,q,Y){let z=new GF($,q,K);if("code"in q)q.code(z,Y);else if(z.$data&&q.validate)Jv.funcKeywordCode(z,q);else if("macro"in q)Jv.macroKeywordCode(z,q);else if(q.compile||q.validate)Jv.funcKeywordCode(z,q)}var Mz1=/^\/(?:[^~]|~0|~1)*$/,Nz1=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function bc8($,{dataLevel:K,dataNames:q,dataPathArr:Y}){let z,P;if($==="")return n8.default.rootData;if($[0]==="/"){if(!Mz1.test($))throw new Error(`Invalid JSON-pointer: ${$}`);z=$,P=n8.default.rootData}else{let Z=Nz1.exec($);if(!Z)throw new Error(`Invalid JSON-pointer: ${$}`);let O=+Z[1];if(z=Z[2],z==="#"){if(O>=K)throw new Error(H("property/index",O));return Y[K-O]}if(O>K)throw new Error(H("data",O));if(P=q[K-O],!z)return P}let J=P,W=z.split("/");for(let Z of W)if(Z)P=u8._`${P}${u8.getProperty(aK.unescapeJsonPointer(Z))}`,J=u8._`${J} && ${P}`;return J;function H(Z,O){return`Cannot access ${Z} ${O} levels up, current level is ${K}`}}gc8.getData=bc8});var kh=j((mc8)=>{Object.defineProperty(mc8,"__esModule",{value:!0});class uc8 extends Error{constructor($){super("validation failed");this.errors=$,this.ajv=this.validation=!0}}mc8.default=uc8});var Hv=j((cc8)=>{Object.defineProperty(cc8,"__esModule",{value:!0});var _F=zv();class pc8 extends Error{constructor($,K,q,Y){super(Y||`can't resolve reference ${q} from id ${K}`);this.missingRef=_F.resolveUrl($,K,q),this.missingSchema=_F.normalizeId(_F.getFullPath($,this.missingRef))}}cc8.default=pc8});var Nh=j((lc8)=>{Object.defineProperty(lc8,"__esModule",{value:!0});lc8.resolveSchema=lc8.getCompilingSchema=lc8.resolveRef=lc8.compileSchema=lc8.SchemaEnv=void 0;var E9=O6(),Sz1=kh(),_P=oK(),L9=zv(),Bc8=p6(),Ez1=Wv();class Zv{constructor($){var K;this.refs={},this.dynamicAnchors={};let q;if(typeof $.schema=="object")q=$.schema;this.schema=$.schema,this.schemaId=$.schemaId,this.root=$.root||this,this.baseId=(K=$.baseId)!==null&&K!==void 0?K:L9.normalizeId(q===null||q===void 0?void 0:q[$.schemaId||"$id"]),this.schemaPath=$.schemaPath,this.localRefs=$.localRefs,this.meta=$.meta,this.$async=q===null||q===void 0?void 0:q.$async,this.refs={}}}lc8.SchemaEnv=Zv;function AF($){let K=Uc8.call(this,$);if(K)return K;let q=L9.getFullPath(this.opts.uriResolver,$.root.baseId),{es5:Y,lines:z}=this.opts.code,{ownProperties:P}=this.opts,J=new E9.CodeGen(this.scope,{es5:Y,lines:z,ownProperties:P}),W;if($.$async)W=J.scopeValue("Error",{ref:Sz1.default,code:E9._`require("ajv/dist/runtime/validation_error").default`});let H=J.scopeName("validate");$.validateName=H;let Z={gen:J,allErrors:this.opts.allErrors,data:_P.default.data,parentData:_P.default.parentData,parentDataProperty:_P.default.parentDataProperty,dataNames:[_P.default.data],dataPathArr:[E9.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:J.scopeValue("schema",this.opts.code.source===!0?{ref:$.schema,code:E9.stringify($.schema)}:{ref:$.schema}),validateName:H,ValidationError:W,schema:$.schema,schemaEnv:$,rootId:q,baseId:$.baseId||q,schemaPath:E9.nil,errSchemaPath:$.schemaPath||(this.opts.jtd?"":"#"),errorPath:E9._`""`,opts:this.opts,self:this},O;try{this._compilations.add($),Ez1.validateFunctionCode(Z),J.optimize(this.opts.code.optimize);let w=J.toString();if(O=`${J.scopeRefs(_P.default.scope)}return ${w}`,this.opts.code.process)O=this.opts.code.process(O,$);let T=new Function(`${_P.default.self}`,`${_P.default.scope}`,O)(this,this.scope.get());if(this.scope.value(H,{ref:T}),T.errors=null,T.schema=$.schema,T.schemaEnv=$,$.$async)T.$async=!0;if(this.opts.code.source===!0)T.source={validateName:H,validateCode:w,scopeValues:J._values};if(this.opts.unevaluated){let{props:G,items:v}=Z;if(T.evaluated={props:G instanceof E9.Name?void 0:G,items:v instanceof E9.Name?void 0:v,dynamicProps:G instanceof E9.Name,dynamicItems:v instanceof E9.Name},T.source)T.source.evaluated=E9.stringify(T.evaluated)}return $.validate=T,$}catch(w){if(delete $.validate,delete $.validateName,O)this.logger.error("Error compiling schema, function code:",O);throw w}finally{this._compilations.delete($)}}lc8.compileSchema=AF;function Lz1($,K,q){var Y;q=L9.resolveUrl(this.opts.uriResolver,K,q);let z=$.refs[q];if(z)return z;let P=bz1.call(this,$,q);if(P===void 0){let J=(Y=$.localRefs)===null||Y===void 0?void 0:Y[q],{schemaId:W}=this.opts;if(J)P=new Zv({schema:J,schemaId:W,root:$,baseId:K})}if(P===void 0)return;return $.refs[q]=Iz1.call(this,P)}lc8.resolveRef=Lz1;function Iz1($){if(L9.inlineRef($.schema,this.opts.inlineRefs))return $.schema;return $.validate?$:AF.call(this,$)}function Uc8($){for(let K of this._compilations)if(xz1(K,$))return K}lc8.getCompilingSchema=Uc8;function xz1($,K){return $.schema===K.schema&&$.root===K.root&&$.baseId===K.baseId}function bz1($,K){let q;while(typeof(q=this.refs[K])=="string")K=q;return q||this.schemas[K]||Mh.call(this,$,K)}function Mh($,K){let q=this.opts.uriResolver.parse(K),Y=L9._getFullPath(this.opts.uriResolver,q),z=L9.getFullPath(this.opts.uriResolver,$.baseId,void 0);if(Object.keys($.schema).length>0&&Y===z)return fF.call(this,q,$);let P=L9.normalizeId(Y),J=this.refs[P]||this.schemas[P];if(typeof J=="string"){let W=Mh.call(this,$,J);if(typeof(W===null||W===void 0?void 0:W.schema)!=="object")return;return fF.call(this,q,W)}if(typeof(J===null||J===void 0?void 0:J.schema)!=="object")return;if(!J.validate)AF.call(this,J);if(P===L9.normalizeId(K)){let{schema:W}=J,{schemaId:H}=this.opts,Z=W[H];if(Z)z=L9.resolveUrl(this.opts.uriResolver,z,Z);return new Zv({schema:W,schemaId:H,root:$,baseId:z})}return fF.call(this,q,J)}lc8.resolveSchema=Mh;var gz1=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function fF($,{baseId:K,schema:q,root:Y}){var z;if(((z=$.fragment)===null||z===void 0?void 0:z[0])!=="/")return;for(let W of $.fragment.slice(1).split("/")){if(typeof q==="boolean")return;let H=q[Bc8.unescapeFragment(W)];if(H===void 0)return;q=H;let Z=typeof q==="object"&&q[this.opts.schemaId];if(!gz1.has(W)&&Z)K=L9.resolveUrl(this.opts.uriResolver,K,Z)}let P;if(typeof q!="boolean"&&q.$ref&&!Bc8.schemaHasRulesButRef(q,this.RULES)){let W=L9.resolveUrl(this.opts.uriResolver,K,q.$ref);P=Mh.call(this,Y,W)}let{schemaId:J}=this.opts;if(P=P||new Zv({schema:q,schemaId:J,root:Y,baseId:K}),P.schema!==P.root.schema)return P;return}});var ic8=j((X34,cz1)=>{cz1.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var kF=j((T34,oc8)=>{var Bz1=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),dc8=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function VF($){let K="",q=0,Y=0;for(Y=0;Y<$.length;Y++){if(q=$[Y].charCodeAt(0),q===48)continue;if(!(q>=48&&q<=57||q>=65&&q<=70||q>=97&&q<=102))return"";K+=$[Y];break}for(Y+=1;Y<$.length;Y++){if(q=$[Y].charCodeAt(0),!(q>=48&&q<=57||q>=65&&q<=70||q>=97&&q<=102))return"";K+=$[Y]}return K}var Uz1=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Qc8($){return $.length=0,!0}function lz1($,K,q){if($.length){let Y=VF($);if(Y!=="")K.push(Y);else return q.error=!0,!1;$.length=0}return!0}function Fz1($){let K=0,q={error:!1,address:"",zone:""},Y=[],z=[],P=!1,J=!1,W=lz1;for(let H=0;H<$.length;H++){let Z=$[H];if(Z==="["||Z==="]")continue;if(Z===":"){if(P===!0)J=!0;if(!W(z,Y,q))break;if(++K>7){q.error=!0;break}if(H>0&&$[H-1]===":")P=!0;Y.push(":");continue}else if(Z==="%"){if(!W(z,Y,q))break;W=Qc8}else{z.push(Z);continue}}if(z.length)if(W===Qc8)q.zone=z.join("");else if(J)Y.push(z.join(""));else Y.push(VF(z));return q.address=Y.join(""),q}function nc8($){if(iz1($,":")<2)return{host:$,isIPV6:!1};let K=Fz1($);if(!K.error){let{address:q,address:Y}=K;if(K.zone)q+="%"+K.zone,Y+="%25"+K.zone;return{host:q,isIPV6:!0,escapedHost:Y}}else return{host:$,isIPV6:!1}}function iz1($,K){let q=0;for(let Y=0;Y<$.length;Y++)if($[Y]===K)q++;return q}function Qz1($){let K=$,q=[],Y=-1,z=0;while(z=K.length){if(z===1)if(K===".")break;else if(K==="/"){q.push("/");break}else{q.push(K);break}else if(z===2){if(K[0]==="."){if(K[1]===".")break;else if(K[1]==="/"){K=K.slice(2);continue}}else if(K[0]==="/"){if(K[1]==="."||K[1]==="/"){q.push("/");break}}}else if(z===3){if(K==="/.."){if(q.length!==0)q.pop();q.push("/");break}}if(K[0]==="."){if(K[1]==="."){if(K[2]==="/"){K=K.slice(3);continue}}else if(K[1]==="/"){K=K.slice(2);continue}}else if(K[0]==="/"){if(K[1]==="."){if(K[2]==="/"){K=K.slice(2);continue}else if(K[2]==="."){if(K[3]==="/"){if(K=K.slice(3),q.length!==0)q.pop();continue}}}}if((Y=K.indexOf("/",1))===-1){q.push(K);break}else q.push(K.slice(0,Y)),K=K.slice(Y)}return q.join("")}function dz1($,K){let q=K!==!0?escape:unescape;if($.scheme!==void 0)$.scheme=q($.scheme);if($.userinfo!==void 0)$.userinfo=q($.userinfo);if($.host!==void 0)$.host=q($.host);if($.path!==void 0)$.path=q($.path);if($.query!==void 0)$.query=q($.query);if($.fragment!==void 0)$.fragment=q($.fragment);return $}function nz1($){let K=[];if($.userinfo!==void 0)K.push($.userinfo),K.push("@");if($.host!==void 0){let q=unescape($.host);if(!dc8(q)){let Y=nc8(q);if(Y.isIPV6===!0)q=`[${Y.escapedHost}]`;else q=$.host}K.push(q)}if(typeof $.port==="number"||typeof $.port==="string")K.push(":"),K.push(String($.port));return K.length?K.join(""):void 0}oc8.exports={nonSimpleDomain:Uz1,recomposeAuthority:nz1,normalizeComponentEncoding:dz1,removeDotSegments:Qz1,isIPv4:dc8,isUUID:Bz1,normalizeIPv6:nc8,stringArrayToHexStripped:VF}});var ec8=j((j34,tc8)=>{var{isUUID:oz1}=kF(),az1=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,rz1=["http","https","ws","wss","urn","urn:uuid"];function sz1($){return rz1.indexOf($)!==-1}function MF($){if($.secure===!0)return!0;else if($.secure===!1)return!1;else if($.scheme)return $.scheme.length===3&&($.scheme[0]==="w"||$.scheme[0]==="W")&&($.scheme[1]==="s"||$.scheme[1]==="S")&&($.scheme[2]==="s"||$.scheme[2]==="S");else return!1}function ac8($){if(!$.host)$.error=$.error||"HTTP URIs must have a host.";return $}function rc8($){let K=String($.scheme).toLowerCase()==="https";if($.port===(K?443:80)||$.port==="")$.port=void 0;if(!$.path)$.path="/";return $}function tz1($){return $.secure=MF($),$.resourceName=($.path||"/")+($.query?"?"+$.query:""),$.path=void 0,$.query=void 0,$}function ez1($){if($.port===(MF($)?443:80)||$.port==="")$.port=void 0;if(typeof $.secure==="boolean")$.scheme=$.secure?"wss":"ws",$.secure=void 0;if($.resourceName){let[K,q]=$.resourceName.split("?");$.path=K&&K!=="/"?K:void 0,$.query=q,$.resourceName=void 0}return $.fragment=void 0,$}function $21($,K){if(!$.path)return $.error="URN can not be parsed",$;let q=$.path.match(az1);if(q){let Y=K.scheme||$.scheme||"urn";$.nid=q[1].toLowerCase(),$.nss=q[2];let z=`${Y}:${K.nid||$.nid}`,P=NF(z);if($.path=void 0,P)$=P.parse($,K)}else $.error=$.error||"URN can not be parsed.";return $}function K21($,K){if($.nid===void 0)throw new Error("URN without nid cannot be serialized");let q=K.scheme||$.scheme||"urn",Y=$.nid.toLowerCase(),z=`${q}:${K.nid||Y}`,P=NF(z);if(P)$=P.serialize($,K);let J=$,W=$.nss;return J.path=`${Y||K.nid}:${W}`,K.skipEscape=!0,J}function q21($,K){let q=$;if(q.uuid=q.nss,q.nss=void 0,!K.tolerant&&(!q.uuid||!oz1(q.uuid)))q.error=q.error||"UUID is not valid.";return q}function Y21($){let K=$;return K.nss=($.uuid||"").toLowerCase(),K}var sc8={scheme:"http",domainHost:!0,parse:ac8,serialize:rc8},z21={scheme:"https",domainHost:sc8.domainHost,parse:ac8,serialize:rc8},hh={scheme:"ws",domainHost:!0,parse:tz1,serialize:ez1},P21={scheme:"wss",domainHost:hh.domainHost,parse:hh.parse,serialize:hh.serialize},J21={scheme:"urn",parse:$21,serialize:K21,skipNormalize:!0},W21={scheme:"urn:uuid",parse:q21,serialize:Y21,skipNormalize:!0},Ch={http:sc8,https:z21,ws:hh,wss:P21,urn:J21,"urn:uuid":W21};Object.setPrototypeOf(Ch,null);function NF($){return $&&(Ch[$]||Ch[$.toLowerCase()])||void 0}tc8.exports={wsIsSecure:MF,SCHEMES:Ch,isValidSchemeName:sz1,getSchemeHandler:NF}});var qB8=j((v34,Dh)=>{var{normalizeIPv6:H21,removeDotSegments:Ov,recomposeAuthority:Z21,normalizeComponentEncoding:Rh,isIPv4:O21,nonSimpleDomain:w21}=kF(),{SCHEMES:X21,getSchemeHandler:$B8}=ec8();function T21($,K){if(typeof $==="string")$=l5(rK($,K),K);else if(typeof $==="object")$=rK(l5($,K),K);return $}function j21($,K,q){let Y=q?Object.assign({scheme:"null"},q):{scheme:"null"},z=KB8(rK($,Y),rK(K,Y),Y,!0);return Y.skipEscape=!0,l5(z,Y)}function KB8($,K,q,Y){let z={};if(!Y)$=rK(l5($,q),q),K=rK(l5(K,q),q);if(q=q||{},!q.tolerant&&K.scheme)z.scheme=K.scheme,z.userinfo=K.userinfo,z.host=K.host,z.port=K.port,z.path=Ov(K.path||""),z.query=K.query;else{if(K.userinfo!==void 0||K.host!==void 0||K.port!==void 0)z.userinfo=K.userinfo,z.host=K.host,z.port=K.port,z.path=Ov(K.path||""),z.query=K.query;else{if(!K.path)if(z.path=$.path,K.query!==void 0)z.query=K.query;else z.query=$.query;else{if(K.path[0]==="/")z.path=Ov(K.path);else{if(($.userinfo!==void 0||$.host!==void 0||$.port!==void 0)&&!$.path)z.path="/"+K.path;else if(!$.path)z.path=K.path;else z.path=$.path.slice(0,$.path.lastIndexOf("/")+1)+K.path;z.path=Ov(z.path)}z.query=K.query}z.userinfo=$.userinfo,z.host=$.host,z.port=$.port}z.scheme=$.scheme}return z.fragment=K.fragment,z}function v21($,K,q){if(typeof $==="string")$=unescape($),$=l5(Rh(rK($,q),!0),{...q,skipEscape:!0});else if(typeof $==="object")$=l5(Rh($,!0),{...q,skipEscape:!0});if(typeof K==="string")K=unescape(K),K=l5(Rh(rK(K,q),!0),{...q,skipEscape:!0});else if(typeof K==="object")K=l5(Rh(K,!0),{...q,skipEscape:!0});return $.toLowerCase()===K.toLowerCase()}function l5($,K){let q={host:$.host,scheme:$.scheme,userinfo:$.userinfo,port:$.port,path:$.path,query:$.query,nid:$.nid,nss:$.nss,uuid:$.uuid,fragment:$.fragment,reference:$.reference,resourceName:$.resourceName,secure:$.secure,error:""},Y=Object.assign({},K),z=[],P=$B8(Y.scheme||q.scheme);if(P&&P.serialize)P.serialize(q,Y);if(q.path!==void 0)if(!Y.skipEscape){if(q.path=escape(q.path),q.scheme!==void 0)q.path=q.path.split("%3A").join(":")}else q.path=unescape(q.path);if(Y.reference!=="suffix"&&q.scheme)z.push(q.scheme,":");let J=Z21(q);if(J!==void 0){if(Y.reference!=="suffix")z.push("//");if(z.push(J),q.path&&q.path[0]!=="/")z.push("/")}if(q.path!==void 0){let W=q.path;if(!Y.absolutePath&&(!P||!P.absolutePath))W=Ov(W);if(J===void 0&&W[0]==="/"&&W[1]==="/")W="/%2F"+W.slice(2);z.push(W)}if(q.query!==void 0)z.push("?",q.query);if(q.fragment!==void 0)z.push("#",q.fragment);return z.join("")}var G21=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function rK($,K){let q=Object.assign({},K),Y={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},z=!1;if(q.reference==="suffix")if(q.scheme)$=q.scheme+":"+$;else $="//"+$;let P=$.match(G21);if(P){if(Y.scheme=P[1],Y.userinfo=P[3],Y.host=P[4],Y.port=parseInt(P[5],10),Y.path=P[6]||"",Y.query=P[7],Y.fragment=P[8],isNaN(Y.port))Y.port=P[5];if(Y.host)if(O21(Y.host)===!1){let H=H21(Y.host);Y.host=H.host.toLowerCase(),z=H.isIPV6}else z=!0;if(Y.scheme===void 0&&Y.userinfo===void 0&&Y.host===void 0&&Y.port===void 0&&Y.query===void 0&&!Y.path)Y.reference="same-document";else if(Y.scheme===void 0)Y.reference="relative";else if(Y.fragment===void 0)Y.reference="absolute";else Y.reference="uri";if(q.reference&&q.reference!=="suffix"&&q.reference!==Y.reference)Y.error=Y.error||"URI is not a "+q.reference+" reference.";let J=$B8(q.scheme||Y.scheme);if(!q.unicodeSupport&&(!J||!J.unicodeSupport)){if(Y.host&&(q.domainHost||J&&J.domainHost)&&z===!1&&w21(Y.host))try{Y.host=URL.domainToASCII(Y.host.toLowerCase())}catch(W){Y.error=Y.error||"Host's domain name can not be converted to ASCII: "+W}}if(!J||J&&!J.skipNormalize){if($.indexOf("%")!==-1){if(Y.scheme!==void 0)Y.scheme=unescape(Y.scheme);if(Y.host!==void 0)Y.host=unescape(Y.host)}if(Y.path)Y.path=escape(unescape(Y.path));if(Y.fragment)Y.fragment=encodeURI(decodeURIComponent(Y.fragment))}if(J&&J.parse)J.parse(Y,q)}else Y.error=Y.error||"URI can not be parsed.";return Y}var hF={SCHEMES:X21,normalize:T21,resolve:j21,resolveComponent:KB8,equal:v21,serialize:l5,parse:rK};Dh.exports=hF;Dh.exports.default=hF;Dh.exports.fastUri=hF});var PB8=j((zB8)=>{Object.defineProperty(zB8,"__esModule",{value:!0});var YB8=qB8();YB8.code='require("ajv/dist/runtime/uri").default';zB8.default=YB8});var TB8=j((sK)=>{Object.defineProperty(sK,"__esModule",{value:!0});sK.CodeGen=sK.Name=sK.nil=sK.stringify=sK.str=sK._=sK.KeywordCxt=void 0;var f21=Wv();Object.defineProperty(sK,"KeywordCxt",{enumerable:!0,get:function(){return f21.KeywordCxt}});var yZ=O6();Object.defineProperty(sK,"_",{enumerable:!0,get:function(){return yZ._}});Object.defineProperty(sK,"str",{enumerable:!0,get:function(){return yZ.str}});Object.defineProperty(sK,"stringify",{enumerable:!0,get:function(){return yZ.stringify}});Object.defineProperty(sK,"nil",{enumerable:!0,get:function(){return yZ.nil}});Object.defineProperty(sK,"Name",{enumerable:!0,get:function(){return yZ.Name}});Object.defineProperty(sK,"CodeGen",{enumerable:!0,get:function(){return yZ.CodeGen}});var A21=kh(),OB8=Hv(),V21=YF(),wv=Nh(),k21=O6(),Xv=zv(),Sh=Yv(),RF=p6(),JB8=ic8(),M21=PB8(),wB8=($,K)=>new RegExp($,K);wB8.code="new RegExp";var N21=["removeAdditional","useDefaults","coerceTypes"],h21=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),C21={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},R21={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},WB8=200;function D21($){var K,q,Y,z,P,J,W,H,Z,O,w,X,T,G,v,f,A,C,V,M,R,I,D,m,b;let h=$.strict,L=(K=$.code)===null||K===void 0?void 0:K.optimize,B=L===!0||L===void 0?1:L||0,i=(Y=(q=$.code)===null||q===void 0?void 0:q.regExp)!==null&&Y!==void 0?Y:wB8,X8=(z=$.uriResolver)!==null&&z!==void 0?z:M21.default;return{strictSchema:(J=(P=$.strictSchema)!==null&&P!==void 0?P:h)!==null&&J!==void 0?J:!0,strictNumbers:(H=(W=$.strictNumbers)!==null&&W!==void 0?W:h)!==null&&H!==void 0?H:!0,strictTypes:(O=(Z=$.strictTypes)!==null&&Z!==void 0?Z:h)!==null&&O!==void 0?O:"log",strictTuples:(X=(w=$.strictTuples)!==null&&w!==void 0?w:h)!==null&&X!==void 0?X:"log",strictRequired:(G=(T=$.strictRequired)!==null&&T!==void 0?T:h)!==null&&G!==void 0?G:!1,code:$.code?{...$.code,optimize:B,regExp:i}:{optimize:B,regExp:i},loopRequired:(v=$.loopRequired)!==null&&v!==void 0?v:WB8,loopEnum:(f=$.loopEnum)!==null&&f!==void 0?f:WB8,meta:(A=$.meta)!==null&&A!==void 0?A:!0,messages:(C=$.messages)!==null&&C!==void 0?C:!0,inlineRefs:(V=$.inlineRefs)!==null&&V!==void 0?V:!0,schemaId:(M=$.schemaId)!==null&&M!==void 0?M:"$id",addUsedSchema:(R=$.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(I=$.validateSchema)!==null&&I!==void 0?I:!0,validateFormats:(D=$.validateFormats)!==null&&D!==void 0?D:!0,unicodeRegExp:(m=$.unicodeRegExp)!==null&&m!==void 0?m:!0,int32range:(b=$.int32range)!==null&&b!==void 0?b:!0,uriResolver:X8}}class Eh{constructor($={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,$=this.opts={...$,...D21($)};let{es5:K,lines:q}=this.opts.code;this.scope=new k21.ValueScope({scope:{},prefixes:h21,es5:K,lines:q}),this.logger=b21($.logger);let Y=$.validateFormats;if($.validateFormats=!1,this.RULES=V21.getRules(),HB8.call(this,C21,$,"NOT SUPPORTED"),HB8.call(this,R21,$,"DEPRECATED","warn"),this._metaOpts=I21.call(this),$.formats)E21.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),$.keywords)L21.call(this,$.keywords);if(typeof $.meta=="object")this.addMetaSchema($.meta);S21.call(this),$.validateFormats=Y}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:$,meta:K,schemaId:q}=this.opts,Y=JB8;if(q==="id")Y={...JB8},Y.id=Y.$id,delete Y.$id;if(K&&$)this.addMetaSchema(Y,Y[q],!1)}defaultMeta(){let{meta:$,schemaId:K}=this.opts;return this.opts.defaultMeta=typeof $=="object"?$[K]||$:void 0}validate($,K){let q;if(typeof $=="string"){if(q=this.getSchema($),!q)throw new Error(`no schema with key or ref "${$}"`)}else q=this.compile($);let Y=q(K);if(!("$async"in q))this.errors=q.errors;return Y}compile($,K){let q=this._addSchema($,K);return q.validate||this._compileSchemaEnv(q)}compileAsync($,K){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:q}=this.opts;return Y.call(this,$,K);async function Y(Z,O){await z.call(this,Z.$schema);let w=this._addSchema(Z,O);return w.validate||P.call(this,w)}async function z(Z){if(Z&&!this.getSchema(Z))await Y.call(this,{$ref:Z},!0)}async function P(Z){try{return this._compileSchemaEnv(Z)}catch(O){if(!(O instanceof OB8.default))throw O;return J.call(this,O),await W.call(this,O.missingSchema),P.call(this,Z)}}function J({missingSchema:Z,missingRef:O}){if(this.refs[Z])throw new Error(`AnySchema ${Z} is loaded but ${O} cannot be resolved`)}async function W(Z){let O=await H.call(this,Z);if(!this.refs[Z])await z.call(this,O.$schema);if(!this.refs[Z])this.addSchema(O,Z,K)}async function H(Z){let O=this._loading[Z];if(O)return O;try{return await(this._loading[Z]=q(Z))}finally{delete this._loading[Z]}}}addSchema($,K,q,Y=this.opts.validateSchema){if(Array.isArray($)){for(let P of $)this.addSchema(P,void 0,q,Y);return this}let z;if(typeof $==="object"){let{schemaId:P}=this.opts;if(z=$[P],z!==void 0&&typeof z!="string")throw new Error(`schema ${P} must be string`)}return K=Xv.normalizeId(K||z),this._checkUnique(K),this.schemas[K]=this._addSchema($,q,K,Y,!0),this}addMetaSchema($,K,q=this.opts.validateSchema){return this.addSchema($,K,!0,q),this}validateSchema($,K){if(typeof $=="boolean")return!0;let q;if(q=$.$schema,q!==void 0&&typeof q!="string")throw new Error("$schema must be a string");if(q=q||this.opts.defaultMeta||this.defaultMeta(),!q)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let Y=this.validate(q,$);if(!Y&&K){let z="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(z);else throw new Error(z)}return Y}getSchema($){let K;while(typeof(K=ZB8.call(this,$))=="string")$=K;if(K===void 0){let{schemaId:q}=this.opts,Y=new wv.SchemaEnv({schema:{},schemaId:q});if(K=wv.resolveSchema.call(this,Y,$),!K)return;this.refs[$]=K}return K.validate||this._compileSchemaEnv(K)}removeSchema($){if($ instanceof RegExp)return this._removeAllSchemas(this.schemas,$),this._removeAllSchemas(this.refs,$),this;switch(typeof $){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let K=ZB8.call(this,$);if(typeof K=="object")this._cache.delete(K.schema);return delete this.schemas[$],delete this.refs[$],this}case"object":{let K=$;this._cache.delete(K);let q=$[this.opts.schemaId];if(q)q=Xv.normalizeId(q),delete this.schemas[q],delete this.refs[q];return this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary($){for(let K of $)this.addKeyword(K);return this}addKeyword($,K){let q;if(typeof $=="string"){if(q=$,typeof K=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),K.keyword=q}else if(typeof $=="object"&&K===void 0){if(K=$,q=K.keyword,Array.isArray(q)&&!q.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(y21.call(this,q,K),!K)return RF.eachItem(q,(z)=>CF.call(this,z)),this;m21.call(this,K);let Y={...K,type:Sh.getJSONTypes(K.type),schemaType:Sh.getJSONTypes(K.schemaType)};return RF.eachItem(q,Y.type.length===0?(z)=>CF.call(this,z,Y):(z)=>Y.type.forEach((P)=>CF.call(this,z,Y,P))),this}getKeyword($){let K=this.RULES.all[$];return typeof K=="object"?K.definition:!!K}removeKeyword($){let{RULES:K}=this;delete K.keywords[$],delete K.all[$];for(let q of K.rules){let Y=q.rules.findIndex((z)=>z.keyword===$);if(Y>=0)q.rules.splice(Y,1)}return this}addFormat($,K){if(typeof K=="string")K=new RegExp(K);return this.formats[$]=K,this}errorsText($=this.errors,{separator:K=", ",dataVar:q="data"}={}){if(!$||$.length===0)return"No errors";return $.map((Y)=>`${q}${Y.instancePath} ${Y.message}`).reduce((Y,z)=>Y+K+z)}$dataMetaSchema($,K){let q=this.RULES.all;$=JSON.parse(JSON.stringify($));for(let Y of K){let z=Y.split("/").slice(1),P=$;for(let J of z)P=P[J];for(let J in q){let W=q[J];if(typeof W!="object")continue;let{$data:H}=W.definition,Z=P[J];if(H&&Z)P[J]=XB8(Z)}}return $}_removeAllSchemas($,K){for(let q in $){let Y=$[q];if(!K||K.test(q)){if(typeof Y=="string")delete $[q];else if(Y&&!Y.meta)this._cache.delete(Y.schema),delete $[q]}}}_addSchema($,K,q,Y=this.opts.validateSchema,z=this.opts.addUsedSchema){let P,{schemaId:J}=this.opts;if(typeof $=="object")P=$[J];else if(this.opts.jtd)throw new Error("schema must be object");else if(typeof $!="boolean")throw new Error("schema must be object or boolean");let W=this._cache.get($);if(W!==void 0)return W;q=Xv.normalizeId(P||q);let H=Xv.getSchemaRefs.call(this,$,q);if(W=new wv.SchemaEnv({schema:$,schemaId:J,meta:K,baseId:q,localRefs:H}),this._cache.set(W.schema,W),z&&!q.startsWith("#")){if(q)this._checkUnique(q);this.refs[q]=W}if(Y)this.validateSchema($,!0);return W}_checkUnique($){if(this.schemas[$]||this.refs[$])throw new Error(`schema with key or id "${$}" already exists`)}_compileSchemaEnv($){if($.meta)this._compileMetaSchema($);else wv.compileSchema.call(this,$);if(!$.validate)throw new Error("ajv implementation error");return $.validate}_compileMetaSchema($){let K=this.opts;this.opts=this._metaOpts;try{wv.compileSchema.call(this,$)}finally{this.opts=K}}}Eh.ValidationError=A21.default;Eh.MissingRefError=OB8.default;sK.default=Eh;function HB8($,K,q,Y="error"){for(let z in $){let P=z;if(P in K)this.logger[Y](`${q}: option ${z}. ${$[P]}`)}}function ZB8($){return $=Xv.normalizeId($),this.schemas[$]||this.refs[$]}function S21(){let $=this.opts.schemas;if(!$)return;if(Array.isArray($))this.addSchema($);else for(let K in $)this.addSchema($[K],K)}function E21(){for(let $ in this.opts.formats){let K=this.opts.formats[$];if(K)this.addFormat($,K)}}function L21($){if(Array.isArray($)){this.addVocabulary($);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let K in $){let q=$[K];if(!q.keyword)q.keyword=K;this.addKeyword(q)}}function I21(){let $={...this.opts};for(let K of N21)delete $[K];return $}var x21={log(){},warn(){},error(){}};function b21($){if($===!1)return x21;if($===void 0)return console;if($.log&&$.warn&&$.error)return $;throw new Error("logger must implement log, warn and error methods")}var g21=/^[a-z_$][a-z0-9_$:-]*$/i;function y21($,K){let{RULES:q}=this;if(RF.eachItem($,(Y)=>{if(q.keywords[Y])throw new Error(`Keyword ${Y} is already defined`);if(!g21.test(Y))throw new Error(`Keyword ${Y} has invalid name`)}),!K)return;if(K.$data&&!(("code"in K)||("validate"in K)))throw new Error('$data keyword must have "code" or "validate" function')}function CF($,K,q){var Y;let z=K===null||K===void 0?void 0:K.post;if(q&&z)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:P}=this,J=z?P.post:P.rules.find(({type:H})=>H===q);if(!J)J={type:q,rules:[]},P.rules.push(J);if(P.keywords[$]=!0,!K)return;let W={keyword:$,definition:{...K,type:Sh.getJSONTypes(K.type),schemaType:Sh.getJSONTypes(K.schemaType)}};if(K.before)u21.call(this,J,W,K.before);else J.rules.push(W);P.all[$]=W,(Y=K.implements)===null||Y===void 0||Y.forEach((H)=>this.addKeyword(H))}function u21($,K,q){let Y=$.rules.findIndex((z)=>z.keyword===q);if(Y>=0)$.rules.splice(Y,0,K);else $.rules.push(K),this.logger.warn(`rule ${q} is not defined`)}function m21($){let{metaSchema:K}=$;if(K===void 0)return;if($.$data&&this.opts.$data)K=XB8(K);$.validateSchema=this.compile(K,!0)}var p21={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function XB8($){return{anyOf:[$,p21]}}});var vB8=j((jB8)=>{Object.defineProperty(jB8,"__esModule",{value:!0});var U21={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};jB8.default=U21});var kB8=j((AB8)=>{Object.defineProperty(AB8,"__esModule",{value:!0});AB8.callRef=AB8.getValidate=void 0;var F21=Hv(),GB8=I7(),S$=O6(),uZ=oK(),_B8=Nh(),Lh=p6(),i21={keyword:"$ref",schemaType:"string",code($){let{gen:K,schema:q,it:Y}=$,{baseId:z,schemaEnv:P,validateName:J,opts:W,self:H}=Y,{root:Z}=P;if((q==="#"||q==="#/")&&z===Z.baseId)return w();let O=_B8.resolveRef.call(H,Z,z,q);if(O===void 0)throw new F21.default(Y.opts.uriResolver,z,q);if(O instanceof _B8.SchemaEnv)return X(O);return T(O);function w(){if(P===Z)return Ih($,J,P,P.$async);let G=K.scopeValue("root",{ref:Z});return Ih($,S$._`${G}.validate`,Z,Z.$async)}function X(G){let v=fB8($,G);Ih($,v,G,G.$async)}function T(G){let v=K.scopeValue("schema",W.code.source===!0?{ref:G,code:S$.stringify(G)}:{ref:G}),f=K.name("valid"),A=$.subschema({schema:G,dataTypes:[],schemaPath:S$.nil,topSchemaRef:v,errSchemaPath:q},f);$.mergeEvaluated(A),$.ok(f)}}};function fB8($,K){let{gen:q}=$;return K.validate?q.scopeValue("validate",{ref:K.validate}):S$._`${q.scopeValue("wrapper",{ref:K})}.validate`}AB8.getValidate=fB8;function Ih($,K,q,Y){let{gen:z,it:P}=$,{allErrors:J,schemaEnv:W,opts:H}=P,Z=H.passContext?uZ.default.this:S$.nil;if(Y)O();else w();function O(){if(!W.$async)throw new Error("async schema referenced by sync schema");let G=z.let("valid");z.try(()=>{if(z.code(S$._`await ${GB8.callValidateCode($,K,Z)}`),T(K),!J)z.assign(G,!0)},(v)=>{if(z.if(S$._`!(${v} instanceof ${P.ValidationError})`,()=>z.throw(v)),X(v),!J)z.assign(G,!1)}),$.ok(G)}function w(){$.result(GB8.callValidateCode($,K,Z),()=>T(K),()=>X(K))}function X(G){let v=S$._`${G}.errors`;z.assign(uZ.default.vErrors,S$._`${uZ.default.vErrors} === null ? ${v} : ${uZ.default.vErrors}.concat(${v})`),z.assign(uZ.default.errors,S$._`${uZ.default.vErrors}.length`)}function T(G){var v;if(!P.opts.unevaluated)return;let f=(v=q===null||q===void 0?void 0:q.validate)===null||v===void 0?void 0:v.evaluated;if(P.props!==!0)if(f&&!f.dynamicProps){if(f.props!==void 0)P.props=Lh.mergeEvaluated.props(z,f.props,P.props)}else{let A=z.var("props",S$._`${G}.evaluated.props`);P.props=Lh.mergeEvaluated.props(z,A,P.props,S$.Name)}if(P.items!==!0)if(f&&!f.dynamicItems){if(f.items!==void 0)P.items=Lh.mergeEvaluated.items(z,f.items,P.items)}else{let A=z.var("items",S$._`${G}.evaluated.items`);P.items=Lh.mergeEvaluated.items(z,A,P.items,S$.Name)}}}AB8.callRef=Ih;AB8.default=i21});var NB8=j((MB8)=>{Object.defineProperty(MB8,"__esModule",{value:!0});var n21=vB8(),o21=kB8(),a21=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",n21.default,o21.default];MB8.default=a21});var CB8=j((hB8)=>{Object.defineProperty(hB8,"__esModule",{value:!0});var xh=O6(),LY=xh.operators,bh={maximum:{okStr:"<=",ok:LY.LTE,fail:LY.GT},minimum:{okStr:">=",ok:LY.GTE,fail:LY.LT},exclusiveMaximum:{okStr:"<",ok:LY.LT,fail:LY.GTE},exclusiveMinimum:{okStr:">",ok:LY.GT,fail:LY.LTE}},s21={message:({keyword:$,schemaCode:K})=>xh.str`must be ${bh[$].okStr} ${K}`,params:({keyword:$,schemaCode:K})=>xh._`{comparison: ${bh[$].okStr}, limit: ${K}}`},t21={keyword:Object.keys(bh),type:"number",schemaType:"number",$data:!0,error:s21,code($){let{keyword:K,data:q,schemaCode:Y}=$;$.fail$data(xh._`${q} ${bh[K].fail} ${Y} || isNaN(${q})`)}};hB8.default=t21});var DB8=j((RB8)=>{Object.defineProperty(RB8,"__esModule",{value:!0});var Tv=O6(),$P1={message:({schemaCode:$})=>Tv.str`must be multiple of ${$}`,params:({schemaCode:$})=>Tv._`{multipleOf: ${$}}`},KP1={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:$P1,code($){let{gen:K,data:q,schemaCode:Y,it:z}=$,P=z.opts.multipleOfPrecision,J=K.let("res"),W=P?Tv._`Math.abs(Math.round(${J}) - ${J}) > 1e-${P}`:Tv._`${J} !== parseInt(${J})`;$.fail$data(Tv._`(${Y} === 0 || (${J} = ${q}/${Y}, ${W}))`)}};RB8.default=KP1});var LB8=j((EB8)=>{Object.defineProperty(EB8,"__esModule",{value:!0});function SB8($){let K=$.length,q=0,Y=0,z;while(Y<K)if(q++,z=$.charCodeAt(Y++),z>=55296&&z<=56319&&Y<K){if(z=$.charCodeAt(Y),(z&64512)===56320)Y++}return q}EB8.default=SB8;SB8.code='require("ajv/dist/runtime/ucs2length").default'});var xB8=j((IB8)=>{Object.defineProperty(IB8,"__esModule",{value:!0});var fP=O6(),zP1=p6(),PP1=LB8(),JP1={message({keyword:$,schemaCode:K}){let q=$==="maxLength"?"more":"fewer";return fP.str`must NOT have ${q} than ${K} characters`},params:({schemaCode:$})=>fP._`{limit: ${$}}`},WP1={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:JP1,code($){let{keyword:K,data:q,schemaCode:Y,it:z}=$,P=K==="maxLength"?fP.operators.GT:fP.operators.LT,J=z.opts.unicode===!1?fP._`${q}.length`:fP._`${zP1.useFunc($.gen,PP1.default)}(${q})`;$.fail$data(fP._`${J} ${P} ${Y}`)}};IB8.default=WP1});var gB8=j((bB8)=>{Object.defineProperty(bB8,"__esModule",{value:!0});var ZP1=I7(),gh=O6(),OP1={message:({schemaCode:$})=>gh.str`must match pattern "${$}"`,params:({schemaCode:$})=>gh._`{pattern: ${$}}`},wP1={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:OP1,code($){let{data:K,$data:q,schema:Y,schemaCode:z,it:P}=$,J=P.opts.unicodeRegExp?"u":"",W=q?gh._`(new RegExp(${z}, ${J}))`:ZP1.usePattern($,Y);$.fail$data(gh._`!${W}.test(${K})`)}};bB8.default=wP1});var uB8=j((yB8)=>{Object.defineProperty(yB8,"__esModule",{value:!0});var jv=O6(),TP1={message({keyword:$,schemaCode:K}){let q=$==="maxProperties"?"more":"fewer";return jv.str`must NOT have ${q} than ${K} properties`},params:({schemaCode:$})=>jv._`{limit: ${$}}`},jP1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:TP1,code($){let{keyword:K,data:q,schemaCode:Y}=$,z=K==="maxProperties"?jv.operators.GT:jv.operators.LT;$.fail$data(jv._`Object.keys(${q}).length ${z} ${Y}`)}};yB8.default=jP1});var pB8=j((mB8)=>{Object.defineProperty(mB8,"__esModule",{value:!0});var vv=I7(),Gv=O6(),GP1=p6(),_P1={message:({params:{missingProperty:$}})=>Gv.str`must have required property '${$}'`,params:({params:{missingProperty:$}})=>Gv._`{missingProperty: ${$}}`},fP1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:_P1,code($){let{gen:K,schema:q,schemaCode:Y,data:z,$data:P,it:J}=$,{opts:W}=J;if(!P&&q.length===0)return;let H=q.length>=W.loopRequired;if(J.allErrors)Z();else O();if(W.strictRequired){let T=$.parentSchema.properties,{definedProperties:G}=$.it;for(let v of q)if((T===null||T===void 0?void 0:T[v])===void 0&&!G.has(v)){let f=J.schemaEnv.baseId+J.errSchemaPath,A=`required property "${v}" is not defined at "${f}" (strictRequired)`;GP1.checkStrictMode(J,A,J.opts.strictRequired)}}function Z(){if(H||P)$.block$data(Gv.nil,w);else for(let T of q)vv.checkReportMissingProp($,T)}function O(){let T=K.let("missing");if(H||P){let G=K.let("valid",!0);$.block$data(G,()=>X(T,G)),$.ok(G)}else K.if(vv.checkMissingProp($,q,T)),vv.reportMissingProp($,T),K.else()}function w(){K.forOf("prop",Y,(T)=>{$.setParams({missingProperty:T}),K.if(vv.noPropertyInData(K,z,T,W.ownProperties),()=>$.error())})}function X(T,G){$.setParams({missingProperty:T}),K.forOf(T,Y,()=>{K.assign(G,vv.propertyInData(K,z,T,W.ownProperties)),K.if(Gv.not(G),()=>{$.error(),K.break()})},Gv.nil)}}};mB8.default=fP1});var BB8=j((cB8)=>{Object.defineProperty(cB8,"__esModule",{value:!0});var _v=O6(),VP1={message({keyword:$,schemaCode:K}){let q=$==="maxItems"?"more":"fewer";return _v.str`must NOT have ${q} than ${K} items`},params:({schemaCode:$})=>_v._`{limit: ${$}}`},kP1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:VP1,code($){let{keyword:K,data:q,schemaCode:Y}=$,z=K==="maxItems"?_v.operators.GT:_v.operators.LT;$.fail$data(_v._`${q}.length ${z} ${Y}`)}};cB8.default=kP1});var yh=j((lB8)=>{Object.defineProperty(lB8,"__esModule",{value:!0});var UB8=wF();UB8.code='require("ajv/dist/runtime/equal").default';lB8.default=UB8});var iB8=j((FB8)=>{Object.defineProperty(FB8,"__esModule",{value:!0});var DF=Yv(),T3=O6(),hP1=p6(),CP1=yh(),RP1={message:({params:{i:$,j:K}})=>T3.str`must NOT have duplicate items (items ## ${K} and ${$} are identical)`,params:({params:{i:$,j:K}})=>T3._`{i: ${$}, j: ${K}}`},DP1={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:RP1,code($){let{gen:K,data:q,$data:Y,schema:z,parentSchema:P,schemaCode:J,it:W}=$;if(!Y&&!z)return;let H=K.let("valid"),Z=P.items?DF.getSchemaTypes(P.items):[];$.block$data(H,O,T3._`${J} === false`),$.ok(H);function O(){let G=K.let("i",T3._`${q}.length`),v=K.let("j");$.setParams({i:G,j:v}),K.assign(H,!0),K.if(T3._`${G} > 1`,()=>(w()?X:T)(G,v))}function w(){return Z.length>0&&!Z.some((G)=>G==="object"||G==="array")}function X(G,v){let f=K.name("item"),A=DF.checkDataTypes(Z,f,W.opts.strictNumbers,DF.DataType.Wrong),C=K.const("indices",T3._`{}`);K.for(T3._`;${G}--;`,()=>{if(K.let(f,T3._`${q}[${G}]`),K.if(A,T3._`continue`),Z.length>1)K.if(T3._`typeof ${f} == "string"`,T3._`${f} += "_"`);K.if(T3._`typeof ${C}[${f}] == "number"`,()=>{K.assign(v,T3._`${C}[${f}]`),$.error(),K.assign(H,!1).break()}).code(T3._`${C}[${f}] = ${G}`)})}function T(G,v){let f=hP1.useFunc(K,CP1.default),A=K.name("outer");K.label(A).for(T3._`;${G}--;`,()=>K.for(T3._`${v} = ${G}; ${v}--;`,()=>K.if(T3._`${f}(${q}[${G}], ${q}[${v}])`,()=>{$.error(),K.assign(H,!1).break(A)})))}}};FB8.default=DP1});var dB8=j((QB8)=>{Object.defineProperty(QB8,"__esModule",{value:!0});var SF=O6(),EP1=p6(),LP1=yh(),IP1={message:"must be equal to constant",params:({schemaCode:$})=>SF._`{allowedValue: ${$}}`},xP1={keyword:"const",$data:!0,error:IP1,code($){let{gen:K,data:q,$data:Y,schemaCode:z,schema:P}=$;if(Y||P&&typeof P=="object")$.fail$data(SF._`!${EP1.useFunc(K,LP1.default)}(${q}, ${z})`);else $.fail(SF._`${P} !== ${q}`)}};QB8.default=xP1});var oB8=j((nB8)=>{Object.defineProperty(nB8,"__esModule",{value:!0});var fv=O6(),gP1=p6(),yP1=yh(),uP1={message:"must be equal to one of the allowed values",params:({schemaCode:$})=>fv._`{allowedValues: ${$}}`},mP1={keyword:"enum",schemaType:"array",$data:!0,error:uP1,code($){let{gen:K,data:q,$data:Y,schema:z,schemaCode:P,it:J}=$;if(!Y&&z.length===0)throw new Error("enum must have non-empty array");let W=z.length>=J.opts.loopEnum,H,Z=()=>H!==null&&H!==void 0?H:H=gP1.useFunc(K,yP1.default),O;if(W||Y)O=K.let("valid"),$.block$data(O,w);else{if(!Array.isArray(z))throw new Error("ajv implementation error");let T=K.const("vSchema",P);O=fv.or(...z.map((G,v)=>X(T,v)))}$.pass(O);function w(){K.assign(O,!1),K.forOf("v",P,(T)=>K.if(fv._`${Z()}(${q}, ${T})`,()=>K.assign(O,!0).break()))}function X(T,G){let v=z[G];return typeof v==="object"&&v!==null?fv._`${Z()}(${q}, ${T}[${G}])`:fv._`${q} === ${v}`}}};nB8.default=mP1});var rB8=j((aB8)=>{Object.defineProperty(aB8,"__esModule",{value:!0});var cP1=CB8(),BP1=DB8(),UP1=xB8(),lP1=gB8(),FP1=uB8(),iP1=pB8(),QP1=BB8(),dP1=iB8(),nP1=dB8(),oP1=oB8(),aP1=[cP1.default,BP1.default,UP1.default,lP1.default,FP1.default,iP1.default,QP1.default,dP1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},nP1.default,oP1.default];aB8.default=aP1});var LF=j((tB8)=>{Object.defineProperty(tB8,"__esModule",{value:!0});tB8.validateAdditionalItems=void 0;var AP=O6(),EF=p6(),sP1={message:({params:{len:$}})=>AP.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>AP._`{limit: ${$}}`},tP1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sP1,code($){let{parentSchema:K,it:q}=$,{items:Y}=K;if(!Array.isArray(Y)){EF.checkStrictMode(q,'"additionalItems" is ignored when "items" is not an array of schemas');return}sB8($,Y)}};function sB8($,K){let{gen:q,schema:Y,data:z,keyword:P,it:J}=$;J.items=!0;let W=q.const("len",AP._`${z}.length`);if(Y===!1)$.setParams({len:K.length}),$.pass(AP._`${W} <= ${K.length}`);else if(typeof Y=="object"&&!EF.alwaysValidSchema(J,Y)){let Z=q.var("valid",AP._`${W} <= ${K.length}`);q.if(AP.not(Z),()=>H(Z)),$.ok(Z)}function H(Z){q.forRange("i",K.length,W,(O)=>{if($.subschema({keyword:P,dataProp:O,dataPropType:EF.Type.Num},Z),!J.allErrors)q.if(AP.not(Z),()=>q.break())})}}tB8.validateAdditionalItems=sB8;tB8.default=tP1});var IF=j((qU8)=>{Object.defineProperty(qU8,"__esModule",{value:!0});qU8.validateTuple=void 0;var $U8=O6(),uh=p6(),$J1=I7(),KJ1={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code($){let{schema:K,it:q}=$;if(Array.isArray(K))return KU8($,"additionalItems",K);if(q.items=!0,uh.alwaysValidSchema(q,K))return;$.ok($J1.validateArray($))}};function KU8($,K,q=$.schema){let{gen:Y,parentSchema:z,data:P,keyword:J,it:W}=$;if(O(z),W.opts.unevaluated&&q.length&&W.items!==!0)W.items=uh.mergeEvaluated.items(Y,q.length,W.items);let H=Y.name("valid"),Z=Y.const("len",$U8._`${P}.length`);q.forEach((w,X)=>{if(uh.alwaysValidSchema(W,w))return;Y.if($U8._`${Z} > ${X}`,()=>$.subschema({keyword:J,schemaProp:X,dataProp:X},H)),$.ok(H)});function O(w){let{opts:X,errSchemaPath:T}=W,G=q.length,v=G===w.minItems&&(G===w.maxItems||w[K]===!1);if(X.strictTuples&&!v){let f=`"${J}" is ${G}-tuple, but minItems or maxItems/${K} are not specified or different at path "${T}"`;uh.checkStrictMode(W,f,X.strictTuples)}}}qU8.validateTuple=KU8;qU8.default=KJ1});var PU8=j((zU8)=>{Object.defineProperty(zU8,"__esModule",{value:!0});var YJ1=IF(),zJ1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:($)=>YJ1.validateTuple($,"items")};zU8.default=zJ1});var HU8=j((WU8)=>{Object.defineProperty(WU8,"__esModule",{value:!0});var JU8=O6(),JJ1=p6(),WJ1=I7(),HJ1=LF(),ZJ1={message:({params:{len:$}})=>JU8.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>JU8._`{limit: ${$}}`},OJ1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:ZJ1,code($){let{schema:K,parentSchema:q,it:Y}=$,{prefixItems:z}=q;if(Y.items=!0,JJ1.alwaysValidSchema(Y,K))return;if(z)HJ1.validateAdditionalItems($,z);else $.ok(WJ1.validateArray($))}};WU8.default=OJ1});var OU8=j((ZU8)=>{Object.defineProperty(ZU8,"__esModule",{value:!0});var x7=O6(),mh=p6(),XJ1={message:({params:{min:$,max:K}})=>K===void 0?x7.str`must contain at least ${$} valid item(s)`:x7.str`must contain at least ${$} and no more than ${K} valid item(s)`,params:({params:{min:$,max:K}})=>K===void 0?x7._`{minContains: ${$}}`:x7._`{minContains: ${$}, maxContains: ${K}}`},TJ1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:XJ1,code($){let{gen:K,schema:q,parentSchema:Y,data:z,it:P}=$,J,W,{minContains:H,maxContains:Z}=Y;if(P.opts.next)J=H===void 0?1:H,W=Z;else J=1;let O=K.const("len",x7._`${z}.length`);if($.setParams({min:J,max:W}),W===void 0&&J===0){mh.checkStrictMode(P,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(W!==void 0&&J>W){mh.checkStrictMode(P,'"minContains" > "maxContains" is always invalid'),$.fail();return}if(mh.alwaysValidSchema(P,q)){let v=x7._`${O} >= ${J}`;if(W!==void 0)v=x7._`${v} && ${O} <= ${W}`;$.pass(v);return}P.items=!0;let w=K.name("valid");if(W===void 0&&J===1)T(w,()=>K.if(w,()=>K.break()));else if(J===0){if(K.let(w,!0),W!==void 0)K.if(x7._`${z}.length > 0`,X)}else K.let(w,!1),X();$.result(w,()=>$.reset());function X(){let v=K.name("_valid"),f=K.let("count",0);T(v,()=>K.if(v,()=>G(f)))}function T(v,f){K.forRange("i",0,O,(A)=>{$.subschema({keyword:"contains",dataProp:A,dataPropType:mh.Type.Num,compositeRule:!0},v),f()})}function G(v){if(K.code(x7._`${v}++`),W===void 0)K.if(x7._`${v} >= ${J}`,()=>K.assign(w,!0).break());else if(K.if(x7._`${v} > ${W}`,()=>K.assign(w,!1).break()),J===1)K.assign(w,!0);else K.if(x7._`${v} >= ${J}`,()=>K.assign(w,!0))}}};ZU8.default=TJ1});var GU8=j((TU8)=>{Object.defineProperty(TU8,"__esModule",{value:!0});TU8.validateSchemaDeps=TU8.validatePropertyDeps=TU8.error=void 0;var xF=O6(),vJ1=p6(),Av=I7();TU8.error={message:({params:{property:$,depsCount:K,deps:q}})=>{let Y=K===1?"property":"properties";return xF.str`must have ${Y} ${q} when property ${$} is present`},params:({params:{property:$,depsCount:K,deps:q,missingProperty:Y}})=>xF._`{property: ${$},
|
|
447
447
|
missingProperty: ${Y},
|
|
448
448
|
depsCount: ${K},
|
|
449
|
-
deps: ${q}}`};var GJ1={keyword:"dependencies",type:"object",schemaType:"object",error:TU8.error,code($){let[K,q]=_J1($);wU8($,K),XU8($,q)}};function _J1({schema:$}){let K={},q={};for(let Y in $){if(Y==="__proto__")continue;let z=Array.isArray($[Y])?K:q;z[Y]=$[Y]}return[K,q]}function wU8($,K=$.schema){let{gen:q,data:Y,it:z}=$;if(Object.keys(K).length===0)return;let P=q.let("missing");for(let J in K){let W=K[J];if(W.length===0)continue;let H=Av.propertyInData(q,Y,J,z.opts.ownProperties);if($.setParams({property:J,depsCount:W.length,deps:W.join(", ")}),z.allErrors)q.if(H,()=>{for(let Z of W)Av.checkReportMissingProp($,Z)});else q.if(xF._`${H} && (${Av.checkMissingProp($,W,P)})`),Av.reportMissingProp($,P),q.else()}}TU8.validatePropertyDeps=wU8;function XU8($,K=$.schema){let{gen:q,data:Y,keyword:z,it:P}=$,J=q.name("valid");for(let W in K){if(vJ1.alwaysValidSchema(P,K[W]))continue;q.if(Av.propertyInData(q,Y,W,P.opts.ownProperties),()=>{let H=$.subschema({keyword:z,schemaProp:W},J);$.mergeValidEvaluated(H,J)},()=>q.var(J,!0)),$.ok(J)}}TU8.validateSchemaDeps=XU8;TU8.default=GJ1});var AU8=j((fU8)=>{Object.defineProperty(fU8,"__esModule",{value:!0});var _U8=O6(),VJ1=p6(),kJ1={message:"property name must be valid",params:({params:$})=>_U8._`{propertyName: ${$.propertyName}}`},MJ1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kJ1,code($){let{gen:K,schema:q,data:Y,it:z}=$;if(VJ1.alwaysValidSchema(z,q))return;let P=K.name("valid");K.forIn("key",Y,(J)=>{$.setParams({propertyName:J}),$.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},P),K.if(_U8.not(P),()=>{if($.error(!0),!z.allErrors)K.break()})}),$.ok(P)}};fU8.default=MJ1});var bF=j((VU8)=>{Object.defineProperty(VU8,"__esModule",{value:!0});var ph=I7(),I9=O6(),hJ1=oK(),ch=p6(),CJ1={message:"must NOT have additional properties",params:({params:$})=>I9._`{additionalProperty: ${$.additionalProperty}}`},RJ1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:CJ1,code($){let{gen:K,schema:q,parentSchema:Y,data:z,errsCount:P,it:J}=$;if(!P)throw new Error("ajv implementation error");let{allErrors:W,opts:H}=J;if(J.props=!0,H.removeAdditional!=="all"&&ch.alwaysValidSchema(J,q))return;let Z=ph.allSchemaProperties(Y.properties),O=ph.allSchemaProperties(Y.patternProperties);w(),$.ok(I9._`${P} === ${hJ1.default.errors}`);function w(){K.forIn("key",z,(f)=>{if(!Z.length&&!O.length)G(f);else K.if(X(f),()=>G(f))})}function X(f){let A;if(Z.length>8){let C=ch.schemaRefOrVal(J,Y.properties,"properties");A=ph.isOwnProperty(K,C,f)}else if(Z.length)A=I9.or(...Z.map((C)=>I9._`${f} === ${C}`));else A=I9.nil;if(O.length)A=I9.or(A,...O.map((C)=>I9._`${ph.usePattern($,C)}.test(${f})`));return I9.not(A)}function T(f){K.code(I9._`delete ${z}[${f}]`)}function G(f){if(H.removeAdditional==="all"||H.removeAdditional&&q===!1){T(f);return}if(q===!1){if($.setParams({additionalProperty:f}),$.error(),!W)K.break();return}if(typeof q=="object"&&!ch.alwaysValidSchema(J,q)){let A=K.name("valid");if(H.removeAdditional==="failing")v(f,A,!1),K.if(I9.not(A),()=>{$.reset(),T(f)});else if(v(f,A),!W)K.if(I9.not(A),()=>K.break())}}function v(f,A,C){let V={keyword:"additionalProperties",dataProp:f,dataPropType:ch.Type.Str};if(C===!1)Object.assign(V,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(V,A)}}};VU8.default=RJ1});var hU8=j((NU8)=>{Object.defineProperty(NU8,"__esModule",{value:!0});var SJ1=Wv(),kU8=I7(),gF=p6(),MU8=bF(),EJ1={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:K,schema:q,parentSchema:Y,data:z,it:P}=$;if(P.opts.removeAdditional==="all"&&Y.additionalProperties===void 0)MU8.default.code(new SJ1.KeywordCxt(P,MU8.default,"additionalProperties"));let J=kU8.allSchemaProperties(q);for(let w of J)P.definedProperties.add(w);if(P.opts.unevaluated&&J.length&&P.props!==!0)P.props=gF.mergeEvaluated.props(K,gF.toHash(J),P.props);let W=J.filter((w)=>!gF.alwaysValidSchema(P,q[w]));if(W.length===0)return;let H=K.name("valid");for(let w of W){if(Z(w))O(w);else{if(K.if(kU8.propertyInData(K,z,w,P.opts.ownProperties)),O(w),!P.allErrors)K.else().var(H,!0);K.endIf()}$.it.definedProperties.add(w),$.ok(H)}function Z(w){return P.opts.useDefaults&&!P.compositeRule&&q[w].default!==void 0}function O(w){$.subschema({keyword:"properties",schemaProp:w,dataProp:w},H)}}};NU8.default=EJ1});var EU8=j((SU8)=>{Object.defineProperty(SU8,"__esModule",{value:!0});var CU8=I7(),Bh=O6(),RU8=p6(),DU8=p6(),IJ1={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:K,schema:q,data:Y,parentSchema:z,it:P}=$,{opts:J}=P,W=CU8.allSchemaProperties(q),H=W.filter((v)=>RU8.alwaysValidSchema(P,q[v]));if(W.length===0||H.length===W.length&&(!P.opts.unevaluated||P.props===!0))return;let Z=J.strictSchema&&!J.allowMatchingProperties&&z.properties,O=K.name("valid");if(P.props!==!0&&!(P.props instanceof Bh.Name))P.props=DU8.evaluatedPropsToName(K,P.props);let{props:w}=P;X();function X(){for(let v of W){if(Z)T(v);if(P.allErrors)G(v);else K.var(O,!0),G(v),K.if(O)}}function T(v){for(let f in Z)if(new RegExp(v).test(f))RU8.checkStrictMode(P,`property ${f} matches pattern ${v} (use allowMatchingProperties)`)}function G(v){K.forIn("key",Y,(f)=>{K.if(Bh._`${CU8.usePattern($,v)}.test(${f})`,()=>{let A=H.includes(v);if(!A)$.subschema({keyword:"patternProperties",schemaProp:v,dataProp:f,dataPropType:DU8.Type.Str},O);if(P.opts.unevaluated&&w!==!0)K.assign(Bh._`${w}[${f}]`,!0);else if(!A&&!P.allErrors)K.if(Bh.not(O),()=>K.break())})})}}};SU8.default=IJ1});var IU8=j((LU8)=>{Object.defineProperty(LU8,"__esModule",{value:!0});var bJ1=p6(),gJ1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code($){let{gen:K,schema:q,it:Y}=$;if(bJ1.alwaysValidSchema(Y,q)){$.fail();return}let z=K.name("valid");$.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},z),$.failResult(z,()=>$.reset(),()=>$.error())},error:{message:"must NOT be valid"}};LU8.default=gJ1});var bU8=j((xU8)=>{Object.defineProperty(xU8,"__esModule",{value:!0});var uJ1=I7(),mJ1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:uJ1.validateUnion,error:{message:"must match a schema in anyOf"}};xU8.default=mJ1});var yU8=j((gU8)=>{Object.defineProperty(gU8,"__esModule",{value:!0});var Uh=O6(),cJ1=p6(),BJ1={message:"must match exactly one schema in oneOf",params:({params:$})=>Uh._`{passingSchemas: ${$.passing}}`},UJ1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:BJ1,code($){let{gen:K,schema:q,parentSchema:Y,it:z}=$;if(!Array.isArray(q))throw new Error("ajv implementation error");if(z.opts.discriminator&&Y.discriminator)return;let P=q,J=K.let("valid",!1),W=K.let("passing",null),H=K.name("_valid");$.setParams({passing:W}),K.block(Z),$.result(J,()=>$.reset(),()=>$.error(!0));function Z(){P.forEach((O,w)=>{let X;if(cJ1.alwaysValidSchema(z,O))K.var(H,!0);else X=$.subschema({keyword:"oneOf",schemaProp:w,compositeRule:!0},H);if(w>0)K.if(Uh._`${H} && ${J}`).assign(J,!1).assign(W,Uh._`[${W}, ${w}]`).else();K.if(H,()=>{if(K.assign(J,!0),K.assign(W,w),X)$.mergeEvaluated(X,Uh.Name)})})}}};gU8.default=UJ1});var mU8=j((uU8)=>{Object.defineProperty(uU8,"__esModule",{value:!0});var FJ1=p6(),iJ1={keyword:"allOf",schemaType:"array",code($){let{gen:K,schema:q,it:Y}=$;if(!Array.isArray(q))throw new Error("ajv implementation error");let z=K.name("valid");q.forEach((P,J)=>{if(FJ1.alwaysValidSchema(Y,P))return;let W=$.subschema({keyword:"allOf",schemaProp:J},z);$.ok(z),$.mergeEvaluated(W)})}};uU8.default=iJ1});var UU8=j((BU8)=>{Object.defineProperty(BU8,"__esModule",{value:!0});var lh=O6(),cU8=p6(),dJ1={message:({params:$})=>lh.str`must match "${$.ifClause}" schema`,params:({params:$})=>lh._`{failingKeyword: ${$.ifClause}}`},nJ1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:dJ1,code($){let{gen:K,parentSchema:q,it:Y}=$;if(q.then===void 0&&q.else===void 0)cU8.checkStrictMode(Y,'"if" without "then" and "else" is ignored');let z=pU8(Y,"then"),P=pU8(Y,"else");if(!z&&!P)return;let J=K.let("valid",!0),W=K.name("_valid");if(H(),$.reset(),z&&P){let O=K.let("ifClause");$.setParams({ifClause:O}),K.if(W,Z("then",O),Z("else",O))}else if(z)K.if(W,Z("then"));else K.if(lh.not(W),Z("else"));$.pass(J,()=>$.error(!0));function H(){let O=$.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},W);$.mergeEvaluated(O)}function Z(O,w){return()=>{let X=$.subschema({keyword:O},W);if(K.assign(J,W),$.mergeValidEvaluated(X,J),w)K.assign(w,lh._`${O}`);else $.setParams({ifClause:O})}}}};function pU8($,K){let q=$.schema[K];return q!==void 0&&!cU8.alwaysValidSchema($,q)}BU8.default=nJ1});var FU8=j((lU8)=>{Object.defineProperty(lU8,"__esModule",{value:!0});var aJ1=p6(),rJ1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:$,parentSchema:K,it:q}){if(K.if===void 0)aJ1.checkStrictMode(q,`"${$}" without "if" is ignored`)}};lU8.default=rJ1});var QU8=j((iU8)=>{Object.defineProperty(iU8,"__esModule",{value:!0});var tJ1=LF(),eJ1=PU8(),$W1=IF(),KW1=HU8(),qW1=OU8(),YW1=GU8(),zW1=AU8(),PW1=bF(),JW1=hU8(),WW1=EU8(),HW1=IU8(),ZW1=bU8(),OW1=yU8(),wW1=mU8(),XW1=UU8(),TW1=FU8();function jW1($=!1){let K=[HW1.default,ZW1.default,OW1.default,wW1.default,XW1.default,TW1.default,zW1.default,PW1.default,YW1.default,JW1.default,WW1.default];if($)K.push(eJ1.default,KW1.default);else K.push(tJ1.default,$W1.default);return K.push(qW1.default),K}iU8.default=jW1});var nU8=j((dU8)=>{Object.defineProperty(dU8,"__esModule",{value:!0});var j4=O6(),GW1={message:({schemaCode:$})=>j4.str`must match format "${$}"`,params:({schemaCode:$})=>j4._`{format: ${$}}`},_W1={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:GW1,code($,K){let{gen:q,data:Y,$data:z,schema:P,schemaCode:J,it:W}=$,{opts:H,errSchemaPath:Z,schemaEnv:O,self:w}=W;if(!H.validateFormats)return;if(z)X();else T();function X(){let G=q.scopeValue("formats",{ref:w.formats,code:H.code.formats}),v=q.const("fDef",j4._`${G}[${J}]`),f=q.let("fType"),A=q.let("format");q.if(j4._`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>q.assign(f,j4._`${v}.type || "string"`).assign(A,j4._`${v}.validate`),()=>q.assign(f,j4._`"string"`).assign(A,v)),$.fail$data(j4.or(C(),V()));function C(){if(H.strictSchema===!1)return j4.nil;return j4._`${J} && !${A}`}function V(){let M=O.$async?j4._`(${v}.async ? await ${A}(${Y}) : ${A}(${Y}))`:j4._`${A}(${Y})`,R=j4._`(typeof ${A} == "function" ? ${M} : ${A}.test(${Y}))`;return j4._`${A} && ${A} !== true && ${f} === ${K} && !${R}`}}function T(){let G=w.formats[P];if(!G){C();return}if(G===!0)return;let[v,f,A]=V(G);if(v===K)$.pass(M());function C(){if(H.strictSchema===!1){w.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${P}" ignored in schema at path "${Z}"`}}function V(R){let I=R instanceof RegExp?j4.regexpCode(R):H.code.formats?j4._`${H.code.formats}${j4.getProperty(P)}`:void 0,D=q.scopeValue("formats",{key:P,ref:R,code:I});if(typeof R=="object"&&!(R instanceof RegExp))return[R.type||"string",R.validate,j4._`${D}.validate`];return["string",R,D]}function M(){if(typeof G=="object"&&!(G instanceof RegExp)&&G.async){if(!O.$async)throw new Error("async format in sync schema");return j4._`await ${A}(${Y})`}return typeof f=="function"?j4._`${A}(${Y})`:j4._`${A}.test(${Y})`}}}};dU8.default=_W1});var aU8=j((oU8)=>{Object.defineProperty(oU8,"__esModule",{value:!0});var AW1=nU8(),VW1=[AW1.default];oU8.default=VW1});var tU8=j((rU8)=>{Object.defineProperty(rU8,"__esModule",{value:!0});rU8.contentVocabulary=rU8.metadataVocabulary=void 0;rU8.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];rU8.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Kl8=j(($l8)=>{Object.defineProperty($l8,"__esModule",{value:!0});var NW1=NB8(),hW1=rB8(),CW1=QU8(),RW1=aU8(),eU8=tU8(),DW1=[NW1.default,hW1.default,CW1.default(),RW1.default,eU8.metadataVocabulary,eU8.contentVocabulary];$l8.default=DW1});var Pl8=j((Yl8)=>{Object.defineProperty(Yl8,"__esModule",{value:!0});Yl8.DiscrError=void 0;var ql8;(function($){$.Tag="tag",$.Mapping="mapping"})(ql8||(Yl8.DiscrError=ql8={}))});var Hl8=j((Wl8)=>{Object.defineProperty(Wl8,"__esModule",{value:!0});var mZ=O6(),yF=Pl8(),Jl8=Nh(),EW1=Hv(),LW1=p6(),IW1={message:({params:{discrError:$,tagName:K}})=>$===yF.DiscrError.Tag?`tag "${K}" must be string`:`value of tag "${K}" must be in oneOf`,params:({params:{discrError:$,tag:K,tagName:q}})=>mZ._`{error: ${$}, tag: ${q}, tagValue: ${K}}`},xW1={keyword:"discriminator",type:"object",schemaType:"object",error:IW1,code($){let{gen:K,data:q,schema:Y,parentSchema:z,it:P}=$,{oneOf:J}=z;if(!P.opts.discriminator)throw new Error("discriminator: requires discriminator option");let W=Y.propertyName;if(typeof W!="string")throw new Error("discriminator: requires propertyName");if(Y.mapping)throw new Error("discriminator: mapping is not supported");if(!J)throw new Error("discriminator: requires oneOf keyword");let H=K.let("valid",!1),Z=K.const("tag",mZ._`${q}${mZ.getProperty(W)}`);K.if(mZ._`typeof ${Z} == "string"`,()=>O(),()=>$.error(!1,{discrError:yF.DiscrError.Tag,tag:Z,tagName:W})),$.ok(H);function O(){let T=X();K.if(!1);for(let G in T)K.elseIf(mZ._`${Z} === ${G}`),K.assign(H,w(T[G]));K.else(),$.error(!1,{discrError:yF.DiscrError.Mapping,tag:Z,tagName:W}),K.endIf()}function w(T){let G=K.name("valid"),v=$.subschema({keyword:"oneOf",schemaProp:T},G);return $.mergeEvaluated(v,mZ.Name),G}function X(){var T;let G={},v=A(z),f=!0;for(let M=0;M<J.length;M++){let R=J[M];if((R===null||R===void 0?void 0:R.$ref)&&!LW1.schemaHasRulesButRef(R,P.self.RULES)){let D=R.$ref;if(R=Jl8.resolveRef.call(P.self,P.schemaEnv.root,P.baseId,D),R instanceof Jl8.SchemaEnv)R=R.schema;if(R===void 0)throw new EW1.default(P.opts.uriResolver,P.baseId,D)}let I=(T=R===null||R===void 0?void 0:R.properties)===null||T===void 0?void 0:T[W];if(typeof I!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${W}"`);f=f&&(v||A(R)),C(I,M)}if(!f)throw new Error(`discriminator: "${W}" must be required`);return G;function A({required:M}){return Array.isArray(M)&&M.includes(W)}function C(M,R){if(M.const)V(M.const,R);else if(M.enum)for(let I of M.enum)V(I,R);else throw new Error(`discriminator: "properties/${W}" must have "const" or "enum"`)}function V(M,R){if(typeof M!="string"||M in G)throw new Error(`discriminator: "${W}" values must be unique strings`);G[M]=R}}}};Wl8.default=xW1});var Zl8=j((Z$4,gW1)=>{gW1.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var mF=j((E$,uF)=>{Object.defineProperty(E$,"__esModule",{value:!0});E$.MissingRefError=E$.ValidationError=E$.CodeGen=E$.Name=E$.nil=E$.stringify=E$.str=E$._=E$.KeywordCxt=E$.Ajv=void 0;var yW1=TB8(),uW1=Kl8(),mW1=Hl8(),Ol8=Zl8(),pW1=["/properties"],Fh="http://json-schema.org/draft-07/schema";class Vv extends yW1.default{_addVocabularies(){if(super._addVocabularies(),uW1.default.forEach(($)=>this.addVocabulary($)),this.opts.discriminator)this.addKeyword(mW1.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let $=this.opts.$data?this.$dataMetaSchema(Ol8,pW1):Ol8;this.addMetaSchema($,Fh,!1),this.refs["http://json-schema.org/schema"]=Fh}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Fh)?Fh:void 0)}}E$.Ajv=Vv;uF.exports=E$=Vv;uF.exports.Ajv=Vv;Object.defineProperty(E$,"__esModule",{value:!0});E$.default=Vv;var cW1=Wv();Object.defineProperty(E$,"KeywordCxt",{enumerable:!0,get:function(){return cW1.KeywordCxt}});var pZ=O6();Object.defineProperty(E$,"_",{enumerable:!0,get:function(){return pZ._}});Object.defineProperty(E$,"str",{enumerable:!0,get:function(){return pZ.str}});Object.defineProperty(E$,"stringify",{enumerable:!0,get:function(){return pZ.stringify}});Object.defineProperty(E$,"nil",{enumerable:!0,get:function(){return pZ.nil}});Object.defineProperty(E$,"Name",{enumerable:!0,get:function(){return pZ.Name}});Object.defineProperty(E$,"CodeGen",{enumerable:!0,get:function(){return pZ.CodeGen}});var BW1=kh();Object.defineProperty(E$,"ValidationError",{enumerable:!0,get:function(){return BW1.default}});var UW1=Hv();Object.defineProperty(E$,"MissingRefError",{enumerable:!0,get:function(){return UW1.default}})});var Vl8=j((fl8)=>{Object.defineProperty(fl8,"__esModule",{value:!0});fl8.formatNames=fl8.fastFormats=fl8.fullFormats=void 0;function F5($,K){return{validate:$,compare:K}}fl8.fullFormats={date:F5(jl8,UF),time:F5(cF(!0),lF),"date-time":F5(wl8(!0),Gl8),"iso-time":F5(cF(),vl8),"iso-date-time":F5(wl8(),_l8),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:aW1,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:qH1,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rW1,int32:{type:"number",validate:eW1},int64:{type:"number",validate:$H1},float:{type:"number",validate:Tl8},double:{type:"number",validate:Tl8},password:!0,binary:!0};fl8.fastFormats={...fl8.fullFormats,date:F5(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,UF),time:F5(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,lF),"date-time":F5(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Gl8),"iso-time":F5(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,vl8),"iso-date-time":F5(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,_l8),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};fl8.formatNames=Object.keys(fl8.fullFormats);function iW1($){return $%4===0&&($%100!==0||$%400===0)}var QW1=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,dW1=[0,31,28,31,30,31,30,31,31,30,31,30,31];function jl8($){let K=QW1.exec($);if(!K)return!1;let q=+K[1],Y=+K[2],z=+K[3];return Y>=1&&Y<=12&&z>=1&&z<=(Y===2&&iW1(q)?29:dW1[Y])}function UF($,K){if(!($&&K))return;if($>K)return 1;if($<K)return-1;return 0}var pF=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function cF($){return function K(q){let Y=pF.exec(q);if(!Y)return!1;let z=+Y[1],P=+Y[2],J=+Y[3],W=Y[4],H=Y[5]==="-"?-1:1,Z=+(Y[6]||0),O=+(Y[7]||0);if(Z>23||O>59||$&&!W)return!1;if(z<=23&&P<=59&&J<60)return!0;let w=P-O*H,X=z-Z*H-(w<0?1:0);return(X===23||X===-1)&&(w===59||w===-1)&&J<61}}function lF($,K){if(!($&&K))return;let q=new Date("2020-01-01T"+$).valueOf(),Y=new Date("2020-01-01T"+K).valueOf();if(!(q&&Y))return;return q-Y}function vl8($,K){if(!($&&K))return;let q=pF.exec($),Y=pF.exec(K);if(!(q&&Y))return;if($=q[1]+q[2]+q[3],K=Y[1]+Y[2]+Y[3],$>K)return 1;if($<K)return-1;return 0}var BF=/t|\s/i;function wl8($){let K=cF($);return function q(Y){let z=Y.split(BF);return z.length===2&&jl8(z[0])&&K(z[1])}}function Gl8($,K){if(!($&&K))return;let q=new Date($).valueOf(),Y=new Date(K).valueOf();if(!(q&&Y))return;return q-Y}function _l8($,K){if(!($&&K))return;let[q,Y]=$.split(BF),[z,P]=K.split(BF),J=UF(q,z);if(J===void 0)return;return J||lF(Y,P)}var nW1=/\/|:/,oW1=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function aW1($){return nW1.test($)&&oW1.test($)}var Xl8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rW1($){return Xl8.lastIndex=0,Xl8.test($)}var sW1=-2147483648,tW1=2147483647;function eW1($){return Number.isInteger($)&&$<=tW1&&$>=sW1}function $H1($){return Number.isInteger($)}function Tl8(){return!0}var KH1=/[^\\]\\Z/;function qH1($){if(KH1.test($))return!1;try{return new RegExp($),!0}catch(K){return!1}}});var Ml8=j((kl8)=>{Object.defineProperty(kl8,"__esModule",{value:!0});kl8.formatLimitDefinition=void 0;var zH1=mF(),x9=O6(),IY=x9.operators,ih={formatMaximum:{okStr:"<=",ok:IY.LTE,fail:IY.GT},formatMinimum:{okStr:">=",ok:IY.GTE,fail:IY.LT},formatExclusiveMaximum:{okStr:"<",ok:IY.LT,fail:IY.GTE},formatExclusiveMinimum:{okStr:">",ok:IY.GT,fail:IY.LTE}},PH1={message:({keyword:$,schemaCode:K})=>x9.str`should be ${ih[$].okStr} ${K}`,params:({keyword:$,schemaCode:K})=>x9._`{comparison: ${ih[$].okStr}, limit: ${K}}`};kl8.formatLimitDefinition={keyword:Object.keys(ih),type:"string",schemaType:"string",$data:!0,error:PH1,code($){let{gen:K,data:q,schemaCode:Y,keyword:z,it:P}=$,{opts:J,self:W}=P;if(!J.validateFormats)return;let H=new zH1.KeywordCxt(P,W.RULES.all.format.definition,"format");if(H.$data)Z();else O();function Z(){let X=K.scopeValue("formats",{ref:W.formats,code:J.code.formats}),T=K.const("fmt",x9._`${X}[${H.schemaCode}]`);$.fail$data(x9.or(x9._`typeof ${T} != "object"`,x9._`${T} instanceof RegExp`,x9._`typeof ${T}.compare != "function"`,w(T)))}function O(){let X=H.schema,T=W.formats[X];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${z}": format "${X}" does not define "compare" function`);let G=K.scopeValue("formats",{key:X,ref:T,code:J.code.formats?x9._`${J.code.formats}${x9.getProperty(X)}`:void 0});$.fail$data(w(G))}function w(X){return x9._`${X}.compare(${q}, ${Y}) ${ih[z].fail} 0`}},dependencies:["format"]};var JH1=($)=>{return $.addKeyword(kl8.formatLimitDefinition),$};kl8.default=JH1});var Rl8=j((kv,Cl8)=>{Object.defineProperty(kv,"__esModule",{value:!0});var cZ=Vl8(),HH1=Ml8(),QF=O6(),Nl8=new QF.Name("fullFormats"),ZH1=new QF.Name("fastFormats"),dF=($,K={keywords:!0})=>{if(Array.isArray(K))return hl8($,K,cZ.fullFormats,Nl8),$;let[q,Y]=K.mode==="fast"?[cZ.fastFormats,ZH1]:[cZ.fullFormats,Nl8],z=K.formats||cZ.formatNames;if(hl8($,z,q,Y),K.keywords)HH1.default($);return $};dF.get=($,K="full")=>{let Y=(K==="fast"?cZ.fastFormats:cZ.fullFormats)[$];if(!Y)throw new Error(`Unknown format "${$}"`);return Y};function hl8($,K,q,Y){var z,P;(z=(P=$.opts.code).formats)!==null&&z!==void 0||(P.formats=QF._`require("ajv-formats/dist/formats").${Y}`);for(let J of K)$.addFormat(J,q[J])}Cl8.exports=kv=dF;Object.defineProperty(kv,"__esModule",{value:!0});kv.default=dF});import Pi from"path";import{fileURLToPath as iZ1}from"url";import{homedir as QZ1}from"os";var zi=K1(TD(),1),rF8=K1(X$(),1);var zu8=K1(X$(),1);function x$($){return typeof $==="undefined"||$===void 0}function f1($){return typeof $==="string"}function Hq($){return typeof $==="number"}function tY($){return typeof $==="boolean"}function qJ($){return $===null}function Et($){return $ instanceof Date}function YJ($){return typeof $==="bigint"}function A1($){return typeof $==="function"}function M4($){return typeof $==="object"&&$!==null}function Lt($){return $[$.length-1]}function k($){return Object.freeze($)}function QO($){if(j3($))return $;else return[$]}function j3($){return Array.isArray($)}function l3($){return $}var x6=k({is($){return $.kind==="AlterTableNode"},create($){return k({kind:"AlterTableNode",table:$})},cloneWithTableProps($,K){return k({...$,...K})},cloneWithColumnAlteration($,K){return k({...$,columnAlterations:$.columnAlterations?[...$.columnAlterations,K]:[K]})}});var p8=k({is($){return $.kind==="IdentifierNode"},create($){return k({kind:"IdentifierNode",name:$})}});var c7=k({is($){return $.kind==="CreateIndexNode"},create($){return k({kind:"CreateIndexNode",name:p8.create($)})},cloneWith($,K){return k({...$,...K})},cloneWithColumns($,K){return k({...$,columns:[...$.columns||[],...K]})}});var aG=k({is($){return $.kind==="CreateSchemaNode"},create($,K){return k({kind:"CreateSchemaNode",schema:p8.create($),...K})},cloneWith($,K){return k({...$,...K})}});var It=["preserve rows","delete rows","drop"],v3=k({is($){return $.kind==="CreateTableNode"},create($){return k({kind:"CreateTableNode",table:$,columns:k([])})},cloneWithColumn($,K){return k({...$,columns:k([...$.columns,K])})},cloneWithConstraint($,K){return k({...$,constraints:$.constraints?k([...$.constraints,K]):k([K])})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):k([K])})},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):k([K])})},cloneWith($,K){return k({...$,...K})}});var G3=k({is($){return $.kind==="SchemableIdentifierNode"},create($){return k({kind:"SchemableIdentifierNode",identifier:p8.create($)})},createWithSchema($,K){return k({kind:"SchemableIdentifierNode",schema:p8.create($),identifier:p8.create(K)})}});var Zq=k({is($){return $.kind==="DropIndexNode"},create($,K){return k({kind:"DropIndexNode",name:G3.create($),...K})},cloneWith($,K){return k({...$,...K})}});var dO=k({is($){return $.kind==="DropSchemaNode"},create($,K){return k({kind:"DropSchemaNode",schema:p8.create($),...K})},cloneWith($,K){return k({...$,...K})}});var nO=k({is($){return $.kind==="DropTableNode"},create($,K){return k({kind:"DropTableNode",table:$,...K})},cloneWith($,K){return k({...$,...K})}});var i4=k({is($){return $.kind==="AliasNode"},create($,K){return k({kind:"AliasNode",node:$,alias:K})}});var b$=k({is($){return $.kind==="TableNode"},create($){return k({kind:"TableNode",table:G3.create($)})},createWithSchema($,K){return k({kind:"TableNode",table:G3.createWithSchema($,K)})}});function w1($){return M4($)&&A1($.toOperationNode)}function rG($){return M4($)&&"expressionType"in $&&w1($)}function xt($){return M4($)&&"expression"in $&&f1($.alias)&&w1($)}var U9=k({is($){return $.kind==="SelectModifierNode"},create($,K){return k({kind:"SelectModifierNode",modifier:$,of:K})},createWithExpression($){return k({kind:"SelectModifierNode",rawModifier:$})}});var T$=k({is($){return $.kind==="AndNode"},create($,K){return k({kind:"AndNode",left:$,right:K})}});var B7=k({is($){return $.kind==="OrNode"},create($,K){return k({kind:"OrNode",left:$,right:K})}});var sG=k({is($){return $.kind==="OnNode"},create($){return k({kind:"OnNode",on:$})},cloneWithOperation($,K,q){return k({...$,on:K==="And"?T$.create($.on,q):B7.create($.on,q)})}});var U7=k({is($){return $.kind==="JoinNode"},create($,K){return k({kind:"JoinNode",joinType:$,table:K,on:void 0})},createWithOn($,K,q){return k({kind:"JoinNode",joinType:$,table:K,on:sG.create(q)})},cloneWithOn($,K){return k({...$,on:$.on?sG.cloneWithOperation($.on,"And",K):sG.create(K)})}});var Oq=k({is($){return $.kind==="BinaryOperationNode"},create($,K,q){return k({kind:"BinaryOperationNode",leftOperand:$,operator:K,rightOperand:q})}});var K46=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],q46=["+","-","*","/","%","^","&","|","#","<<",">>"],bt=["->","->>"],Y46=[...K46,...q46,"&&","||"],z46=["exists","not exists"],P46=["not","-",...z46],gt=[...Y46,...bt,...P46,"between","between symmetric"],g$=k({is($){return $.kind==="OperatorNode"},create($){return k({kind:"OperatorNode",operator:$})}});function GD($){return f1($)&&bt.includes($)}var R6=k({is($){return $.kind==="ColumnNode"},create($){return k({kind:"ColumnNode",column:p8.create($)})}});var zJ=k({is($){return $.kind==="SelectAllNode"},create(){return k({kind:"SelectAllNode"})}});var PJ=k({is($){return $.kind==="ReferenceNode"},create($,K){return k({kind:"ReferenceNode",table:K,column:$})},createSelectAll($){return k({kind:"ReferenceNode",table:$,column:zJ.create()})}});class _D{#$;get dynamicReference(){return this.#$}get refType(){return}constructor($){this.#$=$}toOperationNode(){return fD(this.#$)}}function tG($){return M4($)&&w1($)&&f1($.dynamicReference)}var l7=k({is($){return $.kind==="OrderByItemNode"},create($,K){return k({kind:"OrderByItemNode",orderBy:$,direction:K})},cloneWith($,K){return k({...$,...K})}});var b6=k({is($){return $.kind==="RawNode"},create($,K){return k({kind:"RawNode",sqlFragments:k($),parameters:k(K)})},createWithSql($){return b6.create([$],[])},createWithChild($){return b6.create(["",""],[$])},createWithChildren($){return b6.create(new Array($.length+1).fill(""),$)}});var yt={is($){return $.kind==="CollateNode"},create($){return k({kind:"CollateNode",collation:p8.create($)})}};class wq{#$;constructor($){this.#$=k($)}desc(){return new wq({node:l7.cloneWith(this.#$.node,{direction:b6.createWithSql("desc")})})}asc(){return new wq({node:l7.cloneWith(this.#$.node,{direction:b6.createWithSql("asc")})})}nullsLast(){return new wq({node:l7.cloneWith(this.#$.node,{nulls:"last"})})}nullsFirst(){return new wq({node:l7.cloneWith(this.#$.node,{nulls:"first"})})}collate($){return new wq({node:l7.cloneWith(this.#$.node,{collation:yt.create($)})})}toOperationNode(){return this.#$.node}}var ut=new Set;function l9($){if(ut.has($))return;ut.add($),console.log($)}function VD($){return $==="asc"||$==="desc"}function u$($){if($.length===2)return[AD($[0],$[1])];if($.length===1){let[K]=$;if(Array.isArray(K))return l9("orderBy(array) is deprecated, use multiple orderBy calls instead."),K.map((q)=>AD(q));return[AD(K)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${$.length}`)}function AD($,K){let q=J46($);if(l7.is(q)){if(K)throw new Error("Cannot specify direction twice!");return q}return mt(q,K)}function J46($){if(n5($))return j$($);if(tG($))return $.toOperationNode();let[K,q]=$.split(" ");if(q)return l9("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),mt(y$(K),q);return y$($)}function mt($,K){if(typeof K==="string"){if(!VD(K))throw new Error(`Invalid order by direction: ${K}`);return l7.create($,b6.createWithSql(K))}if(rG(K))return l9("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),l7.create($,K.toOperationNode());let q=l7.create($);if(!K)return q;return K(new wq({node:q})).toOperationNode()}var JJ=k({is($){return $.kind==="JSONReferenceNode"},create($,K){return k({kind:"JSONReferenceNode",reference:$,traversal:K})},cloneWithTraversal($,K){return k({...$,traversal:K})}});var eG=k({is($){return $.kind==="JSONOperatorChainNode"},create($){return k({kind:"JSONOperatorChainNode",operator:$,values:k([])})},cloneWithValue($,K){return k({...$,values:k([...$.values,K])})}});var Xq=k({is($){return $.kind==="JSONPathNode"},create($){return k({kind:"JSONPathNode",inOperator:$,pathLegs:k([])})},cloneWithLeg($,K){return k({...$,pathLegs:k([...$.pathLegs,K])})}});function fD($){if(f1($))return y$($);return $.toOperationNode()}function o5($){if(j3($))return $.map((K)=>s4(K));else return[s4($)]}function s4($){if(n5($))return j$($);return fD($)}function pt($,K){let q=y$($);if(GD(K))return JJ.create(q,eG.create(g$.create(K)));let Y=K.slice(0,-1);if(GD(Y))return JJ.create(q,Xq.create(g$.create(Y)));throw new Error(`Invalid JSON operator: ${K}`)}function y$($){if(!$.includes("."))return PJ.create(R6.create($));let q=$.split(".").map(MD);if(q.length===3)return W46(q);if(q.length===2)return H46(q);throw new Error(`invalid column reference ${$}`)}function ct($){if($.includes(" as ")){let[q,Y]=$.split(" as ").map(MD);return i4.create(y$(q),p8.create(Y))}else return y$($)}function kD($){return R6.create($)}function WJ($){if($.includes(" ")){let[q,Y]=$.split(" ").map(MD);if(!VD(Y))throw new Error(`invalid order direction "${Y}" next to "${q}"`);return u$([q,Y])[0]}else return kD($)}function W46($){let[K,q,Y]=$;return PJ.create(R6.create(Y),b$.createWithSchema(K,q))}function H46($){let[K,q]=$;return PJ.create(R6.create(q),b$.create(K))}function MD($){return $.trim()}var $0=k({is($){return $.kind==="PrimitiveValueListNode"},create($){return k({kind:"PrimitiveValueListNode",values:k([...$])})}});var Tq=k({is($){return $.kind==="ValueListNode"},create($){return k({kind:"ValueListNode",values:k($)})}});var _4=k({is($){return $.kind==="ValueNode"},create($){return k({kind:"ValueNode",value:$})},createImmediate($){return k({kind:"ValueNode",value:$,immediate:!0})}});function Bt($){if(j3($))return Z46($);return q1($)}function q1($){if(n5($))return j$($);return _4.create($)}function K0($){return Hq($)||tY($)||qJ($)}function oO($){if(!K0($))throw new Error(`unsafe immediate value ${JSON.stringify($)}`);return _4.createImmediate($)}function Z46($){if($.some(n5))return Tq.create($.map((K)=>q1(K)));return $0.create($)}var m$=k({is($){return $.kind==="ParensNode"},create($){return k({kind:"ParensNode",node:$})}});function W1($){if($.length===3)return q0($[0],$[1],$[2]);else if($.length===1)return q1($[0]);throw new Error(`invalid arguments: ${JSON.stringify($)}`)}function q0($,K,q){if(O46(K)&<(q))return Oq.create(s4($),ND(K),_4.createImmediate(q));return Oq.create(s4($),ND(K),Bt(q))}function Q4($,K,q){return Oq.create(s4($),ND(K),s4(q))}function hD($,K){return HJ(Object.entries($).filter(([,q])=>!x$(q)).map(([q,Y])=>q0(q,lt(Y)?"is":"=",Y)),K)}function HJ($,K,q=!0){let Y=K==="and"?T$.create:B7.create;if($.length===0)return Oq.create(_4.createImmediate(1),g$.create("="),_4.createImmediate(K==="and"?1:0));let z=Ut($[0]);for(let P=1;P<$.length;++P)z=Y(z,Ut($[P]));if($.length>1&&q)return m$.create(z);return z}function O46($){return $==="is"||$==="is not"}function lt($){return qJ($)||tY($)}function ND($){if(f1($)&>.includes($))return g$.create($);if(w1($))return $.toOperationNode();throw new Error(`invalid operator ${JSON.stringify($)}`)}function Ut($){return w1($)?$.toOperationNode():$}var a5=k({is($){return $.kind==="OrderByNode"},create($){return k({kind:"OrderByNode",items:k([...$])})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var CD=k({is($){return $.kind==="PartitionByNode"},create($){return k({kind:"PartitionByNode",items:k($)})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var aO=k({is($){return $.kind==="OverNode"},create(){return k({kind:"OverNode"})},cloneWithOrderByItems($,K){return k({...$,orderBy:$.orderBy?a5.cloneWithItems($.orderBy,K):a5.create(K)})},cloneWithPartitionByItems($,K){return k({...$,partitionBy:$.partitionBy?CD.cloneWithItems($.partitionBy,K):CD.create(K)})}});var eY=k({is($){return $.kind==="FromNode"},create($){return k({kind:"FromNode",froms:k($)})},cloneWithFroms($,K){return k({...$,froms:k([...$.froms,...K])})}});var RD=k({is($){return $.kind==="GroupByNode"},create($){return k({kind:"GroupByNode",items:k($)})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var DD=k({is($){return $.kind==="HavingNode"},create($){return k({kind:"HavingNode",having:$})},cloneWithOperation($,K,q){return k({...$,having:K==="And"?T$.create($.having,q):B7.create($.having,q)})}});var i1=k({is($){return $.kind==="InsertQueryNode"},create($,K,q){return k({kind:"InsertQueryNode",into:$,...K&&{with:K},replace:q})},createWithoutInto(){return k({kind:"InsertQueryNode"})},cloneWith($,K){return k({...$,...K})}});var Y0=k({is($){return $.kind==="ListNode"},create($){return k({kind:"ListNode",items:k($)})}});var F9=k({is($){return $.kind==="UpdateQueryNode"},create($,K){return k({kind:"UpdateQueryNode",table:$.length===1?$[0]:Y0.create($),...K&&{with:K}})},createWithoutTable(){return k({kind:"UpdateQueryNode"})},cloneWithFromItems($,K){return k({...$,from:$.from?eY.cloneWithFroms($.from,K):eY.create(K)})},cloneWithUpdates($,K){return k({...$,updates:$.updates?k([...$.updates,...K]):K})},cloneWithLimit($,K){return k({...$,limit:K})}});var SD=k({is($){return $.kind==="UsingNode"},create($){return k({kind:"UsingNode",tables:k($)})},cloneWithTables($,K){return k({...$,tables:k([...$.tables,...K])})}});var jq=k({is($){return $.kind==="DeleteQueryNode"},create($,K){return k({kind:"DeleteQueryNode",from:eY.create($),...K&&{with:K}})},cloneWithOrderByItems:($,K)=>C8.cloneWithOrderByItems($,K),cloneWithoutOrderBy:($)=>C8.cloneWithoutOrderBy($),cloneWithLimit($,K){return k({...$,limit:K})},cloneWithoutLimit($){return k({...$,limit:void 0})},cloneWithUsing($,K){return k({...$,using:$.using!==void 0?SD.cloneWithTables($.using,K):SD.create(K)})}});var t4=k({is($){return $.kind==="WhereNode"},create($){return k({kind:"WhereNode",where:$})},cloneWithOperation($,K,q){return k({...$,where:K==="And"?T$.create($.where,q):B7.create($.where,q)})}});var ED=k({is($){return $.kind==="ReturningNode"},create($){return k({kind:"ReturningNode",selections:k($)})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})}});var Ft=k({is($){return $.kind==="ExplainNode"},create($,K){return k({kind:"ExplainNode",format:$,options:K})}});var Y7=k({is($){return $.kind==="WhenNode"},create($){return k({kind:"WhenNode",condition:$})},cloneWithResult($,K){return k({...$,result:K})}});var p$=k({is($){return $.kind==="MergeQueryNode"},create($,K){return k({kind:"MergeQueryNode",into:$,...K&&{with:K}})},cloneWithUsing($,K){return k({...$,using:K})},cloneWithWhen($,K){return k({...$,whens:$.whens?k([...$.whens,K]):k([K])})},cloneWithThen($,K){return k({...$,whens:$.whens?k([...$.whens.slice(0,-1),Y7.cloneWithResult($.whens[$.whens.length-1],K)]):void 0})}});var LD=k({is($){return $.kind==="OutputNode"},create($){return k({kind:"OutputNode",selections:k($)})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})}});var C8=k({is($){return m6.is($)||i1.is($)||F9.is($)||jq.is($)||p$.is($)},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):k([K])})},cloneWithWhere($,K){return k({...$,where:$.where?t4.cloneWithOperation($.where,"And",K):t4.create(K)})},cloneWithJoin($,K){return k({...$,joins:$.joins?k([...$.joins,K]):k([K])})},cloneWithReturning($,K){return k({...$,returning:$.returning?ED.cloneWithSelections($.returning,K):ED.create(K)})},cloneWithoutReturning($){return k({...$,returning:void 0})},cloneWithoutWhere($){return k({...$,where:void 0})},cloneWithExplain($,K,q){return k({...$,explain:Ft.create(K,q?.toOperationNode())})},cloneWithTop($,K){return k({...$,top:K})},cloneWithOutput($,K){return k({...$,output:$.output?LD.cloneWithSelections($.output,K):LD.create(K)})},cloneWithOrderByItems($,K){return k({...$,orderBy:$.orderBy?a5.cloneWithItems($.orderBy,K):a5.create(K)})},cloneWithoutOrderBy($){return k({...$,orderBy:void 0})}});var m6=k({is($){return $.kind==="SelectQueryNode"},create($){return k({kind:"SelectQueryNode",...$&&{with:$}})},createFrom($,K){return k({kind:"SelectQueryNode",from:eY.create($),...K&&{with:K}})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})},cloneWithDistinctOn($,K){return k({...$,distinctOn:$.distinctOn?k([...$.distinctOn,...K]):k(K)})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):k([K])})},cloneWithOrderByItems:($,K)=>C8.cloneWithOrderByItems($,K),cloneWithGroupByItems($,K){return k({...$,groupBy:$.groupBy?RD.cloneWithItems($.groupBy,K):RD.create(K)})},cloneWithLimit($,K){return k({...$,limit:K})},cloneWithOffset($,K){return k({...$,offset:K})},cloneWithFetch($,K){return k({...$,fetch:K})},cloneWithHaving($,K){return k({...$,having:$.having?DD.cloneWithOperation($.having,"And",K):DD.create(K)})},cloneWithSetOperations($,K){return k({...$,setOperations:$.setOperations?k([...$.setOperations,...K]):k([...K])})},cloneWithoutSelections($){return k({...$,selections:[]})},cloneWithoutLimit($){return k({...$,limit:void 0})},cloneWithoutOffset($){return k({...$,offset:void 0})},cloneWithoutOrderBy:($)=>C8.cloneWithoutOrderBy($),cloneWithoutGroupBy($){return k({...$,groupBy:void 0})}});class ZJ{#$;constructor($){this.#$=k($)}on(...$){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,W1($))})}onRef($,K,q){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,Q4($,K,q))})}onTrue(){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,b6.createWithSql("true"))})}$call($){return $(this)}toOperationNode(){return this.#$.joinNode}}var it=k({is($){return $.kind==="PartitionByItemNode"},create($){return k({kind:"PartitionByItemNode",partitionBy:$})}});function Qt($){return o5($).map(it.create)}class OJ{#$;constructor($){this.#$=k($)}orderBy(...$){return new OJ({overNode:aO.cloneWithOrderByItems(this.#$.overNode,u$($))})}clearOrderBy(){return new OJ({overNode:C8.cloneWithoutOrderBy(this.#$.overNode)})}partitionBy($){return new OJ({overNode:aO.cloneWithPartitionByItems(this.#$.overNode,Qt($))})}$call($){return $(this)}toOperationNode(){return this.#$.overNode}}var wJ=k({is($){return $.kind==="SelectionNode"},create($){return k({kind:"SelectionNode",selection:$})},createSelectAll(){return k({kind:"SelectionNode",selection:zJ.create()})},createSelectAllFromTable($){return k({kind:"SelectionNode",selection:PJ.createSelectAll($)})}});function N4($){if(A1($))return N4($(F7()));else if(j3($))return $.map((K)=>dt(K));else return[dt($)]}function dt($){if(f1($))return wJ.create(ct($));else if(tG($))return wJ.create($.toOperationNode());else return wJ.create(z0($))}function d4($){if(!$)return[wJ.createSelectAll()];else if(Array.isArray($))return $.map(nt);else return[nt($)]}function nt($){if(f1($))return wJ.createSelectAllFromTable(g6($));throw new Error(`invalid value selectAll expression: ${JSON.stringify($)}`)}var ot=k({is($){return $.kind==="ValuesNode"},create($){return k({kind:"ValuesNode",values:k($)})}});var at=k({is($){return $.kind==="DefaultInsertValueNode"},create(){return k({kind:"DefaultInsertValueNode"})}});function P0($){let K=A1($)?$(F7()):$,q=j3(K)?K:k([K]);return w46(q)}function w46($){let K=X46($);return[k([...K.keys()].map(R6.create)),ot.create($.map((q)=>T46(q,K)))]}function X46($){let K=new Map;for(let q of $){let Y=Object.keys(q);for(let z of Y)if(!K.has(z)&&q[z]!==void 0)K.set(z,K.size)}return K}function T46($,K){let q=Object.keys($),Y=Array.from({length:K.size}),z=!1,P=q.length;for(let W of q){let H=K.get(W);if(x$(H)){P--;continue}let Z=$[W];if(x$(Z)||n5(Z))z=!0;Y[H]=Z}if(P<K.size||z){let W=at.create();return Tq.create(Y.map((H)=>x$(H)?W:q1(H)))}return $0.create(Y)}var ID=k({is($){return $.kind==="ColumnUpdateNode"},create($,K){return k({kind:"ColumnUpdateNode",column:$,value:K})}});function rt(...$){if($.length===2)return[ID.create(s4($[0]),q1($[1]))];return rO($[0])}function rO($){let K=A1($)?$(F7()):$;return Object.entries(K).filter(([q,Y])=>Y!==void 0).map(([q,Y])=>{return ID.create(R6.create(q),q1(Y))})}var st=k({is($){return $.kind==="OnDuplicateKeyNode"},create($){return k({kind:"OnDuplicateKeyNode",updates:$})}});class xD{insertId;numInsertedOrUpdatedRows;constructor($,K){this.insertId=$,this.numInsertedOrUpdatedRows=K}}class i7 extends Error{node;constructor($){super("no result");this.node=$}}function i9($){return Object.prototype.hasOwnProperty.call($,"prototype")}var F3=k({is($){return $.kind==="OnConflictNode"},create(){return k({kind:"OnConflictNode"})},cloneWith($,K){return k({...$,...K})},cloneWithIndexWhere($,K){return k({...$,indexWhere:$.indexWhere?t4.cloneWithOperation($.indexWhere,"And",K):t4.create(K)})},cloneWithIndexOrWhere($,K){return k({...$,indexWhere:$.indexWhere?t4.cloneWithOperation($.indexWhere,"Or",K):t4.create(K)})},cloneWithUpdateWhere($,K){return k({...$,updateWhere:$.updateWhere?t4.cloneWithOperation($.updateWhere,"And",K):t4.create(K)})},cloneWithUpdateOrWhere($,K){return k({...$,updateWhere:$.updateWhere?t4.cloneWithOperation($.updateWhere,"Or",K):t4.create(K)})},cloneWithoutIndexWhere($){return k({...$,indexWhere:void 0})},cloneWithoutUpdateWhere($){return k({...$,updateWhere:void 0})}});class Q9{#$;constructor($){this.#$=k($)}column($){let K=R6.create($);return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{columns:this.#$.onConflictNode.columns?k([...this.#$.onConflictNode.columns,K]):k([K])})})}columns($){let K=$.map(R6.create);return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{columns:this.#$.onConflictNode.columns?k([...this.#$.onConflictNode.columns,...K]):k(K)})})}constraint($){return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{constraint:p8.create($)})})}expression($){return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{indexExpression:$.toOperationNode()})})}where(...$){return new Q9({...this.#$,onConflictNode:F3.cloneWithIndexWhere(this.#$.onConflictNode,W1($))})}whereRef($,K,q){return new Q9({...this.#$,onConflictNode:F3.cloneWithIndexWhere(this.#$.onConflictNode,Q4($,K,q))})}clearWhere(){return new Q9({...this.#$,onConflictNode:F3.cloneWithoutIndexWhere(this.#$.onConflictNode)})}doNothing(){return new tt({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{doNothing:!0})})}doUpdateSet($){return new sO({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{updates:rO($)})})}$call($){return $(this)}}class tt{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.onConflictNode}}class sO{#$;constructor($){this.#$=k($)}where(...$){return new sO({...this.#$,onConflictNode:F3.cloneWithUpdateWhere(this.#$.onConflictNode,W1($))})}whereRef($,K,q){return new sO({...this.#$,onConflictNode:F3.cloneWithUpdateWhere(this.#$.onConflictNode,Q4($,K,q))})}clearWhere(){return new sO({...this.#$,onConflictNode:F3.cloneWithoutUpdateWhere(this.#$.onConflictNode)})}$call($){return $(this)}toOperationNode(){return this.#$.onConflictNode}}var et=k({is($){return $.kind==="TopNode"},create($,K){return k({kind:"TopNode",expression:$,modifiers:K})}});function Q7($,K){if(!Hq($)&&!YJ($))throw new Error(`Invalid top expression: ${$}`);if(!x$(K)&&!j46(K))throw new Error(`Invalid top modifiers: ${K}`);return et.create($,K)}function j46($){return $==="percent"||$==="with ties"||$==="percent with ties"}var $z=k({is($){return $.kind==="OrActionNode"},create($){return k({kind:"OrActionNode",action:$})}});class Y1{#$;constructor($){this.#$=k($)}values($){let[K,q]=P0($);return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{columns:K,values:q})})}columns($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{columns:k($.map(R6.create))})})}expression($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{values:j$($)})})}defaultValues(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{defaultValues:!0})})}modifyEnd($){return new Y1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}ignore(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("ignore")})})}orIgnore(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("ignore")})})}orAbort(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("abort")})})}orFail(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("fail")})})}orReplace(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("replace")})})}orRollback(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("rollback")})})}top($,K){return new Y1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}onConflict($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{onConflict:$(new Q9({onConflictNode:F3.create()})).toOperationNode()})})}onDuplicateKeyUpdate($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{onDuplicateKey:st.create(rO($))})})}returning($){return new Y1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll(){return new Y1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4())})}output($){return new Y1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new Y1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}clearReturning(){return new Y1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new Y1({...this.#$})}$castTo(){return new Y1(this.#$)}$narrowType(){return new Y1(this.#$)}$assertType(){return new Y1(this.#$)}withPlugin($){return new Y1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new xD(K.insertId,K.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new Y1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}class bD{numDeletedRows;constructor($){this.numDeletedRows=$}}var XJ=k({is($){return $.kind==="LimitNode"},create($){return k({kind:"LimitNode",limit:$})}});class M1{#$;constructor($){this.#$=k($)}where(...$){return new M1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new M1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}clearWhere(){return new M1({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}top($,K){return new M1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}using($){return new M1({...this.#$,queryNode:jq.cloneWithUsing(this.#$.queryNode,d7($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}#K($,K){return new M1({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}returning($){return new M1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new M1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new M1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new M1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}clearReturning(){return new M1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}clearLimit(){return new M1({...this.#$,queryNode:jq.cloneWithoutLimit(this.#$.queryNode)})}orderBy(...$){return new M1({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}clearOrderBy(){return new M1({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}limit($){return new M1({...this.#$,queryNode:jq.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}modifyEnd($){return new M1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}$call($){return $(this)}$if($,K){if($)return K(this);return new M1({...this.#$})}$castTo(){return new M1(this.#$)}$narrowType(){return new M1(this.#$)}$assertType(){return new M1(this.#$)}withPlugin($){return new M1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new bD(K.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new M1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}class gD{numUpdatedRows;numChangedRows;constructor($,K){this.numUpdatedRows=$,this.numChangedRows=K}}class X1{#$;constructor($){this.#$=k($)}where(...$){return new X1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new X1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}clearWhere(){return new X1({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}top($,K){return new X1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}from($){return new X1({...this.#$,queryNode:F9.cloneWithFromItems(this.#$.queryNode,d7($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}#K($,K){return new X1({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}orderBy(...$){return new X1({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}clearOrderBy(){return new X1({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}limit($){return new X1({...this.#$,queryNode:F9.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}set(...$){return new X1({...this.#$,queryNode:F9.cloneWithUpdates(this.#$.queryNode,rt(...$))})}returning($){return new X1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new X1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new X1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new X1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}modifyEnd($){return new X1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}clearReturning(){return new X1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new X1({...this.#$})}$castTo(){return new X1(this.#$)}$narrowType(){return new X1(this.#$)}$assertType(){return new X1(this.#$)}withPlugin($){return new X1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new gD(K.numAffectedRows??BigInt(0),K.numChangedRows)]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new X1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}var yD=k({is($){return $.kind==="CommonTableExpressionNameNode"},create($,K){return k({kind:"CommonTableExpressionNameNode",table:b$.create($),columns:K?k(K.map(R6.create)):void 0})}});var TJ=k({is($){return $.kind==="CommonTableExpressionNode"},create($,K){return k({kind:"CommonTableExpressionNode",name:$,expression:K})},cloneWith($,K){return k({...$,...K})}});class tO{#$;constructor($){this.#$=k($)}materialized(){return new tO({...this.#$,node:TJ.cloneWith(this.#$.node,{materialized:!0})})}notMaterialized(){return new tO({...this.#$,node:TJ.cloneWith(this.#$.node,{materialized:!1})})}toOperationNode(){return this.#$.node}}function uD($,K){let q=K(Ke()).toOperationNode();if(A1($))return $(v46(q)).toOperationNode();return TJ.create($e($),q)}function v46($){return(K)=>{return new tO({node:TJ.create($e(K),$)})}}function $e($){if($.includes("(")){let K=$.split(/[\(\)]/),q=K[0],Y=K[1].split(",").map((z)=>z.trim());return yD.create(q,Y)}else return yD.create($)}var eO=k({is($){return $.kind==="WithNode"},create($,K){return k({kind:"WithNode",expressions:k([$]),...K})},cloneWithExpression($,K){return k({...$,expressions:k([...$.expressions,K])})}});var qe=["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","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","0","1","2","3","4","5","6","7","8","9"];function Ye($){let K="";for(let q=0;q<$;++q)K+=G46();return K}function G46(){return qe[~~(Math.random()*qe.length)]}function $6(){return new ze}class ze{#$;get queryId(){if(this.#$===void 0)this.#$=Ye(8);return this.#$}}function _8($){return $}class $w{nodeStack=[];#$=k({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode($,K){if(!$)return $;this.nodeStack.push($);let q=this.transformNodeImpl($,K);return this.nodeStack.pop(),k(q)}transformNodeImpl($,K){return this.#$[$.kind]($,K)}transformNodeList($,K){if(!$)return $;return k($.map((q)=>this.transformNode(q,K)))}transformSelectQuery($,K){return _8({kind:"SelectQueryNode",from:this.transformNode($.from,K),selections:this.transformNodeList($.selections,K),distinctOn:this.transformNodeList($.distinctOn,K),joins:this.transformNodeList($.joins,K),groupBy:this.transformNode($.groupBy,K),orderBy:this.transformNode($.orderBy,K),where:this.transformNode($.where,K),frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),limit:this.transformNode($.limit,K),offset:this.transformNode($.offset,K),with:this.transformNode($.with,K),having:this.transformNode($.having,K),explain:this.transformNode($.explain,K),setOperations:this.transformNodeList($.setOperations,K),fetch:this.transformNode($.fetch,K),top:this.transformNode($.top,K)})}transformSelection($,K){return _8({kind:"SelectionNode",selection:this.transformNode($.selection,K)})}transformColumn($,K){return _8({kind:"ColumnNode",column:this.transformNode($.column,K)})}transformAlias($,K){return _8({kind:"AliasNode",node:this.transformNode($.node,K),alias:this.transformNode($.alias,K)})}transformTable($,K){return _8({kind:"TableNode",table:this.transformNode($.table,K)})}transformFrom($,K){return _8({kind:"FromNode",froms:this.transformNodeList($.froms,K)})}transformReference($,K){return _8({kind:"ReferenceNode",column:this.transformNode($.column,K),table:this.transformNode($.table,K)})}transformAnd($,K){return _8({kind:"AndNode",left:this.transformNode($.left,K),right:this.transformNode($.right,K)})}transformOr($,K){return _8({kind:"OrNode",left:this.transformNode($.left,K),right:this.transformNode($.right,K)})}transformValueList($,K){return _8({kind:"ValueListNode",values:this.transformNodeList($.values,K)})}transformParens($,K){return _8({kind:"ParensNode",node:this.transformNode($.node,K)})}transformJoin($,K){return _8({kind:"JoinNode",joinType:$.joinType,table:this.transformNode($.table,K),on:this.transformNode($.on,K)})}transformRaw($,K){return _8({kind:"RawNode",sqlFragments:k([...$.sqlFragments]),parameters:this.transformNodeList($.parameters,K)})}transformWhere($,K){return _8({kind:"WhereNode",where:this.transformNode($.where,K)})}transformInsertQuery($,K){return _8({kind:"InsertQueryNode",into:this.transformNode($.into,K),columns:this.transformNodeList($.columns,K),values:this.transformNode($.values,K),returning:this.transformNode($.returning,K),onConflict:this.transformNode($.onConflict,K),onDuplicateKey:this.transformNode($.onDuplicateKey,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),ignore:$.ignore,orAction:this.transformNode($.orAction,K),replace:$.replace,explain:this.transformNode($.explain,K),defaultValues:$.defaultValues,top:this.transformNode($.top,K),output:this.transformNode($.output,K)})}transformValues($,K){return _8({kind:"ValuesNode",values:this.transformNodeList($.values,K)})}transformDeleteQuery($,K){return _8({kind:"DeleteQueryNode",from:this.transformNode($.from,K),using:this.transformNode($.using,K),joins:this.transformNodeList($.joins,K),where:this.transformNode($.where,K),returning:this.transformNode($.returning,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),orderBy:this.transformNode($.orderBy,K),limit:this.transformNode($.limit,K),explain:this.transformNode($.explain,K),top:this.transformNode($.top,K),output:this.transformNode($.output,K)})}transformReturning($,K){return _8({kind:"ReturningNode",selections:this.transformNodeList($.selections,K)})}transformCreateTable($,K){return _8({kind:"CreateTableNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),constraints:this.transformNodeList($.constraints,K),temporary:$.temporary,ifNotExists:$.ifNotExists,onCommit:$.onCommit,frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),selectQuery:this.transformNode($.selectQuery,K)})}transformColumnDefinition($,K){return _8({kind:"ColumnDefinitionNode",column:this.transformNode($.column,K),dataType:this.transformNode($.dataType,K),references:this.transformNode($.references,K),primaryKey:$.primaryKey,autoIncrement:$.autoIncrement,unique:$.unique,notNull:$.notNull,unsigned:$.unsigned,defaultTo:this.transformNode($.defaultTo,K),check:this.transformNode($.check,K),generated:this.transformNode($.generated,K),frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),nullsNotDistinct:$.nullsNotDistinct,identity:$.identity,ifNotExists:$.ifNotExists})}transformAddColumn($,K){return _8({kind:"AddColumnNode",column:this.transformNode($.column,K)})}transformDropTable($,K){return _8({kind:"DropTableNode",table:this.transformNode($.table,K),ifExists:$.ifExists,cascade:$.cascade})}transformOrderBy($,K){return _8({kind:"OrderByNode",items:this.transformNodeList($.items,K)})}transformOrderByItem($,K){return _8({kind:"OrderByItemNode",orderBy:this.transformNode($.orderBy,K),direction:this.transformNode($.direction,K),collation:this.transformNode($.collation,K),nulls:$.nulls})}transformGroupBy($,K){return _8({kind:"GroupByNode",items:this.transformNodeList($.items,K)})}transformGroupByItem($,K){return _8({kind:"GroupByItemNode",groupBy:this.transformNode($.groupBy,K)})}transformUpdateQuery($,K){return _8({kind:"UpdateQueryNode",table:this.transformNode($.table,K),from:this.transformNode($.from,K),joins:this.transformNodeList($.joins,K),where:this.transformNode($.where,K),updates:this.transformNodeList($.updates,K),returning:this.transformNode($.returning,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),explain:this.transformNode($.explain,K),limit:this.transformNode($.limit,K),top:this.transformNode($.top,K),output:this.transformNode($.output,K),orderBy:this.transformNode($.orderBy,K)})}transformColumnUpdate($,K){return _8({kind:"ColumnUpdateNode",column:this.transformNode($.column,K),value:this.transformNode($.value,K)})}transformLimit($,K){return _8({kind:"LimitNode",limit:this.transformNode($.limit,K)})}transformOffset($,K){return _8({kind:"OffsetNode",offset:this.transformNode($.offset,K)})}transformOnConflict($,K){return _8({kind:"OnConflictNode",columns:this.transformNodeList($.columns,K),constraint:this.transformNode($.constraint,K),indexExpression:this.transformNode($.indexExpression,K),indexWhere:this.transformNode($.indexWhere,K),updates:this.transformNodeList($.updates,K),updateWhere:this.transformNode($.updateWhere,K),doNothing:$.doNothing})}transformOnDuplicateKey($,K){return _8({kind:"OnDuplicateKeyNode",updates:this.transformNodeList($.updates,K)})}transformCreateIndex($,K){return _8({kind:"CreateIndexNode",name:this.transformNode($.name,K),table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),unique:$.unique,using:this.transformNode($.using,K),ifNotExists:$.ifNotExists,where:this.transformNode($.where,K),nullsNotDistinct:$.nullsNotDistinct})}transformList($,K){return _8({kind:"ListNode",items:this.transformNodeList($.items,K)})}transformDropIndex($,K){return _8({kind:"DropIndexNode",name:this.transformNode($.name,K),table:this.transformNode($.table,K),ifExists:$.ifExists,cascade:$.cascade})}transformPrimaryKeyConstraint($,K){return _8({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList($.columns,K),name:this.transformNode($.name,K),deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformUniqueConstraint($,K){return _8({kind:"UniqueConstraintNode",columns:this.transformNodeList($.columns,K),name:this.transformNode($.name,K),nullsNotDistinct:$.nullsNotDistinct,deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformForeignKeyConstraint($,K){return _8({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList($.columns,K),references:this.transformNode($.references,K),name:this.transformNode($.name,K),onDelete:$.onDelete,onUpdate:$.onUpdate,deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformSetOperation($,K){return _8({kind:"SetOperationNode",operator:$.operator,expression:this.transformNode($.expression,K),all:$.all})}transformReferences($,K){return _8({kind:"ReferencesNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),onDelete:$.onDelete,onUpdate:$.onUpdate})}transformCheckConstraint($,K){return _8({kind:"CheckConstraintNode",expression:this.transformNode($.expression,K),name:this.transformNode($.name,K)})}transformWith($,K){return _8({kind:"WithNode",expressions:this.transformNodeList($.expressions,K),recursive:$.recursive})}transformCommonTableExpression($,K){return _8({kind:"CommonTableExpressionNode",name:this.transformNode($.name,K),materialized:$.materialized,expression:this.transformNode($.expression,K)})}transformCommonTableExpressionName($,K){return _8({kind:"CommonTableExpressionNameNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K)})}transformHaving($,K){return _8({kind:"HavingNode",having:this.transformNode($.having,K)})}transformCreateSchema($,K){return _8({kind:"CreateSchemaNode",schema:this.transformNode($.schema,K),ifNotExists:$.ifNotExists})}transformDropSchema($,K){return _8({kind:"DropSchemaNode",schema:this.transformNode($.schema,K),ifExists:$.ifExists,cascade:$.cascade})}transformAlterTable($,K){return _8({kind:"AlterTableNode",table:this.transformNode($.table,K),renameTo:this.transformNode($.renameTo,K),setSchema:this.transformNode($.setSchema,K),columnAlterations:this.transformNodeList($.columnAlterations,K),addConstraint:this.transformNode($.addConstraint,K),dropConstraint:this.transformNode($.dropConstraint,K),renameConstraint:this.transformNode($.renameConstraint,K),addIndex:this.transformNode($.addIndex,K),dropIndex:this.transformNode($.dropIndex,K)})}transformDropColumn($,K){return _8({kind:"DropColumnNode",column:this.transformNode($.column,K)})}transformRenameColumn($,K){return _8({kind:"RenameColumnNode",column:this.transformNode($.column,K),renameTo:this.transformNode($.renameTo,K)})}transformAlterColumn($,K){return _8({kind:"AlterColumnNode",column:this.transformNode($.column,K),dataType:this.transformNode($.dataType,K),dataTypeExpression:this.transformNode($.dataTypeExpression,K),setDefault:this.transformNode($.setDefault,K),dropDefault:$.dropDefault,setNotNull:$.setNotNull,dropNotNull:$.dropNotNull})}transformModifyColumn($,K){return _8({kind:"ModifyColumnNode",column:this.transformNode($.column,K)})}transformAddConstraint($,K){return _8({kind:"AddConstraintNode",constraint:this.transformNode($.constraint,K)})}transformDropConstraint($,K){return _8({kind:"DropConstraintNode",constraintName:this.transformNode($.constraintName,K),ifExists:$.ifExists,modifier:$.modifier})}transformRenameConstraint($,K){return _8({kind:"RenameConstraintNode",oldName:this.transformNode($.oldName,K),newName:this.transformNode($.newName,K)})}transformCreateView($,K){return _8({kind:"CreateViewNode",name:this.transformNode($.name,K),temporary:$.temporary,orReplace:$.orReplace,ifNotExists:$.ifNotExists,materialized:$.materialized,columns:this.transformNodeList($.columns,K),as:this.transformNode($.as,K)})}transformRefreshMaterializedView($,K){return _8({kind:"RefreshMaterializedViewNode",name:this.transformNode($.name,K),concurrently:$.concurrently,withNoData:$.withNoData})}transformDropView($,K){return _8({kind:"DropViewNode",name:this.transformNode($.name,K),ifExists:$.ifExists,materialized:$.materialized,cascade:$.cascade})}transformGenerated($,K){return _8({kind:"GeneratedNode",byDefault:$.byDefault,always:$.always,identity:$.identity,stored:$.stored,expression:this.transformNode($.expression,K)})}transformDefaultValue($,K){return _8({kind:"DefaultValueNode",defaultValue:this.transformNode($.defaultValue,K)})}transformOn($,K){return _8({kind:"OnNode",on:this.transformNode($.on,K)})}transformSelectModifier($,K){return _8({kind:"SelectModifierNode",modifier:$.modifier,rawModifier:this.transformNode($.rawModifier,K),of:this.transformNodeList($.of,K)})}transformCreateType($,K){return _8({kind:"CreateTypeNode",name:this.transformNode($.name,K),enum:this.transformNode($.enum,K)})}transformDropType($,K){return _8({kind:"DropTypeNode",name:this.transformNode($.name,K),ifExists:$.ifExists})}transformExplain($,K){return _8({kind:"ExplainNode",format:$.format,options:this.transformNode($.options,K)})}transformSchemableIdentifier($,K){return _8({kind:"SchemableIdentifierNode",schema:this.transformNode($.schema,K),identifier:this.transformNode($.identifier,K)})}transformAggregateFunction($,K){return _8({kind:"AggregateFunctionNode",func:$.func,aggregated:this.transformNodeList($.aggregated,K),distinct:$.distinct,orderBy:this.transformNode($.orderBy,K),withinGroup:this.transformNode($.withinGroup,K),filter:this.transformNode($.filter,K),over:this.transformNode($.over,K)})}transformOver($,K){return _8({kind:"OverNode",orderBy:this.transformNode($.orderBy,K),partitionBy:this.transformNode($.partitionBy,K)})}transformPartitionBy($,K){return _8({kind:"PartitionByNode",items:this.transformNodeList($.items,K)})}transformPartitionByItem($,K){return _8({kind:"PartitionByItemNode",partitionBy:this.transformNode($.partitionBy,K)})}transformBinaryOperation($,K){return _8({kind:"BinaryOperationNode",leftOperand:this.transformNode($.leftOperand,K),operator:this.transformNode($.operator,K),rightOperand:this.transformNode($.rightOperand,K)})}transformUnaryOperation($,K){return _8({kind:"UnaryOperationNode",operator:this.transformNode($.operator,K),operand:this.transformNode($.operand,K)})}transformUsing($,K){return _8({kind:"UsingNode",tables:this.transformNodeList($.tables,K)})}transformFunction($,K){return _8({kind:"FunctionNode",func:$.func,arguments:this.transformNodeList($.arguments,K)})}transformCase($,K){return _8({kind:"CaseNode",value:this.transformNode($.value,K),when:this.transformNodeList($.when,K),else:this.transformNode($.else,K),isStatement:$.isStatement})}transformWhen($,K){return _8({kind:"WhenNode",condition:this.transformNode($.condition,K),result:this.transformNode($.result,K)})}transformJSONReference($,K){return _8({kind:"JSONReferenceNode",reference:this.transformNode($.reference,K),traversal:this.transformNode($.traversal,K)})}transformJSONPath($,K){return _8({kind:"JSONPathNode",inOperator:this.transformNode($.inOperator,K),pathLegs:this.transformNodeList($.pathLegs,K)})}transformJSONPathLeg($,K){return _8({kind:"JSONPathLegNode",type:$.type,value:$.value})}transformJSONOperatorChain($,K){return _8({kind:"JSONOperatorChainNode",operator:this.transformNode($.operator,K),values:this.transformNodeList($.values,K)})}transformTuple($,K){return _8({kind:"TupleNode",values:this.transformNodeList($.values,K)})}transformMergeQuery($,K){return _8({kind:"MergeQueryNode",into:this.transformNode($.into,K),using:this.transformNode($.using,K),whens:this.transformNodeList($.whens,K),with:this.transformNode($.with,K),top:this.transformNode($.top,K),endModifiers:this.transformNodeList($.endModifiers,K),output:this.transformNode($.output,K),returning:this.transformNode($.returning,K)})}transformMatched($,K){return _8({kind:"MatchedNode",not:$.not,bySource:$.bySource})}transformAddIndex($,K){return _8({kind:"AddIndexNode",name:this.transformNode($.name,K),columns:this.transformNodeList($.columns,K),unique:$.unique,using:this.transformNode($.using,K),ifNotExists:$.ifNotExists})}transformCast($,K){return _8({kind:"CastNode",expression:this.transformNode($.expression,K),dataType:this.transformNode($.dataType,K)})}transformFetch($,K){return _8({kind:"FetchNode",rowCount:this.transformNode($.rowCount,K),modifier:$.modifier})}transformTop($,K){return _8({kind:"TopNode",expression:$.expression,modifiers:$.modifiers})}transformOutput($,K){return _8({kind:"OutputNode",selections:this.transformNodeList($.selections,K)})}transformDataType($,K){return $}transformSelectAll($,K){return $}transformIdentifier($,K){return $}transformValue($,K){return $}transformPrimitiveValueList($,K){return $}transformOperator($,K){return $}transformDefaultInsertValue($,K){return $}transformOrAction($,K){return $}transformCollate($,K){return $}}var _46=k({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),f46={json_agg:!0,to_json:!0};class mD extends $w{#$;#K=new Set;#q=new Set;constructor($){super();this.#$=$}transformNodeImpl($,K){if(!this.#z($))return super.transformNodeImpl($,K);let q=this.#P($);for(let P of q)this.#q.add(P);let Y=this.#w($);for(let P of Y)this.#K.add(P);let z=super.transformNodeImpl($,K);for(let P of Y)this.#K.delete(P);for(let P of q)this.#q.delete(P);return z}transformSchemableIdentifier($,K){let q=super.transformSchemableIdentifier($,K);if(q.schema||!this.#K.has($.identifier.name))return q;return{...q,schema:p8.create(this.#$)}}transformReferences($,K){let q=super.transformReferences($,K);if(q.table.table.schema)return q;return{...q,table:b$.createWithSchema(this.#$,q.table.table.identifier.name)}}transformAggregateFunction($,K){return{...super.transformAggregateFunction({...$,aggregated:[]},K),aggregated:this.#Y($,K,"aggregated")}}transformFunction($,K){return{...super.transformFunction({...$,arguments:[]},K),arguments:this.#Y($,K,"arguments")}}#Y($,K,q){return f46[$.func]?$[q].map((Y)=>!b$.is(Y)||Y.table.schema?this.transformNode(Y,K):{...Y,table:this.transformIdentifier(Y.table.identifier,K)}):this.transformNodeList($[q],K)}#z($){return $.kind in _46}#w($){let K=new Set;if("name"in $&&$.name&&G3.is($.name))this.#W($.name,K);if("from"in $&&$.from)for(let q of $.from.froms)this.#H(q,K);if("into"in $&&$.into)this.#H($.into,K);if("table"in $&&$.table)this.#H($.table,K);if("joins"in $&&$.joins)for(let q of $.joins)this.#H(q.table,K);if("using"in $&&$.using)if(U7.is($.using))this.#H($.using.table,K);else this.#H($.using,K);return K}#P($){let K=new Set;if("with"in $&&$.with)this.#O($.with,K);return K}#H($,K){if(b$.is($))this.#W($.table,K);else if(i4.is($)&&b$.is($.node))this.#W($.node.table,K);else if(Y0.is($))for(let q of $.items)this.#H(q,K)}#W($,K){let q=$.identifier.name;if(!this.#K.has(q)&&!this.#q.has(q))K.add(q)}#O($,K){for(let q of $.expressions){let Y=q.name.table.table.identifier.name;if(!this.#q.has(Y))K.add(Y)}}}class c${#$;constructor($){this.#$=new mD($)}transformQuery($){return this.#$.transformNode($.node,$.queryId)}async transformResult($){return $.result}}var Pe=k({is($){return $.kind==="MatchedNode"},create($,K=!1){return k({kind:"MatchedNode",not:$,bySource:K})}});function pD($,K,q){return Y7.create(HJ([Pe.create(!$.isMatched,$.bySource),...K&&K.length>0?[K.length===3&&q?Q4(K[0],K[1],K[2]):W1(K)]:[]],"and",!1))}function jJ($){if(f1($))return b6.create([$],[]);if(w1($))return $.toOperationNode();return $}class J0{#$;#K;#q;constructor(){this.#$=new Promise(($,K)=>{this.#q=K,this.#K=$})}get promise(){return this.#$}resolve=($)=>{if(this.#K)this.#K($)};reject=($)=>{if(this.#q)this.#q($)}}async function W0($){let K=new J0,q=new J0;return $.provideConnection(async(Y)=>{return K.resolve(Y),await q.promise}).catch((Y)=>K.reject(Y)),k({connection:await K.promise,release:q.resolve})}var A46=k([]);class Kw{#$;constructor($=A46){this.#$=$}get plugins(){return this.#$}transformQuery($,K){for(let q of this.#$){let Y=q.transformQuery({node:$,queryId:K});if(Y.kind===$.kind)$=Y;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${$.kind}`,`but it returned a ${Y.kind}`].join(" "))}return $}async executeQuery($){return await this.provideConnection(async(K)=>{let q=await K.executeQuery($);if("numUpdatedOrDeletedRows"in q)l9("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#K(q,$.queryId)})}async*stream($,K){let{connection:q,release:Y}=await W0(this);try{for await(let z of q.streamQuery($,K))yield await this.#K(z,$.queryId)}finally{Y()}}async#K($,K){for(let q of this.#$)$=await q.transformResult({result:$,queryId:K});return $}}class vJ extends Kw{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin($){return new vJ([...this.plugins,$])}withPlugins($){return new vJ([...this.plugins,...$])}withPluginAtFront($){return new vJ([$,...this.plugins])}withoutPlugins(){return new vJ([])}}var Gq=new vJ;class cD{numChangedRows;constructor($){this.numChangedRows=$}}class r5{#$;constructor($){this.#$=k($)}modifyEnd($){return new r5({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}top($,K){return new r5({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}using(...$){return new v$({...this.#$,queryNode:p$.cloneWithUsing(this.#$.queryNode,vq("Using",$))})}returning($){return new r5({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new r5({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new r5({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new r5({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}}class v${#$;constructor($){this.#$=k($)}modifyEnd($){return new v$({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}top($,K){return new v$({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}whenMatched(){return this.#K([])}whenMatchedAnd(...$){return this.#K($)}whenMatchedAndRef($,K,q){return this.#K([$,K,q],!0)}#K($,K){return new BD({...this.#$,queryNode:p$.cloneWithWhen(this.#$.queryNode,pD({isMatched:!0},$,K))})}whenNotMatched(){return this.#q([])}whenNotMatchedAnd(...$){return this.#q($)}whenNotMatchedAndRef($,K,q){return this.#q([$,K,q],!0)}whenNotMatchedBySource(){return this.#q([],!1,!0)}whenNotMatchedBySourceAnd(...$){return this.#q($,!1,!0)}whenNotMatchedBySourceAndRef($,K,q){return this.#q([$,K,q],!0,!0)}returning($){return new v$({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new v$({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new v$({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new v$({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}#q($,K=!1,q=!1){let Y={...this.#$,queryNode:p$.cloneWithWhen(this.#$.queryNode,pD({isMatched:!1,bySource:q},$,K))};return new(q?BD:Je)(Y)}$call($){return $(this)}$if($,K){if($)return K(this);return new v$({...this.#$})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new cD(K.numAffectedRows)]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}}class BD{#$;constructor($){this.#$=k($)}thenDelete(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("delete"))})}thenDoNothing(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("do nothing"))})}thenUpdate($){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ($(new X1({queryId:this.#$.queryId,executor:Gq,queryNode:F9.createWithoutTable()}))))})}thenUpdateSet(...$){return this.thenUpdate((K)=>K.set(...$))}}class Je{#$;constructor($){this.#$=k($)}thenDoNothing(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("do nothing"))})}thenInsertValues($){let[K,q]=P0($);return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ(i1.cloneWith(i1.createWithoutInto(),{columns:K,values:q})))})}}class d9{#$;constructor($){this.#$=k($)}selectFrom($){return GJ({queryId:$6(),executor:this.#$.executor,queryNode:m6.createFrom(d7($),this.#$.withNode)})}selectNoFrom($){return GJ({queryId:$6(),executor:this.#$.executor,queryNode:m6.cloneWithSelections(m6.create(this.#$.withNode),N4($))})}insertInto($){return new Y1({queryId:$6(),executor:this.#$.executor,queryNode:i1.create(g6($),this.#$.withNode)})}replaceInto($){return new Y1({queryId:$6(),executor:this.#$.executor,queryNode:i1.create(g6($),this.#$.withNode,!0)})}deleteFrom($){return new M1({queryId:$6(),executor:this.#$.executor,queryNode:jq.create(d7($),this.#$.withNode)})}updateTable($){return new X1({queryId:$6(),executor:this.#$.executor,queryNode:F9.create(d7($),this.#$.withNode)})}mergeInto($){return new r5({queryId:$6(),executor:this.#$.executor,queryNode:p$.create(UD($),this.#$.withNode)})}with($,K){let q=uD($,K);return new d9({...this.#$,withNode:this.#$.withNode?eO.cloneWithExpression(this.#$.withNode,q):eO.create(q)})}withRecursive($,K){let q=uD($,K);return new d9({...this.#$,withNode:this.#$.withNode?eO.cloneWithExpression(this.#$.withNode,q):eO.create(q,{recursive:!0})})}withPlugin($){return new d9({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new d9({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new d9({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}}function Ke(){return new d9({executor:Gq})}function We($,K){return new ZJ({joinNode:U7.create($,Kz(K))})}function He(){return new OJ({overNode:aO.create()})}function vq($,K){if(K.length===3)return k46($,K[0],K[1],K[2]);else if(K.length===2)return V46($,K[0],K[1]);else if(K.length===1)return M46($,K[0]);else throw new Error("not implemented")}function V46($,K,q){return q(We($,K)).toOperationNode()}function k46($,K,q,Y){return U7.createWithOn($,Kz(K),Q4(q,"=",Y))}function M46($,K){return U7.create($,Kz(K))}var Ze=k({is($){return $.kind==="OffsetNode"},create($){return k({kind:"OffsetNode",offset:$})}});var Oe=k({is($){return $.kind==="GroupByItemNode"},create($){return k({kind:"GroupByItemNode",groupBy:$})}});function we($){return $=A1($)?$(F7()):$,o5($).map(Oe.create)}var H0=k({is($){return $.kind==="SetOperationNode"},create($,K,q){return k({kind:"SetOperationNode",operator:$,expression:K,all:q})}});function qz($,K,q){if(A1(K))K=K(Z0());if(!j3(K))K=[K];return K.map((Y)=>H0.create($,j$(Y),q))}class U6{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}or(...$){return new O0(B7.create(this.#$,W1($)))}and(...$){return new w0(T$.create(this.#$,W1($)))}$castTo(){return new U6(this.#$)}$notNull(){return new U6(this.#$)}toOperationNode(){return this.#$}}class X0{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}class O0{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}or(...$){return new O0(B7.create(this.#$,W1($)))}$castTo(){return new O0(this.#$)}toOperationNode(){return m$.create(this.#$)}}class w0{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}and(...$){return new w0(T$.create(this.#$,W1($)))}$castTo(){return new w0(this.#$)}toOperationNode(){return m$.create(this.#$)}}var Xe={is($){return $.kind==="FetchNode"},create($,K){return{kind:"FetchNode",rowCount:_4.create($),modifier:K}}};function Te($,K){if(!Hq($)&&!YJ($))throw new Error(`Invalid fetch row count: ${$}`);if(!N46(K))throw new Error(`Invalid fetch modifier: ${K}`);return Xe.create($,K)}function N46($){return $==="only"||$==="with ties"}class r8{#$;constructor($){this.#$=k($)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...$){return new r8({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new r8({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}having(...$){return new r8({...this.#$,queryNode:m6.cloneWithHaving(this.#$.queryNode,W1($))})}havingRef($,K,q){return new r8({...this.#$,queryNode:m6.cloneWithHaving(this.#$.queryNode,Q4($,K,q))})}select($){return new r8({...this.#$,queryNode:m6.cloneWithSelections(this.#$.queryNode,N4($))})}distinctOn($){return new r8({...this.#$,queryNode:m6.cloneWithDistinctOn(this.#$.queryNode,o5($))})}modifyFront($){return new r8({...this.#$,queryNode:m6.cloneWithFrontModifier(this.#$.queryNode,U9.createWithExpression($.toOperationNode()))})}modifyEnd($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.createWithExpression($.toOperationNode()))})}distinct(){return new r8({...this.#$,queryNode:m6.cloneWithFrontModifier(this.#$.queryNode,U9.create("Distinct"))})}forUpdate($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForUpdate",$?QO($).map(g6):void 0))})}forShare($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForShare",$?QO($).map(g6):void 0))})}forKeyShare($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForKeyShare",$?QO($).map(g6):void 0))})}forNoKeyUpdate($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForNoKeyUpdate",$?QO($).map(g6):void 0))})}skipLocked(){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("SkipLocked"))})}noWait(){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("NoWait"))})}selectAll($){return new r8({...this.#$,queryNode:m6.cloneWithSelections(this.#$.queryNode,d4($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}crossJoin(...$){return this.#K("CrossJoin",$)}innerJoinLateral(...$){return this.#K("LateralInnerJoin",$)}leftJoinLateral(...$){return this.#K("LateralLeftJoin",$)}crossJoinLateral(...$){return this.#K("LateralCrossJoin",$)}crossApply(...$){return this.#K("CrossApply",$)}outerApply(...$){return this.#K("OuterApply",$)}#K($,K){return new r8({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}orderBy(...$){return new r8({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}groupBy($){return new r8({...this.#$,queryNode:m6.cloneWithGroupByItems(this.#$.queryNode,we($))})}limit($){return new r8({...this.#$,queryNode:m6.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}offset($){return new r8({...this.#$,queryNode:m6.cloneWithOffset(this.#$.queryNode,Ze.create(q1($)))})}fetch($,K="only"){return new r8({...this.#$,queryNode:m6.cloneWithFetch(this.#$.queryNode,Te($,K))})}top($,K){return new r8({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}union($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("union",$,!1))})}unionAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("union",$,!0))})}intersect($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("intersect",$,!1))})}intersectAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("intersect",$,!0))})}except($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("except",$,!1))})}exceptAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("except",$,!0))})}as($){return new je(this,$)}clearSelect(){return new r8({...this.#$,queryNode:m6.cloneWithoutSelections(this.#$.queryNode)})}clearWhere(){return new r8({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}clearLimit(){return new r8({...this.#$,queryNode:m6.cloneWithoutLimit(this.#$.queryNode)})}clearOffset(){return new r8({...this.#$,queryNode:m6.cloneWithoutOffset(this.#$.queryNode)})}clearOrderBy(){return new r8({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}clearGroupBy(){return new r8({...this.#$,queryNode:m6.cloneWithoutGroupBy(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new r8({...this.#$})}$castTo(){return new r8(this.#$)}$narrowType(){return new r8(this.#$)}$assertType(){return new r8(this.#$)}$asTuple(){return new U6(this.toOperationNode())}$asScalar(){return new U6(this.toOperationNode())}withPlugin($){return new r8({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile();return(await this.#$.executor.executeQuery($)).rows}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new r8({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}function GJ($){return new r8($)}class je{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return i4.create(this.#$.toOperationNode(),p8.create(this.#K))}}var n9=k({is($){return $.kind==="AggregateFunctionNode"},create($,K=[]){return k({kind:"AggregateFunctionNode",func:$,aggregated:K})},cloneWithDistinct($){return k({...$,distinct:!0})},cloneWithOrderBy($,K,q=!1){let Y=q?"withinGroup":"orderBy";return k({...$,[Y]:$[Y]?a5.cloneWithItems($[Y],K):a5.create(K)})},cloneWithFilter($,K){return k({...$,filter:$.filter?t4.cloneWithOperation($.filter,"And",K):t4.create(K)})},cloneWithOrFilter($,K){return k({...$,filter:$.filter?t4.cloneWithOperation($.filter,"Or",K):t4.create(K)})},cloneWithOver($,K){return k({...$,over:K})}});var lD=k({is($){return $.kind==="FunctionNode"},create($,K){return k({kind:"FunctionNode",func:$,arguments:K})}});class G${#$;constructor($){this.#$=k($)}get expressionType(){return}as($){return new ve(this,$)}distinct(){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithDistinct(this.#$.aggregateFunctionNode)})}orderBy(...$){return new G$({...this.#$,aggregateFunctionNode:C8.cloneWithOrderByItems(this.#$.aggregateFunctionNode,u$($))})}clearOrderBy(){return new G$({...this.#$,aggregateFunctionNode:C8.cloneWithoutOrderBy(this.#$.aggregateFunctionNode)})}withinGroupOrderBy(...$){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithOrderBy(this.#$.aggregateFunctionNode,u$($),!0)})}filterWhere(...$){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithFilter(this.#$.aggregateFunctionNode,W1($))})}filterWhereRef($,K,q){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithFilter(this.#$.aggregateFunctionNode,Q4($,K,q))})}over($){let K=He();return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithOver(this.#$.aggregateFunctionNode,($?$(K):K).toOperationNode())})}$call($){return $(this)}$castTo(){return new G$(this.#$)}$notNull(){return new G$(this.#$)}toOperationNode(){return this.#$.aggregateFunctionNode}}class ve{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),p8.create(this.#K))}}function T0(){let $=(q,Y)=>{return new U6(lD.create(q,o5(Y??[])))},K=(q,Y)=>{return new G$({aggregateFunctionNode:n9.create(q,Y?o5(Y):void 0)})};return Object.assign($,{agg:K,avg(q){return K("avg",[q])},coalesce(...q){return $("coalesce",q)},count(q){return K("count",[q])},countAll(q){return new G$({aggregateFunctionNode:n9.create("count",d4(q))})},max(q){return K("max",[q])},min(q){return K("min",[q])},sum(q){return K("sum",[q])},any(q){return $("any",[q])},jsonAgg(q){return new G$({aggregateFunctionNode:n9.create("json_agg",[f1(q)?g6(q):q.toOperationNode()])})},toJson(q){return new U6(lD.create("to_json",[f1(q)?g6(q):q.toOperationNode()]))}})}var Ge=k({is($){return $.kind==="UnaryOperationNode"},create($,K){return k({kind:"UnaryOperationNode",operator:$,operand:K})}});function _e($,K){return Ge.create(g$.create($),s4(K))}var B$=k({is($){return $.kind==="CaseNode"},create($){return k({kind:"CaseNode",value:$})},cloneWithWhen($,K){return k({...$,when:k($.when?[...$.when,K]:[K])})},cloneWithThen($,K){return k({...$,when:$.when?k([...$.when.slice(0,-1),Y7.cloneWithResult($.when[$.when.length-1],K)]):void 0})},cloneWith($,K){return k({...$,...K})}});class qw{#$;constructor($){this.#$=k($)}when(...$){return new FD({...this.#$,node:B$.cloneWithWhen(this.#$.node,Y7.create(W1($)))})}}class FD{#$;constructor($){this.#$=k($)}then($){return new fe({...this.#$,node:B$.cloneWithThen(this.#$.node,K0($)?oO($):q1($))})}}class fe{#$;constructor($){this.#$=k($)}when(...$){return new FD({...this.#$,node:B$.cloneWithWhen(this.#$.node,Y7.create(W1($)))})}else($){return new Ae({...this.#$,node:B$.cloneWith(this.#$.node,{else:K0($)?oO($):q1($)})})}end(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!1}))}endCase(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!0}))}}class Ae{#$;constructor($){this.#$=k($)}end(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!1}))}endCase(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!0}))}}var iD=k({is($){return $.kind==="JSONPathLegNode"},create($,K){return k({kind:"JSONPathLegNode",type:$,value:K})}});class zw{#$;constructor($){this.#$=$}at($){return this.#K("ArrayLocation",$)}key($){return this.#K("Member",$)}#K($,K){if(JJ.is(this.#$))return new Yw(JJ.cloneWithTraversal(this.#$,Xq.is(this.#$.traversal)?Xq.cloneWithLeg(this.#$.traversal,iD.create($,K)):eG.cloneWithValue(this.#$.traversal,_4.createImmediate(K))));return new Yw(Xq.cloneWithLeg(this.#$,iD.create($,K)))}}class Yw extends zw{#$;constructor($){super($);this.#$=$}get expressionType(){return}as($){return new Ve(this,$)}$castTo(){return new Yw(this.#$)}$notNull(){return new Yw(this.#$)}toOperationNode(){return this.#$}}class Ve{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}var QD=k({is($){return $.kind==="TupleNode"},create($){return k({kind:"TupleNode",values:k($)})}});var h46=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],C46=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ke=k({is($){return $.kind==="DataTypeNode"},create($){return k({kind:"DataTypeNode",dataType:$})}});function Me($){if(h46.includes($))return!0;if(C46.some((K)=>K.test($)))return!0;return!1}function n7($){if(w1($))return $.toOperationNode();if(Me($))return ke.create($);throw new Error(`invalid column data type ${JSON.stringify($)}`)}var Ne=k({is($){return $.kind==="CastNode"},create($,K){return k({kind:"CastNode",expression:$,dataType:K})}});function Z0($=Gq){function K(z,P,J){return new U6(q0(z,P,J))}function q(z,P){return new U6(_e(z,P))}let Y=Object.assign(K,{fn:void 0,eb:void 0,selectFrom(z){return GJ({queryId:$6(),executor:$,queryNode:m6.createFrom(d7(z))})},case(z){return new qw({node:B$.create(x$(z)?void 0:s4(z))})},ref(z,P){if(x$(P))return new U6(y$(z));return new zw(pt(z,P))},jsonPath(){return new zw(Xq.create())},table(z){return new U6(g6(z))},val(z){return new U6(q1(z))},refTuple(...z){return new U6(QD.create(z.map(s4)))},tuple(...z){return new U6(QD.create(z.map(q1)))},lit(z){return new U6(oO(z))},unary:q,not(z){return q("not",z)},exists(z){return q("exists",z)},neg(z){return q("-",z)},between(z,P,J){return new U6(Oq.create(s4(z),g$.create("between"),T$.create(q1(P),q1(J))))},betweenSymmetric(z,P,J){return new U6(Oq.create(s4(z),g$.create("between symmetric"),T$.create(q1(P),q1(J))))},and(z){if(j3(z))return new U6(HJ(z,"and"));return new U6(hD(z,"and"))},or(z){if(j3(z))return new U6(HJ(z,"or"));return new U6(hD(z,"or"))},parens(...z){let P=W1(z);if(m$.is(P))return new U6(P);else return new U6(m$.create(P))},cast(z,P){return new U6(Ne.create(s4(z),n7(P)))},withSchema(z){return Z0($.withPluginAtFront(new c$(z)))}});return Y.fn=T0(),Y.eb=Y,Y}function F7($){return Z0()}function j$($){if(w1($))return $.toOperationNode();else if(A1($))return $(F7()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify($)}`)}function z0($){if(w1($))return $.toOperationNode();else if(A1($))return $(F7()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify($)}`)}function n5($){return rG($)||xt($)||A1($)}class dD{#$;get table(){return this.#$}constructor($){this.#$=$}as($){return new he(this.#$,$)}}class he{#$;#K;get table(){return this.#$}get alias(){return this.#K}constructor($,K){this.#$=$,this.#K=K}toOperationNode(){return i4.create(g6(this.#$),p8.create(this.#K))}}function Ce($){return M4($)&&w1($)&&f1($.table)&&f1($.alias)}function d7($){if(j3($))return $.map((K)=>Kz(K));else return[Kz($)]}function Kz($){if(f1($))return UD($);else if(Ce($))return $.toOperationNode();else return z0($)}function UD($){if($.includes(" as ")){let[q,Y]=$.split(" as ").map(Re);return i4.create(g6(q),p8.create(Y))}else return g6($)}function g6($){if($.includes(".")){let[q,Y]=$.split(".").map(Re);return b$.createWithSchema(q,Y)}else return b$.create($)}function Re($){return $.trim()}var nD=k({is($){return $.kind==="AddColumnNode"},create($){return k({kind:"AddColumnNode",column:$})}});var T1=k({is($){return $.kind==="ColumnDefinitionNode"},create($,K){return k({kind:"ColumnDefinitionNode",column:R6.create($),dataType:K})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):[K]})},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):[K]})},cloneWith($,K){return k({...$,...K})}});var oD=k({is($){return $.kind==="DropColumnNode"},create($){return k({kind:"DropColumnNode",column:R6.create($)})}});var aD=k({is($){return $.kind==="RenameColumnNode"},create($,K){return k({kind:"RenameColumnNode",column:R6.create($),renameTo:R6.create(K)})}});var _J=k({is($){return $.kind==="CheckConstraintNode"},create($,K){return k({kind:"CheckConstraintNode",expression:$,name:K?p8.create(K):void 0})}});var De=["no action","restrict","cascade","set null","set default"],fJ=k({is($){return $.kind==="ReferencesNode"},create($,K){return k({kind:"ReferencesNode",table:$,columns:k([...K])})},cloneWithOnDelete($,K){return k({...$,onDelete:K})},cloneWithOnUpdate($,K){return k({...$,onUpdate:K})}});function j0($){return w1($)?$.toOperationNode():_4.createImmediate($)}var Pw=k({is($){return $.kind==="GeneratedNode"},create($){return k({kind:"GeneratedNode",...$})},createWithExpression($){return k({kind:"GeneratedNode",always:!0,expression:$})},cloneWith($,K){return k({...$,...K})}});var Se=k({is($){return $.kind==="DefaultValueNode"},create($){return k({kind:"DefaultValueNode",defaultValue:$})}});function AJ($){if(De.includes($))return $;throw new Error(`invalid OnModifyForeignAction ${$}`)}class j1{#$;constructor($){this.#$=$}autoIncrement(){return new j1(T1.cloneWith(this.#$,{autoIncrement:!0}))}identity(){return new j1(T1.cloneWith(this.#$,{identity:!0}))}primaryKey(){return new j1(T1.cloneWith(this.#$,{primaryKey:!0}))}references($){let K=y$($);if(!K.table||zJ.is(K.column))throw new Error(`invalid call references('${$}'). The reference must have format table.column or schema.table.column`);return new j1(T1.cloneWith(this.#$,{references:fJ.create(K.table,[K.column])}))}onDelete($){if(!this.#$.references)throw new Error("on delete constraint can only be added for foreign keys");return new j1(T1.cloneWith(this.#$,{references:fJ.cloneWithOnDelete(this.#$.references,AJ($))}))}onUpdate($){if(!this.#$.references)throw new Error("on update constraint can only be added for foreign keys");return new j1(T1.cloneWith(this.#$,{references:fJ.cloneWithOnUpdate(this.#$.references,AJ($))}))}unique(){return new j1(T1.cloneWith(this.#$,{unique:!0}))}notNull(){return new j1(T1.cloneWith(this.#$,{notNull:!0}))}unsigned(){return new j1(T1.cloneWith(this.#$,{unsigned:!0}))}defaultTo($){return new j1(T1.cloneWith(this.#$,{defaultTo:Se.create(j0($))}))}check($){return new j1(T1.cloneWith(this.#$,{check:_J.create($.toOperationNode())}))}generatedAlwaysAs($){return new j1(T1.cloneWith(this.#$,{generated:Pw.createWithExpression($.toOperationNode())}))}generatedAlwaysAsIdentity(){return new j1(T1.cloneWith(this.#$,{generated:Pw.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new j1(T1.cloneWith(this.#$,{generated:Pw.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#$.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new j1(T1.cloneWith(this.#$,{generated:Pw.cloneWith(this.#$.generated,{stored:!0})}))}modifyFront($){return new j1(T1.cloneWithFrontModifier(this.#$,$.toOperationNode()))}nullsNotDistinct(){return new j1(T1.cloneWith(this.#$,{nullsNotDistinct:!0}))}ifNotExists(){return new j1(T1.cloneWith(this.#$,{ifNotExists:!0}))}modifyEnd($){return new j1(T1.cloneWithEndModifier(this.#$,$.toOperationNode()))}$call($){return $(this)}toOperationNode(){return this.#$}}var rD=k({is($){return $.kind==="ModifyColumnNode"},create($){return k({kind:"ModifyColumnNode",column:$})}});var o7=k({is($){return $.kind==="ForeignKeyConstraintNode"},create($,K,q,Y){return k({kind:"ForeignKeyConstraintNode",columns:$,references:fJ.create(K,q),name:Y?p8.create(Y):void 0})},cloneWith($,K){return k({...$,...K})}});class a7{#$;constructor($){this.#$=$}onDelete($){return new a7(o7.cloneWith(this.#$,{onDelete:AJ($)}))}onUpdate($){return new a7(o7.cloneWith(this.#$,{onUpdate:AJ($)}))}deferrable(){return new a7(o7.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new a7(o7.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new a7(o7.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new a7(o7.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}var VJ=k({is($){return $.kind==="AddConstraintNode"},create($){return k({kind:"AddConstraintNode",constraint:$})}});var o9=k({is($){return $.kind==="UniqueConstraintNode"},create($,K,q){return k({kind:"UniqueConstraintNode",columns:k($.map(R6.create)),name:K?p8.create(K):void 0,nullsNotDistinct:q})},cloneWith($,K){return k({...$,...K})}});var kJ=k({is($){return $.kind==="DropConstraintNode"},create($){return k({kind:"DropConstraintNode",constraintName:p8.create($)})},cloneWith($,K){return k({...$,...K})}});var MJ=k({is($){return $.kind==="AlterColumnNode"},create($,K,q){return k({kind:"AlterColumnNode",column:R6.create($),[K]:q})}});class v0{#$;constructor($){this.#$=$}setDataType($){return new NJ(MJ.create(this.#$,"dataType",n7($)))}setDefault($){return new NJ(MJ.create(this.#$,"setDefault",j0($)))}dropDefault(){return new NJ(MJ.create(this.#$,"dropDefault",!0))}setNotNull(){return new NJ(MJ.create(this.#$,"setNotNull",!0))}dropNotNull(){return new NJ(MJ.create(this.#$,"dropNotNull",!0))}$call($){return $(this)}}class NJ{#$;constructor($){this.#$=$}toOperationNode(){return this.#$}}class _q{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class s5{#$;constructor($){this.#$=k($)}onDelete($){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.onDelete($)})}onUpdate($){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.onUpdate($)})}deferrable(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.deferrable()})}notDeferrable(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.initiallyImmediate()})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(this.#$.constraintBuilder.toOperationNode())}),this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Yz{#$;constructor($){this.#$=k($)}ifExists(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{ifExists:!0})})})}cascade(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{modifier:"restrict"})})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var t5=k({is($){return $.kind==="PrimaryKeyConstraintNode"},create($,K){return k({kind:"PrimaryKeyConstraintNode",columns:k($.map(R6.create)),name:K?p8.create(K):void 0})},cloneWith($,K){return k({...$,...K})}});var fq=k({is($){return $.kind==="AddIndexNode"},create($){return k({kind:"AddIndexNode",name:p8.create($)})},cloneWith($,K){return k({...$,...K})},cloneWithColumns($,K){return k({...$,columns:[...$.columns||[],...K]})}});class Aq{#$;constructor($){this.#$=k($)}unique(){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWith(this.#$.node.addIndex,{unique:!0})})})}column($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,[WJ($)])})})}columns($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,$.map(WJ))})})}expression($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,[$.toOperationNode()])})})}using($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWith(this.#$.node.addIndex,{using:b6.createWithSql($)})})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class a9{#$;constructor($){this.#$=$}nullsNotDistinct(){return new a9(o9.cloneWith(this.#$,{nullsNotDistinct:!0}))}deferrable(){return new a9(o9.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new a9(o9.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new a9(o9.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new a9(o9.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}class e5{#$;constructor($){this.#$=$}deferrable(){return new e5(t5.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new e5(t5.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new e5(t5.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new e5(t5.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}class Jw{#$;constructor($){this.#$=$}$call($){return $(this)}toOperationNode(){return this.#$}}var Ee=k({is($){return $.kind==="RenameConstraintNode"},create($,K){return k({kind:"RenameConstraintNode",oldName:p8.create($),newName:p8.create(K)})}});class sD{#$;constructor($){this.#$=k($)}renameTo($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{renameTo:g6($)})})}setSchema($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{setSchema:p8.create($)})})}alterColumn($,K){let q=K(new v0($));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,q.toOperationNode())})}dropColumn($){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,oD.create($))})}renameColumn($,K){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,aD.create($,K))})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,nD.create(Y.toOperationNode()))})}modifyColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,rD.create(Y.toOperationNode()))})}addUniqueConstraint($,K,q=l3){let Y=q(new a9(o9.create(K,$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}addCheckConstraint($,K,q=l3){let Y=q(new Jw(_J.create(K.toOperationNode(),$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}addForeignKeyConstraint($,K,q,Y,z=l3){let P=z(new a7(o7.create(K.map(R6.create),g6(q),Y.map(R6.create),$)));return new s5({...this.#$,constraintBuilder:P})}addPrimaryKeyConstraint($,K,q=l3){let Y=q(new e5(t5.create(K,$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}dropConstraint($){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.create($)})})}renameConstraint($,K){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{renameConstraint:Ee.create($,K)})})}addIndex($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.create($)})})}dropIndex($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropIndex:Zq.create($)})})}$call($){return $(this)}}class r7{#$;constructor($){this.#$=k($)}alterColumn($,K){let q=K(new v0($));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,q.toOperationNode())})}dropColumn($){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,oD.create($))})}renameColumn($,K){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,aD.create($,K))})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,nD.create(Y.toOperationNode()))})}modifyColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,rD.create(Y.toOperationNode()))})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Ww extends $w{transformPrimitiveValueList($){return Tq.create($.values.map(_4.createImmediate))}transformValue($){return _4.createImmediate($.value)}}class z7{#$;constructor($){this.#$=k($)}ifNotExists(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{ifNotExists:!0})})}unique(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{unique:!0})})}nullsNotDistinct(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{nullsNotDistinct:!0})})}on($){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{table:g6($)})})}column($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,[WJ($)])})}columns($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,$.map(WJ))})}expression($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,[$.toOperationNode()])})}using($){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{using:b6.createWithSql($)})})}where(...$){let K=new Ww;return new z7({...this.#$,node:C8.cloneWithWhere(this.#$.node,K.transformNode(W1($),this.#$.queryId))})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class G0{#$;constructor($){this.#$=k($)}ifNotExists(){return new G0({...this.#$,node:aG.cloneWith(this.#$.node,{ifNotExists:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}function Le($){if(It.includes($))return $;throw new Error(`invalid OnCommitAction ${$}`)}class _${#$;constructor($){this.#$=k($)}temporary(){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{temporary:!0})})}onCommit($){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{onCommit:Le($)})})}ifNotExists(){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{ifNotExists:!0})})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new _$({...this.#$,node:v3.cloneWithColumn(this.#$.node,Y.toOperationNode())})}addPrimaryKeyConstraint($,K,q=l3){let Y=q(new e5(t5.create(K,$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addUniqueConstraint($,K,q=l3){let Y=q(new a9(o9.create(K,$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addCheckConstraint($,K,q=l3){let Y=q(new Jw(_J.create(K.toOperationNode(),$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addForeignKeyConstraint($,K,q,Y,z=l3){let P=z(new a7(o7.create(K.map(R6.create),g6(q),Y.map(R6.create),$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,P.toOperationNode())})}modifyFront($){return new _$({...this.#$,node:v3.cloneWithFrontModifier(this.#$.node,$.toOperationNode())})}modifyEnd($){return new _$({...this.#$,node:v3.cloneWithEndModifier(this.#$.node,$.toOperationNode())})}as($){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{selectQuery:j$($)})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class hJ{#$;constructor($){this.#$=k($)}on($){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{table:g6($)})})}ifExists(){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Hw{#$;constructor($){this.#$=k($)}ifExists(){return new Hw({...this.#$,node:dO.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new Hw({...this.#$,node:dO.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Zw{#$;constructor($){this.#$=k($)}ifExists(){return new Zw({...this.#$,node:nO.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new Zw({...this.#$,node:nO.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var s7=k({is($){return $.kind==="CreateViewNode"},create($){return k({kind:"CreateViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class tD{#$=new Ww;transformQuery($){return this.#$.transformNode($.node,$.queryId)}transformResult($){return Promise.resolve($.result)}}class $K{#$;constructor($){this.#$=k($)}temporary(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{temporary:!0})})}materialized(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{materialized:!0})})}ifNotExists(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{ifNotExists:!0})})}orReplace(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{orReplace:!0})})}columns($){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{columns:$.map(kD)})})}as($){let K=$.withPlugin(new tD).toOperationNode();return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{as:K})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var CJ=k({is($){return $.kind==="DropViewNode"},create($){return k({kind:"DropViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class RJ{#$;constructor($){this.#$=k($)}materialized(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{materialized:!0})})}ifExists(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var _0=k({is($){return $.kind==="CreateTypeNode"},create($){return k({kind:"CreateTypeNode",name:$})},cloneWithEnum($,K){return k({...$,enum:Tq.create(K.map(_4.createImmediate))})}});class f0{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}asEnum($){return new f0({...this.#$,node:_0.cloneWithEnum(this.#$.node,$)})}$call($){return $(this)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var A0=k({is($){return $.kind==="DropTypeNode"},create($){return k({kind:"DropTypeNode",name:$})},cloneWith($,K){return k({...$,...K})}});class V0{#$;constructor($){this.#$=k($)}ifExists(){return new V0({...this.#$,node:A0.cloneWith(this.#$.node,{ifExists:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}function eD($){if($.includes(".")){let q=$.split(".").map(R46);if(q.length===2)return G3.createWithSchema(q[0],q[1]);else throw new Error(`invalid schemable identifier ${$}`)}else return G3.create($)}function R46($){return $.trim()}var DJ=k({is($){return $.kind==="RefreshMaterializedViewNode"},create($){return k({kind:"RefreshMaterializedViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class SJ{#$;constructor($){this.#$=k($)}concurrently(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{concurrently:!0,withNoData:!1})})}withData(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{withNoData:!1})})}withNoData(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{withNoData:!0,concurrently:!1})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class EJ{#$;constructor($){this.#$=$}createTable($){return new _$({queryId:$6(),executor:this.#$,node:v3.create(g6($))})}dropTable($){return new Zw({queryId:$6(),executor:this.#$,node:nO.create(g6($))})}createIndex($){return new z7({queryId:$6(),executor:this.#$,node:c7.create($)})}dropIndex($){return new hJ({queryId:$6(),executor:this.#$,node:Zq.create($)})}createSchema($){return new G0({queryId:$6(),executor:this.#$,node:aG.create($)})}dropSchema($){return new Hw({queryId:$6(),executor:this.#$,node:dO.create($)})}alterTable($){return new sD({queryId:$6(),executor:this.#$,node:x6.create(g6($))})}createView($){return new $K({queryId:$6(),executor:this.#$,node:s7.create($)})}refreshMaterializedView($){return new SJ({queryId:$6(),executor:this.#$,node:DJ.create($)})}dropView($){return new RJ({queryId:$6(),executor:this.#$,node:CJ.create($)})}createType($){return new f0({queryId:$6(),executor:this.#$,node:_0.create(eD($))})}dropType($){return new V0({queryId:$6(),executor:this.#$,node:A0.create(eD($))})}withPlugin($){return new EJ(this.#$.withPlugin($))}withoutPlugins(){return new EJ(this.#$.withoutPlugins())}withSchema($){return new EJ(this.#$.withPluginAtFront(new c$($)))}}class $S{ref($){return new _D($)}table($){return new dD($)}}class KS{#$;constructor($){this.#$=$}async provideConnection($){let K=await this.#$.acquireConnection();try{return await $(K)}finally{await this.#$.releaseConnection(K)}}}class Vq extends Kw{#$;#K;#q;constructor($,K,q,Y=[]){super(Y);this.#$=$,this.#K=K,this.#q=q}get adapter(){return this.#K}compileQuery($,K){return this.#$.compileQuery($,K)}provideConnection($){return this.#q.provideConnection($)}withPlugins($){return new Vq(this.#$,this.#K,this.#q,[...this.plugins,...$])}withPlugin($){return new Vq(this.#$,this.#K,this.#q,[...this.plugins,$])}withPluginAtFront($){return new Vq(this.#$,this.#K,this.#q,[$,...this.plugins])}withConnectionProvider($){return new Vq(this.#$,this.#K,$,[...this.plugins])}withoutPlugins(){return new Vq(this.#$,this.#K,this.#q,[])}}function k0(){if(typeof performance!=="undefined"&&A1(performance.now))return performance.now();else return Date.now()}class qS{#$;#K;#q;#Y;#z;#w=new WeakSet;constructor($,K){this.#Y=!1,this.#$=$,this.#K=K}async init(){if(this.#z)throw new Error("driver has already been destroyed");if(!this.#q)this.#q=this.#$.init().then(()=>{this.#Y=!0}).catch(($)=>{return this.#q=void 0,Promise.reject($)});await this.#q}async acquireConnection(){if(this.#z)throw new Error("driver has already been destroyed");if(!this.#Y)await this.init();let $=await this.#$.acquireConnection();if(!this.#w.has($)){if(this.#P())this.#H($);this.#w.add($)}return $}async releaseConnection($){await this.#$.releaseConnection($)}beginTransaction($,K){return this.#$.beginTransaction($,K)}commitTransaction($){return this.#$.commitTransaction($)}rollbackTransaction($){return this.#$.rollbackTransaction($)}savepoint($,K,q){if(this.#$.savepoint)return this.#$.savepoint($,K,q);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint($,K,q){if(this.#$.rollbackToSavepoint)return this.#$.rollbackToSavepoint($,K,q);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint($,K,q){if(this.#$.releaseSavepoint)return this.#$.releaseSavepoint($,K,q);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){if(!this.#q)return;if(await this.#q,!this.#z)this.#z=this.#$.destroy().catch(($)=>{return this.#z=void 0,Promise.reject($)});await this.#z}#P(){return this.#K.isLevelEnabled("query")||this.#K.isLevelEnabled("error")}#H($){let{executeQuery:K,streamQuery:q}=$,Y=this;$.executeQuery=async(z)=>{let P,J=k0();try{return await K.call($,z)}catch(W){throw P=W,await Y.#W(W,z,J),W}finally{if(!P)await Y.#O(z,J)}},$.streamQuery=async function*(z,P){let J,W=k0();try{for await(let H of q.call($,z,P))yield H}catch(H){throw J=H,await Y.#W(H,z,W),H}finally{if(!J)await Y.#O(z,W,!0)}}}async#W($,K,q){await this.#K.error(()=>({level:"error",error:$,query:K,queryDurationMillis:this.#J(q)}))}async#O($,K,q=!1){await this.#K.query(()=>({level:"query",isStream:q,query:$,queryDurationMillis:this.#J(K)}))}#J($){return k0()-$}}var D46=()=>{};class Ow{#$;#K;constructor($){this.#$=$}async provideConnection($){while(this.#K)await this.#K.catch(D46);return this.#K=this.#q($).finally(()=>{this.#K=void 0}),this.#K}async#q($){return await $(this.#$)}}var S46=["read only","read write"],E46=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function YS($){if($.accessMode&&!S46.includes($.accessMode))throw new Error(`invalid transaction access mode ${$.accessMode}`);if($.isolationLevel&&!E46.includes($.isolationLevel))throw new Error(`invalid transaction isolation level ${$.isolationLevel}`)}var sR1=k(["query","error"]);class zS{#$;#K;constructor($){if(A1($))this.#K=$,this.#$=k({query:!0,error:!0});else this.#K=L46,this.#$=k({query:$.includes("query"),error:$.includes("error")})}isLevelEnabled($){return this.#$[$]}async query($){if(this.#$.query)await this.#K($())}async error($){if(this.#$.error)await this.#K($())}}function L46($){if($.level==="query"){let K=`kysely:query:${$.isStream?"stream:":""}`;console.log(`${K} ${$.query.sql}`),console.log(`${K} duration: ${$.queryDurationMillis.toFixed(1)}ms`)}else if($.level==="error")if($.error instanceof Error)console.error(`kysely:error: ${$.error.stack??$.error.message}`);else console.error(`kysely:error: ${JSON.stringify({error:$.error,query:$.query.sql,queryDurationMillis:$.queryDurationMillis})}`)}function Ie($){return M4($)&&A1($.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class r9 extends d9{#$;constructor($){let K,q;if(I46($))K={executor:$.executor},q={...$};else{let Y=$.dialect,z=Y.createDriver(),P=Y.createQueryCompiler(),J=Y.createAdapter(),W=new zS($.log??[]),H=new qS(z,W),Z=new KS(H),O=new Vq(P,J,Z,$.plugins??[]);K={executor:O},q={config:$,executor:O,dialect:Y,driver:H}}super(K);this.#$=k(q)}get schema(){return new EJ(this.#$.executor)}get dynamic(){return new $S}get introspection(){return this.#$.dialect.createIntrospector(this.withoutPlugins())}case($){return new qw({node:B$.create(x$($)?void 0:j$($))})}get fn(){return T0()}transaction(){return new M0({...this.#$})}startTransaction(){return new N0({...this.#$})}connection(){return new xe({...this.#$})}withPlugin($){return new r9({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new r9({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new r9({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new r9({...this.#$})}async destroy(){await this.#$.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#$.executor}executeQuery($,K){if(K!==void 0)l9("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let q=Ie($)?$.compile():$;return this.getExecutor().executeQuery(q)}async[Symbol.asyncDispose](){await this.destroy()}}class Pz extends r9{#$;constructor($){super($);this.#$=$}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin($){return new Pz({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new Pz({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new Pz({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new Pz({...this.#$})}}function I46($){return M4($)&&M4($.config)&&M4($.driver)&&M4($.executor)&&M4($.dialect)}class xe{#$;constructor($){this.#$=k($)}async execute($){return this.#$.executor.provideConnection(async(K)=>{let q=this.#$.executor.withConnectionProvider(new Ow(K)),Y=new r9({...this.#$,executor:q});return await $(Y)})}}class M0{#$;constructor($){this.#$=k($)}setAccessMode($){return new M0({...this.#$,accessMode:$})}setIsolationLevel($){return new M0({...this.#$,isolationLevel:$})}async execute($){let{isolationLevel:K,accessMode:q,...Y}=this.#$,z={isolationLevel:K,accessMode:q};return YS(z),this.#$.executor.provideConnection(async(P)=>{let J=this.#$.executor.withConnectionProvider(new Ow(P)),W=new Pz({...Y,executor:J}),H=!1;try{await this.#$.driver.beginTransaction(P,z),H=!0;let Z=await $(W);return await this.#$.driver.commitTransaction(P),Z}catch(Z){if(H)await this.#$.driver.rollbackTransaction(P);throw Z}})}}class N0{#$;constructor($){this.#$=k($)}setAccessMode($){return new N0({...this.#$,accessMode:$})}setIsolationLevel($){return new N0({...this.#$,isolationLevel:$})}async execute(){let{isolationLevel:$,accessMode:K,...q}=this.#$,Y={isolationLevel:$,accessMode:K};YS(Y);let z=await W0(this.#$.executor);return await this.#$.driver.beginTransaction(z.connection,Y),new KK({...q,connection:z,executor:this.#$.executor.withConnectionProvider(new Ow(z.connection))})}}class KK extends Pz{#$;#K;#q;constructor($){let K={isCommitted:!1,isRolledBack:!1};$={...$,executor:new kq($.executor,K)};let{connection:q,...Y}=$;super(Y);this.#$=k($),this.#q=K;let z=$6();this.#K=(P)=>$.executor.compileQuery(P,z)}get isCommitted(){return this.#q.isCommitted}get isRolledBack(){return this.#q.isRolledBack}commit(){return zz(this.#q),new LJ(async()=>{await this.#$.driver.commitTransaction(this.#$.connection.connection),this.#q.isCommitted=!0,this.#$.connection.release()})}rollback(){return zz(this.#q),new LJ(async()=>{await this.#$.driver.rollbackTransaction(this.#$.connection.connection),this.#q.isRolledBack=!0,this.#$.connection.release()})}savepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.savepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}rollbackToSavepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.rollbackToSavepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}releaseSavepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.releaseSavepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}withPlugin($){return new KK({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new KK({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new KK({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new KK({...this.#$})}}class LJ{#$;constructor($){this.#$=$}async execute(){return await this.#$()}}function zz($){if($.isCommitted)throw new Error("Transaction is already committed");if($.isRolledBack)throw new Error("Transaction is already rolled back")}class kq{#$;#K;constructor($,K){if($ instanceof kq)this.#$=$.#$;else this.#$=$;this.#K=K}get adapter(){return this.#$.adapter}get plugins(){return this.#$.plugins}transformQuery($,K){return this.#$.transformQuery($,K)}compileQuery($,K){return this.#$.compileQuery($,K)}provideConnection($){return this.#$.provideConnection($)}executeQuery($){return zz(this.#K),this.#$.executeQuery($)}stream($,K){return zz(this.#K),this.#$.stream($,K)}withConnectionProvider($){return new kq(this.#$.withConnectionProvider($),this.#K)}withPlugin($){return new kq(this.#$.withPlugin($),this.#K)}withPlugins($){return new kq(this.#$.withPlugins($),this.#K)}withPluginAtFront($){return new kq(this.#$.withPluginAtFront($),this.#K)}withoutPlugins(){return new kq(this.#$.withoutPlugins(),this.#K)}}class ww{#$;constructor($){this.#$=k($)}get expressionType(){return}get isRawBuilder(){return!0}as($){return new be(this,$)}$castTo(){return new ww({...this.#$})}$notNull(){return new ww(this.#$)}withPlugin($){return new ww({...this.#$,plugins:this.#$.plugins!==void 0?k([...this.#$.plugins,$]):k([$])})}toOperationNode(){return this.#q(this.#K())}compile($){return this.#Y(this.#K($))}async execute($){let K=this.#K($);return K.executeQuery(this.#Y(K))}#K($){let K=$!==void 0?$.getExecutor():Gq;return this.#$.plugins!==void 0?K.withPlugins(this.#$.plugins):K}#q($){return $.transformQuery(this.#$.rawNode,this.#$.queryId)}#Y($){return $.compileQuery(this.#q($),this.#$.queryId)}}function qK($){return new ww($)}class be{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}get rawBuilder(){return this.#$}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}var U$=Object.assign(($,...K)=>{return qK({queryId:$6(),rawNode:b6.create($,K?.map(ge)??[])})},{ref($){return qK({queryId:$6(),rawNode:b6.createWithChild(y$($))})},val($){return qK({queryId:$6(),rawNode:b6.createWithChild(q1($))})},value($){return this.val($)},table($){return qK({queryId:$6(),rawNode:b6.createWithChild(g6($))})},id(...$){let K=new Array($.length+1).fill(".");return K[0]="",K[K.length-1]="",qK({queryId:$6(),rawNode:b6.create(K,$.map(p8.create))})},lit($){return qK({queryId:$6(),rawNode:b6.createWithChild(_4.createImmediate($))})},literal($){return this.lit($)},raw($){return qK({queryId:$6(),rawNode:b6.createWithSql($)})},join($,K=U$`, `){let q=new Array(Math.max(2*$.length-1,0)),Y=K.toOperationNode();for(let z=0;z<$.length;++z)if(q[2*z]=ge($[z]),z!==$.length-1)q[2*z+1]=Y;return qK({queryId:$6(),rawNode:b6.createWithChildren(q)})}});function ge($){if(w1($))return $.toOperationNode();return q1($)}class PS{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#$=k({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=($)=>{this.nodeStack.push($),this.#$[$.kind]($),this.nodeStack.pop()}}var x46=/'/g;class JS extends PS{#$="";#K=[];get numParameters(){return this.#K.length}compileQuery($,K){return this.#$="",this.#K=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode($),k({query:$,queryId:K,sql:this.getSql(),parameters:[...this.#K]})}getSql(){return this.#$}visitSelectQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!i1.is(this.parentNode)&&!v3.is(this.parentNode)&&!s7.is(this.parentNode)&&!H0.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("select"),$.distinctOn)this.append(" "),this.compileDistinctOn($.distinctOn);if($.frontModifiers?.length)this.append(" "),this.compileList($.frontModifiers," ");if($.top)this.append(" "),this.visitNode($.top);if($.selections)this.append(" "),this.compileList($.selections);if($.from)this.append(" "),this.visitNode($.from);if($.joins)this.append(" "),this.compileList($.joins," ");if($.where)this.append(" "),this.visitNode($.where);if($.groupBy)this.append(" "),this.visitNode($.groupBy);if($.having)this.append(" "),this.visitNode($.having);if($.setOperations)this.append(" "),this.compileList($.setOperations," ");if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.offset)this.append(" "),this.visitNode($.offset);if($.fetch)this.append(" "),this.visitNode($.fetch);if($.endModifiers?.length)this.append(" "),this.compileList(this.sortSelectModifiers([...$.endModifiers])," ");if(K)this.append(")")}visitFrom($){this.append("from "),this.compileList($.froms)}visitSelection($){this.visitNode($.selection)}visitColumn($){this.visitNode($.column)}compileDistinctOn($){this.append("distinct on ("),this.compileList($),this.append(")")}compileList($,K=", "){let q=$.length-1;for(let Y=0;Y<=q;Y++)if(this.visitNode($[Y]),Y<q)this.append(K)}visitWhere($){this.append("where "),this.visitNode($.where)}visitHaving($){this.append("having "),this.visitNode($.having)}visitInsertQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode)&&!Y7.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append($.replace?"replace":"insert"),$.ignore)l9("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore");if($.orAction)this.append(" "),this.visitNode($.orAction);if($.top)this.append(" "),this.visitNode($.top);if($.into)this.append(" into "),this.visitNode($.into);if($.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.output)this.append(" "),this.visitNode($.output);if($.values)this.append(" "),this.visitNode($.values);if($.defaultValues)this.append(" "),this.append("default values");if($.onConflict)this.append(" "),this.visitNode($.onConflict);if($.onDuplicateKey)this.append(" "),this.visitNode($.onDuplicateKey);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitValues($){this.append("values "),this.compileList($.values)}visitDeleteQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("delete "),$.top)this.visitNode($.top),this.append(" ");if(this.visitNode($.from),$.output)this.append(" "),this.visitNode($.output);if($.using)this.append(" "),this.visitNode($.using);if($.joins)this.append(" "),this.compileList($.joins," ");if($.where)this.append(" "),this.visitNode($.where);if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitReturning($){this.append("returning "),this.compileList($.selections)}visitAlias($){this.visitNode($.node),this.append(" as "),this.visitNode($.alias)}visitReference($){if($.table)this.visitNode($.table),this.append(".");this.visitNode($.column)}visitSelectAll($){this.append("*")}visitIdentifier($){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier($),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier($){if(!f1($.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier($.name))}visitAnd($){this.visitNode($.left),this.append(" and "),this.visitNode($.right)}visitOr($){this.visitNode($.left),this.append(" or "),this.visitNode($.right)}visitValue($){if($.immediate)this.appendImmediateValue($.value);else this.appendValue($.value)}visitValueList($){this.append("("),this.compileList($.values),this.append(")")}visitTuple($){this.append("("),this.compileList($.values),this.append(")")}visitPrimitiveValueList($){this.append("(");let{values:K}=$;for(let q=0;q<K.length;++q)if(this.appendValue(K[q]),q!==K.length-1)this.append(", ");this.append(")")}visitParens($){this.append("("),this.visitNode($.node),this.append(")")}visitJoin($){if(this.append(g46[$.joinType]),this.append(" "),this.visitNode($.table),$.on)this.append(" "),this.visitNode($.on)}visitOn($){this.append("on "),this.visitNode($.on)}visitRaw($){let{sqlFragments:K,parameters:q}=$;for(let Y=0;Y<K.length;++Y)if(this.append(K[Y]),q.length>Y)this.visitNode(q[Y])}visitOperator($){this.append($.operator)}visitTable($){this.visitNode($.table)}visitSchemableIdentifier($){if($.schema)this.visitNode($.schema),this.append(".");this.visitNode($.identifier)}visitCreateTable($){if(this.append("create "),$.frontModifiers&&$.frontModifiers.length>0)this.compileList($.frontModifiers," "),this.append(" ");if($.temporary)this.append("temporary ");if(this.append("table "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.table),$.selectQuery)this.append(" as "),this.visitNode($.selectQuery);else{if(this.append(" ("),this.compileList([...$.columns,...$.constraints??[]]),this.append(")"),$.onCommit)this.append(" on commit "),this.append($.onCommit);if($.endModifiers&&$.endModifiers.length>0)this.append(" "),this.compileList($.endModifiers," ")}}visitColumnDefinition($){if($.ifNotExists)this.append("if not exists ");if(this.visitNode($.column),this.append(" "),this.visitNode($.dataType),$.unsigned)this.append(" unsigned");if($.frontModifiers&&$.frontModifiers.length>0)this.append(" "),this.compileList($.frontModifiers," ");if($.generated)this.append(" "),this.visitNode($.generated);if($.identity)this.append(" identity");if($.defaultTo)this.append(" "),this.visitNode($.defaultTo);if($.notNull)this.append(" not null");if($.unique)this.append(" unique");if($.nullsNotDistinct)this.append(" nulls not distinct");if($.primaryKey)this.append(" primary key");if($.autoIncrement)this.append(" "),this.append(this.getAutoIncrement());if($.references)this.append(" "),this.visitNode($.references);if($.check)this.append(" "),this.visitNode($.check);if($.endModifiers&&$.endModifiers.length>0)this.append(" "),this.compileList($.endModifiers," ")}getAutoIncrement(){return"auto_increment"}visitReferences($){if(this.append("references "),this.visitNode($.table),this.append(" ("),this.compileList($.columns),this.append(")"),$.onDelete)this.append(" on delete "),this.append($.onDelete);if($.onUpdate)this.append(" on update "),this.append($.onUpdate)}visitDropTable($){if(this.append("drop table "),$.ifExists)this.append("if exists ");if(this.visitNode($.table),$.cascade)this.append(" cascade")}visitDataType($){this.append($.dataType)}visitOrderBy($){this.append("order by "),this.compileList($.items)}visitOrderByItem($){if(this.visitNode($.orderBy),$.collation)this.append(" "),this.visitNode($.collation);if($.direction)this.append(" "),this.visitNode($.direction);if($.nulls)this.append(" nulls "),this.append($.nulls)}visitGroupBy($){this.append("group by "),this.compileList($.items)}visitGroupByItem($){this.visitNode($.groupBy)}visitUpdateQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode)&&!Y7.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("update "),$.top)this.visitNode($.top),this.append(" ");if($.table)this.visitNode($.table),this.append(" ");if(this.append("set "),$.updates)this.compileList($.updates);if($.output)this.append(" "),this.visitNode($.output);if($.from)this.append(" "),this.visitNode($.from);if($.joins){if(!$.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList($.joins," ")}if($.where)this.append(" "),this.visitNode($.where);if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitColumnUpdate($){this.visitNode($.column),this.append(" = "),this.visitNode($.value)}visitLimit($){this.append("limit "),this.visitNode($.limit)}visitOffset($){this.append("offset "),this.visitNode($.offset)}visitOnConflict($){if(this.append("on conflict"),$.columns)this.append(" ("),this.compileList($.columns),this.append(")");else if($.constraint)this.append(" on constraint "),this.visitNode($.constraint);else if($.indexExpression)this.append(" ("),this.visitNode($.indexExpression),this.append(")");if($.indexWhere)this.append(" "),this.visitNode($.indexWhere);if($.doNothing===!0)this.append(" do nothing");else if($.updates){if(this.append(" do update set "),this.compileList($.updates),$.updateWhere)this.append(" "),this.visitNode($.updateWhere)}}visitOnDuplicateKey($){this.append("on duplicate key update "),this.compileList($.updates)}visitCreateIndex($){if(this.append("create "),$.unique)this.append("unique ");if(this.append("index "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.name),$.table)this.append(" on "),this.visitNode($.table);if($.using)this.append(" using "),this.visitNode($.using);if($.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.nullsNotDistinct)this.append(" nulls not distinct");if($.where)this.append(" "),this.visitNode($.where)}visitDropIndex($){if(this.append("drop index "),$.ifExists)this.append("if exists ");if(this.visitNode($.name),$.table)this.append(" on "),this.visitNode($.table);if($.cascade)this.append(" cascade")}visitCreateSchema($){if(this.append("create schema "),$.ifNotExists)this.append("if not exists ");this.visitNode($.schema)}visitDropSchema($){if(this.append("drop schema "),$.ifExists)this.append("if exists ");if(this.visitNode($.schema),$.cascade)this.append(" cascade")}visitPrimaryKeyConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");this.append("primary key ("),this.compileList($.columns),this.append(")"),this.buildDeferrable($)}buildDeferrable($){if($.deferrable!==void 0)if($.deferrable)this.append(" deferrable");else this.append(" not deferrable");if($.initiallyDeferred!==void 0)if($.initiallyDeferred)this.append(" initially deferred");else this.append(" initially immediate")}visitUniqueConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");if(this.append("unique"),$.nullsNotDistinct)this.append(" nulls not distinct");this.append(" ("),this.compileList($.columns),this.append(")"),this.buildDeferrable($)}visitCheckConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");this.append("check ("),this.visitNode($.expression),this.append(")")}visitForeignKeyConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");if(this.append("foreign key ("),this.compileList($.columns),this.append(") "),this.visitNode($.references),$.onDelete)this.append(" on delete "),this.append($.onDelete);if($.onUpdate)this.append(" on update "),this.append($.onUpdate);this.buildDeferrable($)}visitList($){this.compileList($.items)}visitWith($){if(this.append("with "),$.recursive)this.append("recursive ");this.compileList($.expressions)}visitCommonTableExpression($){if(this.visitNode($.name),this.append(" as "),tY($.materialized)){if(!$.materialized)this.append("not ");this.append("materialized ")}this.visitNode($.expression)}visitCommonTableExpressionName($){if(this.visitNode($.table),$.columns)this.append("("),this.compileList($.columns),this.append(")")}visitAlterTable($){if(this.append("alter table "),this.visitNode($.table),this.append(" "),$.renameTo)this.append("rename to "),this.visitNode($.renameTo);if($.setSchema)this.append("set schema "),this.visitNode($.setSchema);if($.addConstraint)this.visitNode($.addConstraint);if($.dropConstraint)this.visitNode($.dropConstraint);if($.renameConstraint)this.visitNode($.renameConstraint);if($.columnAlterations)this.compileColumnAlterations($.columnAlterations);if($.addIndex)this.visitNode($.addIndex);if($.dropIndex)this.visitNode($.dropIndex)}visitAddColumn($){this.append("add column "),this.visitNode($.column)}visitRenameColumn($){this.append("rename column "),this.visitNode($.column),this.append(" to "),this.visitNode($.renameTo)}visitDropColumn($){this.append("drop column "),this.visitNode($.column)}visitAlterColumn($){if(this.append("alter column "),this.visitNode($.column),this.append(" "),$.dataType){if(this.announcesNewColumnDataType())this.append("type ");if(this.visitNode($.dataType),$.dataTypeExpression)this.append("using "),this.visitNode($.dataTypeExpression)}if($.setDefault)this.append("set default "),this.visitNode($.setDefault);if($.dropDefault)this.append("drop default");if($.setNotNull)this.append("set not null");if($.dropNotNull)this.append("drop not null")}visitModifyColumn($){this.append("modify column "),this.visitNode($.column)}visitAddConstraint($){this.append("add "),this.visitNode($.constraint)}visitDropConstraint($){if(this.append("drop constraint "),$.ifExists)this.append("if exists ");if(this.visitNode($.constraintName),$.modifier==="cascade")this.append(" cascade");else if($.modifier==="restrict")this.append(" restrict")}visitRenameConstraint($){this.append("rename constraint "),this.visitNode($.oldName),this.append(" to "),this.visitNode($.newName)}visitSetOperation($){if(this.append($.operator),this.append(" "),$.all)this.append("all ");this.visitNode($.expression)}visitCreateView($){if(this.append("create "),$.orReplace)this.append("or replace ");if($.materialized)this.append("materialized ");if($.temporary)this.append("temporary ");if(this.append("view "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.name),this.append(" "),$.columns)this.append("("),this.compileList($.columns),this.append(") ");if($.as)this.append("as "),this.visitNode($.as)}visitRefreshMaterializedView($){if(this.append("refresh materialized view "),$.concurrently)this.append("concurrently ");if(this.visitNode($.name),$.withNoData)this.append(" with no data");else this.append(" with data")}visitDropView($){if(this.append("drop "),$.materialized)this.append("materialized ");if(this.append("view "),$.ifExists)this.append("if exists ");if(this.visitNode($.name),$.cascade)this.append(" cascade")}visitGenerated($){if(this.append("generated "),$.always)this.append("always ");if($.byDefault)this.append("by default ");if(this.append("as "),$.identity)this.append("identity");if($.expression)this.append("("),this.visitNode($.expression),this.append(")");if($.stored)this.append(" stored")}visitDefaultValue($){this.append("default "),this.visitNode($.defaultValue)}visitSelectModifier($){if($.rawModifier)this.visitNode($.rawModifier);else this.append(b46[$.modifier]);if($.of)this.append(" of "),this.compileList($.of,", ")}visitCreateType($){if(this.append("create type "),this.visitNode($.name),$.enum)this.append(" as enum "),this.visitNode($.enum)}visitDropType($){if(this.append("drop type "),$.ifExists)this.append("if exists ");this.visitNode($.name)}visitExplain($){if(this.append("explain"),$.options||$.format){if(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),$.options){if(this.visitNode($.options),$.format)this.append(this.getExplainOptionsDelimiter())}if($.format)this.append("format"),this.append(this.getExplainOptionAssignment()),this.append($.format);this.append(this.getRightExplainOptionsWrapper())}}visitDefaultInsertValue($){this.append("default")}visitAggregateFunction($){if(this.append($.func),this.append("("),$.distinct)this.append("distinct ");if(this.compileList($.aggregated),$.orderBy)this.append(" "),this.visitNode($.orderBy);if(this.append(")"),$.withinGroup)this.append(" within group ("),this.visitNode($.withinGroup),this.append(")");if($.filter)this.append(" filter("),this.visitNode($.filter),this.append(")");if($.over)this.append(" "),this.visitNode($.over)}visitOver($){if(this.append("over("),$.partitionBy){if(this.visitNode($.partitionBy),$.orderBy)this.append(" ")}if($.orderBy)this.visitNode($.orderBy);this.append(")")}visitPartitionBy($){this.append("partition by "),this.compileList($.items)}visitPartitionByItem($){this.visitNode($.partitionBy)}visitBinaryOperation($){this.visitNode($.leftOperand),this.append(" "),this.visitNode($.operator),this.append(" "),this.visitNode($.rightOperand)}visitUnaryOperation($){if(this.visitNode($.operator),!this.isMinusOperator($.operator))this.append(" ");this.visitNode($.operand)}isMinusOperator($){return g$.is($)&&$.operator==="-"}visitUsing($){this.append("using "),this.compileList($.tables)}visitFunction($){this.append($.func),this.append("("),this.compileList($.arguments),this.append(")")}visitCase($){if(this.append("case"),$.value)this.append(" "),this.visitNode($.value);if($.when)this.append(" "),this.compileList($.when," ");if($.else)this.append(" else "),this.visitNode($.else);if(this.append(" end"),$.isStatement)this.append(" case")}visitWhen($){if(this.append("when "),this.visitNode($.condition),$.result)this.append(" then "),this.visitNode($.result)}visitJSONReference($){this.visitNode($.reference),this.visitNode($.traversal)}visitJSONPath($){if($.inOperator)this.visitNode($.inOperator);this.append("'$");for(let K of $.pathLegs)this.visitNode(K);this.append("'")}visitJSONPathLeg($){let K=$.type==="ArrayLocation";if(this.append(K?"[":"."),this.append(String($.value)),K)this.append("]")}visitJSONOperatorChain($){for(let K=0,q=$.values.length;K<q;K++){if(K===q-1)this.visitNode($.operator);else this.append("->");this.visitNode($.values[K])}}visitMergeQuery($){if($.with)this.visitNode($.with),this.append(" ");if(this.append("merge "),$.top)this.visitNode($.top),this.append(" ");if(this.append("into "),this.visitNode($.into),$.using)this.append(" "),this.visitNode($.using);if($.whens)this.append(" "),this.compileList($.whens," ");if($.returning)this.append(" "),this.visitNode($.returning);if($.output)this.append(" "),this.visitNode($.output);if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitMatched($){if($.not)this.append("not ");if(this.append("matched"),$.bySource)this.append(" by source")}visitAddIndex($){if(this.append("add "),$.unique)this.append("unique ");if(this.append("index "),this.visitNode($.name),$.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.using)this.append(" using "),this.visitNode($.using)}visitCast($){this.append("cast("),this.visitNode($.expression),this.append(" as "),this.visitNode($.dataType),this.append(")")}visitFetch($){this.append("fetch next "),this.visitNode($.rowCount),this.append(` rows ${$.modifier}`)}visitOutput($){this.append("output "),this.compileList($.selections)}visitTop($){if(this.append(`top(${$.expression})`),$.modifiers)this.append(` ${$.modifiers}`)}visitOrAction($){this.append($.action)}visitCollate($){this.append("collate "),this.visitNode($.collation)}append($){this.#$+=$}appendValue($){this.addParameter($),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier($){let K=this.getLeftIdentifierWrapper(),q=this.getRightIdentifierWrapper(),Y="";for(let z of $)if(Y+=z,z===K)Y+=K;else if(z===q)Y+=q;return Y}sanitizeStringLiteral($){return $.replace(x46,"''")}addParameter($){this.#K.push($)}appendImmediateValue($){if(f1($))this.appendStringLiteral($);else if(Hq($)||tY($)||YJ($))this.append($.toString());else if(qJ($))this.append("null");else if(Et($))this.appendImmediateValue($.toISOString());else throw new Error(`invalid immediate value ${$}`)}appendStringLiteral($){this.append("'"),this.append(this.sanitizeStringLiteral($)),this.append("'")}sortSelectModifiers($){return $.sort((K,q)=>K.modifier&&q.modifier?ye[K.modifier]-ye[q.modifier]:1),k($)}compileColumnAlterations($){this.compileList($)}announcesNewColumnDataType(){return!0}}var b46=k({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),ye=k({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),g46=k({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"});var h0=k({raw($,K=[]){return k({sql:$,query:b6.createWithSql($),parameters:k(K),queryId:$6()})}});class WS{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}function C0($,K){return b6.createWithChildren([b6.createWithSql(`${$} `),p8.create(K)])}class HS{#$;#K=new me;#q;#Y;constructor($){this.#$=k({...$})}async init(){if(this.#q=A1(this.#$.database)?await this.#$.database():this.#$.database,this.#Y=new ue(this.#q),this.#$.onCreateConnection)await this.#$.onCreateConnection(this.#Y)}async acquireConnection(){return await this.#K.lock(),this.#Y}async beginTransaction($){await $.executeQuery(h0.raw("begin"))}async commitTransaction($){await $.executeQuery(h0.raw("commit"))}async rollbackTransaction($){await $.executeQuery(h0.raw("rollback"))}async savepoint($,K,q){await $.executeQuery(q(C0("savepoint",K),$6()))}async rollbackToSavepoint($,K,q){await $.executeQuery(q(C0("rollback to",K),$6()))}async releaseSavepoint($,K,q){await $.executeQuery(q(C0("release",K),$6()))}async releaseConnection(){this.#K.unlock()}async destroy(){this.#q?.close()}}class ue{#$;constructor($){this.#$=$}executeQuery($){let{sql:K,parameters:q}=$,Y=this.#$.prepare(K);if(Y.reader)return Promise.resolve({rows:Y.all(q)});let{changes:z,lastInsertRowid:P}=Y.run(q);return Promise.resolve({numAffectedRows:z!==void 0&&z!==null?BigInt(z):void 0,insertId:P!==void 0&&P!==null?BigInt(P):void 0,rows:[]})}async*streamQuery($,K){let{sql:q,parameters:Y,query:z}=$,P=this.#$.prepare(q);if(m6.is(z)){let J=P.iterate(Y);for(let W of J)yield{rows:[W]}}else throw new Error("Sqlite driver only supports streaming of select queries")}}class me{#$;#K;async lock(){while(this.#$)await this.#$;this.#$=new Promise(($)=>{this.#K=$})}unlock(){let $=this.#K;this.#$=void 0,this.#K=void 0,$?.()}}var y46=/"/g;class ZS extends JS{visitOrAction($){this.append("or "),this.append($.action)}getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier($){return $.replace(y46,'""')}visitDefaultInsertValue($){this.append("null")}}class OS{transformQuery($){return $.node}async transformResult($){return $.result}}var XS="kysely_migration",D0="kysely_migration_lock",u46=!1,wS="migration_lock",_S1=k({__noMigrations__:!0});class m46{#$;constructor($){this.#$=k($)}async getMigrations(){let $=await this.#X(this.#Y)?await this.#$.db.withPlugin(this.#P).selectFrom(this.#Y).select(["name","timestamp"]).$narrowType().execute():[];return(await this.#k()).map(({name:q,...Y})=>{let z=$.find((P)=>P.name===q);return{name:q,migration:Y,executedAt:z?new Date(z.timestamp):void 0}})}async migrateToLatest(){return this.#K(()=>({direction:"Up",step:1/0}))}async migrateTo($){return this.#K(({migrations:K,executedMigrations:q,pendingMigrations:Y})=>{if(M4($)&&$.__noMigrations__===!0)return{direction:"Down",step:1/0};if(!K.find((J)=>J.name===$))throw new Error(`migration "${$}" doesn't exist`);let z=q.indexOf($),P=Y.findIndex((J)=>J.name===$);if(z!==-1)return{direction:"Down",step:q.length-z-1};else if(P!==-1)return{direction:"Up",step:P+1};else throw new Error(`migration "${$}" isn't executed or pending`)})}async migrateUp(){return this.#K(()=>({direction:"Up",step:1}))}async migrateDown(){return this.#K(()=>({direction:"Down",step:1}))}async#K($){try{return await this.#H(),await this.#C($)}catch(K){if(K instanceof R0)return K.resultSet;return{error:K}}}get#q(){return this.#$.migrationTableSchema}get#Y(){return this.#$.migrationTableName??XS}get#z(){return this.#$.migrationLockTableName??D0}get#w(){return this.#$.allowUnorderedMigrations??u46}get#P(){if(this.#q)return new c$(this.#q);return new OS}async#H(){await this.#W(),await this.#O(),await this.#J(),await this.#f()}async#W(){if(!this.#q)return;if(!await this.#v())try{await this.#A(this.#$.db.schema.createSchema(this.#q))}catch($){if(!await this.#v())throw $}}async#O(){if(!await this.#X(this.#Y))try{if(this.#q)await this.#A(this.#$.db.schema.createSchema(this.#q));await this.#A(this.#$.db.schema.withPlugin(this.#P).createTable(this.#Y).addColumn("name","varchar(255)",($)=>$.notNull().primaryKey()).addColumn("timestamp","varchar(255)",($)=>$.notNull()))}catch($){if(!await this.#X(this.#Y))throw $}}async#J(){if(!await this.#X(this.#z))try{await this.#A(this.#$.db.schema.withPlugin(this.#P).createTable(this.#z).addColumn("id","varchar(255)",($)=>$.notNull().primaryKey()).addColumn("is_locked","integer",($)=>$.notNull().defaultTo(0)))}catch($){if(!await this.#X(this.#z))throw $}}async#f(){if(!await this.#j())try{await this.#$.db.withPlugin(this.#P).insertInto(this.#z).values({id:wS,is_locked:0}).execute()}catch($){if(!await this.#j())throw $}}async#v(){return(await this.#$.db.introspection.getSchemas()).some((K)=>K.name===this.#q)}async#X($){let K=this.#q;return(await this.#$.db.introspection.getTables({withInternalKyselyTables:!0})).some((Y)=>Y.name===$&&(!K||Y.schema===K))}async#j(){return!!await this.#$.db.withPlugin(this.#P).selectFrom(this.#z).where("id","=",wS).select("id").executeTakeFirst()}async#C($){let K=this.#$.db.getExecutor().adapter,q=k({lockTable:this.#$.migrationLockTableName??D0,lockRowId:wS,lockTableSchema:this.#$.migrationTableSchema}),Y=async(z)=>{try{await K.acquireMigrationLock(z,q);let P=await this.#_(z);if(P.migrations.length===0)return{results:[]};let{direction:J,step:W}=$(P);if(W<=0)return{results:[]};if(J==="Down")return await this.#G(z,P,W);else if(J==="Up")return await this.#D(z,P,W);return{results:[]}}finally{await K.releaseMigrationLock(z,q)}};if(K.supportsTransactionalDdl&&!this.#$.disableTransactions)return this.#$.db.transaction().execute(Y);else return this.#$.db.connection().execute(Y)}async#_($){let K=await this.#k(),q=await this.#V($);if(this.#M(K,q),!this.#w)this.#N(K,q);let Y=this.#R(K,q);return k({migrations:K,executedMigrations:q,lastMigration:Lt(q),pendingMigrations:Y})}#R($,K){return $.filter((q)=>{return!K.includes(q.name)})}async#k(){let $=await this.#$.provider.getMigrations();return Object.keys($).sort().map((K)=>({...$[K],name:K}))}async#V($){let K=await $.withPlugin(this.#P).selectFrom(this.#Y).select(["name","timestamp"]).$narrowType().execute(),q=this.#$.nameComparator||((Y,z)=>Y.localeCompare(z));return K.sort((Y,z)=>{if(Y.timestamp===z.timestamp)return q(Y.name,z.name);return new Date(Y.timestamp).getTime()-new Date(z.timestamp).getTime()}).map((Y)=>Y.name)}#M($,K){for(let q of K)if(!$.some((Y)=>Y.name===q))throw new Error(`corrupted migrations: previously executed migration ${q} is missing`)}#N($,K){for(let q=0;q<K.length;++q)if($[q].name!==K[q])throw new Error(`corrupted migrations: expected previously executed migration ${K[q]} to be at index ${q} but ${$[q].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)}async#G($,K,q){let Y=K.executedMigrations.slice().reverse().slice(0,q).map((P)=>{return K.migrations.find((J)=>J.name===P)}),z=Y.map((P)=>{return{migrationName:P.name,direction:"Down",status:"NotExecuted"}});for(let P=0;P<z.length;++P){let J=Y[P];try{if(J.down)await J.down($),await $.withPlugin(this.#P).deleteFrom(this.#Y).where("name","=",J.name).execute(),z[P]={migrationName:J.name,direction:"Down",status:"Success"}}catch(W){throw z[P]={migrationName:J.name,direction:"Down",status:"Error"},new R0({error:W,results:z})}}return{results:z}}async#D($,K,q){let z=K.pendingMigrations.slice(0,q).map((P)=>{return{migrationName:P.name,direction:"Up",status:"NotExecuted"}});for(let P=0;P<z.length;P++){let J=K.pendingMigrations[P];try{await J.up($),await $.withPlugin(this.#P).insertInto(this.#Y).values({name:J.name,timestamp:new Date().toISOString()}).execute(),z[P]={migrationName:J.name,direction:"Up",status:"Success"}}catch(W){throw z[P]={migrationName:J.name,direction:"Up",status:"Error"},new R0({error:W,results:z})}}return{results:z}}async#A($){if(this.#$.db.getExecutor().adapter.supportsCreateIfNotExists)$=$.ifNotExists();await $.execute()}}class R0 extends Error{#$;constructor($){super();this.#$=$}get resultSet(){return this.#$}}class TS{#$;constructor($){this.#$=$}async getSchemas(){return[]}async getTables($={withInternalKyselyTables:!1}){return await this.#q($)}async getMetadata($){return{tables:await this.getTables($)}}#K($,K){let q=$.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select(["name","sql","type"]).orderBy("name");if(!K.withInternalKyselyTables)q=q.where("name","!=",XS).where("name","!=",D0);return q}async#q($){let K=await this.#K(this.#$,$).execute(),q=await this.#$.with("table_list",(z)=>this.#K(z,$)).selectFrom(["table_list as tl",U$`pragma_table_info(tl.name)`.as("p")]).select(["tl.name as table","p.cid","p.name","p.type","p.notnull","p.dflt_value","p.pk"]).orderBy("tl.name").orderBy("p.cid").execute(),Y={};for(let z of q)Y[z.table]??=[],Y[z.table].push(z);return K.map(({name:z,sql:P,type:J})=>{let W=P?.split(/[\(\),]/)?.find((Z)=>Z.toLowerCase().includes("autoincrement"))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g,""),H=Y[z]??[];if(!W){let Z=H.filter((O)=>O.pk>0);if(Z.length===1&&Z[0].type.toLowerCase()==="integer")W=Z[0].name}return{name:z,isView:J==="view",columns:H.map((Z)=>({name:Z.name,dataType:Z.type,isNullable:!Z.notnull,isAutoIncrementing:Z.name===W,hasDefaultValue:Z.dflt_value!=null,comment:void 0}))}})}}class jS extends WS{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock($,K){}async releaseMigrationLock($,K){}}class vS{#$;constructor($){this.#$=k({...$})}createDriver(){return new HS(this.#$)}createQueryCompiler(){return new ZS}createAdapter(){return new jS}createIntrospector($){return new TS($)}}import{existsSync as EW6,mkdirSync as LW6}from"fs";import{dirname as IW6}from"path";var pe=async($)=>{return(await U$`
|
|
449
|
+
deps: ${q}}`};var GJ1={keyword:"dependencies",type:"object",schemaType:"object",error:TU8.error,code($){let[K,q]=_J1($);wU8($,K),XU8($,q)}};function _J1({schema:$}){let K={},q={};for(let Y in $){if(Y==="__proto__")continue;let z=Array.isArray($[Y])?K:q;z[Y]=$[Y]}return[K,q]}function wU8($,K=$.schema){let{gen:q,data:Y,it:z}=$;if(Object.keys(K).length===0)return;let P=q.let("missing");for(let J in K){let W=K[J];if(W.length===0)continue;let H=Av.propertyInData(q,Y,J,z.opts.ownProperties);if($.setParams({property:J,depsCount:W.length,deps:W.join(", ")}),z.allErrors)q.if(H,()=>{for(let Z of W)Av.checkReportMissingProp($,Z)});else q.if(xF._`${H} && (${Av.checkMissingProp($,W,P)})`),Av.reportMissingProp($,P),q.else()}}TU8.validatePropertyDeps=wU8;function XU8($,K=$.schema){let{gen:q,data:Y,keyword:z,it:P}=$,J=q.name("valid");for(let W in K){if(vJ1.alwaysValidSchema(P,K[W]))continue;q.if(Av.propertyInData(q,Y,W,P.opts.ownProperties),()=>{let H=$.subschema({keyword:z,schemaProp:W},J);$.mergeValidEvaluated(H,J)},()=>q.var(J,!0)),$.ok(J)}}TU8.validateSchemaDeps=XU8;TU8.default=GJ1});var AU8=j((fU8)=>{Object.defineProperty(fU8,"__esModule",{value:!0});var _U8=O6(),VJ1=p6(),kJ1={message:"property name must be valid",params:({params:$})=>_U8._`{propertyName: ${$.propertyName}}`},MJ1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kJ1,code($){let{gen:K,schema:q,data:Y,it:z}=$;if(VJ1.alwaysValidSchema(z,q))return;let P=K.name("valid");K.forIn("key",Y,(J)=>{$.setParams({propertyName:J}),$.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},P),K.if(_U8.not(P),()=>{if($.error(!0),!z.allErrors)K.break()})}),$.ok(P)}};fU8.default=MJ1});var bF=j((VU8)=>{Object.defineProperty(VU8,"__esModule",{value:!0});var ph=I7(),I9=O6(),hJ1=oK(),ch=p6(),CJ1={message:"must NOT have additional properties",params:({params:$})=>I9._`{additionalProperty: ${$.additionalProperty}}`},RJ1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:CJ1,code($){let{gen:K,schema:q,parentSchema:Y,data:z,errsCount:P,it:J}=$;if(!P)throw new Error("ajv implementation error");let{allErrors:W,opts:H}=J;if(J.props=!0,H.removeAdditional!=="all"&&ch.alwaysValidSchema(J,q))return;let Z=ph.allSchemaProperties(Y.properties),O=ph.allSchemaProperties(Y.patternProperties);w(),$.ok(I9._`${P} === ${hJ1.default.errors}`);function w(){K.forIn("key",z,(f)=>{if(!Z.length&&!O.length)G(f);else K.if(X(f),()=>G(f))})}function X(f){let A;if(Z.length>8){let C=ch.schemaRefOrVal(J,Y.properties,"properties");A=ph.isOwnProperty(K,C,f)}else if(Z.length)A=I9.or(...Z.map((C)=>I9._`${f} === ${C}`));else A=I9.nil;if(O.length)A=I9.or(A,...O.map((C)=>I9._`${ph.usePattern($,C)}.test(${f})`));return I9.not(A)}function T(f){K.code(I9._`delete ${z}[${f}]`)}function G(f){if(H.removeAdditional==="all"||H.removeAdditional&&q===!1){T(f);return}if(q===!1){if($.setParams({additionalProperty:f}),$.error(),!W)K.break();return}if(typeof q=="object"&&!ch.alwaysValidSchema(J,q)){let A=K.name("valid");if(H.removeAdditional==="failing")v(f,A,!1),K.if(I9.not(A),()=>{$.reset(),T(f)});else if(v(f,A),!W)K.if(I9.not(A),()=>K.break())}}function v(f,A,C){let V={keyword:"additionalProperties",dataProp:f,dataPropType:ch.Type.Str};if(C===!1)Object.assign(V,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(V,A)}}};VU8.default=RJ1});var hU8=j((NU8)=>{Object.defineProperty(NU8,"__esModule",{value:!0});var SJ1=Wv(),kU8=I7(),gF=p6(),MU8=bF(),EJ1={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:K,schema:q,parentSchema:Y,data:z,it:P}=$;if(P.opts.removeAdditional==="all"&&Y.additionalProperties===void 0)MU8.default.code(new SJ1.KeywordCxt(P,MU8.default,"additionalProperties"));let J=kU8.allSchemaProperties(q);for(let w of J)P.definedProperties.add(w);if(P.opts.unevaluated&&J.length&&P.props!==!0)P.props=gF.mergeEvaluated.props(K,gF.toHash(J),P.props);let W=J.filter((w)=>!gF.alwaysValidSchema(P,q[w]));if(W.length===0)return;let H=K.name("valid");for(let w of W){if(Z(w))O(w);else{if(K.if(kU8.propertyInData(K,z,w,P.opts.ownProperties)),O(w),!P.allErrors)K.else().var(H,!0);K.endIf()}$.it.definedProperties.add(w),$.ok(H)}function Z(w){return P.opts.useDefaults&&!P.compositeRule&&q[w].default!==void 0}function O(w){$.subschema({keyword:"properties",schemaProp:w,dataProp:w},H)}}};NU8.default=EJ1});var EU8=j((SU8)=>{Object.defineProperty(SU8,"__esModule",{value:!0});var CU8=I7(),Bh=O6(),RU8=p6(),DU8=p6(),IJ1={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:K,schema:q,data:Y,parentSchema:z,it:P}=$,{opts:J}=P,W=CU8.allSchemaProperties(q),H=W.filter((v)=>RU8.alwaysValidSchema(P,q[v]));if(W.length===0||H.length===W.length&&(!P.opts.unevaluated||P.props===!0))return;let Z=J.strictSchema&&!J.allowMatchingProperties&&z.properties,O=K.name("valid");if(P.props!==!0&&!(P.props instanceof Bh.Name))P.props=DU8.evaluatedPropsToName(K,P.props);let{props:w}=P;X();function X(){for(let v of W){if(Z)T(v);if(P.allErrors)G(v);else K.var(O,!0),G(v),K.if(O)}}function T(v){for(let f in Z)if(new RegExp(v).test(f))RU8.checkStrictMode(P,`property ${f} matches pattern ${v} (use allowMatchingProperties)`)}function G(v){K.forIn("key",Y,(f)=>{K.if(Bh._`${CU8.usePattern($,v)}.test(${f})`,()=>{let A=H.includes(v);if(!A)$.subschema({keyword:"patternProperties",schemaProp:v,dataProp:f,dataPropType:DU8.Type.Str},O);if(P.opts.unevaluated&&w!==!0)K.assign(Bh._`${w}[${f}]`,!0);else if(!A&&!P.allErrors)K.if(Bh.not(O),()=>K.break())})})}}};SU8.default=IJ1});var IU8=j((LU8)=>{Object.defineProperty(LU8,"__esModule",{value:!0});var bJ1=p6(),gJ1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code($){let{gen:K,schema:q,it:Y}=$;if(bJ1.alwaysValidSchema(Y,q)){$.fail();return}let z=K.name("valid");$.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},z),$.failResult(z,()=>$.reset(),()=>$.error())},error:{message:"must NOT be valid"}};LU8.default=gJ1});var bU8=j((xU8)=>{Object.defineProperty(xU8,"__esModule",{value:!0});var uJ1=I7(),mJ1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:uJ1.validateUnion,error:{message:"must match a schema in anyOf"}};xU8.default=mJ1});var yU8=j((gU8)=>{Object.defineProperty(gU8,"__esModule",{value:!0});var Uh=O6(),cJ1=p6(),BJ1={message:"must match exactly one schema in oneOf",params:({params:$})=>Uh._`{passingSchemas: ${$.passing}}`},UJ1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:BJ1,code($){let{gen:K,schema:q,parentSchema:Y,it:z}=$;if(!Array.isArray(q))throw new Error("ajv implementation error");if(z.opts.discriminator&&Y.discriminator)return;let P=q,J=K.let("valid",!1),W=K.let("passing",null),H=K.name("_valid");$.setParams({passing:W}),K.block(Z),$.result(J,()=>$.reset(),()=>$.error(!0));function Z(){P.forEach((O,w)=>{let X;if(cJ1.alwaysValidSchema(z,O))K.var(H,!0);else X=$.subschema({keyword:"oneOf",schemaProp:w,compositeRule:!0},H);if(w>0)K.if(Uh._`${H} && ${J}`).assign(J,!1).assign(W,Uh._`[${W}, ${w}]`).else();K.if(H,()=>{if(K.assign(J,!0),K.assign(W,w),X)$.mergeEvaluated(X,Uh.Name)})})}}};gU8.default=UJ1});var mU8=j((uU8)=>{Object.defineProperty(uU8,"__esModule",{value:!0});var FJ1=p6(),iJ1={keyword:"allOf",schemaType:"array",code($){let{gen:K,schema:q,it:Y}=$;if(!Array.isArray(q))throw new Error("ajv implementation error");let z=K.name("valid");q.forEach((P,J)=>{if(FJ1.alwaysValidSchema(Y,P))return;let W=$.subschema({keyword:"allOf",schemaProp:J},z);$.ok(z),$.mergeEvaluated(W)})}};uU8.default=iJ1});var UU8=j((BU8)=>{Object.defineProperty(BU8,"__esModule",{value:!0});var lh=O6(),cU8=p6(),dJ1={message:({params:$})=>lh.str`must match "${$.ifClause}" schema`,params:({params:$})=>lh._`{failingKeyword: ${$.ifClause}}`},nJ1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:dJ1,code($){let{gen:K,parentSchema:q,it:Y}=$;if(q.then===void 0&&q.else===void 0)cU8.checkStrictMode(Y,'"if" without "then" and "else" is ignored');let z=pU8(Y,"then"),P=pU8(Y,"else");if(!z&&!P)return;let J=K.let("valid",!0),W=K.name("_valid");if(H(),$.reset(),z&&P){let O=K.let("ifClause");$.setParams({ifClause:O}),K.if(W,Z("then",O),Z("else",O))}else if(z)K.if(W,Z("then"));else K.if(lh.not(W),Z("else"));$.pass(J,()=>$.error(!0));function H(){let O=$.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},W);$.mergeEvaluated(O)}function Z(O,w){return()=>{let X=$.subschema({keyword:O},W);if(K.assign(J,W),$.mergeValidEvaluated(X,J),w)K.assign(w,lh._`${O}`);else $.setParams({ifClause:O})}}}};function pU8($,K){let q=$.schema[K];return q!==void 0&&!cU8.alwaysValidSchema($,q)}BU8.default=nJ1});var FU8=j((lU8)=>{Object.defineProperty(lU8,"__esModule",{value:!0});var aJ1=p6(),rJ1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:$,parentSchema:K,it:q}){if(K.if===void 0)aJ1.checkStrictMode(q,`"${$}" without "if" is ignored`)}};lU8.default=rJ1});var QU8=j((iU8)=>{Object.defineProperty(iU8,"__esModule",{value:!0});var tJ1=LF(),eJ1=PU8(),$W1=IF(),KW1=HU8(),qW1=OU8(),YW1=GU8(),zW1=AU8(),PW1=bF(),JW1=hU8(),WW1=EU8(),HW1=IU8(),ZW1=bU8(),OW1=yU8(),wW1=mU8(),XW1=UU8(),TW1=FU8();function jW1($=!1){let K=[HW1.default,ZW1.default,OW1.default,wW1.default,XW1.default,TW1.default,zW1.default,PW1.default,YW1.default,JW1.default,WW1.default];if($)K.push(eJ1.default,KW1.default);else K.push(tJ1.default,$W1.default);return K.push(qW1.default),K}iU8.default=jW1});var nU8=j((dU8)=>{Object.defineProperty(dU8,"__esModule",{value:!0});var j4=O6(),GW1={message:({schemaCode:$})=>j4.str`must match format "${$}"`,params:({schemaCode:$})=>j4._`{format: ${$}}`},_W1={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:GW1,code($,K){let{gen:q,data:Y,$data:z,schema:P,schemaCode:J,it:W}=$,{opts:H,errSchemaPath:Z,schemaEnv:O,self:w}=W;if(!H.validateFormats)return;if(z)X();else T();function X(){let G=q.scopeValue("formats",{ref:w.formats,code:H.code.formats}),v=q.const("fDef",j4._`${G}[${J}]`),f=q.let("fType"),A=q.let("format");q.if(j4._`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>q.assign(f,j4._`${v}.type || "string"`).assign(A,j4._`${v}.validate`),()=>q.assign(f,j4._`"string"`).assign(A,v)),$.fail$data(j4.or(C(),V()));function C(){if(H.strictSchema===!1)return j4.nil;return j4._`${J} && !${A}`}function V(){let M=O.$async?j4._`(${v}.async ? await ${A}(${Y}) : ${A}(${Y}))`:j4._`${A}(${Y})`,R=j4._`(typeof ${A} == "function" ? ${M} : ${A}.test(${Y}))`;return j4._`${A} && ${A} !== true && ${f} === ${K} && !${R}`}}function T(){let G=w.formats[P];if(!G){C();return}if(G===!0)return;let[v,f,A]=V(G);if(v===K)$.pass(M());function C(){if(H.strictSchema===!1){w.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${P}" ignored in schema at path "${Z}"`}}function V(R){let I=R instanceof RegExp?j4.regexpCode(R):H.code.formats?j4._`${H.code.formats}${j4.getProperty(P)}`:void 0,D=q.scopeValue("formats",{key:P,ref:R,code:I});if(typeof R=="object"&&!(R instanceof RegExp))return[R.type||"string",R.validate,j4._`${D}.validate`];return["string",R,D]}function M(){if(typeof G=="object"&&!(G instanceof RegExp)&&G.async){if(!O.$async)throw new Error("async format in sync schema");return j4._`await ${A}(${Y})`}return typeof f=="function"?j4._`${A}(${Y})`:j4._`${A}.test(${Y})`}}}};dU8.default=_W1});var aU8=j((oU8)=>{Object.defineProperty(oU8,"__esModule",{value:!0});var AW1=nU8(),VW1=[AW1.default];oU8.default=VW1});var tU8=j((rU8)=>{Object.defineProperty(rU8,"__esModule",{value:!0});rU8.contentVocabulary=rU8.metadataVocabulary=void 0;rU8.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];rU8.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Kl8=j(($l8)=>{Object.defineProperty($l8,"__esModule",{value:!0});var NW1=NB8(),hW1=rB8(),CW1=QU8(),RW1=aU8(),eU8=tU8(),DW1=[NW1.default,hW1.default,CW1.default(),RW1.default,eU8.metadataVocabulary,eU8.contentVocabulary];$l8.default=DW1});var Pl8=j((Yl8)=>{Object.defineProperty(Yl8,"__esModule",{value:!0});Yl8.DiscrError=void 0;var ql8;(function($){$.Tag="tag",$.Mapping="mapping"})(ql8||(Yl8.DiscrError=ql8={}))});var Hl8=j((Wl8)=>{Object.defineProperty(Wl8,"__esModule",{value:!0});var mZ=O6(),yF=Pl8(),Jl8=Nh(),EW1=Hv(),LW1=p6(),IW1={message:({params:{discrError:$,tagName:K}})=>$===yF.DiscrError.Tag?`tag "${K}" must be string`:`value of tag "${K}" must be in oneOf`,params:({params:{discrError:$,tag:K,tagName:q}})=>mZ._`{error: ${$}, tag: ${q}, tagValue: ${K}}`},xW1={keyword:"discriminator",type:"object",schemaType:"object",error:IW1,code($){let{gen:K,data:q,schema:Y,parentSchema:z,it:P}=$,{oneOf:J}=z;if(!P.opts.discriminator)throw new Error("discriminator: requires discriminator option");let W=Y.propertyName;if(typeof W!="string")throw new Error("discriminator: requires propertyName");if(Y.mapping)throw new Error("discriminator: mapping is not supported");if(!J)throw new Error("discriminator: requires oneOf keyword");let H=K.let("valid",!1),Z=K.const("tag",mZ._`${q}${mZ.getProperty(W)}`);K.if(mZ._`typeof ${Z} == "string"`,()=>O(),()=>$.error(!1,{discrError:yF.DiscrError.Tag,tag:Z,tagName:W})),$.ok(H);function O(){let T=X();K.if(!1);for(let G in T)K.elseIf(mZ._`${Z} === ${G}`),K.assign(H,w(T[G]));K.else(),$.error(!1,{discrError:yF.DiscrError.Mapping,tag:Z,tagName:W}),K.endIf()}function w(T){let G=K.name("valid"),v=$.subschema({keyword:"oneOf",schemaProp:T},G);return $.mergeEvaluated(v,mZ.Name),G}function X(){var T;let G={},v=A(z),f=!0;for(let M=0;M<J.length;M++){let R=J[M];if((R===null||R===void 0?void 0:R.$ref)&&!LW1.schemaHasRulesButRef(R,P.self.RULES)){let D=R.$ref;if(R=Jl8.resolveRef.call(P.self,P.schemaEnv.root,P.baseId,D),R instanceof Jl8.SchemaEnv)R=R.schema;if(R===void 0)throw new EW1.default(P.opts.uriResolver,P.baseId,D)}let I=(T=R===null||R===void 0?void 0:R.properties)===null||T===void 0?void 0:T[W];if(typeof I!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${W}"`);f=f&&(v||A(R)),C(I,M)}if(!f)throw new Error(`discriminator: "${W}" must be required`);return G;function A({required:M}){return Array.isArray(M)&&M.includes(W)}function C(M,R){if(M.const)V(M.const,R);else if(M.enum)for(let I of M.enum)V(I,R);else throw new Error(`discriminator: "properties/${W}" must have "const" or "enum"`)}function V(M,R){if(typeof M!="string"||M in G)throw new Error(`discriminator: "${W}" values must be unique strings`);G[M]=R}}}};Wl8.default=xW1});var Zl8=j((Z$4,gW1)=>{gW1.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var mF=j((E$,uF)=>{Object.defineProperty(E$,"__esModule",{value:!0});E$.MissingRefError=E$.ValidationError=E$.CodeGen=E$.Name=E$.nil=E$.stringify=E$.str=E$._=E$.KeywordCxt=E$.Ajv=void 0;var yW1=TB8(),uW1=Kl8(),mW1=Hl8(),Ol8=Zl8(),pW1=["/properties"],Fh="http://json-schema.org/draft-07/schema";class Vv extends yW1.default{_addVocabularies(){if(super._addVocabularies(),uW1.default.forEach(($)=>this.addVocabulary($)),this.opts.discriminator)this.addKeyword(mW1.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let $=this.opts.$data?this.$dataMetaSchema(Ol8,pW1):Ol8;this.addMetaSchema($,Fh,!1),this.refs["http://json-schema.org/schema"]=Fh}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Fh)?Fh:void 0)}}E$.Ajv=Vv;uF.exports=E$=Vv;uF.exports.Ajv=Vv;Object.defineProperty(E$,"__esModule",{value:!0});E$.default=Vv;var cW1=Wv();Object.defineProperty(E$,"KeywordCxt",{enumerable:!0,get:function(){return cW1.KeywordCxt}});var pZ=O6();Object.defineProperty(E$,"_",{enumerable:!0,get:function(){return pZ._}});Object.defineProperty(E$,"str",{enumerable:!0,get:function(){return pZ.str}});Object.defineProperty(E$,"stringify",{enumerable:!0,get:function(){return pZ.stringify}});Object.defineProperty(E$,"nil",{enumerable:!0,get:function(){return pZ.nil}});Object.defineProperty(E$,"Name",{enumerable:!0,get:function(){return pZ.Name}});Object.defineProperty(E$,"CodeGen",{enumerable:!0,get:function(){return pZ.CodeGen}});var BW1=kh();Object.defineProperty(E$,"ValidationError",{enumerable:!0,get:function(){return BW1.default}});var UW1=Hv();Object.defineProperty(E$,"MissingRefError",{enumerable:!0,get:function(){return UW1.default}})});var Vl8=j((fl8)=>{Object.defineProperty(fl8,"__esModule",{value:!0});fl8.formatNames=fl8.fastFormats=fl8.fullFormats=void 0;function F5($,K){return{validate:$,compare:K}}fl8.fullFormats={date:F5(jl8,UF),time:F5(cF(!0),lF),"date-time":F5(wl8(!0),Gl8),"iso-time":F5(cF(),vl8),"iso-date-time":F5(wl8(),_l8),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:aW1,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:qH1,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rW1,int32:{type:"number",validate:eW1},int64:{type:"number",validate:$H1},float:{type:"number",validate:Tl8},double:{type:"number",validate:Tl8},password:!0,binary:!0};fl8.fastFormats={...fl8.fullFormats,date:F5(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,UF),time:F5(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,lF),"date-time":F5(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Gl8),"iso-time":F5(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,vl8),"iso-date-time":F5(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,_l8),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};fl8.formatNames=Object.keys(fl8.fullFormats);function iW1($){return $%4===0&&($%100!==0||$%400===0)}var QW1=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,dW1=[0,31,28,31,30,31,30,31,31,30,31,30,31];function jl8($){let K=QW1.exec($);if(!K)return!1;let q=+K[1],Y=+K[2],z=+K[3];return Y>=1&&Y<=12&&z>=1&&z<=(Y===2&&iW1(q)?29:dW1[Y])}function UF($,K){if(!($&&K))return;if($>K)return 1;if($<K)return-1;return 0}var pF=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function cF($){return function K(q){let Y=pF.exec(q);if(!Y)return!1;let z=+Y[1],P=+Y[2],J=+Y[3],W=Y[4],H=Y[5]==="-"?-1:1,Z=+(Y[6]||0),O=+(Y[7]||0);if(Z>23||O>59||$&&!W)return!1;if(z<=23&&P<=59&&J<60)return!0;let w=P-O*H,X=z-Z*H-(w<0?1:0);return(X===23||X===-1)&&(w===59||w===-1)&&J<61}}function lF($,K){if(!($&&K))return;let q=new Date("2020-01-01T"+$).valueOf(),Y=new Date("2020-01-01T"+K).valueOf();if(!(q&&Y))return;return q-Y}function vl8($,K){if(!($&&K))return;let q=pF.exec($),Y=pF.exec(K);if(!(q&&Y))return;if($=q[1]+q[2]+q[3],K=Y[1]+Y[2]+Y[3],$>K)return 1;if($<K)return-1;return 0}var BF=/t|\s/i;function wl8($){let K=cF($);return function q(Y){let z=Y.split(BF);return z.length===2&&jl8(z[0])&&K(z[1])}}function Gl8($,K){if(!($&&K))return;let q=new Date($).valueOf(),Y=new Date(K).valueOf();if(!(q&&Y))return;return q-Y}function _l8($,K){if(!($&&K))return;let[q,Y]=$.split(BF),[z,P]=K.split(BF),J=UF(q,z);if(J===void 0)return;return J||lF(Y,P)}var nW1=/\/|:/,oW1=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function aW1($){return nW1.test($)&&oW1.test($)}var Xl8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rW1($){return Xl8.lastIndex=0,Xl8.test($)}var sW1=-2147483648,tW1=2147483647;function eW1($){return Number.isInteger($)&&$<=tW1&&$>=sW1}function $H1($){return Number.isInteger($)}function Tl8(){return!0}var KH1=/[^\\]\\Z/;function qH1($){if(KH1.test($))return!1;try{return new RegExp($),!0}catch(K){return!1}}});var Ml8=j((kl8)=>{Object.defineProperty(kl8,"__esModule",{value:!0});kl8.formatLimitDefinition=void 0;var zH1=mF(),x9=O6(),IY=x9.operators,ih={formatMaximum:{okStr:"<=",ok:IY.LTE,fail:IY.GT},formatMinimum:{okStr:">=",ok:IY.GTE,fail:IY.LT},formatExclusiveMaximum:{okStr:"<",ok:IY.LT,fail:IY.GTE},formatExclusiveMinimum:{okStr:">",ok:IY.GT,fail:IY.LTE}},PH1={message:({keyword:$,schemaCode:K})=>x9.str`should be ${ih[$].okStr} ${K}`,params:({keyword:$,schemaCode:K})=>x9._`{comparison: ${ih[$].okStr}, limit: ${K}}`};kl8.formatLimitDefinition={keyword:Object.keys(ih),type:"string",schemaType:"string",$data:!0,error:PH1,code($){let{gen:K,data:q,schemaCode:Y,keyword:z,it:P}=$,{opts:J,self:W}=P;if(!J.validateFormats)return;let H=new zH1.KeywordCxt(P,W.RULES.all.format.definition,"format");if(H.$data)Z();else O();function Z(){let X=K.scopeValue("formats",{ref:W.formats,code:J.code.formats}),T=K.const("fmt",x9._`${X}[${H.schemaCode}]`);$.fail$data(x9.or(x9._`typeof ${T} != "object"`,x9._`${T} instanceof RegExp`,x9._`typeof ${T}.compare != "function"`,w(T)))}function O(){let X=H.schema,T=W.formats[X];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${z}": format "${X}" does not define "compare" function`);let G=K.scopeValue("formats",{key:X,ref:T,code:J.code.formats?x9._`${J.code.formats}${x9.getProperty(X)}`:void 0});$.fail$data(w(G))}function w(X){return x9._`${X}.compare(${q}, ${Y}) ${ih[z].fail} 0`}},dependencies:["format"]};var JH1=($)=>{return $.addKeyword(kl8.formatLimitDefinition),$};kl8.default=JH1});var Rl8=j((kv,Cl8)=>{Object.defineProperty(kv,"__esModule",{value:!0});var cZ=Vl8(),HH1=Ml8(),QF=O6(),Nl8=new QF.Name("fullFormats"),ZH1=new QF.Name("fastFormats"),dF=($,K={keywords:!0})=>{if(Array.isArray(K))return hl8($,K,cZ.fullFormats,Nl8),$;let[q,Y]=K.mode==="fast"?[cZ.fastFormats,ZH1]:[cZ.fullFormats,Nl8],z=K.formats||cZ.formatNames;if(hl8($,z,q,Y),K.keywords)HH1.default($);return $};dF.get=($,K="full")=>{let Y=(K==="fast"?cZ.fastFormats:cZ.fullFormats)[$];if(!Y)throw new Error(`Unknown format "${$}"`);return Y};function hl8($,K,q,Y){var z,P;(z=(P=$.opts.code).formats)!==null&&z!==void 0||(P.formats=QF._`require("ajv-formats/dist/formats").${Y}`);for(let J of K)$.addFormat(J,q[J])}Cl8.exports=kv=dF;Object.defineProperty(kv,"__esModule",{value:!0});kv.default=dF});import Pi from"path";import{fileURLToPath as iZ1}from"url";import{homedir as QZ1}from"os";var zi=K1(TD(),1),rF8=K1(X$(),1);var zu8=K1(X$(),1);function x$($){return typeof $==="undefined"||$===void 0}function f1($){return typeof $==="string"}function Hq($){return typeof $==="number"}function tY($){return typeof $==="boolean"}function qJ($){return $===null}function Et($){return $ instanceof Date}function YJ($){return typeof $==="bigint"}function A1($){return typeof $==="function"}function M4($){return typeof $==="object"&&$!==null}function Lt($){return $[$.length-1]}function k($){return Object.freeze($)}function QO($){if(j3($))return $;else return[$]}function j3($){return Array.isArray($)}function l3($){return $}var x6=k({is($){return $.kind==="AlterTableNode"},create($){return k({kind:"AlterTableNode",table:$})},cloneWithTableProps($,K){return k({...$,...K})},cloneWithColumnAlteration($,K){return k({...$,columnAlterations:$.columnAlterations?[...$.columnAlterations,K]:[K]})}});var p8=k({is($){return $.kind==="IdentifierNode"},create($){return k({kind:"IdentifierNode",name:$})}});var c7=k({is($){return $.kind==="CreateIndexNode"},create($){return k({kind:"CreateIndexNode",name:p8.create($)})},cloneWith($,K){return k({...$,...K})},cloneWithColumns($,K){return k({...$,columns:[...$.columns||[],...K]})}});var aG=k({is($){return $.kind==="CreateSchemaNode"},create($,K){return k({kind:"CreateSchemaNode",schema:p8.create($),...K})},cloneWith($,K){return k({...$,...K})}});var It=["preserve rows","delete rows","drop"],v3=k({is($){return $.kind==="CreateTableNode"},create($){return k({kind:"CreateTableNode",table:$,columns:k([])})},cloneWithColumn($,K){return k({...$,columns:k([...$.columns,K])})},cloneWithConstraint($,K){return k({...$,constraints:$.constraints?k([...$.constraints,K]):k([K])})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):k([K])})},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):k([K])})},cloneWith($,K){return k({...$,...K})}});var G3=k({is($){return $.kind==="SchemableIdentifierNode"},create($){return k({kind:"SchemableIdentifierNode",identifier:p8.create($)})},createWithSchema($,K){return k({kind:"SchemableIdentifierNode",schema:p8.create($),identifier:p8.create(K)})}});var Zq=k({is($){return $.kind==="DropIndexNode"},create($,K){return k({kind:"DropIndexNode",name:G3.create($),...K})},cloneWith($,K){return k({...$,...K})}});var dO=k({is($){return $.kind==="DropSchemaNode"},create($,K){return k({kind:"DropSchemaNode",schema:p8.create($),...K})},cloneWith($,K){return k({...$,...K})}});var nO=k({is($){return $.kind==="DropTableNode"},create($,K){return k({kind:"DropTableNode",table:$,...K})},cloneWith($,K){return k({...$,...K})}});var i4=k({is($){return $.kind==="AliasNode"},create($,K){return k({kind:"AliasNode",node:$,alias:K})}});var b$=k({is($){return $.kind==="TableNode"},create($){return k({kind:"TableNode",table:G3.create($)})},createWithSchema($,K){return k({kind:"TableNode",table:G3.createWithSchema($,K)})}});function w1($){return M4($)&&A1($.toOperationNode)}function rG($){return M4($)&&"expressionType"in $&&w1($)}function xt($){return M4($)&&"expression"in $&&f1($.alias)&&w1($)}var U9=k({is($){return $.kind==="SelectModifierNode"},create($,K){return k({kind:"SelectModifierNode",modifier:$,of:K})},createWithExpression($){return k({kind:"SelectModifierNode",rawModifier:$})}});var T$=k({is($){return $.kind==="AndNode"},create($,K){return k({kind:"AndNode",left:$,right:K})}});var B7=k({is($){return $.kind==="OrNode"},create($,K){return k({kind:"OrNode",left:$,right:K})}});var sG=k({is($){return $.kind==="OnNode"},create($){return k({kind:"OnNode",on:$})},cloneWithOperation($,K,q){return k({...$,on:K==="And"?T$.create($.on,q):B7.create($.on,q)})}});var U7=k({is($){return $.kind==="JoinNode"},create($,K){return k({kind:"JoinNode",joinType:$,table:K,on:void 0})},createWithOn($,K,q){return k({kind:"JoinNode",joinType:$,table:K,on:sG.create(q)})},cloneWithOn($,K){return k({...$,on:$.on?sG.cloneWithOperation($.on,"And",K):sG.create(K)})}});var Oq=k({is($){return $.kind==="BinaryOperationNode"},create($,K,q){return k({kind:"BinaryOperationNode",leftOperand:$,operator:K,rightOperand:q})}});var K46=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],q46=["+","-","*","/","%","^","&","|","#","<<",">>"],bt=["->","->>"],Y46=[...K46,...q46,"&&","||"],z46=["exists","not exists"],P46=["not","-",...z46],gt=[...Y46,...bt,...P46,"between","between symmetric"],g$=k({is($){return $.kind==="OperatorNode"},create($){return k({kind:"OperatorNode",operator:$})}});function GD($){return f1($)&&bt.includes($)}var R6=k({is($){return $.kind==="ColumnNode"},create($){return k({kind:"ColumnNode",column:p8.create($)})}});var zJ=k({is($){return $.kind==="SelectAllNode"},create(){return k({kind:"SelectAllNode"})}});var PJ=k({is($){return $.kind==="ReferenceNode"},create($,K){return k({kind:"ReferenceNode",table:K,column:$})},createSelectAll($){return k({kind:"ReferenceNode",table:$,column:zJ.create()})}});class _D{#$;get dynamicReference(){return this.#$}get refType(){return}constructor($){this.#$=$}toOperationNode(){return fD(this.#$)}}function tG($){return M4($)&&w1($)&&f1($.dynamicReference)}var l7=k({is($){return $.kind==="OrderByItemNode"},create($,K){return k({kind:"OrderByItemNode",orderBy:$,direction:K})},cloneWith($,K){return k({...$,...K})}});var b6=k({is($){return $.kind==="RawNode"},create($,K){return k({kind:"RawNode",sqlFragments:k($),parameters:k(K)})},createWithSql($){return b6.create([$],[])},createWithChild($){return b6.create(["",""],[$])},createWithChildren($){return b6.create(new Array($.length+1).fill(""),$)}});var yt={is($){return $.kind==="CollateNode"},create($){return k({kind:"CollateNode",collation:p8.create($)})}};class wq{#$;constructor($){this.#$=k($)}desc(){return new wq({node:l7.cloneWith(this.#$.node,{direction:b6.createWithSql("desc")})})}asc(){return new wq({node:l7.cloneWith(this.#$.node,{direction:b6.createWithSql("asc")})})}nullsLast(){return new wq({node:l7.cloneWith(this.#$.node,{nulls:"last"})})}nullsFirst(){return new wq({node:l7.cloneWith(this.#$.node,{nulls:"first"})})}collate($){return new wq({node:l7.cloneWith(this.#$.node,{collation:yt.create($)})})}toOperationNode(){return this.#$.node}}var ut=new Set;function l9($){if(ut.has($))return;ut.add($),console.log($)}function VD($){return $==="asc"||$==="desc"}function u$($){if($.length===2)return[AD($[0],$[1])];if($.length===1){let[K]=$;if(Array.isArray(K))return l9("orderBy(array) is deprecated, use multiple orderBy calls instead."),K.map((q)=>AD(q));return[AD(K)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${$.length}`)}function AD($,K){let q=J46($);if(l7.is(q)){if(K)throw new Error("Cannot specify direction twice!");return q}return mt(q,K)}function J46($){if(n5($))return j$($);if(tG($))return $.toOperationNode();let[K,q]=$.split(" ");if(q)return l9("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),mt(y$(K),q);return y$($)}function mt($,K){if(typeof K==="string"){if(!VD(K))throw new Error(`Invalid order by direction: ${K}`);return l7.create($,b6.createWithSql(K))}if(rG(K))return l9("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),l7.create($,K.toOperationNode());let q=l7.create($);if(!K)return q;return K(new wq({node:q})).toOperationNode()}var JJ=k({is($){return $.kind==="JSONReferenceNode"},create($,K){return k({kind:"JSONReferenceNode",reference:$,traversal:K})},cloneWithTraversal($,K){return k({...$,traversal:K})}});var eG=k({is($){return $.kind==="JSONOperatorChainNode"},create($){return k({kind:"JSONOperatorChainNode",operator:$,values:k([])})},cloneWithValue($,K){return k({...$,values:k([...$.values,K])})}});var Xq=k({is($){return $.kind==="JSONPathNode"},create($){return k({kind:"JSONPathNode",inOperator:$,pathLegs:k([])})},cloneWithLeg($,K){return k({...$,pathLegs:k([...$.pathLegs,K])})}});function fD($){if(f1($))return y$($);return $.toOperationNode()}function o5($){if(j3($))return $.map((K)=>s4(K));else return[s4($)]}function s4($){if(n5($))return j$($);return fD($)}function pt($,K){let q=y$($);if(GD(K))return JJ.create(q,eG.create(g$.create(K)));let Y=K.slice(0,-1);if(GD(Y))return JJ.create(q,Xq.create(g$.create(Y)));throw new Error(`Invalid JSON operator: ${K}`)}function y$($){if(!$.includes("."))return PJ.create(R6.create($));let q=$.split(".").map(MD);if(q.length===3)return W46(q);if(q.length===2)return H46(q);throw new Error(`invalid column reference ${$}`)}function ct($){if($.includes(" as ")){let[q,Y]=$.split(" as ").map(MD);return i4.create(y$(q),p8.create(Y))}else return y$($)}function kD($){return R6.create($)}function WJ($){if($.includes(" ")){let[q,Y]=$.split(" ").map(MD);if(!VD(Y))throw new Error(`invalid order direction "${Y}" next to "${q}"`);return u$([q,Y])[0]}else return kD($)}function W46($){let[K,q,Y]=$;return PJ.create(R6.create(Y),b$.createWithSchema(K,q))}function H46($){let[K,q]=$;return PJ.create(R6.create(q),b$.create(K))}function MD($){return $.trim()}var $0=k({is($){return $.kind==="PrimitiveValueListNode"},create($){return k({kind:"PrimitiveValueListNode",values:k([...$])})}});var Tq=k({is($){return $.kind==="ValueListNode"},create($){return k({kind:"ValueListNode",values:k($)})}});var G4=k({is($){return $.kind==="ValueNode"},create($){return k({kind:"ValueNode",value:$})},createImmediate($){return k({kind:"ValueNode",value:$,immediate:!0})}});function Bt($){if(j3($))return Z46($);return q1($)}function q1($){if(n5($))return j$($);return G4.create($)}function K0($){return Hq($)||tY($)||qJ($)}function oO($){if(!K0($))throw new Error(`unsafe immediate value ${JSON.stringify($)}`);return G4.createImmediate($)}function Z46($){if($.some(n5))return Tq.create($.map((K)=>q1(K)));return $0.create($)}var m$=k({is($){return $.kind==="ParensNode"},create($){return k({kind:"ParensNode",node:$})}});function W1($){if($.length===3)return q0($[0],$[1],$[2]);else if($.length===1)return q1($[0]);throw new Error(`invalid arguments: ${JSON.stringify($)}`)}function q0($,K,q){if(O46(K)&<(q))return Oq.create(s4($),ND(K),G4.createImmediate(q));return Oq.create(s4($),ND(K),Bt(q))}function Q4($,K,q){return Oq.create(s4($),ND(K),s4(q))}function hD($,K){return HJ(Object.entries($).filter(([,q])=>!x$(q)).map(([q,Y])=>q0(q,lt(Y)?"is":"=",Y)),K)}function HJ($,K,q=!0){let Y=K==="and"?T$.create:B7.create;if($.length===0)return Oq.create(G4.createImmediate(1),g$.create("="),G4.createImmediate(K==="and"?1:0));let z=Ut($[0]);for(let P=1;P<$.length;++P)z=Y(z,Ut($[P]));if($.length>1&&q)return m$.create(z);return z}function O46($){return $==="is"||$==="is not"}function lt($){return qJ($)||tY($)}function ND($){if(f1($)&>.includes($))return g$.create($);if(w1($))return $.toOperationNode();throw new Error(`invalid operator ${JSON.stringify($)}`)}function Ut($){return w1($)?$.toOperationNode():$}var a5=k({is($){return $.kind==="OrderByNode"},create($){return k({kind:"OrderByNode",items:k([...$])})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var CD=k({is($){return $.kind==="PartitionByNode"},create($){return k({kind:"PartitionByNode",items:k($)})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var aO=k({is($){return $.kind==="OverNode"},create(){return k({kind:"OverNode"})},cloneWithOrderByItems($,K){return k({...$,orderBy:$.orderBy?a5.cloneWithItems($.orderBy,K):a5.create(K)})},cloneWithPartitionByItems($,K){return k({...$,partitionBy:$.partitionBy?CD.cloneWithItems($.partitionBy,K):CD.create(K)})}});var eY=k({is($){return $.kind==="FromNode"},create($){return k({kind:"FromNode",froms:k($)})},cloneWithFroms($,K){return k({...$,froms:k([...$.froms,...K])})}});var RD=k({is($){return $.kind==="GroupByNode"},create($){return k({kind:"GroupByNode",items:k($)})},cloneWithItems($,K){return k({...$,items:k([...$.items,...K])})}});var DD=k({is($){return $.kind==="HavingNode"},create($){return k({kind:"HavingNode",having:$})},cloneWithOperation($,K,q){return k({...$,having:K==="And"?T$.create($.having,q):B7.create($.having,q)})}});var i1=k({is($){return $.kind==="InsertQueryNode"},create($,K,q){return k({kind:"InsertQueryNode",into:$,...K&&{with:K},replace:q})},createWithoutInto(){return k({kind:"InsertQueryNode"})},cloneWith($,K){return k({...$,...K})}});var Y0=k({is($){return $.kind==="ListNode"},create($){return k({kind:"ListNode",items:k($)})}});var F9=k({is($){return $.kind==="UpdateQueryNode"},create($,K){return k({kind:"UpdateQueryNode",table:$.length===1?$[0]:Y0.create($),...K&&{with:K}})},createWithoutTable(){return k({kind:"UpdateQueryNode"})},cloneWithFromItems($,K){return k({...$,from:$.from?eY.cloneWithFroms($.from,K):eY.create(K)})},cloneWithUpdates($,K){return k({...$,updates:$.updates?k([...$.updates,...K]):K})},cloneWithLimit($,K){return k({...$,limit:K})}});var SD=k({is($){return $.kind==="UsingNode"},create($){return k({kind:"UsingNode",tables:k($)})},cloneWithTables($,K){return k({...$,tables:k([...$.tables,...K])})}});var jq=k({is($){return $.kind==="DeleteQueryNode"},create($,K){return k({kind:"DeleteQueryNode",from:eY.create($),...K&&{with:K}})},cloneWithOrderByItems:($,K)=>C8.cloneWithOrderByItems($,K),cloneWithoutOrderBy:($)=>C8.cloneWithoutOrderBy($),cloneWithLimit($,K){return k({...$,limit:K})},cloneWithoutLimit($){return k({...$,limit:void 0})},cloneWithUsing($,K){return k({...$,using:$.using!==void 0?SD.cloneWithTables($.using,K):SD.create(K)})}});var t4=k({is($){return $.kind==="WhereNode"},create($){return k({kind:"WhereNode",where:$})},cloneWithOperation($,K,q){return k({...$,where:K==="And"?T$.create($.where,q):B7.create($.where,q)})}});var ED=k({is($){return $.kind==="ReturningNode"},create($){return k({kind:"ReturningNode",selections:k($)})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})}});var Ft=k({is($){return $.kind==="ExplainNode"},create($,K){return k({kind:"ExplainNode",format:$,options:K})}});var Y7=k({is($){return $.kind==="WhenNode"},create($){return k({kind:"WhenNode",condition:$})},cloneWithResult($,K){return k({...$,result:K})}});var p$=k({is($){return $.kind==="MergeQueryNode"},create($,K){return k({kind:"MergeQueryNode",into:$,...K&&{with:K}})},cloneWithUsing($,K){return k({...$,using:K})},cloneWithWhen($,K){return k({...$,whens:$.whens?k([...$.whens,K]):k([K])})},cloneWithThen($,K){return k({...$,whens:$.whens?k([...$.whens.slice(0,-1),Y7.cloneWithResult($.whens[$.whens.length-1],K)]):void 0})}});var LD=k({is($){return $.kind==="OutputNode"},create($){return k({kind:"OutputNode",selections:k($)})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})}});var C8=k({is($){return m6.is($)||i1.is($)||F9.is($)||jq.is($)||p$.is($)},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):k([K])})},cloneWithWhere($,K){return k({...$,where:$.where?t4.cloneWithOperation($.where,"And",K):t4.create(K)})},cloneWithJoin($,K){return k({...$,joins:$.joins?k([...$.joins,K]):k([K])})},cloneWithReturning($,K){return k({...$,returning:$.returning?ED.cloneWithSelections($.returning,K):ED.create(K)})},cloneWithoutReturning($){return k({...$,returning:void 0})},cloneWithoutWhere($){return k({...$,where:void 0})},cloneWithExplain($,K,q){return k({...$,explain:Ft.create(K,q?.toOperationNode())})},cloneWithTop($,K){return k({...$,top:K})},cloneWithOutput($,K){return k({...$,output:$.output?LD.cloneWithSelections($.output,K):LD.create(K)})},cloneWithOrderByItems($,K){return k({...$,orderBy:$.orderBy?a5.cloneWithItems($.orderBy,K):a5.create(K)})},cloneWithoutOrderBy($){return k({...$,orderBy:void 0})}});var m6=k({is($){return $.kind==="SelectQueryNode"},create($){return k({kind:"SelectQueryNode",...$&&{with:$}})},createFrom($,K){return k({kind:"SelectQueryNode",from:eY.create($),...K&&{with:K}})},cloneWithSelections($,K){return k({...$,selections:$.selections?k([...$.selections,...K]):k(K)})},cloneWithDistinctOn($,K){return k({...$,distinctOn:$.distinctOn?k([...$.distinctOn,...K]):k(K)})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):k([K])})},cloneWithOrderByItems:($,K)=>C8.cloneWithOrderByItems($,K),cloneWithGroupByItems($,K){return k({...$,groupBy:$.groupBy?RD.cloneWithItems($.groupBy,K):RD.create(K)})},cloneWithLimit($,K){return k({...$,limit:K})},cloneWithOffset($,K){return k({...$,offset:K})},cloneWithFetch($,K){return k({...$,fetch:K})},cloneWithHaving($,K){return k({...$,having:$.having?DD.cloneWithOperation($.having,"And",K):DD.create(K)})},cloneWithSetOperations($,K){return k({...$,setOperations:$.setOperations?k([...$.setOperations,...K]):k([...K])})},cloneWithoutSelections($){return k({...$,selections:[]})},cloneWithoutLimit($){return k({...$,limit:void 0})},cloneWithoutOffset($){return k({...$,offset:void 0})},cloneWithoutOrderBy:($)=>C8.cloneWithoutOrderBy($),cloneWithoutGroupBy($){return k({...$,groupBy:void 0})}});class ZJ{#$;constructor($){this.#$=k($)}on(...$){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,W1($))})}onRef($,K,q){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,Q4($,K,q))})}onTrue(){return new ZJ({...this.#$,joinNode:U7.cloneWithOn(this.#$.joinNode,b6.createWithSql("true"))})}$call($){return $(this)}toOperationNode(){return this.#$.joinNode}}var it=k({is($){return $.kind==="PartitionByItemNode"},create($){return k({kind:"PartitionByItemNode",partitionBy:$})}});function Qt($){return o5($).map(it.create)}class OJ{#$;constructor($){this.#$=k($)}orderBy(...$){return new OJ({overNode:aO.cloneWithOrderByItems(this.#$.overNode,u$($))})}clearOrderBy(){return new OJ({overNode:C8.cloneWithoutOrderBy(this.#$.overNode)})}partitionBy($){return new OJ({overNode:aO.cloneWithPartitionByItems(this.#$.overNode,Qt($))})}$call($){return $(this)}toOperationNode(){return this.#$.overNode}}var wJ=k({is($){return $.kind==="SelectionNode"},create($){return k({kind:"SelectionNode",selection:$})},createSelectAll(){return k({kind:"SelectionNode",selection:zJ.create()})},createSelectAllFromTable($){return k({kind:"SelectionNode",selection:PJ.createSelectAll($)})}});function N4($){if(A1($))return N4($(F7()));else if(j3($))return $.map((K)=>dt(K));else return[dt($)]}function dt($){if(f1($))return wJ.create(ct($));else if(tG($))return wJ.create($.toOperationNode());else return wJ.create(z0($))}function d4($){if(!$)return[wJ.createSelectAll()];else if(Array.isArray($))return $.map(nt);else return[nt($)]}function nt($){if(f1($))return wJ.createSelectAllFromTable(g6($));throw new Error(`invalid value selectAll expression: ${JSON.stringify($)}`)}var ot=k({is($){return $.kind==="ValuesNode"},create($){return k({kind:"ValuesNode",values:k($)})}});var at=k({is($){return $.kind==="DefaultInsertValueNode"},create(){return k({kind:"DefaultInsertValueNode"})}});function P0($){let K=A1($)?$(F7()):$,q=j3(K)?K:k([K]);return w46(q)}function w46($){let K=X46($);return[k([...K.keys()].map(R6.create)),ot.create($.map((q)=>T46(q,K)))]}function X46($){let K=new Map;for(let q of $){let Y=Object.keys(q);for(let z of Y)if(!K.has(z)&&q[z]!==void 0)K.set(z,K.size)}return K}function T46($,K){let q=Object.keys($),Y=Array.from({length:K.size}),z=!1,P=q.length;for(let W of q){let H=K.get(W);if(x$(H)){P--;continue}let Z=$[W];if(x$(Z)||n5(Z))z=!0;Y[H]=Z}if(P<K.size||z){let W=at.create();return Tq.create(Y.map((H)=>x$(H)?W:q1(H)))}return $0.create(Y)}var ID=k({is($){return $.kind==="ColumnUpdateNode"},create($,K){return k({kind:"ColumnUpdateNode",column:$,value:K})}});function rt(...$){if($.length===2)return[ID.create(s4($[0]),q1($[1]))];return rO($[0])}function rO($){let K=A1($)?$(F7()):$;return Object.entries(K).filter(([q,Y])=>Y!==void 0).map(([q,Y])=>{return ID.create(R6.create(q),q1(Y))})}var st=k({is($){return $.kind==="OnDuplicateKeyNode"},create($){return k({kind:"OnDuplicateKeyNode",updates:$})}});class xD{insertId;numInsertedOrUpdatedRows;constructor($,K){this.insertId=$,this.numInsertedOrUpdatedRows=K}}class i7 extends Error{node;constructor($){super("no result");this.node=$}}function i9($){return Object.prototype.hasOwnProperty.call($,"prototype")}var F3=k({is($){return $.kind==="OnConflictNode"},create(){return k({kind:"OnConflictNode"})},cloneWith($,K){return k({...$,...K})},cloneWithIndexWhere($,K){return k({...$,indexWhere:$.indexWhere?t4.cloneWithOperation($.indexWhere,"And",K):t4.create(K)})},cloneWithIndexOrWhere($,K){return k({...$,indexWhere:$.indexWhere?t4.cloneWithOperation($.indexWhere,"Or",K):t4.create(K)})},cloneWithUpdateWhere($,K){return k({...$,updateWhere:$.updateWhere?t4.cloneWithOperation($.updateWhere,"And",K):t4.create(K)})},cloneWithUpdateOrWhere($,K){return k({...$,updateWhere:$.updateWhere?t4.cloneWithOperation($.updateWhere,"Or",K):t4.create(K)})},cloneWithoutIndexWhere($){return k({...$,indexWhere:void 0})},cloneWithoutUpdateWhere($){return k({...$,updateWhere:void 0})}});class Q9{#$;constructor($){this.#$=k($)}column($){let K=R6.create($);return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{columns:this.#$.onConflictNode.columns?k([...this.#$.onConflictNode.columns,K]):k([K])})})}columns($){let K=$.map(R6.create);return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{columns:this.#$.onConflictNode.columns?k([...this.#$.onConflictNode.columns,...K]):k(K)})})}constraint($){return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{constraint:p8.create($)})})}expression($){return new Q9({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{indexExpression:$.toOperationNode()})})}where(...$){return new Q9({...this.#$,onConflictNode:F3.cloneWithIndexWhere(this.#$.onConflictNode,W1($))})}whereRef($,K,q){return new Q9({...this.#$,onConflictNode:F3.cloneWithIndexWhere(this.#$.onConflictNode,Q4($,K,q))})}clearWhere(){return new Q9({...this.#$,onConflictNode:F3.cloneWithoutIndexWhere(this.#$.onConflictNode)})}doNothing(){return new tt({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{doNothing:!0})})}doUpdateSet($){return new sO({...this.#$,onConflictNode:F3.cloneWith(this.#$.onConflictNode,{updates:rO($)})})}$call($){return $(this)}}class tt{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.onConflictNode}}class sO{#$;constructor($){this.#$=k($)}where(...$){return new sO({...this.#$,onConflictNode:F3.cloneWithUpdateWhere(this.#$.onConflictNode,W1($))})}whereRef($,K,q){return new sO({...this.#$,onConflictNode:F3.cloneWithUpdateWhere(this.#$.onConflictNode,Q4($,K,q))})}clearWhere(){return new sO({...this.#$,onConflictNode:F3.cloneWithoutUpdateWhere(this.#$.onConflictNode)})}$call($){return $(this)}toOperationNode(){return this.#$.onConflictNode}}var et=k({is($){return $.kind==="TopNode"},create($,K){return k({kind:"TopNode",expression:$,modifiers:K})}});function Q7($,K){if(!Hq($)&&!YJ($))throw new Error(`Invalid top expression: ${$}`);if(!x$(K)&&!j46(K))throw new Error(`Invalid top modifiers: ${K}`);return et.create($,K)}function j46($){return $==="percent"||$==="with ties"||$==="percent with ties"}var $z=k({is($){return $.kind==="OrActionNode"},create($){return k({kind:"OrActionNode",action:$})}});class Y1{#$;constructor($){this.#$=k($)}values($){let[K,q]=P0($);return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{columns:K,values:q})})}columns($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{columns:k($.map(R6.create))})})}expression($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{values:j$($)})})}defaultValues(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{defaultValues:!0})})}modifyEnd($){return new Y1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}ignore(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("ignore")})})}orIgnore(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("ignore")})})}orAbort(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("abort")})})}orFail(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("fail")})})}orReplace(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("replace")})})}orRollback(){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{orAction:$z.create("rollback")})})}top($,K){return new Y1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}onConflict($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{onConflict:$(new Q9({onConflictNode:F3.create()})).toOperationNode()})})}onDuplicateKeyUpdate($){return new Y1({...this.#$,queryNode:i1.cloneWith(this.#$.queryNode,{onDuplicateKey:st.create(rO($))})})}returning($){return new Y1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll(){return new Y1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4())})}output($){return new Y1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new Y1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}clearReturning(){return new Y1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new Y1({...this.#$})}$castTo(){return new Y1(this.#$)}$narrowType(){return new Y1(this.#$)}$assertType(){return new Y1(this.#$)}withPlugin($){return new Y1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new xD(K.insertId,K.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new Y1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}class bD{numDeletedRows;constructor($){this.numDeletedRows=$}}var XJ=k({is($){return $.kind==="LimitNode"},create($){return k({kind:"LimitNode",limit:$})}});class M1{#$;constructor($){this.#$=k($)}where(...$){return new M1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new M1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}clearWhere(){return new M1({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}top($,K){return new M1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}using($){return new M1({...this.#$,queryNode:jq.cloneWithUsing(this.#$.queryNode,d7($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}#K($,K){return new M1({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}returning($){return new M1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new M1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new M1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new M1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}clearReturning(){return new M1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}clearLimit(){return new M1({...this.#$,queryNode:jq.cloneWithoutLimit(this.#$.queryNode)})}orderBy(...$){return new M1({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}clearOrderBy(){return new M1({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}limit($){return new M1({...this.#$,queryNode:jq.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}modifyEnd($){return new M1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}$call($){return $(this)}$if($,K){if($)return K(this);return new M1({...this.#$})}$castTo(){return new M1(this.#$)}$narrowType(){return new M1(this.#$)}$assertType(){return new M1(this.#$)}withPlugin($){return new M1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new bD(K.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new M1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}class gD{numUpdatedRows;numChangedRows;constructor($,K){this.numUpdatedRows=$,this.numChangedRows=K}}class X1{#$;constructor($){this.#$=k($)}where(...$){return new X1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new X1({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}clearWhere(){return new X1({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}top($,K){return new X1({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}from($){return new X1({...this.#$,queryNode:F9.cloneWithFromItems(this.#$.queryNode,d7($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}#K($,K){return new X1({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}orderBy(...$){return new X1({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}clearOrderBy(){return new X1({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}limit($){return new X1({...this.#$,queryNode:F9.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}set(...$){return new X1({...this.#$,queryNode:F9.cloneWithUpdates(this.#$.queryNode,rt(...$))})}returning($){return new X1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new X1({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new X1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new X1({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}modifyEnd($){return new X1({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}clearReturning(){return new X1({...this.#$,queryNode:C8.cloneWithoutReturning(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new X1({...this.#$})}$castTo(){return new X1(this.#$)}$narrowType(){return new X1(this.#$)}$assertType(){return new X1(this.#$)}withPlugin($){return new X1({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new gD(K.numAffectedRows??BigInt(0),K.numChangedRows)]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new X1({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}var yD=k({is($){return $.kind==="CommonTableExpressionNameNode"},create($,K){return k({kind:"CommonTableExpressionNameNode",table:b$.create($),columns:K?k(K.map(R6.create)):void 0})}});var TJ=k({is($){return $.kind==="CommonTableExpressionNode"},create($,K){return k({kind:"CommonTableExpressionNode",name:$,expression:K})},cloneWith($,K){return k({...$,...K})}});class tO{#$;constructor($){this.#$=k($)}materialized(){return new tO({...this.#$,node:TJ.cloneWith(this.#$.node,{materialized:!0})})}notMaterialized(){return new tO({...this.#$,node:TJ.cloneWith(this.#$.node,{materialized:!1})})}toOperationNode(){return this.#$.node}}function uD($,K){let q=K(Ke()).toOperationNode();if(A1($))return $(v46(q)).toOperationNode();return TJ.create($e($),q)}function v46($){return(K)=>{return new tO({node:TJ.create($e(K),$)})}}function $e($){if($.includes("(")){let K=$.split(/[\(\)]/),q=K[0],Y=K[1].split(",").map((z)=>z.trim());return yD.create(q,Y)}else return yD.create($)}var eO=k({is($){return $.kind==="WithNode"},create($,K){return k({kind:"WithNode",expressions:k([$]),...K})},cloneWithExpression($,K){return k({...$,expressions:k([...$.expressions,K])})}});var qe=["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","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","0","1","2","3","4","5","6","7","8","9"];function Ye($){let K="";for(let q=0;q<$;++q)K+=G46();return K}function G46(){return qe[~~(Math.random()*qe.length)]}function $6(){return new ze}class ze{#$;get queryId(){if(this.#$===void 0)this.#$=Ye(8);return this.#$}}function _8($){return $}class $w{nodeStack=[];#$=k({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode($,K){if(!$)return $;this.nodeStack.push($);let q=this.transformNodeImpl($,K);return this.nodeStack.pop(),k(q)}transformNodeImpl($,K){return this.#$[$.kind]($,K)}transformNodeList($,K){if(!$)return $;return k($.map((q)=>this.transformNode(q,K)))}transformSelectQuery($,K){return _8({kind:"SelectQueryNode",from:this.transformNode($.from,K),selections:this.transformNodeList($.selections,K),distinctOn:this.transformNodeList($.distinctOn,K),joins:this.transformNodeList($.joins,K),groupBy:this.transformNode($.groupBy,K),orderBy:this.transformNode($.orderBy,K),where:this.transformNode($.where,K),frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),limit:this.transformNode($.limit,K),offset:this.transformNode($.offset,K),with:this.transformNode($.with,K),having:this.transformNode($.having,K),explain:this.transformNode($.explain,K),setOperations:this.transformNodeList($.setOperations,K),fetch:this.transformNode($.fetch,K),top:this.transformNode($.top,K)})}transformSelection($,K){return _8({kind:"SelectionNode",selection:this.transformNode($.selection,K)})}transformColumn($,K){return _8({kind:"ColumnNode",column:this.transformNode($.column,K)})}transformAlias($,K){return _8({kind:"AliasNode",node:this.transformNode($.node,K),alias:this.transformNode($.alias,K)})}transformTable($,K){return _8({kind:"TableNode",table:this.transformNode($.table,K)})}transformFrom($,K){return _8({kind:"FromNode",froms:this.transformNodeList($.froms,K)})}transformReference($,K){return _8({kind:"ReferenceNode",column:this.transformNode($.column,K),table:this.transformNode($.table,K)})}transformAnd($,K){return _8({kind:"AndNode",left:this.transformNode($.left,K),right:this.transformNode($.right,K)})}transformOr($,K){return _8({kind:"OrNode",left:this.transformNode($.left,K),right:this.transformNode($.right,K)})}transformValueList($,K){return _8({kind:"ValueListNode",values:this.transformNodeList($.values,K)})}transformParens($,K){return _8({kind:"ParensNode",node:this.transformNode($.node,K)})}transformJoin($,K){return _8({kind:"JoinNode",joinType:$.joinType,table:this.transformNode($.table,K),on:this.transformNode($.on,K)})}transformRaw($,K){return _8({kind:"RawNode",sqlFragments:k([...$.sqlFragments]),parameters:this.transformNodeList($.parameters,K)})}transformWhere($,K){return _8({kind:"WhereNode",where:this.transformNode($.where,K)})}transformInsertQuery($,K){return _8({kind:"InsertQueryNode",into:this.transformNode($.into,K),columns:this.transformNodeList($.columns,K),values:this.transformNode($.values,K),returning:this.transformNode($.returning,K),onConflict:this.transformNode($.onConflict,K),onDuplicateKey:this.transformNode($.onDuplicateKey,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),ignore:$.ignore,orAction:this.transformNode($.orAction,K),replace:$.replace,explain:this.transformNode($.explain,K),defaultValues:$.defaultValues,top:this.transformNode($.top,K),output:this.transformNode($.output,K)})}transformValues($,K){return _8({kind:"ValuesNode",values:this.transformNodeList($.values,K)})}transformDeleteQuery($,K){return _8({kind:"DeleteQueryNode",from:this.transformNode($.from,K),using:this.transformNode($.using,K),joins:this.transformNodeList($.joins,K),where:this.transformNode($.where,K),returning:this.transformNode($.returning,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),orderBy:this.transformNode($.orderBy,K),limit:this.transformNode($.limit,K),explain:this.transformNode($.explain,K),top:this.transformNode($.top,K),output:this.transformNode($.output,K)})}transformReturning($,K){return _8({kind:"ReturningNode",selections:this.transformNodeList($.selections,K)})}transformCreateTable($,K){return _8({kind:"CreateTableNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),constraints:this.transformNodeList($.constraints,K),temporary:$.temporary,ifNotExists:$.ifNotExists,onCommit:$.onCommit,frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),selectQuery:this.transformNode($.selectQuery,K)})}transformColumnDefinition($,K){return _8({kind:"ColumnDefinitionNode",column:this.transformNode($.column,K),dataType:this.transformNode($.dataType,K),references:this.transformNode($.references,K),primaryKey:$.primaryKey,autoIncrement:$.autoIncrement,unique:$.unique,notNull:$.notNull,unsigned:$.unsigned,defaultTo:this.transformNode($.defaultTo,K),check:this.transformNode($.check,K),generated:this.transformNode($.generated,K),frontModifiers:this.transformNodeList($.frontModifiers,K),endModifiers:this.transformNodeList($.endModifiers,K),nullsNotDistinct:$.nullsNotDistinct,identity:$.identity,ifNotExists:$.ifNotExists})}transformAddColumn($,K){return _8({kind:"AddColumnNode",column:this.transformNode($.column,K)})}transformDropTable($,K){return _8({kind:"DropTableNode",table:this.transformNode($.table,K),ifExists:$.ifExists,cascade:$.cascade})}transformOrderBy($,K){return _8({kind:"OrderByNode",items:this.transformNodeList($.items,K)})}transformOrderByItem($,K){return _8({kind:"OrderByItemNode",orderBy:this.transformNode($.orderBy,K),direction:this.transformNode($.direction,K),collation:this.transformNode($.collation,K),nulls:$.nulls})}transformGroupBy($,K){return _8({kind:"GroupByNode",items:this.transformNodeList($.items,K)})}transformGroupByItem($,K){return _8({kind:"GroupByItemNode",groupBy:this.transformNode($.groupBy,K)})}transformUpdateQuery($,K){return _8({kind:"UpdateQueryNode",table:this.transformNode($.table,K),from:this.transformNode($.from,K),joins:this.transformNodeList($.joins,K),where:this.transformNode($.where,K),updates:this.transformNodeList($.updates,K),returning:this.transformNode($.returning,K),endModifiers:this.transformNodeList($.endModifiers,K),with:this.transformNode($.with,K),explain:this.transformNode($.explain,K),limit:this.transformNode($.limit,K),top:this.transformNode($.top,K),output:this.transformNode($.output,K),orderBy:this.transformNode($.orderBy,K)})}transformColumnUpdate($,K){return _8({kind:"ColumnUpdateNode",column:this.transformNode($.column,K),value:this.transformNode($.value,K)})}transformLimit($,K){return _8({kind:"LimitNode",limit:this.transformNode($.limit,K)})}transformOffset($,K){return _8({kind:"OffsetNode",offset:this.transformNode($.offset,K)})}transformOnConflict($,K){return _8({kind:"OnConflictNode",columns:this.transformNodeList($.columns,K),constraint:this.transformNode($.constraint,K),indexExpression:this.transformNode($.indexExpression,K),indexWhere:this.transformNode($.indexWhere,K),updates:this.transformNodeList($.updates,K),updateWhere:this.transformNode($.updateWhere,K),doNothing:$.doNothing})}transformOnDuplicateKey($,K){return _8({kind:"OnDuplicateKeyNode",updates:this.transformNodeList($.updates,K)})}transformCreateIndex($,K){return _8({kind:"CreateIndexNode",name:this.transformNode($.name,K),table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),unique:$.unique,using:this.transformNode($.using,K),ifNotExists:$.ifNotExists,where:this.transformNode($.where,K),nullsNotDistinct:$.nullsNotDistinct})}transformList($,K){return _8({kind:"ListNode",items:this.transformNodeList($.items,K)})}transformDropIndex($,K){return _8({kind:"DropIndexNode",name:this.transformNode($.name,K),table:this.transformNode($.table,K),ifExists:$.ifExists,cascade:$.cascade})}transformPrimaryKeyConstraint($,K){return _8({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList($.columns,K),name:this.transformNode($.name,K),deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformUniqueConstraint($,K){return _8({kind:"UniqueConstraintNode",columns:this.transformNodeList($.columns,K),name:this.transformNode($.name,K),nullsNotDistinct:$.nullsNotDistinct,deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformForeignKeyConstraint($,K){return _8({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList($.columns,K),references:this.transformNode($.references,K),name:this.transformNode($.name,K),onDelete:$.onDelete,onUpdate:$.onUpdate,deferrable:$.deferrable,initiallyDeferred:$.initiallyDeferred})}transformSetOperation($,K){return _8({kind:"SetOperationNode",operator:$.operator,expression:this.transformNode($.expression,K),all:$.all})}transformReferences($,K){return _8({kind:"ReferencesNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K),onDelete:$.onDelete,onUpdate:$.onUpdate})}transformCheckConstraint($,K){return _8({kind:"CheckConstraintNode",expression:this.transformNode($.expression,K),name:this.transformNode($.name,K)})}transformWith($,K){return _8({kind:"WithNode",expressions:this.transformNodeList($.expressions,K),recursive:$.recursive})}transformCommonTableExpression($,K){return _8({kind:"CommonTableExpressionNode",name:this.transformNode($.name,K),materialized:$.materialized,expression:this.transformNode($.expression,K)})}transformCommonTableExpressionName($,K){return _8({kind:"CommonTableExpressionNameNode",table:this.transformNode($.table,K),columns:this.transformNodeList($.columns,K)})}transformHaving($,K){return _8({kind:"HavingNode",having:this.transformNode($.having,K)})}transformCreateSchema($,K){return _8({kind:"CreateSchemaNode",schema:this.transformNode($.schema,K),ifNotExists:$.ifNotExists})}transformDropSchema($,K){return _8({kind:"DropSchemaNode",schema:this.transformNode($.schema,K),ifExists:$.ifExists,cascade:$.cascade})}transformAlterTable($,K){return _8({kind:"AlterTableNode",table:this.transformNode($.table,K),renameTo:this.transformNode($.renameTo,K),setSchema:this.transformNode($.setSchema,K),columnAlterations:this.transformNodeList($.columnAlterations,K),addConstraint:this.transformNode($.addConstraint,K),dropConstraint:this.transformNode($.dropConstraint,K),renameConstraint:this.transformNode($.renameConstraint,K),addIndex:this.transformNode($.addIndex,K),dropIndex:this.transformNode($.dropIndex,K)})}transformDropColumn($,K){return _8({kind:"DropColumnNode",column:this.transformNode($.column,K)})}transformRenameColumn($,K){return _8({kind:"RenameColumnNode",column:this.transformNode($.column,K),renameTo:this.transformNode($.renameTo,K)})}transformAlterColumn($,K){return _8({kind:"AlterColumnNode",column:this.transformNode($.column,K),dataType:this.transformNode($.dataType,K),dataTypeExpression:this.transformNode($.dataTypeExpression,K),setDefault:this.transformNode($.setDefault,K),dropDefault:$.dropDefault,setNotNull:$.setNotNull,dropNotNull:$.dropNotNull})}transformModifyColumn($,K){return _8({kind:"ModifyColumnNode",column:this.transformNode($.column,K)})}transformAddConstraint($,K){return _8({kind:"AddConstraintNode",constraint:this.transformNode($.constraint,K)})}transformDropConstraint($,K){return _8({kind:"DropConstraintNode",constraintName:this.transformNode($.constraintName,K),ifExists:$.ifExists,modifier:$.modifier})}transformRenameConstraint($,K){return _8({kind:"RenameConstraintNode",oldName:this.transformNode($.oldName,K),newName:this.transformNode($.newName,K)})}transformCreateView($,K){return _8({kind:"CreateViewNode",name:this.transformNode($.name,K),temporary:$.temporary,orReplace:$.orReplace,ifNotExists:$.ifNotExists,materialized:$.materialized,columns:this.transformNodeList($.columns,K),as:this.transformNode($.as,K)})}transformRefreshMaterializedView($,K){return _8({kind:"RefreshMaterializedViewNode",name:this.transformNode($.name,K),concurrently:$.concurrently,withNoData:$.withNoData})}transformDropView($,K){return _8({kind:"DropViewNode",name:this.transformNode($.name,K),ifExists:$.ifExists,materialized:$.materialized,cascade:$.cascade})}transformGenerated($,K){return _8({kind:"GeneratedNode",byDefault:$.byDefault,always:$.always,identity:$.identity,stored:$.stored,expression:this.transformNode($.expression,K)})}transformDefaultValue($,K){return _8({kind:"DefaultValueNode",defaultValue:this.transformNode($.defaultValue,K)})}transformOn($,K){return _8({kind:"OnNode",on:this.transformNode($.on,K)})}transformSelectModifier($,K){return _8({kind:"SelectModifierNode",modifier:$.modifier,rawModifier:this.transformNode($.rawModifier,K),of:this.transformNodeList($.of,K)})}transformCreateType($,K){return _8({kind:"CreateTypeNode",name:this.transformNode($.name,K),enum:this.transformNode($.enum,K)})}transformDropType($,K){return _8({kind:"DropTypeNode",name:this.transformNode($.name,K),ifExists:$.ifExists})}transformExplain($,K){return _8({kind:"ExplainNode",format:$.format,options:this.transformNode($.options,K)})}transformSchemableIdentifier($,K){return _8({kind:"SchemableIdentifierNode",schema:this.transformNode($.schema,K),identifier:this.transformNode($.identifier,K)})}transformAggregateFunction($,K){return _8({kind:"AggregateFunctionNode",func:$.func,aggregated:this.transformNodeList($.aggregated,K),distinct:$.distinct,orderBy:this.transformNode($.orderBy,K),withinGroup:this.transformNode($.withinGroup,K),filter:this.transformNode($.filter,K),over:this.transformNode($.over,K)})}transformOver($,K){return _8({kind:"OverNode",orderBy:this.transformNode($.orderBy,K),partitionBy:this.transformNode($.partitionBy,K)})}transformPartitionBy($,K){return _8({kind:"PartitionByNode",items:this.transformNodeList($.items,K)})}transformPartitionByItem($,K){return _8({kind:"PartitionByItemNode",partitionBy:this.transformNode($.partitionBy,K)})}transformBinaryOperation($,K){return _8({kind:"BinaryOperationNode",leftOperand:this.transformNode($.leftOperand,K),operator:this.transformNode($.operator,K),rightOperand:this.transformNode($.rightOperand,K)})}transformUnaryOperation($,K){return _8({kind:"UnaryOperationNode",operator:this.transformNode($.operator,K),operand:this.transformNode($.operand,K)})}transformUsing($,K){return _8({kind:"UsingNode",tables:this.transformNodeList($.tables,K)})}transformFunction($,K){return _8({kind:"FunctionNode",func:$.func,arguments:this.transformNodeList($.arguments,K)})}transformCase($,K){return _8({kind:"CaseNode",value:this.transformNode($.value,K),when:this.transformNodeList($.when,K),else:this.transformNode($.else,K),isStatement:$.isStatement})}transformWhen($,K){return _8({kind:"WhenNode",condition:this.transformNode($.condition,K),result:this.transformNode($.result,K)})}transformJSONReference($,K){return _8({kind:"JSONReferenceNode",reference:this.transformNode($.reference,K),traversal:this.transformNode($.traversal,K)})}transformJSONPath($,K){return _8({kind:"JSONPathNode",inOperator:this.transformNode($.inOperator,K),pathLegs:this.transformNodeList($.pathLegs,K)})}transformJSONPathLeg($,K){return _8({kind:"JSONPathLegNode",type:$.type,value:$.value})}transformJSONOperatorChain($,K){return _8({kind:"JSONOperatorChainNode",operator:this.transformNode($.operator,K),values:this.transformNodeList($.values,K)})}transformTuple($,K){return _8({kind:"TupleNode",values:this.transformNodeList($.values,K)})}transformMergeQuery($,K){return _8({kind:"MergeQueryNode",into:this.transformNode($.into,K),using:this.transformNode($.using,K),whens:this.transformNodeList($.whens,K),with:this.transformNode($.with,K),top:this.transformNode($.top,K),endModifiers:this.transformNodeList($.endModifiers,K),output:this.transformNode($.output,K),returning:this.transformNode($.returning,K)})}transformMatched($,K){return _8({kind:"MatchedNode",not:$.not,bySource:$.bySource})}transformAddIndex($,K){return _8({kind:"AddIndexNode",name:this.transformNode($.name,K),columns:this.transformNodeList($.columns,K),unique:$.unique,using:this.transformNode($.using,K),ifNotExists:$.ifNotExists})}transformCast($,K){return _8({kind:"CastNode",expression:this.transformNode($.expression,K),dataType:this.transformNode($.dataType,K)})}transformFetch($,K){return _8({kind:"FetchNode",rowCount:this.transformNode($.rowCount,K),modifier:$.modifier})}transformTop($,K){return _8({kind:"TopNode",expression:$.expression,modifiers:$.modifiers})}transformOutput($,K){return _8({kind:"OutputNode",selections:this.transformNodeList($.selections,K)})}transformDataType($,K){return $}transformSelectAll($,K){return $}transformIdentifier($,K){return $}transformValue($,K){return $}transformPrimitiveValueList($,K){return $}transformOperator($,K){return $}transformDefaultInsertValue($,K){return $}transformOrAction($,K){return $}transformCollate($,K){return $}}var _46=k({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),f46={json_agg:!0,to_json:!0};class mD extends $w{#$;#K=new Set;#q=new Set;constructor($){super();this.#$=$}transformNodeImpl($,K){if(!this.#z($))return super.transformNodeImpl($,K);let q=this.#P($);for(let P of q)this.#q.add(P);let Y=this.#w($);for(let P of Y)this.#K.add(P);let z=super.transformNodeImpl($,K);for(let P of Y)this.#K.delete(P);for(let P of q)this.#q.delete(P);return z}transformSchemableIdentifier($,K){let q=super.transformSchemableIdentifier($,K);if(q.schema||!this.#K.has($.identifier.name))return q;return{...q,schema:p8.create(this.#$)}}transformReferences($,K){let q=super.transformReferences($,K);if(q.table.table.schema)return q;return{...q,table:b$.createWithSchema(this.#$,q.table.table.identifier.name)}}transformAggregateFunction($,K){return{...super.transformAggregateFunction({...$,aggregated:[]},K),aggregated:this.#Y($,K,"aggregated")}}transformFunction($,K){return{...super.transformFunction({...$,arguments:[]},K),arguments:this.#Y($,K,"arguments")}}#Y($,K,q){return f46[$.func]?$[q].map((Y)=>!b$.is(Y)||Y.table.schema?this.transformNode(Y,K):{...Y,table:this.transformIdentifier(Y.table.identifier,K)}):this.transformNodeList($[q],K)}#z($){return $.kind in _46}#w($){let K=new Set;if("name"in $&&$.name&&G3.is($.name))this.#W($.name,K);if("from"in $&&$.from)for(let q of $.from.froms)this.#H(q,K);if("into"in $&&$.into)this.#H($.into,K);if("table"in $&&$.table)this.#H($.table,K);if("joins"in $&&$.joins)for(let q of $.joins)this.#H(q.table,K);if("using"in $&&$.using)if(U7.is($.using))this.#H($.using.table,K);else this.#H($.using,K);return K}#P($){let K=new Set;if("with"in $&&$.with)this.#O($.with,K);return K}#H($,K){if(b$.is($))this.#W($.table,K);else if(i4.is($)&&b$.is($.node))this.#W($.node.table,K);else if(Y0.is($))for(let q of $.items)this.#H(q,K)}#W($,K){let q=$.identifier.name;if(!this.#K.has(q)&&!this.#q.has(q))K.add(q)}#O($,K){for(let q of $.expressions){let Y=q.name.table.table.identifier.name;if(!this.#q.has(Y))K.add(Y)}}}class c${#$;constructor($){this.#$=new mD($)}transformQuery($){return this.#$.transformNode($.node,$.queryId)}async transformResult($){return $.result}}var Pe=k({is($){return $.kind==="MatchedNode"},create($,K=!1){return k({kind:"MatchedNode",not:$,bySource:K})}});function pD($,K,q){return Y7.create(HJ([Pe.create(!$.isMatched,$.bySource),...K&&K.length>0?[K.length===3&&q?Q4(K[0],K[1],K[2]):W1(K)]:[]],"and",!1))}function jJ($){if(f1($))return b6.create([$],[]);if(w1($))return $.toOperationNode();return $}class J0{#$;#K;#q;constructor(){this.#$=new Promise(($,K)=>{this.#q=K,this.#K=$})}get promise(){return this.#$}resolve=($)=>{if(this.#K)this.#K($)};reject=($)=>{if(this.#q)this.#q($)}}async function W0($){let K=new J0,q=new J0;return $.provideConnection(async(Y)=>{return K.resolve(Y),await q.promise}).catch((Y)=>K.reject(Y)),k({connection:await K.promise,release:q.resolve})}var A46=k([]);class Kw{#$;constructor($=A46){this.#$=$}get plugins(){return this.#$}transformQuery($,K){for(let q of this.#$){let Y=q.transformQuery({node:$,queryId:K});if(Y.kind===$.kind)$=Y;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${$.kind}`,`but it returned a ${Y.kind}`].join(" "))}return $}async executeQuery($){return await this.provideConnection(async(K)=>{let q=await K.executeQuery($);if("numUpdatedOrDeletedRows"in q)l9("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#K(q,$.queryId)})}async*stream($,K){let{connection:q,release:Y}=await W0(this);try{for await(let z of q.streamQuery($,K))yield await this.#K(z,$.queryId)}finally{Y()}}async#K($,K){for(let q of this.#$)$=await q.transformResult({result:$,queryId:K});return $}}class vJ extends Kw{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin($){return new vJ([...this.plugins,$])}withPlugins($){return new vJ([...this.plugins,...$])}withPluginAtFront($){return new vJ([$,...this.plugins])}withoutPlugins(){return new vJ([])}}var Gq=new vJ;class cD{numChangedRows;constructor($){this.numChangedRows=$}}class r5{#$;constructor($){this.#$=k($)}modifyEnd($){return new r5({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}top($,K){return new r5({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}using(...$){return new v$({...this.#$,queryNode:p$.cloneWithUsing(this.#$.queryNode,vq("Using",$))})}returning($){return new r5({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new r5({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new r5({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new r5({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}}class v${#$;constructor($){this.#$=k($)}modifyEnd($){return new v$({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,$.toOperationNode())})}top($,K){return new v$({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}whenMatched(){return this.#K([])}whenMatchedAnd(...$){return this.#K($)}whenMatchedAndRef($,K,q){return this.#K([$,K,q],!0)}#K($,K){return new BD({...this.#$,queryNode:p$.cloneWithWhen(this.#$.queryNode,pD({isMatched:!0},$,K))})}whenNotMatched(){return this.#q([])}whenNotMatchedAnd(...$){return this.#q($)}whenNotMatchedAndRef($,K,q){return this.#q([$,K,q],!0)}whenNotMatchedBySource(){return this.#q([],!1,!0)}whenNotMatchedBySourceAnd(...$){return this.#q($,!1,!0)}whenNotMatchedBySourceAndRef($,K,q){return this.#q([$,K,q],!0,!0)}returning($){return new v$({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,N4($))})}returningAll($){return new v$({...this.#$,queryNode:C8.cloneWithReturning(this.#$.queryNode,d4($))})}output($){return new v$({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,N4($))})}outputAll($){return new v$({...this.#$,queryNode:C8.cloneWithOutput(this.#$.queryNode,d4($))})}#q($,K=!1,q=!1){let Y={...this.#$,queryNode:p$.cloneWithWhen(this.#$.queryNode,pD({isMatched:!1,bySource:q},$,K))};return new(q?BD:Je)(Y)}$call($){return $(this)}$if($,K){if($)return K(this);return new v$({...this.#$})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile(),K=await this.#$.executor.executeQuery($),{adapter:q}=this.#$.executor,Y=$.query;if(Y.returning&&q.supportsReturning||Y.output&&q.supportsOutput)return K.rows;return[new cD(K.numAffectedRows)]}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}}class BD{#$;constructor($){this.#$=k($)}thenDelete(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("delete"))})}thenDoNothing(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("do nothing"))})}thenUpdate($){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ($(new X1({queryId:this.#$.queryId,executor:Gq,queryNode:F9.createWithoutTable()}))))})}thenUpdateSet(...$){return this.thenUpdate((K)=>K.set(...$))}}class Je{#$;constructor($){this.#$=k($)}thenDoNothing(){return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ("do nothing"))})}thenInsertValues($){let[K,q]=P0($);return new v$({...this.#$,queryNode:p$.cloneWithThen(this.#$.queryNode,jJ(i1.cloneWith(i1.createWithoutInto(),{columns:K,values:q})))})}}class d9{#$;constructor($){this.#$=k($)}selectFrom($){return GJ({queryId:$6(),executor:this.#$.executor,queryNode:m6.createFrom(d7($),this.#$.withNode)})}selectNoFrom($){return GJ({queryId:$6(),executor:this.#$.executor,queryNode:m6.cloneWithSelections(m6.create(this.#$.withNode),N4($))})}insertInto($){return new Y1({queryId:$6(),executor:this.#$.executor,queryNode:i1.create(g6($),this.#$.withNode)})}replaceInto($){return new Y1({queryId:$6(),executor:this.#$.executor,queryNode:i1.create(g6($),this.#$.withNode,!0)})}deleteFrom($){return new M1({queryId:$6(),executor:this.#$.executor,queryNode:jq.create(d7($),this.#$.withNode)})}updateTable($){return new X1({queryId:$6(),executor:this.#$.executor,queryNode:F9.create(d7($),this.#$.withNode)})}mergeInto($){return new r5({queryId:$6(),executor:this.#$.executor,queryNode:p$.create(UD($),this.#$.withNode)})}with($,K){let q=uD($,K);return new d9({...this.#$,withNode:this.#$.withNode?eO.cloneWithExpression(this.#$.withNode,q):eO.create(q)})}withRecursive($,K){let q=uD($,K);return new d9({...this.#$,withNode:this.#$.withNode?eO.cloneWithExpression(this.#$.withNode,q):eO.create(q,{recursive:!0})})}withPlugin($){return new d9({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new d9({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new d9({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}}function Ke(){return new d9({executor:Gq})}function We($,K){return new ZJ({joinNode:U7.create($,Kz(K))})}function He(){return new OJ({overNode:aO.create()})}function vq($,K){if(K.length===3)return k46($,K[0],K[1],K[2]);else if(K.length===2)return V46($,K[0],K[1]);else if(K.length===1)return M46($,K[0]);else throw new Error("not implemented")}function V46($,K,q){return q(We($,K)).toOperationNode()}function k46($,K,q,Y){return U7.createWithOn($,Kz(K),Q4(q,"=",Y))}function M46($,K){return U7.create($,Kz(K))}var Ze=k({is($){return $.kind==="OffsetNode"},create($){return k({kind:"OffsetNode",offset:$})}});var Oe=k({is($){return $.kind==="GroupByItemNode"},create($){return k({kind:"GroupByItemNode",groupBy:$})}});function we($){return $=A1($)?$(F7()):$,o5($).map(Oe.create)}var H0=k({is($){return $.kind==="SetOperationNode"},create($,K,q){return k({kind:"SetOperationNode",operator:$,expression:K,all:q})}});function qz($,K,q){if(A1(K))K=K(Z0());if(!j3(K))K=[K];return K.map((Y)=>H0.create($,j$(Y),q))}class U6{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}or(...$){return new O0(B7.create(this.#$,W1($)))}and(...$){return new w0(T$.create(this.#$,W1($)))}$castTo(){return new U6(this.#$)}$notNull(){return new U6(this.#$)}toOperationNode(){return this.#$}}class X0{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}class O0{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}or(...$){return new O0(B7.create(this.#$,W1($)))}$castTo(){return new O0(this.#$)}toOperationNode(){return m$.create(this.#$)}}class w0{#$;constructor($){this.#$=$}get expressionType(){return}as($){return new X0(this,$)}and(...$){return new w0(T$.create(this.#$,W1($)))}$castTo(){return new w0(this.#$)}toOperationNode(){return m$.create(this.#$)}}var Xe={is($){return $.kind==="FetchNode"},create($,K){return{kind:"FetchNode",rowCount:G4.create($),modifier:K}}};function Te($,K){if(!Hq($)&&!YJ($))throw new Error(`Invalid fetch row count: ${$}`);if(!N46(K))throw new Error(`Invalid fetch modifier: ${K}`);return Xe.create($,K)}function N46($){return $==="only"||$==="with ties"}class r8{#$;constructor($){this.#$=k($)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...$){return new r8({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,W1($))})}whereRef($,K,q){return new r8({...this.#$,queryNode:C8.cloneWithWhere(this.#$.queryNode,Q4($,K,q))})}having(...$){return new r8({...this.#$,queryNode:m6.cloneWithHaving(this.#$.queryNode,W1($))})}havingRef($,K,q){return new r8({...this.#$,queryNode:m6.cloneWithHaving(this.#$.queryNode,Q4($,K,q))})}select($){return new r8({...this.#$,queryNode:m6.cloneWithSelections(this.#$.queryNode,N4($))})}distinctOn($){return new r8({...this.#$,queryNode:m6.cloneWithDistinctOn(this.#$.queryNode,o5($))})}modifyFront($){return new r8({...this.#$,queryNode:m6.cloneWithFrontModifier(this.#$.queryNode,U9.createWithExpression($.toOperationNode()))})}modifyEnd($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.createWithExpression($.toOperationNode()))})}distinct(){return new r8({...this.#$,queryNode:m6.cloneWithFrontModifier(this.#$.queryNode,U9.create("Distinct"))})}forUpdate($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForUpdate",$?QO($).map(g6):void 0))})}forShare($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForShare",$?QO($).map(g6):void 0))})}forKeyShare($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForKeyShare",$?QO($).map(g6):void 0))})}forNoKeyUpdate($){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("ForNoKeyUpdate",$?QO($).map(g6):void 0))})}skipLocked(){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("SkipLocked"))})}noWait(){return new r8({...this.#$,queryNode:C8.cloneWithEndModifier(this.#$.queryNode,U9.create("NoWait"))})}selectAll($){return new r8({...this.#$,queryNode:m6.cloneWithSelections(this.#$.queryNode,d4($))})}innerJoin(...$){return this.#K("InnerJoin",$)}leftJoin(...$){return this.#K("LeftJoin",$)}rightJoin(...$){return this.#K("RightJoin",$)}fullJoin(...$){return this.#K("FullJoin",$)}crossJoin(...$){return this.#K("CrossJoin",$)}innerJoinLateral(...$){return this.#K("LateralInnerJoin",$)}leftJoinLateral(...$){return this.#K("LateralLeftJoin",$)}crossJoinLateral(...$){return this.#K("LateralCrossJoin",$)}crossApply(...$){return this.#K("CrossApply",$)}outerApply(...$){return this.#K("OuterApply",$)}#K($,K){return new r8({...this.#$,queryNode:C8.cloneWithJoin(this.#$.queryNode,vq($,K))})}orderBy(...$){return new r8({...this.#$,queryNode:C8.cloneWithOrderByItems(this.#$.queryNode,u$($))})}groupBy($){return new r8({...this.#$,queryNode:m6.cloneWithGroupByItems(this.#$.queryNode,we($))})}limit($){return new r8({...this.#$,queryNode:m6.cloneWithLimit(this.#$.queryNode,XJ.create(q1($)))})}offset($){return new r8({...this.#$,queryNode:m6.cloneWithOffset(this.#$.queryNode,Ze.create(q1($)))})}fetch($,K="only"){return new r8({...this.#$,queryNode:m6.cloneWithFetch(this.#$.queryNode,Te($,K))})}top($,K){return new r8({...this.#$,queryNode:C8.cloneWithTop(this.#$.queryNode,Q7($,K))})}union($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("union",$,!1))})}unionAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("union",$,!0))})}intersect($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("intersect",$,!1))})}intersectAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("intersect",$,!0))})}except($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("except",$,!1))})}exceptAll($){return new r8({...this.#$,queryNode:m6.cloneWithSetOperations(this.#$.queryNode,qz("except",$,!0))})}as($){return new je(this,$)}clearSelect(){return new r8({...this.#$,queryNode:m6.cloneWithoutSelections(this.#$.queryNode)})}clearWhere(){return new r8({...this.#$,queryNode:C8.cloneWithoutWhere(this.#$.queryNode)})}clearLimit(){return new r8({...this.#$,queryNode:m6.cloneWithoutLimit(this.#$.queryNode)})}clearOffset(){return new r8({...this.#$,queryNode:m6.cloneWithoutOffset(this.#$.queryNode)})}clearOrderBy(){return new r8({...this.#$,queryNode:C8.cloneWithoutOrderBy(this.#$.queryNode)})}clearGroupBy(){return new r8({...this.#$,queryNode:m6.cloneWithoutGroupBy(this.#$.queryNode)})}$call($){return $(this)}$if($,K){if($)return K(this);return new r8({...this.#$})}$castTo(){return new r8(this.#$)}$narrowType(){return new r8(this.#$)}$assertType(){return new r8(this.#$)}$asTuple(){return new U6(this.toOperationNode())}$asScalar(){return new U6(this.toOperationNode())}withPlugin($){return new r8({...this.#$,executor:this.#$.executor.withPlugin($)})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.queryNode,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){let $=this.compile();return(await this.#$.executor.executeQuery($)).rows}async executeTakeFirst(){let[$]=await this.execute();return $}async executeTakeFirstOrThrow($=i7){let K=await this.executeTakeFirst();if(K===void 0)throw i9($)?new $(this.toOperationNode()):$(this.toOperationNode());return K}async*stream($=100){let K=this.compile(),q=this.#$.executor.stream(K,$);for await(let Y of q)yield*Y.rows}async explain($,K){return await new r8({...this.#$,queryNode:C8.cloneWithExplain(this.#$.queryNode,$,K)}).execute()}}function GJ($){return new r8($)}class je{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return i4.create(this.#$.toOperationNode(),p8.create(this.#K))}}var n9=k({is($){return $.kind==="AggregateFunctionNode"},create($,K=[]){return k({kind:"AggregateFunctionNode",func:$,aggregated:K})},cloneWithDistinct($){return k({...$,distinct:!0})},cloneWithOrderBy($,K,q=!1){let Y=q?"withinGroup":"orderBy";return k({...$,[Y]:$[Y]?a5.cloneWithItems($[Y],K):a5.create(K)})},cloneWithFilter($,K){return k({...$,filter:$.filter?t4.cloneWithOperation($.filter,"And",K):t4.create(K)})},cloneWithOrFilter($,K){return k({...$,filter:$.filter?t4.cloneWithOperation($.filter,"Or",K):t4.create(K)})},cloneWithOver($,K){return k({...$,over:K})}});var lD=k({is($){return $.kind==="FunctionNode"},create($,K){return k({kind:"FunctionNode",func:$,arguments:K})}});class G${#$;constructor($){this.#$=k($)}get expressionType(){return}as($){return new ve(this,$)}distinct(){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithDistinct(this.#$.aggregateFunctionNode)})}orderBy(...$){return new G$({...this.#$,aggregateFunctionNode:C8.cloneWithOrderByItems(this.#$.aggregateFunctionNode,u$($))})}clearOrderBy(){return new G$({...this.#$,aggregateFunctionNode:C8.cloneWithoutOrderBy(this.#$.aggregateFunctionNode)})}withinGroupOrderBy(...$){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithOrderBy(this.#$.aggregateFunctionNode,u$($),!0)})}filterWhere(...$){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithFilter(this.#$.aggregateFunctionNode,W1($))})}filterWhereRef($,K,q){return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithFilter(this.#$.aggregateFunctionNode,Q4($,K,q))})}over($){let K=He();return new G$({...this.#$,aggregateFunctionNode:n9.cloneWithOver(this.#$.aggregateFunctionNode,($?$(K):K).toOperationNode())})}$call($){return $(this)}$castTo(){return new G$(this.#$)}$notNull(){return new G$(this.#$)}toOperationNode(){return this.#$.aggregateFunctionNode}}class ve{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),p8.create(this.#K))}}function T0(){let $=(q,Y)=>{return new U6(lD.create(q,o5(Y??[])))},K=(q,Y)=>{return new G$({aggregateFunctionNode:n9.create(q,Y?o5(Y):void 0)})};return Object.assign($,{agg:K,avg(q){return K("avg",[q])},coalesce(...q){return $("coalesce",q)},count(q){return K("count",[q])},countAll(q){return new G$({aggregateFunctionNode:n9.create("count",d4(q))})},max(q){return K("max",[q])},min(q){return K("min",[q])},sum(q){return K("sum",[q])},any(q){return $("any",[q])},jsonAgg(q){return new G$({aggregateFunctionNode:n9.create("json_agg",[f1(q)?g6(q):q.toOperationNode()])})},toJson(q){return new U6(lD.create("to_json",[f1(q)?g6(q):q.toOperationNode()]))}})}var Ge=k({is($){return $.kind==="UnaryOperationNode"},create($,K){return k({kind:"UnaryOperationNode",operator:$,operand:K})}});function _e($,K){return Ge.create(g$.create($),s4(K))}var B$=k({is($){return $.kind==="CaseNode"},create($){return k({kind:"CaseNode",value:$})},cloneWithWhen($,K){return k({...$,when:k($.when?[...$.when,K]:[K])})},cloneWithThen($,K){return k({...$,when:$.when?k([...$.when.slice(0,-1),Y7.cloneWithResult($.when[$.when.length-1],K)]):void 0})},cloneWith($,K){return k({...$,...K})}});class qw{#$;constructor($){this.#$=k($)}when(...$){return new FD({...this.#$,node:B$.cloneWithWhen(this.#$.node,Y7.create(W1($)))})}}class FD{#$;constructor($){this.#$=k($)}then($){return new fe({...this.#$,node:B$.cloneWithThen(this.#$.node,K0($)?oO($):q1($))})}}class fe{#$;constructor($){this.#$=k($)}when(...$){return new FD({...this.#$,node:B$.cloneWithWhen(this.#$.node,Y7.create(W1($)))})}else($){return new Ae({...this.#$,node:B$.cloneWith(this.#$.node,{else:K0($)?oO($):q1($)})})}end(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!1}))}endCase(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!0}))}}class Ae{#$;constructor($){this.#$=k($)}end(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!1}))}endCase(){return new U6(B$.cloneWith(this.#$.node,{isStatement:!0}))}}var iD=k({is($){return $.kind==="JSONPathLegNode"},create($,K){return k({kind:"JSONPathLegNode",type:$,value:K})}});class zw{#$;constructor($){this.#$=$}at($){return this.#K("ArrayLocation",$)}key($){return this.#K("Member",$)}#K($,K){if(JJ.is(this.#$))return new Yw(JJ.cloneWithTraversal(this.#$,Xq.is(this.#$.traversal)?Xq.cloneWithLeg(this.#$.traversal,iD.create($,K)):eG.cloneWithValue(this.#$.traversal,G4.createImmediate(K))));return new Yw(Xq.cloneWithLeg(this.#$,iD.create($,K)))}}class Yw extends zw{#$;constructor($){super($);this.#$=$}get expressionType(){return}as($){return new Ve(this,$)}$castTo(){return new Yw(this.#$)}$notNull(){return new Yw(this.#$)}toOperationNode(){return this.#$}}class Ve{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}var QD=k({is($){return $.kind==="TupleNode"},create($){return k({kind:"TupleNode",values:k($)})}});var h46=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],C46=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ke=k({is($){return $.kind==="DataTypeNode"},create($){return k({kind:"DataTypeNode",dataType:$})}});function Me($){if(h46.includes($))return!0;if(C46.some((K)=>K.test($)))return!0;return!1}function n7($){if(w1($))return $.toOperationNode();if(Me($))return ke.create($);throw new Error(`invalid column data type ${JSON.stringify($)}`)}var Ne=k({is($){return $.kind==="CastNode"},create($,K){return k({kind:"CastNode",expression:$,dataType:K})}});function Z0($=Gq){function K(z,P,J){return new U6(q0(z,P,J))}function q(z,P){return new U6(_e(z,P))}let Y=Object.assign(K,{fn:void 0,eb:void 0,selectFrom(z){return GJ({queryId:$6(),executor:$,queryNode:m6.createFrom(d7(z))})},case(z){return new qw({node:B$.create(x$(z)?void 0:s4(z))})},ref(z,P){if(x$(P))return new U6(y$(z));return new zw(pt(z,P))},jsonPath(){return new zw(Xq.create())},table(z){return new U6(g6(z))},val(z){return new U6(q1(z))},refTuple(...z){return new U6(QD.create(z.map(s4)))},tuple(...z){return new U6(QD.create(z.map(q1)))},lit(z){return new U6(oO(z))},unary:q,not(z){return q("not",z)},exists(z){return q("exists",z)},neg(z){return q("-",z)},between(z,P,J){return new U6(Oq.create(s4(z),g$.create("between"),T$.create(q1(P),q1(J))))},betweenSymmetric(z,P,J){return new U6(Oq.create(s4(z),g$.create("between symmetric"),T$.create(q1(P),q1(J))))},and(z){if(j3(z))return new U6(HJ(z,"and"));return new U6(hD(z,"and"))},or(z){if(j3(z))return new U6(HJ(z,"or"));return new U6(hD(z,"or"))},parens(...z){let P=W1(z);if(m$.is(P))return new U6(P);else return new U6(m$.create(P))},cast(z,P){return new U6(Ne.create(s4(z),n7(P)))},withSchema(z){return Z0($.withPluginAtFront(new c$(z)))}});return Y.fn=T0(),Y.eb=Y,Y}function F7($){return Z0()}function j$($){if(w1($))return $.toOperationNode();else if(A1($))return $(F7()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify($)}`)}function z0($){if(w1($))return $.toOperationNode();else if(A1($))return $(F7()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify($)}`)}function n5($){return rG($)||xt($)||A1($)}class dD{#$;get table(){return this.#$}constructor($){this.#$=$}as($){return new he(this.#$,$)}}class he{#$;#K;get table(){return this.#$}get alias(){return this.#K}constructor($,K){this.#$=$,this.#K=K}toOperationNode(){return i4.create(g6(this.#$),p8.create(this.#K))}}function Ce($){return M4($)&&w1($)&&f1($.table)&&f1($.alias)}function d7($){if(j3($))return $.map((K)=>Kz(K));else return[Kz($)]}function Kz($){if(f1($))return UD($);else if(Ce($))return $.toOperationNode();else return z0($)}function UD($){if($.includes(" as ")){let[q,Y]=$.split(" as ").map(Re);return i4.create(g6(q),p8.create(Y))}else return g6($)}function g6($){if($.includes(".")){let[q,Y]=$.split(".").map(Re);return b$.createWithSchema(q,Y)}else return b$.create($)}function Re($){return $.trim()}var nD=k({is($){return $.kind==="AddColumnNode"},create($){return k({kind:"AddColumnNode",column:$})}});var T1=k({is($){return $.kind==="ColumnDefinitionNode"},create($,K){return k({kind:"ColumnDefinitionNode",column:R6.create($),dataType:K})},cloneWithFrontModifier($,K){return k({...$,frontModifiers:$.frontModifiers?k([...$.frontModifiers,K]):[K]})},cloneWithEndModifier($,K){return k({...$,endModifiers:$.endModifiers?k([...$.endModifiers,K]):[K]})},cloneWith($,K){return k({...$,...K})}});var oD=k({is($){return $.kind==="DropColumnNode"},create($){return k({kind:"DropColumnNode",column:R6.create($)})}});var aD=k({is($){return $.kind==="RenameColumnNode"},create($,K){return k({kind:"RenameColumnNode",column:R6.create($),renameTo:R6.create(K)})}});var _J=k({is($){return $.kind==="CheckConstraintNode"},create($,K){return k({kind:"CheckConstraintNode",expression:$,name:K?p8.create(K):void 0})}});var De=["no action","restrict","cascade","set null","set default"],fJ=k({is($){return $.kind==="ReferencesNode"},create($,K){return k({kind:"ReferencesNode",table:$,columns:k([...K])})},cloneWithOnDelete($,K){return k({...$,onDelete:K})},cloneWithOnUpdate($,K){return k({...$,onUpdate:K})}});function j0($){return w1($)?$.toOperationNode():G4.createImmediate($)}var Pw=k({is($){return $.kind==="GeneratedNode"},create($){return k({kind:"GeneratedNode",...$})},createWithExpression($){return k({kind:"GeneratedNode",always:!0,expression:$})},cloneWith($,K){return k({...$,...K})}});var Se=k({is($){return $.kind==="DefaultValueNode"},create($){return k({kind:"DefaultValueNode",defaultValue:$})}});function AJ($){if(De.includes($))return $;throw new Error(`invalid OnModifyForeignAction ${$}`)}class j1{#$;constructor($){this.#$=$}autoIncrement(){return new j1(T1.cloneWith(this.#$,{autoIncrement:!0}))}identity(){return new j1(T1.cloneWith(this.#$,{identity:!0}))}primaryKey(){return new j1(T1.cloneWith(this.#$,{primaryKey:!0}))}references($){let K=y$($);if(!K.table||zJ.is(K.column))throw new Error(`invalid call references('${$}'). The reference must have format table.column or schema.table.column`);return new j1(T1.cloneWith(this.#$,{references:fJ.create(K.table,[K.column])}))}onDelete($){if(!this.#$.references)throw new Error("on delete constraint can only be added for foreign keys");return new j1(T1.cloneWith(this.#$,{references:fJ.cloneWithOnDelete(this.#$.references,AJ($))}))}onUpdate($){if(!this.#$.references)throw new Error("on update constraint can only be added for foreign keys");return new j1(T1.cloneWith(this.#$,{references:fJ.cloneWithOnUpdate(this.#$.references,AJ($))}))}unique(){return new j1(T1.cloneWith(this.#$,{unique:!0}))}notNull(){return new j1(T1.cloneWith(this.#$,{notNull:!0}))}unsigned(){return new j1(T1.cloneWith(this.#$,{unsigned:!0}))}defaultTo($){return new j1(T1.cloneWith(this.#$,{defaultTo:Se.create(j0($))}))}check($){return new j1(T1.cloneWith(this.#$,{check:_J.create($.toOperationNode())}))}generatedAlwaysAs($){return new j1(T1.cloneWith(this.#$,{generated:Pw.createWithExpression($.toOperationNode())}))}generatedAlwaysAsIdentity(){return new j1(T1.cloneWith(this.#$,{generated:Pw.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new j1(T1.cloneWith(this.#$,{generated:Pw.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#$.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new j1(T1.cloneWith(this.#$,{generated:Pw.cloneWith(this.#$.generated,{stored:!0})}))}modifyFront($){return new j1(T1.cloneWithFrontModifier(this.#$,$.toOperationNode()))}nullsNotDistinct(){return new j1(T1.cloneWith(this.#$,{nullsNotDistinct:!0}))}ifNotExists(){return new j1(T1.cloneWith(this.#$,{ifNotExists:!0}))}modifyEnd($){return new j1(T1.cloneWithEndModifier(this.#$,$.toOperationNode()))}$call($){return $(this)}toOperationNode(){return this.#$}}var rD=k({is($){return $.kind==="ModifyColumnNode"},create($){return k({kind:"ModifyColumnNode",column:$})}});var o7=k({is($){return $.kind==="ForeignKeyConstraintNode"},create($,K,q,Y){return k({kind:"ForeignKeyConstraintNode",columns:$,references:fJ.create(K,q),name:Y?p8.create(Y):void 0})},cloneWith($,K){return k({...$,...K})}});class a7{#$;constructor($){this.#$=$}onDelete($){return new a7(o7.cloneWith(this.#$,{onDelete:AJ($)}))}onUpdate($){return new a7(o7.cloneWith(this.#$,{onUpdate:AJ($)}))}deferrable(){return new a7(o7.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new a7(o7.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new a7(o7.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new a7(o7.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}var VJ=k({is($){return $.kind==="AddConstraintNode"},create($){return k({kind:"AddConstraintNode",constraint:$})}});var o9=k({is($){return $.kind==="UniqueConstraintNode"},create($,K,q){return k({kind:"UniqueConstraintNode",columns:k($.map(R6.create)),name:K?p8.create(K):void 0,nullsNotDistinct:q})},cloneWith($,K){return k({...$,...K})}});var kJ=k({is($){return $.kind==="DropConstraintNode"},create($){return k({kind:"DropConstraintNode",constraintName:p8.create($)})},cloneWith($,K){return k({...$,...K})}});var MJ=k({is($){return $.kind==="AlterColumnNode"},create($,K,q){return k({kind:"AlterColumnNode",column:R6.create($),[K]:q})}});class v0{#$;constructor($){this.#$=$}setDataType($){return new NJ(MJ.create(this.#$,"dataType",n7($)))}setDefault($){return new NJ(MJ.create(this.#$,"setDefault",j0($)))}dropDefault(){return new NJ(MJ.create(this.#$,"dropDefault",!0))}setNotNull(){return new NJ(MJ.create(this.#$,"setNotNull",!0))}dropNotNull(){return new NJ(MJ.create(this.#$,"dropNotNull",!0))}$call($){return $(this)}}class NJ{#$;constructor($){this.#$=$}toOperationNode(){return this.#$}}class _q{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class s5{#$;constructor($){this.#$=k($)}onDelete($){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.onDelete($)})}onUpdate($){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.onUpdate($)})}deferrable(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.deferrable()})}notDeferrable(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new s5({...this.#$,constraintBuilder:this.#$.constraintBuilder.initiallyImmediate()})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(this.#$.constraintBuilder.toOperationNode())}),this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Yz{#$;constructor($){this.#$=k($)}ifExists(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{ifExists:!0})})})}cascade(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.cloneWith(this.#$.node.dropConstraint,{modifier:"restrict"})})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var t5=k({is($){return $.kind==="PrimaryKeyConstraintNode"},create($,K){return k({kind:"PrimaryKeyConstraintNode",columns:k($.map(R6.create)),name:K?p8.create(K):void 0})},cloneWith($,K){return k({...$,...K})}});var fq=k({is($){return $.kind==="AddIndexNode"},create($){return k({kind:"AddIndexNode",name:p8.create($)})},cloneWith($,K){return k({...$,...K})},cloneWithColumns($,K){return k({...$,columns:[...$.columns||[],...K]})}});class Aq{#$;constructor($){this.#$=k($)}unique(){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWith(this.#$.node.addIndex,{unique:!0})})})}column($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,[WJ($)])})})}columns($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,$.map(WJ))})})}expression($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWithColumns(this.#$.node.addIndex,[$.toOperationNode()])})})}using($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.cloneWith(this.#$.node.addIndex,{using:b6.createWithSql($)})})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class a9{#$;constructor($){this.#$=$}nullsNotDistinct(){return new a9(o9.cloneWith(this.#$,{nullsNotDistinct:!0}))}deferrable(){return new a9(o9.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new a9(o9.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new a9(o9.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new a9(o9.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}class e5{#$;constructor($){this.#$=$}deferrable(){return new e5(t5.cloneWith(this.#$,{deferrable:!0}))}notDeferrable(){return new e5(t5.cloneWith(this.#$,{deferrable:!1}))}initiallyDeferred(){return new e5(t5.cloneWith(this.#$,{initiallyDeferred:!0}))}initiallyImmediate(){return new e5(t5.cloneWith(this.#$,{initiallyDeferred:!1}))}$call($){return $(this)}toOperationNode(){return this.#$}}class Jw{#$;constructor($){this.#$=$}$call($){return $(this)}toOperationNode(){return this.#$}}var Ee=k({is($){return $.kind==="RenameConstraintNode"},create($,K){return k({kind:"RenameConstraintNode",oldName:p8.create($),newName:p8.create(K)})}});class sD{#$;constructor($){this.#$=k($)}renameTo($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{renameTo:g6($)})})}setSchema($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{setSchema:p8.create($)})})}alterColumn($,K){let q=K(new v0($));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,q.toOperationNode())})}dropColumn($){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,oD.create($))})}renameColumn($,K){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,aD.create($,K))})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,nD.create(Y.toOperationNode()))})}modifyColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,rD.create(Y.toOperationNode()))})}addUniqueConstraint($,K,q=l3){let Y=q(new a9(o9.create(K,$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}addCheckConstraint($,K,q=l3){let Y=q(new Jw(_J.create(K.toOperationNode(),$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}addForeignKeyConstraint($,K,q,Y,z=l3){let P=z(new a7(o7.create(K.map(R6.create),g6(q),Y.map(R6.create),$)));return new s5({...this.#$,constraintBuilder:P})}addPrimaryKeyConstraint($,K,q=l3){let Y=q(new e5(t5.create(K,$)));return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addConstraint:VJ.create(Y.toOperationNode())})})}dropConstraint($){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropConstraint:kJ.create($)})})}renameConstraint($,K){return new Yz({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{renameConstraint:Ee.create($,K)})})}addIndex($){return new Aq({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{addIndex:fq.create($)})})}dropIndex($){return new _q({...this.#$,node:x6.cloneWithTableProps(this.#$.node,{dropIndex:Zq.create($)})})}$call($){return $(this)}}class r7{#$;constructor($){this.#$=k($)}alterColumn($,K){let q=K(new v0($));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,q.toOperationNode())})}dropColumn($){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,oD.create($))})}renameColumn($,K){return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,aD.create($,K))})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,nD.create(Y.toOperationNode()))})}modifyColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new r7({...this.#$,node:x6.cloneWithColumnAlteration(this.#$.node,rD.create(Y.toOperationNode()))})}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Ww extends $w{transformPrimitiveValueList($){return Tq.create($.values.map(G4.createImmediate))}transformValue($){return G4.createImmediate($.value)}}class z7{#$;constructor($){this.#$=k($)}ifNotExists(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{ifNotExists:!0})})}unique(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{unique:!0})})}nullsNotDistinct(){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{nullsNotDistinct:!0})})}on($){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{table:g6($)})})}column($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,[WJ($)])})}columns($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,$.map(WJ))})}expression($){return new z7({...this.#$,node:c7.cloneWithColumns(this.#$.node,[$.toOperationNode()])})}using($){return new z7({...this.#$,node:c7.cloneWith(this.#$.node,{using:b6.createWithSql($)})})}where(...$){let K=new Ww;return new z7({...this.#$,node:C8.cloneWithWhere(this.#$.node,K.transformNode(W1($),this.#$.queryId))})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class G0{#$;constructor($){this.#$=k($)}ifNotExists(){return new G0({...this.#$,node:aG.cloneWith(this.#$.node,{ifNotExists:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}function Le($){if(It.includes($))return $;throw new Error(`invalid OnCommitAction ${$}`)}class _${#$;constructor($){this.#$=k($)}temporary(){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{temporary:!0})})}onCommit($){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{onCommit:Le($)})})}ifNotExists(){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{ifNotExists:!0})})}addColumn($,K,q=l3){let Y=q(new j1(T1.create($,n7(K))));return new _$({...this.#$,node:v3.cloneWithColumn(this.#$.node,Y.toOperationNode())})}addPrimaryKeyConstraint($,K,q=l3){let Y=q(new e5(t5.create(K,$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addUniqueConstraint($,K,q=l3){let Y=q(new a9(o9.create(K,$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addCheckConstraint($,K,q=l3){let Y=q(new Jw(_J.create(K.toOperationNode(),$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,Y.toOperationNode())})}addForeignKeyConstraint($,K,q,Y,z=l3){let P=z(new a7(o7.create(K.map(R6.create),g6(q),Y.map(R6.create),$)));return new _$({...this.#$,node:v3.cloneWithConstraint(this.#$.node,P.toOperationNode())})}modifyFront($){return new _$({...this.#$,node:v3.cloneWithFrontModifier(this.#$.node,$.toOperationNode())})}modifyEnd($){return new _$({...this.#$,node:v3.cloneWithEndModifier(this.#$.node,$.toOperationNode())})}as($){return new _$({...this.#$,node:v3.cloneWith(this.#$.node,{selectQuery:j$($)})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class hJ{#$;constructor($){this.#$=k($)}on($){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{table:g6($)})})}ifExists(){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new hJ({...this.#$,node:Zq.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Hw{#$;constructor($){this.#$=k($)}ifExists(){return new Hw({...this.#$,node:dO.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new Hw({...this.#$,node:dO.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class Zw{#$;constructor($){this.#$=k($)}ifExists(){return new Zw({...this.#$,node:nO.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new Zw({...this.#$,node:nO.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var s7=k({is($){return $.kind==="CreateViewNode"},create($){return k({kind:"CreateViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class tD{#$=new Ww;transformQuery($){return this.#$.transformNode($.node,$.queryId)}transformResult($){return Promise.resolve($.result)}}class $K{#$;constructor($){this.#$=k($)}temporary(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{temporary:!0})})}materialized(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{materialized:!0})})}ifNotExists(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{ifNotExists:!0})})}orReplace(){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{orReplace:!0})})}columns($){return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{columns:$.map(kD)})})}as($){let K=$.withPlugin(new tD).toOperationNode();return new $K({...this.#$,node:s7.cloneWith(this.#$.node,{as:K})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var CJ=k({is($){return $.kind==="DropViewNode"},create($){return k({kind:"DropViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class RJ{#$;constructor($){this.#$=k($)}materialized(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{materialized:!0})})}ifExists(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{ifExists:!0})})}cascade(){return new RJ({...this.#$,node:CJ.cloneWith(this.#$.node,{cascade:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var _0=k({is($){return $.kind==="CreateTypeNode"},create($){return k({kind:"CreateTypeNode",name:$})},cloneWithEnum($,K){return k({...$,enum:Tq.create(K.map(G4.createImmediate))})}});class f0{#$;constructor($){this.#$=k($)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}asEnum($){return new f0({...this.#$,node:_0.cloneWithEnum(this.#$.node,$)})}$call($){return $(this)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}var A0=k({is($){return $.kind==="DropTypeNode"},create($){return k({kind:"DropTypeNode",name:$})},cloneWith($,K){return k({...$,...K})}});class V0{#$;constructor($){this.#$=k($)}ifExists(){return new V0({...this.#$,node:A0.cloneWith(this.#$.node,{ifExists:!0})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}function eD($){if($.includes(".")){let q=$.split(".").map(R46);if(q.length===2)return G3.createWithSchema(q[0],q[1]);else throw new Error(`invalid schemable identifier ${$}`)}else return G3.create($)}function R46($){return $.trim()}var DJ=k({is($){return $.kind==="RefreshMaterializedViewNode"},create($){return k({kind:"RefreshMaterializedViewNode",name:G3.create($)})},cloneWith($,K){return k({...$,...K})}});class SJ{#$;constructor($){this.#$=k($)}concurrently(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{concurrently:!0,withNoData:!1})})}withData(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{withNoData:!1})})}withNoData(){return new SJ({...this.#$,node:DJ.cloneWith(this.#$.node,{withNoData:!0,concurrently:!1})})}$call($){return $(this)}toOperationNode(){return this.#$.executor.transformQuery(this.#$.node,this.#$.queryId)}compile(){return this.#$.executor.compileQuery(this.toOperationNode(),this.#$.queryId)}async execute(){await this.#$.executor.executeQuery(this.compile())}}class EJ{#$;constructor($){this.#$=$}createTable($){return new _$({queryId:$6(),executor:this.#$,node:v3.create(g6($))})}dropTable($){return new Zw({queryId:$6(),executor:this.#$,node:nO.create(g6($))})}createIndex($){return new z7({queryId:$6(),executor:this.#$,node:c7.create($)})}dropIndex($){return new hJ({queryId:$6(),executor:this.#$,node:Zq.create($)})}createSchema($){return new G0({queryId:$6(),executor:this.#$,node:aG.create($)})}dropSchema($){return new Hw({queryId:$6(),executor:this.#$,node:dO.create($)})}alterTable($){return new sD({queryId:$6(),executor:this.#$,node:x6.create(g6($))})}createView($){return new $K({queryId:$6(),executor:this.#$,node:s7.create($)})}refreshMaterializedView($){return new SJ({queryId:$6(),executor:this.#$,node:DJ.create($)})}dropView($){return new RJ({queryId:$6(),executor:this.#$,node:CJ.create($)})}createType($){return new f0({queryId:$6(),executor:this.#$,node:_0.create(eD($))})}dropType($){return new V0({queryId:$6(),executor:this.#$,node:A0.create(eD($))})}withPlugin($){return new EJ(this.#$.withPlugin($))}withoutPlugins(){return new EJ(this.#$.withoutPlugins())}withSchema($){return new EJ(this.#$.withPluginAtFront(new c$($)))}}class $S{ref($){return new _D($)}table($){return new dD($)}}class KS{#$;constructor($){this.#$=$}async provideConnection($){let K=await this.#$.acquireConnection();try{return await $(K)}finally{await this.#$.releaseConnection(K)}}}class Vq extends Kw{#$;#K;#q;constructor($,K,q,Y=[]){super(Y);this.#$=$,this.#K=K,this.#q=q}get adapter(){return this.#K}compileQuery($,K){return this.#$.compileQuery($,K)}provideConnection($){return this.#q.provideConnection($)}withPlugins($){return new Vq(this.#$,this.#K,this.#q,[...this.plugins,...$])}withPlugin($){return new Vq(this.#$,this.#K,this.#q,[...this.plugins,$])}withPluginAtFront($){return new Vq(this.#$,this.#K,this.#q,[$,...this.plugins])}withConnectionProvider($){return new Vq(this.#$,this.#K,$,[...this.plugins])}withoutPlugins(){return new Vq(this.#$,this.#K,this.#q,[])}}function k0(){if(typeof performance!=="undefined"&&A1(performance.now))return performance.now();else return Date.now()}class qS{#$;#K;#q;#Y;#z;#w=new WeakSet;constructor($,K){this.#Y=!1,this.#$=$,this.#K=K}async init(){if(this.#z)throw new Error("driver has already been destroyed");if(!this.#q)this.#q=this.#$.init().then(()=>{this.#Y=!0}).catch(($)=>{return this.#q=void 0,Promise.reject($)});await this.#q}async acquireConnection(){if(this.#z)throw new Error("driver has already been destroyed");if(!this.#Y)await this.init();let $=await this.#$.acquireConnection();if(!this.#w.has($)){if(this.#P())this.#H($);this.#w.add($)}return $}async releaseConnection($){await this.#$.releaseConnection($)}beginTransaction($,K){return this.#$.beginTransaction($,K)}commitTransaction($){return this.#$.commitTransaction($)}rollbackTransaction($){return this.#$.rollbackTransaction($)}savepoint($,K,q){if(this.#$.savepoint)return this.#$.savepoint($,K,q);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint($,K,q){if(this.#$.rollbackToSavepoint)return this.#$.rollbackToSavepoint($,K,q);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint($,K,q){if(this.#$.releaseSavepoint)return this.#$.releaseSavepoint($,K,q);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){if(!this.#q)return;if(await this.#q,!this.#z)this.#z=this.#$.destroy().catch(($)=>{return this.#z=void 0,Promise.reject($)});await this.#z}#P(){return this.#K.isLevelEnabled("query")||this.#K.isLevelEnabled("error")}#H($){let{executeQuery:K,streamQuery:q}=$,Y=this;$.executeQuery=async(z)=>{let P,J=k0();try{return await K.call($,z)}catch(W){throw P=W,await Y.#W(W,z,J),W}finally{if(!P)await Y.#O(z,J)}},$.streamQuery=async function*(z,P){let J,W=k0();try{for await(let H of q.call($,z,P))yield H}catch(H){throw J=H,await Y.#W(H,z,W),H}finally{if(!J)await Y.#O(z,W,!0)}}}async#W($,K,q){await this.#K.error(()=>({level:"error",error:$,query:K,queryDurationMillis:this.#J(q)}))}async#O($,K,q=!1){await this.#K.query(()=>({level:"query",isStream:q,query:$,queryDurationMillis:this.#J(K)}))}#J($){return k0()-$}}var D46=()=>{};class Ow{#$;#K;constructor($){this.#$=$}async provideConnection($){while(this.#K)await this.#K.catch(D46);return this.#K=this.#q($).finally(()=>{this.#K=void 0}),this.#K}async#q($){return await $(this.#$)}}var S46=["read only","read write"],E46=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function YS($){if($.accessMode&&!S46.includes($.accessMode))throw new Error(`invalid transaction access mode ${$.accessMode}`);if($.isolationLevel&&!E46.includes($.isolationLevel))throw new Error(`invalid transaction isolation level ${$.isolationLevel}`)}var sR1=k(["query","error"]);class zS{#$;#K;constructor($){if(A1($))this.#K=$,this.#$=k({query:!0,error:!0});else this.#K=L46,this.#$=k({query:$.includes("query"),error:$.includes("error")})}isLevelEnabled($){return this.#$[$]}async query($){if(this.#$.query)await this.#K($())}async error($){if(this.#$.error)await this.#K($())}}function L46($){if($.level==="query"){let K=`kysely:query:${$.isStream?"stream:":""}`;console.log(`${K} ${$.query.sql}`),console.log(`${K} duration: ${$.queryDurationMillis.toFixed(1)}ms`)}else if($.level==="error")if($.error instanceof Error)console.error(`kysely:error: ${$.error.stack??$.error.message}`);else console.error(`kysely:error: ${JSON.stringify({error:$.error,query:$.query.sql,queryDurationMillis:$.queryDurationMillis})}`)}function Ie($){return M4($)&&A1($.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class r9 extends d9{#$;constructor($){let K,q;if(I46($))K={executor:$.executor},q={...$};else{let Y=$.dialect,z=Y.createDriver(),P=Y.createQueryCompiler(),J=Y.createAdapter(),W=new zS($.log??[]),H=new qS(z,W),Z=new KS(H),O=new Vq(P,J,Z,$.plugins??[]);K={executor:O},q={config:$,executor:O,dialect:Y,driver:H}}super(K);this.#$=k(q)}get schema(){return new EJ(this.#$.executor)}get dynamic(){return new $S}get introspection(){return this.#$.dialect.createIntrospector(this.withoutPlugins())}case($){return new qw({node:B$.create(x$($)?void 0:j$($))})}get fn(){return T0()}transaction(){return new M0({...this.#$})}startTransaction(){return new N0({...this.#$})}connection(){return new xe({...this.#$})}withPlugin($){return new r9({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new r9({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new r9({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new r9({...this.#$})}async destroy(){await this.#$.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#$.executor}executeQuery($,K){if(K!==void 0)l9("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let q=Ie($)?$.compile():$;return this.getExecutor().executeQuery(q)}async[Symbol.asyncDispose](){await this.destroy()}}class Pz extends r9{#$;constructor($){super($);this.#$=$}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin($){return new Pz({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new Pz({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new Pz({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new Pz({...this.#$})}}function I46($){return M4($)&&M4($.config)&&M4($.driver)&&M4($.executor)&&M4($.dialect)}class xe{#$;constructor($){this.#$=k($)}async execute($){return this.#$.executor.provideConnection(async(K)=>{let q=this.#$.executor.withConnectionProvider(new Ow(K)),Y=new r9({...this.#$,executor:q});return await $(Y)})}}class M0{#$;constructor($){this.#$=k($)}setAccessMode($){return new M0({...this.#$,accessMode:$})}setIsolationLevel($){return new M0({...this.#$,isolationLevel:$})}async execute($){let{isolationLevel:K,accessMode:q,...Y}=this.#$,z={isolationLevel:K,accessMode:q};return YS(z),this.#$.executor.provideConnection(async(P)=>{let J=this.#$.executor.withConnectionProvider(new Ow(P)),W=new Pz({...Y,executor:J}),H=!1;try{await this.#$.driver.beginTransaction(P,z),H=!0;let Z=await $(W);return await this.#$.driver.commitTransaction(P),Z}catch(Z){if(H)await this.#$.driver.rollbackTransaction(P);throw Z}})}}class N0{#$;constructor($){this.#$=k($)}setAccessMode($){return new N0({...this.#$,accessMode:$})}setIsolationLevel($){return new N0({...this.#$,isolationLevel:$})}async execute(){let{isolationLevel:$,accessMode:K,...q}=this.#$,Y={isolationLevel:$,accessMode:K};YS(Y);let z=await W0(this.#$.executor);return await this.#$.driver.beginTransaction(z.connection,Y),new KK({...q,connection:z,executor:this.#$.executor.withConnectionProvider(new Ow(z.connection))})}}class KK extends Pz{#$;#K;#q;constructor($){let K={isCommitted:!1,isRolledBack:!1};$={...$,executor:new kq($.executor,K)};let{connection:q,...Y}=$;super(Y);this.#$=k($),this.#q=K;let z=$6();this.#K=(P)=>$.executor.compileQuery(P,z)}get isCommitted(){return this.#q.isCommitted}get isRolledBack(){return this.#q.isRolledBack}commit(){return zz(this.#q),new LJ(async()=>{await this.#$.driver.commitTransaction(this.#$.connection.connection),this.#q.isCommitted=!0,this.#$.connection.release()})}rollback(){return zz(this.#q),new LJ(async()=>{await this.#$.driver.rollbackTransaction(this.#$.connection.connection),this.#q.isRolledBack=!0,this.#$.connection.release()})}savepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.savepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}rollbackToSavepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.rollbackToSavepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}releaseSavepoint($){return zz(this.#q),new LJ(async()=>{return await this.#$.driver.releaseSavepoint?.(this.#$.connection.connection,$,this.#K),new KK({...this.#$})})}withPlugin($){return new KK({...this.#$,executor:this.#$.executor.withPlugin($)})}withoutPlugins(){return new KK({...this.#$,executor:this.#$.executor.withoutPlugins()})}withSchema($){return new KK({...this.#$,executor:this.#$.executor.withPluginAtFront(new c$($))})}withTables(){return new KK({...this.#$})}}class LJ{#$;constructor($){this.#$=$}async execute(){return await this.#$()}}function zz($){if($.isCommitted)throw new Error("Transaction is already committed");if($.isRolledBack)throw new Error("Transaction is already rolled back")}class kq{#$;#K;constructor($,K){if($ instanceof kq)this.#$=$.#$;else this.#$=$;this.#K=K}get adapter(){return this.#$.adapter}get plugins(){return this.#$.plugins}transformQuery($,K){return this.#$.transformQuery($,K)}compileQuery($,K){return this.#$.compileQuery($,K)}provideConnection($){return this.#$.provideConnection($)}executeQuery($){return zz(this.#K),this.#$.executeQuery($)}stream($,K){return zz(this.#K),this.#$.stream($,K)}withConnectionProvider($){return new kq(this.#$.withConnectionProvider($),this.#K)}withPlugin($){return new kq(this.#$.withPlugin($),this.#K)}withPlugins($){return new kq(this.#$.withPlugins($),this.#K)}withPluginAtFront($){return new kq(this.#$.withPluginAtFront($),this.#K)}withoutPlugins(){return new kq(this.#$.withoutPlugins(),this.#K)}}class ww{#$;constructor($){this.#$=k($)}get expressionType(){return}get isRawBuilder(){return!0}as($){return new be(this,$)}$castTo(){return new ww({...this.#$})}$notNull(){return new ww(this.#$)}withPlugin($){return new ww({...this.#$,plugins:this.#$.plugins!==void 0?k([...this.#$.plugins,$]):k([$])})}toOperationNode(){return this.#q(this.#K())}compile($){return this.#Y(this.#K($))}async execute($){let K=this.#K($);return K.executeQuery(this.#Y(K))}#K($){let K=$!==void 0?$.getExecutor():Gq;return this.#$.plugins!==void 0?K.withPlugins(this.#$.plugins):K}#q($){return $.transformQuery(this.#$.rawNode,this.#$.queryId)}#Y($){return $.compileQuery(this.#q($),this.#$.queryId)}}function qK($){return new ww($)}class be{#$;#K;constructor($,K){this.#$=$,this.#K=K}get expression(){return this.#$}get alias(){return this.#K}get rawBuilder(){return this.#$}toOperationNode(){return i4.create(this.#$.toOperationNode(),w1(this.#K)?this.#K.toOperationNode():p8.create(this.#K))}}var U$=Object.assign(($,...K)=>{return qK({queryId:$6(),rawNode:b6.create($,K?.map(ge)??[])})},{ref($){return qK({queryId:$6(),rawNode:b6.createWithChild(y$($))})},val($){return qK({queryId:$6(),rawNode:b6.createWithChild(q1($))})},value($){return this.val($)},table($){return qK({queryId:$6(),rawNode:b6.createWithChild(g6($))})},id(...$){let K=new Array($.length+1).fill(".");return K[0]="",K[K.length-1]="",qK({queryId:$6(),rawNode:b6.create(K,$.map(p8.create))})},lit($){return qK({queryId:$6(),rawNode:b6.createWithChild(G4.createImmediate($))})},literal($){return this.lit($)},raw($){return qK({queryId:$6(),rawNode:b6.createWithSql($)})},join($,K=U$`, `){let q=new Array(Math.max(2*$.length-1,0)),Y=K.toOperationNode();for(let z=0;z<$.length;++z)if(q[2*z]=ge($[z]),z!==$.length-1)q[2*z+1]=Y;return qK({queryId:$6(),rawNode:b6.createWithChildren(q)})}});function ge($){if(w1($))return $.toOperationNode();return q1($)}class PS{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#$=k({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=($)=>{this.nodeStack.push($),this.#$[$.kind]($),this.nodeStack.pop()}}var x46=/'/g;class JS extends PS{#$="";#K=[];get numParameters(){return this.#K.length}compileQuery($,K){return this.#$="",this.#K=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode($),k({query:$,queryId:K,sql:this.getSql(),parameters:[...this.#K]})}getSql(){return this.#$}visitSelectQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!i1.is(this.parentNode)&&!v3.is(this.parentNode)&&!s7.is(this.parentNode)&&!H0.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("select"),$.distinctOn)this.append(" "),this.compileDistinctOn($.distinctOn);if($.frontModifiers?.length)this.append(" "),this.compileList($.frontModifiers," ");if($.top)this.append(" "),this.visitNode($.top);if($.selections)this.append(" "),this.compileList($.selections);if($.from)this.append(" "),this.visitNode($.from);if($.joins)this.append(" "),this.compileList($.joins," ");if($.where)this.append(" "),this.visitNode($.where);if($.groupBy)this.append(" "),this.visitNode($.groupBy);if($.having)this.append(" "),this.visitNode($.having);if($.setOperations)this.append(" "),this.compileList($.setOperations," ");if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.offset)this.append(" "),this.visitNode($.offset);if($.fetch)this.append(" "),this.visitNode($.fetch);if($.endModifiers?.length)this.append(" "),this.compileList(this.sortSelectModifiers([...$.endModifiers])," ");if(K)this.append(")")}visitFrom($){this.append("from "),this.compileList($.froms)}visitSelection($){this.visitNode($.selection)}visitColumn($){this.visitNode($.column)}compileDistinctOn($){this.append("distinct on ("),this.compileList($),this.append(")")}compileList($,K=", "){let q=$.length-1;for(let Y=0;Y<=q;Y++)if(this.visitNode($[Y]),Y<q)this.append(K)}visitWhere($){this.append("where "),this.visitNode($.where)}visitHaving($){this.append("having "),this.visitNode($.having)}visitInsertQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode)&&!Y7.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append($.replace?"replace":"insert"),$.ignore)l9("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore");if($.orAction)this.append(" "),this.visitNode($.orAction);if($.top)this.append(" "),this.visitNode($.top);if($.into)this.append(" into "),this.visitNode($.into);if($.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.output)this.append(" "),this.visitNode($.output);if($.values)this.append(" "),this.visitNode($.values);if($.defaultValues)this.append(" "),this.append("default values");if($.onConflict)this.append(" "),this.visitNode($.onConflict);if($.onDuplicateKey)this.append(" "),this.visitNode($.onDuplicateKey);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitValues($){this.append("values "),this.compileList($.values)}visitDeleteQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("delete "),$.top)this.visitNode($.top),this.append(" ");if(this.visitNode($.from),$.output)this.append(" "),this.visitNode($.output);if($.using)this.append(" "),this.visitNode($.using);if($.joins)this.append(" "),this.compileList($.joins," ");if($.where)this.append(" "),this.visitNode($.where);if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitReturning($){this.append("returning "),this.compileList($.selections)}visitAlias($){this.visitNode($.node),this.append(" as "),this.visitNode($.alias)}visitReference($){if($.table)this.visitNode($.table),this.append(".");this.visitNode($.column)}visitSelectAll($){this.append("*")}visitIdentifier($){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier($),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier($){if(!f1($.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier($.name))}visitAnd($){this.visitNode($.left),this.append(" and "),this.visitNode($.right)}visitOr($){this.visitNode($.left),this.append(" or "),this.visitNode($.right)}visitValue($){if($.immediate)this.appendImmediateValue($.value);else this.appendValue($.value)}visitValueList($){this.append("("),this.compileList($.values),this.append(")")}visitTuple($){this.append("("),this.compileList($.values),this.append(")")}visitPrimitiveValueList($){this.append("(");let{values:K}=$;for(let q=0;q<K.length;++q)if(this.appendValue(K[q]),q!==K.length-1)this.append(", ");this.append(")")}visitParens($){this.append("("),this.visitNode($.node),this.append(")")}visitJoin($){if(this.append(g46[$.joinType]),this.append(" "),this.visitNode($.table),$.on)this.append(" "),this.visitNode($.on)}visitOn($){this.append("on "),this.visitNode($.on)}visitRaw($){let{sqlFragments:K,parameters:q}=$;for(let Y=0;Y<K.length;++Y)if(this.append(K[Y]),q.length>Y)this.visitNode(q[Y])}visitOperator($){this.append($.operator)}visitTable($){this.visitNode($.table)}visitSchemableIdentifier($){if($.schema)this.visitNode($.schema),this.append(".");this.visitNode($.identifier)}visitCreateTable($){if(this.append("create "),$.frontModifiers&&$.frontModifiers.length>0)this.compileList($.frontModifiers," "),this.append(" ");if($.temporary)this.append("temporary ");if(this.append("table "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.table),$.selectQuery)this.append(" as "),this.visitNode($.selectQuery);else{if(this.append(" ("),this.compileList([...$.columns,...$.constraints??[]]),this.append(")"),$.onCommit)this.append(" on commit "),this.append($.onCommit);if($.endModifiers&&$.endModifiers.length>0)this.append(" "),this.compileList($.endModifiers," ")}}visitColumnDefinition($){if($.ifNotExists)this.append("if not exists ");if(this.visitNode($.column),this.append(" "),this.visitNode($.dataType),$.unsigned)this.append(" unsigned");if($.frontModifiers&&$.frontModifiers.length>0)this.append(" "),this.compileList($.frontModifiers," ");if($.generated)this.append(" "),this.visitNode($.generated);if($.identity)this.append(" identity");if($.defaultTo)this.append(" "),this.visitNode($.defaultTo);if($.notNull)this.append(" not null");if($.unique)this.append(" unique");if($.nullsNotDistinct)this.append(" nulls not distinct");if($.primaryKey)this.append(" primary key");if($.autoIncrement)this.append(" "),this.append(this.getAutoIncrement());if($.references)this.append(" "),this.visitNode($.references);if($.check)this.append(" "),this.visitNode($.check);if($.endModifiers&&$.endModifiers.length>0)this.append(" "),this.compileList($.endModifiers," ")}getAutoIncrement(){return"auto_increment"}visitReferences($){if(this.append("references "),this.visitNode($.table),this.append(" ("),this.compileList($.columns),this.append(")"),$.onDelete)this.append(" on delete "),this.append($.onDelete);if($.onUpdate)this.append(" on update "),this.append($.onUpdate)}visitDropTable($){if(this.append("drop table "),$.ifExists)this.append("if exists ");if(this.visitNode($.table),$.cascade)this.append(" cascade")}visitDataType($){this.append($.dataType)}visitOrderBy($){this.append("order by "),this.compileList($.items)}visitOrderByItem($){if(this.visitNode($.orderBy),$.collation)this.append(" "),this.visitNode($.collation);if($.direction)this.append(" "),this.visitNode($.direction);if($.nulls)this.append(" nulls "),this.append($.nulls)}visitGroupBy($){this.append("group by "),this.compileList($.items)}visitGroupByItem($){this.visitNode($.groupBy)}visitUpdateQuery($){let K=this.parentNode!==void 0&&!m$.is(this.parentNode)&&!b6.is(this.parentNode)&&!Y7.is(this.parentNode);if(this.parentNode===void 0&&$.explain)this.visitNode($.explain),this.append(" ");if(K)this.append("(");if($.with)this.visitNode($.with),this.append(" ");if(this.append("update "),$.top)this.visitNode($.top),this.append(" ");if($.table)this.visitNode($.table),this.append(" ");if(this.append("set "),$.updates)this.compileList($.updates);if($.output)this.append(" "),this.visitNode($.output);if($.from)this.append(" "),this.visitNode($.from);if($.joins){if(!$.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList($.joins," ")}if($.where)this.append(" "),this.visitNode($.where);if($.orderBy)this.append(" "),this.visitNode($.orderBy);if($.limit)this.append(" "),this.visitNode($.limit);if($.returning)this.append(" "),this.visitNode($.returning);if(K)this.append(")");if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitColumnUpdate($){this.visitNode($.column),this.append(" = "),this.visitNode($.value)}visitLimit($){this.append("limit "),this.visitNode($.limit)}visitOffset($){this.append("offset "),this.visitNode($.offset)}visitOnConflict($){if(this.append("on conflict"),$.columns)this.append(" ("),this.compileList($.columns),this.append(")");else if($.constraint)this.append(" on constraint "),this.visitNode($.constraint);else if($.indexExpression)this.append(" ("),this.visitNode($.indexExpression),this.append(")");if($.indexWhere)this.append(" "),this.visitNode($.indexWhere);if($.doNothing===!0)this.append(" do nothing");else if($.updates){if(this.append(" do update set "),this.compileList($.updates),$.updateWhere)this.append(" "),this.visitNode($.updateWhere)}}visitOnDuplicateKey($){this.append("on duplicate key update "),this.compileList($.updates)}visitCreateIndex($){if(this.append("create "),$.unique)this.append("unique ");if(this.append("index "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.name),$.table)this.append(" on "),this.visitNode($.table);if($.using)this.append(" using "),this.visitNode($.using);if($.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.nullsNotDistinct)this.append(" nulls not distinct");if($.where)this.append(" "),this.visitNode($.where)}visitDropIndex($){if(this.append("drop index "),$.ifExists)this.append("if exists ");if(this.visitNode($.name),$.table)this.append(" on "),this.visitNode($.table);if($.cascade)this.append(" cascade")}visitCreateSchema($){if(this.append("create schema "),$.ifNotExists)this.append("if not exists ");this.visitNode($.schema)}visitDropSchema($){if(this.append("drop schema "),$.ifExists)this.append("if exists ");if(this.visitNode($.schema),$.cascade)this.append(" cascade")}visitPrimaryKeyConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");this.append("primary key ("),this.compileList($.columns),this.append(")"),this.buildDeferrable($)}buildDeferrable($){if($.deferrable!==void 0)if($.deferrable)this.append(" deferrable");else this.append(" not deferrable");if($.initiallyDeferred!==void 0)if($.initiallyDeferred)this.append(" initially deferred");else this.append(" initially immediate")}visitUniqueConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");if(this.append("unique"),$.nullsNotDistinct)this.append(" nulls not distinct");this.append(" ("),this.compileList($.columns),this.append(")"),this.buildDeferrable($)}visitCheckConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");this.append("check ("),this.visitNode($.expression),this.append(")")}visitForeignKeyConstraint($){if($.name)this.append("constraint "),this.visitNode($.name),this.append(" ");if(this.append("foreign key ("),this.compileList($.columns),this.append(") "),this.visitNode($.references),$.onDelete)this.append(" on delete "),this.append($.onDelete);if($.onUpdate)this.append(" on update "),this.append($.onUpdate);this.buildDeferrable($)}visitList($){this.compileList($.items)}visitWith($){if(this.append("with "),$.recursive)this.append("recursive ");this.compileList($.expressions)}visitCommonTableExpression($){if(this.visitNode($.name),this.append(" as "),tY($.materialized)){if(!$.materialized)this.append("not ");this.append("materialized ")}this.visitNode($.expression)}visitCommonTableExpressionName($){if(this.visitNode($.table),$.columns)this.append("("),this.compileList($.columns),this.append(")")}visitAlterTable($){if(this.append("alter table "),this.visitNode($.table),this.append(" "),$.renameTo)this.append("rename to "),this.visitNode($.renameTo);if($.setSchema)this.append("set schema "),this.visitNode($.setSchema);if($.addConstraint)this.visitNode($.addConstraint);if($.dropConstraint)this.visitNode($.dropConstraint);if($.renameConstraint)this.visitNode($.renameConstraint);if($.columnAlterations)this.compileColumnAlterations($.columnAlterations);if($.addIndex)this.visitNode($.addIndex);if($.dropIndex)this.visitNode($.dropIndex)}visitAddColumn($){this.append("add column "),this.visitNode($.column)}visitRenameColumn($){this.append("rename column "),this.visitNode($.column),this.append(" to "),this.visitNode($.renameTo)}visitDropColumn($){this.append("drop column "),this.visitNode($.column)}visitAlterColumn($){if(this.append("alter column "),this.visitNode($.column),this.append(" "),$.dataType){if(this.announcesNewColumnDataType())this.append("type ");if(this.visitNode($.dataType),$.dataTypeExpression)this.append("using "),this.visitNode($.dataTypeExpression)}if($.setDefault)this.append("set default "),this.visitNode($.setDefault);if($.dropDefault)this.append("drop default");if($.setNotNull)this.append("set not null");if($.dropNotNull)this.append("drop not null")}visitModifyColumn($){this.append("modify column "),this.visitNode($.column)}visitAddConstraint($){this.append("add "),this.visitNode($.constraint)}visitDropConstraint($){if(this.append("drop constraint "),$.ifExists)this.append("if exists ");if(this.visitNode($.constraintName),$.modifier==="cascade")this.append(" cascade");else if($.modifier==="restrict")this.append(" restrict")}visitRenameConstraint($){this.append("rename constraint "),this.visitNode($.oldName),this.append(" to "),this.visitNode($.newName)}visitSetOperation($){if(this.append($.operator),this.append(" "),$.all)this.append("all ");this.visitNode($.expression)}visitCreateView($){if(this.append("create "),$.orReplace)this.append("or replace ");if($.materialized)this.append("materialized ");if($.temporary)this.append("temporary ");if(this.append("view "),$.ifNotExists)this.append("if not exists ");if(this.visitNode($.name),this.append(" "),$.columns)this.append("("),this.compileList($.columns),this.append(") ");if($.as)this.append("as "),this.visitNode($.as)}visitRefreshMaterializedView($){if(this.append("refresh materialized view "),$.concurrently)this.append("concurrently ");if(this.visitNode($.name),$.withNoData)this.append(" with no data");else this.append(" with data")}visitDropView($){if(this.append("drop "),$.materialized)this.append("materialized ");if(this.append("view "),$.ifExists)this.append("if exists ");if(this.visitNode($.name),$.cascade)this.append(" cascade")}visitGenerated($){if(this.append("generated "),$.always)this.append("always ");if($.byDefault)this.append("by default ");if(this.append("as "),$.identity)this.append("identity");if($.expression)this.append("("),this.visitNode($.expression),this.append(")");if($.stored)this.append(" stored")}visitDefaultValue($){this.append("default "),this.visitNode($.defaultValue)}visitSelectModifier($){if($.rawModifier)this.visitNode($.rawModifier);else this.append(b46[$.modifier]);if($.of)this.append(" of "),this.compileList($.of,", ")}visitCreateType($){if(this.append("create type "),this.visitNode($.name),$.enum)this.append(" as enum "),this.visitNode($.enum)}visitDropType($){if(this.append("drop type "),$.ifExists)this.append("if exists ");this.visitNode($.name)}visitExplain($){if(this.append("explain"),$.options||$.format){if(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),$.options){if(this.visitNode($.options),$.format)this.append(this.getExplainOptionsDelimiter())}if($.format)this.append("format"),this.append(this.getExplainOptionAssignment()),this.append($.format);this.append(this.getRightExplainOptionsWrapper())}}visitDefaultInsertValue($){this.append("default")}visitAggregateFunction($){if(this.append($.func),this.append("("),$.distinct)this.append("distinct ");if(this.compileList($.aggregated),$.orderBy)this.append(" "),this.visitNode($.orderBy);if(this.append(")"),$.withinGroup)this.append(" within group ("),this.visitNode($.withinGroup),this.append(")");if($.filter)this.append(" filter("),this.visitNode($.filter),this.append(")");if($.over)this.append(" "),this.visitNode($.over)}visitOver($){if(this.append("over("),$.partitionBy){if(this.visitNode($.partitionBy),$.orderBy)this.append(" ")}if($.orderBy)this.visitNode($.orderBy);this.append(")")}visitPartitionBy($){this.append("partition by "),this.compileList($.items)}visitPartitionByItem($){this.visitNode($.partitionBy)}visitBinaryOperation($){this.visitNode($.leftOperand),this.append(" "),this.visitNode($.operator),this.append(" "),this.visitNode($.rightOperand)}visitUnaryOperation($){if(this.visitNode($.operator),!this.isMinusOperator($.operator))this.append(" ");this.visitNode($.operand)}isMinusOperator($){return g$.is($)&&$.operator==="-"}visitUsing($){this.append("using "),this.compileList($.tables)}visitFunction($){this.append($.func),this.append("("),this.compileList($.arguments),this.append(")")}visitCase($){if(this.append("case"),$.value)this.append(" "),this.visitNode($.value);if($.when)this.append(" "),this.compileList($.when," ");if($.else)this.append(" else "),this.visitNode($.else);if(this.append(" end"),$.isStatement)this.append(" case")}visitWhen($){if(this.append("when "),this.visitNode($.condition),$.result)this.append(" then "),this.visitNode($.result)}visitJSONReference($){this.visitNode($.reference),this.visitNode($.traversal)}visitJSONPath($){if($.inOperator)this.visitNode($.inOperator);this.append("'$");for(let K of $.pathLegs)this.visitNode(K);this.append("'")}visitJSONPathLeg($){let K=$.type==="ArrayLocation";if(this.append(K?"[":"."),this.append(String($.value)),K)this.append("]")}visitJSONOperatorChain($){for(let K=0,q=$.values.length;K<q;K++){if(K===q-1)this.visitNode($.operator);else this.append("->");this.visitNode($.values[K])}}visitMergeQuery($){if($.with)this.visitNode($.with),this.append(" ");if(this.append("merge "),$.top)this.visitNode($.top),this.append(" ");if(this.append("into "),this.visitNode($.into),$.using)this.append(" "),this.visitNode($.using);if($.whens)this.append(" "),this.compileList($.whens," ");if($.returning)this.append(" "),this.visitNode($.returning);if($.output)this.append(" "),this.visitNode($.output);if($.endModifiers?.length)this.append(" "),this.compileList($.endModifiers," ")}visitMatched($){if($.not)this.append("not ");if(this.append("matched"),$.bySource)this.append(" by source")}visitAddIndex($){if(this.append("add "),$.unique)this.append("unique ");if(this.append("index "),this.visitNode($.name),$.columns)this.append(" ("),this.compileList($.columns),this.append(")");if($.using)this.append(" using "),this.visitNode($.using)}visitCast($){this.append("cast("),this.visitNode($.expression),this.append(" as "),this.visitNode($.dataType),this.append(")")}visitFetch($){this.append("fetch next "),this.visitNode($.rowCount),this.append(` rows ${$.modifier}`)}visitOutput($){this.append("output "),this.compileList($.selections)}visitTop($){if(this.append(`top(${$.expression})`),$.modifiers)this.append(` ${$.modifiers}`)}visitOrAction($){this.append($.action)}visitCollate($){this.append("collate "),this.visitNode($.collation)}append($){this.#$+=$}appendValue($){this.addParameter($),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier($){let K=this.getLeftIdentifierWrapper(),q=this.getRightIdentifierWrapper(),Y="";for(let z of $)if(Y+=z,z===K)Y+=K;else if(z===q)Y+=q;return Y}sanitizeStringLiteral($){return $.replace(x46,"''")}addParameter($){this.#K.push($)}appendImmediateValue($){if(f1($))this.appendStringLiteral($);else if(Hq($)||tY($)||YJ($))this.append($.toString());else if(qJ($))this.append("null");else if(Et($))this.appendImmediateValue($.toISOString());else throw new Error(`invalid immediate value ${$}`)}appendStringLiteral($){this.append("'"),this.append(this.sanitizeStringLiteral($)),this.append("'")}sortSelectModifiers($){return $.sort((K,q)=>K.modifier&&q.modifier?ye[K.modifier]-ye[q.modifier]:1),k($)}compileColumnAlterations($){this.compileList($)}announcesNewColumnDataType(){return!0}}var b46=k({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),ye=k({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),g46=k({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"});var h0=k({raw($,K=[]){return k({sql:$,query:b6.createWithSql($),parameters:k(K),queryId:$6()})}});class WS{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}function C0($,K){return b6.createWithChildren([b6.createWithSql(`${$} `),p8.create(K)])}class HS{#$;#K=new me;#q;#Y;constructor($){this.#$=k({...$})}async init(){if(this.#q=A1(this.#$.database)?await this.#$.database():this.#$.database,this.#Y=new ue(this.#q),this.#$.onCreateConnection)await this.#$.onCreateConnection(this.#Y)}async acquireConnection(){return await this.#K.lock(),this.#Y}async beginTransaction($){await $.executeQuery(h0.raw("begin"))}async commitTransaction($){await $.executeQuery(h0.raw("commit"))}async rollbackTransaction($){await $.executeQuery(h0.raw("rollback"))}async savepoint($,K,q){await $.executeQuery(q(C0("savepoint",K),$6()))}async rollbackToSavepoint($,K,q){await $.executeQuery(q(C0("rollback to",K),$6()))}async releaseSavepoint($,K,q){await $.executeQuery(q(C0("release",K),$6()))}async releaseConnection(){this.#K.unlock()}async destroy(){this.#q?.close()}}class ue{#$;constructor($){this.#$=$}executeQuery($){let{sql:K,parameters:q}=$,Y=this.#$.prepare(K);if(Y.reader)return Promise.resolve({rows:Y.all(q)});let{changes:z,lastInsertRowid:P}=Y.run(q);return Promise.resolve({numAffectedRows:z!==void 0&&z!==null?BigInt(z):void 0,insertId:P!==void 0&&P!==null?BigInt(P):void 0,rows:[]})}async*streamQuery($,K){let{sql:q,parameters:Y,query:z}=$,P=this.#$.prepare(q);if(m6.is(z)){let J=P.iterate(Y);for(let W of J)yield{rows:[W]}}else throw new Error("Sqlite driver only supports streaming of select queries")}}class me{#$;#K;async lock(){while(this.#$)await this.#$;this.#$=new Promise(($)=>{this.#K=$})}unlock(){let $=this.#K;this.#$=void 0,this.#K=void 0,$?.()}}var y46=/"/g;class ZS extends JS{visitOrAction($){this.append("or "),this.append($.action)}getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier($){return $.replace(y46,'""')}visitDefaultInsertValue($){this.append("null")}}class OS{transformQuery($){return $.node}async transformResult($){return $.result}}var XS="kysely_migration",D0="kysely_migration_lock",u46=!1,wS="migration_lock",_S1=k({__noMigrations__:!0});class m46{#$;constructor($){this.#$=k($)}async getMigrations(){let $=await this.#X(this.#Y)?await this.#$.db.withPlugin(this.#P).selectFrom(this.#Y).select(["name","timestamp"]).$narrowType().execute():[];return(await this.#k()).map(({name:q,...Y})=>{let z=$.find((P)=>P.name===q);return{name:q,migration:Y,executedAt:z?new Date(z.timestamp):void 0}})}async migrateToLatest(){return this.#K(()=>({direction:"Up",step:1/0}))}async migrateTo($){return this.#K(({migrations:K,executedMigrations:q,pendingMigrations:Y})=>{if(M4($)&&$.__noMigrations__===!0)return{direction:"Down",step:1/0};if(!K.find((J)=>J.name===$))throw new Error(`migration "${$}" doesn't exist`);let z=q.indexOf($),P=Y.findIndex((J)=>J.name===$);if(z!==-1)return{direction:"Down",step:q.length-z-1};else if(P!==-1)return{direction:"Up",step:P+1};else throw new Error(`migration "${$}" isn't executed or pending`)})}async migrateUp(){return this.#K(()=>({direction:"Up",step:1}))}async migrateDown(){return this.#K(()=>({direction:"Down",step:1}))}async#K($){try{return await this.#H(),await this.#C($)}catch(K){if(K instanceof R0)return K.resultSet;return{error:K}}}get#q(){return this.#$.migrationTableSchema}get#Y(){return this.#$.migrationTableName??XS}get#z(){return this.#$.migrationLockTableName??D0}get#w(){return this.#$.allowUnorderedMigrations??u46}get#P(){if(this.#q)return new c$(this.#q);return new OS}async#H(){await this.#W(),await this.#O(),await this.#J(),await this.#f()}async#W(){if(!this.#q)return;if(!await this.#v())try{await this.#A(this.#$.db.schema.createSchema(this.#q))}catch($){if(!await this.#v())throw $}}async#O(){if(!await this.#X(this.#Y))try{if(this.#q)await this.#A(this.#$.db.schema.createSchema(this.#q));await this.#A(this.#$.db.schema.withPlugin(this.#P).createTable(this.#Y).addColumn("name","varchar(255)",($)=>$.notNull().primaryKey()).addColumn("timestamp","varchar(255)",($)=>$.notNull()))}catch($){if(!await this.#X(this.#Y))throw $}}async#J(){if(!await this.#X(this.#z))try{await this.#A(this.#$.db.schema.withPlugin(this.#P).createTable(this.#z).addColumn("id","varchar(255)",($)=>$.notNull().primaryKey()).addColumn("is_locked","integer",($)=>$.notNull().defaultTo(0)))}catch($){if(!await this.#X(this.#z))throw $}}async#f(){if(!await this.#j())try{await this.#$.db.withPlugin(this.#P).insertInto(this.#z).values({id:wS,is_locked:0}).execute()}catch($){if(!await this.#j())throw $}}async#v(){return(await this.#$.db.introspection.getSchemas()).some((K)=>K.name===this.#q)}async#X($){let K=this.#q;return(await this.#$.db.introspection.getTables({withInternalKyselyTables:!0})).some((Y)=>Y.name===$&&(!K||Y.schema===K))}async#j(){return!!await this.#$.db.withPlugin(this.#P).selectFrom(this.#z).where("id","=",wS).select("id").executeTakeFirst()}async#C($){let K=this.#$.db.getExecutor().adapter,q=k({lockTable:this.#$.migrationLockTableName??D0,lockRowId:wS,lockTableSchema:this.#$.migrationTableSchema}),Y=async(z)=>{try{await K.acquireMigrationLock(z,q);let P=await this.#_(z);if(P.migrations.length===0)return{results:[]};let{direction:J,step:W}=$(P);if(W<=0)return{results:[]};if(J==="Down")return await this.#G(z,P,W);else if(J==="Up")return await this.#D(z,P,W);return{results:[]}}finally{await K.releaseMigrationLock(z,q)}};if(K.supportsTransactionalDdl&&!this.#$.disableTransactions)return this.#$.db.transaction().execute(Y);else return this.#$.db.connection().execute(Y)}async#_($){let K=await this.#k(),q=await this.#V($);if(this.#M(K,q),!this.#w)this.#N(K,q);let Y=this.#R(K,q);return k({migrations:K,executedMigrations:q,lastMigration:Lt(q),pendingMigrations:Y})}#R($,K){return $.filter((q)=>{return!K.includes(q.name)})}async#k(){let $=await this.#$.provider.getMigrations();return Object.keys($).sort().map((K)=>({...$[K],name:K}))}async#V($){let K=await $.withPlugin(this.#P).selectFrom(this.#Y).select(["name","timestamp"]).$narrowType().execute(),q=this.#$.nameComparator||((Y,z)=>Y.localeCompare(z));return K.sort((Y,z)=>{if(Y.timestamp===z.timestamp)return q(Y.name,z.name);return new Date(Y.timestamp).getTime()-new Date(z.timestamp).getTime()}).map((Y)=>Y.name)}#M($,K){for(let q of K)if(!$.some((Y)=>Y.name===q))throw new Error(`corrupted migrations: previously executed migration ${q} is missing`)}#N($,K){for(let q=0;q<K.length;++q)if($[q].name!==K[q])throw new Error(`corrupted migrations: expected previously executed migration ${K[q]} to be at index ${q} but ${$[q].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)}async#G($,K,q){let Y=K.executedMigrations.slice().reverse().slice(0,q).map((P)=>{return K.migrations.find((J)=>J.name===P)}),z=Y.map((P)=>{return{migrationName:P.name,direction:"Down",status:"NotExecuted"}});for(let P=0;P<z.length;++P){let J=Y[P];try{if(J.down)await J.down($),await $.withPlugin(this.#P).deleteFrom(this.#Y).where("name","=",J.name).execute(),z[P]={migrationName:J.name,direction:"Down",status:"Success"}}catch(W){throw z[P]={migrationName:J.name,direction:"Down",status:"Error"},new R0({error:W,results:z})}}return{results:z}}async#D($,K,q){let z=K.pendingMigrations.slice(0,q).map((P)=>{return{migrationName:P.name,direction:"Up",status:"NotExecuted"}});for(let P=0;P<z.length;P++){let J=K.pendingMigrations[P];try{await J.up($),await $.withPlugin(this.#P).insertInto(this.#Y).values({name:J.name,timestamp:new Date().toISOString()}).execute(),z[P]={migrationName:J.name,direction:"Up",status:"Success"}}catch(W){throw z[P]={migrationName:J.name,direction:"Up",status:"Error"},new R0({error:W,results:z})}}return{results:z}}async#A($){if(this.#$.db.getExecutor().adapter.supportsCreateIfNotExists)$=$.ifNotExists();await $.execute()}}class R0 extends Error{#$;constructor($){super();this.#$=$}get resultSet(){return this.#$}}class TS{#$;constructor($){this.#$=$}async getSchemas(){return[]}async getTables($={withInternalKyselyTables:!1}){return await this.#q($)}async getMetadata($){return{tables:await this.getTables($)}}#K($,K){let q=$.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select(["name","sql","type"]).orderBy("name");if(!K.withInternalKyselyTables)q=q.where("name","!=",XS).where("name","!=",D0);return q}async#q($){let K=await this.#K(this.#$,$).execute(),q=await this.#$.with("table_list",(z)=>this.#K(z,$)).selectFrom(["table_list as tl",U$`pragma_table_info(tl.name)`.as("p")]).select(["tl.name as table","p.cid","p.name","p.type","p.notnull","p.dflt_value","p.pk"]).orderBy("tl.name").orderBy("p.cid").execute(),Y={};for(let z of q)Y[z.table]??=[],Y[z.table].push(z);return K.map(({name:z,sql:P,type:J})=>{let W=P?.split(/[\(\),]/)?.find((Z)=>Z.toLowerCase().includes("autoincrement"))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g,""),H=Y[z]??[];if(!W){let Z=H.filter((O)=>O.pk>0);if(Z.length===1&&Z[0].type.toLowerCase()==="integer")W=Z[0].name}return{name:z,isView:J==="view",columns:H.map((Z)=>({name:Z.name,dataType:Z.type,isNullable:!Z.notnull,isAutoIncrementing:Z.name===W,hasDefaultValue:Z.dflt_value!=null,comment:void 0}))}})}}class jS extends WS{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock($,K){}async releaseMigrationLock($,K){}}class vS{#$;constructor($){this.#$=k({...$})}createDriver(){return new HS(this.#$)}createQueryCompiler(){return new ZS}createAdapter(){return new jS}createIntrospector($){return new TS($)}}import{existsSync as EW6,mkdirSync as LW6}from"fs";import{dirname as IW6}from"path";var pe=async($)=>{return(await U$`
|
|
450
450
|
SELECT name FROM sqlite_master WHERE type='table' AND name='entities'
|
|
451
451
|
`.execute($)).rows.length>0},ce=async($)=>{await $.schema.createTable("projects").addColumn("id","integer",(K)=>K.primaryKey()).addColumn("object_id","text",(K)=>K.notNull().unique()).addColumn("name","text",(K)=>K.notNull()).addColumn("path","text",(K)=>K.notNull().unique()).addColumn("created_at","text",(K)=>K.notNull()).addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("stores").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("object_id","text",(K)=>K.notNull().unique()).addColumn("type","text",(K)=>K.notNull()).addColumn("code","text").addColumn("name","text",(K)=>K.notNull()).addColumn("created_at","text",(K)=>K.notNull()).addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("store_children").addColumn("parent_store_id","integer",(K)=>K.notNull().references("stores.id").onDelete("cascade")).addColumn("child_store_id","integer",(K)=>K.notNull().references("stores.id").onDelete("cascade")).execute(),await $.schema.createIndex("store_children_pk").on("store_children").columns(["parent_store_id","child_store_id"]).unique().execute(),await $.schema.createTable("project_stores").addColumn("project_id","integer",(K)=>K.notNull().references("projects.id").onDelete("cascade")).addColumn("store_id","integer",(K)=>K.notNull().references("stores.id").onDelete("cascade")).addColumn("is_root","integer",(K)=>K.notNull().defaultTo(0)).execute(),await $.schema.createIndex("project_stores_pk").on("project_stores").columns(["project_id","store_id"]).unique().execute(),await $.schema.createTable("sequences").addColumn("scope_type","text",(K)=>K.notNull()).addColumn("scope_id","integer",(K)=>K.references("stores.id").onDelete("cascade")).addColumn("type_code","text",(K)=>K.notNull()).addColumn("next_value","integer",(K)=>K.notNull().defaultTo(1)).execute(),await U$`
|
|
452
452
|
CREATE UNIQUE INDEX sequences_pk
|
|
@@ -458,7 +458,7 @@ globstar while`,$,w,K,X,T),this.matchOne($.slice(w),K.slice(X),q))return this.de
|
|
|
458
458
|
CREATE UNIQUE INDEX entities_name_unique
|
|
459
459
|
ON entities(store_id, parent_folder_id, name)
|
|
460
460
|
WHERE deleted_at IS NULL AND name IS NOT NULL
|
|
461
|
-
`.execute($),await $.schema.createIndex("entities_store_id_idx").on("entities").columns(["store_id"]).execute(),await $.schema.createIndex("entities_parent_folder_id_idx").on("entities").columns(["parent_folder_id"]).execute(),await $.schema.createTable("folders").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).execute(),await $.schema.createTable("documents").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("published_version_id","integer",(K)=>K.references("document_versions.id")).execute(),await $.schema.createTable("document_drafts").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("content","text").addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("document_versions").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("entity_id","integer",(K)=>K.notNull().references("entities.id").onDelete("cascade")).addColumn("version_number","integer",(K)=>K.notNull()).addColumn("content","text").addColumn("published_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("document_versions_entity_version_unique").on("document_versions").columns(["entity_id","version_number"]).unique().execute(),await $.schema.createIndex("document_versions_entity_id_idx").on("document_versions").columns(["entity_id"]).execute(),await $.schema.createTable("document_edit_state").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("client_id","text",(K)=>K.notNull()).addColumn("started_at","text",(K)=>K.notNull()).addColumn("last_activity_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("field_definitions").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("store_id","integer",(K)=>K.notNull().references("stores.id").onDelete("cascade")).addColumn("object_id","text",(K)=>K.notNull()).addColumn("entity_type_id","integer",(K)=>K.notNull().references("entity_types.id")).addColumn("type_code","text",(K)=>K.notNull()).addColumn("seq","integer",(K)=>K.notNull()).addColumn("owner_entity_id","integer",(K)=>K.references("entities.id").onDelete("cascade")).addColumn("name","text",(K)=>K.notNull()).addColumn("label","text").addColumn("description","text").addColumn("primitive_type","text",(K)=>K.notNull()).addColumn("required","integer",(K)=>K.notNull().defaultTo(0)).addColumn("multiplicity","text",(K)=>K.notNull().defaultTo("single")).addColumn("config","text").addColumn("is_system","integer",(K)=>K.notNull().defaultTo(0)).addColumn("ordinal","integer").addColumn("created_at","text",(K)=>K.notNull()).addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("idx_field_def_object_id_unique").on("field_definitions").columns(["store_id","object_id"]).unique().execute(),await $.schema.createIndex("idx_field_def_store_type_seq").on("field_definitions").columns(["store_id","type_code","seq"]).unique().execute(),await $.schema.createIndex("idx_field_def_owner").on("field_definitions").columns(["owner_entity_id"]).execute(),await $.schema.createIndex("idx_field_def_owner_name").on("field_definitions").columns(["owner_entity_id","name"]).execute(),await $.schema.createTable("field_values").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("entity_id","integer",(K)=>K.notNull().references("entities.id").onDelete("cascade")).addColumn("field_definition_id","integer",(K)=>K.notNull().references("field_definitions.id").onDelete("cascade")).addColumn("value","text").addColumn("ordinal","integer").addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("idx_field_values_entity").on("field_values").columns(["entity_id"]).execute(),await $.schema.createIndex("idx_field_values_entity_def").on("field_values").columns(["entity_id","field_definition_id"]).execute()};var p46=()=>new Date().toISOString(),K4=p46;var c46=[{code:"f",name:"Folder",subtype:null},{code:"f",name:"Document Root Folder",subtype:"root_d"},{code:"f",name:"Template Root Folder",subtype:"root_t"},{code:"d",name:"Document",subtype:null},{code:"t",name:"Template",subtype:null},{code:"n",name:"field_definition",subtype:null}],Ue=async($)=>{return(await $.selectFrom("entity_types").select("id").limit(1).execute()).length>0},B46=async($,K,q=null)=>{return(await $.selectFrom("entity_types").select("id").where("code","=",K).where((z)=>q?z("subtype","=",q):z("subtype","is",null)).executeTakeFirstOrThrow()).id},Be=async($,K,q,Y)=>{let z=K4(),J=await B46($,"f",Y==="d"?"root_d":"root_t");if(!await $.selectFrom("sequences").select("next_value").where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").executeTakeFirst())await $.insertInto("sequences").values({scope_type:"store",scope_id:K,type_code:"f",next_value:1}).execute();let H=await $.selectFrom("sequences").select("next_value").where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").executeTakeFirst();await $.updateTable("sequences").set((X)=>({next_value:X("next_value","+",1)})).where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").execute();let Z=`${q}f${H.next_value}`,O=await $.insertInto("entities").values({store_id:K,object_id:Z,entity_type_id:J,type_code:"f",seq:H.next_value,parent_folder_id:null,parent_object_id:null,name:null,created_at:z,updated_at:z}).returning("id").executeTakeFirstOrThrow();await $.insertInto("folders").values({entity_id:O.id}).execute();let w=Y==="d"?"document":"template";return O.id},U46=async($)=>{for(let K of c46)await $.insertInto("entity_types").values(K).execute()},l46=async($)=>{let K=await $.selectFrom("sequences").select("next_value").where("scope_type","=","global").where("scope_id","is",null).where("type_code","=","s").executeTakeFirstOrThrow();await $.updateTable("sequences").set((P)=>({next_value:P("next_value","+",1)})).where("scope_type","=","global").where("scope_id","is",null).where("type_code","=","s").execute();let q=`S${K.next_value}`,Y=K4(),z=await $.insertInto("stores").values({id:K.next_value,object_id:q,type:"local",code:"B",name:"Shared",created_at:Y,updated_at:Y}).returning("id").executeTakeFirstOrThrow();await Be($,z.id,"B","d"),await Be($,z.id,"B","t")},le=async($)=>{await U46($),await $.insertInto("sequences").values([{scope_type:"global",scope_id:null,type_code:"s",next_value:1},{scope_type:"global",scope_id:null,type_code:"p",next_value:1}]).execute(),await l46($)};var S0=K1(ie(),1),F46=($,K)=>{if($)throw new Error(K)},Qe=($,K)=>{if(S0.default.null($)||S0.default.undefined($))throw new Error(`${K} is required`)},i46=($,K)=>{if(Qe($,K),S0.default.empty($))throw new Error(`${K} cannot be empty`)},Q46=($,K,...q)=>{if($)throw K(...q)},d46={condition:F46,nullish:Qe,empty:i46,factory:Q46},Y8=d46;var xW6=typeof Bun!=="undefined",bW6=async($)=>{if(xW6){let{Database:K}=await import("bun:sqlite"),{BunSqliteDialect:q}=await Promise.resolve().then(() => K1(NP8(),1)),Y=new K($);return Y.exec("PRAGMA journal_mode = WAL"),Y.exec("PRAGMA foreign_keys = ON"),new r9({dialect:new q({database:Y})})}else{let q=new(await import("better-sqlite3")).default($);return q.pragma("journal_mode = WAL"),q.pragma("foreign_keys = ON"),new r9({dialect:new vS({database:q})})}},gW6=($,K)=>{if(!EW6($)){if(!K)throw new Error(`Database file not found: ${$}`);LW6(IW6($),{recursive:!0})}},yW6=async($,K)=>{if(!await pe($)){if(!K)throw new Error("Database schema not found");await ce($)}},uW6=async($,K)=>{if(!await Ue($)){if(!K)throw new Error("Database seed data not found");await le($)}},mW6=($)=>{let{kyselyFactory:K=bW6}=$??{};return Object.freeze({getDb:async(Y,z)=>{if(Y8.nullish(Y,"databaseFilepath"),Y!==":memory:")gW6(Y,z);let P=await K(Y);return await yW6(P,z),await uW6(P,z),P}})},hP8={create:mW6};var pW6=($)=>{let{id:K,name:q,createdAt:Y,updatedAt:z}=$,Z=Object.freeze({getObjectId:()=>K,getName:()=>q,getCreatedAt:()=>Y,getUpdatedAt:()=>z}),X=Object.freeze({setName:(T)=>{q=T},setUpdatedAt:(T)=>{z=T}});return{entityFns:Z,mutationFns:X}},K5=Object.freeze({create:pW6});var cW6=($)=>{let{id:K,name:q,path:Y,createdAt:z,updatedAt:P}=$,{entityFns:J,mutationFns:W}=K5.create({id:K,name:q,createdAt:z,updatedAt:P}),H=()=>Y,O=Object.freeze({...J,getPath:H,toJSON:()=>({objectId:J.getObjectId(),name:J.getName(),path:H(),createdAt:J.getCreatedAt(),updatedAt:J.getUpdatedAt()})}),X=Object.freeze({...W,setPath:(T)=>{Y=T}});return{entity:O,mutationApi:X}},CP8=Object.freeze({create:cW6});var BW6=($,K,q)=>{return Object.freeze({getEntity:()=>$,getMutationApi:()=>K,getPk:()=>q})},l6=Object.freeze({create:BW6});var UW6=async($,K,q,Y)=>{if(!await $.selectFrom("sequences").select("next_value").where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).executeTakeFirst())await $.insertInto("sequences").values({scope_type:K,scope_id:q,type_code:Y,next_value:1}).execute();let P=await $.selectFrom("sequences").select("next_value").where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).executeTakeFirstOrThrow();return await $.updateTable("sequences").set((J)=>({next_value:J("next_value","+",1)})).where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).execute(),P.next_value},q5=Object.freeze({nextSeq:UW6});var lW6=($)=>$.object_id,RP8=($)=>{if(!$||$.length<2||$[0]!=="P")return null;let K=parseInt($.slice(1),10);return isNaN(K)?null:K},Tf=($)=>{let K=lW6($),q=$.id,{entity:Y,mutationApi:z}=CP8.create({id:K,name:$.name,path:$.path,createdAt:$.created_at,updatedAt:$.updated_at});return{entity:Y,mutationApi:z,id:K,pk:q}},FW6=()=>{let $=new Map;return Object.freeze({createProject:async(J,W,{name:H,path:Z},O)=>{let w=K4(),X=await q5.nextSeq(J,"global",null,"p"),T=`P${X}`,G=await J.insertInto("projects").values({id:X,object_id:T,name:H,path:Z,created_at:w,updated_at:w}).returningAll().executeTakeFirstOrThrow(),{entity:v,mutationApi:f,id:A,pk:C}=Tf(G);return O(()=>{$.set(A,l6.create(v,f,C))}),v},readProject:async(J,W,H)=>{let Z=$.get(H);if(Z)return Z.getEntity();let O=RP8(H);if(O===null)return null;let w=await J.selectFrom("projects").selectAll().where("id","=",O).executeTakeFirst();if(!w)return null;let{entity:X,mutationApi:T,id:G,pk:v}=Tf(w);return $.set(G,l6.create(X,T,v)),X},readProjectByObjectId:async(J,W,H)=>{let Z=$.get(H);if(Z)return Z.getEntity();let O=RP8(H);if(O===null)return null;let w=await J.selectFrom("projects").selectAll().where("id","=",O).executeTakeFirst();if(!w)return null;let{entity:X,mutationApi:T,id:G,pk:v}=Tf(w);return $.set(G,l6.create(X,T,v)),X},readProjectByPath:async(J,W,H)=>{let Z=await J.selectFrom("projects").selectAll().where("path","=",H).executeTakeFirst();if(!Z)return null;let{entity:O,mutationApi:w,id:X,pk:T}=Tf(Z),G=$.get(X);if(G)return G.getEntity();return $.set(X,l6.create(O,w,T)),O},evictProject:(J)=>{$.delete(J)}})},DP8=Object.freeze({create:FW6});var iW6=()=>{let $=new Map,K=new Map;return Object.freeze({get:(w)=>$.get(w),getByPk:(w)=>{let X=K.get(w);return X?$.get(X):void 0},has:(w)=>$.has(w),set:(w,X)=>{$.set(w,X),K.set(X.getPk(),w)},remove:(w)=>{let X=$.get(w);if(X)K.delete(X.getPk());$.delete(w)},getIdByPk:(w)=>K.get(w),setIdByPk:(w,X)=>K.set(w,X),clear:()=>{$.clear(),K.clear()},entries:()=>$.entries()})},jf=Object.freeze({create:iW6});var yP8=K1(X$(),1);var QW6=async($,K,q,Y=null)=>{return(await $.selectFrom("entity_types").select("id").where("code","=",q).where((P)=>Y?P("subtype","=",Y):P("subtype","is",null)).executeTakeFirstOrThrow()).id},uz=Object.freeze({readEntityTypeId:QW6});var dW6=($)=>{let{id:K,name:q,parentId:Y,path:z,createdAt:P,updatedAt:J,publishedVersionNumber:W,hasDraft:H,draftContent:Z,publishedContent:O}=$,{entityFns:w,mutationFns:X}=K5.create({id:K,name:q,createdAt:P,updatedAt:J}),T=new Map,G=W??null,v=H??!1,f=Z??null,A=O??null,C=null,h8=Object.freeze({...w,getParentId:()=>Y,getPath:()=>z,getField:(K8)=>{return T.get(K8)},getFields:()=>{let K8={};for(let[P8,H8]of T.entries())K8[P8]=H8;return K8},getPublishedVersionNumber:()=>G,hasDraftContent:()=>v,getDraftContent:()=>f,getPublishedContent:()=>A,getEditState:()=>C,hasPublished:()=>G>0,isBeingEdited:()=>C!==null,getVersionCount:()=>G??0,getIsFolder:()=>!1}),s=Object.freeze({...X,setParentId:(K8)=>{Y=K8},setPath:(K8)=>{z=K8},setField:(K8,P8)=>{T.set(K8,P8)},removeField:(K8)=>{T.delete(K8)},setPublishedVersionNumber:(K8)=>{G=K8},setHasDraft:(K8)=>{v=K8},setDraftContent:(K8)=>{f=K8},setPublishedContent:(K8)=>{A=K8},setEditState:(K8)=>{C=K8}});return{entityFns:h8,mutationFns:s}},YW=Object.freeze({create:dW6});var SP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>K.getParentId()===null,z=()=>!0,J=Object.freeze({...K,isRoot:Y,getIsFolder:z,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),isFolder:z(),isRoot:Y()})}),W=Object.freeze({...q});return{entity:J,mutationApi:W}},nW6=($,K,q,Y)=>{return SP8({id:K,parentId:q,name:$.name,path:Y,createdAt:$.created_at,updatedAt:$.updated_at})},mz=Object.freeze({create:SP8,createFromRow:nW6});var oW6=($)=>{let{id:K,name:q,ownerEntityId:Y,label:z,description:P,primitiveType:J,required:W,multiplicity:H,isSystem:Z,createdAt:O,updatedAt:w}=$,{entityFns:X,mutationFns:T}=K5.create({id:K,name:q,createdAt:O,updatedAt:w}),G=()=>Y,v=()=>z,f=()=>P,A=()=>J,C=()=>W,V=()=>H,M=()=>Z,I=Object.freeze({...X,getOwnerEntityId:G,getLabel:v,getDescription:f,getPrimitiveType:A,getRequired:C,getMultiplicity:V,getIsSystem:M,toJSON:()=>({id:X.getObjectId(),ownerEntityId:G(),name:X.getName(),label:v(),description:f(),primitiveType:A(),required:C(),multiplicity:V(),isSystem:M(),createdAt:X.getCreatedAt(),updatedAt:X.getUpdatedAt()})}),D=Object.freeze({...T});return{entity:I,mutationApi:D}},Wx=Object.freeze({create:oW6});var aW6=({definition:$,values:K=[]})=>{let q=$,Y=[...K];if(q.getMultiplicity()==="single"&&Y.length>1)throw new Error(`Field "${q.getName()}" is single-valued but received ${Y.length} values`);let z=(T=0)=>{return Y[T]},P=()=>{return[...Y]},J=()=>{return q},W=()=>{return q.getMultiplicity()==="multi"};return Object.freeze({getValue:z,getValues:P,getDefinition:J,isMultiValued:W,isRequired:()=>{return q.getRequired()},getType:()=>{return q.getPrimitiveType()},getLabel:()=>{return q.getLabel()||q.getName()},getName:()=>{return q.getName()},toJSON:()=>{if(W())return Y;else return Y[0]}})},Hx=Object.freeze({create:aW6});R4();R4();var $H6=($)=>{let K=$.trim();Y8.factory(!K,t.validation,"Folder name cannot be empty","EMPTY_NAME"),Y8.factory(K.length>255,t.validation,"Folder name cannot exceed 255 characters","NAME_TOO_LONG");let q=/[/\\:*?"<>|]/;return Y8.factory(q.test(K),t.validation,'Folder name contains invalid characters: /\\:*?"<>|',"INVALID_CHARS"),K},KH6=($)=>{return $.getParentId()===null},HK=Object.freeze({validateFolderName:$H6,isRootFolder:KH6});R4();var qH6=($)=>{if(!$||$.length<3)return null;let K=$[0],q=$[1],Y=parseInt($.slice(2),10);if(isNaN(Y))return null;return{storeCode:K,typeCode:q,seq:Y}},YH6=($,K,q)=>`${$}${K}${q}`,zH6=($,K)=>{Y8.factory($!==K,t.validation,`Store code mismatch: expected ${K}, got ${$}`,"STORE_CODE_MISMATCH")},zW=Object.freeze({parseId:qH6,buildId:YH6,validateStoreCode:zH6});var EP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>"d",P=Object.freeze({...K,getTypeCode:Y,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),publishedVersionNumber:K.getPublishedVersionNumber(),hasDraft:K.hasDraftContent(),draftContent:K.getDraftContent(),publishedContent:K.getPublishedContent(),editState:K.getEditState(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),versionCount:K.getVersionCount(),isFolder:K.getIsFolder(),type:Y(),hasPublished:K.hasPublished(),isBeingEdited:K.isBeingEdited()})}),J=Object.freeze({...q});return{entity:P,mutationApi:J}},PH6=($,K,q,Y,z,P,J=null,W=null)=>{return EP8({id:K,parentId:q,name:$.name,path:Y,publishedVersionNumber:z,hasDraft:P,draftContent:J,publishedContent:W,createdAt:$.created_at,updatedAt:$.updated_at})},LP8=Object.freeze({create:EP8,createFromRow:PH6});var IP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>"t",P=Object.freeze({...K,getTypeCode:Y,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),publishedVersionNumber:K.getPublishedVersionNumber(),hasDraft:K.hasDraftContent(),draftContent:K.getDraftContent(),publishedContent:K.getPublishedContent(),editState:K.getEditState(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),versionCount:K.getVersionCount(),isFolder:K.getIsFolder(),type:Y(),hasPublished:K.hasPublished(),isBeingEdited:K.isBeingEdited()})}),J=Object.freeze({...q});return{entity:P,mutationApi:J}},JH6=($,K,q,Y,z,P,J=null,W=null)=>{return IP8({id:K,parentId:q,name:$.name,path:Y,publishedVersionNumber:z,hasDraft:P,draftContent:J,publishedContent:W,createdAt:$.created_at,updatedAt:$.updated_at})},xP8=Object.freeze({create:IP8,createFromRow:JH6});R4();var bP8=($)=>{let K=zW.parseId($);if(!K)throw t.notFound(`Invalid entity ID format: ${$}`,"NOT_FOUND");let{storeCode:q,typeCode:Y,seq:z}=K;return{entityId:`${Y}${z}`,storeCode:q,typeCode:Y,seq:z}},WH6=($)=>{let{typeCode:K}=bP8($);return K},HH6={d:LP8.createFromRow,t:xP8.createFromRow},ZH6=($)=>{let K=HH6[$];if(!K)throw new Error(`Unknown content type: ${$}`);return K},OH6=($)=>{return{d:"document",t:"template"}[$]||"content"},m1=Object.freeze({resolveEntityId:bP8,getTypeFromId:WH6,getEntityFactory:ZH6,getContentTypeLabel:OH6,buildId:zW.buildId,parseId:zW.parseId});var{parseId:O4,buildId:Zx,validateStoreCode:wH6}=zW,{validateFolderName:gP8,isRootFolder:gg1}=HK,yg1=yP8.default("caw:stores:db"),PW=3600000,XH6=({id:$,code:K,name:q,pk:Y,folderCache:z,createdAt:P,updatedAt:J})=>{let W=new Map,{entityFns:H,mutationFns:Z}=K5.create({id:$,name:q,createdAt:P,updatedAt:J}),O=()=>new Set([K]),w=()=>"local",X=()=>K,T=()=>Y,G=()=>({id:$,code:K,name:H.getName(),createdAt:H.getCreatedAt(),updatedAt:H.getUpdatedAt(),type:"local"}),v=(E)=>{wH6(E,K)},f=async(E,u)=>{if(!u)return null;if(z){let d=z.get(u);if(d)return d.getPk()}if(!O4(u))Y8.factory(!0,t.validation,`Invalid parent folder ID: ${u}`,"INVALID_ID");let Q=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("object_id","=",u).where("deleted_at","is",null).executeTakeFirst();return Q?Q.id:null},A=async(E,u)=>{let y=await E.selectFrom("entities").select(["name","parent_folder_id","parent_object_id","object_id"]).where("id","=",u).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!y,t.notFound,`Entity not found for PK ${u}`,"ENTITY_NOT_FOUND");let Q=y.object_id,d=z?z.get(Q):null;if(d){let w8=d.getEntity();if(w8.getName()===y.name&&w8.getParentId()===y.parent_object_id)return w8.getPath()}if(y.name===null)return"";if(!y.parent_object_id)return y.name;let $8=z?z.get(y.parent_object_id):null;if($8){let k8=$8.getEntity().getPath();return k8?`${k8}/${y.name}`:y.name}let W8=[y.name],z8=y.parent_folder_id;while(z8!==null){let w8=W.get(z8),k8=w8&&z?z.get(w8):null;if(k8){let h6=k8.getEntity().getPath();if(h6){let o8=h6.split("/").filter((d6)=>d6);W8.unshift(...o8)}break}let m8=await E.selectFrom("entities").select(["name","parent_folder_id"]).where("id","=",z8).where("deleted_at","is",null).executeTakeFirst();if(Y8.factory(!m8,t.notFound,`Folder not found for PK ${z8}`,"FOLDER_NOT_FOUND"),m8.name!==null)W8.unshift(m8.name);z8=m8.parent_folder_id}return W8.join("/")},C=async(E,u)=>{let y=[],Q=[u];while(Q.length>0){let d=Q.shift(),$8=await E.selectFrom("entities").select(["id","type_code"]).where("store_id","=",Y).where("parent_folder_id","=",d).where("deleted_at","is",null).execute();for(let W8 of $8)if(y.push(W8.id),W8.type_code==="f")Q.push(W8.id)}return y},V=async(E,u,y,Q)=>{let d=K4(),$8=await uz.readEntityTypeId(E,{},"f",Q),W8=await q5.nextSeq(E,"store",Y,"f"),z8=await f(E,u),w8=Zx(K,"f",W8),k8=await E.insertInto("entities").values({store_id:Y,object_id:w8,entity_type_id:$8,type_code:"f",seq:W8,parent_folder_id:z8,parent_object_id:u,name:y,created_at:d,updated_at:d}).returningAll().executeTakeFirstOrThrow();return await E.insertInto("folders").values({entity_id:k8.id}).execute(),{row:k8,id:w8}},M=(E)=>{let u=null;if(E.owner_entity_id!==null)u=W.get(E.owner_entity_id)??null;let{entity:y,mutationApi:Q}=Wx.create({id:E.object_id,name:E.name,ownerEntityId:u,label:E.label,description:E.description,primitiveType:E.primitive_type,required:E.required===1,multiplicity:E.multiplicity,isSystem:E.is_system===1,createdAt:E.created_at,updatedAt:E.updated_at});return{entity:y,mutationApi:Q,pk:E.id}},R=async(E,u)=>{let y=await E.selectFrom("field_values as fv").innerJoin("field_definitions as fd","fd.id","fv.field_definition_id").select(["fv.id as value_id","fv.value","fd.id as def_id","fd.object_id as def_object_id","fd.name as def_name","fd.label as def_label","fd.description as def_description","fd.primitive_type as def_primitive_type","fd.required as def_required","fd.multiplicity as def_multiplicity","fd.is_system as def_is_system","fd.owner_entity_id as def_owner_entity_id","fd.created_at as def_created_at","fd.updated_at as def_updated_at"]).where("fv.entity_id","=",u).execute(),Q=new Map;for(let $8 of y){let W8=$8.def_id;if(!Q.has(W8))Q.set(W8,{definition:{id:$8.def_object_id,name:$8.def_name,label:$8.def_label,description:$8.def_description,primitiveType:$8.def_primitive_type,required:$8.def_required===1,multiplicity:$8.def_multiplicity,isSystem:$8.def_is_system===1,ownerEntityId:$8.def_owner_entity_id?W.get($8.def_owner_entity_id):null,createdAt:$8.def_created_at,updatedAt:$8.def_updated_at},values:[]});Q.get(W8).values.push($8.value)}let d=[];for(let{definition:$8,values:W8}of Q.values()){let{entity:z8}=Wx.create($8),w8=Hx.create({definition:z8,values:W8});d.push(w8)}return d},I=async(E,u)=>{let y=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",1).where("type_code","=","n").executeTakeFirst();if(!y)return null;if(y.owner_entity_id){let d=await E.selectFrom("entities").select("object_id").where("id","=",y.owner_entity_id).executeTakeFirst();if(d)W.set(y.owner_entity_id,d.object_id)}let Q=`${K}n1`;return W.set(y.id,Q),M(y)},D=async(E,u,{storeCode:y,parentId:Q,name:d,subtype:$8})=>{if(y!==void 0)v(y);if(d!==null&&d!==void 0)gP8(d);let{row:W8,id:z8}=await V(E,Q,d,$8||null),w8=W8.id;W.set(w8,z8);let k8=await A(E,w8),{entity:m8,mutationApi:Q8}=mz.createFromRow(W8,z8,Q,k8);return{entity:m8,mutationApi:Q8,pk:w8}},m=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.seq","=",Q.seq).where("entities.type_code","=","f").where("entities.deleted_at","is",null).executeTakeFirst();if(!d)return null;let{id:$8,parent_object_id:W8}=d;W.set($8,y);let z8=await A(E,$8),w8=await R(E,$8),{entity:k8,mutationApi:m8}=mz.createFromRow(d,y,W8,z8);for(let Q8 of w8)m8.setField(Q8.getDefinition().getName(),Q8);return{entity:k8,mutationApi:m8,pk:$8}},b=async(E,u,{id:y,name:Q,parentId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid folder ID: ${y}`,"INVALID_ID");let W8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",$8.seq).where("type_code","=","f").where("deleted_at","is",null).executeTakeFirst();Y8.factory(!W8,t.notFound,`Folder not found: ${y}`,"FOLDER_NOT_FOUND");let z8=W8.id,w8={name:W8.name,parentId:W8.parent_object_id,path:null};if(W.set(z8,y),w8.path=await A(E,z8),Q!==void 0)gP8(Q);let k8={};if(Q!==void 0)k8.name=Q;if(d!==void 0){let n6=await f(E,d);k8.parent_folder_id=n6,k8.parent_object_id=d}k8.updated_at=K4();let m8=await E.updateTable("entities").set(k8).where("id","=",z8).returningAll().executeTakeFirstOrThrow(),Q8=await A(E,z8),h6=await R(E,z8),{entity:o8,mutationApi:d6}=mz.createFromRow(m8,y,m8.parent_object_id,Q8);for(let n6 of h6)d6.setField(n6.getDefinition().getName(),n6);return{entity:o8,mutationApi:d6,pk:z8,oldValues:w8}},h=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid folder ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","f").where("deleted_at","is",null).executeTakeFirst();Y8.factory(!d,t.notFound,`Folder not found: ${y}`,"FOLDER_NOT_FOUND");let $8=d.id;W.set($8,y);let W8=await A(E,$8),z8=await C(E,$8),w8=K4();await E.updateTable("entities").set({deleted_at:w8}).where("id","in",[$8,...z8]).execute();let k8=[];for(let m8 of z8){let Q8=await E.selectFrom("entities").select("object_id").where("id","=",m8).executeTakeFirst();if(Q8)k8.push(Q8.object_id)}return{id:y,deleted:!0,descendantCount:z8.length,path:W8,descendantIds:k8,deletedPks:[$8,...z8]}},L=async(E,u,y,Q,d=null)=>{let $8=await f(E,y),W8=E.selectFrom("entities").select("object_id").where("store_id","=",Y).where("parent_folder_id",$8===null?"is":"=",$8).where("name","=",Q).where("deleted_at","is",null);if(d)W8=W8.where("object_id","!=",d);return!!await W8.executeTakeFirst()},B=async(E,u,y,Q)=>{let d=await f(E,y),$8=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.parent_folder_id",d===null?"is":"=",d).where("entities.name","=",Q).where("entities.deleted_at","is",null).executeTakeFirst();if(!$8)return null;let{id:W8,object_id:z8}=$8;W.set(W8,z8);let w8=await A(E,W8),k8=await R(E,W8),{entity:m8,mutationApi:Q8}=mz.createFromRow($8,z8,y,w8);for(let h6 of k8)Q8.setField(h6.getDefinition().getName(),h6);return{entity:m8,mutationApi:Q8,pk:W8}},i=async(E,u,{folderId:y,type:Q})=>{let d;if(y){if(d=await f(E,y),d===null)return[]}else if(Q){let w8=await N8(E,u,Q);if(!w8)return[];d=w8.pk}else d=null;let $8=E.selectFrom("entities").selectAll().where("store_id","=",Y).where("parent_folder_id",d===null?"is":"=",d).where("deleted_at","is",null);if(Q)$8=$8.where("type_code","=","f").innerJoin("folders","folders.entity_id","entities.id");let W8=await $8.execute(),z8=[];for(let w8 of W8){let{id:k8,object_id:m8}=w8;W.set(k8,m8);let Q8=await A(E,k8),h6=await R(E,k8),{entity:o8,mutationApi:d6}=mz.createFromRow(w8,m8,w8.parent_object_id,Q8);for(let n6 of h6)d6.setField(n6.getDefinition().getName(),n6);z8.push({entity:o8,mutationApi:d6,pk:k8})}return z8},X8=async(E,u,{path:y,type:Q})=>{let d=(y??"").trim(),$8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("type_code","=","f").where("deleted_at","is",null).execute();for(let W8 of $8){let z8=await m(E,u,{id:W8.object_id});if(z8&&z8.entity.getPath()===d)return z8}return null},N8=async(E,u,y,Q)=>{if(Q!==void 0)v(Q);let d=y==="d"?"root_d":"root_t",$8=await uz.readEntityTypeId(E,u,"f",d),W8=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.entity_type_id","=",$8).where("entities.deleted_at","is",null).executeTakeFirst();if(!W8)return null;let{id:z8,object_id:w8}=W8;W.set(z8,w8);let k8=await A(E,z8),m8=await R(E,z8),{entity:Q8,mutationApi:h6}=mz.createFromRow(W8,w8,W8.parent_object_id,k8);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);return{entity:Q8,mutationApi:h6,pk:z8}},h8=async(E,u,{storeCode:y,ownerEntityId:Q,name:d,label:$8,description:W8,primitiveType:z8,required:w8,multiplicity:k8,isSystem:m8=!1})=>{if(y!==void 0)v(y);Y8.factory(z8!=="string"&&z8!=="object_ref",t.validation,`Invalid primitiveType: ${z8}`,"INVALID_PRIMITIVE_TYPE"),Y8.factory(k8!=="single"&&k8!=="multi",t.validation,`Invalid multiplicity: ${k8}`,"INVALID_MULTIPLICITY");let Q8=K4(),h6=await uz.readEntityTypeId(E,u,"n",null),o8=await q5.nextSeq(E,"store",Y,"n"),d6=Zx(K,"n",o8),n6=Q?await f(E,Q):null,L$=await E.insertInto("field_definitions").values({store_id:Y,object_id:d6,entity_type_id:h6,type_code:"n",seq:o8,owner_entity_id:n6,name:d,label:$8,description:W8,primitive_type:z8,required:w8?1:0,multiplicity:k8,is_system:m8?1:0,created_at:Q8,updated_at:Q8}).returningAll().executeTakeFirstOrThrow(),u3=L$.id;return W.set(u3,d6),M(L$)},c8=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","n").executeTakeFirst();if(!d)return null;if(d.owner_entity_id){let $8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if($8)W.set(d.owner_entity_id,$8.object_id)}return W.set(d.id,y),M(d)},E8=async(E,u,y,Q)=>{let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("name","=",y).where("owner_entity_id",Q===null?"is":"=",Q).executeTakeFirst();if(!d)return null;if(d.owner_entity_id){let $8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if($8)W.set(d.owner_entity_id,$8.object_id)}return W.set(d.id,d.object_id),M(d)},g8=async(E,u,{fieldDefinitionId:y,fieldName:Q,ownerEntityPk:d})=>{if(y){let W8=await c8(E,u,{id:y});if(W8)return W8}if(Q&&d){let W8=await E8(E,u,Q,d);if(W8)return W8}if(Q){let W8=await E8(E,u,Q,null);if(W8)return W8}let $8=await I(E);return Y8.factory(!$8,t.notFound,"No field definition found and no default available","NO_FIELD_DEFINITION"),$8},t8=async(E,u,{ownerEntityPk:y,includeSystem:Q=!0})=>{let d=E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("owner_entity_id",y===null?"is":"=",y);if(!Q)d=d.where("is_system","=",0);let $8=await d.execute(),W8=[];for(let z8 of $8){if(z8.owner_entity_id){let w8=await E.selectFrom("entities").select("object_id").where("id","=",z8.owner_entity_id).executeTakeFirst();if(w8)W.set(z8.owner_entity_id,w8.object_id)}W.set(z8.id,z8.object_id),W8.push(M(z8))}return W8},v4=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid definition ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","n").executeTakeFirst();Y8.factory(!d,t.notFound,`Field definition not found: ${y}`,"DEFINITION_NOT_FOUND"),Y8.factory(d.is_system===1,t.validation,`Cannot delete system field definition: ${y}`,"SYSTEM_DEFINITION");let $8=d.id;if(await E.deleteFrom("field_definitions").where("id","=",$8).execute(),d.owner_entity_id){let z8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if(z8)W.set(d.owner_entity_id,z8.object_id)}let{entity:W8}=M(d);return W8},g3=async(E,u,{entityId:y,fieldDefinitionId:Q,fieldName:d,value:$8,values:W8})=>{let z8=O4(y);Y8.factory(!z8,t.validation,`Invalid entity ID: ${y}`,"INVALID_ID");let w8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("seq","=",z8.seq).where("type_code","=",z8.typeCode).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!w8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let k8=w8.id,{entity:m8,pk:Q8}=await g8(E,u,{fieldDefinitionId:Q,fieldName:d,ownerEntityPk:k8}),h6=m8.getMultiplicity(),o8;if(h6==="single")if(W8&&Array.isArray(W8))Y8.factory(W8.length>1||W8.length===0,t.validation,`Field '${m8.getName()}' is single-valued but received ${W8.length} values`,"MULTIPLICITY_VIOLATION"),o8=[W8[0]];else Y8.factory($8===void 0,t.validation,"Single-valued field requires value parameter","VALUE_REQUIRED"),o8=[$8];else if(W8&&Array.isArray(W8))o8=W8;else if($8!==void 0)o8=[$8];else Y8.factory(!0,t.validation,"Multi-valued field requires either value or values parameter","VALUE_OR_VALUES_REQUIRED");await E.deleteFrom("field_values").where("entity_id","=",k8).where("field_definition_id","=",Q8).execute();let d6=K4();for(let xY of o8)await E.insertInto("field_values").values({entity_id:k8,field_definition_id:Q8,value:xY,updated_at:d6}).execute();let n6=o8,L$=Hx.create({definition:m8,values:n6}),u3;if(z8.typeCode==="f")u3=await m(E,u,{id:y});else u3=await a(E,u,{id:y});return Y8.factory(!u3,t.notFound,`Entity not found after field update: ${y}`,"ENTITY_NOT_FOUND"),{...u3,field:L$,fieldName:m8.getName()}},v8=async(E,u,{entityId:y,fieldDefinitionId:Q,fieldName:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid entity ID: ${y}`,"INVALID_ID");let W8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("seq","=",$8.seq).where("type_code","=",$8.typeCode).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!W8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let z8=W8.id,{entity:w8,pk:k8}=await g8(E,u,{fieldDefinitionId:Q,fieldName:d,ownerEntityPk:z8});await E.deleteFrom("field_values").where("entity_id","=",z8).where("field_definition_id","=",k8).execute();let m8;if($8.typeCode==="f")m8=await m(E,u,{id:y});else m8=await a(E,u,{id:y});return Y8.factory(!m8,t.notFound,`Entity not found after field delete: ${y}`,"ENTITY_NOT_FOUND"),{...m8,fieldName:w8.getName()}},r=async(E,u,{type:y,storeCode:Q,parentId:d,name:$8,initialContent:W8})=>{let z8=m1.getEntityFactory(y);if(Q!==void 0)v(Q);let w8=K4(),k8=await uz.readEntityTypeId(E,u,y,null),m8=await q5.nextSeq(E,"store",Y,y),Q8=Zx(K,y,m8),h6=await f(E,d),o8=await E.insertInto("entities").values({store_id:Y,object_id:Q8,entity_type_id:k8,type_code:y,seq:m8,parent_folder_id:h6,parent_object_id:d,name:$8,created_at:w8,updated_at:w8}).returningAll().executeTakeFirstOrThrow();await E.insertInto("documents").values({entity_id:o8.id,published_version_id:null}).execute();let d6=W8!==null&&W8!==void 0;if(d6)await E.insertInto("document_drafts").values({entity_id:o8.id,content:W8,updated_at:w8}).execute();let n6=o8.id;W.set(n6,Q8);let L$=await A(E,n6),{entity:u3,mutationApi:xY}=z8(o8,Q8,d,L$,null,d6,d6?W8:null,null);return{entity:u3,mutationApi:xY,pk:n6}},a=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let{typeCode:d,seq:$8}=Q,W8=m1.getEntityFactory(d),z8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").leftJoin("document_edit_state as es","es.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","e.deleted_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft"),"es.client_id as edit_client_id","es.started_at as edit_started_at","es.last_activity_at as edit_activity"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();if(!z8)return null;let w8=z8.entity_id;W.set(w8,y);let k8=await A(E,w8),m8=await R(E,w8),{entity:Q8,mutationApi:h6}=W8(z8,z8.object_id,z8.parent_object_id,k8,z8.published_version_number,z8.has_draft===1,z8.draft_content??null,z8.published_content??null);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);if(z8.edit_client_id)h6.setEditState({clientId:z8.edit_client_id,startedAt:z8.edit_started_at,lastActivityAt:z8.edit_activity});return{entity:Q8,mutationApi:h6,pk:w8}},s=async(E,u,{id:y,name:Q,parentId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:W8,seq:z8}=$8,w8=m1.getContentTypeLabel(W8),k8=m1.getEntityFactory(W8),m8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",z8).where("type_code","=",W8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!m8,t.notFound,`${w8} not found: ${y}`,"NOT_FOUND");let Q8=m8.id,h6={name:m8.name,parentId:m8.parent_object_id,path:null};W.set(Q8,y),h6.path=await A(E,Q8);let d6={updated_at:K4()};if(Q!==void 0)d6.name=Q;if(d!==void 0){let i5=await f(E,d);d6.parent_folder_id=i5,d6.parent_object_id=d}let n6=await E.updateTable("entities").set(d6).where("id","=",Q8).returningAll().executeTakeFirstOrThrow(),L$=await E.selectFrom("documents as d").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","d.entity_id").select(["dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft")]).where("d.entity_id","=",Q8).executeTakeFirst(),u3=await A(E,Q8),xY=await R(E,Q8),{entity:kP,mutationApi:hv}=k8(n6,y,n6.parent_object_id,u3,L$.published_version_number,L$.has_draft===1,L$.draft_content??null,L$.published_content??null);for(let i5 of xY)hv.setField(i5.getDefinition().getName(),i5);return{entity:kP,mutationApi:hv,pk:Q8,oldValues:h6}},K8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",$8).where("type_code","=",d).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`${W8} not found: ${y}`,"NOT_FOUND");let w8=z8.id;W.set(w8,y);let k8=await A(E,w8),m8=K4();return await E.updateTable("entities").set({deleted_at:m8}).where("id","=",w8).execute(),{id:y,deleted:!0,path:k8}},P8=async(E,u,{id:y,content:Q,clientId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid content ID: ${y}`,"INVALID_ID"),Y8.factory(!d,t.validation,"clientId is required","MISSING_CLIENT_ID");let{typeCode:W8,seq:z8}=$8,w8=m1.getContentTypeLabel(W8),k8=K4(),m8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",W8).where("seq","=",z8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!m8,t.notFound,`${w8} not found: ${y}`,"NOT_FOUND");let Q8=m8.id;await E.insertInto("document_drafts").values({entity_id:Q8,content:Q,updated_at:k8}).onConflict((n6)=>n6.column("entity_id").doUpdateSet({content:Q,updated_at:k8})).execute();let o8=!await tK(E,u,{id:y,clientId:d}),d6=await a(E,u,{id:y});return Y8.factory(!d6,t.notFound,`${w8} not found after draft save: ${y}`,"NOT_FOUND"),{...d6,lockLost:o8}},H8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=K4(),w8=await E.selectFrom("entities as e").innerJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.id as entity_id","dd.content"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();Y8.factory(!w8,t.notFound,`No draft found for ${W8}: ${y}`,"DRAFT_NOT_FOUND");let k8=w8.entity_id,Q8=((await E.selectFrom("document_versions").select(E.fn.max("version_number").as("max_version")).where("entity_id","=",k8).executeTakeFirst())?.max_version||0)+1,h6=await E.insertInto("document_versions").values({entity_id:k8,version_number:Q8,content:w8.content,published_at:z8}).returningAll().executeTakeFirstOrThrow();await E.updateTable("documents").set({published_version_id:h6.id}).where("entity_id","=",k8).execute(),await E.deleteFrom("document_drafts").where("entity_id","=",k8).execute(),await E.deleteFrom("document_edit_state").where("entity_id","=",k8).execute();let o8=await a(E,u,{id:y});return Y8.factory(!o8,t.notFound,`${W8} not found after publish: ${y}`,"NOT_FOUND"),o8},O8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d).where("seq","=",$8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`${W8} not found: ${y}`,"NOT_FOUND"),await E.deleteFrom("document_drafts").where("entity_id","=",z8.id).execute();let w8=await a(E,u,{id:y});return Y8.factory(!w8,t.notFound,`${W8} not found after discard: ${y}`,"NOT_FOUND"),w8},A8=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let{typeCode:d,seq:$8}=Q,W8=await E.selectFrom("entities as e").innerJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.object_id","dd.content","dd.updated_at"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();if(!W8)return null;return{entityId:W8.object_id,content:W8.content,updatedAt:W8.updated_at}},A6=async(E,u,{id:y,versionNumber:Q})=>{let d=O4(y);if(!d)return null;let{typeCode:$8,seq:W8}=d,z8=await E.selectFrom("entities as e").innerJoin("document_versions as dv","dv.entity_id","e.id").select(["e.object_id","dv.version_number","dv.content","dv.published_at"]).where("e.store_id","=",Y).where("e.type_code","=",$8).where("e.seq","=",W8).where("e.deleted_at","is",null).where("dv.version_number","=",Q).executeTakeFirst();if(!z8)return null;return{entityId:z8.object_id,versionNumber:z8.version_number,content:z8.content,publishedAt:z8.published_at}},E6=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return[];let{typeCode:d,seq:$8}=Q;return(await E.selectFrom("entities as e").innerJoin("document_versions as dv","dv.entity_id","e.id").select(["dv.version_number","dv.published_at"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).orderBy("dv.version_number","desc").execute()).map((z8)=>({versionNumber:z8.version_number,publishedAt:z8.published_at}))},$1=async(E,u,y,Q,d)=>{let $8=m1.getEntityFactory(d),W8=await f(E,y),z8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft")]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.parent_folder_id",W8===null?"is":"=",W8).where("e.name","=",Q).where("e.deleted_at","is",null).executeTakeFirst();if(!z8)return null;let w8=z8.entity_id;W.set(w8,z8.object_id);let k8=await A(E,w8),m8=await R(E,w8),{entity:Q8,mutationApi:h6}=$8(z8,z8.object_id,z8.parent_object_id,k8,z8.published_version_number,z8.has_draft===1,z8.draft_content??null,z8.published_content??null);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);return{entity:Q8,mutationApi:h6,pk:w8}},y3=async(E,u,{parentId:y,type:Q})=>{let d=m1.getEntityFactory(Q),$8=await f(E,y),W8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").leftJoin("document_edit_state as es","es.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft"),"es.client_id as edit_client_id","es.started_at as edit_started_at","es.last_activity_at as edit_activity"]).where("e.store_id","=",Y).where("e.type_code","=",Q).where("e.parent_folder_id",$8===null?"is":"=",$8).where("e.deleted_at","is",null).execute(),z8=[];for(let w8 of W8){let k8=w8.entity_id;W.set(k8,w8.object_id);let m8=await A(E,k8),Q8=await R(E,k8),{entity:h6,mutationApi:o8}=d(w8,w8.object_id,w8.parent_object_id,m8,w8.published_version_number,w8.has_draft===1,w8.draft_content??null,w8.published_content??null);for(let d6 of Q8)o8.setField(d6.getDefinition().getName(),d6);if(w8.edit_client_id)o8.setEditState({clientId:w8.edit_client_id,startedAt:w8.edit_started_at,lastActivityAt:w8.edit_activity});z8.push({entity:h6,mutationApi:o8,pk:k8})}return z8},g7=async(E,u,{id:y,clientId:Q})=>{let d=O4(y);Y8.factory(!d,t.validation,`Invalid ID: ${y}`,"INVALID_ID");let $8=K4(),W8=new Date(Date.now()-PW).toISOString(),z8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d.typeCode).where("seq","=",d.seq).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let w8=z8.id,k8=await E.selectFrom("document_edit_state").selectAll().where("entity_id","=",w8).executeTakeFirst();if(k8)if(k8.client_id===Q)return await E.updateTable("document_edit_state").set({started_at:$8,last_activity_at:$8}).where("entity_id","=",w8).execute(),{success:!0};else if(k8.last_activity_at<W8)return await E.updateTable("document_edit_state").set({client_id:Q,started_at:$8,last_activity_at:$8}).where("entity_id","=",w8).execute(),{success:!0};else return{success:!1,meta:{lockedBy:k8.client_id,lockedSince:k8.started_at,timeoutSeconds:PW/1000}};else return await E.insertInto("document_edit_state").values({entity_id:w8,client_id:Q,started_at:$8,last_activity_at:$8}).execute(),{success:!0}},tK=async(E,u,{id:y,clientId:Q})=>{let d=O4(y);if(!d)return!1;let $8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d.typeCode).where("seq","=",d.seq).executeTakeFirst();if(!$8)return!1;return((await E.updateTable("document_edit_state").set({last_activity_at:K4()}).where("entity_id","=",$8.id).where("client_id","=",Q).execute())[0]?.numUpdatedRows||0)>0},c=Object.freeze({...H,getCodes:O,getType:w,getCode:X,getPk:T,toJSON:G,createFolder:D,readFolder:m,updateFolder:b,deleteFolder:h,isDuplicateNameInParent:L,findFolderByName:B,listFolderContents:i,getFolderByPath:X8,readRootFolderForType:N8,createContent:r,readContent:a,updateContent:s,deleteContent:K8,saveDraft:P8,readDraft:A8,publishContent:H8,discardDraft:O8,readVersion:A6,getVersions:E6,findContentByName:$1,listContent:y3,createFieldDefinition:h8,readFieldDefinition:c8,readDefaultFieldDefinition:I,findFieldDefinitionByName:E8,resolveFieldDefinition:g8,getFieldDefinitionsForOwner:t8,deleteFieldDefinition:v4,setFieldValue:g3,deleteFieldValue:v8,setEditState:g7,clearEditState:async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",Q.typeCode).where("seq","=",Q.seq).executeTakeFirst();Y8.factory(!d,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND"),await E.deleteFrom("document_edit_state").where("entity_id","=",d.id).execute()},getEditState:async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("entities as e").innerJoin("document_edit_state as es","es.entity_id","e.id").select(["es.client_id","es.started_at","es.last_activity_at"]).where("e.store_id","=",Y).where("e.type_code","=",Q.typeCode).where("e.seq","=",Q.seq).executeTakeFirst();if(!d)return null;return{clientId:d.client_id,startedAt:d.started_at,lastActivityAt:d.last_activity_at}}}),o=Object.freeze({...Z});return{store:c,mutationApi:o}},uP8=Object.freeze({create:XH6});var TH6=({inner:$,folderCache:K,contentCache:q,fieldDefinitionCache:Y})=>{let z=async(r,a,s,K8)=>{let P8=await $.createFolder(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{K.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},P=async(r,a,{id:s})=>{let K8=K.get(s);if(K8)return K8.getEntity();let P8=await $.readFolder(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return K.set(s,l6.create(H8,O8,A8)),H8},J=async(r,a,s,K8)=>{let{id:P8}=s,H8=K.get(P8),O8=await $.updateFolder(r,a,s),A8=s.name!==void 0&&s.name!==O8.oldValues.name||s.parentId!==void 0&&s.parentId!==O8.oldValues.parentId;return K8(()=>{if(H8){let E6=H8.getMutationApi();if(s.name!==void 0)E6.setName(s.name);if(s.parentId!==void 0)E6.setParentId(s.parentId);E6.setUpdatedAt(O8.entity.getUpdatedAt()),E6.setPath(O8.entity.getPath())}else{let{entity:E6,mutationApi:$1,pk:y3}=O8;K.set(P8,l6.create(E6,$1,y3))}if(A8){let $1=O8.oldValues.path+"/";for(let[y3,g7]of K.entries())if(g7.getEntity().getPath().startsWith($1))K.remove(y3)}}),{entity:H8?H8.getEntity():O8.entity,oldValues:O8.oldValues}},W=async(r,a,{id:s},K8)=>{let P8=K.get(s),H8=P8?P8.getEntity().getPath():null,O8=await $.deleteFolder(r,a,{id:s});return K8(()=>{K.remove(s);for(let A8 of O8.descendantIds||[])K.remove(A8)}),{...O8,path:H8}},H=async(r,a,s)=>{let K8=await $.listFolderContents(r,a,s);for(let P8 of K8)K.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},Z=async(r,a,s)=>{let K8=await $.getFolderByPath(r,a,s);if(!K8)return null;let{entity:P8,mutationApi:H8,pk:O8}=K8;return K.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},O=async(r,a,s,K8)=>{let P8=await $.findFolderByName(r,a,s,K8);if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return K.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},w=async(r,a,s)=>{let K8=await $.readRootFolderForType(r,a,s);if(!K8)return null;let{entity:P8,mutationApi:H8,pk:O8}=K8;return K.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},X=async(r,a,s,K8,P8)=>{return $.isDuplicateNameInParent(r,a,s,K8,P8)},T=async(r,a,s,K8)=>{let P8=await $.createContent(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{q.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},G=async(r,a,{id:s})=>{let K8=q.get(s);if(K8)return K8.getEntity();let P8=await $.readContent(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return q.set(s,l6.create(H8,O8,A8)),H8},v=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.updateContent(r,a,s);return K8(()=>{if(H8){let A8=H8.getMutationApi();if(s.name!==void 0)A8.setName(s.name);if(s.parentId!==void 0)A8.setParentId(s.parentId);A8.setUpdatedAt(O8.entity.getUpdatedAt()),A8.setPath(O8.entity.getPath())}else{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}}),H8?H8.getEntity():O8.entity},f=async(r,a,{id:s},K8)=>{let P8=q.get(s),H8=P8?P8.getEntity().getPath():null,O8=await $.deleteContent(r,a,{id:s});return K8(()=>{q.remove(s)}),{...O8,path:H8}},A=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.saveDraft(r,a,s);K8(()=>{if(H8){let A6=H8.getMutationApi();A6.setDraftContent(O8.entity.getDraftContent()),A6.setHasDraft(O8.entity.hasDraftContent()),A6.setUpdatedAt(O8.entity.getUpdatedAt())}else{let{entity:A6,mutationApi:E6,pk:$1}=O8;q.set(P8,l6.create(A6,E6,$1))}});let A8=H8?H8.getEntity():O8.entity;if(O8.lockLost!==void 0)return{entity:A8,lockLost:O8.lockLost};return A8},C=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.publishContent(r,a,s);if(H8){let A8=H8.getMutationApi();return A8.setPublishedVersionNumber(O8.entity.getPublishedVersionNumber()),A8.setPublishedContent(O8.entity.getPublishedContent()),A8.setDraftContent(null),A8.setHasDraft(!1),A8.setUpdatedAt(O8.entity.getUpdatedAt()),H8.getEntity()}else return K8(()=>{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}),O8.entity},V=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.discardDraft(r,a,s);return K8(()=>{if(H8){let A8=H8.getMutationApi();A8.setDraftContent(null),A8.setHasDraft(!1),A8.setUpdatedAt(O8.entity.getUpdatedAt())}else{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}}),H8?H8.getEntity():O8.entity},M=async(r,a,s)=>{return $.readDraft(r,a,s)},R=async(r,a,s)=>{return $.readVersion(r,a,s)},I=async(r,a,s)=>{return $.getVersions(r,a,s)},D=async(r,a,s,K8,P8)=>{let H8=await $.findContentByName(r,a,s,K8,P8);if(!H8)return null;let{entity:O8,mutationApi:A8,pk:A6}=H8;return q.set(O8.getObjectId(),l6.create(O8,A8,A6)),O8},m=async(r,a,s)=>{let K8=await $.listContent(r,a,s);for(let P8 of K8)q.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},b=async(r,a,s,K8)=>{let{id:P8}=s,H8=await $.setEditState(r,a,s);return K8(()=>{q.remove(P8)}),H8},h=async(r,a,s)=>{return $.getEditState(r,a,s)},L=async(r,a,s,K8)=>{let{id:P8}=s;await $.clearEditState(r,a,s),K8(()=>{q.remove(P8)})},B=async(r,a,s,K8)=>{let P8=await $.createFieldDefinition(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{Y.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},i=async(r,a,{id:s})=>{let K8=Y.get(s);if(K8)return K8.getEntity();let P8=await $.readFieldDefinition(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(s,l6.create(H8,O8,A8)),H8},X8=async(r,a,s,K8)=>{let P8=await $.findFieldDefinitionByName(r,a,s,K8);if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},N8=async(r,a,s)=>{let K8=await $.getFieldDefinitionsForOwner(r,a,s);for(let P8 of K8)Y.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},h8=async(r,a)=>{let s=`${$.getCode()}n1`,K8=Y.get(s);if(K8)return K8.getEntity();let P8=await $.readDefaultFieldDefinition(r,a),{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},c8=async(r,a,s)=>{let K8=await $.resolveFieldDefinition(r,a,s),{entity:P8,mutationApi:H8,pk:O8}=K8;return Y.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},E8=async(r,a,{id:s},K8)=>{let P8=await $.deleteFieldDefinition(r,a,{id:s});return K8(()=>{Y.remove(s)}),P8},g8=async(r,a,s,K8)=>{let{entityId:P8}=s,H8=await $.setFieldValue(r,a,s);return K8(()=>{let O8=K.get(P8)||q.get(P8);if(O8){let A8=O8.getMutationApi(),A6=H8.entity.getField(H8.fieldName);A8.setField(H8.fieldName,A6)}}),H8.entity},t8=async(r,a,s)=>{return $.getFieldValue(r,a,s)},v4=async(r,a,s,K8)=>{let{entityId:P8}=s,H8=await $.deleteFieldValue(r,a,s);K8(()=>{let O8=K.get(P8)||q.get(P8);if(O8)O8.getMutationApi().removeField(H8.fieldName)})},g3=(r)=>{K.remove(r)};return Object.freeze({getObjectId:$.getObjectId,getName:$.getName,getCreatedAt:$.getCreatedAt,getUpdatedAt:$.getUpdatedAt,getCodes:$.getCodes,getType:$.getType,getCode:$.getCode,getPk:$.getPk,toJSON:$.toJSON,createFolder:z,readFolder:P,updateFolder:J,deleteFolder:W,listFolderContents:H,getFolderByPath:Z,findFolderByName:O,readRootFolderForType:w,isDuplicateNameInParent:X,createContent:T,readContent:G,updateContent:v,deleteContent:f,saveDraft:A,readDraft:M,publishContent:C,discardDraft:V,readVersion:R,getVersions:I,findContentByName:D,listContent:m,setEditState:b,getEditState:h,clearEditState:L,createFieldDefinition:B,readFieldDefinition:i,findFieldDefinitionByName:X8,getFieldDefinitionsForOwner:N8,readDefaultFieldDefinition:h8,resolveFieldDefinition:c8,deleteFieldDefinition:E8,setFieldValue:g8,getFieldValue:t8,deleteFieldValue:v4,evictFolder:g3})},mP8=Object.freeze({create:TH6});var jH6=($)=>{let K=new Map;return $.forEach((P)=>K.set(P,new Set)),Object.freeze({subscribe:(P,J)=>{return K.get(P)?.add(J),()=>K.get(P)?.delete(J)},subscribeAll:(P)=>{let J=[];for(let[W,H]of K){let Z=`on${W.charAt(0).toUpperCase()}${W.slice(1)}`;if(P[Z])H.add(P[Z]),J.push(()=>H.delete(P[Z]))}return()=>J.forEach((W)=>W())},notify:(P,J)=>{K.get(P)?.forEach((W)=>{try{W(J)}catch(H){console.error(`Error in ${P} handler:`,H)}})}})},pP8=Object.freeze({create:jH6});var T6=Object.freeze({FOLDER_CREATED:"folderCreated",FOLDER_RENAMED:"folderRenamed",FOLDER_MOVED:"folderMoved",FOLDER_DELETED:"folderDeleted",DOCUMENT_CREATED:"documentCreated",DOCUMENT_RENAMED:"documentRenamed",DOCUMENT_MOVED:"documentMoved",DOCUMENT_DELETED:"documentDeleted",DOCUMENT_PUBLISHED:"documentPublished",DRAFT_SAVED:"draftSaved",DRAFT_DISCARDED:"draftDiscarded",TEMPLATE_CREATED:"templateCreated",TEMPLATE_RENAMED:"templateRenamed",TEMPLATE_MOVED:"templateMoved",TEMPLATE_DELETED:"templateDeleted",TEMPLATE_PUBLISHED:"templatePublished",TEMPLATE_DRAFT_SAVED:"templateDraftSaved",TEMPLATE_DRAFT_DISCARDED:"templateDraftDiscarded",EDIT_STATE_ACQUIRED:"editStateAcquired",EDIT_STATE_REFRESHED:"editStateRefreshed",EDIT_STATE_CLEARED:"editStateCleared"});var vH6=({inner:$,storeCode:K})=>{let q=pP8.create([T6.FOLDER_CREATED,T6.FOLDER_RENAMED,T6.FOLDER_MOVED,T6.FOLDER_DELETED,T6.DOCUMENT_CREATED,T6.DOCUMENT_RENAMED,T6.DOCUMENT_MOVED,T6.DOCUMENT_DELETED,T6.DOCUMENT_PUBLISHED,T6.DRAFT_SAVED,T6.DRAFT_DISCARDED,T6.TEMPLATE_CREATED,T6.TEMPLATE_RENAMED,T6.TEMPLATE_MOVED,T6.TEMPLATE_DELETED,T6.TEMPLATE_PUBLISHED,T6.TEMPLATE_DRAFT_SAVED,T6.TEMPLATE_DRAFT_DISCARDED]),Y=async(v8,r,a)=>{let s=await $.readFolder(v8,r,{id:a});if(!s)return null;let K8=await v8.selectFrom("entities").innerJoin("entity_types","entities.entity_type_id","entity_types.id").select(["entity_types.code as entity_type_code","entity_types.subtype as entity_type_subtype"]).where("entities.object_id","=",a).executeTakeFirst();if(K8?.entity_type_code==="f"&&K8?.entity_type_subtype==="root_d")return"d";if(K8?.entity_type_code==="f"&&K8?.entity_type_subtype==="root_t")return"t";let P8=await $.readRootFolderForType(v8,r,"d"),H8=await $.readRootFolderForType(v8,r,"t"),O8=s;while(O8&&O8.getParentId()!==null){let A8=await $.readFolder(v8,r,{id:O8.getParentId()});if(!A8)break;O8=A8}if(O8&&O8.getObjectId()===P8?.getObjectId())return"d";else if(O8&&O8.getObjectId()===H8?.getObjectId())return"t";return null},z=async(v8,r,a,s)=>{let{parentId:K8,subtype:P8}=a,H8=await $.createFolder(v8,r,a,s),O8=null;if(P8==="root_d")O8="d";else if(P8==="root_t")O8="t";else{let A8=await $.readRootFolderForType(v8,r,"d"),A6=await $.readRootFolderForType(v8,r,"t");if(K8===A8?.getObjectId())O8="d";else if(K8===A6?.getObjectId())O8="t";else if(K8){let E6=await $.readFolder(v8,r,{id:K8});if(E6){let $1=E6;while($1&&$1.getParentId()!==null){let y3=await $.readFolder(v8,r,{id:$1.getParentId()});if(!y3)break;$1=y3}if($1&&$1.getObjectId()===A8?.getObjectId())O8="d";else if($1&&$1.getObjectId()===A6?.getObjectId())O8="t"}}}return s(()=>{q.notify(T6.FOLDER_CREATED,{id:H8.getObjectId(),storeCode:K,name:H8.getName(),path:H8.getPath(),parentFolderId:K8,contentType:O8})}),H8},P=async(v8,r,a)=>{return $.readFolder(v8,r,a)},J=async(v8,r,a,s)=>{let{id:K8,name:P8,parentId:H8}=a,O8=await $.updateFolder(v8,r,a,s),A8=O8.entity,A6=O8.oldValues.name,E6=O8.oldValues.parentId,$1=await Y(v8,r,K8);if(P8!==void 0&&P8!==A6)s(()=>{q.notify(T6.FOLDER_RENAMED,{id:K8,storeCode:K,parentFolderId:A8.getParentId(),contentType:$1,oldName:A6,newName:P8,path:A8.getPath()})});if(H8!==void 0&&H8!==E6)s(()=>{q.notify(T6.FOLDER_MOVED,{id:K8,storeCode:K,contentType:$1,oldParentFolderId:E6,parentFolderId:H8,path:A8.getPath()})});return A8},W=async(v8,r,a,s)=>{let{id:K8}=a,H8=(await $.readFolder(v8,r,{id:K8}))?.getParentId(),O8=await Y(v8,r,K8),A8=await $.deleteFolder(v8,r,a,s);return s(()=>{q.notify(T6.FOLDER_DELETED,{id:K8,storeCode:K,parentFolderId:H8,contentType:O8,path:A8.path,descendantCount:A8.descendantIds?.length||0})}),A8},H=async(v8,r,a)=>{return $.listFolderContents(v8,r,a)},Z=async(v8,r,a)=>{return $.getFolderByPath(v8,r,a)},O=async(v8,r,a,s)=>{return $.findFolderByName(v8,r,a,s)},w=async(v8,r,a)=>{return $.readRootFolderForType(v8,r,a)},X=async(v8,r,a,s,K8)=>{return $.isDuplicateNameInParent(v8,r,a,s,K8)},T=async(v8,r,a,s)=>{let{type:K8,parentId:P8}=a,H8=await $.createContent(v8,r,a,s),O8=K8==="t"?T6.TEMPLATE_CREATED:T6.DOCUMENT_CREATED;return s(()=>{q.notify(O8,{storeCode:K,id:H8.getObjectId(),type:K8,parentFolderId:P8,name:H8.getName(),path:H8.getPath()})}),H8},G=async(v8,r,a)=>{return $.readContent(v8,r,a)},v=async(v8,r,a,s)=>{let{id:K8,name:P8,parentId:H8}=a,O8=m1.getTypeFromId(K8),A8=await $.readContent(v8,r,{id:K8}),A6=A8?.getName(),E6=A8?.getParentId(),$1=await $.updateContent(v8,r,a,s),y3=O8==="t"?T6.TEMPLATE_RENAMED:T6.DOCUMENT_RENAMED,g7=O8==="t"?T6.TEMPLATE_MOVED:T6.DOCUMENT_MOVED;if(P8!==void 0&&P8!==A6)s(()=>{q.notify(y3,{storeCode:K,id:K8,type:O8,parentFolderId:$1.getParentId(),oldName:A6,newName:P8,path:$1.getPath()})});if(H8!==void 0&&H8!==E6)s(()=>{q.notify(g7,{storeCode:K,id:K8,type:O8,oldParentFolderId:E6,parentFolderId:H8,path:$1.getPath()})});return $1},f=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),O8=(await $.readContent(v8,r,{id:K8}))?.getParentId(),A8=await $.deleteContent(v8,r,a,s),A6=P8==="t"?T6.TEMPLATE_DELETED:T6.DOCUMENT_DELETED;return s(()=>{q.notify(A6,{storeCode:K,id:K8,type:P8,parentFolderId:O8,path:A8.path})}),A8},A=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),O8=(await $.readContent(v8,r,{id:K8}))?.getParentId(),A8=await $.saveDraft(v8,r,a,s),A6=P8==="t"?T6.TEMPLATE_DRAFT_SAVED:T6.DRAFT_SAVED;return s(()=>{let E6=A8.lockLost!==void 0?A8.entity:A8;q.notify(A6,{storeCode:K,id:K8,type:P8,parentFolderId:O8,updatedAt:E6?E6.getUpdatedAt():null,lockLost:A8.lockLost})}),A8},C=async(v8,r,a)=>{return $.readDraft(v8,r,a)},V=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),H8=await $.publishContent(v8,r,a,s),O8=P8==="t"?T6.TEMPLATE_PUBLISHED:T6.DOCUMENT_PUBLISHED;return s(()=>{q.notify(O8,{storeCode:K,id:K8,type:P8,parentFolderId:H8.getParentId(),versionNumber:H8.getPublishedVersionNumber()})}),{entityId:K8,versionNumber:H8.getPublishedVersionNumber(),content:H8.getPublishedContent(),publishedAt:H8.getUpdatedAt()}},M=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),H8=await $.discardDraft(v8,r,a,s),O8=P8==="t"?T6.TEMPLATE_DRAFT_DISCARDED:T6.DRAFT_DISCARDED;return s(()=>{q.notify(O8,{storeCode:K,id:K8})}),H8},R=async(v8,r,a)=>{return $.readVersion(v8,r,a)},I=async(v8,r,a)=>{return $.getVersions(v8,r,a)},D=async(v8,r,a,s,K8)=>{return $.findContentByName(v8,r,a,s,K8)},m=async(v8,r,a)=>{return $.listContent(v8,r,a)},b=async(v8,r,a,s)=>{return $.setEditState(v8,r,a,s)},h=async(v8,r,a)=>{return $.getEditState(v8,r,a)},L=async(v8,r,a,s)=>{return $.clearEditState(v8,r,a,s)},B=async(v8,r,a,s)=>{return $.createFieldDefinition(v8,r,a,s)},i=async(v8,r,a)=>{return $.readFieldDefinition(v8,r,a)},X8=async(v8,r,a,s)=>{return $.findFieldDefinitionByName(v8,r,a,s)},N8=async(v8,r,a)=>{return $.getFieldDefinitionsForOwner(v8,r,a)},h8=async(v8,r)=>{return $.readDefaultFieldDefinition(v8,r)},c8=async(v8,r,a)=>{return $.resolveFieldDefinition(v8,r,a)},E8=async(v8,r,a,s)=>{return $.deleteFieldDefinition(v8,r,a,s)},g8=async(v8,r,a,s)=>{return $.setFieldValue(v8,r,a,s)},t8=async(v8,r,a)=>{return $.getFieldValue(v8,r,a)},v4=async(v8,r,a,s)=>{return $.deleteFieldValue(v8,r,a,s)};return Object.freeze({getObjectId:$.getObjectId,getName:$.getName,getCreatedAt:$.getCreatedAt,getUpdatedAt:$.getUpdatedAt,getCodes:$.getCodes,getType:$.getType,getCode:$.getCode,getPk:$.getPk,toJSON:$.toJSON,createFolder:z,readFolder:P,updateFolder:J,deleteFolder:W,listFolderContents:H,getFolderByPath:Z,findFolderByName:O,readRootFolderForType:w,isDuplicateNameInParent:X,createContent:T,readContent:G,updateContent:v,deleteContent:f,saveDraft:A,readDraft:C,publishContent:V,discardDraft:M,readVersion:R,getVersions:I,findContentByName:D,listContent:m,setEditState:b,getEditState:h,clearEditState:L,createFieldDefinition:B,readFieldDefinition:i,findFieldDefinitionByName:X8,getFieldDefinitionsForOwner:N8,readDefaultFieldDefinition:h8,resolveFieldDefinition:c8,deleteFieldDefinition:E8,setFieldValue:g8,getFieldValue:t8,deleteFieldValue:v4,evictFolder:$.evictFolder,subscribe:q.subscribe,subscribeAll:q.subscribeAll})},cP8=Object.freeze({create:vH6});var GH6=($)=>{let{id:K,code:q,name:Y,pk:z,createdAt:P,updatedAt:J}=$,W=jf.create(),H=jf.create(),Z=jf.create(),{store:O,mutationApi:w}=uP8.create({id:K,code:q,name:Y,pk:z,createdAt:P,updatedAt:J,folderCache:W}),X=mP8.create({inner:O,folderCache:W,contentCache:H,fieldDefinitionCache:Z});return{store:cP8.create({inner:X,storeCode:q}),mutationApi:w}},BP8=Object.freeze({create:GH6});R4();var _H6=({id:$,name:K,createdAt:q,updatedAt:Y,children:z=[]})=>{let P=[...z],J=new Map,{entityFns:W,mutationFns:H}=K5.create({id:$,name:K,createdAt:q,updatedAt:Y}),Z=()=>{J.clear();for(let V8 of P){let R8=V8.getCodes();for(let c of R8)J.set(c,V8)}};Z();let O=()=>"demux",w=()=>P.map((V8)=>V8.getObjectId()),X=()=>[...P],T=()=>{return new Set(J.keys())},G=()=>({id:$,name:K,createdAt:q,updatedAt:Y,type:"demux",childIds:w()}),v=(V8)=>{P.push(V8),Z()},f=(V8)=>{return J.get(V8)??null},A=async(V8,R8,{store:c,storeCode:o,parentId:E,name:u,subtype:y},Q)=>{let d=c??o;Y8.factory(!d,t.validation,"store parameter is required","MISSING_STORE_CODE");let $8=f(d);return Y8.factory(!$8,t.notFound,`No child store with code: ${d}`,"STORE_NOT_FOUND"),$8.createFolder(V8,R8,{storeCode:d,parentId:E,name:u,subtype:y},Q)},C=async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readFolder(V8,R8,{id:c})},g7=Object.freeze({...W,getType:O,getCodes:T,getChildIds:w,getChildren:X,toJSON:G,createFolder:A,readFolder:C,updateFolder:async(V8,R8,{id:c,name:o,parentId:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.updateFolder(V8,R8,{id:c,name:o,parentId:E},u)},deleteFolder:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteFolder(V8,R8,{id:c},o)},evictFolder:(V8)=>{let R8=V8?.[0],c=f(R8);if(c)c.evictFolder(V8)},getFolder:async(V8,R8,{id:c})=>{return C(V8,R8,{id:c})},listFolderContents:async(V8,R8,{folderId:c,store:o,storeCode:E,type:u})=>{let y;if(c!==null&&c!==void 0)y=c[0];else{let $8=o??E;Y8.factory(!$8,t.validation,"store required when folderId is null","STORE_CODE_REQUIRED"),y=$8}let Q=f(y);Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND");let d={...R8,storeCode:y};return Q.listFolderContents(V8,d,{folderId:c,type:u})},getFolderByPath:async(V8,R8,{path:c,type:o,store:E,storeCode:u})=>{let y=E??u;Y8.factory(!y,t.validation,"store required for getFolderByPath","STORE_CODE_REQUIRED");let Q=f(y);if(!Q)return null;let d={...R8,storeCode:y};return Q.getFolderByPath(V8,d,{path:c,type:o})},isDuplicateNameInParent:async(V8,R8,c,o,E=null)=>{let u;if(c)u=c[0];else{let Q=P[0];if(!Q)Y8.factory(!0,t.notFound,"No child stores available","STORE_NOT_FOUND");u=[...Q.getCodes()][0]}let y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.isDuplicateNameInParent(V8,R8,c,o,E)},findFolderByName:async(V8,R8,c,o)=>{let E=c[0],u=f(E);if(!u)return null;return u.findFolderByName(V8,R8,c,o)},readRootFolderForType:async(V8,R8,c,o)=>{let E=f(o);return Y8.factory(!E,t.notFound,`No child store with code: ${o}`,"STORE_NOT_FOUND"),E.readRootFolderForType(V8,R8,c,o)},createFieldDefinition:async(V8,R8,{storeCode:c,ownerEntityId:o,name:E,label:u,description:y,primitiveType:Q,required:d,multiplicity:$8,isSystem:W8},z8)=>{let w8=f(c);return Y8.factory(!w8,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),w8.createFieldDefinition(V8,R8,{storeCode:c,ownerEntityId:o,name:E,label:u,description:y,primitiveType:Q,required:d,multiplicity:$8,isSystem:W8},z8)},readFieldDefinition:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readFieldDefinition(V8,R8,{id:c})},readDefaultFieldDefinition:async(V8,R8,c)=>{let o=f(c);return Y8.factory(!o,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),o.readDefaultFieldDefinition(V8,R8)},getFieldDefinitionsForOwner:async(V8,R8,{storeCode:c,ownerEntityPk:o,includeSystem:E})=>{let u=f(c);return Y8.factory(!u,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),u.getFieldDefinitionsForOwner(V8,R8,{ownerEntityPk:o,includeSystem:E})},deleteFieldDefinition:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteFieldDefinition(V8,R8,{id:c},o)},setFieldValue:async(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E,value:u,values:y},Q)=>{let d=c?.[0],$8=f(d);return Y8.factory(!$8,t.notFound,`No child store with code: ${d}`,"STORE_NOT_FOUND"),$8.setFieldValue(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E,value:u,values:y},Q)},deleteFieldValue:async(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.deleteFieldValue(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E},u)},createContent:async(V8,R8,{storeCode:c,type:o,...E},u)=>{let y=f(c);return Y8.factory(!y,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),y.createContent(V8,R8,{type:o,storeCode:c,...E},u)},readContent:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readContent(V8,R8,{id:c})},updateContent:async(V8,R8,{id:c,...o},E)=>{let u=c?.[0],y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.updateContent(V8,R8,{id:c,...o},E)},deleteContent:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteContent(V8,R8,{id:c},o)},saveDraft:async(V8,R8,{id:c,content:o,clientId:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.saveDraft(V8,R8,{id:c,content:o,clientId:E},u)},readDraft:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readDraft(V8,R8,{id:c})},publishContent:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.publishContent(V8,R8,{id:c},o)},discardDraft:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.discardDraft(V8,R8,{id:c},o)},findContentByName:async(V8,R8,c,o,E)=>{let u=c?.[0],y=f(u);if(!y)return null;return y.findContentByName(V8,R8,c,o,E)},listContent:async(V8,R8,{parentId:c,storeCode:o,type:E})=>{let u,y;if(c)u=c[0],y=c;else{Y8.factory(!o,t.validation,"storeCode required when parentId is null","MISSING_STORE_CODE"),u=o;let d=f(u);Y8.factory(!d,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND");try{y=(await d.readRootFolderForType(V8,R8,E||"d",u)).getObjectId()}catch($8){y=null}}let Q=f(u);return Y8.factory(!Q,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),Q.listContent(V8,R8,{parentId:y,type:E})},setEditState:async(V8,R8,{id:c,clientId:o},E)=>{let u=c?.[0],y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.setEditState(V8,R8,{id:c,clientId:o},E)},clearEditState:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.clearEditState(V8,R8,{id:c},o)},getEditState:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.getEditState(V8,R8,{id:c})},readVersion:async(V8,R8,{id:c,versionNumber:o})=>{let E=c?.[0],u=f(E);if(!u)return null;return u.readVersion(V8,R8,{id:c,versionNumber:o})},getVersions:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return[];return E.getVersions(V8,R8,{id:c})},subscribe:(V8,R8)=>{let c=P.map((o)=>o.subscribe(V8,R8));return()=>c.forEach((o)=>o())},subscribeAll:(V8)=>{let R8=P.map((c)=>c.subscribeAll(V8));return()=>R8.forEach((c)=>c())}}),tK=Object.freeze({...H,addChild:v});return{store:g7,mutationApi:tK}},UP8=Object.freeze({create:_H6});R4();var fX=($)=>{if(!$||$.length<2||$[0]!=="S")return null;let K=parseInt($.slice(1),10);return isNaN(K)?null:K},wx=($)=>$.object_id,Ox=($)=>{let K=wx($),q=$.id,{store:Y,mutationApi:z}=BP8.create({id:K,code:$.code,name:$.name,createdAt:$.created_at,updatedAt:$.updated_at,pk:q});return{store:Y,mutationApi:z,id:K,pk:q}},lP8=($,K)=>{let q=wx($),Y=$.id,{store:z,mutationApi:P}=UP8.create({id:q,name:$.name,createdAt:$.created_at,updatedAt:$.updated_at,children:K});return{store:z,mutationApi:P,id:q,pk:Y}},fH6=async($,K,q,Y,z)=>{let P=await uz.readEntityTypeId($,K,"n",null),J=await q5.nextSeq($,"store",q,"n"),W=`${Y}n${J}`,H=K4();await $.insertInto("field_definitions").values({store_id:q,object_id:W,entity_type_id:P,type_code:"n",seq:J,owner_entity_id:null,name:"default",label:"Default Field",description:"Auto-created for ad-hoc fields without explicit definitions",primitive_type:"string",required:0,multiplicity:"single",config:null,is_system:1,ordinal:null,created_at:H,updated_at:H}).execute()},AH6=()=>{let $=new Map,K=new Map,q=async(O,w,{code:X,name:T},G)=>{let v=K4(),f=await q5.nextSeq(O,"global",null,"s"),A=`S${f}`,C=await O.insertInto("stores").values({id:f,object_id:A,type:"local",code:X,name:T,created_at:v,updated_at:v}).returningAll().executeTakeFirstOrThrow(),{store:V,mutationApi:M,id:R,pk:I}=Ox(C);return await fH6(O,w,I,X,G),G(()=>{$.set(R,l6.create(V,M,I)),K.set(I,R)}),V},Y=async(O,w,{name:X},T)=>{let G=K4(),v=await q5.nextSeq(O,"global",null,"s"),f=`S${v}`,A=await O.insertInto("stores").values({id:v,object_id:f,type:"demux",code:null,name:X,created_at:G,updated_at:G}).returningAll().executeTakeFirstOrThrow(),{store:C,mutationApi:V,id:M,pk:R}=lP8(A,[]);return T(()=>{$.set(M,l6.create(C,V,R)),K.set(R,M)}),C},z=async(O,w,X)=>{let T=$.get(X);if(T)return T.getEntity();let G=fX(X);if(G===null)return null;let v=await O.selectFrom("stores").selectAll().where("id","=",G).executeTakeFirst();if(!v)return null;let f,A,C,V;if(v.type==="local"){let M=Ox(v);f=M.store,A=M.mutationApi,C=M.id,V=M.pk}else{let M=await O.selectFrom("store_children").innerJoin("stores","stores.id","store_children.child_store_id").select(["stores.object_id"]).where("store_children.parent_store_id","=",v.id).execute(),R=[];for(let D of M){let m=await z(O,w,D.object_id);if(m)R.push(m)}let I=lP8(v,R);f=I.store,A=I.mutationApi,C=I.id,V=I.pk}return $.set(C,l6.create(f,A,V)),K.set(V,C),f};return Object.freeze({createLocalStore:q,createDemuxStore:Y,readStore:z,readSharedStore:async(O,w)=>{let X=await O.selectFrom("stores").selectAll().where("code","=","B").executeTakeFirstOrThrow(),T=wx(X),G=$.get(T);if(G)return G.getEntity();let{store:v,mutationApi:f,pk:A}=Ox(X);return $.set(T,l6.create(v,f,A)),K.set(A,T),v},readRootStoreForProject:async(O,w,X)=>{let T=X&&X.length>=2&&X[0]==="P"?parseInt(X.slice(1),10):null;Y8.factory(T===null||isNaN(T),t.validation,`Invalid project ID: ${X}`,"INVALID_PROJECT_ID");let G=await O.selectFrom("project_stores").innerJoin("stores","stores.id","project_stores.store_id").select(["stores.object_id"]).where("project_stores.project_id","=",T).where("project_stores.is_root","=",1).executeTakeFirst();return Y8.factory(!G,t.notFound,`Root store not found for project: ${X}`,"ROOT_STORE_NOT_FOUND"),await z(O,w,G.object_id)},addChildToDemux:async(O,w,{demuxId:X,childId:T},G)=>{let v=$.get(X),f=$.get(T),A,C;if(v)A=v.getPk();else{let V=fX(X);Y8.factory(V===null,t.validation,`Invalid demux store ID: ${X}`,"INVALID_ID");let M=await O.selectFrom("stores").select("id").where("id","=",V).executeTakeFirst();Y8.factory(!M,t.notFound,`Demux store not found: ${X}`,"STORE_NOT_FOUND"),A=M.id}if(f)C=f.getPk();else{let V=fX(T);Y8.factory(V===null,t.validation,`Invalid child store ID: ${T}`,"INVALID_ID");let M=await O.selectFrom("stores").select("id").where("id","=",V).executeTakeFirst();Y8.factory(!M,t.notFound,`Child store not found: ${T}`,"STORE_NOT_FOUND"),C=M.id}await O.insertInto("store_children").values({parent_store_id:A,child_store_id:C}).execute(),G(()=>{let V=$.get(X),M=$.get(T);if(V&&M)V.getMutationApi().addChild(M.getEntity())})},addStoresToProject:async(O,w,{projectId:X,rootStoreId:T,storeIds:G})=>{let v=X&&X.length>=2&&X[0]==="P"?parseInt(X.slice(1),10):null;Y8.factory(v===null||isNaN(v),t.validation,`Invalid project ID: ${X}`,"INVALID_PROJECT_ID");let f=await O.selectFrom("projects").select("id").where("id","=",v).executeTakeFirst();Y8.factory(!f,t.notFound,`Project not found: ${X}`,"PROJECT_NOT_FOUND");let A=f.id,C=$.get(T),V;if(C)V=C.getPk();else{let M=fX(T);Y8.factory(M===null,t.validation,`Invalid root store ID: ${T}`,"INVALID_ID");let R=await O.selectFrom("stores").select("id").where("id","=",M).executeTakeFirst();Y8.factory(!R,t.notFound,`Root store not found: ${T}`,"STORE_NOT_FOUND"),V=R.id}for(let M of G){let R=$.get(M),I;if(R)I=R.getPk();else{let D=fX(M);Y8.factory(D===null,t.validation,`Invalid store ID: ${M}`,"INVALID_ID");let m=await O.selectFrom("stores").select("id").where("id","=",D).executeTakeFirst();Y8.factory(!m,t.notFound,`Store not found: ${M}`,"STORE_NOT_FOUND"),I=m.id}await O.insertInto("project_stores").values({project_id:A,store_id:I,is_root:I===V?1:0}).execute()}},evictStore:(O)=>{let w=$.get(O);if(w)K.delete(w.getPk());$.delete(O)}})},FP8=Object.freeze({create:AH6});R4();R4();var VH6=({store:$})=>{let K=async(Z,O,w,X,T,G)=>{let v=w.split("/").filter((C)=>C.trim());Y8.factory(v.length===0,t.validation,"Path cannot be empty or contain only slashes","EMPTY_PATH");let f=await $.readRootFolderForType(Z,O,X,T);for(let C=0;C<v.length-1;C++){let V=HK.validateFolderName(v[C]),M=await $.findFolderByName(Z,O,f.getObjectId(),V);if(M)f=M;else f=await $.createFolder(Z,O,{storeCode:T,parentId:f.getObjectId(),name:V},G)}let A=HK.validateFolderName(v[v.length-1]);return{parentObjectId:f.getObjectId(),name:A}},q=async(Z,O,{store:w,path:X,type:T},G)=>{Y8.factory(!X||X==="/",t.validation,"Path cannot be empty","EMPTY_PATH"),Y8.factory(T!=="d"&&T!=="t",t.validation,'Type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!w,t.validation,"store is required","MISSING_STORE_CODE");let{parentObjectId:v,name:f}=await K(Z,O,X,T,w,G),A=await $.isDuplicateNameInParent(Z,O,v,f);return Y8.factory(A,t.conflict,`Folder "${f}" already exists in parent`,"DUPLICATE_NAME"),await $.createFolder(Z,O,{storeCode:w,parentId:v,name:f},G)},Y=async(Z,O,{id:w})=>{return await $.readFolder(Z,O,{id:w})};return Object.freeze({resolvePath:K,createFolder:q,readFolder:Y,renameFolder:async(Z,O,{id:w,name:X},T)=>{let G=await Y(Z,O,{id:w});Y8.factory(!G,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(G),t.validation,"Cannot rename root folder","CANNOT_RENAME_ROOT");let v=HK.validateFolderName(X),f=await $.isDuplicateNameInParent(Z,O,G.getParentId(),v,w);return Y8.factory(f,t.conflict,`Folder "${v}" already exists in parent`,"DUPLICATE_NAME"),await $.updateFolder(Z,O,{id:w,name:v},T)},moveFolder:async(Z,O,{id:w,parentId:X},T)=>{let G=await Y(Z,O,{id:w});Y8.factory(!G,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(G),t.validation,"Cannot move root folder","CANNOT_MOVE_ROOT");let v=await Y(Z,O,{id:X});Y8.factory(!v,t.notFound,`Parent folder not found: ${X}`,"PARENT_NOT_FOUND"),Y8.factory(!w||w.length<1,t.validation,"Invalid folder ID format","INVALID_ID_FORMAT"),Y8.factory(!X||X.length<1,t.validation,"Invalid parent ID format","INVALID_PARENT_ID_FORMAT");let f=w[0],A=X[0];Y8.factory(f!==A,t.validation,"Cannot move folders between stores","CROSS_STORE_MOVE"),Y8.factory(w===X,t.validation,"Cannot move folder into itself","SELF_MOVE");let C=X;while(C!==null){Y8.factory(C===w,t.validation,"Cannot move folder into its own descendant","CYCLE_DETECTED");let M=await $.readFolder(Z,O,{id:C});if(!M)break;C=M.getParentId()}let V=await $.isDuplicateNameInParent(Z,O,X,G.getName(),w);return Y8.factory(V,t.conflict,`Folder "${G.getName()}" already exists in target parent`,"DUPLICATE_NAME"),await $.updateFolder(Z,O,{id:w,parentId:X},T)},deleteFolder:async(Z,O,{id:w},X)=>{let T=await Y(Z,O,{id:w});return Y8.factory(!T,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(T),t.validation,"Cannot delete root folder","CANNOT_DELETE_ROOT"),await $.deleteFolder(Z,O,{id:w},X)},getFolderByPath:async(Z,O,{path:w,type:X,storeCode:T})=>{return await $.getFolderByPath(Z,O,{path:w,type:X,storeCode:T})},listFolderContents:async(Z,O,{folderId:w,type:X,storeCode:T})=>{return await $.listFolderContents(Z,O,{folderId:w,type:X,storeCode:T})}})},iP8=Object.freeze({create:VH6});R4();var kH6=({store:$})=>{let K=async(W,H,{store:Z,ownerEntityId:O,name:w,label:X,description:T,primitiveType:G,required:v,multiplicity:f,isSystem:A=!1},C)=>{Y8.factory(!Z,t.validation,"store is required","MISSING_STORE_CODE"),Y8.factory(G!=="string"&&G!=="object_ref",t.validation,`Invalid primitiveType: ${G}. Must be 'string' or 'object_ref'`,"INVALID_PRIMITIVE_TYPE"),Y8.factory(f!=="single"&&f!=="multi",t.validation,`Invalid multiplicity: ${f}. Must be 'single' or 'multi'`,"INVALID_MULTIPLICITY");let V=/^[a-zA-Z0-9_]+$/;return Y8.factory(!w||!V.test(w),t.validation,`Invalid name: ${w}. Must contain only alphanumeric characters and underscores`,"INVALID_NAME"),await $.createFieldDefinition(W,H,{storeCode:Z,ownerEntityId:O,name:w,label:X,description:T,primitiveType:G,required:v,multiplicity:f,isSystem:A},C)},q=async(W,H,{id:Z})=>{return Y8.factory(!Z||Z.length<3,t.validation,"Invalid field definition ID","INVALID_ID"),await $.readFieldDefinition(W,H,{id:Z})};return Object.freeze({createFieldDefinition:K,readFieldDefinition:q,getFieldDefinitionsForOwner:async(W,H,{store:Z,ownerEntityId:O,includeSystem:w=!0})=>{Y8.factory(!Z,t.validation,"store is required","MISSING_STORE_CODE");let X=null;if(O)X=null;return await $.getFieldDefinitionsForOwner(W,H,{storeCode:Z,ownerEntityPk:X,includeSystem:w})},deleteFieldDefinition:async(W,H,{id:Z},O)=>{let w=await q(W,H,{id:Z});return Y8.factory(!w,t.notFound,`Field definition not found: ${Z}`,"DEFINITION_NOT_FOUND"),Y8.factory(w.getIsSystem(),t.validation,`Cannot delete system field definition: ${Z}`,"SYSTEM_DEFINITION"),await $.deleteFieldDefinition(W,H,{id:Z},O)},setFieldValue:async(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w,value:X,values:T},G)=>{return Y8.factory(!Z,t.validation,"entityId is required","MISSING_ENTITY_ID"),Y8.factory(!O&&!w,t.validation,"Either fieldDefinitionId or fieldName must be provided","MISSING_FIELD_IDENTIFIER"),Y8.factory(X!==void 0&&T!==void 0,t.validation,"Cannot provide both value and values","AMBIGUOUS_VALUE"),Y8.factory(X===void 0&&T===void 0,t.validation,"Either value or values must be provided","MISSING_VALUE"),await $.setFieldValue(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w,value:X,values:T},G)},deleteFieldValue:async(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w},X)=>{return Y8.factory(!Z,t.validation,"entityId is required","MISSING_ENTITY_ID"),Y8.factory(!O&&!w,t.validation,"Either fieldDefinitionId or fieldName must be provided","MISSING_FIELD_IDENTIFIER"),await $.deleteFieldValue(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w},X)}})},QP8=Object.freeze({create:kH6});R4();var MH6=($)=>{let K=$.split("/").filter((z)=>z.trim()),q=K[K.length-1];return{parentPath:K.slice(0,-1).join("/")||null,name:q,segments:K}},NH6=($)=>{return $[0]},AX=Object.freeze({parsePath:MH6,extractStoreCode:NH6});var hH6=({store:$,folderService:K,documentHooks:q})=>{let Y=(M)=>{return M==="t"?"Template":"Document"},z=async(M,R,I,D,m,b)=>{if(I){let h=await K.resolvePath(M,R,I,D,m,b),L=await $.findFolderByName(M,R,h.parentObjectId,h.name);if(L)return L.getObjectId();else return(await $.createFolder(M,R,{storeCode:m,parentId:h.parentObjectId,name:h.name},b)).getObjectId()}else return(await $.readRootFolderForType(M,R,D,m)).getObjectId()},P=async(M,R,{store:I,path:D,type:m,content:b},h)=>{Y8.factory(m!=="d"&&m!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!D||D==="/",t.validation,"Path cannot be empty","EMPTY_PATH"),Y8.factory(!I,t.validation,"store is required","MISSING_STORE_CODE");let{parentPath:L,name:B}=AX.parsePath(D),i=await z(M,R,L,m,I,h),X8=Y(m),N8=await $.findContentByName(M,R,i,B,m);return Y8.factory(N8,t.conflict,`${X8} "${B}" already exists in folder`,"DUPLICATE_NAME"),await $.createContent(M,R,{storeCode:I,type:m,parentId:i,name:B,initialContent:b},h)},J=async(M,R,{id:I})=>{let{typeCode:D}=m1.resolveEntityId(I),m=Y(D),b=await $.readContent(M,R,{id:I});return Y8.factory(!b,t.notFound,`${m} not found: ${I}`,"NOT_FOUND"),b};return Object.freeze({createDocument:P,readDocument:J,readDocumentByPath:async(M,R,{path:I,type:D,storeCode:m})=>{Y8.factory(D!=="d"&&D!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE");let{parentPath:b,name:h}=AX.parsePath(I),L;if(b){let B=await $.getFolderByPath(M,R,{path:b,type:D,storeCode:m});if(!B)return null;L=B.getObjectId()}else L=(await $.readRootFolderForType(M,R,D,m)).getObjectId();return await $.findContentByName(M,R,L,h,D)},updateDocumentPath:async(M,R,{id:I,path:D,type:m},b)=>{Y8.factory(m!=="d"&&m!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!D||D==="/",t.validation,"Path cannot be empty","EMPTY_PATH");let h=await J(M,R,{id:I}),{parentPath:L,name:B}=AX.parsePath(D),i=AX.extractStoreCode(I),X8=await z(M,R,L,m,i,b),N8=B!==h.getName(),h8=X8!==h.getParentId();if(!N8&&!h8)return h;if(N8||h8){let c8=Y(m),E8=await $.findContentByName(M,R,X8,B,m);Y8.factory(E8&&E8.getObjectId()!==I,t.conflict,`${c8} "${B}" already exists in target folder`,"DUPLICATE_NAME")}return await $.updateContent(M,R,{id:I,name:N8?B:void 0,parentId:h8?X8:void 0},b)},deleteDocument:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.deleteContent(M,R,{id:I},D)},saveDraft:async(M,R,{id:I,content:D,clientId:m},b)=>{return await J(M,R,{id:I}),await $.saveDraft(M,R,{id:I,content:D,clientId:m},b)},readDraft:async(M,R,{id:I})=>{let{typeCode:D}=m1.resolveEntityId(I);await J(M,R,{id:I});let m=Y(D),b=await $.readDraft(M,R,{id:I});return Y8.factory(!b,t.notFound,`No draft found for ${m}: ${I}`,"DRAFT_NOT_FOUND"),b},publishDocument:async(M,R,{id:I},D)=>{await J(M,R,{id:I});let{typeCode:m}=m1.resolveEntityId(I),b=await $.publishContent(M,R,{id:I},D),h=q.getHook("prePublish",m);if(h){let L=await J(M,R,{id:I});await h(M,R,L)}return b},discardDraft:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.discardDraft(M,R,{id:I},D)},readVersion:async(M,R,{id:I,versionNumber:D})=>{let{typeCode:m}=m1.resolveEntityId(I);await J(M,R,{id:I});let b=Y(m),h=await $.readVersion(M,R,{id:I,versionNumber:D});return Y8.factory(!h,t.notFound,`Version ${D} not found for ${b}: ${I}`,"VERSION_NOT_FOUND"),h},getVersions:async(M,R,{id:I})=>{return await J(M,R,{id:I}),await $.getVersions(M,R,{id:I})},setEditState:async(M,R,{id:I,clientId:D},m)=>{return await J(M,R,{id:I}),await $.setEditState(M,R,{id:I,clientId:D},m)},clearEditState:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.clearEditState(M,R,{id:I},D)},getEditState:async(M,R,{id:I})=>{return await J(M,R,{id:I}),await $.getEditState(M,R,{id:I})},listDocuments:async(M,R,{parentId:I,storeCode:D,type:m="d"})=>{return await $.listContent(M,R,{parentId:I,storeCode:D,type:m})}})},dP8=Object.freeze({create:hH6});var GO8=K1(OH8(),1),_O8=K1(kb(),1),fO8=($)=>{if(!$)return{parameters:{},target:null,targetPath:null,body:""};let K=GO8.default($),q=K.data?.parameters||{},Y=K.data?.target||null,z=K.data?.targetPath||null,P=K.content;return{parameters:q,target:Y,targetPath:z,body:P}},O_6=($)=>{if(!$)return new Set;let K=new Set,q=new Set(["if","unless","each","with","lookup","log"]);try{let Y=_O8.default.parse($),z=(P,J=null,W=null)=>{if(!P)return;if(P.type==="PathExpression"){if(P.data)return;let H=P.parts.join(".");if(!H||H.startsWith("@"))return;if(J?.type==="BlockStatement"&&W==="path"||J?.type==="MustacheStatement"&&W==="path"&&J.params?.length>0){if(q.has(H))return;return}K.add(H)}if(P.program)z(P.program,P,"program");if(P.inverse)z(P.inverse,P,"inverse");if(P.body)P.body.forEach((H)=>z(H,P,"body"));if(P.params)P.params.forEach((H)=>z(H,P,"params"));if(P.hash?.pairs)P.hash.pairs.forEach((H)=>z(H.value,P,"hash"));if(P.path)z(P.path,P,"path")};z(Y)}catch(Y){throw new Error(`Invalid Handlebars template: ${Y.message}`)}return K},w_6=($)=>{if(!$)return{parameters:{},target:null,targetPath:null};let{parameters:K,target:q,targetPath:Y}=fO8($);return{parameters:K,target:q,targetPath:Y}},M$=Object.freeze({parseFrontMatter:fO8,extractVariables:O_6,getParameters:w_6});R4();var X_6=async($,K,q,Y)=>{try{let z=typeof q.getPublishedContent==="function"?q.getPublishedContent():q.publishedContent,{parameters:P}=M$.parseFrontMatter(z||"");if(!P||Object.keys(P).length===0)return;let J=typeof q.getObjectId==="function"?q.getObjectId():q.id,W=J[0];for(let[H,Z]of Object.entries(P)){let O=Z.type||"string",w=Z.required||!1,X=Z.description||null,T=Z.label||H,G="single";if(O!=="string"&&O!=="object_ref"){console.warn(`Invalid parameter type "${O}" for parameter "${H}" in template ${J}. Defaulting to "string".`);continue}try{await Y.createFieldDefinition($,K,{store:W,ownerEntityId:J,name:H,label:T,description:X,primitiveType:O,required:w,multiplicity:"single",isSystem:!1},()=>{})}catch(v){if(v.code==="DUPLICATE_FIELD_DEFINITION"||v.message?.includes("unique"))console.warn(`Field definition "${H}" already exists for template ${J}. Skipping.`);else console.error(`Failed to create field definition for parameter "${H}" in template ${J}:`,v)}}}catch(z){console.error(`Template publish hook failed for ${q.id}:`,z)}},T_6=({fieldService:$})=>{let K={prePublish:{d:null,t:(Y,z,P)=>X_6(Y,z,P,$)},postPublish:{},preDelete:{},postCreate:{}};return Object.freeze({getHook:(Y,z)=>{return K[Y]?.[z]||null}})},AO8=Object.freeze({create:T_6});R4();var Mb=K1(kb(),1),j_6=($={})=>{return Object.freeze({renderTemplate:(Y,z={})=>{if(!Y)throw t.validation("Template content cannot be empty","EMPTY_TEMPLATE");let{body:P}=M$.parseFrontMatter(Y),J;try{J=Mb.default.compile(P,{noEscape:!0})(z)}catch(W){throw t.validation(`Failed to render template: ${W.message}`,"RENDER_ERROR")}return J},extractTemplateParameters:(Y)=>{if(!Y)return{parameters:{},detectedVariables:[],target:null,targetPath:null};let{parameters:z,target:P,targetPath:J,body:W}=M$.parseFrontMatter(Y),H=M$.extractVariables(W),Z=Array.from(H);return{parameters:z,detectedVariables:Z,target:P,targetPath:J}}})},VO8=Object.freeze({create:j_6});import pX from"node:fs";import kO8 from"node:os";import cf from"node:path";var v_6=({projectStore:$,storeStore:K})=>{return Object.freeze({createProject:async(P,J,{name:W,path:H},Z)=>{if(await $.readProjectByPath(P,J,H)){let v=new Error("Project with this path already exists");throw v.code="DUPLICATE_PATH",v}let w=await $.createProject(P,J,{name:W,path:H},Z),X=await K.createLocalStore(P,J,{code:"A",name:"Project"},Z);await X.createFolder(P,J,{parentId:null,name:null,subtype:"root_d"},Z),await X.createFolder(P,J,{parentId:null,name:null,subtype:"root_t"},Z);let T=await K.readSharedStore(P,J),G=await K.createDemuxStore(P,J,{name:W},Z);return await K.addChildToDemux(P,J,{demuxId:G.getObjectId(),childId:X.getObjectId()},Z),await K.addChildToDemux(P,J,{demuxId:G.getObjectId(),childId:T.getObjectId()},Z),await K.addStoresToProject(P,J,{projectId:w.getObjectId(),rootStoreId:G.getObjectId(),storeIds:[G.getObjectId(),X.getObjectId(),T.getObjectId()]}),w},validateProjectPath:(P)=>{if(!P||typeof P!=="string"){let X=new Error("Path is required and must be a non-empty string");throw X.code="VALIDATION_ERROR",X}let J;if(P==="~")J=kO8.homedir();else if(P.startsWith("~/"))J=cf.join(kO8.homedir(),P.slice(2));else J=P;let W=pX.existsSync(J),H=!1,Z=!1,O=!1;if(W)try{if(H=pX.statSync(J).isDirectory(),H){let T=cf.join(J,".git");try{Z=pX.statSync(T).isDirectory()}catch{Z=!1}let G=cf.join(J,".claude");try{O=pX.statSync(G).isDirectory()}catch{O=!1}}}catch(X){H=!1}let w=cf.basename(J);return{path:J,exists:W,isDirectory:H,hasGit:Z,hasClaude:O,suggestedName:w}},listProjects:async(P)=>{let J=await P.selectFrom("projects").selectAll().where("name","!=","__system__").orderBy("created_at","desc").execute();return await Promise.all(J.map(async(H)=>{let O=(await P.selectFrom("project_stores").innerJoin("stores","stores.id","project_stores.store_id").select(["stores.object_id","stores.code","stores.name","stores.type"]).where("project_stores.project_id","=",H.id).where("stores.type","=","local").execute()).map((w)=>({id:w.code==="B"?"store:B":`store:${w.code}:${H.object_id}`,code:w.code,name:w.name}));return{objectId:H.object_id,name:H.name,path:H.path,createdAt:H.created_at,updatedAt:H.updated_at,children:O}}))}})},Bf=Object.freeze({create:v_6});var G_6=()=>{let $=[];return{enqueuePostCommitHook:(K)=>{$.push(K)},flush:()=>{for(let K of $)try{K()}catch(q){console.error("Post-commit hook failed:",q)}}}},__6=({db:$,folderService:K,fieldService:q,documentService:Y,templateService:z,projectService:P,clipboardService:J})=>{let W=async(h)=>{let L=G_6(),B;return await $.transaction().execute(async(i)=>{B=await h(i,L.enqueuePostCommitHook)}),L.flush(),B};return Object.freeze({createFolder:async(h,{store:L,path:B,type:i})=>{return W(async(X8,N8)=>{return await K.createFolder(X8,h,{store:L,path:B,type:i},N8)})},renameFolder:async(h,{id:L,name:B})=>{return W(async(i,X8)=>{return await K.renameFolder(i,h,{id:L,name:B},X8)})},moveFolder:async(h,{id:L,parentId:B})=>{return W(async(i,X8)=>{return await K.moveFolder(i,h,{id:L,parentId:B},X8)})},deleteFolder:async(h,{id:L})=>{return W(async(B,i)=>{return await K.deleteFolder(B,h,{id:L},i)})},createProject:async(h,{name:L,path:B})=>{return W(async(i,X8)=>{return await P.createProject(i,h,{name:L,path:B},X8)})},createFieldDefinition:async(h,{store:L,ownerEntityId:B,name:i,label:X8,description:N8,primitiveType:h8,required:c8,multiplicity:E8,isSystem:g8})=>{return W(async(t8,v4)=>{return await q.createFieldDefinition(t8,h,{store:L,ownerEntityId:B,name:i,label:X8,description:N8,primitiveType:h8,required:c8,multiplicity:E8,isSystem:g8},v4)})},setFieldValue:async(h,{entityId:L,fieldDefinitionId:B,fieldName:i,value:X8,values:N8})=>{return W(async(h8,c8)=>{return await q.setFieldValue(h8,h,{entityId:L,fieldDefinitionId:B,fieldName:i,value:X8,values:N8},c8)})},deleteFieldValue:async(h,{entityId:L,fieldDefinitionId:B,fieldName:i})=>{return W(async(X8,N8)=>{return await q.deleteFieldValue(X8,h,{entityId:L,fieldDefinitionId:B,fieldName:i},N8)})},deleteFieldDefinition:async(h,{id:L})=>{return W(async(B,i)=>{return await q.deleteFieldDefinition(B,h,{id:L},i)})},createDocument:async(h,{store:L,path:B,type:i,content:X8})=>{return W(async(N8,h8)=>{return await Y.createDocument(N8,h,{store:L,path:B,type:i,content:X8},h8)})},updateDocumentPath:async(h,{id:L,path:B,type:i})=>{return W(async(X8,N8)=>{return await Y.updateDocumentPath(X8,h,{id:L,path:B,type:i},N8)})},deleteDocument:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.deleteDocument(B,h,{id:L},i)})},saveDraft:async(h,{id:L,content:B,clientId:i})=>{return W(async(X8,N8)=>{return await Y.saveDraft(X8,h,{id:L,content:B,clientId:i},N8)})},publishDocument:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.publishDocument(B,h,{id:L},i)})},discardDraft:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.discardDraft(B,h,{id:L},i)})},setEditState:async(h,{id:L,clientId:B})=>{return W(async(i,X8)=>{return await Y.setEditState(i,h,{id:L,clientId:B},X8)})},clearEditState:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.clearEditState(B,h,{id:L},i)})},renderTemplate:async(h,{id:L,params:B,target:i,targetOptions:X8})=>{let N8=await Y.readDocument($,h,{id:L});if(!N8.getPublishedContent())throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("Template has no published content","NO_PUBLISHED_CONTENT");let{target:h8,targetPath:c8}=z.extractTemplateParameters(N8.getPublishedContent()),E8=i||h8||"stdout",g8=X8||{},t8=g8.path||c8,v4=z.renderTemplate(N8.getPublishedContent(),B||{});switch(E8){case"stdout":return{output:v4,target:"stdout"};case"clipboard":return J.write(v4),{output:v4,target:"clipboard",message:"Copied to clipboard"};case"document":return W(async(r,a)=>{if(!t8)throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("targetOptions.path is required for document target","MISSING_TARGET_PATH");let s=await Y.createDocument(r,h,{store:"A",path:t8,type:"d",content:v4},a);if(g8.publish)await Y.publishDocument(r,h,{id:s.getObjectId()},a);return{output:v4,target:"document",documentId:s.getObjectId(),documentPath:t8,published:!!g8.publish}});case"file":throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("file target not yet implemented","NOT_IMPLEMENTED");default:throw(await Promise.resolve().then(() => (R4(),_X))).default.validation(`Unknown target: ${E8}`,"INVALID_TARGET")}}})},Nb=Object.freeze({create:__6});var IE8=K1(SE8(),1),xE8=K1(X$(),1);R4();import q$ from"fs/promises";import Y$ from"path";import{createWriteStream as yr6}from"fs";import ur6 from"crypto";var uK=xE8.default("caw:export"),EE8=".caw-exports",LE8=".tmp",mr6=1,pr6=({store:$,folderService:K,documentService:q,templateService:Y})=>{let z=()=>{let T=new Date,G=T.getFullYear(),v=String(T.getMonth()+1).padStart(2,"0"),f=String(T.getDate()).padStart(2,"0"),A=String(T.getHours()).padStart(2,"0"),C=String(T.getMinutes()).padStart(2,"0"),V=String(T.getSeconds()).padStart(2,"0");return`${G}-${v}-${f}-${A}${C}${V}`},P=async(T)=>{let G=Y$.join(T,EE8),v=Y$.join(G,LE8);try{return await q$.mkdir(G,{recursive:!0}),await q$.mkdir(v,{recursive:!0}),G}catch(f){if(f.code==="EACCES")throw t.validation("Permission denied creating export directory","EXPORT_ERROR");if(f.code==="ENOSPC")throw t.validation("Insufficient disk space","EXPORT_ERROR");throw uK("Error creating export directory: [%s] %s",f.code||"UNKNOWN",f.message),t.validation(`Failed to create export directory: ${f.message} (${f.code||"UNKNOWN"})`,"EXPORT_ERROR")}},J=async(T,G,v,f)=>{let A=[],C=async(V,M)=>{let R=await K.listFolderContents(T,G,{folderId:V,type:v,storeCode:f});for(let I of R)if(I.getParentId()!==null)A.push({entity:I,depth:M,contentType:v}),await C(I.getObjectId(),M+1)};return await C(null,0),A},W=async(T,G,v)=>{let f=[],A=[],C=async(V)=>{let M=await q.listDocuments(T,G,{parentId:V,storeCode:v});for(let I of M){let D=I.getPublishedVersionNumber();if(D!==null){let m=await q.readVersion(T,G,{id:I.getObjectId(),versionNumber:D});f.push({entity:I,version:m})}else A.push(I)}let R=await K.listFolderContents(T,G,{folderId:V,type:"d",storeCode:v});for(let I of R)await C(I.getObjectId())};return await C(null),{published:f,draftOnly:A}},H=async(T,G,v)=>{let f=[],A=[],C=async(V)=>{let M=await q.listDocuments(T,G,{parentId:V,storeCode:v,type:"t"});for(let I of M){let D=I.getPublishedVersionNumber();if(D!==null){let m=await q.readVersion(T,G,{id:I.getObjectId(),versionNumber:D});f.push({entity:I,version:m})}else A.push(I)}let R=await K.listFolderContents(T,G,{folderId:V,type:"t",storeCode:v});for(let I of R)await C(I.getObjectId())};return await C(null),{published:f,draftOnly:A}},Z=async(T)=>{try{await q$.rm(T,{recursive:!0,force:!0})}catch(G){uK("Warning: Failed to cleanup temp directory: %s",G.message)}};return Object.freeze({listExports:async(T,G,{projectPath:v})=>{let f=Y$.join(v,EE8);try{let A=await q$.readdir(f),C=[];for(let V of A)if(V.endsWith(".zip")){let M=Y$.join(f,V),R=await q$.stat(M);C.push({filename:V,timestamp:R.mtime.toISOString(),size:R.size})}return uK("Found %d export files",C.length),C}catch(A){if(A.code==="ENOENT")return[];throw A}},exportPreview:async(T,G,{storeCode:v})=>{let f=await J(T,G,"d",v),A=await J(T,G,"t",v),{published:C,draftOnly:V}=await W(T,G,v),{published:M,draftOnly:R}=await H(T,G,v),I={folders:[...f,...A].map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()})),documents:C.map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()})),templates:M.map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()}))},D={documents:V.map((h)=>({id:h.getObjectId(),path:h.getPath(),name:h.getName()})),templates:R.map((h)=>({id:h.getObjectId(),path:h.getPath(),name:h.getName()}))},m=I.folders.length+I.documents.length+I.templates.length,b=D.documents.length+D.templates.length;return uK("Preview: %d published, %d draft-only",m,b),{toExport:I,draftOnly:D}},exportDocuments:async(T,G,{storeCode:v,projectPath:f})=>{uK("Starting export for store %s",v);let A=await P(f),C=ur6.randomUUID(),V=Y$.join(A,LE8,C);await q$.mkdir(V,{recursive:!0});try{let M=await J(T,G,"d",v),R=await J(T,G,"t",v),I=[...M,...R],{published:D,draftOnly:m}=await W(T,G,v),{published:b,draftOnly:h}=await H(T,G,v);uK("Found %d folders, %d documents, %d templates",I.length,D.length,b.length);let L=[...I.map((E8)=>({id:E8.entity.getObjectId(),type:"folder",path:E8.entity.getPath(),contentType:E8.contentType})),...D.map((E8)=>({id:E8.entity.getObjectId(),type:"document",path:E8.entity.getPath()})),...b.map((E8)=>({id:E8.entity.getObjectId(),type:"template",path:E8.entity.getPath()}))],B={version:mr6,exportedAt:new Date().toISOString(),entities:L};await q$.writeFile(Y$.join(V,"manifest.json"),JSON.stringify(B,null,2),"utf-8");for(let E8 of I){let g8=E8.contentType==="d"?"documents":"templates",t8=Y$.join(V,g8,E8.entity.getPath());await q$.mkdir(t8,{recursive:!0})}await q$.mkdir(Y$.join(V,"documents"),{recursive:!0}),await q$.mkdir(Y$.join(V,"templates"),{recursive:!0});for(let E8 of D){let g8=Y$.join(V,"documents",E8.entity.getPath()),t8=E8.version.content;await q$.mkdir(Y$.dirname(g8),{recursive:!0}),await q$.writeFile(g8,t8,"utf-8")}for(let E8 of b){let g8=Y$.join(V,"templates",E8.entity.getPath()),t8=E8.version.content;await q$.mkdir(Y$.dirname(g8),{recursive:!0}),await q$.writeFile(g8,t8,"utf-8")}for(let E8 of L)if(E8.type!=="folder"){let g8=E8.type==="document"?"documents":"templates",t8=Y$.join(V,g8,E8.path);try{await q$.access(t8)}catch(v4){throw t.validation(`Manifest entry missing file: ${E8.path}`,"EXPORT_VALIDATION_FAILED")}}let i=`caw-export-${z()}.zip`,X8=Y$.join(A,i),N8=yr6(X8),h8=IE8.default("zip",{zlib:{level:9}});h8.on("error",async(E8)=>{throw await Z(V),uK("Zip creation error: %s",E8.message),t.validation(`Export failed: ${E8.message}`,"EXPORT_ERROR")}),h8.pipe(N8),h8.directory(V,!1),await h8.finalize(),await new Promise((E8,g8)=>{N8.on("close",E8),N8.on("error",g8),setTimeout(()=>{g8(new Error("Zip creation timeout"))},60000)}),uK("Created zip: %s (%d bytes)",i,h8.pointer()),await Z(V);let c8=L.length;return uK("Export complete: %s (%d entities)",i,c8),{success:!0,filename:i,path:X8,counts:{folders:I.length,documents:D.length,templates:b.length},draftOnlySkipped:{documents:m.length,templates:h.length}}}catch(M){throw await Z(V),M}}})},bE8=Object.freeze({create:pr6});var jL8=K1(XL8(),1),vL8=K1(X$(),1);R4();import s2 from"fs/promises";import jY from"path";import ws6 from"crypto";var V1=vL8.default("caw:import"),HB=".caw-exports",TL8=".tmp",Xs6=1,Ts6=/\b([A-Z][dtfn]\d+)\b/g,js6=({store:$,folderService:K,documentService:q,templateService:Y})=>{let z=(Z,O)=>{if(!Z)return Z;return Z.replace(Ts6,(w,X)=>{return O[X]??w})},P=async(Z)=>{try{await s2.rm(Z,{recursive:!0,force:!0})}catch(O){V1("Warning: Failed to cleanup temp directory: %s",O.message)}},J=async(Z,O,{storeCode:w})=>{let X=await K.listFolderContents(Z,O,{folderId:null,type:"d",storeCode:w}),T=await K.listFolderContents(Z,O,{folderId:null,type:"t",storeCode:w}),G=await q.listDocuments(Z,O,{parentId:null,storeCode:w,type:"d"}),v=await q.listDocuments(Z,O,{parentId:null,storeCode:w,type:"t"}),f=X.length===0&&T.length===0&&G.length===0&&v.length===0;return V1("Store %s empty check: %s",w,f),f},W=async(Z,O,{manifest:w,tempPath:X,storeCode:T})=>{return V1("Starting transaction..."),await Z.transaction().execute(async(G)=>{let v={},f=(m)=>{},A=w.entities.filter((m)=>m.type==="folder");V1("Phase 1: Creating %d folders",A.length);for(let m of A){let b=m.contentType||"d",h=await K.createFolder(G,O,{store:T,path:m.path,type:b},f);v[m.id]=h.getObjectId()}V1("Phase 1 complete - created %d folders",A.length);let C=w.entities.filter((m)=>m.type==="document"),V=[];V1("Phase 2: Reading %d documents",C.length);for(let m of C){let b=jY.join(X,"documents",m.path),h=await s2.readFile(b,"utf-8");V.push({oldId:m.id,path:m.path,content:h})}V1("Phase 2 complete - read %d documents",V.length),V1("Phase 3: Creating %d document entities",V.length);let M=[];for(let m of V){let b=await q.createDocument(G,O,{store:T,path:m.path,type:"d"},f);v[m.oldId]=b.getObjectId(),M.push({document:b,originalContent:m.content})}V1("Phase 3 complete - created %d document entities",M.length);let R=w.entities.filter((m)=>m.type==="template"),I=[];V1("Phase 4: Reading %d templates",R.length);for(let m of R){let b=jY.join(X,"templates",m.path),h=await s2.readFile(b,"utf-8");I.push({oldId:m.id,path:m.path,content:h})}V1("Phase 4 complete - read %d templates",I.length),V1("Phase 5: Creating %d template entities",I.length);let D=[];for(let m of I){let b=await q.createDocument(G,O,{store:T,path:m.path,type:"t"},f);v[m.oldId]=b.getObjectId(),D.push({template:b,originalContent:m.content})}V1("Phase 5 complete - created %d template entities",D.length),V1("Phase 6: Remapping and saving content for %d documents",M.length);for(let{document:m,originalContent:b}of M){let h=z(b,v);await q.saveDraft(G,O,{id:m.getObjectId(),content:h,clientId:"import-service"},f),await q.publishDocument(G,O,{id:m.getObjectId()},f)}V1("Phase 6 complete - saved and published %d documents",M.length),V1("Phase 7: Remapping and saving content for %d templates",D.length);for(let{template:m,originalContent:b}of D){let h=z(b,v);await q.saveDraft(G,O,{id:m.getObjectId(),content:h,clientId:"import-service"},f),await q.publishDocument(G,O,{id:m.getObjectId()},f)}return V1("Phase 7 complete - saved and published %d templates",D.length),V1("Transaction committed successfully"),{success:!0,counts:{folders:A.length,documents:M.length,templates:D.length},remapped:v}})};return Object.freeze({isStoreEmpty:J,importDocuments:async(Z,O,{filename:w,storeCode:X,projectPath:T})=>{V1("Starting import from %s to store %s",w,X);let G=jY.join(T,HB,w);try{await s2.access(G),V1("Zip file found: %s",G)}catch(V){throw t.notFound(`Export file not found: ${w}`,"EXPORT_NOT_FOUND")}V1("Validating zip and manifest...");let v=await J(Z,O,{storeCode:X});if(!v)throw t.conflict("Store not empty - import requires empty store","STORE_NOT_EMPTY");V1("Store empty check: %s",v);let f=ws6.randomUUID(),A=jY.join(T,HB,TL8,f),C=jY.join(T,HB,TL8);await s2.mkdir(C,{recursive:!0});try{new jL8.default(G).extractAllTo(A,!0),V1("Extracted zip to: %s",A)}catch(V){throw t.validation("Corrupted or invalid zip file","IMPORT_VALIDATION_FAILED")}try{let V=jY.join(A,"manifest.json"),M;try{let D=await s2.readFile(V,"utf-8");M=JSON.parse(D)}catch(D){throw t.validation(`Failed to read manifest: ${D.message}`,"MANIFEST_READ_FAILED")}if(M.version!==Xs6)throw t.validation(`Unsupported manifest version: ${M.version}`,"UNSUPPORTED_VERSION");if(!M.entities||!Array.isArray(M.entities))throw t.validation("Invalid manifest structure","MANIFEST_READ_FAILED");V1("Manifest valid: version=%d, entities=%d",M.version,M.entities.length);for(let D of M.entities)if(D.type!=="folder"){let m=D.type==="document"?jY.join(A,"documents",D.path):jY.join(A,"templates",D.path);try{await s2.access(m)}catch(b){throw t.validation(`Missing file for manifest entry: ${D.path}`,"IMPORT_VALIDATION_FAILED")}}V1("All content files validated");let R=await W(Z,O,{manifest:M,tempPath:A,storeCode:X}),I=R.counts.folders+R.counts.documents+R.counts.templates;return V1("Import complete: %d entities imported",I),R}finally{await P(A)}}})},GL8=Object.freeze({create:js6});var vs6=($)=>{let{name:K,interval:q,execute:Y}=$,z=null,P=!1,J=null,W=null,H=0,Z=null,A=Object.freeze({getName:()=>K,getInterval:()=>q,getIsRunning:()=>P,getLastRun:()=>J,getLastError:()=>W,getRunCount:()=>H,getNextRun:()=>Z}),C=async()=>{try{await Y(),J=new Date().toISOString(),W=null,H++}catch(D){console.error(`[CronJob] ${K} failed:`,D),W={message:D.message,timestamp:new Date().toISOString()}}if(P)Z=new Date(Date.now()+q).toISOString()},V=()=>{if(z!==null)return;z=setInterval(C,q),P=!0,Z=new Date(Date.now()+q).toISOString()},M=()=>{if(z===null)return;clearInterval(z),z=null,P=!1,Z=null},I=Object.freeze({start:V,stop:M,restart:()=>{M(),V()}});return{jobFns:A,controlFns:I}},OM=Object.freeze({create:vs6});var _L8=K1(X$(),1),Gs6=_L8.default("caw:cron:cleanup-edit-states"),fL8=async($)=>{let K=new Date(Date.now()-PW).toISOString();try{let q=await $.deleteFrom("document_edit_state").where("last_activity_at","<",K).execute(),Y=Number(q[0]?.numDeletedRows??0);if(Y>0)Gs6("Cleaned up %d expired edit locks (older than %d minutes)",Y,PW/60000);return{expired:Y}}catch(q){throw console.error("[Cleanup] Failed to cleanup expired edit locks:",q),q}};var _s6=({db:$})=>{let{jobFns:K,controlFns:q}=OM.create({name:"cleanup-stale-edit-states",interval:900000,execute:async()=>{await fL8($)}});return{job:Object.freeze(K),control:q}},AL8=Object.freeze({create:_s6});var fs6=({db:$})=>{let K=new Map,q=(Z,O)=>{let{job:w,control:X}=Z.create(O);K.set(w.getName(),{job:w,control:X})},Y=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);let w=O.job.getIsRunning();return O.control.start(),{name:Z,status:w?"already-running":"started",isRunning:O.job.getIsRunning()}},z=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);let w=O.job.getIsRunning();return O.control.stop(),{name:Z,status:w?"stopped":"already-stopped",isRunning:O.job.getIsRunning()}},P=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);return O.control.restart(),{name:Z,status:"restarted",isRunning:O.job.getIsRunning()}},J=()=>{let Z=[];for(let[O,{job:w}]of K.entries())Z.push({name:w.getName(),interval:w.getInterval(),isRunning:w.getIsRunning(),lastRun:w.getLastRun(),lastError:w.getLastError(),runCount:w.getRunCount(),nextRun:w.getNextRun()});return Z},W=()=>{for(let[Z,{control:O}]of K.entries())O.start()},H=()=>{for(let[Z,{control:O}]of K.entries())O.stop()};return q(AL8,{db:$}),Object.freeze({register:q,start:Y,stop:z,restart:P,list:J,startAll:W,stopAll:H})},VL8=Object.freeze({create:fs6});import Ku8 from"node:process";import NL8 from"node:process";import Ns6 from"node:os";import hs6 from"node:fs";import ks6 from"node:fs";import kL8 from"node:fs";var ZB;function As6(){try{return kL8.statSync("/.dockerenv"),!0}catch{return!1}}function Vs6(){try{return kL8.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function OB(){if(ZB===void 0)ZB=As6()||Vs6();return ZB}var wB,Ms6=()=>{try{return ks6.statSync("/run/.containerenv"),!0}catch{return!1}};function wM(){if(wB===void 0)wB=Ms6()||OB();return wB}var ML8=()=>{if(NL8.platform!=="linux")return!1;if(Ns6.release().toLowerCase().includes("microsoft")){if(wM())return!1;return!0}try{return hs6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!wM():!1}catch{return!1}},hL8=NL8.env.__IS_WSL_TEST__?ML8:ML8();import XB from"node:process";function TB(){if(XB.platform!=="linux")return!1;if(XB.env.WAYLAND_DISPLAY)return!0;if(XB.env.XDG_SESSION_TYPE==="wayland")return!0;return!1}function T4($){if(typeof $!=="object"||$===null)return!1;let K=Object.getPrototypeOf($);return(K===null||K===Object.prototype||Object.getPrototypeOf(K)===null)&&!(Symbol.toStringTag in $)&&!(Symbol.iterator in $)}import{fileURLToPath as Cs6}from"node:url";var nH=($,K)=>{let q=vB(Rs6($));if(typeof q!=="string")throw new TypeError(`${K} must be a string or a file URL: ${q}.`);return q},Rs6=($)=>jB($)?$.toString():$,jB=($)=>typeof $!=="string"&&$&&Object.getPrototypeOf($)===String.prototype,vB=($)=>$ instanceof URL?Cs6($):$;var XM=($,K=[],q={})=>{let Y=nH($,"First argument"),[z,P]=T4(K)?[[],K]:[K,q];if(!Array.isArray(z))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${z}`);if(z.some((H)=>typeof H==="object"&&H!==null))throw new TypeError(`Second argument must be an array of strings: ${z}`);let J=z.map(String),W=J.find((H)=>H.includes("\x00"));if(W!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${W}`);if(!T4(P))throw new TypeError(`Last argument must be an options object: ${P}`);return[Y,J,P]};import{ChildProcess as bs6}from"node:child_process";import{StringDecoder as Ds6}from"node:string_decoder";var{toString:CL8}=Object.prototype,RL8=($)=>CL8.call($)==="[object ArrayBuffer]",m4=($)=>CL8.call($)==="[object Uint8Array]",mK=($)=>new Uint8Array($.buffer,$.byteOffset,$.byteLength),Ss6=new TextEncoder,DL8=($)=>Ss6.encode($),Es6=new TextDecoder,TM=($)=>Es6.decode($),SL8=($,K)=>{return Ls6($,K).join("")},Ls6=($,K)=>{if(K==="utf8"&&$.every((P)=>typeof P==="string"))return $;let q=new Ds6(K),Y=$.map((P)=>typeof P==="string"?DL8(P):P).map((P)=>q.write(P)),z=q.end();return z===""?Y:[...Y,z]},Vj=($)=>{if($.length===1&&m4($[0]))return $[0];return GB(Is6($))},Is6=($)=>$.map((K)=>typeof K==="string"?DL8(K):K),GB=($)=>{let K=new Uint8Array(xs6($)),q=0;for(let Y of $)K.set(Y,q),q+=Y.length;return K},xs6=($)=>{let K=0;for(let q of $)K+=q.length;return K};var xL8=($)=>Array.isArray($)&&Array.isArray($.raw),bL8=($,K)=>{let q=[];for(let[P,J]of $.entries())q=gs6({templates:$,expressions:K,tokens:q,index:P,template:J});if(q.length===0)throw new TypeError("Template script must not be empty");let[Y,...z]=q;return[Y,z,{}]},gs6=({templates:$,expressions:K,tokens:q,index:Y,template:z})=>{if(z===void 0)throw new TypeError(`Invalid backslash sequence: ${$.raw[Y]}`);let{nextTokens:P,leadingWhitespaces:J,trailingWhitespaces:W}=ys6(z,$.raw[Y]),H=LL8(q,P,J);if(Y===K.length)return H;let Z=K[Y],O=Array.isArray(Z)?Z.map((w)=>IL8(w)):[IL8(Z)];return LL8(H,O,W)},ys6=($,K)=>{if(K.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let q=[],Y=0,z=EL8.has(K[0]);for(let J=0,W=0;J<$.length;J+=1,W+=1){let H=K[W];if(EL8.has(H)){if(Y!==J)q.push($.slice(Y,J));Y=J+1}else if(H==="\\"){let Z=K[W+1];if(Z===`
|
|
461
|
+
`.execute($),await $.schema.createIndex("entities_store_id_idx").on("entities").columns(["store_id"]).execute(),await $.schema.createIndex("entities_parent_folder_id_idx").on("entities").columns(["parent_folder_id"]).execute(),await $.schema.createTable("folders").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).execute(),await $.schema.createTable("documents").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("published_version_id","integer",(K)=>K.references("document_versions.id")).execute(),await $.schema.createTable("document_drafts").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("content","text").addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("document_versions").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("entity_id","integer",(K)=>K.notNull().references("entities.id").onDelete("cascade")).addColumn("version_number","integer",(K)=>K.notNull()).addColumn("content","text").addColumn("published_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("document_versions_entity_version_unique").on("document_versions").columns(["entity_id","version_number"]).unique().execute(),await $.schema.createIndex("document_versions_entity_id_idx").on("document_versions").columns(["entity_id"]).execute(),await $.schema.createTable("document_edit_state").addColumn("entity_id","integer",(K)=>K.primaryKey().references("entities.id").onDelete("cascade")).addColumn("client_id","text",(K)=>K.notNull()).addColumn("started_at","text",(K)=>K.notNull()).addColumn("last_activity_at","text",(K)=>K.notNull()).execute(),await $.schema.createTable("field_definitions").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("store_id","integer",(K)=>K.notNull().references("stores.id").onDelete("cascade")).addColumn("object_id","text",(K)=>K.notNull()).addColumn("entity_type_id","integer",(K)=>K.notNull().references("entity_types.id")).addColumn("type_code","text",(K)=>K.notNull()).addColumn("seq","integer",(K)=>K.notNull()).addColumn("owner_entity_id","integer",(K)=>K.references("entities.id").onDelete("cascade")).addColumn("name","text",(K)=>K.notNull()).addColumn("label","text").addColumn("description","text").addColumn("primitive_type","text",(K)=>K.notNull()).addColumn("required","integer",(K)=>K.notNull().defaultTo(0)).addColumn("multiplicity","text",(K)=>K.notNull().defaultTo("single")).addColumn("config","text").addColumn("is_system","integer",(K)=>K.notNull().defaultTo(0)).addColumn("ordinal","integer").addColumn("created_at","text",(K)=>K.notNull()).addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("idx_field_def_object_id_unique").on("field_definitions").columns(["store_id","object_id"]).unique().execute(),await $.schema.createIndex("idx_field_def_store_type_seq").on("field_definitions").columns(["store_id","type_code","seq"]).unique().execute(),await $.schema.createIndex("idx_field_def_owner").on("field_definitions").columns(["owner_entity_id"]).execute(),await $.schema.createIndex("idx_field_def_owner_name").on("field_definitions").columns(["owner_entity_id","name"]).execute(),await $.schema.createTable("field_values").addColumn("id","integer",(K)=>K.primaryKey().autoIncrement()).addColumn("entity_id","integer",(K)=>K.notNull().references("entities.id").onDelete("cascade")).addColumn("field_definition_id","integer",(K)=>K.notNull().references("field_definitions.id").onDelete("cascade")).addColumn("value","text").addColumn("ordinal","integer").addColumn("updated_at","text",(K)=>K.notNull()).execute(),await $.schema.createIndex("idx_field_values_entity").on("field_values").columns(["entity_id"]).execute(),await $.schema.createIndex("idx_field_values_entity_def").on("field_values").columns(["entity_id","field_definition_id"]).execute()};var p46=()=>new Date().toISOString(),K4=p46;var c46=[{code:"f",name:"Folder",subtype:null},{code:"f",name:"Document Root Folder",subtype:"root_d"},{code:"f",name:"Template Root Folder",subtype:"root_t"},{code:"d",name:"Document",subtype:null},{code:"t",name:"Template",subtype:null},{code:"n",name:"field_definition",subtype:null}],Ue=async($)=>{return(await $.selectFrom("entity_types").select("id").limit(1).execute()).length>0},B46=async($,K,q=null)=>{return(await $.selectFrom("entity_types").select("id").where("code","=",K).where((z)=>q?z("subtype","=",q):z("subtype","is",null)).executeTakeFirstOrThrow()).id},Be=async($,K,q,Y)=>{let z=K4(),J=await B46($,"f",Y==="d"?"root_d":"root_t");if(!await $.selectFrom("sequences").select("next_value").where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").executeTakeFirst())await $.insertInto("sequences").values({scope_type:"store",scope_id:K,type_code:"f",next_value:1}).execute();let H=await $.selectFrom("sequences").select("next_value").where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").executeTakeFirst();await $.updateTable("sequences").set((X)=>({next_value:X("next_value","+",1)})).where("scope_type","=","store").where("scope_id","=",K).where("type_code","=","f").execute();let Z=`${q}f${H.next_value}`,O=await $.insertInto("entities").values({store_id:K,object_id:Z,entity_type_id:J,type_code:"f",seq:H.next_value,parent_folder_id:null,parent_object_id:null,name:null,created_at:z,updated_at:z}).returning("id").executeTakeFirstOrThrow();await $.insertInto("folders").values({entity_id:O.id}).execute();let w=Y==="d"?"document":"template";return O.id},U46=async($)=>{for(let K of c46)await $.insertInto("entity_types").values(K).execute()},l46=async($)=>{let K=await $.selectFrom("sequences").select("next_value").where("scope_type","=","global").where("scope_id","is",null).where("type_code","=","s").executeTakeFirstOrThrow();await $.updateTable("sequences").set((P)=>({next_value:P("next_value","+",1)})).where("scope_type","=","global").where("scope_id","is",null).where("type_code","=","s").execute();let q=`S${K.next_value}`,Y=K4(),z=await $.insertInto("stores").values({id:K.next_value,object_id:q,type:"local",code:"B",name:"Shared",created_at:Y,updated_at:Y}).returning("id").executeTakeFirstOrThrow();await Be($,z.id,"B","d"),await Be($,z.id,"B","t")},le=async($)=>{await U46($),await $.insertInto("sequences").values([{scope_type:"global",scope_id:null,type_code:"s",next_value:1},{scope_type:"global",scope_id:null,type_code:"p",next_value:1}]).execute(),await l46($)};var S0=K1(ie(),1),F46=($,K)=>{if($)throw new Error(K)},Qe=($,K)=>{if(S0.default.null($)||S0.default.undefined($))throw new Error(`${K} is required`)},i46=($,K)=>{if(Qe($,K),S0.default.empty($))throw new Error(`${K} cannot be empty`)},Q46=($,K,...q)=>{if($)throw K(...q)},d46={condition:F46,nullish:Qe,empty:i46,factory:Q46},Y8=d46;var xW6=typeof Bun!=="undefined",bW6=async($)=>{if(xW6){let{Database:K}=await import("bun:sqlite"),{BunSqliteDialect:q}=await Promise.resolve().then(() => K1(NP8(),1)),Y=new K($);return Y.exec("PRAGMA journal_mode = WAL"),Y.exec("PRAGMA foreign_keys = ON"),new r9({dialect:new q({database:Y})})}else{let q=new(await import("better-sqlite3")).default($);return q.pragma("journal_mode = WAL"),q.pragma("foreign_keys = ON"),new r9({dialect:new vS({database:q})})}},gW6=($,K)=>{if(!EW6($)){if(!K)throw new Error(`Database file not found: ${$}`);LW6(IW6($),{recursive:!0})}},yW6=async($,K)=>{if(!await pe($)){if(!K)throw new Error("Database schema not found");await ce($)}},uW6=async($,K)=>{if(!await Ue($)){if(!K)throw new Error("Database seed data not found");await le($)}},mW6=($)=>{let{kyselyFactory:K=bW6}=$??{};return Object.freeze({getDb:async(Y,z)=>{if(Y8.nullish(Y,"databaseFilepath"),Y!==":memory:")gW6(Y,z);let P=await K(Y);return await yW6(P,z),await uW6(P,z),P}})},hP8={create:mW6};var pW6=($)=>{let{id:K,name:q,createdAt:Y,updatedAt:z}=$,Z=Object.freeze({getObjectId:()=>K,getName:()=>q,getCreatedAt:()=>Y,getUpdatedAt:()=>z}),X=Object.freeze({setName:(T)=>{q=T},setUpdatedAt:(T)=>{z=T}});return{entityFns:Z,mutationFns:X}},K5=Object.freeze({create:pW6});var cW6=($)=>{let{id:K,name:q,path:Y,createdAt:z,updatedAt:P}=$,{entityFns:J,mutationFns:W}=K5.create({id:K,name:q,createdAt:z,updatedAt:P}),H=()=>Y,O=Object.freeze({...J,getPath:H,toJSON:()=>({objectId:J.getObjectId(),name:J.getName(),path:H(),createdAt:J.getCreatedAt(),updatedAt:J.getUpdatedAt()})}),X=Object.freeze({...W,setPath:(T)=>{Y=T}});return{entity:O,mutationApi:X}},CP8=Object.freeze({create:cW6});var BW6=($,K,q)=>{return Object.freeze({getEntity:()=>$,getMutationApi:()=>K,getPk:()=>q})},l6=Object.freeze({create:BW6});var UW6=async($,K,q,Y)=>{if(!await $.selectFrom("sequences").select("next_value").where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).executeTakeFirst())await $.insertInto("sequences").values({scope_type:K,scope_id:q,type_code:Y,next_value:1}).execute();let P=await $.selectFrom("sequences").select("next_value").where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).executeTakeFirstOrThrow();return await $.updateTable("sequences").set((J)=>({next_value:J("next_value","+",1)})).where("scope_type","=",K).where("scope_id",q===null?"is":"=",q).where("type_code","=",Y).execute(),P.next_value},q5=Object.freeze({nextSeq:UW6});var lW6=($)=>$.object_id,RP8=($)=>{if(!$||$.length<2||$[0]!=="P")return null;let K=parseInt($.slice(1),10);return isNaN(K)?null:K},Tf=($)=>{let K=lW6($),q=$.id,{entity:Y,mutationApi:z}=CP8.create({id:K,name:$.name,path:$.path,createdAt:$.created_at,updatedAt:$.updated_at});return{entity:Y,mutationApi:z,id:K,pk:q}},FW6=()=>{let $=new Map;return Object.freeze({createProject:async(J,W,{name:H,path:Z},O)=>{let w=K4(),X=await q5.nextSeq(J,"global",null,"p"),T=`P${X}`,G=await J.insertInto("projects").values({id:X,object_id:T,name:H,path:Z,created_at:w,updated_at:w}).returningAll().executeTakeFirstOrThrow(),{entity:v,mutationApi:f,id:A,pk:C}=Tf(G);return O(()=>{$.set(A,l6.create(v,f,C))}),v},readProject:async(J,W,H)=>{let Z=$.get(H);if(Z)return Z.getEntity();let O=RP8(H);if(O===null)return null;let w=await J.selectFrom("projects").selectAll().where("id","=",O).executeTakeFirst();if(!w)return null;let{entity:X,mutationApi:T,id:G,pk:v}=Tf(w);return $.set(G,l6.create(X,T,v)),X},readProjectByObjectId:async(J,W,H)=>{let Z=$.get(H);if(Z)return Z.getEntity();let O=RP8(H);if(O===null)return null;let w=await J.selectFrom("projects").selectAll().where("id","=",O).executeTakeFirst();if(!w)return null;let{entity:X,mutationApi:T,id:G,pk:v}=Tf(w);return $.set(G,l6.create(X,T,v)),X},readProjectByPath:async(J,W,H)=>{let Z=await J.selectFrom("projects").selectAll().where("path","=",H).executeTakeFirst();if(!Z)return null;let{entity:O,mutationApi:w,id:X,pk:T}=Tf(Z),G=$.get(X);if(G)return G.getEntity();return $.set(X,l6.create(O,w,T)),O},evictProject:(J)=>{$.delete(J)}})},DP8=Object.freeze({create:FW6});var iW6=()=>{let $=new Map,K=new Map;return Object.freeze({get:(w)=>$.get(w),getByPk:(w)=>{let X=K.get(w);return X?$.get(X):void 0},has:(w)=>$.has(w),set:(w,X)=>{$.set(w,X),K.set(X.getPk(),w)},remove:(w)=>{let X=$.get(w);if(X)K.delete(X.getPk());$.delete(w)},getIdByPk:(w)=>K.get(w),setIdByPk:(w,X)=>K.set(w,X),clear:()=>{$.clear(),K.clear()},entries:()=>$.entries()})},jf=Object.freeze({create:iW6});var yP8=K1(X$(),1);var QW6=async($,K,q,Y=null)=>{return(await $.selectFrom("entity_types").select("id").where("code","=",q).where((P)=>Y?P("subtype","=",Y):P("subtype","is",null)).executeTakeFirstOrThrow()).id},uz=Object.freeze({readEntityTypeId:QW6});var dW6=($)=>{let{id:K,name:q,parentId:Y,path:z,createdAt:P,updatedAt:J,publishedVersionNumber:W,hasDraft:H,draftContent:Z,publishedContent:O}=$,{entityFns:w,mutationFns:X}=K5.create({id:K,name:q,createdAt:P,updatedAt:J}),T=new Map,G=W??null,v=H??!1,f=Z??null,A=O??null,C=null,h8=Object.freeze({...w,getParentId:()=>Y,getPath:()=>z,getField:(K8)=>{return T.get(K8)},getFields:()=>{let K8={};for(let[P8,H8]of T.entries())K8[P8]=H8;return K8},getPublishedVersionNumber:()=>G,hasDraftContent:()=>v,getDraftContent:()=>f,getPublishedContent:()=>A,getEditState:()=>C,hasPublished:()=>G>0,isBeingEdited:()=>C!==null,getVersionCount:()=>G??0,getIsFolder:()=>!1}),s=Object.freeze({...X,setParentId:(K8)=>{Y=K8},setPath:(K8)=>{z=K8},setField:(K8,P8)=>{T.set(K8,P8)},removeField:(K8)=>{T.delete(K8)},setPublishedVersionNumber:(K8)=>{G=K8},setHasDraft:(K8)=>{v=K8},setDraftContent:(K8)=>{f=K8},setPublishedContent:(K8)=>{A=K8},setEditState:(K8)=>{C=K8}});return{entityFns:h8,mutationFns:s}},YW=Object.freeze({create:dW6});var SP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>K.getParentId()===null,z=()=>!0,J=Object.freeze({...K,isRoot:Y,getIsFolder:z,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),isFolder:z(),isRoot:Y()})}),W=Object.freeze({...q});return{entity:J,mutationApi:W}},nW6=($,K,q,Y)=>{return SP8({id:K,parentId:q,name:$.name,path:Y,createdAt:$.created_at,updatedAt:$.updated_at})},mz=Object.freeze({create:SP8,createFromRow:nW6});var oW6=($)=>{let{id:K,name:q,ownerEntityId:Y,label:z,description:P,primitiveType:J,required:W,multiplicity:H,isSystem:Z,createdAt:O,updatedAt:w}=$,{entityFns:X,mutationFns:T}=K5.create({id:K,name:q,createdAt:O,updatedAt:w}),G=()=>Y,v=()=>z,f=()=>P,A=()=>J,C=()=>W,V=()=>H,M=()=>Z,I=Object.freeze({...X,getOwnerEntityId:G,getLabel:v,getDescription:f,getPrimitiveType:A,getRequired:C,getMultiplicity:V,getIsSystem:M,toJSON:()=>({id:X.getObjectId(),ownerEntityId:G(),name:X.getName(),label:v(),description:f(),primitiveType:A(),required:C(),multiplicity:V(),isSystem:M(),createdAt:X.getCreatedAt(),updatedAt:X.getUpdatedAt()})}),D=Object.freeze({...T});return{entity:I,mutationApi:D}},Wx=Object.freeze({create:oW6});var aW6=({definition:$,values:K=[]})=>{let q=$,Y=[...K];if(q.getMultiplicity()==="single"&&Y.length>1)throw new Error(`Field "${q.getName()}" is single-valued but received ${Y.length} values`);let z=(T=0)=>{return Y[T]},P=()=>{return[...Y]},J=()=>{return q},W=()=>{return q.getMultiplicity()==="multi"};return Object.freeze({getValue:z,getValues:P,getDefinition:J,isMultiValued:W,isRequired:()=>{return q.getRequired()},getType:()=>{return q.getPrimitiveType()},getLabel:()=>{return q.getLabel()||q.getName()},getName:()=>{return q.getName()},toJSON:()=>{if(W())return Y;else return Y[0]}})},Hx=Object.freeze({create:aW6});R4();R4();var $H6=($)=>{let K=$.trim();Y8.factory(!K,t.validation,"Folder name cannot be empty","EMPTY_NAME"),Y8.factory(K.length>255,t.validation,"Folder name cannot exceed 255 characters","NAME_TOO_LONG");let q=/[/\\:*?"<>|]/;return Y8.factory(q.test(K),t.validation,'Folder name contains invalid characters: /\\:*?"<>|',"INVALID_CHARS"),K},KH6=($)=>{return $.getParentId()===null},HK=Object.freeze({validateFolderName:$H6,isRootFolder:KH6});R4();var qH6=($)=>{if(!$||$.length<3)return null;let K=$[0],q=$[1],Y=parseInt($.slice(2),10);if(isNaN(Y))return null;return{storeCode:K,typeCode:q,seq:Y}},YH6=($,K,q)=>`${$}${K}${q}`,zH6=($,K)=>{Y8.factory($!==K,t.validation,`Store code mismatch: expected ${K}, got ${$}`,"STORE_CODE_MISMATCH")},zW=Object.freeze({parseId:qH6,buildId:YH6,validateStoreCode:zH6});var EP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>"d",P=Object.freeze({...K,getTypeCode:Y,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),publishedVersionNumber:K.getPublishedVersionNumber(),hasDraft:K.hasDraftContent(),draftContent:K.getDraftContent(),publishedContent:K.getPublishedContent(),editState:K.getEditState(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),versionCount:K.getVersionCount(),isFolder:K.getIsFolder(),type:Y(),hasPublished:K.hasPublished(),isBeingEdited:K.isBeingEdited()})}),J=Object.freeze({...q});return{entity:P,mutationApi:J}},PH6=($,K,q,Y,z,P,J=null,W=null)=>{return EP8({id:K,parentId:q,name:$.name,path:Y,publishedVersionNumber:z,hasDraft:P,draftContent:J,publishedContent:W,createdAt:$.created_at,updatedAt:$.updated_at})},LP8=Object.freeze({create:EP8,createFromRow:PH6});var IP8=($)=>{let{entityFns:K,mutationFns:q}=YW.create($),Y=()=>"t",P=Object.freeze({...K,getTypeCode:Y,toJSON:()=>({id:K.getObjectId(),parentId:K.getParentId(),name:K.getName(),path:K.getPath(),publishedVersionNumber:K.getPublishedVersionNumber(),hasDraft:K.hasDraftContent(),draftContent:K.getDraftContent(),publishedContent:K.getPublishedContent(),editState:K.getEditState(),createdAt:K.getCreatedAt(),updatedAt:K.getUpdatedAt(),versionCount:K.getVersionCount(),isFolder:K.getIsFolder(),type:Y(),hasPublished:K.hasPublished(),isBeingEdited:K.isBeingEdited()})}),J=Object.freeze({...q});return{entity:P,mutationApi:J}},JH6=($,K,q,Y,z,P,J=null,W=null)=>{return IP8({id:K,parentId:q,name:$.name,path:Y,publishedVersionNumber:z,hasDraft:P,draftContent:J,publishedContent:W,createdAt:$.created_at,updatedAt:$.updated_at})},xP8=Object.freeze({create:IP8,createFromRow:JH6});R4();var bP8=($)=>{let K=zW.parseId($);if(!K)throw t.notFound(`Invalid entity ID format: ${$}`,"NOT_FOUND");let{storeCode:q,typeCode:Y,seq:z}=K;return{entityId:`${Y}${z}`,storeCode:q,typeCode:Y,seq:z}},WH6=($)=>{let{typeCode:K}=bP8($);return K},HH6={d:LP8.createFromRow,t:xP8.createFromRow},ZH6=($)=>{let K=HH6[$];if(!K)throw new Error(`Unknown content type: ${$}`);return K},OH6=($)=>{return{d:"document",t:"template"}[$]||"content"},m1=Object.freeze({resolveEntityId:bP8,getTypeFromId:WH6,getEntityFactory:ZH6,getContentTypeLabel:OH6,buildId:zW.buildId,parseId:zW.parseId});var{parseId:O4,buildId:Zx,validateStoreCode:wH6}=zW,{validateFolderName:gP8,isRootFolder:gg1}=HK,yg1=yP8.default("caw:stores:db"),PW=3600000,XH6=({id:$,code:K,name:q,pk:Y,folderCache:z,createdAt:P,updatedAt:J})=>{let W=new Map,{entityFns:H,mutationFns:Z}=K5.create({id:$,name:q,createdAt:P,updatedAt:J}),O=()=>new Set([K]),w=()=>"local",X=()=>K,T=()=>Y,G=()=>({id:$,code:K,name:H.getName(),createdAt:H.getCreatedAt(),updatedAt:H.getUpdatedAt(),type:"local"}),v=(E)=>{wH6(E,K)},f=async(E,u)=>{if(!u)return null;if(z){let d=z.get(u);if(d)return d.getPk()}if(!O4(u))Y8.factory(!0,t.validation,`Invalid parent folder ID: ${u}`,"INVALID_ID");let Q=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("object_id","=",u).where("deleted_at","is",null).executeTakeFirst();return Q?Q.id:null},A=async(E,u)=>{let y=await E.selectFrom("entities").select(["name","parent_folder_id","parent_object_id","object_id"]).where("id","=",u).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!y,t.notFound,`Entity not found for PK ${u}`,"ENTITY_NOT_FOUND");let Q=y.object_id,d=z?z.get(Q):null;if(d){let w8=d.getEntity();if(w8.getName()===y.name&&w8.getParentId()===y.parent_object_id)return w8.getPath()}if(y.name===null)return"";if(!y.parent_object_id)return y.name;let $8=z?z.get(y.parent_object_id):null;if($8){let k8=$8.getEntity().getPath();return k8?`${k8}/${y.name}`:y.name}let W8=[y.name],z8=y.parent_folder_id;while(z8!==null){let w8=W.get(z8),k8=w8&&z?z.get(w8):null;if(k8){let h6=k8.getEntity().getPath();if(h6){let o8=h6.split("/").filter((d6)=>d6);W8.unshift(...o8)}break}let m8=await E.selectFrom("entities").select(["name","parent_folder_id"]).where("id","=",z8).where("deleted_at","is",null).executeTakeFirst();if(Y8.factory(!m8,t.notFound,`Folder not found for PK ${z8}`,"FOLDER_NOT_FOUND"),m8.name!==null)W8.unshift(m8.name);z8=m8.parent_folder_id}return W8.join("/")},C=async(E,u)=>{let y=[],Q=[u];while(Q.length>0){let d=Q.shift(),$8=await E.selectFrom("entities").select(["id","type_code"]).where("store_id","=",Y).where("parent_folder_id","=",d).where("deleted_at","is",null).execute();for(let W8 of $8)if(y.push(W8.id),W8.type_code==="f")Q.push(W8.id)}return y},V=async(E,u,y,Q)=>{let d=K4(),$8=await uz.readEntityTypeId(E,{},"f",Q),W8=await q5.nextSeq(E,"store",Y,"f"),z8=await f(E,u),w8=Zx(K,"f",W8),k8=await E.insertInto("entities").values({store_id:Y,object_id:w8,entity_type_id:$8,type_code:"f",seq:W8,parent_folder_id:z8,parent_object_id:u,name:y,created_at:d,updated_at:d}).returningAll().executeTakeFirstOrThrow();return await E.insertInto("folders").values({entity_id:k8.id}).execute(),{row:k8,id:w8}},M=(E)=>{let u=null;if(E.owner_entity_id!==null)u=W.get(E.owner_entity_id)??null;let{entity:y,mutationApi:Q}=Wx.create({id:E.object_id,name:E.name,ownerEntityId:u,label:E.label,description:E.description,primitiveType:E.primitive_type,required:E.required===1,multiplicity:E.multiplicity,isSystem:E.is_system===1,createdAt:E.created_at,updatedAt:E.updated_at});return{entity:y,mutationApi:Q,pk:E.id}},R=async(E,u)=>{let y=await E.selectFrom("field_values as fv").innerJoin("field_definitions as fd","fd.id","fv.field_definition_id").select(["fv.id as value_id","fv.value","fd.id as def_id","fd.object_id as def_object_id","fd.name as def_name","fd.label as def_label","fd.description as def_description","fd.primitive_type as def_primitive_type","fd.required as def_required","fd.multiplicity as def_multiplicity","fd.is_system as def_is_system","fd.owner_entity_id as def_owner_entity_id","fd.created_at as def_created_at","fd.updated_at as def_updated_at"]).where("fv.entity_id","=",u).execute(),Q=new Map;for(let $8 of y){let W8=$8.def_id;if(!Q.has(W8))Q.set(W8,{definition:{id:$8.def_object_id,name:$8.def_name,label:$8.def_label,description:$8.def_description,primitiveType:$8.def_primitive_type,required:$8.def_required===1,multiplicity:$8.def_multiplicity,isSystem:$8.def_is_system===1,ownerEntityId:$8.def_owner_entity_id?W.get($8.def_owner_entity_id):null,createdAt:$8.def_created_at,updatedAt:$8.def_updated_at},values:[]});Q.get(W8).values.push($8.value)}let d=[];for(let{definition:$8,values:W8}of Q.values()){let{entity:z8}=Wx.create($8),w8=Hx.create({definition:z8,values:W8});d.push(w8)}return d},I=async(E,u)=>{let y=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",1).where("type_code","=","n").executeTakeFirst();if(!y)return null;if(y.owner_entity_id){let d=await E.selectFrom("entities").select("object_id").where("id","=",y.owner_entity_id).executeTakeFirst();if(d)W.set(y.owner_entity_id,d.object_id)}let Q=`${K}n1`;return W.set(y.id,Q),M(y)},D=async(E,u,{storeCode:y,parentId:Q,name:d,subtype:$8})=>{if(y!==void 0)v(y);if(d!==null&&d!==void 0)gP8(d);let{row:W8,id:z8}=await V(E,Q,d,$8||null),w8=W8.id;W.set(w8,z8);let k8=await A(E,w8),{entity:m8,mutationApi:Q8}=mz.createFromRow(W8,z8,Q,k8);return{entity:m8,mutationApi:Q8,pk:w8}},m=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.seq","=",Q.seq).where("entities.type_code","=","f").where("entities.deleted_at","is",null).executeTakeFirst();if(!d)return null;let{id:$8,parent_object_id:W8}=d;W.set($8,y);let z8=await A(E,$8),w8=await R(E,$8),{entity:k8,mutationApi:m8}=mz.createFromRow(d,y,W8,z8);for(let Q8 of w8)m8.setField(Q8.getDefinition().getName(),Q8);return{entity:k8,mutationApi:m8,pk:$8}},b=async(E,u,{id:y,name:Q,parentId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid folder ID: ${y}`,"INVALID_ID");let W8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",$8.seq).where("type_code","=","f").where("deleted_at","is",null).executeTakeFirst();Y8.factory(!W8,t.notFound,`Folder not found: ${y}`,"FOLDER_NOT_FOUND");let z8=W8.id,w8={name:W8.name,parentId:W8.parent_object_id,path:null};if(W.set(z8,y),w8.path=await A(E,z8),Q!==void 0)gP8(Q);let k8={};if(Q!==void 0)k8.name=Q;if(d!==void 0){let n6=await f(E,d);k8.parent_folder_id=n6,k8.parent_object_id=d}k8.updated_at=K4();let m8=await E.updateTable("entities").set(k8).where("id","=",z8).returningAll().executeTakeFirstOrThrow(),Q8=await A(E,z8),h6=await R(E,z8),{entity:o8,mutationApi:d6}=mz.createFromRow(m8,y,m8.parent_object_id,Q8);for(let n6 of h6)d6.setField(n6.getDefinition().getName(),n6);return{entity:o8,mutationApi:d6,pk:z8,oldValues:w8}},h=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid folder ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","f").where("deleted_at","is",null).executeTakeFirst();Y8.factory(!d,t.notFound,`Folder not found: ${y}`,"FOLDER_NOT_FOUND");let $8=d.id;W.set($8,y);let W8=await A(E,$8),z8=await C(E,$8),w8=K4();await E.updateTable("entities").set({deleted_at:w8}).where("id","in",[$8,...z8]).execute();let k8=[];for(let m8 of z8){let Q8=await E.selectFrom("entities").select("object_id").where("id","=",m8).executeTakeFirst();if(Q8)k8.push(Q8.object_id)}return{id:y,deleted:!0,descendantCount:z8.length,path:W8,descendantIds:k8,deletedPks:[$8,...z8]}},L=async(E,u,y,Q,d=null)=>{let $8=await f(E,y),W8=E.selectFrom("entities").select("object_id").where("store_id","=",Y).where("parent_folder_id",$8===null?"is":"=",$8).where("name","=",Q).where("deleted_at","is",null);if(d)W8=W8.where("object_id","!=",d);return!!await W8.executeTakeFirst()},B=async(E,u,y,Q)=>{let d=await f(E,y),$8=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.parent_folder_id",d===null?"is":"=",d).where("entities.name","=",Q).where("entities.deleted_at","is",null).executeTakeFirst();if(!$8)return null;let{id:W8,object_id:z8}=$8;W.set(W8,z8);let w8=await A(E,W8),k8=await R(E,W8),{entity:m8,mutationApi:Q8}=mz.createFromRow($8,z8,y,w8);for(let h6 of k8)Q8.setField(h6.getDefinition().getName(),h6);return{entity:m8,mutationApi:Q8,pk:W8}},i=async(E,u,{folderId:y,type:Q})=>{let d;if(y){if(d=await f(E,y),d===null)return[]}else if(Q){let w8=await N8(E,u,Q);if(!w8)return[];d=w8.pk}else d=null;let $8=E.selectFrom("entities").selectAll().where("store_id","=",Y).where("parent_folder_id",d===null?"is":"=",d).where("deleted_at","is",null);if(Q)$8=$8.where("type_code","=","f").innerJoin("folders","folders.entity_id","entities.id");let W8=await $8.execute(),z8=[];for(let w8 of W8){let{id:k8,object_id:m8}=w8;W.set(k8,m8);let Q8=await A(E,k8),h6=await R(E,k8),{entity:o8,mutationApi:d6}=mz.createFromRow(w8,m8,w8.parent_object_id,Q8);for(let n6 of h6)d6.setField(n6.getDefinition().getName(),n6);z8.push({entity:o8,mutationApi:d6,pk:k8})}return z8},X8=async(E,u,{path:y,type:Q})=>{let d=(y??"").trim(),$8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("type_code","=","f").where("deleted_at","is",null).execute();for(let W8 of $8){let z8=await m(E,u,{id:W8.object_id});if(z8&&z8.entity.getPath()===d)return z8}return null},N8=async(E,u,y,Q)=>{if(Q!==void 0)v(Q);let d=y==="d"?"root_d":"root_t",$8=await uz.readEntityTypeId(E,u,"f",d),W8=await E.selectFrom("entities").innerJoin("folders","folders.entity_id","entities.id").selectAll("entities").where("entities.store_id","=",Y).where("entities.entity_type_id","=",$8).where("entities.deleted_at","is",null).executeTakeFirst();if(!W8)return null;let{id:z8,object_id:w8}=W8;W.set(z8,w8);let k8=await A(E,z8),m8=await R(E,z8),{entity:Q8,mutationApi:h6}=mz.createFromRow(W8,w8,W8.parent_object_id,k8);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);return{entity:Q8,mutationApi:h6,pk:z8}},h8=async(E,u,{storeCode:y,ownerEntityId:Q,name:d,label:$8,description:W8,primitiveType:z8,required:w8,multiplicity:k8,isSystem:m8=!1})=>{if(y!==void 0)v(y);Y8.factory(z8!=="string"&&z8!=="object_ref",t.validation,`Invalid primitiveType: ${z8}`,"INVALID_PRIMITIVE_TYPE"),Y8.factory(k8!=="single"&&k8!=="multi",t.validation,`Invalid multiplicity: ${k8}`,"INVALID_MULTIPLICITY");let Q8=K4(),h6=await uz.readEntityTypeId(E,u,"n",null),o8=await q5.nextSeq(E,"store",Y,"n"),d6=Zx(K,"n",o8),n6=Q?await f(E,Q):null,L$=await E.insertInto("field_definitions").values({store_id:Y,object_id:d6,entity_type_id:h6,type_code:"n",seq:o8,owner_entity_id:n6,name:d,label:$8,description:W8,primitive_type:z8,required:w8?1:0,multiplicity:k8,is_system:m8?1:0,created_at:Q8,updated_at:Q8}).returningAll().executeTakeFirstOrThrow(),u3=L$.id;return W.set(u3,d6),M(L$)},c8=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","n").executeTakeFirst();if(!d)return null;if(d.owner_entity_id){let $8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if($8)W.set(d.owner_entity_id,$8.object_id)}return W.set(d.id,y),M(d)},E8=async(E,u,y,Q)=>{let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("name","=",y).where("owner_entity_id",Q===null?"is":"=",Q).executeTakeFirst();if(!d)return null;if(d.owner_entity_id){let $8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if($8)W.set(d.owner_entity_id,$8.object_id)}return W.set(d.id,d.object_id),M(d)},g8=async(E,u,{fieldDefinitionId:y,fieldName:Q,ownerEntityPk:d})=>{if(y){let W8=await c8(E,u,{id:y});if(W8)return W8}if(Q&&d){let W8=await E8(E,u,Q,d);if(W8)return W8}if(Q){let W8=await E8(E,u,Q,null);if(W8)return W8}let $8=await I(E);return Y8.factory(!$8,t.notFound,"No field definition found and no default available","NO_FIELD_DEFINITION"),$8},t8=async(E,u,{ownerEntityPk:y,includeSystem:Q=!0})=>{let d=E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("owner_entity_id",y===null?"is":"=",y);if(!Q)d=d.where("is_system","=",0);let $8=await d.execute(),W8=[];for(let z8 of $8){if(z8.owner_entity_id){let w8=await E.selectFrom("entities").select("object_id").where("id","=",z8.owner_entity_id).executeTakeFirst();if(w8)W.set(z8.owner_entity_id,w8.object_id)}W.set(z8.id,z8.object_id),W8.push(M(z8))}return W8},V4=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid definition ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("field_definitions").selectAll().where("store_id","=",Y).where("seq","=",Q.seq).where("type_code","=","n").executeTakeFirst();Y8.factory(!d,t.notFound,`Field definition not found: ${y}`,"DEFINITION_NOT_FOUND"),Y8.factory(d.is_system===1,t.validation,`Cannot delete system field definition: ${y}`,"SYSTEM_DEFINITION");let $8=d.id;if(await E.deleteFrom("field_definitions").where("id","=",$8).execute(),d.owner_entity_id){let z8=await E.selectFrom("entities").select("object_id").where("id","=",d.owner_entity_id).executeTakeFirst();if(z8)W.set(d.owner_entity_id,z8.object_id)}let{entity:W8}=M(d);return W8},g3=async(E,u,{entityId:y,fieldDefinitionId:Q,fieldName:d,value:$8,values:W8})=>{let z8=O4(y);Y8.factory(!z8,t.validation,`Invalid entity ID: ${y}`,"INVALID_ID");let w8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("seq","=",z8.seq).where("type_code","=",z8.typeCode).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!w8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let k8=w8.id,{entity:m8,pk:Q8}=await g8(E,u,{fieldDefinitionId:Q,fieldName:d,ownerEntityPk:k8}),h6=m8.getMultiplicity(),o8;if(h6==="single")if(W8&&Array.isArray(W8))Y8.factory(W8.length>1||W8.length===0,t.validation,`Field '${m8.getName()}' is single-valued but received ${W8.length} values`,"MULTIPLICITY_VIOLATION"),o8=[W8[0]];else Y8.factory($8===void 0,t.validation,"Single-valued field requires value parameter","VALUE_REQUIRED"),o8=[$8];else if(W8&&Array.isArray(W8))o8=W8;else if($8!==void 0)o8=[$8];else Y8.factory(!0,t.validation,"Multi-valued field requires either value or values parameter","VALUE_OR_VALUES_REQUIRED");await E.deleteFrom("field_values").where("entity_id","=",k8).where("field_definition_id","=",Q8).execute();let d6=K4();for(let xY of o8)await E.insertInto("field_values").values({entity_id:k8,field_definition_id:Q8,value:xY,updated_at:d6}).execute();let n6=o8,L$=Hx.create({definition:m8,values:n6}),u3;if(z8.typeCode==="f")u3=await m(E,u,{id:y});else u3=await a(E,u,{id:y});return Y8.factory(!u3,t.notFound,`Entity not found after field update: ${y}`,"ENTITY_NOT_FOUND"),{...u3,field:L$,fieldName:m8.getName()}},v8=async(E,u,{entityId:y,fieldDefinitionId:Q,fieldName:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid entity ID: ${y}`,"INVALID_ID");let W8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("seq","=",$8.seq).where("type_code","=",$8.typeCode).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!W8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let z8=W8.id,{entity:w8,pk:k8}=await g8(E,u,{fieldDefinitionId:Q,fieldName:d,ownerEntityPk:z8});await E.deleteFrom("field_values").where("entity_id","=",z8).where("field_definition_id","=",k8).execute();let m8;if($8.typeCode==="f")m8=await m(E,u,{id:y});else m8=await a(E,u,{id:y});return Y8.factory(!m8,t.notFound,`Entity not found after field delete: ${y}`,"ENTITY_NOT_FOUND"),{...m8,fieldName:w8.getName()}},r=async(E,u,{type:y,storeCode:Q,parentId:d,name:$8,initialContent:W8})=>{let z8=m1.getEntityFactory(y);if(Q!==void 0)v(Q);let w8=K4(),k8=await uz.readEntityTypeId(E,u,y,null),m8=await q5.nextSeq(E,"store",Y,y),Q8=Zx(K,y,m8),h6=await f(E,d),o8=await E.insertInto("entities").values({store_id:Y,object_id:Q8,entity_type_id:k8,type_code:y,seq:m8,parent_folder_id:h6,parent_object_id:d,name:$8,created_at:w8,updated_at:w8}).returningAll().executeTakeFirstOrThrow();await E.insertInto("documents").values({entity_id:o8.id,published_version_id:null}).execute();let d6=W8!==null&&W8!==void 0;if(d6)await E.insertInto("document_drafts").values({entity_id:o8.id,content:W8,updated_at:w8}).execute();let n6=o8.id;W.set(n6,Q8);let L$=await A(E,n6),{entity:u3,mutationApi:xY}=z8(o8,Q8,d,L$,null,d6,d6?W8:null,null);return{entity:u3,mutationApi:xY,pk:n6}},a=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let{typeCode:d,seq:$8}=Q,W8=m1.getEntityFactory(d),z8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").leftJoin("document_edit_state as es","es.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","e.deleted_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft"),"es.client_id as edit_client_id","es.started_at as edit_started_at","es.last_activity_at as edit_activity"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();if(!z8)return null;let w8=z8.entity_id;W.set(w8,y);let k8=await A(E,w8),m8=await R(E,w8),{entity:Q8,mutationApi:h6}=W8(z8,z8.object_id,z8.parent_object_id,k8,z8.published_version_number,z8.has_draft===1,z8.draft_content??null,z8.published_content??null);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);if(z8.edit_client_id)h6.setEditState({clientId:z8.edit_client_id,startedAt:z8.edit_started_at,lastActivityAt:z8.edit_activity});return{entity:Q8,mutationApi:h6,pk:w8}},s=async(E,u,{id:y,name:Q,parentId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:W8,seq:z8}=$8,w8=m1.getContentTypeLabel(W8),k8=m1.getEntityFactory(W8),m8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",z8).where("type_code","=",W8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!m8,t.notFound,`${w8} not found: ${y}`,"NOT_FOUND");let Q8=m8.id,h6={name:m8.name,parentId:m8.parent_object_id,path:null};W.set(Q8,y),h6.path=await A(E,Q8);let d6={updated_at:K4()};if(Q!==void 0)d6.name=Q;if(d!==void 0){let i5=await f(E,d);d6.parent_folder_id=i5,d6.parent_object_id=d}let n6=await E.updateTable("entities").set(d6).where("id","=",Q8).returningAll().executeTakeFirstOrThrow(),L$=await E.selectFrom("documents as d").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","d.entity_id").select(["dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft")]).where("d.entity_id","=",Q8).executeTakeFirst(),u3=await A(E,Q8),xY=await R(E,Q8),{entity:kP,mutationApi:hv}=k8(n6,y,n6.parent_object_id,u3,L$.published_version_number,L$.has_draft===1,L$.draft_content??null,L$.published_content??null);for(let i5 of xY)hv.setField(i5.getDefinition().getName(),i5);return{entity:kP,mutationApi:hv,pk:Q8,oldValues:h6}},K8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=await E.selectFrom("entities").selectAll().where("store_id","=",Y).where("seq","=",$8).where("type_code","=",d).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`${W8} not found: ${y}`,"NOT_FOUND");let w8=z8.id;W.set(w8,y);let k8=await A(E,w8),m8=K4();return await E.updateTable("entities").set({deleted_at:m8}).where("id","=",w8).execute(),{id:y,deleted:!0,path:k8}},P8=async(E,u,{id:y,content:Q,clientId:d})=>{let $8=O4(y);Y8.factory(!$8,t.validation,`Invalid content ID: ${y}`,"INVALID_ID"),Y8.factory(!d,t.validation,"clientId is required","MISSING_CLIENT_ID");let{typeCode:W8,seq:z8}=$8,w8=m1.getContentTypeLabel(W8),k8=K4(),m8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",W8).where("seq","=",z8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!m8,t.notFound,`${w8} not found: ${y}`,"NOT_FOUND");let Q8=m8.id;await E.insertInto("document_drafts").values({entity_id:Q8,content:Q,updated_at:k8}).onConflict((n6)=>n6.column("entity_id").doUpdateSet({content:Q,updated_at:k8})).execute();let o8=!await tK(E,u,{id:y,clientId:d}),d6=await a(E,u,{id:y});return Y8.factory(!d6,t.notFound,`${w8} not found after draft save: ${y}`,"NOT_FOUND"),{...d6,lockLost:o8}},H8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=K4(),w8=await E.selectFrom("entities as e").innerJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.id as entity_id","dd.content"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();Y8.factory(!w8,t.notFound,`No draft found for ${W8}: ${y}`,"DRAFT_NOT_FOUND");let k8=w8.entity_id,Q8=((await E.selectFrom("document_versions").select(E.fn.max("version_number").as("max_version")).where("entity_id","=",k8).executeTakeFirst())?.max_version||0)+1,h6=await E.insertInto("document_versions").values({entity_id:k8,version_number:Q8,content:w8.content,published_at:z8}).returningAll().executeTakeFirstOrThrow();await E.updateTable("documents").set({published_version_id:h6.id}).where("entity_id","=",k8).execute(),await E.deleteFrom("document_drafts").where("entity_id","=",k8).execute(),await E.deleteFrom("document_edit_state").where("entity_id","=",k8).execute();let o8=await a(E,u,{id:y});return Y8.factory(!o8,t.notFound,`${W8} not found after publish: ${y}`,"NOT_FOUND"),o8},O8=async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid content ID: ${y}`,"INVALID_ID");let{typeCode:d,seq:$8}=Q,W8=m1.getContentTypeLabel(d),z8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d).where("seq","=",$8).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`${W8} not found: ${y}`,"NOT_FOUND"),await E.deleteFrom("document_drafts").where("entity_id","=",z8.id).execute();let w8=await a(E,u,{id:y});return Y8.factory(!w8,t.notFound,`${W8} not found after discard: ${y}`,"NOT_FOUND"),w8},A8=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let{typeCode:d,seq:$8}=Q,W8=await E.selectFrom("entities as e").innerJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.object_id","dd.content","dd.updated_at"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).executeTakeFirst();if(!W8)return null;return{entityId:W8.object_id,content:W8.content,updatedAt:W8.updated_at}},A6=async(E,u,{id:y,versionNumber:Q})=>{let d=O4(y);if(!d)return null;let{typeCode:$8,seq:W8}=d,z8=await E.selectFrom("entities as e").innerJoin("document_versions as dv","dv.entity_id","e.id").select(["e.object_id","dv.version_number","dv.content","dv.published_at"]).where("e.store_id","=",Y).where("e.type_code","=",$8).where("e.seq","=",W8).where("e.deleted_at","is",null).where("dv.version_number","=",Q).executeTakeFirst();if(!z8)return null;return{entityId:z8.object_id,versionNumber:z8.version_number,content:z8.content,publishedAt:z8.published_at}},E6=async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return[];let{typeCode:d,seq:$8}=Q;return(await E.selectFrom("entities as e").innerJoin("document_versions as dv","dv.entity_id","e.id").select(["dv.version_number","dv.published_at"]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.seq","=",$8).where("e.deleted_at","is",null).orderBy("dv.version_number","desc").execute()).map((z8)=>({versionNumber:z8.version_number,publishedAt:z8.published_at}))},$1=async(E,u,y,Q,d)=>{let $8=m1.getEntityFactory(d),W8=await f(E,y),z8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft")]).where("e.store_id","=",Y).where("e.type_code","=",d).where("e.parent_folder_id",W8===null?"is":"=",W8).where("e.name","=",Q).where("e.deleted_at","is",null).executeTakeFirst();if(!z8)return null;let w8=z8.entity_id;W.set(w8,z8.object_id);let k8=await A(E,w8),m8=await R(E,w8),{entity:Q8,mutationApi:h6}=$8(z8,z8.object_id,z8.parent_object_id,k8,z8.published_version_number,z8.has_draft===1,z8.draft_content??null,z8.published_content??null);for(let o8 of m8)h6.setField(o8.getDefinition().getName(),o8);return{entity:Q8,mutationApi:h6,pk:w8}},y3=async(E,u,{parentId:y,type:Q})=>{let d=m1.getEntityFactory(Q),$8=await f(E,y),W8=await E.selectFrom("entities as e").innerJoin("documents as d","d.entity_id","e.id").leftJoin("document_versions as dv","dv.id","d.published_version_id").leftJoin("document_drafts as dd","dd.entity_id","e.id").leftJoin("document_edit_state as es","es.entity_id","e.id").select(["e.id as entity_id","e.object_id","e.parent_folder_id","e.parent_object_id","e.name","e.created_at","e.updated_at","dv.version_number as published_version_number","dv.content as published_content","dd.content as draft_content",U$.raw("CASE WHEN dd.entity_id IS NOT NULL THEN 1 ELSE 0 END").as("has_draft"),"es.client_id as edit_client_id","es.started_at as edit_started_at","es.last_activity_at as edit_activity"]).where("e.store_id","=",Y).where("e.type_code","=",Q).where("e.parent_folder_id",$8===null?"is":"=",$8).where("e.deleted_at","is",null).execute(),z8=[];for(let w8 of W8){let k8=w8.entity_id;W.set(k8,w8.object_id);let m8=await A(E,k8),Q8=await R(E,k8),{entity:h6,mutationApi:o8}=d(w8,w8.object_id,w8.parent_object_id,m8,w8.published_version_number,w8.has_draft===1,w8.draft_content??null,w8.published_content??null);for(let d6 of Q8)o8.setField(d6.getDefinition().getName(),d6);if(w8.edit_client_id)o8.setEditState({clientId:w8.edit_client_id,startedAt:w8.edit_started_at,lastActivityAt:w8.edit_activity});z8.push({entity:h6,mutationApi:o8,pk:k8})}return z8},g7=async(E,u,{id:y,clientId:Q})=>{let d=O4(y);Y8.factory(!d,t.validation,`Invalid ID: ${y}`,"INVALID_ID");let $8=K4(),W8=new Date(Date.now()-PW).toISOString(),z8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d.typeCode).where("seq","=",d.seq).where("deleted_at","is",null).executeTakeFirst();Y8.factory(!z8,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND");let w8=z8.id,k8=await E.selectFrom("document_edit_state").selectAll().where("entity_id","=",w8).executeTakeFirst();if(k8)if(k8.client_id===Q)return await E.updateTable("document_edit_state").set({started_at:$8,last_activity_at:$8}).where("entity_id","=",w8).execute(),{success:!0};else if(k8.last_activity_at<W8)return await E.updateTable("document_edit_state").set({client_id:Q,started_at:$8,last_activity_at:$8}).where("entity_id","=",w8).execute(),{success:!0};else return{success:!1,meta:{lockedBy:k8.client_id,lockedSince:k8.started_at,timeoutSeconds:PW/1000}};else return await E.insertInto("document_edit_state").values({entity_id:w8,client_id:Q,started_at:$8,last_activity_at:$8}).execute(),{success:!0}},tK=async(E,u,{id:y,clientId:Q})=>{let d=O4(y);if(!d)return!1;let $8=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",d.typeCode).where("seq","=",d.seq).executeTakeFirst();if(!$8)return!1;return((await E.updateTable("document_edit_state").set({last_activity_at:K4()}).where("entity_id","=",$8.id).where("client_id","=",Q).execute())[0]?.numUpdatedRows||0)>0},c=Object.freeze({...H,getCodes:O,getType:w,getCode:X,getPk:T,toJSON:G,createFolder:D,readFolder:m,updateFolder:b,deleteFolder:h,isDuplicateNameInParent:L,findFolderByName:B,listFolderContents:i,getFolderByPath:X8,readRootFolderForType:N8,createContent:r,readContent:a,updateContent:s,deleteContent:K8,saveDraft:P8,readDraft:A8,publishContent:H8,discardDraft:O8,readVersion:A6,getVersions:E6,findContentByName:$1,listContent:y3,createFieldDefinition:h8,readFieldDefinition:c8,readDefaultFieldDefinition:I,findFieldDefinitionByName:E8,resolveFieldDefinition:g8,getFieldDefinitionsForOwner:t8,deleteFieldDefinition:V4,setFieldValue:g3,deleteFieldValue:v8,setEditState:g7,clearEditState:async(E,u,{id:y})=>{let Q=O4(y);Y8.factory(!Q,t.validation,`Invalid ID: ${y}`,"INVALID_ID");let d=await E.selectFrom("entities").select("id").where("store_id","=",Y).where("type_code","=",Q.typeCode).where("seq","=",Q.seq).executeTakeFirst();Y8.factory(!d,t.notFound,`Entity not found: ${y}`,"ENTITY_NOT_FOUND"),await E.deleteFrom("document_edit_state").where("entity_id","=",d.id).execute()},getEditState:async(E,u,{id:y})=>{let Q=O4(y);if(!Q)return null;let d=await E.selectFrom("entities as e").innerJoin("document_edit_state as es","es.entity_id","e.id").select(["es.client_id","es.started_at","es.last_activity_at"]).where("e.store_id","=",Y).where("e.type_code","=",Q.typeCode).where("e.seq","=",Q.seq).executeTakeFirst();if(!d)return null;return{clientId:d.client_id,startedAt:d.started_at,lastActivityAt:d.last_activity_at}}}),o=Object.freeze({...Z});return{store:c,mutationApi:o}},uP8=Object.freeze({create:XH6});var TH6=({inner:$,folderCache:K,contentCache:q,fieldDefinitionCache:Y})=>{let z=async(r,a,s,K8)=>{let P8=await $.createFolder(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{K.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},P=async(r,a,{id:s})=>{let K8=K.get(s);if(K8)return K8.getEntity();let P8=await $.readFolder(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return K.set(s,l6.create(H8,O8,A8)),H8},J=async(r,a,s,K8)=>{let{id:P8}=s,H8=K.get(P8),O8=await $.updateFolder(r,a,s),A8=s.name!==void 0&&s.name!==O8.oldValues.name||s.parentId!==void 0&&s.parentId!==O8.oldValues.parentId;return K8(()=>{if(H8){let E6=H8.getMutationApi();if(s.name!==void 0)E6.setName(s.name);if(s.parentId!==void 0)E6.setParentId(s.parentId);E6.setUpdatedAt(O8.entity.getUpdatedAt()),E6.setPath(O8.entity.getPath())}else{let{entity:E6,mutationApi:$1,pk:y3}=O8;K.set(P8,l6.create(E6,$1,y3))}if(A8){let $1=O8.oldValues.path+"/";for(let[y3,g7]of K.entries())if(g7.getEntity().getPath().startsWith($1))K.remove(y3)}}),{entity:H8?H8.getEntity():O8.entity,oldValues:O8.oldValues}},W=async(r,a,{id:s},K8)=>{let P8=K.get(s),H8=P8?P8.getEntity().getPath():null,O8=await $.deleteFolder(r,a,{id:s});return K8(()=>{K.remove(s);for(let A8 of O8.descendantIds||[])K.remove(A8)}),{...O8,path:H8}},H=async(r,a,s)=>{let K8=await $.listFolderContents(r,a,s);for(let P8 of K8)K.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},Z=async(r,a,s)=>{let K8=await $.getFolderByPath(r,a,s);if(!K8)return null;let{entity:P8,mutationApi:H8,pk:O8}=K8;return K.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},O=async(r,a,s,K8)=>{let P8=await $.findFolderByName(r,a,s,K8);if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return K.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},w=async(r,a,s)=>{let K8=await $.readRootFolderForType(r,a,s);if(!K8)return null;let{entity:P8,mutationApi:H8,pk:O8}=K8;return K.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},X=async(r,a,s,K8,P8)=>{return $.isDuplicateNameInParent(r,a,s,K8,P8)},T=async(r,a,s,K8)=>{let P8=await $.createContent(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{q.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},G=async(r,a,{id:s})=>{let K8=q.get(s);if(K8)return K8.getEntity();let P8=await $.readContent(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return q.set(s,l6.create(H8,O8,A8)),H8},v=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.updateContent(r,a,s);return K8(()=>{if(H8){let A8=H8.getMutationApi();if(s.name!==void 0)A8.setName(s.name);if(s.parentId!==void 0)A8.setParentId(s.parentId);A8.setUpdatedAt(O8.entity.getUpdatedAt()),A8.setPath(O8.entity.getPath())}else{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}}),H8?H8.getEntity():O8.entity},f=async(r,a,{id:s},K8)=>{let P8=q.get(s),H8=P8?P8.getEntity().getPath():null,O8=await $.deleteContent(r,a,{id:s});return K8(()=>{q.remove(s)}),{...O8,path:H8}},A=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.saveDraft(r,a,s);K8(()=>{if(H8){let A6=H8.getMutationApi();A6.setDraftContent(O8.entity.getDraftContent()),A6.setHasDraft(O8.entity.hasDraftContent()),A6.setUpdatedAt(O8.entity.getUpdatedAt())}else{let{entity:A6,mutationApi:E6,pk:$1}=O8;q.set(P8,l6.create(A6,E6,$1))}});let A8=H8?H8.getEntity():O8.entity;if(O8.lockLost!==void 0)return{entity:A8,lockLost:O8.lockLost};return A8},C=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.publishContent(r,a,s);if(H8){let A8=H8.getMutationApi();return A8.setPublishedVersionNumber(O8.entity.getPublishedVersionNumber()),A8.setPublishedContent(O8.entity.getPublishedContent()),A8.setDraftContent(null),A8.setHasDraft(!1),A8.setUpdatedAt(O8.entity.getUpdatedAt()),H8.getEntity()}else return K8(()=>{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}),O8.entity},V=async(r,a,s,K8)=>{let{id:P8}=s,H8=q.get(P8),O8=await $.discardDraft(r,a,s);return K8(()=>{if(H8){let A8=H8.getMutationApi();A8.setDraftContent(null),A8.setHasDraft(!1),A8.setUpdatedAt(O8.entity.getUpdatedAt())}else{let{entity:A8,mutationApi:A6,pk:E6}=O8;q.set(P8,l6.create(A8,A6,E6))}}),H8?H8.getEntity():O8.entity},M=async(r,a,s)=>{return $.readDraft(r,a,s)},R=async(r,a,s)=>{return $.readVersion(r,a,s)},I=async(r,a,s)=>{return $.getVersions(r,a,s)},D=async(r,a,s,K8,P8)=>{let H8=await $.findContentByName(r,a,s,K8,P8);if(!H8)return null;let{entity:O8,mutationApi:A8,pk:A6}=H8;return q.set(O8.getObjectId(),l6.create(O8,A8,A6)),O8},m=async(r,a,s)=>{let K8=await $.listContent(r,a,s);for(let P8 of K8)q.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},b=async(r,a,s,K8)=>{let{id:P8}=s,H8=await $.setEditState(r,a,s);return K8(()=>{q.remove(P8)}),H8},h=async(r,a,s)=>{return $.getEditState(r,a,s)},L=async(r,a,s,K8)=>{let{id:P8}=s;await $.clearEditState(r,a,s),K8(()=>{q.remove(P8)})},B=async(r,a,s,K8)=>{let P8=await $.createFieldDefinition(r,a,s),{entity:H8,mutationApi:O8,pk:A8}=P8;return K8(()=>{Y.set(H8.getObjectId(),l6.create(H8,O8,A8))}),H8},i=async(r,a,{id:s})=>{let K8=Y.get(s);if(K8)return K8.getEntity();let P8=await $.readFieldDefinition(r,a,{id:s});if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(s,l6.create(H8,O8,A8)),H8},X8=async(r,a,s,K8)=>{let P8=await $.findFieldDefinitionByName(r,a,s,K8);if(!P8)return null;let{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},N8=async(r,a,s)=>{let K8=await $.getFieldDefinitionsForOwner(r,a,s);for(let P8 of K8)Y.set(P8.entity.getObjectId(),l6.create(P8.entity,P8.mutationApi,P8.pk));return K8.map((P8)=>P8.entity)},h8=async(r,a)=>{let s=`${$.getCode()}n1`,K8=Y.get(s);if(K8)return K8.getEntity();let P8=await $.readDefaultFieldDefinition(r,a),{entity:H8,mutationApi:O8,pk:A8}=P8;return Y.set(H8.getObjectId(),l6.create(H8,O8,A8)),H8},c8=async(r,a,s)=>{let K8=await $.resolveFieldDefinition(r,a,s),{entity:P8,mutationApi:H8,pk:O8}=K8;return Y.set(P8.getObjectId(),l6.create(P8,H8,O8)),P8},E8=async(r,a,{id:s},K8)=>{let P8=await $.deleteFieldDefinition(r,a,{id:s});return K8(()=>{Y.remove(s)}),P8},g8=async(r,a,s,K8)=>{let{entityId:P8}=s,H8=await $.setFieldValue(r,a,s);return K8(()=>{let O8=K.get(P8)||q.get(P8);if(O8){let A8=O8.getMutationApi(),A6=H8.entity.getField(H8.fieldName);A8.setField(H8.fieldName,A6)}}),H8.entity},t8=async(r,a,s)=>{return $.getFieldValue(r,a,s)},V4=async(r,a,s,K8)=>{let{entityId:P8}=s,H8=await $.deleteFieldValue(r,a,s);K8(()=>{let O8=K.get(P8)||q.get(P8);if(O8)O8.getMutationApi().removeField(H8.fieldName)})},g3=(r)=>{K.remove(r)};return Object.freeze({getObjectId:$.getObjectId,getName:$.getName,getCreatedAt:$.getCreatedAt,getUpdatedAt:$.getUpdatedAt,getCodes:$.getCodes,getType:$.getType,getCode:$.getCode,getPk:$.getPk,toJSON:$.toJSON,createFolder:z,readFolder:P,updateFolder:J,deleteFolder:W,listFolderContents:H,getFolderByPath:Z,findFolderByName:O,readRootFolderForType:w,isDuplicateNameInParent:X,createContent:T,readContent:G,updateContent:v,deleteContent:f,saveDraft:A,readDraft:M,publishContent:C,discardDraft:V,readVersion:R,getVersions:I,findContentByName:D,listContent:m,setEditState:b,getEditState:h,clearEditState:L,createFieldDefinition:B,readFieldDefinition:i,findFieldDefinitionByName:X8,getFieldDefinitionsForOwner:N8,readDefaultFieldDefinition:h8,resolveFieldDefinition:c8,deleteFieldDefinition:E8,setFieldValue:g8,getFieldValue:t8,deleteFieldValue:V4,evictFolder:g3})},mP8=Object.freeze({create:TH6});var jH6=($)=>{let K=new Map;return $.forEach((P)=>K.set(P,new Set)),Object.freeze({subscribe:(P,J)=>{return K.get(P)?.add(J),()=>K.get(P)?.delete(J)},subscribeAll:(P)=>{let J=[];for(let[W,H]of K){let Z=`on${W.charAt(0).toUpperCase()}${W.slice(1)}`;if(P[Z])H.add(P[Z]),J.push(()=>H.delete(P[Z]))}return()=>J.forEach((W)=>W())},notify:(P,J)=>{K.get(P)?.forEach((W)=>{try{W(J)}catch(H){console.error(`Error in ${P} handler:`,H)}})}})},pP8=Object.freeze({create:jH6});var T6=Object.freeze({FOLDER_CREATED:"folderCreated",FOLDER_RENAMED:"folderRenamed",FOLDER_MOVED:"folderMoved",FOLDER_DELETED:"folderDeleted",DOCUMENT_CREATED:"documentCreated",DOCUMENT_RENAMED:"documentRenamed",DOCUMENT_MOVED:"documentMoved",DOCUMENT_DELETED:"documentDeleted",DOCUMENT_PUBLISHED:"documentPublished",DRAFT_SAVED:"draftSaved",DRAFT_DISCARDED:"draftDiscarded",TEMPLATE_CREATED:"templateCreated",TEMPLATE_RENAMED:"templateRenamed",TEMPLATE_MOVED:"templateMoved",TEMPLATE_DELETED:"templateDeleted",TEMPLATE_PUBLISHED:"templatePublished",TEMPLATE_DRAFT_SAVED:"templateDraftSaved",TEMPLATE_DRAFT_DISCARDED:"templateDraftDiscarded",EDIT_STATE_ACQUIRED:"editStateAcquired",EDIT_STATE_REFRESHED:"editStateRefreshed",EDIT_STATE_CLEARED:"editStateCleared"});var vH6=({inner:$,storeCode:K})=>{let q=pP8.create([T6.FOLDER_CREATED,T6.FOLDER_RENAMED,T6.FOLDER_MOVED,T6.FOLDER_DELETED,T6.DOCUMENT_CREATED,T6.DOCUMENT_RENAMED,T6.DOCUMENT_MOVED,T6.DOCUMENT_DELETED,T6.DOCUMENT_PUBLISHED,T6.DRAFT_SAVED,T6.DRAFT_DISCARDED,T6.TEMPLATE_CREATED,T6.TEMPLATE_RENAMED,T6.TEMPLATE_MOVED,T6.TEMPLATE_DELETED,T6.TEMPLATE_PUBLISHED,T6.TEMPLATE_DRAFT_SAVED,T6.TEMPLATE_DRAFT_DISCARDED]),Y=async(v8,r,a)=>{let s=await $.readFolder(v8,r,{id:a});if(!s)return null;let K8=await v8.selectFrom("entities").innerJoin("entity_types","entities.entity_type_id","entity_types.id").select(["entity_types.code as entity_type_code","entity_types.subtype as entity_type_subtype"]).where("entities.object_id","=",a).executeTakeFirst();if(K8?.entity_type_code==="f"&&K8?.entity_type_subtype==="root_d")return"d";if(K8?.entity_type_code==="f"&&K8?.entity_type_subtype==="root_t")return"t";let P8=await $.readRootFolderForType(v8,r,"d"),H8=await $.readRootFolderForType(v8,r,"t"),O8=s;while(O8&&O8.getParentId()!==null){let A8=await $.readFolder(v8,r,{id:O8.getParentId()});if(!A8)break;O8=A8}if(O8&&O8.getObjectId()===P8?.getObjectId())return"d";else if(O8&&O8.getObjectId()===H8?.getObjectId())return"t";return null},z=async(v8,r,a,s)=>{let{parentId:K8,subtype:P8}=a,H8=await $.createFolder(v8,r,a,s),O8=null;if(P8==="root_d")O8="d";else if(P8==="root_t")O8="t";else{let A8=await $.readRootFolderForType(v8,r,"d"),A6=await $.readRootFolderForType(v8,r,"t");if(K8===A8?.getObjectId())O8="d";else if(K8===A6?.getObjectId())O8="t";else if(K8){let E6=await $.readFolder(v8,r,{id:K8});if(E6){let $1=E6;while($1&&$1.getParentId()!==null){let y3=await $.readFolder(v8,r,{id:$1.getParentId()});if(!y3)break;$1=y3}if($1&&$1.getObjectId()===A8?.getObjectId())O8="d";else if($1&&$1.getObjectId()===A6?.getObjectId())O8="t"}}}return s(()=>{q.notify(T6.FOLDER_CREATED,{id:H8.getObjectId(),storeCode:K,name:H8.getName(),path:H8.getPath(),parentFolderId:K8,contentType:O8})}),H8},P=async(v8,r,a)=>{return $.readFolder(v8,r,a)},J=async(v8,r,a,s)=>{let{id:K8,name:P8,parentId:H8}=a,O8=await $.updateFolder(v8,r,a,s),A8=O8.entity,A6=O8.oldValues.name,E6=O8.oldValues.parentId,$1=await Y(v8,r,K8);if(P8!==void 0&&P8!==A6)s(()=>{q.notify(T6.FOLDER_RENAMED,{id:K8,storeCode:K,parentFolderId:A8.getParentId(),contentType:$1,oldName:A6,newName:P8,path:A8.getPath()})});if(H8!==void 0&&H8!==E6)s(()=>{q.notify(T6.FOLDER_MOVED,{id:K8,storeCode:K,contentType:$1,oldParentFolderId:E6,parentFolderId:H8,path:A8.getPath()})});return A8},W=async(v8,r,a,s)=>{let{id:K8}=a,H8=(await $.readFolder(v8,r,{id:K8}))?.getParentId(),O8=await Y(v8,r,K8),A8=await $.deleteFolder(v8,r,a,s);return s(()=>{q.notify(T6.FOLDER_DELETED,{id:K8,storeCode:K,parentFolderId:H8,contentType:O8,path:A8.path,descendantCount:A8.descendantIds?.length||0})}),A8},H=async(v8,r,a)=>{return $.listFolderContents(v8,r,a)},Z=async(v8,r,a)=>{return $.getFolderByPath(v8,r,a)},O=async(v8,r,a,s)=>{return $.findFolderByName(v8,r,a,s)},w=async(v8,r,a)=>{return $.readRootFolderForType(v8,r,a)},X=async(v8,r,a,s,K8)=>{return $.isDuplicateNameInParent(v8,r,a,s,K8)},T=async(v8,r,a,s)=>{let{type:K8,parentId:P8}=a,H8=await $.createContent(v8,r,a,s),O8=K8==="t"?T6.TEMPLATE_CREATED:T6.DOCUMENT_CREATED;return s(()=>{q.notify(O8,{storeCode:K,id:H8.getObjectId(),type:K8,parentFolderId:P8,name:H8.getName(),path:H8.getPath()})}),H8},G=async(v8,r,a)=>{return $.readContent(v8,r,a)},v=async(v8,r,a,s)=>{let{id:K8,name:P8,parentId:H8}=a,O8=m1.getTypeFromId(K8),A8=await $.readContent(v8,r,{id:K8}),A6=A8?.getName(),E6=A8?.getParentId(),$1=await $.updateContent(v8,r,a,s),y3=O8==="t"?T6.TEMPLATE_RENAMED:T6.DOCUMENT_RENAMED,g7=O8==="t"?T6.TEMPLATE_MOVED:T6.DOCUMENT_MOVED;if(P8!==void 0&&P8!==A6)s(()=>{q.notify(y3,{storeCode:K,id:K8,type:O8,parentFolderId:$1.getParentId(),oldName:A6,newName:P8,path:$1.getPath()})});if(H8!==void 0&&H8!==E6)s(()=>{q.notify(g7,{storeCode:K,id:K8,type:O8,oldParentFolderId:E6,parentFolderId:H8,path:$1.getPath()})});return $1},f=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),O8=(await $.readContent(v8,r,{id:K8}))?.getParentId(),A8=await $.deleteContent(v8,r,a,s),A6=P8==="t"?T6.TEMPLATE_DELETED:T6.DOCUMENT_DELETED;return s(()=>{q.notify(A6,{storeCode:K,id:K8,type:P8,parentFolderId:O8,path:A8.path})}),A8},A=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),O8=(await $.readContent(v8,r,{id:K8}))?.getParentId(),A8=await $.saveDraft(v8,r,a,s),A6=P8==="t"?T6.TEMPLATE_DRAFT_SAVED:T6.DRAFT_SAVED;return s(()=>{let E6=A8.lockLost!==void 0?A8.entity:A8;q.notify(A6,{storeCode:K,id:K8,type:P8,parentFolderId:O8,updatedAt:E6?E6.getUpdatedAt():null,lockLost:A8.lockLost})}),A8},C=async(v8,r,a)=>{return $.readDraft(v8,r,a)},V=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),H8=await $.publishContent(v8,r,a,s),O8=P8==="t"?T6.TEMPLATE_PUBLISHED:T6.DOCUMENT_PUBLISHED;return s(()=>{q.notify(O8,{storeCode:K,id:K8,type:P8,parentFolderId:H8.getParentId(),versionNumber:H8.getPublishedVersionNumber()})}),{entityId:K8,versionNumber:H8.getPublishedVersionNumber(),content:H8.getPublishedContent(),publishedAt:H8.getUpdatedAt()}},M=async(v8,r,a,s)=>{let{id:K8}=a,P8=m1.getTypeFromId(K8),H8=await $.discardDraft(v8,r,a,s),O8=P8==="t"?T6.TEMPLATE_DRAFT_DISCARDED:T6.DRAFT_DISCARDED;return s(()=>{q.notify(O8,{storeCode:K,id:K8})}),H8},R=async(v8,r,a)=>{return $.readVersion(v8,r,a)},I=async(v8,r,a)=>{return $.getVersions(v8,r,a)},D=async(v8,r,a,s,K8)=>{return $.findContentByName(v8,r,a,s,K8)},m=async(v8,r,a)=>{return $.listContent(v8,r,a)},b=async(v8,r,a,s)=>{return $.setEditState(v8,r,a,s)},h=async(v8,r,a)=>{return $.getEditState(v8,r,a)},L=async(v8,r,a,s)=>{return $.clearEditState(v8,r,a,s)},B=async(v8,r,a,s)=>{return $.createFieldDefinition(v8,r,a,s)},i=async(v8,r,a)=>{return $.readFieldDefinition(v8,r,a)},X8=async(v8,r,a,s)=>{return $.findFieldDefinitionByName(v8,r,a,s)},N8=async(v8,r,a)=>{return $.getFieldDefinitionsForOwner(v8,r,a)},h8=async(v8,r)=>{return $.readDefaultFieldDefinition(v8,r)},c8=async(v8,r,a)=>{return $.resolveFieldDefinition(v8,r,a)},E8=async(v8,r,a,s)=>{return $.deleteFieldDefinition(v8,r,a,s)},g8=async(v8,r,a,s)=>{return $.setFieldValue(v8,r,a,s)},t8=async(v8,r,a)=>{return $.getFieldValue(v8,r,a)},V4=async(v8,r,a,s)=>{return $.deleteFieldValue(v8,r,a,s)};return Object.freeze({getObjectId:$.getObjectId,getName:$.getName,getCreatedAt:$.getCreatedAt,getUpdatedAt:$.getUpdatedAt,getCodes:$.getCodes,getType:$.getType,getCode:$.getCode,getPk:$.getPk,toJSON:$.toJSON,createFolder:z,readFolder:P,updateFolder:J,deleteFolder:W,listFolderContents:H,getFolderByPath:Z,findFolderByName:O,readRootFolderForType:w,isDuplicateNameInParent:X,createContent:T,readContent:G,updateContent:v,deleteContent:f,saveDraft:A,readDraft:C,publishContent:V,discardDraft:M,readVersion:R,getVersions:I,findContentByName:D,listContent:m,setEditState:b,getEditState:h,clearEditState:L,createFieldDefinition:B,readFieldDefinition:i,findFieldDefinitionByName:X8,getFieldDefinitionsForOwner:N8,readDefaultFieldDefinition:h8,resolveFieldDefinition:c8,deleteFieldDefinition:E8,setFieldValue:g8,getFieldValue:t8,deleteFieldValue:V4,evictFolder:$.evictFolder,subscribe:q.subscribe,subscribeAll:q.subscribeAll})},cP8=Object.freeze({create:vH6});var GH6=($)=>{let{id:K,code:q,name:Y,pk:z,createdAt:P,updatedAt:J}=$,W=jf.create(),H=jf.create(),Z=jf.create(),{store:O,mutationApi:w}=uP8.create({id:K,code:q,name:Y,pk:z,createdAt:P,updatedAt:J,folderCache:W}),X=mP8.create({inner:O,folderCache:W,contentCache:H,fieldDefinitionCache:Z});return{store:cP8.create({inner:X,storeCode:q}),mutationApi:w}},BP8=Object.freeze({create:GH6});R4();var _H6=({id:$,name:K,createdAt:q,updatedAt:Y,children:z=[]})=>{let P=[...z],J=new Map,{entityFns:W,mutationFns:H}=K5.create({id:$,name:K,createdAt:q,updatedAt:Y}),Z=()=>{J.clear();for(let V8 of P){let R8=V8.getCodes();for(let c of R8)J.set(c,V8)}};Z();let O=()=>"demux",w=()=>P.map((V8)=>V8.getObjectId()),X=()=>[...P],T=()=>{return new Set(J.keys())},G=()=>({id:$,name:K,createdAt:q,updatedAt:Y,type:"demux",childIds:w()}),v=(V8)=>{P.push(V8),Z()},f=(V8)=>{return J.get(V8)??null},A=async(V8,R8,{store:c,storeCode:o,parentId:E,name:u,subtype:y},Q)=>{let d=c??o;Y8.factory(!d,t.validation,"store parameter is required","MISSING_STORE_CODE");let $8=f(d);return Y8.factory(!$8,t.notFound,`No child store with code: ${d}`,"STORE_NOT_FOUND"),$8.createFolder(V8,R8,{storeCode:d,parentId:E,name:u,subtype:y},Q)},C=async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readFolder(V8,R8,{id:c})},g7=Object.freeze({...W,getType:O,getCodes:T,getChildIds:w,getChildren:X,toJSON:G,createFolder:A,readFolder:C,updateFolder:async(V8,R8,{id:c,name:o,parentId:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.updateFolder(V8,R8,{id:c,name:o,parentId:E},u)},deleteFolder:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteFolder(V8,R8,{id:c},o)},evictFolder:(V8)=>{let R8=V8?.[0],c=f(R8);if(c)c.evictFolder(V8)},getFolder:async(V8,R8,{id:c})=>{return C(V8,R8,{id:c})},listFolderContents:async(V8,R8,{folderId:c,store:o,storeCode:E,type:u})=>{let y;if(c!==null&&c!==void 0)y=c[0];else{let $8=o??E;Y8.factory(!$8,t.validation,"store required when folderId is null","STORE_CODE_REQUIRED"),y=$8}let Q=f(y);Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND");let d={...R8,storeCode:y};return Q.listFolderContents(V8,d,{folderId:c,type:u})},getFolderByPath:async(V8,R8,{path:c,type:o,store:E,storeCode:u})=>{let y=E??u;Y8.factory(!y,t.validation,"store required for getFolderByPath","STORE_CODE_REQUIRED");let Q=f(y);if(!Q)return null;let d={...R8,storeCode:y};return Q.getFolderByPath(V8,d,{path:c,type:o})},isDuplicateNameInParent:async(V8,R8,c,o,E=null)=>{let u;if(c)u=c[0];else{let Q=P[0];if(!Q)Y8.factory(!0,t.notFound,"No child stores available","STORE_NOT_FOUND");u=[...Q.getCodes()][0]}let y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.isDuplicateNameInParent(V8,R8,c,o,E)},findFolderByName:async(V8,R8,c,o)=>{let E=c[0],u=f(E);if(!u)return null;return u.findFolderByName(V8,R8,c,o)},readRootFolderForType:async(V8,R8,c,o)=>{let E=f(o);return Y8.factory(!E,t.notFound,`No child store with code: ${o}`,"STORE_NOT_FOUND"),E.readRootFolderForType(V8,R8,c,o)},createFieldDefinition:async(V8,R8,{storeCode:c,ownerEntityId:o,name:E,label:u,description:y,primitiveType:Q,required:d,multiplicity:$8,isSystem:W8},z8)=>{let w8=f(c);return Y8.factory(!w8,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),w8.createFieldDefinition(V8,R8,{storeCode:c,ownerEntityId:o,name:E,label:u,description:y,primitiveType:Q,required:d,multiplicity:$8,isSystem:W8},z8)},readFieldDefinition:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readFieldDefinition(V8,R8,{id:c})},readDefaultFieldDefinition:async(V8,R8,c)=>{let o=f(c);return Y8.factory(!o,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),o.readDefaultFieldDefinition(V8,R8)},getFieldDefinitionsForOwner:async(V8,R8,{storeCode:c,ownerEntityPk:o,includeSystem:E})=>{let u=f(c);return Y8.factory(!u,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),u.getFieldDefinitionsForOwner(V8,R8,{ownerEntityPk:o,includeSystem:E})},deleteFieldDefinition:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteFieldDefinition(V8,R8,{id:c},o)},setFieldValue:async(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E,value:u,values:y},Q)=>{let d=c?.[0],$8=f(d);return Y8.factory(!$8,t.notFound,`No child store with code: ${d}`,"STORE_NOT_FOUND"),$8.setFieldValue(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E,value:u,values:y},Q)},deleteFieldValue:async(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.deleteFieldValue(V8,R8,{entityId:c,fieldDefinitionId:o,fieldName:E},u)},createContent:async(V8,R8,{storeCode:c,type:o,...E},u)=>{let y=f(c);return Y8.factory(!y,t.notFound,`No child store with code: ${c}`,"STORE_NOT_FOUND"),y.createContent(V8,R8,{type:o,storeCode:c,...E},u)},readContent:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readContent(V8,R8,{id:c})},updateContent:async(V8,R8,{id:c,...o},E)=>{let u=c?.[0],y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.updateContent(V8,R8,{id:c,...o},E)},deleteContent:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.deleteContent(V8,R8,{id:c},o)},saveDraft:async(V8,R8,{id:c,content:o,clientId:E},u)=>{let y=c?.[0],Q=f(y);return Y8.factory(!Q,t.notFound,`No child store with code: ${y}`,"STORE_NOT_FOUND"),Q.saveDraft(V8,R8,{id:c,content:o,clientId:E},u)},readDraft:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.readDraft(V8,R8,{id:c})},publishContent:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.publishContent(V8,R8,{id:c},o)},discardDraft:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.discardDraft(V8,R8,{id:c},o)},findContentByName:async(V8,R8,c,o,E)=>{let u=c?.[0],y=f(u);if(!y)return null;return y.findContentByName(V8,R8,c,o,E)},listContent:async(V8,R8,{parentId:c,storeCode:o,type:E})=>{let u,y;if(c)u=c[0],y=c;else{Y8.factory(!o,t.validation,"storeCode required when parentId is null","MISSING_STORE_CODE"),u=o;let d=f(u);Y8.factory(!d,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND");try{y=(await d.readRootFolderForType(V8,R8,E||"d",u)).getObjectId()}catch($8){y=null}}let Q=f(u);return Y8.factory(!Q,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),Q.listContent(V8,R8,{parentId:y,type:E})},setEditState:async(V8,R8,{id:c,clientId:o},E)=>{let u=c?.[0],y=f(u);return Y8.factory(!y,t.notFound,`No child store with code: ${u}`,"STORE_NOT_FOUND"),y.setEditState(V8,R8,{id:c,clientId:o},E)},clearEditState:async(V8,R8,{id:c},o)=>{let E=c?.[0],u=f(E);return Y8.factory(!u,t.notFound,`No child store with code: ${E}`,"STORE_NOT_FOUND"),u.clearEditState(V8,R8,{id:c},o)},getEditState:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return null;return E.getEditState(V8,R8,{id:c})},readVersion:async(V8,R8,{id:c,versionNumber:o})=>{let E=c?.[0],u=f(E);if(!u)return null;return u.readVersion(V8,R8,{id:c,versionNumber:o})},getVersions:async(V8,R8,{id:c})=>{let o=c?.[0],E=f(o);if(!E)return[];return E.getVersions(V8,R8,{id:c})},subscribe:(V8,R8)=>{let c=P.map((o)=>o.subscribe(V8,R8));return()=>c.forEach((o)=>o())},subscribeAll:(V8)=>{let R8=P.map((c)=>c.subscribeAll(V8));return()=>R8.forEach((c)=>c())}}),tK=Object.freeze({...H,addChild:v});return{store:g7,mutationApi:tK}},UP8=Object.freeze({create:_H6});R4();var fX=($)=>{if(!$||$.length<2||$[0]!=="S")return null;let K=parseInt($.slice(1),10);return isNaN(K)?null:K},wx=($)=>$.object_id,Ox=($)=>{let K=wx($),q=$.id,{store:Y,mutationApi:z}=BP8.create({id:K,code:$.code,name:$.name,createdAt:$.created_at,updatedAt:$.updated_at,pk:q});return{store:Y,mutationApi:z,id:K,pk:q}},lP8=($,K)=>{let q=wx($),Y=$.id,{store:z,mutationApi:P}=UP8.create({id:q,name:$.name,createdAt:$.created_at,updatedAt:$.updated_at,children:K});return{store:z,mutationApi:P,id:q,pk:Y}},fH6=async($,K,q,Y,z)=>{let P=await uz.readEntityTypeId($,K,"n",null),J=await q5.nextSeq($,"store",q,"n"),W=`${Y}n${J}`,H=K4();await $.insertInto("field_definitions").values({store_id:q,object_id:W,entity_type_id:P,type_code:"n",seq:J,owner_entity_id:null,name:"default",label:"Default Field",description:"Auto-created for ad-hoc fields without explicit definitions",primitive_type:"string",required:0,multiplicity:"single",config:null,is_system:1,ordinal:null,created_at:H,updated_at:H}).execute()},AH6=()=>{let $=new Map,K=new Map,q=async(O,w,{code:X,name:T},G)=>{let v=K4(),f=await q5.nextSeq(O,"global",null,"s"),A=`S${f}`,C=await O.insertInto("stores").values({id:f,object_id:A,type:"local",code:X,name:T,created_at:v,updated_at:v}).returningAll().executeTakeFirstOrThrow(),{store:V,mutationApi:M,id:R,pk:I}=Ox(C);return await fH6(O,w,I,X,G),G(()=>{$.set(R,l6.create(V,M,I)),K.set(I,R)}),V},Y=async(O,w,{name:X},T)=>{let G=K4(),v=await q5.nextSeq(O,"global",null,"s"),f=`S${v}`,A=await O.insertInto("stores").values({id:v,object_id:f,type:"demux",code:null,name:X,created_at:G,updated_at:G}).returningAll().executeTakeFirstOrThrow(),{store:C,mutationApi:V,id:M,pk:R}=lP8(A,[]);return T(()=>{$.set(M,l6.create(C,V,R)),K.set(R,M)}),C},z=async(O,w,X)=>{let T=$.get(X);if(T)return T.getEntity();let G=fX(X);if(G===null)return null;let v=await O.selectFrom("stores").selectAll().where("id","=",G).executeTakeFirst();if(!v)return null;let f,A,C,V;if(v.type==="local"){let M=Ox(v);f=M.store,A=M.mutationApi,C=M.id,V=M.pk}else{let M=await O.selectFrom("store_children").innerJoin("stores","stores.id","store_children.child_store_id").select(["stores.object_id"]).where("store_children.parent_store_id","=",v.id).execute(),R=[];for(let D of M){let m=await z(O,w,D.object_id);if(m)R.push(m)}let I=lP8(v,R);f=I.store,A=I.mutationApi,C=I.id,V=I.pk}return $.set(C,l6.create(f,A,V)),K.set(V,C),f};return Object.freeze({createLocalStore:q,createDemuxStore:Y,readStore:z,readSharedStore:async(O,w)=>{let X=await O.selectFrom("stores").selectAll().where("code","=","B").executeTakeFirstOrThrow(),T=wx(X),G=$.get(T);if(G)return G.getEntity();let{store:v,mutationApi:f,pk:A}=Ox(X);return $.set(T,l6.create(v,f,A)),K.set(A,T),v},readRootStoreForProject:async(O,w,X)=>{let T=X&&X.length>=2&&X[0]==="P"?parseInt(X.slice(1),10):null;Y8.factory(T===null||isNaN(T),t.validation,`Invalid project ID: ${X}`,"INVALID_PROJECT_ID");let G=await O.selectFrom("project_stores").innerJoin("stores","stores.id","project_stores.store_id").select(["stores.object_id"]).where("project_stores.project_id","=",T).where("project_stores.is_root","=",1).executeTakeFirst();return Y8.factory(!G,t.notFound,`Root store not found for project: ${X}`,"ROOT_STORE_NOT_FOUND"),await z(O,w,G.object_id)},addChildToDemux:async(O,w,{demuxId:X,childId:T},G)=>{let v=$.get(X),f=$.get(T),A,C;if(v)A=v.getPk();else{let V=fX(X);Y8.factory(V===null,t.validation,`Invalid demux store ID: ${X}`,"INVALID_ID");let M=await O.selectFrom("stores").select("id").where("id","=",V).executeTakeFirst();Y8.factory(!M,t.notFound,`Demux store not found: ${X}`,"STORE_NOT_FOUND"),A=M.id}if(f)C=f.getPk();else{let V=fX(T);Y8.factory(V===null,t.validation,`Invalid child store ID: ${T}`,"INVALID_ID");let M=await O.selectFrom("stores").select("id").where("id","=",V).executeTakeFirst();Y8.factory(!M,t.notFound,`Child store not found: ${T}`,"STORE_NOT_FOUND"),C=M.id}await O.insertInto("store_children").values({parent_store_id:A,child_store_id:C}).execute(),G(()=>{let V=$.get(X),M=$.get(T);if(V&&M)V.getMutationApi().addChild(M.getEntity())})},addStoresToProject:async(O,w,{projectId:X,rootStoreId:T,storeIds:G})=>{let v=X&&X.length>=2&&X[0]==="P"?parseInt(X.slice(1),10):null;Y8.factory(v===null||isNaN(v),t.validation,`Invalid project ID: ${X}`,"INVALID_PROJECT_ID");let f=await O.selectFrom("projects").select("id").where("id","=",v).executeTakeFirst();Y8.factory(!f,t.notFound,`Project not found: ${X}`,"PROJECT_NOT_FOUND");let A=f.id,C=$.get(T),V;if(C)V=C.getPk();else{let M=fX(T);Y8.factory(M===null,t.validation,`Invalid root store ID: ${T}`,"INVALID_ID");let R=await O.selectFrom("stores").select("id").where("id","=",M).executeTakeFirst();Y8.factory(!R,t.notFound,`Root store not found: ${T}`,"STORE_NOT_FOUND"),V=R.id}for(let M of G){let R=$.get(M),I;if(R)I=R.getPk();else{let D=fX(M);Y8.factory(D===null,t.validation,`Invalid store ID: ${M}`,"INVALID_ID");let m=await O.selectFrom("stores").select("id").where("id","=",D).executeTakeFirst();Y8.factory(!m,t.notFound,`Store not found: ${M}`,"STORE_NOT_FOUND"),I=m.id}await O.insertInto("project_stores").values({project_id:A,store_id:I,is_root:I===V?1:0}).execute()}},evictStore:(O)=>{let w=$.get(O);if(w)K.delete(w.getPk());$.delete(O)}})},FP8=Object.freeze({create:AH6});R4();R4();var VH6=({store:$})=>{let K=async(Z,O,w,X,T,G)=>{let v=w.split("/").filter((C)=>C.trim());Y8.factory(v.length===0,t.validation,"Path cannot be empty or contain only slashes","EMPTY_PATH");let f=await $.readRootFolderForType(Z,O,X,T);for(let C=0;C<v.length-1;C++){let V=HK.validateFolderName(v[C]),M=await $.findFolderByName(Z,O,f.getObjectId(),V);if(M)f=M;else f=await $.createFolder(Z,O,{storeCode:T,parentId:f.getObjectId(),name:V},G)}let A=HK.validateFolderName(v[v.length-1]);return{parentObjectId:f.getObjectId(),name:A}},q=async(Z,O,{store:w,path:X,type:T},G)=>{Y8.factory(!X||X==="/",t.validation,"Path cannot be empty","EMPTY_PATH"),Y8.factory(T!=="d"&&T!=="t",t.validation,'Type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!w,t.validation,"store is required","MISSING_STORE_CODE");let{parentObjectId:v,name:f}=await K(Z,O,X,T,w,G),A=await $.isDuplicateNameInParent(Z,O,v,f);return Y8.factory(A,t.conflict,`Folder "${f}" already exists in parent`,"DUPLICATE_NAME"),await $.createFolder(Z,O,{storeCode:w,parentId:v,name:f},G)},Y=async(Z,O,{id:w})=>{return await $.readFolder(Z,O,{id:w})};return Object.freeze({resolvePath:K,createFolder:q,readFolder:Y,renameFolder:async(Z,O,{id:w,name:X},T)=>{let G=await Y(Z,O,{id:w});Y8.factory(!G,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(G),t.validation,"Cannot rename root folder","CANNOT_RENAME_ROOT");let v=HK.validateFolderName(X),f=await $.isDuplicateNameInParent(Z,O,G.getParentId(),v,w);return Y8.factory(f,t.conflict,`Folder "${v}" already exists in parent`,"DUPLICATE_NAME"),await $.updateFolder(Z,O,{id:w,name:v},T)},moveFolder:async(Z,O,{id:w,parentId:X},T)=>{let G=await Y(Z,O,{id:w});Y8.factory(!G,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(G),t.validation,"Cannot move root folder","CANNOT_MOVE_ROOT");let v=await Y(Z,O,{id:X});Y8.factory(!v,t.notFound,`Parent folder not found: ${X}`,"PARENT_NOT_FOUND"),Y8.factory(!w||w.length<1,t.validation,"Invalid folder ID format","INVALID_ID_FORMAT"),Y8.factory(!X||X.length<1,t.validation,"Invalid parent ID format","INVALID_PARENT_ID_FORMAT");let f=w[0],A=X[0];Y8.factory(f!==A,t.validation,"Cannot move folders between stores","CROSS_STORE_MOVE"),Y8.factory(w===X,t.validation,"Cannot move folder into itself","SELF_MOVE");let C=X;while(C!==null){Y8.factory(C===w,t.validation,"Cannot move folder into its own descendant","CYCLE_DETECTED");let M=await $.readFolder(Z,O,{id:C});if(!M)break;C=M.getParentId()}let V=await $.isDuplicateNameInParent(Z,O,X,G.getName(),w);return Y8.factory(V,t.conflict,`Folder "${G.getName()}" already exists in target parent`,"DUPLICATE_NAME"),await $.updateFolder(Z,O,{id:w,parentId:X},T)},deleteFolder:async(Z,O,{id:w},X)=>{let T=await Y(Z,O,{id:w});return Y8.factory(!T,t.notFound,`Folder not found: ${w}`,"FOLDER_NOT_FOUND"),Y8.factory(HK.isRootFolder(T),t.validation,"Cannot delete root folder","CANNOT_DELETE_ROOT"),await $.deleteFolder(Z,O,{id:w},X)},getFolderByPath:async(Z,O,{path:w,type:X,storeCode:T})=>{return await $.getFolderByPath(Z,O,{path:w,type:X,storeCode:T})},listFolderContents:async(Z,O,{folderId:w,type:X,storeCode:T})=>{return await $.listFolderContents(Z,O,{folderId:w,type:X,storeCode:T})}})},iP8=Object.freeze({create:VH6});R4();var kH6=({store:$})=>{let K=async(W,H,{store:Z,ownerEntityId:O,name:w,label:X,description:T,primitiveType:G,required:v,multiplicity:f,isSystem:A=!1},C)=>{Y8.factory(!Z,t.validation,"store is required","MISSING_STORE_CODE"),Y8.factory(G!=="string"&&G!=="object_ref",t.validation,`Invalid primitiveType: ${G}. Must be 'string' or 'object_ref'`,"INVALID_PRIMITIVE_TYPE"),Y8.factory(f!=="single"&&f!=="multi",t.validation,`Invalid multiplicity: ${f}. Must be 'single' or 'multi'`,"INVALID_MULTIPLICITY");let V=/^[a-zA-Z0-9_]+$/;return Y8.factory(!w||!V.test(w),t.validation,`Invalid name: ${w}. Must contain only alphanumeric characters and underscores`,"INVALID_NAME"),await $.createFieldDefinition(W,H,{storeCode:Z,ownerEntityId:O,name:w,label:X,description:T,primitiveType:G,required:v,multiplicity:f,isSystem:A},C)},q=async(W,H,{id:Z})=>{return Y8.factory(!Z||Z.length<3,t.validation,"Invalid field definition ID","INVALID_ID"),await $.readFieldDefinition(W,H,{id:Z})};return Object.freeze({createFieldDefinition:K,readFieldDefinition:q,getFieldDefinitionsForOwner:async(W,H,{store:Z,ownerEntityId:O,includeSystem:w=!0})=>{Y8.factory(!Z,t.validation,"store is required","MISSING_STORE_CODE");let X=null;if(O)X=null;return await $.getFieldDefinitionsForOwner(W,H,{storeCode:Z,ownerEntityPk:X,includeSystem:w})},deleteFieldDefinition:async(W,H,{id:Z},O)=>{let w=await q(W,H,{id:Z});return Y8.factory(!w,t.notFound,`Field definition not found: ${Z}`,"DEFINITION_NOT_FOUND"),Y8.factory(w.getIsSystem(),t.validation,`Cannot delete system field definition: ${Z}`,"SYSTEM_DEFINITION"),await $.deleteFieldDefinition(W,H,{id:Z},O)},setFieldValue:async(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w,value:X,values:T},G)=>{return Y8.factory(!Z,t.validation,"entityId is required","MISSING_ENTITY_ID"),Y8.factory(!O&&!w,t.validation,"Either fieldDefinitionId or fieldName must be provided","MISSING_FIELD_IDENTIFIER"),Y8.factory(X!==void 0&&T!==void 0,t.validation,"Cannot provide both value and values","AMBIGUOUS_VALUE"),Y8.factory(X===void 0&&T===void 0,t.validation,"Either value or values must be provided","MISSING_VALUE"),await $.setFieldValue(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w,value:X,values:T},G)},deleteFieldValue:async(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w},X)=>{return Y8.factory(!Z,t.validation,"entityId is required","MISSING_ENTITY_ID"),Y8.factory(!O&&!w,t.validation,"Either fieldDefinitionId or fieldName must be provided","MISSING_FIELD_IDENTIFIER"),await $.deleteFieldValue(W,H,{entityId:Z,fieldDefinitionId:O,fieldName:w},X)}})},QP8=Object.freeze({create:kH6});R4();var MH6=($)=>{let K=$.split("/").filter((z)=>z.trim()),q=K[K.length-1];return{parentPath:K.slice(0,-1).join("/")||null,name:q,segments:K}},NH6=($)=>{return $[0]},AX=Object.freeze({parsePath:MH6,extractStoreCode:NH6});var hH6=({store:$,folderService:K,documentHooks:q})=>{let Y=(M)=>{return M==="t"?"Template":"Document"},z=async(M,R,I,D,m,b)=>{if(I){let h=await K.resolvePath(M,R,I,D,m,b),L=await $.findFolderByName(M,R,h.parentObjectId,h.name);if(L)return L.getObjectId();else return(await $.createFolder(M,R,{storeCode:m,parentId:h.parentObjectId,name:h.name},b)).getObjectId()}else return(await $.readRootFolderForType(M,R,D,m)).getObjectId()},P=async(M,R,{store:I,path:D,type:m,content:b},h)=>{Y8.factory(m!=="d"&&m!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!D||D==="/",t.validation,"Path cannot be empty","EMPTY_PATH"),Y8.factory(!I,t.validation,"store is required","MISSING_STORE_CODE");let{parentPath:L,name:B}=AX.parsePath(D),i=await z(M,R,L,m,I,h),X8=Y(m),N8=await $.findContentByName(M,R,i,B,m);return Y8.factory(N8,t.conflict,`${X8} "${B}" already exists in folder`,"DUPLICATE_NAME"),await $.createContent(M,R,{storeCode:I,type:m,parentId:i,name:B,initialContent:b},h)},J=async(M,R,{id:I})=>{let{typeCode:D}=m1.resolveEntityId(I),m=Y(D),b=await $.readContent(M,R,{id:I});return Y8.factory(!b,t.notFound,`${m} not found: ${I}`,"NOT_FOUND"),b};return Object.freeze({createDocument:P,readDocument:J,readDocumentByPath:async(M,R,{path:I,type:D,storeCode:m})=>{Y8.factory(D!=="d"&&D!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE");let{parentPath:b,name:h}=AX.parsePath(I),L;if(b){let B=await $.getFolderByPath(M,R,{path:b,type:D,storeCode:m});if(!B)return null;L=B.getObjectId()}else L=(await $.readRootFolderForType(M,R,D,m)).getObjectId();return await $.findContentByName(M,R,L,h,D)},updateDocumentPath:async(M,R,{id:I,path:D,type:m},b)=>{Y8.factory(m!=="d"&&m!=="t",t.validation,'type must be "d" or "t"',"INVALID_TYPE"),Y8.factory(!D||D==="/",t.validation,"Path cannot be empty","EMPTY_PATH");let h=await J(M,R,{id:I}),{parentPath:L,name:B}=AX.parsePath(D),i=AX.extractStoreCode(I),X8=await z(M,R,L,m,i,b),N8=B!==h.getName(),h8=X8!==h.getParentId();if(!N8&&!h8)return h;if(N8||h8){let c8=Y(m),E8=await $.findContentByName(M,R,X8,B,m);Y8.factory(E8&&E8.getObjectId()!==I,t.conflict,`${c8} "${B}" already exists in target folder`,"DUPLICATE_NAME")}return await $.updateContent(M,R,{id:I,name:N8?B:void 0,parentId:h8?X8:void 0},b)},deleteDocument:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.deleteContent(M,R,{id:I},D)},saveDraft:async(M,R,{id:I,content:D,clientId:m},b)=>{return await J(M,R,{id:I}),await $.saveDraft(M,R,{id:I,content:D,clientId:m},b)},readDraft:async(M,R,{id:I})=>{let{typeCode:D}=m1.resolveEntityId(I);await J(M,R,{id:I});let m=Y(D),b=await $.readDraft(M,R,{id:I});return Y8.factory(!b,t.notFound,`No draft found for ${m}: ${I}`,"DRAFT_NOT_FOUND"),b},publishDocument:async(M,R,{id:I},D)=>{await J(M,R,{id:I});let{typeCode:m}=m1.resolveEntityId(I),b=await $.publishContent(M,R,{id:I},D),h=q.getHook("prePublish",m);if(h){let L=await J(M,R,{id:I});await h(M,R,L)}return b},discardDraft:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.discardDraft(M,R,{id:I},D)},readVersion:async(M,R,{id:I,versionNumber:D})=>{let{typeCode:m}=m1.resolveEntityId(I);await J(M,R,{id:I});let b=Y(m),h=await $.readVersion(M,R,{id:I,versionNumber:D});return Y8.factory(!h,t.notFound,`Version ${D} not found for ${b}: ${I}`,"VERSION_NOT_FOUND"),h},getVersions:async(M,R,{id:I})=>{return await J(M,R,{id:I}),await $.getVersions(M,R,{id:I})},setEditState:async(M,R,{id:I,clientId:D},m)=>{return await J(M,R,{id:I}),await $.setEditState(M,R,{id:I,clientId:D},m)},clearEditState:async(M,R,{id:I},D)=>{return await J(M,R,{id:I}),await $.clearEditState(M,R,{id:I},D)},getEditState:async(M,R,{id:I})=>{return await J(M,R,{id:I}),await $.getEditState(M,R,{id:I})},listDocuments:async(M,R,{parentId:I,storeCode:D,type:m="d"})=>{return await $.listContent(M,R,{parentId:I,storeCode:D,type:m})}})},dP8=Object.freeze({create:hH6});var GO8=K1(OH8(),1),_O8=K1(kb(),1),fO8=($)=>{if(!$)return{parameters:{},target:null,targetPath:null,body:""};let K=GO8.default($),q=K.data?.parameters||{},Y=K.data?.target||null,z=K.data?.targetPath||null,P=K.content;return{parameters:q,target:Y,targetPath:z,body:P}},O_6=($)=>{if(!$)return new Set;let K=new Set,q=new Set(["if","unless","each","with","lookup","log"]);try{let Y=_O8.default.parse($),z=(P,J=null,W=null)=>{if(!P)return;if(P.type==="PathExpression"){if(P.data)return;let H=P.parts.join(".");if(!H||H.startsWith("@"))return;if(J?.type==="BlockStatement"&&W==="path"||J?.type==="MustacheStatement"&&W==="path"&&J.params?.length>0){if(q.has(H))return;return}K.add(H)}if(P.program)z(P.program,P,"program");if(P.inverse)z(P.inverse,P,"inverse");if(P.body)P.body.forEach((H)=>z(H,P,"body"));if(P.params)P.params.forEach((H)=>z(H,P,"params"));if(P.hash?.pairs)P.hash.pairs.forEach((H)=>z(H.value,P,"hash"));if(P.path)z(P.path,P,"path")};z(Y)}catch(Y){throw new Error(`Invalid Handlebars template: ${Y.message}`)}return K},w_6=($)=>{if(!$)return{parameters:{},target:null,targetPath:null};let{parameters:K,target:q,targetPath:Y}=fO8($);return{parameters:K,target:q,targetPath:Y}},M$=Object.freeze({parseFrontMatter:fO8,extractVariables:O_6,getParameters:w_6});R4();var X_6=async($,K,q,Y)=>{try{let z=typeof q.getPublishedContent==="function"?q.getPublishedContent():q.publishedContent,{parameters:P}=M$.parseFrontMatter(z||"");if(!P||Object.keys(P).length===0)return;let J=typeof q.getObjectId==="function"?q.getObjectId():q.id,W=J[0];for(let[H,Z]of Object.entries(P)){let O=Z.type||"string",w=Z.required||!1,X=Z.description||null,T=Z.label||H,G="single";if(O!=="string"&&O!=="object_ref"){console.warn(`Invalid parameter type "${O}" for parameter "${H}" in template ${J}. Defaulting to "string".`);continue}try{await Y.createFieldDefinition($,K,{store:W,ownerEntityId:J,name:H,label:T,description:X,primitiveType:O,required:w,multiplicity:"single",isSystem:!1},()=>{})}catch(v){if(v.code==="DUPLICATE_FIELD_DEFINITION"||v.message?.includes("unique"))console.warn(`Field definition "${H}" already exists for template ${J}. Skipping.`);else console.error(`Failed to create field definition for parameter "${H}" in template ${J}:`,v)}}}catch(z){let P=typeof q.getObjectId==="function"?q.getObjectId():q.id;console.error(`Template publish hook failed for ${P}:`,z)}},T_6=({fieldService:$})=>{let K={prePublish:{d:null,t:(Y,z,P)=>X_6(Y,z,P,$)},postPublish:{},preDelete:{},postCreate:{}};return Object.freeze({getHook:(Y,z)=>{return K[Y]?.[z]||null}})},AO8=Object.freeze({create:T_6});R4();var Mb=K1(kb(),1),j_6=($={})=>{return Object.freeze({renderTemplate:(Y,z={})=>{if(!Y)throw t.validation("Template content cannot be empty","EMPTY_TEMPLATE");let{body:P}=M$.parseFrontMatter(Y),J;try{J=Mb.default.compile(P,{noEscape:!0})(z)}catch(W){throw t.validation(`Failed to render template: ${W.message}`,"RENDER_ERROR")}return J},extractTemplateParameters:(Y)=>{if(!Y)return{parameters:{},detectedVariables:[],target:null,targetPath:null};let{parameters:z,target:P,targetPath:J,body:W}=M$.parseFrontMatter(Y),H=M$.extractVariables(W),Z=Array.from(H);return{parameters:z,detectedVariables:Z,target:P,targetPath:J}}})},VO8=Object.freeze({create:j_6});import pX from"node:fs";import kO8 from"node:os";import cf from"node:path";var v_6=({projectStore:$,storeStore:K})=>{return Object.freeze({createProject:async(P,J,{name:W,path:H},Z)=>{if(await $.readProjectByPath(P,J,H)){let v=new Error("Project with this path already exists");throw v.code="DUPLICATE_PATH",v}let w=await $.createProject(P,J,{name:W,path:H},Z),X=await K.createLocalStore(P,J,{code:"A",name:"Project"},Z);await X.createFolder(P,J,{parentId:null,name:null,subtype:"root_d"},Z),await X.createFolder(P,J,{parentId:null,name:null,subtype:"root_t"},Z);let T=await K.readSharedStore(P,J),G=await K.createDemuxStore(P,J,{name:W},Z);return await K.addChildToDemux(P,J,{demuxId:G.getObjectId(),childId:X.getObjectId()},Z),await K.addChildToDemux(P,J,{demuxId:G.getObjectId(),childId:T.getObjectId()},Z),await K.addStoresToProject(P,J,{projectId:w.getObjectId(),rootStoreId:G.getObjectId(),storeIds:[G.getObjectId(),X.getObjectId(),T.getObjectId()]}),w},validateProjectPath:(P)=>{if(!P||typeof P!=="string"){let X=new Error("Path is required and must be a non-empty string");throw X.code="VALIDATION_ERROR",X}let J;if(P==="~")J=kO8.homedir();else if(P.startsWith("~/"))J=cf.join(kO8.homedir(),P.slice(2));else J=P;let W=pX.existsSync(J),H=!1,Z=!1,O=!1;if(W)try{if(H=pX.statSync(J).isDirectory(),H){let T=cf.join(J,".git");try{Z=pX.statSync(T).isDirectory()}catch{Z=!1}let G=cf.join(J,".claude");try{O=pX.statSync(G).isDirectory()}catch{O=!1}}}catch(X){H=!1}let w=cf.basename(J);return{path:J,exists:W,isDirectory:H,hasGit:Z,hasClaude:O,suggestedName:w}},listProjects:async(P)=>{let J=await P.selectFrom("projects").selectAll().where("name","!=","__system__").orderBy("created_at","desc").execute();return await Promise.all(J.map(async(H)=>{let O=(await P.selectFrom("project_stores").innerJoin("stores","stores.id","project_stores.store_id").select(["stores.object_id","stores.code","stores.name","stores.type"]).where("project_stores.project_id","=",H.id).where("stores.type","=","local").execute()).map((w)=>({id:w.code==="B"?"store:B":`store:${w.code}:${H.object_id}`,code:w.code,name:w.name}));return{objectId:H.object_id,name:H.name,path:H.path,createdAt:H.created_at,updatedAt:H.updated_at,children:O}}))}})},Bf=Object.freeze({create:v_6});var G_6=()=>{let $=[];return{enqueuePostCommitHook:(K)=>{$.push(K)},flush:()=>{for(let K of $)try{K()}catch(q){console.error("Post-commit hook failed:",q)}}}},__6=({db:$,folderService:K,fieldService:q,documentService:Y,templateService:z,projectService:P,clipboardService:J})=>{let W=async(h)=>{let L=G_6(),B;return await $.transaction().execute(async(i)=>{B=await h(i,L.enqueuePostCommitHook)}),L.flush(),B};return Object.freeze({createFolder:async(h,{store:L,path:B,type:i})=>{return W(async(X8,N8)=>{return await K.createFolder(X8,h,{store:L,path:B,type:i},N8)})},renameFolder:async(h,{id:L,name:B})=>{return W(async(i,X8)=>{return await K.renameFolder(i,h,{id:L,name:B},X8)})},moveFolder:async(h,{id:L,parentId:B})=>{return W(async(i,X8)=>{return await K.moveFolder(i,h,{id:L,parentId:B},X8)})},deleteFolder:async(h,{id:L})=>{return W(async(B,i)=>{return await K.deleteFolder(B,h,{id:L},i)})},createProject:async(h,{name:L,path:B})=>{return W(async(i,X8)=>{return await P.createProject(i,h,{name:L,path:B},X8)})},createFieldDefinition:async(h,{store:L,ownerEntityId:B,name:i,label:X8,description:N8,primitiveType:h8,required:c8,multiplicity:E8,isSystem:g8})=>{return W(async(t8,V4)=>{return await q.createFieldDefinition(t8,h,{store:L,ownerEntityId:B,name:i,label:X8,description:N8,primitiveType:h8,required:c8,multiplicity:E8,isSystem:g8},V4)})},setFieldValue:async(h,{entityId:L,fieldDefinitionId:B,fieldName:i,value:X8,values:N8})=>{return W(async(h8,c8)=>{return await q.setFieldValue(h8,h,{entityId:L,fieldDefinitionId:B,fieldName:i,value:X8,values:N8},c8)})},deleteFieldValue:async(h,{entityId:L,fieldDefinitionId:B,fieldName:i})=>{return W(async(X8,N8)=>{return await q.deleteFieldValue(X8,h,{entityId:L,fieldDefinitionId:B,fieldName:i},N8)})},deleteFieldDefinition:async(h,{id:L})=>{return W(async(B,i)=>{return await q.deleteFieldDefinition(B,h,{id:L},i)})},createDocument:async(h,{store:L,path:B,type:i,content:X8})=>{return W(async(N8,h8)=>{return await Y.createDocument(N8,h,{store:L,path:B,type:i,content:X8},h8)})},updateDocumentPath:async(h,{id:L,path:B,type:i})=>{return W(async(X8,N8)=>{return await Y.updateDocumentPath(X8,h,{id:L,path:B,type:i},N8)})},deleteDocument:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.deleteDocument(B,h,{id:L},i)})},saveDraft:async(h,{id:L,content:B,clientId:i})=>{return W(async(X8,N8)=>{return await Y.saveDraft(X8,h,{id:L,content:B,clientId:i},N8)})},publishDocument:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.publishDocument(B,h,{id:L},i)})},discardDraft:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.discardDraft(B,h,{id:L},i)})},setEditState:async(h,{id:L,clientId:B})=>{return W(async(i,X8)=>{return await Y.setEditState(i,h,{id:L,clientId:B},X8)})},clearEditState:async(h,{id:L})=>{return W(async(B,i)=>{return await Y.clearEditState(B,h,{id:L},i)})},renderTemplate:async(h,{id:L,params:B,target:i,targetOptions:X8})=>{let N8=await Y.readDocument($,h,{id:L});if(!N8.getPublishedContent())throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("Template has no published content","NO_PUBLISHED_CONTENT");let{target:h8,targetPath:c8}=z.extractTemplateParameters(N8.getPublishedContent()),E8=i||h8||"stdout",g8=X8||{},t8=g8.path||c8,V4=z.renderTemplate(N8.getPublishedContent(),B||{});switch(E8){case"stdout":return{content:V4,target:"stdout"};case"clipboard":return await J.copyToClipboard(V4),{target:"clipboard",message:"Copied to clipboard"};case"document":return W(async(r,a)=>{if(!t8)throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("targetOptions.path is required for document target","MISSING_TARGET_PATH");let s=await Y.createDocument(r,h,{store:"A",path:t8,type:"d",content:V4},a);if(g8.publish)await Y.publishDocument(r,h,{id:s.getObjectId()},a);return{content:V4,target:"document",documentId:s.getObjectId(),documentPath:t8,published:!!g8.publish}});case"file":throw(await Promise.resolve().then(() => (R4(),_X))).default.validation("file target not yet implemented","NOT_IMPLEMENTED");default:throw(await Promise.resolve().then(() => (R4(),_X))).default.validation(`Unknown target: ${E8}`,"INVALID_TARGET")}}})},Nb=Object.freeze({create:__6});var IE8=K1(SE8(),1),xE8=K1(X$(),1);R4();import q$ from"fs/promises";import Y$ from"path";import{createWriteStream as yr6}from"fs";import ur6 from"crypto";var uK=xE8.default("caw:export"),EE8=".caw-exports",LE8=".tmp",mr6=1,pr6=({store:$,folderService:K,documentService:q,templateService:Y})=>{let z=()=>{let T=new Date,G=T.getFullYear(),v=String(T.getMonth()+1).padStart(2,"0"),f=String(T.getDate()).padStart(2,"0"),A=String(T.getHours()).padStart(2,"0"),C=String(T.getMinutes()).padStart(2,"0"),V=String(T.getSeconds()).padStart(2,"0");return`${G}-${v}-${f}-${A}${C}${V}`},P=async(T)=>{let G=Y$.join(T,EE8),v=Y$.join(G,LE8);try{return await q$.mkdir(G,{recursive:!0}),await q$.mkdir(v,{recursive:!0}),G}catch(f){if(f.code==="EACCES")throw t.validation("Permission denied creating export directory","EXPORT_ERROR");if(f.code==="ENOSPC")throw t.validation("Insufficient disk space","EXPORT_ERROR");throw uK("Error creating export directory: [%s] %s",f.code||"UNKNOWN",f.message),t.validation(`Failed to create export directory: ${f.message} (${f.code||"UNKNOWN"})`,"EXPORT_ERROR")}},J=async(T,G,v,f)=>{let A=[],C=async(V,M)=>{let R=await K.listFolderContents(T,G,{folderId:V,type:v,storeCode:f});for(let I of R)if(I.getParentId()!==null)A.push({entity:I,depth:M,contentType:v}),await C(I.getObjectId(),M+1)};return await C(null,0),A},W=async(T,G,v)=>{let f=[],A=[],C=async(V)=>{let M=await q.listDocuments(T,G,{parentId:V,storeCode:v});for(let I of M){let D=I.getPublishedVersionNumber();if(D!==null){let m=await q.readVersion(T,G,{id:I.getObjectId(),versionNumber:D});f.push({entity:I,version:m})}else A.push(I)}let R=await K.listFolderContents(T,G,{folderId:V,type:"d",storeCode:v});for(let I of R)await C(I.getObjectId())};return await C(null),{published:f,draftOnly:A}},H=async(T,G,v)=>{let f=[],A=[],C=async(V)=>{let M=await q.listDocuments(T,G,{parentId:V,storeCode:v,type:"t"});for(let I of M){let D=I.getPublishedVersionNumber();if(D!==null){let m=await q.readVersion(T,G,{id:I.getObjectId(),versionNumber:D});f.push({entity:I,version:m})}else A.push(I)}let R=await K.listFolderContents(T,G,{folderId:V,type:"t",storeCode:v});for(let I of R)await C(I.getObjectId())};return await C(null),{published:f,draftOnly:A}},Z=async(T)=>{try{await q$.rm(T,{recursive:!0,force:!0})}catch(G){uK("Warning: Failed to cleanup temp directory: %s",G.message)}};return Object.freeze({listExports:async(T,G,{projectPath:v})=>{let f=Y$.join(v,EE8);try{let A=await q$.readdir(f),C=[];for(let V of A)if(V.endsWith(".zip")){let M=Y$.join(f,V),R=await q$.stat(M);C.push({filename:V,timestamp:R.mtime.toISOString(),size:R.size})}return uK("Found %d export files",C.length),C}catch(A){if(A.code==="ENOENT")return[];throw A}},exportPreview:async(T,G,{storeCode:v})=>{let f=await J(T,G,"d",v),A=await J(T,G,"t",v),{published:C,draftOnly:V}=await W(T,G,v),{published:M,draftOnly:R}=await H(T,G,v),I={folders:[...f,...A].map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()})),documents:C.map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()})),templates:M.map((h)=>({id:h.entity.getObjectId(),path:h.entity.getPath(),name:h.entity.getName()}))},D={documents:V.map((h)=>({id:h.getObjectId(),path:h.getPath(),name:h.getName()})),templates:R.map((h)=>({id:h.getObjectId(),path:h.getPath(),name:h.getName()}))},m=I.folders.length+I.documents.length+I.templates.length,b=D.documents.length+D.templates.length;return uK("Preview: %d published, %d draft-only",m,b),{toExport:I,draftOnly:D}},exportDocuments:async(T,G,{storeCode:v,projectPath:f})=>{uK("Starting export for store %s",v);let A=await P(f),C=ur6.randomUUID(),V=Y$.join(A,LE8,C);await q$.mkdir(V,{recursive:!0});try{let M=await J(T,G,"d",v),R=await J(T,G,"t",v),I=[...M,...R],{published:D,draftOnly:m}=await W(T,G,v),{published:b,draftOnly:h}=await H(T,G,v);uK("Found %d folders, %d documents, %d templates",I.length,D.length,b.length);let L=[...I.map((E8)=>({id:E8.entity.getObjectId(),type:"folder",path:E8.entity.getPath(),contentType:E8.contentType})),...D.map((E8)=>({id:E8.entity.getObjectId(),type:"document",path:E8.entity.getPath()})),...b.map((E8)=>({id:E8.entity.getObjectId(),type:"template",path:E8.entity.getPath()}))],B={version:mr6,exportedAt:new Date().toISOString(),entities:L};await q$.writeFile(Y$.join(V,"manifest.json"),JSON.stringify(B,null,2),"utf-8");for(let E8 of I){let g8=E8.contentType==="d"?"documents":"templates",t8=Y$.join(V,g8,E8.entity.getPath());await q$.mkdir(t8,{recursive:!0})}await q$.mkdir(Y$.join(V,"documents"),{recursive:!0}),await q$.mkdir(Y$.join(V,"templates"),{recursive:!0});for(let E8 of D){let g8=Y$.join(V,"documents",E8.entity.getPath()),t8=E8.version.content;await q$.mkdir(Y$.dirname(g8),{recursive:!0}),await q$.writeFile(g8,t8,"utf-8")}for(let E8 of b){let g8=Y$.join(V,"templates",E8.entity.getPath()),t8=E8.version.content;await q$.mkdir(Y$.dirname(g8),{recursive:!0}),await q$.writeFile(g8,t8,"utf-8")}for(let E8 of L)if(E8.type!=="folder"){let g8=E8.type==="document"?"documents":"templates",t8=Y$.join(V,g8,E8.path);try{await q$.access(t8)}catch(V4){throw t.validation(`Manifest entry missing file: ${E8.path}`,"EXPORT_VALIDATION_FAILED")}}let i=`caw-export-${z()}.zip`,X8=Y$.join(A,i),N8=yr6(X8),h8=IE8.default("zip",{zlib:{level:9}});h8.on("error",async(E8)=>{throw await Z(V),uK("Zip creation error: %s",E8.message),t.validation(`Export failed: ${E8.message}`,"EXPORT_ERROR")}),h8.pipe(N8),h8.directory(V,!1),await h8.finalize(),await new Promise((E8,g8)=>{N8.on("close",E8),N8.on("error",g8),setTimeout(()=>{g8(new Error("Zip creation timeout"))},60000)}),uK("Created zip: %s (%d bytes)",i,h8.pointer()),await Z(V);let c8=L.length;return uK("Export complete: %s (%d entities)",i,c8),{success:!0,filename:i,path:X8,counts:{folders:I.length,documents:D.length,templates:b.length},draftOnlySkipped:{documents:m.length,templates:h.length}}}catch(M){throw await Z(V),M}}})},bE8=Object.freeze({create:pr6});var jL8=K1(XL8(),1),vL8=K1(X$(),1);R4();import s2 from"fs/promises";import jY from"path";import ws6 from"crypto";var V1=vL8.default("caw:import"),HB=".caw-exports",TL8=".tmp",Xs6=1,Ts6=/\b([A-Z][dtfn]\d+)\b/g,js6=({store:$,folderService:K,documentService:q,templateService:Y})=>{let z=(Z,O)=>{if(!Z)return Z;return Z.replace(Ts6,(w,X)=>{return O[X]??w})},P=async(Z)=>{try{await s2.rm(Z,{recursive:!0,force:!0})}catch(O){V1("Warning: Failed to cleanup temp directory: %s",O.message)}},J=async(Z,O,{storeCode:w})=>{let X=await K.listFolderContents(Z,O,{folderId:null,type:"d",storeCode:w}),T=await K.listFolderContents(Z,O,{folderId:null,type:"t",storeCode:w}),G=await q.listDocuments(Z,O,{parentId:null,storeCode:w,type:"d"}),v=await q.listDocuments(Z,O,{parentId:null,storeCode:w,type:"t"}),f=X.length===0&&T.length===0&&G.length===0&&v.length===0;return V1("Store %s empty check: %s",w,f),f},W=async(Z,O,{manifest:w,tempPath:X,storeCode:T})=>{return V1("Starting transaction..."),await Z.transaction().execute(async(G)=>{let v={},f=(m)=>{},A=w.entities.filter((m)=>m.type==="folder");V1("Phase 1: Creating %d folders",A.length);for(let m of A){let b=m.contentType||"d",h=await K.createFolder(G,O,{store:T,path:m.path,type:b},f);v[m.id]=h.getObjectId()}V1("Phase 1 complete - created %d folders",A.length);let C=w.entities.filter((m)=>m.type==="document"),V=[];V1("Phase 2: Reading %d documents",C.length);for(let m of C){let b=jY.join(X,"documents",m.path),h=await s2.readFile(b,"utf-8");V.push({oldId:m.id,path:m.path,content:h})}V1("Phase 2 complete - read %d documents",V.length),V1("Phase 3: Creating %d document entities",V.length);let M=[];for(let m of V){let b=await q.createDocument(G,O,{store:T,path:m.path,type:"d"},f);v[m.oldId]=b.getObjectId(),M.push({document:b,originalContent:m.content})}V1("Phase 3 complete - created %d document entities",M.length);let R=w.entities.filter((m)=>m.type==="template"),I=[];V1("Phase 4: Reading %d templates",R.length);for(let m of R){let b=jY.join(X,"templates",m.path),h=await s2.readFile(b,"utf-8");I.push({oldId:m.id,path:m.path,content:h})}V1("Phase 4 complete - read %d templates",I.length),V1("Phase 5: Creating %d template entities",I.length);let D=[];for(let m of I){let b=await q.createDocument(G,O,{store:T,path:m.path,type:"t"},f);v[m.oldId]=b.getObjectId(),D.push({template:b,originalContent:m.content})}V1("Phase 5 complete - created %d template entities",D.length),V1("Phase 6: Remapping and saving content for %d documents",M.length);for(let{document:m,originalContent:b}of M){let h=z(b,v);await q.saveDraft(G,O,{id:m.getObjectId(),content:h,clientId:"import-service"},f),await q.publishDocument(G,O,{id:m.getObjectId()},f)}V1("Phase 6 complete - saved and published %d documents",M.length),V1("Phase 7: Remapping and saving content for %d templates",D.length);for(let{template:m,originalContent:b}of D){let h=z(b,v);await q.saveDraft(G,O,{id:m.getObjectId(),content:h,clientId:"import-service"},f),await q.publishDocument(G,O,{id:m.getObjectId()},f)}return V1("Phase 7 complete - saved and published %d templates",D.length),V1("Transaction committed successfully"),{success:!0,counts:{folders:A.length,documents:M.length,templates:D.length},remapped:v}})};return Object.freeze({isStoreEmpty:J,importDocuments:async(Z,O,{filename:w,storeCode:X,projectPath:T})=>{V1("Starting import from %s to store %s",w,X);let G=jY.join(T,HB,w);try{await s2.access(G),V1("Zip file found: %s",G)}catch(V){throw t.notFound(`Export file not found: ${w}`,"EXPORT_NOT_FOUND")}V1("Validating zip and manifest...");let v=await J(Z,O,{storeCode:X});if(!v)throw t.conflict("Store not empty - import requires empty store","STORE_NOT_EMPTY");V1("Store empty check: %s",v);let f=ws6.randomUUID(),A=jY.join(T,HB,TL8,f),C=jY.join(T,HB,TL8);await s2.mkdir(C,{recursive:!0});try{new jL8.default(G).extractAllTo(A,!0),V1("Extracted zip to: %s",A)}catch(V){throw t.validation("Corrupted or invalid zip file","IMPORT_VALIDATION_FAILED")}try{let V=jY.join(A,"manifest.json"),M;try{let D=await s2.readFile(V,"utf-8");M=JSON.parse(D)}catch(D){throw t.validation(`Failed to read manifest: ${D.message}`,"MANIFEST_READ_FAILED")}if(M.version!==Xs6)throw t.validation(`Unsupported manifest version: ${M.version}`,"UNSUPPORTED_VERSION");if(!M.entities||!Array.isArray(M.entities))throw t.validation("Invalid manifest structure","MANIFEST_READ_FAILED");V1("Manifest valid: version=%d, entities=%d",M.version,M.entities.length);for(let D of M.entities)if(D.type!=="folder"){let m=D.type==="document"?jY.join(A,"documents",D.path):jY.join(A,"templates",D.path);try{await s2.access(m)}catch(b){throw t.validation(`Missing file for manifest entry: ${D.path}`,"IMPORT_VALIDATION_FAILED")}}V1("All content files validated");let R=await W(Z,O,{manifest:M,tempPath:A,storeCode:X}),I=R.counts.folders+R.counts.documents+R.counts.templates;return V1("Import complete: %d entities imported",I),R}finally{await P(A)}}})},GL8=Object.freeze({create:js6});var vs6=($)=>{let{name:K,interval:q,execute:Y}=$,z=null,P=!1,J=null,W=null,H=0,Z=null,A=Object.freeze({getName:()=>K,getInterval:()=>q,getIsRunning:()=>P,getLastRun:()=>J,getLastError:()=>W,getRunCount:()=>H,getNextRun:()=>Z}),C=async()=>{try{await Y(),J=new Date().toISOString(),W=null,H++}catch(D){console.error(`[CronJob] ${K} failed:`,D),W={message:D.message,timestamp:new Date().toISOString()}}if(P)Z=new Date(Date.now()+q).toISOString()},V=()=>{if(z!==null)return;z=setInterval(C,q),P=!0,Z=new Date(Date.now()+q).toISOString()},M=()=>{if(z===null)return;clearInterval(z),z=null,P=!1,Z=null},I=Object.freeze({start:V,stop:M,restart:()=>{M(),V()}});return{jobFns:A,controlFns:I}},OM=Object.freeze({create:vs6});var _L8=K1(X$(),1),Gs6=_L8.default("caw:cron:cleanup-edit-states"),fL8=async($)=>{let K=new Date(Date.now()-PW).toISOString();try{let q=await $.deleteFrom("document_edit_state").where("last_activity_at","<",K).execute(),Y=Number(q[0]?.numDeletedRows??0);if(Y>0)Gs6("Cleaned up %d expired edit locks (older than %d minutes)",Y,PW/60000);return{expired:Y}}catch(q){throw console.error("[Cleanup] Failed to cleanup expired edit locks:",q),q}};var _s6=({db:$})=>{let{jobFns:K,controlFns:q}=OM.create({name:"cleanup-stale-edit-states",interval:900000,execute:async()=>{await fL8($)}});return{job:Object.freeze(K),control:q}},AL8=Object.freeze({create:_s6});var fs6=({db:$})=>{let K=new Map,q=(Z,O)=>{let{job:w,control:X}=Z.create(O);K.set(w.getName(),{job:w,control:X})},Y=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);let w=O.job.getIsRunning();return O.control.start(),{name:Z,status:w?"already-running":"started",isRunning:O.job.getIsRunning()}},z=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);let w=O.job.getIsRunning();return O.control.stop(),{name:Z,status:w?"stopped":"already-stopped",isRunning:O.job.getIsRunning()}},P=(Z)=>{let O=K.get(Z);if(!O)throw new Error(`Job not found: ${Z}`);return O.control.restart(),{name:Z,status:"restarted",isRunning:O.job.getIsRunning()}},J=()=>{let Z=[];for(let[O,{job:w}]of K.entries())Z.push({name:w.getName(),interval:w.getInterval(),isRunning:w.getIsRunning(),lastRun:w.getLastRun(),lastError:w.getLastError(),runCount:w.getRunCount(),nextRun:w.getNextRun()});return Z},W=()=>{for(let[Z,{control:O}]of K.entries())O.start()},H=()=>{for(let[Z,{control:O}]of K.entries())O.stop()};return q(AL8,{db:$}),Object.freeze({register:q,start:Y,stop:z,restart:P,list:J,startAll:W,stopAll:H})},VL8=Object.freeze({create:fs6});import Ku8 from"node:process";import NL8 from"node:process";import Ns6 from"node:os";import hs6 from"node:fs";import ks6 from"node:fs";import kL8 from"node:fs";var ZB;function As6(){try{return kL8.statSync("/.dockerenv"),!0}catch{return!1}}function Vs6(){try{return kL8.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function OB(){if(ZB===void 0)ZB=As6()||Vs6();return ZB}var wB,Ms6=()=>{try{return ks6.statSync("/run/.containerenv"),!0}catch{return!1}};function wM(){if(wB===void 0)wB=Ms6()||OB();return wB}var ML8=()=>{if(NL8.platform!=="linux")return!1;if(Ns6.release().toLowerCase().includes("microsoft")){if(wM())return!1;return!0}try{return hs6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!wM():!1}catch{return!1}},hL8=NL8.env.__IS_WSL_TEST__?ML8:ML8();import XB from"node:process";function TB(){if(XB.platform!=="linux")return!1;if(XB.env.WAYLAND_DISPLAY)return!0;if(XB.env.XDG_SESSION_TYPE==="wayland")return!0;return!1}function T4($){if(typeof $!=="object"||$===null)return!1;let K=Object.getPrototypeOf($);return(K===null||K===Object.prototype||Object.getPrototypeOf(K)===null)&&!(Symbol.toStringTag in $)&&!(Symbol.iterator in $)}import{fileURLToPath as Cs6}from"node:url";var nH=($,K)=>{let q=vB(Rs6($));if(typeof q!=="string")throw new TypeError(`${K} must be a string or a file URL: ${q}.`);return q},Rs6=($)=>jB($)?$.toString():$,jB=($)=>typeof $!=="string"&&$&&Object.getPrototypeOf($)===String.prototype,vB=($)=>$ instanceof URL?Cs6($):$;var XM=($,K=[],q={})=>{let Y=nH($,"First argument"),[z,P]=T4(K)?[[],K]:[K,q];if(!Array.isArray(z))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${z}`);if(z.some((H)=>typeof H==="object"&&H!==null))throw new TypeError(`Second argument must be an array of strings: ${z}`);let J=z.map(String),W=J.find((H)=>H.includes("\x00"));if(W!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${W}`);if(!T4(P))throw new TypeError(`Last argument must be an options object: ${P}`);return[Y,J,P]};import{ChildProcess as bs6}from"node:child_process";import{StringDecoder as Ds6}from"node:string_decoder";var{toString:CL8}=Object.prototype,RL8=($)=>CL8.call($)==="[object ArrayBuffer]",m4=($)=>CL8.call($)==="[object Uint8Array]",mK=($)=>new Uint8Array($.buffer,$.byteOffset,$.byteLength),Ss6=new TextEncoder,DL8=($)=>Ss6.encode($),Es6=new TextDecoder,TM=($)=>Es6.decode($),SL8=($,K)=>{return Ls6($,K).join("")},Ls6=($,K)=>{if(K==="utf8"&&$.every((P)=>typeof P==="string"))return $;let q=new Ds6(K),Y=$.map((P)=>typeof P==="string"?DL8(P):P).map((P)=>q.write(P)),z=q.end();return z===""?Y:[...Y,z]},Vj=($)=>{if($.length===1&&m4($[0]))return $[0];return GB(Is6($))},Is6=($)=>$.map((K)=>typeof K==="string"?DL8(K):K),GB=($)=>{let K=new Uint8Array(xs6($)),q=0;for(let Y of $)K.set(Y,q),q+=Y.length;return K},xs6=($)=>{let K=0;for(let q of $)K+=q.length;return K};var xL8=($)=>Array.isArray($)&&Array.isArray($.raw),bL8=($,K)=>{let q=[];for(let[P,J]of $.entries())q=gs6({templates:$,expressions:K,tokens:q,index:P,template:J});if(q.length===0)throw new TypeError("Template script must not be empty");let[Y,...z]=q;return[Y,z,{}]},gs6=({templates:$,expressions:K,tokens:q,index:Y,template:z})=>{if(z===void 0)throw new TypeError(`Invalid backslash sequence: ${$.raw[Y]}`);let{nextTokens:P,leadingWhitespaces:J,trailingWhitespaces:W}=ys6(z,$.raw[Y]),H=LL8(q,P,J);if(Y===K.length)return H;let Z=K[Y],O=Array.isArray(Z)?Z.map((w)=>IL8(w)):[IL8(Z)];return LL8(H,O,W)},ys6=($,K)=>{if(K.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let q=[],Y=0,z=EL8.has(K[0]);for(let J=0,W=0;J<$.length;J+=1,W+=1){let H=K[W];if(EL8.has(H)){if(Y!==J)q.push($.slice(Y,J));Y=J+1}else if(H==="\\"){let Z=K[W+1];if(Z===`
|
|
462
462
|
`)J-=1,W+=1;else if(Z==="u"&&K[W+2]==="{")W=K.indexOf("}",W+3);else W+=us6[Z]??1}}let P=Y===$.length;if(!P)q.push($.slice(Y));return{nextTokens:q,leadingWhitespaces:z,trailingWhitespaces:P}},EL8=new Set([" ","\t","\r",`
|
|
463
463
|
`]),us6={x:3,u:5},LL8=($,K,q)=>q||$.length===0||K.length===0?[...$,...K]:[...$.slice(0,-1),`${$.at(-1)}${K[0]}`,...K.slice(1)],IL8=($)=>{let K=typeof $;if(K==="string")return $;if(K==="number")return String($);if(T4($)&&(("stdout"in $)||("isMaxBuffer"in $)))return ms6($);if($ instanceof bs6||Object.prototype.toString.call($)==="[object Promise]")throw new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw new TypeError(`Unexpected "${K}" in template expression`)},ms6=({stdout:$})=>{if(typeof $==="string")return $;if(m4($))return TM($);if($===void 0)throw new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw new TypeError(`Unexpected "${typeof $}" stdout in template expression`)};import{spawnSync as Q11}from"node:child_process";import{debuglog as ps6}from"node:util";import _B from"node:process";var f9=($)=>jM.includes($),jM=[_B.stdin,_B.stdout,_B.stderr],D7=["stdin","stdout","stderr"],vM=($)=>D7[$]??`stdio[${$}]`;var yL8=($)=>{let K={...$};for(let q of VB)K[q]=fB($,q);return K},fB=($,K)=>{let q=Array.from({length:cs6($)+1}),Y=Bs6($[K],q,K);return Qs6(Y,K)},cs6=({stdio:$})=>Array.isArray($)?Math.max($.length,D7.length):D7.length,Bs6=($,K,q)=>T4($)?Us6($,K,q):K.fill($),Us6=($,K,q)=>{for(let Y of Object.keys($).sort(ls6))for(let z of Fs6(Y,q,K))K[z]=$[Y];return K},ls6=($,K)=>gL8($)<gL8(K)?1:-1,gL8=($)=>{if($==="stdout"||$==="stderr")return 0;return $==="all"?2:1},Fs6=($,K,q)=>{if($==="ipc")return[q.length-1];let Y=AB($);if(Y===void 0||Y===0)throw new TypeError(`"${K}.${$}" is invalid.
|
|
464
464
|
It must be "${K}.stdout", "${K}.stderr", "${K}.all", "${K}.ipc", or "${K}.fd3", "${K}.fd4" (and so on).`);if(Y>=q.length)throw new TypeError(`"${K}.${$}" is invalid: that file descriptor does not exist.
|
|
@@ -520,7 +520,7 @@ try {
|
|
|
520
520
|
Write-Error "Failed to get clipboard: $($_.Exception.Message)"
|
|
521
521
|
exit 1
|
|
522
522
|
}
|
|
523
|
-
`.trim(),ty8=async($,K)=>{try{return await $()}catch{return K()}},ey8=($,K)=>{try{return $()}catch{return K()}},j$1={copy:async($)=>ty8(async()=>L3(RN,DN(ry8),$),async()=>L3(CN,["--copy"],$)),async paste($){let{stdout:K}=await ty8(async()=>L3(RN,DN(sy8),$),async()=>L3(CN,["--paste"],$));return K},copySync:($)=>ey8(()=>I3(RN,DN(ry8),$),()=>I3(CN,["--copy"],$)),pasteSync:($)=>ey8(()=>I3(RN,DN(sy8),$),()=>I3(CN,["--paste"],$)).stdout},lU=j$1;var SN=(()=>{switch(Ku8.platform){case"darwin":return ny8;case"win32":return lU;case"android":{if(Ku8.env.TERMUX_VERSION===void 0)throw new Error("You need to install Termux for this module to work on Android: https://termux.com");return gy8}default:{if(hL8)return lU;if(TB())return dy8;return zP}}})(),v$1={async write($){if(typeof $!=="string")throw new TypeError(`Expected a string, got ${typeof $}`);await SN.copy({input:$})},async read(){return SN.paste({stripFinalNewline:!1})},writeSync($){if(typeof $!=="string")throw new TypeError(`Expected a string, got ${typeof $}`);SN.copySync({input:$})},readSync(){return SN.pasteSync({stripFinalNewline:!1})}},qu8=v$1;var G$1=()=>{return Object.freeze({copyToClipboard:async(K)=>{try{await qu8.write(K)}catch(q){throw new Error(`Failed to copy to clipboard: ${q.message}`)}}})},Yu8=Object.freeze({create:G$1});var HZ=zu8.default("caw:core"),_$1=async({databaseFilepath:$,lazilyCreateDb:K,kyselyFactory:q},Y)=>{let P=await hP8.create({kyselyFactory:q}).getDb($,K),J=DP8.create(),W=FP8.create(),H=VL8.create({db:P}),Z=Yu8.create(),O=new Map,w=async(c)=>{if(!c||!/^P\d+$/.test(c))Y8.factory(!0,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND");let o=parseInt(c.slice(1),10);Y8.factory(o<1||o>Number.MAX_SAFE_INTEGER,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND");let E=await J.readProjectByObjectId(P,null,c);return Y8.factory(!E,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND"),{projCtx:E.getObjectId(),projectPath:E.getPath(),authCtx:null}},X=async(c)=>{let o=O.get(c);if(o)return o;let E=await W.readRootStoreForProject(P,{},c),u=iP8.create({store:E}),y=QP8.create({store:E}),Q=AO8.create({fieldService:y}),d=dP8.create({store:E,folderService:u,documentHooks:Q}),$8=VO8.create(),W8=Nb.create({db:P,folderService:u,fieldService:y,documentService:d,templateService:$8,projectService:null,clipboardService:Z}),z8=bE8.create({store:E,folderService:u,documentService:d,templateService:$8}),w8=GL8.create({store:E,folderService:u,documentService:d,templateService:$8}),k8={folderService:u,fieldService:y,documentService:d,templateService:$8,transactionService:W8,exportService:z8,importService:w8,rootStore:E};return O.set(c,k8),k8},T=async()=>{return await Bf.create({projectStore:J,storeStore:W}).listProjects(P)},G=async(c)=>{if(!c||!/^P\d+$/.test(c))return null;let o=parseInt(c.slice(1),10);if(o<1||o>Number.MAX_SAFE_INTEGER)return null;return await J.readProjectByObjectId(P,null,c)},v=async(c,{store:o,path:E,type:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.createFolder(y,{store:o,path:E,type:u})},f=async(c,{id:o,name:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.renameFolder(u,{id:o,name:E})},A=async(c,{id:o,parentId:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.moveFolder(u,{id:o,parentId:E})},C=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteFolder(E,{id:o})},V=async(c,{id:o})=>{let E=await w(c),{folderService:u}=await X(E.projCtx);return await u.readFolder(P,E,{id:o})},M=async(c,{store:o,path:E,type:u})=>{let y=await w(c),{folderService:Q}=await X(y.projCtx);return await Q.getFolderByPath(P,y,{path:E,type:u,storeCode:o})},R=async(c,{folderId:o,store:E,type:u})=>{let y=await w(c);HZ("listFolderContents: Listing contents for project %s: folderId=%s, store=%s, type=%s",y.projCtx,o||"root",E,u);let{folderService:Q,documentService:d,rootStore:$8}=await X(y.projCtx),W8=await Q.listFolderContents(P,y,{folderId:o,storeCode:E,type:u}),z8=o;if((o===null||o===void 0)&&(u==="d"||u==="t"))z8=(await $8.readRootFolderForType(P,y,u,E)).getObjectId(),HZ("listFolderContents: Resolved root folder for type %s: %s",u,z8);HZ("listFolderContents: Querying content with parentId=%s, store=%s, type=%s",z8,E,u);let w8=await d.listDocuments(P,y,{parentId:z8,storeCode:E,type:u});return HZ("listFolderContents: Found %d folders, %d documents",W8?.length||0,w8?.length||0),{folders:W8,documents:w8}},I=async(c)=>{let o=await w(c),{rootStore:E}=await X(o.projCtx);return E},D=async({name:c,path:o})=>{let E=Bf.create({projectStore:J,storeStore:W}),u=Nb.create({db:P,folderService:null,projectService:E}),y={};return await u.createProject(y,{name:c,path:o})},m=(c)=>{return Bf.create({projectStore:J,storeStore:W}).validateProjectPath(c)},b=(c)=>{O.delete(c)},h=async(c,{store:o,path:E,type:u,content:y})=>{let Q=await w(c);HZ("createDocument: Creating document in project %s: path=%s, store=%s, type=%s",Q.projCtx,E,o,u);let{transactionService:d}=await X(Q.projCtx),$8=await d.createDocument(Q,{store:o,path:E,type:u,content:y});return HZ("createDocument: Document created: id=%s, path=%s",$8.getObjectId(),$8.getPath()),$8},L=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.readDocument(P,E,{id:o})},B=async(c,{path:o,store:E,type:u})=>{let y=await w(c),{documentService:Q}=await X(y.projCtx);return await Q.readDocumentByPath(P,y,{path:o,type:u,storeCode:E})},i=async(c,{id:o,path:E,type:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.updateDocumentPath(y,{id:o,path:E,type:u})},X8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteDocument(E,{id:o})},N8=async(c,{id:o,content:E,clientId:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.saveDraft(y,{id:o,content:E,clientId:u})},h8=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.readDraft(P,E,{id:o})},c8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.publishDocument(E,{id:o})},E8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.discardDraft(E,{id:o})},g8=async(c,{id:o,clientId:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.setEditState(u,{id:o,clientId:E})},t8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.clearEditState(E,{id:o})},v4=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.getEditState(P,E,{id:o})},g3=async(c,{id:o,versionNumber:E})=>{let u=await w(c),{documentService:y}=await X(u.projCtx);return await y.readVersion(P,u,{id:o,versionNumber:E})},v8=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.getVersions(P,E,{id:o})},r=async(c,{folderId:o,store:E,type:u="d"})=>{let y=await w(c),{documentService:Q}=await X(y.projCtx);return await Q.listDocuments(P,y,{parentId:o,storeCode:E,type:u})},a=async(c,{id:o,params:E,target:u,targetOptions:y})=>{let Q=await w(c),{transactionService:d}=await X(Q.projCtx);return await d.renderTemplate(Q,{id:o,params:E,target:u,targetOptions:y})},s=async(c,{id:o})=>{let E=await w(c),{documentService:u,templateService:y}=await X(E.projCtx),Q=await u.readDocument(P,E,{id:o});if(!Q.getPublishedContent())return{parameters:{},detectedVariables:[],target:null,targetPath:null};return y.extractTemplateParameters(Q.getPublishedContent())},K8=async(c,{store:o,ownerEntityId:E,name:u,label:y,description:Q,primitiveType:d,required:$8,multiplicity:W8,isSystem:z8})=>{let w8=await w(c),{transactionService:k8}=await X(w8.projCtx);return await k8.createFieldDefinition(w8,{store:o,ownerEntityId:E,name:u,label:y,description:Q,primitiveType:d,required:$8,multiplicity:W8,isSystem:z8})},P8=async(c,{id:o})=>{let E=await w(c),{fieldService:u}=await X(E.projCtx);return await u.readFieldDefinition(P,E,{id:o})},H8=async(c,{store:o,ownerEntityId:E,includeSystem:u})=>{let y=await w(c),{fieldService:Q}=await X(y.projCtx);return await Q.getFieldDefinitionsForOwner(P,y,{store:o,ownerEntityId:E,includeSystem:u})},O8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteFieldDefinition(E,{id:o})},A8=async(c,{entityId:o,fieldDefinitionId:E,fieldName:u,value:y,values:Q})=>{let d=await w(c),{transactionService:$8,rootStore:W8}=await X(d.projCtx),z8=await $8.setFieldValue(d,{entityId:o,fieldDefinitionId:E,fieldName:u,value:y,values:Q});return W8.evictFolder(o),z8},A6=async(c,{entityId:o})=>{let E=await w(c),{folderService:u}=await X(E.projCtx),y=await u.readFolder(P,E,{id:o});if(!y)return{};return y.getFields()},E6=async(c,{entityId:o,fieldDefinitionId:E,fieldName:u})=>{let y=await w(c),{transactionService:Q,rootStore:d}=await X(y.projCtx),$8=await Q.deleteFieldValue(y,{entityId:o,fieldDefinitionId:E,fieldName:u});return d.evictFolder(o),$8},$1=async(c)=>{let o=await w(c),{exportService:E}=await X(o.projCtx);return await E.listExports(P,o,{projectPath:o.projectPath})},y3=async(c,{store:o="A"}={})=>{let E=await w(c),{exportService:u}=await X(E.projCtx);return await u.exportPreview(P,E,{storeCode:o})},g7=async(c,{store:o="A",confirm:E=!1}={})=>{let u=await w(c),{exportService:y}=await X(u.projCtx);if(!E)return await y.exportPreview(P,u,{storeCode:o});return await y.exportDocuments(P,u,{storeCode:o,projectPath:u.projectPath})},tK=async(c,{filename:o,store:E="A"})=>{let u=await w(c);Y8.factory(!o,t.validation,"filename is required","FILENAME_REQUIRED");let{importService:y}=await X(u.projCtx);return await y.importDocuments(P,u,{filename:o,storeCode:E,projectPath:u.projectPath})};if(Y)Y({db:P,projectStore:J,storeStore:W});return Object.freeze({getProjects:T,getProjectByObjectId:G,createProject:D,validateProjectPath:m,createFolder:v,renameFolder:f,moveFolder:A,deleteFolder:C,getFolder:V,getFolderByPath:M,listFolderContents:R,getRootStore:I,evictProject:b,getDb:()=>P,createDocument:h,readDocument:L,readDocumentByPath:B,updateDocumentPath:i,deleteDocument:X8,saveDraft:N8,readDraft:h8,publishDocument:c8,discardDraft:E8,setEditState:g8,clearEditState:t8,getEditState:v4,readVersion:g3,getVersions:v8,listDocuments:r,renderTemplate:a,getTemplateParameters:s,createFieldDefinition:K8,readFieldDefinition:P8,getFieldDefinitions:H8,deleteFieldDefinition:O8,setField:A8,getFields:A6,deleteField:E6,listExports:$1,exportPreview:y3,exportDocuments:g7,importDocuments:tK,listCrons:()=>H.list(),startCron:(c)=>H.start(c),stopCron:(c)=>H.stop(c),restartCron:(c)=>H.restart(c),startAllCrons:()=>H.startAll(),stopAllCrons:()=>H.stopAll(),registerCronJob:(c,o)=>{H.register(c,o)}})},Pu8=Object.freeze({create:_$1});var Ju8=K1(TD(),1);import{join as f$1}from"path";var A$1=($,{staticPath:K})=>{return $.use(Ju8.default.static(K)),$.get("*",(q,Y,z)=>{if(q.path.startsWith("/api")||q.path==="/health")return z();Y.sendFile(f$1(K,"index.html"))}),Object.freeze({})},Wu8=Object.freeze({create:A$1});var Hu8=K1(X$(),1),EN=Hu8.default("caw:api:projects"),V$1=($,{core:K})=>{return $.get("/api/projects",async(q,Y)=>{try{EN("GET /api/projects - Fetching projects list");let z=await K.getProjects();EN("GET /api/projects - Returning %d projects",z.length),z.forEach((P)=>{EN(" - %s (%s) with %d children",P.name,P.objectId,P.children?.length||0)}),Y.json(z)}catch(z){EN("GET /api/projects - Error: %s",z.message),Y.status(500).json({error:z.message})}}),$.post("/api/projects/validate",async(q,Y)=>{try{let{path:z}=q.body,P=K.validateProjectPath(z);Y.json(P)}catch(z){if(z.code==="VALIDATION_ERROR")return Y.status(400).json({error:z.message,code:"VALIDATION_ERROR"});Y.status(500).json({error:z.message})}}),$.post("/api/projects",async(q,Y)=>{try{let{name:z,path:P}=q.body;if(!z||typeof z!=="string"||z.trim()==="")return Y.status(400).json({error:"Name is required",code:"VALIDATION_ERROR"});if(!P||typeof P!=="string"||P.trim()==="")return Y.status(400).json({error:"Path is required",code:"VALIDATION_ERROR"});if(z.length>255)return Y.status(400).json({error:"Name exceeds maximum length (255)",code:"VALIDATION_ERROR"});let J=await K.createProject({name:z.trim(),path:P.trim()});Y.status(201).json(J.toJSON())}catch(z){if(z.code==="DUPLICATE_PATH")return Y.status(409).json({error:z.message,code:"DUPLICATE_PATH"});console.error("Failed to create project:",z),Y.status(500).json({error:z.message})}}),Object.freeze({})},Zu8=Object.freeze({create:V$1});var wu8=K1(X$(),1);var k$1=($,K)=>{if($.isDomainError){let q=$.code==="UNAUTHORIZED"||$.code==="INVALID_TOKEN"?401:$.code==="NOT_FOUND"||$.code==="PROJECT_NOT_FOUND"||$.code==="EXPORT_NOT_FOUND"?404:$.code==="CONFLICT"||$.code==="STORE_NOT_EMPTY"?409:$.code==="EXPORT_ERROR"?500:400;return K.status(q).json({error:$.message,code:$.code})}console.error("Unhandled error:",$),K.status(500).json({error:$.message})},Z6=k$1;var ZZ=wu8.default("caw:api:folders"),Ou8=($)=>({folders:$.folders.map((K)=>K.toJSON()),documents:$.documents.map((K)=>K.toJSON())}),M$1=($,{core:K})=>{return $.get("/api/p/:projectId/folders/contents",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,type:J}=q.query;ZZ("GET /api/p/%s/folders/contents - Listing root contents: store=%s, type=%s",z,P,J);let W=await K.listFolderContents(z,{folderId:null,store:P,type:J}),H=Ou8(W);ZZ("GET /api/p/%s/folders/contents - Found %d folders, %d documents",z,H.folders.length,H.documents.length),Y.json(H)}catch(z){ZZ("GET /api/p/%s/folders/contents - Error: %s",q.params.projectId,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/folders/by-path",async(q,Y)=>{try{let{projectId:z}=q.params,{path:P,store:J,type:W}=q.query,H=await K.getFolderByPath(z,{path:P,store:J,type:W});if(!H)return Y.status(404).json({error:"Not found"});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/folders/:id/contents",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{type:J}=q.query;ZZ("GET /api/p/%s/folders/%s/contents - Listing folder contents: type=%s",z,P,J);let W=await K.listFolderContents(z,{folderId:P,type:J}),H=Ou8(W);ZZ("GET /api/p/%s/folders/%s/contents - Found %d folders, %d documents",z,P,H.folders.length,H.documents.length),Y.json(H)}catch(z){ZZ("GET /api/p/%s/folders/%s/contents - Error: %s",q.params.projectId,q.params.id,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getFolder(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/folders",async(q,Y)=>{try{let{projectId:z}=q.params,P=await K.createFolder(z,q.body);Y.status(201).json(P.toJSON())}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteFolder(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.patch("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{name:J,parentId:W}=q.body;if(J&&W)return Y.status(400).json({error:"Provide only name or parentId, not both",code:"INVALID_REQUEST"});if(!J&&!W)return Y.status(400).json({error:"Provide name or parentId",code:"INVALID_REQUEST"});let H;if(J)H=await K.renameFolder(z,{id:P,name:J});else H=await K.moveFolder(z,{id:P,parentId:W});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),Object.freeze({})},Xu8=Object.freeze({create:M$1});var N$1=($,{core:K})=>{return $.post("/api/p/:projectId/field-definitions",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,ownerEntityId:J,name:W,label:H,description:Z,primitiveType:O,required:w,multiplicity:X}=q.body,T=await K.createFieldDefinition(z,{store:P,ownerEntityId:J??null,name:W,label:H??null,description:Z??null,primitiveType:O,required:w??!1,multiplicity:X??"single"});Y.status(201).json(T.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/field-definitions/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readFieldDefinition(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/field-definitions",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,ownerEntityId:J,includeSystem:W}=q.query,H=await K.getFieldDefinitions(z,{store:P,ownerEntityId:J??null,includeSystem:W==="true"});Y.json(H.map((Z)=>Z.toJSON()))}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/field-definitions/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteFieldDefinition(z,{id:P});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.put("/api/p/:projectId/entities/:id/fields/:fieldName",async(q,Y)=>{try{let{projectId:z,id:P,fieldName:J}=q.params,{fieldDefinitionId:W,value:H,values:Z}=q.body,O={entityId:P,fieldDefinitionId:W!==void 0?W:null,fieldName:J};if(H!==void 0)O.value=H;if(Z!==void 0)O.values=Z;await K.setField(z,O);let w=await K.getFolder(z,{id:P});Y.json({id:w.getObjectId(),parentId:w.getParentId(),name:w.getName(),path:w.getPath(),createdAt:w.getCreatedAt(),updatedAt:w.getUpdatedAt()})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/entities/:id/fields",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getFields(z,{entityId:P}),W={};for(let[H,Z]of Object.entries(J))W[H]=Z.toJSON();Y.json(W)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/entities/:id/fields/:fieldName",async(q,Y)=>{try{let{projectId:z,id:P,fieldName:J}=q.params,{fieldDefinitionId:W}=q.query,H={entityId:P,fieldName:J};if(W!==void 0)H.fieldDefinitionId=W;await K.deleteField(z,H),Y.status(204).send()}catch(z){Z6(z,Y)}}),Object.freeze({})},Tu8=Object.freeze({create:N$1});var ju8=K1(X$(),1);var FU=ju8.default("caw:api:documents"),h$1=($,{core:K})=>{return $.post("/api/p/:projectId/documents",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,path:J,type:W="d",content:H}=q.body;FU("POST /api/p/%s/documents - Creating content: path=%s, store=%s, type=%s, hasContent=%s",z,J,P,W,!!H);let O=(await K.createDocument(z,{store:P,path:J,type:W,content:H})).toJSON();FU("POST /api/p/%s/documents - Content created: id=%s, path=%s, parentId=%s",z,O.id,O.path,O.parentId),Y.status(201).json(O)}catch(z){FU("POST /api/p/%s/documents - Error: %s",q.params.projectId,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/documents/by-path",async(q,Y)=>{try{let{projectId:z}=q.params,{path:P,store:J,type:W="d"}=q.query,H=await K.readDocumentByPath(z,{path:P,store:J,type:W});if(!H)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents",async(q,Y)=>{try{let{projectId:z}=q.params,{folderId:P,store:J,type:W="d"}=q.query,H=await K.listDocuments(z,{folderId:P??null,store:J,type:W});Y.json(H.map((Z)=>Z.toJSON()))}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/parameters",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDocument(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});let W=J.getPublishedContent();if(!W)return Y.json({id:P,parameters:{},target:null,targetPath:null,detectedVariables:[]});try{let{parameters:H,target:Z,targetPath:O}=M$.getParameters(W),{body:w}=M$.parseFrontMatter(W),X=Array.from(M$.extractVariables(w));Y.json({id:P,parameters:H,target:Z,targetPath:O,detectedVariables:X})}catch(H){return Y.json({id:P,parameters:{},target:null,targetPath:null,detectedVariables:[],parseError:H.message})}}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/render",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{params:J,target:W,targetOptions:H}=q.body,Z=await K.renderTemplate(z,{id:P,params:J,target:W,targetOptions:H});Y.json(Z)}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDocument(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.patch("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{path:J}=q.body,W=m1.getTypeFromId(P),H=await K.updateDocumentPath(z,{id:P,path:J,type:W});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteDocument(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.put("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{content:J,clientId:W}=q.body;if(J===void 0)return Y.status(400).json({error:"content is required",code:"MISSING_CONTENT"});if(!W)return Y.status(400).json({error:"clientId is required",code:"MISSING_CLIENT_ID"});let H=await K.saveDraft(z,{id:P,content:J,clientId:W});Y.json({id:P,updated:!0,lockLost:H.lockLost??!1})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDraft(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/publish",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.publishDocument(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params;await K.discardDraft(z,{id:P}),Y.json({id:P,discarded:!0})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/versions",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getVersions(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/versions/:versionNumber",async(q,Y)=>{try{let{projectId:z,id:P,versionNumber:J}=q.params,W=await K.readVersion(z,{id:P,versionNumber:parseInt(J,10)});if(!W)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(W)}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/edit-state",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{clientId:J}=q.body;if(!J)return Y.status(400).json({error:"clientId is required"});let W=await K.setEditState(z,{id:P,clientId:J});if(!W.success)return Y.status(409).json(W);Y.json(W)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id/edit-state",async(q,Y)=>{try{let{projectId:z,id:P}=q.params;await K.clearEditState(z,{id:P}),Y.json({success:!0})}catch(z){Z6(z,Y)}}),Object.freeze({})},vu8=Object.freeze({create:h$1});var Gu8=K1(X$(),1);var s$=Gu8.default("caw:api:export"),C$1=($,{core:K})=>{return $.get("/api/p/:projectId/exports",async(q,Y)=>{try{let{projectId:z}=q.params;s$("GET /api/p/%s/exports - Listing export files",z);let P=await K.listExports(z);s$("GET /api/p/%s/exports - Found %d export files",z,P.length),Y.json({ok:!0,exports:P})}catch(z){s$("GET /api/p/:projectId/exports - Error: %s",z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/export/preview",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P}=q.query;s$("GET /api/p/%s/export/preview - Previewing export: store=%s",z,P);let J=await K.exportPreview(z,{store:P});s$("GET /api/p/%s/export/preview - Preview complete: %d to export, %d draft-only",z,(J.toExport?.folders?.length||0)+(J.toExport?.documents?.length||0)+(J.toExport?.templates?.length||0),(J.draftOnly?.documents?.length||0)+(J.draftOnly?.templates?.length||0)),Y.json(J)}catch(z){s$("GET /api/p/:projectId/export/preview - Error: %s",z.message),Z6(z,Y)}}),$.post("/api/p/:projectId/export",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,confirm:J}=q.body;s$("POST /api/p/%s/export - Export request: store=%s, confirm=%s",z,P,J);let W=await K.exportDocuments(z,{store:P,confirm:J});if(J)s$("POST /api/p/%s/export - Export complete: %s",z,W.filename);else s$("POST /api/p/%s/export - Preview returned (confirm=false)",z);Y.json(W)}catch(z){s$("POST /api/p/:projectId/export - Error: %s",z.message),Z6(z,Y)}}),$.post("/api/p/:projectId/import",async(q,Y)=>{try{let{projectId:z}=q.params,{filename:P,store:J}=q.body;s$("POST /api/p/%s/import - Import request: filename=%s, store=%s",z,P,J);let W=await K.importDocuments(z,{filename:P,store:J});s$("POST /api/p/%s/import - Import complete: %d folders, %d documents, %d templates",z,W.counts?.folders||0,W.counts?.documents||0,W.counts?.templates||0),Y.json({ok:!0,...W})}catch(z){s$("POST /api/p/:projectId/import - Error: %s",z.message),Z6(z,Y)}}),Object.freeze({})},_u8=Object.freeze({create:C$1});var fu8=K1(X$(),1);var LN=fu8.default("caw:api:events"),R$1=($,{core:K})=>{return $.get("/api/p/:projectId/events",async(q,Y)=>{try{let{projectId:z}=q.params;LN("GET /api/p/%s/events - Client connecting",z);let P=await K.getRootStore(z);LN("GET /api/p/%s/events - Got root store, setting up SSE subscription",z),Y.setHeader("Content-Type","text/event-stream"),Y.setHeader("Cache-Control","no-cache"),Y.setHeader("Connection","keep-alive"),Y.flushHeaders(),Y.write(`: connected
|
|
523
|
+
`.trim(),ty8=async($,K)=>{try{return await $()}catch{return K()}},ey8=($,K)=>{try{return $()}catch{return K()}},j$1={copy:async($)=>ty8(async()=>L3(RN,DN(ry8),$),async()=>L3(CN,["--copy"],$)),async paste($){let{stdout:K}=await ty8(async()=>L3(RN,DN(sy8),$),async()=>L3(CN,["--paste"],$));return K},copySync:($)=>ey8(()=>I3(RN,DN(ry8),$),()=>I3(CN,["--copy"],$)),pasteSync:($)=>ey8(()=>I3(RN,DN(sy8),$),()=>I3(CN,["--paste"],$)).stdout},lU=j$1;var SN=(()=>{switch(Ku8.platform){case"darwin":return ny8;case"win32":return lU;case"android":{if(Ku8.env.TERMUX_VERSION===void 0)throw new Error("You need to install Termux for this module to work on Android: https://termux.com");return gy8}default:{if(hL8)return lU;if(TB())return dy8;return zP}}})(),v$1={async write($){if(typeof $!=="string")throw new TypeError(`Expected a string, got ${typeof $}`);await SN.copy({input:$})},async read(){return SN.paste({stripFinalNewline:!1})},writeSync($){if(typeof $!=="string")throw new TypeError(`Expected a string, got ${typeof $}`);SN.copySync({input:$})},readSync(){return SN.pasteSync({stripFinalNewline:!1})}},qu8=v$1;var G$1=()=>{return Object.freeze({copyToClipboard:async(K)=>{try{await qu8.write(K)}catch(q){throw new Error(`Failed to copy to clipboard: ${q.message}`)}}})},Yu8=Object.freeze({create:G$1});var HZ=zu8.default("caw:core"),_$1=async({databaseFilepath:$,lazilyCreateDb:K,kyselyFactory:q},Y)=>{let P=await hP8.create({kyselyFactory:q}).getDb($,K),J=DP8.create(),W=FP8.create(),H=VL8.create({db:P}),Z=Yu8.create(),O=new Map,w=async(c)=>{if(!c||!/^P\d+$/.test(c))Y8.factory(!0,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND");let o=parseInt(c.slice(1),10);Y8.factory(o<1||o>Number.MAX_SAFE_INTEGER,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND");let E=await J.readProjectByObjectId(P,null,c);return Y8.factory(!E,t.notFound,`Project not found: ${c}`,"PROJECT_NOT_FOUND"),{projCtx:E.getObjectId(),projectPath:E.getPath(),authCtx:null}},X=async(c)=>{let o=O.get(c);if(o)return o;let E=await W.readRootStoreForProject(P,{},c),u=iP8.create({store:E}),y=QP8.create({store:E}),Q=AO8.create({fieldService:y}),d=dP8.create({store:E,folderService:u,documentHooks:Q}),$8=VO8.create(),W8=Nb.create({db:P,folderService:u,fieldService:y,documentService:d,templateService:$8,projectService:null,clipboardService:Z}),z8=bE8.create({store:E,folderService:u,documentService:d,templateService:$8}),w8=GL8.create({store:E,folderService:u,documentService:d,templateService:$8}),k8={folderService:u,fieldService:y,documentService:d,templateService:$8,transactionService:W8,exportService:z8,importService:w8,rootStore:E};return O.set(c,k8),k8},T=async()=>{return await Bf.create({projectStore:J,storeStore:W}).listProjects(P)},G=async(c)=>{if(!c||!/^P\d+$/.test(c))return null;let o=parseInt(c.slice(1),10);if(o<1||o>Number.MAX_SAFE_INTEGER)return null;return await J.readProjectByObjectId(P,null,c)},v=async(c,{store:o,path:E,type:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.createFolder(y,{store:o,path:E,type:u})},f=async(c,{id:o,name:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.renameFolder(u,{id:o,name:E})},A=async(c,{id:o,parentId:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.moveFolder(u,{id:o,parentId:E})},C=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteFolder(E,{id:o})},V=async(c,{id:o})=>{let E=await w(c),{folderService:u}=await X(E.projCtx);return await u.readFolder(P,E,{id:o})},M=async(c,{store:o,path:E,type:u})=>{let y=await w(c),{folderService:Q}=await X(y.projCtx);return await Q.getFolderByPath(P,y,{path:E,type:u,storeCode:o})},R=async(c,{folderId:o,store:E,type:u})=>{let y=await w(c);HZ("listFolderContents: Listing contents for project %s: folderId=%s, store=%s, type=%s",y.projCtx,o||"root",E,u);let{folderService:Q,documentService:d,rootStore:$8}=await X(y.projCtx),W8=await Q.listFolderContents(P,y,{folderId:o,storeCode:E,type:u}),z8=o;if((o===null||o===void 0)&&(u==="d"||u==="t"))z8=(await $8.readRootFolderForType(P,y,u,E)).getObjectId(),HZ("listFolderContents: Resolved root folder for type %s: %s",u,z8);HZ("listFolderContents: Querying content with parentId=%s, store=%s, type=%s",z8,E,u);let w8=await d.listDocuments(P,y,{parentId:z8,storeCode:E,type:u});return HZ("listFolderContents: Found %d folders, %d documents",W8?.length||0,w8?.length||0),{folders:W8,documents:w8}},I=async(c)=>{let o=await w(c),{rootStore:E}=await X(o.projCtx);return E},D=async({name:c,path:o})=>{let E=Bf.create({projectStore:J,storeStore:W}),u=Nb.create({db:P,folderService:null,projectService:E}),y={};return await u.createProject(y,{name:c,path:o})},m=(c)=>{return Bf.create({projectStore:J,storeStore:W}).validateProjectPath(c)},b=(c)=>{O.delete(c)},h=async(c,{store:o,path:E,type:u,content:y})=>{let Q=await w(c);HZ("createDocument: Creating document in project %s: path=%s, store=%s, type=%s",Q.projCtx,E,o,u);let{transactionService:d}=await X(Q.projCtx),$8=await d.createDocument(Q,{store:o,path:E,type:u,content:y});return HZ("createDocument: Document created: id=%s, path=%s",$8.getObjectId(),$8.getPath()),$8},L=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.readDocument(P,E,{id:o})},B=async(c,{path:o,store:E,type:u})=>{let y=await w(c),{documentService:Q}=await X(y.projCtx);return await Q.readDocumentByPath(P,y,{path:o,type:u,storeCode:E})},i=async(c,{id:o,path:E,type:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.updateDocumentPath(y,{id:o,path:E,type:u})},X8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteDocument(E,{id:o})},N8=async(c,{id:o,content:E,clientId:u})=>{let y=await w(c),{transactionService:Q}=await X(y.projCtx);return await Q.saveDraft(y,{id:o,content:E,clientId:u})},h8=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.readDraft(P,E,{id:o})},c8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.publishDocument(E,{id:o})},E8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.discardDraft(E,{id:o})},g8=async(c,{id:o,clientId:E})=>{let u=await w(c),{transactionService:y}=await X(u.projCtx);return await y.setEditState(u,{id:o,clientId:E})},t8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.clearEditState(E,{id:o})},V4=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.getEditState(P,E,{id:o})},g3=async(c,{id:o,versionNumber:E})=>{let u=await w(c),{documentService:y}=await X(u.projCtx);return await y.readVersion(P,u,{id:o,versionNumber:E})},v8=async(c,{id:o})=>{let E=await w(c),{documentService:u}=await X(E.projCtx);return await u.getVersions(P,E,{id:o})},r=async(c,{folderId:o,store:E,type:u="d"})=>{let y=await w(c),{documentService:Q}=await X(y.projCtx);return await Q.listDocuments(P,y,{parentId:o,storeCode:E,type:u})},a=async(c,{id:o,params:E,target:u,targetOptions:y})=>{let Q=await w(c),{transactionService:d}=await X(Q.projCtx);return await d.renderTemplate(Q,{id:o,params:E,target:u,targetOptions:y})},s=async(c,{id:o})=>{let E=await w(c),{documentService:u,templateService:y}=await X(E.projCtx),Q=await u.readDocument(P,E,{id:o});if(!Q.getPublishedContent())return{parameters:{},detectedVariables:[],target:null,targetPath:null};return y.extractTemplateParameters(Q.getPublishedContent())},K8=async(c,{store:o,ownerEntityId:E,name:u,label:y,description:Q,primitiveType:d,required:$8,multiplicity:W8,isSystem:z8})=>{let w8=await w(c),{transactionService:k8}=await X(w8.projCtx);return await k8.createFieldDefinition(w8,{store:o,ownerEntityId:E,name:u,label:y,description:Q,primitiveType:d,required:$8,multiplicity:W8,isSystem:z8})},P8=async(c,{id:o})=>{let E=await w(c),{fieldService:u}=await X(E.projCtx);return await u.readFieldDefinition(P,E,{id:o})},H8=async(c,{store:o,ownerEntityId:E,includeSystem:u})=>{let y=await w(c),{fieldService:Q}=await X(y.projCtx);return await Q.getFieldDefinitionsForOwner(P,y,{store:o,ownerEntityId:E,includeSystem:u})},O8=async(c,{id:o})=>{let E=await w(c),{transactionService:u}=await X(E.projCtx);return await u.deleteFieldDefinition(E,{id:o})},A8=async(c,{entityId:o,fieldDefinitionId:E,fieldName:u,value:y,values:Q})=>{let d=await w(c),{transactionService:$8,rootStore:W8}=await X(d.projCtx),z8=await $8.setFieldValue(d,{entityId:o,fieldDefinitionId:E,fieldName:u,value:y,values:Q});return W8.evictFolder(o),z8},A6=async(c,{entityId:o})=>{let E=await w(c),{folderService:u}=await X(E.projCtx),y=await u.readFolder(P,E,{id:o});if(!y)return{};return y.getFields()},E6=async(c,{entityId:o,fieldDefinitionId:E,fieldName:u})=>{let y=await w(c),{transactionService:Q,rootStore:d}=await X(y.projCtx),$8=await Q.deleteFieldValue(y,{entityId:o,fieldDefinitionId:E,fieldName:u});return d.evictFolder(o),$8},$1=async(c)=>{let o=await w(c),{exportService:E}=await X(o.projCtx);return await E.listExports(P,o,{projectPath:o.projectPath})},y3=async(c,{store:o="A"}={})=>{let E=await w(c),{exportService:u}=await X(E.projCtx);return await u.exportPreview(P,E,{storeCode:o})},g7=async(c,{store:o="A",confirm:E=!1}={})=>{let u=await w(c),{exportService:y}=await X(u.projCtx);if(!E)return await y.exportPreview(P,u,{storeCode:o});return await y.exportDocuments(P,u,{storeCode:o,projectPath:u.projectPath})},tK=async(c,{filename:o,store:E="A"})=>{let u=await w(c);Y8.factory(!o,t.validation,"filename is required","FILENAME_REQUIRED");let{importService:y}=await X(u.projCtx);return await y.importDocuments(P,u,{filename:o,storeCode:E,projectPath:u.projectPath})};if(Y)Y({db:P,projectStore:J,storeStore:W});return Object.freeze({getProjects:T,getProjectByObjectId:G,createProject:D,validateProjectPath:m,createFolder:v,renameFolder:f,moveFolder:A,deleteFolder:C,getFolder:V,getFolderByPath:M,listFolderContents:R,getRootStore:I,evictProject:b,getDb:()=>P,createDocument:h,readDocument:L,readDocumentByPath:B,updateDocumentPath:i,deleteDocument:X8,saveDraft:N8,readDraft:h8,publishDocument:c8,discardDraft:E8,setEditState:g8,clearEditState:t8,getEditState:V4,readVersion:g3,getVersions:v8,listDocuments:r,renderTemplate:a,getTemplateParameters:s,createFieldDefinition:K8,readFieldDefinition:P8,getFieldDefinitions:H8,deleteFieldDefinition:O8,setField:A8,getFields:A6,deleteField:E6,listExports:$1,exportPreview:y3,exportDocuments:g7,importDocuments:tK,listCrons:()=>H.list(),startCron:(c)=>H.start(c),stopCron:(c)=>H.stop(c),restartCron:(c)=>H.restart(c),startAllCrons:()=>H.startAll(),stopAllCrons:()=>H.stopAll(),registerCronJob:(c,o)=>{H.register(c,o)}})},Pu8=Object.freeze({create:_$1});var Ju8=K1(TD(),1);import{join as f$1}from"path";var A$1=($,{staticPath:K})=>{return $.use(Ju8.default.static(K)),$.get("*",(q,Y,z)=>{if(q.path.startsWith("/api")||q.path==="/health")return z();Y.sendFile(f$1(K,"index.html"))}),Object.freeze({})},Wu8=Object.freeze({create:A$1});var Hu8=K1(X$(),1),EN=Hu8.default("caw:api:projects"),V$1=($,{core:K})=>{return $.get("/api/projects",async(q,Y)=>{try{EN("GET /api/projects - Fetching projects list");let z=await K.getProjects();EN("GET /api/projects - Returning %d projects",z.length),z.forEach((P)=>{EN(" - %s (%s) with %d children",P.name,P.objectId,P.children?.length||0)}),Y.json(z)}catch(z){EN("GET /api/projects - Error: %s",z.message),Y.status(500).json({error:z.message})}}),$.post("/api/projects/validate",async(q,Y)=>{try{let{path:z}=q.body,P=K.validateProjectPath(z);Y.json(P)}catch(z){if(z.code==="VALIDATION_ERROR")return Y.status(400).json({error:z.message,code:"VALIDATION_ERROR"});Y.status(500).json({error:z.message})}}),$.post("/api/projects",async(q,Y)=>{try{let{name:z,path:P}=q.body;if(!z||typeof z!=="string"||z.trim()==="")return Y.status(400).json({error:"Name is required",code:"VALIDATION_ERROR"});if(!P||typeof P!=="string"||P.trim()==="")return Y.status(400).json({error:"Path is required",code:"VALIDATION_ERROR"});if(z.length>255)return Y.status(400).json({error:"Name exceeds maximum length (255)",code:"VALIDATION_ERROR"});let J=await K.createProject({name:z.trim(),path:P.trim()});Y.status(201).json(J.toJSON())}catch(z){if(z.code==="DUPLICATE_PATH")return Y.status(409).json({error:z.message,code:"DUPLICATE_PATH"});console.error("Failed to create project:",z),Y.status(500).json({error:z.message})}}),Object.freeze({})},Zu8=Object.freeze({create:V$1});var wu8=K1(X$(),1);var k$1=($,K)=>{if($.isDomainError){let q=$.code==="UNAUTHORIZED"||$.code==="INVALID_TOKEN"?401:$.code==="NOT_FOUND"||$.code==="PROJECT_NOT_FOUND"||$.code==="EXPORT_NOT_FOUND"?404:$.code==="CONFLICT"||$.code==="STORE_NOT_EMPTY"?409:$.code==="EXPORT_ERROR"?500:400;return K.status(q).json({error:$.message,code:$.code})}console.error("Unhandled error:",$),K.status(500).json({error:$.message})},Z6=k$1;var ZZ=wu8.default("caw:api:folders"),Ou8=($)=>({folders:$.folders.map((K)=>K.toJSON()),documents:$.documents.map((K)=>K.toJSON())}),M$1=($,{core:K})=>{return $.get("/api/p/:projectId/folders/contents",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,type:J}=q.query;ZZ("GET /api/p/%s/folders/contents - Listing root contents: store=%s, type=%s",z,P,J);let W=await K.listFolderContents(z,{folderId:null,store:P,type:J}),H=Ou8(W);ZZ("GET /api/p/%s/folders/contents - Found %d folders, %d documents",z,H.folders.length,H.documents.length),Y.json(H)}catch(z){ZZ("GET /api/p/%s/folders/contents - Error: %s",q.params.projectId,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/folders/by-path",async(q,Y)=>{try{let{projectId:z}=q.params,{path:P,store:J,type:W}=q.query,H=await K.getFolderByPath(z,{path:P,store:J,type:W});if(!H)return Y.status(404).json({error:"Not found"});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/folders/:id/contents",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{type:J}=q.query;ZZ("GET /api/p/%s/folders/%s/contents - Listing folder contents: type=%s",z,P,J);let W=await K.listFolderContents(z,{folderId:P,type:J}),H=Ou8(W);ZZ("GET /api/p/%s/folders/%s/contents - Found %d folders, %d documents",z,P,H.folders.length,H.documents.length),Y.json(H)}catch(z){ZZ("GET /api/p/%s/folders/%s/contents - Error: %s",q.params.projectId,q.params.id,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getFolder(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/folders",async(q,Y)=>{try{let{projectId:z}=q.params,P=await K.createFolder(z,q.body);Y.status(201).json(P.toJSON())}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteFolder(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.patch("/api/p/:projectId/folders/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{name:J,parentId:W}=q.body;if(J&&W)return Y.status(400).json({error:"Provide only name or parentId, not both",code:"INVALID_REQUEST"});if(!J&&!W)return Y.status(400).json({error:"Provide name or parentId",code:"INVALID_REQUEST"});let H;if(J)H=await K.renameFolder(z,{id:P,name:J});else H=await K.moveFolder(z,{id:P,parentId:W});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),Object.freeze({})},Xu8=Object.freeze({create:M$1});var N$1=($,{core:K})=>{return $.post("/api/p/:projectId/field-definitions",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,ownerEntityId:J,name:W,label:H,description:Z,primitiveType:O,required:w,multiplicity:X}=q.body,T=await K.createFieldDefinition(z,{store:P,ownerEntityId:J??null,name:W,label:H??null,description:Z??null,primitiveType:O,required:w??!1,multiplicity:X??"single"});Y.status(201).json(T.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/field-definitions/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readFieldDefinition(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/field-definitions",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,ownerEntityId:J,includeSystem:W}=q.query,H=await K.getFieldDefinitions(z,{store:P,ownerEntityId:J??null,includeSystem:W==="true"});Y.json(H.map((Z)=>Z.toJSON()))}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/field-definitions/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteFieldDefinition(z,{id:P});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.put("/api/p/:projectId/entities/:id/fields/:fieldName",async(q,Y)=>{try{let{projectId:z,id:P,fieldName:J}=q.params,{fieldDefinitionId:W,value:H,values:Z}=q.body,O={entityId:P,fieldDefinitionId:W!==void 0?W:null,fieldName:J};if(H!==void 0)O.value=H;if(Z!==void 0)O.values=Z;await K.setField(z,O);let w=await K.getFolder(z,{id:P});Y.json({id:w.getObjectId(),parentId:w.getParentId(),name:w.getName(),path:w.getPath(),createdAt:w.getCreatedAt(),updatedAt:w.getUpdatedAt()})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/entities/:id/fields",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getFields(z,{entityId:P}),W={};for(let[H,Z]of Object.entries(J))W[H]=Z.toJSON();Y.json(W)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/entities/:id/fields/:fieldName",async(q,Y)=>{try{let{projectId:z,id:P,fieldName:J}=q.params,{fieldDefinitionId:W}=q.query,H={entityId:P,fieldName:J};if(W!==void 0)H.fieldDefinitionId=W;await K.deleteField(z,H),Y.status(204).send()}catch(z){Z6(z,Y)}}),Object.freeze({})},Tu8=Object.freeze({create:N$1});var ju8=K1(X$(),1);var FU=ju8.default("caw:api:documents"),h$1=($,{core:K})=>{return $.post("/api/p/:projectId/documents",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,path:J,type:W="d",content:H}=q.body;FU("POST /api/p/%s/documents - Creating content: path=%s, store=%s, type=%s, hasContent=%s",z,J,P,W,!!H);let O=(await K.createDocument(z,{store:P,path:J,type:W,content:H})).toJSON();FU("POST /api/p/%s/documents - Content created: id=%s, path=%s, parentId=%s",z,O.id,O.path,O.parentId),Y.status(201).json(O)}catch(z){FU("POST /api/p/%s/documents - Error: %s",q.params.projectId,z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/documents/by-path",async(q,Y)=>{try{let{projectId:z}=q.params,{path:P,store:J,type:W="d"}=q.query,H=await K.readDocumentByPath(z,{path:P,store:J,type:W});if(!H)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents",async(q,Y)=>{try{let{projectId:z}=q.params,{folderId:P,store:J,type:W="d"}=q.query,H=await K.listDocuments(z,{folderId:P??null,store:J,type:W});Y.json(H.map((Z)=>Z.toJSON()))}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/parameters",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDocument(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});let W=J.getPublishedContent();if(!W)return Y.json({id:P,parameters:{},target:null,targetPath:null,detectedVariables:[]});try{let{parameters:H,target:Z,targetPath:O}=M$.getParameters(W),{body:w}=M$.parseFrontMatter(W),X=Array.from(M$.extractVariables(w));Y.json({id:P,parameters:H,target:Z,targetPath:O,detectedVariables:X})}catch(H){return Y.json({id:P,parameters:{},target:null,targetPath:null,detectedVariables:[],parseError:H.message})}}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/render",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{params:J,target:W,targetOptions:H}=q.body,Z=await K.renderTemplate(z,{id:P,params:J,target:W,targetOptions:H});Y.json(Z)}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDocument(z,{id:P});if(!J)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(J.toJSON())}catch(z){Z6(z,Y)}}),$.patch("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{path:J}=q.body,W=m1.getTypeFromId(P),H=await K.updateDocumentPath(z,{id:P,path:J,type:W});Y.json(H.toJSON())}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.deleteDocument(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.put("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{content:J,clientId:W}=q.body;if(J===void 0)return Y.status(400).json({error:"content is required",code:"MISSING_CONTENT"});if(!W)return Y.status(400).json({error:"clientId is required",code:"MISSING_CLIENT_ID"});let H=await K.saveDraft(z,{id:P,content:J,clientId:W});Y.json({id:P,updated:!0,lockLost:H.lockLost??!1})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.readDraft(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/publish",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.publishDocument(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id/draft",async(q,Y)=>{try{let{projectId:z,id:P}=q.params;await K.discardDraft(z,{id:P}),Y.json({id:P,discarded:!0})}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/versions",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,J=await K.getVersions(z,{id:P});Y.json(J)}catch(z){Z6(z,Y)}}),$.get("/api/p/:projectId/documents/:id/versions/:versionNumber",async(q,Y)=>{try{let{projectId:z,id:P,versionNumber:J}=q.params,W=await K.readVersion(z,{id:P,versionNumber:parseInt(J,10)});if(!W)return Y.status(404).json({error:"Not found",code:"NOT_FOUND"});Y.json(W)}catch(z){Z6(z,Y)}}),$.post("/api/p/:projectId/documents/:id/edit-state",async(q,Y)=>{try{let{projectId:z,id:P}=q.params,{clientId:J}=q.body;if(!J)return Y.status(400).json({error:"clientId is required"});let W=await K.setEditState(z,{id:P,clientId:J});if(!W.success)return Y.status(409).json(W);Y.json(W)}catch(z){Z6(z,Y)}}),$.delete("/api/p/:projectId/documents/:id/edit-state",async(q,Y)=>{try{let{projectId:z,id:P}=q.params;await K.clearEditState(z,{id:P}),Y.json({success:!0})}catch(z){Z6(z,Y)}}),Object.freeze({})},vu8=Object.freeze({create:h$1});var Gu8=K1(X$(),1);var s$=Gu8.default("caw:api:export"),C$1=($,{core:K})=>{return $.get("/api/p/:projectId/exports",async(q,Y)=>{try{let{projectId:z}=q.params;s$("GET /api/p/%s/exports - Listing export files",z);let P=await K.listExports(z);s$("GET /api/p/%s/exports - Found %d export files",z,P.length),Y.json({ok:!0,exports:P})}catch(z){s$("GET /api/p/:projectId/exports - Error: %s",z.message),Z6(z,Y)}}),$.get("/api/p/:projectId/export/preview",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P}=q.query;s$("GET /api/p/%s/export/preview - Previewing export: store=%s",z,P);let J=await K.exportPreview(z,{store:P});s$("GET /api/p/%s/export/preview - Preview complete: %d to export, %d draft-only",z,(J.toExport?.folders?.length||0)+(J.toExport?.documents?.length||0)+(J.toExport?.templates?.length||0),(J.draftOnly?.documents?.length||0)+(J.draftOnly?.templates?.length||0)),Y.json(J)}catch(z){s$("GET /api/p/:projectId/export/preview - Error: %s",z.message),Z6(z,Y)}}),$.post("/api/p/:projectId/export",async(q,Y)=>{try{let{projectId:z}=q.params,{store:P,confirm:J}=q.body;s$("POST /api/p/%s/export - Export request: store=%s, confirm=%s",z,P,J);let W=await K.exportDocuments(z,{store:P,confirm:J});if(J)s$("POST /api/p/%s/export - Export complete: %s",z,W.filename);else s$("POST /api/p/%s/export - Preview returned (confirm=false)",z);Y.json(W)}catch(z){s$("POST /api/p/:projectId/export - Error: %s",z.message),Z6(z,Y)}}),$.post("/api/p/:projectId/import",async(q,Y)=>{try{let{projectId:z}=q.params,{filename:P,store:J}=q.body;s$("POST /api/p/%s/import - Import request: filename=%s, store=%s",z,P,J);let W=await K.importDocuments(z,{filename:P,store:J});s$("POST /api/p/%s/import - Import complete: %d folders, %d documents, %d templates",z,W.counts?.folders||0,W.counts?.documents||0,W.counts?.templates||0),Y.json({ok:!0,...W})}catch(z){s$("POST /api/p/:projectId/import - Error: %s",z.message),Z6(z,Y)}}),Object.freeze({})},_u8=Object.freeze({create:C$1});var fu8=K1(X$(),1);var LN=fu8.default("caw:api:events"),R$1=($,{core:K})=>{return $.get("/api/p/:projectId/events",async(q,Y)=>{try{let{projectId:z}=q.params;LN("GET /api/p/%s/events - Client connecting",z);let P=await K.getRootStore(z);LN("GET /api/p/%s/events - Got root store, setting up SSE subscription",z),Y.setHeader("Content-Type","text/event-stream"),Y.setHeader("Cache-Control","no-cache"),Y.setHeader("Connection","keep-alive"),Y.flushHeaders(),Y.write(`: connected
|
|
524
524
|
|
|
525
525
|
`);let J=(Z,O)=>{LN("SSE sending event: %s with data: %o",Z,O),Y.write(`event: ${Z}
|
|
526
526
|
`),Y.write(`data: ${JSON.stringify(O)}
|