speckeeper 0.19.0 → 0.19.1
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/cli-contract.yaml +1 -1
- package/dist/speckeeper.bundle.mjs +40 -40
- package/docs/cli-reference.md +1 -1
- package/docs/design/test-refs.md +2 -2
- package/package.json +3 -3
|
@@ -139,7 +139,7 @@ ${f.comment}`:f.comment}this.doc.range[2]=f.offset;break}default:this.errors.pus
|
|
|
139
139
|
`)+1;for(;f!==0;)this.onNewLine(this.offset+f),f=this.source.indexOf(`
|
|
140
140
|
`,f)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(r){let f=r.items[r.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,f.value){let h="end"in f.value?f.value.end:void 0;(Array.isArray(h)?h[h.length-1]:void 0)?.type==="comment"?h?.push(this.sourceToken):r.items.push({start:[this.sourceToken]})}else f.sep?f.sep.push(this.sourceToken):f.start.push(this.sourceToken);return;case"space":case"comment":if(f.value)r.items.push({start:[this.sourceToken]});else if(f.sep)f.sep.push(this.sourceToken);else{if(this.atIndentedComment(f.start,r.indent)){let l=r.items[r.items.length-2]?.value?.end;if(Array.isArray(l)){aE(l,f.start),l.push(this.sourceToken),r.items.pop();return}}f.start.push(this.sourceToken)}return}if(this.indent>=r.indent){let h=!this.onKeyLine&&this.indent===r.indent,l=h&&(f.sep||f.explicitKey)&&this.type!=="seq-item-ind",t=[];if(l&&f.sep&&!f.value){let $=[];for(let re=0;re<f.sep.length;++re){let e=f.sep[re];switch(e.type){case"newline":$.push(re);break;case"space":break;case"comment":e.indent>r.indent&&($.length=0);break;default:$.length=0}}$.length>=2&&(t=f.sep.splice($[1]))}switch(this.type){case"anchor":case"tag":l||f.value?(t.push(this.sourceToken),r.items.push({start:t}),this.onKeyLine=!0):f.sep?f.sep.push(this.sourceToken):f.start.push(this.sourceToken);return;case"explicit-key-ind":!f.sep&&!f.explicitKey?(f.start.push(this.sourceToken),f.explicitKey=!0):l||f.value?(t.push(this.sourceToken),r.items.push({start:t,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(f.explicitKey)if(f.sep)if(f.value)r.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Hh(f.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]});else if(L2(f.key)&&!Hh(f.sep,"newline")){let $=Xg(f.start),re=f.key,e=f.sep;e.push(this.sourceToken),delete f.key,delete f.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:re,sep:e}]})}else t.length>0?f.sep=f.sep.concat(t,this.sourceToken):f.sep.push(this.sourceToken);else if(Hh(f.start,"newline"))Object.assign(f,{key:null,sep:[this.sourceToken]});else{let $=Xg(f.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:null,sep:[this.sourceToken]}]})}else f.sep?f.value||l?r.items.push({start:t,key:null,sep:[this.sourceToken]}):Hh(f.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):f.sep.push(this.sourceToken):Object.assign(f,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let $=this.flowScalar(this.type);l||f.value?(r.items.push({start:t,key:$,sep:[]}),this.onKeyLine=!0):f.sep?this.stack.push($):(Object.assign(f,{key:$,sep:[]}),this.onKeyLine=!0);return}default:{let $=this.startBlockValue(r);if($){if($.type==="block-seq"){if(!f.explicitKey&&f.sep&&!Hh(f.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else h&&r.items.push({start:t});this.stack.push($);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(r){let f=r.items[r.items.length-1];switch(this.type){case"newline":if(f.value){let h="end"in f.value?f.value.end:void 0;(Array.isArray(h)?h[h.length-1]:void 0)?.type==="comment"?h?.push(this.sourceToken):r.items.push({start:[this.sourceToken]})}else f.start.push(this.sourceToken);return;case"space":case"comment":if(f.value)r.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(f.start,r.indent)){let l=r.items[r.items.length-2]?.value?.end;if(Array.isArray(l)){aE(l,f.start),l.push(this.sourceToken),r.items.pop();return}}f.start.push(this.sourceToken)}return;case"anchor":case"tag":if(f.value||this.indent<=r.indent)break;f.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==r.indent)break;f.value||Hh(f.start,"seq-item-ind")?r.items.push({start:[this.sourceToken]}):f.start.push(this.sourceToken);return}if(this.indent>r.indent){let h=this.startBlockValue(r);if(h){this.stack.push(h);return}}yield*this.pop(),yield*this.step()}*flowCollection(r){let f=r.items[r.items.length-1];if(this.type==="flow-error-end"){let h;do yield*this.pop(),h=this.peek(1);while(h?.type==="flow-collection")}else if(r.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!f||f.sep?r.items.push({start:[this.sourceToken]}):f.start.push(this.sourceToken);return;case"map-value-ind":!f||f.value?r.items.push({start:[],key:null,sep:[this.sourceToken]}):f.sep?f.sep.push(this.sourceToken):Object.assign(f,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!f||f.value?r.items.push({start:[this.sourceToken]}):f.sep?f.sep.push(this.sourceToken):f.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let l=this.flowScalar(this.type);!f||f.value?r.items.push({start:[],key:l,sep:[]}):f.sep?this.stack.push(l):Object.assign(f,{key:l,sep:[]});return}case"flow-map-end":case"flow-seq-end":r.end.push(this.sourceToken);return}let h=this.startBlockValue(r);h?this.stack.push(h):(yield*this.pop(),yield*this.step())}else{let h=this.peek(2);if(h.type==="block-map"&&(this.type==="map-value-ind"&&h.indent===r.indent||this.type==="newline"&&!h.items[h.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&h.type!=="flow-collection"){let l=iE(h),t=Xg(l);C2(r);let $=r.end.splice(1,r.end.length);$.push(this.sourceToken);let re={type:"block-map",offset:r.offset,indent:r.indent,items:[{start:t,key:r,sep:$}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=re}else yield*this.lineEnd(r)}}flowScalar(r){if(this.onNewLine){let f=this.source.indexOf(`
|
|
141
141
|
`)+1;for(;f!==0;)this.onNewLine(this.offset+f),f=this.source.indexOf(`
|
|
142
|
-
`,f)+1}return{type:r,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(r){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let f=iE(r),h=Xg(f);return h.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let f=iE(r),h=Xg(f);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(r,f){return this.type!=="comment"||this.indent<=f?!1:r.every(h=>h.type==="newline"||h.type==="space")}*documentEnd(r){this.type!=="doc-mode"&&(r.end?r.end.push(this.sourceToken):r.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(r){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:r.end?r.end.push(this.sourceToken):r.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};E2.Parser=JI});var T2=La($w=>{"use strict";var A2=MI(),O9=_w(),Ow=Tw(),$9=US(),D9=A0(),U9=KI(),_2=XI();function S2(n){let r=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||r&&new U9.LineCounter||null,prettyErrors:r}}function P9(n,r={}){let{lineCounter:f,prettyErrors:h}=S2(r),l=new _2.Parser(f?.addNewLine),t=new A2.Composer(r),$=Array.from(t.compose(l.parse(n)));if(h&&f)for(let re of $)re.errors.forEach(Ow.prettifyError(n,f)),re.warnings.forEach(Ow.prettifyError(n,f));return $.length>0?$:Object.assign([],{empty:!0},t.streamInfo())}function I2(n,r={}){let{lineCounter:f,prettyErrors:h}=S2(r),l=new _2.Parser(f?.addNewLine),t=new A2.Composer(r),$=null;for(let re of t.compose(l.parse(n),!0,n.length))if(!$)$=re;else if($.options.logLevel!=="silent"){$.errors.push(new Ow.YAMLParseError(re.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return h&&f&&($.errors.forEach(Ow.prettifyError(n,f)),$.warnings.forEach(Ow.prettifyError(n,f))),$}function M9(n,r,f){let h;typeof r=="function"?h=r:f===void 0&&r&&typeof r=="object"&&(f=r);let l=I2(n,f);if(!l)return null;if(l.warnings.forEach(t=>$9.warn(l.options.logLevel,t)),l.errors.length>0){if(l.options.logLevel!=="silent")throw l.errors[0];l.errors=[]}return l.toJS(Object.assign({reviver:h},f))}function j9(n,r,f){let h=null;if(typeof r=="function"||Array.isArray(r)?h=r:f===void 0&&r&&(f=r),typeof f=="string"&&(f=f.length),typeof f=="number"){let l=Math.round(f);f=l<1?void 0:l>8?{indent:8}:{indent:l}}if(n===void 0){let{keepUndefined:l}=f??r??{};if(!l)return}return D9.isDocument(n)&&!h?n.toString(f):new O9.Document(n,h,f).toString(f)}$w.parse=M9;$w.parseAllDocuments=P9;$w.parseDocument=I2;$w.stringify=j9});var ih=La(Hb=>{"use strict";var F9=MI(),z9=_w(),G9=gI(),QI=Tw(),B9=lw(),Yh=A0(),q9=Gh(),V9=Yv(),H9=qh(),Y9=Vh(),W9=sE(),Z9=WI(),K9=KI(),J9=XI(),uE=T2(),x2=ow();Hb.Composer=F9.Composer;Hb.Document=z9.Document;Hb.Schema=G9.Schema;Hb.YAMLError=QI.YAMLError;Hb.YAMLParseError=QI.YAMLParseError;Hb.YAMLWarning=QI.YAMLWarning;Hb.Alias=B9.Alias;Hb.isAlias=Yh.isAlias;Hb.isCollection=Yh.isCollection;Hb.isDocument=Yh.isDocument;Hb.isMap=Yh.isMap;Hb.isNode=Yh.isNode;Hb.isPair=Yh.isPair;Hb.isScalar=Yh.isScalar;Hb.isSeq=Yh.isSeq;Hb.Pair=q9.Pair;Hb.Scalar=V9.Scalar;Hb.YAMLMap=H9.YAMLMap;Hb.YAMLSeq=Y9.YAMLSeq;Hb.CST=W9;Hb.Lexer=Z9.Lexer;Hb.LineCounter=K9.LineCounter;Hb.Parser=J9.Parser;Hb.parse=uE.parse;Hb.parseAllDocuments=uE.parseAllDocuments;Hb.parseDocument=uE.parseDocument;Hb.stringify=uE.stringify;Hb.visit=x2.visit;Hb.visitAsync=x2.visitAsync});var Dj=La((soe,Z_)=>{var Qv=(function(n){"use strict";var r=1e7,f=7,h=9007199254740992,l=gt(h),t="0123456789abcdefghijklmnopqrstuvwxyz",$=typeof BigInt=="function";function re(Ir,ns,ms,js){return typeof Ir>"u"?re[0]:typeof ns<"u"?+ns==10&&!ms?Qi(Ir):dd(Ir,ns,ms,js):Qi(Ir)}function e(Ir,ns){this.value=Ir,this.sign=ns,this.isSmall=!1}e.prototype=Object.create(re.prototype);function qe(Ir){this.value=Ir,this.sign=Ir<0,this.isSmall=!0}qe.prototype=Object.create(re.prototype);function ht(Ir){this.value=Ir}ht.prototype=Object.create(re.prototype);function Ke(Ir){return-h<Ir&&Ir<h}function gt(Ir){return Ir<1e7?[Ir]:Ir<1e14?[Ir%1e7,Math.floor(Ir/1e7)]:[Ir%1e7,Math.floor(Ir/1e7)%1e7,Math.floor(Ir/1e14)]}function ln(Ir){Qn(Ir);var ns=Ir.length;if(ns<4&&Tl(Ir,l)<0)switch(ns){case 0:return 0;case 1:return Ir[0];case 2:return Ir[0]+Ir[1]*r;default:return Ir[0]+(Ir[1]+Ir[2]*r)*r}return Ir}function Qn(Ir){for(var ns=Ir.length;Ir[--ns]===0;);Ir.length=ns+1}function bn(Ir){for(var ns=new Array(Ir),ms=-1;++ms<Ir;)ns[ms]=0;return ns}function zr(Ir){return Ir>0?Math.floor(Ir):Math.ceil(Ir)}function tr(Ir,ns){var ms=Ir.length,js=ns.length,oo=new Array(ms),Vs=0,xo=r,No,Po;for(Po=0;Po<js;Po++)No=Ir[Po]+ns[Po]+Vs,Vs=No>=xo?1:0,oo[Po]=No-Vs*xo;for(;Po<ms;)No=Ir[Po]+Vs,Vs=No===xo?1:0,oo[Po++]=No-Vs*xo;return Vs>0&&oo.push(Vs),oo}function Er(Ir,ns){return Ir.length>=ns.length?tr(Ir,ns):tr(ns,Ir)}function cs(Ir,ns){var ms=Ir.length,js=new Array(ms),oo=r,Vs,xo;for(xo=0;xo<ms;xo++)Vs=Ir[xo]-oo+ns,ns=Math.floor(Vs/oo),js[xo]=Vs-ns*oo,ns+=1;for(;ns>0;)js[xo++]=ns%oo,ns=Math.floor(ns/oo);return js}e.prototype.add=function(Ir){var ns=Qi(Ir);if(this.sign!==ns.sign)return this.subtract(ns.negate());var ms=this.value,js=ns.value;return ns.isSmall?new e(cs(ms,Math.abs(js)),this.sign):new e(Er(ms,js),this.sign)},e.prototype.plus=e.prototype.add,qe.prototype.add=function(Ir){var ns=Qi(Ir),ms=this.value;if(ms<0!==ns.sign)return this.subtract(ns.negate());var js=ns.value;if(ns.isSmall){if(Ke(ms+js))return new qe(ms+js);js=gt(Math.abs(js))}return new e(cs(js,Math.abs(ms)),ms<0)},qe.prototype.plus=qe.prototype.add,ht.prototype.add=function(Ir){return new ht(this.value+Qi(Ir).value)},ht.prototype.plus=ht.prototype.add;function Ys(Ir,ns){var ms=Ir.length,js=ns.length,oo=new Array(ms),Vs=0,xo=r,No,Po;for(No=0;No<js;No++)Po=Ir[No]-Vs-ns[No],Po<0?(Po+=xo,Vs=1):Vs=0,oo[No]=Po;for(No=js;No<ms;No++){if(Po=Ir[No]-Vs,Po<0)Po+=xo;else{oo[No++]=Po;break}oo[No]=Po}for(;No<ms;No++)oo[No]=Ir[No];return Qn(oo),oo}function ao(Ir,ns,ms){var js;return Tl(Ir,ns)>=0?js=Ys(Ir,ns):(js=Ys(ns,Ir),ms=!ms),js=ln(js),typeof js=="number"?(ms&&(js=-js),new qe(js)):new e(js,ms)}function uo(Ir,ns,ms){var js=Ir.length,oo=new Array(js),Vs=-ns,xo=r,No,Po;for(No=0;No<js;No++)Po=Ir[No]+Vs,Vs=Math.floor(Po/xo),Po%=xo,oo[No]=Po<0?Po+xo:Po;return oo=ln(oo),typeof oo=="number"?(ms&&(oo=-oo),new qe(oo)):new e(oo,ms)}e.prototype.subtract=function(Ir){var ns=Qi(Ir);if(this.sign!==ns.sign)return this.add(ns.negate());var ms=this.value,js=ns.value;return ns.isSmall?uo(ms,Math.abs(js),this.sign):ao(ms,js,this.sign)},e.prototype.minus=e.prototype.subtract,qe.prototype.subtract=function(Ir){var ns=Qi(Ir),ms=this.value;if(ms<0!==ns.sign)return this.add(ns.negate());var js=ns.value;return ns.isSmall?new qe(ms-js):uo(js,Math.abs(ms),ms>=0)},qe.prototype.minus=qe.prototype.subtract,ht.prototype.subtract=function(Ir){return new ht(this.value-Qi(Ir).value)},ht.prototype.minus=ht.prototype.subtract,e.prototype.negate=function(){return new e(this.value,!this.sign)},qe.prototype.negate=function(){var Ir=this.sign,ns=new qe(-this.value);return ns.sign=!Ir,ns},ht.prototype.negate=function(){return new ht(-this.value)},e.prototype.abs=function(){return new e(this.value,!1)},qe.prototype.abs=function(){return new qe(Math.abs(this.value))},ht.prototype.abs=function(){return new ht(this.value>=0?this.value:-this.value)};function ni(Ir,ns){var ms=Ir.length,js=ns.length,oo=ms+js,Vs=bn(oo),xo=r,No,Po,na,Ra,aa;for(na=0;na<ms;++na){Ra=Ir[na];for(var Va=0;Va<js;++Va)aa=ns[Va],No=Ra*aa+Vs[na+Va],Po=Math.floor(No/xo),Vs[na+Va]=No-Po*xo,Vs[na+Va+1]+=Po}return Qn(Vs),Vs}function zo(Ir,ns){var ms=Ir.length,js=new Array(ms),oo=r,Vs=0,xo,No;for(No=0;No<ms;No++)xo=Ir[No]*ns+Vs,Vs=Math.floor(xo/oo),js[No]=xo-Vs*oo;for(;Vs>0;)js[No++]=Vs%oo,Vs=Math.floor(Vs/oo);return js}function ta(Ir,ns){for(var ms=[];ns-- >0;)ms.push(0);return ms.concat(Ir)}function Ha(Ir,ns){var ms=Math.max(Ir.length,ns.length);if(ms<=30)return ni(Ir,ns);ms=Math.ceil(ms/2);var js=Ir.slice(ms),oo=Ir.slice(0,ms),Vs=ns.slice(ms),xo=ns.slice(0,ms),No=Ha(oo,xo),Po=Ha(js,Vs),na=Ha(Er(oo,js),Er(xo,Vs)),Ra=Er(Er(No,ta(Ys(Ys(na,No),Po),ms)),ta(Po,2*ms));return Qn(Ra),Ra}function ja(Ir,ns){return-.012*Ir-.012*ns+15e-6*Ir*ns>0}e.prototype.multiply=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo=this.sign!==ns.sign,Vs;if(ns.isSmall){if(js===0)return re[0];if(js===1)return this;if(js===-1)return this.negate();if(Vs=Math.abs(js),Vs<r)return new e(zo(ms,Vs),oo);js=gt(Vs)}return ja(ms.length,js.length)?new e(Ha(ms,js),oo):new e(ni(ms,js),oo)},e.prototype.times=e.prototype.multiply;function Aa(Ir,ns,ms){return Ir<r?new e(zo(ns,Ir),ms):new e(ni(ns,gt(Ir)),ms)}qe.prototype._multiplyBySmall=function(Ir){return Ke(Ir.value*this.value)?new qe(Ir.value*this.value):Aa(Math.abs(Ir.value),gt(Math.abs(this.value)),this.sign!==Ir.sign)},e.prototype._multiplyBySmall=function(Ir){return Ir.value===0?re[0]:Ir.value===1?this:Ir.value===-1?this.negate():Aa(Math.abs(Ir.value),this.value,this.sign!==Ir.sign)},qe.prototype.multiply=function(Ir){return Qi(Ir)._multiplyBySmall(this)},qe.prototype.times=qe.prototype.multiply,ht.prototype.multiply=function(Ir){return new ht(this.value*Qi(Ir).value)},ht.prototype.times=ht.prototype.multiply;function cl(Ir){var ns=Ir.length,ms=bn(ns+ns),js=r,oo,Vs,xo,No,Po;for(xo=0;xo<ns;xo++){No=Ir[xo],Vs=0-No*No;for(var na=xo;na<ns;na++)Po=Ir[na],oo=2*(No*Po)+ms[xo+na]+Vs,Vs=Math.floor(oo/js),ms[xo+na]=oo-Vs*js;ms[xo+ns]=Vs}return Qn(ms),ms}e.prototype.square=function(){return new e(cl(this.value),!1)},qe.prototype.square=function(){var Ir=this.value*this.value;return Ke(Ir)?new qe(Ir):new e(cl(gt(Math.abs(this.value))),!1)},ht.prototype.square=function(Ir){return new ht(this.value*this.value)};function nl(Ir,ns){var ms=Ir.length,js=ns.length,oo=r,Vs=bn(ns.length),xo=ns[js-1],No=Math.ceil(oo/(2*xo)),Po=zo(Ir,No),na=zo(ns,No),Ra,aa,Va,Cu,uu,lu,ec;for(Po.length<=ms&&Po.push(0),na.push(0),xo=na[js-1],aa=ms-js;aa>=0;aa--){for(Ra=oo-1,Po[aa+js]!==xo&&(Ra=Math.floor((Po[aa+js]*oo+Po[aa+js-1])/xo)),Va=0,Cu=0,lu=na.length,uu=0;uu<lu;uu++)Va+=Ra*na[uu],ec=Math.floor(Va/oo),Cu+=Po[aa+uu]-(Va-ec*oo),Va=ec,Cu<0?(Po[aa+uu]=Cu+oo,Cu=-1):(Po[aa+uu]=Cu,Cu=0);for(;Cu!==0;){for(Ra-=1,Va=0,uu=0;uu<lu;uu++)Va+=Po[aa+uu]-oo+na[uu],Va<0?(Po[aa+uu]=Va+oo,Va=0):(Po[aa+uu]=Va,Va=1);Cu+=Va}Vs[aa]=Ra}return Po=cd(Po,No)[0],[ln(Vs),ln(Po)]}function lf(Ir,ns){for(var ms=Ir.length,js=ns.length,oo=[],Vs=[],xo=r,No,Po,na,Ra,aa;ms;){if(Vs.unshift(Ir[--ms]),Qn(Vs),Tl(Vs,ns)<0){oo.push(0);continue}Po=Vs.length,na=Vs[Po-1]*xo+Vs[Po-2],Ra=ns[js-1]*xo+ns[js-2],Po>js&&(na=(na+1)*xo),No=Math.ceil(na/Ra);do{if(aa=zo(ns,No),Tl(aa,Vs)<=0)break;No--}while(No);oo.push(No),Vs=Ys(Vs,aa)}return oo.reverse(),[ln(oo),ln(Vs)]}function cd(Ir,ns){var ms=Ir.length,js=bn(ms),oo=r,Vs,xo,No,Po;for(No=0,Vs=ms-1;Vs>=0;--Vs)Po=No*oo+Ir[Vs],xo=zr(Po/ns),No=Po-xo*ns,js[Vs]=xo|0;return[js,No|0]}function Il(Ir,ns){var ms,js=Qi(ns);if($)return[new ht(Ir.value/js.value),new ht(Ir.value%js.value)];var oo=Ir.value,Vs=js.value,xo;if(Vs===0)throw new Error("Cannot divide by zero");if(Ir.isSmall)return js.isSmall?[new qe(zr(oo/Vs)),new qe(oo%Vs)]:[re[0],Ir];if(js.isSmall){if(Vs===1)return[Ir,re[0]];if(Vs==-1)return[Ir.negate(),re[0]];var No=Math.abs(Vs);if(No<r){ms=cd(oo,No),xo=ln(ms[0]);var Po=ms[1];return Ir.sign&&(Po=-Po),typeof xo=="number"?(Ir.sign!==js.sign&&(xo=-xo),[new qe(xo),new qe(Po)]):[new e(xo,Ir.sign!==js.sign),new qe(Po)]}Vs=gt(No)}var na=Tl(oo,Vs);if(na===-1)return[re[0],Ir];if(na===0)return[re[Ir.sign===js.sign?1:-1],re[0]];oo.length+Vs.length<=200?ms=nl(oo,Vs):ms=lf(oo,Vs),xo=ms[0];var Ra=Ir.sign!==js.sign,aa=ms[1],Va=Ir.sign;return typeof xo=="number"?(Ra&&(xo=-xo),xo=new qe(xo)):xo=new e(xo,Ra),typeof aa=="number"?(Va&&(aa=-aa),aa=new qe(aa)):aa=new e(aa,Va),[xo,aa]}e.prototype.divmod=function(Ir){var ns=Il(this,Ir);return{quotient:ns[0],remainder:ns[1]}},ht.prototype.divmod=qe.prototype.divmod=e.prototype.divmod,e.prototype.divide=function(Ir){return Il(this,Ir)[0]},ht.prototype.over=ht.prototype.divide=function(Ir){return new ht(this.value/Qi(Ir).value)},qe.prototype.over=qe.prototype.divide=e.prototype.over=e.prototype.divide,e.prototype.mod=function(Ir){return Il(this,Ir)[1]},ht.prototype.mod=ht.prototype.remainder=function(Ir){return new ht(this.value%Qi(Ir).value)},qe.prototype.remainder=qe.prototype.mod=e.prototype.remainder=e.prototype.mod,e.prototype.pow=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo,Vs,xo;if(js===0)return re[1];if(ms===0)return re[0];if(ms===1)return re[1];if(ms===-1)return ns.isEven()?re[1]:re[-1];if(ns.sign)return re[0];if(!ns.isSmall)throw new Error("The exponent "+ns.toString()+" is too large.");if(this.isSmall&&Ke(oo=Math.pow(ms,js)))return new qe(zr(oo));for(Vs=this,xo=re[1];js&!0&&(xo=xo.times(Vs),--js),js!==0;)js/=2,Vs=Vs.square();return xo},qe.prototype.pow=e.prototype.pow,ht.prototype.pow=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo=BigInt(0),Vs=BigInt(1),xo=BigInt(2);if(js===oo)return re[1];if(ms===oo)return re[0];if(ms===Vs)return re[1];if(ms===BigInt(-1))return ns.isEven()?re[1]:re[-1];if(ns.isNegative())return new ht(oo);for(var No=this,Po=re[1];(js&Vs)===Vs&&(Po=Po.times(No),--js),js!==oo;)js/=xo,No=No.square();return Po},e.prototype.modPow=function(Ir,ns){if(Ir=Qi(Ir),ns=Qi(ns),ns.isZero())throw new Error("Cannot take modPow with modulus 0");var ms=re[1],js=this.mod(ns);for(Ir.isNegative()&&(Ir=Ir.multiply(re[-1]),js=js.modInv(ns));Ir.isPositive();){if(js.isZero())return re[0];Ir.isOdd()&&(ms=ms.multiply(js).mod(ns)),Ir=Ir.divide(2),js=js.square().mod(ns)}return ms},ht.prototype.modPow=qe.prototype.modPow=e.prototype.modPow;function Tl(Ir,ns){if(Ir.length!==ns.length)return Ir.length>ns.length?1:-1;for(var ms=Ir.length-1;ms>=0;ms--)if(Ir[ms]!==ns[ms])return Ir[ms]>ns[ms]?1:-1;return 0}e.prototype.compareAbs=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value;return ns.isSmall?1:Tl(ms,js)},qe.prototype.compareAbs=function(Ir){var ns=Qi(Ir),ms=Math.abs(this.value),js=ns.value;return ns.isSmall?(js=Math.abs(js),ms===js?0:ms>js?1:-1):-1},ht.prototype.compareAbs=function(Ir){var ns=this.value,ms=Qi(Ir).value;return ns=ns>=0?ns:-ns,ms=ms>=0?ms:-ms,ns===ms?0:ns>ms?1:-1},e.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=Qi(Ir),ms=this.value,js=ns.value;return this.sign!==ns.sign?ns.sign?1:-1:ns.isSmall?this.sign?-1:1:Tl(ms,js)*(this.sign?-1:1)},e.prototype.compareTo=e.prototype.compare,qe.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=Qi(Ir),ms=this.value,js=ns.value;return ns.isSmall?ms==js?0:ms>js?1:-1:ms<0!==ns.sign?ms<0?-1:1:ms<0?1:-1},qe.prototype.compareTo=qe.prototype.compare,ht.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=this.value,ms=Qi(Ir).value;return ns===ms?0:ns>ms?1:-1},ht.prototype.compareTo=ht.prototype.compare,e.prototype.equals=function(Ir){return this.compare(Ir)===0},ht.prototype.eq=ht.prototype.equals=qe.prototype.eq=qe.prototype.equals=e.prototype.eq=e.prototype.equals,e.prototype.notEquals=function(Ir){return this.compare(Ir)!==0},ht.prototype.neq=ht.prototype.notEquals=qe.prototype.neq=qe.prototype.notEquals=e.prototype.neq=e.prototype.notEquals,e.prototype.greater=function(Ir){return this.compare(Ir)>0},ht.prototype.gt=ht.prototype.greater=qe.prototype.gt=qe.prototype.greater=e.prototype.gt=e.prototype.greater,e.prototype.lesser=function(Ir){return this.compare(Ir)<0},ht.prototype.lt=ht.prototype.lesser=qe.prototype.lt=qe.prototype.lesser=e.prototype.lt=e.prototype.lesser,e.prototype.greaterOrEquals=function(Ir){return this.compare(Ir)>=0},ht.prototype.geq=ht.prototype.greaterOrEquals=qe.prototype.geq=qe.prototype.greaterOrEquals=e.prototype.geq=e.prototype.greaterOrEquals,e.prototype.lesserOrEquals=function(Ir){return this.compare(Ir)<=0},ht.prototype.leq=ht.prototype.lesserOrEquals=qe.prototype.leq=qe.prototype.lesserOrEquals=e.prototype.leq=e.prototype.lesserOrEquals,e.prototype.isEven=function(){return(this.value[0]&1)===0},qe.prototype.isEven=function(){return(this.value&1)===0},ht.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},e.prototype.isOdd=function(){return(this.value[0]&1)===1},qe.prototype.isOdd=function(){return(this.value&1)===1},ht.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},e.prototype.isPositive=function(){return!this.sign},qe.prototype.isPositive=function(){return this.value>0},ht.prototype.isPositive=qe.prototype.isPositive,e.prototype.isNegative=function(){return this.sign},qe.prototype.isNegative=function(){return this.value<0},ht.prototype.isNegative=qe.prototype.isNegative,e.prototype.isUnit=function(){return!1},qe.prototype.isUnit=function(){return Math.abs(this.value)===1},ht.prototype.isUnit=function(){return this.abs().value===BigInt(1)},e.prototype.isZero=function(){return!1},qe.prototype.isZero=function(){return this.value===0},ht.prototype.isZero=function(){return this.value===BigInt(0)},e.prototype.isDivisibleBy=function(Ir){var ns=Qi(Ir);return ns.isZero()?!1:ns.isUnit()?!0:ns.compareAbs(2)===0?this.isEven():this.mod(ns).isZero()},ht.prototype.isDivisibleBy=qe.prototype.isDivisibleBy=e.prototype.isDivisibleBy;function cf(Ir){var ns=Ir.abs();if(ns.isUnit())return!1;if(ns.equals(2)||ns.equals(3)||ns.equals(5))return!0;if(ns.isEven()||ns.isDivisibleBy(3)||ns.isDivisibleBy(5))return!1;if(ns.lesser(49))return!0}function xf(Ir,ns){for(var ms=Ir.prev(),js=ms,oo=0,Vs,xo,No,Po;js.isEven();)js=js.divide(2),oo++;e:for(No=0;No<ns.length;No++)if(!Ir.lesser(ns[No])&&(Po=Qv(ns[No]).modPow(js,Ir),!(Po.isUnit()||Po.equals(ms)))){for(Vs=oo-1;Vs!=0;Vs--){if(Po=Po.square().mod(Ir),Po.isUnit())return!1;if(Po.equals(ms))continue e}return!1}return!0}e.prototype.isPrime=function(Ir){var ns=cf(this);if(ns!==n)return ns;var ms=this.abs(),js=ms.bitLength();if(js<=64)return xf(ms,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var oo=Math.log(2)*js.toJSNumber(),Vs=Math.ceil(Ir===!0?2*Math.pow(oo,2):oo),xo=[],No=0;No<Vs;No++)xo.push(Qv(No+2));return xf(ms,xo)},ht.prototype.isPrime=qe.prototype.isPrime=e.prototype.isPrime,e.prototype.isProbablePrime=function(Ir,ns){var ms=cf(this);if(ms!==n)return ms;for(var js=this.abs(),oo=Ir===n?5:Ir,Vs=[],xo=0;xo<oo;xo++)Vs.push(Qv.randBetween(2,js.minus(2),ns));return xf(js,Vs)},ht.prototype.isProbablePrime=qe.prototype.isProbablePrime=e.prototype.isProbablePrime,e.prototype.modInv=function(Ir){for(var ns=Qv.zero,ms=Qv.one,js=Qi(Ir),oo=this.abs(),Vs,xo,No;!oo.isZero();)Vs=js.divide(oo),xo=ns,No=js,ns=ms,js=oo,ms=xo.subtract(Vs.multiply(ms)),oo=No.subtract(Vs.multiply(oo));if(!js.isUnit())throw new Error(this.toString()+" and "+Ir.toString()+" are not co-prime");return ns.compare(0)===-1&&(ns=ns.add(Ir)),this.isNegative()?ns.negate():ns},ht.prototype.modInv=qe.prototype.modInv=e.prototype.modInv,e.prototype.next=function(){var Ir=this.value;return this.sign?uo(Ir,1,this.sign):new e(cs(Ir,1),this.sign)},qe.prototype.next=function(){var Ir=this.value;return Ir+1<h?new qe(Ir+1):new e(l,!1)},ht.prototype.next=function(){return new ht(this.value+BigInt(1))},e.prototype.prev=function(){var Ir=this.value;return this.sign?new e(cs(Ir,1),!0):uo(Ir,1,this.sign)},qe.prototype.prev=function(){var Ir=this.value;return Ir-1>-h?new qe(Ir-1):new e(l,!0)},ht.prototype.prev=function(){return new ht(this.value-BigInt(1))};for(var xu=[1];2*xu[xu.length-1]<=r;)xu.push(2*xu[xu.length-1]);var Qd=xu.length,jl=xu[Qd-1];function Od(Ir){return Math.abs(Ir)<=r}e.prototype.shiftLeft=function(Ir){var ns=Qi(Ir).toJSNumber();if(!Od(ns))throw new Error(String(ns)+" is too large for shifting.");if(ns<0)return this.shiftRight(-ns);var ms=this;if(ms.isZero())return ms;for(;ns>=Qd;)ms=ms.multiply(jl),ns-=Qd-1;return ms.multiply(xu[ns])},ht.prototype.shiftLeft=qe.prototype.shiftLeft=e.prototype.shiftLeft,e.prototype.shiftRight=function(Ir){var ns,ms=Qi(Ir).toJSNumber();if(!Od(ms))throw new Error(String(ms)+" is too large for shifting.");if(ms<0)return this.shiftLeft(-ms);for(var js=this;ms>=Qd;){if(js.isZero()||js.isNegative()&&js.isUnit())return js;ns=Il(js,jl),js=ns[1].isNegative()?ns[0].prev():ns[0],ms-=Qd-1}return ns=Il(js,xu[ms]),ns[1].isNegative()?ns[0].prev():ns[0]},ht.prototype.shiftRight=qe.prototype.shiftRight=e.prototype.shiftRight;function $d(Ir,ns,ms){ns=Qi(ns);for(var js=Ir.isNegative(),oo=ns.isNegative(),Vs=js?Ir.not():Ir,xo=oo?ns.not():ns,No=0,Po=0,na=null,Ra=null,aa=[];!Vs.isZero()||!xo.isZero();)na=Il(Vs,jl),No=na[1].toJSNumber(),js&&(No=jl-1-No),Ra=Il(xo,jl),Po=Ra[1].toJSNumber(),oo&&(Po=jl-1-Po),Vs=na[0],xo=Ra[0],aa.push(ms(No,Po));for(var Va=ms(js?1:0,oo?1:0)!==0?Qv(-1):Qv(0),Cu=aa.length-1;Cu>=0;Cu-=1)Va=Va.multiply(jl).add(Qv(aa[Cu]));return Va}e.prototype.not=function(){return this.negate().prev()},ht.prototype.not=qe.prototype.not=e.prototype.not,e.prototype.and=function(Ir){return $d(this,Ir,function(ns,ms){return ns&ms})},ht.prototype.and=qe.prototype.and=e.prototype.and,e.prototype.or=function(Ir){return $d(this,Ir,function(ns,ms){return ns|ms})},ht.prototype.or=qe.prototype.or=e.prototype.or,e.prototype.xor=function(Ir){return $d(this,Ir,function(ns,ms){return ns^ms})},ht.prototype.xor=qe.prototype.xor=e.prototype.xor;var wp=1<<30,Zf=(r&-r)*(r&-r)|wp;function ml(Ir){var ns=Ir.value,ms=typeof ns=="number"?ns|wp:typeof ns=="bigint"?ns|BigInt(wp):ns[0]+ns[1]*r|Zf;return ms&-ms}function Dd(Ir,ns){if(ns.compareTo(Ir)<=0){var ms=Dd(Ir,ns.square(ns)),js=ms.p,oo=ms.e,Vs=js.multiply(ns);return Vs.compareTo(Ir)<=0?{p:Vs,e:oo*2+1}:{p:js,e:oo*2}}return{p:Qv(1),e:0}}e.prototype.bitLength=function(){var Ir=this;return Ir.compareTo(Qv(0))<0&&(Ir=Ir.negate().subtract(Qv(1))),Ir.compareTo(Qv(0))===0?Qv(0):Qv(Dd(Ir,Qv(2)).e).add(Qv(1))},ht.prototype.bitLength=qe.prototype.bitLength=e.prototype.bitLength;function Cc(Ir,ns){return Ir=Qi(Ir),ns=Qi(ns),Ir.greater(ns)?Ir:ns}function Kf(Ir,ns){return Ir=Qi(Ir),ns=Qi(ns),Ir.lesser(ns)?Ir:ns}function kf(Ir,ns){if(Ir=Qi(Ir).abs(),ns=Qi(ns).abs(),Ir.equals(ns))return Ir;if(Ir.isZero())return ns;if(ns.isZero())return Ir;for(var ms=re[1],js,oo;Ir.isEven()&&ns.isEven();)js=Kf(ml(Ir),ml(ns)),Ir=Ir.divide(js),ns=ns.divide(js),ms=ms.multiply(js);for(;Ir.isEven();)Ir=Ir.divide(ml(Ir));do{for(;ns.isEven();)ns=ns.divide(ml(ns));Ir.greater(ns)&&(oo=ns,ns=Ir,Ir=oo),ns=ns.subtract(Ir)}while(!ns.isZero());return ms.isUnit()?Ir:Ir.multiply(ms)}function fd(Ir,ns){return Ir=Qi(Ir).abs(),ns=Qi(ns).abs(),Ir.divide(kf(Ir,ns)).multiply(ns)}function cb(Ir,ns,ms){Ir=Qi(Ir),ns=Qi(ns);var js=ms||Math.random,oo=Kf(Ir,ns),Vs=Cc(Ir,ns),xo=Vs.subtract(oo).add(1);if(xo.isSmall)return oo.add(Math.floor(js()*xo));for(var No=ku(xo,r).value,Po=[],na=!0,Ra=0;Ra<No.length;Ra++){var aa=na?No[Ra]+(Ra+1<No.length?No[Ra+1]/r:0):r,Va=zr(js()*aa);Po.push(Va),Va<No[Ra]&&(na=!1)}return oo.add(re.fromArray(Po,r,!1))}var dd=function(Ir,ns,ms,js){ms=ms||t,Ir=String(Ir),js||(Ir=Ir.toLowerCase(),ms=ms.toLowerCase());var oo=Ir.length,Vs,xo=Math.abs(ns),No={};for(Vs=0;Vs<ms.length;Vs++)No[ms[Vs]]=Vs;for(Vs=0;Vs<oo;Vs++){var Po=Ir[Vs];if(Po!=="-"&&Po in No&&No[Po]>=xo){if(Po==="1"&&xo===1)continue;throw new Error(Po+" is not a valid digit in base "+ns+".")}}ns=Qi(ns);var na=[],Ra=Ir[0]==="-";for(Vs=Ra?1:0;Vs<Ir.length;Vs++){var Po=Ir[Vs];if(Po in No)na.push(Qi(No[Po]));else if(Po==="<"){var aa=Vs;do Vs++;while(Ir[Vs]!==">"&&Vs<Ir.length);na.push(Qi(Ir.slice(aa+1,Vs)))}else throw new Error(Po+" is not a valid character")}return hl(na,ns,Ra)};function hl(Ir,ns,ms){var js=re[0],oo=re[1],Vs;for(Vs=Ir.length-1;Vs>=0;Vs--)js=js.add(Ir[Vs].times(oo)),oo=oo.times(ns);return ms?js.negate():js}function e0(Ir,ns){return ns=ns||t,Ir<ns.length?ns[Ir]:"<"+Ir+">"}function ku(Ir,ns){if(ns=Qv(ns),ns.isZero()){if(Ir.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(ns.equals(-1)){if(Ir.isZero())return{value:[0],isNegative:!1};if(Ir.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-Ir.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var ms=Array.apply(null,Array(Ir.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return ms.unshift([1]),{value:[].concat.apply([],ms),isNegative:!1}}var js=!1;if(Ir.isNegative()&&ns.isPositive()&&(js=!0,Ir=Ir.abs()),ns.isUnit())return Ir.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(Ir.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:js};for(var oo=[],Vs=Ir,xo;Vs.isNegative()||Vs.compareAbs(ns)>=0;){xo=Vs.divmod(ns),Vs=xo.quotient;var No=xo.remainder;No.isNegative()&&(No=ns.minus(No).abs(),Vs=Vs.next()),oo.push(No.toJSNumber())}return oo.push(Vs.toJSNumber()),{value:oo.reverse(),isNegative:js}}function Up(Ir,ns,ms){var js=ku(Ir,ns);return(js.isNegative?"-":"")+js.value.map(function(oo){return e0(oo,ms)}).join("")}e.prototype.toArray=function(Ir){return ku(this,Ir)},qe.prototype.toArray=function(Ir){return ku(this,Ir)},ht.prototype.toArray=function(Ir){return ku(this,Ir)},e.prototype.toString=function(Ir,ns){if(Ir===n&&(Ir=10),Ir!==10||ns)return Up(this,Ir,ns);for(var ms=this.value,js=ms.length,oo=String(ms[--js]),Vs="0000000",xo;--js>=0;)xo=String(ms[js]),oo+=Vs.slice(xo.length)+xo;var No=this.sign?"-":"";return No+oo},qe.prototype.toString=function(Ir,ns){return Ir===n&&(Ir=10),Ir!=10||ns?Up(this,Ir,ns):String(this.value)},ht.prototype.toString=qe.prototype.toString,ht.prototype.toJSON=e.prototype.toJSON=qe.prototype.toJSON=function(){return this.toString()},e.prototype.valueOf=function(){return parseInt(this.toString(),10)},e.prototype.toJSNumber=e.prototype.valueOf,qe.prototype.valueOf=function(){return this.value},qe.prototype.toJSNumber=qe.prototype.valueOf,ht.prototype.valueOf=ht.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function ep(Ir){if(Ke(+Ir)){var ns=+Ir;if(ns===zr(ns))return $?new ht(BigInt(ns)):new qe(ns);throw new Error("Invalid integer: "+Ir)}var ms=Ir[0]==="-";ms&&(Ir=Ir.slice(1));var js=Ir.split(/e/i);if(js.length>2)throw new Error("Invalid integer: "+js.join("e"));if(js.length===2){var oo=js[1];if(oo[0]==="+"&&(oo=oo.slice(1)),oo=+oo,oo!==zr(oo)||!Ke(oo))throw new Error("Invalid integer: "+oo+" is not a valid exponent.");var Vs=js[0],xo=Vs.indexOf(".");if(xo>=0&&(oo-=Vs.length-xo-1,Vs=Vs.slice(0,xo)+Vs.slice(xo+1)),oo<0)throw new Error("Cannot include negative exponent part for integers");Vs+=new Array(oo+1).join("0"),Ir=Vs}var No=/^([0-9][0-9]*)$/.test(Ir);if(!No)throw new Error("Invalid integer: "+Ir);if($)return new ht(BigInt(ms?"-"+Ir:Ir));for(var Po=[],na=Ir.length,Ra=f,aa=na-Ra;na>0;)Po.push(+Ir.slice(aa,na)),aa-=Ra,aa<0&&(aa=0),na-=Ra;return Qn(Po),new e(Po,ms)}function pd(Ir){if($)return new ht(BigInt(Ir));if(Ke(Ir)){if(Ir!==zr(Ir))throw new Error(Ir+" is not an integer.");return new qe(Ir)}return ep(Ir.toString())}function Qi(Ir){return typeof Ir=="number"?pd(Ir):typeof Ir=="string"?ep(Ir):typeof Ir=="bigint"?new ht(Ir):Ir}for(var Vu=0;Vu<1e3;Vu++)re[Vu]=Qi(Vu),Vu>0&&(re[-Vu]=Qi(-Vu));return re.one=re[1],re.zero=re[0],re.minusOne=re[-1],re.max=Cc,re.min=Kf,re.gcd=kf,re.lcm=fd,re.isInstance=function(Ir){return Ir instanceof e||Ir instanceof qe||Ir instanceof ht},re.randBetween=cb,re.fromArray=function(Ir,ns,ms){return hl(Ir.map(Qi),Qi(ns||10),ms)},re})();typeof Z_<"u"&&Z_.hasOwnProperty("exports")&&(Z_.exports=Qv);typeof define=="function"&&define.amd&&define(function(){return Qv})});var Pj=La(Uj=>{(function(n,r){for(var f in r)n[f]=r[f]})(Uj,(function(n){var r={};function f(h){if(r[h])return r[h].exports;var l=r[h]={i:h,l:!1,exports:{}};return n[h].call(l.exports,l,l.exports,f),l.l=!0,l.exports}return f.m=n,f.c=r,f.d=function(h,l,t){f.o(h,l)||Object.defineProperty(h,l,{enumerable:!0,get:t})},f.r=function(h){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(h,"__esModule",{value:!0})},f.t=function(h,l){if(1&l&&(h=f(h)),8&l||4&l&&typeof h=="object"&&h&&h.__esModule)return h;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:h}),2&l&&typeof h!="string")for(var $ in h)f.d(t,$,function(re){return h[re]}.bind(null,$));return t},f.n=function(h){var l=h&&h.__esModule?function(){return h.default}:function(){return h};return f.d(l,"a",l),l},f.o=function(h,l){return Object.prototype.hasOwnProperty.call(h,l)},f.p="",f(f.s=15)})([function(n,r){n.exports=Dj()},function(n,r,f){"use strict";var h=f(0);function l(t,$,re,e){this.message=t,this.expected=$,this.found=re,this.location=e,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,l)}(function(t,$){function re(){this.constructor=t}re.prototype=$.prototype,t.prototype=new re})(l,Error),l.buildMessage=function(t,$){var re={literal:function(Ke){return'"'+qe(Ke.text)+'"'},class:function(Ke){var gt,ln="";for(gt=0;gt<Ke.parts.length;gt++)ln+=Ke.parts[gt]instanceof Array?ht(Ke.parts[gt][0])+"-"+ht(Ke.parts[gt][1]):ht(Ke.parts[gt]);return"["+(Ke.inverted?"^":"")+ln+"]"},any:function(Ke){return"any character"},end:function(Ke){return"end of input"},other:function(Ke){return Ke.description}};function e(Ke){return Ke.charCodeAt(0).toString(16).toUpperCase()}function qe(Ke){return Ke.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}function ht(Ke){return Ke.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}return"Expected "+(function(Ke){var gt,ln,Qn,bn=new Array(Ke.length);for(gt=0;gt<Ke.length;gt++)bn[gt]=(Qn=Ke[gt],re[Qn.type](Qn));if(bn.sort(),bn.length>0){for(gt=1,ln=1;gt<bn.length;gt++)bn[gt-1]!==bn[gt]&&(bn[ln]=bn[gt],ln++);bn.length=ln}switch(bn.length){case 1:return bn[0];case 2:return bn[0]+" or "+bn[1];default:return bn.slice(0,-1).join(", ")+", or "+bn[bn.length-1]}})(t)+" but "+(function(Ke){return Ke?'"'+qe(Ke)+'"':"end of input"})($)+" found."},n.exports={SyntaxError:l,parse:function(t,$){$=$!==void 0?$:{};var re,e={},qe={start:sl},ht=sl,Ke=function(W,fe){return rn(W,fe,1)},gt=os("IF",!0),ln=function(W,fe){return rn(W,fe)},Qn=os("AUTO_INCREMENT",!0),bn=os("UNIQUE",!0),zr=os("KEY",!0),tr=os("PRIMARY",!0),Er=os("COLUMN_FORMAT",!0),cs=os("FIXED",!0),Ys=os("DYNAMIC",!0),ao=os("DEFAULT",!0),uo=os("STORAGE",!0),ni=os("DISK",!0),zo=os("MEMORY",!0),ta=os("ALGORITHM",!0),Ha=os("INSTANT",!0),ja=os("INPLACE",!0),Aa=os("COPY",!0),cl=os("LOCK",!0),nl=os("NONE",!0),lf=os("SHARED",!0),cd=os("EXCLUSIVE",!0),Il=os("PRIMARY KEY",!0),Tl=os("FOREIGN KEY",!0),cf=os("MATCH FULL",!0),xf=os("MATCH PARTIAL",!0),xu=os("MATCH SIMPLE",!0),Qd=os("RESTRICT",!0),jl=os("CASCADE",!0),Od=os("SET NULL",!0),$d=os("NO ACTION",!0),wp=os("SET DEFAULT",!0),Zf=os("CHARACTER",!0),ml=os("SET",!0),Dd=os("CHARSET",!0),Cc=os("COLLATE",!0),Kf=os("AVG_ROW_LENGTH",!0),kf=os("KEY_BLOCK_SIZE",!0),fd=os("MAX_ROWS",!0),cb=os("MIN_ROWS",!0),dd=os("STATS_SAMPLE_PAGES",!0),hl=os("CONNECTION",!0),e0=os("COMPRESSION",!0),ku=os("'",!1),Up=os("ZLIB",!0),ep=os("LZ4",!0),pd=os("ENGINE",!0),Qi=os("READ",!0),Vu=os("LOCAL",!0),Ir=os("LOW_PRIORITY",!0),ns=os("WRITE",!0),ms=function(W,fe){return rn(W,fe)},js=os("(",!1),oo=os(")",!1),Vs=os(".",!1),xo=os("UNNEST",!0),No=os("BTREE",!0),Po=os("HASH",!0),na=os("WITH",!0),Ra=os("PARSER",!0),aa=os("VISIBLE",!0),Va=os("INVISIBLE",!0),Cu=function(W,fe){return fe.unshift(W),fe.forEach(Te=>{let{table:Ge,as:bt}=Te;fa[Ge]=Ge,bt&&(fa[bt]=Ge),(function(et){let s=Iu(et);et.clear(),s.forEach(Be=>et.add(Be))})(va)}),fe},uu=os("FOLLOWING",!0),lu=os("PRECEDING",!0),ec=os("CURRENT",!0),Pp=os("ROW",!0),Rf=os("UNBOUNDED",!0),Nf=os("=",!1),Of=function(W,fe){return Qu(W,fe)},ff=os("!",!1),$f=function(W){return W[0]+" "+W[2]},nf=os(">=",!1),_0=os(">",!1),S0=os("<=",!1),I0=os("<>",!1),Df=os("<",!1),df=os("==",!1),Mp=os("!=",!1),bd=function(W,fe){return{op:W,right:fe}},tc=os("+",!1),Jf=os("-",!1),tp=os("*",!1),t0=os("/",!1),H0=os("%",!1),vd=os("~",!1),Uf=os("?|",!1),md=os("?&",!1),Ud=os("?",!1),jp=os("#-",!1),Lu=os("#>>",!1),n0=os("#>",!1),np=os("@>",!1),r0=os("<@",!1),Xf=function(W){return da[W.toUpperCase()]===!0},Lc=os('"',!1),xl=/^[^"]/,Gc=Eu(['"'],!0,!1),Y0=/^[^']/,Bc=Eu(["'"],!0,!1),rp=os("`",!1),W0=/^[^`]/,hd=Eu(["`"],!0,!1),T0=function(W,fe){return W+fe.join("")},sp=/^[A-Za-z_]/,Qf=Eu([["A","Z"],["a","z"],"_"],!1,!1),Pf=/^[A-Za-z0-9_]/,no=Eu([["A","Z"],["a","z"],["0","9"],"_"],!1,!1),nc=/^[A-Za-z0-9_:\u4E00-\u9FA5\xC0-\u017F]/,Ec=Eu([["A","Z"],["a","z"],["0","9"],"_",":",["\u4E00","\u9FA5"],["\xC0","\u017F"]],!1,!1),Mf=os(":",!1),Pd=os("OVER",!0),Fp=os("filter",!0),Z0=os("BOTH",!0),Md=os("LEADING",!0),zp=os("TRAILING",!0),Cp=os("trim",!0),s0=os("AT TIME ZONE",!0),jd=os("CENTURY",!0),gd=os("DAY",!0),gl=os("DATE",!0),yd=os("DECADE",!0),fb=os("DOW",!0),o0=os("DOY",!0),Lp=os("EPOCH",!0),rc=os("HOUR",!0),Ac=os("ISODOW",!0),op=os("ISOYEAR",!0),i0=os("MICROSECONDS",!0),Fa=os("MILLENNIUM",!0),_c=os("MILLISECONDS",!0),Sc=os("MINUTE",!0),K0=os("MONTH",!0),Ep=os("QUARTER",!0),ip=os("SECOND",!0),Fd=os("TIMEZONE",!0),a0=os("TIMEZONE_HOUR",!0),J0=os("TIMEZONE_MINUTE",!0),x0=os("WEEK",!0),Fl=os("YEAR",!0),Ic=os("u&",!0),qc=function(W,fe){return{type:W.toLowerCase(),value:fe[1].join("")}},Gp=/^[^"\\\0-\x1F\x7F]/,ap=Eu(['"',"\\",["\0",""],"\x7F"],!0,!1),Ap=/^[^'\\]/,wd=Eu(["'","\\"],!0,!1),_p=os("\\'",!1),Bp=os('\\"',!1),k0=os("\\\\",!1),Cd=os("\\/",!1),sc=os("\\b",!1),zd=os("\\f",!1),vt=os("\\n",!1),gn=os("\\r",!1),Yn=os("\\t",!1),On=os("\\u",!1),Kr=os("\\",!1),Vr=os("''",!1),us=os('""',!1),Ds=os("``",!1),Os=/^[\n\r]/,lo=Eu([`
|
|
142
|
+
`,f)+1}return{type:r,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(r){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let f=iE(r),h=Xg(f);return h.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let f=iE(r),h=Xg(f);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(r,f){return this.type!=="comment"||this.indent<=f?!1:r.every(h=>h.type==="newline"||h.type==="space")}*documentEnd(r){this.type!=="doc-mode"&&(r.end?r.end.push(this.sourceToken):r.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(r){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:r.end?r.end.push(this.sourceToken):r.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};E2.Parser=JI});var T2=La($w=>{"use strict";var A2=MI(),O9=_w(),Ow=Tw(),$9=US(),D9=A0(),U9=KI(),_2=XI();function S2(n){let r=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||r&&new U9.LineCounter||null,prettyErrors:r}}function P9(n,r={}){let{lineCounter:f,prettyErrors:h}=S2(r),l=new _2.Parser(f?.addNewLine),t=new A2.Composer(r),$=Array.from(t.compose(l.parse(n)));if(h&&f)for(let re of $)re.errors.forEach(Ow.prettifyError(n,f)),re.warnings.forEach(Ow.prettifyError(n,f));return $.length>0?$:Object.assign([],{empty:!0},t.streamInfo())}function I2(n,r={}){let{lineCounter:f,prettyErrors:h}=S2(r),l=new _2.Parser(f?.addNewLine),t=new A2.Composer(r),$=null;for(let re of t.compose(l.parse(n),!0,n.length))if(!$)$=re;else if($.options.logLevel!=="silent"){$.errors.push(new Ow.YAMLParseError(re.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return h&&f&&($.errors.forEach(Ow.prettifyError(n,f)),$.warnings.forEach(Ow.prettifyError(n,f))),$}function M9(n,r,f){let h;typeof r=="function"?h=r:f===void 0&&r&&typeof r=="object"&&(f=r);let l=I2(n,f);if(!l)return null;if(l.warnings.forEach(t=>$9.warn(l.options.logLevel,t)),l.errors.length>0){if(l.options.logLevel!=="silent")throw l.errors[0];l.errors=[]}return l.toJS(Object.assign({reviver:h},f))}function j9(n,r,f){let h=null;if(typeof r=="function"||Array.isArray(r)?h=r:f===void 0&&r&&(f=r),typeof f=="string"&&(f=f.length),typeof f=="number"){let l=Math.round(f);f=l<1?void 0:l>8?{indent:8}:{indent:l}}if(n===void 0){let{keepUndefined:l}=f??r??{};if(!l)return}return D9.isDocument(n)&&!h?n.toString(f):new O9.Document(n,h,f).toString(f)}$w.parse=M9;$w.parseAllDocuments=P9;$w.parseDocument=I2;$w.stringify=j9});var ih=La(Hb=>{"use strict";var F9=MI(),z9=_w(),G9=gI(),QI=Tw(),B9=lw(),Yh=A0(),q9=Gh(),V9=Yv(),H9=qh(),Y9=Vh(),W9=sE(),Z9=WI(),K9=KI(),J9=XI(),uE=T2(),x2=ow();Hb.Composer=F9.Composer;Hb.Document=z9.Document;Hb.Schema=G9.Schema;Hb.YAMLError=QI.YAMLError;Hb.YAMLParseError=QI.YAMLParseError;Hb.YAMLWarning=QI.YAMLWarning;Hb.Alias=B9.Alias;Hb.isAlias=Yh.isAlias;Hb.isCollection=Yh.isCollection;Hb.isDocument=Yh.isDocument;Hb.isMap=Yh.isMap;Hb.isNode=Yh.isNode;Hb.isPair=Yh.isPair;Hb.isScalar=Yh.isScalar;Hb.isSeq=Yh.isSeq;Hb.Pair=q9.Pair;Hb.Scalar=V9.Scalar;Hb.YAMLMap=H9.YAMLMap;Hb.YAMLSeq=Y9.YAMLSeq;Hb.CST=W9;Hb.Lexer=Z9.Lexer;Hb.LineCounter=K9.LineCounter;Hb.Parser=J9.Parser;Hb.parse=uE.parse;Hb.parseAllDocuments=uE.parseAllDocuments;Hb.parseDocument=uE.parseDocument;Hb.stringify=uE.stringify;Hb.visit=x2.visit;Hb.visitAsync=x2.visitAsync});var Dj=La((ooe,Z_)=>{var Qv=(function(n){"use strict";var r=1e7,f=7,h=9007199254740992,l=gt(h),t="0123456789abcdefghijklmnopqrstuvwxyz",$=typeof BigInt=="function";function re(Ir,ns,ms,js){return typeof Ir>"u"?re[0]:typeof ns<"u"?+ns==10&&!ms?Qi(Ir):dd(Ir,ns,ms,js):Qi(Ir)}function e(Ir,ns){this.value=Ir,this.sign=ns,this.isSmall=!1}e.prototype=Object.create(re.prototype);function qe(Ir){this.value=Ir,this.sign=Ir<0,this.isSmall=!0}qe.prototype=Object.create(re.prototype);function ht(Ir){this.value=Ir}ht.prototype=Object.create(re.prototype);function Ke(Ir){return-h<Ir&&Ir<h}function gt(Ir){return Ir<1e7?[Ir]:Ir<1e14?[Ir%1e7,Math.floor(Ir/1e7)]:[Ir%1e7,Math.floor(Ir/1e7)%1e7,Math.floor(Ir/1e14)]}function ln(Ir){Qn(Ir);var ns=Ir.length;if(ns<4&&Tl(Ir,l)<0)switch(ns){case 0:return 0;case 1:return Ir[0];case 2:return Ir[0]+Ir[1]*r;default:return Ir[0]+(Ir[1]+Ir[2]*r)*r}return Ir}function Qn(Ir){for(var ns=Ir.length;Ir[--ns]===0;);Ir.length=ns+1}function bn(Ir){for(var ns=new Array(Ir),ms=-1;++ms<Ir;)ns[ms]=0;return ns}function zr(Ir){return Ir>0?Math.floor(Ir):Math.ceil(Ir)}function tr(Ir,ns){var ms=Ir.length,js=ns.length,oo=new Array(ms),Vs=0,xo=r,No,Po;for(Po=0;Po<js;Po++)No=Ir[Po]+ns[Po]+Vs,Vs=No>=xo?1:0,oo[Po]=No-Vs*xo;for(;Po<ms;)No=Ir[Po]+Vs,Vs=No===xo?1:0,oo[Po++]=No-Vs*xo;return Vs>0&&oo.push(Vs),oo}function Er(Ir,ns){return Ir.length>=ns.length?tr(Ir,ns):tr(ns,Ir)}function cs(Ir,ns){var ms=Ir.length,js=new Array(ms),oo=r,Vs,xo;for(xo=0;xo<ms;xo++)Vs=Ir[xo]-oo+ns,ns=Math.floor(Vs/oo),js[xo]=Vs-ns*oo,ns+=1;for(;ns>0;)js[xo++]=ns%oo,ns=Math.floor(ns/oo);return js}e.prototype.add=function(Ir){var ns=Qi(Ir);if(this.sign!==ns.sign)return this.subtract(ns.negate());var ms=this.value,js=ns.value;return ns.isSmall?new e(cs(ms,Math.abs(js)),this.sign):new e(Er(ms,js),this.sign)},e.prototype.plus=e.prototype.add,qe.prototype.add=function(Ir){var ns=Qi(Ir),ms=this.value;if(ms<0!==ns.sign)return this.subtract(ns.negate());var js=ns.value;if(ns.isSmall){if(Ke(ms+js))return new qe(ms+js);js=gt(Math.abs(js))}return new e(cs(js,Math.abs(ms)),ms<0)},qe.prototype.plus=qe.prototype.add,ht.prototype.add=function(Ir){return new ht(this.value+Qi(Ir).value)},ht.prototype.plus=ht.prototype.add;function Ys(Ir,ns){var ms=Ir.length,js=ns.length,oo=new Array(ms),Vs=0,xo=r,No,Po;for(No=0;No<js;No++)Po=Ir[No]-Vs-ns[No],Po<0?(Po+=xo,Vs=1):Vs=0,oo[No]=Po;for(No=js;No<ms;No++){if(Po=Ir[No]-Vs,Po<0)Po+=xo;else{oo[No++]=Po;break}oo[No]=Po}for(;No<ms;No++)oo[No]=Ir[No];return Qn(oo),oo}function ao(Ir,ns,ms){var js;return Tl(Ir,ns)>=0?js=Ys(Ir,ns):(js=Ys(ns,Ir),ms=!ms),js=ln(js),typeof js=="number"?(ms&&(js=-js),new qe(js)):new e(js,ms)}function uo(Ir,ns,ms){var js=Ir.length,oo=new Array(js),Vs=-ns,xo=r,No,Po;for(No=0;No<js;No++)Po=Ir[No]+Vs,Vs=Math.floor(Po/xo),Po%=xo,oo[No]=Po<0?Po+xo:Po;return oo=ln(oo),typeof oo=="number"?(ms&&(oo=-oo),new qe(oo)):new e(oo,ms)}e.prototype.subtract=function(Ir){var ns=Qi(Ir);if(this.sign!==ns.sign)return this.add(ns.negate());var ms=this.value,js=ns.value;return ns.isSmall?uo(ms,Math.abs(js),this.sign):ao(ms,js,this.sign)},e.prototype.minus=e.prototype.subtract,qe.prototype.subtract=function(Ir){var ns=Qi(Ir),ms=this.value;if(ms<0!==ns.sign)return this.add(ns.negate());var js=ns.value;return ns.isSmall?new qe(ms-js):uo(js,Math.abs(ms),ms>=0)},qe.prototype.minus=qe.prototype.subtract,ht.prototype.subtract=function(Ir){return new ht(this.value-Qi(Ir).value)},ht.prototype.minus=ht.prototype.subtract,e.prototype.negate=function(){return new e(this.value,!this.sign)},qe.prototype.negate=function(){var Ir=this.sign,ns=new qe(-this.value);return ns.sign=!Ir,ns},ht.prototype.negate=function(){return new ht(-this.value)},e.prototype.abs=function(){return new e(this.value,!1)},qe.prototype.abs=function(){return new qe(Math.abs(this.value))},ht.prototype.abs=function(){return new ht(this.value>=0?this.value:-this.value)};function ni(Ir,ns){var ms=Ir.length,js=ns.length,oo=ms+js,Vs=bn(oo),xo=r,No,Po,na,Ra,aa;for(na=0;na<ms;++na){Ra=Ir[na];for(var Va=0;Va<js;++Va)aa=ns[Va],No=Ra*aa+Vs[na+Va],Po=Math.floor(No/xo),Vs[na+Va]=No-Po*xo,Vs[na+Va+1]+=Po}return Qn(Vs),Vs}function zo(Ir,ns){var ms=Ir.length,js=new Array(ms),oo=r,Vs=0,xo,No;for(No=0;No<ms;No++)xo=Ir[No]*ns+Vs,Vs=Math.floor(xo/oo),js[No]=xo-Vs*oo;for(;Vs>0;)js[No++]=Vs%oo,Vs=Math.floor(Vs/oo);return js}function ta(Ir,ns){for(var ms=[];ns-- >0;)ms.push(0);return ms.concat(Ir)}function Ha(Ir,ns){var ms=Math.max(Ir.length,ns.length);if(ms<=30)return ni(Ir,ns);ms=Math.ceil(ms/2);var js=Ir.slice(ms),oo=Ir.slice(0,ms),Vs=ns.slice(ms),xo=ns.slice(0,ms),No=Ha(oo,xo),Po=Ha(js,Vs),na=Ha(Er(oo,js),Er(xo,Vs)),Ra=Er(Er(No,ta(Ys(Ys(na,No),Po),ms)),ta(Po,2*ms));return Qn(Ra),Ra}function ja(Ir,ns){return-.012*Ir-.012*ns+15e-6*Ir*ns>0}e.prototype.multiply=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo=this.sign!==ns.sign,Vs;if(ns.isSmall){if(js===0)return re[0];if(js===1)return this;if(js===-1)return this.negate();if(Vs=Math.abs(js),Vs<r)return new e(zo(ms,Vs),oo);js=gt(Vs)}return ja(ms.length,js.length)?new e(Ha(ms,js),oo):new e(ni(ms,js),oo)},e.prototype.times=e.prototype.multiply;function Aa(Ir,ns,ms){return Ir<r?new e(zo(ns,Ir),ms):new e(ni(ns,gt(Ir)),ms)}qe.prototype._multiplyBySmall=function(Ir){return Ke(Ir.value*this.value)?new qe(Ir.value*this.value):Aa(Math.abs(Ir.value),gt(Math.abs(this.value)),this.sign!==Ir.sign)},e.prototype._multiplyBySmall=function(Ir){return Ir.value===0?re[0]:Ir.value===1?this:Ir.value===-1?this.negate():Aa(Math.abs(Ir.value),this.value,this.sign!==Ir.sign)},qe.prototype.multiply=function(Ir){return Qi(Ir)._multiplyBySmall(this)},qe.prototype.times=qe.prototype.multiply,ht.prototype.multiply=function(Ir){return new ht(this.value*Qi(Ir).value)},ht.prototype.times=ht.prototype.multiply;function cl(Ir){var ns=Ir.length,ms=bn(ns+ns),js=r,oo,Vs,xo,No,Po;for(xo=0;xo<ns;xo++){No=Ir[xo],Vs=0-No*No;for(var na=xo;na<ns;na++)Po=Ir[na],oo=2*(No*Po)+ms[xo+na]+Vs,Vs=Math.floor(oo/js),ms[xo+na]=oo-Vs*js;ms[xo+ns]=Vs}return Qn(ms),ms}e.prototype.square=function(){return new e(cl(this.value),!1)},qe.prototype.square=function(){var Ir=this.value*this.value;return Ke(Ir)?new qe(Ir):new e(cl(gt(Math.abs(this.value))),!1)},ht.prototype.square=function(Ir){return new ht(this.value*this.value)};function nl(Ir,ns){var ms=Ir.length,js=ns.length,oo=r,Vs=bn(ns.length),xo=ns[js-1],No=Math.ceil(oo/(2*xo)),Po=zo(Ir,No),na=zo(ns,No),Ra,aa,Va,Cu,uu,lu,ec;for(Po.length<=ms&&Po.push(0),na.push(0),xo=na[js-1],aa=ms-js;aa>=0;aa--){for(Ra=oo-1,Po[aa+js]!==xo&&(Ra=Math.floor((Po[aa+js]*oo+Po[aa+js-1])/xo)),Va=0,Cu=0,lu=na.length,uu=0;uu<lu;uu++)Va+=Ra*na[uu],ec=Math.floor(Va/oo),Cu+=Po[aa+uu]-(Va-ec*oo),Va=ec,Cu<0?(Po[aa+uu]=Cu+oo,Cu=-1):(Po[aa+uu]=Cu,Cu=0);for(;Cu!==0;){for(Ra-=1,Va=0,uu=0;uu<lu;uu++)Va+=Po[aa+uu]-oo+na[uu],Va<0?(Po[aa+uu]=Va+oo,Va=0):(Po[aa+uu]=Va,Va=1);Cu+=Va}Vs[aa]=Ra}return Po=cd(Po,No)[0],[ln(Vs),ln(Po)]}function lf(Ir,ns){for(var ms=Ir.length,js=ns.length,oo=[],Vs=[],xo=r,No,Po,na,Ra,aa;ms;){if(Vs.unshift(Ir[--ms]),Qn(Vs),Tl(Vs,ns)<0){oo.push(0);continue}Po=Vs.length,na=Vs[Po-1]*xo+Vs[Po-2],Ra=ns[js-1]*xo+ns[js-2],Po>js&&(na=(na+1)*xo),No=Math.ceil(na/Ra);do{if(aa=zo(ns,No),Tl(aa,Vs)<=0)break;No--}while(No);oo.push(No),Vs=Ys(Vs,aa)}return oo.reverse(),[ln(oo),ln(Vs)]}function cd(Ir,ns){var ms=Ir.length,js=bn(ms),oo=r,Vs,xo,No,Po;for(No=0,Vs=ms-1;Vs>=0;--Vs)Po=No*oo+Ir[Vs],xo=zr(Po/ns),No=Po-xo*ns,js[Vs]=xo|0;return[js,No|0]}function Il(Ir,ns){var ms,js=Qi(ns);if($)return[new ht(Ir.value/js.value),new ht(Ir.value%js.value)];var oo=Ir.value,Vs=js.value,xo;if(Vs===0)throw new Error("Cannot divide by zero");if(Ir.isSmall)return js.isSmall?[new qe(zr(oo/Vs)),new qe(oo%Vs)]:[re[0],Ir];if(js.isSmall){if(Vs===1)return[Ir,re[0]];if(Vs==-1)return[Ir.negate(),re[0]];var No=Math.abs(Vs);if(No<r){ms=cd(oo,No),xo=ln(ms[0]);var Po=ms[1];return Ir.sign&&(Po=-Po),typeof xo=="number"?(Ir.sign!==js.sign&&(xo=-xo),[new qe(xo),new qe(Po)]):[new e(xo,Ir.sign!==js.sign),new qe(Po)]}Vs=gt(No)}var na=Tl(oo,Vs);if(na===-1)return[re[0],Ir];if(na===0)return[re[Ir.sign===js.sign?1:-1],re[0]];oo.length+Vs.length<=200?ms=nl(oo,Vs):ms=lf(oo,Vs),xo=ms[0];var Ra=Ir.sign!==js.sign,aa=ms[1],Va=Ir.sign;return typeof xo=="number"?(Ra&&(xo=-xo),xo=new qe(xo)):xo=new e(xo,Ra),typeof aa=="number"?(Va&&(aa=-aa),aa=new qe(aa)):aa=new e(aa,Va),[xo,aa]}e.prototype.divmod=function(Ir){var ns=Il(this,Ir);return{quotient:ns[0],remainder:ns[1]}},ht.prototype.divmod=qe.prototype.divmod=e.prototype.divmod,e.prototype.divide=function(Ir){return Il(this,Ir)[0]},ht.prototype.over=ht.prototype.divide=function(Ir){return new ht(this.value/Qi(Ir).value)},qe.prototype.over=qe.prototype.divide=e.prototype.over=e.prototype.divide,e.prototype.mod=function(Ir){return Il(this,Ir)[1]},ht.prototype.mod=ht.prototype.remainder=function(Ir){return new ht(this.value%Qi(Ir).value)},qe.prototype.remainder=qe.prototype.mod=e.prototype.remainder=e.prototype.mod,e.prototype.pow=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo,Vs,xo;if(js===0)return re[1];if(ms===0)return re[0];if(ms===1)return re[1];if(ms===-1)return ns.isEven()?re[1]:re[-1];if(ns.sign)return re[0];if(!ns.isSmall)throw new Error("The exponent "+ns.toString()+" is too large.");if(this.isSmall&&Ke(oo=Math.pow(ms,js)))return new qe(zr(oo));for(Vs=this,xo=re[1];js&!0&&(xo=xo.times(Vs),--js),js!==0;)js/=2,Vs=Vs.square();return xo},qe.prototype.pow=e.prototype.pow,ht.prototype.pow=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value,oo=BigInt(0),Vs=BigInt(1),xo=BigInt(2);if(js===oo)return re[1];if(ms===oo)return re[0];if(ms===Vs)return re[1];if(ms===BigInt(-1))return ns.isEven()?re[1]:re[-1];if(ns.isNegative())return new ht(oo);for(var No=this,Po=re[1];(js&Vs)===Vs&&(Po=Po.times(No),--js),js!==oo;)js/=xo,No=No.square();return Po},e.prototype.modPow=function(Ir,ns){if(Ir=Qi(Ir),ns=Qi(ns),ns.isZero())throw new Error("Cannot take modPow with modulus 0");var ms=re[1],js=this.mod(ns);for(Ir.isNegative()&&(Ir=Ir.multiply(re[-1]),js=js.modInv(ns));Ir.isPositive();){if(js.isZero())return re[0];Ir.isOdd()&&(ms=ms.multiply(js).mod(ns)),Ir=Ir.divide(2),js=js.square().mod(ns)}return ms},ht.prototype.modPow=qe.prototype.modPow=e.prototype.modPow;function Tl(Ir,ns){if(Ir.length!==ns.length)return Ir.length>ns.length?1:-1;for(var ms=Ir.length-1;ms>=0;ms--)if(Ir[ms]!==ns[ms])return Ir[ms]>ns[ms]?1:-1;return 0}e.prototype.compareAbs=function(Ir){var ns=Qi(Ir),ms=this.value,js=ns.value;return ns.isSmall?1:Tl(ms,js)},qe.prototype.compareAbs=function(Ir){var ns=Qi(Ir),ms=Math.abs(this.value),js=ns.value;return ns.isSmall?(js=Math.abs(js),ms===js?0:ms>js?1:-1):-1},ht.prototype.compareAbs=function(Ir){var ns=this.value,ms=Qi(Ir).value;return ns=ns>=0?ns:-ns,ms=ms>=0?ms:-ms,ns===ms?0:ns>ms?1:-1},e.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=Qi(Ir),ms=this.value,js=ns.value;return this.sign!==ns.sign?ns.sign?1:-1:ns.isSmall?this.sign?-1:1:Tl(ms,js)*(this.sign?-1:1)},e.prototype.compareTo=e.prototype.compare,qe.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=Qi(Ir),ms=this.value,js=ns.value;return ns.isSmall?ms==js?0:ms>js?1:-1:ms<0!==ns.sign?ms<0?-1:1:ms<0?1:-1},qe.prototype.compareTo=qe.prototype.compare,ht.prototype.compare=function(Ir){if(Ir===1/0)return-1;if(Ir===-1/0)return 1;var ns=this.value,ms=Qi(Ir).value;return ns===ms?0:ns>ms?1:-1},ht.prototype.compareTo=ht.prototype.compare,e.prototype.equals=function(Ir){return this.compare(Ir)===0},ht.prototype.eq=ht.prototype.equals=qe.prototype.eq=qe.prototype.equals=e.prototype.eq=e.prototype.equals,e.prototype.notEquals=function(Ir){return this.compare(Ir)!==0},ht.prototype.neq=ht.prototype.notEquals=qe.prototype.neq=qe.prototype.notEquals=e.prototype.neq=e.prototype.notEquals,e.prototype.greater=function(Ir){return this.compare(Ir)>0},ht.prototype.gt=ht.prototype.greater=qe.prototype.gt=qe.prototype.greater=e.prototype.gt=e.prototype.greater,e.prototype.lesser=function(Ir){return this.compare(Ir)<0},ht.prototype.lt=ht.prototype.lesser=qe.prototype.lt=qe.prototype.lesser=e.prototype.lt=e.prototype.lesser,e.prototype.greaterOrEquals=function(Ir){return this.compare(Ir)>=0},ht.prototype.geq=ht.prototype.greaterOrEquals=qe.prototype.geq=qe.prototype.greaterOrEquals=e.prototype.geq=e.prototype.greaterOrEquals,e.prototype.lesserOrEquals=function(Ir){return this.compare(Ir)<=0},ht.prototype.leq=ht.prototype.lesserOrEquals=qe.prototype.leq=qe.prototype.lesserOrEquals=e.prototype.leq=e.prototype.lesserOrEquals,e.prototype.isEven=function(){return(this.value[0]&1)===0},qe.prototype.isEven=function(){return(this.value&1)===0},ht.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},e.prototype.isOdd=function(){return(this.value[0]&1)===1},qe.prototype.isOdd=function(){return(this.value&1)===1},ht.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},e.prototype.isPositive=function(){return!this.sign},qe.prototype.isPositive=function(){return this.value>0},ht.prototype.isPositive=qe.prototype.isPositive,e.prototype.isNegative=function(){return this.sign},qe.prototype.isNegative=function(){return this.value<0},ht.prototype.isNegative=qe.prototype.isNegative,e.prototype.isUnit=function(){return!1},qe.prototype.isUnit=function(){return Math.abs(this.value)===1},ht.prototype.isUnit=function(){return this.abs().value===BigInt(1)},e.prototype.isZero=function(){return!1},qe.prototype.isZero=function(){return this.value===0},ht.prototype.isZero=function(){return this.value===BigInt(0)},e.prototype.isDivisibleBy=function(Ir){var ns=Qi(Ir);return ns.isZero()?!1:ns.isUnit()?!0:ns.compareAbs(2)===0?this.isEven():this.mod(ns).isZero()},ht.prototype.isDivisibleBy=qe.prototype.isDivisibleBy=e.prototype.isDivisibleBy;function cf(Ir){var ns=Ir.abs();if(ns.isUnit())return!1;if(ns.equals(2)||ns.equals(3)||ns.equals(5))return!0;if(ns.isEven()||ns.isDivisibleBy(3)||ns.isDivisibleBy(5))return!1;if(ns.lesser(49))return!0}function xf(Ir,ns){for(var ms=Ir.prev(),js=ms,oo=0,Vs,xo,No,Po;js.isEven();)js=js.divide(2),oo++;e:for(No=0;No<ns.length;No++)if(!Ir.lesser(ns[No])&&(Po=Qv(ns[No]).modPow(js,Ir),!(Po.isUnit()||Po.equals(ms)))){for(Vs=oo-1;Vs!=0;Vs--){if(Po=Po.square().mod(Ir),Po.isUnit())return!1;if(Po.equals(ms))continue e}return!1}return!0}e.prototype.isPrime=function(Ir){var ns=cf(this);if(ns!==n)return ns;var ms=this.abs(),js=ms.bitLength();if(js<=64)return xf(ms,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var oo=Math.log(2)*js.toJSNumber(),Vs=Math.ceil(Ir===!0?2*Math.pow(oo,2):oo),xo=[],No=0;No<Vs;No++)xo.push(Qv(No+2));return xf(ms,xo)},ht.prototype.isPrime=qe.prototype.isPrime=e.prototype.isPrime,e.prototype.isProbablePrime=function(Ir,ns){var ms=cf(this);if(ms!==n)return ms;for(var js=this.abs(),oo=Ir===n?5:Ir,Vs=[],xo=0;xo<oo;xo++)Vs.push(Qv.randBetween(2,js.minus(2),ns));return xf(js,Vs)},ht.prototype.isProbablePrime=qe.prototype.isProbablePrime=e.prototype.isProbablePrime,e.prototype.modInv=function(Ir){for(var ns=Qv.zero,ms=Qv.one,js=Qi(Ir),oo=this.abs(),Vs,xo,No;!oo.isZero();)Vs=js.divide(oo),xo=ns,No=js,ns=ms,js=oo,ms=xo.subtract(Vs.multiply(ms)),oo=No.subtract(Vs.multiply(oo));if(!js.isUnit())throw new Error(this.toString()+" and "+Ir.toString()+" are not co-prime");return ns.compare(0)===-1&&(ns=ns.add(Ir)),this.isNegative()?ns.negate():ns},ht.prototype.modInv=qe.prototype.modInv=e.prototype.modInv,e.prototype.next=function(){var Ir=this.value;return this.sign?uo(Ir,1,this.sign):new e(cs(Ir,1),this.sign)},qe.prototype.next=function(){var Ir=this.value;return Ir+1<h?new qe(Ir+1):new e(l,!1)},ht.prototype.next=function(){return new ht(this.value+BigInt(1))},e.prototype.prev=function(){var Ir=this.value;return this.sign?new e(cs(Ir,1),!0):uo(Ir,1,this.sign)},qe.prototype.prev=function(){var Ir=this.value;return Ir-1>-h?new qe(Ir-1):new e(l,!0)},ht.prototype.prev=function(){return new ht(this.value-BigInt(1))};for(var xu=[1];2*xu[xu.length-1]<=r;)xu.push(2*xu[xu.length-1]);var Qd=xu.length,jl=xu[Qd-1];function Od(Ir){return Math.abs(Ir)<=r}e.prototype.shiftLeft=function(Ir){var ns=Qi(Ir).toJSNumber();if(!Od(ns))throw new Error(String(ns)+" is too large for shifting.");if(ns<0)return this.shiftRight(-ns);var ms=this;if(ms.isZero())return ms;for(;ns>=Qd;)ms=ms.multiply(jl),ns-=Qd-1;return ms.multiply(xu[ns])},ht.prototype.shiftLeft=qe.prototype.shiftLeft=e.prototype.shiftLeft,e.prototype.shiftRight=function(Ir){var ns,ms=Qi(Ir).toJSNumber();if(!Od(ms))throw new Error(String(ms)+" is too large for shifting.");if(ms<0)return this.shiftLeft(-ms);for(var js=this;ms>=Qd;){if(js.isZero()||js.isNegative()&&js.isUnit())return js;ns=Il(js,jl),js=ns[1].isNegative()?ns[0].prev():ns[0],ms-=Qd-1}return ns=Il(js,xu[ms]),ns[1].isNegative()?ns[0].prev():ns[0]},ht.prototype.shiftRight=qe.prototype.shiftRight=e.prototype.shiftRight;function $d(Ir,ns,ms){ns=Qi(ns);for(var js=Ir.isNegative(),oo=ns.isNegative(),Vs=js?Ir.not():Ir,xo=oo?ns.not():ns,No=0,Po=0,na=null,Ra=null,aa=[];!Vs.isZero()||!xo.isZero();)na=Il(Vs,jl),No=na[1].toJSNumber(),js&&(No=jl-1-No),Ra=Il(xo,jl),Po=Ra[1].toJSNumber(),oo&&(Po=jl-1-Po),Vs=na[0],xo=Ra[0],aa.push(ms(No,Po));for(var Va=ms(js?1:0,oo?1:0)!==0?Qv(-1):Qv(0),Cu=aa.length-1;Cu>=0;Cu-=1)Va=Va.multiply(jl).add(Qv(aa[Cu]));return Va}e.prototype.not=function(){return this.negate().prev()},ht.prototype.not=qe.prototype.not=e.prototype.not,e.prototype.and=function(Ir){return $d(this,Ir,function(ns,ms){return ns&ms})},ht.prototype.and=qe.prototype.and=e.prototype.and,e.prototype.or=function(Ir){return $d(this,Ir,function(ns,ms){return ns|ms})},ht.prototype.or=qe.prototype.or=e.prototype.or,e.prototype.xor=function(Ir){return $d(this,Ir,function(ns,ms){return ns^ms})},ht.prototype.xor=qe.prototype.xor=e.prototype.xor;var wp=1<<30,Zf=(r&-r)*(r&-r)|wp;function ml(Ir){var ns=Ir.value,ms=typeof ns=="number"?ns|wp:typeof ns=="bigint"?ns|BigInt(wp):ns[0]+ns[1]*r|Zf;return ms&-ms}function Dd(Ir,ns){if(ns.compareTo(Ir)<=0){var ms=Dd(Ir,ns.square(ns)),js=ms.p,oo=ms.e,Vs=js.multiply(ns);return Vs.compareTo(Ir)<=0?{p:Vs,e:oo*2+1}:{p:js,e:oo*2}}return{p:Qv(1),e:0}}e.prototype.bitLength=function(){var Ir=this;return Ir.compareTo(Qv(0))<0&&(Ir=Ir.negate().subtract(Qv(1))),Ir.compareTo(Qv(0))===0?Qv(0):Qv(Dd(Ir,Qv(2)).e).add(Qv(1))},ht.prototype.bitLength=qe.prototype.bitLength=e.prototype.bitLength;function Cc(Ir,ns){return Ir=Qi(Ir),ns=Qi(ns),Ir.greater(ns)?Ir:ns}function Kf(Ir,ns){return Ir=Qi(Ir),ns=Qi(ns),Ir.lesser(ns)?Ir:ns}function kf(Ir,ns){if(Ir=Qi(Ir).abs(),ns=Qi(ns).abs(),Ir.equals(ns))return Ir;if(Ir.isZero())return ns;if(ns.isZero())return Ir;for(var ms=re[1],js,oo;Ir.isEven()&&ns.isEven();)js=Kf(ml(Ir),ml(ns)),Ir=Ir.divide(js),ns=ns.divide(js),ms=ms.multiply(js);for(;Ir.isEven();)Ir=Ir.divide(ml(Ir));do{for(;ns.isEven();)ns=ns.divide(ml(ns));Ir.greater(ns)&&(oo=ns,ns=Ir,Ir=oo),ns=ns.subtract(Ir)}while(!ns.isZero());return ms.isUnit()?Ir:Ir.multiply(ms)}function fd(Ir,ns){return Ir=Qi(Ir).abs(),ns=Qi(ns).abs(),Ir.divide(kf(Ir,ns)).multiply(ns)}function cb(Ir,ns,ms){Ir=Qi(Ir),ns=Qi(ns);var js=ms||Math.random,oo=Kf(Ir,ns),Vs=Cc(Ir,ns),xo=Vs.subtract(oo).add(1);if(xo.isSmall)return oo.add(Math.floor(js()*xo));for(var No=ku(xo,r).value,Po=[],na=!0,Ra=0;Ra<No.length;Ra++){var aa=na?No[Ra]+(Ra+1<No.length?No[Ra+1]/r:0):r,Va=zr(js()*aa);Po.push(Va),Va<No[Ra]&&(na=!1)}return oo.add(re.fromArray(Po,r,!1))}var dd=function(Ir,ns,ms,js){ms=ms||t,Ir=String(Ir),js||(Ir=Ir.toLowerCase(),ms=ms.toLowerCase());var oo=Ir.length,Vs,xo=Math.abs(ns),No={};for(Vs=0;Vs<ms.length;Vs++)No[ms[Vs]]=Vs;for(Vs=0;Vs<oo;Vs++){var Po=Ir[Vs];if(Po!=="-"&&Po in No&&No[Po]>=xo){if(Po==="1"&&xo===1)continue;throw new Error(Po+" is not a valid digit in base "+ns+".")}}ns=Qi(ns);var na=[],Ra=Ir[0]==="-";for(Vs=Ra?1:0;Vs<Ir.length;Vs++){var Po=Ir[Vs];if(Po in No)na.push(Qi(No[Po]));else if(Po==="<"){var aa=Vs;do Vs++;while(Ir[Vs]!==">"&&Vs<Ir.length);na.push(Qi(Ir.slice(aa+1,Vs)))}else throw new Error(Po+" is not a valid character")}return hl(na,ns,Ra)};function hl(Ir,ns,ms){var js=re[0],oo=re[1],Vs;for(Vs=Ir.length-1;Vs>=0;Vs--)js=js.add(Ir[Vs].times(oo)),oo=oo.times(ns);return ms?js.negate():js}function e0(Ir,ns){return ns=ns||t,Ir<ns.length?ns[Ir]:"<"+Ir+">"}function ku(Ir,ns){if(ns=Qv(ns),ns.isZero()){if(Ir.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(ns.equals(-1)){if(Ir.isZero())return{value:[0],isNegative:!1};if(Ir.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-Ir.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var ms=Array.apply(null,Array(Ir.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return ms.unshift([1]),{value:[].concat.apply([],ms),isNegative:!1}}var js=!1;if(Ir.isNegative()&&ns.isPositive()&&(js=!0,Ir=Ir.abs()),ns.isUnit())return Ir.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(Ir.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:js};for(var oo=[],Vs=Ir,xo;Vs.isNegative()||Vs.compareAbs(ns)>=0;){xo=Vs.divmod(ns),Vs=xo.quotient;var No=xo.remainder;No.isNegative()&&(No=ns.minus(No).abs(),Vs=Vs.next()),oo.push(No.toJSNumber())}return oo.push(Vs.toJSNumber()),{value:oo.reverse(),isNegative:js}}function Up(Ir,ns,ms){var js=ku(Ir,ns);return(js.isNegative?"-":"")+js.value.map(function(oo){return e0(oo,ms)}).join("")}e.prototype.toArray=function(Ir){return ku(this,Ir)},qe.prototype.toArray=function(Ir){return ku(this,Ir)},ht.prototype.toArray=function(Ir){return ku(this,Ir)},e.prototype.toString=function(Ir,ns){if(Ir===n&&(Ir=10),Ir!==10||ns)return Up(this,Ir,ns);for(var ms=this.value,js=ms.length,oo=String(ms[--js]),Vs="0000000",xo;--js>=0;)xo=String(ms[js]),oo+=Vs.slice(xo.length)+xo;var No=this.sign?"-":"";return No+oo},qe.prototype.toString=function(Ir,ns){return Ir===n&&(Ir=10),Ir!=10||ns?Up(this,Ir,ns):String(this.value)},ht.prototype.toString=qe.prototype.toString,ht.prototype.toJSON=e.prototype.toJSON=qe.prototype.toJSON=function(){return this.toString()},e.prototype.valueOf=function(){return parseInt(this.toString(),10)},e.prototype.toJSNumber=e.prototype.valueOf,qe.prototype.valueOf=function(){return this.value},qe.prototype.toJSNumber=qe.prototype.valueOf,ht.prototype.valueOf=ht.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function ep(Ir){if(Ke(+Ir)){var ns=+Ir;if(ns===zr(ns))return $?new ht(BigInt(ns)):new qe(ns);throw new Error("Invalid integer: "+Ir)}var ms=Ir[0]==="-";ms&&(Ir=Ir.slice(1));var js=Ir.split(/e/i);if(js.length>2)throw new Error("Invalid integer: "+js.join("e"));if(js.length===2){var oo=js[1];if(oo[0]==="+"&&(oo=oo.slice(1)),oo=+oo,oo!==zr(oo)||!Ke(oo))throw new Error("Invalid integer: "+oo+" is not a valid exponent.");var Vs=js[0],xo=Vs.indexOf(".");if(xo>=0&&(oo-=Vs.length-xo-1,Vs=Vs.slice(0,xo)+Vs.slice(xo+1)),oo<0)throw new Error("Cannot include negative exponent part for integers");Vs+=new Array(oo+1).join("0"),Ir=Vs}var No=/^([0-9][0-9]*)$/.test(Ir);if(!No)throw new Error("Invalid integer: "+Ir);if($)return new ht(BigInt(ms?"-"+Ir:Ir));for(var Po=[],na=Ir.length,Ra=f,aa=na-Ra;na>0;)Po.push(+Ir.slice(aa,na)),aa-=Ra,aa<0&&(aa=0),na-=Ra;return Qn(Po),new e(Po,ms)}function pd(Ir){if($)return new ht(BigInt(Ir));if(Ke(Ir)){if(Ir!==zr(Ir))throw new Error(Ir+" is not an integer.");return new qe(Ir)}return ep(Ir.toString())}function Qi(Ir){return typeof Ir=="number"?pd(Ir):typeof Ir=="string"?ep(Ir):typeof Ir=="bigint"?new ht(Ir):Ir}for(var Vu=0;Vu<1e3;Vu++)re[Vu]=Qi(Vu),Vu>0&&(re[-Vu]=Qi(-Vu));return re.one=re[1],re.zero=re[0],re.minusOne=re[-1],re.max=Cc,re.min=Kf,re.gcd=kf,re.lcm=fd,re.isInstance=function(Ir){return Ir instanceof e||Ir instanceof qe||Ir instanceof ht},re.randBetween=cb,re.fromArray=function(Ir,ns,ms){return hl(Ir.map(Qi),Qi(ns||10),ms)},re})();typeof Z_<"u"&&Z_.hasOwnProperty("exports")&&(Z_.exports=Qv);typeof define=="function"&&define.amd&&define(function(){return Qv})});var Pj=La(Uj=>{(function(n,r){for(var f in r)n[f]=r[f]})(Uj,(function(n){var r={};function f(h){if(r[h])return r[h].exports;var l=r[h]={i:h,l:!1,exports:{}};return n[h].call(l.exports,l,l.exports,f),l.l=!0,l.exports}return f.m=n,f.c=r,f.d=function(h,l,t){f.o(h,l)||Object.defineProperty(h,l,{enumerable:!0,get:t})},f.r=function(h){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(h,"__esModule",{value:!0})},f.t=function(h,l){if(1&l&&(h=f(h)),8&l||4&l&&typeof h=="object"&&h&&h.__esModule)return h;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:h}),2&l&&typeof h!="string")for(var $ in h)f.d(t,$,function(re){return h[re]}.bind(null,$));return t},f.n=function(h){var l=h&&h.__esModule?function(){return h.default}:function(){return h};return f.d(l,"a",l),l},f.o=function(h,l){return Object.prototype.hasOwnProperty.call(h,l)},f.p="",f(f.s=15)})([function(n,r){n.exports=Dj()},function(n,r,f){"use strict";var h=f(0);function l(t,$,re,e){this.message=t,this.expected=$,this.found=re,this.location=e,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,l)}(function(t,$){function re(){this.constructor=t}re.prototype=$.prototype,t.prototype=new re})(l,Error),l.buildMessage=function(t,$){var re={literal:function(Ke){return'"'+qe(Ke.text)+'"'},class:function(Ke){var gt,ln="";for(gt=0;gt<Ke.parts.length;gt++)ln+=Ke.parts[gt]instanceof Array?ht(Ke.parts[gt][0])+"-"+ht(Ke.parts[gt][1]):ht(Ke.parts[gt]);return"["+(Ke.inverted?"^":"")+ln+"]"},any:function(Ke){return"any character"},end:function(Ke){return"end of input"},other:function(Ke){return Ke.description}};function e(Ke){return Ke.charCodeAt(0).toString(16).toUpperCase()}function qe(Ke){return Ke.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}function ht(Ke){return Ke.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}return"Expected "+(function(Ke){var gt,ln,Qn,bn=new Array(Ke.length);for(gt=0;gt<Ke.length;gt++)bn[gt]=(Qn=Ke[gt],re[Qn.type](Qn));if(bn.sort(),bn.length>0){for(gt=1,ln=1;gt<bn.length;gt++)bn[gt-1]!==bn[gt]&&(bn[ln]=bn[gt],ln++);bn.length=ln}switch(bn.length){case 1:return bn[0];case 2:return bn[0]+" or "+bn[1];default:return bn.slice(0,-1).join(", ")+", or "+bn[bn.length-1]}})(t)+" but "+(function(Ke){return Ke?'"'+qe(Ke)+'"':"end of input"})($)+" found."},n.exports={SyntaxError:l,parse:function(t,$){$=$!==void 0?$:{};var re,e={},qe={start:sl},ht=sl,Ke=function(W,fe){return rn(W,fe,1)},gt=os("IF",!0),ln=function(W,fe){return rn(W,fe)},Qn=os("AUTO_INCREMENT",!0),bn=os("UNIQUE",!0),zr=os("KEY",!0),tr=os("PRIMARY",!0),Er=os("COLUMN_FORMAT",!0),cs=os("FIXED",!0),Ys=os("DYNAMIC",!0),ao=os("DEFAULT",!0),uo=os("STORAGE",!0),ni=os("DISK",!0),zo=os("MEMORY",!0),ta=os("ALGORITHM",!0),Ha=os("INSTANT",!0),ja=os("INPLACE",!0),Aa=os("COPY",!0),cl=os("LOCK",!0),nl=os("NONE",!0),lf=os("SHARED",!0),cd=os("EXCLUSIVE",!0),Il=os("PRIMARY KEY",!0),Tl=os("FOREIGN KEY",!0),cf=os("MATCH FULL",!0),xf=os("MATCH PARTIAL",!0),xu=os("MATCH SIMPLE",!0),Qd=os("RESTRICT",!0),jl=os("CASCADE",!0),Od=os("SET NULL",!0),$d=os("NO ACTION",!0),wp=os("SET DEFAULT",!0),Zf=os("CHARACTER",!0),ml=os("SET",!0),Dd=os("CHARSET",!0),Cc=os("COLLATE",!0),Kf=os("AVG_ROW_LENGTH",!0),kf=os("KEY_BLOCK_SIZE",!0),fd=os("MAX_ROWS",!0),cb=os("MIN_ROWS",!0),dd=os("STATS_SAMPLE_PAGES",!0),hl=os("CONNECTION",!0),e0=os("COMPRESSION",!0),ku=os("'",!1),Up=os("ZLIB",!0),ep=os("LZ4",!0),pd=os("ENGINE",!0),Qi=os("READ",!0),Vu=os("LOCAL",!0),Ir=os("LOW_PRIORITY",!0),ns=os("WRITE",!0),ms=function(W,fe){return rn(W,fe)},js=os("(",!1),oo=os(")",!1),Vs=os(".",!1),xo=os("UNNEST",!0),No=os("BTREE",!0),Po=os("HASH",!0),na=os("WITH",!0),Ra=os("PARSER",!0),aa=os("VISIBLE",!0),Va=os("INVISIBLE",!0),Cu=function(W,fe){return fe.unshift(W),fe.forEach(Te=>{let{table:Ge,as:bt}=Te;fa[Ge]=Ge,bt&&(fa[bt]=Ge),(function(et){let s=Iu(et);et.clear(),s.forEach(Be=>et.add(Be))})(va)}),fe},uu=os("FOLLOWING",!0),lu=os("PRECEDING",!0),ec=os("CURRENT",!0),Pp=os("ROW",!0),Rf=os("UNBOUNDED",!0),Nf=os("=",!1),Of=function(W,fe){return Qu(W,fe)},ff=os("!",!1),$f=function(W){return W[0]+" "+W[2]},nf=os(">=",!1),_0=os(">",!1),S0=os("<=",!1),I0=os("<>",!1),Df=os("<",!1),df=os("==",!1),Mp=os("!=",!1),bd=function(W,fe){return{op:W,right:fe}},tc=os("+",!1),Jf=os("-",!1),tp=os("*",!1),t0=os("/",!1),H0=os("%",!1),vd=os("~",!1),Uf=os("?|",!1),md=os("?&",!1),Ud=os("?",!1),jp=os("#-",!1),Lu=os("#>>",!1),n0=os("#>",!1),np=os("@>",!1),r0=os("<@",!1),Xf=function(W){return da[W.toUpperCase()]===!0},Lc=os('"',!1),xl=/^[^"]/,Gc=Eu(['"'],!0,!1),Y0=/^[^']/,Bc=Eu(["'"],!0,!1),rp=os("`",!1),W0=/^[^`]/,hd=Eu(["`"],!0,!1),T0=function(W,fe){return W+fe.join("")},sp=/^[A-Za-z_]/,Qf=Eu([["A","Z"],["a","z"],"_"],!1,!1),Pf=/^[A-Za-z0-9_]/,no=Eu([["A","Z"],["a","z"],["0","9"],"_"],!1,!1),nc=/^[A-Za-z0-9_:\u4E00-\u9FA5\xC0-\u017F]/,Ec=Eu([["A","Z"],["a","z"],["0","9"],"_",":",["\u4E00","\u9FA5"],["\xC0","\u017F"]],!1,!1),Mf=os(":",!1),Pd=os("OVER",!0),Fp=os("filter",!0),Z0=os("BOTH",!0),Md=os("LEADING",!0),zp=os("TRAILING",!0),Cp=os("trim",!0),s0=os("AT TIME ZONE",!0),jd=os("CENTURY",!0),gd=os("DAY",!0),gl=os("DATE",!0),yd=os("DECADE",!0),fb=os("DOW",!0),o0=os("DOY",!0),Lp=os("EPOCH",!0),rc=os("HOUR",!0),Ac=os("ISODOW",!0),op=os("ISOYEAR",!0),i0=os("MICROSECONDS",!0),Fa=os("MILLENNIUM",!0),_c=os("MILLISECONDS",!0),Sc=os("MINUTE",!0),K0=os("MONTH",!0),Ep=os("QUARTER",!0),ip=os("SECOND",!0),Fd=os("TIMEZONE",!0),a0=os("TIMEZONE_HOUR",!0),J0=os("TIMEZONE_MINUTE",!0),x0=os("WEEK",!0),Fl=os("YEAR",!0),Ic=os("u&",!0),qc=function(W,fe){return{type:W.toLowerCase(),value:fe[1].join("")}},Gp=/^[^"\\\0-\x1F\x7F]/,ap=Eu(['"',"\\",["\0",""],"\x7F"],!0,!1),Ap=/^[^'\\]/,wd=Eu(["'","\\"],!0,!1),_p=os("\\'",!1),Bp=os('\\"',!1),k0=os("\\\\",!1),Cd=os("\\/",!1),sc=os("\\b",!1),zd=os("\\f",!1),vt=os("\\n",!1),gn=os("\\r",!1),Yn=os("\\t",!1),On=os("\\u",!1),Kr=os("\\",!1),Vr=os("''",!1),us=os('""',!1),Ds=os("``",!1),Os=/^[\n\r]/,lo=Eu([`
|
|
143
143
|
`,"\r"],!1,!1),ho=/^[0-9]/,Oo=Eu([["0","9"]],!1,!1),ui=/^[0-9a-fA-F]/,ri=Eu([["0","9"],["a","f"],["A","F"]],!1,!1),Oi=/^[eE]/,Wi=Eu(["e","E"],!1,!1),mi=/^[+\-]/,Zi=Eu(["+","-"],!1,!1),Bi=os("NULL",!0),_a=os("NOT NULL",!0),ga=os("TRUE",!0),cu=os("TO",!0),Da=os("FALSE",!0),Wu=(os("SHOW",!0),os("DROP",!0)),Na=os("USE",!0),rl=os("ALTER",!0),pf=os("SELECT",!0),Tc=os("UPDATE",!0),fl=os("CREATE",!0),up=os("TEMPORARY",!0),Gd=os("DELETE",!0),fu=os("INSERT",!0),kl=os("RECURSIVE",!0),bf=os("REPLACE",!0),Vc=os("RENAME",!0),u0=os("IGNORE",!0),X0=(os("EXPLAIN",!0),os("PARTITION",!0)),rf=os("INTO",!0),xc=os("OVERWRITE",!0),vf=os("FROM",!0),jf=os("UNLOCK",!0),Ff=os("AS",!0),lp=os("TABLE",!0),Wb=os("TABLES",!0),Q0=os("DATABASE",!0),Zb=os("SCHEMA",!0),Kb=os("ON",!0),kc=os("LEFT",!0),oc=os("RIGHT",!0),R0=os("FULL",!0),Bd=os("CROSS",!0),db=os("INNER",!0),eb=os("JOIN",!0),pb=os("OUTER",!0),Jb=os("UNION",!0),l0=os("VALUES",!0),tb=os("USING",!0),bb=os("WHERE",!0),nb=os("GROUP",!0),c0=os("BY",!0),_b=os("ORDER",!0),Sb=os("HAVING",!0),N0=os("LIMIT",!0),Xb=os("OFFSET",!0),yv=os("ASC",!0),vb=os("DESC",!0),wv=os("ALL",!0),Ib=os("DISTINCT",!0),Cv=os("BETWEEN",!0),Nv=os("IN",!0),Tb=os("IS",!0),xb=os("LIKE",!0),Qb=os("RLIKE",!0),f0=os("EXISTS",!0),Ld=os("NOT",!0),zf=os("AND",!0),Hc=os("OR",!0),Sp=os("COUNT",!0),qp=os("MAX",!0),kb=os("MIN",!0),ev=os("SUM",!0),d0=os("AVG",!0),Rb=os("EXTRACT",!0),Nb=os("CALL",!0),Ob=os("CASE",!0),O0=os("WHEN",!0),Ip=os("THEN",!0),Vp=os("ELSE",!0),rb=os("END",!0),tv=os("CAST",!0),$b=os("ARRAY",!0),nv=os("ARRAY_AGG",!0),rv=os("CHAR",!0),$0=os("VARCHAR",!0),sv=os("NUMERIC",!0),ov=os("DECIMAL",!0),Db=os("SIGNED",!0),Lv=os("STRING",!0),Ev=os("UNSIGNED",!0),Ub=os("INT",!0),Pb=os("ZEROFILL",!0),Hp=os("INTEGER",!0),zl=os("JSON",!0),mf=os("SMALLINT",!0),p0=os("TINYINT",!0),Rc=os("TINYTEXT",!0),ic=os("TEXT",!0),mb=os("MEDIUMTEXT",!0),D0=os("LONGTEXT",!0),ac=os("BIGINT",!0),hf=os("FLOAT",!0),Av=os("REAL",!0),iv=os("DOUBLE",!0),_v=os("DATETIME",!0),av=os("ROWS",!0),hb=os("TIME",!0),gb=os("TIMESTAMP",!0),yb=os("TRUNCATE",!0),uv=os("USER",!0),Ov=os("CURRENT_DATE",!0),Sv=(os("ADDDATE",!0),os("INTERVAL",!0)),lv=os("CURRENT_TIME",!0),cv=os("CURRENT_TIMESTAMP",!0),Mb=os("CURRENT_USER",!0),Iv=os("SESSION_USER",!0),Tv=os("SYSTEM_USER",!0),fv=os("GLOBAL",!0),xv=os("SESSION",!0),dv=os("PERSIST",!0),jb=os("PERSIST_ONLY",!0),j=os("@",!1),jr=os("@@",!1),b0=os("$",!1),uc=os("return",!0),sb=os(":=",!1),An=os("DUAL",!0),hs=os("ADD",!0),gf=os("COLUMN",!0),U0=os("INDEX",!0),ob=os("FULLTEXT",!0),es=os("SPATIAL",!0),Fb=os("COMMENT",!0),pv=os("CONSTRAINT",!0),$v=os("REFERENCES",!0),v0=os("SQL_CALC_FOUND_ROWS",!0),P=os("SQL_CACHE",!0),Mr=os("SQL_NO_CACHE",!0),P0=os("SQL_SMALL_RESULT",!0),Ed=os("SQL_BIG_RESULT",!0),M0=os("SQL_BUFFER_RESULT",!0),mn=os(",",!1),ds=os("[",!1),Yc=os("]",!1),wb=os(";",!1),m0=os("->",!1),Br=os("||",!1),bv=os("&&",!1),ib=os("/*",!1),h0=os("*/",!1),ab=os("--",!1),j0=os("#",!1),qd={type:"any"},F0=/^[ \t\n\r]/,z0=Eu([" "," ",`
|
|
144
144
|
`,"\r"],!1,!1),Tp=function(W){return{dataType:W}},xp=os("boolean",!0),N=0,Or=0,Yp=[{line:1,column:1}],lc=0,kp=[],an=0;if("startRule"in $){if(!($.startRule in qe))throw new Error(`Can't start parsing from rule "`+$.startRule+'".');ht=qe[$.startRule]}function os(W,fe){return{type:"literal",text:W,ignoreCase:fe}}function Eu(W,fe,Te){return{type:"class",parts:W,inverted:fe,ignoreCase:Te}}function cp(W){var fe,Te=Yp[W];if(Te)return Te;for(fe=W-1;!Yp[fe];)fe--;for(Te={line:(Te=Yp[fe]).line,column:Te.column};fe<W;)t.charCodeAt(fe)===10?(Te.line++,Te.column=1):Te.column++,fe++;return Yp[W]=Te,Te}function Wp(W,fe){var Te=cp(W),Ge=cp(fe);return{start:{offset:W,line:Te.line,column:Te.column},end:{offset:fe,line:Ge.line,column:Ge.column}}}function $r(W){N<lc||(N>lc&&(lc=N,kp=[]),kp.push(W))}function Rl(W,fe,Te){return new l(l.buildMessage(W,fe),W,fe,Te)}function sl(){var W,fe;return W=N,Et()!==e&&(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr;if(Te=N,(Ge=Vd())!==e){for(bt=[],et=N,(s=Et())!==e&&(Be=hn())!==e&&(kn=Et())!==e&&(nr=Vd())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);et!==e;)bt.push(et),et=N,(s=Et())!==e&&(Be=hn())!==e&&(kn=Et())!==e&&(nr=Vd())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);bt!==e?(Or=Te,Ge=(function(ur,Ce){let Gt=ur&&ur.ast||ur,Es=Ce&&Ce.length&&Ce[0].length>=4?[Gt]:Gt;for(let Co=0;Co<Ce.length;Co++)Ce[Co][3]&&Ce[Co][3].length!==0&&Es.push(Ce[Co][3]&&Ce[Co][3].ast||Ce[Co][3]);return{tableList:Array.from(wa),columnList:Iu(va),ast:Es}})(Ge,bt),Te=Ge):(N=Te,Te=e)}else N=Te,Te=e;return Te})())!==e?(Or=W,W=fe):(N=W,W=e),W}function ub(){var W;return(W=(function(){var fe,Te,Ge,bt,et,s;fe=N,(Te=ba())!==e&&Et()!==e&&(Ge=Yl())!==e&&Et()!==e&&(bt=pl())!==e?(Or=fe,Be=Te,kn=Ge,(nr=bt)&&nr.forEach(ur=>wa.add(`${Be}::${ur.db}::${ur.table}`)),Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:Be.toLowerCase(),keyword:kn.toLowerCase(),name:nr}},fe=Te):(N=fe,fe=e);var Be,kn,nr;return fe===e&&(fe=N,(Te=ba())!==e&&Et()!==e&&(Ge=Xn())!==e&&Et()!==e&&(bt=il())!==e&&Et()!==e&&Ki()!==e&&Et()!==e&&(et=Ku())!==e&&Et()!==e?((s=(function(){var ur,Ce,Gt,Es,Co,ai;if(ur=N,(Ce=Zp())===e&&(Ce=G0()),Ce!==e){for(Gt=[],Es=N,(Co=Et())!==e?((ai=Zp())===e&&(ai=G0()),ai!==e?Es=Co=[Co,ai]:(N=Es,Es=e)):(N=Es,Es=e);Es!==e;)Gt.push(Es),Es=N,(Co=Et())!==e?((ai=Zp())===e&&(ai=G0()),ai!==e?Es=Co=[Co,ai]:(N=Es,Es=e)):(N=Es,Es=e);Gt!==e?(Or=ur,Ce=Ke(Ce,Gt),ur=Ce):(N=ur,ur=e)}else N=ur,ur=e;return ur})())===e&&(s=null),s!==e&&Et()!==e?(Or=fe,Te=(function(ur,Ce,Gt,Es,Co){return{tableList:Array.from(wa),columnList:Iu(va),ast:{type:ur.toLowerCase(),keyword:Ce.toLowerCase(),name:Gt,table:Es,options:Co}}})(Te,Ge,bt,et,s),fe=Te):(N=fe,fe=e)):(N=fe,fe=e)),fe})())===e&&(W=(function(){var fe;return(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr,ur,Ce;Te=N,(Ge=Ju())!==e&&Et()!==e?((bt=od())===e&&(bt=null),bt!==e&&Et()!==e&&Yl()!==e&&Et()!==e?((et=Cb())===e&&(et=null),et!==e&&Et()!==e&&(s=pl())!==e&&Et()!==e&&(Be=(function(){var li,Pt,So,so,Xo,Ut,yo,zi,Y;if(li=N,(Pt=V())!==e)if(Et()!==e)if((So=fp())!==e){for(so=[],Xo=N,(Ut=Et())!==e&&(yo=ae())!==e&&(zi=Et())!==e&&(Y=fp())!==e?Xo=Ut=[Ut,yo,zi,Y]:(N=Xo,Xo=e);Xo!==e;)so.push(Xo),Xo=N,(Ut=Et())!==e&&(yo=ae())!==e&&(zi=Et())!==e&&(Y=fp())!==e?Xo=Ut=[Ut,yo,zi,Y]:(N=Xo,Xo=e);so!==e&&(Xo=Et())!==e&&(Ut=Se())!==e?(Or=li,Pt=ln(So,so),li=Pt):(N=li,li=e)}else N=li,li=e;else N=li,li=e;else N=li,li=e;return li})())!==e&&Et()!==e?((kn=(function(){var li,Pt,So,so,Xo,Ut,yo,zi;if(li=N,(Pt=dp())!==e){for(So=[],so=N,(Xo=Et())!==e?((Ut=ae())===e&&(Ut=null),Ut!==e&&(yo=Et())!==e&&(zi=dp())!==e?so=Xo=[Xo,Ut,yo,zi]:(N=so,so=e)):(N=so,so=e);so!==e;)So.push(so),so=N,(Xo=Et())!==e?((Ut=ae())===e&&(Ut=null),Ut!==e&&(yo=Et())!==e&&(zi=dp())!==e?so=Xo=[Xo,Ut,yo,zi]:(N=so,so=e)):(N=so,so=e);So!==e?(Or=li,Pt=rn(Pt,So),li=Pt):(N=li,li=e)}else N=li,li=e;return li})())===e&&(kn=null),kn!==e&&Et()!==e?((nr=(function(){var li,Pt,So,so;return li=N,t.substr(N,6).toLowerCase()==="ignore"?(Pt=t.substr(N,6),N+=6):(Pt=e,an===0&&$r(u0)),Pt!==e?(So=N,an++,so=fo(),an--,so===e?So=void 0:(N=So,So=e),So!==e?li=Pt=[Pt,So]:(N=li,li=e)):(N=li,li=e),li})())===e&&(nr=Qs()),nr===e&&(nr=null),nr!==e&&Et()!==e?((ur=gu())===e&&(ur=null),ur!==e&&Et()!==e?((Ce=Gf())===e&&(Ce=null),Ce!==e?(Or=Te,Ge=(function(li,Pt,So,so,Xo,Ut,yo,zi,Y){return so&&so.forEach(le=>wa.add(`create::${le.db}::${le.table}`)),{tableList:Array.from(wa),columnList:Iu(va),ast:{type:li[0].toLowerCase(),keyword:"table",temporary:Pt&&Pt[0].toLowerCase(),if_not_exists:So,table:so,ignore_replace:yo&&yo[0].toLowerCase(),as:zi&&zi[0].toLowerCase(),query_expr:Y&&Y.ast,create_definitions:Xo,table_options:Ut}}})(Ge,bt,et,s,Be,kn,nr,ur,Ce),Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e),Te===e&&(Te=N,(Ge=Ju())!==e&&Et()!==e?((bt=od())===e&&(bt=null),bt!==e&&Et()!==e&&Yl()!==e&&Et()!==e?((et=Cb())===e&&(et=null),et!==e&&Et()!==e&&(s=pl())!==e&&Et()!==e&&(Be=(function li(){var Pt,So;(Pt=(function(){var Xo,Ut;return Xo=N,ua()!==e&&Et()!==e&&(Ut=pl())!==e?(Or=Xo,Xo={type:"like",table:Ut}):(N=Xo,Xo=e),Xo})())===e&&(Pt=N,V()!==e&&Et()!==e&&(So=li())!==e&&Et()!==e&&Se()!==e?(Or=Pt,(so=So).parentheses=!0,Pt=so):(N=Pt,Pt=e));var so;return Pt})())!==e?(Or=Te,Gt=Ge,Es=bt,Co=et,Mt=Be,(ai=s)&&ai.forEach(li=>wa.add(`create::${li.db}::${li.table}`)),Ge={tableList:Array.from(wa),columnList:Iu(va),ast:{type:Gt[0].toLowerCase(),keyword:"table",temporary:Es&&Es[0].toLowerCase(),if_not_exists:Co,table:ai,like:Mt}},Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e));var Gt,Es,Co,ai,Mt;return Te})())===e&&(fe=(function(){var Te,Ge,bt,et,s,Be;return Te=N,(Ge=Ju())!==e&&Et()!==e?((bt=(function(){var kn,nr,ur,Ce;return kn=N,t.substr(N,8).toLowerCase()==="database"?(nr=t.substr(N,8),N+=8):(nr=e,an===0&&$r(Q0)),nr!==e?(ur=N,an++,Ce=fo(),an--,Ce===e?ur=void 0:(N=ur,ur=e),ur!==e?(Or=kn,kn=nr="DATABASE"):(N=kn,kn=e)):(N=kn,kn=e),kn})())===e&&(bt=(function(){var kn,nr,ur,Ce;return kn=N,t.substr(N,6).toLowerCase()==="schema"?(nr=t.substr(N,6),N+=6):(nr=e,an===0&&$r(Zb)),nr!==e?(ur=N,an++,Ce=fo(),an--,Ce===e?ur=void 0:(N=ur,ur=e),ur!==e?(Or=kn,kn=nr="SCHEMA"):(N=kn,kn=e)):(N=kn,kn=e),kn})()),bt!==e&&Et()!==e?((et=Cb())===e&&(et=null),et!==e&&Et()!==e&&(s=pi())!==e&&Et()!==e?((Be=(function(){var kn,nr,ur,Ce,Gt,Es;if(kn=N,(nr=B0())!==e){for(ur=[],Ce=N,(Gt=Et())!==e&&(Es=B0())!==e?Ce=Gt=[Gt,Es]:(N=Ce,Ce=e);Ce!==e;)ur.push(Ce),Ce=N,(Gt=Et())!==e&&(Es=B0())!==e?Ce=Gt=[Gt,Es]:(N=Ce,Ce=e);ur!==e?(Or=kn,nr=Ke(nr,ur),kn=nr):(N=kn,kn=e)}else N=kn,kn=e;return kn})())===e&&(Be=null),Be!==e?(Or=Te,Ge=(function(kn,nr,ur,Ce,Gt){let Es=nr.toLowerCase();return{tableList:Array.from(wa),columnList:Iu(va),ast:{type:kn[0].toLowerCase(),keyword:Es,if_not_exists:ur,[Es]:{db:Ce.schema,schema:Ce.name},create_definitions:Gt}}})(Ge,bt,et,s,Be),Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e),Te})()),fe})())===e&&(W=(function(){var fe,Te,Ge,bt;fe=N,(Te=(function(){var kn,nr,ur,Ce;return kn=N,t.substr(N,8).toLowerCase()==="truncate"?(nr=t.substr(N,8),N+=8):(nr=e,an===0&&$r(yb)),nr!==e?(ur=N,an++,Ce=fo(),an--,Ce===e?ur=void 0:(N=ur,ur=e),ur!==e?(Or=kn,kn=nr="TRUNCATE"):(N=kn,kn=e)):(N=kn,kn=e),kn})())!==e&&Et()!==e?((Ge=Yl())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=pl())!==e?(Or=fe,et=Te,s=Ge,(Be=bt)&&Be.forEach(kn=>wa.add(`${et}::${kn.db}::${kn.table}`)),Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:et.toLowerCase(),keyword:s&&s.toLowerCase()||"table",name:Be}},fe=Te):(N=fe,fe=e)):(N=fe,fe=e);var et,s,Be;return fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=_u())!==e&&Et()!==e&&Yl()!==e&&Et()!==e&&(Ge=(function(){var et,s,Be,kn,nr,ur,Ce,Gt;if(et=N,(s=E())!==e){for(Be=[],kn=N,(nr=Et())!==e&&(ur=ae())!==e&&(Ce=Et())!==e&&(Gt=E())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e);kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e&&(ur=ae())!==e&&(Ce=Et())!==e&&(Gt=E())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e);Be!==e?(Or=et,s=ln(s,Be),et=s):(N=et,et=e)}else N=et,et=e;return et})())!==e?(Or=fe,(bt=Ge).forEach(et=>et.forEach(s=>s.table&&wa.add(`rename::${s.db}::${s.table}`))),Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"rename",table:bt}},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=(function(){var et,s,Be,kn;return et=N,t.substr(N,4).toLowerCase()==="call"?(s=t.substr(N,4),N+=4):(s=e,an===0&&$r(Nb)),s!==e?(Be=N,an++,kn=fo(),an--,kn===e?Be=void 0:(N=Be,Be=e),Be!==e?(Or=et,et=s="CALL"):(N=et,et=e)):(N=et,et=e),et})())!==e&&Et()!==e&&(Ge=Hi())!==e?(Or=fe,bt=Ge,Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"call",expr:bt},...qs()},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=(function(){var et,s,Be,kn;return et=N,t.substr(N,3).toLowerCase()==="use"?(s=t.substr(N,3),N+=3):(s=e,an===0&&$r(Na)),s!==e?(Be=N,an++,kn=fo(),an--,kn===e?Be=void 0:(N=Be,Be=e),Be!==e?et=s=[s,Be]:(N=et,et=e)):(N=et,et=e),et})())!==e&&Et()!==e&&(Ge=Au())!==e?(Or=fe,bt=Ge,wa.add(`use::${bt}::null`),Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"use",db:bt}},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt;fe=N,(Te=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,5).toLowerCase()==="alter"?(kn=t.substr(N,5),N+=5):(kn=e,an===0&&$r(rl)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?Be=kn=[kn,nr]:(N=Be,Be=e)):(N=Be,Be=e),Be})())!==e&&Et()!==e&&Yl()!==e&&Et()!==e&&(Ge=pl())!==e&&Et()!==e&&(bt=(function(){var Be,kn,nr,ur,Ce,Gt,Es,Co;if(Be=N,(kn=w0())!==e){for(nr=[],ur=N,(Ce=Et())!==e&&(Gt=ae())!==e&&(Es=Et())!==e&&(Co=w0())!==e?ur=Ce=[Ce,Gt,Es,Co]:(N=ur,ur=e);ur!==e;)nr.push(ur),ur=N,(Ce=Et())!==e&&(Gt=ae())!==e&&(Es=Et())!==e&&(Co=w0())!==e?ur=Ce=[Ce,Gt,Es,Co]:(N=ur,ur=e);nr!==e?(Or=Be,kn=ln(kn,nr),Be=kn):(N=Be,Be=e)}else N=Be,Be=e;return Be})())!==e?(Or=fe,s=bt,(et=Ge)&&et.length>0&&et.forEach(Be=>wa.add(`alter::${Be.db}::${Be.table}`)),Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"alter",table:et,expr:s}},fe=Te):(N=fe,fe=e);var et,s;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt;fe=N,(Te=Ol())!==e&&Et()!==e?((Ge=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,6).toLowerCase()==="global"?(kn=t.substr(N,6),N+=6):(kn=e,an===0&&$r(fv)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?(Or=Be,Be=kn="GLOBAL"):(N=Be,Be=e)):(N=Be,Be=e),Be})())===e&&(Ge=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,7).toLowerCase()==="session"?(kn=t.substr(N,7),N+=7):(kn=e,an===0&&$r(xv)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?(Or=Be,Be=kn="SESSION"):(N=Be,Be=e)):(N=Be,Be=e),Be})())===e&&(Ge=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,5).toLowerCase()==="local"?(kn=t.substr(N,5),N+=5):(kn=e,an===0&&$r(Vu)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?(Or=Be,Be=kn="LOCAL"):(N=Be,Be=e)):(N=Be,Be=e),Be})())===e&&(Ge=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,7).toLowerCase()==="persist"?(kn=t.substr(N,7),N+=7):(kn=e,an===0&&$r(dv)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?(Or=Be,Be=kn="PERSIST"):(N=Be,Be=e)):(N=Be,Be=e),Be})())===e&&(Ge=(function(){var Be,kn,nr,ur;return Be=N,t.substr(N,12).toLowerCase()==="persist_only"?(kn=t.substr(N,12),N+=12):(kn=e,an===0&&$r(jb)),kn!==e?(nr=N,an++,ur=fo(),an--,ur===e?nr=void 0:(N=nr,nr=e),nr!==e?(Or=Be,Be=kn="PERSIST_ONLY"):(N=Be,Be=e)):(N=Be,Be=e),Be})()),Ge===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=(function(){var Be,kn,nr,ur,Ce,Gt,Es,Co;if(Be=N,(kn=Ho())!==e){for(nr=[],ur=N,(Ce=Et())!==e&&(Gt=ae())!==e&&(Es=Et())!==e&&(Co=Ho())!==e?ur=Ce=[Ce,Gt,Es,Co]:(N=ur,ur=e);ur!==e;)nr.push(ur),ur=N,(Ce=Et())!==e&&(Gt=ae())!==e&&(Es=Et())!==e&&(Co=Ho())!==e?ur=Ce=[Ce,Gt,Es,Co]:(N=ur,ur=e);nr!==e?(Or=Be,kn=ms(kn,nr),Be=kn):(N=Be,Be=e)}else N=Be,Be=e;return Be})())!==e?(Or=fe,et=Ge,(s=bt).keyword=et,Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"set",keyword:et,expr:s}},fe=Te):(N=fe,fe=e)):(N=fe,fe=e);var et,s;return fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=(function(){var et,s,Be,kn;return et=N,t.substr(N,4).toLowerCase()==="lock"?(s=t.substr(N,4),N+=4):(s=e,an===0&&$r(cl)),s!==e?(Be=N,an++,kn=fo(),an--,kn===e?Be=void 0:(N=Be,Be=e),Be!==e?et=s=[s,Be]:(N=et,et=e)):(N=et,et=e),et})())!==e&&Et()!==e&&mt()!==e&&Et()!==e&&(Ge=(function(){var et,s,Be,kn,nr,ur,Ce,Gt;if(et=N,(s=I())!==e){for(Be=[],kn=N,(nr=Et())!==e&&(ur=ae())!==e&&(Ce=Et())!==e&&(Gt=I())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e);kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e&&(ur=ae())!==e&&(Ce=Et())!==e&&(Gt=I())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e);Be!==e?(Or=et,s=ms(s,Be),et=s):(N=et,et=e)}else N=et,et=e;return et})())!==e?(Or=fe,bt=Ge,Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"lock",keyword:"tables",tables:bt}},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te;return fe=N,(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,6).toLowerCase()==="unlock"?(bt=t.substr(N,6),N+=6):(bt=e,an===0&&$r(jf)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())!==e&&Et()!==e&&mt()!==e?(Or=fe,Te={tableList:Array.from(wa),columnList:Iu(va),ast:{type:"unlock",keyword:"tables"}},fe=Te):(N=fe,fe=e),fe})()),W}function Vd(){var W;return(W=Gf())===e&&(W=(function(){var fe,Te,Ge,bt,et;return fe=N,(Te=Uc())!==e&&Et()!==e&&(Ge=pl())!==e&&Et()!==e&&Ol()!==e&&Et()!==e&&(bt=(function(){var s,Be,kn,nr,ur,Ce,Gt,Es;if(s=N,(Be=nd())!==e){for(kn=[],nr=N,(ur=Et())!==e&&(Ce=ae())!==e&&(Gt=Et())!==e&&(Es=nd())!==e?nr=ur=[ur,Ce,Gt,Es]:(N=nr,nr=e);nr!==e;)kn.push(nr),nr=N,(ur=Et())!==e&&(Ce=ae())!==e&&(Gt=Et())!==e&&(Es=nd())!==e?nr=ur=[ur,Ce,Gt,Es]:(N=nr,nr=e);kn!==e?(Or=s,Be=ln(Be,kn),s=Be):(N=s,s=e)}else N=s,s=e;return s})())!==e&&Et()!==e?((et=Rp())===e&&(et=null),et!==e?(Or=fe,Te=(function(s,Be,kn){let nr={};return s&&s.forEach(ur=>{let{db:Ce,as:Gt,table:Es,join:Co}=ur,ai=Co?"select":"update";Ce&&(nr[Es]=Ce),Es&&wa.add(`${ai}::${Ce}::${Es}`)}),Be&&Be.forEach(ur=>{if(ur.table){let Ce=Qc(ur.table);wa.add(`update::${nr[Ce]||null}::${Ce}`)}va.add(`update::${ur.table}::${ur.column}`)}),{tableList:Array.from(wa),columnList:Iu(va),ast:{type:"update",table:s,set:Be,where:kn}}})(Ge,bt,et),fe=Te):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s,Be,kn;return fe=N,(Te=sf())!==e&&Et()!==e&&(Ge=b())!==e&&Et()!==e?((bt=Yl())===e&&(bt=null),bt!==e&&Et()!==e&&(et=Ku())!==e?((s=mp())===e&&(s=null),s!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=(function(){var nr,ur,Ce,Gt,Es,Co,ai,Mt;if(nr=N,(ur=Jc())!==e){for(Ce=[],Gt=N,(Es=Et())!==e&&(Co=ae())!==e&&(ai=Et())!==e&&(Mt=Jc())!==e?Gt=Es=[Es,Co,ai,Mt]:(N=Gt,Gt=e);Gt!==e;)Ce.push(Gt),Gt=N,(Es=Et())!==e&&(Co=ae())!==e&&(ai=Et())!==e&&(Mt=Jc())!==e?Gt=Es=[Es,Co,ai,Mt]:(N=Gt,Gt=e);Ce!==e?(Or=nr,ur=ln(ur,Ce),nr=ur):(N=nr,nr=e)}else N=nr,nr=e;return nr})())!==e&&Et()!==e&&Se()!==e&&Et()!==e&&(kn=vp())!==e?(Or=fe,Te=(function(nr,ur,Ce,Gt,Es,Co,ai){if(Gt&&(wa.add(`insert::${Gt.db}::${Gt.table}`),Gt.as=null),Co){let li=Gt&&Gt.table||null;Array.isArray(ai.values)&&ai.values.forEach((Pt,So)=>{if(Pt.value.length!=Co.length)throw new Error("Error: column count doesn't match value count at row "+(So+1))}),Co.forEach(Pt=>va.add(`insert::${li}::${Pt}`))}let Mt=Ce?" "+Ce.toLowerCase():"";return{tableList:Array.from(wa),columnList:Iu(va),ast:{type:nr,prefix:`${ur.toLowerCase()}${Mt}`,table:[Gt],columns:Co,values:ai,partition:Es}}})(Te,Ge,bt,et,s,Be,kn),fe=Te):(N=fe,fe=e)):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s,Be;return fe=N,(Te=sf())!==e&&Et()!==e?((Ge=b())===e&&(Ge=(function(){var kn,nr,ur,Ce;return kn=N,t.substr(N,9).toLowerCase()==="overwrite"?(nr=t.substr(N,9),N+=9):(nr=e,an===0&&$r(xc)),nr!==e?(ur=N,an++,Ce=fo(),an--,Ce===e?ur=void 0:(N=ur,ur=e),ur!==e?(Or=kn,kn=nr="OVERWRITE"):(N=kn,kn=e)):(N=kn,kn=e),kn})()),Ge!==e&&Et()!==e?((bt=Yl())===e&&(bt=null),bt!==e&&Et()!==e&&(et=Ku())!==e&&Et()!==e?((s=mp())===e&&(s=null),s!==e&&Et()!==e&&(Be=vp())!==e?(Or=fe,Te=(function(kn,nr,ur,Ce,Gt,Es){Ce&&(wa.add(`insert::${Ce.db}::${Ce.table}`),va.add(`insert::${Ce.table}::(.*)`),Ce.as=null);let Co=ur?" "+ur.toLowerCase():"";return{tableList:Array.from(wa),columnList:Iu(va),ast:{type:kn,prefix:`${nr.toLowerCase()}${Co}`,table:[Ce],columns:null,values:Es,partition:Gt}}})(Te,Ge,bt,et,s,Be),fe=Te):(N=fe,fe=e)):(N=fe,fe=e)):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et;return fe=N,(Te=Wa())!==e&&Et()!==e?((Ge=pl())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=hr())!==e&&Et()!==e?((et=Rp())===e&&(et=null),et!==e?(Or=fe,Te=(function(s,Be,kn){if(Be&&Be.forEach(nr=>{let{db:ur,as:Ce,table:Gt,join:Es}=nr,Co=Es?"select":"delete";Gt&&wa.add(`${Co}::${ur}::${Gt}`),Es||va.add(`delete::${Gt}::(.*)`)}),s===null&&Be.length===1){let nr=Be[0];s=[{db:nr.db,table:nr.table,as:nr.as,addition:!0}]}return{tableList:Array.from(wa),columnList:Iu(va),ast:{type:"delete",table:s,from:Be,where:kn}}})(Ge,bt,et),fe=Te):(N=fe,fe=e)):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=ub())===e&&(W=(function(){var fe,Te;for(fe=[],Te=Bt();Te!==e;)fe.push(Te),Te=Bt();return fe})()),W}function ed(){var W,fe,Te;return W=N,(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,5).toLowerCase()==="union"?(bt=t.substr(N,5),N+=5):(bt=e,an===0&&$r(Jb)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})()!==e&&Et()!==e?((fe=bl())===e&&(fe=ju()),fe===e&&(fe=null),fe!==e?(Or=W,W=(Te=fe)?"union "+Te.toLowerCase():"union"):(N=W,W=e)):(N=W,W=e),W}function Gf(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=_r())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ed())!==e&&(s=Et())!==e&&(Be=_r())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ed())!==e&&(s=Et())!==e&&(Be=_r())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e&&(Ge=Et())!==e?((bt=ol())===e&&(bt=null),bt!==e&&(et=Et())!==e?((s=Jp())===e&&(s=null),s!==e?(Or=W,W=fe=(function(kn,nr,ur,Ce){nr.forEach(Es=>Es.slice(1,1));let Gt=kn;for(let Es=0;Es<nr.length;Es++)Gt._next=nr[Es][3],Gt.set_op=nr[Es][1],Gt=Gt._next;return ur&&(kn._orderby=ur),Ce&&(kn._limit=Ce),{tableList:Array.from(wa),columnList:Iu(va),ast:kn}})(fe,Te,bt,s)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;return W}function Cb(){var W,fe;return W=N,t.substr(N,2).toLowerCase()==="if"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(gt)),fe!==e&&Et()!==e&&Zl()!==e&&Et()!==e&&Wl()!==e?(Or=W,W=fe="IF NOT EXISTS"):(N=W,W=e),W}function fp(){var W;return(W=vv())===e&&(W=Wc())===e&&(W=zb())===e&&(W=(function(){var fe;return(fe=(function(){var Te,Ge,bt,et,s,Be;Te=N,(Ge=Kp())===e&&(Ge=null),Ge!==e&&Et()!==e?(t.substr(N,11).toLowerCase()==="primary key"?(bt=t.substr(N,11),N+=11):(bt=e,an===0&&$r(Il)),bt!==e&&Et()!==e?((et=vr())===e&&(et=null),et!==e&&Et()!==e&&(s=_())!==e&&Et()!==e?((Be=fc())===e&&(Be=null),Be!==e?(Or=Te,nr=bt,ur=et,Ce=s,Gt=Be,Ge={constraint:(kn=Ge)&&kn.constraint,definition:Ce,constraint_type:nr.toLowerCase(),keyword:kn&&kn.keyword,index_type:ur,resource:"constraint",index_options:Gt},Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e);var kn,nr,ur,Ce,Gt;return Te})())===e&&(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr;Te=N,(Ge=Kp())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=(function(){var li,Pt,So,so;return li=N,t.substr(N,6).toLowerCase()==="unique"?(Pt=t.substr(N,6),N+=6):(Pt=e,an===0&&$r(bn)),Pt!==e?(So=N,an++,so=fo(),an--,so===e?So=void 0:(N=So,So=e),So!==e?(Or=li,li=Pt="UNIQUE"):(N=li,li=e)):(N=li,li=e),li})())!==e&&Et()!==e?((et=Xn())===e&&(et=u()),et===e&&(et=null),et!==e&&Et()!==e?((s=Jc())===e&&(s=null),s!==e&&Et()!==e?((Be=vr())===e&&(Be=null),Be!==e&&Et()!==e&&(kn=_())!==e&&Et()!==e?((nr=fc())===e&&(nr=null),nr!==e?(Or=Te,Ce=bt,Gt=et,Es=s,Co=Be,ai=kn,Mt=nr,Ge={constraint:(ur=Ge)&&ur.constraint,definition:ai,constraint_type:Gt&&`${Ce.toLowerCase()} ${Gt.toLowerCase()}`||Ce.toLowerCase(),keyword:ur&&ur.keyword,index_type:Co,index:Es,resource:"constraint",index_options:Mt},Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e);var ur,Ce,Gt,Es,Co,ai,Mt;return Te})())===e&&(fe=(function(){var Te,Ge,bt,et,s,Be;Te=N,(Ge=Kp())===e&&(Ge=null),Ge!==e&&Et()!==e?(t.substr(N,11).toLowerCase()==="foreign key"?(bt=t.substr(N,11),N+=11):(bt=e,an===0&&$r(Tl)),bt!==e&&Et()!==e?((et=Jc())===e&&(et=null),et!==e&&Et()!==e&&(s=_())!==e&&Et()!==e?((Be=C0())===e&&(Be=null),Be!==e?(Or=Te,nr=bt,ur=et,Ce=s,Gt=Be,Ge={constraint:(kn=Ge)&&kn.constraint,definition:Ce,constraint_type:nr,keyword:kn&&kn.keyword,index:ur,resource:"constraint",reference_definition:Gt},Te=Ge):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e);var kn,nr,ur,Ce,Gt;return Te})()),fe})()),W}function g0(){var W,fe,Te,Ge;return W=N,(fe=(function(){var bt,et;return bt=N,(et=(function(){var s,Be,kn,nr;return s=N,t.substr(N,8).toLowerCase()==="not null"?(Be=t.substr(N,8),N+=8):(Be=e,an===0&&$r(_a)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?s=Be=[Be,kn]:(N=s,s=e)):(N=s,s=e),s})())!==e&&(Or=bt,et={type:"not null",value:"not null"}),bt=et})())===e&&(fe=yr()),fe!==e&&(Or=W,(Ge=fe)&&!Ge.value&&(Ge.value="null"),fe={nullable:Ge}),(W=fe)===e&&(W=N,(fe=(function(){var bt,et;return bt=N,pc()!==e&&Et()!==e&&(et=ya())!==e?(Or=bt,bt={type:"default",value:et}):(N=bt,bt=e),bt})())!==e&&(Or=W,fe={default_val:fe}),(W=fe)===e&&(W=N,t.substr(N,14).toLowerCase()==="auto_increment"?(fe=t.substr(N,14),N+=14):(fe=e,an===0&&$r(Qn)),fe!==e&&(Or=W,fe={auto_increment:fe.toLowerCase()}),(W=fe)===e&&(W=N,t.substr(N,6).toLowerCase()==="unique"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(bn)),fe!==e&&Et()!==e?(t.substr(N,3).toLowerCase()==="key"?(Te=t.substr(N,3),N+=3):(Te=e,an===0&&$r(zr)),Te===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(bt){let et=["unique"];return bt&&et.push(bt),{unique:et.join(" ").toLowerCase("")}})(Te)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,t.substr(N,7).toLowerCase()==="primary"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(tr)),fe===e&&(fe=null),fe!==e&&Et()!==e?(t.substr(N,3).toLowerCase()==="key"?(Te=t.substr(N,3),N+=3):(Te=e,an===0&&$r(zr)),Te!==e?(Or=W,W=fe=(function(bt){let et=[];return bt&&et.push("primary"),et.push("key"),{primary_key:et.join(" ").toLowerCase("")}})(fe)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=_n())!==e&&(Or=W,fe={comment:fe}),(W=fe)===e&&(W=N,(fe=y0())!==e&&(Or=W,fe={collate:fe}),(W=fe)===e&&(W=N,(fe=(function(){var bt,et,s;return bt=N,t.substr(N,13).toLowerCase()==="column_format"?(et=t.substr(N,13),N+=13):(et=e,an===0&&$r(Er)),et!==e&&Et()!==e?(t.substr(N,5).toLowerCase()==="fixed"?(s=t.substr(N,5),N+=5):(s=e,an===0&&$r(cs)),s===e&&(t.substr(N,7).toLowerCase()==="dynamic"?(s=t.substr(N,7),N+=7):(s=e,an===0&&$r(Ys)),s===e&&(t.substr(N,7).toLowerCase()==="default"?(s=t.substr(N,7),N+=7):(s=e,an===0&&$r(ao)))),s!==e?(Or=bt,et={type:"column_format",value:s.toLowerCase()},bt=et):(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Or=W,fe={column_format:fe}),(W=fe)===e&&(W=N,(fe=(function(){var bt,et,s;return bt=N,t.substr(N,7).toLowerCase()==="storage"?(et=t.substr(N,7),N+=7):(et=e,an===0&&$r(uo)),et!==e&&Et()!==e?(t.substr(N,4).toLowerCase()==="disk"?(s=t.substr(N,4),N+=4):(s=e,an===0&&$r(ni)),s===e&&(t.substr(N,6).toLowerCase()==="memory"?(s=t.substr(N,6),N+=6):(s=e,an===0&&$r(zo))),s!==e?(Or=bt,et={type:"storage",value:s.toLowerCase()},bt=et):(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Or=W,fe={storage:fe}),(W=fe)===e&&(W=N,(fe=C0())!==e&&(Or=W,fe={reference_definition:fe}),W=fe))))))))),W}function vv(){var W,fe,Te,Ge;return W=N,(fe=il())!==e&&Et()!==e&&(Te=pu())!==e&&Et()!==e?((Ge=(function(){var bt,et,s,Be,kn,nr;if(bt=N,(et=g0())!==e)if(Et()!==e){for(s=[],Be=N,(kn=Et())!==e&&(nr=g0())!==e?Be=kn=[kn,nr]:(N=Be,Be=e);Be!==e;)s.push(Be),Be=N,(kn=Et())!==e&&(nr=g0())!==e?Be=kn=[kn,nr]:(N=Be,Be=e);s!==e?(Or=bt,bt=et=(function(ur,Ce){let Gt=ur;for(let Es=0;Es<Ce.length;Es++)Gt={...Gt,...Ce[Es][1]};return Gt})(et,s)):(N=bt,bt=e)}else N=bt,bt=e;else N=bt,bt=e;return bt})())===e&&(Ge=null),Ge!==e?(Or=W,W=fe=(function(bt,et,s){return va.add(`create::${bt.table}::${bt.column}`),{column:bt,definition:et,resource:"column",...s||{}}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e),W}function y0(){var W,fe,Te,Ge;return W=N,or()!==e&&Et()!==e&&(fe=Pu())!==e&&Et()!==e&&(Te=$t())!==e&&Et()!==e&&(Ge=Au())!==e?(Or=W,W={type:"collate",keyword:"collate",collate:{name:fe,symbol:Te,value:Ge}}):(N=W,W=e),W===e&&(W=N,or()!==e&&Et()!==e?((fe=$t())===e&&(fe=null),fe!==e&&Et()!==e&&(Te=Au())!==e?(Or=W,W=(function(bt,et){return{type:"collate",keyword:"collate",collate:{name:et,symbol:bt}}})(fe,Te)):(N=W,W=e)):(N=W,W=e)),W}function w0(){var W;return(W=(function(){var fe,Te,Ge,bt;fe=N,(Te=Ht())!==e&&Et()!==e?((Ge=$n())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=vv())!==e?(Or=fe,et=Ge,s=bt,Te={action:"add",...s,keyword:et,resource:"column",type:"alter"},fe=Te):(N=fe,fe=e)):(N=fe,fe=e);var et,s;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt;return fe=N,(Te=ba())!==e&&Et()!==e?((Ge=$n())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=il())!==e?(Or=fe,Te=(function(et,s){return{action:"drop",column:s,keyword:et,resource:"column",type:"alter"}})(Ge,bt),fe=Te):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=Ht())!==e&&Et()!==e&&(Ge=Wc())!==e?(Or=fe,bt=Ge,Te={action:"add",type:"alter",...bt},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te,Ge;fe=N,(Te=Ht())!==e&&Et()!==e&&(Ge=zb())!==e?(Or=fe,bt=Ge,Te={action:"add",type:"alter",...bt},fe=Te):(N=fe,fe=e);var bt;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt;fe=N,(Te=_u())!==e&&Et()!==e?((Ge=Rd())===e&&(Ge=gu()),Ge===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=Au())!==e?(Or=fe,s=bt,Te={action:"rename",type:"alter",resource:"table",keyword:(et=Ge)&&et[0].toLowerCase(),table:s},fe=Te):(N=fe,fe=e)):(N=fe,fe=e);var et,s;return fe})())===e&&(W=Zp())===e&&(W=G0()),W}function Zp(){var W,fe,Te,Ge;return W=N,t.substr(N,9).toLowerCase()==="algorithm"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(ta)),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e?(t.substr(N,7).toLowerCase()==="default"?(Ge=t.substr(N,7),N+=7):(Ge=e,an===0&&$r(ao)),Ge===e&&(t.substr(N,7).toLowerCase()==="instant"?(Ge=t.substr(N,7),N+=7):(Ge=e,an===0&&$r(Ha)),Ge===e&&(t.substr(N,7).toLowerCase()==="inplace"?(Ge=t.substr(N,7),N+=7):(Ge=e,an===0&&$r(ja)),Ge===e&&(t.substr(N,4).toLowerCase()==="copy"?(Ge=t.substr(N,4),N+=4):(Ge=e,an===0&&$r(Aa))))),Ge!==e?(Or=W,W=fe={type:"alter",keyword:"algorithm",resource:"algorithm",symbol:Te,algorithm:Ge}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function G0(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="lock"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(cl)),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e?(t.substr(N,7).toLowerCase()==="default"?(Ge=t.substr(N,7),N+=7):(Ge=e,an===0&&$r(ao)),Ge===e&&(t.substr(N,4).toLowerCase()==="none"?(Ge=t.substr(N,4),N+=4):(Ge=e,an===0&&$r(nl)),Ge===e&&(t.substr(N,6).toLowerCase()==="shared"?(Ge=t.substr(N,6),N+=6):(Ge=e,an===0&&$r(lf)),Ge===e&&(t.substr(N,9).toLowerCase()==="exclusive"?(Ge=t.substr(N,9),N+=9):(Ge=e,an===0&&$r(cd))))),Ge!==e?(Or=W,W=fe={type:"alter",keyword:"lock",resource:"lock",symbol:Te,lock:Ge}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function Wc(){var W,fe,Te,Ge,bt,et;return W=N,(fe=Xn())===e&&(fe=u()),fe!==e&&Et()!==e?((Te=Jc())===e&&(Te=null),Te!==e&&Et()!==e?((Ge=vr())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=_())!==e&&Et()!==e?((et=fc())===e&&(et=null),et!==e&&Et()!==e?(Or=W,W=fe=(function(s,Be,kn,nr,ur){return{index:Be,definition:nr,keyword:s.toLowerCase(),index_type:kn,resource:"index",index_options:ur}})(fe,Te,Ge,bt,et)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function zb(){var W,fe,Te,Ge,bt,et;return W=N,(fe=(function(){var s,Be,kn,nr;return s=N,t.substr(N,8).toLowerCase()==="fulltext"?(Be=t.substr(N,8),N+=8):(Be=e,an===0&&$r(ob)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="FULLTEXT"):(N=s,s=e)):(N=s,s=e),s})())===e&&(fe=(function(){var s,Be,kn,nr;return s=N,t.substr(N,7).toLowerCase()==="spatial"?(Be=t.substr(N,7),N+=7):(Be=e,an===0&&$r(es)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="SPATIAL"):(N=s,s=e)):(N=s,s=e),s})()),fe!==e&&Et()!==e?((Te=Xn())===e&&(Te=u()),Te===e&&(Te=null),Te!==e&&Et()!==e?((Ge=Jc())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=_())!==e&&Et()!==e?((et=fc())===e&&(et=null),et!==e&&Et()!==e?(Or=W,W=fe=(function(s,Be,kn,nr,ur){return{index:kn,definition:nr,keyword:Be&&`${s.toLowerCase()} ${Be.toLowerCase()}`||s.toLowerCase(),index_options:ur,resource:"index"}})(fe,Te,Ge,bt,et)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function Kp(){var W,fe,Te;return W=N,(fe=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,10).toLowerCase()==="constraint"?(bt=t.substr(N,10),N+=10):(bt=e,an===0&&$r(pv)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="CONSTRAINT"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())!==e&&Et()!==e?((Te=Au())===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(Ge,bt){return{keyword:Ge.toLowerCase(),constraint:bt}})(fe,Te)):(N=W,W=e)):(N=W,W=e),W}function C0(){var W,fe,Te,Ge,bt,et,s,Be,kn,nr;return W=N,(fe=(function(){var ur,Ce,Gt,Es;return ur=N,t.substr(N,10).toLowerCase()==="references"?(Ce=t.substr(N,10),N+=10):(Ce=e,an===0&&$r($v)),Ce!==e?(Gt=N,an++,Es=fo(),an--,Es===e?Gt=void 0:(N=Gt,Gt=e),Gt!==e?(Or=ur,ur=Ce="REFERENCES"):(N=ur,ur=e)):(N=ur,ur=e),ur})())!==e&&Et()!==e&&(Te=pl())!==e&&Et()!==e&&(Ge=_())!==e&&Et()!==e?(t.substr(N,10).toLowerCase()==="match full"?(bt=t.substr(N,10),N+=10):(bt=e,an===0&&$r(cf)),bt===e&&(t.substr(N,13).toLowerCase()==="match partial"?(bt=t.substr(N,13),N+=13):(bt=e,an===0&&$r(xf)),bt===e&&(t.substr(N,12).toLowerCase()==="match simple"?(bt=t.substr(N,12),N+=12):(bt=e,an===0&&$r(xu)))),bt===e&&(bt=null),bt!==e&&Et()!==e?((et=td())===e&&(et=null),et!==e&&Et()!==e?((s=td())===e&&(s=null),s!==e?(Or=W,Be=bt,kn=et,nr=s,W=fe={definition:Ge,table:Te,keyword:fe.toLowerCase(),match:Be&&Be.toLowerCase(),on_action:[kn,nr].filter(ur=>ur)}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=td())!==e&&(Or=W,fe={on_action:[fe]}),W=fe),W}function td(){var W,fe,Te,Ge;return W=N,Ki()!==e&&Et()!==e?((fe=Wa())===e&&(fe=Uc()),fe!==e&&Et()!==e&&(Te=(function(){var bt,et,s;return bt=N,(et=He())!==e&&Et()!==e&&V()!==e&&Et()!==e?((s=Nc())===e&&(s=null),s!==e&&Et()!==e&&Se()!==e?(Or=bt,bt=et={type:"function",name:{name:[{type:"origin",value:et}]},args:s}):(N=bt,bt=e)):(N=bt,bt=e),bt===e&&(bt=N,t.substr(N,8).toLowerCase()==="restrict"?(et=t.substr(N,8),N+=8):(et=e,an===0&&$r(Qd)),et===e&&(t.substr(N,7).toLowerCase()==="cascade"?(et=t.substr(N,7),N+=7):(et=e,an===0&&$r(jl)),et===e&&(t.substr(N,8).toLowerCase()==="set null"?(et=t.substr(N,8),N+=8):(et=e,an===0&&$r(Od)),et===e&&(t.substr(N,9).toLowerCase()==="no action"?(et=t.substr(N,9),N+=9):(et=e,an===0&&$r($d)),et===e&&(t.substr(N,11).toLowerCase()==="set default"?(et=t.substr(N,11),N+=11):(et=e,an===0&&$r(wp)),et===e&&(et=He()))))),et!==e&&(Or=bt,et={type:"origin",value:et.toLowerCase()}),bt=et),bt})())!==e?(Or=W,Ge=Te,W={type:"on "+fe[0].toLowerCase(),value:Ge}):(N=W,W=e)):(N=W,W=e),W}function B0(){var W,fe,Te,Ge,bt,et,s,Be,kn;return W=N,(fe=pc())===e&&(fe=null),fe!==e&&Et()!==e?((Te=(function(){var nr,ur,Ce;return nr=N,t.substr(N,9).toLowerCase()==="character"?(ur=t.substr(N,9),N+=9):(ur=e,an===0&&$r(Zf)),ur!==e&&Et()!==e?(t.substr(N,3).toLowerCase()==="set"?(Ce=t.substr(N,3),N+=3):(Ce=e,an===0&&$r(ml)),Ce!==e?(Or=nr,nr=ur="CHARACTER SET"):(N=nr,nr=e)):(N=nr,nr=e),nr})())===e&&(t.substr(N,7).toLowerCase()==="charset"?(Te=t.substr(N,7),N+=7):(Te=e,an===0&&$r(Dd)),Te===e&&(t.substr(N,7).toLowerCase()==="collate"?(Te=t.substr(N,7),N+=7):(Te=e,an===0&&$r(Cc)))),Te!==e&&Et()!==e?((Ge=$t())===e&&(Ge=null),Ge!==e&&Et()!==e&&(bt=dc())!==e?(Or=W,s=Te,Be=Ge,kn=bt,W=fe={keyword:(et=fe)&&`${et[0].toLowerCase()} ${s.toLowerCase()}`||s.toLowerCase(),symbol:Be,value:kn}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function dp(){var W,fe,Te,Ge,bt,et,s,Be,kn;return W=N,t.substr(N,14).toLowerCase()==="auto_increment"?(fe=t.substr(N,14),N+=14):(fe=e,an===0&&$r(Qn)),fe===e&&(t.substr(N,14).toLowerCase()==="avg_row_length"?(fe=t.substr(N,14),N+=14):(fe=e,an===0&&$r(Kf)),fe===e&&(t.substr(N,14).toLowerCase()==="key_block_size"?(fe=t.substr(N,14),N+=14):(fe=e,an===0&&$r(kf)),fe===e&&(t.substr(N,8).toLowerCase()==="max_rows"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(fd)),fe===e&&(t.substr(N,8).toLowerCase()==="min_rows"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(cb)),fe===e&&(t.substr(N,18).toLowerCase()==="stats_sample_pages"?(fe=t.substr(N,18),N+=18):(fe=e,an===0&&$r(dd))))))),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e&&(Ge=Dc())!==e?(Or=W,Be=Te,kn=Ge,W=fe={keyword:fe.toLowerCase(),symbol:Be,value:kn.value}):(N=W,W=e)):(N=W,W=e),W===e&&(W=B0())===e&&(W=N,(fe=xt())===e&&(t.substr(N,10).toLowerCase()==="connection"?(fe=t.substr(N,10),N+=10):(fe=e,an===0&&$r(hl))),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e&&(Ge=Ya())!==e?(Or=W,W=fe=(function(nr,ur,Ce){return{keyword:nr.toLowerCase(),symbol:ur,value:`'${Ce.value}'`}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,t.substr(N,11).toLowerCase()==="compression"?(fe=t.substr(N,11),N+=11):(fe=e,an===0&&$r(e0)),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e?(Ge=N,t.charCodeAt(N)===39?(bt="'",N++):(bt=e,an===0&&$r(ku)),bt!==e?(t.substr(N,4).toLowerCase()==="zlib"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(Up)),et===e&&(t.substr(N,3).toLowerCase()==="lz4"?(et=t.substr(N,3),N+=3):(et=e,an===0&&$r(ep)),et===e&&(t.substr(N,4).toLowerCase()==="none"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(nl)))),et!==e?(t.charCodeAt(N)===39?(s="'",N++):(s=e,an===0&&$r(ku)),s!==e?Ge=bt=[bt,et,s]:(N=Ge,Ge=e)):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge!==e?(Or=W,W=fe=(function(nr,ur,Ce){return{keyword:nr.toLowerCase(),symbol:ur,value:Ce.join("").toUpperCase()}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,t.substr(N,6).toLowerCase()==="engine"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(pd)),fe!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e&&(Ge=Pu())!==e?(Or=W,W=fe=(function(nr,ur,Ce){return{keyword:nr.toLowerCase(),symbol:ur,value:Ce.toUpperCase()}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e)))),W}function I(){var W,fe,Te,Ge,bt;return W=N,(fe=Fr())!==e&&Et()!==e&&(Te=(function(){var et,s,Be;return et=N,t.substr(N,4).toLowerCase()==="read"?(s=t.substr(N,4),N+=4):(s=e,an===0&&$r(Qi)),s!==e&&Et()!==e?(t.substr(N,5).toLowerCase()==="local"?(Be=t.substr(N,5),N+=5):(Be=e,an===0&&$r(Vu)),Be===e&&(Be=null),Be!==e?(Or=et,et=s={type:"read",suffix:Be&&"local"}):(N=et,et=e)):(N=et,et=e),et===e&&(et=N,t.substr(N,12).toLowerCase()==="low_priority"?(s=t.substr(N,12),N+=12):(s=e,an===0&&$r(Ir)),s===e&&(s=null),s!==e&&Et()!==e?(t.substr(N,5).toLowerCase()==="write"?(Be=t.substr(N,5),N+=5):(Be=e,an===0&&$r(ns)),Be!==e?(Or=et,et=s={type:"write",prefix:s&&"low_priority"}):(N=et,et=e)):(N=et,et=e)),et})())!==e?(Or=W,Ge=fe,bt=Te,wa.add(`lock::${Ge.db}::${Ge.table}`),W=fe={table:Ge,lock_type:bt}):(N=W,W=e),W}function _r(){var W,fe,Te,Ge,bt,et,s;return(W=(function(){var Be,kn,nr,ur,Ce,Gt,Es,Co,ai,Mt,li,Pt;return Be=N,(kn=Et())!==e?((nr=(function(){var So,so,Xo,Ut,yo,zi,Y,le,Le,Re,pt,Ct;if(So=N,(so=bc())!==e)if(Et()!==e)if((Xo=cc())!==e){for(Ut=[],yo=N,(zi=Et())!==e&&(Y=ae())!==e&&(le=Et())!==e&&(Le=cc())!==e?yo=zi=[zi,Y,le,Le]:(N=yo,yo=e);yo!==e;)Ut.push(yo),yo=N,(zi=Et())!==e&&(Y=ae())!==e&&(le=Et())!==e&&(Le=cc())!==e?yo=zi=[zi,Y,le,Le]:(N=yo,yo=e);Ut!==e?(Or=So,so=ln(Xo,Ut),So=so):(N=So,So=e)}else N=So,So=e;else N=So,So=e;else N=So,So=e;if(So===e)if(So=N,(so=Et())!==e)if(bc()!==e)if((Xo=Et())!==e)if((Ut=(function(){var Kt,qn,er,Gr;return Kt=N,t.substr(N,9).toLowerCase()==="recursive"?(qn=t.substr(N,9),N+=9):(qn=e,an===0&&$r(kl)),qn!==e?(er=N,an++,Gr=fo(),an--,Gr===e?er=void 0:(N=er,er=e),er!==e?Kt=qn=[qn,er]:(N=Kt,Kt=e)):(N=Kt,Kt=e),Kt})())!==e)if((yo=Et())!==e)if((zi=cc())!==e){for(Y=[],le=N,(Le=Et())!==e&&(Re=ae())!==e&&(pt=Et())!==e&&(Ct=cc())!==e?le=Le=[Le,Re,pt,Ct]:(N=le,le=e);le!==e;)Y.push(le),le=N,(Le=Et())!==e&&(Re=ae())!==e&&(pt=Et())!==e&&(Ct=cc())!==e?le=Le=[Le,Re,pt,Ct]:(N=le,le=e);Y!==e?(Or=So,Zt=Y,(Dt=zi).recursive=!0,so=rn(Dt,Zt),So=so):(N=So,So=e)}else N=So,So=e;else N=So,So=e;else N=So,So=e;else N=So,So=e;else N=So,So=e;else N=So,So=e;var Dt,Zt;return So})())===e&&(nr=null),nr!==e&&Et()!==e&&(function(){var So,so,Xo,Ut;return So=N,t.substr(N,6).toLowerCase()==="select"?(so=t.substr(N,6),N+=6):(so=e,an===0&&$r(pf)),so!==e?(Xo=N,an++,Ut=fo(),an--,Ut===e?Xo=void 0:(N=Xo,Xo=e),Xo!==e?So=so=[so,Xo]:(N=So,So=e)):(N=So,So=e),So})()!==e&&ps()!==e?((ur=(function(){var So,so,Xo,Ut,yo,zi;if(So=N,(so=Sr())!==e){for(Xo=[],Ut=N,(yo=Et())!==e&&(zi=Sr())!==e?Ut=yo=[yo,zi]:(N=Ut,Ut=e);Ut!==e;)Xo.push(Ut),Ut=N,(yo=Et())!==e&&(zi=Sr())!==e?Ut=yo=[yo,zi]:(N=Ut,Ut=e);Xo!==e?(Or=So,so=(function(Y,le){let Le=[Y];for(let Re=0,pt=le.length;Re<pt;++Re)Le.push(le[Re][1]);return Le})(so,Xo),So=so):(N=So,So=e)}else N=So,So=e;return So})())===e&&(ur=null),ur!==e&&Et()!==e?((Ce=ju())===e&&(Ce=null),Ce!==e&&Et()!==e&&(Gt=Xt())!==e&&Et()!==e?((Es=hr())===e&&(Es=null),Es!==e&&Et()!==e?((Co=Rp())===e&&(Co=null),Co!==e&&Et()!==e?((ai=(function(){var So,so,Xo;return So=N,(so=(function(){var Ut,yo,zi,Y;return Ut=N,t.substr(N,5).toLowerCase()==="group"?(yo=t.substr(N,5),N+=5):(yo=e,an===0&&$r(nb)),yo!==e?(zi=N,an++,Y=fo(),an--,Y===e?zi=void 0:(N=zi,zi=e),zi!==e?Ut=yo=[yo,zi]:(N=Ut,Ut=e)):(N=Ut,Ut=e),Ut})())!==e&&Et()!==e&&of()!==e&&Et()!==e&&(Xo=Nc())!==e?(Or=So,so={columns:Xo.value},So=so):(N=So,So=e),So})())===e&&(ai=null),ai!==e&&Et()!==e?((Mt=(function(){var So,so;return So=N,(function(){var Xo,Ut,yo,zi;return Xo=N,t.substr(N,6).toLowerCase()==="having"?(Ut=t.substr(N,6),N+=6):(Ut=e,an===0&&$r(Sb)),Ut!==e?(yo=N,an++,zi=fo(),an--,zi===e?yo=void 0:(N=yo,yo=e),yo!==e?Xo=Ut=[Ut,yo]:(N=Xo,Xo=e)):(N=Xo,Xo=e),Xo})()!==e&&Et()!==e&&(so=ql())!==e?(Or=So,So=so):(N=So,So=e),So})())===e&&(Mt=null),Mt!==e&&Et()!==e?((li=ol())===e&&(li=null),li!==e&&Et()!==e?((Pt=Jp())===e&&(Pt=null),Pt!==e?(Or=Be,kn=(function(So,so,Xo,Ut,yo,zi,Y,le,Le,Re){return yo&&(Array.isArray(yo)?yo:yo.expr).forEach(pt=>pt.table&&wa.add(`select::${pt.db}::${pt.table}`)),{with:So,type:"select",options:so,distinct:Xo,columns:Ut,from:yo,where:zi,groupby:Y,having:le,orderby:Le,limit:Re}})(nr,ur,Ce,Gt,Es,Co,ai,Mt,li,Pt),Be=kn):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e)):(N=Be,Be=e),Be})())===e&&(W=N,fe=N,t.charCodeAt(N)===40?(Te="(",N++):(Te=e,an===0&&$r(js)),Te!==e&&(Ge=Et())!==e&&(bt=_r())!==e&&(et=Et())!==e?(t.charCodeAt(N)===41?(s=")",N++):(s=e,an===0&&$r(oo)),s!==e?fe=Te=[Te,Ge,bt,et,s]:(N=fe,fe=e)):(N=fe,fe=e),fe!==e&&(Or=W,fe={...fe[2],parentheses_symbol:!0}),W=fe),W}function cc(){var W,fe,Te,Ge;return W=N,(fe=Ya())===e&&(fe=Pu()),fe!==e&&Et()!==e?((Te=_())===e&&(Te=null),Te!==e&&Et()!==e&&gu()!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Ge=Gf())!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe=(function(bt,et,s){return typeof bt=="string"&&(bt={type:"default",value:bt}),{name:bt,stmt:s,columns:et}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e),W}function _(){var W,fe;return W=N,V()!==e&&Et()!==e&&(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr;if(Te=N,(Ge=il())!==e){for(bt=[],et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=il())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);et!==e;)bt.push(et),et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=il())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);bt!==e?(Or=Te,Ge=ln(Ge,bt),Te=Ge):(N=Te,Te=e)}else N=Te,Te=e;return Te})())!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe):(N=W,W=e),W}function Sr(){var W,fe;return W=N,(fe=(function(){var Te;return t.substr(N,19).toLowerCase()==="sql_calc_found_rows"?(Te=t.substr(N,19),N+=19):(Te=e,an===0&&$r(v0)),Te})())===e&&((fe=(function(){var Te;return t.substr(N,9).toLowerCase()==="sql_cache"?(Te=t.substr(N,9),N+=9):(Te=e,an===0&&$r(P)),Te})())===e&&(fe=(function(){var Te;return t.substr(N,12).toLowerCase()==="sql_no_cache"?(Te=t.substr(N,12),N+=12):(Te=e,an===0&&$r(Mr)),Te})()),fe===e&&(fe=(function(){var Te;return t.substr(N,14).toLowerCase()==="sql_big_result"?(Te=t.substr(N,14),N+=14):(Te=e,an===0&&$r(Ed)),Te})())===e&&(fe=(function(){var Te;return t.substr(N,16).toLowerCase()==="sql_small_result"?(Te=t.substr(N,16),N+=16):(Te=e,an===0&&$r(P0)),Te})())===e&&(fe=(function(){var Te;return t.substr(N,17).toLowerCase()==="sql_buffer_result"?(Te=t.substr(N,17),N+=17):(Te=e,an===0&&$r(M0)),Te})())),fe!==e&&(Or=W,fe=fe),W=fe}function Xt(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=bl())===e&&(fe=N,(Te=Ie())!==e?(Ge=N,an++,bt=fo(),an--,bt===e?Ge=void 0:(N=Ge,Ge=e),Ge!==e?fe=Te=[Te,Ge]:(N=fe,fe=e)):(N=fe,fe=e),fe===e&&(fe=Ie())),fe!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=qr())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=qr())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(kn,nr){va.add("select::null::(.*)");let ur={expr:{type:"column_ref",table:null,column:"*"},as:null};return nr&&nr.length>0?rn(ur,nr):[ur]})(0,Te)):(N=W,W=e)}else N=W,W=e;if(W===e)if(W=N,(fe=qr())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=qr())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=qr())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=ln(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Qr(){var W,fe,Te,Ge,bt,et,s;return W=N,kt()!==e&&Et()!==e?((fe=Dc())===e&&(fe=Ya()),fe!==e&&Et()!==e&&qt()!==e?(Te=N,(Ge=Et())!==e?(t.charCodeAt(N)===46?(bt=".",N++):(bt=e,an===0&&$r(Vs)),bt!==e&&(et=Et())!==e&&(s=Au())!==e?Te=Ge=[Ge,bt,et,s]:(N=Te,Te=e)):(N=Te,Te=e),Te===e&&(Te=null),Te!==e?(Or=W,W=(function(Be,kn){let nr;return kn&&(nr={type:"default",value:kn[3]}),{brackets:!0,index:Be,property:nr}})(fe,Te)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function yl(){var W,fe,Te,Ge,bt,et;if(W=N,(fe=Qr())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=Qr())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=Qr())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Ke(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function nn(){var W,fe,Te,Ge,bt;return W=N,(fe=(function(){var et,s,Be,kn,nr,ur,Ce,Gt;if(et=N,(s=ya())!==e){for(Be=[],kn=N,(nr=Et())!==e?((ur=Za())===e&&(ur=Tn())===e&&(ur=fr()),ur!==e&&(Ce=Et())!==e&&(Gt=ya())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e?((ur=Za())===e&&(ur=Tn())===e&&(ur=fr()),ur!==e&&(Ce=Et())!==e&&(Gt=ya())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);Be!==e?(Or=et,s=(function(Es,Co){let ai=Es.ast;if(ai&&ai.type==="select"&&(!(Es.parentheses_symbol||Es.parentheses||Es.ast.parentheses||Es.ast.parentheses_symbol)||ai.columns.length!==1||ai.columns[0].expr.column==="*"))throw new Error("invalid column clause with select statement");if(!Co||Co.length===0)return Es;let Mt=Co.length,li=Co[Mt-1][3];for(let Pt=Mt-1;Pt>=0;Pt--){let So=Pt===0?Es:Co[Pt-1][3];li=Pa(Co[Pt][1],So,li)}return li})(s,Be),et=s):(N=et,et=e)}else N=et,et=e;return et})())!==e&&Et()!==e?((Te=yl())===e&&(Te=null),Te!==e?(Or=W,Ge=fe,(bt=Te)&&(Ge.array_index=bt),W=fe=Ge):(N=W,W=e)):(N=W,W=e),W}function qr(){var W,fe,Te,Ge,bt,et,s;return W=N,fe=N,(Te=Au())!==e&&(Ge=Et())!==e&&(bt=X())!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e),fe===e&&(fe=null),fe!==e&&(Te=Et())!==e&&(Ge=Ie())!==e?(Or=W,W=fe=(function(Be){let kn=Be&&Be[0]||null;return va.add(`select::${kn}::(.*)`),{expr:{type:"column_ref",table:kn,column:"*"},as:null}})(fe)):(N=W,W=e),W===e&&(W=N,(fe=nn())!==e&&(Te=Et())!==e?((Ge=Hd())===e&&(Ge=null),Ge!==e?(Or=W,s=Ge,(et=fe).type!=="double_quote_string"&&et.type!=="single_quote_string"||va.add("select::null::"+et.value),W=fe={type:"expr",expr:et,as:s}):(N=W,W=e)):(N=W,W=e)),W}function pr(){var W,fe,Te;return W=N,(fe=gu())===e&&(fe=null),fe!==e&&Et()!==e?((Te=$u())===e&&(Te=hp()),Te!==e?(Or=W,W=fe=Te):(N=W,W=e)):(N=W,W=e),W}function Hd(){var W,fe,Te;return W=N,(fe=gu())!==e&&Et()!==e?((Te=$u())===e&&(Te=hp()),Te!==e?(Or=W,W=fe=Te):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=gu())===e&&(fe=null),fe!==e&&Et()!==e&&(Te=Au())!==e?(Or=W,W=fe=Te):(N=W,W=e)),W}function pp(){var W,fe,Te,Ge,bt;return W=N,t.substr(N,6).toLowerCase()==="unnest"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(xo)),fe!==e&&Et()!==e&&V()!==e&&Et()!==e?((Te=ya())===e&&(Te=null),Te!==e&&Et()!==e&&Se()!==e&&Et()!==e?((Ge=$u())===e&&(Ge=Hd()),Ge===e&&(Ge=null),Ge!==e&&Et()!==e?((bt=(function(){var et,s;return et=N,bc()!==e&&Et()!==e&&jn()!==e&&Et()!==e?((s=Hd())===e&&(s=null),s!==e?(Or=et,et={keyword:"with offset as",as:s}):(N=et,et=e)):(N=et,et=e),et})())===e&&(bt=null),bt!==e?(Or=W,W=fe={type:"unnest",expr:Te,parentheses:!0,as:Ge,with_offset:bt}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W}function hr(){var W,fe;return W=N,Dn()!==e&&Et()!==e&&(fe=pl())!==e?(Or=W,W=fe):(N=W,W=e),W}function E(){var W,fe,Te;return W=N,(fe=Ku())!==e&&Et()!==e&&Rd()!==e&&Et()!==e&&(Te=Ku())!==e?(Or=W,W=fe=[fe,Te]):(N=W,W=e),W}function vr(){var W,fe;return W=N,Ef()!==e&&Et()!==e?(t.substr(N,5).toLowerCase()==="btree"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(No)),fe===e&&(t.substr(N,4).toLowerCase()==="hash"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Po))),fe!==e?(Or=W,W={keyword:"using",type:fe.toLowerCase()}):(N=W,W=e)):(N=W,W=e),W}function fc(){var W,fe,Te,Ge,bt,et;if(W=N,(fe=dl())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=dl())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=dl())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(s,Be){let kn=[s];for(let nr=0;nr<Be.length;nr++)kn.push(Be[nr][1]);return kn})(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function dl(){var W,fe,Te,Ge,bt,et;return W=N,(fe=(function(){var s,Be,kn,nr;return s=N,t.substr(N,14).toLowerCase()==="key_block_size"?(Be=t.substr(N,14),N+=14):(Be=e,an===0&&$r(kf)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="KEY_BLOCK_SIZE"):(N=s,s=e)):(N=s,s=e),s})())!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e&&(Ge=Dc())!==e?(Or=W,bt=Te,et=Ge,W=fe={type:fe.toLowerCase(),symbol:bt,expr:et}):(N=W,W=e)):(N=W,W=e),W===e&&(W=vr())===e&&(W=N,t.substr(N,4).toLowerCase()==="with"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(na)),fe!==e&&Et()!==e?(t.substr(N,6).toLowerCase()==="parser"?(Te=t.substr(N,6),N+=6):(Te=e,an===0&&$r(Ra)),Te!==e&&Et()!==e&&(Ge=Pu())!==e?(Or=W,W=fe={type:"with parser",expr:Ge}):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,t.substr(N,7).toLowerCase()==="visible"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(aa)),fe===e&&(t.substr(N,9).toLowerCase()==="invisible"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(Va))),fe!==e&&(Or=W,fe=(function(s){return{type:s.toLowerCase(),expr:s.toLowerCase()}})(fe)),(W=fe)===e&&(W=_n()))),W}function pl(){var W,fe,Te,Ge;if(W=N,(fe=Fr())!==e)if(Et()!==e){for(Te=[],Ge=Vt();Ge!==e;)Te.push(Ge),Ge=Vt();Te!==e?(Or=W,W=fe=Cu(fe,Te)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;return W}function Vt(){var W,fe,Te;return W=N,Et()!==e&&(fe=ae())!==e&&Et()!==e&&(Te=Fr())!==e?(Or=W,W=Te):(N=W,W=e),W===e&&(W=N,Et()!==e&&(fe=(function(){var Ge,bt,et,s,Be,kn,nr,ur,Ce,Gt,Es;if(Ge=N,(bt=Zu())!==e)if(Et()!==e)if((et=Fr())!==e)if(Et()!==e)if((s=Ef())!==e)if(Et()!==e)if(V()!==e)if(Et()!==e)if((Be=dc())!==e){for(kn=[],nr=N,(ur=Et())!==e&&(Ce=ae())!==e&&(Gt=Et())!==e&&(Es=dc())!==e?nr=ur=[ur,Ce,Gt,Es]:(N=nr,nr=e);nr!==e;)kn.push(nr),nr=N,(ur=Et())!==e&&(Ce=ae())!==e&&(Gt=Et())!==e&&(Es=dc())!==e?nr=ur=[ur,Ce,Gt,Es]:(N=nr,nr=e);kn!==e&&(nr=Et())!==e&&(ur=Se())!==e?(Or=Ge,Co=bt,Mt=Be,li=kn,(ai=et).join=Co,ai.using=rn(Mt,li),Ge=bt=ai):(N=Ge,Ge=e)}else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;else N=Ge,Ge=e;var Co,ai,Mt,li;return Ge===e&&(Ge=N,(bt=Zu())!==e&&Et()!==e&&(et=Fr())!==e&&Et()!==e?((s=dr())===e&&(s=null),s!==e?(Or=Ge,bt=(function(Pt,So,so){return So.join=Pt,So.on=so,So})(bt,et,s),Ge=bt):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge===e&&(Ge=N,(bt=Zu())===e&&(bt=ed()),bt!==e&&Et()!==e&&(et=V())!==e&&Et()!==e?((s=Gf())===e&&(s=pl()),s!==e&&Et()!==e&&Se()!==e&&Et()!==e?((Be=Hd())===e&&(Be=null),Be!==e&&(kn=Et())!==e?((nr=dr())===e&&(nr=null),nr!==e?(Or=Ge,bt=(function(Pt,So,so,Xo){return So.parentheses=!0,{expr:So,as:so,join:Pt,on:Xo}})(bt,s,Be,nr),Ge=bt):(N=Ge,Ge=e)):(N=Ge,Ge=e)):(N=Ge,Ge=e)):(N=Ge,Ge=e))),Ge})())!==e?(Or=W,W=fe):(N=W,W=e)),W}function Fr(){var W,fe,Te,Ge;return(W=pp())===e&&(W=N,(fe=(function(){var bt;return t.substr(N,4).toLowerCase()==="dual"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(An)),bt})())!==e&&(Or=W,fe={type:"dual"}),(W=fe)===e&&(W=N,(fe=Np())!==e&&Et()!==e?((Te=pr())===e&&(Te=null),Te!==e?(Or=W,W=fe={expr:fe,as:Te}):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=V())!==e&&Et()!==e&&(Te=Np())!==e&&Et()!==e&&Se()!==e&&Et()!==e?((Ge=pr())===e&&(Ge=null),Ge!==e?(Or=W,W=fe=(function(bt,et){return{expr:{...bt,parentheses:!0},as:et}})(Te,Ge)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=Ku())!==e&&Et()!==e?((Te=Hd())===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(bt,et){return bt.type==="var"?(bt.as=et,bt):{db:bt.db,table:bt.table,as:et}})(fe,Te)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=V())!==e&&Et()!==e&&(Te=Gf())!==e&&Et()!==e&&Se()!==e&&Et()!==e?((Ge=Hd())===e&&(Ge=null),Ge!==e?(Or=W,W=fe=(function(bt,et){return bt.parentheses=!0,{expr:bt,as:et}})(Te,Ge)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=V())!==e&&Et()!==e&&(Te=pl())!==e&&Et()!==e&&Se()!==e&&Et()!==e?((Ge=Hd())===e&&(Ge=null),Ge!==e?(Or=W,W=fe=(function(bt,et){return{expr:bt={type:"tables",expr:bt,parentheses:!0},as:et}})(Te,Ge)):(N=W,W=e)):(N=W,W=e))))))),W}function Zu(){var W,fe,Te,Ge;return W=N,(fe=(function(){var bt,et,s,Be;return bt=N,t.substr(N,4).toLowerCase()==="left"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(kc)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?bt=et=[et,s]:(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Te=Et())!==e?((Ge=oa())===e&&(Ge=null),Ge!==e&&Et()!==e&&$s()!==e?(Or=W,W=fe="LEFT JOIN"):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=(function(){var bt,et,s,Be;return bt=N,t.substr(N,5).toLowerCase()==="right"?(et=t.substr(N,5),N+=5):(et=e,an===0&&$r(oc)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?bt=et=[et,s]:(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Te=Et())!==e?((Ge=oa())===e&&(Ge=null),Ge!==e&&Et()!==e&&$s()!==e?(Or=W,W=fe="RIGHT JOIN"):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=(function(){var bt,et,s,Be;return bt=N,t.substr(N,4).toLowerCase()==="full"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(R0)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?bt=et=[et,s]:(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Te=Et())!==e?((Ge=oa())===e&&(Ge=null),Ge!==e&&Et()!==e&&$s()!==e?(Or=W,W=fe="FULL JOIN"):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,fe=N,(Te=(function(){var bt,et,s,Be;return bt=N,t.substr(N,5).toLowerCase()==="inner"?(et=t.substr(N,5),N+=5):(et=e,an===0&&$r(db)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?bt=et=[et,s]:(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Ge=Et())!==e?fe=Te=[Te,Ge]:(N=fe,fe=e),fe===e&&(fe=null),fe!==e&&(Te=$s())!==e?(Or=W,W=fe="INNER JOIN"):(N=W,W=e),W===e&&(W=N,(fe=(function(){var bt,et,s,Be;return bt=N,t.substr(N,5).toLowerCase()==="cross"?(et=t.substr(N,5),N+=5):(et=e,an===0&&$r(Bd)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?bt=et=[et,s]:(N=bt,bt=e)):(N=bt,bt=e),bt})())!==e&&(Te=Et())!==e&&(Ge=$s())!==e?(Or=W,W=fe="CROSS JOIN"):(N=W,W=e))))),W}function Ku(){var W,fe,Te,Ge,bt,et,s,Be;return W=N,(fe=Au())!==e?(Te=N,(Ge=Et())!==e&&(bt=X())!==e&&(et=Et())!==e&&(s=Au())!==e?Te=Ge=[Ge,bt,et,s]:(N=Te,Te=e),Te===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(kn,nr){let ur={db:null,table:kn};return nr!==null&&(ur.db=kn,ur.table=nr[3]),ur})(fe,Te)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=Sa())!==e&&(Or=W,(Be=fe).db=null,Be.table=Be.name,fe=Be),W=fe),W}function Yd(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=ya())!==e){for(Te=[],Ge=N,(bt=Et())!==e?((et=Za())===e&&(et=Tn()),et!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e?((et=Za())===e&&(et=Tn()),et!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(kn,nr){let ur=nr.length,Ce=kn;for(let Gt=0;Gt<ur;++Gt)Ce=Pa(nr[Gt][1],Ce,nr[Gt][3]);return Ce})(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function dr(){var W,fe;return W=N,Ki()!==e&&Et()!==e&&(fe=ql())!==e?(Or=W,W=fe):(N=W,W=e),W}function Rp(){var W,fe;return W=N,(function(){var Te,Ge,bt,et;return Te=N,t.substr(N,5).toLowerCase()==="where"?(Ge=t.substr(N,5),N+=5):(Ge=e,an===0&&$r(bb)),Ge!==e?(bt=N,an++,et=fo(),an--,et===e?bt=void 0:(N=bt,bt=e),bt!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e)):(N=Te,Te=e),Te})()!==e&&Et()!==e&&(fe=ql())!==e?(Or=W,W=fe):(N=W,W=e),W}function Bf(){var W,fe;return(W=Pu())===e&&(W=N,V()!==e&&Et()!==e?((fe=(function(){var Te,Ge,bt,et;return Te=N,(Ge=Gl())===e&&(Ge=null),Ge!==e&&Et()!==e?((bt=ol())===e&&(bt=null),bt!==e&&Et()!==e?((et=(function(){var s,Be,kn,nr,ur;return s=N,(Be=ct())!==e&&Et()!==e?((kn=bp())===e&&(kn=Ad()),kn!==e?(Or=s,s=Be={type:"rows",expr:kn}):(N=s,s=e)):(N=s,s=e),s===e&&(s=N,(Be=ct())!==e&&Et()!==e&&(kn=$i())!==e&&Et()!==e&&(nr=Ad())!==e&&Et()!==e&&Za()!==e&&Et()!==e?((ur=bp())===e&&(ur=Ad()),ur!==e?(Or=s,Be=Pa(kn,{type:"origin",value:"rows"},{type:"expr_list",value:[nr,ur]}),s=Be):(N=s,s=e)):(N=s,s=e)),s})())===e&&(et=null),et!==e?(Or=Te,Te=Ge={name:null,partitionby:Ge,orderby:bt,window_frame_clause:et}):(N=Te,Te=e)):(N=Te,Te=e)):(N=Te,Te=e),Te})())===e&&(fe=null),fe!==e&&Et()!==e&&Se()!==e?(Or=W,W={window_specification:fe||{},parentheses:!0}):(N=W,W=e)):(N=W,W=e)),W}function bp(){var W,fe,Te,Ge;return W=N,(fe=Zc())!==e&&Et()!==e?(t.substr(N,9).toLowerCase()==="following"?(Te=t.substr(N,9),N+=9):(Te=e,an===0&&$r(uu)),Te!==e?(Or=W,(Ge=fe).value+=" FOLLOWING",W=fe=Ge):(N=W,W=e)):(N=W,W=e),W===e&&(W=Wd()),W}function Ad(){var W,fe,Te,Ge,bt;return W=N,(fe=Zc())!==e&&Et()!==e?(t.substr(N,9).toLowerCase()==="preceding"?(Te=t.substr(N,9),N+=9):(Te=e,an===0&&$r(lu)),Te===e&&(t.substr(N,9).toLowerCase()==="following"?(Te=t.substr(N,9),N+=9):(Te=e,an===0&&$r(uu))),Te!==e?(Or=W,bt=Te,(Ge=fe).value+=" "+bt.toUpperCase(),W=fe=Ge):(N=W,W=e)):(N=W,W=e),W===e&&(W=Wd()),W}function Wd(){var W,fe,Te;return W=N,t.substr(N,7).toLowerCase()==="current"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(ec)),fe!==e&&Et()!==e?(t.substr(N,3).toLowerCase()==="row"?(Te=t.substr(N,3),N+=3):(Te=e,an===0&&$r(Pp)),Te!==e?(Or=W,W=fe={type:"origin",value:"current row"}):(N=W,W=e)):(N=W,W=e),W}function Zc(){var W,fe;return W=N,t.substr(N,9).toLowerCase()==="unbounded"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(Rf)),fe!==e&&(Or=W,fe={type:"origin",value:fe.toUpperCase()}),(W=fe)===e&&(W=Dc()),W}function ol(){var W,fe;return W=N,(function(){var Te,Ge,bt,et;return Te=N,t.substr(N,5).toLowerCase()==="order"?(Ge=t.substr(N,5),N+=5):(Ge=e,an===0&&$r(_b)),Ge!==e?(bt=N,an++,et=fo(),an--,et===e?bt=void 0:(N=bt,bt=e),bt!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e)):(N=Te,Te=e),Te})()!==e&&Et()!==e&&of()!==e&&Et()!==e&&(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr;if(Te=N,(Ge=za())!==e){for(bt=[],et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=za())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);et!==e;)bt.push(et),et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=za())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);bt!==e?(Or=Te,Ge=ln(Ge,bt),Te=Ge):(N=Te,Te=e)}else N=Te,Te=e;return Te})())!==e?(Or=W,W=fe):(N=W,W=e),W}function Gl(){var W,fe;return W=N,Al()!==e&&Et()!==e&&of()!==e&&Et()!==e&&(fe=Xt())!==e?(Or=W,W=fe):(N=W,W=e),W}function za(){var W,fe,Te;return W=N,(fe=ya())!==e&&Et()!==e?((Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="desc"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(vb)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="DESC"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())===e&&(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,3).toLowerCase()==="asc"?(bt=t.substr(N,3),N+=3):(bt=e,an===0&&$r(yv)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="ASC"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})()),Te===e&&(Te=null),Te!==e?(Or=W,W=fe={expr:fe,type:Te}):(N=W,W=e)):(N=W,W=e),W}function Js(){var W;return(W=Dc())===e&&(W=$c()),W}function Jp(){var W,fe,Te,Ge,bt,et;return W=N,(function(){var s,Be,kn,nr;return s=N,t.substr(N,5).toLowerCase()==="limit"?(Be=t.substr(N,5),N+=5):(Be=e,an===0&&$r(N0)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?s=Be=[Be,kn]:(N=s,s=e)):(N=s,s=e),s})()!==e&&Et()!==e&&(fe=Js())!==e&&Et()!==e?(Te=N,(Ge=ae())===e&&(Ge=jn()),Ge!==e&&(bt=Et())!==e&&(et=Js())!==e?Te=Ge=[Ge,bt,et]:(N=Te,Te=e),Te===e&&(Te=null),Te!==e?(Or=W,W=(function(s,Be){let kn=[s];return Be&&kn.push(Be[2]),{seperator:Be&&Be[0]&&Be[0].toLowerCase()||"",value:kn}})(fe,Te)):(N=W,W=e)):(N=W,W=e),W}function nd(){var W,fe,Te,Ge,bt,et,s,Be;return W=N,fe=N,(Te=Au())!==e&&(Ge=Et())!==e&&(bt=X())!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e),fe===e&&(fe=null),fe!==e&&(Te=Et())!==e&&(Ge=Lf())!==e&&(bt=Et())!==e?(t.charCodeAt(N)===61?(et="=",N++):(et=e,an===0&&$r(Nf)),et!==e&&Et()!==e&&(s=ya())!==e?(Or=W,W=fe=(function(kn,nr,ur){return{column:nr,value:ur,table:kn&&kn[0]}})(fe,Ge,s)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,fe=N,(Te=Au())!==e&&(Ge=Et())!==e&&(bt=X())!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e),fe===e&&(fe=null),fe!==e&&(Te=Et())!==e&&(Ge=Lf())!==e&&(bt=Et())!==e?(t.charCodeAt(N)===61?(et="=",N++):(et=e,an===0&&$r(Nf)),et!==e&&Et()!==e&&(s=En())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=il())!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe=(function(kn,nr,ur){return{column:nr,value:ur,table:kn&&kn[0],keyword:"values"}})(fe,Ge,Be)):(N=W,W=e)):(N=W,W=e)),W}function vp(){var W,fe;return(W=Np())===e&&(W=N,(fe=Gf())!==e&&(Or=W,fe=fe.ast),W=fe),W}function mp(){var W,fe,Te,Ge,bt,et,s,Be,kn;if(W=N,Al()!==e)if(Et()!==e)if((fe=V())!==e)if(Et()!==e)if((Te=Pu())!==e){for(Ge=[],bt=N,(et=Et())!==e&&(s=ae())!==e&&(Be=Et())!==e&&(kn=Pu())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,(et=Et())!==e&&(s=ae())!==e&&(Be=Et())!==e&&(kn=Pu())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e);Ge!==e&&(bt=Et())!==e&&(et=Se())!==e?(Or=W,W=rn(Te,Ge)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;return W===e&&(W=N,Al()!==e&&Et()!==e&&(fe=Nl())!==e?(Or=W,W=fe):(N=W,W=e)),W}function sf(){var W,fe;return W=N,(fe=(function(){var Te,Ge,bt,et;return Te=N,t.substr(N,6).toLowerCase()==="insert"?(Ge=t.substr(N,6),N+=6):(Ge=e,an===0&&$r(fu)),Ge!==e?(bt=N,an++,et=fo(),an--,et===e?bt=void 0:(N=bt,bt=e),bt!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e)):(N=Te,Te=e),Te})())!==e&&(Or=W,fe="insert"),(W=fe)===e&&(W=N,(fe=Qs())!==e&&(Or=W,fe="replace"),W=fe),W}function Np(){var W,fe;return W=N,En()!==e&&Et()!==e&&(fe=(function(){var Te,Ge,bt,et,s,Be,kn,nr;if(Te=N,(Ge=Nl())!==e){for(bt=[],et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=Nl())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);et!==e;)bt.push(et),et=N,(s=Et())!==e&&(Be=ae())!==e&&(kn=Et())!==e&&(nr=Nl())!==e?et=s=[s,Be,kn,nr]:(N=et,et=e);bt!==e?(Or=Te,Ge=ln(Ge,bt),Te=Ge):(N=Te,Te=e)}else N=Te,Te=e;return Te})())!==e?(Or=W,W={type:"values",values:fe}):(N=W,W=e),W}function Nl(){var W,fe;return W=N,V()!==e&&Et()!==e&&(fe=Nc())!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe):(N=W,W=e),W===e&&(W=$u()),W}function Nc(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=ya())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(kn,nr){let ur={type:"expr_list"};return ur.value=rn(kn,nr),ur})(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Bl(){var W,fe,Te;return W=N,De()!==e&&Et()!==e&&(fe=ya())!==e&&Et()!==e&&(Te=(function(){var Ge;return(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,4).toLowerCase()==="year"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(Fl)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="YEAR"):(N=bt,bt=e)):(N=bt,bt=e),bt})())===e&&(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,5).toLowerCase()==="month"?(et=t.substr(N,5),N+=5):(et=e,an===0&&$r(K0)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="MONTH"):(N=bt,bt=e)):(N=bt,bt=e),bt})())===e&&(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,3).toLowerCase()==="day"?(et=t.substr(N,3),N+=3):(et=e,an===0&&$r(gd)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="DAY"):(N=bt,bt=e)):(N=bt,bt=e),bt})())===e&&(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,4).toLowerCase()==="hour"?(et=t.substr(N,4),N+=4):(et=e,an===0&&$r(rc)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="HOUR"):(N=bt,bt=e)):(N=bt,bt=e),bt})())===e&&(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,6).toLowerCase()==="minute"?(et=t.substr(N,6),N+=6):(et=e,an===0&&$r(Sc)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="MINUTE"):(N=bt,bt=e)):(N=bt,bt=e),bt})())===e&&(Ge=(function(){var bt,et,s,Be;return bt=N,t.substr(N,6).toLowerCase()==="second"?(et=t.substr(N,6),N+=6):(et=e,an===0&&$r(ip)),et!==e?(s=N,an++,Be=fo(),an--,Be===e?s=void 0:(N=s,s=e),s!==e?(Or=bt,bt=et="SECOND"):(N=bt,bt=e)):(N=bt,bt=e),bt})()),Ge})())!==e?(Or=W,W={type:"interval",expr:fe,unit:Te.toLowerCase()}):(N=W,W=e),W}function co(){var W,fe,Te,Ge,bt,et;if(W=N,(fe=Zd())!==e)if(Et()!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=Zd())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=Zd())!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Ke(fe,Te)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;return W}function Zd(){var W,fe,Te;return W=N,(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="when"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(O0)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})()!==e&&Et()!==e&&(fe=ql())!==e&&Et()!==e&&(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="then"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(Ip)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})()!==e&&Et()!==e&&(Te=ya())!==e?(Or=W,W={type:"when",cond:fe,result:Te}):(N=W,W=e),W}function _d(){var W,fe;return W=N,(function(){var Te,Ge,bt,et;return Te=N,t.substr(N,4).toLowerCase()==="else"?(Ge=t.substr(N,4),N+=4):(Ge=e,an===0&&$r(Vp)),Ge!==e?(bt=N,an++,et=fo(),an--,et===e?bt=void 0:(N=bt,bt=e),bt!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e)):(N=Te,Te=e),Te})()!==e&&Et()!==e&&(fe=ya())!==e?(Or=W,W={type:"else",result:fe}):(N=W,W=e),W}function Sd(){var W;return(W=(function(){var fe,Te,Ge,bt,et,s,Be,kn;if(fe=N,(Te=yf())!==e){for(Ge=[],bt=N,(et=ps())!==e&&(s=Tn())!==e&&(Be=Et())!==e&&(kn=yf())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,(et=ps())!==e&&(s=Tn())!==e&&(Be=Et())!==e&&(kn=yf())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e);Ge!==e?(Or=fe,Te=Of(Te,Ge),fe=Te):(N=fe,fe=e)}else N=fe,fe=e;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s;if(fe=N,(Te=rd())!==e){if(Ge=[],bt=N,(et=Et())!==e&&(s=Hf())!==e?bt=et=[et,s]:(N=bt,bt=e),bt!==e)for(;bt!==e;)Ge.push(bt),bt=N,(et=Et())!==e&&(s=Hf())!==e?bt=et=[et,s]:(N=bt,bt=e);else Ge=e;Ge!==e?(Or=fe,Te=Bu(Te,Ge[0][1]),fe=Te):(N=fe,fe=e)}else N=fe,fe=e;return fe})()),W}function ya(){var W;return(W=Sd())===e&&(W=Gf()),W}function ql(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=ya())!==e){for(Te=[],Ge=N,(bt=Et())!==e?((et=Za())===e&&(et=Tn())===e&&(et=ae()),et!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e?((et=Za())===e&&(et=Tn())===e&&(et=ae()),et!==e&&(s=Et())!==e&&(Be=ya())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(kn,nr){let ur=nr.length,Ce=kn,Gt="";for(let Es=0;Es<ur;++Es)nr[Es][1]===","?(Gt=",",Array.isArray(Ce)||(Ce=[Ce]),Ce.push(nr[Es][3])):Ce=Pa(nr[Es][1],Ce,nr[Es][3]);if(Gt===","){let Es={type:"expr_list"};return Es.value=Ce,Es}return Ce})(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function yf(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=qf())!==e){for(Te=[],Ge=N,(bt=ps())!==e&&(et=Za())!==e&&(s=Et())!==e&&(Be=qf())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=ps())!==e&&(et=Za())!==e&&(s=Et())!==e&&(Be=qf())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Qu(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function qf(){var W,fe,Te,Ge,bt;return(W=Kc())===e&&(W=(function(){var et,s,Be;et=N,(s=(function(){var ur,Ce,Gt,Es,Co;return ur=N,Ce=N,(Gt=Zl())!==e&&(Es=Et())!==e&&(Co=Wl())!==e?Ce=Gt=[Gt,Es,Co]:(N=Ce,Ce=e),Ce!==e&&(Or=ur,Ce=$f(Ce)),(ur=Ce)===e&&(ur=Wl()),ur})())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=Gf())!==e&&Et()!==e&&Se()!==e?(Or=et,kn=s,(nr=Be).parentheses=!0,s=Bu(kn,nr),et=s):(N=et,et=e);var kn,nr;return et})())===e&&(W=N,(fe=Zl())===e&&(fe=N,t.charCodeAt(N)===33?(Te="!",N++):(Te=e,an===0&&$r(ff)),Te!==e?(Ge=N,an++,t.charCodeAt(N)===61?(bt="=",N++):(bt=e,an===0&&$r(Nf)),an--,bt===e?Ge=void 0:(N=Ge,Ge=e),Ge!==e?fe=Te=[Te,Ge]:(N=fe,fe=e)):(N=fe,fe=e)),fe!==e&&(Te=Et())!==e&&(Ge=qf())!==e?(Or=W,W=fe=Bu("NOT",Ge)):(N=W,W=e)),W}function Kc(){var W,fe,Te,Ge,bt;return W=N,(fe=Vl())!==e&&Et()!==e?((Te=(function(){var et;return(et=(function(){var s,Be,kn,nr,ur,Ce,Gt;if(s=N,Be=[],kn=N,(nr=Et())!==e&&(ur=wf())!==e&&(Ce=Et())!==e&&(Gt=Vl())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e),kn!==e)for(;kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e&&(ur=wf())!==e&&(Ce=Et())!==e&&(Gt=Vl())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e);else Be=e;return Be!==e&&(Or=s,Be={type:"arithmetic",tail:Be}),s=Be})())===e&&(et=(function(){var s,Be,kn,nr;return s=N,(Be=Vf())!==e&&Et()!==e&&(kn=V())!==e&&Et()!==e&&(nr=Nc())!==e&&Et()!==e&&Se()!==e?(Or=s,s=Be={op:Be,right:nr}):(N=s,s=e),s===e&&(s=N,(Be=Vf())!==e&&Et()!==e?((kn=Sa())===e&&(kn=Ya())===e&&(kn=$u()),kn!==e?(Or=s,Be=(function(ur,Ce){return{op:ur,right:Ce}})(Be,kn),s=Be):(N=s,s=e)):(N=s,s=e)),s})())===e&&(et=(function(){var s,Be,kn,nr;return s=N,(Be=(function(){var ur,Ce,Gt,Es,Co;return ur=N,Ce=N,(Gt=Zl())!==e&&(Es=Et())!==e&&(Co=$i())!==e?Ce=Gt=[Gt,Es,Co]:(N=Ce,Ce=e),Ce!==e&&(Or=ur,Ce=$f(Ce)),(ur=Ce)===e&&(ur=$i()),ur})())!==e&&Et()!==e&&(kn=Vl())!==e&&Et()!==e&&Za()!==e&&Et()!==e&&(nr=Vl())!==e?(Or=s,s=Be={op:Be,right:{type:"expr_list",value:[kn,nr]}}):(N=s,s=e),s})())===e&&(et=(function(){var s,Be,kn,nr,ur;return s=N,(Be=ha())!==e&&(kn=Et())!==e&&(nr=Vl())!==e?(Or=s,s=Be={op:"IS",right:nr}):(N=s,s=e),s===e&&(s=N,Be=N,(kn=ha())!==e&&(nr=Et())!==e&&(ur=Zl())!==e?Be=kn=[kn,nr,ur]:(N=Be,Be=e),Be!==e&&(kn=Et())!==e&&(nr=Vl())!==e?(Or=s,Be=(function(Ce){return{op:"IS NOT",right:Ce}})(nr),s=Be):(N=s,s=e)),s})())===e&&(et=(function(){var s,Be,kn;return s=N,(Be=(function(){var nr,ur,Ce,Gt,Es;return nr=N,ur=N,(Ce=Zl())!==e&&(Gt=Et())!==e&&(Es=ua())!==e?ur=Ce=[Ce,Gt,Es]:(N=ur,ur=e),ur!==e&&(Or=nr,ur=$f(ur)),(nr=ur)===e&&(nr=ua()),nr})())!==e&&Et()!==e?((kn=Oe())===e&&(kn=Kc()),kn!==e?(Or=s,Be=bd(Be,kn),s=Be):(N=s,s=e)):(N=s,s=e),s})())===e&&(et=(function(){var s,Be,kn;return s=N,(Be=(function(){var nr,ur,Ce,Gt,Es;return nr=N,ur=N,(Ce=Zl())!==e&&(Gt=Et())!==e&&(Es=vc())!==e?ur=Ce=[Ce,Gt,Es]:(N=ur,ur=e),ur!==e&&(Or=nr,ur=$f(ur)),(nr=ur)===e&&(nr=vc()),nr})())!==e&&Et()!==e?((kn=Oe())===e&&(kn=Kc()),kn!==e?(Or=s,Be=bd(Be,kn),s=Be):(N=s,s=e)):(N=s,s=e),s})()),et})())===e&&(Te=null),Te!==e?(Or=W,Ge=fe,W=fe=(bt=Te)===null?Ge:bt.type==="arithmetic"?Qu(Ge,bt.tail):Pa(bt.op,Ge,bt.right)):(N=W,W=e)):(N=W,W=e),W===e&&(W=Ya())===e&&(W=il()),W}function wf(){var W;return t.substr(N,2)===">="?(W=">=",N+=2):(W=e,an===0&&$r(nf)),W===e&&(t.charCodeAt(N)===62?(W=">",N++):(W=e,an===0&&$r(_0)),W===e&&(t.substr(N,2)==="<="?(W="<=",N+=2):(W=e,an===0&&$r(S0)),W===e&&(t.substr(N,2)==="<>"?(W="<>",N+=2):(W=e,an===0&&$r(I0)),W===e&&(t.charCodeAt(N)===60?(W="<",N++):(W=e,an===0&&$r(Df)),W===e&&(t.substr(N,2)==="=="?(W="==",N+=2):(W=e,an===0&&$r(df)),W===e&&(t.charCodeAt(N)===61?(W="=",N++):(W=e,an===0&&$r(Nf)),W===e&&(t.substr(N,2)==="!="?(W="!=",N+=2):(W=e,an===0&&$r(Mp))))))))),W}function Vf(){var W,fe,Te,Ge,bt;return W=N,fe=N,(Te=Zl())!==e&&(Ge=Et())!==e&&(bt=du())!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e),fe!==e&&(Or=W,fe=$f(fe)),(W=fe)===e&&(W=du()),W}function Vl(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=Xa())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=rd())!==e&&(s=Et())!==e&&(Be=Xa())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=rd())!==e&&(s=Et())!==e&&(Be=Xa())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=(function(kn,nr){if(nr&&nr.length&&kn.type==="column_ref"&&kn.column==="*")throw new Error(JSON.stringify({message:"args could not be star column in additive expr",...qs()}));return Qu(kn,nr)})(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function rd(){var W;return t.charCodeAt(N)===43?(W="+",N++):(W=e,an===0&&$r(tc)),W===e&&(t.charCodeAt(N)===45?(W="-",N++):(W=e,an===0&&$r(Jf))),W}function Xa(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=Id())!==e){for(Te=[],Ge=N,(bt=Et())!==e?((et=Oc())===e&&(et=fr()),et!==e&&(s=Et())!==e&&(Be=Id())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e?((et=Oc())===e&&(et=fr()),et!==e&&(s=Et())!==e&&(Be=Id())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e)):(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Qu(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Oc(){var W;return t.charCodeAt(N)===42?(W="*",N++):(W=e,an===0&&$r(tp)),W===e&&(t.charCodeAt(N)===47?(W="/",N++):(W=e,an===0&&$r(t0)),W===e&&(t.charCodeAt(N)===37?(W="%",N++):(W=e,an===0&&$r(H0)))),W}function Hf(){var W,fe,Te,Ge;return(W=(function(){var bt,et,s,Be,kn,nr,ur;return bt=N,(et=Hu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(s=ya())!==e&&Et()!==e&&gu()!==e&&Et()!==e&&(Be=pu())!==e&&Et()!==e&&(kn=Se())!==e?(Or=bt,et=(function(Ce,Gt,Es){return{type:"cast",keyword:Ce.toLowerCase(),expr:Gt,symbol:"as",target:[Es]}})(et,s,Be),bt=et):(N=bt,bt=e),bt===e&&(bt=N,(et=Hu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(s=ya())!==e&&Et()!==e&&gu()!==e&&Et()!==e&&(Be=mc())!==e&&Et()!==e&&(kn=V())!==e&&Et()!==e&&(nr=Gu())!==e&&Et()!==e&&Se()!==e&&Et()!==e&&(ur=Se())!==e?(Or=bt,et=(function(Ce,Gt,Es){return{type:"cast",keyword:Ce.toLowerCase(),expr:Gt,symbol:"as",target:[{dataType:"DECIMAL("+Es+")"}]}})(et,s,nr),bt=et):(N=bt,bt=e),bt===e&&(bt=N,(et=Hu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(s=ya())!==e&&Et()!==e&&gu()!==e&&Et()!==e&&(Be=mc())!==e&&Et()!==e&&(kn=V())!==e&&Et()!==e&&(nr=Gu())!==e&&Et()!==e&&ae()!==e&&Et()!==e&&(ur=Gu())!==e&&Et()!==e&&Se()!==e&&Et()!==e&&Se()!==e?(Or=bt,et=(function(Ce,Gt,Es,Co){return{type:"cast",keyword:Ce.toLowerCase(),expr:Gt,symbol:"as",target:[{dataType:"DECIMAL("+Es+", "+Co+")"}]}})(et,s,nr,ur),bt=et):(N=bt,bt=e),bt===e&&(bt=N,(et=Hu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(s=ya())!==e&&Et()!==e&&gu()!==e&&Et()!==e&&(Be=(function(){var Ce;return(Ce=(function(){var Gt,Es,Co,ai;return Gt=N,t.substr(N,6).toLowerCase()==="signed"?(Es=t.substr(N,6),N+=6):(Es=e,an===0&&$r(Db)),Es!==e?(Co=N,an++,ai=fo(),an--,ai===e?Co=void 0:(N=Co,Co=e),Co!==e?(Or=Gt,Gt=Es="SIGNED"):(N=Gt,Gt=e)):(N=Gt,Gt=e),Gt})())===e&&(Ce=d()),Ce})())!==e&&Et()!==e?((kn=Fu())===e&&(kn=null),kn!==e&&Et()!==e&&(nr=Se())!==e?(Or=bt,et=(function(Ce,Gt,Es,Co){return{type:"cast",keyword:Ce.toLowerCase(),expr:Gt,symbol:"as",target:[{dataType:Es+(Co?" "+Co:"")}]}})(et,s,Be,kn),bt=et):(N=bt,bt=e)):(N=bt,bt=e)))),bt})())===e&&(W=Oe())===e&&(W=Bl())===e&&(W=(function(){var bt;return(bt=(function(){var et,s,Be,kn;return et=N,(s=(function(){var nr,ur,Ce,Gt;return nr=N,t.substr(N,5).toLowerCase()==="count"?(ur=t.substr(N,5),N+=5):(ur=e,an===0&&$r(Sp)),ur!==e?(Ce=N,an++,Gt=fo(),an--,Gt===e?Ce=void 0:(N=Ce,Ce=e),Ce!==e?(Or=nr,nr=ur="COUNT"):(N=nr,nr=e)):(N=nr,nr=e),nr})())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=(function(){var nr,ur;return nr=N,(ur=(function(){var Ce,Gt;return Ce=N,t.charCodeAt(N)===42?(Gt="*",N++):(Gt=e,an===0&&$r(tp)),Gt!==e&&(Or=Ce,Gt={type:"star",value:"*"}),Ce=Gt})())!==e&&(Or=nr,ur={expr:ur}),(nr=ur)===e&&(nr=Ll()),nr})())!==e&&Et()!==e&&Se()!==e&&Et()!==e?((kn=Oa())===e&&(kn=null),kn!==e?(Or=et,s=(function(nr,ur,Ce){return{type:"aggr_func",name:nr,args:ur,over:Ce}})(s,Be,kn),et=s):(N=et,et=e)):(N=et,et=e),et})())===e&&(bt=(function(){var et,s,Be,kn;return et=N,(s=(function(){var nr;return(nr=(function(){var ur,Ce,Gt,Es;return ur=N,t.substr(N,3).toLowerCase()==="sum"?(Ce=t.substr(N,3),N+=3):(Ce=e,an===0&&$r(ev)),Ce!==e?(Gt=N,an++,Es=fo(),an--,Es===e?Gt=void 0:(N=Gt,Gt=e),Gt!==e?(Or=ur,ur=Ce="SUM"):(N=ur,ur=e)):(N=ur,ur=e),ur})())===e&&(nr=(function(){var ur,Ce,Gt,Es;return ur=N,t.substr(N,3).toLowerCase()==="max"?(Ce=t.substr(N,3),N+=3):(Ce=e,an===0&&$r(qp)),Ce!==e?(Gt=N,an++,Es=fo(),an--,Es===e?Gt=void 0:(N=Gt,Gt=e),Gt!==e?(Or=ur,ur=Ce="MAX"):(N=ur,ur=e)):(N=ur,ur=e),ur})())===e&&(nr=(function(){var ur,Ce,Gt,Es;return ur=N,t.substr(N,3).toLowerCase()==="min"?(Ce=t.substr(N,3),N+=3):(Ce=e,an===0&&$r(kb)),Ce!==e?(Gt=N,an++,Es=fo(),an--,Es===e?Gt=void 0:(N=Gt,Gt=e),Gt!==e?(Or=ur,ur=Ce="MIN"):(N=ur,ur=e)):(N=ur,ur=e),ur})())===e&&(nr=(function(){var ur,Ce,Gt,Es;return ur=N,t.substr(N,3).toLowerCase()==="avg"?(Ce=t.substr(N,3),N+=3):(Ce=e,an===0&&$r(d0)),Ce!==e?(Gt=N,an++,Es=fo(),an--,Es===e?Gt=void 0:(N=Gt,Gt=e),Gt!==e?(Or=ur,ur=Ce="AVG"):(N=ur,ur=e)):(N=ur,ur=e),ur})()),nr})())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=Vl())!==e&&Et()!==e&&Se()!==e&&Et()!==e?((kn=Oa())===e&&(kn=null),kn!==e?(Or=et,s=(function(nr,ur,Ce){return{type:"aggr_func",name:nr,args:{expr:ur},over:Ce,...qs()}})(s,Be,kn),et=s):(N=et,et=e)):(N=et,et=e),et})())===e&&(bt=(function(){var et,s,Be,kn,nr,ur;return et=N,s=N,(Be=Au())!==e&&(kn=Et())!==e&&(nr=X())!==e?s=Be=[Be,kn,nr]:(N=s,s=e),s===e&&(s=null),s!==e&&(Be=Et())!==e&&(kn=(function(){var Ce,Gt,Es,Co;return Ce=N,t.substr(N,9).toLowerCase()==="array_agg"?(Gt=t.substr(N,9),N+=9):(Gt=e,an===0&&$r(nv)),Gt!==e?(Es=N,an++,Co=fo(),an--,Co===e?Es=void 0:(N=Es,Es=e),Es!==e?(Or=Ce,Ce=Gt="ARRAY_AGG"):(N=Ce,Ce=e)):(N=Ce,Ce=e),Ce})())!==e&&(nr=Et())!==e&&V()!==e&&Et()!==e&&(ur=Ll())!==e&&Et()!==e&&Se()!==e?(Or=et,s=(function(Ce,Gt,Es){return{type:"aggr_func",name:Ce?`${Ce[0]}.${Gt}`:Gt,args:Es}})(s,kn,ur),et=s):(N=et,et=e),et})()),bt})())===e&&(W=$u())===e&&(W=(function(){var bt,et,s,Be,kn,nr,ur,Ce;return bt=N,yu()!==e&&Et()!==e&&(et=co())!==e&&Et()!==e?((s=_d())===e&&(s=null),s!==e&&Et()!==e&&(Be=Zs())!==e&&Et()!==e?((kn=yu())===e&&(kn=null),kn!==e?(Or=bt,ur=et,(Ce=s)&&ur.push(Ce),bt={type:"case",expr:null,args:ur}):(N=bt,bt=e)):(N=bt,bt=e)):(N=bt,bt=e),bt===e&&(bt=N,yu()!==e&&Et()!==e&&(et=ya())!==e&&Et()!==e&&(s=co())!==e&&Et()!==e?((Be=_d())===e&&(Be=null),Be!==e&&Et()!==e&&(kn=Zs())!==e&&Et()!==e?((nr=yu())===e&&(nr=null),nr!==e?(Or=bt,bt=(function(Gt,Es,Co){return Co&&Es.push(Co),{type:"case",expr:Gt,args:Es}})(et,s,Be)):(N=bt,bt=e)):(N=bt,bt=e)):(N=bt,bt=e)),bt})())===e&&(W=N,(fe=il())!==e&&Et()!==e&&(Te=yl())!==e?(Or=W,W=fe=(function(bt,et){return bt.array_index=et,bt})(fe,Te)):(N=W,W=e),W===e&&(W=il())===e&&(W=$c())===e&&(W=N,(fe=V())!==e&&Et()!==e&&(Te=ql())!==e&&Et()!==e&&Se()!==e?(Or=W,(Ge=Te).parentheses=!0,W=fe=Ge):(N=W,W=e),W===e&&(W=Sa()))),W}function Id(){var W,fe,Te,Ge,bt;return(W=(function(){var et,s,Be,kn,nr,ur,Ce,Gt;if(et=N,(s=Td())!==e)if(Et()!==e){for(Be=[],kn=N,(nr=Et())!==e?(t.substr(N,2)==="?|"?(ur="?|",N+=2):(ur=e,an===0&&$r(Uf)),ur===e&&(t.substr(N,2)==="?&"?(ur="?&",N+=2):(ur=e,an===0&&$r(md)),ur===e&&(t.charCodeAt(N)===63?(ur="?",N++):(ur=e,an===0&&$r(Ud)),ur===e&&(t.substr(N,2)==="#-"?(ur="#-",N+=2):(ur=e,an===0&&$r(jp)),ur===e&&(t.substr(N,3)==="#>>"?(ur="#>>",N+=3):(ur=e,an===0&&$r(Lu)),ur===e&&(t.substr(N,2)==="#>"?(ur="#>",N+=2):(ur=e,an===0&&$r(n0)),ur===e&&(ur=o())===e&&(t.substr(N,2)==="@>"?(ur="@>",N+=2):(ur=e,an===0&&$r(np)),ur===e&&(t.substr(N,2)==="<@"?(ur="<@",N+=2):(ur=e,an===0&&$r(r0))))))))),ur!==e&&(Ce=Et())!==e&&(Gt=Td())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e?(t.substr(N,2)==="?|"?(ur="?|",N+=2):(ur=e,an===0&&$r(Uf)),ur===e&&(t.substr(N,2)==="?&"?(ur="?&",N+=2):(ur=e,an===0&&$r(md)),ur===e&&(t.charCodeAt(N)===63?(ur="?",N++):(ur=e,an===0&&$r(Ud)),ur===e&&(t.substr(N,2)==="#-"?(ur="#-",N+=2):(ur=e,an===0&&$r(jp)),ur===e&&(t.substr(N,3)==="#>>"?(ur="#>>",N+=3):(ur=e,an===0&&$r(Lu)),ur===e&&(t.substr(N,2)==="#>"?(ur="#>",N+=2):(ur=e,an===0&&$r(n0)),ur===e&&(ur=o())===e&&(t.substr(N,2)==="@>"?(ur="@>",N+=2):(ur=e,an===0&&$r(np)),ur===e&&(t.substr(N,2)==="<@"?(ur="<@",N+=2):(ur=e,an===0&&$r(r0))))))))),ur!==e&&(Ce=Et())!==e&&(Gt=Td())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);Be!==e?(Or=et,Es=s,s=(Co=Be)&&Co.length!==0?Qu(Es,Co):Es,et=s):(N=et,et=e)}else N=et,et=e;else N=et,et=e;var Es,Co;return et})())===e&&(W=N,(fe=(function(){var et;return t.charCodeAt(N)===33?(et="!",N++):(et=e,an===0&&$r(ff)),et===e&&(t.charCodeAt(N)===45?(et="-",N++):(et=e,an===0&&$r(Jf)),et===e&&(t.charCodeAt(N)===43?(et="+",N++):(et=e,an===0&&$r(tc)),et===e&&(t.charCodeAt(N)===126?(et="~",N++):(et=e,an===0&&$r(vd))))),et})())!==e?(Te=N,(Ge=Et())!==e&&(bt=Id())!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e),Te!==e?(Or=W,W=fe=Bu(fe,Te[1])):(N=W,W=e)):(N=W,W=e)),W}function Td(){var W,fe,Te,Ge,bt;return W=N,(fe=Hf())!==e&&Et()!==e?((Te=yl())===e&&(Te=null),Te!==e?(Or=W,Ge=fe,(bt=Te)&&(Ge.array_index=bt),W=fe=Ge):(N=W,W=e)):(N=W,W=e),W}function il(){var W,fe,Te,Ge,bt,et,s,Be,kn,nr,ur,Ce;if(W=N,(fe=Au())!==e)if(Te=N,(Ge=Et())!==e&&(bt=X())!==e&&(et=Et())!==e&&(s=Au())!==e?Te=Ge=[Ge,bt,et,s]:(N=Te,Te=e),Te!==e){if(Ge=[],bt=N,(et=Et())!==e&&(s=X())!==e&&(Be=Et())!==e&&(kn=Jc())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e),bt!==e)for(;bt!==e;)Ge.push(bt),bt=N,(et=Et())!==e&&(s=X())!==e&&(Be=Et())!==e&&(kn=Jc())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e);else Ge=e;Ge!==e?(bt=N,(et=Et())!==e&&(s=y0())!==e?bt=et=[et,s]:(N=bt,bt=e),bt===e&&(bt=null),bt!==e?(Or=W,W=fe=(function(Gt,Es,Co,ai){return Co.length===1?(va.add(`select::${Gt}.${Es[3]}::${Co[0][3].value||Co[0][3]}`),{type:"column_ref",schema:Gt,table:Es[3],column:Co[0][3],collate:ai&&ai[1]}):{type:"column_ref",column:{expr:Qu(Pa(".",Gt,Es[3]),Co)},collate:ai&&ai[1]}})(fe,Te,Ge,bt)):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;return W===e&&(W=N,(fe=Au())!==e&&(Te=Et())!==e&&(Ge=X())!==e&&(bt=Et())!==e&&(et=Jc())!==e?(s=N,(Be=Et())!==e&&(kn=y0())!==e?s=Be=[Be,kn]:(N=s,s=e),s===e&&(s=null),s!==e?(Or=W,nr=fe,ur=et,Ce=s,va.add(`select::${nr}::${ur}`),W=fe={type:"column_ref",table:nr,column:ur,collate:Ce&&Ce[1]}):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=Jc())!==e?(Te=N,(Ge=Et())!==e&&(bt=y0())!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e),Te===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(Gt,Es){return va.add("select::null::"+Gt),{type:"column_ref",table:null,column:Gt,collate:Es&&Es[1]}})(fe,Te)):(N=W,W=e)):(N=W,W=e))),W}function dc(){var W,fe;return W=N,(fe=Pu())!==e&&(Or=W,fe={type:"default",value:fe}),(W=fe)===e&&(W=Cf()),W}function Au(){var W,fe;return W=N,(fe=Pu())!==e?(Or=N,(Xf(fe)?e:void 0)!==e?(Or=W,W=fe=fe):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=Hl())!==e&&(Or=W,fe=fe),W=fe),W}function hp(){var W,fe;return W=N,(fe=Pu())!==e?(Or=N,((function(Te){if(da[Te.toUpperCase()]===!0)throw new Error("Error: "+JSON.stringify(Te)+" is a reserved word, can not as alias clause");return!1})(fe)?e:void 0)!==e?(Or=W,W=fe=fe):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=Hl())!==e&&(Or=W,fe=fe),W=fe),W}function Cf(){var W;return(W=Ru())===e&&(W=gp())===e&&(W=xd()),W}function Hl(){var W,fe;return W=N,(fe=Ru())===e&&(fe=gp())===e&&(fe=xd()),fe!==e&&(Or=W,fe=fe.value),W=fe}function Ru(){var W,fe,Te,Ge;if(W=N,t.charCodeAt(N)===34?(fe='"',N++):(fe=e,an===0&&$r(Lc)),fe!==e){if(Te=[],xl.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(Gc)),Ge!==e)for(;Ge!==e;)Te.push(Ge),xl.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(Gc));else Te=e;Te!==e?(t.charCodeAt(N)===34?(Ge='"',N++):(Ge=e,an===0&&$r(Lc)),Ge!==e?(Or=W,W=fe={type:"double_quote_string",value:Te.join("")}):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;return W}function gp(){var W,fe,Te,Ge;if(W=N,t.charCodeAt(N)===39?(fe="'",N++):(fe=e,an===0&&$r(ku)),fe!==e){if(Te=[],Y0.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(Bc)),Ge!==e)for(;Ge!==e;)Te.push(Ge),Y0.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(Bc));else Te=e;Te!==e?(t.charCodeAt(N)===39?(Ge="'",N++):(Ge=e,an===0&&$r(ku)),Ge!==e?(Or=W,W=fe={type:"single_quote_string",value:Te.join("")}):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;return W}function xd(){var W,fe,Te,Ge;if(W=N,t.charCodeAt(N)===96?(fe="`",N++):(fe=e,an===0&&$r(rp)),fe!==e){if(Te=[],W0.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(hd)),Ge!==e)for(;Ge!==e;)Te.push(Ge),W0.test(t.charAt(N))?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(hd));else Te=e;Te!==e?(t.charCodeAt(N)===96?(Ge="`",N++):(Ge=e,an===0&&$r(rp)),Ge!==e?(Or=W,W=fe={type:"backticks_quote_string",value:Te.join("")}):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;return W}function Lf(){var W,fe;return W=N,(fe=Xc())!==e&&(Or=W,fe=fe),(W=fe)===e&&(W=Hl()),W}function Jc(){var W,fe;return W=N,(fe=Xc())!==e?(Or=N,(Xf(fe)?e:void 0)!==e?(Or=W,W=fe=fe):(N=W,W=e)):(N=W,W=e),W===e&&(W=Hl()),W}function Xc(){var W,fe,Te,Ge;if(W=N,(fe=Yf())!==e){for(Te=[],Ge=wl();Ge!==e;)Te.push(Ge),Ge=wl();Te!==e?(Or=W,W=fe=T0(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Pu(){var W,fe,Te,Ge;if(W=N,(fe=fo())!==e){for(Te=[],Ge=Yf();Ge!==e;)Te.push(Ge),Ge=Yf();Te!==e?(Or=W,W=fe=T0(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function fo(){var W;return sp.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(Qf)),W}function Yf(){var W;return Pf.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(no)),W}function wl(){var W;return nc.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(Ec)),W}function $c(){var W,fe,Te,Ge;return W=N,fe=N,t.charCodeAt(N)===58?(Te=":",N++):(Te=e,an===0&&$r(Mf)),Te!==e&&(Ge=Pu())!==e?fe=Te=[Te,Ge]:(N=fe,fe=e),fe!==e&&(Or=W,fe={type:"param",value:fe[1]}),W=fe}function Cl(){var W,fe,Te;return W=N,Ki()!==e&&Et()!==e&&Uc()!==e&&Et()!==e&&(fe=He())!==e&&Et()!==e&&V()!==e&&Et()!==e?((Te=Nc())===e&&(Te=null),Te!==e&&Et()!==e&&Se()!==e?(Or=W,W={type:"on update",keyword:fe,parentheses:!0,expr:Te}):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,Ki()!==e&&Et()!==e&&Uc()!==e&&Et()!==e&&(fe=He())!==e?(Or=W,W=(function(Ge){return{type:"on update",keyword:Ge}})(fe)):(N=W,W=e)),W}function Oa(){var W,fe,Te,Ge,bt;return W=N,t.substr(N,4).toLowerCase()==="over"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Pd)),fe!==e&&Et()!==e&&(Te=Bf())!==e?(Or=W,W=fe={type:"window",as_window_specification:Te}):(N=W,W=e),W===e&&(W=N,t.substr(N,4).toLowerCase()==="over"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Pd)),fe!==e&&Et()!==e&&(Te=V())!==e&&Et()!==e?((Ge=Gl())===e&&(Ge=null),Ge!==e&&Et()!==e?((bt=ol())===e&&(bt=null),bt!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe={partitionby:Ge,orderby:bt}):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W===e&&(W=Cl())),W}function Ll(){var W,fe,Te,Ge,bt,et,s,Be,kn,nr,ur,Ce,Gt;if(W=N,(fe=ju())===e&&(fe=null),fe!==e)if(Et()!==e)if((Te=V())!==e)if(Et()!==e)if((Ge=ya())!==e)if((bt=Et())!==e)if((et=Se())!==e)if((s=Et())!==e){for(Be=[],kn=N,(nr=Et())!==e?((ur=Za())===e&&(ur=Tn())===e&&(ur=tt()),ur!==e&&(Ce=Et())!==e&&(Gt=ya())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);kn!==e;)Be.push(kn),kn=N,(nr=Et())!==e?((ur=Za())===e&&(ur=Tn())===e&&(ur=tt()),ur!==e&&(Ce=Et())!==e&&(Gt=ya())!==e?kn=nr=[nr,ur,Ce,Gt]:(N=kn,kn=e)):(N=kn,kn=e);Be!==e&&(kn=Et())!==e?((nr=ol())===e&&(nr=null),nr!==e?(Or=W,W=fe=(function(Es,Co,ai,Mt){let li=ai.length,Pt=Co;Pt.parentheses=!0;for(let So=0;So<li;++So)Pt=Pa(ai[So][1],Pt,ai[So][3]);return{distinct:Es,expr:Pt,orderby:Mt}})(fe,Ge,Be,nr)):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;if(W===e)if(W=N,(fe=ju())===e&&(fe=null),fe!==e)if(Et()!==e)if((Te=il())===e&&(Te=Yd()),Te!==e)if(Et()!==e){for(Ge=[],bt=N,(et=Et())!==e?((s=ae())===e&&(s=tt()),s!==e&&(Be=Et())!==e&&(kn=ya())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e)):(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,(et=Et())!==e?((s=ae())===e&&(s=tt()),s!==e&&(Be=Et())!==e&&(kn=ya())!==e?bt=et=[et,s,Be,kn]:(N=bt,bt=e)):(N=bt,bt=e);Ge!==e&&(bt=Et())!==e?((et=ol())===e&&(et=null),et!==e?(Or=W,W=fe=(function(Es,Co,ai,Mt){let li=ai.length,Pt=Co;for(let So=0;So<li;++So)Pt=Pa(ai[So][1],Pt,ai[So][3]);return{distinct:Es,expr:Pt,orderby:Mt}})(fe,Te,Ge,et)):(N=W,W=e)):(N=W,W=e)}else N=W,W=e;else N=W,W=e;else N=W,W=e;else N=W,W=e;return W}function y(){var W,fe,Te,Ge;return W=N,(fe=dc())!==e&&Et()!==e&&(Te=o())!==e&&Et()!==e&&(Ge=ya())!==e?(Or=W,W=fe=Pa(Te,fe,Ge)):(N=W,W=e),W}function p(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="filter"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Fp)),fe!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Te=ya())!==e&&Et()!==e&&ae()!==e&&Et()!==e&&(Ge=y())!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe={type:"function",name:{name:[{type:"origin",value:"filter"}]},args:{type:"expr_list",value:[Te,Ge]},...qs()}):(N=W,W=e),W}function Pn(){var W,fe,Te;return W=N,(fe=(function(){var Ge;return t.substr(N,4).toLowerCase()==="both"?(Ge=t.substr(N,4),N+=4):(Ge=e,an===0&&$r(Z0)),Ge===e&&(t.substr(N,7).toLowerCase()==="leading"?(Ge=t.substr(N,7),N+=7):(Ge=e,an===0&&$r(Md)),Ge===e&&(t.substr(N,8).toLowerCase()==="trailing"?(Ge=t.substr(N,8),N+=8):(Ge=e,an===0&&$r(zp)))),Ge})())===e&&(fe=null),fe!==e&&Et()!==e?((Te=ya())===e&&(Te=null),Te!==e&&Et()!==e&&Dn()!==e?(Or=W,W=fe=(function(Ge,bt,et){let s=[];return Ge&&s.push({type:"origin",value:Ge}),bt&&s.push(bt),s.push({type:"origin",value:"from"}),{type:"expr_list",value:s}})(fe,Te)):(N=W,W=e)):(N=W,W=e),W}function $u(){var W,fe,Te,Ge,bt;return W=N,(fe=(function(){var et;return(et=jt())===e&&(et=(function(){var s,Be,kn,nr;return s=N,t.substr(N,12).toLowerCase()==="current_user"?(Be=t.substr(N,12),N+=12):(Be=e,an===0&&$r(Mb)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="CURRENT_USER"):(N=s,s=e)):(N=s,s=e),s})())===e&&(et=(function(){var s,Be,kn,nr;return s=N,t.substr(N,4).toLowerCase()==="user"?(Be=t.substr(N,4),N+=4):(Be=e,an===0&&$r(uv)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="USER"):(N=s,s=e)):(N=s,s=e),s})())===e&&(et=(function(){var s,Be,kn,nr;return s=N,t.substr(N,12).toLowerCase()==="session_user"?(Be=t.substr(N,12),N+=12):(Be=e,an===0&&$r(Iv)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="SESSION_USER"):(N=s,s=e)):(N=s,s=e),s})())===e&&(et=(function(){var s,Be,kn,nr;return s=N,t.substr(N,11).toLowerCase()==="system_user"?(Be=t.substr(N,11),N+=11):(Be=e,an===0&&$r(Tv)),Be!==e?(kn=N,an++,nr=fo(),an--,nr===e?kn=void 0:(N=kn,kn=e),kn!==e?(Or=s,s=Be="SYSTEM_USER"):(N=s,s=e)):(N=s,s=e),s})()),et})())!==e&&Et()!==e&&(Te=V())!==e&&Et()!==e?((Ge=Nc())===e&&(Ge=null),Ge!==e&&Et()!==e&&Se()!==e&&Et()!==e?((bt=Oa())===e&&(bt=null),bt!==e?(Or=W,W=fe=(function(et,s,Be){return{type:"function",name:{name:[{type:"origin",value:et}]},args:s||{type:"expr_list",value:[]},over:Be,...qs()}})(fe,Ge,bt)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W===e&&(W=(function(){var et,s,Be,kn,nr;et=N,(s=Xu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=Qa())!==e&&Et()!==e&&Dn()!==e&&Et()!==e?((kn=we())===e&&(kn=De())===e&&(kn=G())===e&&(kn=ea()),kn===e&&(kn=null),kn!==e&&Et()!==e&&(nr=ya())!==e&&Et()!==e&&Se()!==e?(Or=et,ur=Be,Ce=kn,Gt=nr,s={type:s.toLowerCase(),args:{field:ur,cast_type:Ce,source:Gt},...qs()},et=s):(N=et,et=e)):(N=et,et=e);var ur,Ce,Gt;return et===e&&(et=N,(s=Xu())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Be=Qa())!==e&&Et()!==e&&Dn()!==e&&Et()!==e&&(kn=ya())!==e&&Et()!==e&&(nr=Se())!==e?(Or=et,s=(function(Es,Co,ai){return{type:Es.toLowerCase(),args:{field:Co,source:ai},...qs()}})(s,Be,kn),et=s):(N=et,et=e)),et})())===e&&(W=p())===e&&(W=(function(){var et,s,Be,kn;return et=N,t.substr(N,4).toLowerCase()==="trim"?(s=t.substr(N,4),N+=4):(s=e,an===0&&$r(Cp)),s!==e&&Et()!==e&&V()!==e&&Et()!==e?((Be=Pn())===e&&(Be=null),Be!==e&&Et()!==e&&(kn=nn())!==e&&Et()!==e&&Se()!==e?(Or=et,et=s=(function(nr,ur){let Ce=nr||{type:"expr_list",value:[]};return Ce.value.push(ur),{type:"function",name:{name:[{type:"origin",value:"trim"}]},args:Ce}})(Be,kn)):(N=et,et=e)):(N=et,et=e),et})())===e&&(W=N,(fe=jt())!==e&&Et()!==e?((Te=Cl())===e&&(Te=null),Te!==e?(Or=W,W=fe={type:"function",name:{name:[{type:"origin",value:fe}]},over:Te,...qs()}):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=ea())===e&&(fe=G())===e&&(fe=we())===e&&(t.substr(N,12).toLowerCase()==="at time zone"?(fe=t.substr(N,12),N+=12):(fe=e,an===0&&$r(s0))),fe!==e&&Et()!==e?((Te=ql())===e&&(Te=null),Te!==e&&Et()!==e?((Ge=Oa())===e&&(Ge=null),Ge!==e?(Or=W,W=fe=(function(et,s,Be){return s&&s.type!=="expr_list"&&(s={type:"expr_list",value:[s]}),{type:"function",name:{name:[{type:"default",value:et}]},args:s||{type:"expr_list",value:[]},over:Be,args_parentheses:!1,...qs()}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=pi())!==e&&Et()!==e&&(Te=V())!==e&&Et()!==e?((Ge=ql())===e&&(Ge=null),Ge!==e&&Et()!==e&&Se()!==e&&Et()!==e?((bt=Oa())===e&&(bt=null),bt!==e?(Or=W,W=fe=(function(et,s,Be){return s&&s.type!=="expr_list"&&(s={type:"expr_list",value:[s]}),{type:"function",name:et,args:s||{type:"expr_list",value:[]},over:Be,...qs()}})(fe,Ge,bt)):(N=W,W=e)):(N=W,W=e)):(N=W,W=e)))),W}function Qa(){var W,fe;return W=N,t.substr(N,7).toLowerCase()==="century"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(jd)),fe===e&&(t.substr(N,3).toLowerCase()==="day"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(gd)),fe===e&&(t.substr(N,4).toLowerCase()==="date"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(gl)),fe===e&&(t.substr(N,6).toLowerCase()==="decade"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(yd)),fe===e&&(t.substr(N,3).toLowerCase()==="dow"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(fb)),fe===e&&(t.substr(N,3).toLowerCase()==="doy"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(o0)),fe===e&&(t.substr(N,5).toLowerCase()==="epoch"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(Lp)),fe===e&&(t.substr(N,4).toLowerCase()==="hour"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(rc)),fe===e&&(t.substr(N,6).toLowerCase()==="isodow"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Ac)),fe===e&&(t.substr(N,7).toLowerCase()==="isoyear"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(op)),fe===e&&(t.substr(N,12).toLowerCase()==="microseconds"?(fe=t.substr(N,12),N+=12):(fe=e,an===0&&$r(i0)),fe===e&&(t.substr(N,10).toLowerCase()==="millennium"?(fe=t.substr(N,10),N+=10):(fe=e,an===0&&$r(Fa)),fe===e&&(t.substr(N,12).toLowerCase()==="milliseconds"?(fe=t.substr(N,12),N+=12):(fe=e,an===0&&$r(_c)),fe===e&&(t.substr(N,6).toLowerCase()==="minute"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Sc)),fe===e&&(t.substr(N,5).toLowerCase()==="month"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(K0)),fe===e&&(t.substr(N,7).toLowerCase()==="quarter"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Ep)),fe===e&&(t.substr(N,6).toLowerCase()==="second"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(ip)),fe===e&&(t.substr(N,8).toLowerCase()==="timezone"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(Fd)),fe===e&&(t.substr(N,13).toLowerCase()==="timezone_hour"?(fe=t.substr(N,13),N+=13):(fe=e,an===0&&$r(a0)),fe===e&&(t.substr(N,15).toLowerCase()==="timezone_minute"?(fe=t.substr(N,15),N+=15):(fe=e,an===0&&$r(J0)),fe===e&&(t.substr(N,4).toLowerCase()==="week"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(x0)),fe===e&&(t.substr(N,4).toLowerCase()==="year"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Fl))))))))))))))))))))))),fe!==e&&(Or=W,fe=fe),W=fe}function jt(){var W;return(W=(function(){var fe,Te,Ge,bt;return fe=N,t.substr(N,12).toLowerCase()==="current_date"?(Te=t.substr(N,12),N+=12):(Te=e,an===0&&$r(Ov)),Te!==e?(Ge=N,an++,bt=fo(),an--,bt===e?Ge=void 0:(N=Ge,Ge=e),Ge!==e?(Or=fe,fe=Te="CURRENT_DATE"):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=(function(){var fe,Te,Ge,bt;return fe=N,t.substr(N,12).toLowerCase()==="current_time"?(Te=t.substr(N,12),N+=12):(Te=e,an===0&&$r(lv)),Te!==e?(Ge=N,an++,bt=fo(),an--,bt===e?Ge=void 0:(N=Ge,Ge=e),Ge!==e?(Or=fe,fe=Te="CURRENT_TIME"):(N=fe,fe=e)):(N=fe,fe=e),fe})())===e&&(W=He()),W}function Oe(){var W;return(W=Ya())===e&&(W=Dc())===e&&(W=(function(){var fe,Te;return fe=N,(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="true"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(ga)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())!==e&&(Or=fe,Te={type:"bool",value:!0}),(fe=Te)===e&&(fe=N,(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,5).toLowerCase()==="false"?(bt=t.substr(N,5),N+=5):(bt=e,an===0&&$r(Da)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?Ge=bt=[bt,et]:(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())!==e&&(Or=fe,Te={type:"bool",value:!1}),fe=Te),fe})())===e&&(W=yr())===e&&(W=(function(){var fe,Te,Ge,bt,et,s;if(fe=N,(Te=G())===e&&(Te=ea())===e&&(Te=we())===e&&(Te=sn()),Te!==e)if(Et()!==e){if(Ge=N,t.charCodeAt(N)===39?(bt="'",N++):(bt=e,an===0&&$r(ku)),bt!==e){for(et=[],s=Kn();s!==e;)et.push(s),s=Kn();et!==e?(t.charCodeAt(N)===39?(s="'",N++):(s=e,an===0&&$r(ku)),s!==e?Ge=bt=[bt,et,s]:(N=Ge,Ge=e)):(N=Ge,Ge=e)}else N=Ge,Ge=e;Ge!==e?(Or=fe,Te=qc(Te,Ge),fe=Te):(N=fe,fe=e)}else N=fe,fe=e;else N=fe,fe=e;if(fe===e)if(fe=N,(Te=G())===e&&(Te=ea())===e&&(Te=we())===e&&(Te=sn()),Te!==e)if(Et()!==e){if(Ge=N,t.charCodeAt(N)===34?(bt='"',N++):(bt=e,an===0&&$r(Lc)),bt!==e){for(et=[],s=sd();s!==e;)et.push(s),s=sd();et!==e?(t.charCodeAt(N)===34?(s='"',N++):(s=e,an===0&&$r(Lc)),s!==e?Ge=bt=[bt,et,s]:(N=Ge,Ge=e)):(N=Ge,Ge=e)}else N=Ge,Ge=e;Ge!==e?(Or=fe,Te=qc(Te,Ge),fe=Te):(N=fe,fe=e)}else N=fe,fe=e;else N=fe,fe=e;return fe})())===e&&(W=(function(){var fe,Te,Ge;return fe=N,(Te=Su())!==e&&Et()!==e&&kt()!==e&&Et()!==e?((Ge=Nc())===e&&(Ge=null),Ge!==e&&Et()!==e&&qt()!==e?(Or=fe,Te=(function(bt,et){return{expr_list:et||{type:"origin",value:""},type:"array",keyword:"array",brackets:!0}})(0,Ge),fe=Te):(N=fe,fe=e)):(N=fe,fe=e),fe})()),W}function yr(){var W,fe;return W=N,(fe=(function(){var Te,Ge,bt,et;return Te=N,t.substr(N,4).toLowerCase()==="null"?(Ge=t.substr(N,4),N+=4):(Ge=e,an===0&&$r(Bi)),Ge!==e?(bt=N,an++,et=fo(),an--,et===e?bt=void 0:(N=bt,bt=e),bt!==e?Te=Ge=[Ge,bt]:(N=Te,Te=e)):(N=Te,Te=e),Te})())!==e&&(Or=W,fe={type:"null",value:null}),W=fe}function Ya(){var W,fe,Te,Ge,bt,et;if(W=N,t.substr(N,2).toLowerCase()==="u&"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Ic)),fe!==e){if(Te=N,t.charCodeAt(N)===39?(Ge="'",N++):(Ge=e,an===0&&$r(ku)),Ge!==e){for(bt=[],et=Kn();et!==e;)bt.push(et),et=Kn();bt!==e?(t.charCodeAt(N)===39?(et="'",N++):(et=e,an===0&&$r(ku)),et!==e?Te=Ge=[Ge,bt,et]:(N=Te,Te=e)):(N=Te,Te=e)}else N=Te,Te=e;Te!==e?(Or=W,W=fe={type:"unicode_string",value:Te[1].join("")}):(N=W,W=e)}else N=W,W=e;if(W===e){if(W=N,fe=N,t.charCodeAt(N)===39?(Te="'",N++):(Te=e,an===0&&$r(ku)),Te!==e){for(Ge=[],bt=Kn();bt!==e;)Ge.push(bt),bt=Kn();Ge!==e?(t.charCodeAt(N)===39?(bt="'",N++):(bt=e,an===0&&$r(ku)),bt!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e)):(N=fe,fe=e)}else N=fe,fe=e;if(fe!==e&&(Or=W,fe=(function(s){return{type:"single_quote_string",value:s[1].join("")}})(fe)),(W=fe)===e){if(W=N,fe=N,t.charCodeAt(N)===34?(Te='"',N++):(Te=e,an===0&&$r(Lc)),Te!==e){for(Ge=[],bt=sd();bt!==e;)Ge.push(bt),bt=sd();Ge!==e?(t.charCodeAt(N)===34?(bt='"',N++):(bt=e,an===0&&$r(Lc)),bt!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e)):(N=fe,fe=e)}else N=fe,fe=e;fe!==e&&(Te=Et())!==e?(Ge=N,an++,(bt=X())===e&&(bt=V()),an--,bt===e?Ge=void 0:(N=Ge,Ge=e),Ge!==e?(Or=W,W=fe=(function(s){return{type:"double_quote_string",value:s[1].join("")}})(fe)):(N=W,W=e)):(N=W,W=e)}}return W}function sd(){var W;return Gp.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(ap)),W===e&&(W=Nn()),W}function Kn(){var W;return Ap.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(wd)),W===e&&(W=Nn()),W}function Nn(){var W,fe,Te,Ge,bt,et,s,Be,kn,nr;return W=N,t.substr(N,2)==="\\'"?(fe="\\'",N+=2):(fe=e,an===0&&$r(_p)),fe!==e&&(Or=W,fe="\\'"),(W=fe)===e&&(W=N,t.substr(N,2)==='\\"'?(fe='\\"',N+=2):(fe=e,an===0&&$r(Bp)),fe!==e&&(Or=W,fe='\\"'),(W=fe)===e&&(W=N,t.substr(N,2)==="\\\\"?(fe="\\\\",N+=2):(fe=e,an===0&&$r(k0)),fe!==e&&(Or=W,fe="\\\\"),(W=fe)===e&&(W=N,t.substr(N,2)==="\\/"?(fe="\\/",N+=2):(fe=e,an===0&&$r(Cd)),fe!==e&&(Or=W,fe="\\/"),(W=fe)===e&&(W=N,t.substr(N,2)==="\\b"?(fe="\\b",N+=2):(fe=e,an===0&&$r(sc)),fe!==e&&(Or=W,fe="\b"),(W=fe)===e&&(W=N,t.substr(N,2)==="\\f"?(fe="\\f",N+=2):(fe=e,an===0&&$r(zd)),fe!==e&&(Or=W,fe="\f"),(W=fe)===e&&(W=N,t.substr(N,2)==="\\n"?(fe="\\n",N+=2):(fe=e,an===0&&$r(vt)),fe!==e&&(Or=W,fe=`
|
|
145
145
|
`),(W=fe)===e&&(W=N,t.substr(N,2)==="\\r"?(fe="\\r",N+=2):(fe=e,an===0&&$r(gn)),fe!==e&&(Or=W,fe="\r"),(W=fe)===e&&(W=N,t.substr(N,2)==="\\t"?(fe="\\t",N+=2):(fe=e,an===0&&$r(Yn)),fe!==e&&(Or=W,fe=" "),(W=fe)===e&&(W=N,t.substr(N,2)==="\\u"?(fe="\\u",N+=2):(fe=e,an===0&&$r(On)),fe!==e&&(Te=El())!==e&&(Ge=El())!==e&&(bt=El())!==e&&(et=El())!==e?(Or=W,s=Te,Be=Ge,kn=bt,nr=et,W=fe=String.fromCharCode(parseInt("0x"+s+Be+kn+nr))):(N=W,W=e),W===e&&(W=N,t.charCodeAt(N)===92?(fe="\\",N++):(fe=e,an===0&&$r(Kr)),fe!==e&&(Or=W,fe="\\"),(W=fe)===e&&(W=N,t.substr(N,2)==="''"?(fe="''",N+=2):(fe=e,an===0&&$r(Vr)),fe!==e&&(Or=W,fe="''"),(W=fe)===e&&(W=N,t.substr(N,2)==='""'?(fe='""',N+=2):(fe=e,an===0&&$r(us)),fe!==e&&(Or=W,fe='""'),(W=fe)===e&&(W=N,t.substr(N,2)==="``"?(fe="``",N+=2):(fe=e,an===0&&$r(Ds)),fe!==e&&(Or=W,fe="``"),W=fe))))))))))))),W}function Dc(){var W,fe,Te;return W=N,(fe=(function(){var Ge,bt,et,s;return Ge=N,(bt=Gu())!==e&&(et=kd())!==e&&(s=eu())!==e?(Or=Ge,Ge=bt={type:"bigint",value:bt+et+s}):(N=Ge,Ge=e),Ge===e&&(Ge=N,(bt=Gu())!==e&&(et=kd())!==e?(Or=Ge,bt=(function(Be,kn){let nr=Be+kn;return xa(Be)?{type:"bigint",value:nr}:parseFloat(nr).toFixed(kn.length-1)})(bt,et),Ge=bt):(N=Ge,Ge=e),Ge===e&&(Ge=N,(bt=Gu())!==e&&(et=eu())!==e?(Or=Ge,bt=(function(Be,kn){return{type:"bigint",value:Be+kn}})(bt,et),Ge=bt):(N=Ge,Ge=e),Ge===e&&(Ge=N,(bt=Gu())!==e&&(Or=Ge,bt=(function(Be){return xa(Be)?{type:"bigint",value:Be}:parseFloat(Be)})(bt)),Ge=bt))),Ge})())!==e&&(Or=W,fe=(Te=fe)&&Te.type==="bigint"?Te:{type:"number",value:Te}),W=fe}function Gu(){var W,fe,Te;return(W=ma())===e&&(W=Mu())===e&&(W=N,t.charCodeAt(N)===45?(fe="-",N++):(fe=e,an===0&&$r(Jf)),fe===e&&(t.charCodeAt(N)===43?(fe="+",N++):(fe=e,an===0&&$r(tc))),fe!==e&&(Te=ma())!==e?(Or=W,W=fe=fe+Te):(N=W,W=e),W===e&&(W=N,t.charCodeAt(N)===45?(fe="-",N++):(fe=e,an===0&&$r(Jf)),fe===e&&(t.charCodeAt(N)===43?(fe="+",N++):(fe=e,an===0&&$r(tc))),fe!==e&&(Te=Mu())!==e?(Or=W,W=fe=(function(Ge,bt){return Ge+bt})(fe,Te)):(N=W,W=e))),W}function kd(){var W,fe,Te;return W=N,t.charCodeAt(N)===46?(fe=".",N++):(fe=e,an===0&&$r(Vs)),fe!==e&&(Te=ma())!==e?(Or=W,W=fe="."+Te):(N=W,W=e),W}function eu(){var W,fe,Te;return W=N,(fe=(function(){var Ge,bt,et;Ge=N,Oi.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Wi)),bt!==e?(mi.test(t.charAt(N))?(et=t.charAt(N),N++):(et=e,an===0&&$r(Zi)),et===e&&(et=null),et!==e?(Or=Ge,Ge=bt=bt+((s=et)!==null?s:"")):(N=Ge,Ge=e)):(N=Ge,Ge=e);var s;return Ge})())!==e&&(Te=ma())!==e?(Or=W,W=fe=fe+Te):(N=W,W=e),W}function ma(){var W,fe,Te;if(W=N,fe=[],(Te=Mu())!==e)for(;Te!==e;)fe.push(Te),Te=Mu();else fe=e;return fe!==e&&(Or=W,fe=fe.join("")),W=fe}function Mu(){var W;return ho.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(Oo)),W}function El(){var W;return ui.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(ri)),W}function pc(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="default"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(ao)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Rd(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="to"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(cu)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function ba(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="drop"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Wu)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DROP"):(N=W,W=e)):(N=W,W=e),W}function Uc(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="update"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Tc)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Ju(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="create"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(fl)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function od(){var W,fe,Te,Ge;return W=N,t.substr(N,9).toLowerCase()==="temporary"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(up)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Wa(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="delete"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Gd)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Qs(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="replace"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(bf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function _u(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="rename"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Vc)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Al(){var W,fe,Te,Ge;return W=N,t.substr(N,9).toLowerCase()==="partition"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(X0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="PARTITION"):(N=W,W=e)):(N=W,W=e),W}function b(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="into"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(rf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="INTO"):(N=W,W=e)):(N=W,W=e),W}function Dn(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="from"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(vf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Ol(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="set"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(ml)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="SET"):(N=W,W=e)):(N=W,W=e),W}function gu(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="as"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Ff)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Yl(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="table"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(lp)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="TABLE"):(N=W,W=e)):(N=W,W=e),W}function mt(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="tables"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Wb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="TABLES"):(N=W,W=e)):(N=W,W=e),W}function or(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="collate"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Cc)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="COLLATE"):(N=W,W=e)):(N=W,W=e),W}function Ki(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="on"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Kb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function $s(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="join"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(eb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function oa(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="outer"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(pb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function En(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="values"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(l0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Ef(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="using"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(tb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function bc(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="with"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(na)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function of(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="by"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(c0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function jn(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="offset"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(Xb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="OFFSET"):(N=W,W=e)):(N=W,W=e),W}function bl(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="all"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(wv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="ALL"):(N=W,W=e)):(N=W,W=e),W}function ju(){var W,fe,Te,Ge;return W=N,t.substr(N,8).toLowerCase()==="distinct"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(Ib)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DISTINCT"):(N=W,W=e)):(N=W,W=e),W}function $i(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="between"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Cv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="BETWEEN"):(N=W,W=e)):(N=W,W=e),W}function du(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="in"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Nv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="IN"):(N=W,W=e)):(N=W,W=e),W}function ha(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="is"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Tb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="IS"):(N=W,W=e)):(N=W,W=e),W}function ua(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="like"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(xb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="LIKE"):(N=W,W=e)):(N=W,W=e),W}function vc(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="rlike"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(Qb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="RLIKE"):(N=W,W=e)):(N=W,W=e),W}function Wl(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="exists"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(f0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="EXISTS"):(N=W,W=e)):(N=W,W=e),W}function Zl(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="not"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(Ld)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="NOT"):(N=W,W=e)):(N=W,W=e),W}function Za(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="and"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(zf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="AND"):(N=W,W=e)):(N=W,W=e),W}function Tn(){var W,fe,Te,Ge;return W=N,t.substr(N,2).toLowerCase()==="or"?(fe=t.substr(N,2),N+=2):(fe=e,an===0&&$r(Hc)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="OR"):(N=W,W=e)):(N=W,W=e),W}function Xu(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="extract"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Rb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="EXTRACT"):(N=W,W=e)):(N=W,W=e),W}function yu(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="case"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Ob)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Zs(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="end"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(rb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?W=fe=[fe,Te]:(N=W,W=e)):(N=W,W=e),W}function Hu(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="cast"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(tv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="CAST"):(N=W,W=e)):(N=W,W=e),W}function Su(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="array"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r($b)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="ARRAY"):(N=W,W=e)):(N=W,W=e),W}function $l(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="char"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(rv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="CHAR"):(N=W,W=e)):(N=W,W=e),W}function $a(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="varchar"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r($0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="VARCHAR"):(N=W,W=e)):(N=W,W=e),W}function al(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="numeric"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(sv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="NUMERIC"):(N=W,W=e)):(N=W,W=e),W}function mc(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="decimal"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(ov)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DECIMAL"):(N=W,W=e)):(N=W,W=e),W}function d(){var W,fe,Te,Ge;return W=N,t.substr(N,8).toLowerCase()==="unsigned"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(Ev)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="UNSIGNED"):(N=W,W=e)):(N=W,W=e),W}function In(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="int"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(Ub)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="INT"):(N=W,W=e)):(N=W,W=e),W}function Fu(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="integer"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Hp)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="INTEGER"):(N=W,W=e)):(N=W,W=e),W}function Du(){var W,fe,Te,Ge;return W=N,t.substr(N,8).toLowerCase()==="smallint"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(mf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="SMALLINT"):(N=W,W=e)):(N=W,W=e),W}function ru(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="tinyint"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(p0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="TINYINT"):(N=W,W=e)):(N=W,W=e),W}function dt(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="bigint"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(ac)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="BIGINT"):(N=W,W=e)):(N=W,W=e),W}function i(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="float"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(hf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="FLOAT"):(N=W,W=e)):(N=W,W=e),W}function vn(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="real"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(Av)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="REAL"):(N=W,W=e)):(N=W,W=e),W}function Ua(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="double"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(iv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DOUBLE"):(N=W,W=e)):(N=W,W=e),W}function ea(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="date"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(gl)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DATE"):(N=W,W=e)):(N=W,W=e),W}function sn(){var W,fe,Te,Ge;return W=N,t.substr(N,8).toLowerCase()==="datetime"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(_v)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="DATETIME"):(N=W,W=e)):(N=W,W=e),W}function ct(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="rows"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(av)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="ROWS"):(N=W,W=e)):(N=W,W=e),W}function G(){var W,fe,Te,Ge;return W=N,t.substr(N,4).toLowerCase()==="time"?(fe=t.substr(N,4),N+=4):(fe=e,an===0&&$r(hb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="TIME"):(N=W,W=e)):(N=W,W=e),W}function we(){var W,fe,Te,Ge;return W=N,t.substr(N,9).toLowerCase()==="timestamp"?(fe=t.substr(N,9),N+=9):(fe=e,an===0&&$r(gb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="TIMESTAMP"):(N=W,W=e)):(N=W,W=e),W}function De(){var W,fe,Te,Ge;return W=N,t.substr(N,8).toLowerCase()==="interval"?(fe=t.substr(N,8),N+=8):(fe=e,an===0&&$r(Sv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="INTERVAL"):(N=W,W=e)):(N=W,W=e),W}function He(){var W,fe,Te,Ge;return W=N,t.substr(N,17).toLowerCase()==="current_timestamp"?(fe=t.substr(N,17),N+=17):(fe=e,an===0&&$r(cv)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="CURRENT_TIMESTAMP"):(N=W,W=e)):(N=W,W=e),W}function ye(){var W;return(W=(function(){var fe;return t.substr(N,2)==="@@"?(fe="@@",N+=2):(fe=e,an===0&&$r(jr)),fe})())===e&&(W=(function(){var fe;return t.charCodeAt(N)===64?(fe="@",N++):(fe=e,an===0&&$r(j)),fe})())===e&&(W=(function(){var fe;return t.charCodeAt(N)===36?(fe="$",N++):(fe=e,an===0&&$r(b0)),fe})()),W}function $t(){var W;return t.charCodeAt(N)===61?(W="=",N++):(W=e,an===0&&$r(Nf)),W}function Ht(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="add"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(hs)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="ADD"):(N=W,W=e)):(N=W,W=e),W}function $n(){var W,fe,Te,Ge;return W=N,t.substr(N,6).toLowerCase()==="column"?(fe=t.substr(N,6),N+=6):(fe=e,an===0&&$r(gf)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="COLUMN"):(N=W,W=e)):(N=W,W=e),W}function Xn(){var W,fe,Te,Ge;return W=N,t.substr(N,5).toLowerCase()==="index"?(fe=t.substr(N,5),N+=5):(fe=e,an===0&&$r(U0)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="INDEX"):(N=W,W=e)):(N=W,W=e),W}function u(){var W,fe,Te,Ge;return W=N,t.substr(N,3).toLowerCase()==="key"?(fe=t.substr(N,3),N+=3):(fe=e,an===0&&$r(zr)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="KEY"):(N=W,W=e)):(N=W,W=e),W}function xt(){var W,fe,Te,Ge;return W=N,t.substr(N,7).toLowerCase()==="comment"?(fe=t.substr(N,7),N+=7):(fe=e,an===0&&$r(Fb)),fe!==e?(Te=N,an++,Ge=fo(),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te!==e?(Or=W,W=fe="COMMENT"):(N=W,W=e)):(N=W,W=e),W}function X(){var W;return t.charCodeAt(N)===46?(W=".",N++):(W=e,an===0&&$r(Vs)),W}function ae(){var W;return t.charCodeAt(N)===44?(W=",",N++):(W=e,an===0&&$r(mn)),W}function Ie(){var W;return t.charCodeAt(N)===42?(W="*",N++):(W=e,an===0&&$r(tp)),W}function V(){var W;return t.charCodeAt(N)===40?(W="(",N++):(W=e,an===0&&$r(js)),W}function Se(){var W;return t.charCodeAt(N)===41?(W=")",N++):(W=e,an===0&&$r(oo)),W}function kt(){var W;return t.charCodeAt(N)===91?(W="[",N++):(W=e,an===0&&$r(ds)),W}function qt(){var W;return t.charCodeAt(N)===93?(W="]",N++):(W=e,an===0&&$r(Yc)),W}function hn(){var W;return t.charCodeAt(N)===59?(W=";",N++):(W=e,an===0&&$r(wb)),W}function o(){var W;return t.substr(N,2)==="->"?(W="->",N+=2):(W=e,an===0&&$r(m0)),W}function tt(){var W;return t.substr(N,2)==="||"?(W="||",N+=2):(W=e,an===0&&$r(Br)),W}function fr(){var W;return(W=tt())===e&&(W=(function(){var fe;return t.substr(N,2)==="&&"?(fe="&&",N+=2):(fe=e,an===0&&$r(bv)),fe})()),W}function Et(){var W,fe;for(W=[],(fe=jo())===e&&(fe=je());fe!==e;)W.push(fe),(fe=jo())===e&&(fe=je());return W}function ps(){var W,fe;if(W=[],(fe=jo())===e&&(fe=je()),fe!==e)for(;fe!==e;)W.push(fe),(fe=jo())===e&&(fe=je());else W=e;return W}function je(){var W;return(W=(function(){var fe,Te,Ge,bt,et,s;if(fe=N,t.substr(N,2)==="/*"?(Te="/*",N+=2):(Te=e,an===0&&$r(ib)),Te!==e){for(Ge=[],bt=N,et=N,an++,t.substr(N,2)==="*/"?(s="*/",N+=2):(s=e,an===0&&$r(h0)),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,et=N,an++,t.substr(N,2)==="*/"?(s="*/",N+=2):(s=e,an===0&&$r(h0)),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);Ge!==e?(t.substr(N,2)==="*/"?(bt="*/",N+=2):(bt=e,an===0&&$r(h0)),bt!==e?fe=Te=[Te,Ge,bt]:(N=fe,fe=e)):(N=fe,fe=e)}else N=fe,fe=e;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s;if(fe=N,t.substr(N,2)==="--"?(Te="--",N+=2):(Te=e,an===0&&$r(ab)),Te!==e){for(Ge=[],bt=N,et=N,an++,s=Do(),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,et=N,an++,s=Do(),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);Ge!==e?fe=Te=[Te,Ge]:(N=fe,fe=e)}else N=fe,fe=e;return fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s;if(fe=N,t.charCodeAt(N)===35?(Te="#",N++):(Te=e,an===0&&$r(j0)),Te!==e){for(Ge=[],bt=N,et=N,an++,s=Do(),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);bt!==e;)Ge.push(bt),bt=N,et=N,an++,s=Do(),an--,s===e?et=void 0:(N=et,et=e),et!==e&&(s=go())!==e?bt=et=[et,s]:(N=bt,bt=e);Ge!==e?fe=Te=[Te,Ge]:(N=fe,fe=e)}else N=fe,fe=e;return fe})()),W}function _n(){var W,fe,Te,Ge;return W=N,(fe=xt())!==e&&Et()!==e?((Te=$t())===e&&(Te=null),Te!==e&&Et()!==e&&(Ge=Ya())!==e?(Or=W,W=fe=(function(bt,et,s){return{type:bt.toLowerCase(),keyword:bt.toLowerCase(),symbol:et,value:s}})(fe,Te,Ge)):(N=W,W=e)):(N=W,W=e),W}function go(){var W;return t.length>N?(W=t.charAt(N),N++):(W=e,an===0&&$r(qd)),W}function jo(){var W;return F0.test(t.charAt(N))?(W=t.charAt(N),N++):(W=e,an===0&&$r(z0)),W}function Do(){var W,fe;if((W=(function(){var Te,Ge;return Te=N,an++,t.length>N?(Ge=t.charAt(N),N++):(Ge=e,an===0&&$r(qd)),an--,Ge===e?Te=void 0:(N=Te,Te=e),Te})())===e)if(W=[],Os.test(t.charAt(N))?(fe=t.charAt(N),N++):(fe=e,an===0&&$r(lo)),fe!==e)for(;fe!==e;)W.push(fe),Os.test(t.charAt(N))?(fe=t.charAt(N),N++):(fe=e,an===0&&$r(lo));else W=e;return W}function Bt(){var W,fe;return W=N,Or=N,qu=[],e!==void 0&&Et()!==e?((fe=Ho())===e&&(fe=(function(){var Te,Ge;return Te=N,(function(){var bt;return t.substr(N,6).toLowerCase()==="return"?(bt=t.substr(N,6),N+=6):(bt=e,an===0&&$r(uc)),bt})()!==e&&Et()!==e&&(Ge=mo())!==e?(Or=Te,Te={type:"return",expr:Ge}):(N=Te,Te=e),Te})()),fe!==e?(Or=W,W={stmt:fe,vars:qu}):(N=W,W=e)):(N=W,W=e),W}function Ho(){var W,fe,Te,Ge;return W=N,(fe=Sa())===e&&(fe=Uu()),fe!==e&&Et()!==e?((Te=(function(){var bt;return t.substr(N,2)===":="?(bt=":=",N+=2):(bt=e,an===0&&$r(sb)),bt})())===e&&(Te=$t()),Te!==e&&Et()!==e&&(Ge=mo())!==e?(Or=W,W=fe={type:"assign",left:fe,symbol:Te,right:Ge}):(N=W,W=e)):(N=W,W=e),W}function mo(){var W;return(W=_r())===e&&(W=(function(){var fe,Te,Ge,bt,et;return fe=N,(Te=Sa())!==e&&Et()!==e&&(Ge=Zu())!==e&&Et()!==e&&(bt=Sa())!==e&&Et()!==e&&(et=dr())!==e?(Or=fe,fe=Te={type:"join",ltable:Te,rtable:bt,op:Ge,on:et}):(N=fe,fe=e),fe})())===e&&(W=Wo())===e&&(W=(function(){var fe,Te;return fe=N,kt()!==e&&Et()!==e&&(Te=Ta())!==e&&Et()!==e&&qt()!==e?(Or=fe,fe={type:"array",value:Te}):(N=fe,fe=e),fe})()),W}function Wo(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=Fo())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=rd())!==e&&(s=Et())!==e&&(Be=Fo())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=rd())!==e&&(s=Et())!==e&&(Be=Fo())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Of(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Fo(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=di())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=Oc())!==e&&(s=Et())!==e&&(Be=di())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=Oc())!==e&&(s=Et())!==e&&(Be=di())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=Of(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function di(){var W,fe,Te;return(W=Oe())===e&&(W=Sa())===e&&(W=Hi())===e&&(W=$c())===e&&(W=N,V()!==e&&Et()!==e&&(fe=Wo())!==e&&Et()!==e&&Se()!==e?(Or=W,(Te=fe).parentheses=!0,W=Te):(N=W,W=e)),W}function pi(){var W,fe,Te,Ge,bt,et,s;return W=N,(fe=dc())!==e?(Te=N,(Ge=Et())!==e&&(bt=X())!==e&&(et=Et())!==e&&(s=dc())!==e?Te=Ge=[Ge,bt,et,s]:(N=Te,Te=e),Te===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(Be,kn){let nr={name:[Be]};return kn!==null&&(nr.schema=Be,nr.name=[kn[3]]),nr})(fe,Te)):(N=W,W=e)):(N=W,W=e),W}function Hi(){var W,fe,Te;return W=N,(fe=pi())!==e&&Et()!==e&&V()!==e&&Et()!==e?((Te=Ta())===e&&(Te=null),Te!==e&&Et()!==e&&Se()!==e?(Or=W,W=fe=(function(Ge,bt){return{type:"function",name:Ge,args:{type:"expr_list",value:bt},...qs()}})(fe,Te)):(N=W,W=e)):(N=W,W=e),W===e&&(W=N,(fe=pi())!==e&&(Or=W,fe=(function(Ge){return{type:"function",name:Ge,args:null,...qs()}})(fe)),W=fe),W}function Ta(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=di())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=di())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=di())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=ln(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function Sa(){var W,fe,Te,Ge,bt;return W=N,(fe=ye())!==e&&(Te=Uu())!==e?(Or=W,Ge=fe,bt=Te,W=fe={type:"var",...bt,prefix:Ge}):(N=W,W=e),W}function Uu(){var W,fe,Te;return W=N,(fe=Pu())!==e&&(Te=(function(){var Ge,bt,et,s,Be;for(Ge=N,bt=[],et=N,t.charCodeAt(N)===46?(s=".",N++):(s=e,an===0&&$r(Vs)),s!==e&&(Be=Pu())!==e?et=s=[s,Be]:(N=et,et=e);et!==e;)bt.push(et),et=N,t.charCodeAt(N)===46?(s=".",N++):(s=e,an===0&&$r(Vs)),s!==e&&(Be=Pu())!==e?et=s=[s,Be]:(N=et,et=e);return bt!==e&&(Or=Ge,bt=(function(kn){let nr=[];for(let ur=0;ur<kn.length;ur++)nr.push(kn[ur][1]);return nr})(bt)),Ge=bt})())!==e?(Or=W,W=fe=(function(Ge,bt){return qu.push(Ge),{type:"var",name:Ge,members:bt,prefix:null}})(fe,Te)):(N=W,W=e),W===e&&(W=N,(fe=Dc())!==e&&(Or=W,fe={type:"var",name:fe.value,members:[],quoted:null,prefix:null}),W=fe),W}function pu(){var W;return(W=ci())===e&&(W=(function(){var fe,Te,Ge;return fe=N,(Te=Su())!==e&&Et()!==e&&V()!==e&&Et()!==e&&(Ge=su())!==e&&Et()!==e&&Se()!==e?(Or=fe,Te={dataType:Te,parentheses:!0,expr:{type:"expr_list",value:Ge.map(bt=>({type:"datatype",...bt}))}},fe=Te):(N=fe,fe=e),fe===e&&(fe=N,(Te=Su())!==e&&Et()!==e&&(function(){var bt;return t.charCodeAt(N)===60?(bt="<",N++):(bt=e,an===0&&$r(Df)),bt})()!==e&&Et()!==e&&(Ge=su())!==e&&Et()!==e&&(function(){var bt;return t.charCodeAt(N)===62?(bt=">",N++):(bt=e,an===0&&$r(_0)),bt})()!==e?(Or=fe,Te=(function(bt,et){return{dataType:bt,angle_brackets:!0,expr:{type:"expr_list",value:et.map(s=>({type:"datatype",...s}))}}})(Te,Ge),fe=Te):(N=fe,fe=e)),fe})()),W}function ci(){var W;return(W=(function(){var fe,Te,Ge,bt;if(fe=N,(Te=$l())===e&&(Te=$a()),Te!==e)if(Et()!==e)if(V()!==e)if(Et()!==e){if(Ge=[],ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo)),bt!==e)for(;bt!==e;)Ge.push(bt),ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo));else Ge=e;Ge!==e&&(bt=Et())!==e&&Se()!==e?(Or=fe,Te={dataType:Te,length:parseInt(Ge.join(""),10),parentheses:!0},fe=Te):(N=fe,fe=e)}else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;return fe===e&&(fe=N,(Te=$l())===e&&(Te=$a())===e&&(Te=(function(){var et,s,Be,kn;return et=N,t.substr(N,6).toLowerCase()==="string"?(s=t.substr(N,6),N+=6):(s=e,an===0&&$r(Lv)),s!==e?(Be=N,an++,kn=fo(),an--,kn===e?Be=void 0:(N=Be,Be=e),Be!==e?(Or=et,et=s="STRING"):(N=et,et=e)):(N=et,et=e),et})()),Te!==e&&(Or=fe,Te=Tp(Te)),fe=Te),fe})())===e&&(W=(function(){var fe,Te,Ge,bt,et,s,Be,kn,nr,ur,Ce,Gt;if(fe=N,(Te=al())===e&&(Te=mc())===e&&(Te=In())===e&&(Te=Fu())===e&&(Te=Du())===e&&(Te=ru())===e&&(Te=dt())===e&&(Te=i())===e&&(Te=Ua())===e&&(Te=vn()),Te!==e)if((Ge=Et())!==e)if((bt=V())!==e)if((et=Et())!==e){if(s=[],ho.test(t.charAt(N))?(Be=t.charAt(N),N++):(Be=e,an===0&&$r(Oo)),Be!==e)for(;Be!==e;)s.push(Be),ho.test(t.charAt(N))?(Be=t.charAt(N),N++):(Be=e,an===0&&$r(Oo));else s=e;if(s!==e)if((Be=Et())!==e){if(kn=N,(nr=ae())!==e)if((ur=Et())!==e){if(Ce=[],ho.test(t.charAt(N))?(Gt=t.charAt(N),N++):(Gt=e,an===0&&$r(Oo)),Gt!==e)for(;Gt!==e;)Ce.push(Gt),ho.test(t.charAt(N))?(Gt=t.charAt(N),N++):(Gt=e,an===0&&$r(Oo));else Ce=e;Ce!==e?kn=nr=[nr,ur,Ce]:(N=kn,kn=e)}else N=kn,kn=e;else N=kn,kn=e;kn===e&&(kn=null),kn!==e&&(nr=Et())!==e&&(ur=Se())!==e&&(Ce=Et())!==e?((Gt=ii())===e&&(Gt=null),Gt!==e?(Or=fe,Es=kn,Co=Gt,Te={dataType:Te,length:parseInt(s.join(""),10),scale:Es&&parseInt(Es[2].join(""),10),parentheses:!0,suffix:Co},fe=Te):(N=fe,fe=e)):(N=fe,fe=e)}else N=fe,fe=e;else N=fe,fe=e}else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;var Es,Co;if(fe===e){if(fe=N,(Te=al())===e&&(Te=mc())===e&&(Te=In())===e&&(Te=Fu())===e&&(Te=Du())===e&&(Te=ru())===e&&(Te=dt())===e&&(Te=i())===e&&(Te=Ua())===e&&(Te=vn()),Te!==e){if(Ge=[],ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo)),bt!==e)for(;bt!==e;)Ge.push(bt),ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo));else Ge=e;Ge!==e&&(bt=Et())!==e?((et=ii())===e&&(et=null),et!==e?(Or=fe,Te=(function(ai,Mt,li){return{dataType:ai,length:parseInt(Mt.join(""),10),suffix:li}})(Te,Ge,et),fe=Te):(N=fe,fe=e)):(N=fe,fe=e)}else N=fe,fe=e;fe===e&&(fe=N,(Te=al())===e&&(Te=mc())===e&&(Te=In())===e&&(Te=Fu())===e&&(Te=Du())===e&&(Te=ru())===e&&(Te=dt())===e&&(Te=i())===e&&(Te=Ua())===e&&(Te=vn()),Te!==e&&(Ge=Et())!==e?((bt=ii())===e&&(bt=null),bt!==e&&(et=Et())!==e?(Or=fe,Te=(function(ai,Mt){return{dataType:ai,suffix:Mt}})(Te,bt),fe=Te):(N=fe,fe=e)):(N=fe,fe=e))}return fe})())===e&&(W=(function(){var fe,Te,Ge,bt;if(fe=N,(Te=ea())===e&&(Te=sn())===e&&(Te=G())===e&&(Te=we()),Te!==e)if(Et()!==e)if(V()!==e)if(Et()!==e){if(Ge=[],ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo)),bt!==e)for(;bt!==e;)Ge.push(bt),ho.test(t.charAt(N))?(bt=t.charAt(N),N++):(bt=e,an===0&&$r(Oo));else Ge=e;Ge!==e&&(bt=Et())!==e&&Se()!==e?(Or=fe,Te={dataType:Te,length:parseInt(Ge.join(""),10),parentheses:!0},fe=Te):(N=fe,fe=e)}else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;else N=fe,fe=e;return fe===e&&(fe=N,(Te=ea())===e&&(Te=sn())===e&&(Te=G())===e&&(Te=we()),Te!==e&&(Or=fe,Te=(function(et){return{dataType:et}})(Te)),fe=Te),fe})())===e&&(W=(function(){var fe,Te;return fe=N,(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="json"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(zl)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="JSON"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())!==e&&(Or=fe,Te=Tp(Te)),fe=Te})())===e&&(W=(function(){var fe,Te;return fe=N,(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,8).toLowerCase()==="tinytext"?(bt=t.substr(N,8),N+=8):(bt=e,an===0&&$r(Rc)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="TINYTEXT"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())===e&&(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,4).toLowerCase()==="text"?(bt=t.substr(N,4),N+=4):(bt=e,an===0&&$r(ic)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="TEXT"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())===e&&(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,10).toLowerCase()==="mediumtext"?(bt=t.substr(N,10),N+=10):(bt=e,an===0&&$r(mb)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="MEDIUMTEXT"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())===e&&(Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,8).toLowerCase()==="longtext"?(bt=t.substr(N,8),N+=8):(bt=e,an===0&&$r(D0)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="LONGTEXT"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})()),Te!==e&&(Or=fe,Te={dataType:Te}),fe=Te})())===e&&(W=(function(){var fe,Te;return fe=N,t.substr(N,7).toLowerCase()==="boolean"?(Te=t.substr(N,7),N+=7):(Te=e,an===0&&$r(xp)),Te!==e&&(Or=fe,Te={dataType:"BOOLEAN"}),fe=Te})()),W}function su(){var W,fe,Te,Ge,bt,et,s,Be;if(W=N,(fe=ci())!==e){for(Te=[],Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=ci())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Ge!==e;)Te.push(Ge),Ge=N,(bt=Et())!==e&&(et=ae())!==e&&(s=Et())!==e&&(Be=ci())!==e?Ge=bt=[bt,et,s,Be]:(N=Ge,Ge=e);Te!==e?(Or=W,W=fe=ln(fe,Te)):(N=W,W=e)}else N=W,W=e;return W}function ii(){var W,fe,Te;return W=N,(fe=d())===e&&(fe=null),fe!==e&&Et()!==e?((Te=(function(){var Ge,bt,et,s;return Ge=N,t.substr(N,8).toLowerCase()==="zerofill"?(bt=t.substr(N,8),N+=8):(bt=e,an===0&&$r(Pb)),bt!==e?(et=N,an++,s=fo(),an--,s===e?et=void 0:(N=et,et=e),et!==e?(Or=Ge,Ge=bt="ZEROFILL"):(N=Ge,Ge=e)):(N=Ge,Ge=e),Ge})())===e&&(Te=null),Te!==e?(Or=W,W=fe=(function(Ge,bt){let et=[];return Ge&&et.push(Ge),bt&&et.push(bt),et})(fe,Te)):(N=W,W=e)):(N=W,W=e),W}let da={ALTER:!0,ALL:!0,ADD:!0,AND:!0,AS:!0,ASC:!0,BETWEEN:!0,BY:!0,CALL:!0,CASE:!0,CREATE:!0,CROSS:!0,CONTAINS:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,DELETE:!0,DESC:!0,DISTINCT:!0,DROP:!0,ELSE:!0,END:!0,EXISTS:!0,EXPLAIN:!0,FALSE:!0,FROM:!0,FULL:!0,GROUP:!0,HAVING:!0,IN:!0,INNER:!0,INSERT:!0,INTO:!0,IS:!0,JOIN:!0,JSON:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOW_PRIORITY:!0,NOT:!0,NULL:!0,ON:!0,OR:!0,ORDER:!0,OUTER:!0,RECURSIVE:!0,RENAME:!0,READ:!0,RIGHT:!0,SELECT:!0,SESSION_USER:!0,SET:!0,SHOW:!0,SYSTEM_USER:!0,TABLE:!0,THEN:!0,TRUE:!0,TRUNCATE:!0,UNION:!0,UPDATE:!0,USING:!0,UNNEST:!0,VALUES:!0,WITH:!0,WHEN:!0,WHERE:!0,WRITE:!0,GLOBAL:!0,SESSION:!0,LOCAL:!0,PERSIST:!0,PERSIST_ONLY:!0};function qs(){return $.includeLocations?{loc:Wp(Or,N)}:{}}function Bu(W,fe){return{type:"unary_expr",operator:W,expr:fe}}function Pa(W,fe,Te){return{type:"binary_expr",operator:W,left:fe,right:Te}}function xa(W){let fe=h(Number.MAX_SAFE_INTEGER);return!(h(W)<fe)}function rn(W,fe,Te=3){let Ge=[W];for(let bt=0;bt<fe.length;bt++)delete fe[bt][Te].tableList,delete fe[bt][Te].columnList,Ge.push(fe[bt][Te]);return Ge}function Qu(W,fe){let Te=W;for(let Ge=0;Ge<fe.length;Ge++)Te=Pa(fe[Ge][1],Te,fe[Ge][3]);return Te}function Qc(W){return fa[W]||W||null}function Iu(W){let fe=new Set;for(let Te of W.keys()){let Ge=Te.split("::");if(!Ge){fe.add(Te);break}Ge&&Ge[1]&&(Ge[1]=Qc(Ge[1])),fe.add(Ge.join("::"))}return Array.from(fe)}let qu=[],wa=new Set,va=new Set,fa={};if((re=ht())!==e&&N===t.length)return re;throw re!==e&&N<t.length&&$r({type:"end"}),Rl(kp,lc<t.length?t.charAt(lc):null,lc<t.length?Wp(lc,lc+1):Wp(lc,lc))}}},function(n,r,f){"use strict";var h=f(0);function l(t,$,re,e){this.message=t,this.expected=$,this.found=re,this.location=e,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,l)}(function(t,$){function re(){this.constructor=t}re.prototype=$.prototype,t.prototype=new re})(l,Error),l.buildMessage=function(t,$){var re={literal:function(Ke){return'"'+qe(Ke.text)+'"'},class:function(Ke){var gt,ln="";for(gt=0;gt<Ke.parts.length;gt++)ln+=Ke.parts[gt]instanceof Array?ht(Ke.parts[gt][0])+"-"+ht(Ke.parts[gt][1]):ht(Ke.parts[gt]);return"["+(Ke.inverted?"^":"")+ln+"]"},any:function(Ke){return"any character"},end:function(Ke){return"end of input"},other:function(Ke){return Ke.description}};function e(Ke){return Ke.charCodeAt(0).toString(16).toUpperCase()}function qe(Ke){return Ke.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}function ht(Ke){return Ke.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(gt){return"\\x0"+e(gt)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(gt){return"\\x"+e(gt)}))}return"Expected "+(function(Ke){var gt,ln,Qn,bn=new Array(Ke.length);for(gt=0;gt<Ke.length;gt++)bn[gt]=(Qn=Ke[gt],re[Qn.type](Qn));if(bn.sort(),bn.length>0){for(gt=1,ln=1;gt<bn.length;gt++)bn[gt-1]!==bn[gt]&&(bn[ln]=bn[gt],ln++);bn.length=ln}switch(bn.length){case 1:return bn[0];case 2:return bn[0]+" or "+bn[1];default:return bn.slice(0,-1).join(", ")+", or "+bn[bn.length-1]}})(t)+" but "+(function(Ke){return Ke?'"'+qe(Ke)+'"':"end of input"})($)+" found."},n.exports={SyntaxError:l,parse:function(t,$){$=$!==void 0?$:{};var re,e={},qe={start:vr},ht=vr,Ke=function(q,ue){return er(q,ue)},gt=function(q,ue){return Gr(q,ue)},ln=function(q,ue){return er(q,ue)},Qn=qr("=",!1),bn=qr("DUPLICATE",!0),zr=qr("BINARY",!0),tr=qr("MASTER",!0),Er=qr("LOGS",!0),cs=qr("BINLOG",!0),Ys=qr("EVENTS",!0),ao=qr("CHARACTER",!0),uo=qr("SET",!0),ni=qr("COLLATION",!0),zo=function(q,ue){return er(q,ue,1)},ta=qr("IF",!0),Ha=qr("CASCADED",!0),ja=qr("LOCAL",!0),Aa=qr("CHECK",!0),cl=qr("OPTION",!1),nl=qr("check_option",!0),lf=qr("security_barrier",!0),cd=qr("security_invoker",!0),Il=qr("GRANTS",!0),Tl=qr(".",!1),cf=qr("ALGORITHM",!0),xf=qr("DEFAULT",!0),xu=qr("INSTANT",!0),Qd=qr("INPLACE",!0),jl=qr("COPY",!0),Od=qr("LOCK",!0),$d=qr("NONE",!0),wp=qr("SHARED",!0),Zf=qr("EXCLUSIVE",!0),ml=qr("AUTO_INCREMENT",!0),Dd=qr("UNIQUE",!0),Cc=qr("KEY",!0),Kf=qr("PRIMARY",!0),kf=qr("FOR",!0),fd=qr("COLUMN_FORMAT",!0),cb=qr("FIXED",!0),dd=qr("DYNAMIC",!0),hl=qr("STORAGE",!0),e0=qr("DISK",!0),ku=qr("MEMORY",!0),Up=qr("MATCH FULL",!0),ep=qr("MATCH PARTIAL",!0),pd=qr("MATCH SIMPLE",!0),Qi=qr("expiration_timestamp",!0),Vu=qr("partition_expiration_days",!0),Ir=qr("require_partition_filter",!0),ns=qr("kms_key_name",!0),ms=qr("friendly_name",!0),js=qr("description",!0),oo=qr("labels",!0),Vs=qr("default_rounding_mode",!0),xo=qr("AVG_ROW_LENGTH",!0),No=qr("KEY_BLOCK_SIZE",!0),Po=qr("MAX_ROWS",!0),na=qr("MIN_ROWS",!0),Ra=qr("STATS_SAMPLE_PAGES",!0),aa=qr("CONNECTION",!0),Va=qr("COMPRESSION",!0),Cu=qr("'",!1),uu=qr("ZLIB",!0),lu=qr("LZ4",!0),ec=qr("ENGINE",!0),Pp=qr("CLUSTER",!0),Rf=qr("BY",!0),Nf=qr("OPTIONS",!0),Of=qr("CHARSET",!0),ff=qr("COLLATE",!0),$f=qr("READ",!0),nf=qr("LOW_PRIORITY",!0),_0=qr("WRITE",!0),S0=(qr("FOREIGN KEY",!0),qr("NOT",!0)),I0=(qr("REPLICATION",!0),qr("BTREE",!0)),Df=qr("HASH",!0),df=qr("WITH",!0),Mp=qr("PARSER",!0),bd=qr("VISIBLE",!0),tc=qr("INVISIBLE",!0),Jf=qr("RESTRICT",!0),tp=qr("CASCADE",!0),t0=qr("SET NULL",!0),H0=qr("NO ACTION",!0),vd=qr("SET DEFAULT",!0),Uf=qr("UPDATE",!0),md=qr("CREATE",!0),Ud=qr("DELETE",!0),jp=qr("INSERT",!0),Lu=qr(":=",!1),n0=qr("return",!0),np=qr("REPLACE",!0),r0=qr("ANALYZE",!0),Xf=qr("ATTACH",!0),Lc=qr("DATABASE",!0),xl=qr("RENAME",!0),Gc=qr("SHOW",!0),Y0=qr("DESCRIBE",!0),Bc=qr("@",!1),rp=qr("@@",!1),W0=qr("$",!1),hd=qr("TEMPORARY",!0),T0=qr("TEMP",!0),sp=qr("SCHEMA",!0),Qf=qr("ALTER",!0),Pf=qr("SPATIAL",!0),no=qr("(",!1),nc=qr(")",!1),Ec=qr("INTERSECT",!0),Mf=qr("EXCEPT",!0),Pd=qr("SYSTEM_TIME",!0),Fp=qr("AS",!0),Z0=qr("OF",!0),Md=qr("UNNEST",!0),zp=function(q,ue){return ue.unshift(q),ue.forEach(xe=>{let{table:Ee,as:lt}=xe;io[Ee]=Ee,lt&&(io[lt]=Ee),(function(St){let Ft=bs(St);St.clear(),Ft.forEach(dn=>St.add(dn))})(Ms)}),ue},Cp=/^[@]/,s0=pr(["@"],!1,!1),jd=/^[{]/,gd=pr(["{"],!1,!1),gl=/^[=]/,yd=pr(["="],!1,!1),fb=/^[}]/,o0=pr(["}"],!1,!1),Lp=qr("TABLESAMPLE",!0),rc=qr("BERNOULLI",!0),Ac=qr("RESERVOIR",!0),op=qr("PERCENT",!0),i0=qr("ROWS",!0),Fa=qr("RANGE",!0),_c=qr("FOLLOWING",!0),Sc=qr("PRECEDING",!0),K0=qr("CURRENT",!0),Ep=qr("ROW",!0),ip=qr("UNBOUNDED",!0),Fd=qr("!",!1),a0=function(q){return q[0]+" "+q[2]},J0=qr(">=",!1),x0=qr(">",!1),Fl=qr("<=",!1),Ic=qr("<>",!1),qc=qr("<",!1),Gp=qr("!=",!1),ap=qr("+",!1),Ap=qr("-",!1),wd=qr("*",!1),_p=qr("/",!1),Bp=qr("%",!1),k0=qr("~",!1),Cd=function(q){return pt[q.toUpperCase()]===!0},sc=qr('"',!1),zd=/^[^"]/,vt=pr(['"'],!0,!1),gn=/^[^']/,Yn=pr(["'"],!0,!1),On=qr("`",!1),Kr=/^[^`]/,Vr=pr(["`"],!0,!1),us=function(q,ue){return q+ue.join("")},Ds=/^[A-Za-z_]/,Os=pr([["A","Z"],["a","z"],"_"],!1,!1),lo=/^[A-Za-z0-9_\-]/,ho=pr([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1),Oo=/^[A-Za-z0-9_:\u4E00-\u9FA5\xC0-\u017F]/,ui=pr([["A","Z"],["a","z"],["0","9"],"_",":",["\u4E00","\u9FA5"],["\xC0","\u017F"]],!1,!1),ri=qr(":",!1),Oi=qr("string_agg",!0),Wi=qr("ANY_VALUE",!0),mi=qr("YEAR_MONTH",!0),Zi=qr("DAY_HOUR",!0),Bi=qr("DAY_MINUTE",!0),_a=qr("DAY_SECOND",!0),ga=qr("DAY_MICROSECOND",!0),cu=qr("HOUR_MINUTE",!0),Da=qr("HOUR_SECOND",!0),Wu=qr("HOUR_MICROSECOND",!0),Na=qr("MINUTE_SECOND",!0),rl=qr("MINUTE_MICROSECOND",!0),pf=qr("SECOND_MICROSECOND",!0),Tc=qr("TIMEZONE_HOUR",!0),fl=qr("TIMEZONE_MINUTE",!0),up=qr("CENTURY",!0),Gd=qr("DAYOFWEEK",!0),fu=qr("DAY",!0),kl=qr("DATE",!0),bf=qr("DECADE",!0),Vc=qr("DOW",!0),u0=qr("DOY",!0),X0=qr("EPOCH",!0),rf=qr("HOUR",!0),xc=qr("ISODOW",!0),vf=qr("ISOWEEK",!0),jf=qr("ISOYEAR",!0),Ff=qr("MICROSECONDS",!0),lp=qr("MILLENNIUM",!0),Wb=qr("MILLISECONDS",!0),Q0=qr("MINUTE",!0),Zb=qr("MONTH",!0),Kb=qr("QUARTER",!0),kc=qr("SECOND",!0),oc=qr("TIME",!0),R0=qr("TIMEZONE",!0),Bd=qr("WEEK",!0),db=qr("YEAR",!0),eb=qr("DATE_TRUNC",!0),pb=qr("R",!0),Jb=function(q,ue){return{type:q.toLowerCase(),value:ue[1].join("")}},l0=/^[^"\\\0-\x1F\x7F]/,tb=pr(['"',"\\",["\0",""],"\x7F"],!0,!1),bb=/^[^'\\]/,nb=pr(["'","\\"],!0,!1),c0=qr("\\'",!1),_b=qr('\\"',!1),Sb=qr("\\\\",!1),N0=qr("\\/",!1),Xb=qr("\\b",!1),yv=qr("\\f",!1),vb=qr("\\n",!1),wv=qr("\\r",!1),Ib=qr("\\t",!1),Cv=qr("\\u",!1),Nv=qr("\\",!1),Tb=qr("''",!1),xb=qr('""',!1),Qb=qr("``",!1),f0=/^[\n\r]/,Ld=pr([`
|
|
@@ -206,13 +206,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
206
206
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function Lu(vt,gn){if(vt){if(typeof vt=="string")return n0(vt,gn);var Yn={}.toString.call(vt).slice(8,-1);return Yn==="Object"&&vt.constructor&&(Yn=vt.constructor.name),Yn==="Map"||Yn==="Set"?Array.from(vt):Yn==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Yn)?n0(vt,gn):void 0}}function n0(vt,gn){(gn==null||gn>vt.length)&&(gn=vt.length);for(var Yn=0,On=Array(gn);Yn<gn;Yn++)On[Yn]=vt[Yn];return On}function np(vt){if(!vt)return[];var gn,Yn,On,Kr,Vr=vt.resource;switch(Vr){case"column":return rc(vt);case"index":return Yn=[],On=(gn=vt).keyword,Kr=gn.index,Yn.push(tr(On)),Yn.push(Kr),Yn.push.apply(Yn,lf(xf(gn))),Yn.filter(Er).join(" ");case"constraint":return Jf(vt);case"sequence":return[tr(vt.prefix),no(vt.value)].filter(Er).join(" ");default:throw new Error("unknown resource = ".concat(Vr," type"))}}function r0(vt){var gn=[];switch(vt.keyword){case"from":gn.push("FROM","(".concat(cs(vt.from),")"),"TO","(".concat(cs(vt.to),")"));break;case"in":gn.push("IN","(".concat(no(vt.in),")"));break;case"with":gn.push("WITH","(MODULUS ".concat(cs(vt.modulus),", REMAINDER ").concat(cs(vt.remainder),")"))}return gn.filter(Er).join(" ")}function Xf(vt){var gn=vt.keyword,Yn=vt.table,On=vt.for_values,Kr=vt.tablespace,Vr=[tr(gn),uu(Yn),tr(On.keyword),r0(On.expr)];return Kr&&Vr.push("TABLESPACE",cs(Kr)),Vr.filter(Er).join(" ")}function Lc(vt){return vt.dataType?ni(vt):[zr(vt.db),zr(vt.schema),zr(vt.table)].filter(Er).join(".")}function xl(vt){var gn=vt.type;switch(gn){case"as":return[tr(gn),vt.symbol,Qi(vt.declare),tr(vt.begin),Vu(vt.expr),tr(vt.end),vt.symbol].filter(Er).join(" ");case"set":return[tr(gn),vt.parameter,tr(vt.value&&vt.value.prefix),vt.value&&vt.value.expr.map(no).join(", ")].filter(Er).join(" ");case"return":return[tr(gn),no(vt.expr)].filter(Er).join(" ");default:return no(vt)}}function Gc(vt){var gn=vt.type,Yn=vt.symbol,On=vt.value,Kr=[tr(gn),Yn];switch(tr(gn)){case"SFUNC":Kr.push([zr(On.schema),On.name].filter(Er).join("."));break;case"STYPE":case"MSTYPE":Kr.push(ni(On));break;default:Kr.push(no(On))}return Kr.filter(Er).join(" ")}function Y0(vt,gn){if(vt==="add"){var Yn=gn.map((function(On){var Kr=On.name,Vr=On.value;return["PARTITION",cs(Kr),"VALUES",tr(Vr.type),"(".concat(cs(Vr.expr),")")].join(" ")})).join(", ");return"(".concat(Yn,")")}else return Fa(gn)}function Bc(vt){if(!vt)return"";var gn=vt.action,Yn=vt.create_definitions,On=vt.if_not_exists,Kr=vt.keyword,Vr=vt.if_exists,us=vt.old_column,Ds=vt.prefix,Os=vt.resource,lo=vt.symbol,ho=vt.suffix,Oo="",ui=[];switch(Os){case"column":ui=[rc(vt)];break;case"index":ui=xf(vt),Oo=vt[Os];break;case"table":case"schema":Oo=zr(vt[Os]);break;case"aggregate":case"function":case"domain":case"type":Oo=zr(vt[Os]);break;case"algorithm":case"lock":case"table-option":Oo=[lo,tr(vt[Os])].filter(Er).join(" ");break;case"constraint":Oo=zr(vt[Os]),ui=[np(Yn)];break;case"partition":ui=[Y0(gn,vt.partitions)];break;case"key":Oo=zr(vt[Os]);break;default:Oo=[lo,vt[Os]].filter((function(Oi){return Oi!==null})).join(" ")}var ri=[tr(gn),tr(Kr),tr(On),tr(Vr),us&&gl(us),tr(Ds),Oo&&Oo.trim(),ui.filter(Er).join(" ")];return ho&&ri.push(tr(ho.keyword),ho.expr&&gl(ho.expr)),ri.filter(Er).join(" ")}function rp(vt){var gn=vt.default&&[tr(vt.default.keyword),no(vt.default.value)].join(" ");return[tr(vt.mode),vt.name,ni(vt.type),gn].filter(Er).join(" ")}function W0(vt){return(W0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}function hd(vt){var gn=vt.expr_list;switch(tr(vt.type)){case"STRUCT":case"ROW":return"(".concat(Fa(gn),")");case"ARRAY":return(function(Yn){var On=Yn.array_path,Kr=Yn.brackets,Vr=Yn.expr_list,us=Yn.parentheses;if(!Vr)return"[".concat(Fa(On),"]");var Ds=Array.isArray(Vr)?Vr.map((function(Os){return"(".concat(Fa(Os),")")})).filter(Er).join(", "):no(Vr);return Kr?"[".concat(Ds,"]"):us?"(".concat(Ds,")"):Ds})(vt);default:return""}}function T0(vt){var gn=vt.definition,Yn=vt.keyword,On=vt.orderby,Kr=vt.limit,Vr=[tr(Yn)];return gn&&W0(gn)==="object"&&(Vr.length=0,Vr.push(zo(gn))),Vr.push(hd(vt),Ec(On,"order by"),Zf(Kr)),Vr.filter(Er).join("")}function sp(vt){return(sp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}var Qf={alter:Bc,aggr_func:function(vt){var gn=vt.args,Yn=vt.filter,On=vt.over,Kr=vt.within_group_orderby,Vr=no(gn.expr);Vr=Array.isArray(Vr)?Vr.join(", "):Vr;var us=vt.name,Ds=vd(On);gn.distinct&&(Vr=["DISTINCT",Vr].join(" ")),gn.separator&&gn.separator.delimiter&&(Vr=[Vr,cs(gn.separator.delimiter)].join("".concat(gn.separator.symbol," "))),gn.separator&&gn.separator.expr&&(Vr=[Vr,no(gn.separator.expr)].join(" ")),gn.orderby&&(Vr=[Vr,Ec(gn.orderby,"order by")].join(" ")),gn.separator&&gn.separator.value&&(Vr=[Vr,tr(gn.separator.keyword),cs(gn.separator.value)].filter(Er).join(" "));var Os=Kr?"WITHIN GROUP (".concat(Ec(Kr,"order by"),")"):"",lo=Yn?"FILTER (WHERE ".concat(no(Yn.where),")"):"";return["".concat(us,"(").concat(Vr,")"),Os,Ds,lo].filter(Er).join(" ")},any_value:function(vt){var gn=vt.args,Yn=vt.type,On=vt.over,Kr=gn.expr,Vr=gn.having,us="".concat(tr(Yn),"(").concat(no(Kr));return Vr&&(us="".concat(us," HAVING ").concat(tr(Vr.prefix)," ").concat(no(Vr.expr))),[us="".concat(us,")"),vd(On)].filter(Er).join(" ")},window_func:function(vt){var gn=vt.over;return[(function(Yn){var On=Yn.args,Kr=Yn.name,Vr=Yn.consider_nulls,us=Vr===void 0?"":Vr,Ds=Yn.separator,Os=Ds===void 0?", ":Ds;return[Kr,"(",On?no(On).join(Os):"",")",us&&" ",us].filter(Er).join("")})(vt),vd(gn)].filter(Er).join(" ")},array:T0,assign:Up,binary_expr:xu,case:function(vt){var gn=["CASE"],Yn=vt.args,On=vt.expr,Kr=vt.parentheses;On&&gn.push(no(On));for(var Vr=0,us=Yn.length;Vr<us;++Vr)gn.push(Yn[Vr].type.toUpperCase()),Yn[Vr].cond&&(gn.push(no(Yn[Vr].cond)),gn.push("THEN")),gn.push(no(Yn[Vr].result));return gn.push("END"),Kr?"(".concat(gn.join(" "),")"):gn.join(" ")},cast:md,collate:Mf,column_ref:gl,column_definition:rc,datatype:ni,extract:function(vt){var gn=vt.args,Yn=vt.type,On=gn.field,Kr=gn.cast_type,Vr=gn.source,us=["".concat(tr(Yn),"(").concat(tr(On)),"FROM",tr(Kr),no(Vr)];return"".concat(us.filter(Er).join(" "),")")},flatten:function(vt){var gn=vt.args,Yn=vt.type,On=["input","path","outer","recursive","mode"].map((function(Kr){return(function(Vr){if(!Vr)return"";var us=Vr.type,Ds=Vr.symbol,Os=Vr.value;return[tr(us),Ds,no(Os)].filter(Er).join(" ")})(gn[Kr])})).filter(Er).join(", ");return"".concat(tr(Yn),"(").concat(On,")")},fulltext_search:function(vt){var gn=vt.against,Yn=vt.as,On=vt.columns,Kr=vt.match,Vr=vt.mode,us=[tr(Kr),"(".concat(On.map((function(Os){return gl(Os)})).join(", "),")")].join(" "),Ds=[tr(gn),["(",no(vt.expr),Vr&&" ".concat(cs(Vr)),")"].filter(Er).join("")].join(" ");return[us,Ds,Ac(Yn)].filter(Er).join(" ")},function:Ud,lambda:function(vt){var gn=vt.args,Yn=vt.expr,On=gn.value,Kr=gn.parentheses,Vr=On.map(no).join(", ");return[Kr?"(".concat(Vr,")"):Vr,"->",no(Yn)].join(" ")},load_data:ku,insert:Qi,interval:xo,json:function(vt){var gn=vt.keyword,Yn=vt.expr_list;return[tr(gn),Yn.map((function(On){return no(On)})).join(", ")].join(" ")},json_object_arg:function(vt){var gn=vt.expr,Yn=gn.key,On=gn.value,Kr=gn.on,Vr=[no(Yn),"VALUE",no(On)];return Kr&&Vr.push("ON","NULL",no(Kr)),Vr.filter(Er).join(" ")},json_visitor:function(vt){return[vt.symbol,no(vt.expr)].join("")},func_arg:function(vt){var gn=vt.value;return[gn.name,gn.symbol,no(gn.expr)].filter(Er).join(" ")},show:ep,struct:T0,tablefunc:function(vt){var gn=vt.as,Yn=vt.name,On=vt.args,Kr=[cs(Yn.schema),Yn.name.map(cs).join(".")].filter(Er).join(".");return["".concat(Kr,"(").concat(no(On).join(", "),")"),"AS",Ud(gn)].join(" ")},tables:lu,unnest:na,values:Ir,window:function(vt){return vt.expr.map(H0).join(", ")}};function Pf(vt){var gn=vt.prefix,Yn=gn===void 0?"@":gn,On=vt.name,Kr=vt.members,Vr=vt.quoted,us=vt.suffix,Ds=[],Os=Kr&&Kr.length>0?"".concat(On,".").concat(Kr.join(".")):On,lo="".concat(Yn||"").concat(Os);return us&&(lo+=us),Ds.push(lo),[Vr,Ds.join(" "),Vr].filter(Er).join("")}function no(vt){if(vt){var gn=vt;if(vt.ast){var Yn=gn.ast;Reflect.deleteProperty(gn,Yn);for(var On=0,Kr=Object.keys(Yn);On<Kr.length;On++){var Vr=Kr[On];gn[Vr]=Yn[Vr]}}var us=gn.type;return us==="expr"?no(gn.expr):Qf[us]?Qf[us](gn):cs(gn)}}function nc(vt){return vt?(Array.isArray(vt)||(vt=[vt]),vt.map(no)):[]}function Ec(vt,gn){if(!Array.isArray(vt))return"";var Yn=[],On=tr(gn);return On==="ORDER BY"?Yn=vt.map((function(Kr){return[no(Kr.expr),Kr.type||"ASC",tr(Kr.nulls)].filter(Er).join(" ")})):Yn=vt.map((function(Kr){return no(Kr.expr)})),e(On,Yn.join(", "))}function Mf(vt){if(vt){var gn=vt.keyword,Yn=vt.collate,On=Yn.name,Kr=Yn.symbol,Vr=Yn.value,us=[tr(gn)];return Vr||us.push(Kr),us.push(Array.isArray(On)?On.map(cs).join("."):cs(On)),Vr&&us.push(Kr),us.push(no(Vr)),us.filter(Er).join(" ")}}function Pd(vt){return(Pd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}function Fp(vt,gn){var Yn=Object.keys(vt);if(Object.getOwnPropertySymbols){var On=Object.getOwnPropertySymbols(vt);gn&&(On=On.filter((function(Kr){return Object.getOwnPropertyDescriptor(vt,Kr).enumerable}))),Yn.push.apply(Yn,On)}return Yn}function Z0(vt){for(var gn=1;gn<arguments.length;gn++){var Yn=arguments[gn]!=null?arguments[gn]:{};gn%2?Fp(Object(Yn),!0).forEach((function(On){Md(vt,On,Yn[On])})):Object.getOwnPropertyDescriptors?Object.defineProperties(vt,Object.getOwnPropertyDescriptors(Yn)):Fp(Object(Yn)).forEach((function(On){Object.defineProperty(vt,On,Object.getOwnPropertyDescriptor(Yn,On))}))}return vt}function Md(vt,gn,Yn){return(gn=(function(On){var Kr=(function(Vr,us){if(Pd(Vr)!="object"||!Vr)return Vr;var Ds=Vr[Symbol.toPrimitive];if(Ds!==void 0){var Os=Ds.call(Vr,us||"default");if(Pd(Os)!="object")return Os;throw new TypeError("@@toPrimitive must return a primitive value.")}return(us==="string"?String:Number)(Vr)})(On,"string");return Pd(Kr)=="symbol"?Kr:Kr+""})(gn))in vt?Object.defineProperty(vt,gn,{value:Yn,enumerable:!0,configurable:!0,writable:!0}):vt[gn]=Yn,vt}function zp(vt){return(function(gn){if(Array.isArray(gn))return s0(gn)})(vt)||(function(gn){if(typeof Symbol<"u"&&gn[Symbol.iterator]!=null||gn["@@iterator"]!=null)return Array.from(gn)})(vt)||Cp(vt)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
207
207
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function Cp(vt,gn){if(vt){if(typeof vt=="string")return s0(vt,gn);var Yn={}.toString.call(vt).slice(8,-1);return Yn==="Object"&&vt.constructor&&(Yn=vt.constructor.name),Yn==="Map"||Yn==="Set"?Array.from(vt):Yn==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Yn)?s0(vt,gn):void 0}}function s0(vt,gn){(gn==null||gn>vt.length)&&(gn=vt.length);for(var Yn=0,On=Array(gn);Yn<gn;Yn++)On[Yn]=vt[Yn];return On}function jd(vt,gn){if(typeof vt=="string")return zr(vt,gn);var Yn=vt.expr,On=vt.offset,Kr=vt.suffix,Vr=On&&On.map((function(us){return["[",us.name,"".concat(us.name?"(":""),cs(us.value),"".concat(us.name?")":""),"]"].filter(Er).join("")})).join("");return[no(Yn),Vr,Kr].filter(Er).join("")}function gd(vt){if(!vt||vt.length===0)return"";var gn,Yn=[],On=(function(us,Ds){var Os=typeof Symbol<"u"&&us[Symbol.iterator]||us["@@iterator"];if(!Os){if(Array.isArray(us)||(Os=Cp(us))||Ds&&us&&typeof us.length=="number"){Os&&(us=Os);var lo=0,ho=function(){};return{s:ho,n:function(){return lo>=us.length?{done:!0}:{done:!1,value:us[lo++]}},e:function(Oi){throw Oi},f:ho}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
208
208
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Oo,ui=!0,ri=!1;return{s:function(){Os=Os.call(us)},n:function(){var Oi=Os.next();return ui=Oi.done,Oi},e:function(Oi){ri=!0,Oo=Oi},f:function(){try{ui||Os.return==null||Os.return()}finally{if(ri)throw Oo}}}})(vt);try{for(On.s();!(gn=On.n()).done;){var Kr=gn.value,Vr=Kr.brackets?"[".concat(no(Kr.index),"]"):"".concat(Kr.notation).concat(no(Kr.index));Kr.property&&(Vr="".concat(Vr,".").concat(cs(Kr.property))),Yn.push(Vr)}}catch(us){On.e(us)}finally{On.f()}return Yn.join("")}function gl(vt){var gn=vt.array_index,Yn=vt.as,On=vt.column,Kr=vt.collate,Vr=vt.db,us=vt.isDual,Ds=vt.notations,Os=Ds===void 0?[]:Ds,lo=vt.options,ho=vt.schema,Oo=vt.table,ui=vt.parentheses,ri=vt.suffix,Oi=vt.order_by,Wi=vt.subFields,mi=Wi===void 0?[]:Wi,Zi=On==="*"?"*":jd(On,us),Bi=[Vr,ho,Oo].filter(Er).map((function(Wu){return"".concat(typeof Wu=="string"?zr(Wu):no(Wu))})),_a=Bi[0];if(_a){for(var ga=1;ga<Bi.length;++ga)_a="".concat(_a).concat(Os[ga]||".").concat(Bi[ga]);Zi="".concat(_a).concat(Os[ga]||".").concat(Zi)}var cu=[Zi=["".concat(Zi).concat(gd(gn))].concat(zp(mi)).join("."),Mf(Kr),no(lo),re("AS",no,Yn)];cu.push(typeof ri=="string"?tr(ri):no(ri)),cu.push(tr(Oi));var Da=cu.filter(Er).join(" ");return ui?"(".concat(Da,")"):Da}function yd(vt){if(vt){var gn=vt.schema,Yn=vt.dataType,On=vt.length,Kr=vt.suffix,Vr=vt.scale,us=vt.expr,Ds=ni({schema:gn,dataType:Yn,length:On,suffix:Kr,scale:Vr,parentheses:On!=null});if(us&&(Ds+=no(us)),vt.array){var Os=Uf(vt);Ds+=[/^\[.*\]$/.test(Os)?"":" ",Os].join("")}return Ds}}function fb(vt){var gn=[];if(!vt)return gn;var Yn=vt.definition,On=vt.keyword,Kr=vt.match,Vr=vt.table,us=vt.on_action;return gn.push(tr(On)),gn.push(lu(Vr)),gn.push(Yn&&"(".concat(Yn.map((function(Ds){return no(Ds)})).join(", "),")")),gn.push(tr(Kr)),us.map((function(Ds){return gn.push(tr(Ds.type),no(Ds.value))})),gn.filter(Er)}function o0(vt){var gn=[],Yn=vt.nullable,On=vt.character_set,Kr=vt.check,Vr=vt.comment,us=vt.constraint,Ds=vt.collate,Os=vt.storage,lo=vt.using,ho=vt.default_val,Oo=vt.generated,ui=vt.auto_increment,ri=vt.unique,Oi=vt.primary_key,Wi=vt.column_format,mi=vt.reference_definition,Zi=vt.generated_by_default,Bi=[tr(Yn&&Yn.action),tr(Yn&&Yn.value)].filter(Er).join(" ");if(Oo||gn.push(Bi),ho){var _a=ho.type,ga=ho.value;gn.push(_a.toUpperCase(),no(ga))}var cu=gt().database;return us&&gn.push(tr(us.keyword),cs(us.constraint)),gn.push(Jf(Kr)),gn.push((function(Da){if(Da)return[tr(Da.value),"(".concat(no(Da.expr),")"),tr(Da.storage_type)].filter(Er).join(" ")})(Oo)),Oo&&gn.push(Bi),gn.push(cl(ui),tr(Oi),tr(ri),cs(Zi),ta(Vr)),gn.push.apply(gn,zp(Ys(On))),cu.toLowerCase()!=="sqlite"&&gn.push(no(Ds)),gn.push.apply(gn,zp(Ys(Wi))),gn.push.apply(gn,zp(Ys(Os))),gn.push.apply(gn,zp(fb(mi))),gn.push(re("USING",no,lo)),gn.filter(Er).join(" ")}function Lp(vt){var gn=vt.order_by,Yn=vt.column,On=vt.collate,Kr=vt.nulls,Vr=vt.opclass,us=typeof Yn=="string"?{type:"column_ref",table:vt.table,column:Yn}:Z0(Z0({},vt),{},{order_by:null});return us.collate=null,[no(us),no(On),Vr,tr(gn),tr(Kr)].filter(Er).join(" ")}function rc(vt){var gn=[],Yn=gl(vt.column),On=yd(vt.definition);return gn.push(Yn),gn.push(On),gn.push(o0(vt)),gn.filter(Er).join(" ")}function Ac(vt){return vt?Pd(vt)==="object"?["AS",no(vt)].join(" "):["AS",/^(`?)[a-z_][0-9a-z_]*(`?)$/i.test(vt)?zr(vt):bn(vt)].join(" "):""}function op(vt,gn){var Yn=vt.expr,On=vt.type;if(On==="cast")return md(vt);gn&&(Yn.isDual=gn);var Kr=no(Yn),Vr=vt.expr_list;if(Vr){var us=[Kr],Ds=Vr.map((function(Os){return op(Os,gn)})).join(", ");return us.push([tr(On),On&&"(",Ds,On&&")"].filter(Er).join("")),us.filter(Er).join(" ")}return Yn.parentheses&&Reflect.has(Yn,"array_index")&&Yn.type!=="cast"&&(Kr="(".concat(Kr,")")),Yn.array_index&&Yn.type!=="column_ref"&&Yn.type!=="function"&&(Kr="".concat(Kr).concat(gd(Yn.array_index))),[Kr,Ac(vt.as)].filter(Er).join(" ")}function i0(vt){var gn=Array.isArray(vt)&&vt[0];return!(!gn||gn.type!=="dual")}function Fa(vt,gn){if(!vt||vt==="*")return vt;var Yn=i0(gn);return vt.map((function(On){return op(On,Yn)})).join(", ")}Qf.var=Pf,Qf.expr_list=function(vt){var gn=nc(vt.value),Yn=vt.parentheses,On=vt.separator;if(!Yn&&!On)return gn;var Kr=On||", ",Vr=gn.join(Kr);return Yn?"(".concat(Vr,")"):Vr},Qf.select=function(vt){var gn=sp(vt._next)==="object"?Qi(vt):Cc(vt);return vt.parentheses?"(".concat(gn,")"):gn},Qf.unary_expr=function(vt){var gn=vt.operator,Yn=vt.parentheses,On=vt.expr,Kr=gn==="-"||gn==="+"||gn==="~"||gn==="!"?"":" ",Vr="".concat(gn).concat(Kr).concat(no(On));return Yn?"(".concat(Vr,")"):Vr},Qf.map_object=function(vt){var gn=vt.keyword,Yn=vt.expr.map((function(On){return[cs(On.key),cs(On.value)].join(", ")})).join(", ");return[tr(gn),"[".concat(Yn,"]")].join("")};var _c=f(1),Sc=f(2),K0=f(3),Ep=f(4),ip=f(5),Fd=f(6),a0=f(7),J0=f(8),x0=f(9),Fl=f(10),Ic=f(11),qc=f(12),Gp=f(13),ap=f(14),Ap={athena:_c.parse,bigquery:Sc.parse,db2:K0.parse,flinksql:Ep.parse,hive:ip.parse,mysql:Fd.parse,mariadb:a0.parse,noql:J0.parse,postgresql:x0.parse,redshift:Fl.parse,snowflake:Gp.parse,sqlite:Ic.parse,transactsql:qc.parse,trino:ap.parse};function wd(vt){return(wd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}function _p(vt,gn){var Yn=typeof Symbol<"u"&&vt[Symbol.iterator]||vt["@@iterator"];if(!Yn){if(Array.isArray(vt)||(Yn=(function(Os,lo){if(Os){if(typeof Os=="string")return Bp(Os,lo);var ho={}.toString.call(Os).slice(8,-1);return ho==="Object"&&Os.constructor&&(ho=Os.constructor.name),ho==="Map"||ho==="Set"?Array.from(Os):ho==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ho)?Bp(Os,lo):void 0}})(vt))||gn&&vt&&typeof vt.length=="number"){Yn&&(vt=Yn);var On=0,Kr=function(){};return{s:Kr,n:function(){return On>=vt.length?{done:!0}:{done:!1,value:vt[On++]}},e:function(Os){throw Os},f:Kr}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
209
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Vr,us=!0,Ds=!1;return{s:function(){Yn=Yn.call(vt)},n:function(){var Os=Yn.next();return us=Os.done,Os},e:function(Os){Ds=!0,Vr=Os},f:function(){try{us||Yn.return==null||Yn.return()}finally{if(Ds)throw Vr}}}}function Bp(vt,gn){(gn==null||gn>vt.length)&&(gn=vt.length);for(var Yn=0,On=Array(gn);Yn<gn;Yn++)On[Yn]=vt[Yn];return On}function k0(vt,gn){for(var Yn=0;Yn<gn.length;Yn++){var On=gn[Yn];On.enumerable=On.enumerable||!1,On.configurable=!0,"value"in On&&(On.writable=!0),Object.defineProperty(vt,Cd(On.key),On)}}function Cd(vt){var gn=(function(Yn,On){if(wd(Yn)!="object"||!Yn)return Yn;var Kr=Yn[Symbol.toPrimitive];if(Kr!==void 0){var Vr=Kr.call(Yn,On||"default");if(wd(Vr)!="object")return Vr;throw new TypeError("@@toPrimitive must return a primitive value.")}return(On==="string"?String:Number)(Yn)})(vt,"string");return wd(gn)=="symbol"?gn:gn+""}var sc=(function(){return vt=function On(){(function(Kr,Vr){if(!(Kr instanceof Vr))throw new TypeError("Cannot call a class as a function")})(this,On)},(gn=[{key:"astify",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,Vr=this.parse(On,Kr);return Vr&&Vr.ast}},{key:"sqlify",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t;return ln(Kr),Of(On)}},{key:"exprToSQL",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t;return ln(Kr),no(On)}},{key:"columnsToSQL",value:function(On,Kr){var Vr=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t;if(ln(Vr),!On||On==="*")return[];var us=i0(Kr);return On.map((function(Ds){return op(Ds,us)}))}},{key:"parse",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,Vr=Kr.database,us=Vr===void 0?"mysql":Vr;ln(Kr);var Ds=us.toLowerCase();if(Ap[Ds])return Ap[Ds](Kr.trimQuery===!1?On:On.trim(),Kr.parseOptions||t.parseOptions);throw new Error("".concat(us," is not supported currently"))}},{key:"whiteListCheck",value:function(On,Kr){var Vr=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t;if(Kr&&Kr.length!==0){var us=Vr.type,Ds=us===void 0?"table":us;if(!this["".concat(Ds,"List")]||typeof this["".concat(Ds,"List")]!="function")throw new Error("".concat(Ds," is not valid check mode"));var Os,lo=this["".concat(Ds,"List")].bind(this),ho=lo(On,Vr),Oo=!0,ui="",ri=_p(ho);try{for(ri.s();!(Os=ri.n()).done;){var Oi,Wi=Os.value,mi=!1,Zi=_p(Kr);try{for(Zi.s();!(Oi=Zi.n()).done;){var Bi=Oi.value,_a=new RegExp("^".concat(Bi,"$"),"i");if(_a.test(Wi)){mi=!0;break}}}catch(ga){Zi.e(ga)}finally{Zi.f()}if(!mi){ui=Wi,Oo=!1;break}}}catch(ga){ri.e(ga)}finally{ri.f()}if(!Oo)throw new Error("authority = '".concat(ui,"' is required in ").concat(Ds," whiteList to execute SQL = '").concat(On,"'"))}}},{key:"tableList",value:function(On,Kr){var Vr=this.parse(On,Kr);return Vr&&Vr.tableList}},{key:"columnList",value:function(On,Kr){var Vr=this.parse(On,Kr);return Vr&&Vr.columnList}}])&&k0(vt.prototype,gn),Yn&&k0(vt,Yn),Object.defineProperty(vt,"prototype",{writable:!1}),vt;var vt,gn,Yn})();function zd(vt){return(zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}(typeof self>"u"?"undefined":zd(self))==="object"&&self&&(self.NodeSQLParser={Parser:sc,util:h}),typeof global>"u"&&(typeof window>"u"?"undefined":zd(window))==="object"&&window&&(window.global=window),(typeof global>"u"?"undefined":zd(global))==="object"&&global&&global.window&&(global.window.NodeSQLParser={Parser:sc,util:h})}]))});import{register as
|
|
209
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Vr,us=!0,Ds=!1;return{s:function(){Yn=Yn.call(vt)},n:function(){var Os=Yn.next();return us=Os.done,Os},e:function(Os){Ds=!0,Vr=Os},f:function(){try{us||Yn.return==null||Yn.return()}finally{if(Ds)throw Vr}}}}function Bp(vt,gn){(gn==null||gn>vt.length)&&(gn=vt.length);for(var Yn=0,On=Array(gn);Yn<gn;Yn++)On[Yn]=vt[Yn];return On}function k0(vt,gn){for(var Yn=0;Yn<gn.length;Yn++){var On=gn[Yn];On.enumerable=On.enumerable||!1,On.configurable=!0,"value"in On&&(On.writable=!0),Object.defineProperty(vt,Cd(On.key),On)}}function Cd(vt){var gn=(function(Yn,On){if(wd(Yn)!="object"||!Yn)return Yn;var Kr=Yn[Symbol.toPrimitive];if(Kr!==void 0){var Vr=Kr.call(Yn,On||"default");if(wd(Vr)!="object")return Vr;throw new TypeError("@@toPrimitive must return a primitive value.")}return(On==="string"?String:Number)(Yn)})(vt,"string");return wd(gn)=="symbol"?gn:gn+""}var sc=(function(){return vt=function On(){(function(Kr,Vr){if(!(Kr instanceof Vr))throw new TypeError("Cannot call a class as a function")})(this,On)},(gn=[{key:"astify",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,Vr=this.parse(On,Kr);return Vr&&Vr.ast}},{key:"sqlify",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t;return ln(Kr),Of(On)}},{key:"exprToSQL",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t;return ln(Kr),no(On)}},{key:"columnsToSQL",value:function(On,Kr){var Vr=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t;if(ln(Vr),!On||On==="*")return[];var us=i0(Kr);return On.map((function(Ds){return op(Ds,us)}))}},{key:"parse",value:function(On){var Kr=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,Vr=Kr.database,us=Vr===void 0?"mysql":Vr;ln(Kr);var Ds=us.toLowerCase();if(Ap[Ds])return Ap[Ds](Kr.trimQuery===!1?On:On.trim(),Kr.parseOptions||t.parseOptions);throw new Error("".concat(us," is not supported currently"))}},{key:"whiteListCheck",value:function(On,Kr){var Vr=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t;if(Kr&&Kr.length!==0){var us=Vr.type,Ds=us===void 0?"table":us;if(!this["".concat(Ds,"List")]||typeof this["".concat(Ds,"List")]!="function")throw new Error("".concat(Ds," is not valid check mode"));var Os,lo=this["".concat(Ds,"List")].bind(this),ho=lo(On,Vr),Oo=!0,ui="",ri=_p(ho);try{for(ri.s();!(Os=ri.n()).done;){var Oi,Wi=Os.value,mi=!1,Zi=_p(Kr);try{for(Zi.s();!(Oi=Zi.n()).done;){var Bi=Oi.value,_a=new RegExp("^".concat(Bi,"$"),"i");if(_a.test(Wi)){mi=!0;break}}}catch(ga){Zi.e(ga)}finally{Zi.f()}if(!mi){ui=Wi,Oo=!1;break}}}catch(ga){ri.e(ga)}finally{ri.f()}if(!Oo)throw new Error("authority = '".concat(ui,"' is required in ").concat(Ds," whiteList to execute SQL = '").concat(On,"'"))}}},{key:"tableList",value:function(On,Kr){var Vr=this.parse(On,Kr);return Vr&&Vr.tableList}},{key:"columnList",value:function(On,Kr){var Vr=this.parse(On,Kr);return Vr&&Vr.columnList}}])&&k0(vt.prototype,gn),Yn&&k0(vt,Yn),Object.defineProperty(vt,"prototype",{writable:!1}),vt;var vt,gn,Yn})();function zd(vt){return(zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(gn){return typeof gn}:function(gn){return gn&&typeof Symbol=="function"&&gn.constructor===Symbol&&gn!==Symbol.prototype?"symbol":typeof gn})(vt)}(typeof self>"u"?"undefined":zd(self))==="object"&&self&&(self.NodeSQLParser={Parser:sc,util:h}),typeof global>"u"&&(typeof window>"u"?"undefined":zd(window))==="object"&&window&&(window.global=window),(typeof global>"u"?"undefined":zd(global))==="object"&&global&&global.window&&(global.window.NodeSQLParser={Parser:sc,util:h})}]))});import{register as gJ}from"node:module";import{register as yJ}from"tsx/esm/api";function RO(n,r,f){let h=n.indexOf(r);if(h===-1)return n;let l=r.length,t=0,$="";do $+=n.slice(t,h)+r+f,t=h+l,h=n.indexOf(r,t);while(h!==-1);return $+=n.slice(t),$}function NO(n,r,f,h){let l=0,t="";do{let $=n[h-1]==="\r";t+=n.slice(l,$?h-1:h)+r+($?`\r
|
|
210
210
|
`:`
|
|
211
211
|
`)+f,l=h+1,h=n.indexOf(`
|
|
212
|
-
`,l)}while(h!==-1);return t+=n.slice(l),t}var OO=(n=0)=>r=>`\x1B[${r+n}m`,vS=(n=0)=>r=>`\x1B[${38+n};5;${r}m`,mS=(n=0)=>(r,f,h)=>`\x1B[${38+n};2;${r};${f};${h}m`,u7=n=>`\x1B[58;5;${n<90?n-30:n-90+8}m`,hv={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}},
|
|
213
|
-
`);return t!==-1&&(r=NO(r,l,h,t)),h+r+l};Object.defineProperties(sw.prototype,{...rw,level:g7});var A7=sw(),$J=sw({level:jO?jO.level:0});var Xs=A7;import{join as $_,resolve as JM}from"node:path";var O2=nh(ih(),1);import{readFileSync as k2,existsSync as X9}from"node:fs";import{resolve as N2,dirname as R2}from"node:path";import{pathToFileURL as Q9}from"node:url";var $2={srcDir:"src",designDir:"design",docsDir:"docs",specsDir:"specs"},D2=["speckeeper.config.yaml","speckeeper.config.yml","speckeeper.config.json","speckeeper.config.ts","speckeeper.config.js"];function t1(n=process.cwd()){let r=n;for(;r!==R2(r);){for(let f of D2){let h=N2(r,f);if(X9(h))return h}r=R2(r)}return null}function e1(n,r){if(n===null||typeof n!="object"||Array.isArray(n))throw new Error(`Config at ${r} must export an object, received ${n===null?"null":typeof n}`);return{...$2,...n}}async function nm(n,r=process.cwd()){let f=n!==void 0?N2(r,n):t1(r);if(!f)return{...$2};let h=f.split(".").pop()?.toLowerCase();try{if(h==="yaml"||h==="yml"){let l=k2(f,"utf-8");return e1((0,O2.parse)(l),f)}if(h==="json"){let l=k2(f,"utf-8");return e1(JSON.parse(l),f)}if(h==="ts"||h==="js"){let l=await import(Q9(f).href);return e1(l.default??l,f)}}catch(l){throw new Error(`Failed to load config from ${f}: ${l instanceof Error?l.message:String(l)}`,{cause:l})}throw new Error(`Unsupported config file extension: ${f}. Supported extensions: ${D2.map(l=>l.split(".").pop()).join(", ")}`)}import{writeFileSync as K8,mkdirSync as J8,existsSync as qD,readFileSync as X8}from"node:fs";import{dirname as Q8,join as jQ}from"node:path";import{fileURLToPath as n8}from"node:url";import{posix as i8,win32 as f1}from"node:path";import{fileURLToPath as a8}from"node:url";import{lstatSync as u8,readdir as l8,readdirSync as c8,readlinkSync as f8,realpathSync as d8}from"fs";import*as p8 from"node:fs";import{lstat as b8,readdir as v8,readlink as m8,realpath as h8}from"node:fs/promises";import{EventEmitter as b1}from"node:events";import wD from"node:stream";import{StringDecoder as g8}from"node:string_decoder";var sD=(n,r,f)=>{let h=n instanceof RegExp?U2(n,f):n,l=r instanceof RegExp?U2(r,f):r,t=h!==null&&l!=null&&eG(h,l,f);return t&&{start:t[0],end:t[1],pre:f.slice(0,t[0]),body:f.slice(t[0]+h.length,t[1]),post:f.slice(t[1]+l.length)}},U2=(n,r)=>{let f=r.match(n);return f?f[0]:null},eG=(n,r,f)=>{let h,l,t,$,re,e=f.indexOf(n),qe=f.indexOf(r,e+1),ht=e;if(e>=0&&qe>0){if(n===r)return[e,qe];for(h=[],t=f.length;ht>=0&&!re;){if(ht===e)h.push(ht),e=f.indexOf(n,ht+1);else if(h.length===1){let Ke=h.pop();Ke!==void 0&&(re=[Ke,qe])}else l=h.pop(),l!==void 0&&l<t&&(t=l,$=qe),qe=f.indexOf(r,ht+1);ht=e<qe&&e>=0?e:qe}h.length&&$!==void 0&&(re=[t,$])}return re},oD="\0SLASH"+Math.random()+"\0",iD="\0OPEN"+Math.random()+"\0",d1="\0CLOSE"+Math.random()+"\0",aD="\0COMMA"+Math.random()+"\0",uD="\0PERIOD"+Math.random()+"\0",tG=new RegExp(oD,"g"),nG=new RegExp(iD,"g"),rG=new RegExp(d1,"g"),sG=new RegExp(aD,"g"),oG=new RegExp(uD,"g"),iG=/\\\\/g,aG=/\\{/g,uG=/\\}/g,lG=/\\,/g,cG=/\\./g,fG=1e5;function n1(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function dG(n){return n.replace(iG,oD).replace(aG,iD).replace(uG,d1).replace(lG,aD).replace(cG,uD)}function pG(n){return n.replace(tG,"\\").replace(nG,"{").replace(rG,"}").replace(sG,",").replace(oG,".")}function lD(n){if(!n)return[""];let r=[],f=sD("{","}",n);if(!f)return n.split(",");let{pre:h,body:l,post:t}=f,$=h.split(",");$[$.length-1]+="{"+l+"}";let re=lD(t);return t.length&&($[$.length-1]+=re.shift(),$.push.apply($,re)),r.push.apply(r,$),r}function bG(n,r={}){if(!n)return[];let{max:f=fG}=r;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),zw(dG(n),f,!0).map(pG)}function vG(n){return"{"+n+"}"}function mG(n){return/^-?0\d/.test(n)}function hG(n,r){return n<=r}function gG(n,r){return n>=r}function zw(n,r,f){let h=[],l=sD("{","}",n);if(!l)return[n];let t=l.pre,$=l.post.length?zw(l.post,r,!1):[""];if(/\$$/.test(l.pre))for(let re=0;re<$.length&&re<r;re++){let e=t+"{"+l.body+"}"+$[re];h.push(e)}else{let re=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),e=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),qe=re||e,ht=l.body.indexOf(",")>=0;if(!qe&&!ht)return l.post.match(/,(?!,).*\}/)?(n=l.pre+"{"+l.body+d1+l.post,zw(n,r,!0)):[n];let Ke;if(qe)Ke=l.body.split(/\.\./);else if(Ke=lD(l.body),Ke.length===1&&Ke[0]!==void 0&&(Ke=zw(Ke[0],r,!1).map(vG),Ke.length===1))return $.map(ln=>l.pre+Ke[0]+ln);let gt;if(qe&&Ke[0]!==void 0&&Ke[1]!==void 0){let ln=n1(Ke[0]),Qn=n1(Ke[1]),bn=Math.max(Ke[0].length,Ke[1].length),zr=Ke.length===3&&Ke[2]!==void 0?Math.abs(n1(Ke[2])):1,tr=hG;Qn<ln&&(zr*=-1,tr=gG);let Er=Ke.some(mG);gt=[];for(let cs=ln;tr(cs,Qn);cs+=zr){let Ys;if(e)Ys=String.fromCharCode(cs),Ys==="\\"&&(Ys="");else if(Ys=String(cs),Er){let ao=bn-Ys.length;if(ao>0){let uo=new Array(ao+1).join("0");cs<0?Ys="-"+uo+Ys.slice(1):Ys=uo+Ys}}gt.push(Ys)}}else{gt=[];for(let ln=0;ln<Ke.length;ln++)gt.push.apply(gt,zw(Ke[ln],r,!1))}for(let ln=0;ln<gt.length;ln++)for(let Qn=0;Qn<$.length&&h.length<r;Qn++){let bn=t+gt[ln]+$[Qn];(!f||qe||bn)&&h.push(bn)}}return h}var yE=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},yG={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Dw=n=>n.replace(/[[\]\\-]/g,"\\$&"),wG=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),P2=n=>n.join(""),CG=(n,r)=>{let f=r;if(n.charAt(f)!=="[")throw new Error("not in a brace expression");let h=[],l=[],t=f+1,$=!1,re=!1,e=!1,qe=!1,ht=f,Ke="";e:for(;t<n.length;){let Qn=n.charAt(t);if((Qn==="!"||Qn==="^")&&t===f+1){qe=!0,t++;continue}if(Qn==="]"&&$&&!e){ht=t+1;break}if($=!0,Qn==="\\"&&!e){e=!0,t++;continue}if(Qn==="["&&!e){for(let[bn,[zr,tr,Er]]of Object.entries(yG))if(n.startsWith(bn,t)){if(Ke)return["$.",!1,n.length-f,!0];t+=bn.length,Er?l.push(zr):h.push(zr),re=re||tr;continue e}}if(e=!1,Ke){Qn>Ke?h.push(Dw(Ke)+"-"+Dw(Qn)):Qn===Ke&&h.push(Dw(Qn)),Ke="",t++;continue}if(n.startsWith("-]",t+1)){h.push(Dw(Qn+"-")),t+=2;continue}if(n.startsWith("-",t+1)){Ke=Qn,t+=2;continue}h.push(Dw(Qn)),t++}if(ht<t)return["",!1,0,!1];if(!h.length&&!l.length)return["$.",!1,n.length-f,!0];if(l.length===0&&h.length===1&&/^\\?.$/.test(h[0])&&!qe){let Qn=h[0].length===2?h[0].slice(-1):h[0];return[wG(Qn),!1,ht-f,!1]}let gt="["+(qe?"^":"")+P2(h)+"]",ln="["+(qe?"":"^")+P2(l)+"]";return[h.length&&l.length?"("+gt+"|"+ln+")":h.length?gt:ln,re,ht-f,!0]},ty=(n,{windowsPathsNoEscape:r=!1,magicalBraces:f=!0}={})=>f?r?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):r?n.replace(/\[([^\/\\{}])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),LG=new Set(["!","?","+","*","@"]),M2=n=>LG.has(n),EG="(?!(?:^|/)\\.\\.?(?:$|/))",lE="(?!\\.)",AG=new Set(["[","."]),_G=new Set(["..","."]),SG=new Set("().*{}+?[]^$\\!"),IG=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),p1="[^/]",j2=p1+"*?",F2=p1+"+?",cD=class $m{type;#e;#n;#o=!1;#s=[];#i;#w;#h;#c=!1;#a;#d;#f=!1;constructor(r,f,h={}){this.type=r,r&&(this.#n=!0),this.#i=f,this.#e=this.#i?this.#i.#e:this,this.#a=this.#e===this?h:this.#e.#a,this.#h=this.#e===this?[]:this.#e.#h,r==="!"&&!this.#e.#c&&this.#h.push(this),this.#w=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let r of this.#s)if(typeof r!="string"&&(r.type||r.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#s.map(r=>String(r)).join("|")+")":this.#d=this.#s.map(r=>String(r)).join("")}#u(){if(this!==this.#e)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let r;for(;r=this.#h.pop();){if(r.type!=="!")continue;let f=r,h=f.#i;for(;h;){for(let l=f.#w+1;!h.type&&l<h.#s.length;l++)for(let t of r.#s){if(typeof t=="string")throw new Error("string part in extglob AST??");t.copyIn(h.#s[l])}f=h,h=f.#i}}return this}push(...r){for(let f of r)if(f!==""){if(typeof f!="string"&&!(f instanceof $m&&f.#i===this))throw new Error("invalid part: "+f);this.#s.push(f)}}toJSON(){let r=this.type===null?this.#s.slice().map(f=>typeof f=="string"?f:f.toJSON()):[this.type,...this.#s.map(f=>f.toJSON())];return this.isStart()&&!this.type&&r.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#c&&this.#i?.type==="!")&&r.push({}),r}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#w===0)return!0;let r=this.#i;for(let f=0;f<this.#w;f++){let h=r.#s[f];if(!(h instanceof $m&&h.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let r=this.#i?this.#i.#s.length:0;return this.#w===r-1}copyIn(r){typeof r=="string"?this.push(r):this.push(r.clone(this))}clone(r){let f=new $m(this.type,r);for(let h of this.#s)f.copyIn(h);return f}static#r(r,f,h,l){let t=!1,$=!1,re=-1,e=!1;if(f.type===null){let ln=h,Qn="";for(;ln<r.length;){let bn=r.charAt(ln++);if(t||bn==="\\"){t=!t,Qn+=bn;continue}if($){ln===re+1?(bn==="^"||bn==="!")&&(e=!0):bn==="]"&&!(ln===re+2&&e)&&($=!1),Qn+=bn;continue}else if(bn==="["){$=!0,re=ln,e=!1,Qn+=bn;continue}if(!l.noext&&M2(bn)&&r.charAt(ln)==="("){f.push(Qn),Qn="";let zr=new $m(bn,f);ln=$m.#r(r,zr,ln,l),f.push(zr);continue}Qn+=bn}return f.push(Qn),ln}let qe=h+1,ht=new $m(null,f),Ke=[],gt="";for(;qe<r.length;){let ln=r.charAt(qe++);if(t||ln==="\\"){t=!t,gt+=ln;continue}if($){qe===re+1?(ln==="^"||ln==="!")&&(e=!0):ln==="]"&&!(qe===re+2&&e)&&($=!1),gt+=ln;continue}else if(ln==="["){$=!0,re=qe,e=!1,gt+=ln;continue}if(M2(ln)&&r.charAt(qe)==="("){ht.push(gt),gt="";let Qn=new $m(ln,ht);ht.push(Qn),qe=$m.#r(r,Qn,qe,l);continue}if(ln==="|"){ht.push(gt),gt="",Ke.push(ht),ht=new $m(null,f);continue}if(ln===")")return gt===""&&f.#s.length===0&&(f.#f=!0),ht.push(gt),gt="",f.push(...Ke,ht),qe;gt+=ln}return f.type=null,f.#n=void 0,f.#s=[r.substring(h-1)],qe}static fromGlob(r,f={}){let h=new $m(null,void 0,f);return $m.#r(r,h,0,f),h}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let r=this.toString(),[f,h,l,t]=this.toRegExpSource();if(!(l||this.#n||this.#a.nocase&&!this.#a.nocaseMagicOnly&&r.toUpperCase()!==r.toLowerCase()))return h;let $=(this.#a.nocase?"i":"")+(t?"u":"");return Object.assign(new RegExp(`^${f}$`,$),{_src:f,_glob:r})}get options(){return this.#a}toRegExpSource(r){let f=r??!!this.#a.dot;if(this.#e===this&&this.#u(),!this.type){let e=this.isStart()&&this.isEnd()&&!this.#s.some(gt=>typeof gt!="string"),qe=this.#s.map(gt=>{let[ln,Qn,bn,zr]=typeof gt=="string"?$m.#C(gt,this.#n,e):gt.toRegExpSource(r);return this.#n=this.#n||bn,this.#o=this.#o||zr,ln}).join(""),ht="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&_G.has(this.#s[0]))){let gt=AG,ln=f&>.has(qe.charAt(0))||qe.startsWith("\\.")&>.has(qe.charAt(2))||qe.startsWith("\\.\\.")&>.has(qe.charAt(4)),Qn=!f&&!r&>.has(qe.charAt(0));ht=ln?EG:Qn?lE:""}let Ke="";return this.isEnd()&&this.#e.#c&&this.#i?.type==="!"&&(Ke="(?:$|\\/)"),[ht+qe+Ke,ty(qe),this.#n=!!this.#n,this.#o]}let h=this.type==="*"||this.type==="+",l=this.type==="!"?"(?:(?!(?:":"(?:",t=this.#p(f);if(this.isStart()&&this.isEnd()&&!t&&this.type!=="!"){let e=this.toString();return this.#s=[e],this.type=null,this.#n=void 0,[e,ty(this.toString()),!1,!1]}let $=!h||r||f||!lE?"":this.#p(!0);$===t&&($=""),$&&(t=`(?:${t})(?:${$})*?`);let re="";if(this.type==="!"&&this.#f)re=(this.isStart()&&!f?lE:"")+F2;else{let e=this.type==="!"?"))"+(this.isStart()&&!f&&!r?lE:"")+j2+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&$?")":this.type==="*"&&$?")?":`)${this.type}`;re=l+t+e}return[re,ty(t),this.#n=!!this.#n,this.#o]}#p(r){return this.#s.map(f=>{if(typeof f=="string")throw new Error("string type in extglob ast??");let[h,l,t,$]=f.toRegExpSource(r);return this.#o=this.#o||$,h}).filter(f=>!(this.isStart()&&this.isEnd())||!!f).join("|")}static#C(r,f,h=!1){let l=!1,t="",$=!1,re=!1;for(let e=0;e<r.length;e++){let qe=r.charAt(e);if(l){l=!1,t+=(SG.has(qe)?"\\":"")+qe;continue}if(qe==="*"){if(re)continue;re=!0,t+=h&&/^[*]+$/.test(r)?F2:j2,f=!0;continue}else re=!1;if(qe==="\\"){e===r.length-1?t+="\\\\":l=!0;continue}if(qe==="["){let[ht,Ke,gt,ln]=CG(r,e);if(gt){t+=ht,$=$||Ke,e+=gt-1,f=f||ln;continue}}if(qe==="?"){t+=p1,f=!0;continue}t+=IG(qe)}return[t,ty(r),!!f,$]}},fD=(n,{windowsPathsNoEscape:r=!1,magicalBraces:f=!1}={})=>f?r?n.replace(/[?*()[\]{}]/g,"[$&]"):n.replace(/[?*()[\]\\{}]/g,"\\$&"):r?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),mm=(n,r,f={})=>(yE(r),!f.nocomment&&r.charAt(0)==="#"?!1:new Kh(r,f).match(n)),TG=/^\*+([^+@!?\*\[\(]*)$/,xG=n=>r=>!r.startsWith(".")&&r.endsWith(n),kG=n=>r=>r.endsWith(n),RG=n=>(n=n.toLowerCase(),r=>!r.startsWith(".")&&r.toLowerCase().endsWith(n)),NG=n=>(n=n.toLowerCase(),r=>r.toLowerCase().endsWith(n)),OG=/^\*+\.\*+$/,$G=n=>!n.startsWith(".")&&n.includes("."),DG=n=>n!=="."&&n!==".."&&n.includes("."),UG=/^\.\*+$/,PG=n=>n!=="."&&n!==".."&&n.startsWith("."),MG=/^\*+$/,jG=n=>n.length!==0&&!n.startsWith("."),FG=n=>n.length!==0&&n!=="."&&n!=="..",zG=/^\?+([^+@!?\*\[\(]*)?$/,GG=([n,r=""])=>{let f=dD([n]);return r?(r=r.toLowerCase(),h=>f(h)&&h.toLowerCase().endsWith(r)):f},BG=([n,r=""])=>{let f=pD([n]);return r?(r=r.toLowerCase(),h=>f(h)&&h.toLowerCase().endsWith(r)):f},qG=([n,r=""])=>{let f=pD([n]);return r?h=>f(h)&&h.endsWith(r):f},VG=([n,r=""])=>{let f=dD([n]);return r?h=>f(h)&&h.endsWith(r):f},dD=([n])=>{let r=n.length;return f=>f.length===r&&!f.startsWith(".")},pD=([n])=>{let r=n.length;return f=>f.length===r&&f!=="."&&f!==".."},bD=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",z2={win32:{sep:"\\"},posix:{sep:"/"}},HG=bD==="win32"?z2.win32.sep:z2.posix.sep;mm.sep=HG;var vm=Symbol("globstar **");mm.GLOBSTAR=vm;var YG="[^/]",WG=YG+"*?",ZG="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",KG="(?:(?!(?:\\/|^)\\.).)*?",JG=(n,r={})=>f=>mm(f,n,r);mm.filter=JG;var Fm=(n,r={})=>Object.assign({},n,r),XG=n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return mm;let r=mm;return Object.assign((f,h,l={})=>r(f,h,Fm(n,l)),{Minimatch:class extends r.Minimatch{constructor(f,h={}){super(f,Fm(n,h))}static defaults(f){return r.defaults(Fm(n,f)).Minimatch}},AST:class extends r.AST{constructor(f,h,l={}){super(f,h,Fm(n,l))}static fromGlob(f,h={}){return r.AST.fromGlob(f,Fm(n,h))}},unescape:(f,h={})=>r.unescape(f,Fm(n,h)),escape:(f,h={})=>r.escape(f,Fm(n,h)),filter:(f,h={})=>r.filter(f,Fm(n,h)),defaults:f=>r.defaults(Fm(n,f)),makeRe:(f,h={})=>r.makeRe(f,Fm(n,h)),braceExpand:(f,h={})=>r.braceExpand(f,Fm(n,h)),match:(f,h,l={})=>r.match(f,h,Fm(n,l)),sep:r.sep,GLOBSTAR:vm})};mm.defaults=XG;var vD=(n,r={})=>(yE(n),r.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:bG(n,{max:r.braceExpandMax}));mm.braceExpand=vD;var QG=(n,r={})=>new Kh(n,r).makeRe();mm.makeRe=QG;var e8=(n,r,f={})=>{let h=new Kh(r,f);return n=n.filter(l=>h.match(l)),h.options.nonull&&!n.length&&n.push(r),n};mm.match=e8;var G2=/[?*]|[+@!]\(.*?\)|\[|\]/,t8=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Kh=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(n,r={}){yE(n),r=r||{},this.options=r,this.pattern=n,this.platform=r.platform||bD,this.isWindows=this.platform==="win32";let f="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[f]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let n of this.set)for(let r of n)if(typeof r!="string")return!0;return!1}debug(...n){}make(){let n=this.pattern,r=this.options;if(!r.nocomment&&n.charAt(0)==="#"){this.comment=!0;return}if(!n){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...l)=>console.error(...l)),this.debug(this.pattern,this.globSet);let f=this.globSet.map(l=>this.slashSplit(l));this.globParts=this.preprocess(f),this.debug(this.pattern,this.globParts);let h=this.globParts.map((l,t,$)=>{if(this.isWindows&&this.windowsNoMagicRoot){let re=l[0]===""&&l[1]===""&&(l[2]==="?"||!G2.test(l[2]))&&!G2.test(l[3]),e=/^[a-z]:/i.test(l[0]);if(re)return[...l.slice(0,4),...l.slice(4).map(qe=>this.parse(qe))];if(e)return[l[0],...l.slice(1).map(qe=>this.parse(qe))]}return l.map(re=>this.parse(re))});if(this.debug(this.pattern,h),this.set=h.filter(l=>l.indexOf(!1)===-1),this.isWindows)for(let l=0;l<this.set.length;l++){let t=this.set[l];t[0]===""&&t[1]===""&&this.globParts[l][2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3])&&(t[2]="?")}this.debug(this.pattern,this.set)}preprocess(n){if(this.options.noglobstar)for(let f=0;f<n.length;f++)for(let h=0;h<n[f].length;h++)n[f][h]==="**"&&(n[f][h]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(n=this.firstPhasePreProcess(n),n=this.secondPhasePreProcess(n)):r>=1?n=this.levelOneOptimize(n):n=this.adjascentGlobstarOptimize(n),n}adjascentGlobstarOptimize(n){return n.map(r=>{let f=-1;for(;(f=r.indexOf("**",f+1))!==-1;){let h=f;for(;r[h+1]==="**";)h++;h!==f&&r.splice(f,h-f)}return r})}levelOneOptimize(n){return n.map(r=>(r=r.reduce((f,h)=>{let l=f[f.length-1];return h==="**"&&l==="**"?f:h===".."&&l&&l!==".."&&l!=="."&&l!=="**"?(f.pop(),f):(f.push(h),f)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(n){Array.isArray(n)||(n=this.slashSplit(n));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let h=1;h<n.length-1;h++){let l=n[h];h===1&&l===""&&n[0]===""||(l==="."||l==="")&&(r=!0,n.splice(h,1),h--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let f=0;for(;(f=n.indexOf("..",f+1))!==-1;){let h=n[f-1];h&&h!=="."&&h!==".."&&h!=="**"&&(r=!0,n.splice(f-1,2),f-=2)}}while(r);return n.length===0?[""]:n}firstPhasePreProcess(n){let r=!1;do{r=!1;for(let f of n){let h=-1;for(;(h=f.indexOf("**",h+1))!==-1;){let t=h;for(;f[t+1]==="**";)t++;t>h&&f.splice(h+1,t-h);let $=f[h+1],re=f[h+2],e=f[h+3];if($!==".."||!re||re==="."||re===".."||!e||e==="."||e==="..")continue;r=!0,f.splice(h,1);let qe=f.slice(0);qe[h]="**",n.push(qe),h--}if(!this.preserveMultipleSlashes){for(let t=1;t<f.length-1;t++){let $=f[t];t===1&&$===""&&f[0]===""||($==="."||$==="")&&(r=!0,f.splice(t,1),t--)}f[0]==="."&&f.length===2&&(f[1]==="."||f[1]==="")&&(r=!0,f.pop())}let l=0;for(;(l=f.indexOf("..",l+1))!==-1;){let t=f[l-1];if(t&&t!=="."&&t!==".."&&t!=="**"){r=!0;let $=l===1&&f[l+1]==="**"?["."]:[];f.splice(l-1,2,...$),f.length===0&&f.push(""),l-=2}}}}while(r);return n}secondPhasePreProcess(n){for(let r=0;r<n.length-1;r++)for(let f=r+1;f<n.length;f++){let h=this.partsMatch(n[r],n[f],!this.preserveMultipleSlashes);if(h){n[r]=[],n[f]=h;break}}return n.filter(r=>r.length)}partsMatch(n,r,f=!1){let h=0,l=0,t=[],$="";for(;h<n.length&&l<r.length;)if(n[h]===r[l])t.push($==="b"?r[l]:n[h]),h++,l++;else if(f&&n[h]==="**"&&r[l]===n[h+1])t.push(n[h]),h++;else if(f&&r[l]==="**"&&n[h]===r[l+1])t.push(r[l]),l++;else if(n[h]==="*"&&r[l]&&(this.options.dot||!r[l].startsWith("."))&&r[l]!=="**"){if($==="b")return!1;$="a",t.push(n[h]),h++,l++}else if(r[l]==="*"&&n[h]&&(this.options.dot||!n[h].startsWith("."))&&n[h]!=="**"){if($==="a")return!1;$="b",t.push(r[l]),h++,l++}else return!1;return n.length===r.length&&t}parseNegate(){if(this.nonegate)return;let n=this.pattern,r=!1,f=0;for(let h=0;h<n.length&&n.charAt(h)==="!";h++)r=!r,f++;f&&(this.pattern=n.slice(f)),this.negate=r}matchOne(n,r,f=!1){let h=this.options;if(this.isWindows){let Qn=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),bn=!Qn&&n[0]===""&&n[1]===""&&n[2]==="?"&&/^[a-z]:$/i.test(n[3]),zr=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),tr=!zr&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),Er=bn?3:Qn?0:void 0,cs=tr?3:zr?0:void 0;if(typeof Er=="number"&&typeof cs=="number"){let[Ys,ao]=[n[Er],r[cs]];Ys.toLowerCase()===ao.toLowerCase()&&(r[cs]=Ys,cs>Er?r=r.slice(cs):Er>cs&&(n=n.slice(Er)))}}let{optimizationLevel:l=1}=this.options;l>=2&&(n=this.levelTwoFileOptimize(n)),this.debug("matchOne",this,{file:n,pattern:r}),this.debug("matchOne",n.length,r.length);for(var t=0,$=0,re=n.length,e=r.length;t<re&&$<e;t++,$++){this.debug("matchOne loop");var qe=r[$],ht=n[t];if(this.debug(r,qe,ht),qe===!1)return!1;if(qe===vm){this.debug("GLOBSTAR",[r,qe,ht]);var Ke=t,gt=$+1;if(gt===e){for(this.debug("** at the end");t<re;t++)if(n[t]==="."||n[t]===".."||!h.dot&&n[t].charAt(0)===".")return!1;return!0}for(;Ke<re;){var ln=n[Ke];if(this.debug(`
|
|
212
|
+
`,l)}while(h!==-1);return t+=n.slice(l),t}var OO=(n=0)=>r=>`\x1B[${r+n}m`,vS=(n=0)=>r=>`\x1B[${38+n};5;${r}m`,mS=(n=0)=>(r,f,h)=>`\x1B[${38+n};2;${r};${f};${h}m`,u7=n=>`\x1B[58;5;${n<90?n-30:n-90+8}m`,hv={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}},AJ=Object.keys(hv.modifier),l7=Object.keys(hv.color),c7=Object.keys(hv.bgColor),_J=Object.keys(hv.underlineColor),SJ=[...l7,...c7];function f7(){let n=new Map;for(let[r,f]of Object.entries(hv)){for(let[h,l]of Object.entries(f))hv[h]={open:`\x1B[${l[0]}m`,close:`\x1B[${l[1]}m`},f[h]=hv[h],n.set(Number.parseInt(l[0],10),l[1]);Object.defineProperty(hv,r,{value:f,enumerable:!1})}return Object.defineProperty(hv,"codes",{value:n,enumerable:!1}),hv.color.close="\x1B[39m",hv.bgColor.close="\x1B[49m",hv.underlineColor.close="\x1B[59m",hv.color.ansi=OO(),hv.color.ansi256=vS(),hv.color.ansi16m=mS(),hv.bgColor.ansi=OO(10),hv.bgColor.ansi256=vS(10),hv.bgColor.ansi16m=mS(10),hv.underlineColor.ansi=u7,hv.underlineColor.ansi256=vS(20),hv.underlineColor.ansi16m=mS(20),Object.defineProperties(hv,{rgbToAnsi256:{value(r,f,h){return r===f&&f===h?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(f/255*5)+Math.round(h/255*5)},enumerable:!1},hexToRgb:{value(r){let f=/[\da-f]{6}|[\da-f]{3}/i.exec(r.toString(16));if(!f)return[0,0,0];let[h]=f;h.length===3&&(h=[...h].map(t=>t+t).join(""));let l=Number.parseInt(h,16);return[l>>16&255,l>>8&255,l&255]},enumerable:!1},hexToAnsi256:{value:r=>hv.rgbToAnsi256(...hv.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let f,h,l;if(r>=232)f=((r-232)*10+8)/255,h=f,l=f;else{r-=16;let re=r%36;f=Math.floor(r/36)/5,h=Math.floor(re/6)/5,l=re%6/5}let t=Math.max(f,h,l)*2;if(t===0)return 30;let $=30+(Math.round(l)<<2|Math.round(h)<<1|Math.round(f));return t===2&&($+=60),$},enumerable:!1},rgbToAnsi:{value:(r,f,h)=>hv.ansi256ToAnsi(hv.rgbToAnsi256(r,f,h)),enumerable:!1},hexToAnsi:{value:r=>hv.ansi256ToAnsi(hv.hexToAnsi256(r)),enumerable:!1}}),hv}var d7=f7(),rh=d7;import hS from"node:process";import p7 from"node:os";import $O from"node:tty";function Mm(n,r=globalThis.Deno?globalThis.Deno.args:hS.argv){let f=n.startsWith("-")?"":n.length===1?"-":"--",h=r.indexOf(f+n),l=r.indexOf("--");return h!==-1&&(l===-1||h<l)}var{env:Pv}=hS,uL;Mm("no-color")||Mm("no-colors")||Mm("color=false")||Mm("color=never")?uL=0:(Mm("color")||Mm("colors")||Mm("color=true")||Mm("color=always"))&&(uL=1);function UO(){return/^\d+$/.test(Pv.FORCE_COLOR)}function b7(){if("FORCE_COLOR"in Pv){if(Pv.FORCE_COLOR==="false")return 0;if(Pv.FORCE_COLOR==="true"||Pv.FORCE_COLOR.length===0)return 1;if(UO())return Math.min(Number.parseInt(Pv.FORCE_COLOR,10),3)}}function v7(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function m7(n,{streamIsTTY:r,sniffFlags:f=!0}={}){let h=b7();h!==void 0&&(uL=h);let l=f?uL:h;if(l===0)return 0;if(f){if(Mm("color=16m")||Mm("color=full")||Mm("color=truecolor"))return 3;if(Mm("color=256"))return 2}if(l!==void 0&&UO())return l;if("TF_BUILD"in Pv&&"AGENT_NAME"in Pv)return 1;if(n&&!r&&l===void 0)return 0;let t=l||0;if(Pv.TERM==="dumb")return t;if(hS.platform==="win32"){let $=p7.release().split(".");return Number($[0])>=10&&Number($[2])>=10586?Number($[2])>=14931?3:2:1}if("CI"in Pv)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some($=>$ in Pv)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some($=>$ in Pv)||Pv.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Pv)return/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(Pv.TEAMCITY_VERSION)?1:0;if(Pv.COLORTERM==="truecolor"||Pv.TERM==="xterm-kitty"||Pv.TERM==="xterm-ghostty"||Pv.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Pv){let $=Number.parseInt((Pv.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(Pv.TERM_PROGRAM){case"iTerm.app":return $>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(Pv.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Pv.TERM)||"COLORTERM"in Pv?1:t}function DO(n,r={}){let f=m7(n,{streamIsTTY:n&&n.isTTY,...r});return v7(f)}var h7={stdout:DO({isTTY:$O.isatty(1)}),stderr:DO({isTTY:$O.isatty(2)})},PO=h7;var{stdout:MO,stderr:jO}=PO,tw=Symbol("GENERATOR"),nw=Symbol("STYLER"),cL=Symbol("IS_EMPTY"),lL=Symbol("LEVEL"),rw=Object.create(null),FO=n=>{if(!Number.isSafeInteger(n)||n<0||n>3)throw new Error("The `level` should be an integer from 0 to 3")},g7={enumerable:!0,get(){return this[lL]},set(n){FO(n),this[lL]=n}},y7=(n,r={})=>{r.level!==void 0&&FO(r.level);let f=MO?MO.level:0;n[lL]=r.level===void 0?f:r.level};var w7=n=>{let r=(...f)=>f.join(" ");return y7(r,n),Object.setPrototypeOf(r,sw.prototype),r};function sw(n){return w7(n)}Object.setPrototypeOf(sw.prototype,Function.prototype);for(let[n,r]of Object.entries(rh))rw[n]={get(){let f=yS(this,zO(r.open,r.close,this[nw]),this[cL]);return Object.defineProperty(this,n,{value:f}),f}};rw.visible={get(){let n=yS(this,this[nw],!0);return Object.defineProperty(this,"visible",{value:n}),n}};var C7=(n,r)=>{let f=rh[r];if(n==="rgb"){let l=($,re,e)=>f.ansi(rh.rgbToAnsi($,re,e));return[l,l,($,re,e)=>f.ansi256(rh.rgbToAnsi256($,re,e)),f.ansi16m]}if(n==="hex"){let l=$=>f.ansi(rh.hexToAnsi($));return[l,l,$=>f.ansi256(rh.hexToAnsi256($)),$=>f.ansi16m(...rh.hexToRgb($))]}let h=l=>f.ansi(rh.ansi256ToAnsi(l));return[h,h,f.ansi256,f.ansi256]},L7=["rgb","hex","ansi256"];for(let n of L7){let r=n[0].toUpperCase()+n.slice(1);for(let[f,h]of[[n,"color"],["bg"+r,"bgColor"],["underline"+r,"underlineColor"]]){let{close:l}=rh[h],t=C7(n,h);rw[f]={get(){let $=function(re,e,qe){let ht=t[this.level](re,e,qe);return yS(this,zO(ht,l,this[nw]),this[cL])};return Object.defineProperty(this,f,{value:$}),$}}}}var E7=Object.defineProperties(()=>{},{...rw,level:{enumerable:!0,get(){return this[tw].level},set(n){this[tw].level=n}}}),zO=(n,r,f)=>{let h,l;return f===void 0?(h=n,l=r):(h=f.openAll+n,l=r+f.closeAll),{open:n,close:r,openAll:h,closeAll:l,parent:f}},yS=(n,r,f)=>{let h=(...l)=>l.length===1?gS(h,""+l[0]):l.length===2?gS(h,l[0]+" "+l[1]):gS(h,l.join(" "));return Object.setPrototypeOf(h,E7),h[tw]=n[tw]??n,h[nw]=r,h[cL]=f,h},gS=(n,r)=>{if(n[tw][lL]<=0||!r)return n[cL]?"":r;let f=n[nw];if(f===void 0)return r;let{openAll:h,closeAll:l}=f;if(r.includes("\x1B"))for(;f!==void 0;)r=RO(r,f.close,f.open),f=f.parent;let t=r.indexOf(`
|
|
213
|
+
`);return t!==-1&&(r=NO(r,l,h,t)),h+r+l};Object.defineProperties(sw.prototype,{...rw,level:g7});var A7=sw(),DJ=sw({level:jO?jO.level:0});var Xs=A7;import{join as $_,resolve as JM}from"node:path";var O2=nh(ih(),1);import{readFileSync as k2,existsSync as X9}from"node:fs";import{resolve as N2,dirname as R2}from"node:path";import{pathToFileURL as Q9}from"node:url";var $2={srcDir:"src",designDir:"design",docsDir:"docs",specsDir:"specs"},D2=["speckeeper.config.yaml","speckeeper.config.yml","speckeeper.config.json","speckeeper.config.ts","speckeeper.config.js"];function t1(n=process.cwd()){let r=n;for(;r!==R2(r);){for(let f of D2){let h=N2(r,f);if(X9(h))return h}r=R2(r)}return null}function e1(n,r){if(n===null||typeof n!="object"||Array.isArray(n))throw new Error(`Config at ${r} must export an object, received ${n===null?"null":typeof n}`);return{...$2,...n}}async function nm(n,r=process.cwd()){let f=n!==void 0?N2(r,n):t1(r);if(!f)return{...$2};let h=f.split(".").pop()?.toLowerCase();try{if(h==="yaml"||h==="yml"){let l=k2(f,"utf-8");return e1((0,O2.parse)(l),f)}if(h==="json"){let l=k2(f,"utf-8");return e1(JSON.parse(l),f)}if(h==="ts"||h==="js"){let l=await import(Q9(f).href);return e1(l.default??l,f)}}catch(l){throw new Error(`Failed to load config from ${f}: ${l instanceof Error?l.message:String(l)}`,{cause:l})}throw new Error(`Unsupported config file extension: ${f}. Supported extensions: ${D2.map(l=>l.split(".").pop()).join(", ")}`)}import{writeFileSync as K8,mkdirSync as J8,existsSync as qD,readFileSync as X8}from"node:fs";import{dirname as Q8,join as FQ}from"node:path";import{fileURLToPath as n8}from"node:url";import{posix as i8,win32 as f1}from"node:path";import{fileURLToPath as a8}from"node:url";import{lstatSync as u8,readdir as l8,readdirSync as c8,readlinkSync as f8,realpathSync as d8}from"fs";import*as p8 from"node:fs";import{lstat as b8,readdir as v8,readlink as m8,realpath as h8}from"node:fs/promises";import{EventEmitter as b1}from"node:events";import wD from"node:stream";import{StringDecoder as g8}from"node:string_decoder";var sD=(n,r,f)=>{let h=n instanceof RegExp?U2(n,f):n,l=r instanceof RegExp?U2(r,f):r,t=h!==null&&l!=null&&eG(h,l,f);return t&&{start:t[0],end:t[1],pre:f.slice(0,t[0]),body:f.slice(t[0]+h.length,t[1]),post:f.slice(t[1]+l.length)}},U2=(n,r)=>{let f=r.match(n);return f?f[0]:null},eG=(n,r,f)=>{let h,l,t,$,re,e=f.indexOf(n),qe=f.indexOf(r,e+1),ht=e;if(e>=0&&qe>0){if(n===r)return[e,qe];for(h=[],t=f.length;ht>=0&&!re;){if(ht===e)h.push(ht),e=f.indexOf(n,ht+1);else if(h.length===1){let Ke=h.pop();Ke!==void 0&&(re=[Ke,qe])}else l=h.pop(),l!==void 0&&l<t&&(t=l,$=qe),qe=f.indexOf(r,ht+1);ht=e<qe&&e>=0?e:qe}h.length&&$!==void 0&&(re=[t,$])}return re},oD="\0SLASH"+Math.random()+"\0",iD="\0OPEN"+Math.random()+"\0",d1="\0CLOSE"+Math.random()+"\0",aD="\0COMMA"+Math.random()+"\0",uD="\0PERIOD"+Math.random()+"\0",tG=new RegExp(oD,"g"),nG=new RegExp(iD,"g"),rG=new RegExp(d1,"g"),sG=new RegExp(aD,"g"),oG=new RegExp(uD,"g"),iG=/\\\\/g,aG=/\\{/g,uG=/\\}/g,lG=/\\,/g,cG=/\\./g,fG=1e5;function n1(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function dG(n){return n.replace(iG,oD).replace(aG,iD).replace(uG,d1).replace(lG,aD).replace(cG,uD)}function pG(n){return n.replace(tG,"\\").replace(nG,"{").replace(rG,"}").replace(sG,",").replace(oG,".")}function lD(n){if(!n)return[""];let r=[],f=sD("{","}",n);if(!f)return n.split(",");let{pre:h,body:l,post:t}=f,$=h.split(",");$[$.length-1]+="{"+l+"}";let re=lD(t);return t.length&&($[$.length-1]+=re.shift(),$.push.apply($,re)),r.push.apply(r,$),r}function bG(n,r={}){if(!n)return[];let{max:f=fG}=r;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),zw(dG(n),f,!0).map(pG)}function vG(n){return"{"+n+"}"}function mG(n){return/^-?0\d/.test(n)}function hG(n,r){return n<=r}function gG(n,r){return n>=r}function zw(n,r,f){let h=[],l=sD("{","}",n);if(!l)return[n];let t=l.pre,$=l.post.length?zw(l.post,r,!1):[""];if(/\$$/.test(l.pre))for(let re=0;re<$.length&&re<r;re++){let e=t+"{"+l.body+"}"+$[re];h.push(e)}else{let re=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),e=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),qe=re||e,ht=l.body.indexOf(",")>=0;if(!qe&&!ht)return l.post.match(/,(?!,).*\}/)?(n=l.pre+"{"+l.body+d1+l.post,zw(n,r,!0)):[n];let Ke;if(qe)Ke=l.body.split(/\.\./);else if(Ke=lD(l.body),Ke.length===1&&Ke[0]!==void 0&&(Ke=zw(Ke[0],r,!1).map(vG),Ke.length===1))return $.map(ln=>l.pre+Ke[0]+ln);let gt;if(qe&&Ke[0]!==void 0&&Ke[1]!==void 0){let ln=n1(Ke[0]),Qn=n1(Ke[1]),bn=Math.max(Ke[0].length,Ke[1].length),zr=Ke.length===3&&Ke[2]!==void 0?Math.abs(n1(Ke[2])):1,tr=hG;Qn<ln&&(zr*=-1,tr=gG);let Er=Ke.some(mG);gt=[];for(let cs=ln;tr(cs,Qn);cs+=zr){let Ys;if(e)Ys=String.fromCharCode(cs),Ys==="\\"&&(Ys="");else if(Ys=String(cs),Er){let ao=bn-Ys.length;if(ao>0){let uo=new Array(ao+1).join("0");cs<0?Ys="-"+uo+Ys.slice(1):Ys=uo+Ys}}gt.push(Ys)}}else{gt=[];for(let ln=0;ln<Ke.length;ln++)gt.push.apply(gt,zw(Ke[ln],r,!1))}for(let ln=0;ln<gt.length;ln++)for(let Qn=0;Qn<$.length&&h.length<r;Qn++){let bn=t+gt[ln]+$[Qn];(!f||qe||bn)&&h.push(bn)}}return h}var yE=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},yG={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Dw=n=>n.replace(/[[\]\\-]/g,"\\$&"),wG=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),P2=n=>n.join(""),CG=(n,r)=>{let f=r;if(n.charAt(f)!=="[")throw new Error("not in a brace expression");let h=[],l=[],t=f+1,$=!1,re=!1,e=!1,qe=!1,ht=f,Ke="";e:for(;t<n.length;){let Qn=n.charAt(t);if((Qn==="!"||Qn==="^")&&t===f+1){qe=!0,t++;continue}if(Qn==="]"&&$&&!e){ht=t+1;break}if($=!0,Qn==="\\"&&!e){e=!0,t++;continue}if(Qn==="["&&!e){for(let[bn,[zr,tr,Er]]of Object.entries(yG))if(n.startsWith(bn,t)){if(Ke)return["$.",!1,n.length-f,!0];t+=bn.length,Er?l.push(zr):h.push(zr),re=re||tr;continue e}}if(e=!1,Ke){Qn>Ke?h.push(Dw(Ke)+"-"+Dw(Qn)):Qn===Ke&&h.push(Dw(Qn)),Ke="",t++;continue}if(n.startsWith("-]",t+1)){h.push(Dw(Qn+"-")),t+=2;continue}if(n.startsWith("-",t+1)){Ke=Qn,t+=2;continue}h.push(Dw(Qn)),t++}if(ht<t)return["",!1,0,!1];if(!h.length&&!l.length)return["$.",!1,n.length-f,!0];if(l.length===0&&h.length===1&&/^\\?.$/.test(h[0])&&!qe){let Qn=h[0].length===2?h[0].slice(-1):h[0];return[wG(Qn),!1,ht-f,!1]}let gt="["+(qe?"^":"")+P2(h)+"]",ln="["+(qe?"":"^")+P2(l)+"]";return[h.length&&l.length?"("+gt+"|"+ln+")":h.length?gt:ln,re,ht-f,!0]},ty=(n,{windowsPathsNoEscape:r=!1,magicalBraces:f=!0}={})=>f?r?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):r?n.replace(/\[([^\/\\{}])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),LG=new Set(["!","?","+","*","@"]),M2=n=>LG.has(n),EG="(?!(?:^|/)\\.\\.?(?:$|/))",lE="(?!\\.)",AG=new Set(["[","."]),_G=new Set(["..","."]),SG=new Set("().*{}+?[]^$\\!"),IG=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),p1="[^/]",j2=p1+"*?",F2=p1+"+?",cD=class $m{type;#e;#n;#o=!1;#s=[];#i;#w;#h;#c=!1;#a;#d;#f=!1;constructor(r,f,h={}){this.type=r,r&&(this.#n=!0),this.#i=f,this.#e=this.#i?this.#i.#e:this,this.#a=this.#e===this?h:this.#e.#a,this.#h=this.#e===this?[]:this.#e.#h,r==="!"&&!this.#e.#c&&this.#h.push(this),this.#w=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let r of this.#s)if(typeof r!="string"&&(r.type||r.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#s.map(r=>String(r)).join("|")+")":this.#d=this.#s.map(r=>String(r)).join("")}#u(){if(this!==this.#e)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let r;for(;r=this.#h.pop();){if(r.type!=="!")continue;let f=r,h=f.#i;for(;h;){for(let l=f.#w+1;!h.type&&l<h.#s.length;l++)for(let t of r.#s){if(typeof t=="string")throw new Error("string part in extglob AST??");t.copyIn(h.#s[l])}f=h,h=f.#i}}return this}push(...r){for(let f of r)if(f!==""){if(typeof f!="string"&&!(f instanceof $m&&f.#i===this))throw new Error("invalid part: "+f);this.#s.push(f)}}toJSON(){let r=this.type===null?this.#s.slice().map(f=>typeof f=="string"?f:f.toJSON()):[this.type,...this.#s.map(f=>f.toJSON())];return this.isStart()&&!this.type&&r.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#c&&this.#i?.type==="!")&&r.push({}),r}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#w===0)return!0;let r=this.#i;for(let f=0;f<this.#w;f++){let h=r.#s[f];if(!(h instanceof $m&&h.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let r=this.#i?this.#i.#s.length:0;return this.#w===r-1}copyIn(r){typeof r=="string"?this.push(r):this.push(r.clone(this))}clone(r){let f=new $m(this.type,r);for(let h of this.#s)f.copyIn(h);return f}static#r(r,f,h,l){let t=!1,$=!1,re=-1,e=!1;if(f.type===null){let ln=h,Qn="";for(;ln<r.length;){let bn=r.charAt(ln++);if(t||bn==="\\"){t=!t,Qn+=bn;continue}if($){ln===re+1?(bn==="^"||bn==="!")&&(e=!0):bn==="]"&&!(ln===re+2&&e)&&($=!1),Qn+=bn;continue}else if(bn==="["){$=!0,re=ln,e=!1,Qn+=bn;continue}if(!l.noext&&M2(bn)&&r.charAt(ln)==="("){f.push(Qn),Qn="";let zr=new $m(bn,f);ln=$m.#r(r,zr,ln,l),f.push(zr);continue}Qn+=bn}return f.push(Qn),ln}let qe=h+1,ht=new $m(null,f),Ke=[],gt="";for(;qe<r.length;){let ln=r.charAt(qe++);if(t||ln==="\\"){t=!t,gt+=ln;continue}if($){qe===re+1?(ln==="^"||ln==="!")&&(e=!0):ln==="]"&&!(qe===re+2&&e)&&($=!1),gt+=ln;continue}else if(ln==="["){$=!0,re=qe,e=!1,gt+=ln;continue}if(M2(ln)&&r.charAt(qe)==="("){ht.push(gt),gt="";let Qn=new $m(ln,ht);ht.push(Qn),qe=$m.#r(r,Qn,qe,l);continue}if(ln==="|"){ht.push(gt),gt="",Ke.push(ht),ht=new $m(null,f);continue}if(ln===")")return gt===""&&f.#s.length===0&&(f.#f=!0),ht.push(gt),gt="",f.push(...Ke,ht),qe;gt+=ln}return f.type=null,f.#n=void 0,f.#s=[r.substring(h-1)],qe}static fromGlob(r,f={}){let h=new $m(null,void 0,f);return $m.#r(r,h,0,f),h}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let r=this.toString(),[f,h,l,t]=this.toRegExpSource();if(!(l||this.#n||this.#a.nocase&&!this.#a.nocaseMagicOnly&&r.toUpperCase()!==r.toLowerCase()))return h;let $=(this.#a.nocase?"i":"")+(t?"u":"");return Object.assign(new RegExp(`^${f}$`,$),{_src:f,_glob:r})}get options(){return this.#a}toRegExpSource(r){let f=r??!!this.#a.dot;if(this.#e===this&&this.#u(),!this.type){let e=this.isStart()&&this.isEnd()&&!this.#s.some(gt=>typeof gt!="string"),qe=this.#s.map(gt=>{let[ln,Qn,bn,zr]=typeof gt=="string"?$m.#C(gt,this.#n,e):gt.toRegExpSource(r);return this.#n=this.#n||bn,this.#o=this.#o||zr,ln}).join(""),ht="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&_G.has(this.#s[0]))){let gt=AG,ln=f&>.has(qe.charAt(0))||qe.startsWith("\\.")&>.has(qe.charAt(2))||qe.startsWith("\\.\\.")&>.has(qe.charAt(4)),Qn=!f&&!r&>.has(qe.charAt(0));ht=ln?EG:Qn?lE:""}let Ke="";return this.isEnd()&&this.#e.#c&&this.#i?.type==="!"&&(Ke="(?:$|\\/)"),[ht+qe+Ke,ty(qe),this.#n=!!this.#n,this.#o]}let h=this.type==="*"||this.type==="+",l=this.type==="!"?"(?:(?!(?:":"(?:",t=this.#p(f);if(this.isStart()&&this.isEnd()&&!t&&this.type!=="!"){let e=this.toString();return this.#s=[e],this.type=null,this.#n=void 0,[e,ty(this.toString()),!1,!1]}let $=!h||r||f||!lE?"":this.#p(!0);$===t&&($=""),$&&(t=`(?:${t})(?:${$})*?`);let re="";if(this.type==="!"&&this.#f)re=(this.isStart()&&!f?lE:"")+F2;else{let e=this.type==="!"?"))"+(this.isStart()&&!f&&!r?lE:"")+j2+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&$?")":this.type==="*"&&$?")?":`)${this.type}`;re=l+t+e}return[re,ty(t),this.#n=!!this.#n,this.#o]}#p(r){return this.#s.map(f=>{if(typeof f=="string")throw new Error("string type in extglob ast??");let[h,l,t,$]=f.toRegExpSource(r);return this.#o=this.#o||$,h}).filter(f=>!(this.isStart()&&this.isEnd())||!!f).join("|")}static#C(r,f,h=!1){let l=!1,t="",$=!1,re=!1;for(let e=0;e<r.length;e++){let qe=r.charAt(e);if(l){l=!1,t+=(SG.has(qe)?"\\":"")+qe;continue}if(qe==="*"){if(re)continue;re=!0,t+=h&&/^[*]+$/.test(r)?F2:j2,f=!0;continue}else re=!1;if(qe==="\\"){e===r.length-1?t+="\\\\":l=!0;continue}if(qe==="["){let[ht,Ke,gt,ln]=CG(r,e);if(gt){t+=ht,$=$||Ke,e+=gt-1,f=f||ln;continue}}if(qe==="?"){t+=p1,f=!0;continue}t+=IG(qe)}return[t,ty(r),!!f,$]}},fD=(n,{windowsPathsNoEscape:r=!1,magicalBraces:f=!1}={})=>f?r?n.replace(/[?*()[\]{}]/g,"[$&]"):n.replace(/[?*()[\]\\{}]/g,"\\$&"):r?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),mm=(n,r,f={})=>(yE(r),!f.nocomment&&r.charAt(0)==="#"?!1:new Kh(r,f).match(n)),TG=/^\*+([^+@!?\*\[\(]*)$/,xG=n=>r=>!r.startsWith(".")&&r.endsWith(n),kG=n=>r=>r.endsWith(n),RG=n=>(n=n.toLowerCase(),r=>!r.startsWith(".")&&r.toLowerCase().endsWith(n)),NG=n=>(n=n.toLowerCase(),r=>r.toLowerCase().endsWith(n)),OG=/^\*+\.\*+$/,$G=n=>!n.startsWith(".")&&n.includes("."),DG=n=>n!=="."&&n!==".."&&n.includes("."),UG=/^\.\*+$/,PG=n=>n!=="."&&n!==".."&&n.startsWith("."),MG=/^\*+$/,jG=n=>n.length!==0&&!n.startsWith("."),FG=n=>n.length!==0&&n!=="."&&n!=="..",zG=/^\?+([^+@!?\*\[\(]*)?$/,GG=([n,r=""])=>{let f=dD([n]);return r?(r=r.toLowerCase(),h=>f(h)&&h.toLowerCase().endsWith(r)):f},BG=([n,r=""])=>{let f=pD([n]);return r?(r=r.toLowerCase(),h=>f(h)&&h.toLowerCase().endsWith(r)):f},qG=([n,r=""])=>{let f=pD([n]);return r?h=>f(h)&&h.endsWith(r):f},VG=([n,r=""])=>{let f=dD([n]);return r?h=>f(h)&&h.endsWith(r):f},dD=([n])=>{let r=n.length;return f=>f.length===r&&!f.startsWith(".")},pD=([n])=>{let r=n.length;return f=>f.length===r&&f!=="."&&f!==".."},bD=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",z2={win32:{sep:"\\"},posix:{sep:"/"}},HG=bD==="win32"?z2.win32.sep:z2.posix.sep;mm.sep=HG;var vm=Symbol("globstar **");mm.GLOBSTAR=vm;var YG="[^/]",WG=YG+"*?",ZG="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",KG="(?:(?!(?:\\/|^)\\.).)*?",JG=(n,r={})=>f=>mm(f,n,r);mm.filter=JG;var Fm=(n,r={})=>Object.assign({},n,r),XG=n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return mm;let r=mm;return Object.assign((f,h,l={})=>r(f,h,Fm(n,l)),{Minimatch:class extends r.Minimatch{constructor(f,h={}){super(f,Fm(n,h))}static defaults(f){return r.defaults(Fm(n,f)).Minimatch}},AST:class extends r.AST{constructor(f,h,l={}){super(f,h,Fm(n,l))}static fromGlob(f,h={}){return r.AST.fromGlob(f,Fm(n,h))}},unescape:(f,h={})=>r.unescape(f,Fm(n,h)),escape:(f,h={})=>r.escape(f,Fm(n,h)),filter:(f,h={})=>r.filter(f,Fm(n,h)),defaults:f=>r.defaults(Fm(n,f)),makeRe:(f,h={})=>r.makeRe(f,Fm(n,h)),braceExpand:(f,h={})=>r.braceExpand(f,Fm(n,h)),match:(f,h,l={})=>r.match(f,h,Fm(n,l)),sep:r.sep,GLOBSTAR:vm})};mm.defaults=XG;var vD=(n,r={})=>(yE(n),r.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:bG(n,{max:r.braceExpandMax}));mm.braceExpand=vD;var QG=(n,r={})=>new Kh(n,r).makeRe();mm.makeRe=QG;var e8=(n,r,f={})=>{let h=new Kh(r,f);return n=n.filter(l=>h.match(l)),h.options.nonull&&!n.length&&n.push(r),n};mm.match=e8;var G2=/[?*]|[+@!]\(.*?\)|\[|\]/,t8=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Kh=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(n,r={}){yE(n),r=r||{},this.options=r,this.pattern=n,this.platform=r.platform||bD,this.isWindows=this.platform==="win32";let f="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[f]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let n of this.set)for(let r of n)if(typeof r!="string")return!0;return!1}debug(...n){}make(){let n=this.pattern,r=this.options;if(!r.nocomment&&n.charAt(0)==="#"){this.comment=!0;return}if(!n){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...l)=>console.error(...l)),this.debug(this.pattern,this.globSet);let f=this.globSet.map(l=>this.slashSplit(l));this.globParts=this.preprocess(f),this.debug(this.pattern,this.globParts);let h=this.globParts.map((l,t,$)=>{if(this.isWindows&&this.windowsNoMagicRoot){let re=l[0]===""&&l[1]===""&&(l[2]==="?"||!G2.test(l[2]))&&!G2.test(l[3]),e=/^[a-z]:/i.test(l[0]);if(re)return[...l.slice(0,4),...l.slice(4).map(qe=>this.parse(qe))];if(e)return[l[0],...l.slice(1).map(qe=>this.parse(qe))]}return l.map(re=>this.parse(re))});if(this.debug(this.pattern,h),this.set=h.filter(l=>l.indexOf(!1)===-1),this.isWindows)for(let l=0;l<this.set.length;l++){let t=this.set[l];t[0]===""&&t[1]===""&&this.globParts[l][2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3])&&(t[2]="?")}this.debug(this.pattern,this.set)}preprocess(n){if(this.options.noglobstar)for(let f=0;f<n.length;f++)for(let h=0;h<n[f].length;h++)n[f][h]==="**"&&(n[f][h]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(n=this.firstPhasePreProcess(n),n=this.secondPhasePreProcess(n)):r>=1?n=this.levelOneOptimize(n):n=this.adjascentGlobstarOptimize(n),n}adjascentGlobstarOptimize(n){return n.map(r=>{let f=-1;for(;(f=r.indexOf("**",f+1))!==-1;){let h=f;for(;r[h+1]==="**";)h++;h!==f&&r.splice(f,h-f)}return r})}levelOneOptimize(n){return n.map(r=>(r=r.reduce((f,h)=>{let l=f[f.length-1];return h==="**"&&l==="**"?f:h===".."&&l&&l!==".."&&l!=="."&&l!=="**"?(f.pop(),f):(f.push(h),f)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(n){Array.isArray(n)||(n=this.slashSplit(n));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let h=1;h<n.length-1;h++){let l=n[h];h===1&&l===""&&n[0]===""||(l==="."||l==="")&&(r=!0,n.splice(h,1),h--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let f=0;for(;(f=n.indexOf("..",f+1))!==-1;){let h=n[f-1];h&&h!=="."&&h!==".."&&h!=="**"&&(r=!0,n.splice(f-1,2),f-=2)}}while(r);return n.length===0?[""]:n}firstPhasePreProcess(n){let r=!1;do{r=!1;for(let f of n){let h=-1;for(;(h=f.indexOf("**",h+1))!==-1;){let t=h;for(;f[t+1]==="**";)t++;t>h&&f.splice(h+1,t-h);let $=f[h+1],re=f[h+2],e=f[h+3];if($!==".."||!re||re==="."||re===".."||!e||e==="."||e==="..")continue;r=!0,f.splice(h,1);let qe=f.slice(0);qe[h]="**",n.push(qe),h--}if(!this.preserveMultipleSlashes){for(let t=1;t<f.length-1;t++){let $=f[t];t===1&&$===""&&f[0]===""||($==="."||$==="")&&(r=!0,f.splice(t,1),t--)}f[0]==="."&&f.length===2&&(f[1]==="."||f[1]==="")&&(r=!0,f.pop())}let l=0;for(;(l=f.indexOf("..",l+1))!==-1;){let t=f[l-1];if(t&&t!=="."&&t!==".."&&t!=="**"){r=!0;let $=l===1&&f[l+1]==="**"?["."]:[];f.splice(l-1,2,...$),f.length===0&&f.push(""),l-=2}}}}while(r);return n}secondPhasePreProcess(n){for(let r=0;r<n.length-1;r++)for(let f=r+1;f<n.length;f++){let h=this.partsMatch(n[r],n[f],!this.preserveMultipleSlashes);if(h){n[r]=[],n[f]=h;break}}return n.filter(r=>r.length)}partsMatch(n,r,f=!1){let h=0,l=0,t=[],$="";for(;h<n.length&&l<r.length;)if(n[h]===r[l])t.push($==="b"?r[l]:n[h]),h++,l++;else if(f&&n[h]==="**"&&r[l]===n[h+1])t.push(n[h]),h++;else if(f&&r[l]==="**"&&n[h]===r[l+1])t.push(r[l]),l++;else if(n[h]==="*"&&r[l]&&(this.options.dot||!r[l].startsWith("."))&&r[l]!=="**"){if($==="b")return!1;$="a",t.push(n[h]),h++,l++}else if(r[l]==="*"&&n[h]&&(this.options.dot||!n[h].startsWith("."))&&n[h]!=="**"){if($==="a")return!1;$="b",t.push(r[l]),h++,l++}else return!1;return n.length===r.length&&t}parseNegate(){if(this.nonegate)return;let n=this.pattern,r=!1,f=0;for(let h=0;h<n.length&&n.charAt(h)==="!";h++)r=!r,f++;f&&(this.pattern=n.slice(f)),this.negate=r}matchOne(n,r,f=!1){let h=this.options;if(this.isWindows){let Qn=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),bn=!Qn&&n[0]===""&&n[1]===""&&n[2]==="?"&&/^[a-z]:$/i.test(n[3]),zr=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),tr=!zr&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),Er=bn?3:Qn?0:void 0,cs=tr?3:zr?0:void 0;if(typeof Er=="number"&&typeof cs=="number"){let[Ys,ao]=[n[Er],r[cs]];Ys.toLowerCase()===ao.toLowerCase()&&(r[cs]=Ys,cs>Er?r=r.slice(cs):Er>cs&&(n=n.slice(Er)))}}let{optimizationLevel:l=1}=this.options;l>=2&&(n=this.levelTwoFileOptimize(n)),this.debug("matchOne",this,{file:n,pattern:r}),this.debug("matchOne",n.length,r.length);for(var t=0,$=0,re=n.length,e=r.length;t<re&&$<e;t++,$++){this.debug("matchOne loop");var qe=r[$],ht=n[t];if(this.debug(r,qe,ht),qe===!1)return!1;if(qe===vm){this.debug("GLOBSTAR",[r,qe,ht]);var Ke=t,gt=$+1;if(gt===e){for(this.debug("** at the end");t<re;t++)if(n[t]==="."||n[t]===".."||!h.dot&&n[t].charAt(0)===".")return!1;return!0}for(;Ke<re;){var ln=n[Ke];if(this.debug(`
|
|
214
214
|
globstar while`,n,Ke,r,gt,ln),this.matchOne(n.slice(Ke),r.slice(gt),f))return this.debug("globstar found match!",Ke,re,ln),!0;if(ln==="."||ln===".."||!h.dot&&ln.charAt(0)==="."){this.debug("dot detected!",n,Ke,r,gt);break}this.debug("globstar swallow a segment, and continue"),Ke++}return!!(f&&(this.debug(`
|
|
215
|
-
>>> no match, partial?`,n,Ke,r,gt),Ke===re))}let Qn;if(typeof qe=="string"?(Qn=ht===qe,this.debug("string match",qe,ht,Qn)):(Qn=qe.test(ht),this.debug("pattern match",qe,ht,Qn)),!Qn)return!1}if(t===re&&$===e)return!0;if(t===re)return f;if($===e)return t===re-1&&n[t]==="";throw new Error("wtf?")}braceExpand(){return vD(this.pattern,this.options)}parse(n){yE(n);let r=this.options;if(n==="**")return vm;if(n==="")return"";let f,h=null;(f=n.match(MG))?h=r.dot?FG:jG:(f=n.match(TG))?h=(r.nocase?r.dot?NG:RG:r.dot?kG:xG)(f[1]):(f=n.match(zG))?h=(r.nocase?r.dot?BG:GG:r.dot?qG:VG)(f):(f=n.match(OG))?h=r.dot?DG:$G:(f=n.match(UG))&&(h=PG);let l=cD.fromGlob(n,this.options).toMMPattern();return h&&typeof l=="object"&&Reflect.defineProperty(l,"test",{value:h}),l}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let n=this.set;if(!n.length)return this.regexp=!1,this.regexp;let r=this.options,f=r.noglobstar?WG:r.dot?ZG:KG,h=new Set(r.nocase?["i"]:[]),l=n.map(re=>{let e=re.map(ht=>{if(ht instanceof RegExp)for(let Ke of ht.flags.split(""))h.add(Ke);return typeof ht=="string"?t8(ht):ht===vm?vm:ht._src});e.forEach((ht,Ke)=>{let gt=e[Ke+1],ln=e[Ke-1];ht!==vm||ln===vm||(ln===void 0?gt!==void 0&>!==vm?e[Ke+1]="(?:\\/|"+f+"\\/)?"+gt:e[Ke]=f:gt===void 0?e[Ke-1]=ln+"(?:\\/|\\/"+f+")?":gt!==vm&&(e[Ke-1]=ln+"(?:\\/|\\/"+f+"\\/)"+gt,e[Ke+1]=vm))});let qe=e.filter(ht=>ht!==vm);if(this.partial&&qe.length>=1){let ht=[];for(let Ke=1;Ke<=qe.length;Ke++)ht.push(qe.slice(0,Ke).join("/"));return"(?:"+ht.join("|")+")"}return qe.join("/")}).join("|"),[t,$]=n.length>1?["(?:",")"]:["",""];l="^"+t+l+$+"$",this.partial&&(l="^(?:\\/|"+t+l.slice(1,-1)+$+")$"),this.negate&&(l="^(?!"+l+").+$");try{this.regexp=new RegExp(l,[...h].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(n){return this.preserveMultipleSlashes?n.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(n)?["",...n.split(/\/+/)]:n.split(/\/+/)}match(n,r=this.partial){if(this.debug("match",n,this.pattern),this.comment)return!1;if(this.empty)return n==="";if(n==="/"&&r)return!0;let f=this.options;this.isWindows&&(n=n.split("\\").join("/"));let h=this.slashSplit(n);this.debug(this.pattern,"split",h);let l=this.set;this.debug(this.pattern,"set",l);let t=h[h.length-1];if(!t)for(let $=h.length-2;!t&&$>=0;$--)t=h[$];for(let $=0;$<l.length;$++){let re=l[$],e=h;if(f.matchBase&&re.length===1&&(e=[t]),this.matchOne(e,re,r))return f.flipNegate?!0:!this.negate}return f.flipNegate?!1:this.negate}static defaults(n){return mm.defaults(n).Minimatch}};mm.AST=cD;mm.Minimatch=Kh;mm.escape=fD;mm.unescape=ty;var r8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,mD=new Set,c1=typeof process=="object"&&process?process:{},hD=(n,r,f,h)=>{typeof c1.emitWarning=="function"?c1.emitWarning(n,r,f,h):console.error(`[${f}] ${r}: ${n}`)},wE=globalThis.AbortController,B2=globalThis.AbortSignal;if(typeof wE>"u"){B2=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(f,h){this._onabort.push(h)}},wE=class{constructor(){r()}signal=new B2;abort(f){if(!this.signal.aborted){this.signal.reason=f,this.signal.aborted=!0;for(let h of this.signal._onabort)h(f);this.signal.onabort?.(f)}}};let n=c1.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",r=()=>{n&&(n=!1,hD("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",r))}}var s8=n=>!mD.has(n),Zh=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),gD=n=>Zh(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?hE:null:null,hE=class extends Array{constructor(n){super(n),this.fill(0)}},o8=class Gw{heap;length;static#e=!1;static create(r){let f=gD(r);if(!f)return[];Gw.#e=!0;let h=new Gw(r,f);return Gw.#e=!1,h}constructor(r,f){if(!Gw.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new f(r),this.length=0}push(r){this.heap[this.length++]=r}pop(){return this.heap[--this.length]}},LE=class yD{#e;#n;#o;#s;#i;#w;#h;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#d;#f;#u;#r;#p;#C;#y;#b;#T;#v;#A;#_;#m;#g;#L;#S;#t;#$;static unsafeExposeInternals(r){return{starts:r.#_,ttls:r.#m,autopurgeTimers:r.#g,sizes:r.#A,keyMap:r.#f,keyList:r.#u,valList:r.#r,next:r.#p,prev:r.#C,get head(){return r.#y},get tail(){return r.#b},free:r.#T,isBackgroundFetch:f=>r.#l(f),backgroundFetch:(f,h,l,t)=>r.#G(f,h,l,t),moveToTail:f=>r.#U(f),indexes:f=>r.#k(f),rindexes:f=>r.#R(f),isStale:f=>r.#E(f)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#d}get size(){return this.#a}get fetchMethod(){return this.#w}get memoMethod(){return this.#h}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(r){let{max:f=0,ttl:h,ttlResolution:l=1,ttlAutopurge:t,updateAgeOnGet:$,updateAgeOnHas:re,allowStale:e,dispose:qe,onInsert:ht,disposeAfter:Ke,noDisposeOnSet:gt,noUpdateTTL:ln,maxSize:Qn=0,maxEntrySize:bn=0,sizeCalculation:zr,fetchMethod:tr,memoMethod:Er,noDeleteOnFetchRejection:cs,noDeleteOnStaleGet:Ys,allowStaleOnFetchRejection:ao,allowStaleOnFetchAbort:uo,ignoreFetchAbort:ni,perf:zo}=r;if(zo!==void 0&&typeof zo?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=zo??r8,f!==0&&!Zh(f))throw new TypeError("max option must be a nonnegative integer");let ta=f?gD(f):Array;if(!ta)throw new Error("invalid max value: "+f);if(this.#e=f,this.#n=Qn,this.maxEntrySize=bn||this.#n,this.sizeCalculation=zr,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(Er!==void 0&&typeof Er!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#h=Er,tr!==void 0&&typeof tr!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#w=tr,this.#S=!!tr,this.#f=new Map,this.#u=new Array(f).fill(void 0),this.#r=new Array(f).fill(void 0),this.#p=new ta(f),this.#C=new ta(f),this.#y=0,this.#b=0,this.#T=o8.create(f),this.#a=0,this.#d=0,typeof qe=="function"&&(this.#o=qe),typeof ht=="function"&&(this.#s=ht),typeof Ke=="function"?(this.#i=Ke,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#L=!!this.#o,this.#$=!!this.#s,this.#t=!!this.#i,this.noDisposeOnSet=!!gt,this.noUpdateTTL=!!ln,this.noDeleteOnFetchRejection=!!cs,this.allowStaleOnFetchRejection=!!ao,this.allowStaleOnFetchAbort=!!uo,this.ignoreFetchAbort=!!ni,this.maxEntrySize!==0){if(this.#n!==0&&!Zh(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Zh(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#q()}if(this.allowStale=!!e,this.noDeleteOnStaleGet=!!Ys,this.updateAgeOnGet=!!$,this.updateAgeOnHas=!!re,this.ttlResolution=Zh(l)||l===0?l:1,this.ttlAutopurge=!!t,this.ttl=h||0,this.ttl){if(!Zh(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Ha="LRU_CACHE_UNBOUNDED";s8(Ha)&&(mD.add(Ha),hD("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ha,yD))}}getRemainingTTL(r){return this.#f.has(r)?1/0:0}#N(){let r=new hE(this.#e),f=new hE(this.#e);this.#m=r,this.#_=f;let h=this.ttlAutopurge?new Array(this.#e):void 0;this.#g=h,this.#M=($,re,e=this.#c.now())=>{if(f[$]=re!==0?e:0,r[$]=re,h?.[$]&&(clearTimeout(h[$]),h[$]=void 0),re!==0&&h){let qe=setTimeout(()=>{this.#E($)&&this.#x(this.#u[$],"expire")},re+1);qe.unref&&qe.unref(),h[$]=qe}},this.#I=$=>{f[$]=r[$]!==0?this.#c.now():0},this.#O=($,re)=>{if(r[re]){let e=r[re],qe=f[re];if(!e||!qe)return;$.ttl=e,$.start=qe,$.now=l||t();let ht=$.now-qe;$.remainingTTL=e-ht}};let l=0,t=()=>{let $=this.#c.now();if(this.ttlResolution>0){l=$;let re=setTimeout(()=>l=0,this.ttlResolution);re.unref&&re.unref()}return $};this.getRemainingTTL=$=>{let re=this.#f.get($);if(re===void 0)return 0;let e=r[re],qe=f[re];if(!e||!qe)return 1/0;let ht=(l||t())-qe;return e-ht},this.#E=$=>{let re=f[$],e=r[$];return!!e&&!!re&&(l||t())-re>e}}#I=()=>{};#O=()=>{};#M=()=>{};#E=()=>!1;#q(){let r=new hE(this.#e);this.#d=0,this.#A=r,this.#P=f=>{this.#d-=r[f],r[f]=0},this.#j=(f,h,l,t)=>{if(this.#l(h))return 0;if(!Zh(l))if(t){if(typeof t!="function")throw new TypeError("sizeCalculation must be a function");if(l=t(h,f),!Zh(l))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return l},this.#D=(f,h,l)=>{if(r[f]=h,this.#n){let t=this.#n-r[f];for(;this.#d>t;)this.#z(!0)}this.#d+=r[f],l&&(l.entrySize=h,l.totalCalculatedSize=this.#d)}}#P=r=>{};#D=(r,f,h)=>{};#j=(r,f,h,l)=>{if(h||l)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#k({allowStale:r=this.allowStale}={}){if(this.#a)for(let f=this.#b;!(!this.#F(f)||((r||!this.#E(f))&&(yield f),f===this.#y));)f=this.#C[f]}*#R({allowStale:r=this.allowStale}={}){if(this.#a)for(let f=this.#y;!(!this.#F(f)||((r||!this.#E(f))&&(yield f),f===this.#b));)f=this.#p[f]}#F(r){return r!==void 0&&this.#f.get(this.#u[r])===r}*entries(){for(let r of this.#k())this.#r[r]!==void 0&&this.#u[r]!==void 0&&!this.#l(this.#r[r])&&(yield[this.#u[r],this.#r[r]])}*rentries(){for(let r of this.#R())this.#r[r]!==void 0&&this.#u[r]!==void 0&&!this.#l(this.#r[r])&&(yield[this.#u[r],this.#r[r]])}*keys(){for(let r of this.#k()){let f=this.#u[r];f!==void 0&&!this.#l(this.#r[r])&&(yield f)}}*rkeys(){for(let r of this.#R()){let f=this.#u[r];f!==void 0&&!this.#l(this.#r[r])&&(yield f)}}*values(){for(let r of this.#k())this.#r[r]!==void 0&&!this.#l(this.#r[r])&&(yield this.#r[r])}*rvalues(){for(let r of this.#R())this.#r[r]!==void 0&&!this.#l(this.#r[r])&&(yield this.#r[r])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(r,f={}){for(let h of this.#k()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;if(t!==void 0&&r(t,this.#u[h],this))return this.get(this.#u[h],f)}}forEach(r,f=this){for(let h of this.#k()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;t!==void 0&&r.call(f,t,this.#u[h],this)}}rforEach(r,f=this){for(let h of this.#R()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;t!==void 0&&r.call(f,t,this.#u[h],this)}}purgeStale(){let r=!1;for(let f of this.#R({allowStale:!0}))this.#E(f)&&(this.#x(this.#u[f],"expire"),r=!0);return r}info(r){let f=this.#f.get(r);if(f===void 0)return;let h=this.#r[f],l=this.#l(h)?h.__staleWhileFetching:h;if(l===void 0)return;let t={value:l};if(this.#m&&this.#_){let $=this.#m[f],re=this.#_[f];if($&&re){let e=$-(this.#c.now()-re);t.ttl=e,t.start=Date.now()}}return this.#A&&(t.size=this.#A[f]),t}dump(){let r=[];for(let f of this.#k({allowStale:!0})){let h=this.#u[f],l=this.#r[f],t=this.#l(l)?l.__staleWhileFetching:l;if(t===void 0||h===void 0)continue;let $={value:t};if(this.#m&&this.#_){$.ttl=this.#m[f];let re=this.#c.now()-this.#_[f];$.start=Math.floor(Date.now()-re)}this.#A&&($.size=this.#A[f]),r.unshift([h,$])}return r}load(r){this.clear();for(let[f,h]of r){if(h.start){let l=Date.now()-h.start;h.start=this.#c.now()-l}this.set(f,h.value,h)}}set(r,f,h={}){if(f===void 0)return this.delete(r),this;let{ttl:l=this.ttl,start:t,noDisposeOnSet:$=this.noDisposeOnSet,sizeCalculation:re=this.sizeCalculation,status:e}=h,{noUpdateTTL:qe=this.noUpdateTTL}=h,ht=this.#j(r,f,h.size||0,re);if(this.maxEntrySize&&ht>this.maxEntrySize)return e&&(e.set="miss",e.maxEntrySizeExceeded=!0),this.#x(r,"set"),this;let Ke=this.#a===0?void 0:this.#f.get(r);if(Ke===void 0)Ke=this.#a===0?this.#b:this.#T.length!==0?this.#T.pop():this.#a===this.#e?this.#z(!1):this.#a,this.#u[Ke]=r,this.#r[Ke]=f,this.#f.set(r,Ke),this.#p[this.#b]=Ke,this.#C[Ke]=this.#b,this.#b=Ke,this.#a++,this.#D(Ke,ht,e),e&&(e.set="add"),qe=!1,this.#$&&this.#s?.(f,r,"add");else{this.#U(Ke);let gt=this.#r[Ke];if(f!==gt){if(this.#S&&this.#l(gt)){gt.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:ln}=gt;ln!==void 0&&!$&&(this.#L&&this.#o?.(ln,r,"set"),this.#t&&this.#v?.push([ln,r,"set"]))}else $||(this.#L&&this.#o?.(gt,r,"set"),this.#t&&this.#v?.push([gt,r,"set"]));if(this.#P(Ke),this.#D(Ke,ht,e),this.#r[Ke]=f,e){e.set="replace";let ln=gt&&this.#l(gt)?gt.__staleWhileFetching:gt;ln!==void 0&&(e.oldValue=ln)}}else e&&(e.set="update");this.#$&&this.onInsert?.(f,r,f===gt?"update":"replace")}if(l!==0&&!this.#m&&this.#N(),this.#m&&(qe||this.#M(Ke,l,t),e&&this.#O(e,Ke)),!$&&this.#t&&this.#v){let gt=this.#v,ln;for(;ln=gt?.shift();)this.#i?.(...ln)}return this}pop(){try{for(;this.#a;){let r=this.#r[this.#y];if(this.#z(!0),this.#l(r)){if(r.__staleWhileFetching)return r.__staleWhileFetching}else if(r!==void 0)return r}}finally{if(this.#t&&this.#v){let r=this.#v,f;for(;f=r?.shift();)this.#i?.(...f)}}}#z(r){let f=this.#y,h=this.#u[f],l=this.#r[f];return this.#S&&this.#l(l)?l.__abortController.abort(new Error("evicted")):(this.#L||this.#t)&&(this.#L&&this.#o?.(l,h,"evict"),this.#t&&this.#v?.push([l,h,"evict"])),this.#P(f),this.#g?.[f]&&(clearTimeout(this.#g[f]),this.#g[f]=void 0),r&&(this.#u[f]=void 0,this.#r[f]=void 0,this.#T.push(f)),this.#a===1?(this.#y=this.#b=0,this.#T.length=0):this.#y=this.#p[f],this.#f.delete(h),this.#a--,f}has(r,f={}){let{updateAgeOnHas:h=this.updateAgeOnHas,status:l}=f,t=this.#f.get(r);if(t!==void 0){let $=this.#r[t];if(this.#l($)&&$.__staleWhileFetching===void 0)return!1;if(this.#E(t))l&&(l.has="stale",this.#O(l,t));else return h&&this.#I(t),l&&(l.has="hit",this.#O(l,t)),!0}else l&&(l.has="miss");return!1}peek(r,f={}){let{allowStale:h=this.allowStale}=f,l=this.#f.get(r);if(l===void 0||!h&&this.#E(l))return;let t=this.#r[l];return this.#l(t)?t.__staleWhileFetching:t}#G(r,f,h,l){let t=f===void 0?void 0:this.#r[f];if(this.#l(t))return t;let $=new wE,{signal:re}=h;re?.addEventListener("abort",()=>$.abort(re.reason),{signal:$.signal});let e={signal:$.signal,options:h,context:l},qe=(bn,zr=!1)=>{let{aborted:tr}=$.signal,Er=h.ignoreFetchAbort&&bn!==void 0,cs=h.ignoreFetchAbort||!!(h.allowStaleOnFetchAbort&&bn!==void 0);if(h.status&&(tr&&!zr?(h.status.fetchAborted=!0,h.status.fetchError=$.signal.reason,Er&&(h.status.fetchAbortIgnored=!0)):h.status.fetchResolved=!0),tr&&!Er&&!zr)return Ke($.signal.reason,cs);let Ys=ln,ao=this.#r[f];return(ao===ln||Er&&zr&&ao===void 0)&&(bn===void 0?Ys.__staleWhileFetching!==void 0?this.#r[f]=Ys.__staleWhileFetching:this.#x(r,"fetch"):(h.status&&(h.status.fetchUpdated=!0),this.set(r,bn,e.options))),bn},ht=bn=>(h.status&&(h.status.fetchRejected=!0,h.status.fetchError=bn),Ke(bn,!1)),Ke=(bn,zr)=>{let{aborted:tr}=$.signal,Er=tr&&h.allowStaleOnFetchAbort,cs=Er||h.allowStaleOnFetchRejection,Ys=cs||h.noDeleteOnFetchRejection,ao=ln;if(this.#r[f]===ln&&(!Ys||!zr&&ao.__staleWhileFetching===void 0?this.#x(r,"fetch"):Er||(this.#r[f]=ao.__staleWhileFetching)),cs)return h.status&&ao.__staleWhileFetching!==void 0&&(h.status.returnedStale=!0),ao.__staleWhileFetching;if(ao.__returned===ao)throw bn},gt=(bn,zr)=>{let tr=this.#w?.(r,t,e);tr&&tr instanceof Promise&&tr.then(Er=>bn(Er===void 0?void 0:Er),zr),$.signal.addEventListener("abort",()=>{(!h.ignoreFetchAbort||h.allowStaleOnFetchAbort)&&(bn(void 0),h.allowStaleOnFetchAbort&&(bn=Er=>qe(Er,!0)))})};h.status&&(h.status.fetchDispatched=!0);let ln=new Promise(gt).then(qe,ht),Qn=Object.assign(ln,{__abortController:$,__staleWhileFetching:t,__returned:void 0});return f===void 0?(this.set(r,Qn,{...e.options,status:void 0}),f=this.#f.get(r)):this.#r[f]=Qn,Qn}#l(r){if(!this.#S)return!1;let f=r;return!!f&&f instanceof Promise&&f.hasOwnProperty("__staleWhileFetching")&&f.__abortController instanceof wE}async fetch(r,f={}){let{allowStale:h=this.allowStale,updateAgeOnGet:l=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,ttl:$=this.ttl,noDisposeOnSet:re=this.noDisposeOnSet,size:e=0,sizeCalculation:qe=this.sizeCalculation,noUpdateTTL:ht=this.noUpdateTTL,noDeleteOnFetchRejection:Ke=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:gt=this.allowStaleOnFetchRejection,ignoreFetchAbort:ln=this.ignoreFetchAbort,allowStaleOnFetchAbort:Qn=this.allowStaleOnFetchAbort,context:bn,forceRefresh:zr=!1,status:tr,signal:Er}=f;if(!this.#S)return tr&&(tr.fetch="get"),this.get(r,{allowStale:h,updateAgeOnGet:l,noDeleteOnStaleGet:t,status:tr});let cs={allowStale:h,updateAgeOnGet:l,noDeleteOnStaleGet:t,ttl:$,noDisposeOnSet:re,size:e,sizeCalculation:qe,noUpdateTTL:ht,noDeleteOnFetchRejection:Ke,allowStaleOnFetchRejection:gt,allowStaleOnFetchAbort:Qn,ignoreFetchAbort:ln,status:tr,signal:Er},Ys=this.#f.get(r);if(Ys===void 0){tr&&(tr.fetch="miss");let ao=this.#G(r,Ys,cs,bn);return ao.__returned=ao}else{let ao=this.#r[Ys];if(this.#l(ao)){let ta=h&&ao.__staleWhileFetching!==void 0;return tr&&(tr.fetch="inflight",ta&&(tr.returnedStale=!0)),ta?ao.__staleWhileFetching:ao.__returned=ao}let uo=this.#E(Ys);if(!zr&&!uo)return tr&&(tr.fetch="hit"),this.#U(Ys),l&&this.#I(Ys),tr&&this.#O(tr,Ys),ao;let ni=this.#G(r,Ys,cs,bn),zo=ni.__staleWhileFetching!==void 0&&h;return tr&&(tr.fetch=uo?"stale":"refresh",zo&&uo&&(tr.returnedStale=!0)),zo?ni.__staleWhileFetching:ni.__returned=ni}}async forceFetch(r,f={}){let h=await this.fetch(r,f);if(h===void 0)throw new Error("fetch() returned undefined");return h}memo(r,f={}){let h=this.#h;if(!h)throw new Error("no memoMethod provided to constructor");let{context:l,forceRefresh:t,...$}=f,re=this.get(r,$);if(!t&&re!==void 0)return re;let e=h(r,re,{options:$,context:l});return this.set(r,e,$),e}get(r,f={}){let{allowStale:h=this.allowStale,updateAgeOnGet:l=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,status:$}=f,re=this.#f.get(r);if(re!==void 0){let e=this.#r[re],qe=this.#l(e);return $&&this.#O($,re),this.#E(re)?($&&($.get="stale"),qe?($&&h&&e.__staleWhileFetching!==void 0&&($.returnedStale=!0),h?e.__staleWhileFetching:void 0):(t||this.#x(r,"expire"),$&&h&&($.returnedStale=!0),h?e:void 0)):($&&($.get="hit"),qe?e.__staleWhileFetching:(this.#U(re),l&&this.#I(re),e))}else $&&($.get="miss")}#B(r,f){this.#C[f]=r,this.#p[r]=f}#U(r){r!==this.#b&&(r===this.#y?this.#y=this.#p[r]:this.#B(this.#C[r],this.#p[r]),this.#B(this.#b,r),this.#b=r)}delete(r){return this.#x(r,"delete")}#x(r,f){let h=!1;if(this.#a!==0){let l=this.#f.get(r);if(l!==void 0)if(this.#g?.[l]&&(clearTimeout(this.#g?.[l]),this.#g[l]=void 0),h=!0,this.#a===1)this.#V(f);else{this.#P(l);let t=this.#r[l];if(this.#l(t)?t.__abortController.abort(new Error("deleted")):(this.#L||this.#t)&&(this.#L&&this.#o?.(t,r,f),this.#t&&this.#v?.push([t,r,f])),this.#f.delete(r),this.#u[l]=void 0,this.#r[l]=void 0,l===this.#b)this.#b=this.#C[l];else if(l===this.#y)this.#y=this.#p[l];else{let $=this.#C[l];this.#p[$]=this.#p[l];let re=this.#p[l];this.#C[re]=this.#C[l]}this.#a--,this.#T.push(l)}}if(this.#t&&this.#v?.length){let l=this.#v,t;for(;t=l?.shift();)this.#i?.(...t)}return h}clear(){return this.#V("delete")}#V(r){for(let f of this.#R({allowStale:!0})){let h=this.#r[f];if(this.#l(h))h.__abortController.abort(new Error("deleted"));else{let l=this.#u[f];this.#L&&this.#o?.(h,l,r),this.#t&&this.#v?.push([h,l,r])}}if(this.#f.clear(),this.#r.fill(void 0),this.#u.fill(void 0),this.#m&&this.#_){this.#m.fill(0),this.#_.fill(0);for(let f of this.#g??[])f!==void 0&&clearTimeout(f);this.#g?.fill(void 0)}if(this.#A&&this.#A.fill(0),this.#y=0,this.#b=0,this.#T.length=0,this.#d=0,this.#a=0,this.#t&&this.#v){let f=this.#v,h;for(;h=f?.shift();)this.#i?.(...h)}}},q2=typeof process=="object"&&process?process:{stdout:null,stderr:null},y8=n=>!!n&&typeof n=="object"&&(n instanceof CE||n instanceof wD||w8(n)||C8(n)),w8=n=>!!n&&typeof n=="object"&&n instanceof b1&&typeof n.pipe=="function"&&n.pipe!==wD.Writable.prototype.pipe,C8=n=>!!n&&typeof n=="object"&&n instanceof b1&&typeof n.write=="function"&&typeof n.end=="function",wh=Symbol("EOF"),Ch=Symbol("maybeEmitEnd"),Wh=Symbol("emittedEnd"),cE=Symbol("emittingEnd"),Uw=Symbol("emittedError"),fE=Symbol("closed"),V2=Symbol("read"),dE=Symbol("flush"),H2=Symbol("flushChunk"),Km=Symbol("encoding"),Qg=Symbol("decoder"),rm=Symbol("flowing"),Pw=Symbol("paused"),ey=Symbol("resume"),sm=Symbol("buffer"),bm=Symbol("pipes"),om=Symbol("bufferLength"),r1=Symbol("bufferPush"),pE=Symbol("bufferShift"),cm=Symbol("objectMode"),Gv=Symbol("destroyed"),s1=Symbol("error"),o1=Symbol("emitData"),Y2=Symbol("emitEnd"),i1=Symbol("emitEnd2"),ah=Symbol("async"),a1=Symbol("abort"),bE=Symbol("aborted"),Mw=Symbol("signal"),yg=Symbol("dataListeners"),Om=Symbol("discarded"),jw=n=>Promise.resolve().then(n),L8=n=>n(),E8=n=>n==="end"||n==="finish"||n==="prefinish",A8=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,_8=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),CD=class{src;dest;opts;ondrain;constructor(n,r,f){this.src=n,this.dest=r,this.opts=f,this.ondrain=()=>n[ey](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(n){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},S8=class extends CD{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(n,r,f){super(n,r,f),this.proxyErrors=h=>this.dest.emit("error",h),n.on("error",this.proxyErrors)}},I8=n=>!!n.objectMode,T8=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",CE=class extends b1{[rm]=!1;[Pw]=!1;[bm]=[];[sm]=[];[cm];[Km];[ah];[Qg];[wh]=!1;[Wh]=!1;[cE]=!1;[fE]=!1;[Uw]=null;[om]=0;[Gv]=!1;[Mw];[bE]=!1;[yg]=0;[Om]=!1;writable=!0;readable=!0;constructor(...n){let r=n[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");I8(r)?(this[cm]=!0,this[Km]=null):T8(r)?(this[Km]=r.encoding,this[cm]=!1):(this[cm]=!1,this[Km]=null),this[ah]=!!r.async,this[Qg]=this[Km]?new g8(this[Km]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[sm]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[bm]});let{signal:f}=r;f&&(this[Mw]=f,f.aborted?this[a1]():f.addEventListener("abort",()=>this[a1]()))}get bufferLength(){return this[om]}get encoding(){return this[Km]}set encoding(n){throw new Error("Encoding must be set at instantiation time")}setEncoding(n){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[cm]}set objectMode(n){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ah]}set async(n){this[ah]=this[ah]||!!n}[a1](){this[bE]=!0,this.emit("abort",this[Mw]?.reason),this.destroy(this[Mw]?.reason)}get aborted(){return this[bE]}set aborted(n){}write(n,r,f){if(this[bE])return!1;if(this[wh])throw new Error("write after end");if(this[Gv])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(f=r,r="utf8"),r||(r="utf8");let h=this[ah]?jw:L8;if(!this[cm]&&!Buffer.isBuffer(n)){if(_8(n))n=Buffer.from(n.buffer,n.byteOffset,n.byteLength);else if(A8(n))n=Buffer.from(n);else if(typeof n!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[cm]?(this[rm]&&this[om]!==0&&this[dE](!0),this[rm]?this.emit("data",n):this[r1](n),this[om]!==0&&this.emit("readable"),f&&h(f),this[rm]):n.length?(typeof n=="string"&&!(r===this[Km]&&!this[Qg]?.lastNeed)&&(n=Buffer.from(n,r)),Buffer.isBuffer(n)&&this[Km]&&(n=this[Qg].write(n)),this[rm]&&this[om]!==0&&this[dE](!0),this[rm]?this.emit("data",n):this[r1](n),this[om]!==0&&this.emit("readable"),f&&h(f),this[rm]):(this[om]!==0&&this.emit("readable"),f&&h(f),this[rm])}read(n){if(this[Gv])return null;if(this[Om]=!1,this[om]===0||n===0||n&&n>this[om])return this[Ch](),null;this[cm]&&(n=null),this[sm].length>1&&!this[cm]&&(this[sm]=[this[Km]?this[sm].join(""):Buffer.concat(this[sm],this[om])]);let r=this[V2](n||null,this[sm][0]);return this[Ch](),r}[V2](n,r){if(this[cm])this[pE]();else{let f=r;n===f.length||n===null?this[pE]():typeof f=="string"?(this[sm][0]=f.slice(n),r=f.slice(0,n),this[om]-=n):(this[sm][0]=f.subarray(n),r=f.subarray(0,n),this[om]-=n)}return this.emit("data",r),!this[sm].length&&!this[wh]&&this.emit("drain"),r}end(n,r,f){return typeof n=="function"&&(f=n,n=void 0),typeof r=="function"&&(f=r,r="utf8"),n!==void 0&&this.write(n,r),f&&this.once("end",f),this[wh]=!0,this.writable=!1,(this[rm]||!this[Pw])&&this[Ch](),this}[ey](){this[Gv]||(!this[yg]&&!this[bm].length&&(this[Om]=!0),this[Pw]=!1,this[rm]=!0,this.emit("resume"),this[sm].length?this[dE]():this[wh]?this[Ch]():this.emit("drain"))}resume(){return this[ey]()}pause(){this[rm]=!1,this[Pw]=!0,this[Om]=!1}get destroyed(){return this[Gv]}get flowing(){return this[rm]}get paused(){return this[Pw]}[r1](n){this[cm]?this[om]+=1:this[om]+=n.length,this[sm].push(n)}[pE](){return this[cm]?this[om]-=1:this[om]-=this[sm][0].length,this[sm].shift()}[dE](n=!1){do;while(this[H2](this[pE]())&&this[sm].length);!n&&!this[sm].length&&!this[wh]&&this.emit("drain")}[H2](n){return this.emit("data",n),this[rm]}pipe(n,r){if(this[Gv])return n;this[Om]=!1;let f=this[Wh];return r=r||{},n===q2.stdout||n===q2.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,f?r.end&&n.end():(this[bm].push(r.proxyErrors?new S8(this,n,r):new CD(this,n,r)),this[ah]?jw(()=>this[ey]()):this[ey]()),n}unpipe(n){let r=this[bm].find(f=>f.dest===n);r&&(this[bm].length===1?(this[rm]&&this[yg]===0&&(this[rm]=!1),this[bm]=[]):this[bm].splice(this[bm].indexOf(r),1),r.unpipe())}addListener(n,r){return this.on(n,r)}on(n,r){let f=super.on(n,r);if(n==="data")this[Om]=!1,this[yg]++,!this[bm].length&&!this[rm]&&this[ey]();else if(n==="readable"&&this[om]!==0)super.emit("readable");else if(E8(n)&&this[Wh])super.emit(n),this.removeAllListeners(n);else if(n==="error"&&this[Uw]){let h=r;this[ah]?jw(()=>h.call(this,this[Uw])):h.call(this,this[Uw])}return f}removeListener(n,r){return this.off(n,r)}off(n,r){let f=super.off(n,r);return n==="data"&&(this[yg]=this.listeners("data").length,this[yg]===0&&!this[Om]&&!this[bm].length&&(this[rm]=!1)),f}removeAllListeners(n){let r=super.removeAllListeners(n);return(n==="data"||n===void 0)&&(this[yg]=0,!this[Om]&&!this[bm].length&&(this[rm]=!1)),r}get emittedEnd(){return this[Wh]}[Ch](){!this[cE]&&!this[Wh]&&!this[Gv]&&this[sm].length===0&&this[wh]&&(this[cE]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[fE]&&this.emit("close"),this[cE]=!1)}emit(n,...r){let f=r[0];if(n!=="error"&&n!=="close"&&n!==Gv&&this[Gv])return!1;if(n==="data")return!this[cm]&&!f?!1:this[ah]?(jw(()=>this[o1](f)),!0):this[o1](f);if(n==="end")return this[Y2]();if(n==="close"){if(this[fE]=!0,!this[Wh]&&!this[Gv])return!1;let l=super.emit("close");return this.removeAllListeners("close"),l}else if(n==="error"){this[Uw]=f,super.emit(s1,f);let l=!this[Mw]||this.listeners("error").length?super.emit("error",f):!1;return this[Ch](),l}else if(n==="resume"){let l=super.emit("resume");return this[Ch](),l}else if(n==="finish"||n==="prefinish"){let l=super.emit(n);return this.removeAllListeners(n),l}let h=super.emit(n,...r);return this[Ch](),h}[o1](n){for(let f of this[bm])f.dest.write(n)===!1&&this.pause();let r=this[Om]?!1:super.emit("data",n);return this[Ch](),r}[Y2](){return this[Wh]?!1:(this[Wh]=!0,this.readable=!1,this[ah]?(jw(()=>this[i1]()),!0):this[i1]())}[i1](){if(this[Qg]){let r=this[Qg].end();if(r){for(let f of this[bm])f.dest.write(r);this[Om]||super.emit("data",r)}}for(let r of this[bm])r.end();let n=super.emit("end");return this.removeAllListeners("end"),n}async collect(){let n=Object.assign([],{dataLength:0});this[cm]||(n.dataLength=0);let r=this.promise();return this.on("data",f=>{n.push(f),this[cm]||(n.dataLength+=f.length)}),await r,n}async concat(){if(this[cm])throw new Error("cannot concat in objectMode");let n=await this.collect();return this[Km]?n.join(""):Buffer.concat(n,n.dataLength)}async promise(){return new Promise((n,r)=>{this.on(Gv,()=>r(new Error("stream destroyed"))),this.on("error",f=>r(f)),this.on("end",()=>n())})}[Symbol.asyncIterator](){this[Om]=!1;let n=!1,r=async()=>(this.pause(),n=!0,{value:void 0,done:!0});return{next:()=>{if(n)return r();let f=this.read();if(f!==null)return Promise.resolve({done:!1,value:f});if(this[wh])return r();let h,l,t=qe=>{this.off("data",$),this.off("end",re),this.off(Gv,e),r(),l(qe)},$=qe=>{this.off("error",t),this.off("end",re),this.off(Gv,e),this.pause(),h({value:qe,done:!!this[wh]})},re=()=>{this.off("error",t),this.off("data",$),this.off(Gv,e),r(),h({done:!0,value:void 0})},e=()=>t(new Error("stream destroyed"));return new Promise((qe,ht)=>{l=ht,h=qe,this.once(Gv,e),this.once("error",t),this.once("end",re),this.once("data",$)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Om]=!1;let n=!1,r=()=>(this.pause(),this.off(s1,r),this.off(Gv,r),this.off("end",r),n=!0,{done:!0,value:void 0}),f=()=>{if(n)return r();let h=this.read();return h===null?r():{done:!1,value:h}};return this.once("end",r),this.once(s1,r),this.once(Gv,r),{next:f,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(n){if(this[Gv])return n?this.emit("error",n):this.emit(Gv),this;this[Gv]=!0,this[Om]=!0,this[sm].length=0,this[om]=0;let r=this;return typeof r.close=="function"&&!this[fE]&&r.close(),n?this.emit("error",n):this.emit(Gv),this}static get isStream(){return y8}},x8=d8.native,Bw={lstatSync:u8,readdir:l8,readdirSync:c8,readlinkSync:f8,realpathSync:x8,promises:{lstat:b8,readdir:v8,readlink:m8,realpath:h8}},LD=n=>!n||n===Bw||n===p8?Bw:{...Bw,...n,promises:{...Bw.promises,...n.promises||{}}},ED=/^\\\\\?\\([a-z]:)\\?$/i,k8=n=>n.replace(/\//g,"\\").replace(ED,"$1\\"),R8=/[\\\/]/,Gm=0,AD=1,_D=2,uh=4,SD=6,ID=8,wg=10,TD=12,zm=15,Fw=~zm,u1=16,W2=32,qw=64,Jm=128,vE=256,gE=512,Z2=qw|Jm|gE,N8=1023,l1=n=>n.isFile()?ID:n.isDirectory()?uh:n.isSymbolicLink()?wg:n.isCharacterDevice()?_D:n.isBlockDevice()?SD:n.isSocket()?TD:n.isFIFO()?AD:Gm,K2=new LE({max:2**12}),Vw=n=>{let r=K2.get(n);if(r)return r;let f=n.normalize("NFKD");return K2.set(n,f),f},J2=new LE({max:2**12}),mE=n=>{let r=J2.get(n);if(r)return r;let f=Vw(n.toLowerCase());return J2.set(n,f),f},X2=class extends LE{constructor(){super({max:256})}},O8=class extends LE{constructor(n=16*1024){super({maxSize:n,sizeCalculation:r=>r.length+1})}},xD=Symbol("PathScurry setAsCwd"),Sm=class{name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#w;get gid(){return this.#w}#h;get rdev(){return this.#h}#c;get blksize(){return this.#c}#a;get ino(){return this.#a}#d;get size(){return this.#d}#f;get blocks(){return this.#f}#u;get atimeMs(){return this.#u}#r;get mtimeMs(){return this.#r}#p;get ctimeMs(){return this.#p}#C;get birthtimeMs(){return this.#C}#y;get atime(){return this.#y}#b;get mtime(){return this.#b}#T;get ctime(){return this.#T}#v;get birthtime(){return this.#v}#A;#_;#m;#g;#L;#S;#t;#$;#N;#I;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(n,r=Gm,f,h,l,t,$){this.name=n,this.#A=l?mE(n):Vw(n),this.#t=r&N8,this.nocase=l,this.roots=h,this.root=f||this,this.#$=t,this.#m=$.fullpath,this.#L=$.relative,this.#S=$.relativePosix,this.parent=$.parent,this.parent?this.#e=this.parent.#e:this.#e=LD($.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#$}resolve(n){if(!n)return this;let r=this.getRootString(n),f=n.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#O(f):this.#O(f)}#O(n){let r=this;for(let f of n)r=r.child(f);return r}children(){let n=this.#$.get(this);if(n)return n;let r=Object.assign([],{provisional:0});return this.#$.set(this,r),this.#t&=~u1,r}child(n,r){if(n===""||n===".")return this;if(n==="..")return this.parent||this;let f=this.children(),h=this.nocase?mE(n):Vw(n);for(let re of f)if(re.#A===h)return re;let l=this.parent?this.sep:"",t=this.#m?this.#m+l+n:void 0,$=this.newChild(n,Gm,{...r,parent:this,fullpath:t});return this.canReaddir()||($.#t|=Jm),f.push($),$}relative(){if(this.isCWD)return"";if(this.#L!==void 0)return this.#L;let n=this.name,r=this.parent;if(!r)return this.#L=this.name;let f=r.relative();return f+(!f||!r.parent?"":this.sep)+n}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let n=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let f=r.relativePosix();return f+(!f||!r.parent?"":"/")+n}fullpath(){if(this.#m!==void 0)return this.#m;let n=this.name,r=this.parent;if(!r)return this.#m=this.name;let f=r.fullpath()+(r.parent?this.sep:"")+n;return this.#m=f}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let h=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(h)?this.#g=`//?/${h}`:this.#g=h}let n=this.parent,r=n.fullpathPosix(),f=r+(!r||!n.parent?"":"/")+this.name;return this.#g=f}isUnknown(){return(this.#t&zm)===Gm}isType(n){return this[`is${n}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#t&zm)===ID}isDirectory(){return(this.#t&zm)===uh}isCharacterDevice(){return(this.#t&zm)===_D}isBlockDevice(){return(this.#t&zm)===SD}isFIFO(){return(this.#t&zm)===AD}isSocket(){return(this.#t&zm)===TD}isSymbolicLink(){return(this.#t&wg)===wg}lstatCached(){return this.#t&W2?this:void 0}readlinkCached(){return this.#N}realpathCached(){return this.#I}readdirCached(){let n=this.children();return n.slice(0,n.provisional)}canReadlink(){if(this.#N)return!0;if(!this.parent)return!1;let n=this.#t&zm;return!(n!==Gm&&n!==wg||this.#t&vE||this.#t&Jm)}calledReaddir(){return!!(this.#t&u1)}isENOENT(){return!!(this.#t&Jm)}isNamed(n){return this.nocase?this.#A===mE(n):this.#A===Vw(n)}async readlink(){let n=this.#N;if(n)return n;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),f=(await this.parent.realpath())?.resolve(r);if(f)return this.#N=f}catch(r){this.#R(r.code);return}}readlinkSync(){let n=this.#N;if(n)return n;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),f=this.parent.realpathSync()?.resolve(r);if(f)return this.#N=f}catch(r){this.#R(r.code);return}}#M(n){this.#t|=u1;for(let r=n.provisional;r<n.length;r++){let f=n[r];f&&f.#E()}}#E(){this.#t&Jm||(this.#t=(this.#t|Jm)&Fw,this.#q())}#q(){let n=this.children();n.provisional=0;for(let r of n)r.#E()}#P(){this.#t|=gE,this.#D()}#D(){if(this.#t&qw)return;let n=this.#t;(n&zm)===uh&&(n&=Fw),this.#t=n|qw,this.#q()}#j(n=""){n==="ENOTDIR"||n==="EPERM"?this.#D():n==="ENOENT"?this.#E():this.children().provisional=0}#k(n=""){n==="ENOTDIR"?this.parent.#D():n==="ENOENT"&&this.#E()}#R(n=""){let r=this.#t;r|=vE,n==="ENOENT"&&(r|=Jm),(n==="EINVAL"||n==="UNKNOWN")&&(r&=Fw),this.#t=r,n==="ENOTDIR"&&this.parent&&this.parent.#D()}#F(n,r){return this.#G(n,r)||this.#z(n,r)}#z(n,r){let f=l1(n),h=this.newChild(n.name,f,{parent:this}),l=h.#t&zm;return l!==uh&&l!==wg&&l!==Gm&&(h.#t|=qw),r.unshift(h),r.provisional++,h}#G(n,r){for(let f=r.provisional;f<r.length;f++){let h=r[f];if((this.nocase?mE(n.name):Vw(n.name))===h.#A)return this.#l(n,h,f,r)}}#l(n,r,f,h){let l=r.name;return r.#t=r.#t&Fw|l1(n),l!==n.name&&(r.name=n.name),f!==h.provisional&&(f===h.length-1?h.pop():h.splice(f,1),h.unshift(r)),h.provisional++,r}async lstat(){if((this.#t&Jm)===0)try{return this.#B(await this.#e.promises.lstat(this.fullpath())),this}catch(n){this.#k(n.code)}}lstatSync(){if((this.#t&Jm)===0)try{return this.#B(this.#e.lstatSync(this.fullpath())),this}catch(n){this.#k(n.code)}}#B(n){let{atime:r,atimeMs:f,birthtime:h,birthtimeMs:l,blksize:t,blocks:$,ctime:re,ctimeMs:e,dev:qe,gid:ht,ino:Ke,mode:gt,mtime:ln,mtimeMs:Qn,nlink:bn,rdev:zr,size:tr,uid:Er}=n;this.#y=r,this.#u=f,this.#v=h,this.#C=l,this.#c=t,this.#f=$,this.#T=re,this.#p=e,this.#n=qe,this.#w=ht,this.#a=Ke,this.#o=gt,this.#b=ln,this.#r=Qn,this.#s=bn,this.#h=zr,this.#d=tr,this.#i=Er;let cs=l1(n);this.#t=this.#t&Fw|cs|W2,cs!==Gm&&cs!==uh&&cs!==wg&&(this.#t|=qw)}#U=[];#x=!1;#V(n){this.#x=!1;let r=this.#U.slice();this.#U.length=0,r.forEach(f=>f(null,n))}readdirCB(n,r=!1){if(!this.canReaddir()){r?n(null,[]):queueMicrotask(()=>n(null,[]));return}let f=this.children();if(this.calledReaddir()){let l=f.slice(0,f.provisional);r?n(null,l):queueMicrotask(()=>n(null,l));return}if(this.#U.push(n),this.#x)return;this.#x=!0;let h=this.fullpath();this.#e.readdir(h,{withFileTypes:!0},(l,t)=>{if(l)this.#j(l.code),f.provisional=0;else{for(let $ of t)this.#F($,f);this.#M(f)}this.#V(f.slice(0,f.provisional))})}#H;async readdir(){if(!this.canReaddir())return[];let n=this.children();if(this.calledReaddir())return n.slice(0,n.provisional);let r=this.fullpath();if(this.#H)await this.#H;else{let f=()=>{};this.#H=new Promise(h=>f=h);try{for(let h of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#F(h,n);this.#M(n)}catch(h){this.#j(h.code),n.provisional=0}this.#H=void 0,f()}return n.slice(0,n.provisional)}readdirSync(){if(!this.canReaddir())return[];let n=this.children();if(this.calledReaddir())return n.slice(0,n.provisional);let r=this.fullpath();try{for(let f of this.#e.readdirSync(r,{withFileTypes:!0}))this.#F(f,n);this.#M(n)}catch(f){this.#j(f.code),n.provisional=0}return n.slice(0,n.provisional)}canReaddir(){if(this.#t&Z2)return!1;let n=zm&this.#t;return n===Gm||n===uh||n===wg}shouldWalk(n,r){return(this.#t&uh)===uh&&!(this.#t&Z2)&&!n.has(this)&&(!r||r(this))}async realpath(){if(this.#I)return this.#I;if(!((gE|vE|Jm)&this.#t))try{let n=await this.#e.promises.realpath(this.fullpath());return this.#I=this.resolve(n)}catch{this.#P()}}realpathSync(){if(this.#I)return this.#I;if(!((gE|vE|Jm)&this.#t))try{let n=this.#e.realpathSync(this.fullpath());return this.#I=this.resolve(n)}catch{this.#P()}}[xD](n){if(n===this)return;n.isCWD=!1,this.isCWD=!0;let r=new Set([]),f=[],h=this;for(;h&&h.parent;)r.add(h),h.#L=f.join(this.sep),h.#S=f.join("/"),h=h.parent,f.push("..");for(h=n;h&&h.parent&&!r.has(h);)h.#L=void 0,h.#S=void 0,h=h.parent}},kD=class RD extends Sm{sep="\\";splitSep=R8;constructor(r,f=Gm,h,l,t,$,re){super(r,f,h,l,t,$,re)}newChild(r,f=Gm,h={}){return new RD(r,f,this.root,this.roots,this.nocase,this.childrenCache(),h)}getRootString(r){return f1.parse(r).root}getRoot(r){if(r=k8(r.toUpperCase()),r===this.root.name)return this.root;for(let[f,h]of Object.entries(this.roots))if(this.sameRoot(r,f))return this.roots[r]=h;return this.roots[r]=new v1(r,this).root}sameRoot(r,f=this.root.name){return r=r.toUpperCase().replace(/\//g,"\\").replace(ED,"$1\\"),r===f}},ND=class OD extends Sm{splitSep="/";sep="/";constructor(r,f=Gm,h,l,t,$,re){super(r,f,h,l,t,$,re)}getRootString(r){return r.startsWith("/")?"/":""}getRoot(r){return this.root}newChild(r,f=Gm,h={}){return new OD(r,f,this.root,this.roots,this.nocase,this.childrenCache(),h)}},$D=class{root;rootPath;roots;cwd;#e;#n;#o;nocase;#s;constructor(n=process.cwd(),r,f,{nocase:h,childrenCacheSize:l=16*1024,fs:t=Bw}={}){this.#s=LD(t),(n instanceof URL||n.startsWith("file://"))&&(n=a8(n));let $=r.resolve(n);this.roots=Object.create(null),this.rootPath=this.parseRootPath($),this.#e=new X2,this.#n=new X2,this.#o=new O8(l);let re=$.substring(this.rootPath.length).split(f);if(re.length===1&&!re[0]&&re.pop(),h===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=h,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let e=this.root,qe=re.length-1,ht=r.sep,Ke=this.rootPath,gt=!1;for(let ln of re){let Qn=qe--;e=e.child(ln,{relative:new Array(Qn).fill("..").join(ht),relativePosix:new Array(Qn).fill("..").join("/"),fullpath:Ke+=(gt?"":ht)+ln}),gt=!0}this.cwd=e}depth(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.depth()}childrenCache(){return this.#o}resolve(...n){let r="";for(let l=n.length-1;l>=0;l--){let t=n[l];if(!(!t||t===".")&&(r=r?`${t}/${r}`:t,this.isAbsolute(t)))break}let f=this.#e.get(r);if(f!==void 0)return f;let h=this.cwd.resolve(r).fullpath();return this.#e.set(r,h),h}resolvePosix(...n){let r="";for(let l=n.length-1;l>=0;l--){let t=n[l];if(!(!t||t===".")&&(r=r?`${t}/${r}`:t,this.isAbsolute(t)))break}let f=this.#n.get(r);if(f!==void 0)return f;let h=this.cwd.resolve(r).fullpathPosix();return this.#n.set(r,h),h}relative(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.relative()}relativePosix(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.relativePosix()}basename(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.name}dirname(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),(n.parent||n).fullpath()}async readdir(n=this.cwd,r={withFileTypes:!0}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f}=r;if(n.canReaddir()){let h=await n.readdir();return f?h:h.map(l=>l.name)}else return[]}readdirSync(n=this.cwd,r={withFileTypes:!0}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0}=r;return n.canReaddir()?f?n.readdirSync():n.readdirSync().map(h=>h.name):[]}async lstat(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.lstat()}lstatSync(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.lstatSync()}async readlink(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=await n.readlink();return r?f:f?.fullpath()}readlinkSync(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=n.readlinkSync();return r?f:f?.fullpath()}async realpath(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=await n.realpath();return r?f:f?.fullpath()}realpathSync(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=n.realpathSync();return r?f:f?.fullpath()}async walk(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=[];(!l||l(n))&&$.push(f?n:n.fullpath());let re=new Set,e=(ht,Ke)=>{re.add(ht),ht.readdirCB((gt,ln)=>{if(gt)return Ke(gt);let Qn=ln.length;if(!Qn)return Ke();let bn=()=>{--Qn===0&&Ke()};for(let zr of ln)(!l||l(zr))&&$.push(f?zr:zr.fullpath()),h&&zr.isSymbolicLink()?zr.realpath().then(tr=>tr?.isUnknown()?tr.lstat():tr).then(tr=>tr?.shouldWalk(re,t)?e(tr,bn):bn()):zr.shouldWalk(re,t)?e(zr,bn):bn()},!0)},qe=n;return new Promise((ht,Ke)=>{e(qe,gt=>{if(gt)return Ke(gt);ht($)})})}walkSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=[];(!l||l(n))&&$.push(f?n:n.fullpath());let re=new Set([n]);for(let e of re){let qe=e.readdirSync();for(let ht of qe){(!l||l(ht))&&$.push(f?ht:ht.fullpath());let Ke=ht;if(ht.isSymbolicLink()){if(!(h&&(Ke=ht.realpathSync())))continue;Ke.isUnknown()&&Ke.lstatSync()}Ke.shouldWalk(re,t)&&re.add(Ke)}}return $}[Symbol.asyncIterator](){return this.iterate()}iterate(n=this.cwd,r={}){return typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd),this.stream(n,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r;(!l||l(n))&&(yield f?n:n.fullpath());let $=new Set([n]);for(let re of $){let e=re.readdirSync();for(let qe of e){(!l||l(qe))&&(yield f?qe:qe.fullpath());let ht=qe;if(qe.isSymbolicLink()){if(!(h&&(ht=qe.realpathSync())))continue;ht.isUnknown()&&ht.lstatSync()}ht.shouldWalk($,t)&&$.add(ht)}}}stream(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=new CE({objectMode:!0});(!l||l(n))&&$.write(f?n:n.fullpath());let re=new Set,e=[n],qe=0,ht=()=>{let Ke=!1;for(;!Ke;){let gt=e.shift();if(!gt){qe===0&&$.end();return}qe++,re.add(gt);let ln=(bn,zr,tr=!1)=>{if(bn)return $.emit("error",bn);if(h&&!tr){let Er=[];for(let cs of zr)cs.isSymbolicLink()&&Er.push(cs.realpath().then(Ys=>Ys?.isUnknown()?Ys.lstat():Ys));if(Er.length){Promise.all(Er).then(()=>ln(null,zr,!0));return}}for(let Er of zr)Er&&(!l||l(Er))&&($.write(f?Er:Er.fullpath())||(Ke=!0));qe--;for(let Er of zr){let cs=Er.realpathCached()||Er;cs.shouldWalk(re,t)&&e.push(cs)}Ke&&!$.flowing?$.once("drain",ht):Qn||ht()},Qn=!0;gt.readdirCB(ln,!0),Qn=!1}};return ht(),$}streamSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=new CE({objectMode:!0}),re=new Set;(!l||l(n))&&$.write(f?n:n.fullpath());let e=[n],qe=0,ht=()=>{let Ke=!1;for(;!Ke;){let gt=e.shift();if(!gt){qe===0&&$.end();return}qe++,re.add(gt);let ln=gt.readdirSync();for(let Qn of ln)(!l||l(Qn))&&($.write(f?Qn:Qn.fullpath())||(Ke=!0));qe--;for(let Qn of ln){let bn=Qn;if(Qn.isSymbolicLink()){if(!(h&&(bn=Qn.realpathSync())))continue;bn.isUnknown()&&bn.lstatSync()}bn.shouldWalk(re,t)&&e.push(bn)}}Ke&&!$.flowing&&$.once("drain",ht)};return ht(),$}chdir(n=this.cwd){let r=this.cwd;this.cwd=typeof n=="string"?this.cwd.resolve(n):n,this.cwd[xD](r)}},v1=class extends $D{sep="\\";constructor(n=process.cwd(),r={}){let{nocase:f=!0}=r;super(n,f1,"\\",{...r,nocase:f}),this.nocase=f;for(let h=this.cwd;h;h=h.parent)h.nocase=this.nocase}parseRootPath(n){return f1.parse(n).root.toUpperCase()}newRoot(n){return new kD(this.rootPath,uh,void 0,this.roots,this.nocase,this.childrenCache(),{fs:n})}isAbsolute(n){return n.startsWith("/")||n.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(n)}},m1=class extends $D{sep="/";constructor(n=process.cwd(),r={}){let{nocase:f=!1}=r;super(n,i8,"/",{...r,nocase:f}),this.nocase=f}parseRootPath(n){return"/"}newRoot(n){return new ND(this.rootPath,uh,void 0,this.roots,this.nocase,this.childrenCache(),{fs:n})}isAbsolute(n){return n.startsWith("/")}},DD=class extends m1{constructor(n=process.cwd(),r={}){let{nocase:f=!0}=r;super(n,{...r,nocase:f})}},dQ=process.platform==="win32"?kD:ND,$8=process.platform==="win32"?v1:process.platform==="darwin"?DD:m1,D8=n=>n.length>=1,U8=n=>n.length>=1,P8=Symbol.for("nodejs.util.inspect.custom"),UD=class PD{#e;#n;#o;length;#s;#i;#w;#h;#c;#a;#d=!0;constructor(r,f,h,l){if(!D8(r))throw new TypeError("empty pattern list");if(!U8(f))throw new TypeError("empty glob list");if(f.length!==r.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=r.length,h<0||h>=this.length)throw new TypeError("index out of range");if(this.#e=r,this.#n=f,this.#o=h,this.#s=l,this.#o===0){if(this.isUNC()){let[t,$,re,e,...qe]=this.#e,[ht,Ke,gt,ln,...Qn]=this.#n;qe[0]===""&&(qe.shift(),Qn.shift());let bn=[t,$,re,e,""].join("/"),zr=[ht,Ke,gt,ln,""].join("/");this.#e=[bn,...qe],this.#n=[zr,...Qn],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[t,...$]=this.#e,[re,...e]=this.#n;$[0]===""&&($.shift(),e.shift());let qe=t+"/",ht=re+"/";this.#e=[qe,...$],this.#n=[ht,...e],this.length=this.#e.length}}}[P8](){return"Pattern <"+this.#n.slice(this.#o).join("/")+">"}pattern(){return this.#e[this.#o]}isString(){return typeof this.#e[this.#o]=="string"}isGlobstar(){return this.#e[this.#o]===vm}isRegExp(){return this.#e[this.#o]instanceof RegExp}globString(){return this.#w=this.#w||(this.#o===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new PD(this.#e,this.#n,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#c=this.#c,this.#i.#h=this.#h,this.#i):this.#i=null}isUNC(){let r=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#s==="win32"&&this.#o===0&&r[0]===""&&r[1]===""&&typeof r[2]=="string"&&!!r[2]&&typeof r[3]=="string"&&!!r[3]}isDrive(){let r=this.#e;return this.#h!==void 0?this.#h:this.#h=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0])}isAbsolute(){let r=this.#e;return this.#a!==void 0?this.#a:this.#a=r[0]===""&&r.length>1||this.isDrive()||this.isUNC()}root(){let r=this.#e[0];return typeof r=="string"&&this.isAbsolute()&&this.#o===0?r:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#d)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#d?!1:(this.#d=!1,!0)}},M8=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Q2=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(n,{nobrace:r,nocase:f,noext:h,noglobstar:l,platform:t=M8}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=t,this.mmopts={dot:!0,nobrace:r,nocase:f,noext:h,noglobstar:l,optimizationLevel:2,platform:t,nocomment:!0,nonegate:!0};for(let $ of n)this.add($)}add(n){let r=new Kh(n,this.mmopts);for(let f=0;f<r.set.length;f++){let h=r.set[f],l=r.globParts[f];if(!h||!l)throw new Error("invalid pattern object");for(;h[0]==="."&&l[0]===".";)h.shift(),l.shift();let t=new UD(h,l,0,this.platform),$=new Kh(t.globString(),this.mmopts),re=l[l.length-1]==="**",e=t.isAbsolute();e?this.absolute.push($):this.relative.push($),re&&(e?this.absoluteChildren.push($):this.relativeChildren.push($))}}ignored(n){let r=n.fullpath(),f=`${r}/`,h=n.relative()||".",l=`${h}/`;for(let t of this.relative)if(t.match(h)||t.match(l))return!0;for(let t of this.absolute)if(t.match(r)||t.match(f))return!0;return!1}childrenIgnored(n){let r=n.fullpath()+"/",f=(n.relative()||".")+"/";for(let h of this.relativeChildren)if(h.match(f))return!0;for(let h of this.absoluteChildren)if(h.match(r))return!0;return!1}},j8=class MD{store;constructor(r=new Map){this.store=r}copy(){return new MD(new Map(this.store))}hasWalked(r,f){return this.store.get(r.fullpath())?.has(f.globString())}storeWalked(r,f){let h=r.fullpath(),l=this.store.get(h);l?l.add(f.globString()):this.store.set(h,new Set([f.globString()]))}},F8=class{store=new Map;add(n,r,f){let h=(r?2:0)|(f?1:0),l=this.store.get(n);this.store.set(n,l===void 0?h:h&l)}entries(){return[...this.store.entries()].map(([n,r])=>[n,!!(r&2),!!(r&1)])}},z8=class{store=new Map;add(n,r){if(!n.canReaddir())return;let f=this.store.get(n);f?f.find(h=>h.globString()===r.globString())||f.push(r):this.store.set(n,[r])}get(n){let r=this.store.get(n);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(n=>[n,this.store.get(n)])}keys(){return[...this.store.keys()].filter(n=>n.canReaddir())}},eD=class jD{hasWalkedCache;matches=new F8;subwalks=new z8;patterns;follow;dot;opts;constructor(r,f){this.opts=r,this.follow=!!r.follow,this.dot=!!r.dot,this.hasWalkedCache=f?f.copy():new j8}processPatterns(r,f){this.patterns=f;let h=f.map(l=>[r,l]);for(let[l,t]of h){this.hasWalkedCache.storeWalked(l,t);let $=t.root(),re=t.isAbsolute()&&this.opts.absolute!==!1;if($){l=l.resolve($==="/"&&this.opts.root!==void 0?this.opts.root:$);let Ke=t.rest();if(Ke)t=Ke;else{this.matches.add(l,!0,!1);continue}}if(l.isENOENT())continue;let e,qe,ht=!1;for(;typeof(e=t.pattern())=="string"&&(qe=t.rest());)l=l.resolve(e),t=qe,ht=!0;if(e=t.pattern(),qe=t.rest(),ht){if(this.hasWalkedCache.hasWalked(l,t))continue;this.hasWalkedCache.storeWalked(l,t)}if(typeof e=="string"){let Ke=e===".."||e===""||e===".";this.matches.add(l.resolve(e),re,Ke);continue}else if(e===vm){(!l.isSymbolicLink()||this.follow||t.checkFollowGlobstar())&&this.subwalks.add(l,t);let Ke=qe?.pattern(),gt=qe?.rest();if(!qe||(Ke===""||Ke===".")&&!gt)this.matches.add(l,re,Ke===""||Ke===".");else if(Ke===".."){let ln=l.parent||l;gt?this.hasWalkedCache.hasWalked(ln,gt)||this.subwalks.add(ln,gt):this.matches.add(ln,re,!0)}}else e instanceof RegExp&&this.subwalks.add(l,t)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new jD(this.opts,this.hasWalkedCache)}filterEntries(r,f){let h=this.subwalks.get(r),l=this.child();for(let t of f)for(let $ of h){let re=$.isAbsolute(),e=$.pattern(),qe=$.rest();e===vm?l.testGlobstar(t,$,qe,re):e instanceof RegExp?l.testRegExp(t,e,qe,re):l.testString(t,e,qe,re)}return l}testGlobstar(r,f,h,l){if((this.dot||!r.name.startsWith("."))&&(f.hasMore()||this.matches.add(r,l,!1),r.canReaddir()&&(this.follow||!r.isSymbolicLink()?this.subwalks.add(r,f):r.isSymbolicLink()&&(h&&f.checkFollowGlobstar()?this.subwalks.add(r,h):f.markFollowGlobstar()&&this.subwalks.add(r,f)))),h){let t=h.pattern();if(typeof t=="string"&&t!==".."&&t!==""&&t!==".")this.testString(r,t,h.rest(),l);else if(t===".."){let $=r.parent||r;this.subwalks.add($,h)}else t instanceof RegExp&&this.testRegExp(r,t,h.rest(),l)}}testRegExp(r,f,h,l){f.test(r.name)&&(h?this.subwalks.add(r,h):this.matches.add(r,l,!1))}testString(r,f,h,l){r.isNamed(f)&&(h?this.subwalks.add(r,h):this.matches.add(r,l,!1))}},G8=(n,r)=>typeof n=="string"?new Q2([n],r):Array.isArray(n)?new Q2(n,r):n,FD=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#o;signal;maxDepth;includeChildMatches;constructor(n,r,f){if(this.patterns=n,this.path=r,this.opts=f,this.#o=!f.posix&&f.platform==="win32"?"\\":"/",this.includeChildMatches=f.includeChildMatches!==!1,(f.ignore||!this.includeChildMatches)&&(this.#n=G8(f.ignore??[],f),!this.includeChildMatches&&typeof this.#n.add!="function")){let h="cannot ignore child matches, ignore lacks add() method.";throw new Error(h)}this.maxDepth=f.maxDepth||1/0,f.signal&&(this.signal=f.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#s(n){return this.seen.has(n)||!!this.#n?.ignored?.(n)}#i(n){return!!this.#n?.childrenIgnored?.(n)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let n;for(;!this.paused&&(n=this.#e.shift());)n()}onResume(n){this.signal?.aborted||(this.paused?this.#e.push(n):n())}async matchCheck(n,r){if(r&&this.opts.nodir)return;let f;if(this.opts.realpath){if(f=n.realpathCached()||await n.realpath(),!f)return;n=f}let h=n.isUnknown()||this.opts.stat?await n.lstat():n;if(this.opts.follow&&this.opts.nodir&&h?.isSymbolicLink()){let l=await h.realpath();l&&(l.isUnknown()||this.opts.stat)&&await l.lstat()}return this.matchCheckTest(h,r)}matchCheckTest(n,r){return n&&(this.maxDepth===1/0||n.depth()<=this.maxDepth)&&(!r||n.canReaddir())&&(!this.opts.nodir||!n.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!n.isSymbolicLink()||!n.realpathCached()?.isDirectory())&&!this.#s(n)?n:void 0}matchCheckSync(n,r){if(r&&this.opts.nodir)return;let f;if(this.opts.realpath){if(f=n.realpathCached()||n.realpathSync(),!f)return;n=f}let h=n.isUnknown()||this.opts.stat?n.lstatSync():n;if(this.opts.follow&&this.opts.nodir&&h?.isSymbolicLink()){let l=h.realpathSync();l&&(l?.isUnknown()||this.opts.stat)&&l.lstatSync()}return this.matchCheckTest(h,r)}matchFinish(n,r){if(this.#s(n))return;if(!this.includeChildMatches&&this.#n?.add){let l=`${n.relativePosix()}/**`;this.#n.add(l)}let f=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(n);let h=this.opts.mark&&n.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(n);else if(f){let l=this.opts.posix?n.fullpathPosix():n.fullpath();this.matchEmit(l+h)}else{let l=this.opts.posix?n.relativePosix():n.relative(),t=this.opts.dotRelative&&!l.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(l?t+l+h:"."+h)}}async match(n,r,f){let h=await this.matchCheck(n,f);h&&this.matchFinish(h,r)}matchSync(n,r,f){let h=this.matchCheckSync(n,f);h&&this.matchFinish(h,r)}walkCB(n,r,f){this.signal?.aborted&&f(),this.walkCB2(n,r,new eD(this.opts),f)}walkCB2(n,r,f,h){if(this.#i(n))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2(n,r,f,h));return}f.processPatterns(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||(l++,this.match($,re,e).then(()=>t()));for(let $ of f.subwalkTargets()){if(this.maxDepth!==1/0&&$.depth()>=this.maxDepth)continue;l++;let re=$.readdirCached();$.calledReaddir()?this.walkCB3($,re,f,t):$.readdirCB((e,qe)=>this.walkCB3($,qe,f,t),!0)}t()}walkCB3(n,r,f,h){f=f.filterEntries(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||(l++,this.match($,re,e).then(()=>t()));for(let[$,re]of f.subwalks.entries())l++,this.walkCB2($,re,f.child(),t);t()}walkCBSync(n,r,f){this.signal?.aborted&&f(),this.walkCB2Sync(n,r,new eD(this.opts),f)}walkCB2Sync(n,r,f,h){if(this.#i(n))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2Sync(n,r,f,h));return}f.processPatterns(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||this.matchSync($,re,e);for(let $ of f.subwalkTargets()){if(this.maxDepth!==1/0&&$.depth()>=this.maxDepth)continue;l++;let re=$.readdirSync();this.walkCB3Sync($,re,f,t)}t()}walkCB3Sync(n,r,f,h){f=f.filterEntries(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||this.matchSync($,re,e);for(let[$,re]of f.subwalks.entries())l++,this.walkCB2Sync($,re,f.child(),t);t()}},tD=class extends FD{matches=new Set;constructor(n,r,f){super(n,r,f)}matchEmit(n){this.matches.add(n)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((n,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):n(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},nD=class extends FD{results;constructor(n,r,f){super(n,r,f),this.results=new CE({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(n){this.results.write(n),this.results.flowing||this.pause()}stream(){let n=this.path;return n.isUnknown()?n.lstat().then(()=>{this.walkCB(n,this.patterns,()=>this.results.end())}):this.walkCB(n,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},B8=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Cg=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(n,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=n8(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof n=="string"&&(n=[n]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(n=n.map(re=>re.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");n=n.map(re=>re.includes("/")?re:`./**/${re}`)}if(this.pattern=n,this.platform=r.platform||B8,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let re=r.platform==="win32"?v1:r.platform==="darwin"?DD:r.platform?m1:$8;this.scurry=new re(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let f=this.platform==="darwin"||this.platform==="win32",h={braceExpandMax:1e4,...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:f,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},l=this.pattern.map(re=>new Kh(re,h)),[t,$]=l.reduce((re,e)=>(re[0].push(...e.set),re[1].push(...e.globParts),re),[[],[]]);this.patterns=t.map((re,e)=>{let qe=$[e];if(!qe)throw new Error("invalid pattern object");return new UD(re,qe,0,this.platform)})}async walk(){return[...await new tD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new tD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new nD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new nD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},q8=(n,r={})=>{Array.isArray(n)||(n=[n]);for(let f of n)if(new Kh(f,r).hasMagic())return!0;return!1};function EE(n,r={}){return new Cg(n,r).streamSync()}function zD(n,r={}){return new Cg(n,r).stream()}function GD(n,r={}){return new Cg(n,r).walkSync()}async function rD(n,r={}){return new Cg(n,r).walk()}function AE(n,r={}){return new Cg(n,r).iterateSync()}function BD(n,r={}){return new Cg(n,r).iterate()}var V8=EE,H8=Object.assign(zD,{sync:EE}),Y8=AE,W8=Object.assign(BD,{sync:AE}),Z8=Object.assign(GD,{stream:EE,iterate:AE}),Hw=Object.assign(rD,{glob:rD,globSync:GD,sync:Z8,globStream:zD,stream:H8,globStreamSync:EE,streamSync:V8,globIterate:BD,iterate:W8,globIterateSync:AE,iterateSync:Y8,Glob:Cg,hasMagic:q8,escape:fD,unescape:ty});Hw.glob=Hw;function eB(n){qD(n)||J8(n,{recursive:!0})}function tB(n,r){let f=Q8(n);eB(f);let h=qD(n),l=!1;return h&&(l=X8(n,"utf-8")===r),l||K8(n,r,"utf-8"),{path:n,created:!h,updated:h&&!l,unchanged:l}}function _E(n){let r=[];for(let{path:f,content:h}of n)r.push(tB(f,h));return{results:r,created:r.filter(f=>f.created).length,updated:r.filter(f=>f.updated).length,unchanged:r.filter(f=>f.unchanged).length,total:r.length}}var HY=nh(ih(),1);import{join as FC,extname as Nre}from"node:path";var ks={};hh(ks,{$brand:()=>R1,$input:()=>Qx,$output:()=>Xx,INVALID:()=>Cm,NEVER:()=>k1,TimePrecision:()=>ck,ZodAny:()=>XR,ZodArray:()=>nN,ZodBase64:()=>C_,ZodBase64URL:()=>L_,ZodBigInt:()=>jy,ZodBigIntFormat:()=>__,ZodBoolean:()=>My,ZodCIDRv4:()=>y_,ZodCIDRv6:()=>w_,ZodCUID:()=>d_,ZodCUID2:()=>p_,ZodCatch:()=>EN,ZodCodec:()=>DC,ZodCompileAsyncError:()=>Qm,ZodCompileUnsupportedError:()=>Xd,ZodCreditCard:()=>qR,ZodCustom:()=>UC,ZodCustomStringFormat:()=>Uy,ZodDate:()=>xC,ZodDefault:()=>hN,ZodDiscriminatedUnion:()=>sN,ZodE164:()=>E_,ZodEmail:()=>u_,ZodEmoji:()=>c_,ZodEnum:()=>$y,ZodError:()=>yY,ZodExactOptional:()=>x_,ZodFile:()=>pN,ZodFirstPartyTypeKind:()=>jN,ZodFunction:()=>ON,ZodGUID:()=>l_,ZodIBAN:()=>VR,ZodIPv4:()=>h_,ZodIPv6:()=>g_,ZodISODate:()=>ag,ZodISODateTime:()=>ig,ZodISODuration:()=>lg,ZodISOTime:()=>ug,ZodInstanceOf:()=>MN,ZodIntersection:()=>oN,ZodIssueCode:()=>LY,ZodJWT:()=>A_,ZodKSUID:()=>m_,ZodLazy:()=>kN,ZodLiteral:()=>dN,ZodMAC:()=>BR,ZodMap:()=>cN,ZodNaN:()=>_N,ZodNanoID:()=>f_,ZodNever:()=>eN,ZodNonOptional:()=>k_,ZodNull:()=>KR,ZodNullable:()=>mN,ZodNumber:()=>Py,ZodNumberFormat:()=>Mg,ZodObject:()=>RC,ZodOptional:()=>OC,ZodPipe:()=>$C,ZodPrefault:()=>yN,ZodPreprocess:()=>SN,ZodPromise:()=>NN,ZodProperties:()=>$N,ZodReadonly:()=>IN,ZodRealError:()=>km,ZodRecord:()=>Oy,ZodSet:()=>fN,ZodString:()=>Dy,ZodStringFormat:()=>gv,ZodSuccess:()=>LN,ZodSymbol:()=>WR,ZodTemplateLiteral:()=>xN,ZodTransform:()=>bN,ZodTuple:()=>aN,ZodType:()=>uf,ZodULID:()=>b_,ZodURL:()=>TC,ZodUUID:()=>dh,ZodUndefined:()=>ZR,ZodUnion:()=>NC,ZodUnknown:()=>QR,ZodVoid:()=>tN,ZodXID:()=>v_,ZodXor:()=>rN,_ZodString:()=>a_,_default:()=>gN,_function:()=>_M,any:()=>nM,array:()=>kC,base64:()=>PP,base64url:()=>MP,bigint:()=>JP,boolean:()=>YR,catch:()=>AN,check:()=>SM,cidrv4:()=>DP,cidrv6:()=>UP,clone:()=>Lb,codec:()=>CM,coerce:()=>zN,compile:()=>rk,config:()=>zv,core:()=>Sh,creditCard:()=>FP,cuid:()=>IP,cuid2:()=>TP,custom:()=>IM,date:()=>sM,decode:()=>UR,decodeAsync:()=>MR,deepPartial:()=>FM,describe:()=>TM,discriminatedUnion:()=>cM,e164:()=>jP,email:()=>hP,emoji:()=>_P,encode:()=>DR,encodeAsync:()=>PR,endsWith:()=>Cy,enum:()=>I_,exactOptional:()=>vN,file:()=>hM,flattenError:()=>tC,float32:()=>YP,float64:()=>WP,formatError:()=>nC,fromJSONSchema:()=>MM,function:()=>_M,getDiscriminatedOption:()=>_x,getErrorMap:()=>AY,globalRegistry:()=>lm,gt:()=>ch,gte:()=>Um,guid:()=>gP,hash:()=>HP,hex:()=>VP,hostname:()=>qP,httpUrl:()=>AP,iban:()=>zP,includes:()=>yy,input:()=>GM,instanceof:()=>kM,int:()=>o_,int32:()=>ZP,int64:()=>XP,intersection:()=>iN,invertCodec:()=>LM,ipv4:()=>NP,ipv6:()=>$P,iso:()=>PC,json:()=>NM,jwt:()=>GP,keyof:()=>oM,ksuid:()=>RP,lazy:()=>RN,length:()=>Dg,literal:()=>mM,locales:()=>yC,looseObject:()=>uM,looseRecord:()=>dM,lowercase:()=>hy,lt:()=>lh,lte:()=>Dm,mac:()=>OP,map:()=>pM,maxLength:()=>$g,maxSize:()=>tg,memoizer:()=>hC,meta:()=>xM,mime:()=>Ly,minLength:()=>_h,minSize:()=>fh,multipleOf:()=>eg,nan:()=>wM,nanoid:()=>SP,nativeEnum:()=>vM,negative:()=>WA,never:()=>S_,nonnegative:()=>KA,nonoptional:()=>CN,nonpositive:()=>ZA,normalize:()=>Ey,null:()=>JR,nullable:()=>IC,nullish:()=>gM,number:()=>HR,object:()=>iM,optional:()=>Pg,output:()=>BM,overwrite:()=>eh,parse:()=>RR,parseAsync:()=>NR,partialRecord:()=>fM,pipe:()=>i_,positive:()=>YA,prefault:()=>wN,preprocess:()=>OM,prettifyError:()=>U1,promise:()=>AM,properties:()=>DN,property:()=>JA,readonly:()=>TN,record:()=>lN,refine:()=>UN,regex:()=>my,regexes:()=>wm,registry:()=>EA,safeDecode:()=>FR,safeDecodeAsync:()=>GR,safeEncode:()=>jR,safeEncodeAsync:()=>zR,safeParse:()=>OR,safeParseAsync:()=>$R,set:()=>bM,setErrorMap:()=>EY,size:()=>Og,slugify:()=>Iy,startsWith:()=>wy,strictObject:()=>aM,string:()=>SC,stringFormat:()=>BP,stringbool:()=>RM,success:()=>yM,superRefine:()=>PN,symbol:()=>eM,templateLiteral:()=>EM,toJSONSchema:()=>t_,toLowerCase:()=>_y,toUpperCase:()=>Sy,toZod:()=>Yw,transform:()=>T_,treeifyError:()=>D1,trim:()=>Ay,tuple:()=>uN,uint32:()=>KP,uint64:()=>QP,ulid:()=>xP,undefined:()=>tM,union:()=>Fy,unknown:()=>Ug,uppercase:()=>gy,url:()=>EP,util:()=>Zo,uuid:()=>yP,uuidv4:()=>wP,uuidv6:()=>CP,uuidv7:()=>LP,validate:()=>rC,validateAsync:()=>sC,void:()=>rM,withParser:()=>AA,xid:()=>kP,xor:()=>lM});var Sh={};hh(Sh,{$ZodAny:()=>hx,$ZodArray:()=>Lx,$ZodAsyncError:()=>Tm,$ZodBase64:()=>ox,$ZodBase64URL:()=>ix,$ZodBigInt:()=>lA,$ZodBigIntFormat:()=>px,$ZodBoolean:()=>fC,$ZodCIDRv4:()=>rx,$ZodCIDRv6:()=>sx,$ZodCUID:()=>VT,$ZodCUID2:()=>HT,$ZodCatch:()=>zx,$ZodCheck:()=>Rv,$ZodCheckBigIntFormat:()=>yT,$ZodCheckEndsWith:()=>RT,$ZodCheckGreaterThan:()=>HE,$ZodCheckIncludes:()=>xT,$ZodCheckLengthEquals:()=>_T,$ZodCheckLessThan:()=>VE,$ZodCheckLowerCase:()=>IT,$ZodCheckMaxLength:()=>ET,$ZodCheckMaxSize:()=>wT,$ZodCheckMimeType:()=>OT,$ZodCheckMinLength:()=>AT,$ZodCheckMinSize:()=>CT,$ZodCheckMultipleOf:()=>hT,$ZodCheckNumberFormat:()=>gT,$ZodCheckOverwrite:()=>$T,$ZodCheckProperty:()=>NT,$ZodCheckRegex:()=>ST,$ZodCheckSizeEquals:()=>LT,$ZodCheckStartsWith:()=>kT,$ZodCheckStringFormat:()=>dy,$ZodCheckUpperCase:()=>TT,$ZodCodec:()=>pC,$ZodCreditCard:()=>ux,$ZodCustom:()=>Wx,$ZodCustomStringFormat:()=>fx,$ZodCyclicError:()=>mA,$ZodDate:()=>Cx,$ZodDefault:()=>Px,$ZodDiscriminatedUnion:()=>Sx,$ZodE164:()=>ax,$ZodEmail:()=>jT,$ZodEmoji:()=>BT,$ZodEncodeError:()=>Qh,$ZodEnum:()=>Rx,$ZodError:()=>$1,$ZodExactOptional:()=>Dx,$ZodFile:()=>Ox,$ZodFunction:()=>Hx,$ZodGUID:()=>PT,$ZodIBAN:()=>lx,$ZodIPv4:()=>ex,$ZodIPv6:()=>tx,$ZodISODate:()=>JT,$ZodISODateTime:()=>KT,$ZodISODuration:()=>QT,$ZodISOTime:()=>XT,$ZodIntersection:()=>Ix,$ZodJWT:()=>cx,$ZodKSUID:()=>ZT,$ZodLazy:()=>bC,$ZodLiteral:()=>Nx,$ZodMAC:()=>nx,$ZodMap:()=>xx,$ZodNaN:()=>Gx,$ZodNanoID:()=>qT,$ZodNever:()=>yx,$ZodNonOptional:()=>jx,$ZodNull:()=>mx,$ZodNullable:()=>Ux,$ZodNumber:()=>uA,$ZodNumberFormat:()=>dx,$ZodObject:()=>I6,$ZodObjectJIT:()=>Ex,$ZodOptional:()=>fA,$ZodPipe:()=>dA,$ZodPrefault:()=>Mx,$ZodPreprocess:()=>Bx,$ZodPromise:()=>Yx,$ZodProperties:()=>Zx,$ZodReadonly:()=>qx,$ZodRealError:()=>xm,$ZodRecord:()=>Tx,$ZodRegistry:()=>LA,$ZodSet:()=>kx,$ZodString:()=>Ig,$ZodStringFormat:()=>Yb,$ZodSuccess:()=>Fx,$ZodSymbol:()=>bx,$ZodTemplateLiteral:()=>Vx,$ZodTransform:()=>$x,$ZodTuple:()=>cA,$ZodType:()=>Ql,$ZodULID:()=>YT,$ZodURL:()=>GT,$ZodUUID:()=>MT,$ZodUndefined:()=>vx,$ZodUnion:()=>dC,$ZodUnknown:()=>gx,$ZodVoid:()=>wx,$ZodXID:()=>WT,$ZodXor:()=>Ax,$brand:()=>R1,$constructor:()=>eo,$input:()=>Qx,$output:()=>Xx,Doc:()=>Sg,INVALID:()=>Cm,JSONSchema:()=>bP,JSONSchemaGenerator:()=>n_,NEVER:()=>k1,TimePrecision:()=>ck,URL_BAD_FORMAT:()=>FT,URL_UNPARSEABLE:()=>zT,ZodCompileAsyncError:()=>Qm,ZodCompileUnsupportedError:()=>Xd,_any:()=>Ik,_array:()=>Dk,_base64:()=>BA,_base64url:()=>qA,_bigint:()=>wk,_boolean:()=>gk,_catch:()=>iY,_check:()=>XU,_cidrv4:()=>zA,_cidrv6:()=>GA,_coercedBigint:()=>Ck,_coercedBoolean:()=>yk,_coercedDate:()=>Nk,_coercedNumber:()=>dk,_coercedString:()=>ik,_creditCard:()=>uk,_cuid:()=>$A,_cuid2:()=>DA,_custom:()=>Pk,_date:()=>Rk,_decode:()=>DE,_decodeAsync:()=>PE,_default:()=>rY,_discriminatedUnion:()=>VH,_e164:()=>VA,_email:()=>SA,_emoji:()=>NA,_encode:()=>$E,_encodeAsync:()=>UE,_endsWith:()=>Cy,_enum:()=>JH,_file:()=>Uk,_float32:()=>bk,_float64:()=>vk,_gt:()=>ch,_gte:()=>Um,_guid:()=>IA,_iban:()=>lk,_includes:()=>yy,_int:()=>pk,_int32:()=>mk,_int64:()=>Lk,_intersection:()=>HH,_ipv4:()=>jA,_ipv6:()=>FA,_isoDate:()=>LC,_isoDateTime:()=>CC,_isoDuration:()=>AC,_isoTime:()=>EC,_jwt:()=>HA,_ksuid:()=>MA,_lazy:()=>cY,_length:()=>Dg,_literal:()=>QH,_lowercase:()=>hy,_lt:()=>lh,_lte:()=>Dm,_mac:()=>ak,_map:()=>ZH,_max:()=>Dm,_maxLength:()=>$g,_maxSize:()=>tg,_mime:()=>Ly,_min:()=>Um,_minLength:()=>_h,_minSize:()=>fh,_multipleOf:()=>eg,_nan:()=>Ok,_nanoid:()=>OA,_nativeEnum:()=>XH,_negative:()=>WA,_never:()=>xk,_nonnegative:()=>KA,_nonoptional:()=>sY,_nonpositive:()=>ZA,_normalize:()=>Ey,_null:()=>Sk,_nullable:()=>nY,_number:()=>fk,_optional:()=>tY,_overwrite:()=>eh,_parse:()=>uy,_parseAsync:()=>ly,_pipe:()=>aY,_positive:()=>YA,_promise:()=>fY,_properties:()=>$k,_property:()=>JA,_readonly:()=>uY,_record:()=>WH,_refine:()=>Mk,_regex:()=>my,_safeDecode:()=>jE,_safeDecodeAsync:()=>zE,_safeEncode:()=>ME,_safeEncodeAsync:()=>FE,_safeParse:()=>cy,_safeParseAsync:()=>fy,_set:()=>KH,_size:()=>Og,_slugify:()=>Iy,_startsWith:()=>wy,_string:()=>ok,_stringFormat:()=>Ty,_stringbool:()=>Gk,_success:()=>oY,_superRefine:()=>jk,_symbol:()=>Ak,_templateLiteral:()=>lY,_toLowerCase:()=>_y,_toUpperCase:()=>Sy,_transform:()=>eY,_trim:()=>Ay,_tuple:()=>YH,_uint32:()=>hk,_uint64:()=>Ek,_ulid:()=>UA,_undefined:()=>_k,_union:()=>BH,_unknown:()=>Tk,_uppercase:()=>gy,_url:()=>wC,_uuid:()=>TA,_uuidv4:()=>xA,_uuidv6:()=>kA,_uuidv7:()=>RA,_void:()=>kk,_xid:()=>PA,_xor:()=>qH,base64Charset:()=>rA,base64urlCharset:()=>cC,clone:()=>Lb,compile:()=>rk,compileFn:()=>_A,config:()=>zv,createStandardJSONSchemaMethod:()=>xy,createToJSONSchemaMethod:()=>qk,decode:()=>VB,decodeAsync:()=>YB,describe:()=>Fk,encode:()=>qB,encodeAsync:()=>HB,extractDefs:()=>rg,finalize:()=>sg,flattenError:()=>tC,formatError:()=>nC,getDiscriminatedOption:()=>_x,globalConfig:()=>Kv,globalRegistry:()=>lm,handleUnrepresentable:()=>Bv,initializeContext:()=>ng,isBackEdge:()=>gA,isRecursiveSchema:()=>hA,isTransforming:()=>am,isValidBase64:()=>lC,isValidBase64URL:()=>sA,isValidCIDRv6:()=>nA,isValidCreditCard:()=>oA,isValidIBAN:()=>iA,isValidIPv6:()=>uC,isValidJWT:()=>aA,locales:()=>yC,memoizer:()=>hC,mergeValues:()=>py,meta:()=>zk,parse:()=>NE,parseAsync:()=>OE,parseURLObject:()=>XE,prettifyError:()=>U1,process:()=>Eb,processSchema:()=>Eb,regexes:()=>wm,registry:()=>EA,safeDecode:()=>ZB,safeDecodeAsync:()=>JB,safeEncode:()=>WB,safeEncodeAsync:()=>KB,safeParse:()=>jB,safeParseAsync:()=>FB,standardProps:()=>JE,stripTabAndNewline:()=>QE,toDotPath:()=>n6,toJSONSchema:()=>t_,toZod:()=>Yw,treeifyError:()=>D1,urlHostnameOk:()=>eA,urlProtocolOk:()=>tA,util:()=>Zo,validate:()=>rC,validateAsync:()=>sC,version:()=>DT,withParser:()=>AA});var Zo={};hh(Zo,{BIGINT_FORMAT_RANGES:()=>Xw,CONSTANT_CATCH:()=>kE,Class:()=>y1,NUMBER_FORMAT_RANGES:()=>Jw,aborted:()=>gm,allowsEval:()=>L1,assert:()=>iB,assertEqual:()=>nB,assertIs:()=>sB,assertNever:()=>oB,assertNotEqual:()=>rB,assignProp:()=>im,attachSchema:()=>xE,base64ToUint8Array:()=>KD,base64urlToUint8Array:()=>_B,cached:()=>oy,captureStackTrace:()=>IE,cleanEnum:()=>AB,cleanRegex:()=>Eh,clone:()=>Lb,cloneDef:()=>lB,codePointLength:()=>Ag,constantCatch:()=>T1,createTransparentProxy:()=>vB,defineLazy:()=>w1,defineLazyInternal:()=>Wf,derived:()=>xB,esc:()=>hm,escapeRegex:()=>qm,explicitlyAborted:()=>_1,extend:()=>gB,finalizeIssue:()=>Im,floatSafeRemainder:()=>Ww,getElementAtPath:()=>cB,getEnumValues:()=>ry,getLengthableOrigin:()=>eC,getParsedType:()=>bB,getSizableOrigin:()=>Qw,hexToUint8Array:()=>IB,hide:()=>I1,installLazyProp:()=>NB,isObject:()=>Eg,isPlainObject:()=>Bm,issue:()=>ay,joinValues:()=>ro,jsonStringifyReplacer:()=>sy,members:()=>S1,merge:()=>wB,mergeDefs:()=>Xm,normalizeParams:()=>Gi,nullish:()=>SE,numKeys:()=>pB,objectClone:()=>aB,omit:()=>hB,optionalKeys:()=>A1,own:()=>Xh,parsedType:()=>Qo,partial:()=>CB,pick:()=>mB,prefixIssues:()=>ym,primitiveTypes:()=>E1,promiseAllObject:()=>fB,propertyKeyTypes:()=>Kw,randomString:()=>dB,rawShape:()=>iy,required:()=>LB,safeExtend:()=>yB,shallowClone:()=>Zw,slugify:()=>C1,stringifyPrimitive:()=>Jo,toZod:()=>Yw,uint8ArrayToBase64:()=>JD,uint8ArrayToBase64url:()=>SB,uint8ArrayToHex:()=>TB,unwrapMessage:()=>ny});function nB(n){return n}function rB(n){return n}function Yw(){return n=>n}function sB(n){}function oB(n){throw new Error("Unexpected value in exhaustive check")}function iB(n){}function ry(n){let r=Object.values(n).filter(h=>typeof h=="number");return Object.entries(n).filter(([h,l])=>r.indexOf(+h)===-1).map(([h,l])=>l)}function ro(n,r="|"){return n.map(f=>Jo(f)).join(r)}function sy(n,r){return typeof r=="bigint"?r.toString():r}var g1=class{constructor(r){this._getter=r,this._value=void 0}get value(){let r=this._getter;return r!==void 0&&(this._value=r(),this._getter=void 0),this._value}};function oy(n){return new g1(n)}function SE(n){return n==null}function Eh(n){let r=n.startsWith("^")?1:0,f=n.endsWith("$")?n.length-1:n.length;return n.slice(r,f)}function Ww(n,r){let f=n/r,h=Math.round(f),l=4*Number.EPSILON*Math.max(Math.abs(f),1);return Math.abs(f-h)<l?0:f-h}var VD=Symbol("evaluating");function w1(n,r,f){let h;Object.defineProperty(n,r,{get(){if(h!==VD)return h===void 0&&(h=VD,h=f()),h},set(l){Object.defineProperty(n,r,{value:l})},configurable:!0})}function aB(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function im(n,r,f){Object.defineProperty(n,r,{value:f,writable:!0,enumerable:!0,configurable:!0})}function iy(n){let r=Object.getOwnPropertyDescriptor(n,"shape");return r?.get?r.get.raw:r?.value}function Lh(n){return iy(n._zod.def)??n._zod.def.shape}function YD(n,r,f){Object.defineProperty(n,r,{get(){let h=f();return im(this,r,h),h},enumerable:!0,configurable:!0})}function WD(n,r,f){r in n?im(n,r,f):n[r]=f}function Lg(n,r,f,h){let l=Lh(r);for(let t of f){let $=Object.getOwnPropertyDescriptor(l,t);$.enumerable&&($.get?YD(n,t,()=>{let re=r._zod.def.shape[t];return h?h(re,t):re}):WD(n,t,h?h($.value,t):$.value))}}function uB(n,r){for(let f of Reflect.ownKeys(r)){let h=Object.getOwnPropertyDescriptor(r,f);h.enumerable&&(h.get?YD(n,f,()=>r[f]):WD(n,f,h.value))}}function Xm(...n){let r={};for(let f of n){let h=Object.getOwnPropertyDescriptors(f);Object.assign(r,h)}return Object.defineProperties({},r)}function lB(n){return Xm(n._zod.def)}function cB(n,r){return r?r.reduce((f,h)=>f?.[h],n):n}function fB(n){let r=Object.keys(n),f=r.map(h=>n[h]);return Promise.all(f).then(h=>{let l={};for(let t=0;t<r.length;t++)l[r[t]]=h[t];return l})}function dB(n=10){let r="abcdefghijklmnopqrstuvwxyz",f="";for(let h=0;h<n;h++)f+=r[Math.floor(Math.random()*r.length)];return f}function hm(n){return JSON.stringify(n)}function C1(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var IE="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Eg(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var L1=oy(()=>{if(Kv.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function Bm(n){if(Eg(n)===!1)return!1;let r=n.constructor;if(r===void 0||typeof r!="function")return!0;let f=r.prototype;return!(Eg(f)===!1||Object.prototype.hasOwnProperty.call(f,"isPrototypeOf")===!1)}function Zw(n){return Bm(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}function pB(n){let r=0;for(let f in n)Object.prototype.hasOwnProperty.call(n,f)&&r++;return r}var bB=n=>{let r=typeof n;switch(r){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${r}`)}},Kw=new Set(["string","number","symbol"]),E1=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qm(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lb(n,r,f){let h=new n._zod.constr(r??n._zod.def);return(!r||f?.parent)&&(h._zod.parent=n),h}function Gi(n){let r=n;if(!r)return{};if(typeof r=="string")return{error:()=>r};if(r?.message!==void 0){if(r?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");r.error=r.message}return delete r.message,typeof r.error=="string"?{...r,error:()=>r.error}:r}function vB(n){let r;return new Proxy({},{get(f,h,l){return r??(r=n()),Reflect.get(r,h,l)},set(f,h,l,t){return r??(r=n()),Reflect.set(r,h,l,t)},has(f,h){return r??(r=n()),Reflect.has(r,h)},deleteProperty(f,h){return r??(r=n()),Reflect.deleteProperty(r,h)},ownKeys(f){return r??(r=n()),Reflect.ownKeys(r)},getOwnPropertyDescriptor(f,h){return r??(r=n()),Reflect.getOwnPropertyDescriptor(r,h)},defineProperty(f,h,l){return r??(r=n()),Reflect.defineProperty(r,h,l)}})}function Jo(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function A1(n){return Object.keys(n).filter(r=>n[r]._zod.optin!==void 0&&n[r]._zod.optout==="optional")}var Jw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Xw={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mB(n,r){let f=n._zod.def,h=f.checks;if(h&&h.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let t={};return Lg(t,n,TE(n,r)),Lb(n,Xm(f,{shape:t,checks:[]}))}function TE(n,r){let f=Lh(n),h=[];for(let l of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(f,l)?.enumerable)throw new Error(`Unrecognized key: "${String(l)}"`);r[l]&&h.push(l)}return h}function hB(n,r){let f=n._zod.def,h=f.checks;if(h&&h.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let t=new Set(TE(n,r)),$={};return Lg($,n,Reflect.ownKeys(Lh(n)).filter(re=>!t.has(re))),Lb(n,Xm(f,{shape:$,checks:[]}))}function gB(n,r){if(!Bm(r))throw new Error("Invalid input to extend: expected a plain object");let f=n._zod.def.checks;if(f&&f.length>0){let l=Lh(n);for(let t of Reflect.ownKeys(r))if(Object.getOwnPropertyDescriptor(l,t)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Lb(n,Xm(n._zod.def,{shape:ZD(n,r)}))}function ZD(n,r){let f={};return Lg(f,n,Reflect.ownKeys(Lh(n))),uB(f,r),f}function yB(n,r){if(!Bm(r))throw new Error("Invalid input to safeExtend: expected a plain object");return Lb(n,Xm(n._zod.def,{shape:ZD(n,r)}))}function wB(n,r){if(!r?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(n._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let f={};Lg(f,n,Reflect.ownKeys(Lh(n))),Lg(f,r,Reflect.ownKeys(Lh(r)));let h=Xm(n._zod.def,{shape:f,get catchall(){return r._zod.def.catchall},checks:r._zod.def.checks??[]});return Lb(n,h)}function CB(n,r,f,h="partial"){let t=r._zod.def.checks;if(t&&t.length>0)throw new Error(`.${h}() cannot be used on object schemas containing refinements`);let re=f?new Set(TE(r,f)):void 0,e={};return Lg(e,r,Reflect.ownKeys(Lh(r)),n&&((qe,ht)=>re&&!re.has(ht)?qe:new n({type:"optional",innerType:qe}))),Lb(r,Xm(r._zod.def,{shape:e,checks:[]}))}function LB(n,r,f){let h=f?new Set(TE(r,f)):void 0,l={};return Lg(l,r,Reflect.ownKeys(Lh(r)),(t,$)=>h&&!h.has($)?t:new n({type:"nonoptional",innerType:t})),Lb(r,Xm(r._zod.def,{shape:l}))}function gm(n,r=0){if(n.aborted===!0)return!0;for(let f=r;f<n.issues.length;f++)if(n.issues[f]?.continue!==!0)return!0;return!1}function _1(n,r=0){if(n.aborted===!0)return!0;for(let f=r;f<n.issues.length;f++)if(n.issues[f]?.continue===!1)return!0;return!1}function ym(n,r){return r.map(f=>{var h;return(h=f).path??(h.path=[]),f.path.unshift(n),f})}function ny(n){return typeof n=="string"?n:n?.message}function xE(n,r,f){var h;for(let l=r;l<n.length;l++)(h=n[l]).schema??(h.schema=f)}function Im(n,r,f){var h;let l=n.inst?._zod?.traits;l?.has("$ZodType")&&(l.has("$ZodCheck")?(h=n).schema??(h.schema=n.inst):n.schema=n.inst);let t=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,$=n.message?n.message:ny(n.inst?._zod.def?.error?.(n))??ny(t?.(n))??ny(r?.error?.(n))??ny(f.customError?.(n))??ny(f.localeError?.(n))??"Invalid input",re={};for(let e of Object.keys(n))e==="inst"||e==="schema"||e==="continue"||e==="input"||e==="__proto__"||(re[e]=n[e]);return re.path??(re.path=[]),re.message=$,r?.reportInput&&(re.input=n.input),re}function Qw(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}var EB=/[\uD800-\uDBFF]/;function Ag(n){let r=n.length;if(!EB.test(n))return r;let f=r;for(let h=0;h<r-1;h++)(n.charCodeAt(h)&64512)===55296&&(n.charCodeAt(h+1)&64512)===56320&&(f--,h++);return f}function eC(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Qo(n){let r=typeof n;switch(r){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let f=n;if(f&&Object.getPrototypeOf(f)!==Object.prototype&&"constructor"in f&&f.constructor)return f.constructor.name}}return r}function ay(...n){let[r,f,h]=n;return typeof r=="string"?{message:r,code:"custom",input:f,inst:h}:{...r}}function AB(n){return Object.entries(n).filter(([r,f])=>Number.isNaN(Number.parseInt(r,10))).map(r=>r[1])}function KD(n){let r=atob(n),f=new Uint8Array(r.length);for(let h=0;h<r.length;h++)f[h]=r.charCodeAt(h);return f}function JD(n){let r="";for(let f=0;f<n.length;f++)r+=String.fromCharCode(n[f]);return btoa(r)}function _B(n){let r=n.replace(/-/g,"+").replace(/_/g,"/"),f="=".repeat((4-r.length%4)%4);return KD(r+f)}function SB(n){return JD(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function IB(n){let r=n.replace(/^0x/,"");if(r.length%2!==0)throw new Error("Invalid hex string length");let f=new Uint8Array(r.length/2);for(let h=0;h<r.length;h+=2)f[h/2]=Number.parseInt(r.slice(h,h+2),16);return f}function TB(n){return Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("")}var y1=class{constructor(...r){}};function S1(n,r){for(let f in r){let h=Object.getOwnPropertyDescriptor(r,f);h.get?Object.defineProperty(n,f,{...h,enumerable:!1}):HD(n,f,h.value)}for(let f of Object.getOwnPropertySymbols(r))HD(n,f,r[f])}function Xh(n,r,f,h=!0){return Object.defineProperty(n,r,{configurable:!0,writable:!0,enumerable:h,value:f}),f}function I1(n,r,f){return Xh(n,r,f,!1)}function xB(n,r){for(let f in n){let h=n[f];Object.defineProperty(r,f,{configurable:!0,enumerable:!0,get(){return Xh(this,f,h(this))},set(l){Xh(this,f,l)}})}return r}function HD(n,r,f){Object.defineProperty(n,r,{configurable:!0,get(){return this==null?f:Xh(this,r,f.bind(this))},set(h){Xh(this,r,h)}})}function kB(n,r){let f=Object.getPrototypeOf(n);return r in f?void 0:f}var h1,Jh=!1,RB={configurable:!0,get(){Jh=!0}};function Wf(n,r,f){let h=Object.getPrototypeOf(n._zod);if(r in h&&h1!==n._zod){h1=void 0;return}h1=n._zod,Object.defineProperty(h,r,{configurable:!0,get(){Object.defineProperty(this,r,RB);let l=Jh;Jh=!1;try{let t=f(this);return Jh?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),Jh=Jh||l,t}catch(t){throw delete this[r],Jh=Jh||l,t}},set(l){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:l})}})}function NB(n,r,f,h){let l=kB(n,r);l&&Object.defineProperty(l,r,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:h,value:void 0};return Object.defineProperty(this,r,t),t.value=f(this),Object.defineProperty(this,r,t),t.value},set(t){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:h,value:t})}})}var kE="~constantCatch";function T1(n){let r=()=>n;return r[kE]=!0,r}var XD,k1=Object.freeze({status:"aborted"}),x1={value:void 0,enumerable:!1},QD="captureStackTrace"in Error?Error:null;function OB(n){let r=QD;if(r){let f=r.stackTraceLimit;if(typeof f=="number"){try{r.stackTraceLimit=0}catch{return QD=null,new n}try{return new n}finally{r.stackTraceLimit=f}}}return new n}function eo(n,r,f,h){let l={};function t(gt){this.def=gt,this.constr=Ke,this.traits=new Set}t.prototype=l;let $=f,re=$&&new WeakSet;function e(gt,ln){if(!gt._zod){x1.value=new t(ln);try{Object.defineProperty(gt,"_zod",x1)}finally{x1.value=void 0}}if(gt._zod.traits.has(n))return;if(gt._zod.traits.add(n),r(gt,ln),re){let bn=Object.getPrototypeOf(gt),zr=gt._zod.constr.prototype,tr=bn;for(;tr&&tr!==zr;)tr=Object.getPrototypeOf(tr);let Er=tr??bn;re.has(Er)||(re.add(Er),S1(Er,$))}let Qn=Ke.prototype;for(let bn in Qn)Object.prototype.hasOwnProperty.call(Qn,bn)&&(bn in gt||(gt[bn]=Qn[bn].bind(gt)))}let qe=h?.Parent??Object;class ht extends qe{}Object.defineProperty(ht,"name",{value:n});function Ke(gt){let ln=h?.Parent?OB(ht):this;e(ln,gt);let Qn=ln._zod.deferred;if(Qn){for(let zr of Qn)zr();ln._zod.deferred=void 0}let bn=globalThis.__zod_globalConfig?.postProcessor;return bn&&bn(ln),ln}return Object.defineProperty(Ke,"init",{value:e}),Object.defineProperty(Ke,Symbol.hasInstance,{value:gt=>h?.Parent&> instanceof h.Parent?!0:gt?._zod?.traits?.has(n)}),Object.defineProperty(Ke,"name",{value:n}),Ke}var R1=Symbol("zod_brand"),Tm=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qh=class extends Error{constructor(r){super(`Encountered unidirectional transform during encode: ${r}`),this.name="ZodEncodeError"}};(XD=globalThis).__zod_globalConfig??(XD.__zod_globalConfig={});var Kv=globalThis.__zod_globalConfig;function zv(n){return n&&Object.assign(Kv,n),Kv}function $B(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,sy,2)),n.message}function DB(n){this._zod.message=n}var UB={get:$B,set:DB,enumerable:!0,configurable:!0},O1={value:void 0,enumerable:!1},e6=new WeakSet([Object.prototype,Error.prototype]),t6=(n,r)=>{n.name="$ZodError",O1.value=r,Object.defineProperty(n,"issues",O1),O1.value=void 0,Object.defineProperty(n,"message",UB);let f=Object.getPrototypeOf(n);e6.has(f)||(e6.add(f),Object.defineProperty(f,"toString",{configurable:!0,enumerable:!1,get(){let h=()=>this.message;return Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0}),h},set(h){Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0})}}))},$1=eo("$ZodError",t6),xm=eo("$ZodError",t6,void 0,{Parent:Error});function PB(n,r,f){return Object.prototype.hasOwnProperty.call(n,r)||(r==="__proto__"?Object.defineProperty(n,r,{value:f(),writable:!0,enumerable:!0,configurable:!0}):n[r]=f()),n[r]}function tC(n,r=f=>f.message){let f={},h=[];for(let l of n.issues)l.path.length>0?PB(f,l.path[0],()=>[]).push(r(l)):h.push(r(l));return{formErrors:h,fieldErrors:f}}function nC(n,r=f=>f.message){let f={_errors:[]},h=(l,t=[])=>{for(let $ of l.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map(re=>h({issues:re},[...t,...$.path]));else if($.code==="invalid_key")h({issues:$.issues},[...t,...$.path]);else if($.code==="invalid_element")h({issues:$.issues},[...t,...$.path]);else{let re=[...t,...$.path];if(re.length===0)f._errors.push(r($));else{let e=f,qe=0;for(;qe<re.length;){let ht=re[qe],Ke=qe===re.length-1;if(ht==="_errors"){Ke&&e._errors.push(r($)),qe++;continue}Object.prototype.hasOwnProperty.call(e,ht)||Object.defineProperty(e,ht,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let gt=e[ht];Ke&>._errors.push(r($)),e=gt,qe++}}}};return h(n),f}function D1(n,r=f=>f.message){let f={errors:[]},h=(l,t=[])=>{var $;for(let re of l.issues)if(re.code==="invalid_union"&&re.errors.length)re.errors.map(e=>h({issues:e},[...t,...re.path]));else if(re.code==="invalid_key")h({issues:re.issues},[...t,...re.path]);else if(re.code==="invalid_element")h({issues:re.issues},[...t,...re.path]);else{let e=[...t,...re.path];if(e.length===0){f.errors.push(r(re));continue}let qe=f,ht=0;for(;ht<e.length;){let Ke=e[ht],gt=ht===e.length-1;typeof Ke=="string"?(qe.properties??(qe.properties={}),Object.prototype.hasOwnProperty.call(qe.properties,Ke)||Object.defineProperty(qe.properties,Ke,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),qe=qe.properties[Ke]):(qe.items??(qe.items=[]),($=qe.items)[Ke]??($[Ke]={errors:[]}),qe=qe.items[Ke]),gt&&qe.errors.push(r(re)),ht++}}};return h(n),f}function n6(n){let r=[],f=n.map(h=>typeof h=="object"?h.key:h);for(let h of f)typeof h=="number"?r.push(`[${h}]`):typeof h=="symbol"?r.push(`[${JSON.stringify(String(h))}]`):/[^\w$]/.test(h)?r.push(`[${JSON.stringify(h)}]`):(r.length&&r.push("."),r.push(h));return r.join("")}function U1(n){let r=[],f=[...n.issues].sort((h,l)=>(h.path??[]).length-(l.path??[]).length);for(let h of f)r.push(`\u2716 ${h.message}`),h.path?.length&&r.push(` \u2192 at ${n6(h.path)}`);return r.join(`
|
|
215
|
+
>>> no match, partial?`,n,Ke,r,gt),Ke===re))}let Qn;if(typeof qe=="string"?(Qn=ht===qe,this.debug("string match",qe,ht,Qn)):(Qn=qe.test(ht),this.debug("pattern match",qe,ht,Qn)),!Qn)return!1}if(t===re&&$===e)return!0;if(t===re)return f;if($===e)return t===re-1&&n[t]==="";throw new Error("wtf?")}braceExpand(){return vD(this.pattern,this.options)}parse(n){yE(n);let r=this.options;if(n==="**")return vm;if(n==="")return"";let f,h=null;(f=n.match(MG))?h=r.dot?FG:jG:(f=n.match(TG))?h=(r.nocase?r.dot?NG:RG:r.dot?kG:xG)(f[1]):(f=n.match(zG))?h=(r.nocase?r.dot?BG:GG:r.dot?qG:VG)(f):(f=n.match(OG))?h=r.dot?DG:$G:(f=n.match(UG))&&(h=PG);let l=cD.fromGlob(n,this.options).toMMPattern();return h&&typeof l=="object"&&Reflect.defineProperty(l,"test",{value:h}),l}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let n=this.set;if(!n.length)return this.regexp=!1,this.regexp;let r=this.options,f=r.noglobstar?WG:r.dot?ZG:KG,h=new Set(r.nocase?["i"]:[]),l=n.map(re=>{let e=re.map(ht=>{if(ht instanceof RegExp)for(let Ke of ht.flags.split(""))h.add(Ke);return typeof ht=="string"?t8(ht):ht===vm?vm:ht._src});e.forEach((ht,Ke)=>{let gt=e[Ke+1],ln=e[Ke-1];ht!==vm||ln===vm||(ln===void 0?gt!==void 0&>!==vm?e[Ke+1]="(?:\\/|"+f+"\\/)?"+gt:e[Ke]=f:gt===void 0?e[Ke-1]=ln+"(?:\\/|\\/"+f+")?":gt!==vm&&(e[Ke-1]=ln+"(?:\\/|\\/"+f+"\\/)"+gt,e[Ke+1]=vm))});let qe=e.filter(ht=>ht!==vm);if(this.partial&&qe.length>=1){let ht=[];for(let Ke=1;Ke<=qe.length;Ke++)ht.push(qe.slice(0,Ke).join("/"));return"(?:"+ht.join("|")+")"}return qe.join("/")}).join("|"),[t,$]=n.length>1?["(?:",")"]:["",""];l="^"+t+l+$+"$",this.partial&&(l="^(?:\\/|"+t+l.slice(1,-1)+$+")$"),this.negate&&(l="^(?!"+l+").+$");try{this.regexp=new RegExp(l,[...h].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(n){return this.preserveMultipleSlashes?n.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(n)?["",...n.split(/\/+/)]:n.split(/\/+/)}match(n,r=this.partial){if(this.debug("match",n,this.pattern),this.comment)return!1;if(this.empty)return n==="";if(n==="/"&&r)return!0;let f=this.options;this.isWindows&&(n=n.split("\\").join("/"));let h=this.slashSplit(n);this.debug(this.pattern,"split",h);let l=this.set;this.debug(this.pattern,"set",l);let t=h[h.length-1];if(!t)for(let $=h.length-2;!t&&$>=0;$--)t=h[$];for(let $=0;$<l.length;$++){let re=l[$],e=h;if(f.matchBase&&re.length===1&&(e=[t]),this.matchOne(e,re,r))return f.flipNegate?!0:!this.negate}return f.flipNegate?!1:this.negate}static defaults(n){return mm.defaults(n).Minimatch}};mm.AST=cD;mm.Minimatch=Kh;mm.escape=fD;mm.unescape=ty;var r8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,mD=new Set,c1=typeof process=="object"&&process?process:{},hD=(n,r,f,h)=>{typeof c1.emitWarning=="function"?c1.emitWarning(n,r,f,h):console.error(`[${f}] ${r}: ${n}`)},wE=globalThis.AbortController,B2=globalThis.AbortSignal;if(typeof wE>"u"){B2=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(f,h){this._onabort.push(h)}},wE=class{constructor(){r()}signal=new B2;abort(f){if(!this.signal.aborted){this.signal.reason=f,this.signal.aborted=!0;for(let h of this.signal._onabort)h(f);this.signal.onabort?.(f)}}};let n=c1.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",r=()=>{n&&(n=!1,hD("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",r))}}var s8=n=>!mD.has(n),Zh=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),gD=n=>Zh(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?hE:null:null,hE=class extends Array{constructor(n){super(n),this.fill(0)}},o8=class Gw{heap;length;static#e=!1;static create(r){let f=gD(r);if(!f)return[];Gw.#e=!0;let h=new Gw(r,f);return Gw.#e=!1,h}constructor(r,f){if(!Gw.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new f(r),this.length=0}push(r){this.heap[this.length++]=r}pop(){return this.heap[--this.length]}},LE=class yD{#e;#n;#o;#s;#i;#w;#h;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#d;#f;#u;#r;#p;#C;#y;#b;#T;#v;#A;#_;#m;#g;#L;#S;#t;#$;static unsafeExposeInternals(r){return{starts:r.#_,ttls:r.#m,autopurgeTimers:r.#g,sizes:r.#A,keyMap:r.#f,keyList:r.#u,valList:r.#r,next:r.#p,prev:r.#C,get head(){return r.#y},get tail(){return r.#b},free:r.#T,isBackgroundFetch:f=>r.#l(f),backgroundFetch:(f,h,l,t)=>r.#G(f,h,l,t),moveToTail:f=>r.#U(f),indexes:f=>r.#k(f),rindexes:f=>r.#R(f),isStale:f=>r.#E(f)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#d}get size(){return this.#a}get fetchMethod(){return this.#w}get memoMethod(){return this.#h}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(r){let{max:f=0,ttl:h,ttlResolution:l=1,ttlAutopurge:t,updateAgeOnGet:$,updateAgeOnHas:re,allowStale:e,dispose:qe,onInsert:ht,disposeAfter:Ke,noDisposeOnSet:gt,noUpdateTTL:ln,maxSize:Qn=0,maxEntrySize:bn=0,sizeCalculation:zr,fetchMethod:tr,memoMethod:Er,noDeleteOnFetchRejection:cs,noDeleteOnStaleGet:Ys,allowStaleOnFetchRejection:ao,allowStaleOnFetchAbort:uo,ignoreFetchAbort:ni,perf:zo}=r;if(zo!==void 0&&typeof zo?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=zo??r8,f!==0&&!Zh(f))throw new TypeError("max option must be a nonnegative integer");let ta=f?gD(f):Array;if(!ta)throw new Error("invalid max value: "+f);if(this.#e=f,this.#n=Qn,this.maxEntrySize=bn||this.#n,this.sizeCalculation=zr,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(Er!==void 0&&typeof Er!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#h=Er,tr!==void 0&&typeof tr!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#w=tr,this.#S=!!tr,this.#f=new Map,this.#u=new Array(f).fill(void 0),this.#r=new Array(f).fill(void 0),this.#p=new ta(f),this.#C=new ta(f),this.#y=0,this.#b=0,this.#T=o8.create(f),this.#a=0,this.#d=0,typeof qe=="function"&&(this.#o=qe),typeof ht=="function"&&(this.#s=ht),typeof Ke=="function"?(this.#i=Ke,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#L=!!this.#o,this.#$=!!this.#s,this.#t=!!this.#i,this.noDisposeOnSet=!!gt,this.noUpdateTTL=!!ln,this.noDeleteOnFetchRejection=!!cs,this.allowStaleOnFetchRejection=!!ao,this.allowStaleOnFetchAbort=!!uo,this.ignoreFetchAbort=!!ni,this.maxEntrySize!==0){if(this.#n!==0&&!Zh(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Zh(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#q()}if(this.allowStale=!!e,this.noDeleteOnStaleGet=!!Ys,this.updateAgeOnGet=!!$,this.updateAgeOnHas=!!re,this.ttlResolution=Zh(l)||l===0?l:1,this.ttlAutopurge=!!t,this.ttl=h||0,this.ttl){if(!Zh(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Ha="LRU_CACHE_UNBOUNDED";s8(Ha)&&(mD.add(Ha),hD("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ha,yD))}}getRemainingTTL(r){return this.#f.has(r)?1/0:0}#N(){let r=new hE(this.#e),f=new hE(this.#e);this.#m=r,this.#_=f;let h=this.ttlAutopurge?new Array(this.#e):void 0;this.#g=h,this.#M=($,re,e=this.#c.now())=>{if(f[$]=re!==0?e:0,r[$]=re,h?.[$]&&(clearTimeout(h[$]),h[$]=void 0),re!==0&&h){let qe=setTimeout(()=>{this.#E($)&&this.#x(this.#u[$],"expire")},re+1);qe.unref&&qe.unref(),h[$]=qe}},this.#I=$=>{f[$]=r[$]!==0?this.#c.now():0},this.#O=($,re)=>{if(r[re]){let e=r[re],qe=f[re];if(!e||!qe)return;$.ttl=e,$.start=qe,$.now=l||t();let ht=$.now-qe;$.remainingTTL=e-ht}};let l=0,t=()=>{let $=this.#c.now();if(this.ttlResolution>0){l=$;let re=setTimeout(()=>l=0,this.ttlResolution);re.unref&&re.unref()}return $};this.getRemainingTTL=$=>{let re=this.#f.get($);if(re===void 0)return 0;let e=r[re],qe=f[re];if(!e||!qe)return 1/0;let ht=(l||t())-qe;return e-ht},this.#E=$=>{let re=f[$],e=r[$];return!!e&&!!re&&(l||t())-re>e}}#I=()=>{};#O=()=>{};#M=()=>{};#E=()=>!1;#q(){let r=new hE(this.#e);this.#d=0,this.#A=r,this.#P=f=>{this.#d-=r[f],r[f]=0},this.#j=(f,h,l,t)=>{if(this.#l(h))return 0;if(!Zh(l))if(t){if(typeof t!="function")throw new TypeError("sizeCalculation must be a function");if(l=t(h,f),!Zh(l))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return l},this.#D=(f,h,l)=>{if(r[f]=h,this.#n){let t=this.#n-r[f];for(;this.#d>t;)this.#z(!0)}this.#d+=r[f],l&&(l.entrySize=h,l.totalCalculatedSize=this.#d)}}#P=r=>{};#D=(r,f,h)=>{};#j=(r,f,h,l)=>{if(h||l)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#k({allowStale:r=this.allowStale}={}){if(this.#a)for(let f=this.#b;!(!this.#F(f)||((r||!this.#E(f))&&(yield f),f===this.#y));)f=this.#C[f]}*#R({allowStale:r=this.allowStale}={}){if(this.#a)for(let f=this.#y;!(!this.#F(f)||((r||!this.#E(f))&&(yield f),f===this.#b));)f=this.#p[f]}#F(r){return r!==void 0&&this.#f.get(this.#u[r])===r}*entries(){for(let r of this.#k())this.#r[r]!==void 0&&this.#u[r]!==void 0&&!this.#l(this.#r[r])&&(yield[this.#u[r],this.#r[r]])}*rentries(){for(let r of this.#R())this.#r[r]!==void 0&&this.#u[r]!==void 0&&!this.#l(this.#r[r])&&(yield[this.#u[r],this.#r[r]])}*keys(){for(let r of this.#k()){let f=this.#u[r];f!==void 0&&!this.#l(this.#r[r])&&(yield f)}}*rkeys(){for(let r of this.#R()){let f=this.#u[r];f!==void 0&&!this.#l(this.#r[r])&&(yield f)}}*values(){for(let r of this.#k())this.#r[r]!==void 0&&!this.#l(this.#r[r])&&(yield this.#r[r])}*rvalues(){for(let r of this.#R())this.#r[r]!==void 0&&!this.#l(this.#r[r])&&(yield this.#r[r])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(r,f={}){for(let h of this.#k()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;if(t!==void 0&&r(t,this.#u[h],this))return this.get(this.#u[h],f)}}forEach(r,f=this){for(let h of this.#k()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;t!==void 0&&r.call(f,t,this.#u[h],this)}}rforEach(r,f=this){for(let h of this.#R()){let l=this.#r[h],t=this.#l(l)?l.__staleWhileFetching:l;t!==void 0&&r.call(f,t,this.#u[h],this)}}purgeStale(){let r=!1;for(let f of this.#R({allowStale:!0}))this.#E(f)&&(this.#x(this.#u[f],"expire"),r=!0);return r}info(r){let f=this.#f.get(r);if(f===void 0)return;let h=this.#r[f],l=this.#l(h)?h.__staleWhileFetching:h;if(l===void 0)return;let t={value:l};if(this.#m&&this.#_){let $=this.#m[f],re=this.#_[f];if($&&re){let e=$-(this.#c.now()-re);t.ttl=e,t.start=Date.now()}}return this.#A&&(t.size=this.#A[f]),t}dump(){let r=[];for(let f of this.#k({allowStale:!0})){let h=this.#u[f],l=this.#r[f],t=this.#l(l)?l.__staleWhileFetching:l;if(t===void 0||h===void 0)continue;let $={value:t};if(this.#m&&this.#_){$.ttl=this.#m[f];let re=this.#c.now()-this.#_[f];$.start=Math.floor(Date.now()-re)}this.#A&&($.size=this.#A[f]),r.unshift([h,$])}return r}load(r){this.clear();for(let[f,h]of r){if(h.start){let l=Date.now()-h.start;h.start=this.#c.now()-l}this.set(f,h.value,h)}}set(r,f,h={}){if(f===void 0)return this.delete(r),this;let{ttl:l=this.ttl,start:t,noDisposeOnSet:$=this.noDisposeOnSet,sizeCalculation:re=this.sizeCalculation,status:e}=h,{noUpdateTTL:qe=this.noUpdateTTL}=h,ht=this.#j(r,f,h.size||0,re);if(this.maxEntrySize&&ht>this.maxEntrySize)return e&&(e.set="miss",e.maxEntrySizeExceeded=!0),this.#x(r,"set"),this;let Ke=this.#a===0?void 0:this.#f.get(r);if(Ke===void 0)Ke=this.#a===0?this.#b:this.#T.length!==0?this.#T.pop():this.#a===this.#e?this.#z(!1):this.#a,this.#u[Ke]=r,this.#r[Ke]=f,this.#f.set(r,Ke),this.#p[this.#b]=Ke,this.#C[Ke]=this.#b,this.#b=Ke,this.#a++,this.#D(Ke,ht,e),e&&(e.set="add"),qe=!1,this.#$&&this.#s?.(f,r,"add");else{this.#U(Ke);let gt=this.#r[Ke];if(f!==gt){if(this.#S&&this.#l(gt)){gt.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:ln}=gt;ln!==void 0&&!$&&(this.#L&&this.#o?.(ln,r,"set"),this.#t&&this.#v?.push([ln,r,"set"]))}else $||(this.#L&&this.#o?.(gt,r,"set"),this.#t&&this.#v?.push([gt,r,"set"]));if(this.#P(Ke),this.#D(Ke,ht,e),this.#r[Ke]=f,e){e.set="replace";let ln=gt&&this.#l(gt)?gt.__staleWhileFetching:gt;ln!==void 0&&(e.oldValue=ln)}}else e&&(e.set="update");this.#$&&this.onInsert?.(f,r,f===gt?"update":"replace")}if(l!==0&&!this.#m&&this.#N(),this.#m&&(qe||this.#M(Ke,l,t),e&&this.#O(e,Ke)),!$&&this.#t&&this.#v){let gt=this.#v,ln;for(;ln=gt?.shift();)this.#i?.(...ln)}return this}pop(){try{for(;this.#a;){let r=this.#r[this.#y];if(this.#z(!0),this.#l(r)){if(r.__staleWhileFetching)return r.__staleWhileFetching}else if(r!==void 0)return r}}finally{if(this.#t&&this.#v){let r=this.#v,f;for(;f=r?.shift();)this.#i?.(...f)}}}#z(r){let f=this.#y,h=this.#u[f],l=this.#r[f];return this.#S&&this.#l(l)?l.__abortController.abort(new Error("evicted")):(this.#L||this.#t)&&(this.#L&&this.#o?.(l,h,"evict"),this.#t&&this.#v?.push([l,h,"evict"])),this.#P(f),this.#g?.[f]&&(clearTimeout(this.#g[f]),this.#g[f]=void 0),r&&(this.#u[f]=void 0,this.#r[f]=void 0,this.#T.push(f)),this.#a===1?(this.#y=this.#b=0,this.#T.length=0):this.#y=this.#p[f],this.#f.delete(h),this.#a--,f}has(r,f={}){let{updateAgeOnHas:h=this.updateAgeOnHas,status:l}=f,t=this.#f.get(r);if(t!==void 0){let $=this.#r[t];if(this.#l($)&&$.__staleWhileFetching===void 0)return!1;if(this.#E(t))l&&(l.has="stale",this.#O(l,t));else return h&&this.#I(t),l&&(l.has="hit",this.#O(l,t)),!0}else l&&(l.has="miss");return!1}peek(r,f={}){let{allowStale:h=this.allowStale}=f,l=this.#f.get(r);if(l===void 0||!h&&this.#E(l))return;let t=this.#r[l];return this.#l(t)?t.__staleWhileFetching:t}#G(r,f,h,l){let t=f===void 0?void 0:this.#r[f];if(this.#l(t))return t;let $=new wE,{signal:re}=h;re?.addEventListener("abort",()=>$.abort(re.reason),{signal:$.signal});let e={signal:$.signal,options:h,context:l},qe=(bn,zr=!1)=>{let{aborted:tr}=$.signal,Er=h.ignoreFetchAbort&&bn!==void 0,cs=h.ignoreFetchAbort||!!(h.allowStaleOnFetchAbort&&bn!==void 0);if(h.status&&(tr&&!zr?(h.status.fetchAborted=!0,h.status.fetchError=$.signal.reason,Er&&(h.status.fetchAbortIgnored=!0)):h.status.fetchResolved=!0),tr&&!Er&&!zr)return Ke($.signal.reason,cs);let Ys=ln,ao=this.#r[f];return(ao===ln||Er&&zr&&ao===void 0)&&(bn===void 0?Ys.__staleWhileFetching!==void 0?this.#r[f]=Ys.__staleWhileFetching:this.#x(r,"fetch"):(h.status&&(h.status.fetchUpdated=!0),this.set(r,bn,e.options))),bn},ht=bn=>(h.status&&(h.status.fetchRejected=!0,h.status.fetchError=bn),Ke(bn,!1)),Ke=(bn,zr)=>{let{aborted:tr}=$.signal,Er=tr&&h.allowStaleOnFetchAbort,cs=Er||h.allowStaleOnFetchRejection,Ys=cs||h.noDeleteOnFetchRejection,ao=ln;if(this.#r[f]===ln&&(!Ys||!zr&&ao.__staleWhileFetching===void 0?this.#x(r,"fetch"):Er||(this.#r[f]=ao.__staleWhileFetching)),cs)return h.status&&ao.__staleWhileFetching!==void 0&&(h.status.returnedStale=!0),ao.__staleWhileFetching;if(ao.__returned===ao)throw bn},gt=(bn,zr)=>{let tr=this.#w?.(r,t,e);tr&&tr instanceof Promise&&tr.then(Er=>bn(Er===void 0?void 0:Er),zr),$.signal.addEventListener("abort",()=>{(!h.ignoreFetchAbort||h.allowStaleOnFetchAbort)&&(bn(void 0),h.allowStaleOnFetchAbort&&(bn=Er=>qe(Er,!0)))})};h.status&&(h.status.fetchDispatched=!0);let ln=new Promise(gt).then(qe,ht),Qn=Object.assign(ln,{__abortController:$,__staleWhileFetching:t,__returned:void 0});return f===void 0?(this.set(r,Qn,{...e.options,status:void 0}),f=this.#f.get(r)):this.#r[f]=Qn,Qn}#l(r){if(!this.#S)return!1;let f=r;return!!f&&f instanceof Promise&&f.hasOwnProperty("__staleWhileFetching")&&f.__abortController instanceof wE}async fetch(r,f={}){let{allowStale:h=this.allowStale,updateAgeOnGet:l=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,ttl:$=this.ttl,noDisposeOnSet:re=this.noDisposeOnSet,size:e=0,sizeCalculation:qe=this.sizeCalculation,noUpdateTTL:ht=this.noUpdateTTL,noDeleteOnFetchRejection:Ke=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:gt=this.allowStaleOnFetchRejection,ignoreFetchAbort:ln=this.ignoreFetchAbort,allowStaleOnFetchAbort:Qn=this.allowStaleOnFetchAbort,context:bn,forceRefresh:zr=!1,status:tr,signal:Er}=f;if(!this.#S)return tr&&(tr.fetch="get"),this.get(r,{allowStale:h,updateAgeOnGet:l,noDeleteOnStaleGet:t,status:tr});let cs={allowStale:h,updateAgeOnGet:l,noDeleteOnStaleGet:t,ttl:$,noDisposeOnSet:re,size:e,sizeCalculation:qe,noUpdateTTL:ht,noDeleteOnFetchRejection:Ke,allowStaleOnFetchRejection:gt,allowStaleOnFetchAbort:Qn,ignoreFetchAbort:ln,status:tr,signal:Er},Ys=this.#f.get(r);if(Ys===void 0){tr&&(tr.fetch="miss");let ao=this.#G(r,Ys,cs,bn);return ao.__returned=ao}else{let ao=this.#r[Ys];if(this.#l(ao)){let ta=h&&ao.__staleWhileFetching!==void 0;return tr&&(tr.fetch="inflight",ta&&(tr.returnedStale=!0)),ta?ao.__staleWhileFetching:ao.__returned=ao}let uo=this.#E(Ys);if(!zr&&!uo)return tr&&(tr.fetch="hit"),this.#U(Ys),l&&this.#I(Ys),tr&&this.#O(tr,Ys),ao;let ni=this.#G(r,Ys,cs,bn),zo=ni.__staleWhileFetching!==void 0&&h;return tr&&(tr.fetch=uo?"stale":"refresh",zo&&uo&&(tr.returnedStale=!0)),zo?ni.__staleWhileFetching:ni.__returned=ni}}async forceFetch(r,f={}){let h=await this.fetch(r,f);if(h===void 0)throw new Error("fetch() returned undefined");return h}memo(r,f={}){let h=this.#h;if(!h)throw new Error("no memoMethod provided to constructor");let{context:l,forceRefresh:t,...$}=f,re=this.get(r,$);if(!t&&re!==void 0)return re;let e=h(r,re,{options:$,context:l});return this.set(r,e,$),e}get(r,f={}){let{allowStale:h=this.allowStale,updateAgeOnGet:l=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,status:$}=f,re=this.#f.get(r);if(re!==void 0){let e=this.#r[re],qe=this.#l(e);return $&&this.#O($,re),this.#E(re)?($&&($.get="stale"),qe?($&&h&&e.__staleWhileFetching!==void 0&&($.returnedStale=!0),h?e.__staleWhileFetching:void 0):(t||this.#x(r,"expire"),$&&h&&($.returnedStale=!0),h?e:void 0)):($&&($.get="hit"),qe?e.__staleWhileFetching:(this.#U(re),l&&this.#I(re),e))}else $&&($.get="miss")}#B(r,f){this.#C[f]=r,this.#p[r]=f}#U(r){r!==this.#b&&(r===this.#y?this.#y=this.#p[r]:this.#B(this.#C[r],this.#p[r]),this.#B(this.#b,r),this.#b=r)}delete(r){return this.#x(r,"delete")}#x(r,f){let h=!1;if(this.#a!==0){let l=this.#f.get(r);if(l!==void 0)if(this.#g?.[l]&&(clearTimeout(this.#g?.[l]),this.#g[l]=void 0),h=!0,this.#a===1)this.#V(f);else{this.#P(l);let t=this.#r[l];if(this.#l(t)?t.__abortController.abort(new Error("deleted")):(this.#L||this.#t)&&(this.#L&&this.#o?.(t,r,f),this.#t&&this.#v?.push([t,r,f])),this.#f.delete(r),this.#u[l]=void 0,this.#r[l]=void 0,l===this.#b)this.#b=this.#C[l];else if(l===this.#y)this.#y=this.#p[l];else{let $=this.#C[l];this.#p[$]=this.#p[l];let re=this.#p[l];this.#C[re]=this.#C[l]}this.#a--,this.#T.push(l)}}if(this.#t&&this.#v?.length){let l=this.#v,t;for(;t=l?.shift();)this.#i?.(...t)}return h}clear(){return this.#V("delete")}#V(r){for(let f of this.#R({allowStale:!0})){let h=this.#r[f];if(this.#l(h))h.__abortController.abort(new Error("deleted"));else{let l=this.#u[f];this.#L&&this.#o?.(h,l,r),this.#t&&this.#v?.push([h,l,r])}}if(this.#f.clear(),this.#r.fill(void 0),this.#u.fill(void 0),this.#m&&this.#_){this.#m.fill(0),this.#_.fill(0);for(let f of this.#g??[])f!==void 0&&clearTimeout(f);this.#g?.fill(void 0)}if(this.#A&&this.#A.fill(0),this.#y=0,this.#b=0,this.#T.length=0,this.#d=0,this.#a=0,this.#t&&this.#v){let f=this.#v,h;for(;h=f?.shift();)this.#i?.(...h)}}},q2=typeof process=="object"&&process?process:{stdout:null,stderr:null},y8=n=>!!n&&typeof n=="object"&&(n instanceof CE||n instanceof wD||w8(n)||C8(n)),w8=n=>!!n&&typeof n=="object"&&n instanceof b1&&typeof n.pipe=="function"&&n.pipe!==wD.Writable.prototype.pipe,C8=n=>!!n&&typeof n=="object"&&n instanceof b1&&typeof n.write=="function"&&typeof n.end=="function",wh=Symbol("EOF"),Ch=Symbol("maybeEmitEnd"),Wh=Symbol("emittedEnd"),cE=Symbol("emittingEnd"),Uw=Symbol("emittedError"),fE=Symbol("closed"),V2=Symbol("read"),dE=Symbol("flush"),H2=Symbol("flushChunk"),Km=Symbol("encoding"),Qg=Symbol("decoder"),rm=Symbol("flowing"),Pw=Symbol("paused"),ey=Symbol("resume"),sm=Symbol("buffer"),bm=Symbol("pipes"),om=Symbol("bufferLength"),r1=Symbol("bufferPush"),pE=Symbol("bufferShift"),cm=Symbol("objectMode"),Gv=Symbol("destroyed"),s1=Symbol("error"),o1=Symbol("emitData"),Y2=Symbol("emitEnd"),i1=Symbol("emitEnd2"),ah=Symbol("async"),a1=Symbol("abort"),bE=Symbol("aborted"),Mw=Symbol("signal"),yg=Symbol("dataListeners"),Om=Symbol("discarded"),jw=n=>Promise.resolve().then(n),L8=n=>n(),E8=n=>n==="end"||n==="finish"||n==="prefinish",A8=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,_8=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),CD=class{src;dest;opts;ondrain;constructor(n,r,f){this.src=n,this.dest=r,this.opts=f,this.ondrain=()=>n[ey](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(n){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},S8=class extends CD{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(n,r,f){super(n,r,f),this.proxyErrors=h=>this.dest.emit("error",h),n.on("error",this.proxyErrors)}},I8=n=>!!n.objectMode,T8=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",CE=class extends b1{[rm]=!1;[Pw]=!1;[bm]=[];[sm]=[];[cm];[Km];[ah];[Qg];[wh]=!1;[Wh]=!1;[cE]=!1;[fE]=!1;[Uw]=null;[om]=0;[Gv]=!1;[Mw];[bE]=!1;[yg]=0;[Om]=!1;writable=!0;readable=!0;constructor(...n){let r=n[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");I8(r)?(this[cm]=!0,this[Km]=null):T8(r)?(this[Km]=r.encoding,this[cm]=!1):(this[cm]=!1,this[Km]=null),this[ah]=!!r.async,this[Qg]=this[Km]?new g8(this[Km]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[sm]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[bm]});let{signal:f}=r;f&&(this[Mw]=f,f.aborted?this[a1]():f.addEventListener("abort",()=>this[a1]()))}get bufferLength(){return this[om]}get encoding(){return this[Km]}set encoding(n){throw new Error("Encoding must be set at instantiation time")}setEncoding(n){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[cm]}set objectMode(n){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ah]}set async(n){this[ah]=this[ah]||!!n}[a1](){this[bE]=!0,this.emit("abort",this[Mw]?.reason),this.destroy(this[Mw]?.reason)}get aborted(){return this[bE]}set aborted(n){}write(n,r,f){if(this[bE])return!1;if(this[wh])throw new Error("write after end");if(this[Gv])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(f=r,r="utf8"),r||(r="utf8");let h=this[ah]?jw:L8;if(!this[cm]&&!Buffer.isBuffer(n)){if(_8(n))n=Buffer.from(n.buffer,n.byteOffset,n.byteLength);else if(A8(n))n=Buffer.from(n);else if(typeof n!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[cm]?(this[rm]&&this[om]!==0&&this[dE](!0),this[rm]?this.emit("data",n):this[r1](n),this[om]!==0&&this.emit("readable"),f&&h(f),this[rm]):n.length?(typeof n=="string"&&!(r===this[Km]&&!this[Qg]?.lastNeed)&&(n=Buffer.from(n,r)),Buffer.isBuffer(n)&&this[Km]&&(n=this[Qg].write(n)),this[rm]&&this[om]!==0&&this[dE](!0),this[rm]?this.emit("data",n):this[r1](n),this[om]!==0&&this.emit("readable"),f&&h(f),this[rm]):(this[om]!==0&&this.emit("readable"),f&&h(f),this[rm])}read(n){if(this[Gv])return null;if(this[Om]=!1,this[om]===0||n===0||n&&n>this[om])return this[Ch](),null;this[cm]&&(n=null),this[sm].length>1&&!this[cm]&&(this[sm]=[this[Km]?this[sm].join(""):Buffer.concat(this[sm],this[om])]);let r=this[V2](n||null,this[sm][0]);return this[Ch](),r}[V2](n,r){if(this[cm])this[pE]();else{let f=r;n===f.length||n===null?this[pE]():typeof f=="string"?(this[sm][0]=f.slice(n),r=f.slice(0,n),this[om]-=n):(this[sm][0]=f.subarray(n),r=f.subarray(0,n),this[om]-=n)}return this.emit("data",r),!this[sm].length&&!this[wh]&&this.emit("drain"),r}end(n,r,f){return typeof n=="function"&&(f=n,n=void 0),typeof r=="function"&&(f=r,r="utf8"),n!==void 0&&this.write(n,r),f&&this.once("end",f),this[wh]=!0,this.writable=!1,(this[rm]||!this[Pw])&&this[Ch](),this}[ey](){this[Gv]||(!this[yg]&&!this[bm].length&&(this[Om]=!0),this[Pw]=!1,this[rm]=!0,this.emit("resume"),this[sm].length?this[dE]():this[wh]?this[Ch]():this.emit("drain"))}resume(){return this[ey]()}pause(){this[rm]=!1,this[Pw]=!0,this[Om]=!1}get destroyed(){return this[Gv]}get flowing(){return this[rm]}get paused(){return this[Pw]}[r1](n){this[cm]?this[om]+=1:this[om]+=n.length,this[sm].push(n)}[pE](){return this[cm]?this[om]-=1:this[om]-=this[sm][0].length,this[sm].shift()}[dE](n=!1){do;while(this[H2](this[pE]())&&this[sm].length);!n&&!this[sm].length&&!this[wh]&&this.emit("drain")}[H2](n){return this.emit("data",n),this[rm]}pipe(n,r){if(this[Gv])return n;this[Om]=!1;let f=this[Wh];return r=r||{},n===q2.stdout||n===q2.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,f?r.end&&n.end():(this[bm].push(r.proxyErrors?new S8(this,n,r):new CD(this,n,r)),this[ah]?jw(()=>this[ey]()):this[ey]()),n}unpipe(n){let r=this[bm].find(f=>f.dest===n);r&&(this[bm].length===1?(this[rm]&&this[yg]===0&&(this[rm]=!1),this[bm]=[]):this[bm].splice(this[bm].indexOf(r),1),r.unpipe())}addListener(n,r){return this.on(n,r)}on(n,r){let f=super.on(n,r);if(n==="data")this[Om]=!1,this[yg]++,!this[bm].length&&!this[rm]&&this[ey]();else if(n==="readable"&&this[om]!==0)super.emit("readable");else if(E8(n)&&this[Wh])super.emit(n),this.removeAllListeners(n);else if(n==="error"&&this[Uw]){let h=r;this[ah]?jw(()=>h.call(this,this[Uw])):h.call(this,this[Uw])}return f}removeListener(n,r){return this.off(n,r)}off(n,r){let f=super.off(n,r);return n==="data"&&(this[yg]=this.listeners("data").length,this[yg]===0&&!this[Om]&&!this[bm].length&&(this[rm]=!1)),f}removeAllListeners(n){let r=super.removeAllListeners(n);return(n==="data"||n===void 0)&&(this[yg]=0,!this[Om]&&!this[bm].length&&(this[rm]=!1)),r}get emittedEnd(){return this[Wh]}[Ch](){!this[cE]&&!this[Wh]&&!this[Gv]&&this[sm].length===0&&this[wh]&&(this[cE]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[fE]&&this.emit("close"),this[cE]=!1)}emit(n,...r){let f=r[0];if(n!=="error"&&n!=="close"&&n!==Gv&&this[Gv])return!1;if(n==="data")return!this[cm]&&!f?!1:this[ah]?(jw(()=>this[o1](f)),!0):this[o1](f);if(n==="end")return this[Y2]();if(n==="close"){if(this[fE]=!0,!this[Wh]&&!this[Gv])return!1;let l=super.emit("close");return this.removeAllListeners("close"),l}else if(n==="error"){this[Uw]=f,super.emit(s1,f);let l=!this[Mw]||this.listeners("error").length?super.emit("error",f):!1;return this[Ch](),l}else if(n==="resume"){let l=super.emit("resume");return this[Ch](),l}else if(n==="finish"||n==="prefinish"){let l=super.emit(n);return this.removeAllListeners(n),l}let h=super.emit(n,...r);return this[Ch](),h}[o1](n){for(let f of this[bm])f.dest.write(n)===!1&&this.pause();let r=this[Om]?!1:super.emit("data",n);return this[Ch](),r}[Y2](){return this[Wh]?!1:(this[Wh]=!0,this.readable=!1,this[ah]?(jw(()=>this[i1]()),!0):this[i1]())}[i1](){if(this[Qg]){let r=this[Qg].end();if(r){for(let f of this[bm])f.dest.write(r);this[Om]||super.emit("data",r)}}for(let r of this[bm])r.end();let n=super.emit("end");return this.removeAllListeners("end"),n}async collect(){let n=Object.assign([],{dataLength:0});this[cm]||(n.dataLength=0);let r=this.promise();return this.on("data",f=>{n.push(f),this[cm]||(n.dataLength+=f.length)}),await r,n}async concat(){if(this[cm])throw new Error("cannot concat in objectMode");let n=await this.collect();return this[Km]?n.join(""):Buffer.concat(n,n.dataLength)}async promise(){return new Promise((n,r)=>{this.on(Gv,()=>r(new Error("stream destroyed"))),this.on("error",f=>r(f)),this.on("end",()=>n())})}[Symbol.asyncIterator](){this[Om]=!1;let n=!1,r=async()=>(this.pause(),n=!0,{value:void 0,done:!0});return{next:()=>{if(n)return r();let f=this.read();if(f!==null)return Promise.resolve({done:!1,value:f});if(this[wh])return r();let h,l,t=qe=>{this.off("data",$),this.off("end",re),this.off(Gv,e),r(),l(qe)},$=qe=>{this.off("error",t),this.off("end",re),this.off(Gv,e),this.pause(),h({value:qe,done:!!this[wh]})},re=()=>{this.off("error",t),this.off("data",$),this.off(Gv,e),r(),h({done:!0,value:void 0})},e=()=>t(new Error("stream destroyed"));return new Promise((qe,ht)=>{l=ht,h=qe,this.once(Gv,e),this.once("error",t),this.once("end",re),this.once("data",$)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Om]=!1;let n=!1,r=()=>(this.pause(),this.off(s1,r),this.off(Gv,r),this.off("end",r),n=!0,{done:!0,value:void 0}),f=()=>{if(n)return r();let h=this.read();return h===null?r():{done:!1,value:h}};return this.once("end",r),this.once(s1,r),this.once(Gv,r),{next:f,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(n){if(this[Gv])return n?this.emit("error",n):this.emit(Gv),this;this[Gv]=!0,this[Om]=!0,this[sm].length=0,this[om]=0;let r=this;return typeof r.close=="function"&&!this[fE]&&r.close(),n?this.emit("error",n):this.emit(Gv),this}static get isStream(){return y8}},x8=d8.native,Bw={lstatSync:u8,readdir:l8,readdirSync:c8,readlinkSync:f8,realpathSync:x8,promises:{lstat:b8,readdir:v8,readlink:m8,realpath:h8}},LD=n=>!n||n===Bw||n===p8?Bw:{...Bw,...n,promises:{...Bw.promises,...n.promises||{}}},ED=/^\\\\\?\\([a-z]:)\\?$/i,k8=n=>n.replace(/\//g,"\\").replace(ED,"$1\\"),R8=/[\\\/]/,Gm=0,AD=1,_D=2,uh=4,SD=6,ID=8,wg=10,TD=12,zm=15,Fw=~zm,u1=16,W2=32,qw=64,Jm=128,vE=256,gE=512,Z2=qw|Jm|gE,N8=1023,l1=n=>n.isFile()?ID:n.isDirectory()?uh:n.isSymbolicLink()?wg:n.isCharacterDevice()?_D:n.isBlockDevice()?SD:n.isSocket()?TD:n.isFIFO()?AD:Gm,K2=new LE({max:2**12}),Vw=n=>{let r=K2.get(n);if(r)return r;let f=n.normalize("NFKD");return K2.set(n,f),f},J2=new LE({max:2**12}),mE=n=>{let r=J2.get(n);if(r)return r;let f=Vw(n.toLowerCase());return J2.set(n,f),f},X2=class extends LE{constructor(){super({max:256})}},O8=class extends LE{constructor(n=16*1024){super({maxSize:n,sizeCalculation:r=>r.length+1})}},xD=Symbol("PathScurry setAsCwd"),Sm=class{name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#w;get gid(){return this.#w}#h;get rdev(){return this.#h}#c;get blksize(){return this.#c}#a;get ino(){return this.#a}#d;get size(){return this.#d}#f;get blocks(){return this.#f}#u;get atimeMs(){return this.#u}#r;get mtimeMs(){return this.#r}#p;get ctimeMs(){return this.#p}#C;get birthtimeMs(){return this.#C}#y;get atime(){return this.#y}#b;get mtime(){return this.#b}#T;get ctime(){return this.#T}#v;get birthtime(){return this.#v}#A;#_;#m;#g;#L;#S;#t;#$;#N;#I;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(n,r=Gm,f,h,l,t,$){this.name=n,this.#A=l?mE(n):Vw(n),this.#t=r&N8,this.nocase=l,this.roots=h,this.root=f||this,this.#$=t,this.#m=$.fullpath,this.#L=$.relative,this.#S=$.relativePosix,this.parent=$.parent,this.parent?this.#e=this.parent.#e:this.#e=LD($.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#$}resolve(n){if(!n)return this;let r=this.getRootString(n),f=n.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#O(f):this.#O(f)}#O(n){let r=this;for(let f of n)r=r.child(f);return r}children(){let n=this.#$.get(this);if(n)return n;let r=Object.assign([],{provisional:0});return this.#$.set(this,r),this.#t&=~u1,r}child(n,r){if(n===""||n===".")return this;if(n==="..")return this.parent||this;let f=this.children(),h=this.nocase?mE(n):Vw(n);for(let re of f)if(re.#A===h)return re;let l=this.parent?this.sep:"",t=this.#m?this.#m+l+n:void 0,$=this.newChild(n,Gm,{...r,parent:this,fullpath:t});return this.canReaddir()||($.#t|=Jm),f.push($),$}relative(){if(this.isCWD)return"";if(this.#L!==void 0)return this.#L;let n=this.name,r=this.parent;if(!r)return this.#L=this.name;let f=r.relative();return f+(!f||!r.parent?"":this.sep)+n}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let n=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let f=r.relativePosix();return f+(!f||!r.parent?"":"/")+n}fullpath(){if(this.#m!==void 0)return this.#m;let n=this.name,r=this.parent;if(!r)return this.#m=this.name;let f=r.fullpath()+(r.parent?this.sep:"")+n;return this.#m=f}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let h=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(h)?this.#g=`//?/${h}`:this.#g=h}let n=this.parent,r=n.fullpathPosix(),f=r+(!r||!n.parent?"":"/")+this.name;return this.#g=f}isUnknown(){return(this.#t&zm)===Gm}isType(n){return this[`is${n}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#t&zm)===ID}isDirectory(){return(this.#t&zm)===uh}isCharacterDevice(){return(this.#t&zm)===_D}isBlockDevice(){return(this.#t&zm)===SD}isFIFO(){return(this.#t&zm)===AD}isSocket(){return(this.#t&zm)===TD}isSymbolicLink(){return(this.#t&wg)===wg}lstatCached(){return this.#t&W2?this:void 0}readlinkCached(){return this.#N}realpathCached(){return this.#I}readdirCached(){let n=this.children();return n.slice(0,n.provisional)}canReadlink(){if(this.#N)return!0;if(!this.parent)return!1;let n=this.#t&zm;return!(n!==Gm&&n!==wg||this.#t&vE||this.#t&Jm)}calledReaddir(){return!!(this.#t&u1)}isENOENT(){return!!(this.#t&Jm)}isNamed(n){return this.nocase?this.#A===mE(n):this.#A===Vw(n)}async readlink(){let n=this.#N;if(n)return n;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),f=(await this.parent.realpath())?.resolve(r);if(f)return this.#N=f}catch(r){this.#R(r.code);return}}readlinkSync(){let n=this.#N;if(n)return n;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),f=this.parent.realpathSync()?.resolve(r);if(f)return this.#N=f}catch(r){this.#R(r.code);return}}#M(n){this.#t|=u1;for(let r=n.provisional;r<n.length;r++){let f=n[r];f&&f.#E()}}#E(){this.#t&Jm||(this.#t=(this.#t|Jm)&Fw,this.#q())}#q(){let n=this.children();n.provisional=0;for(let r of n)r.#E()}#P(){this.#t|=gE,this.#D()}#D(){if(this.#t&qw)return;let n=this.#t;(n&zm)===uh&&(n&=Fw),this.#t=n|qw,this.#q()}#j(n=""){n==="ENOTDIR"||n==="EPERM"?this.#D():n==="ENOENT"?this.#E():this.children().provisional=0}#k(n=""){n==="ENOTDIR"?this.parent.#D():n==="ENOENT"&&this.#E()}#R(n=""){let r=this.#t;r|=vE,n==="ENOENT"&&(r|=Jm),(n==="EINVAL"||n==="UNKNOWN")&&(r&=Fw),this.#t=r,n==="ENOTDIR"&&this.parent&&this.parent.#D()}#F(n,r){return this.#G(n,r)||this.#z(n,r)}#z(n,r){let f=l1(n),h=this.newChild(n.name,f,{parent:this}),l=h.#t&zm;return l!==uh&&l!==wg&&l!==Gm&&(h.#t|=qw),r.unshift(h),r.provisional++,h}#G(n,r){for(let f=r.provisional;f<r.length;f++){let h=r[f];if((this.nocase?mE(n.name):Vw(n.name))===h.#A)return this.#l(n,h,f,r)}}#l(n,r,f,h){let l=r.name;return r.#t=r.#t&Fw|l1(n),l!==n.name&&(r.name=n.name),f!==h.provisional&&(f===h.length-1?h.pop():h.splice(f,1),h.unshift(r)),h.provisional++,r}async lstat(){if((this.#t&Jm)===0)try{return this.#B(await this.#e.promises.lstat(this.fullpath())),this}catch(n){this.#k(n.code)}}lstatSync(){if((this.#t&Jm)===0)try{return this.#B(this.#e.lstatSync(this.fullpath())),this}catch(n){this.#k(n.code)}}#B(n){let{atime:r,atimeMs:f,birthtime:h,birthtimeMs:l,blksize:t,blocks:$,ctime:re,ctimeMs:e,dev:qe,gid:ht,ino:Ke,mode:gt,mtime:ln,mtimeMs:Qn,nlink:bn,rdev:zr,size:tr,uid:Er}=n;this.#y=r,this.#u=f,this.#v=h,this.#C=l,this.#c=t,this.#f=$,this.#T=re,this.#p=e,this.#n=qe,this.#w=ht,this.#a=Ke,this.#o=gt,this.#b=ln,this.#r=Qn,this.#s=bn,this.#h=zr,this.#d=tr,this.#i=Er;let cs=l1(n);this.#t=this.#t&Fw|cs|W2,cs!==Gm&&cs!==uh&&cs!==wg&&(this.#t|=qw)}#U=[];#x=!1;#V(n){this.#x=!1;let r=this.#U.slice();this.#U.length=0,r.forEach(f=>f(null,n))}readdirCB(n,r=!1){if(!this.canReaddir()){r?n(null,[]):queueMicrotask(()=>n(null,[]));return}let f=this.children();if(this.calledReaddir()){let l=f.slice(0,f.provisional);r?n(null,l):queueMicrotask(()=>n(null,l));return}if(this.#U.push(n),this.#x)return;this.#x=!0;let h=this.fullpath();this.#e.readdir(h,{withFileTypes:!0},(l,t)=>{if(l)this.#j(l.code),f.provisional=0;else{for(let $ of t)this.#F($,f);this.#M(f)}this.#V(f.slice(0,f.provisional))})}#H;async readdir(){if(!this.canReaddir())return[];let n=this.children();if(this.calledReaddir())return n.slice(0,n.provisional);let r=this.fullpath();if(this.#H)await this.#H;else{let f=()=>{};this.#H=new Promise(h=>f=h);try{for(let h of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#F(h,n);this.#M(n)}catch(h){this.#j(h.code),n.provisional=0}this.#H=void 0,f()}return n.slice(0,n.provisional)}readdirSync(){if(!this.canReaddir())return[];let n=this.children();if(this.calledReaddir())return n.slice(0,n.provisional);let r=this.fullpath();try{for(let f of this.#e.readdirSync(r,{withFileTypes:!0}))this.#F(f,n);this.#M(n)}catch(f){this.#j(f.code),n.provisional=0}return n.slice(0,n.provisional)}canReaddir(){if(this.#t&Z2)return!1;let n=zm&this.#t;return n===Gm||n===uh||n===wg}shouldWalk(n,r){return(this.#t&uh)===uh&&!(this.#t&Z2)&&!n.has(this)&&(!r||r(this))}async realpath(){if(this.#I)return this.#I;if(!((gE|vE|Jm)&this.#t))try{let n=await this.#e.promises.realpath(this.fullpath());return this.#I=this.resolve(n)}catch{this.#P()}}realpathSync(){if(this.#I)return this.#I;if(!((gE|vE|Jm)&this.#t))try{let n=this.#e.realpathSync(this.fullpath());return this.#I=this.resolve(n)}catch{this.#P()}}[xD](n){if(n===this)return;n.isCWD=!1,this.isCWD=!0;let r=new Set([]),f=[],h=this;for(;h&&h.parent;)r.add(h),h.#L=f.join(this.sep),h.#S=f.join("/"),h=h.parent,f.push("..");for(h=n;h&&h.parent&&!r.has(h);)h.#L=void 0,h.#S=void 0,h=h.parent}},kD=class RD extends Sm{sep="\\";splitSep=R8;constructor(r,f=Gm,h,l,t,$,re){super(r,f,h,l,t,$,re)}newChild(r,f=Gm,h={}){return new RD(r,f,this.root,this.roots,this.nocase,this.childrenCache(),h)}getRootString(r){return f1.parse(r).root}getRoot(r){if(r=k8(r.toUpperCase()),r===this.root.name)return this.root;for(let[f,h]of Object.entries(this.roots))if(this.sameRoot(r,f))return this.roots[r]=h;return this.roots[r]=new v1(r,this).root}sameRoot(r,f=this.root.name){return r=r.toUpperCase().replace(/\//g,"\\").replace(ED,"$1\\"),r===f}},ND=class OD extends Sm{splitSep="/";sep="/";constructor(r,f=Gm,h,l,t,$,re){super(r,f,h,l,t,$,re)}getRootString(r){return r.startsWith("/")?"/":""}getRoot(r){return this.root}newChild(r,f=Gm,h={}){return new OD(r,f,this.root,this.roots,this.nocase,this.childrenCache(),h)}},$D=class{root;rootPath;roots;cwd;#e;#n;#o;nocase;#s;constructor(n=process.cwd(),r,f,{nocase:h,childrenCacheSize:l=16*1024,fs:t=Bw}={}){this.#s=LD(t),(n instanceof URL||n.startsWith("file://"))&&(n=a8(n));let $=r.resolve(n);this.roots=Object.create(null),this.rootPath=this.parseRootPath($),this.#e=new X2,this.#n=new X2,this.#o=new O8(l);let re=$.substring(this.rootPath.length).split(f);if(re.length===1&&!re[0]&&re.pop(),h===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=h,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let e=this.root,qe=re.length-1,ht=r.sep,Ke=this.rootPath,gt=!1;for(let ln of re){let Qn=qe--;e=e.child(ln,{relative:new Array(Qn).fill("..").join(ht),relativePosix:new Array(Qn).fill("..").join("/"),fullpath:Ke+=(gt?"":ht)+ln}),gt=!0}this.cwd=e}depth(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.depth()}childrenCache(){return this.#o}resolve(...n){let r="";for(let l=n.length-1;l>=0;l--){let t=n[l];if(!(!t||t===".")&&(r=r?`${t}/${r}`:t,this.isAbsolute(t)))break}let f=this.#e.get(r);if(f!==void 0)return f;let h=this.cwd.resolve(r).fullpath();return this.#e.set(r,h),h}resolvePosix(...n){let r="";for(let l=n.length-1;l>=0;l--){let t=n[l];if(!(!t||t===".")&&(r=r?`${t}/${r}`:t,this.isAbsolute(t)))break}let f=this.#n.get(r);if(f!==void 0)return f;let h=this.cwd.resolve(r).fullpathPosix();return this.#n.set(r,h),h}relative(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.relative()}relativePosix(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.relativePosix()}basename(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.name}dirname(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),(n.parent||n).fullpath()}async readdir(n=this.cwd,r={withFileTypes:!0}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f}=r;if(n.canReaddir()){let h=await n.readdir();return f?h:h.map(l=>l.name)}else return[]}readdirSync(n=this.cwd,r={withFileTypes:!0}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0}=r;return n.canReaddir()?f?n.readdirSync():n.readdirSync().map(h=>h.name):[]}async lstat(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.lstat()}lstatSync(n=this.cwd){return typeof n=="string"&&(n=this.cwd.resolve(n)),n.lstatSync()}async readlink(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=await n.readlink();return r?f:f?.fullpath()}readlinkSync(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=n.readlinkSync();return r?f:f?.fullpath()}async realpath(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=await n.realpath();return r?f:f?.fullpath()}realpathSync(n=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n.withFileTypes,n=this.cwd);let f=n.realpathSync();return r?f:f?.fullpath()}async walk(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=[];(!l||l(n))&&$.push(f?n:n.fullpath());let re=new Set,e=(ht,Ke)=>{re.add(ht),ht.readdirCB((gt,ln)=>{if(gt)return Ke(gt);let Qn=ln.length;if(!Qn)return Ke();let bn=()=>{--Qn===0&&Ke()};for(let zr of ln)(!l||l(zr))&&$.push(f?zr:zr.fullpath()),h&&zr.isSymbolicLink()?zr.realpath().then(tr=>tr?.isUnknown()?tr.lstat():tr).then(tr=>tr?.shouldWalk(re,t)?e(tr,bn):bn()):zr.shouldWalk(re,t)?e(zr,bn):bn()},!0)},qe=n;return new Promise((ht,Ke)=>{e(qe,gt=>{if(gt)return Ke(gt);ht($)})})}walkSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=[];(!l||l(n))&&$.push(f?n:n.fullpath());let re=new Set([n]);for(let e of re){let qe=e.readdirSync();for(let ht of qe){(!l||l(ht))&&$.push(f?ht:ht.fullpath());let Ke=ht;if(ht.isSymbolicLink()){if(!(h&&(Ke=ht.realpathSync())))continue;Ke.isUnknown()&&Ke.lstatSync()}Ke.shouldWalk(re,t)&&re.add(Ke)}}return $}[Symbol.asyncIterator](){return this.iterate()}iterate(n=this.cwd,r={}){return typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd),this.stream(n,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r;(!l||l(n))&&(yield f?n:n.fullpath());let $=new Set([n]);for(let re of $){let e=re.readdirSync();for(let qe of e){(!l||l(qe))&&(yield f?qe:qe.fullpath());let ht=qe;if(qe.isSymbolicLink()){if(!(h&&(ht=qe.realpathSync())))continue;ht.isUnknown()&&ht.lstatSync()}ht.shouldWalk($,t)&&$.add(ht)}}}stream(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=new CE({objectMode:!0});(!l||l(n))&&$.write(f?n:n.fullpath());let re=new Set,e=[n],qe=0,ht=()=>{let Ke=!1;for(;!Ke;){let gt=e.shift();if(!gt){qe===0&&$.end();return}qe++,re.add(gt);let ln=(bn,zr,tr=!1)=>{if(bn)return $.emit("error",bn);if(h&&!tr){let Er=[];for(let cs of zr)cs.isSymbolicLink()&&Er.push(cs.realpath().then(Ys=>Ys?.isUnknown()?Ys.lstat():Ys));if(Er.length){Promise.all(Er).then(()=>ln(null,zr,!0));return}}for(let Er of zr)Er&&(!l||l(Er))&&($.write(f?Er:Er.fullpath())||(Ke=!0));qe--;for(let Er of zr){let cs=Er.realpathCached()||Er;cs.shouldWalk(re,t)&&e.push(cs)}Ke&&!$.flowing?$.once("drain",ht):Qn||ht()},Qn=!0;gt.readdirCB(ln,!0),Qn=!1}};return ht(),$}streamSync(n=this.cwd,r={}){typeof n=="string"?n=this.cwd.resolve(n):n instanceof Sm||(r=n,n=this.cwd);let{withFileTypes:f=!0,follow:h=!1,filter:l,walkFilter:t}=r,$=new CE({objectMode:!0}),re=new Set;(!l||l(n))&&$.write(f?n:n.fullpath());let e=[n],qe=0,ht=()=>{let Ke=!1;for(;!Ke;){let gt=e.shift();if(!gt){qe===0&&$.end();return}qe++,re.add(gt);let ln=gt.readdirSync();for(let Qn of ln)(!l||l(Qn))&&($.write(f?Qn:Qn.fullpath())||(Ke=!0));qe--;for(let Qn of ln){let bn=Qn;if(Qn.isSymbolicLink()){if(!(h&&(bn=Qn.realpathSync())))continue;bn.isUnknown()&&bn.lstatSync()}bn.shouldWalk(re,t)&&e.push(bn)}}Ke&&!$.flowing&&$.once("drain",ht)};return ht(),$}chdir(n=this.cwd){let r=this.cwd;this.cwd=typeof n=="string"?this.cwd.resolve(n):n,this.cwd[xD](r)}},v1=class extends $D{sep="\\";constructor(n=process.cwd(),r={}){let{nocase:f=!0}=r;super(n,f1,"\\",{...r,nocase:f}),this.nocase=f;for(let h=this.cwd;h;h=h.parent)h.nocase=this.nocase}parseRootPath(n){return f1.parse(n).root.toUpperCase()}newRoot(n){return new kD(this.rootPath,uh,void 0,this.roots,this.nocase,this.childrenCache(),{fs:n})}isAbsolute(n){return n.startsWith("/")||n.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(n)}},m1=class extends $D{sep="/";constructor(n=process.cwd(),r={}){let{nocase:f=!1}=r;super(n,i8,"/",{...r,nocase:f}),this.nocase=f}parseRootPath(n){return"/"}newRoot(n){return new ND(this.rootPath,uh,void 0,this.roots,this.nocase,this.childrenCache(),{fs:n})}isAbsolute(n){return n.startsWith("/")}},DD=class extends m1{constructor(n=process.cwd(),r={}){let{nocase:f=!0}=r;super(n,{...r,nocase:f})}},pQ=process.platform==="win32"?kD:ND,$8=process.platform==="win32"?v1:process.platform==="darwin"?DD:m1,D8=n=>n.length>=1,U8=n=>n.length>=1,P8=Symbol.for("nodejs.util.inspect.custom"),UD=class PD{#e;#n;#o;length;#s;#i;#w;#h;#c;#a;#d=!0;constructor(r,f,h,l){if(!D8(r))throw new TypeError("empty pattern list");if(!U8(f))throw new TypeError("empty glob list");if(f.length!==r.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=r.length,h<0||h>=this.length)throw new TypeError("index out of range");if(this.#e=r,this.#n=f,this.#o=h,this.#s=l,this.#o===0){if(this.isUNC()){let[t,$,re,e,...qe]=this.#e,[ht,Ke,gt,ln,...Qn]=this.#n;qe[0]===""&&(qe.shift(),Qn.shift());let bn=[t,$,re,e,""].join("/"),zr=[ht,Ke,gt,ln,""].join("/");this.#e=[bn,...qe],this.#n=[zr,...Qn],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[t,...$]=this.#e,[re,...e]=this.#n;$[0]===""&&($.shift(),e.shift());let qe=t+"/",ht=re+"/";this.#e=[qe,...$],this.#n=[ht,...e],this.length=this.#e.length}}}[P8](){return"Pattern <"+this.#n.slice(this.#o).join("/")+">"}pattern(){return this.#e[this.#o]}isString(){return typeof this.#e[this.#o]=="string"}isGlobstar(){return this.#e[this.#o]===vm}isRegExp(){return this.#e[this.#o]instanceof RegExp}globString(){return this.#w=this.#w||(this.#o===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new PD(this.#e,this.#n,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#c=this.#c,this.#i.#h=this.#h,this.#i):this.#i=null}isUNC(){let r=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#s==="win32"&&this.#o===0&&r[0]===""&&r[1]===""&&typeof r[2]=="string"&&!!r[2]&&typeof r[3]=="string"&&!!r[3]}isDrive(){let r=this.#e;return this.#h!==void 0?this.#h:this.#h=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0])}isAbsolute(){let r=this.#e;return this.#a!==void 0?this.#a:this.#a=r[0]===""&&r.length>1||this.isDrive()||this.isUNC()}root(){let r=this.#e[0];return typeof r=="string"&&this.isAbsolute()&&this.#o===0?r:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#d)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#d?!1:(this.#d=!1,!0)}},M8=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Q2=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(n,{nobrace:r,nocase:f,noext:h,noglobstar:l,platform:t=M8}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=t,this.mmopts={dot:!0,nobrace:r,nocase:f,noext:h,noglobstar:l,optimizationLevel:2,platform:t,nocomment:!0,nonegate:!0};for(let $ of n)this.add($)}add(n){let r=new Kh(n,this.mmopts);for(let f=0;f<r.set.length;f++){let h=r.set[f],l=r.globParts[f];if(!h||!l)throw new Error("invalid pattern object");for(;h[0]==="."&&l[0]===".";)h.shift(),l.shift();let t=new UD(h,l,0,this.platform),$=new Kh(t.globString(),this.mmopts),re=l[l.length-1]==="**",e=t.isAbsolute();e?this.absolute.push($):this.relative.push($),re&&(e?this.absoluteChildren.push($):this.relativeChildren.push($))}}ignored(n){let r=n.fullpath(),f=`${r}/`,h=n.relative()||".",l=`${h}/`;for(let t of this.relative)if(t.match(h)||t.match(l))return!0;for(let t of this.absolute)if(t.match(r)||t.match(f))return!0;return!1}childrenIgnored(n){let r=n.fullpath()+"/",f=(n.relative()||".")+"/";for(let h of this.relativeChildren)if(h.match(f))return!0;for(let h of this.absoluteChildren)if(h.match(r))return!0;return!1}},j8=class MD{store;constructor(r=new Map){this.store=r}copy(){return new MD(new Map(this.store))}hasWalked(r,f){return this.store.get(r.fullpath())?.has(f.globString())}storeWalked(r,f){let h=r.fullpath(),l=this.store.get(h);l?l.add(f.globString()):this.store.set(h,new Set([f.globString()]))}},F8=class{store=new Map;add(n,r,f){let h=(r?2:0)|(f?1:0),l=this.store.get(n);this.store.set(n,l===void 0?h:h&l)}entries(){return[...this.store.entries()].map(([n,r])=>[n,!!(r&2),!!(r&1)])}},z8=class{store=new Map;add(n,r){if(!n.canReaddir())return;let f=this.store.get(n);f?f.find(h=>h.globString()===r.globString())||f.push(r):this.store.set(n,[r])}get(n){let r=this.store.get(n);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(n=>[n,this.store.get(n)])}keys(){return[...this.store.keys()].filter(n=>n.canReaddir())}},eD=class jD{hasWalkedCache;matches=new F8;subwalks=new z8;patterns;follow;dot;opts;constructor(r,f){this.opts=r,this.follow=!!r.follow,this.dot=!!r.dot,this.hasWalkedCache=f?f.copy():new j8}processPatterns(r,f){this.patterns=f;let h=f.map(l=>[r,l]);for(let[l,t]of h){this.hasWalkedCache.storeWalked(l,t);let $=t.root(),re=t.isAbsolute()&&this.opts.absolute!==!1;if($){l=l.resolve($==="/"&&this.opts.root!==void 0?this.opts.root:$);let Ke=t.rest();if(Ke)t=Ke;else{this.matches.add(l,!0,!1);continue}}if(l.isENOENT())continue;let e,qe,ht=!1;for(;typeof(e=t.pattern())=="string"&&(qe=t.rest());)l=l.resolve(e),t=qe,ht=!0;if(e=t.pattern(),qe=t.rest(),ht){if(this.hasWalkedCache.hasWalked(l,t))continue;this.hasWalkedCache.storeWalked(l,t)}if(typeof e=="string"){let Ke=e===".."||e===""||e===".";this.matches.add(l.resolve(e),re,Ke);continue}else if(e===vm){(!l.isSymbolicLink()||this.follow||t.checkFollowGlobstar())&&this.subwalks.add(l,t);let Ke=qe?.pattern(),gt=qe?.rest();if(!qe||(Ke===""||Ke===".")&&!gt)this.matches.add(l,re,Ke===""||Ke===".");else if(Ke===".."){let ln=l.parent||l;gt?this.hasWalkedCache.hasWalked(ln,gt)||this.subwalks.add(ln,gt):this.matches.add(ln,re,!0)}}else e instanceof RegExp&&this.subwalks.add(l,t)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new jD(this.opts,this.hasWalkedCache)}filterEntries(r,f){let h=this.subwalks.get(r),l=this.child();for(let t of f)for(let $ of h){let re=$.isAbsolute(),e=$.pattern(),qe=$.rest();e===vm?l.testGlobstar(t,$,qe,re):e instanceof RegExp?l.testRegExp(t,e,qe,re):l.testString(t,e,qe,re)}return l}testGlobstar(r,f,h,l){if((this.dot||!r.name.startsWith("."))&&(f.hasMore()||this.matches.add(r,l,!1),r.canReaddir()&&(this.follow||!r.isSymbolicLink()?this.subwalks.add(r,f):r.isSymbolicLink()&&(h&&f.checkFollowGlobstar()?this.subwalks.add(r,h):f.markFollowGlobstar()&&this.subwalks.add(r,f)))),h){let t=h.pattern();if(typeof t=="string"&&t!==".."&&t!==""&&t!==".")this.testString(r,t,h.rest(),l);else if(t===".."){let $=r.parent||r;this.subwalks.add($,h)}else t instanceof RegExp&&this.testRegExp(r,t,h.rest(),l)}}testRegExp(r,f,h,l){f.test(r.name)&&(h?this.subwalks.add(r,h):this.matches.add(r,l,!1))}testString(r,f,h,l){r.isNamed(f)&&(h?this.subwalks.add(r,h):this.matches.add(r,l,!1))}},G8=(n,r)=>typeof n=="string"?new Q2([n],r):Array.isArray(n)?new Q2(n,r):n,FD=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#o;signal;maxDepth;includeChildMatches;constructor(n,r,f){if(this.patterns=n,this.path=r,this.opts=f,this.#o=!f.posix&&f.platform==="win32"?"\\":"/",this.includeChildMatches=f.includeChildMatches!==!1,(f.ignore||!this.includeChildMatches)&&(this.#n=G8(f.ignore??[],f),!this.includeChildMatches&&typeof this.#n.add!="function")){let h="cannot ignore child matches, ignore lacks add() method.";throw new Error(h)}this.maxDepth=f.maxDepth||1/0,f.signal&&(this.signal=f.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#s(n){return this.seen.has(n)||!!this.#n?.ignored?.(n)}#i(n){return!!this.#n?.childrenIgnored?.(n)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let n;for(;!this.paused&&(n=this.#e.shift());)n()}onResume(n){this.signal?.aborted||(this.paused?this.#e.push(n):n())}async matchCheck(n,r){if(r&&this.opts.nodir)return;let f;if(this.opts.realpath){if(f=n.realpathCached()||await n.realpath(),!f)return;n=f}let h=n.isUnknown()||this.opts.stat?await n.lstat():n;if(this.opts.follow&&this.opts.nodir&&h?.isSymbolicLink()){let l=await h.realpath();l&&(l.isUnknown()||this.opts.stat)&&await l.lstat()}return this.matchCheckTest(h,r)}matchCheckTest(n,r){return n&&(this.maxDepth===1/0||n.depth()<=this.maxDepth)&&(!r||n.canReaddir())&&(!this.opts.nodir||!n.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!n.isSymbolicLink()||!n.realpathCached()?.isDirectory())&&!this.#s(n)?n:void 0}matchCheckSync(n,r){if(r&&this.opts.nodir)return;let f;if(this.opts.realpath){if(f=n.realpathCached()||n.realpathSync(),!f)return;n=f}let h=n.isUnknown()||this.opts.stat?n.lstatSync():n;if(this.opts.follow&&this.opts.nodir&&h?.isSymbolicLink()){let l=h.realpathSync();l&&(l?.isUnknown()||this.opts.stat)&&l.lstatSync()}return this.matchCheckTest(h,r)}matchFinish(n,r){if(this.#s(n))return;if(!this.includeChildMatches&&this.#n?.add){let l=`${n.relativePosix()}/**`;this.#n.add(l)}let f=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(n);let h=this.opts.mark&&n.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(n);else if(f){let l=this.opts.posix?n.fullpathPosix():n.fullpath();this.matchEmit(l+h)}else{let l=this.opts.posix?n.relativePosix():n.relative(),t=this.opts.dotRelative&&!l.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(l?t+l+h:"."+h)}}async match(n,r,f){let h=await this.matchCheck(n,f);h&&this.matchFinish(h,r)}matchSync(n,r,f){let h=this.matchCheckSync(n,f);h&&this.matchFinish(h,r)}walkCB(n,r,f){this.signal?.aborted&&f(),this.walkCB2(n,r,new eD(this.opts),f)}walkCB2(n,r,f,h){if(this.#i(n))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2(n,r,f,h));return}f.processPatterns(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||(l++,this.match($,re,e).then(()=>t()));for(let $ of f.subwalkTargets()){if(this.maxDepth!==1/0&&$.depth()>=this.maxDepth)continue;l++;let re=$.readdirCached();$.calledReaddir()?this.walkCB3($,re,f,t):$.readdirCB((e,qe)=>this.walkCB3($,qe,f,t),!0)}t()}walkCB3(n,r,f,h){f=f.filterEntries(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||(l++,this.match($,re,e).then(()=>t()));for(let[$,re]of f.subwalks.entries())l++,this.walkCB2($,re,f.child(),t);t()}walkCBSync(n,r,f){this.signal?.aborted&&f(),this.walkCB2Sync(n,r,new eD(this.opts),f)}walkCB2Sync(n,r,f,h){if(this.#i(n))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2Sync(n,r,f,h));return}f.processPatterns(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||this.matchSync($,re,e);for(let $ of f.subwalkTargets()){if(this.maxDepth!==1/0&&$.depth()>=this.maxDepth)continue;l++;let re=$.readdirSync();this.walkCB3Sync($,re,f,t)}t()}walkCB3Sync(n,r,f,h){f=f.filterEntries(n,r);let l=1,t=()=>{--l===0&&h()};for(let[$,re,e]of f.matches.entries())this.#s($)||this.matchSync($,re,e);for(let[$,re]of f.subwalks.entries())l++,this.walkCB2Sync($,re,f.child(),t);t()}},tD=class extends FD{matches=new Set;constructor(n,r,f){super(n,r,f)}matchEmit(n){this.matches.add(n)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((n,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):n(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},nD=class extends FD{results;constructor(n,r,f){super(n,r,f),this.results=new CE({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(n){this.results.write(n),this.results.flowing||this.pause()}stream(){let n=this.path;return n.isUnknown()?n.lstat().then(()=>{this.walkCB(n,this.patterns,()=>this.results.end())}):this.walkCB(n,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},B8=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Cg=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(n,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=n8(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof n=="string"&&(n=[n]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(n=n.map(re=>re.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");n=n.map(re=>re.includes("/")?re:`./**/${re}`)}if(this.pattern=n,this.platform=r.platform||B8,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let re=r.platform==="win32"?v1:r.platform==="darwin"?DD:r.platform?m1:$8;this.scurry=new re(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let f=this.platform==="darwin"||this.platform==="win32",h={braceExpandMax:1e4,...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:f,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},l=this.pattern.map(re=>new Kh(re,h)),[t,$]=l.reduce((re,e)=>(re[0].push(...e.set),re[1].push(...e.globParts),re),[[],[]]);this.patterns=t.map((re,e)=>{let qe=$[e];if(!qe)throw new Error("invalid pattern object");return new UD(re,qe,0,this.platform)})}async walk(){return[...await new tD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new tD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new nD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new nD(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},q8=(n,r={})=>{Array.isArray(n)||(n=[n]);for(let f of n)if(new Kh(f,r).hasMagic())return!0;return!1};function EE(n,r={}){return new Cg(n,r).streamSync()}function zD(n,r={}){return new Cg(n,r).stream()}function GD(n,r={}){return new Cg(n,r).walkSync()}async function rD(n,r={}){return new Cg(n,r).walk()}function AE(n,r={}){return new Cg(n,r).iterateSync()}function BD(n,r={}){return new Cg(n,r).iterate()}var V8=EE,H8=Object.assign(zD,{sync:EE}),Y8=AE,W8=Object.assign(BD,{sync:AE}),Z8=Object.assign(GD,{stream:EE,iterate:AE}),Hw=Object.assign(rD,{glob:rD,globSync:GD,sync:Z8,globStream:zD,stream:H8,globStreamSync:EE,streamSync:V8,globIterate:BD,iterate:W8,globIterateSync:AE,iterateSync:Y8,Glob:Cg,hasMagic:q8,escape:fD,unescape:ty});Hw.glob=Hw;function eB(n){qD(n)||J8(n,{recursive:!0})}function tB(n,r){let f=Q8(n);eB(f);let h=qD(n),l=!1;return h&&(l=X8(n,"utf-8")===r),l||K8(n,r,"utf-8"),{path:n,created:!h,updated:h&&!l,unchanged:l}}function _E(n){let r=[];for(let{path:f,content:h}of n)r.push(tB(f,h));return{results:r,created:r.filter(f=>f.created).length,updated:r.filter(f=>f.updated).length,unchanged:r.filter(f=>f.unchanged).length,total:r.length}}var HY=nh(ih(),1);import{join as FC,extname as Ore}from"node:path";var ks={};hh(ks,{$brand:()=>R1,$input:()=>Qx,$output:()=>Xx,INVALID:()=>Cm,NEVER:()=>k1,TimePrecision:()=>ck,ZodAny:()=>XR,ZodArray:()=>nN,ZodBase64:()=>C_,ZodBase64URL:()=>L_,ZodBigInt:()=>jy,ZodBigIntFormat:()=>__,ZodBoolean:()=>My,ZodCIDRv4:()=>y_,ZodCIDRv6:()=>w_,ZodCUID:()=>d_,ZodCUID2:()=>p_,ZodCatch:()=>EN,ZodCodec:()=>DC,ZodCompileAsyncError:()=>Qm,ZodCompileUnsupportedError:()=>Xd,ZodCreditCard:()=>qR,ZodCustom:()=>UC,ZodCustomStringFormat:()=>Uy,ZodDate:()=>xC,ZodDefault:()=>hN,ZodDiscriminatedUnion:()=>sN,ZodE164:()=>E_,ZodEmail:()=>u_,ZodEmoji:()=>c_,ZodEnum:()=>$y,ZodError:()=>yY,ZodExactOptional:()=>x_,ZodFile:()=>pN,ZodFirstPartyTypeKind:()=>jN,ZodFunction:()=>ON,ZodGUID:()=>l_,ZodIBAN:()=>VR,ZodIPv4:()=>h_,ZodIPv6:()=>g_,ZodISODate:()=>ag,ZodISODateTime:()=>ig,ZodISODuration:()=>lg,ZodISOTime:()=>ug,ZodInstanceOf:()=>MN,ZodIntersection:()=>oN,ZodIssueCode:()=>LY,ZodJWT:()=>A_,ZodKSUID:()=>m_,ZodLazy:()=>kN,ZodLiteral:()=>dN,ZodMAC:()=>BR,ZodMap:()=>cN,ZodNaN:()=>_N,ZodNanoID:()=>f_,ZodNever:()=>eN,ZodNonOptional:()=>k_,ZodNull:()=>KR,ZodNullable:()=>mN,ZodNumber:()=>Py,ZodNumberFormat:()=>Mg,ZodObject:()=>RC,ZodOptional:()=>OC,ZodPipe:()=>$C,ZodPrefault:()=>yN,ZodPreprocess:()=>SN,ZodPromise:()=>NN,ZodProperties:()=>$N,ZodReadonly:()=>IN,ZodRealError:()=>km,ZodRecord:()=>Oy,ZodSet:()=>fN,ZodString:()=>Dy,ZodStringFormat:()=>gv,ZodSuccess:()=>LN,ZodSymbol:()=>WR,ZodTemplateLiteral:()=>xN,ZodTransform:()=>bN,ZodTuple:()=>aN,ZodType:()=>uf,ZodULID:()=>b_,ZodURL:()=>TC,ZodUUID:()=>dh,ZodUndefined:()=>ZR,ZodUnion:()=>NC,ZodUnknown:()=>QR,ZodVoid:()=>tN,ZodXID:()=>v_,ZodXor:()=>rN,_ZodString:()=>a_,_default:()=>gN,_function:()=>_M,any:()=>nM,array:()=>kC,base64:()=>PP,base64url:()=>MP,bigint:()=>JP,boolean:()=>YR,catch:()=>AN,check:()=>SM,cidrv4:()=>DP,cidrv6:()=>UP,clone:()=>Lb,codec:()=>CM,coerce:()=>zN,compile:()=>rk,config:()=>zv,core:()=>Sh,creditCard:()=>FP,cuid:()=>IP,cuid2:()=>TP,custom:()=>IM,date:()=>sM,decode:()=>UR,decodeAsync:()=>MR,deepPartial:()=>FM,describe:()=>TM,discriminatedUnion:()=>cM,e164:()=>jP,email:()=>hP,emoji:()=>_P,encode:()=>DR,encodeAsync:()=>PR,endsWith:()=>Cy,enum:()=>I_,exactOptional:()=>vN,file:()=>hM,flattenError:()=>tC,float32:()=>YP,float64:()=>WP,formatError:()=>nC,fromJSONSchema:()=>MM,function:()=>_M,getDiscriminatedOption:()=>_x,getErrorMap:()=>AY,globalRegistry:()=>lm,gt:()=>ch,gte:()=>Um,guid:()=>gP,hash:()=>HP,hex:()=>VP,hostname:()=>qP,httpUrl:()=>AP,iban:()=>zP,includes:()=>yy,input:()=>GM,instanceof:()=>kM,int:()=>o_,int32:()=>ZP,int64:()=>XP,intersection:()=>iN,invertCodec:()=>LM,ipv4:()=>NP,ipv6:()=>$P,iso:()=>PC,json:()=>NM,jwt:()=>GP,keyof:()=>oM,ksuid:()=>RP,lazy:()=>RN,length:()=>Dg,literal:()=>mM,locales:()=>yC,looseObject:()=>uM,looseRecord:()=>dM,lowercase:()=>hy,lt:()=>lh,lte:()=>Dm,mac:()=>OP,map:()=>pM,maxLength:()=>$g,maxSize:()=>tg,memoizer:()=>hC,meta:()=>xM,mime:()=>Ly,minLength:()=>_h,minSize:()=>fh,multipleOf:()=>eg,nan:()=>wM,nanoid:()=>SP,nativeEnum:()=>vM,negative:()=>WA,never:()=>S_,nonnegative:()=>KA,nonoptional:()=>CN,nonpositive:()=>ZA,normalize:()=>Ey,null:()=>JR,nullable:()=>IC,nullish:()=>gM,number:()=>HR,object:()=>iM,optional:()=>Pg,output:()=>BM,overwrite:()=>eh,parse:()=>RR,parseAsync:()=>NR,partialRecord:()=>fM,pipe:()=>i_,positive:()=>YA,prefault:()=>wN,preprocess:()=>OM,prettifyError:()=>U1,promise:()=>AM,properties:()=>DN,property:()=>JA,readonly:()=>TN,record:()=>lN,refine:()=>UN,regex:()=>my,regexes:()=>wm,registry:()=>EA,safeDecode:()=>FR,safeDecodeAsync:()=>GR,safeEncode:()=>jR,safeEncodeAsync:()=>zR,safeParse:()=>OR,safeParseAsync:()=>$R,set:()=>bM,setErrorMap:()=>EY,size:()=>Og,slugify:()=>Iy,startsWith:()=>wy,strictObject:()=>aM,string:()=>SC,stringFormat:()=>BP,stringbool:()=>RM,success:()=>yM,superRefine:()=>PN,symbol:()=>eM,templateLiteral:()=>EM,toJSONSchema:()=>t_,toLowerCase:()=>_y,toUpperCase:()=>Sy,toZod:()=>Yw,transform:()=>T_,treeifyError:()=>D1,trim:()=>Ay,tuple:()=>uN,uint32:()=>KP,uint64:()=>QP,ulid:()=>xP,undefined:()=>tM,union:()=>Fy,unknown:()=>Ug,uppercase:()=>gy,url:()=>EP,util:()=>Zo,uuid:()=>yP,uuidv4:()=>wP,uuidv6:()=>CP,uuidv7:()=>LP,validate:()=>rC,validateAsync:()=>sC,void:()=>rM,withParser:()=>AA,xid:()=>kP,xor:()=>lM});var Sh={};hh(Sh,{$ZodAny:()=>hx,$ZodArray:()=>Lx,$ZodAsyncError:()=>Tm,$ZodBase64:()=>ox,$ZodBase64URL:()=>ix,$ZodBigInt:()=>lA,$ZodBigIntFormat:()=>px,$ZodBoolean:()=>fC,$ZodCIDRv4:()=>rx,$ZodCIDRv6:()=>sx,$ZodCUID:()=>VT,$ZodCUID2:()=>HT,$ZodCatch:()=>zx,$ZodCheck:()=>Rv,$ZodCheckBigIntFormat:()=>yT,$ZodCheckEndsWith:()=>RT,$ZodCheckGreaterThan:()=>HE,$ZodCheckIncludes:()=>xT,$ZodCheckLengthEquals:()=>_T,$ZodCheckLessThan:()=>VE,$ZodCheckLowerCase:()=>IT,$ZodCheckMaxLength:()=>ET,$ZodCheckMaxSize:()=>wT,$ZodCheckMimeType:()=>OT,$ZodCheckMinLength:()=>AT,$ZodCheckMinSize:()=>CT,$ZodCheckMultipleOf:()=>hT,$ZodCheckNumberFormat:()=>gT,$ZodCheckOverwrite:()=>$T,$ZodCheckProperty:()=>NT,$ZodCheckRegex:()=>ST,$ZodCheckSizeEquals:()=>LT,$ZodCheckStartsWith:()=>kT,$ZodCheckStringFormat:()=>dy,$ZodCheckUpperCase:()=>TT,$ZodCodec:()=>pC,$ZodCreditCard:()=>ux,$ZodCustom:()=>Wx,$ZodCustomStringFormat:()=>fx,$ZodCyclicError:()=>mA,$ZodDate:()=>Cx,$ZodDefault:()=>Px,$ZodDiscriminatedUnion:()=>Sx,$ZodE164:()=>ax,$ZodEmail:()=>jT,$ZodEmoji:()=>BT,$ZodEncodeError:()=>Qh,$ZodEnum:()=>Rx,$ZodError:()=>$1,$ZodExactOptional:()=>Dx,$ZodFile:()=>Ox,$ZodFunction:()=>Hx,$ZodGUID:()=>PT,$ZodIBAN:()=>lx,$ZodIPv4:()=>ex,$ZodIPv6:()=>tx,$ZodISODate:()=>JT,$ZodISODateTime:()=>KT,$ZodISODuration:()=>QT,$ZodISOTime:()=>XT,$ZodIntersection:()=>Ix,$ZodJWT:()=>cx,$ZodKSUID:()=>ZT,$ZodLazy:()=>bC,$ZodLiteral:()=>Nx,$ZodMAC:()=>nx,$ZodMap:()=>xx,$ZodNaN:()=>Gx,$ZodNanoID:()=>qT,$ZodNever:()=>yx,$ZodNonOptional:()=>jx,$ZodNull:()=>mx,$ZodNullable:()=>Ux,$ZodNumber:()=>uA,$ZodNumberFormat:()=>dx,$ZodObject:()=>I6,$ZodObjectJIT:()=>Ex,$ZodOptional:()=>fA,$ZodPipe:()=>dA,$ZodPrefault:()=>Mx,$ZodPreprocess:()=>Bx,$ZodPromise:()=>Yx,$ZodProperties:()=>Zx,$ZodReadonly:()=>qx,$ZodRealError:()=>xm,$ZodRecord:()=>Tx,$ZodRegistry:()=>LA,$ZodSet:()=>kx,$ZodString:()=>Ig,$ZodStringFormat:()=>Yb,$ZodSuccess:()=>Fx,$ZodSymbol:()=>bx,$ZodTemplateLiteral:()=>Vx,$ZodTransform:()=>$x,$ZodTuple:()=>cA,$ZodType:()=>Ql,$ZodULID:()=>YT,$ZodURL:()=>GT,$ZodUUID:()=>MT,$ZodUndefined:()=>vx,$ZodUnion:()=>dC,$ZodUnknown:()=>gx,$ZodVoid:()=>wx,$ZodXID:()=>WT,$ZodXor:()=>Ax,$brand:()=>R1,$constructor:()=>eo,$input:()=>Qx,$output:()=>Xx,Doc:()=>Sg,INVALID:()=>Cm,JSONSchema:()=>bP,JSONSchemaGenerator:()=>n_,NEVER:()=>k1,TimePrecision:()=>ck,URL_BAD_FORMAT:()=>FT,URL_UNPARSEABLE:()=>zT,ZodCompileAsyncError:()=>Qm,ZodCompileUnsupportedError:()=>Xd,_any:()=>Ik,_array:()=>Dk,_base64:()=>BA,_base64url:()=>qA,_bigint:()=>wk,_boolean:()=>gk,_catch:()=>iY,_check:()=>XU,_cidrv4:()=>zA,_cidrv6:()=>GA,_coercedBigint:()=>Ck,_coercedBoolean:()=>yk,_coercedDate:()=>Nk,_coercedNumber:()=>dk,_coercedString:()=>ik,_creditCard:()=>uk,_cuid:()=>$A,_cuid2:()=>DA,_custom:()=>Pk,_date:()=>Rk,_decode:()=>DE,_decodeAsync:()=>PE,_default:()=>rY,_discriminatedUnion:()=>VH,_e164:()=>VA,_email:()=>SA,_emoji:()=>NA,_encode:()=>$E,_encodeAsync:()=>UE,_endsWith:()=>Cy,_enum:()=>JH,_file:()=>Uk,_float32:()=>bk,_float64:()=>vk,_gt:()=>ch,_gte:()=>Um,_guid:()=>IA,_iban:()=>lk,_includes:()=>yy,_int:()=>pk,_int32:()=>mk,_int64:()=>Lk,_intersection:()=>HH,_ipv4:()=>jA,_ipv6:()=>FA,_isoDate:()=>LC,_isoDateTime:()=>CC,_isoDuration:()=>AC,_isoTime:()=>EC,_jwt:()=>HA,_ksuid:()=>MA,_lazy:()=>cY,_length:()=>Dg,_literal:()=>QH,_lowercase:()=>hy,_lt:()=>lh,_lte:()=>Dm,_mac:()=>ak,_map:()=>ZH,_max:()=>Dm,_maxLength:()=>$g,_maxSize:()=>tg,_mime:()=>Ly,_min:()=>Um,_minLength:()=>_h,_minSize:()=>fh,_multipleOf:()=>eg,_nan:()=>Ok,_nanoid:()=>OA,_nativeEnum:()=>XH,_negative:()=>WA,_never:()=>xk,_nonnegative:()=>KA,_nonoptional:()=>sY,_nonpositive:()=>ZA,_normalize:()=>Ey,_null:()=>Sk,_nullable:()=>nY,_number:()=>fk,_optional:()=>tY,_overwrite:()=>eh,_parse:()=>uy,_parseAsync:()=>ly,_pipe:()=>aY,_positive:()=>YA,_promise:()=>fY,_properties:()=>$k,_property:()=>JA,_readonly:()=>uY,_record:()=>WH,_refine:()=>Mk,_regex:()=>my,_safeDecode:()=>jE,_safeDecodeAsync:()=>zE,_safeEncode:()=>ME,_safeEncodeAsync:()=>FE,_safeParse:()=>cy,_safeParseAsync:()=>fy,_set:()=>KH,_size:()=>Og,_slugify:()=>Iy,_startsWith:()=>wy,_string:()=>ok,_stringFormat:()=>Ty,_stringbool:()=>Gk,_success:()=>oY,_superRefine:()=>jk,_symbol:()=>Ak,_templateLiteral:()=>lY,_toLowerCase:()=>_y,_toUpperCase:()=>Sy,_transform:()=>eY,_trim:()=>Ay,_tuple:()=>YH,_uint32:()=>hk,_uint64:()=>Ek,_ulid:()=>UA,_undefined:()=>_k,_union:()=>BH,_unknown:()=>Tk,_uppercase:()=>gy,_url:()=>wC,_uuid:()=>TA,_uuidv4:()=>xA,_uuidv6:()=>kA,_uuidv7:()=>RA,_void:()=>kk,_xid:()=>PA,_xor:()=>qH,base64Charset:()=>rA,base64urlCharset:()=>cC,clone:()=>Lb,compile:()=>rk,compileFn:()=>_A,config:()=>zv,createStandardJSONSchemaMethod:()=>xy,createToJSONSchemaMethod:()=>qk,decode:()=>VB,decodeAsync:()=>YB,describe:()=>Fk,encode:()=>qB,encodeAsync:()=>HB,extractDefs:()=>rg,finalize:()=>sg,flattenError:()=>tC,formatError:()=>nC,getDiscriminatedOption:()=>_x,globalConfig:()=>Kv,globalRegistry:()=>lm,handleUnrepresentable:()=>Bv,initializeContext:()=>ng,isBackEdge:()=>gA,isRecursiveSchema:()=>hA,isTransforming:()=>am,isValidBase64:()=>lC,isValidBase64URL:()=>sA,isValidCIDRv6:()=>nA,isValidCreditCard:()=>oA,isValidIBAN:()=>iA,isValidIPv6:()=>uC,isValidJWT:()=>aA,locales:()=>yC,memoizer:()=>hC,mergeValues:()=>py,meta:()=>zk,parse:()=>NE,parseAsync:()=>OE,parseURLObject:()=>XE,prettifyError:()=>U1,process:()=>Eb,processSchema:()=>Eb,regexes:()=>wm,registry:()=>EA,safeDecode:()=>ZB,safeDecodeAsync:()=>JB,safeEncode:()=>WB,safeEncodeAsync:()=>KB,safeParse:()=>jB,safeParseAsync:()=>FB,standardProps:()=>JE,stripTabAndNewline:()=>QE,toDotPath:()=>n6,toJSONSchema:()=>t_,toZod:()=>Yw,treeifyError:()=>D1,urlHostnameOk:()=>eA,urlProtocolOk:()=>tA,util:()=>Zo,validate:()=>rC,validateAsync:()=>sC,version:()=>DT,withParser:()=>AA});var Zo={};hh(Zo,{BIGINT_FORMAT_RANGES:()=>Xw,CONSTANT_CATCH:()=>kE,Class:()=>y1,NUMBER_FORMAT_RANGES:()=>Jw,aborted:()=>gm,allowsEval:()=>L1,assert:()=>iB,assertEqual:()=>nB,assertIs:()=>sB,assertNever:()=>oB,assertNotEqual:()=>rB,assignProp:()=>im,attachSchema:()=>xE,base64ToUint8Array:()=>KD,base64urlToUint8Array:()=>_B,cached:()=>oy,captureStackTrace:()=>IE,cleanEnum:()=>AB,cleanRegex:()=>Eh,clone:()=>Lb,cloneDef:()=>lB,codePointLength:()=>Ag,constantCatch:()=>T1,createTransparentProxy:()=>vB,defineLazy:()=>w1,defineLazyInternal:()=>Wf,derived:()=>xB,esc:()=>hm,escapeRegex:()=>qm,explicitlyAborted:()=>_1,extend:()=>gB,finalizeIssue:()=>Im,floatSafeRemainder:()=>Ww,getElementAtPath:()=>cB,getEnumValues:()=>ry,getLengthableOrigin:()=>eC,getParsedType:()=>bB,getSizableOrigin:()=>Qw,hexToUint8Array:()=>IB,hide:()=>I1,installLazyProp:()=>NB,isObject:()=>Eg,isPlainObject:()=>Bm,issue:()=>ay,joinValues:()=>ro,jsonStringifyReplacer:()=>sy,members:()=>S1,merge:()=>wB,mergeDefs:()=>Xm,normalizeParams:()=>Gi,nullish:()=>SE,numKeys:()=>pB,objectClone:()=>aB,omit:()=>hB,optionalKeys:()=>A1,own:()=>Xh,parsedType:()=>Qo,partial:()=>CB,pick:()=>mB,prefixIssues:()=>ym,primitiveTypes:()=>E1,promiseAllObject:()=>fB,propertyKeyTypes:()=>Kw,randomString:()=>dB,rawShape:()=>iy,required:()=>LB,safeExtend:()=>yB,shallowClone:()=>Zw,slugify:()=>C1,stringifyPrimitive:()=>Jo,toZod:()=>Yw,uint8ArrayToBase64:()=>JD,uint8ArrayToBase64url:()=>SB,uint8ArrayToHex:()=>TB,unwrapMessage:()=>ny});function nB(n){return n}function rB(n){return n}function Yw(){return n=>n}function sB(n){}function oB(n){throw new Error("Unexpected value in exhaustive check")}function iB(n){}function ry(n){let r=Object.values(n).filter(h=>typeof h=="number");return Object.entries(n).filter(([h,l])=>r.indexOf(+h)===-1).map(([h,l])=>l)}function ro(n,r="|"){return n.map(f=>Jo(f)).join(r)}function sy(n,r){return typeof r=="bigint"?r.toString():r}var g1=class{constructor(r){this._getter=r,this._value=void 0}get value(){let r=this._getter;return r!==void 0&&(this._value=r(),this._getter=void 0),this._value}};function oy(n){return new g1(n)}function SE(n){return n==null}function Eh(n){let r=n.startsWith("^")?1:0,f=n.endsWith("$")?n.length-1:n.length;return n.slice(r,f)}function Ww(n,r){let f=n/r,h=Math.round(f),l=4*Number.EPSILON*Math.max(Math.abs(f),1);return Math.abs(f-h)<l?0:f-h}var VD=Symbol("evaluating");function w1(n,r,f){let h;Object.defineProperty(n,r,{get(){if(h!==VD)return h===void 0&&(h=VD,h=f()),h},set(l){Object.defineProperty(n,r,{value:l})},configurable:!0})}function aB(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function im(n,r,f){Object.defineProperty(n,r,{value:f,writable:!0,enumerable:!0,configurable:!0})}function iy(n){let r=Object.getOwnPropertyDescriptor(n,"shape");return r?.get?r.get.raw:r?.value}function Lh(n){return iy(n._zod.def)??n._zod.def.shape}function YD(n,r,f){Object.defineProperty(n,r,{get(){let h=f();return im(this,r,h),h},enumerable:!0,configurable:!0})}function WD(n,r,f){r in n?im(n,r,f):n[r]=f}function Lg(n,r,f,h){let l=Lh(r);for(let t of f){let $=Object.getOwnPropertyDescriptor(l,t);$.enumerable&&($.get?YD(n,t,()=>{let re=r._zod.def.shape[t];return h?h(re,t):re}):WD(n,t,h?h($.value,t):$.value))}}function uB(n,r){for(let f of Reflect.ownKeys(r)){let h=Object.getOwnPropertyDescriptor(r,f);h.enumerable&&(h.get?YD(n,f,()=>r[f]):WD(n,f,h.value))}}function Xm(...n){let r={};for(let f of n){let h=Object.getOwnPropertyDescriptors(f);Object.assign(r,h)}return Object.defineProperties({},r)}function lB(n){return Xm(n._zod.def)}function cB(n,r){return r?r.reduce((f,h)=>f?.[h],n):n}function fB(n){let r=Object.keys(n),f=r.map(h=>n[h]);return Promise.all(f).then(h=>{let l={};for(let t=0;t<r.length;t++)l[r[t]]=h[t];return l})}function dB(n=10){let r="abcdefghijklmnopqrstuvwxyz",f="";for(let h=0;h<n;h++)f+=r[Math.floor(Math.random()*r.length)];return f}function hm(n){return JSON.stringify(n)}function C1(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var IE="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Eg(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var L1=oy(()=>{if(Kv.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function Bm(n){if(Eg(n)===!1)return!1;let r=n.constructor;if(r===void 0||typeof r!="function")return!0;let f=r.prototype;return!(Eg(f)===!1||Object.prototype.hasOwnProperty.call(f,"isPrototypeOf")===!1)}function Zw(n){return Bm(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}function pB(n){let r=0;for(let f in n)Object.prototype.hasOwnProperty.call(n,f)&&r++;return r}var bB=n=>{let r=typeof n;switch(r){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${r}`)}},Kw=new Set(["string","number","symbol"]),E1=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qm(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lb(n,r,f){let h=new n._zod.constr(r??n._zod.def);return(!r||f?.parent)&&(h._zod.parent=n),h}function Gi(n){let r=n;if(!r)return{};if(typeof r=="string")return{error:()=>r};if(r?.message!==void 0){if(r?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");r.error=r.message}return delete r.message,typeof r.error=="string"?{...r,error:()=>r.error}:r}function vB(n){let r;return new Proxy({},{get(f,h,l){return r??(r=n()),Reflect.get(r,h,l)},set(f,h,l,t){return r??(r=n()),Reflect.set(r,h,l,t)},has(f,h){return r??(r=n()),Reflect.has(r,h)},deleteProperty(f,h){return r??(r=n()),Reflect.deleteProperty(r,h)},ownKeys(f){return r??(r=n()),Reflect.ownKeys(r)},getOwnPropertyDescriptor(f,h){return r??(r=n()),Reflect.getOwnPropertyDescriptor(r,h)},defineProperty(f,h,l){return r??(r=n()),Reflect.defineProperty(r,h,l)}})}function Jo(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function A1(n){return Object.keys(n).filter(r=>n[r]._zod.optin!==void 0&&n[r]._zod.optout==="optional")}var Jw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Xw={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mB(n,r){let f=n._zod.def,h=f.checks;if(h&&h.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let t={};return Lg(t,n,TE(n,r)),Lb(n,Xm(f,{shape:t,checks:[]}))}function TE(n,r){let f=Lh(n),h=[];for(let l of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(f,l)?.enumerable)throw new Error(`Unrecognized key: "${String(l)}"`);r[l]&&h.push(l)}return h}function hB(n,r){let f=n._zod.def,h=f.checks;if(h&&h.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let t=new Set(TE(n,r)),$={};return Lg($,n,Reflect.ownKeys(Lh(n)).filter(re=>!t.has(re))),Lb(n,Xm(f,{shape:$,checks:[]}))}function gB(n,r){if(!Bm(r))throw new Error("Invalid input to extend: expected a plain object");let f=n._zod.def.checks;if(f&&f.length>0){let l=Lh(n);for(let t of Reflect.ownKeys(r))if(Object.getOwnPropertyDescriptor(l,t)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Lb(n,Xm(n._zod.def,{shape:ZD(n,r)}))}function ZD(n,r){let f={};return Lg(f,n,Reflect.ownKeys(Lh(n))),uB(f,r),f}function yB(n,r){if(!Bm(r))throw new Error("Invalid input to safeExtend: expected a plain object");return Lb(n,Xm(n._zod.def,{shape:ZD(n,r)}))}function wB(n,r){if(!r?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(n._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let f={};Lg(f,n,Reflect.ownKeys(Lh(n))),Lg(f,r,Reflect.ownKeys(Lh(r)));let h=Xm(n._zod.def,{shape:f,get catchall(){return r._zod.def.catchall},checks:r._zod.def.checks??[]});return Lb(n,h)}function CB(n,r,f,h="partial"){let t=r._zod.def.checks;if(t&&t.length>0)throw new Error(`.${h}() cannot be used on object schemas containing refinements`);let re=f?new Set(TE(r,f)):void 0,e={};return Lg(e,r,Reflect.ownKeys(Lh(r)),n&&((qe,ht)=>re&&!re.has(ht)?qe:new n({type:"optional",innerType:qe}))),Lb(r,Xm(r._zod.def,{shape:e,checks:[]}))}function LB(n,r,f){let h=f?new Set(TE(r,f)):void 0,l={};return Lg(l,r,Reflect.ownKeys(Lh(r)),(t,$)=>h&&!h.has($)?t:new n({type:"nonoptional",innerType:t})),Lb(r,Xm(r._zod.def,{shape:l}))}function gm(n,r=0){if(n.aborted===!0)return!0;for(let f=r;f<n.issues.length;f++)if(n.issues[f]?.continue!==!0)return!0;return!1}function _1(n,r=0){if(n.aborted===!0)return!0;for(let f=r;f<n.issues.length;f++)if(n.issues[f]?.continue===!1)return!0;return!1}function ym(n,r){return r.map(f=>{var h;return(h=f).path??(h.path=[]),f.path.unshift(n),f})}function ny(n){return typeof n=="string"?n:n?.message}function xE(n,r,f){var h;for(let l=r;l<n.length;l++)(h=n[l]).schema??(h.schema=f)}function Im(n,r,f){var h;let l=n.inst?._zod?.traits;l?.has("$ZodType")&&(l.has("$ZodCheck")?(h=n).schema??(h.schema=n.inst):n.schema=n.inst);let t=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,$=n.message?n.message:ny(n.inst?._zod.def?.error?.(n))??ny(t?.(n))??ny(r?.error?.(n))??ny(f.customError?.(n))??ny(f.localeError?.(n))??"Invalid input",re={};for(let e of Object.keys(n))e==="inst"||e==="schema"||e==="continue"||e==="input"||e==="__proto__"||(re[e]=n[e]);return re.path??(re.path=[]),re.message=$,r?.reportInput&&(re.input=n.input),re}function Qw(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}var EB=/[\uD800-\uDBFF]/;function Ag(n){let r=n.length;if(!EB.test(n))return r;let f=r;for(let h=0;h<r-1;h++)(n.charCodeAt(h)&64512)===55296&&(n.charCodeAt(h+1)&64512)===56320&&(f--,h++);return f}function eC(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Qo(n){let r=typeof n;switch(r){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let f=n;if(f&&Object.getPrototypeOf(f)!==Object.prototype&&"constructor"in f&&f.constructor)return f.constructor.name}}return r}function ay(...n){let[r,f,h]=n;return typeof r=="string"?{message:r,code:"custom",input:f,inst:h}:{...r}}function AB(n){return Object.entries(n).filter(([r,f])=>Number.isNaN(Number.parseInt(r,10))).map(r=>r[1])}function KD(n){let r=atob(n),f=new Uint8Array(r.length);for(let h=0;h<r.length;h++)f[h]=r.charCodeAt(h);return f}function JD(n){let r="";for(let f=0;f<n.length;f++)r+=String.fromCharCode(n[f]);return btoa(r)}function _B(n){let r=n.replace(/-/g,"+").replace(/_/g,"/"),f="=".repeat((4-r.length%4)%4);return KD(r+f)}function SB(n){return JD(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function IB(n){let r=n.replace(/^0x/,"");if(r.length%2!==0)throw new Error("Invalid hex string length");let f=new Uint8Array(r.length/2);for(let h=0;h<r.length;h+=2)f[h/2]=Number.parseInt(r.slice(h,h+2),16);return f}function TB(n){return Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("")}var y1=class{constructor(...r){}};function S1(n,r){for(let f in r){let h=Object.getOwnPropertyDescriptor(r,f);h.get?Object.defineProperty(n,f,{...h,enumerable:!1}):HD(n,f,h.value)}for(let f of Object.getOwnPropertySymbols(r))HD(n,f,r[f])}function Xh(n,r,f,h=!0){return Object.defineProperty(n,r,{configurable:!0,writable:!0,enumerable:h,value:f}),f}function I1(n,r,f){return Xh(n,r,f,!1)}function xB(n,r){for(let f in n){let h=n[f];Object.defineProperty(r,f,{configurable:!0,enumerable:!0,get(){return Xh(this,f,h(this))},set(l){Xh(this,f,l)}})}return r}function HD(n,r,f){Object.defineProperty(n,r,{configurable:!0,get(){return this==null?f:Xh(this,r,f.bind(this))},set(h){Xh(this,r,h)}})}function kB(n,r){let f=Object.getPrototypeOf(n);return r in f?void 0:f}var h1,Jh=!1,RB={configurable:!0,get(){Jh=!0}};function Wf(n,r,f){let h=Object.getPrototypeOf(n._zod);if(r in h&&h1!==n._zod){h1=void 0;return}h1=n._zod,Object.defineProperty(h,r,{configurable:!0,get(){Object.defineProperty(this,r,RB);let l=Jh;Jh=!1;try{let t=f(this);return Jh?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),Jh=Jh||l,t}catch(t){throw delete this[r],Jh=Jh||l,t}},set(l){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:l})}})}function NB(n,r,f,h){let l=kB(n,r);l&&Object.defineProperty(l,r,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:h,value:void 0};return Object.defineProperty(this,r,t),t.value=f(this),Object.defineProperty(this,r,t),t.value},set(t){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:h,value:t})}})}var kE="~constantCatch";function T1(n){let r=()=>n;return r[kE]=!0,r}var XD,k1=Object.freeze({status:"aborted"}),x1={value:void 0,enumerable:!1},QD="captureStackTrace"in Error?Error:null;function OB(n){let r=QD;if(r){let f=r.stackTraceLimit;if(typeof f=="number"){try{r.stackTraceLimit=0}catch{return QD=null,new n}try{return new n}finally{r.stackTraceLimit=f}}}return new n}function eo(n,r,f,h){let l={};function t(gt){this.def=gt,this.constr=Ke,this.traits=new Set}t.prototype=l;let $=f,re=$&&new WeakSet;function e(gt,ln){if(!gt._zod){x1.value=new t(ln);try{Object.defineProperty(gt,"_zod",x1)}finally{x1.value=void 0}}if(gt._zod.traits.has(n))return;if(gt._zod.traits.add(n),r(gt,ln),re){let bn=Object.getPrototypeOf(gt),zr=gt._zod.constr.prototype,tr=bn;for(;tr&&tr!==zr;)tr=Object.getPrototypeOf(tr);let Er=tr??bn;re.has(Er)||(re.add(Er),S1(Er,$))}let Qn=Ke.prototype;for(let bn in Qn)Object.prototype.hasOwnProperty.call(Qn,bn)&&(bn in gt||(gt[bn]=Qn[bn].bind(gt)))}let qe=h?.Parent??Object;class ht extends qe{}Object.defineProperty(ht,"name",{value:n});function Ke(gt){let ln=h?.Parent?OB(ht):this;e(ln,gt);let Qn=ln._zod.deferred;if(Qn){for(let zr of Qn)zr();ln._zod.deferred=void 0}let bn=globalThis.__zod_globalConfig?.postProcessor;return bn&&bn(ln),ln}return Object.defineProperty(Ke,"init",{value:e}),Object.defineProperty(Ke,Symbol.hasInstance,{value:gt=>h?.Parent&> instanceof h.Parent?!0:gt?._zod?.traits?.has(n)}),Object.defineProperty(Ke,"name",{value:n}),Ke}var R1=Symbol("zod_brand"),Tm=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qh=class extends Error{constructor(r){super(`Encountered unidirectional transform during encode: ${r}`),this.name="ZodEncodeError"}};(XD=globalThis).__zod_globalConfig??(XD.__zod_globalConfig={});var Kv=globalThis.__zod_globalConfig;function zv(n){return n&&Object.assign(Kv,n),Kv}function $B(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,sy,2)),n.message}function DB(n){this._zod.message=n}var UB={get:$B,set:DB,enumerable:!0,configurable:!0},O1={value:void 0,enumerable:!1},e6=new WeakSet([Object.prototype,Error.prototype]),t6=(n,r)=>{n.name="$ZodError",O1.value=r,Object.defineProperty(n,"issues",O1),O1.value=void 0,Object.defineProperty(n,"message",UB);let f=Object.getPrototypeOf(n);e6.has(f)||(e6.add(f),Object.defineProperty(f,"toString",{configurable:!0,enumerable:!1,get(){let h=()=>this.message;return Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0}),h},set(h){Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0})}}))},$1=eo("$ZodError",t6),xm=eo("$ZodError",t6,void 0,{Parent:Error});function PB(n,r,f){return Object.prototype.hasOwnProperty.call(n,r)||(r==="__proto__"?Object.defineProperty(n,r,{value:f(),writable:!0,enumerable:!0,configurable:!0}):n[r]=f()),n[r]}function tC(n,r=f=>f.message){let f={},h=[];for(let l of n.issues)l.path.length>0?PB(f,l.path[0],()=>[]).push(r(l)):h.push(r(l));return{formErrors:h,fieldErrors:f}}function nC(n,r=f=>f.message){let f={_errors:[]},h=(l,t=[])=>{for(let $ of l.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map(re=>h({issues:re},[...t,...$.path]));else if($.code==="invalid_key")h({issues:$.issues},[...t,...$.path]);else if($.code==="invalid_element")h({issues:$.issues},[...t,...$.path]);else{let re=[...t,...$.path];if(re.length===0)f._errors.push(r($));else{let e=f,qe=0;for(;qe<re.length;){let ht=re[qe],Ke=qe===re.length-1;if(ht==="_errors"){Ke&&e._errors.push(r($)),qe++;continue}Object.prototype.hasOwnProperty.call(e,ht)||Object.defineProperty(e,ht,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let gt=e[ht];Ke&>._errors.push(r($)),e=gt,qe++}}}};return h(n),f}function D1(n,r=f=>f.message){let f={errors:[]},h=(l,t=[])=>{var $;for(let re of l.issues)if(re.code==="invalid_union"&&re.errors.length)re.errors.map(e=>h({issues:e},[...t,...re.path]));else if(re.code==="invalid_key")h({issues:re.issues},[...t,...re.path]);else if(re.code==="invalid_element")h({issues:re.issues},[...t,...re.path]);else{let e=[...t,...re.path];if(e.length===0){f.errors.push(r(re));continue}let qe=f,ht=0;for(;ht<e.length;){let Ke=e[ht],gt=ht===e.length-1;typeof Ke=="string"?(qe.properties??(qe.properties={}),Object.prototype.hasOwnProperty.call(qe.properties,Ke)||Object.defineProperty(qe.properties,Ke,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),qe=qe.properties[Ke]):(qe.items??(qe.items=[]),($=qe.items)[Ke]??($[Ke]={errors:[]}),qe=qe.items[Ke]),gt&&qe.errors.push(r(re)),ht++}}};return h(n),f}function n6(n){let r=[],f=n.map(h=>typeof h=="object"?h.key:h);for(let h of f)typeof h=="number"?r.push(`[${h}]`):typeof h=="symbol"?r.push(`[${JSON.stringify(String(h))}]`):/[^\w$]/.test(h)?r.push(`[${JSON.stringify(h)}]`):(r.length&&r.push("."),r.push(h));return r.join("")}function U1(n){let r=[],f=[...n.issues].sort((h,l)=>(h.path??[]).length-(l.path??[]).length);for(let h of f)r.push(`\u2716 ${h.message}`),h.path?.length&&r.push(` \u2192 at ${n6(h.path)}`);return r.join(`
|
|
216
216
|
`)}function RE(n,r){return{callee:r?.callee??n,Err:r?.Err}}var uy=n=>{let r=(f,h,l,t)=>{let $=l?{...l,async:!1}:{async:!1},re=f._zod.run({value:h,issues:[]},$);if(re instanceof Promise)throw new Tm;if(re.issues.length){let e=new(t?.Err??n)(re.issues.map(qe=>Im(qe,$,zv())));throw IE(e,t?.callee??r),e}return re.value};return r},NE=uy(xm),ly=n=>{let r=async(f,h,l,t)=>{let $=l?{...l,async:!0}:{async:!0},re=f._zod.run({value:h,issues:[]},$);if(re instanceof Promise&&(re=await re),re.issues.length){let e=new(t?.Err??n)(re.issues.map(qe=>Im(qe,$,zv())));throw IE(e,t?.callee??r),e}return re.value};return r},OE=ly(xm),cy=n=>(r,f,h)=>{let l=h?{...h,async:!1}:{async:!1},t=r._zod.run({value:f,issues:[]},l);if(t instanceof Promise)throw new Tm;return t.issues.length?r6(n,t.issues,l):{success:!0,data:t.value}},jB=cy(xm);function r6(n,r,f){let h;return{success:!1,get error(){return h||(h=new n(r.map(l=>Im(l,f,zv()))),r=void 0,f=void 0),h},set error(l){h=l,r=void 0,f=void 0}}}var fy=n=>async(r,f,h)=>{let l=h?{...h,async:!0}:{async:!0},t=r._zod.run({value:f,issues:[]},l);return t instanceof Promise&&(t=await t),t.issues.length?r6(n,t.issues,l):{success:!0,data:t.value}},FB=fy(xm),zB=Symbol.for("zod.compile.invalid"),GB=Symbol.for("zod.compile.fallback"),rC=((n,r,f)=>{let h=n._zod.bag.validator;if(h!==void 0){if(h(r)!==zB)return!0;if(h.definite===!0&&f===void 0)return!1}return BB(n,r,f)});function BB(n,r,f){let h=f?{...f,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},l=n._zod.bag.fallbackRun,t;if(l?(h[GB]=!0,t=l({value:r,issues:[]},h)):t=n._zod.run({value:r,issues:[]},h),t instanceof Promise)throw new Tm;return t.issues.length===0}var sC=async(n,r,f)=>{let h=f?{...f,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},l=n._zod.run({value:r,issues:[]},h);return l instanceof Promise&&(l=await l),l.issues.length===0},$E=n=>{let r=uy(n),f=(h,l,t,$)=>{let re=t?{...t,direction:"backward"}:{direction:"backward"};return r(h,l,re,RE(f,$))};return f},qB=$E(xm),DE=n=>{let r=uy(n),f=(h,l,t,$)=>r(h,l,t,RE(f,$));return f},VB=DE(xm),UE=n=>{let r=ly(n),f=async(h,l,t,$)=>{let re=t?{...t,direction:"backward"}:{direction:"backward"};return await r(h,l,re,RE(f,$))};return f},HB=UE(xm),PE=n=>{let r=ly(n),f=async(h,l,t,$)=>await r(h,l,t,RE(f,$));return f},YB=PE(xm),ME=n=>(r,f,h)=>{let l=h?{...h,direction:"backward"}:{direction:"backward"};return cy(n)(r,f,l)},WB=ME(xm),jE=n=>(r,f,h)=>cy(n)(r,f,h),ZB=jE(xm),FE=n=>async(r,f,h)=>{let l=h?{...h,direction:"backward"}:{direction:"backward"};return fy(n)(r,f,l)},KB=FE(xm),zE=n=>async(r,f,h)=>fy(n)(r,f,h),JB=zE(xm);var wm={};hh(wm,{anyString:()=>aT,base64:()=>eT,base64url:()=>tT,bigint:()=>lT,boolean:()=>cT,browserEmail:()=>oq,cidrv4:()=>X1,cidrv6:()=>Q1,creditCard:()=>GE,cuid:()=>M1,cuid2:()=>j1,date:()=>sT,datetime:()=>iT,domain:()=>uq,duration:()=>V1,e164:()=>rT,email:()=>Y1,emoji:()=>W1,extendedDuration:()=>XB,guid:()=>H1,hex:()=>cq,hostname:()=>aq,html5Email:()=>nq,httpProtocol:()=>nT,iban:()=>BE,idnEmail:()=>sq,integer:()=>oC,ipv4:()=>Z1,ipv6:()=>K1,ksuid:()=>G1,lowercase:()=>pT,mac:()=>J1,md5_base64:()=>dq,md5_base64url:()=>pq,md5_hex:()=>fq,nanoid:()=>B1,nanoidOfLength:()=>q1,null:()=>fT,number:()=>Ah,rfc5322Email:()=>rq,sha1_base64:()=>vq,sha1_base64url:()=>mq,sha1_hex:()=>bq,sha256_base64:()=>gq,sha256_base64url:()=>yq,sha256_hex:()=>hq,sha384_base64:()=>Cq,sha384_base64url:()=>Lq,sha384_hex:()=>wq,sha512_base64:()=>Aq,sha512_base64url:()=>_q,sha512_hex:()=>Eq,string:()=>uT,time:()=>oT,ulid:()=>F1,undefined:()=>dT,unicodeEmail:()=>s6,uppercase:()=>bT,uuid:()=>_g,uuid4:()=>QB,uuid6:()=>eq,uuid7:()=>tq,xid:()=>z1});var M1=/^[cC][0-9a-z]{6,}$/,j1=/^[0-9a-z]+$/,F1=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,z1=/^[0-9a-vA-V]{20}$/,G1=/^[A-Za-z0-9]{27}$/,B1=/^[a-zA-Z0-9_-]{21}$/;function q1(n){return new RegExp(`^[a-zA-Z0-9_-]{${n}}$`)}var V1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,XB=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,H1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_g=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,QB=_g(4),eq=_g(6),tq=_g(7),Y1=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nq=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,rq=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,s6=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,sq=s6,oq=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,iq="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function W1(){return new RegExp(iq,"u")}var Z1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,K1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,J1=n=>{let r=qm(n??":");return new RegExp(`^(?:[0-9A-F]{2}${r}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${r}){5}[0-9a-f]{2}$`)},X1=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Q1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eT=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tT=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,aq=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,uq=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,nT=/^https?$/,rT=/^\+[1-9]\d{6,14}$/,GE=/^\d(?:[ -]?\d){11,18}$/,BE=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,o6="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function lq(n){return new RegExp(`^${n}$`)}var sT=lq(o6);function P1(n){let r="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${r}`:n.precision===0?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${n.precision}}`:n.seconds?`${r}:[0-5]\\d(?:\\.\\d+)?`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}function oT(n){return new RegExp(`^${P1(n)}$`)}function iT(n){let r=["Z"];n.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let f=`${P1({precision:n.precision,seconds:!0})}(?:${r.join("|")})`,h=n.local?`${f}|${P1({precision:n.precision})}`:f;return new RegExp(`^${o6}T(?:${h})$`)}var aT=/^[\s\S]{0,}$/,uT=n=>{let r=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${r}$`)},lT=/^-?\d+n?$/,oC=/^-?\d+$/,Ah=/^-?\d+(?:\.\d+)?$/,cT=/^(?:true|false)$/i,fT=/^null$/i;var dT=/^undefined$/i;var pT=/^[^A-Z]*$/,bT=/^[^a-z]*$/,cq=/^[0-9a-fA-F]*$/;function iC(n,r){return new RegExp(`^[A-Za-z0-9+/]{${n}}${r}$`)}function aC(n){return new RegExp(`^[A-Za-z0-9_-]{${n}}$`)}var fq=/^[0-9a-fA-F]{32}$/,dq=iC(22,"=="),pq=aC(22),bq=/^[0-9a-fA-F]{40}$/,vq=iC(27,"="),mq=aC(27),hq=/^[0-9a-fA-F]{64}$/,gq=iC(43,"="),yq=aC(43),wq=/^[0-9a-fA-F]{96}$/,Cq=iC(64,""),Lq=aC(64),Eq=/^[0-9a-fA-F]{128}$/,Aq=iC(86,"=="),_q=aC(86);var Rv=eo("$ZodCheck",(n,r)=>{var f;n._zod??(n._zod={}),n._zod.def=r,(f=n._zod).onattach??(f.onattach=[])}),vT=n=>{let r=n.value;return!SE(r)&&r.size!==void 0},mT=n=>{let r=n.value;return!SE(r)&&r.length!==void 0},qE={number:"number",bigint:"bigint",object:"date"},VE=eo("$ZodCheckLessThan",(n,r)=>{Rv.init(n,r);let f=qE[typeof r.value];n._zod.check=h=>{(r.inclusive?h.value<=r.value:h.value<r.value)||h.issues.push({origin:qE[typeof h.value]??f,code:"too_big",maximum:typeof r.value=="object"?r.value.getTime():r.value,input:h.value,inclusive:r.inclusive,inst:n,continue:!r.abort})}}),HE=eo("$ZodCheckGreaterThan",(n,r)=>{Rv.init(n,r);let f=qE[typeof r.value];n._zod.check=h=>{(r.inclusive?h.value>=r.value:h.value>r.value)||h.issues.push({origin:qE[typeof h.value]??f,code:"too_small",minimum:typeof r.value=="object"?r.value.getTime():r.value,input:h.value,inclusive:r.inclusive,inst:n,continue:!r.abort})}}),hT=eo("$ZodCheckMultipleOf",(n,r)=>{Rv.init(n,r),n._zod.check=f=>{if(typeof f.value!=typeof r.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof f.value=="bigint"?r.value!==BigInt(0)&&f.value%r.value===BigInt(0):Ww(f.value,r.value)===0)||f.issues.push({origin:typeof f.value,code:"not_multiple_of",divisor:r.value,input:f.value,inst:n,continue:!r.abort})}}),gT=eo("$ZodCheckNumberFormat",(n,r)=>{Rv.init(n,r),r.format=r.format||"float64";let f=r.format?.includes("int"),h=f?"int":"number",[l,t]=Jw[r.format];n._zod.check=$=>{let re=$.value;if(f){if(!Number.isInteger(re)){$.issues.push({expected:h,format:r.format,code:"invalid_type",continue:!1,input:re,inst:n});return}if(!Number.isSafeInteger(re)){re>0?$.issues.push({input:re,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:h,inclusive:!0,continue:!r.abort}):$.issues.push({input:re,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:h,inclusive:!0,continue:!r.abort});return}}re<l&&$.issues.push({origin:"number",input:re,code:"too_small",minimum:l,inclusive:!0,inst:n,continue:!r.abort}),re>t&&$.issues.push({origin:"number",input:re,code:"too_big",maximum:t,inclusive:!0,inst:n,continue:!r.abort})}}),yT=eo("$ZodCheckBigIntFormat",(n,r)=>{Rv.init(n,r);let[f,h]=Xw[r.format];n._zod.check=l=>{let t=l.value;t<f&&l.issues.push({origin:"bigint",input:t,code:"too_small",minimum:f,inclusive:!0,inst:n,continue:!r.abort}),t>h&&l.issues.push({origin:"bigint",input:t,code:"too_big",maximum:h,inclusive:!0,inst:n,continue:!r.abort})}}),wT=eo("$ZodCheckMaxSize",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=vT),n._zod.check=h=>{let l=h.value;l.size<=r.maximum||h.issues.push({origin:Qw(l),code:"too_big",maximum:r.maximum,inclusive:!0,input:l,inst:n,continue:!r.abort})}}),CT=eo("$ZodCheckMinSize",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=vT),n._zod.check=h=>{let l=h.value;l.size>=r.minimum||h.issues.push({origin:Qw(l),code:"too_small",minimum:r.minimum,inclusive:!0,input:l,inst:n,continue:!r.abort})}}),LT=eo("$ZodCheckSizeEquals",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=vT),n._zod.check=h=>{let l=h.value,t=l.size;if(t===r.size)return;let $=t>r.size;h.issues.push({origin:Qw(l),...$?{code:"too_big",maximum:r.size}:{code:"too_small",minimum:r.size},inclusive:!0,exact:!0,input:h.value,inst:n,continue:!r.abort})}}),ET=eo("$ZodCheckMaxLength",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=mT),n._zod.check=h=>{let l=h.value,t=l.length;if((typeof l=="string"&&t>r.maximum?Ag(l):t)<=r.maximum)return;let re=eC(l);h.issues.push({origin:re,code:"too_big",maximum:r.maximum,inclusive:!0,input:l,inst:n,continue:!r.abort})}}),AT=eo("$ZodCheckMinLength",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=mT),n._zod.check=h=>{let l=h.value,t=l.length;if((typeof l=="string"&&t>=r.minimum&&t<r.minimum*2?Ag(l):t)>=r.minimum)return;let re=eC(l);h.issues.push({origin:re,code:"too_small",minimum:r.minimum,inclusive:!0,input:l,inst:n,continue:!r.abort})}}),_T=eo("$ZodCheckLengthEquals",(n,r)=>{var f;Rv.init(n,r),(f=n._zod.def).when??(f.when=mT),n._zod.check=h=>{let l=h.value,t=l.length,$=typeof l=="string"&&t>=r.length&&t<=r.length*2?Ag(l):t;if($===r.length)return;let re=eC(l),e=$>r.length;h.issues.push({origin:re,...e?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:h.value,inst:n,continue:!r.abort})}}),dy=eo("$ZodCheckStringFormat",(n,r)=>{var f,h;Rv.init(n,r),r.pattern?(f=n._zod).check??(f.check=l=>{r.pattern.lastIndex=0,!r.pattern.test(l.value)&&l.issues.push({origin:"string",code:"invalid_format",format:r.format,input:l.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:n,continue:!r.abort})}):(h=n._zod).check??(h.check=()=>{})}),ST=eo("$ZodCheckRegex",(n,r)=>{dy.init(n,r),n._zod.check=f=>{r.pattern.lastIndex=0,!r.pattern.test(f.value)&&f.issues.push({origin:"string",code:"invalid_format",format:"regex",input:f.value,pattern:r.pattern.toString(),inst:n,continue:!r.abort})}}),IT=eo("$ZodCheckLowerCase",(n,r)=>{r.pattern??(r.pattern=pT),dy.init(n,r)}),TT=eo("$ZodCheckUpperCase",(n,r)=>{r.pattern??(r.pattern=bT),dy.init(n,r)}),xT=eo("$ZodCheckIncludes",(n,r)=>{Rv.init(n,r);let f=qm(r.includes),h=new RegExp(typeof r.position=="number"?`^.{${r.position},}${f}`:f);r.pattern=h,n._zod.check=l=>{l.value.includes(r.includes,r.position)||l.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:l.value,inst:n,continue:!r.abort})}}),kT=eo("$ZodCheckStartsWith",(n,r)=>{Rv.init(n,r);let f=new RegExp(`^${qm(r.prefix)}.*`);r.pattern??(r.pattern=f),n._zod.check=h=>{h.value.startsWith(r.prefix)||h.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:h.value,inst:n,continue:!r.abort})}}),RT=eo("$ZodCheckEndsWith",(n,r)=>{Rv.init(n,r);let f=new RegExp(`.*${qm(r.suffix)}$`);r.pattern??(r.pattern=f),n._zod.check=h=>{h.value.endsWith(r.suffix)||h.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:h.value,inst:n,continue:!r.abort})}});function i6(n,r,f){n.issues.length&&r.issues.push(...ym(f,n.issues))}var NT=eo("$ZodCheckProperty",(n,r)=>{Rv.init(n,r),n._zod.check=f=>{let h=r.schema._zod.run({value:f.value[r.property],issues:[]},{});if(h instanceof Promise)return h.then(l=>i6(l,f,r.property));i6(h,f,r.property)}}),OT=eo("$ZodCheckMimeType",(n,r)=>{Rv.init(n,r);let f=new Set(r.mime);n._zod.check=h=>{f.has(h.value.type)||h.issues.push({code:"invalid_value",values:r.mime,input:h.value.type,inst:n,continue:!r.abort})}}),$T=eo("$ZodCheckOverwrite",(n,r)=>{Rv.init(n,r),n._zod.check=f=>{f.value=r.tx(f.value)}});var Sg=class{constructor(r=[],f={}){this.content=[],this.indent=0,this.args=r,this.closed=f}indented(r){this.indent+=1;try{r(this)}finally{this.indent-=1}}write(r){if(typeof r=="function"){r(this,{execution:"sync"}),r(this,{execution:"async"});return}let h=r.split(`
|
|
217
217
|
`).filter($=>$),l=Math.min(...h.map($=>$.length-$.trimStart().length)),t=h.map($=>$.slice(l)).map($=>" ".repeat(this.indent*2)+$);for(let $ of t)this.content.push($)}compile(){let r=Function,f=this?.content??[""];return new r(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
218
218
|
${f.join(`
|
|
@@ -284,15 +284,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
284
284
|
`);function HN(n,r){return typeof n=="string"?n:oj(rj(r,n.file))}async function sj(n,r,f,h){let l=await n.provider.build(r,f),t=JSON.stringify(nj(n),null,2),$=n.rules??[],re=["# Review packet","","## Role",bW,"",`## Check: ${n.id}`,n.description,"",`## Target: ${r.id}`,"","## Instructions",n.prompt.trim(),"",...$.length>0?["## Rules","Report every finding under exactly one of these codes. The severity is fixed by the rule; do not give one.",...$.map(Ke=>`- ${Ke.code} (${Ke.severity}): ${Ke.description}`),""]:[],"## Context",l.body.trimEnd(),"","## Output","Answer with one JSON object that matches this JSON Schema:","```json",t,"```",""].join(`
|
|
285
285
|
`),e={};for(let Ke of[...l.files??[]].sort())e[Ke.replace(/\\/g,"/")]=Th(oj(rj(h,Ke)));let qe={};for(let Ke of[...new Set(l.inputs)].sort())qe[Ke]=Th(BC(f.specs.get(Ke)??null));let ht={prompt:Th(n.prompt),...n.verifyPrompt!==void 0?{verifyPrompt:Th(n.verifyPrompt)}:{},...$.length>0?{rules:Th(BC($))}:{},schema:Th(t),specs:qe,files:e};return{checkId:n.id,targetId:r.id,text:re,contextBody:l.body,hash:Th(BC({check:n.id,packet:re,verifyPrompt:n.verifyPrompt??null,files:e})),inputs:Object.keys(qe),inputHashes:ht,paths:l.paths??{}}}function Th(n){return`sha256:${dW("sha256").update(n).digest("hex")}`}function BC(n){return JSON.stringify(VN(n))}function VN(n){return Array.isArray(n)?n.map(VN):n instanceof Date?n.toISOString():typeof n=="object"&&n!==null?Object.fromEntries(Object.keys(n).sort().filter(r=>n[r]!==void 0).map(r=>[r,VN(n[r])])):n}function oj(n){return pW(n,"utf-8").replace(/\r\n/g,`
|
|
286
286
|
`)}import{existsSync as uj,mkdirSync as vW,readdirSync as ij,readFileSync as mW,writeFileSync as hW}from"node:fs";import{dirname as gW,join as YN}from"node:path";var M_=nh(ih(),1);var Hm=ks.string().regex(/^sha256:[0-9a-f]{64}$/),yW=ks.object({adapter:ks.string(),model:ks.string().optional(),verifyModel:ks.string().optional()}).strict(),wW=GC.extend({fingerprint:Hm,extra:ks.record(ks.string(),ks.unknown()).optional(),status:ks.enum(["open","false_positive","dismissed"]),statusNote:ks.string().optional(),verifier:ks.object({verdict:ks.enum(["confirmed","false_positive"]),rationale:ks.string()}).strict().optional()}).strict().superRefine((n,r)=>{n.status==="dismissed"&&!n.statusNote?.trim()&&r.addIssue({code:"custom",path:["statusNote"],message:"a dismissed finding needs a statusNote"})}),CW=ks.object({prompt:Hm,verifyPrompt:Hm.optional(),rules:Hm.optional(),schema:Hm,specs:ks.record(ks.string(),Hm),files:ks.record(ks.string(),Hm)}).strict(),LW=ks.object({from:Hm,to:Hm,changedInputs:ks.array(ks.object({input:ks.string(),from:Hm.nullable(),to:Hm.nullable()}).strict()),reason:ks.string().min(1),at:ks.string(),gitHead:ks.string().nullable(),gitDirty:ks.boolean().nullable()}).strict(),lj=ks.object({check:ks.string(),target:ks.string(),packetHash:Hm,inputs:ks.array(ks.string()),inputHashes:CW,judge:yW,judgedAt:ks.string(),usage:ks.object({inputTokens:ks.number(),outputTokens:ks.number(),cacheReadTokens:ks.number().optional(),cacheCreationTokens:ks.number().optional()}).strict().optional(),extra:ks.record(ks.string(),ks.unknown()).optional(),findings:ks.array(wW),rebaselined:ks.array(LW).optional()}).strict();function cj(n,r,f){return YN(n,r,`${f}.yaml`)}function fj(n){if(!uj(n))return;let r=lj.safeParse((0,M_.parse)(mW(n,"utf-8")));if(!r.success)throw new Error(`Invalid review record ${n}: ${ks.prettifyError(r.error)}`);return r.data}function j_(n,r){if(!uj(n))return[];let f=[];for(let h of ij(n,{withFileTypes:!0}))if(h.isDirectory())for(let l of ij(YN(n,h.name),{withFileTypes:!0}))!l.isFile()||!l.name.endsWith(r)||f.push({check:h.name,target:l.name.slice(0,-r.length),path:YN(n,h.name,l.name)});return f.sort((h,l)=>qv(h.path,l.path))}function qC(n,r){let f=lj.parse(r),h={check:f.check,target:f.target,packetHash:f.packetHash,inputs:[...f.inputs].sort(qv),inputHashes:{prompt:f.inputHashes.prompt,...f.inputHashes.verifyPrompt?{verifyPrompt:f.inputHashes.verifyPrompt}:{},...f.inputHashes.rules?{rules:f.inputHashes.rules}:{},schema:f.inputHashes.schema,specs:P_(f.inputHashes.specs),files:P_(f.inputHashes.files)},judge:{adapter:f.judge.adapter,...f.judge.model!==void 0?{model:f.judge.model}:{},...f.judge.verifyModel!==void 0?{verifyModel:f.judge.verifyModel}:{}},judgedAt:f.judgedAt,...f.usage?{usage:{inputTokens:f.usage.inputTokens,outputTokens:f.usage.outputTokens,...f.usage.cacheReadTokens!==void 0?{cacheReadTokens:f.usage.cacheReadTokens}:{},...f.usage.cacheCreationTokens!==void 0?{cacheCreationTokens:f.usage.cacheCreationTokens}:{}}}:{},...f.extra&&Object.keys(f.extra).length>0?{extra:P_(f.extra)}:{},findings:[...f.findings].sort(EW).map(AW),...f.rebaselined&&f.rebaselined.length>0?{rebaselined:f.rebaselined}:{}};vW(gW(n),{recursive:!0}),hW(n,(0,M_.stringify)(h,{lineWidth:0}),"utf-8")}function dj(n,r,f){return Th(BC({check:n,target:r,code:f.code,subject:f.subject??D_(f.location?.quote??""),evidence:[...f.evidence??[]].sort(qv)}))}function pj(n,r){let f=t=>{let $=new Map;for(let re of t)$.set(re.fingerprint,($.get(re.fingerprint)??0)+1);return $},h=f(n),l=f(r);return r.map(t=>{if(h.get(t.fingerprint)!==1||l.get(t.fingerprint)!==1)return t;let $=n.find(qe=>qe.fingerprint===t.fingerprint),re=$.status==="false_positive"&&$.verifier?.verdict==="false_positive";if($.status==="open"||re)return t;let e={...t,status:$.status};return $.statusNote!==void 0?e.statusNote=$.statusNote:delete e.statusNote,e})}var aj={error:0,warning:1,info:2};function EW(n,r){return aj[n.severity]-aj[r.severity]||qv(n.code,r.code)||qv(n.subject??"",r.subject??"")||qv(n.fingerprint,r.fingerprint)||qv(n.message,r.message)}function AW(n){return{fingerprint:n.fingerprint,code:n.code,severity:n.severity,message:n.message,...n.subject!==void 0?{subject:n.subject}:{},...n.location!==void 0?{location:n.location}:{},...n.evidence!==void 0?{evidence:[...n.evidence].sort(qv)}:{},...n.suggestion!==void 0?{suggestion:n.suggestion}:{},...n.extra!==void 0&&Object.keys(n.extra).length>0?{extra:P_(n.extra)}:{},status:n.status,...n.statusNote!==void 0?{statusNote:n.statusNote}:{},...n.verifier!==void 0?{verifier:n.verifier}:{}}}function P_(n){return Object.fromEntries(Object.keys(n).sort(qv).map(r=>[r,n[r]]))}var Vv=class extends Error{exitCode=1},F_=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function z_(n,r,f){let h=[...(n?.checks??[]).map(e=>({check:e})),...r.flatMap(e=>e.getReviewChecks().map(qe=>({check:qe,modelId:e.id})))];if(!n&&h.length===0)return null;if(n?.timeoutSeconds!==void 0&&!(Number.isFinite(n.timeoutSeconds)&&n.timeoutSeconds>0))throw new Vv(`review.timeoutSeconds must be a positive number of seconds, got ${String(n.timeoutSeconds)}`);if(n?.claudeExecutable!==void 0&&n.claudeExecutable.trim()==="")throw new Vv("review.claudeExecutable must be a path to a Claude Code executable");let l=new Map([["relations",ej()]]),t=new Set;for(let e of n?.contextProviders??[]){if(t.has(e.id))throw new Vv(`review.contextProviders declares "${e.id}" twice`);t.add(e.id),l.set(e.id,e)}let $=new Set,re=h.map(({check:e,modelId:qe})=>{let ht=qe?`review check "${e.id}" of model ${qe}`:`review check "${e.id}"`;if(!F_.test(e.id))throw new Vv(`${ht}: the ID must match ${F_}`);if($.has(e.id))throw new Vv(`${ht} is declared more than once`);if($.add(e.id),!qe&&!e.select)throw new Vv(`${ht} is declared in the config and needs select()`);let Ke;if(e.context===void 0)Ke=l.get("relations");else if(typeof e.context=="string"){let gt=l.get(e.context);if(!gt)throw new Vv(`${ht}: no context provider "${e.context}"`);Ke=gt}else Ke=e.context;return{check:e,modelId:qe,id:e.id,description:e.description,prompt:HN(e.prompt,f),...e.verify?{verifyPrompt:HN(e.verify.prompt,f)}:{},...e.rules?{rules:IW(e.rules,ht)}:{},output:e.output,provider:Ke,modelClass:e.modelClass??"standard",...e.verify?{verifyModelClass:e.verify.modelClass??e.modelClass??"standard"}:{}}});return{config:n??{},rootDir:f,dir:_W(f,n?.dir??"review"),gate:{stale:n?.gate?.stale??"error",openFindings:n?.gate?.openFindings??"error",blocking:n?.gate?.blocking??["error"],judgeChange:n?.gate?.judgeChange??"ignore"},checks:re}}var SW=ks.object({code:ks.string().min(1),severity:ks.enum(["error","warning","info"]),description:ks.string().min(1)}).strict();function IW(n,r){let f=ks.array(SW).min(1).safeParse(n);if(!f.success)throw new Vv(`${r}: invalid rules: ${ks.prettifyError(f.error)}`);let h=new Set;for(let l of f.data){if(h.has(l.code))throw new Vv(`${r}: rule code "${l.code}" is declared twice`);h.add(l.code)}return f.data}function TW(n,r){let f=n.check.select?n.check.select(r):[...r.models[n.modelId]?.keys()??[]].map(l=>({id:l,specIds:[l]})),h=new Set;for(let l of f){let t=`review check "${n.id}", target "${l.id}"`;if(!F_.test(l.id))throw new Vv(`${t}: the ID must match ${F_}`);if(h.has(l.id))throw new Vv(`${t} is selected more than once`);h.add(l.id);for(let $ of l.specIds)if(!r.specs.has($))throw new Vv(`${t}: no spec has the ID "${$}"`)}return f}function WN(n,r,f,h){if(!n)return{state:"missing",judgeChanged:!1};let l=h!=="ignore"&&f!==void 0&&!xW(n.judge,f);return n.packetHash!==r?{state:"stale",judgeChanged:l}:{state:l&&h==="stale"?"stale":"fresh",judgeChanged:l}}function xW(n,r){return n.adapter===r.adapter&&n.model===r.model&&n.verifyModel===r.verifyModel}async function Hy(n,r,f){let h=[];for(let $ of n.checks){let re=n.gate.judgeChange!=="ignore"&&f?f($):void 0;for(let e of TW($,r)){let qe=await sj($,e,r,n.rootDir),ht=cj(n.dir,$.id,e.id),Ke=fj(ht);h.push({check:$,target:e,packet:qe,recordFile:ht,record:Ke,currentJudge:re,...WN(Ke,qe.hash,re,n.gate.judgeChange)})}}let l=new Set(h.map($=>`${$.check.id}/${$.target.id}`)),t=j_(n.dir,".yaml").filter($=>!l.has(`${$.check}/${$.target}`));return{targets:h,orphans:t}}function G_(n,r){let f=bj(n.inputHashes),h=bj(r.inputHashes);return[...new Set([...Object.keys(f),...Object.keys(h)])].sort().filter(t=>f[t]!==h[t]).map(t=>({input:t,from:f[t]??null,to:h[t]??null}))}function bj(n){let r={prompt:n.prompt,schema:n.schema};n.verifyPrompt&&(r.verifyPrompt=n.verifyPrompt),n.rules&&(r.rules=n.rules);for(let[f,h]of Object.entries(n.specs))r[`spec:${f}`]=h;for(let[f,h]of Object.entries(n.files))r[`file:${f}`]=h;return r}function B_(n,r,f=!1){if(n.packetHash===r.hash)return["the judge changed"];let h=G_(n,r);return h.length===0?["the packet changed (its layout, not an input)"]:h.map(l=>{let t=l.from===null?"added":l.to===null?"removed":"changed",$=f&&l.input.startsWith("spec:")?r.paths[l.input.slice(5)]:void 0;return`${l.input} ${t}${$&&$.length>0?` (${kW($)})`:""}`})}function kW(n){return n.map(r=>`${r.from} -${r.type}-> ${r.to}`).join(", ")}function vj(n){let r={missing:0,stale:1,fresh:2};return[...n].sort((f,h)=>r[f.state]-r[h.state]||qv(f.target.id,h.target.id)||qv(f.check.id,h.check.id))}import{execFileSync as RW}from"node:child_process";import{mkdtempSync as mj,rmSync as hj}from"node:fs";import{tmpdir as gj}from"node:os";import{join as yj}from"node:path";var wj={openai:["OPENAI_API_KEY"],gemini:["GEMINI_API_KEY","GOOGLE_API_KEY"]};function Cj(n,r){let f=h=>(r[h]??"")!=="";switch(n){case"mock":return"none";case"claude":return f("ANTHROPIC_API_KEY")||f("ANTHROPIC_AUTH_TOKEN")?"api-key":f("CLAUDE_CODE_OAUTH_TOKEN")?"token":NW(r.CI)?"unavailable":"local-login";default:return wj[n].some(f)?"api-key":"unavailable"}}function NW(n){return n!==void 0&&n!==""&&n!=="0"&&n.toLowerCase()!=="false"}function HC(n,r,f,h,l){let t=n.createModelResolver({fallbackAdapter:r,fallbackModel:f,pinnedAdapter:r,env:l}),$=t.resolve(h.modelClass).model,re=h.verifyModelClass?t.resolve(h.verifyModelClass).model:void 0;return{adapter:r,...$!==void 0?{model:$}:{},...re!==void 0?{verifyModel:re}:{}}}var ZN={id:"speckeeper-reviewer",role_name:"Spec reviewer",purpose:"Judge one review packet and answer with findings in the requested JSON shape",mode:"read-only",responsibilities:["Judge the target against the check using only the packet"],constraints:["Use no tools and no information outside the packet"]},OW=ks.object({verdict:ks.enum(["confirmed","false_positive"]),rationale:ks.string().min(1)}),q_=class extends Error{},V_=class extends Error{},VC=class extends Error{};async function Lj(n,r){let f={written:[],failed:[]},h=mj(yj(gj(),"speckeeper-review-")),l=new Map,t=e=>{let qe=l.get(e.id);return qe||(qe=HC(r.runtime,r.adapter,r.model,e,r.env),l.set(e.id,qe)),qe},$=()=>f.adapterError!==void 0,re=async e=>{try{let qe=await $W(e,t(e.check),h,r,$);qC(e.recordFile,qe),f.written.push(e)}catch(qe){if(qe instanceof VC){f.failed.push({target:e,reason:qe.message});return}if(qe instanceof V_)return;throw qe}};try{let e=0,qe=async()=>{for(;f.adapterError===void 0&&e<n.length;){let ht=n[e++];try{await re(ht)}catch(Ke){f.adapterError??=Ke instanceof Error?Ke.message:String(Ke)}}};return await Promise.all(Array.from({length:Math.max(1,r.concurrency)},qe)),f}finally{hj(h,{recursive:!0,force:!0})}}async function $W(n,r,f,h,l){let{check:t,target:$,packet:re}=n,e={reported:!1,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0},qe=(bn,zr)=>{if(l())throw new V_;return MW(h,f,bn,e,zr)},ht=await qe(r.model,{taskId:`review-${t.id}`,description:t.description,modelClass:t.modelClass,request:re.text,schema:U_(t,{specs:h.registry.specs,contextBody:re.contextBody})}),Ke=KN(t,$.id,ht),{verifyPrompt:gt,verifyModelClass:ln}=t;gt!==void 0&&ln!==void 0&&(Ke=await Promise.all(Ke.map(async bn=>{let zr=await qe(r.verifyModel,{taskId:`review-${t.id}-verify`,description:`Verify one finding of ${t.id}`,modelClass:ln,request:DW(gt,re.contextBody,bn),schema:OW});return{...bn,...zr.verdict==="false_positive"?{status:"false_positive"}:{},verifier:{verdict:zr.verdict,rationale:zr.rationale}}})));let Qn=(h.now?.()??new Date).toISOString();return JN(n,ht,Ke,r,Qn,e.reported?{inputTokens:e.inputTokens,outputTokens:e.outputTokens,...e.cacheReadTokens>0?{cacheReadTokens:e.cacheReadTokens}:{},...e.cacheCreationTokens>0?{cacheCreationTokens:e.cacheCreationTokens}:{}}:void 0)}function KN(n,r,f){let h=new Map(n.rules?.map(l=>[l.code,l.severity]));return f.findings.map(l=>{let t=Object.fromEntries(Object.entries(l).filter(([re])=>!qN.includes(re))),$=h.get(l.code)??l.severity;if($===void 0)throw new Error(`Finding ${l.code} of ${n.id} has no severity`);return{fingerprint:dj(n.id,r,l),code:l.code,severity:$,message:l.message,...l.subject!==void 0?{subject:l.subject}:{},...l.location!==void 0?{location:l.location}:{},...l.evidence!==void 0?{evidence:l.evidence}:{},...l.suggestion!==void 0?{suggestion:l.suggestion}:{},...Object.keys(t).length>0?{extra:t}:{},status:"open"}})}function JN(n,r,f,h,l,t){let $=Object.fromEntries(Object.entries(r).filter(([re])=>re!=="findings"));return{check:n.check.id,target:n.target.id,packetHash:n.packet.hash,inputs:n.packet.inputs,inputHashes:n.packet.inputHashes,judge:h,judgedAt:l,...t?{usage:t}:{},...Object.keys($).length>0?{extra:$}:{},findings:n.record?pj(n.record.findings,f):f}}function DW(n,r,f){let{fingerprint:h,status:l,...t}=f;return["# Verification request","","## Instructions",n.trim(),"","## Context",r.trimEnd(),"","## Finding","```json",JSON.stringify(t,null,2),"```","","Answer `confirmed` when the context supports the finding, `false_positive` when it does not, with your rationale."].join(`
|
|
287
|
-
`)}function Ej(n,r,f,h){return n.createAdapter(n.adapter,{...f!==void 0?{model:f}:{},tools:[],cwd:r,permissionMode:"default",signal:AbortSignal.timeout(h),...n.adapter==="claude"&&n.claudeExecutable?{pathToClaudeCodeExecutable:n.claudeExecutable}:{}})}function Aj(n,r,f,h){switch(r){case"aborted":return`the judge did not answer within ${h/1e3} s and was stopped (review.timeoutSeconds sets the limit)`;case"authentication":return`the ${n.adapter} credentials were rejected: ${f.replace(/\.+$/,"")}. ${UW(n)}`;default:return f}}function UW(n){return n.adapter==="claude"&&n.credentials!=="api-key"?"Log in again (run `claude` and enter `/login`), or set CLAUDE_CODE_OAUTH_TOKEN (create one with `claude setup-token`).":`Check ${(n.adapter==="claude"?["ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN"]:wj[n.adapter]).join(" / ")}.`}var PW=6e4;async function _j(n){let r=mj(yj(gj(),"speckeeper-review-")),f=Math.min(PW,n.timeoutMs);try{let h=n.runtime.createModelResolver({fallbackAdapter:n.adapter,fallbackModel:n.model,pinnedAdapter:n.adapter}).resolve("fast").model;return await(await Ej(n,r,h,f)).send("Reply with OK.",{readonly:!0}),{ok:!0}}catch(h){let l=n.runtime.adapterErrorKind(h),t=h instanceof Error?h.message:String(h);return{ok:!1,kind:l,message:Aj(n,l,t,f)}}finally{hj(r,{recursive:!0,force:!0})}}function Sj(){let n=!1;if(process.platform==="darwin")try{n=RW("sysctl",["-n","hw.optional.arm64"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()==="1"}catch{}return{platform:process.platform,arch:process.arch,appleSilicon:n}}function Ij(n,r,f){if(!(n!=="claude"||r||f.platform!=="darwin"||f.arch!=="x64"||!f.appleSilicon))return"Node.js runs as x64 on an Apple silicon Mac, so the Claude Agent SDK starts the x64 build of Claude Code, which hangs under Rosetta. Use an arm64 Node.js and install the dependencies again with it (for example `nvm install 22`, then `rm -rf node_modules && npm ci`), or set review.claudeExecutable to an arm64 Claude Code."}async function MW(n,r,f,h,l){let t=`${l.taskId}-output`,$;try{let e=await Ej(n,r,f,n.timeoutMs);$=await n.runtime.runTask(e,l.taskId,{user_request:l.request},{maxFollowUps:1,maxRetries:0,agentRegistry:{[ZN.id]:ZN},taskRegistry:{[l.taskId]:{id:l.taskId,description:l.description,target_agent:ZN.id,result_handoff:t,completion_criteria:[],model_class:l.modelClass}},handoffSchemas:{[t]:l.schema},envelopeAdapter:n.adapter,...f!==void 0?{envelopeModel:f}:{}})}catch(e){throw new q_(e instanceof Error?e.message:String(e))}$.tokenUsage&&(h.reported=!0,h.inputTokens+=$.tokenUsage.inputTokens,h.outputTokens+=$.tokenUsage.outputTokens,h.cacheReadTokens+=$.tokenUsage.cacheReadTokens??0,h.cacheCreationTokens+=$.tokenUsage.cacheCreationTokens??0);let re=$.outcome;switch(re.status){case"success":return l.schema.parse(re.data);case"error":throw new q_(Aj(n,re.kind??"other",re.message,n.timeoutMs));case"validation_error":throw new VC(`the answer did not match the output schema after one correction: ${ks.prettifyError(re.errors)}`);case"escalation":throw new VC(`the judge escalated instead of answering: ${re.reason}`)}}var Yy={stale:"REVIEW-001",openFindings:"REVIEW-002",orphanRecord:"REVIEW-003",judgeChange:"REVIEW-004"};async function Tj(n,r){let f=n.gate.judgeChange==="ignore"?void 0:await zC(),h=n.config.adapter??"claude",l=await Hy(n,r,f?re=>HC(f,h,void 0,re,process.env):void 0),t=[],{gate:$}=n;for(let re of l.targets){let e=re.target.specIds.length===1?re.target.specIds[0]:void 0,qe=`review check "${re.check.id}", target ${re.target.id}`;if(re.state!=="fresh"&&$.stale!=="off"&&t.push({ruleId:Yy.stale,severity:$.stale,message:re.record?re.record.packetHash===re.packet.hash?`${qe}: the record was judged by ${XN(re.record.judge)}, not the configured judge; run "speckeeper review"`:`${qe}: the record is stale (${B_(re.record,re.packet).join(", ")}); run "speckeeper review" or "speckeeper review rebaseline"`:`${qe}: no judgment is recorded; run "speckeeper review"`,specId:e}),re.judgeChanged&&re.record&&re.currentJudge&&$.judgeChange==="warning"&&t.push({ruleId:Yy.judgeChange,severity:"warning",message:`${qe}: judged by ${XN(re.record.judge)}, the configured judge is ${XN(re.currentJudge)}`,specId:e}),$.openFindings!=="off")for(let ht of re.record?.findings??[])ht.status!=="open"||!$.blocking.includes(ht.severity)||t.push({ruleId:Yy.openFindings,severity:$.openFindings,message:`${qe}: open ${ht.severity} finding [${ht.code}] ${ht.message}`,specId:ht.subject?.split("#")[0]??e})}for(let re of l.orphans)t.push({ruleId:Yy.orphanRecord,severity:"warning",message:`review record ${jW(n.rootDir,re.path)} belongs to a check or target that is no longer declared; run "speckeeper review --prune"`});return t}function XN(n){return[n.adapter,n.model,n.verifyModel&&`verify ${n.verifyModel}`].filter(Boolean).join(" / ")}function H_(n){let r=By(n),f=new Map;for(let h of Object.values(r))for(let[l,t]of h)f.set(l,t);return{models:r,graph:jg(n),specs:f}}var YC=ks.enum(["REQ","HLD","LLD","IMPL","OPS","CI"]);function QN(n){return YC.options.indexOf(n)}var $se=ks.enum(["must","should","could","wont"]);var FW=ks.object({field:ks.string(),mustDecideBy:YC,value:ks.union([ks.string(),ks.null()]).optional(),description:ks.string().optional()}),Dse=ks.array(FW).optional();function xj(n){let r=n.value;if(r==null)return!0;let f=r.trim();return f===""||f.toUpperCase()==="TBD"}var Use=ks.object({type:ks.enum(["requirement","component","entity","screen","usecase","external"]),id:ks.string(),label:ks.string().optional()});var Wy={idUnique:"id-unique",refExists:"ref-exists",relationLevel:"relation-level",relationCycle:"relation-cycle",orphan:"orphan",phaseTbd:"phase-tbd",...Yy};function eO(n,r){let f=YC.safeParse(n);if(!f.success)throw new Error(`Unknown phase "${n}" (${r}). Valid phases: ${YC.options.join(", ")}`);return f.data}async function kj(n,r={}){let f=jg(n);return[...zW(f.nodes),...GW(f.nodes,f.edges),...BW(f.nodes,f.edges,r.models??[]),...qW(f.nodes,f.edges),...VW(f.nodes,f.edges),...HW(n,r.phase),...r.review?await Tj(r.review,H_(n)):[]]}function zW(n){let r=new Map;for(let h of n){let l=r.get(h.id)??[];l.push(h.model),r.set(h.id,l)}let f=[];for(let[h,l]of r)l.length<2||f.push({ruleId:Wy.idUnique,severity:"error",message:`ID "${h}" is declared ${l.length} times (${l.join(", ")}); every element must have a unique id`,specId:h});return f}function GW(n,r){let f=new Set(n.map(h=>h.id));return r.filter(h=>!f.has(h.to)).map(h=>({ruleId:Wy.refExists,severity:"error",message:`Relation '${h.type}' of "${h.from}" targets "${h.to}", which is not declared by any model`,specId:h.from}))}function Rj(n,r){let f=new Set(n.map(h=>h.id));return r.filter(h=>f.has(h.to)&&R_.includes(h.type))}function BW(n,r,f){let h=new Map(f.map(t=>[t.id,t.level])),l=new Map(n.map(t=>[t.id,h.get(t.model)]));return Rj(n,r).flatMap(t=>{let $=HM(l.get(t.from),t.from,{type:t.type,target:t.to},l.get(t.to));return $?[{ruleId:Wy.relationLevel,severity:"error",message:`Relation '${t.type}' of "${t.from}" to "${t.to}": ${$.message}`,specId:t.from}]:[]})}function qW(n,r){let f=Rj(n,r).filter(h=>Gy[h.type].propagation!=="both");return YM(f.map(h=>({sourceId:h.from,targetId:h.to,type:h.type}))).map(h=>({ruleId:Wy.relationCycle,severity:"error",message:h.message,specId:h.sourceId}))}function VW(n,r){let f=new Set(n.map(l=>l.id)),h=new Set;for(let l of r)h.add(l.from),f.has(l.to)&&h.add(l.to);return n.filter(l=>!h.has(l.id)).map(l=>({ruleId:Wy.orphan,severity:"info",message:`"${l.id}" (${l.model}) takes part in no relation`,specId:l.id}))}function HW(n,r){if(!r)return[];let f=QN(r),h=[];for(let l of n??[])for(let t of l.data){let{id:$,concretizationSlots:re}=t;for(let e of re??[])QN(e.mustDecideBy)>f||xj(e)&&h.push({ruleId:Wy.phaseTbd,severity:"error",message:`"${$}" leaves ${e.field} unresolved; it must be decided by phase ${e.mustDecideBy} and the gate is at ${r}`,specId:$})}return h}async function Nj(n){console.error(Xs.blue("speckeeper lint")),console.error("");let r=await nm(n.config);console.error(Xs.gray(` Design: ${r.designDir||"design"}/`));let f;try{f=YW(n.phase,r.lint?.phaseGate?.currentPhase)}catch(h){console.error(Xs.red("Lint failed:"),h instanceof Error?h.message:h),process.exitCode=1;return}f&&console.error(Xs.gray(` Phase: ${f}`)),console.error("");try{let h=r.models||[],l=r.specs;console.error(Xs.gray(` Loaded: ${h.length} models`)),console.error(""),console.error(Xs.blue(" Running lint checks..."));let t=z_(r.review,h,process.cwd())??void 0,$=await WW(h,l,{...n,gatePhase:f,review:t});console.error(""),ZW($,n),($.errors>0||n.strict&&$.warnings>0)&&(process.exitCode=1)}catch(h){console.error(Xs.red("Lint failed:"),h),process.exitCode=1}}function YW(n,r){if(n!==void 0)return eO(n,"--phase");if(r!==void 0)return eO(r,"lint.phaseGate.currentPhase")}async function WW(n,r,f){let h=[];for(let re of n){let e=Vm(r,re.id);if(e.length===0)continue;let qe=re.lintAll(e);for(let ht of qe)h.push({rule:ht.ruleId,severity:ht.severity,message:ht.message,specId:ht.specId,modelType:re.name})}for(let re of await kj(r,{phase:f.gatePhase,review:f.review,models:n}))h.push({rule:re.ruleId,severity:re.severity,message:re.message,specId:re.specId});let l=h.filter(re=>re.severity==="error").length,t=h.filter(re=>re.severity==="warning").length,$=h.filter(re=>re.severity==="info").length;return f.strict?{issues:h,errors:l,warnings:t,infos:$}:{issues:h.filter(re=>re.severity!=="info"),errors:l,warnings:t,infos:$}}function ZW(n,r){if(r.format==="json"){console.log(JSON.stringify(n,null,2));return}if(r.format==="github"){for(let f of n.issues){let h=f.severity==="error"?"error":f.severity==="warning"?"warning":"notice";console.log(`::${h}::${f.message} [${f.rule}]${f.specId?` (${f.specId})`:""}`)}return}if(n.issues.length===0){console.log(Xs.green(" \u2713 No issues found"));return}for(let f of n.issues){let h=f.severity==="error"?"\u2717":f.severity==="warning"?"\u26A0":"\u2139",l=f.severity==="error"?Xs.red:f.severity==="warning"?Xs.yellow:Xs.blue,t=f.specId?`[${f.specId}] `:"";console.log(l(` ${h} ${t}${f.message}`)),console.log(Xs.gray(` Rule: ${f.rule}`))}console.log(""),console.log(Xs.gray(` Summary: ${n.errors} errors, ${n.warnings} warnings, ${n.infos} infos`))}import{join as Oj}from"node:path";import{readFileSync as KW,existsSync as JW}from"node:fs";async function $j(n){console.error(Xs.blue("speckeeper drift")),console.error("");let r=process.cwd(),f=await nm(n.config);console.error(Xs.gray(` Design: ${f.designDir||"design"}/`)),console.error(Xs.gray(` Docs: ${f.docsDir}/`)),console.error("");try{let h=f.models??[],l=f.specs,t={docs:Oj(r,f.docsDir),specs:Oj(r,f.specsDir)},$=[];for(let qe of O_(h,l,t).files){if(!JW(qe.path)){$.push({file:qe.path,status:"missing",expected:qe.content,actual:null});continue}let ht=KW(qe.path,"utf-8"),Ke=Y_(qe.content)!==Y_(ht);$.push({file:qe.path,status:Ke?"drifted":"ok",expected:qe.content,actual:ht})}let re=$.filter(qe=>qe.status!=="ok");n.update&&re.length>0&&_E(re.map(qe=>({path:qe.file,content:qe.expected}))),XW($,n),re.length>0&&n.failOnDrift&&(process.exitCode=1)}catch(h){console.error(Xs.red("Drift check failed:"),h),process.exitCode=1}}function Y_(n){return n.trim().replace(/\r\n/g,`
|
|
288
|
-
`)}function
|
|
287
|
+
`)}function Ej(n,r,f,h){return n.createAdapter(n.adapter,{...f!==void 0?{model:f}:{},tools:[],cwd:r,permissionMode:"default",signal:AbortSignal.timeout(h),...n.adapter==="claude"&&n.claudeExecutable?{pathToClaudeCodeExecutable:n.claudeExecutable}:{}})}function Aj(n,r,f,h){switch(r){case"aborted":return`the judge did not answer within ${h/1e3} s and was stopped (review.timeoutSeconds sets the limit)`;case"authentication":return`the ${n.adapter} credentials were rejected: ${f.replace(/\.+$/,"")}. ${UW(n)}`;default:return f}}function UW(n){return n.adapter==="claude"&&n.credentials!=="api-key"?"Log in again (run `claude` and enter `/login`), or set CLAUDE_CODE_OAUTH_TOKEN (create one with `claude setup-token`).":`Check ${(n.adapter==="claude"?["ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN"]:wj[n.adapter]).join(" / ")}.`}var PW=6e4;async function _j(n){let r=mj(yj(gj(),"speckeeper-review-")),f=Math.min(PW,n.timeoutMs);try{let h=n.runtime.createModelResolver({fallbackAdapter:n.adapter,fallbackModel:n.model,pinnedAdapter:n.adapter}).resolve("fast").model;return await(await Ej(n,r,h,f)).send("Reply with OK.",{readonly:!0}),{ok:!0}}catch(h){let l=n.runtime.adapterErrorKind(h),t=h instanceof Error?h.message:String(h);return{ok:!1,kind:l,message:Aj(n,l,t,f)}}finally{hj(r,{recursive:!0,force:!0})}}function Sj(){let n=!1;if(process.platform==="darwin")try{n=RW("sysctl",["-n","hw.optional.arm64"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()==="1"}catch{}return{platform:process.platform,arch:process.arch,appleSilicon:n}}function Ij(n,r,f){if(!(n!=="claude"||r||f.platform!=="darwin"||f.arch!=="x64"||!f.appleSilicon))return"Node.js runs as x64 on an Apple silicon Mac, so the Claude Agent SDK starts the x64 build of Claude Code, which hangs under Rosetta. Use an arm64 Node.js and install the dependencies again with it (for example `nvm install 22`, then `rm -rf node_modules && npm ci`), or set review.claudeExecutable to an arm64 Claude Code."}async function MW(n,r,f,h,l){let t=`${l.taskId}-output`,$;try{let e=await Ej(n,r,f,n.timeoutMs);$=await n.runtime.runTask(e,l.taskId,{user_request:l.request},{maxFollowUps:1,maxRetries:0,agentRegistry:{[ZN.id]:ZN},taskRegistry:{[l.taskId]:{id:l.taskId,description:l.description,target_agent:ZN.id,result_handoff:t,completion_criteria:[],model_class:l.modelClass}},handoffSchemas:{[t]:l.schema},envelopeAdapter:n.adapter,...f!==void 0?{envelopeModel:f}:{}})}catch(e){throw new q_(e instanceof Error?e.message:String(e))}$.tokenUsage&&(h.reported=!0,h.inputTokens+=$.tokenUsage.inputTokens,h.outputTokens+=$.tokenUsage.outputTokens,h.cacheReadTokens+=$.tokenUsage.cacheReadTokens??0,h.cacheCreationTokens+=$.tokenUsage.cacheCreationTokens??0);let re=$.outcome;switch(re.status){case"success":return l.schema.parse(re.data);case"error":throw new q_(Aj(n,re.kind??"other",re.message,n.timeoutMs));case"validation_error":throw new VC(`the answer did not match the output schema after one correction: ${ks.prettifyError(re.errors)}`);case"escalation":throw new VC(`the judge escalated instead of answering: ${re.reason}`)}}var Yy={stale:"REVIEW-001",openFindings:"REVIEW-002",orphanRecord:"REVIEW-003",judgeChange:"REVIEW-004"};async function Tj(n,r){let f=n.gate.judgeChange==="ignore"?void 0:await zC(),h=n.config.adapter??"claude",l=await Hy(n,r,f?re=>HC(f,h,void 0,re,process.env):void 0),t=[],{gate:$}=n;for(let re of l.targets){let e=re.target.specIds.length===1?re.target.specIds[0]:void 0,qe=`review check "${re.check.id}", target ${re.target.id}`;if(re.state!=="fresh"&&$.stale!=="off"&&t.push({ruleId:Yy.stale,severity:$.stale,message:re.record?re.record.packetHash===re.packet.hash?`${qe}: the record was judged by ${XN(re.record.judge)}, not the configured judge; run "speckeeper review"`:`${qe}: the record is stale (${B_(re.record,re.packet).join(", ")}); run "speckeeper review" or "speckeeper review rebaseline"`:`${qe}: no judgment is recorded; run "speckeeper review"`,specId:e}),re.judgeChanged&&re.record&&re.currentJudge&&$.judgeChange==="warning"&&t.push({ruleId:Yy.judgeChange,severity:"warning",message:`${qe}: judged by ${XN(re.record.judge)}, the configured judge is ${XN(re.currentJudge)}`,specId:e}),$.openFindings!=="off")for(let ht of re.record?.findings??[])ht.status!=="open"||!$.blocking.includes(ht.severity)||t.push({ruleId:Yy.openFindings,severity:$.openFindings,message:`${qe}: open ${ht.severity} finding [${ht.code}] ${ht.message}`,specId:ht.subject?.split("#")[0]??e})}for(let re of l.orphans)t.push({ruleId:Yy.orphanRecord,severity:"warning",message:`review record ${jW(n.rootDir,re.path)} belongs to a check or target that is no longer declared; run "speckeeper review --prune"`});return t}function XN(n){return[n.adapter,n.model,n.verifyModel&&`verify ${n.verifyModel}`].filter(Boolean).join(" / ")}function H_(n){let r=n?.map(l=>({...l,data:l.data.map(FW)})),f=By(r),h=new Map;for(let l of Object.values(f))for(let[t,$]of l)h.set(t,$);return{models:f,graph:jg(r),specs:h}}function FW(n){return typeof n!="object"||n===null||!("_sourceFile"in n)?n:Object.fromEntries(Object.entries(n).filter(([r])=>r!=="_sourceFile"))}var YC=ks.enum(["REQ","HLD","LLD","IMPL","OPS","CI"]);function QN(n){return YC.options.indexOf(n)}var Dse=ks.enum(["must","should","could","wont"]);var zW=ks.object({field:ks.string(),mustDecideBy:YC,value:ks.union([ks.string(),ks.null()]).optional(),description:ks.string().optional()}),Use=ks.array(zW).optional();function xj(n){let r=n.value;if(r==null)return!0;let f=r.trim();return f===""||f.toUpperCase()==="TBD"}var Pse=ks.object({type:ks.enum(["requirement","component","entity","screen","usecase","external"]),id:ks.string(),label:ks.string().optional()});var Wy={idUnique:"id-unique",refExists:"ref-exists",relationLevel:"relation-level",relationCycle:"relation-cycle",orphan:"orphan",phaseTbd:"phase-tbd",...Yy};function eO(n,r){let f=YC.safeParse(n);if(!f.success)throw new Error(`Unknown phase "${n}" (${r}). Valid phases: ${YC.options.join(", ")}`);return f.data}async function kj(n,r={}){let f=jg(n);return[...GW(f.nodes),...BW(f.nodes,f.edges),...qW(f.nodes,f.edges,r.models??[]),...VW(f.nodes,f.edges),...HW(f.nodes,f.edges),...YW(n,r.phase),...r.review?await Tj(r.review,H_(n)):[]]}function GW(n){let r=new Map;for(let h of n){let l=r.get(h.id)??[];l.push(h.model),r.set(h.id,l)}let f=[];for(let[h,l]of r)l.length<2||f.push({ruleId:Wy.idUnique,severity:"error",message:`ID "${h}" is declared ${l.length} times (${l.join(", ")}); every element must have a unique id`,specId:h});return f}function BW(n,r){let f=new Set(n.map(h=>h.id));return r.filter(h=>!f.has(h.to)).map(h=>({ruleId:Wy.refExists,severity:"error",message:`Relation '${h.type}' of "${h.from}" targets "${h.to}", which is not declared by any model`,specId:h.from}))}function Rj(n,r){let f=new Set(n.map(h=>h.id));return r.filter(h=>f.has(h.to)&&R_.includes(h.type))}function qW(n,r,f){let h=new Map(f.map(t=>[t.id,t.level])),l=new Map(n.map(t=>[t.id,h.get(t.model)]));return Rj(n,r).flatMap(t=>{let $=HM(l.get(t.from),t.from,{type:t.type,target:t.to},l.get(t.to));return $?[{ruleId:Wy.relationLevel,severity:"error",message:`Relation '${t.type}' of "${t.from}" to "${t.to}": ${$.message}`,specId:t.from}]:[]})}function VW(n,r){let f=Rj(n,r).filter(h=>Gy[h.type].propagation!=="both");return YM(f.map(h=>({sourceId:h.from,targetId:h.to,type:h.type}))).map(h=>({ruleId:Wy.relationCycle,severity:"error",message:h.message,specId:h.sourceId}))}function HW(n,r){let f=new Set(n.map(l=>l.id)),h=new Set;for(let l of r)h.add(l.from),f.has(l.to)&&h.add(l.to);return n.filter(l=>!h.has(l.id)).map(l=>({ruleId:Wy.orphan,severity:"info",message:`"${l.id}" (${l.model}) takes part in no relation`,specId:l.id}))}function YW(n,r){if(!r)return[];let f=QN(r),h=[];for(let l of n??[])for(let t of l.data){let{id:$,concretizationSlots:re}=t;for(let e of re??[])QN(e.mustDecideBy)>f||xj(e)&&h.push({ruleId:Wy.phaseTbd,severity:"error",message:`"${$}" leaves ${e.field} unresolved; it must be decided by phase ${e.mustDecideBy} and the gate is at ${r}`,specId:$})}return h}async function Nj(n){console.error(Xs.blue("speckeeper lint")),console.error("");let r=await nm(n.config);console.error(Xs.gray(` Design: ${r.designDir||"design"}/`));let f;try{f=WW(n.phase,r.lint?.phaseGate?.currentPhase)}catch(h){console.error(Xs.red("Lint failed:"),h instanceof Error?h.message:h),process.exitCode=1;return}f&&console.error(Xs.gray(` Phase: ${f}`)),console.error("");try{let h=r.models||[],l=r.specs;console.error(Xs.gray(` Loaded: ${h.length} models`)),console.error(""),console.error(Xs.blue(" Running lint checks..."));let t=z_(r.review,h,process.cwd())??void 0,$=await ZW(h,l,{...n,gatePhase:f,review:t});console.error(""),KW($,n),($.errors>0||n.strict&&$.warnings>0)&&(process.exitCode=1)}catch(h){console.error(Xs.red("Lint failed:"),h),process.exitCode=1}}function WW(n,r){if(n!==void 0)return eO(n,"--phase");if(r!==void 0)return eO(r,"lint.phaseGate.currentPhase")}async function ZW(n,r,f){let h=[];for(let re of n){let e=Vm(r,re.id);if(e.length===0)continue;let qe=re.lintAll(e);for(let ht of qe)h.push({rule:ht.ruleId,severity:ht.severity,message:ht.message,specId:ht.specId,modelType:re.name})}for(let re of await kj(r,{phase:f.gatePhase,review:f.review,models:n}))h.push({rule:re.ruleId,severity:re.severity,message:re.message,specId:re.specId});let l=h.filter(re=>re.severity==="error").length,t=h.filter(re=>re.severity==="warning").length,$=h.filter(re=>re.severity==="info").length;return f.strict?{issues:h,errors:l,warnings:t,infos:$}:{issues:h.filter(re=>re.severity!=="info"),errors:l,warnings:t,infos:$}}function KW(n,r){if(r.format==="json"){console.log(JSON.stringify(n,null,2));return}if(r.format==="github"){for(let f of n.issues){let h=f.severity==="error"?"error":f.severity==="warning"?"warning":"notice";console.log(`::${h}::${f.message} [${f.rule}]${f.specId?` (${f.specId})`:""}`)}return}if(n.issues.length===0){console.log(Xs.green(" \u2713 No issues found"));return}for(let f of n.issues){let h=f.severity==="error"?"\u2717":f.severity==="warning"?"\u26A0":"\u2139",l=f.severity==="error"?Xs.red:f.severity==="warning"?Xs.yellow:Xs.blue,t=f.specId?`[${f.specId}] `:"";console.log(l(` ${h} ${t}${f.message}`)),console.log(Xs.gray(` Rule: ${f.rule}`))}console.log(""),console.log(Xs.gray(` Summary: ${n.errors} errors, ${n.warnings} warnings, ${n.infos} infos`))}import{join as Oj}from"node:path";import{readFileSync as JW,existsSync as XW}from"node:fs";async function $j(n){console.error(Xs.blue("speckeeper drift")),console.error("");let r=process.cwd(),f=await nm(n.config);console.error(Xs.gray(` Design: ${f.designDir||"design"}/`)),console.error(Xs.gray(` Docs: ${f.docsDir}/`)),console.error("");try{let h=f.models??[],l=f.specs,t={docs:Oj(r,f.docsDir),specs:Oj(r,f.specsDir)},$=[];for(let qe of O_(h,l,t).files){if(!XW(qe.path)){$.push({file:qe.path,status:"missing",expected:qe.content,actual:null});continue}let ht=JW(qe.path,"utf-8"),Ke=Y_(qe.content)!==Y_(ht);$.push({file:qe.path,status:Ke?"drifted":"ok",expected:qe.content,actual:ht})}let re=$.filter(qe=>qe.status!=="ok");n.update&&re.length>0&&_E(re.map(qe=>({path:qe.file,content:qe.expected}))),QW($,n),re.length>0&&n.failOnDrift&&(process.exitCode=1)}catch(h){console.error(Xs.red("Drift check failed:"),h),process.exitCode=1}}function Y_(n){return n.trim().replace(/\r\n/g,`
|
|
288
|
+
`)}function QW(n,r){if(r.format==="json"){let t={ok:n.filter($=>$.status==="ok").length,drifted:n.filter($=>$.status==="drifted").length,missing:n.filter($=>$.status==="missing").length,updated:r.update?n.filter($=>$.status!=="ok").length:0};console.log(JSON.stringify({results:n.map(({file:$,status:re})=>({file:$,status:re})),summary:t},null,2));return}if(r.format==="diff"){for(let t of n)if(t.status!=="ok"){console.log(`--- ${t.file} (on disk)`),console.log(`+++ ${t.file} (generated)`);for(let $ of eZ(t.actual??"",t.expected))console.log($)}return}console.log("");let f=n.filter(t=>t.status==="ok"),h=n.filter(t=>t.status==="drifted"),l=n.filter(t=>t.status==="missing");if(h.length===0&&l.length===0){console.log(Xs.green(" \u2713 No drift detected")),console.log(Xs.gray(` Checked: ${n.length} files`));return}if(h.length>0){console.log(Xs.yellow(` \u26A0 ${h.length} file(s) have drifted:`));for(let t of h)console.log(Xs.yellow(` - ${t.file}`))}if(l.length>0){console.log(Xs.red(` \u2717 ${l.length} file(s) are missing:`));for(let t of l)console.log(Xs.red(` - ${t.file}`))}console.log(""),console.log(Xs.gray(` Summary: ${f.length} ok, ${h.length} drifted, ${l.length} missing`)),r.update?console.log(Xs.cyan(` \u2192 Rewrote ${h.length+l.length} file(s) with their generated content; commit the result.`)):console.log(Xs.cyan(' \u2192 Regenerate the artifacts with "speckeeper build" and commit the result.'))}function eZ(n,r){let f=n===""?[]:Y_(n).split(`
|
|
289
289
|
`),h=Y_(r).split(`
|
|
290
|
-
`),l=Array.from({length:f.length+1},()=>new Array(h.length+1).fill(0));for(let e=f.length-1;e>=0;e--)for(let qe=h.length-1;qe>=0;qe--)l[e][qe]=f[e]===h[qe]?l[e+1][qe+1]+1:Math.max(l[e+1][qe],l[e][qe+1]);let t=[],$=0,re=0;for(;$<f.length&&re<h.length;)f[$]===h[re]?(t.push(` ${f[$]}`),$++,re++):l[$+1][re]>=l[$][re+1]?t.push(`-${f[$++]}`):t.push(`+${h[re++]}`);for(;$<f.length;)t.push(`-${f[$++]}`);for(;re<h.length;)t.push(`+${h[re++]}`);return t}var Hj=nh(ih(),1);import{join as
|
|
291
|
-
`);for(let re=1;re<=$.length;re++){let e=$[re-1],qe=new RegExp(t.source,t.flags),ht;for(;(ht=qe.exec(e))!==null;){let Ke=Bj(ht[1]??"");for(let gt of Ke)h.has(gt)&&l.push({specId:gt,location:`${f}:${re}`,context:{filePath:f,line:re}})}}return l}};function
|
|
292
|
-
`);for(let re=1;re<=$.length;re++){let e=$[re-1];for(let qe of n){let ht=new RegExp(qe.source,qe.flags),Ke;for(;(Ke=ht.exec(e))!==null;){let gt=Bj(Ke[1]??"");for(let ln of gt)l.has(ln)&&t.push({specId:ln,location:`${h}:${re}`,context:{filePath:h,line:re}})}}}return t}}}var bZ={openapi:aZ,ddl:fZ,annotation:dZ};function vZ(n){return n.scanner?n.scanner:n.type==="annotation"&&n.contentPatterns&&n.contentPatterns.length>0?pZ(n.contentPatterns):bZ[n.type]??null}function mZ(n,r){let f=nZ(n,"utf-8");if(r!=="openapi")return f;let h=n.endsWith(".json")?JSON.parse(f):(0,zj.parse)(f);if(h==null)throw new Error("file holds no OpenAPI document");return h}function qj(n,r,f,h){let l=f??process.cwd(),t=new Map,$=[];for(let re of n){let e=vZ(re);if(!e){$.push({severity:"warning",message:`No scanner found for source type "${re.type}". Provide a custom scanner.`,sourceType:re.type});continue}let qe=new Map;for(let gt of r){let Qn=h?.get(gt)?.[re.type]??gt;qe.set(Qn,gt)}let ht=Array.from(qe.keys()),Ke=new Set;for(let gt of re.paths){let ln=W_(Hw.sync(gt,{cwd:l,ignore:re.exclude??[]}));if(ln.length===0){$.push({severity:"error",message:`Source file not found: ${gt}`,sourceType:re.type,filePath:gt});continue}for(let Qn of ln)Ke.add(Qn)}for(let gt of Ke){let ln=sZ(gt)?gt:rZ(l,gt),Qn;try{Qn=mZ(ln,re.type)}catch(zr){let tr=zr instanceof Error?zr.message:String(zr);$.push({severity:"error",message:`Failed to load ${gt}: ${tr}`,sourceType:re.type,filePath:gt});continue}let bn;try{bn=e.findSpecIds(Qn,ht,gt,zr=>{$.push({...zr,sourceType:re.type,filePath:gt})})}catch(zr){let tr=zr instanceof Error?zr.message:String(zr);$.push({severity:"error",message:`Scanner error for ${gt}: ${tr}`,sourceType:re.type,filePath:gt});continue}for(let zr of bn){let tr=qe.get(zr.specId)??zr.specId,Er={...zr,specId:tr,sourceType:re.type,relation:re.relation,filePath:gt},cs=t.get(tr);cs?cs.push(Er):t.set(tr,[Er])}}}return{matches:t,diagnostics:$}}function Vj(n,r,f,h){let l=[],t=[];for(let $ of r){let re=f[$.sourceType];if(re){if(!re.mapper&&!re.constraints)throw new Error(`Deep validation rule for source type "${$.sourceType}" declares neither a mapper nor constraints`);if(hZ(n,$,re.constraints,h,l,t),!!re.mapper){if($.sourceType==="openapi"){let e=re.mapper(h),qe=$.context;if(!qe?.match?.operation)continue;gZ(n,e,qe.doc,qe.match,t)}else if($.sourceType==="ddl"){let e=re.mapper(h),qe=$.context;if(!qe?.table)continue;yZ(n,e,qe.table,t)}}}}return{success:l.length===0,errors:l,warnings:t}}function hZ(n,r,f,h,l,t){for(let $ of f??[]){let re=$.severity==="warning"?t:l;if(r.context===void 0){l.push({message:`Constraint "${$.id}" for "${n}" cannot be evaluated: the ${r.sourceType} match at ${r.location} carries no object`,specId:n,field:$.id});continue}$.holds(h,r.context)||re.push({message:`Constraint "${$.id}" violated for "${n}" at ${r.location}: ${$.description}`,specId:n,field:$.id})}}function gZ(n,r,f,h,l){if(r.method&&h.operation){let t=r.method.toLowerCase(),$=h.method?.toLowerCase();$&&$!==t&&l.push({message:`Method mismatch for "${n}": expected ${t.toUpperCase()}, found ${$.toUpperCase()}`,specId:n})}if(h.operation&&r.parameters){let t=(h.operation.parameters||[]).map($=>nO(f,$));for(let $ of r.parameters){let re=t.find(e=>e?.name===$.name&&(!$.in||e?.in===$.in));re?$.type&&re.schema?.type&&(K_($.type,re.schema.type)||l.push({message:`Parameter "${$.name}" type mismatch: expected ${$.type}, found ${re.schema.type}`,specId:n,field:$.name})):l.push({message:`Parameter "${$.name}" not found in operation "${n}"`,specId:n,field:$.name})}}if(h.operation&&r.responseProperties){let $=(h.operation.responses?.["200"]||h.operation.responses?.["201"])?.content?.["application/json"]?.schema;$=nO(f,$),$?.type==="array"&&($=nO(f,$.items));let re=$?.properties||{};for(let e of r.responseProperties){let qe=re[e.name];qe?e.type&&qe.type&&(K_(e.type,qe.type)||l.push({message:`Response property "${e.name}" type mismatch: expected ${e.type}, found ${qe.type}`,specId:n,field:e.name})):l.push({message:`Response property "${e.name}" not found in operation "${n}"`,specId:n,field:e.name})}}}function yZ(n,r,f,h){if(r.columns)for(let l of r.columns){let t=f.columns.find($=>$.name.toLowerCase()===l.name.toLowerCase());if(!t){h.push({message:`Column "${l.name}" not found in table "${r.tableName}"`,specId:n,field:l.name});continue}r.checkTypes&&l.type&&t.type&&(K_(l.type,t.type)||h.push({message:`Column "${l.name}" type mismatch in table "${r.tableName}": expected ${l.type}, found ${t.type}`,specId:n,field:l.name}))}}async function Yj(n,r){console.log(Xs.blue("speckeeper check")),console.log("");let f=process.cwd(),h=await nm(r.config),l=n??"all";console.log(Xs.gray(` Design: ${h.designDir||"design"}/`)),console.log(Xs.gray(` Type: ${l}`)),console.log("");try{let t=h.models||[],$=h.specs,re=h.sources??[];r.verbose&&(console.log(Xs.gray(` Registered models: ${t.map(Er=>Er.id).join(", ")}`)),console.log(Xs.gray(` Sources: ${re.length} configured`)));let e=[],qe=h.coverage?.transitiveRelations??[],ht=h.coverage?.threshold??80,Ke,gt=[],ln=new Map,Qn=new Map;for(let Er of t){let cs=Vm($,Er.id),Ys=Er.getLookupKeys?.();for(let ao of cs){let uo=ao.id;if(gt.push(uo),ln.set(uo,{modelId:Er.id,spec:ao}),Ys){let ni={};for(let[zo,ta]of Object.entries(Ys))typeof ta=="function"&&(ni[zo]=ta(ao));Object.keys(ni).length>0&&Qn.set(uo,ni)}}}let bn=l==="all"?re:re.filter(Er=>Er.type===l);if(l!=="all"&&bn.length===0&&e.push({type:l,success:!1,issues:[{severity:"error",message:`No source of type "${l}" is configured, so nothing would be checked (configured: ${[...new Set(re.map(Er=>Er.type))].join(", ")||"none"})`}]}),re.length>0&>.length>0){let{matches:Er,diagnostics:cs}=qj(bn,gt,f,Qn.size>0?Qn:void 0);for(let uo of cs)e.push({type:uo.sourceType,success:uo.severity!=="error",issues:[{severity:uo.severity,message:uo.message}]});for(let[uo,ni]of ln){let zo=Er.get(uo);if(zo&&zo.length>0){let Ha=t.find(ja=>ja.id===ni.modelId)?.getDeepValidation?.();if(Ha){let ja=Vj(uo,zo,Ha,ni.spec);(ja.errors.length>0||ja.warnings.length>0)&&e.push({type:ni.modelId,success:ja.success,issues:[...ja.errors.map(Aa=>({severity:"error",message:Aa.message,specId:Aa.specId,field:Aa.field})),...ja.warnings.map(Aa=>({severity:"warning",message:Aa.message,specId:Aa.specId,field:Aa.field}))]})}}}let Ys=new Set(Er.keys()),ao=Ys;if(qe.length>0){let uo=gt.map(ni=>{let ta=ln.get(ni)?.spec;return{id:ni,relations:ta?.relations}});Ke=EZ(Ys,uo,qe),ao=Ke.coveredSet}for(let uo of gt)if(!ao.has(uo)){let ni=ln.get(uo);e.push({type:ni?.modelId??"unknown",success:!0,issues:[{severity:"warning",message:`Spec ID "${uo}" not found in any configured source`,specId:uo}]})}}if(_Z(t,$,f,e),SZ(e),r.coverage){console.log(""),console.log(Xs.blue(" Coverage checks..."));let Er=IZ(t,$);if(Er.length>0){TZ(Er);for(let uo of Er)uo.result.uncoveredItems.length>0&&e.push({type:`coverage-${uo.modelId}`,success:uo.result.coveragePercent>=ht,issues:uo.result.uncoveredItems.slice(0,10).map(ni=>({severity:"warning",message:`[${uo.modelName}\u2192${uo.targetModel}] '${ni.id}'${ni.sourceId?` (${ni.sourceId})`:""} not covered`,specId:ni.id}))})}let cs=Er.map(uo=>uo.result.coveragePercent),Ys;if(Ke&&qe.length>0){let uo=gt.length,ni=Ke.directCount,zo=Ke.transitiveCount,ta=ni+zo,Ha=uo-ta,ja=uo>0?Math.round(ta/uo*100):100;cs.push(ja),ja<ht&&(Ys=`Transitive coverage ${ja}% is below the ${ht}% threshold (${ta}/${uo})`,e.push({type:"coverage-transitive",success:!1,issues:[{severity:"error",message:Ys}]})),console.log(""),console.log(Xs.blue(` Transitive coverage (via ${qe.join(", ")})`)),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(Xs.gray(` Total: ${uo}`)),console.log(Xs.green(` Covered: ${ta} (${ni} direct + ${zo} transitive)`)),console.log(Xs.yellow(` Uncovered: ${Ha}`));let Aa=ja>=ht?Xs.green:ja>=50?Xs.yellow:Xs.red;if(console.log(Aa(` Coverage: ${ja}%`)),Ha>0){let cl=gt.filter(lf=>!Ke.coveredSet.has(lf)),nl=cl.slice(0,10);console.log(""),console.log(Xs.yellow(" Uncovered items:"));for(let lf of nl){let cd=ln.get(lf);console.log(Xs.yellow(` - ${lf} (${cd?.modelId??"unknown"})`))}cl.length>10&&console.log(Xs.yellow(` ... and ${cl.length-10} more`))}}console.log(""),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Ys&&console.log(Xs.red(` \u2717 ${Ys}`));let ao=cs.filter(uo=>uo<ht).length;cs.length===0?console.log(Xs.gray(" No coverage checker found")):console.log(ao===0?Xs.green(` \u2713 All coverage checks passed (\u2265${ht}%)`):Xs.red(` \u2717 ${ao} coverage check(s) below ${ht}%`))}let zr=e.some(Er=>!Er.success),tr=e.some(Er=>Er.issues.some(cs=>cs.severity==="warning"));(zr||r.strict&&tr)&&(process.exitCode=1)}catch(t){console.error(Xs.red("Check failed:"),t),process.exitCode=1}}function EZ(n,r,f){if(f.length===0)return{coveredSet:new Set(n),directCount:n.size,transitiveCount:0};let h=new Map;for(let $ of r)if($.relations)for(let re of $.relations){if(!f.includes(re.type))continue;let e=h.get(re.target)??[];e.push($.id),h.set(re.target,e)}let l=new Set(n),t=!0;for(;t;){t=!1;for(let[$,re]of h)l.has($)||re.length>0&&re.every(e=>l.has(e))&&(l.add($),t=!0)}return{coveredSet:l,directCount:n.size,transitiveCount:l.size-n.size}}function AZ(n){let r=CZ(n,"utf-8");return n.endsWith(".yaml")||n.endsWith(".yml")?(0,Hj.parse)(r):n.endsWith(".json")?JSON.parse(r):r}function _Z(n,r,f,h){for(let l of n){let t=Vm(r,l.id);if(t.length!==0)for(let $ of t){let re=l.getExternalSourcePath?.($);if(!re)continue;let e=wZ(f,re);if(!LZ(e)){h.push({type:l.id,success:!1,issues:[{severity:"error",message:`External source not found: ${re}`,specId:$.id}]});continue}let qe=AZ(e),ht=l.check($,qe);(!ht.success||ht.errors.length>0||ht.warnings.length>0)&&h.push({type:l.id,success:ht.success,issues:[...ht.errors.map(Ke=>({severity:"error",message:Ke.message,specId:Ke.specId,field:Ke.field})),...ht.warnings.map(Ke=>({severity:"warning",message:Ke.message,specId:Ke.specId,field:Ke.field}))]})}}}function SZ(n){if(console.log(""),n.length===0){console.log(Xs.green(" \u2713 All checks passed"));return}let r=0,f=0;for(let h of n)for(let l of h.issues){let t=l.severity==="error"?"\u2717":"\u26A0",$=l.severity==="error"?Xs.red:Xs.yellow;l.severity==="error"?r++:f++;let re=l.specId?`[${l.specId}] `:"";console.log($(` ${t} ${re}${l.message}`))}console.log(""),console.log(Xs.gray(` Summary: ${r} errors, ${f} warnings`))}function IZ(n,r){let f=[],h=By(r);for(let l of n){let t=l.getCoverageChecker();if(t){let $=Vm(r,l.id),re=l.checkCoverage($,h);re&&f.push({modelId:l.id,modelName:l.name,description:t.description,targetModel:t.targetModel,result:re})}}return f}function TZ(n){for(let r of n){console.log(""),console.log(Xs.blue(` Coverage: ${r.modelName} \u2192 ${r.targetModel}`)),console.log(Xs.gray(` ${r.description}`)),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(Xs.gray(` Total: ${r.result.total}`)),console.log(Xs.green(` Covered: ${r.result.covered}`)),console.log(Xs.yellow(` Uncovered: ${r.result.uncovered}`));let f=r.result.coveragePercent>=80?Xs.green:r.result.coveragePercent>=50?Xs.yellow:Xs.red;if(console.log(f(` Coverage: ${r.result.coveragePercent}%`)),r.result.uncoveredItems.length>0&&r.result.uncoveredItems.length<=10){console.log(""),console.log(Xs.yellow(" Uncovered items:"));for(let h of r.result.uncoveredItems){let l=h.description?`: ${h.description.substring(0,40)}`:"",t=h.sourceId?` (${h.sourceId})`:"";console.log(Xs.yellow(` - ${h.id}${t}${l}`))}}else if(r.result.uncoveredItems.length>10){console.log(""),console.log(Xs.yellow(` (${r.result.uncoveredItems.length} uncovered items - showing first 5)`));for(let h of r.result.uncoveredItems.slice(0,5)){let l=h.description?`: ${h.description.substring(0,40)}`:"";console.log(Xs.yellow(` - ${h.id}${l}`))}}}}import{join as Wj}from"node:path";import{writeFileSync as xZ,existsSync as kZ}from"node:fs";async function Zj(n,r){console.log(Xs.blue("speckeeper new")),console.log("");let f=process.cwd(),h=await nm(),l=h.models??[],t=l.find(ht=>ht.id===n);if(!t){console.error(Xs.red(` Error: Unknown model type '${n}'`)),console.error(Xs.gray(` Model types the config registers: ${l.map(ht=>ht.id).join(", ")||"(none)"}`)),process.exitCode=1;return}let $=RZ(t.idPrefix,Vm(h.specs,t.id)),re=NZ(t,$,r.name);if(r.dryRun){console.log(Xs.gray(" Template (dry run):")),console.log(""),console.log(re);return}let e=r.output||Wj(f,h.designDir||"design"),qe=Wj(e,`${t.id}-${$}.ts`);if(kZ(qe)){console.error(Xs.red(` Error: File already exists: ${qe}`)),process.exitCode=1;return}xZ(qe,re),console.log(Xs.green(` \u2713 Created: ${qe}`))}function RZ(n,r){let f=0,h=3;for(let l of r){let t=l.id;if(typeof t!="string"||!t.startsWith(`${n}-`))continue;let $=t.slice(n.length+1);!/^\d+$/.test($)||Number($)<f||(f=Number($),h=$.length)}return`${n}-${String(f+1).padStart(h,"0")}`}function NZ(n,r,f){let h=[];return h.push("/**"),h.push(` * ${n.name}: ${r}`),h.push(" * "),h.push(` * Generated by speckeeper new. Add it to the specs of the ${n.id} model.`),h.push(" */"),h.push(`export const ${OZ(r)} = {`),h.push(` id: ${JSON.stringify(r)},`),f!==void 0&&h.push(` name: ${JSON.stringify(f)},`),h.push(` // TODO: Fill in the fields the ${n.id} model requires`),h.push("};"),h.push(""),h.join(`
|
|
293
|
-
`)}function
|
|
294
|
-
`),re=
|
|
295
|
-
`);if(bn.includes(`type: ${f.type}`)&&bn.includes(`target: ${f.target}`))return{line:ln+1,endLine:ln+Qn.length}}}function
|
|
290
|
+
`),l=Array.from({length:f.length+1},()=>new Array(h.length+1).fill(0));for(let e=f.length-1;e>=0;e--)for(let qe=h.length-1;qe>=0;qe--)l[e][qe]=f[e]===h[qe]?l[e+1][qe+1]+1:Math.max(l[e+1][qe],l[e][qe+1]);let t=[],$=0,re=0;for(;$<f.length&&re<h.length;)f[$]===h[re]?(t.push(` ${f[$]}`),$++,re++):l[$+1][re]>=l[$][re+1]?t.push(`-${f[$++]}`):t.push(`+${h[re++]}`);for(;$<f.length;)t.push(`-${f[$++]}`);for(;re<h.length;)t.push(`+${h[re++]}`);return t}var Hj=nh(ih(),1);import{join as CZ}from"node:path";import{readFileSync as LZ,existsSync as EZ}from"node:fs";import{readFileSync as rZ}from"node:fs";import{join as sZ,isAbsolute as oZ}from"node:path";function tZ(n){return n.replace(/\\/g,"/")}function W_(n){return n.map(tZ)}var zj=nh(ih(),1),Gj=nh(Pj(),1);var nZ={INTEGER:"INT",BOOL:"BOOLEAN",REAL:"FLOAT","DOUBLE PRECISION":"DOUBLE",SERIAL:"INT",BIGSERIAL:"BIGINT",SMALLSERIAL:"SMALLINT",TIMESTAMPTZ:"TIMESTAMP","TIMESTAMP WITH TIME ZONE":"TIMESTAMP","TIMESTAMP WITHOUT TIME ZONE":"TIMESTAMP","CHARACTER VARYING":"VARCHAR",CHARACTER:"CHAR",INT2:"SMALLINT",INT4:"INT",INT8:"BIGINT",FLOAT4:"FLOAT",FLOAT8:"DOUBLE"},Mj=[["SMALLINT","INT","BIGINT"],["FLOAT","DOUBLE"],["CHAR","VARCHAR","TEXT"],["INTEGER","NUMBER"]];function jj(n){let r=n.trim().toUpperCase(),f=r.match(/^([A-Z\s]+?)(?:\(\s*(\d+)(?:\s*,\s*(\d+))?\s*\))?$/);return f?{base:f[1].trim(),length:f[2]!==void 0?Number(f[2]):void 0,precision:f[2]!==void 0?Number(f[2]):void 0,scale:f[3]!==void 0?Number(f[3]):void 0}:{base:r}}function tO(n){return nZ[n]??n}function Fj(n,r){let f=[],h=tO(n);for(let l of r){let t=l.indexOf(n);t===-1&&(t=l.indexOf(h)),t!==-1&&f.push({chain:l,index:t})}return f}function K_(n,r){let f=jj(n),h=jj(r),l=tO(f.base),t=tO(h.base);if(l===t)return l==="DECIMAL"||l==="NUMERIC"?!(f.precision!==void 0&&h.precision!==void 0&&h.precision<f.precision||f.scale!==void 0&&h.scale!==void 0&&h.scale<f.scale):f.length!==void 0&&h.length!==void 0?h.length>=f.length:!0;let $=Fj(f.base,Mj),re=Fj(h.base,Mj);for(let e of $)for(let qe of re)if(e.chain===qe.chain)return qe.index>=e.index;return!1}function iZ(n,r){if(!r.startsWith("#/"))return;let f=r.substring(2).split("/"),h=n;for(let l of f){if(h==null||typeof h!="object")return;h=h[l]}return h}function nO(n,r){return r&&typeof r=="object"&&typeof r.$ref=="string"?iZ(n,r.$ref):r}function aZ(n,r){let f=n.paths;if(!f||typeof f!="object")return null;for(let[t,$]of Object.entries(f)){if($==null||typeof $!="object")continue;let re=["get","post","put","delete","patch","options","head"];for(let e of re){let qe=$[e];if(qe){if(qe.operationId===r)return{pathKey:t,operation:qe,method:e};if(qe["x-spec-id"]===r)return{pathKey:t,operation:qe,method:e}}}}for(let t of Object.keys(f))if(t.split("/").filter(Boolean).map(e=>e.replace(/^\{|\}$/g,"")).includes(r))return{pathKey:t};let h=n.components?.schemas;if(h&&typeof h=="object"&&r in h)return{pathKey:`#/components/schemas/${r}`};function l(t){if(t==null||typeof t!="object")return!1;if(t["x-spec-id"]===r)return!0;for(let $ of Object.values(t))if(l($))return!0;return!1}return l(n)?{pathKey:"(x-spec-id match)"}:null}var uZ={findSpecIds(n,r,f){let h=n;if(!h||typeof h!="object")return[];let l=[];for(let t of r){let $=aZ(h,t);$&&l.push({specId:t,location:`${f}:${$.pathKey}`,context:{doc:h,match:$}})}return l}};function lZ(n){let r=n.lastIndexOf(".");return r>=0?n.substring(r+1):n}function cZ(n){let r=new Gj.default.Parser,f=[];try{let h=r.astify(n),l=Array.isArray(h)?h:[h];for(let t of l){if(t.type!=="create"||t.keyword!=="table")continue;let $=typeof t.table=="string"?t.table:t.table?.[0]?.table??"",re=lZ($),e=(t.create_definitions||[]).filter(qe=>qe.resource==="column").map(qe=>{let ht=qe.column?.column??"",Ke=qe.definition?.dataType??"";return qe.definition?.length&&(Ke+=`(${qe.definition.length})`),qe.definition?.scale&&(Ke=Ke.replace(/\)$/,`,${qe.definition.scale})`)),{name:ht,type:Ke}});re&&f.push({name:re,columns:e})}return f}catch{return null}}function fZ(n){let r=[],f=/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:(?:[`"']?\w+[`"']?\s*\.\s*)?)[`"']?(\w+)[`"']?\s*\(([\s\S]*?)\);/gi,h;for(;(h=f.exec(n))!==null;){let l=h[1],t=h[2],$=[],re=t.split(",").map(e=>e.trim()).filter(Boolean);for(let e of re){if(/^\s*(PRIMARY\s+KEY|UNIQUE|CHECK|CONSTRAINT|INDEX|FOREIGN\s+KEY)/i.test(e))continue;let qe=e.match(/^(?:`|"|')?(\w+)(?:`|"|')?\s+(\w+(?:\([^)]*\))?)/i);qe&&$.push({name:qe[1],type:qe[2]})}l&&r.push({name:l,columns:$})}return r}var dZ={findSpecIds(n,r,f,h){if(typeof n!="string")return[];let l=cZ(n),t=l??[];t.length===0&&(t=fZ(n),l===null&&h?.({severity:"warning",message:`Could not parse DDL ${f}; fell back to regex table extraction`}));let $=[];for(let re of r){let e=t.find(qe=>qe.name.toLowerCase()===re.toLowerCase());e&&$.push({specId:re,location:`${f}:${e.name}`,context:{table:e}})}return $}};function Bj(n){return n.split(/[,\s]+/).map(r=>r.trim()).filter(Boolean)}var pZ={findSpecIds(n,r,f){if(typeof n!="string")return[];let h=new Set(r),l=[],t=/@(?:verifies|implements|traces)\s+([\w-]+(?:[,\s]+[\w-]+)*)/g,$=n.split(`
|
|
291
|
+
`);for(let re=1;re<=$.length;re++){let e=$[re-1],qe=new RegExp(t.source,t.flags),ht;for(;(ht=qe.exec(e))!==null;){let Ke=Bj(ht[1]??"");for(let gt of Ke)h.has(gt)&&l.push({specId:gt,location:`${f}:${re}`,context:{filePath:f,line:re}})}}return l}};function bZ(n){return{findSpecIds(r,f,h){if(typeof r!="string")return[];let l=new Set(f),t=[],$=r.split(`
|
|
292
|
+
`);for(let re=1;re<=$.length;re++){let e=$[re-1];for(let qe of n){let ht=new RegExp(qe.source,qe.flags),Ke;for(;(Ke=ht.exec(e))!==null;){let gt=Bj(Ke[1]??"");for(let ln of gt)l.has(ln)&&t.push({specId:ln,location:`${h}:${re}`,context:{filePath:h,line:re}})}}}return t}}}var vZ={openapi:uZ,ddl:dZ,annotation:pZ};function mZ(n){return n.scanner?n.scanner:n.type==="annotation"&&n.contentPatterns&&n.contentPatterns.length>0?bZ(n.contentPatterns):vZ[n.type]??null}function hZ(n,r){let f=rZ(n,"utf-8");if(r!=="openapi")return f;let h=n.endsWith(".json")?JSON.parse(f):(0,zj.parse)(f);if(h==null)throw new Error("file holds no OpenAPI document");return h}function qj(n,r,f,h){let l=f??process.cwd(),t=new Map,$=[];for(let re of n){let e=mZ(re);if(!e){$.push({severity:"warning",message:`No scanner found for source type "${re.type}". Provide a custom scanner.`,sourceType:re.type});continue}let qe=new Map;for(let gt of r){let Qn=h?.get(gt)?.[re.type]??gt;qe.set(Qn,gt)}let ht=Array.from(qe.keys()),Ke=new Set;for(let gt of re.paths){let ln=W_(Hw.sync(gt,{cwd:l,ignore:re.exclude??[]}));if(ln.length===0){$.push({severity:"error",message:`Source file not found: ${gt}`,sourceType:re.type,filePath:gt});continue}for(let Qn of ln)Ke.add(Qn)}for(let gt of Ke){let ln=oZ(gt)?gt:sZ(l,gt),Qn;try{Qn=hZ(ln,re.type)}catch(zr){let tr=zr instanceof Error?zr.message:String(zr);$.push({severity:"error",message:`Failed to load ${gt}: ${tr}`,sourceType:re.type,filePath:gt});continue}let bn;try{bn=e.findSpecIds(Qn,ht,gt,zr=>{$.push({...zr,sourceType:re.type,filePath:gt})})}catch(zr){let tr=zr instanceof Error?zr.message:String(zr);$.push({severity:"error",message:`Scanner error for ${gt}: ${tr}`,sourceType:re.type,filePath:gt});continue}for(let zr of bn){let tr=qe.get(zr.specId)??zr.specId,Er={...zr,specId:tr,sourceType:re.type,relation:re.relation,filePath:gt},cs=t.get(tr);cs?cs.push(Er):t.set(tr,[Er])}}}return{matches:t,diagnostics:$}}function Vj(n,r,f,h){let l=[],t=[];for(let $ of r){let re=f[$.sourceType];if(re){if(!re.mapper&&!re.constraints)throw new Error(`Deep validation rule for source type "${$.sourceType}" declares neither a mapper nor constraints`);if(gZ(n,$,re.constraints,h,l,t),!!re.mapper){if($.sourceType==="openapi"){let e=re.mapper(h),qe=$.context;if(!qe?.match?.operation)continue;yZ(n,e,qe.doc,qe.match,t)}else if($.sourceType==="ddl"){let e=re.mapper(h),qe=$.context;if(!qe?.table)continue;wZ(n,e,qe.table,t)}}}}return{success:l.length===0,errors:l,warnings:t}}function gZ(n,r,f,h,l,t){for(let $ of f??[]){let re=$.severity==="warning"?t:l;if(r.context===void 0){l.push({message:`Constraint "${$.id}" for "${n}" cannot be evaluated: the ${r.sourceType} match at ${r.location} carries no object`,specId:n,field:$.id});continue}$.holds(h,r.context)||re.push({message:`Constraint "${$.id}" violated for "${n}" at ${r.location}: ${$.description}`,specId:n,field:$.id})}}function yZ(n,r,f,h,l){if(r.method&&h.operation){let t=r.method.toLowerCase(),$=h.method?.toLowerCase();$&&$!==t&&l.push({message:`Method mismatch for "${n}": expected ${t.toUpperCase()}, found ${$.toUpperCase()}`,specId:n})}if(h.operation&&r.parameters){let t=(h.operation.parameters||[]).map($=>nO(f,$));for(let $ of r.parameters){let re=t.find(e=>e?.name===$.name&&(!$.in||e?.in===$.in));re?$.type&&re.schema?.type&&(K_($.type,re.schema.type)||l.push({message:`Parameter "${$.name}" type mismatch: expected ${$.type}, found ${re.schema.type}`,specId:n,field:$.name})):l.push({message:`Parameter "${$.name}" not found in operation "${n}"`,specId:n,field:$.name})}}if(h.operation&&r.responseProperties){let $=(h.operation.responses?.["200"]||h.operation.responses?.["201"])?.content?.["application/json"]?.schema;$=nO(f,$),$?.type==="array"&&($=nO(f,$.items));let re=$?.properties||{};for(let e of r.responseProperties){let qe=re[e.name];qe?e.type&&qe.type&&(K_(e.type,qe.type)||l.push({message:`Response property "${e.name}" type mismatch: expected ${e.type}, found ${qe.type}`,specId:n,field:e.name})):l.push({message:`Response property "${e.name}" not found in operation "${n}"`,specId:n,field:e.name})}}}function wZ(n,r,f,h){if(r.columns)for(let l of r.columns){let t=f.columns.find($=>$.name.toLowerCase()===l.name.toLowerCase());if(!t){h.push({message:`Column "${l.name}" not found in table "${r.tableName}"`,specId:n,field:l.name});continue}r.checkTypes&&l.type&&t.type&&(K_(l.type,t.type)||h.push({message:`Column "${l.name}" type mismatch in table "${r.tableName}": expected ${l.type}, found ${t.type}`,specId:n,field:l.name}))}}async function Yj(n,r){console.log(Xs.blue("speckeeper check")),console.log("");let f=process.cwd(),h=await nm(r.config),l=n??"all";console.log(Xs.gray(` Design: ${h.designDir||"design"}/`)),console.log(Xs.gray(` Type: ${l}`)),console.log("");try{let t=h.models||[],$=h.specs,re=h.sources??[];r.verbose&&(console.log(Xs.gray(` Registered models: ${t.map(Er=>Er.id).join(", ")}`)),console.log(Xs.gray(` Sources: ${re.length} configured`)));let e=[],qe=h.coverage?.transitiveRelations??[],ht=h.coverage?.threshold??80,Ke,gt=[],ln=new Map,Qn=new Map;for(let Er of t){let cs=Vm($,Er.id),Ys=Er.getLookupKeys?.();for(let ao of cs){let uo=ao.id;if(gt.push(uo),ln.set(uo,{modelId:Er.id,spec:ao}),Ys){let ni={};for(let[zo,ta]of Object.entries(Ys))typeof ta=="function"&&(ni[zo]=ta(ao));Object.keys(ni).length>0&&Qn.set(uo,ni)}}}let bn=l==="all"?re:re.filter(Er=>Er.type===l);if(l!=="all"&&bn.length===0&&e.push({type:l,success:!1,issues:[{severity:"error",message:`No source of type "${l}" is configured, so nothing would be checked (configured: ${[...new Set(re.map(Er=>Er.type))].join(", ")||"none"})`}]}),re.length>0&>.length>0){let{matches:Er,diagnostics:cs}=qj(bn,gt,f,Qn.size>0?Qn:void 0);for(let uo of cs)e.push({type:uo.sourceType,success:uo.severity!=="error",issues:[{severity:uo.severity,message:uo.message}]});for(let[uo,ni]of ln){let zo=Er.get(uo);if(zo&&zo.length>0){let Ha=t.find(ja=>ja.id===ni.modelId)?.getDeepValidation?.();if(Ha){let ja=Vj(uo,zo,Ha,ni.spec);(ja.errors.length>0||ja.warnings.length>0)&&e.push({type:ni.modelId,success:ja.success,issues:[...ja.errors.map(Aa=>({severity:"error",message:Aa.message,specId:Aa.specId,field:Aa.field})),...ja.warnings.map(Aa=>({severity:"warning",message:Aa.message,specId:Aa.specId,field:Aa.field}))]})}}}let Ys=new Set(Er.keys()),ao=Ys;if(qe.length>0){let uo=gt.map(ni=>{let ta=ln.get(ni)?.spec;return{id:ni,relations:ta?.relations}});Ke=AZ(Ys,uo,qe),ao=Ke.coveredSet}for(let uo of gt)if(!ao.has(uo)){let ni=ln.get(uo);e.push({type:ni?.modelId??"unknown",success:!0,issues:[{severity:"warning",message:`Spec ID "${uo}" not found in any configured source`,specId:uo}]})}}if(SZ(t,$,f,e),IZ(e),r.coverage){console.log(""),console.log(Xs.blue(" Coverage checks..."));let Er=TZ(t,$);if(Er.length>0){xZ(Er);for(let uo of Er)uo.result.uncoveredItems.length>0&&e.push({type:`coverage-${uo.modelId}`,success:uo.result.coveragePercent>=ht,issues:uo.result.uncoveredItems.slice(0,10).map(ni=>({severity:"warning",message:`[${uo.modelName}\u2192${uo.targetModel}] '${ni.id}'${ni.sourceId?` (${ni.sourceId})`:""} not covered`,specId:ni.id}))})}let cs=Er.map(uo=>uo.result.coveragePercent),Ys;if(Ke&&qe.length>0){let uo=gt.length,ni=Ke.directCount,zo=Ke.transitiveCount,ta=ni+zo,Ha=uo-ta,ja=uo>0?Math.round(ta/uo*100):100;cs.push(ja),ja<ht&&(Ys=`Transitive coverage ${ja}% is below the ${ht}% threshold (${ta}/${uo})`,e.push({type:"coverage-transitive",success:!1,issues:[{severity:"error",message:Ys}]})),console.log(""),console.log(Xs.blue(` Transitive coverage (via ${qe.join(", ")})`)),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(Xs.gray(` Total: ${uo}`)),console.log(Xs.green(` Covered: ${ta} (${ni} direct + ${zo} transitive)`)),console.log(Xs.yellow(` Uncovered: ${Ha}`));let Aa=ja>=ht?Xs.green:ja>=50?Xs.yellow:Xs.red;if(console.log(Aa(` Coverage: ${ja}%`)),Ha>0){let cl=gt.filter(lf=>!Ke.coveredSet.has(lf)),nl=cl.slice(0,10);console.log(""),console.log(Xs.yellow(" Uncovered items:"));for(let lf of nl){let cd=ln.get(lf);console.log(Xs.yellow(` - ${lf} (${cd?.modelId??"unknown"})`))}cl.length>10&&console.log(Xs.yellow(` ... and ${cl.length-10} more`))}}console.log(""),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Ys&&console.log(Xs.red(` \u2717 ${Ys}`));let ao=cs.filter(uo=>uo<ht).length;cs.length===0?console.log(Xs.gray(" No coverage checker found")):console.log(ao===0?Xs.green(` \u2713 All coverage checks passed (\u2265${ht}%)`):Xs.red(` \u2717 ${ao} coverage check(s) below ${ht}%`))}let zr=e.some(Er=>!Er.success),tr=e.some(Er=>Er.issues.some(cs=>cs.severity==="warning"));(zr||r.strict&&tr)&&(process.exitCode=1)}catch(t){console.error(Xs.red("Check failed:"),t),process.exitCode=1}}function AZ(n,r,f){if(f.length===0)return{coveredSet:new Set(n),directCount:n.size,transitiveCount:0};let h=new Map;for(let $ of r)if($.relations)for(let re of $.relations){if(!f.includes(re.type))continue;let e=h.get(re.target)??[];e.push($.id),h.set(re.target,e)}let l=new Set(n),t=!0;for(;t;){t=!1;for(let[$,re]of h)l.has($)||re.length>0&&re.every(e=>l.has(e))&&(l.add($),t=!0)}return{coveredSet:l,directCount:n.size,transitiveCount:l.size-n.size}}function _Z(n){let r=LZ(n,"utf-8");return n.endsWith(".yaml")||n.endsWith(".yml")?(0,Hj.parse)(r):n.endsWith(".json")?JSON.parse(r):r}function SZ(n,r,f,h){for(let l of n){let t=Vm(r,l.id);if(t.length!==0)for(let $ of t){let re=l.getExternalSourcePath?.($);if(!re)continue;let e=CZ(f,re);if(!EZ(e)){h.push({type:l.id,success:!1,issues:[{severity:"error",message:`External source not found: ${re}`,specId:$.id}]});continue}let qe=_Z(e),ht=l.check($,qe);(!ht.success||ht.errors.length>0||ht.warnings.length>0)&&h.push({type:l.id,success:ht.success,issues:[...ht.errors.map(Ke=>({severity:"error",message:Ke.message,specId:Ke.specId,field:Ke.field})),...ht.warnings.map(Ke=>({severity:"warning",message:Ke.message,specId:Ke.specId,field:Ke.field}))]})}}}function IZ(n){if(console.log(""),n.length===0){console.log(Xs.green(" \u2713 All checks passed"));return}let r=0,f=0;for(let h of n)for(let l of h.issues){let t=l.severity==="error"?"\u2717":"\u26A0",$=l.severity==="error"?Xs.red:Xs.yellow;l.severity==="error"?r++:f++;let re=l.specId?`[${l.specId}] `:"";console.log($(` ${t} ${re}${l.message}`))}console.log(""),console.log(Xs.gray(` Summary: ${r} errors, ${f} warnings`))}function TZ(n,r){let f=[],h=By(r);for(let l of n){let t=l.getCoverageChecker();if(t){let $=Vm(r,l.id),re=l.checkCoverage($,h);re&&f.push({modelId:l.id,modelName:l.name,description:t.description,targetModel:t.targetModel,result:re})}}return f}function xZ(n){for(let r of n){console.log(""),console.log(Xs.blue(` Coverage: ${r.modelName} \u2192 ${r.targetModel}`)),console.log(Xs.gray(` ${r.description}`)),console.log(Xs.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(Xs.gray(` Total: ${r.result.total}`)),console.log(Xs.green(` Covered: ${r.result.covered}`)),console.log(Xs.yellow(` Uncovered: ${r.result.uncovered}`));let f=r.result.coveragePercent>=80?Xs.green:r.result.coveragePercent>=50?Xs.yellow:Xs.red;if(console.log(f(` Coverage: ${r.result.coveragePercent}%`)),r.result.uncoveredItems.length>0&&r.result.uncoveredItems.length<=10){console.log(""),console.log(Xs.yellow(" Uncovered items:"));for(let h of r.result.uncoveredItems){let l=h.description?`: ${h.description.substring(0,40)}`:"",t=h.sourceId?` (${h.sourceId})`:"";console.log(Xs.yellow(` - ${h.id}${t}${l}`))}}else if(r.result.uncoveredItems.length>10){console.log(""),console.log(Xs.yellow(` (${r.result.uncoveredItems.length} uncovered items - showing first 5)`));for(let h of r.result.uncoveredItems.slice(0,5)){let l=h.description?`: ${h.description.substring(0,40)}`:"";console.log(Xs.yellow(` - ${h.id}${l}`))}}}}import{join as Wj}from"node:path";import{writeFileSync as kZ,existsSync as RZ}from"node:fs";async function Zj(n,r){console.log(Xs.blue("speckeeper new")),console.log("");let f=process.cwd(),h=await nm(),l=h.models??[],t=l.find(ht=>ht.id===n);if(!t){console.error(Xs.red(` Error: Unknown model type '${n}'`)),console.error(Xs.gray(` Model types the config registers: ${l.map(ht=>ht.id).join(", ")||"(none)"}`)),process.exitCode=1;return}let $=NZ(t.idPrefix,Vm(h.specs,t.id)),re=OZ(t,$,r.name);if(r.dryRun){console.log(Xs.gray(" Template (dry run):")),console.log(""),console.log(re);return}let e=r.output||Wj(f,h.designDir||"design"),qe=Wj(e,`${t.id}-${$}.ts`);if(RZ(qe)){console.error(Xs.red(` Error: File already exists: ${qe}`)),process.exitCode=1;return}kZ(qe,re),console.log(Xs.green(` \u2713 Created: ${qe}`))}function NZ(n,r){let f=0,h=3;for(let l of r){let t=l.id;if(typeof t!="string"||!t.startsWith(`${n}-`))continue;let $=t.slice(n.length+1);!/^\d+$/.test($)||Number($)<f||(f=Number($),h=$.length)}return`${n}-${String(f+1).padStart(h,"0")}`}function OZ(n,r,f){let h=[];return h.push("/**"),h.push(` * ${n.name}: ${r}`),h.push(" * "),h.push(` * Generated by speckeeper new. Add it to the specs of the ${n.id} model.`),h.push(" */"),h.push(`export const ${$Z(r)} = {`),h.push(` id: ${JSON.stringify(r)},`),f!==void 0&&h.push(` name: ${JSON.stringify(f)},`),h.push(` // TODO: Fill in the fields the ${n.id} model requires`),h.push("};"),h.push(""),h.join(`
|
|
293
|
+
`)}function $Z(n){return n.toLowerCase().replace(/[-_](.)/g,(r,f)=>f.toUpperCase())}async function Kj(n,r){if(console.error(Xs.blue("speckeeper impact")),console.error(""),!n){console.error(Xs.red("Error: ID is required")),console.error(Xs.gray(" Usage: speckeeper impact <id>")),process.exitCode=1;return}let f=await nm(r.config),h=Number(r.depth??3),l=r.direction==="upstream"||r.direction==="downstream"?r.direction:"both";console.error(Xs.gray(` Target: ${n}`)),console.error(Xs.gray(` Depth: ${h}`)),console.error(Xs.gray(` Direction: ${l}`)),console.error("");try{let t=jg(f.specs),$=t.nodes.find(e=>e.id===n);if(!$){console.error(Xs.red(` Error: Target '${n}' not found`)),process.exitCode=1;return}console.error(Xs.blue(" Analyzing impact..."));let re=DZ(t,n,$.model,h,l);UZ(re,r)}catch(t){console.error(Xs.red("Impact analysis failed:"),t),process.exitCode=1}}function DZ(n,r,f,h,l){let t=N_(n,r,{depth:h,direction:l}).map($=>({id:$.id,type:$.model,depth:$.depth,impactType:$.depth===1?"direct":"indirect"}));return{target:r,targetType:f,impactedNodes:t}}function UZ(n,r){if(console.error(""),r.format==="json"){console.log(JSON.stringify(n,null,2));return}if(r.format==="mermaid"){console.log("```mermaid"),console.log("graph TD"),console.log(` ${n.target}[${n.target}]`);for(let l of n.impactedNodes){let t=l.impactType==="direct"?"-->|direct|":"-.->|indirect|";console.log(` ${n.target} ${t} ${l.id}[${l.id}]`)}console.log("```");return}if(n.impactedNodes.length===0){console.log(Xs.green(" No impacted elements found"));return}let f=n.impactedNodes.filter(l=>l.impactType==="direct"),h=n.impactedNodes.filter(l=>l.impactType==="indirect");if(f.length>0){console.log(Xs.yellow(` Direct impact (${f.length}):`));for(let l of f)console.log(Xs.yellow(` \u2192 ${l.id} (${l.type})`))}if(h.length>0){console.log(Xs.gray(` Indirect impact (${h.length}):`));for(let l of h)console.log(Xs.gray(` \u2933 ${l.id} (${l.type}, depth: ${l.depth})`))}console.log(""),console.log(Xs.gray(` Total: ${n.impactedNodes.length} impacted elements`))}import{readFileSync as Xj}from"node:fs";import{resolve as Zy,relative as J_,dirname as PZ,join as MZ}from"node:path";import{fileURLToPath as jZ}from"node:url";var rO=class{constructor(r){this.configPath=r}configPath;name="speckeeper";async provide(r){let f=Zy(r.projectRoot),h=await nm(this.configPath,f),l=[],t=new Map;if(!h.specs)return this.buildInsight(l,[]);let $=By(h.specs);zZ(h.specs,$,f,l,t);let re=this.buildInsight(l,Array.from(t.values()));return FZ(re,r)}buildInsight(r,f){return{source:"speckeeper",sourceVersion:JZ(),generatedAt:new Date().toISOString(),edges:r,anchorMapping:f.length>0?f:void 0}}};function Qj(n){return new rO(n)}function FZ(n,r){let{changedFiles:f,artifactIds:h}=r;if(!f?.length&&!h?.length)return n;let l=new Set;if(f?.length){let e=new Set(f);for(let qe of n.anchorMapping??[])qe.filePaths.some(ht=>e.has(ht))&&l.add(qe.domainId)}if(h?.length)for(let e of h)l.add(e);let t=n.edges.filter(e=>l.has(e.from)||l.has(e.to)),$=new Set;for(let e of t)$.add(e.from),$.add(e.to);let re=(n.anchorMapping??[]).filter(e=>$.has(e.domainId));return{...n,edges:t,anchorMapping:re.length>0?re:void 0}}function zZ(n,r,f,h,l){for(let t of n)for(let $ of t.data){let re=$;if(!re.id)continue;let e=re._sourceFile?J_(f,Zy(f,re._sourceFile)):void 0;if(Jj(l,re,e,f),!!re.relations?.length)for(let qe of re.relations){let Ke=Gy[qe.type]?.propagation??"both",gt=e?qZ(e,re.id,qe,f):void 0,ln={kind:"spec_relation",detail:BZ(re.id,qe),...e?{filePath:e}:{},...gt?{line:gt.line,endLine:gt.endLine}:{}};h.push({from:re.id,to:qe.target,kind:qe.type,propagation:Ke,weight:.7,evidence:[ln]})}}for(let[,t]of Object.entries(r))for(let[,$]of t){let re=$;if(!re.id||l.has(re.id))continue;let e=re._sourceFile?J_(f,Zy(f,re._sourceFile)):void 0;Jj(l,re,e,f)}}function Jj(n,r,f,h){let l=new Set;f&&l.add(f),r.source?.path&&l.add(J_(h,Zy(h,r.source.path)));let t=GZ(r,h);l.size===0&&t.length===0||n.set(r.id,{domainId:r.id,filePaths:W_([...l]),...t.length>0?{symbols:t}:{}})}function GZ(n,r){let f=n.source?.path;if(!f)return[];let h=J_(r,Zy(r,f));return[{symbolId:n.id,filePath:h,startLine:1,endLine:1}]}function BZ(n,r){let f=r.description?` (${r.description})`:"";return`${n} --[${r.type}]--> ${r.target}${f}`}function qZ(n,r,f,h){let l=Zy(h,n),t;try{t=Xj(l,"utf-8")}catch{return}let $=t.split(`
|
|
294
|
+
`),re=VZ($,r);if(re<0)return;let e=HZ($,re);if(e<0)return;let qe=YZ($,re),ht=qe>=0?qe:$.length;for(let Ke=e;Ke<ht;Ke++){if(!$[Ke].includes(`target: ${f.target}`))continue;let ln=WZ($,Ke,e),Qn=ZZ($,ln,ht),bn=Qn.join(`
|
|
295
|
+
`);if(bn.includes(`type: ${f.type}`)&&bn.includes(`target: ${f.target}`))return{line:ln+1,endLine:ln+Qn.length}}}function VZ(n,r){let f=new RegExp(`^\\s*-?\\s*id:\\s*${KZ(r)}\\s*$`);for(let h=0;h<n.length;h++)if(f.test(n[h]))return h;return-1}function HZ(n,r){for(let f=r;f<n.length;f++){if(/^\s*relations:\s*$/.test(n[f]))return f;if(f>r&&/^\s*-?\s*id:\s+\S+/.test(n[f]))return-1}return-1}function YZ(n,r){for(let f=r+1;f<n.length;f++)if(/^\s*-?\s*id:\s+\S+/.test(n[f]))return f;return-1}function WZ(n,r,f){for(let h=r;h>=f;h--)if(/^\s*-\s+type:/.test(n[h]))return h;return r}function ZZ(n,r,f){let h=[n[r]],l=n[r].match(/^(\s*)/)?.[1]?.length??0;for(let t=r+1;t<f;t++){let $=n[t];if(/^\s*-\s+type:/.test($))break;let re=$.match(/^(\s*)/)?.[1]?.length??0;if($.trim()!==""&&re<=l)break;h.push($)}return h}function KZ(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function JZ(){try{let n=PZ(jZ(import.meta.url)),r=MZ(n,"..","..","package.json");return JSON.parse(Xj(r,"utf-8")).version}catch{return}}async function e3(n){let r=n.projectRoot??process.cwd();try{let h=await Qj(n.config).provide({projectRoot:r});console.log(JSON.stringify(h))}catch(f){console.error("Insights export failed:",f),process.exitCode=1}}import{existsSync as xh,mkdirSync as sO,writeFileSync as oO,readFileSync as XZ,readdirSync as QZ,statSync as eK}from"node:fs";import{join as kh,dirname as t3,basename as tK}from"node:path";import{fileURLToPath as nK}from"node:url";var rK=nK(import.meta.url),sK=t3(rK);async function n3(n={}){let r=process.cwd();console.log(Xs.cyan("speckeeper init")),console.log("");let f=kh(r,"design"),h=kh(r,"speckeeper.config.ts");if(!n.force&&(xh(f)||xh(h))){console.log(Xs.yellow(" Project already initialized.")),console.log(Xs.gray(" Use --force to overwrite existing files."));return}let l=tK(r)||"my-project",t=kh(sK,"templates","init");if(!xh(t)){console.log(Xs.red(` Error: Templates directory not found at ${t}`)),console.log(Xs.gray(" Please ensure the package is properly installed."));return}let $=n.format==="yaml",re=new Set(["design/requirements.ts"]),e=!1;r3(t,r,l,n.force||!1,(ht,Ke)=>{Ke?(console.log(Xs.green(` Created: ${ht}`)),ht==="package.json"&&(e=!0)):console.log(Xs.yellow(` Skipped: ${ht} (already exists)`))},"",$?re:void 0),$&&oK(r,n.force||!1),console.log(""),console.log(Xs.cyan(" Project initialized successfully!")),console.log("");let qe=$?"design/*.yaml":"design/*.ts using defineSpecs()";console.log(" Next steps:"),e?(console.log(Xs.gray(" 1. Run `npm install` to install dependencies")),console.log(Xs.gray(` 2. Add spec data in ${qe}`)),console.log(Xs.gray(" 3. Import new spec files in design/index.ts")),console.log(Xs.gray(" 4. Run `npx speckeeper lint` to validate"))):(console.log(Xs.gray(" 1. Add speckeeper and zod to your package.json dependencies")),console.log(Xs.gray(' 2. Ensure "type": "module" is set in package.json')),console.log(Xs.gray(` 3. Add spec data in ${qe}`)),console.log(Xs.gray(" 4. Import new spec files in design/index.ts")),console.log(Xs.gray(" 5. Run `npx speckeeper lint` to validate")))}function r3(n,r,f,h,l,t="",$){let re=QZ(n);for(let e of re){let qe=kh(n,e),ht=eK(qe),Ke=e.endsWith(".template")?e.slice(0,-9):e,gt=kh(r,Ke),ln=t?kh(t,Ke):Ke;if(ht.isDirectory())xh(gt)||(sO(gt,{recursive:!0}),l(ln+"/",!0)),r3(qe,gt,f,h,l,ln,$);else{if($?.has(ln))continue;if(!h&&xh(gt)){l(ln,!1);continue}let Qn=XZ(qe,"utf-8");Qn=Qn.replace(/\{\{PROJECT_NAME\}\}/g,f);let bn=t3(gt);xh(bn)||sO(bn,{recursive:!0}),oO(gt,Qn),l(ln,!0)}}}function oK(n,r){let f=kh(n,"design");xh(f)||sO(f,{recursive:!0});let h=kh(f,"requirements.yaml");(r||!xh(h))&&(oO(h,`# Requirements
|
|
296
296
|
model: requirement
|
|
297
297
|
specs:
|
|
298
298
|
- id: REQ-001
|
|
@@ -316,8 +316,8 @@ import { allModels } from './_models/index.ts';
|
|
|
316
316
|
const yamlSpecs = loadYamlDir(import.meta.dirname, allModels);
|
|
317
317
|
|
|
318
318
|
export default mergeSpecs(...yamlSpecs);
|
|
319
|
-
`),console.log(Xs.green(" Created: design/index.ts (yaml mode)")))}var o3=nh(ih(),1);import{existsSync as
|
|
320
|
-
`),f=new Map,h=[],l=[],t=[],$=[],re="TB",e=[];for(let qe of r){let ht=qe.trim();if(!ht||ht.startsWith("%%"))continue;let Ke=ht.match(/^flowchart\s+(\w+)/);if(Ke){re=Ke[1];continue}if(ht.startsWith("graph ")){let tr=ht.match(/^graph\s+(\w+)/);tr&&(re=tr[1]);continue}let gt=ht.match(/^subgraph\s+(\S+)(?:\s*\[([^\]]*)\])?/);if(gt){let tr={id:gt[1],label:gt[2]||void 0,nodeIds:[]};e.push(tr);continue}if(ht==="end"&&e.length>0){let tr=e.pop();$.push(tr);for(let Er of tr.nodeIds){let cs=f.get(Er);cs&&(cs.subgraph=tr.id)}continue}let ln=ht.match(/^classDef\s+(\S+)\s+(.*)/);if(ln){l.push({name:ln[1],styles:ln[2]});continue}let Qn=ht.match(/^class\s+(\S+)\s+(\S+)/);if(Qn){let tr=Qn[1].split(",").map(Er=>Er.trim());t.push({nodeIds:tr,className:Qn[2]});for(let Er of tr){X_(f,Er);let cs=f.get(Er);cs.classes.includes(Qn[2])||cs.classes.push(Qn[2])}continue}let bn=
|
|
319
|
+
`),console.log(Xs.green(" Created: design/index.ts (yaml mode)")))}var o3=nh(ih(),1);import{existsSync as iK,writeFileSync as aK}from"node:fs";import{resolve as s3,basename as uK,dirname as lK,join as cK}from"node:path";async function i3(n,r={}){let f=s3(n);if(!iK(f)){console.error(Xs.red(` Error: File not found: ${f}`)),process.exitCode=1;return}if(!f.endsWith(".ts")&&!f.endsWith(".js")&&!f.endsWith(".mjs")){console.error(Xs.red(" Error: Source file must be a .ts, .js, or .mjs file")),process.exitCode=1;return}console.log(Xs.cyan("speckeeper convert")),console.log(Xs.gray(` Source: ${f}`)),console.log("");let h;try{let re=await import(f);h=re.default??re}catch(re){console.error(Xs.red(` Error: Failed to import ${f}`)),console.error(Xs.gray(` ${re instanceof Error?re.message:String(re)}`)),process.exitCode=1;return}if(!h?.entries||!Array.isArray(h.entries)){console.error(Xs.red(" Error: File does not export a valid SpecModule (missing entries array)")),console.error(Xs.gray(" The file must export a SpecModule via defineSpecs()")),process.exitCode=1;return}let l=h.entries.length===1?{model:h.entries[0].model.id,specs:h.entries[0].data}:{entries:h.entries.map(re=>({model:re.model.id,specs:re.data}))},t=(0,o3.stringify)(l,{lineWidth:120,defaultStringType:"PLAIN",defaultKeyType:"PLAIN"});if(r.dryRun){console.log(Xs.yellow(" Dry run \u2014 showing conversion result:")),console.log(""),console.log(t);return}let $=r.output?s3(r.output):cK(lK(f),uK(f).replace(/\.(ts|js|mjs)$/,".yaml"));aK($,t),console.log(Xs.green(` Created: ${$}`)),console.log(""),console.log(Xs.gray(" Remember to update design/index.ts to use loadYamlDir() for YAML files."))}import{readFileSync as kK,writeFileSync as RK,existsSync as uO,mkdirSync as NK}from"node:fs";import{join as g3,dirname as OK,resolve as y3}from"node:path";function fK(n){let r=[],f=/```mermaid\s*\n([\s\S]*?)```/g,h;for(;(h=f.exec(n))!==null;)r.push(h[1]);return r}function dK(n){let r=n.split(`
|
|
320
|
+
`),f=new Map,h=[],l=[],t=[],$=[],re="TB",e=[];for(let qe of r){let ht=qe.trim();if(!ht||ht.startsWith("%%"))continue;let Ke=ht.match(/^flowchart\s+(\w+)/);if(Ke){re=Ke[1];continue}if(ht.startsWith("graph ")){let tr=ht.match(/^graph\s+(\w+)/);tr&&(re=tr[1]);continue}let gt=ht.match(/^subgraph\s+(\S+)(?:\s*\[([^\]]*)\])?/);if(gt){let tr={id:gt[1],label:gt[2]||void 0,nodeIds:[]};e.push(tr);continue}if(ht==="end"&&e.length>0){let tr=e.pop();$.push(tr);for(let Er of tr.nodeIds){let cs=f.get(Er);cs&&(cs.subgraph=tr.id)}continue}let ln=ht.match(/^classDef\s+(\S+)\s+(.*)/);if(ln){l.push({name:ln[1],styles:ln[2]});continue}let Qn=ht.match(/^class\s+(\S+)\s+(\S+)/);if(Qn){let tr=Qn[1].split(",").map(Er=>Er.trim());t.push({nodeIds:tr,className:Qn[2]});for(let Er of tr){X_(f,Er);let cs=f.get(Er);cs.classes.includes(Qn[2])||cs.classes.push(Qn[2])}continue}let bn=pK(ht);if(bn){for(let{sourceId:tr,sourceLabel:Er,targetId:cs,targetLabel:Ys,label:ao,direction:uo}of bn)if(X_(f,tr,Er),X_(f,cs,Ys),h.push({sourceId:tr,targetId:cs,rawLabel:ao,direction:uo}),e.length>0){let ni=e[e.length-1];ni.nodeIds.includes(tr)||ni.nodeIds.push(tr),ni.nodeIds.includes(cs)||ni.nodeIds.push(cs)}continue}let zr=bK(ht);if(zr&&(X_(f,zr.id,zr.label),e.length>0)){let tr=e[e.length-1];tr.nodeIds.includes(zr.id)||tr.nodeIds.push(zr.id)}}return{direction:re,nodes:f,edges:h,classDefs:l,classAssignments:t,subgraphs:$}}function u3(n){let r=fK(n);for(let f of r){let h=f.trim();if(h.startsWith("flowchart")||h.startsWith("graph"))return dK(h)}return null}function X_(n,r,f){let h=n.get(r);h?f&&!h.label&&(h.label=f):n.set(r,{id:r,label:f,classes:[]})}var a3=/([A-Za-z_]\w*)(?:\[([^\]]*)\])?/;function pK(n){let r=[{regex:/<-{2,}>/,direction:"bidirectional"},{regex:/<={2,}>/,direction:"bidirectional"},{regex:/-{2,}>/,direction:"forward"},{regex:/={2,}>/,direction:"forward"},{regex:/-\.->/,direction:"forward"}],f=null;for(let Qn of r){let bn=n.match(Qn.regex);bn&&bn.index!==void 0&&(!f||bn.index<f.index)&&(f={index:bn.index,length:bn[0].length,direction:Qn.direction})}if(!f)return null;let h=n.substring(0,f.index).trim(),l=n.substring(f.index+f.length).trim(),t=h.match(a3);if(!t)return null;let $=t[1],re=t[2]||void 0,e,qe=l,ht=l.match(/^\|([^|]*)\|\s*(.*)/);ht&&(e=ht[1].trim(),qe=ht[2]);let Ke=qe.match(a3);if(!Ke)return null;let gt=Ke[1],ln=Ke[2]||void 0;return[{sourceId:$,sourceLabel:re,targetId:gt,targetLabel:ln,label:e,direction:f.direction}]}function bK(n){let r=n.match(/^([A-Za-z_]\w*)\[([^\]]*)\]\s*$/);return r?{id:r[1],label:r[2]}:null}var iO=[{label:"implements",expectedDirection:"forward",relationType:"implements",category:"check",description:"Spec is implemented as external artifact (OpenAPI, DDL, etc.)"},{label:"verifiedBy",expectedDirection:"forward",relationType:"verifiedBy",category:"check",description:"Spec is verified by external test code"},{label:"refines",expectedDirection:"forward",relationType:"refines",category:"lint",description:"Decompose higher-level item into lower-level detail"},{label:"relatedTo",expectedDirection:"bidirectional",relationType:"relatedTo",category:"lint",description:"Bidirectional association or consistency constraint"},{label:"uses",expectedDirection:"forward",relationType:"uses",category:"lint",description:"Reference / dependency"},{label:"dependsOn",expectedDirection:"forward",relationType:"dependsOn",category:"lint",description:"Dependency relationship"},{label:"satisfies",expectedDirection:"forward",relationType:"satisfies",category:"lint",description:"Satisfies business/requirements"},{label:"includes",expectedDirection:"forward",relationType:"includes",category:"lint",description:"Parent contains child items"},{label:"traces",expectedDirection:"forward",relationType:"traces",category:"lint",description:"Derive target from source"},{label:"verifies",expectedDirection:"forward",relationType:"verifies",category:"external",description:"Test code tests implementation code (external \u2192 external, no checker)"}],vK=[{label:"generate",expectedDirection:"forward",relationType:void 0,category:"drift",description:"Automated generation (external tool)"},{label:"apply",expectedDirection:"forward",relationType:void 0,category:"external",description:"Apply to external system"},{label:"deploy",expectedDirection:"forward",relationType:void 0,category:"external",description:"Deploy artifact"}],mK=[...iO,...vK],hK=[...mK].sort((n,r)=>r.label.length-n.label.length),gK=[...iO].sort((n,r)=>r.label.length-n.label.length);function l3(n,r=hK){if(!n)return null;let f=n.toLowerCase().trim();for(let h of r)if(f===h.label.toLowerCase())return{entry:h,modifier:void 0};for(let h of r){let l=h.label.toLowerCase();if(f.endsWith(l)){let t=n.slice(0,n.length-h.label.length).trim();return{entry:h,modifier:t||void 0}}}for(let h of r){let l=h.label.toLowerCase();if(f.includes(l)){let t=f.indexOf(l),$=n.slice(0,t).trim(),re=n.slice(t+h.label.length).trim(),e=[$,re].filter(Boolean).join(" ");return{entry:h,modifier:e||void 0}}}return null}var yK=new Set(["test","e2e-test","unit-test","integration-test"]);function wK(n){return n?n.classes.some(r=>yK.has(r)||r.includes("test")):!1}function c3(n,r,f){let h=[],l=[],t=re=>r.get(re)?.classes.includes(f)??!1,$=iO.find(re=>re.label==="relatedTo");for(let re of n){let e=t(re.sourceId)||t(re.targetId),qe=l3(re.rawLabel);if(!qe){e?(h.push({severity:"warning",message:`Edge label "${re.rawLabel}" is not a valid speckeeper RelationType \u2014 falling back to "relatedTo"`,context:`${re.sourceId} \u2192 ${re.targetId}`}),l.push({...re,normalizedLabel:"relatedTo",vocabulary:$,modifier:void 0})):l.push({...re,normalizedLabel:re.rawLabel??"",vocabulary:{label:re.rawLabel??"",expectedDirection:"forward",relationType:void 0,category:"external",description:""},modifier:void 0});continue}if(e&&!qe.entry.relationType&&!l3(re.rawLabel,gK)){h.push({severity:"warning",message:`Edge label "${re.rawLabel}" is not a valid speckeeper RelationType \u2014 falling back to "relatedTo"`,context:`${re.sourceId} \u2192 ${re.targetId}`}),l.push({...re,normalizedLabel:"relatedTo",vocabulary:$,modifier:void 0});continue}if(l.push({...re,normalizedLabel:qe.entry.label,vocabulary:qe.entry,modifier:qe.modifier}),e&&re.direction!==qe.entry.expectedDirection){let ht=qe.entry.expectedDirection==="bidirectional"?"<-->":"-->";h.push({severity:"warning",message:`"${qe.entry.label}" expects ${ht} arrow but got ${re.direction==="bidirectional"?"<-->":"-->"}`,context:`${re.sourceId} \u2192 ${re.targetId}`})}if(qe.entry.label==="implements"&&t(re.sourceId)&&t(re.targetId)&&h.push({severity:"warning",message:'"implements" should be speckeeper \u2192 external; consider using "refines" for speckeeper \u2192 speckeeper edges',context:`${re.sourceId} \u2192 ${re.targetId}`}),qe.entry.label==="verifiedBy"){t(re.sourceId)&&t(re.targetId)&&h.push({severity:"warning",message:'"verifiedBy" should be speckeeper \u2192 external; it represents verification by external test code',context:`${re.sourceId} \u2192 ${re.targetId}`});let ht=r.get(re.targetId);if(ht&&!wK(ht)){let Ke=re.targetId.toUpperCase();["UT","IT","DUT","E2ET"].includes(Ke)||Ke.includes("TEST")||(ht.label??"").toLowerCase().includes("test")||h.push({severity:"warning",message:`"verifiedBy" target "${re.targetId}" does not appear to be a test node; verifiedBy is intended for test targets`,context:`${re.sourceId} \u2192 ${re.targetId}`})}}}return{resolved:l,diagnostics:h}}function f3(n){return n.category==="check"}var CK=[{pattern:/^L0$|business|domain/i,level:"L0"},{pattern:/^L1$|requirement/i,level:"L1"},{pattern:/^L2$|design|architecture/i,level:"L2"},{pattern:/^L3$|implementation|external/i,level:"L3"}];function LK(n){if(!n)return"L0";for(let{pattern:r,level:f}of CK)if(r.test(n))return f;return"L0"}var EK="speckeeper";function Ky(n,r,f){let h=LK(f),l=r?.find(t=>t!==EK);return l?{templateName:"base",defaultLevel:h,defaultIdPrefix:n,modelName:d3(l),fileName:p3(l)}:{templateName:"base",defaultLevel:h,defaultIdPrefix:n,modelName:d3(n),fileName:p3(n)}}function d3(n){return n.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function p3(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function AK(n){return n.length===0?"":`
|
|
321
321
|
// =============================================================================
|
|
322
322
|
// Checker binding
|
|
323
323
|
// =============================================================================
|
|
@@ -331,7 +331,7 @@ ${n.map(f=>{let h=f.targetLabel&&f.targetLabel!==f.targetId?`${f.targetId} (${f.
|
|
|
331
331
|
* \`type\`, \`paths\` and \`relation\` \u2014 so \`speckeeper check\` scans that external
|
|
332
332
|
* SSOT for this model's spec IDs.
|
|
333
333
|
*/
|
|
334
|
-
`}function b3(n){let r=`${n.modelName}Schema`,f=`${n.modelName}Model`,h="import { requireField } from 'speckeeper/dsl';",l=
|
|
334
|
+
`}function b3(n){let r=`${n.modelName}Schema`,f=`${n.modelName}Model`,h="import { requireField } from 'speckeeper/dsl';",l=AK(n.checkerBindings??[]);return`/**
|
|
335
335
|
* ${n.modelName} Model Definition
|
|
336
336
|
*
|
|
337
337
|
* Generated by speckeeper scaffold \u2014 customise as needed.
|
|
@@ -379,7 +379,7 @@ class ${f} extends Model<typeof ${r}> {
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
export { ${f} };
|
|
382
|
-
`}var aO={base:b3};function
|
|
382
|
+
`}var aO={base:b3};function _K(n,r){return n.filter(f=>f3(f.vocabulary)).map(f=>({relation:f.normalizedLabel,targetId:f.targetId,targetLabel:r?.get(f.targetId)?.label}))}function SK(n,r,f,h){let l=Ky(n.id,n.classes,n.subgraph),t=aO[l.templateName],$={modelId:l.fileName,modelName:l.modelName,idPrefix:l.defaultIdPrefix,level:l.defaultLevel,description:n.label??n.id,checkerBindings:_K(f,h)},re=t?t($):aO.base($);return{relativePath:`_models/${l.fileName}.ts`,content:re}}function IK(n,r="ts"){let f=Ky(n.id,n.classes,n.subgraph),h=`${f.modelName}Model`,l=f.modelName,t=v3(f.modelName)+"s",$=f.fileName;if(r==="yaml"){let e=`# ${f.modelName} Specifications
|
|
383
383
|
#
|
|
384
384
|
# Generated by speckeeper scaffold \u2014 add your specs below.
|
|
385
385
|
model: ${f.fileName}
|
|
@@ -403,7 +403,7 @@ const ${t}: ${l}[] = [
|
|
|
403
403
|
export default defineSpecs(
|
|
404
404
|
[${h}.instance, ${t}],
|
|
405
405
|
);
|
|
406
|
-
`;return{relativePath:`${$}.ts`,content:re}}function v3(n){return n.charAt(0).toLowerCase()+n.slice(1)}function
|
|
406
|
+
`;return{relativePath:`${$}.ts`,content:re}}function v3(n){return n.charAt(0).toLowerCase()+n.slice(1)}function TK(n,r="ts"){let f=new Set,h=[];for(let re of n){let e=Ky(re.id,re.classes,re.subgraph),ht=re.classes.some(Ke=>Ke!=="speckeeper")?e.fileName:`base:${re.id}`;f.has(ht)||(f.add(ht),h.push({varName:v3(e.modelName),fileName:e.fileName}))}if(r==="yaml")return{relativePath:"index.ts",content:`/**
|
|
407
407
|
* Design entry point \u2014 generated by speckeeper scaffold
|
|
408
408
|
*
|
|
409
409
|
* YAML spec files in this directory are auto-discovered by loadYamlDir().
|
|
@@ -422,8 +422,8 @@ import { mergeSpecs } from 'speckeeper';
|
|
|
422
422
|
${l}
|
|
423
423
|
|
|
424
424
|
export default mergeSpecs(${t});
|
|
425
|
-
`}}function m3(n,r,f,h="ts"){let l=[],t=new Set,$=new Map;for(let re of n){let e=Ky(re.id,re.classes,re.subgraph),ht=re.classes.some(gt=>gt!=="speckeeper")?e.fileName:`base:${re.id}`,Ke=$.get(ht)??[];Ke.push(re),$.set(ht,Ke)}for(let re of n){let e=Ky(re.id,re.classes,re.subgraph),ht=re.classes.some(bn=>bn!=="speckeeper")?e.fileName:`base:${re.id}`;if(t.has(ht))continue;t.add(ht);let Ke=$.get(ht)??[re],gt=new Set(Ke.map(bn=>bn.id)),ln=r.filter(bn=>gt.has(bn.targetId)),Qn=r.filter(bn=>gt.has(bn.sourceId));l.push(
|
|
426
|
-
`)}}var lO="speckeeper";async function w3(n){if(!n.source)throw new Error("scaffold needs --source");let r=n.format==="yaml"?"yaml":"ts";console.log(Xs.blue("speckeeper scaffold")),console.log("");let f=y3(n.source);if(!uO(f)){console.error(Xs.red(` Error: Source file not found: ${f}`)),process.exitCode=1;return}let h=
|
|
425
|
+
`}}function m3(n,r,f,h="ts"){let l=[],t=new Set,$=new Map;for(let re of n){let e=Ky(re.id,re.classes,re.subgraph),ht=re.classes.some(gt=>gt!=="speckeeper")?e.fileName:`base:${re.id}`,Ke=$.get(ht)??[];Ke.push(re),$.set(ht,Ke)}for(let re of n){let e=Ky(re.id,re.classes,re.subgraph),ht=re.classes.some(bn=>bn!=="speckeeper")?e.fileName:`base:${re.id}`;if(t.has(ht))continue;t.add(ht);let Ke=$.get(ht)??[re],gt=new Set(Ke.map(bn=>bn.id)),ln=r.filter(bn=>gt.has(bn.targetId)),Qn=r.filter(bn=>gt.has(bn.sourceId));l.push(SK(re,ln,Qn,f)),l.push(IK(re,h))}return l.push(TK(n,h)),l}function xK(n){let r=n.match(/export\s*\{([^}]+)\}\s*;?\s*$/m);return r?r[1].split(",").map(f=>f.trim()).filter(Boolean):[]}function h3(n){let r=[];for(let l of n){let t=l.relativePath.replace(/^_models\//,"").replace(/\.ts$/,""),$=xK(l.content);$.length>0&&r.push({fileName:t,classNames:$})}r.sort((l,t)=>l.fileName.localeCompare(t.fileName));let f=[];f.push("/**"),f.push(" * Model index \u2014 generated by speckeeper scaffold"),f.push(" */"),f.push("");for(let l of r)f.push(`export { ${l.classNames.join(", ")} } from './${l.fileName}.js';`);f.push("");let h=r.flatMap(l=>l.classNames.filter(t=>t.endsWith("Model")));if(h.length>0){f.push("import { Model } from 'speckeeper';"),f.push("import type { ZodType } from 'zod';"),f.push("");for(let l of r){let t=l.classNames.filter($=>$.endsWith("Model"));t.length>0&&f.push(`import { ${t.join(", ")} } from './${l.fileName}.js';`)}f.push(""),f.push("// eslint-disable-next-line @typescript-eslint/no-explicit-any"),f.push("export const allModels: Model<ZodType>[] = [");for(let l of h)f.push(` ${l}.instance as Model<ZodType>,`);f.push("];")}return f.push(""),{relativePath:"_models/index.ts",content:f.join(`
|
|
426
|
+
`)}}var lO="speckeeper";async function w3(n){if(!n.source)throw new Error("scaffold needs --source");let r=n.format==="yaml"?"yaml":"ts";console.log(Xs.blue("speckeeper scaffold")),console.log("");let f=y3(n.source);if(!uO(f)){console.error(Xs.red(` Error: Source file not found: ${f}`)),process.exitCode=1;return}let h=kK(f,"utf-8"),l=u3(h);if(!l){console.error(Xs.red(" Error: No mermaid flowchart found in the source file")),process.exitCode=1;return}console.log(Xs.gray(` Parsed: ${l.nodes.size} nodes, ${l.edges.length} edges`));let t=[];for(let Qn of l.nodes.values())Qn.classes.includes(lO)&&t.push(Qn);if(t.length===0){console.error(Xs.red(` Error: No nodes with class "${lO}" found`)),console.log(Xs.gray(" Add `classDef speckeeper ...` and `class NODE1,NODE2 speckeeper` to your flowchart")),process.exitCode=1;return}console.log(Xs.gray(` speckeeper-managed nodes: ${t.map(Qn=>Qn.id).join(", ")}`));let{resolved:$,diagnostics:re}=c3(l.edges,l.nodes,lO);$K(re);let e=n.output?y3(n.output):g3(process.cwd(),"design"),qe=m3(t,$,l.nodes,r),ht=h3(qe),Ke=[...qe,ht];console.log(""),console.log(Xs.cyan(` Files to generate (${Ke.length}):`));for(let Qn of Ke)console.log(Xs.gray(` ${Qn.relativePath}`));if(n.dryRun){console.log(""),console.log(Xs.yellow(" Dry run \u2014 no files written")),console.log("");for(let Qn of Ke)console.log(Xs.cyan(` === ${Qn.relativePath} ===`)),console.log(Qn.content);return}console.log("");let gt=0,ln=0;for(let Qn of Ke){let bn=g3(e,Qn.relativePath),zr=OK(bn);if(uO(zr)||NK(zr,{recursive:!0}),uO(bn)&&!n.force){console.log(Xs.yellow(` Skipped: ${Qn.relativePath} (already exists, use --force to overwrite)`)),ln++;continue}RK(bn,Qn.content),console.log(Xs.green(` Created: ${Qn.relativePath}`)),gt++}console.log(""),console.log(Xs.cyan(` Done: ${gt} created, ${ln} skipped`))}function $K(n){if(n.length!==0){console.log(""),console.log(Xs.cyan(" Diagnostics:"));for(let r of n){let f=r.severity==="error"?Xs.red(" ERROR"):r.severity==="warning"?Xs.yellow(" WARN "):Xs.gray(" INFO "),h=r.context?Xs.gray(` [${r.context}]`):"";console.log(`${f} ${r.message}${h}`)}}}async function cO(n){try{return await nm(n)}catch(r){throw Object.assign(r,{exitCode:Vy})}}function fO(n,r){let f=[];for(let h of n){let l=Vm(r,h.id);for(let t of l){let $=t;f.push({id:$.id,name:$.name,description:$.description,modelType:h.name??h.id,relations:$.relations})}}return f}function Q_(n){let r=[];if(r.push(`### ${n.id} (${n.modelType})`),n.name&&r.push(`Name: ${n.name}`),n.description&&r.push(`Description: ${n.description}`),n.relations&&n.relations.length>0){r.push("Relations:");for(let f of n.relations)r.push(` - ${f.type} \u2192 ${f.target}`)}return r.join(`
|
|
427
427
|
`)}function C3(n,r){let f=[];for(let h of n){let l=Vm(r,h.id);if(l.length!==0)try{let t=h.lintAll(l);for(let $ of t)f.push({rule:$.ruleId,severity:$.severity,message:$.message,specId:$.specId,modelType:h.name})}catch{}}return f}async function L3(n){let r=await cO(n),f=r.models||[],h=r.specs,l=fO(f,h),t=C3(f,h),$=[];if($.push("# Requirement Quality Audit Request"),$.push(`## Project Configuration
|
|
428
428
|
|
|
429
429
|
- Design directory: ${r.designDir||"design"}
|
|
@@ -457,30 +457,30 @@ ${n}
|
|
|
457
457
|
`);for(let ln of gt)qe.push(Q_(ln))}}let ht=r?$.filter(Ke=>Ke.specId&&r.includes(Ke.specId)):$;if(ht.length>0){qe.push(`## Lint Issues (relevant)
|
|
458
458
|
`);for(let Ke of ht)qe.push(`- [${Ke.severity}] [${Ke.specId}] ${Ke.message}`)}return qe.join(`
|
|
459
459
|
|
|
460
|
-
`)}import{writeFile as
|
|
460
|
+
`)}import{writeFile as DK}from"node:fs/promises";function Rh(n,r){if(n.status!=="success"||!n.data)return 1;let f=r.failOn??"error",h=["info","warning","error","critical"],l=h.findIndex($=>$===f);return(n.data.findings??[]).some($=>h.indexOf($.severity)>=l)?10:0}function S3(n){if(n.status!=="success"||!n.data)return n.errorMessage??`Task failed with status: ${n.status}`;let r=n.data,f=[],h=r.findings??[];if(f.push(`Risk Level: ${r.riskLevel.toUpperCase()}`),f.push(`Summary: ${r.summary}`),f.push(""),"explanation"in r&&(f.push(r.explanation),f.push("")),h.length>0){f.push(`Findings (${h.length}):`),f.push("");for(let l of h){let t=UK(l.severity);f.push(` ${t} [${l.category}] ${l.message}`),"location"in l&&l.location&&f.push(` Location: ${l.location}`),"recommendation"in l&&l.recommendation&&f.push(` Recommendation: ${l.recommendation}`),f.push("")}}if(r.recommendedActions&&r.recommendedActions.length>0){f.push("Recommended Actions:");for(let l of r.recommendedActions)f.push(` - [${l.kind}] ${l.title}`),"command"in l&&l.command&&f.push(` $ ${l.command}`)}return f.join(`
|
|
461
461
|
`)}function I3(n){return n.data?JSON.stringify(n.data,null,2):JSON.stringify({error:n.errorMessage,status:n.status},null,2)}function T3(n){return n.data?dO(n.data):`error: ${JSON.stringify(n.errorMessage)}
|
|
462
|
-
status: ${n.status}`}function Nh(n,r){return r==="json"?I3(n):r==="yaml"?T3(n):S3(n)}async function Oh(n,r){r?await
|
|
462
|
+
status: ${n.status}`}function Nh(n,r){return r==="json"?I3(n):r==="yaml"?T3(n):S3(n)}async function Oh(n,r){r?await DK(r,n+`
|
|
463
463
|
`,"utf-8"):process.stdout.write(n+`
|
|
464
|
-
`)}function
|
|
464
|
+
`)}function UK(n){switch(n){case"critical":return"\u2716";case"error":return"\u2716";case"warning":return"\u26A0";case"info":return"\u2139"}}function PK(n,r=2){let f=" ".repeat(r);return n.split(`
|
|
465
465
|
`).map(h=>f+h).join(`
|
|
466
466
|
`)}function dO(n,r=0){let f=" ".repeat(r);if(n==null)return`${f}null`;if(typeof n=="string")return n.includes(`
|
|
467
467
|
`)?`|
|
|
468
|
-
${
|
|
468
|
+
${PK(n,(r+1)*2)}`:JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return n.length===0?"[]":n.map(h=>{let l=dO(h,r+1);return typeof h=="object"&&h!==null?`${f}- ${l.trimStart()}`:`${f}- ${l}`}).join(`
|
|
469
469
|
`);if(typeof n=="object"){let h=Object.entries(n);return h.length===0?"{}":h.map(([l,t])=>{let $=dO(t,r+1);return typeof t=="object"&&t!==null&&!Array.isArray(t)?`${f}${l}:
|
|
470
470
|
${$}`:Array.isArray(t)&&t.length>0?`${f}${l}:
|
|
471
471
|
${$}`:`${f}${l}: ${$}`}).join(`
|
|
472
|
-
`)}return String(n)}async function x3(n){let r=await L3(n.config);if(n.showPrompt)return r;let f={adapter:n.adapter,model:n.model},h={failOn:n.failOn,logFile:n.logFile};try{let l=await Ih(r,"audit-requirement-quality",f,h),t=Nh(l,n.reportFormat??"json");await Oh(t,n.output);let $=Rh(l,h);process.exitCode=$}catch(l){let t=l.exitCode;if(t===Rm){console.error(Xs.red(l.message)),process.exitCode=Rm;return}if(t===Xv){console.error(Xs.red(l.message)),process.exitCode=Xv;return}throw l}}async function k3(n){let r=await E3(n.config);if(n.showPrompt)return r;let f={adapter:n.adapter,model:n.model},h={failOn:n.failOn,logFile:n.logFile};try{let l=await Ih(r,"propose-trace-links",f,h),t=Nh(l,n.reportFormat??"json");await Oh(t,n.output);let $=Rh(l,h);process.exitCode=$}catch(l){let t=l.exitCode;if(t===Rm){console.error(Xs.red(l.message)),process.exitCode=Rm;return}if(t===Xv){console.error(Xs.red(l.message)),process.exitCode=Xv;return}throw l}}async function R3(n){let r=await
|
|
472
|
+
`)}return String(n)}async function x3(n){let r=await L3(n.config);if(n.showPrompt)return r;let f={adapter:n.adapter,model:n.model},h={failOn:n.failOn,logFile:n.logFile};try{let l=await Ih(r,"audit-requirement-quality",f,h),t=Nh(l,n.reportFormat??"json");await Oh(t,n.output);let $=Rh(l,h);process.exitCode=$}catch(l){let t=l.exitCode;if(t===Rm){console.error(Xs.red(l.message)),process.exitCode=Rm;return}if(t===Xv){console.error(Xs.red(l.message)),process.exitCode=Xv;return}throw l}}async function k3(n){let r=await E3(n.config);if(n.showPrompt)return r;let f={adapter:n.adapter,model:n.model},h={failOn:n.failOn,logFile:n.logFile};try{let l=await Ih(r,"propose-trace-links",f,h),t=Nh(l,n.reportFormat??"json");await Oh(t,n.output);let $=Rh(l,h);process.exitCode=$}catch(l){let t=l.exitCode;if(t===Rm){console.error(Xs.red(l.message)),process.exitCode=Rm;return}if(t===Xv){console.error(Xs.red(l.message)),process.exitCode=Xv;return}throw l}}async function R3(n){let r=await MK();if(!r.trim()){console.error(Xs.red("Error: No input received on stdin.")),console.error("Usage: speckeeper impact FR-001 --format json | speckeeper explain-impact"),process.exitCode=Vy;return}let f=A3(r);if(n.showPrompt)return f;let h={adapter:n.adapter,model:n.model},l={failOn:n.failOn,logFile:n.logFile};try{let t=await Ih(f,"explain-impact-result",h,l),$=Nh(t,n.reportFormat??"json");await Oh($,n.output);let re=Rh(t,l);process.exitCode=re}catch(t){let $=t.exitCode;if($===Rm){console.error(Xs.red(t.message)),process.exitCode=Rm;return}if($===Xv){console.error(Xs.red(t.message)),process.exitCode=Xv;return}throw t}}function MK(){return new Promise((n,r)=>{let f=[];process.stdin.on("data",h=>f.push(h)),process.stdin.on("end",()=>n(Buffer.concat(f).toString("utf-8"))),process.stdin.on("error",r),process.stdin.isTTY&&n("")})}async function N3(n,r){let f=n.length>0?n:void 0,h=await _3(r.config,f);if(r.showPrompt)return h;let l={adapter:r.adapter,model:r.model},t={failOn:r.failOn,logFile:r.logFile};try{let $=await Ih(h,"propose-acceptance-criteria",l,t),re=Nh($,r.reportFormat??"json");await Oh(re,r.output);let e=Rh($,t);process.exitCode=e}catch($){let re=$.exitCode;if(re===Rm){console.error(Xs.red($.message)),process.exitCode=Rm;return}if(re===Xv){console.error(Xs.red($.message)),process.exitCode=Xv;return}throw $}}var tS=nh(ih(),1);import{execFileSync as O3}from"node:child_process";import{existsSync as pO,mkdirSync as jK,readFileSync as FK,rmSync as zK,writeFileSync as $3}from"node:fs";import{join as eS,relative as GK,resolve as bO}from"node:path";var BK=13,qK=600,VK=14,HK=()=>({env:process.env,cwd:process.cwd(),loadRuntime:zC}),D3=["claude","openai","gemini","mock"];async function P3(n,r=HK()){try{return await YK(n,r)}catch(f){let h=f.exitCode;return console.error(Xs.red(f instanceof Error?f.message:String(f))),h??1}}async function YK(n,r){let f=await vO(n.config,r.cwd),{setup:h,registry:l}=f,t=WK(n.adapter??h.config.adapter??"claude"),$=n.format==="json",re=h.gate.judgeChange==="ignore"?void 0:await r.loadRuntime(),e=await Hy(h,l,re?cs=>HC(re,t,n.model,cs,r.env):void 0);if(n.prune)return KK(e,h,n.dryRun??!1,$);let qe=F3(e,n.check,n.target);if(n.showPacket||n.showPrompt)return process.stdout.write(qe.map(cs=>cs.packet.text).join(`
|
|
473
473
|
---
|
|
474
474
|
|
|
475
|
-
`)),0;let ht=vj(qe.filter(cs=>n.force||cs.state!=="fresh")),Ke=n.maxTargets!==void 0?Number(n.maxTargets):void 0,gt=Ke!==void 0?ht.slice(0,Ke):ht;if(n.emit)return
|
|
476
|
-
`)),Er.adapterError!==void 0?Xv:Er.failed.length>0?1:0}async function M3(n,r,f={cwd:process.cwd()}){try{let{setup:h,registry:l}=await vO(r.config,f.cwd),t=await Hy(h,l),$=new Map(t.targets.map(Ke=>[`${Ke.check.id}/${Ke.target.id}`,Ke])),re=ks.object({packetHash:ks.string(),output:ks.unknown()}).strict(),e=0,qe=[],ht=bO(f.cwd,n);if(!pO(ht))throw new Vv(`review ingest: ${ht} does not exist`);for(let{check:Ke,target:gt,path:ln}of j_(ht,".result.yaml")){let Qn=$.get(`${Ke}/${gt}`);if(!Qn){qe.push(`${ln}: check "${Ke}" has no target "${gt}"`);continue}let bn=re.safeParse((0,tS.parse)(
|
|
477
|
-
`)),0}function
|
|
478
|
-
`)),0}function
|
|
475
|
+
`)),0;let ht=vj(qe.filter(cs=>n.force||cs.state!=="fresh")),Ke=n.maxTargets!==void 0?Number(n.maxTargets):void 0,gt=Ke!==void 0?ht.slice(0,Ke):ht;if(n.emit)return JK(gt,n.emit,r.cwd,$);if(n.dryRun)return XK(qe,gt,e.targets,n.force??!1,$);if(gt.length===0)return WC($,{judged:[],failed:[]}," \u2713 Every selected target has a current record"),0;let ln=Cj(t,r.env);if(ln==="unavailable")return U3(`no credentials for the ${t} adapter in this environment`,n.requireJudge??!1);if(ln==="api-key"&&h.config.allowApiKey===!1&&!n.allowApiKey)return console.error(Xs.red(`review: the ${t} adapter would use an API key, and review.allowApiKey is false. Unset the key, or pass --allow-api-key for this run.`)),BK;let Qn=h.config.claudeExecutable!==void 0?bO(r.cwd,h.config.claudeExecutable):void 0,bn=Ij(t,Qn,r.host??Sj());if(bn)return console.error(Xs.red(`review: ${bn}`)),Xv;let zr=re??await r.loadRuntime(),tr={runtime:zr,createAdapter:r.createAdapter??zr.createAdapter,adapter:t,model:n.model,credentials:ln,timeoutMs:(h.config.timeoutSeconds??qK)*1e3,...Qn?{claudeExecutable:Qn}:{}};if(ln!=="none"){let cs=await _j(tr);if(!cs.ok)return cs.kind==="authentication"?U3(cs.message,n.requireJudge??!1):(console.error(Xs.red(`review: the judge could not be reached before judging: ${cs.message}`)),Xv)}console.error(Xs.gray(` Judging ${gt.length} target(s) with ${t} (${ln})...`));let Er=await Lj(gt,{...tr,concurrency:Number(n.concurrency??2),registry:l,env:r.env,now:r.now});return WC($,{judged:Er.written.map(cs=>({check:cs.check.id,target:cs.target.id})),failed:Er.failed.map(cs=>({check:cs.target.check.id,target:cs.target.target.id,reason:cs.reason})),...Er.adapterError!==void 0?{adapterError:Er.adapterError}:{}},[` \u2713 Recorded ${Er.written.length} judgment(s)`,...Er.failed.map(cs=>Xs.red(` \u2717 ${cs.target.check.id} / ${cs.target.target.id}: ${cs.reason}`)),...Er.adapterError!==void 0?[Xs.red(` \u2717 Stopped after an adapter error: ${Er.adapterError}`),Xs.gray(" Records written so far are kept; run again to judge the rest.")]:[]].join(`
|
|
476
|
+
`)),Er.adapterError!==void 0?Xv:Er.failed.length>0?1:0}async function M3(n,r,f={cwd:process.cwd()}){try{let{setup:h,registry:l}=await vO(r.config,f.cwd),t=await Hy(h,l),$=new Map(t.targets.map(Ke=>[`${Ke.check.id}/${Ke.target.id}`,Ke])),re=ks.object({packetHash:ks.string(),output:ks.unknown()}).strict(),e=0,qe=[],ht=bO(f.cwd,n);if(!pO(ht))throw new Vv(`review ingest: ${ht} does not exist`);for(let{check:Ke,target:gt,path:ln}of j_(ht,".result.yaml")){let Qn=$.get(`${Ke}/${gt}`);if(!Qn){qe.push(`${ln}: check "${Ke}" has no target "${gt}"`);continue}let bn=re.safeParse((0,tS.parse)(FK(ln,"utf-8")));if(!bn.success){qe.push(`${ln}: ${ks.prettifyError(bn.error)}`);continue}if(bn.data.packetHash!==Qn.packet.hash){qe.push(`${ln}: answers packet ${bn.data.packetHash}, the current packet is ${Qn.packet.hash}`);continue}let zr=U_(Qn.check,{specs:l.specs,contextBody:Qn.packet.contextBody}).safeParse(bn.data.output);if(!zr.success){qe.push(`${ln}: ${ks.prettifyError(zr.error)}`);continue}let tr=KN(Qn.check,gt,zr.data),Er=(f.now?.()??new Date).toISOString();qC(Qn.recordFile,JN(Qn,zr.data,tr,{adapter:"manual"},Er)),e++}console.log(` \u2713 Recorded ${e} result(s)`);for(let Ke of qe)console.log(Xs.red(` \u2717 ${Ke}`));return qe.length>0?1:0}catch(h){return console.error(Xs.red(h instanceof Error?h.message:String(h))),h.exitCode??1}}async function j3(n,r={cwd:process.cwd()}){try{if(!n.reason?.trim())throw new Vv("review rebaseline needs --reason");let{setup:f,registry:h,designDir:l,configFile:t}=await vO(n.config,r.cwd),$=await Hy(f,h),re=F3($,n.check,n.target),e=re.filter(ht=>ht.record!==void 0&&WN(ht.record,ht.packet.hash,void 0,"ignore").state==="stale"),qe=re.filter(ht=>ht.record===void 0).length;if(n.dryRun)for(let ht of e){console.log(` ${ht.check.id} / ${ht.target.id}`);for(let Ke of G_(ht.record,ht.packet))console.log(Xs.gray(` ${Ke.input}`))}else if(e.length>0){let ht=(r.now?.()??new Date).toISOString(),Ke=rJ(r.cwd,[l,...t?[t]:[],...new Set(e.flatMap(nJ))]);for(let gt of e)qC(gt.recordFile,{...gt.record,packetHash:gt.packet.hash,inputs:gt.packet.inputs,inputHashes:gt.packet.inputHashes,rebaselined:[...gt.record.rebaselined??[],{from:gt.record.packetHash,to:gt.packet.hash,changedInputs:G_(gt.record,gt.packet),reason:n.reason.trim(),at:ht,...Ke}]})}return console.log(` ${n.dryRun?"Would rebaseline":"Rebaselined"} ${e.length} record(s)`),qe>0&&console.log(Xs.gray(` ${qe} target(s) have no record to rebaseline; judge them with "speckeeper review"`)),0}catch(f){return console.error(Xs.red(f instanceof Error?f.message:String(f))),f.exitCode??1}}async function vO(n,r){let f=await nm(n,r),h=z_(f.review,f.models??[],r);if(!h)throw new Vv("No review checks are declared (config review.checks or a model's reviewChecks)");let l=n??t1(r)??void 0;return{setup:h,registry:H_(f.specs),designDir:f.designDir??"design",...l?{configFile:l}:{}}}function WK(n){let r=D3.find(f=>f===n);if(!r)throw new Vv(`Unknown adapter "${n}". Available: ${D3.join(", ")}`);return r}function F3(n,r,f){let h=new Set(n.targets.map($=>$.check.id));for(let $ of r??[])if(!h.has($))throw new Vv(`--check ${$}: no such review check`);let l=n.targets.filter($=>!r||r.includes($.check.id)),t=new Set(l.map($=>$.target.id));for(let $ of f??[])if(!t.has($))throw new Vv(`--target ${$}: no selected check judges this target`);return l.filter($=>!f||f.includes($.target.id))}function U3(n,r){return r?(console.error(Xs.red(`review: ${n}, and --require-judge was given`)),VK):(console.error(Xs.yellow(`review skipped: ${ZK(n)} Records were not touched.`)),0)}function ZK(n){return`${n.replace(/\.+$/,"")}.`}function WC(n,r,f){console.log(n?JSON.stringify(r,null,2):f)}function KK(n,r,f,h){let l=n.orphans.map(t=>GK(r.rootDir,t.path));if(!f)for(let t of n.orphans)zK(t.path);return WC(h,{[f?"wouldRemove":"removed"]:l},[` ${f?"Would remove":"Removed"} ${l.length} record(s)`,...l.map(t=>Xs.gray(` ${t}`))].join(`
|
|
477
|
+
`)),0}function JK(n,r,f,h){let l=bO(f,r),t=n.map($=>{let re=`${$.check.id}/${$.target.id}.packet.md`,e=`${$.check.id}/${$.target.id}.result.yaml`;return jK(eS(l,$.check.id),{recursive:!0}),$3(eS(l,re),$.packet.text,"utf-8"),{check:$.check.id,target:$.target.id,packetHash:$.packet.hash,packet:re,result:e}});return $3(eS(l,"index.yaml"),(0,tS.stringify)({resultFormat:"Write each result to its `result` path as YAML: `packetHash` (copied from this index) and `output` (the JSON object the packet asks for). Then run `speckeeper review ingest <dir>`.",packets:t},{lineWidth:0}),"utf-8"),WC(h,{emitted:t},` Wrote ${t.length} packet(s) to ${r}/ (see ${r}/index.yaml)`),0}function XK(n,r,f,h,l){let t=new Set(r),$=Ke=>Ke.record?Ke.state==="fresh"?["forced"]:B_(Ke.record,Ke.packet,!0):["no record"],re=QK(r,f),e=re.approximated>0?` (${re.approximated} target(s) of a check with no recorded usage are estimated from the packet text; the actual usage can differ widely)`:"",qe=r.map(Ke=>({check:Ke.check.id,target:Ke.target.id,reasons:$(Ke)})),ht=n.filter(Ke=>!t.has(Ke)).map(Ke=>({check:Ke.check.id,target:Ke.target.id,reasons:[Ke.state==="fresh"&&!h?"current":"beyond --max-targets"]}));return WC(l,{run:qe,skip:ht,estimatedTokens:re.tokens,approximatedTargets:re.approximated},[` Would judge ${qe.length} target(s), \u2248 ${re.tokens} tokens${e}:`,...qe.map(Ke=>` ${Ke.check} / ${Ke.target}: ${Ke.reasons.join("; ")}`),` Would skip ${ht.length} target(s):`,...ht.map(Ke=>Xs.gray(` ${Ke.check} / ${Ke.target}: ${Ke.reasons.join("; ")}`))].join(`
|
|
478
|
+
`)),0}function QK(n,r){let f=new Map;for(let t of new Set(n.map($=>$.check.id))){let $=r.filter(re=>re.check.id===t).flatMap(re=>re.record?.usage?[eJ(re.record.usage)]:[]);$.length>0&&f.set(t,$.reduce((re,e)=>re+e,0)/$.length)}let h=0,l=0;for(let t of n){let $=f.get(t.check.id);$===void 0&&l++,h+=$??tJ(t.packet.text)}return{tokens:Math.round(h),approximated:l}}function eJ(n){return n.inputTokens+n.outputTokens+(n.cacheReadTokens??0)+(n.cacheCreationTokens??0)}function tJ(n){let r=0,f=0;for(let h of n)h.charCodeAt(0)<128?r++:f++;return r/4+f}function nJ(n){return[...[n.check.check.prompt,n.check.check.verify?.prompt].flatMap(f=>f!==void 0&&typeof f!="string"?[f.file]:[]),...Object.keys(n.packet.inputHashes.files)]}function rJ(n,r){try{let f=O3("git",["rev-parse","HEAD"],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim(),h=r.filter(t=>pO(eS(n,t))||pO(t)),l=h.length>0?O3("git",["status","--porcelain","--",...h],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}):"";return{gitHead:f,gitDirty:l.trim()!==""}}catch{return{gitHead:null,gitDirty:null}}}var z3=`# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json
|
|
479
479
|
cli_contracts: 0.1.0
|
|
480
480
|
|
|
481
481
|
info:
|
|
482
482
|
title: speckeeper CLI
|
|
483
|
-
version: 0.19.
|
|
483
|
+
version: 0.19.1
|
|
484
484
|
description: >-
|
|
485
485
|
TypeScript-first specification validation framework \u2014 validate design
|
|
486
486
|
consistency, external SSOT integrity, and traceability with type-safe
|
|
@@ -2128,7 +2128,7 @@ components:
|
|
|
2128
2128
|
"cli_contracts": "0.1.0",
|
|
2129
2129
|
"info": {
|
|
2130
2130
|
"title": "speckeeper CLI",
|
|
2131
|
-
"version": "0.19.
|
|
2131
|
+
"version": "0.19.1",
|
|
2132
2132
|
"description": "TypeScript-first specification validation framework \u2014 validate design consistency, external SSOT integrity, and traceability with type-safe TypeScript DSL. Supports design lint, external source checks (OpenAPI, DDL, annotations), drift detection, impact analysis, and scaffolding from Mermaid flowcharts.",
|
|
2133
2133
|
"license": {
|
|
2134
2134
|
"name": "MIT"
|
|
@@ -4370,19 +4370,19 @@ components:
|
|
|
4370
4370
|
}
|
|
4371
4371
|
}
|
|
4372
4372
|
}
|
|
4373
|
-
}`;var cg=class extends Error{constructor(r,f,h){super(h),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=f,this.exitCode=r,this.nestedError=void 0}},Fg=class extends cg{constructor(r){super(1,"commander.invalidArgument",r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var ZC=class{constructor(r,f){switch(this.description=f||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,r[0]){case"<":this.required=!0,this._name=r.slice(1,-1);break;case"[":this.required=!1,this._name=r.slice(1,-1);break;default:this.required=!0,this._name=r;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(r,f){return f===this.defaultValue||!Array.isArray(f)?[r]:(f.push(r),f)}default(r,f){return this.defaultValue=r,this.defaultValueDescription=f,this}argParser(r){return this.parseArg=r,this}choices(r){return this.argChoices=r.slice(),this.parseArg=(f,h)=>{if(!this.argChoices.includes(f))throw new Fg(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(f,h):f},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function rS(n){let r=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+r+">":"["+r+"]"}import{EventEmitter as
|
|
4374
|
-
`)}displayWidth(r){return
|
|
4373
|
+
}`;var cg=class extends Error{constructor(r,f,h){super(h),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=f,this.exitCode=r,this.nestedError=void 0}},Fg=class extends cg{constructor(r){super(1,"commander.invalidArgument",r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var ZC=class{constructor(r,f){switch(this.description=f||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,r[0]){case"<":this.required=!0,this._name=r.slice(1,-1);break;case"[":this.required=!1,this._name=r.slice(1,-1);break;default:this.required=!0,this._name=r;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(r,f){return f===this.defaultValue||!Array.isArray(f)?[r]:(f.push(r),f)}default(r,f){return this.defaultValue=r,this.defaultValueDescription=f,this}argParser(r){return this.parseArg=r,this}choices(r){return this.argChoices=r.slice(),this.parseArg=(f,h)=>{if(!this.argChoices.includes(f))throw new Fg(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(f,h):f},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function rS(n){let r=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+r+">":"["+r+"]"}import{EventEmitter as aJ}from"node:events";import hO from"node:child_process";import $h from"node:path";import oS from"node:fs";import Ab from"node:process";import{stripVTControlCharacters as uJ}from"node:util";import{stripVTControlCharacters as sJ}from"node:util";var KC=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(r){this.helpWidth=this.helpWidth??r.helpWidth??80}visibleCommands(r){let f=r.commands.filter(l=>!l._hidden),h=r._getHelpCommand();return h&&!h._hidden&&f.push(h),this.sortSubcommands&&f.sort((l,t)=>l.name().localeCompare(t.name())),f}compareOptions(r,f){let h=l=>l.short?l.short.replace(/^-/,""):l.long.replace(/^--/,"");return h(r).localeCompare(h(f))}visibleOptions(r){let f=r.options.filter(l=>!l.hidden),h=r._getHelpOption();if(h&&!h.hidden){let l=h.short&&r._findOption(h.short),t=h.long&&r._findOption(h.long);!l&&!t?f.push(h):h.long&&!t?f.push(r.createOption(h.long,h.description)):h.short&&!l&&f.push(r.createOption(h.short,h.description))}return this.sortOptions&&f.sort(this.compareOptions),f}visibleGlobalOptions(r){if(!this.showGlobalOptions)return[];let f=[];for(let h=r.parent;h;h=h.parent){let l=h.options.filter(t=>!t.hidden);f.push(...l)}return this.sortOptions&&f.sort(this.compareOptions),f}visibleArguments(r){return r._argsDescription&&r.registeredArguments.forEach(f=>{f.description=f.description||r._argsDescription[f.name()]||""}),r.registeredArguments.find(f=>f.description)?r.registeredArguments:[]}subcommandTerm(r){let f=r.registeredArguments.map(h=>rS(h)).join(" ");return r._name+(r._aliases[0]?"|"+r._aliases[0]:"")+(r.options.length?" [options]":"")+(f?" "+f:"")}optionTerm(r){return r.flags}argumentTerm(r){return r.name()}longestSubcommandTermLength(r,f){return f.visibleCommands(r).reduce((h,l)=>Math.max(h,this.displayWidth(f.styleSubcommandTerm(f.subcommandTerm(l)))),0)}longestOptionTermLength(r,f){return f.visibleOptions(r).reduce((h,l)=>Math.max(h,this.displayWidth(f.styleOptionTerm(f.optionTerm(l)))),0)}longestGlobalOptionTermLength(r,f){return f.visibleGlobalOptions(r).reduce((h,l)=>Math.max(h,this.displayWidth(f.styleOptionTerm(f.optionTerm(l)))),0)}longestArgumentTermLength(r,f){return f.visibleArguments(r).reduce((h,l)=>Math.max(h,this.displayWidth(f.styleArgumentTerm(f.argumentTerm(l)))),0)}commandUsage(r){let f=r._name;r._aliases[0]&&(f=f+"|"+r._aliases[0]);let h="";for(let l=r.parent;l;l=l.parent)h=l.name()+" "+h;return h+f+" "+r.usage()}commandDescription(r){return r.description()}subcommandDescription(r){return r.summary()||r.description()}optionDescription(r){let f=[];if(r.argChoices&&f.push(`choices: ${r.argChoices.map(h=>JSON.stringify(h)).join(", ")}`),r.defaultValue!==void 0&&(r.required||r.optional||r.isBoolean()&&typeof r.defaultValue=="boolean")&&f.push(`default: ${r.defaultValueDescription||JSON.stringify(r.defaultValue)}`),r.presetArg!==void 0&&r.optional&&f.push(`preset: ${JSON.stringify(r.presetArg)}`),r.envVar!==void 0&&f.push(`env: ${r.envVar}`),f.length>0){let h=`(${f.join(", ")})`;return r.description?`${r.description} ${h}`:h}return r.description}argumentDescription(r){let f=[];if(r.argChoices&&f.push(`choices: ${r.argChoices.map(h=>JSON.stringify(h)).join(", ")}`),r.defaultValue!==void 0&&f.push(`default: ${r.defaultValueDescription||JSON.stringify(r.defaultValue)}`),f.length>0){let h=`(${f.join(", ")})`;return r.description?`${r.description} ${h}`:h}return r.description}formatItemList(r,f,h){return f.length===0?[]:[h.styleTitle(r),...f,""]}groupItems(r,f,h){let l=new Map;return r.forEach(t=>{let $=h(t);l.has($)||l.set($,[])}),f.forEach(t=>{let $=h(t);l.has($)||l.set($,[]),l.get($).push(t)}),l}formatHelp(r,f){let h=f.padWidth(r,f),l=f.helpWidth??80;function t(Ke,gt){return f.formatItem(Ke,h,gt,f)}let $=[`${f.styleTitle("Usage:")} ${f.styleUsage(f.commandUsage(r))}`,""],re=f.commandDescription(r);re.length>0&&($=$.concat([f.boxWrap(f.styleCommandDescription(re),l),""]));let e=f.visibleArguments(r).map(Ke=>t(f.styleArgumentTerm(f.argumentTerm(Ke)),f.styleArgumentDescription(f.argumentDescription(Ke))));if($=$.concat(this.formatItemList("Arguments:",e,f)),this.groupItems(r.options,f.visibleOptions(r),Ke=>Ke.helpGroupHeading??"Options:").forEach((Ke,gt)=>{let ln=Ke.map(Qn=>t(f.styleOptionTerm(f.optionTerm(Qn)),f.styleOptionDescription(f.optionDescription(Qn))));$=$.concat(this.formatItemList(gt,ln,f))}),f.showGlobalOptions){let Ke=f.visibleGlobalOptions(r).map(gt=>t(f.styleOptionTerm(f.optionTerm(gt)),f.styleOptionDescription(f.optionDescription(gt))));$=$.concat(this.formatItemList("Global Options:",Ke,f))}return this.groupItems(r.commands,f.visibleCommands(r),Ke=>Ke.helpGroup()||"Commands:").forEach((Ke,gt)=>{let ln=Ke.map(Qn=>t(f.styleSubcommandTerm(f.subcommandTerm(Qn)),f.styleSubcommandDescription(f.subcommandDescription(Qn))));$=$.concat(this.formatItemList(gt,ln,f))}),$.join(`
|
|
4374
|
+
`)}displayWidth(r){return sJ(r).length}styleTitle(r){return r}styleUsage(r){return r.split(" ").map(f=>f==="[options]"?this.styleOptionText(f):f==="[command]"?this.styleSubcommandText(f):f[0]==="["||f[0]==="<"?this.styleArgumentText(f):this.styleCommandText(f)).join(" ")}styleCommandDescription(r){return this.styleDescriptionText(r)}styleOptionDescription(r){return this.styleDescriptionText(r)}styleSubcommandDescription(r){return this.styleDescriptionText(r)}styleArgumentDescription(r){return this.styleDescriptionText(r)}styleDescriptionText(r){return r}styleOptionTerm(r){return this.styleOptionText(r)}styleSubcommandTerm(r){return r.split(" ").map(f=>f==="[options]"?this.styleOptionText(f):f[0]==="["||f[0]==="<"?this.styleArgumentText(f):this.styleSubcommandText(f)).join(" ")}styleArgumentTerm(r){return this.styleArgumentText(r)}styleOptionText(r){return r}styleArgumentText(r){return r}styleSubcommandText(r){return r}styleCommandText(r){return r}padWidth(r,f){return Math.max(f.longestOptionTermLength(r,f),f.longestGlobalOptionTermLength(r,f),f.longestSubcommandTermLength(r,f),f.longestArgumentTermLength(r,f))}preformatted(r){return/\n[^\S\r\n]/.test(r)}formatItem(r,f,h,l){let $=" ".repeat(2);if(!h)return $+r;let re=r.padEnd(f+r.length-l.displayWidth(r)),e=2,ht=(this.helpWidth??80)-f-e-2,Ke;return ht<this.minWidthToWrap||l.preformatted(h)?Ke=h:Ke=l.boxWrap(h,ht).replace(/\n/g,`
|
|
4375
4375
|
`+" ".repeat(f+e)),$+re+" ".repeat(e)+Ke.replace(/\n/g,`
|
|
4376
4376
|
${$}`)}boxWrap(r,f){if(f<this.minWidthToWrap)return r;let h=r.split(/\r\n|\n/),l=/[\s]*[^\s]+/g,t=[];return h.forEach($=>{let re=$.match(l);if(re===null){t.push("");return}let e=[re.shift()],qe=this.displayWidth(e[0]);re.forEach(ht=>{let Ke=this.displayWidth(ht);if(qe+Ke<=f){e.push(ht),qe+=Ke;return}t.push(e.join(""));let gt=ht.trimStart();e=[gt],qe=this.displayWidth(gt)}),t.push(e.join(""))}),t.join(`
|
|
4377
|
-
`)}};var Jy=class{constructor(r,f){this.flags=r,this.description=f||"",this.required=r.includes("<"),this.optional=r.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(r),this.mandatory=!1;let h=
|
|
4377
|
+
`)}};var Jy=class{constructor(r,f){this.flags=r,this.description=f||"",this.required=r.includes("<"),this.optional=r.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(r),this.mandatory=!1;let h=oJ(r);this.short=h.shortFlag,this.long=h.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(r,f){return this.defaultValue=r,this.defaultValueDescription=f,this}preset(r){return this.presetArg=r,this}conflicts(r){return this.conflictsWith=this.conflictsWith.concat(r),this}implies(r){let f=r;return typeof r=="string"&&(f={[r]:!0}),this.implied=Object.assign(this.implied||{},f),this}env(r){return this.envVar=r,this}argParser(r){return this.parseArg=r,this}makeOptionMandatory(r=!0){return this.mandatory=!!r,this}hideHelp(r=!0){return this.hidden=!!r,this}_collectValue(r,f){return f===this.defaultValue||!Array.isArray(f)?[r]:(f.push(r),f)}choices(r){return this.argChoices=r.slice(),this.parseArg=(f,h)=>{if(!this.argChoices.includes(f))throw new Fg(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(f,h):f},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?G3(this.name().replace(/^no-/,"")):G3(this.name())}helpGroup(r){return this.helpGroupHeading=r,this}is(r){return this.short===r||this.long===r}isBoolean(){return!this.required&&!this.optional&&!this.negate}},sS=class{constructor(r){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,r.forEach(f=>{f.negate?this.negativeOptions.set(f.attributeName(),f):this.positiveOptions.set(f.attributeName(),f)}),this.negativeOptions.forEach((f,h)=>{this.positiveOptions.has(h)&&this.dualOptions.add(h)})}valueFromOption(r,f){let h=f.attributeName();if(!this.dualOptions.has(h))return!0;let l=this.negativeOptions.get(h).presetArg,t=l!==void 0?l:!1;return f.negate===(t===r)}};function G3(n){return n.split("-").reduce((r,f)=>r+f[0].toUpperCase()+f.slice(1))}function oJ(n){let r,f,h=/^-[^-]$/,l=/^--[^-]/,t=n.split(/[ |,]+/).concat("guard");if(h.test(t[0])&&(r=t.shift()),l.test(t[0])&&(f=t.shift()),!r&&h.test(t[0])&&(r=t.shift()),!r&&l.test(t[0])&&(r=f,f=t.shift()),t[0].startsWith("-")){let $=t[0],re=`option creation failed due to '${$}' in option flags '${n}'`;throw/^-[^-][^-]/.test($)?new Error(`${re}
|
|
4378
4378
|
- a short flag is a single dash and a single character
|
|
4379
4379
|
- either use a single dash and a single character (for a short flag)
|
|
4380
4380
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):h.test($)?new Error(`${re}
|
|
4381
4381
|
- too many short flags`):l.test($)?new Error(`${re}
|
|
4382
4382
|
- too many long flags`):new Error(`${re}
|
|
4383
|
-
- unrecognised flag format`)}if(r===void 0&&f===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:r,longFlag:f}}function
|
|
4383
|
+
- unrecognised flag format`)}if(r===void 0&&f===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:r,longFlag:f}}function iJ(n,r){if(Math.abs(n.length-r.length)>3)return Math.max(n.length,r.length);let f=[];for(let h=0;h<=n.length;h++)f[h]=[h];for(let h=0;h<=r.length;h++)f[0][h]=h;for(let h=1;h<=r.length;h++)for(let l=1;l<=n.length;l++){let t;n[l-1]===r[h-1]?t=0:t=1,f[l][h]=Math.min(f[l-1][h]+1,f[l][h-1]+1,f[l-1][h-1]+t),l>1&&h>1&&n[l-1]===r[h-2]&&n[l-2]===r[h-1]&&(f[l][h]=Math.min(f[l][h],f[l-2][h-2]+1))}return f[n.length][r.length]}function mO(n,r){if(!r||r.length===0)return"";r=Array.from(new Set(r));let f=n.startsWith("--");f&&(n=n.slice(2),r=r.map($=>$.slice(2)));let h=[],l=3,t=.4;return r.forEach($=>{if($.length<=1)return;let re=iJ(n,$),e=Math.max(n.length,$.length);(e-re)/e>t&&(re<l?(l=re,h=[$]):re===l&&h.push($))}),h.sort(($,re)=>$.localeCompare(re)),f&&(h=h.map($=>`--${$}`)),h.length>1?`
|
|
4384
4384
|
(Did you mean one of ${h.join(", ")}?)`:h.length===1?`
|
|
4385
|
-
(Did you mean ${h[0]}?)`:""}var Xy=class n extends
|
|
4385
|
+
(Did you mean ${h[0]}?)`:""}var Xy=class n extends aJ{constructor(r){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=r||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:f=>Ab.stdout.write(f),writeErr:f=>Ab.stderr.write(f),outputError:(f,h)=>h(f),getOutHelpWidth:()=>Ab.stdout.isTTY?Ab.stdout.columns:void 0,getErrHelpWidth:()=>Ab.stderr.isTTY?Ab.stderr.columns:void 0,getOutHasColors:()=>q3()??(Ab.stdout.isTTY&&Ab.stdout.hasColors?.()),getErrHasColors:()=>q3()??(Ab.stderr.isTTY&&Ab.stderr.hasColors?.()),stripColor:f=>uJ(f)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(r){return this._outputConfiguration=r._outputConfiguration,this._helpOption=r._helpOption,this._helpCommand=r._helpCommand,this._helpConfiguration=r._helpConfiguration,this._exitCallback=r._exitCallback,this._storeOptionsAsProperties=r._storeOptionsAsProperties,this._combineFlagAndOptionalValue=r._combineFlagAndOptionalValue,this._allowExcessArguments=r._allowExcessArguments,this._enablePositionalOptions=r._enablePositionalOptions,this._showHelpAfterError=r._showHelpAfterError,this._showSuggestionAfterError=r._showSuggestionAfterError,this}_getCommandAndAncestors(){let r=[];for(let f=this;f;f=f.parent)r.push(f);return r}command(r,f,h){let l=f,t=h;typeof l=="object"&&l!==null&&(t=l,l=null),t=t||{};let[,$,re]=r.match(/([^ ]+) *(.*)/),e=this.createCommand($);return l&&(e.description(l),e._executableHandler=!0),t.isDefault&&(this._defaultCommandName=e._name),e._hidden=!!(t.noHelp||t.hidden),e._executableFile=t.executableFile||null,re&&e.arguments(re),this._registerCommand(e),e.parent=this,e.copyInheritedSettings(this),l?this:e}createCommand(r){return new n(r)}createHelp(){return Object.assign(new KC,this.configureHelp())}configureHelp(r){return r===void 0?this._helpConfiguration:(this._helpConfiguration=r,this)}configureOutput(r){return r===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...r},this)}showHelpAfterError(r=!0){return typeof r!="string"&&(r=!!r),this._showHelpAfterError=r,this}showSuggestionAfterError(r=!0){return this._showSuggestionAfterError=!!r,this}addCommand(r,f){if(!r._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
4386
4386
|
- specify the name in Command constructor or using .name()`);return f=f||{},f.isDefault&&(this._defaultCommandName=r._name),(f.noHelp||f.hidden)&&(r._hidden=!0),this._registerCommand(r),r.parent=this,r._checkForBrokenPassThrough(),this}createArgument(r,f){return new ZC(r,f)}argument(r,f,h,l){let t=this.createArgument(r,f);return typeof h=="function"?t.default(l).argParser(h):t.default(h),this.addArgument(t),this}arguments(r){return r.trim().split(/ +/).forEach(f=>{this.argument(f)}),this}addArgument(r){let f=this.registeredArguments.slice(-1)[0];if(f?.variadic)throw new Error(`only the last argument can be variadic '${f.name()}'`);if(r.required&&r.defaultValue!==void 0&&r.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${r.name()}'`);return this.registeredArguments.push(r),this}helpCommand(r,f){if(typeof r=="boolean")return this._addImplicitHelpCommand=r,r&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let h=r??"help [command]",[,l,t]=h.match(/([^ ]+) *(.*)/),$=f??"display help for command",re=this.createCommand(l);return re.helpOption(!1),t&&re.arguments(t),$&&re.description($),this._addImplicitHelpCommand=!0,this._helpCommand=re,(r||f)&&this._initCommandGroup(re),this}addHelpCommand(r,f){return typeof r!="object"?(this.helpCommand(r,f),this):(this._addImplicitHelpCommand=!0,this._helpCommand=r,this._initCommandGroup(r),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(r,f){let h=["preSubcommand","preAction","postAction"];if(!h.includes(r))throw new Error(`Unexpected value for event passed to hook : '${r}'.
|
|
4387
4387
|
Expecting one of '${h.join("', '")}'`);return this._lifeCycleHooks[r]?this._lifeCycleHooks[r].push(f):this._lifeCycleHooks[r]=[f],this}exitOverride(r){return r?this._exitCallback=r:this._exitCallback=f=>{if(f.code!=="commander.executeSubCommandAsync")throw f},this}_exit(r,f,h){this._exitCallback&&this._exitCallback(new cg(r,f,h)),Ab.exit(r)}action(r){let f=h=>{let l=this.registeredArguments.length,t=h.slice(0,l);return this._storeOptionsAsProperties?t[l]=this:t[l]=this.opts(),t.push(this),r.apply(this,t)};return this._actionHandler=f,this}createOption(r,f){return new Jy(r,f)}_callParseArg(r,f,h,l){try{return r.parseArg(f,h)}catch(t){if(t.code==="commander.invalidArgument"){let $=`${l} ${t.message}`;this.error($,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(r){let f=r.short&&this._findOption(r.short)||r.long&&this._findOption(r.long);if(f){let h=r.long&&this._findOption(r.long)?r.long:r.short;throw new Error(`Cannot add option '${r.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${h}'
|
|
4388
4388
|
- already used by option '${f.flags}'`)}this._initOptionGroup(r),this.options.push(r)}_registerCommand(r){let f=l=>[l.name()].concat(l.aliases()),h=f(r).find(l=>this._findCommand(l));if(h){let l=f(this._findCommand(h)).join("|"),t=f(r).join("|");throw new Error(`cannot add command '${t}' as already have command '${l}'`)}this._initCommandGroup(r),this.commands.push(r)}addOption(r){this._registerOption(r);let f=r.name(),h=r.attributeName();r.defaultValue!==void 0&&this.setOptionValueWithSource(h,r.defaultValue,"default");let l=(t,$,re)=>{t==null&&r.presetArg!==void 0&&(t=r.presetArg);let e=this.getOptionValue(h);t!==null&&r.parseArg?t=this._callParseArg(r,t,e,$):t!==null&&r.variadic&&(t=r._collectValue(t,e)),t==null&&(r.negate?t=!1:r.isBoolean()||r.optional?t=!0:t=""),this.setOptionValueWithSource(h,t,re)};return this.on("option:"+f,t=>{let $=`error: option '${r.flags}' argument '${t}' is invalid.`;l(t,$,"cli")}),r.envVar&&this.on("optionEnv:"+f,t=>{let $=`error: option '${r.flags}' value '${t}' from env '${r.envVar}' is invalid.`;l(t,$,"env")}),this}_optionEx(r,f,h,l,t){if(typeof f=="object"&&f instanceof Jy)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let $=this.createOption(f,h);if($.makeOptionMandatory(!!r.mandatory),typeof l=="function")$.default(t).argParser(l);else if(l instanceof RegExp){let re=l;l=(e,qe)=>{let ht=re.exec(e);return ht?ht[0]:qe},$.default(t).argParser(l)}else $.default(l);return this.addOption($)}option(r,f,h,l){return this._optionEx({},r,f,h,l)}requiredOption(r,f,h,l){return this._optionEx({mandatory:!0},r,f,h,l)}combineFlagAndOptionalValue(r=!0){return this._combineFlagAndOptionalValue=!!r,this}allowUnknownOption(r=!0){return this._allowUnknownOption=!!r,this}allowExcessArguments(r=!0){return this._allowExcessArguments=!!r,this}enablePositionalOptions(r=!0){return this._enablePositionalOptions=!!r,this}passThroughOptions(r=!0){return this._passThroughOptions=!!r,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(r=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!r,this}getOptionValue(r){return this._storeOptionsAsProperties?this[r]:this._optionValues[r]}setOptionValue(r,f){return this.setOptionValueWithSource(r,f,void 0)}setOptionValueWithSource(r,f,h){return this._storeOptionsAsProperties?this[r]=f:this._optionValues[r]=f,this._optionValueSources[r]=h,this}getOptionValueSource(r){return this._optionValueSources[r]}getOptionValueSourceWithGlobals(r){let f;return this._getCommandAndAncestors().forEach(h=>{h.getOptionValueSource(r)!==void 0&&(f=h.getOptionValueSource(r))}),f}_prepareUserArgs(r,f){if(r!==void 0&&!Array.isArray(r))throw new Error("first parameter to parse must be array or undefined");if(f=f||{},r===void 0&&f.from===void 0){Ab.versions?.electron&&(f.from="electron");let l=Ab.execArgv??[];(l.includes("-e")||l.includes("--eval")||l.includes("-p")||l.includes("--print"))&&(f.from="eval")}r===void 0&&(r=Ab.argv),this.rawArgs=r.slice();let h;switch(f.from){case void 0:case"node":this._scriptPath=r[1],h=r.slice(2);break;case"electron":Ab.defaultApp?(this._scriptPath=r[1],h=r.slice(2)):h=r.slice(1);break;case"user":h=r.slice(0);break;case"eval":h=r.slice(1);break;default:throw new Error(`unexpected parse option { from: '${f.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",h}parse(r,f){this._prepareForParse();let h=this._prepareUserArgs(r,f);return this._parseCommand([],h),this}async parseAsync(r,f){this._prepareForParse();let h=this._prepareUserArgs(r,f);return await this._parseCommand([],h),this}_prepareForParse(){this._savedState===null?(this.options.filter(r=>r.negate&&r.defaultValue===void 0&&this.getOptionValue(r.attributeName())===void 0).forEach(r=>{let f=r.long.replace(/^--no-/,"--");this._findOption(f)||this.setOptionValueWithSource(r.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
@@ -4395,7 +4395,7 @@ Expecting one of '${h.join("', '")}'`);return this._lifeCycleHooks[r]?this._life
|
|
|
4395
4395
|
`),this.outputHelp({error:!0}));let h=f||{},l=h.exitCode||1,t=h.code||"commander.error";this._exit(l,t,r)}_parseOptionsEnv(){this.options.forEach(r=>{if(r.envVar&&r.envVar in Ab.env){let f=r.attributeName();(this.getOptionValue(f)===void 0||["default","config","env"].includes(this.getOptionValueSource(f)))&&(r.required||r.optional?this.emit(`optionEnv:${r.name()}`,Ab.env[r.envVar]):this.emit(`optionEnv:${r.name()}`))}})}_parseOptionsImplied(){let r=new sS(this.options),f=h=>this.getOptionValue(h)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(h));this.options.filter(h=>h.implied!==void 0&&f(h.attributeName())&&r.valueFromOption(this.getOptionValue(h.attributeName()),h)).forEach(h=>{Object.keys(h.implied).filter(l=>!f(l)).forEach(l=>{this.setOptionValueWithSource(l,h.implied[l],"implied")})})}missingArgument(r){let f=`error: missing required argument '${r}'`;this.error(f,{code:"commander.missingArgument"})}optionMissingArgument(r){let f=`error: option '${r.flags}' argument missing`;this.error(f,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(r){let f=`error: required option '${r.flags}' not specified`;this.error(f,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(r,f){let h=$=>{let re=$.attributeName(),e=this.getOptionValue(re),qe=this.options.find(Ke=>Ke.negate&&re===Ke.attributeName()),ht=this.options.find(Ke=>!Ke.negate&&re===Ke.attributeName());return qe&&(qe.presetArg===void 0&&e===!1||qe.presetArg!==void 0&&e===qe.presetArg)?qe:ht||$},l=$=>{let re=h($),e=re.attributeName();return this.getOptionValueSource(e)==="env"?`environment variable '${re.envVar}'`:`option '${re.flags}'`},t=`error: ${l(r)} cannot be used with ${l(f)}`;this.error(t,{code:"commander.conflictingOption"})}unknownOption(r){if(this._allowUnknownOption)return;let f="";if(r.startsWith("--")&&this._showSuggestionAfterError){let l=[],t=this;do{let $=t.createHelp().visibleOptions(t).filter(re=>re.long).map(re=>re.long);l=l.concat($),t=t.parent}while(t&&!t._enablePositionalOptions);f=mO(r,l)}let h=`error: unknown option '${r}'${f}`;this.error(h,{code:"commander.unknownOption"})}_excessArguments(r){if(this._allowExcessArguments)return;let f=this.registeredArguments.length,h=f===1?"":"s",l=r.length,t=this.parent?` for '${this.name()}'`:"",$=r.join(", "),re=`error: too many arguments${t}. Expected ${f} argument${h} but got ${l}: ${$}.`;this.error(re,{code:"commander.excessArguments"})}unknownCommand(){let r=this.args[0],f="";if(this._showSuggestionAfterError){let l=[];this.createHelp().visibleCommands(this).forEach(t=>{l.push(t.name()),t.alias()&&l.push(t.alias())}),f=mO(r,l)}let h=`error: unknown command '${r}'${f}`;this.error(h,{code:"commander.unknownCommand"})}version(r,f,h){if(r===void 0)return this._version;this._version=r,f=f||"-V, --version",h=h||"output the version number";let l=this.createOption(f,h);return this._versionOptionName=l.attributeName(),this._registerOption(l),this.on("option:"+l.name(),()=>{this._outputConfiguration.writeOut(`${r}
|
|
4396
4396
|
`),this._exit(0,"commander.version",r)}),this}description(r,f){return r===void 0&&f===void 0?this._description:(this._description=r,f&&(this._argsDescription=f),this)}summary(r){return r===void 0?this._summary:(this._summary=r,this)}alias(r){if(r===void 0)return this._aliases[0];let f=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(f=this.commands[this.commands.length-1]),r===f._name)throw new Error("Command alias can't be the same as its name");let h=this.parent?._findCommand(r);if(h){let l=[h.name()].concat(h.aliases()).join("|");throw new Error(`cannot add alias '${r}' to command '${this.name()}' as already have command '${l}'`)}return f._aliases.push(r),this}aliases(r){return r===void 0?this._aliases:(r.forEach(f=>this.alias(f)),this)}usage(r){if(r===void 0){if(this._usage)return this._usage;let f=this.registeredArguments.map(h=>rS(h));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?f:[]).join(" ")}return this._usage=r,this}name(r){return r===void 0?this._name:(this._name=r,this)}helpGroup(r){return r===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=r,this)}commandsGroup(r){return r===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=r,this)}optionsGroup(r){return r===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=r,this)}_initOptionGroup(r){this._defaultOptionGroup&&!r.helpGroupHeading&&r.helpGroup(this._defaultOptionGroup)}_initCommandGroup(r){this._defaultCommandGroup&&!r.helpGroup()&&r.helpGroup(this._defaultCommandGroup)}nameFromFilename(r){return this._name=$h.basename(r,$h.extname(r)),this}executableDir(r){return r===void 0?this._executableDir:(this._executableDir=r,this)}helpInformation(r){let f=this.createHelp(),h=this._getOutputContext(r);f.prepareContext({error:h.error,helpWidth:h.helpWidth,outputHasColors:h.hasColors});let l=f.formatHelp(this,f);return h.hasColors?l:this._outputConfiguration.stripColor(l)}_getOutputContext(r){r=r||{};let f=!!r.error,h,l,t;return f?(h=re=>this._outputConfiguration.writeErr(re),l=this._outputConfiguration.getErrHasColors(),t=this._outputConfiguration.getErrHelpWidth()):(h=re=>this._outputConfiguration.writeOut(re),l=this._outputConfiguration.getOutHasColors(),t=this._outputConfiguration.getOutHelpWidth()),{error:f,write:re=>(l||(re=this._outputConfiguration.stripColor(re)),h(re)),hasColors:l,helpWidth:t}}outputHelp(r){let f;typeof r=="function"&&(f=r,r=void 0);let h=this._getOutputContext(r),l={error:h.error,write:h.write,command:this};this._getCommandAndAncestors().reverse().forEach($=>$.emit("beforeAllHelp",l)),this.emit("beforeHelp",l);let t=this.helpInformation({error:h.error});if(f&&(t=f(t),typeof t!="string"&&!Buffer.isBuffer(t)))throw new Error("outputHelp callback must return a string or a Buffer");h.write(t),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",l),this._getCommandAndAncestors().forEach($=>$.emit("afterAllHelp",l))}helpOption(r,f){return typeof r=="boolean"?(r?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(r??"-h, --help",f??"display help for command"),(r||f)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(r){return this._helpOption=r,this._initOptionGroup(r),this}help(r){this.outputHelp(r);let f=Number(Ab.exitCode??0);f===0&&r&&typeof r!="function"&&r.error&&(f=1),this._exit(f,"commander.help","(outputHelp)")}addHelpText(r,f){let h=["beforeAll","before","after","afterAll"];if(!h.includes(r))throw new Error(`Unexpected value for position to addHelpText.
|
|
4397
4397
|
Expecting one of '${h.join("', '")}'`);let l=`${r}Help`;return this.on(l,t=>{let $;typeof f=="function"?$=f({error:t.error,command:t.command}):$=f,$&&t.write(`${$}
|
|
4398
|
-
`)}),this}_outputHelpIfRequested(r){let f=this._getHelpOption();f&&r.find(l=>f.is(l))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function B3(n){return n.map(r=>{if(!r.startsWith("--inspect"))return r;let f,h="127.0.0.1",l="9229",t;return(t=r.match(/^(--inspect(-brk)?)$/))!==null?f=t[1]:(t=r.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(f=t[1],/^\d+$/.test(t[3])?l=t[3]:h=t[3]):(t=r.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(f=t[1],h=t[3],l=t[4]),f&&l!=="0"?`${f}=${h}:${parseInt(l)+1}`:r})}function q3(){if(Ab.env.NO_COLOR||Ab.env.FORCE_COLOR==="0"||Ab.env.FORCE_COLOR==="false")return!1;if(Ab.env.FORCE_COLOR||Ab.env.CLICOLOR_FORCE!==void 0)return!0}var Tae=new Xy;var V3={low:0,medium:1,high:2,critical:3};function uJ(...n){let r="low";for(let f of n)V3[f]>V3[r]&&(r=f);return r}function W3(n,r,f){return n.schema?.type==="boolean"?r===!0:n.repeatable?f&&Array.isArray(r)&&r.length>0:f&&r!=null}function H3(n,r){let f=typeof n=="string"?{target:n}:n;return{kind:"semantic",target:f.target,description:f.description,source:r}}function Y3(n,r){let f=typeof n=="string"?{target:n}:n;return{kind:"semantic",target:f.target,description:f.description,overwrite:f.overwrite,destructive:f.destructive,...f.idempotent!==void 0?{idempotent:f.idempotent}:{},...f.idempotency_key?{idempotency_key:f.idempotency_key}:{},...f.idempotent_note?{idempotent_note:f.idempotent_note}:{},source:r}}function lJ(n){let r=new Set,f=[],h=[],l=[],t=[],$,re,e=Qn=>{r.add("file_write"),h.push(Qn)};if(n.command_effects){let Qn=n.command_effects;if(t.push(Qn.risk_level??"low"),Qn.writes)for(let bn of Qn.writes)e(Y3(bn,`command:${n.command_id}`));if(Qn.reads)for(let bn of Qn.reads)f.push(H3(bn,`command:${n.command_id}`));Qn.network&&(r.add("network"),typeof Qn.network=="object"&&l.push({...Qn.network.description?{description:Qn.network.description}:{},...Qn.network.domains?{domains:[...Qn.network.domains]}:{},...Qn.network.idempotent!==void 0?{idempotent:Qn.network.idempotent}:{},...Qn.network.idempotency_key?{idempotency_key:Qn.network.idempotency_key}:{},...Qn.network.idempotent_note?{idempotent_note:Qn.network.idempotent_note}:{},source:`command:${n.command_id}`})),Qn.execution_mode&&($=Qn.execution_mode),Qn.requires_confirmation!==void 0&&(re=Qn.requires_confirmation)}for(let[Qn,bn]of Object.entries(n.options)){let{definition:zr,value:tr,specified:Er}=bn;if(W3(zr,tr,Er)){if(zr.file){let Ys=typeof tr=="string"?tr:void 0,ao=zr.file.mode;(ao==="read"||ao==="readWrite")&&f.push({kind:"option-file",option:Qn,path:Ys,source:`option:${Qn}`}),(ao==="write"||ao==="append"||ao==="readWrite")&&e({kind:"option-file",option:Qn,path:Ys,mode:ao,source:`option:${Qn}`})}if(zr.effects){let Ys=zr.effects;if(t.push(Ys.risk_level??"low"),Ys.writes)for(let ao of Ys.writes)e(Y3(ao,`option:${Qn}`));if(Ys.reads)for(let ao of Ys.reads)f.push(H3(ao,`option:${Qn}`));Ys.network&&(r.add("network"),typeof Ys.network=="object"&&l.push({...Ys.network.description?{description:Ys.network.description}:{},...Ys.network.domains?{domains:[...Ys.network.domains]}:{},...Ys.network.idempotent!==void 0?{idempotent:Ys.network.idempotent}:{},...Ys.network.idempotency_key?{idempotency_key:Ys.network.idempotency_key}:{},...Ys.network.idempotent_note?{idempotent_note:Ys.network.idempotent_note}:{},source:`option:${Qn}`})),Ys.execution_mode&&!$&&($=Ys.execution_mode),Ys.requires_confirmation!==void 0&&re===void 0&&(re=Ys.requires_confirmation)}}}let qe=t.length>0?uJ(...t):"low",ht=re??(qe==="high"||qe==="critical"),Ke;if(n.env){let Qn=[];for(let[bn,zr]of Object.entries(n.env))zr.sensitive&&Qn.push(bn);Qn.length>0&&(Ke=Qn)}let ln=h.filter(Qn=>Qn.kind==="semantic").every(Qn=>Qn.idempotent===!0)&&l.every(Qn=>Qn.idempotent===!0);return{risk_level:qe,requires_confirmation:ht,idempotent:ln,side_effects:[...r],reads:f,writes:h,...l.length>0?{network:l}:{},...$?{execution_mode:$}:{},...Ke?{requires_secrets:Ke}:{}}}function cJ(n){return n.split("-").map((r,f)=>f===0?r:r.charAt(0).toUpperCase()+r.slice(1)).join("")}function Z3(n,r,f){let h={},l=[];for(let $ of r.options??[]){let re=cJ($.name),e=f[re],qe=re in f&&e!==void 0;h[$.name]={value:e,specified:qe,definition:$},W3($,e,qe)&&l.push($.name)}let t=lJ({command_id:n,command_effects:r.effects,options:h,env:r.env});return{command:n,active_options:l,policy:t}}var fJ={init:{effects:{risk_level:"medium",writes:[{target:"speckeeper.config.ts, design/ directory",description:"generates config and starter template files",idempotent:!1}]},options:[{name:"force",schema:{type:"boolean",default:!1},effects:{risk_level:"high",writes:[{target:"existing project files",description:"overwrites existing config and design files",overwrite:!0,destructive:!0}]}},{name:"format",schema:{type:"string",default:"ts",enum:["ts","yaml"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},build:{effects:{risk_level:"low",writes:[{target:"docs/ directory",description:"generated Markdown documentation files",overwrite:!0,idempotent:!0}]},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"output",schema:{type:"string",default:"."}},{name:"verbose",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},lint:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"phase",schema:{type:"string",enum:["REQ","HLD","LLD","OPS"]}},{name:"strict",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","github"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},drift:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"update",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","diff"]}},{name:"fail-on-drift",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},check:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"strict",schema:{type:"boolean",default:!1}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"coverage",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},new:{effects:{risk_level:"low",writes:[{target:"design/ directory",description:"new TypeScript spec file with auto-generated ID",idempotent:!1}]},options:[{name:"name",schema:{type:"string"}},{name:"output",schema:{type:"string"}},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},impact:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"depth",schema:{type:"integer",minimum:1,default:3}},{name:"direction",schema:{type:"string",default:"both",enum:["upstream","downstream","both"]}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","mermaid"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},insights:{options:[{name:"format",schema:{type:"string",default:"json",enum:["json"]}},{name:"project-root",schema:{type:"string",default:"."}},{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},scaffold:{effects:{risk_level:"low",writes:[{target:"design/ directory",description:"generated _models/ and spec data files",idempotent:!1}]},options:[{name:"source",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"output",schema:{type:"string",default:"design/"}},{name:"force",schema:{type:"boolean",default:!1},effects:{risk_level:"medium",writes:[{target:"existing model and spec files",description:"overwrites existing TypeScript model source files",overwrite:!0}]}},{name:"dry-run",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"ts",enum:["ts","yaml"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},convert:{effects:{risk_level:"low",writes:[{target:".yaml output file",description:"YAML conversion of the TS spec data",idempotent:!0}]},options:[{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"audit-requirements":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"propose-trace-links":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"explain-impact":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"propose-acceptance-criteria":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},review:{effects:{network:{description:"LLM API calls to the configured provider",idempotent:!1}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"check",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"target",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"concurrency",schema:{type:"integer",minimum:1,default:2}},{name:"force",schema:{type:"boolean",default:!1}},{name:"dry-run",schema:{type:"boolean",default:!1}},{name:"show-packet",schema:{type:"boolean",default:!1}},{name:"require-judge",schema:{type:"boolean",default:!1}},{name:"allow-api-key",schema:{type:"boolean",default:!1}},{name:"max-targets",schema:{type:"integer",minimum:1}},{name:"prune",schema:{type:"boolean",default:!1}},{name:"emit",schema:{type:"string"}},{name:"format",schema:{type:"string",default:"text",enum:["text","json"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"review.ingest":{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"review.rebaseline":{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"reason",schema:{type:"string"}},{name:"check",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"target",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},agents:{options:[{name:"format",schema:{type:"string",enum:["yaml","json"],default:"yaml"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}}};function em(n,r){let f=fJ[n];if(!f)throw new Error(`Unknown command: ${n}`);return Z3(n,f,r)}function K3(n,r,f={}){let h=new Xy;h.name("speckeeper").version(r,"-V, --version").description("Requirements and design management framework with TypeScript DSL."),h.option("--introspect","Output derived policy as JSON without executing the command"),h.command("init").description("Initialize a new speckeeper project with starter templates.").option("-F, --force","Overwrite existing files.",!1).option("--format <format>","Spec data format: ts (default) or yaml.","ts").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("init",re);console.log(JSON.stringify(ht,null,2));return}await n.init(re,qe)}),h.command("build").description("Generate docs/ and specs/ from TypeScript models.").option("-c, --config <path>","Path to config file.").option("-o, --output <path>","Base directory the docs/ and specs/ trees are written under.",".").option("-v, --verbose","Show detailed output.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("build",re);console.log(JSON.stringify(ht,null,2));return}await n.build(re,qe)}),h.command("lint").description("Check design integrity (ID duplicates, references, layer violations, etc.).").option("-c, --config <path>","Path to config file.").option("-p, --phase <phase>","Phase gate to check against: REQ, HLD, LLD, OPS.").option("-s, --strict","Treat warnings as errors.",!1).option("-f, --format <format>","Output format: text, json, github.","text").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("lint",re);console.log(JSON.stringify(ht,null,2));return}await n.lint(re,qe)}),h.command("drift").description("Check if generated files have been manually edited.").option("-c, --config <path>","Path to config file.").option("-u, --update","Rewrite drifted and missing generated files with their expected content.",!1).option("-f, --format <format>","Output format: text, json, diff.","text").option("--fail-on-drift","Exit with code 1 if drift is detected (for CI).",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("drift",re);console.log(JSON.stringify(ht,null,2));return}await n.drift(re,qe)}),h.command("check").description("Check external SSOT conformance (including custom models).").argument("[type]","Source type to scan: the type of a configured source (built in: openapi, ddl, annotation), or all, the default.").option("-c, --config <path>","Path to config file.").option("--strict","Treat warnings as errors.",!1).option("-v, --verbose","Show detailed output.",!1).option("--coverage","Check if all testable acceptance criteria are covered by TestRefs.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("check",e);console.log(JSON.stringify(Ke,null,2));return}await n.check(re,e,ht)}),h.command("new").description("Create a new element with auto-generated ID.").argument("<type>","Element type to create: the ID of a model the config registers.").option("-n, --name <name>","Name of the element.").option("-o, --output <path>","Output directory path.").option("--dry-run","Preview generated file content without writing.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("new",e);console.log(JSON.stringify(Ke,null,2));return}await n.new(re,e,ht)}),h.command("impact").description("Analyze impact of changes to an ID.").argument("<id>","Spec ID to analyze (e.g. REQ-001, ENT-ORDER).").option("-c, --config <path>","Path to config file.").option("-d, --depth <n>","Analysis depth (reference tracking level).","3").option("--direction <direction>","Analysis direction: upstream, downstream, both.","both").option("-f, --format <format>","Output format: text, json, mermaid.","text").action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("impact",e);console.log(JSON.stringify(Ke,null,2));return}await n.impact(re,e,ht)}),h.command("insights").description("Export spec relation edges as ExternalInsight JSON.").option("-f, --format <format>","Output format (json only).","json").option("--project-root <path>","Project root directory containing speckeeper.config.",".").option("-c, --config <path>","Path to config file.").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("insights",re);console.log(JSON.stringify(ht,null,2));return}await n.insights(re,qe)}),h.command("scaffold").description("Generate _models/ from a Mermaid flowchart definition.").option("-s, --source <path>","Path to Markdown file containing Mermaid flowchart.").option("-o, --output <path>","Output directory.","design/").option("-F, --force","Overwrite existing files.",!1).option("--dry-run","Preview generated files without writing.",!1).option("--format <format>","Spec data format: ts (default) or yaml.","ts").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("scaffold",re);console.log(JSON.stringify(ht,null,2));return}await n.scaffold(re,qe)}),h.command("convert").description("Convert a TS spec data file to YAML format.").argument("<file>","Path to TS spec data file.").option("-o, --output <path>","Output file path (default: same name with .yaml extension).").option("-n, --dry-run","Preview conversion without writing.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("convert",e);console.log(JSON.stringify(Ke,null,2));return}await n.convert(re,e,ht)}),h.command("audit-requirements").description("Run LLM-based requirement quality audit.").option("-c, --config <path>","Path to config file.").option("-a, --adapter <name>","SDK adapter to use for LLM execution.").option("--model <name>","LLM model override.").option("--fail-on <level>","Minimum severity that causes a non-zero exit.","error").option("-o, --output <file>","Write result to a file instead of stdout.").option("--report-format <fmt>","Output format for the audit report.","json").option("-l, --log-file <value>","Write agent progress log to this file path.").option("--show-prompt","Output the constructed prompt without calling the LLM API.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("audit-requirements",re);console.log(JSON.stringify(ht,null,2));return}if(re.showPrompt){let ht=await n.auditRequirements(re,qe);typeof ht=="string"&&process.stdout.write(ht+`
|
|
4398
|
+
`)}),this}_outputHelpIfRequested(r){let f=this._getHelpOption();f&&r.find(l=>f.is(l))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function B3(n){return n.map(r=>{if(!r.startsWith("--inspect"))return r;let f,h="127.0.0.1",l="9229",t;return(t=r.match(/^(--inspect(-brk)?)$/))!==null?f=t[1]:(t=r.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(f=t[1],/^\d+$/.test(t[3])?l=t[3]:h=t[3]):(t=r.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(f=t[1],h=t[3],l=t[4]),f&&l!=="0"?`${f}=${h}:${parseInt(l)+1}`:r})}function q3(){if(Ab.env.NO_COLOR||Ab.env.FORCE_COLOR==="0"||Ab.env.FORCE_COLOR==="false")return!1;if(Ab.env.FORCE_COLOR||Ab.env.CLICOLOR_FORCE!==void 0)return!0}var xae=new Xy;var V3={low:0,medium:1,high:2,critical:3};function lJ(...n){let r="low";for(let f of n)V3[f]>V3[r]&&(r=f);return r}function W3(n,r,f){return n.schema?.type==="boolean"?r===!0:n.repeatable?f&&Array.isArray(r)&&r.length>0:f&&r!=null}function H3(n,r){let f=typeof n=="string"?{target:n}:n;return{kind:"semantic",target:f.target,description:f.description,source:r}}function Y3(n,r){let f=typeof n=="string"?{target:n}:n;return{kind:"semantic",target:f.target,description:f.description,overwrite:f.overwrite,destructive:f.destructive,...f.idempotent!==void 0?{idempotent:f.idempotent}:{},...f.idempotency_key?{idempotency_key:f.idempotency_key}:{},...f.idempotent_note?{idempotent_note:f.idempotent_note}:{},source:r}}function cJ(n){let r=new Set,f=[],h=[],l=[],t=[],$,re,e=Qn=>{r.add("file_write"),h.push(Qn)};if(n.command_effects){let Qn=n.command_effects;if(t.push(Qn.risk_level??"low"),Qn.writes)for(let bn of Qn.writes)e(Y3(bn,`command:${n.command_id}`));if(Qn.reads)for(let bn of Qn.reads)f.push(H3(bn,`command:${n.command_id}`));Qn.network&&(r.add("network"),typeof Qn.network=="object"&&l.push({...Qn.network.description?{description:Qn.network.description}:{},...Qn.network.domains?{domains:[...Qn.network.domains]}:{},...Qn.network.idempotent!==void 0?{idempotent:Qn.network.idempotent}:{},...Qn.network.idempotency_key?{idempotency_key:Qn.network.idempotency_key}:{},...Qn.network.idempotent_note?{idempotent_note:Qn.network.idempotent_note}:{},source:`command:${n.command_id}`})),Qn.execution_mode&&($=Qn.execution_mode),Qn.requires_confirmation!==void 0&&(re=Qn.requires_confirmation)}for(let[Qn,bn]of Object.entries(n.options)){let{definition:zr,value:tr,specified:Er}=bn;if(W3(zr,tr,Er)){if(zr.file){let Ys=typeof tr=="string"?tr:void 0,ao=zr.file.mode;(ao==="read"||ao==="readWrite")&&f.push({kind:"option-file",option:Qn,path:Ys,source:`option:${Qn}`}),(ao==="write"||ao==="append"||ao==="readWrite")&&e({kind:"option-file",option:Qn,path:Ys,mode:ao,source:`option:${Qn}`})}if(zr.effects){let Ys=zr.effects;if(t.push(Ys.risk_level??"low"),Ys.writes)for(let ao of Ys.writes)e(Y3(ao,`option:${Qn}`));if(Ys.reads)for(let ao of Ys.reads)f.push(H3(ao,`option:${Qn}`));Ys.network&&(r.add("network"),typeof Ys.network=="object"&&l.push({...Ys.network.description?{description:Ys.network.description}:{},...Ys.network.domains?{domains:[...Ys.network.domains]}:{},...Ys.network.idempotent!==void 0?{idempotent:Ys.network.idempotent}:{},...Ys.network.idempotency_key?{idempotency_key:Ys.network.idempotency_key}:{},...Ys.network.idempotent_note?{idempotent_note:Ys.network.idempotent_note}:{},source:`option:${Qn}`})),Ys.execution_mode&&!$&&($=Ys.execution_mode),Ys.requires_confirmation!==void 0&&re===void 0&&(re=Ys.requires_confirmation)}}}let qe=t.length>0?lJ(...t):"low",ht=re??(qe==="high"||qe==="critical"),Ke;if(n.env){let Qn=[];for(let[bn,zr]of Object.entries(n.env))zr.sensitive&&Qn.push(bn);Qn.length>0&&(Ke=Qn)}let ln=h.filter(Qn=>Qn.kind==="semantic").every(Qn=>Qn.idempotent===!0)&&l.every(Qn=>Qn.idempotent===!0);return{risk_level:qe,requires_confirmation:ht,idempotent:ln,side_effects:[...r],reads:f,writes:h,...l.length>0?{network:l}:{},...$?{execution_mode:$}:{},...Ke?{requires_secrets:Ke}:{}}}function fJ(n){return n.split("-").map((r,f)=>f===0?r:r.charAt(0).toUpperCase()+r.slice(1)).join("")}function Z3(n,r,f){let h={},l=[];for(let $ of r.options??[]){let re=fJ($.name),e=f[re],qe=re in f&&e!==void 0;h[$.name]={value:e,specified:qe,definition:$},W3($,e,qe)&&l.push($.name)}let t=cJ({command_id:n,command_effects:r.effects,options:h,env:r.env});return{command:n,active_options:l,policy:t}}var dJ={init:{effects:{risk_level:"medium",writes:[{target:"speckeeper.config.ts, design/ directory",description:"generates config and starter template files",idempotent:!1}]},options:[{name:"force",schema:{type:"boolean",default:!1},effects:{risk_level:"high",writes:[{target:"existing project files",description:"overwrites existing config and design files",overwrite:!0,destructive:!0}]}},{name:"format",schema:{type:"string",default:"ts",enum:["ts","yaml"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},build:{effects:{risk_level:"low",writes:[{target:"docs/ directory",description:"generated Markdown documentation files",overwrite:!0,idempotent:!0}]},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"output",schema:{type:"string",default:"."}},{name:"verbose",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},lint:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"phase",schema:{type:"string",enum:["REQ","HLD","LLD","OPS"]}},{name:"strict",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","github"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},drift:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"update",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","diff"]}},{name:"fail-on-drift",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},check:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"strict",schema:{type:"boolean",default:!1}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"coverage",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},new:{effects:{risk_level:"low",writes:[{target:"design/ directory",description:"new TypeScript spec file with auto-generated ID",idempotent:!1}]},options:[{name:"name",schema:{type:"string"}},{name:"output",schema:{type:"string"}},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},impact:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"depth",schema:{type:"integer",minimum:1,default:3}},{name:"direction",schema:{type:"string",default:"both",enum:["upstream","downstream","both"]}},{name:"format",schema:{type:"string",default:"text",enum:["text","json","mermaid"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},insights:{options:[{name:"format",schema:{type:"string",default:"json",enum:["json"]}},{name:"project-root",schema:{type:"string",default:"."}},{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},scaffold:{effects:{risk_level:"low",writes:[{target:"design/ directory",description:"generated _models/ and spec data files",idempotent:!1}]},options:[{name:"source",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"output",schema:{type:"string",default:"design/"}},{name:"force",schema:{type:"boolean",default:!1},effects:{risk_level:"medium",writes:[{target:"existing model and spec files",description:"overwrites existing TypeScript model source files",overwrite:!0}]}},{name:"dry-run",schema:{type:"boolean",default:!1}},{name:"format",schema:{type:"string",default:"ts",enum:["ts","yaml"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},convert:{effects:{risk_level:"low",writes:[{target:".yaml output file",description:"YAML conversion of the TS spec data",idempotent:!0}]},options:[{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"audit-requirements":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"propose-trace-links":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"explain-impact":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"propose-acceptance-criteria":{effects:{network:{description:"LLM API calls to configured provider",idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}},{name:"show-prompt",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},review:{effects:{network:{description:"LLM API calls to the configured provider",idempotent:!1}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"check",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"target",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"concurrency",schema:{type:"integer",minimum:1,default:2}},{name:"force",schema:{type:"boolean",default:!1}},{name:"dry-run",schema:{type:"boolean",default:!1}},{name:"show-packet",schema:{type:"boolean",default:!1}},{name:"require-judge",schema:{type:"boolean",default:!1}},{name:"allow-api-key",schema:{type:"boolean",default:!1}},{name:"max-targets",schema:{type:"integer",minimum:1}},{name:"prune",schema:{type:"boolean",default:!1}},{name:"emit",schema:{type:"string"}},{name:"format",schema:{type:"string",default:"text",enum:["text","json"]}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"review.ingest":{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},"review.rebaseline":{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!0,encoding:"utf-8"}},{name:"reason",schema:{type:"string"}},{name:"check",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"target",schema:{type:"array",items:{type:"string"}},repeatable:!0},{name:"dry-run",schema:{type:"boolean",default:!1}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}},agents:{options:[{name:"format",schema:{type:"string",enum:["yaml","json"],default:"yaml"}}],env:{GEMINI_API_KEY:{sensitive:!0},OPENAI_API_KEY:{sensitive:!0},ANTHROPIC_API_KEY:{sensitive:!0}}}};function em(n,r){let f=dJ[n];if(!f)throw new Error(`Unknown command: ${n}`);return Z3(n,f,r)}function K3(n,r,f={}){let h=new Xy;h.name("speckeeper").version(r,"-V, --version").description("Requirements and design management framework with TypeScript DSL."),h.option("--introspect","Output derived policy as JSON without executing the command"),h.command("init").description("Initialize a new speckeeper project with starter templates.").option("-F, --force","Overwrite existing files.",!1).option("--format <format>","Spec data format: ts (default) or yaml.","ts").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("init",re);console.log(JSON.stringify(ht,null,2));return}await n.init(re,qe)}),h.command("build").description("Generate docs/ and specs/ from TypeScript models.").option("-c, --config <path>","Path to config file.").option("-o, --output <path>","Base directory the docs/ and specs/ trees are written under.",".").option("-v, --verbose","Show detailed output.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("build",re);console.log(JSON.stringify(ht,null,2));return}await n.build(re,qe)}),h.command("lint").description("Check design integrity (ID duplicates, references, layer violations, etc.).").option("-c, --config <path>","Path to config file.").option("-p, --phase <phase>","Phase gate to check against: REQ, HLD, LLD, OPS.").option("-s, --strict","Treat warnings as errors.",!1).option("-f, --format <format>","Output format: text, json, github.","text").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("lint",re);console.log(JSON.stringify(ht,null,2));return}await n.lint(re,qe)}),h.command("drift").description("Check if generated files have been manually edited.").option("-c, --config <path>","Path to config file.").option("-u, --update","Rewrite drifted and missing generated files with their expected content.",!1).option("-f, --format <format>","Output format: text, json, diff.","text").option("--fail-on-drift","Exit with code 1 if drift is detected (for CI).",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("drift",re);console.log(JSON.stringify(ht,null,2));return}await n.drift(re,qe)}),h.command("check").description("Check external SSOT conformance (including custom models).").argument("[type]","Source type to scan: the type of a configured source (built in: openapi, ddl, annotation), or all, the default.").option("-c, --config <path>","Path to config file.").option("--strict","Treat warnings as errors.",!1).option("-v, --verbose","Show detailed output.",!1).option("--coverage","Check if all testable acceptance criteria are covered by TestRefs.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("check",e);console.log(JSON.stringify(Ke,null,2));return}await n.check(re,e,ht)}),h.command("new").description("Create a new element with auto-generated ID.").argument("<type>","Element type to create: the ID of a model the config registers.").option("-n, --name <name>","Name of the element.").option("-o, --output <path>","Output directory path.").option("--dry-run","Preview generated file content without writing.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("new",e);console.log(JSON.stringify(Ke,null,2));return}await n.new(re,e,ht)}),h.command("impact").description("Analyze impact of changes to an ID.").argument("<id>","Spec ID to analyze (e.g. REQ-001, ENT-ORDER).").option("-c, --config <path>","Path to config file.").option("-d, --depth <n>","Analysis depth (reference tracking level).","3").option("--direction <direction>","Analysis direction: upstream, downstream, both.","both").option("-f, --format <format>","Output format: text, json, mermaid.","text").action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("impact",e);console.log(JSON.stringify(Ke,null,2));return}await n.impact(re,e,ht)}),h.command("insights").description("Export spec relation edges as ExternalInsight JSON.").option("-f, --format <format>","Output format (json only).","json").option("--project-root <path>","Project root directory containing speckeeper.config.",".").option("-c, --config <path>","Path to config file.").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("insights",re);console.log(JSON.stringify(ht,null,2));return}await n.insights(re,qe)}),h.command("scaffold").description("Generate _models/ from a Mermaid flowchart definition.").option("-s, --source <path>","Path to Markdown file containing Mermaid flowchart.").option("-o, --output <path>","Output directory.","design/").option("-F, --force","Overwrite existing files.",!1).option("--dry-run","Preview generated files without writing.",!1).option("--format <format>","Spec data format: ts (default) or yaml.","ts").action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("scaffold",re);console.log(JSON.stringify(ht,null,2));return}await n.scaffold(re,qe)}),h.command("convert").description("Convert a TS spec data file to YAML format.").argument("<file>","Path to TS spec data file.").option("-o, --output <path>","Output file path (default: same name with .yaml extension).").option("-n, --dry-run","Preview conversion without writing.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("convert",e);console.log(JSON.stringify(Ke,null,2));return}await n.convert(re,e,ht)}),h.command("audit-requirements").description("Run LLM-based requirement quality audit.").option("-c, --config <path>","Path to config file.").option("-a, --adapter <name>","SDK adapter to use for LLM execution.").option("--model <name>","LLM model override.").option("--fail-on <level>","Minimum severity that causes a non-zero exit.","error").option("-o, --output <file>","Write result to a file instead of stdout.").option("--report-format <fmt>","Output format for the audit report.","json").option("-l, --log-file <value>","Write agent progress log to this file path.").option("--show-prompt","Output the constructed prompt without calling the LLM API.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("audit-requirements",re);console.log(JSON.stringify(ht,null,2));return}if(re.showPrompt){let ht=await n.auditRequirements(re,qe);typeof ht=="string"&&process.stdout.write(ht+`
|
|
4399
4399
|
`);return}await n.auditRequirements(re,qe)}),h.command("propose-trace-links").description("LLM-based traceability link proposal.").option("-c, --config <path>","Path to config file.").option("-a, --adapter <name>","SDK adapter to use for LLM execution.").option("--model <name>","LLM model override.").option("--fail-on <level>","Minimum severity that causes a non-zero exit.","error").option("-o, --output <file>","Write result to a file instead of stdout.").option("--report-format <fmt>","Output format for the report.","json").option("-l, --log-file <value>","Write agent progress log to this file path.").option("--show-prompt","Output the constructed prompt without calling the LLM API.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("propose-trace-links",re);console.log(JSON.stringify(ht,null,2));return}if(re.showPrompt){let ht=await n.proposeTraceLinks(re,qe);typeof ht=="string"&&process.stdout.write(ht+`
|
|
4400
4400
|
`);return}await n.proposeTraceLinks(re,qe)}),h.command("explain-impact").description("LLM-based explanation of impact analysis output.").option("-a, --adapter <name>","SDK adapter to use for LLM execution.").option("--model <name>","LLM model override.").option("--fail-on <level>","Minimum severity that causes a non-zero exit.","error").option("-o, --output <file>","Write result to a file instead of stdout.").option("--report-format <fmt>","Output format for the report.","json").option("-l, --log-file <value>","Write agent progress log to this file path.").option("--show-prompt","Output the constructed prompt without calling the LLM API.",!1).action(async(re,e)=>{let qe=e.optsWithGlobals();if(qe.introspect){let ht=em("explain-impact",re);console.log(JSON.stringify(ht,null,2));return}if(re.showPrompt){let ht=await n.explainImpact(re,qe);typeof ht=="string"&&process.stdout.write(ht+`
|
|
4401
4401
|
`);return}await n.explainImpact(re,qe)}),h.command("propose-acceptance-criteria").description("LLM-based acceptance criteria proposal.").argument("[specIds...]","Spec IDs to propose criteria for. Defaults to all specs if omitted.").option("-c, --config <path>","Path to config file.").option("-a, --adapter <name>","SDK adapter to use for LLM execution.").option("--model <name>","LLM model override.").option("--fail-on <level>","Minimum severity that causes a non-zero exit.","error").option("-o, --output <file>","Write result to a file instead of stdout.").option("--report-format <fmt>","Output format for the report.","json").option("-l, --log-file <value>","Write agent progress log to this file path.").option("--show-prompt","Output the constructed prompt without calling the LLM API.",!1).action(async(re,e,qe)=>{let ht=qe.optsWithGlobals();if(ht.introspect){let Ke=em("propose-acceptance-criteria",e);console.log(JSON.stringify(Ke,null,2));return}if(e.showPrompt){let Ke=await n.proposeAcceptanceCriteria(re,e,ht);typeof Ke=="string"&&process.stdout.write(Ke+`
|
|
@@ -4405,8 +4405,8 @@ Expecting one of '${h.join("', '")}'`);let l=`${r}Help`;return this.on(l,t=>{let
|
|
|
4405
4405
|
`)}else{let gt=[];if(gt.push("# speckeeper extract"),gt.push("# source: embedded"),gt.push("# type: cli-contracts/command-extract"),e.includeMeta){gt.push("---"),gt.push("source: embedded"),gt.push("type: cli-contracts/command-extract"),gt.push("extractedAt: "+new Date().toISOString()),gt.push("spec_version: "+(ht.cli_contracts??"0.1.0")),gt.push("commands:");for(let ln of["speckeeper.init","speckeeper.build","speckeeper.lint","speckeeper.drift","speckeeper.check","speckeeper.new","speckeeper.impact","speckeeper.insights","speckeeper.scaffold","speckeeper.convert","speckeeper.audit-requirements","speckeeper.propose-trace-links","speckeeper.explain-impact","speckeeper.propose-acceptance-criteria","speckeeper.review","speckeeper.review.ingest","speckeeper.review.rebaseline","speckeeper.agents"])gt.push(" - "+ln)}gt.push("---"),gt.push(z3),process.stdout.write(gt.join(`
|
|
4406
4406
|
`)+`
|
|
4407
4407
|
`)}else{let gt={cli_contracts:ht.cli_contracts,info:ht.info,command_sets:{}},ln=gt.command_sets;for(let[Qn,bn]of Object.entries(ht.command_sets??{})){let zr=bn.commands;if(!zr)continue;let tr={};for(let[Er,cs]of Object.entries(zr)){let Ys=Qn+"."+Er;Ke.some(ao=>ao===Er||ao===Ys||Er.startsWith(ao+"."))&&(tr[Er]=cs)}if(Object.keys(tr).length>0){let Er={...bn};Er.commands=tr,ln[Qn]=Er}}ht.components&&(gt.components=ht.components),process.stdout.write(JSON.stringify(gt,null,2)+`
|
|
4408
|
-
`)}process.exitCode=0});let{onUsageError:$}=f;if($){let re=["commander.help","commander.helpDisplayed","commander.version"],e=qe=>{qe.configureOutput({outputError:()=>{}}),qe.exitOverride(ht=>{re.includes(ht.code)||process.exit($(ht,qe))}),qe.commands.forEach(e)};e(h)}return h}var
|
|
4409
|
-
`),Q3(r)?.exits["2"]!==void 0?2:n.exitCode}function e7(n,r){let f=K3(n,r,{onUsageError:
|
|
4408
|
+
`)}process.exitCode=0});let{onUsageError:$}=f;if($){let re=["commander.help","commander.helpDisplayed","commander.version"],e=qe=>{qe.configureOutput({outputError:()=>{}}),qe.exitOverride(ht=>{re.includes(ht.code)||process.exit($(ht,qe))}),qe.commands.forEach(e)};e(h)}return h}var pJ=new Set(["type","enum","minimum","maximum","items","description","default","examples","title"]),bJ=new Set(["string","boolean","array","integer"]),gO;function vJ(){if(!gO){let n=JSON.parse(nS);gO=new Map(Object.values(n.command_sets).flatMap(r=>Object.entries(r.commands)))}return gO}function Q3(n){let r=[];for(let f=n;f?.parent;f=f.parent)r.unshift(f.name());return r.length>1&&r[r.length-1]===r[r.length-2]&&r.pop(),vJ().get(r.join("."))}function J3(n,r){let f=Object.keys(r).find(h=>!pJ.has(h));if(f!==void 0||r.type!==void 0&&!bJ.has(r.type))throw new Error(`cli-contract.yaml declares a value with ${f?`"${f}"`:`type "${r.type}"`}, which the CLI does not check`);if(r.enum&&!r.enum.some(h=>String(h)===n))return`Allowed choices are ${r.enum.join(", ")}.`;if(r.type==="integer"){if(!/^-?\d+$/.test(n))return"Expected an integer.";if(r.minimum!==void 0&&Number(n)<r.minimum)return`Expected at least ${r.minimum}.`;if(r.maximum!==void 0&&Number(n)>r.maximum)return`Expected at most ${r.maximum}.`}}function X3(n,r){return n===void 0||typeof n=="boolean"?[]:Array.isArray(n)?n.map(f=>[String(f),r.items??r]):[[String(n),r]]}function mJ(n){let r=Q3(n);if(r){for(let f of r.arguments??[])if(f.schema)for(let[h,l]of X3(n.processedArgs[f.index],f.schema)){let t=J3(h,l);if(t)return`error: command-argument value '${h}' is invalid for argument '${f.name}'. ${t}`}for(let f of r.options??[]){if(!f.schema)continue;let h=n.options.find(l=>l.long===`--${f.name}`);if(h)for(let[l,t]of X3(n.getOptionValue(h.attributeName()),f.schema)){let $=J3(l,t);if($)return`error: option '${h.flags}' argument '${l}' is invalid. ${$}`}}}}function hJ(n,r){return process.stderr.write(`${n.message}
|
|
4409
|
+
`),Q3(r)?.exits["2"]!==void 0?2:n.exitCode}function e7(n,r){let f=K3(n,r,{onUsageError:hJ});return f.hook("preAction",(h,l)=>{let t=mJ(l);t&&l.error(t,{code:"commander.invalidArgument"})}),f}yJ();gJ("data:text/javascript,"+encodeURIComponent(`
|
|
4410
4410
|
const isProjectTypeScript = (rawUrl) => {
|
|
4411
4411
|
if (!rawUrl.startsWith('file:')) return false;
|
|
4412
4412
|
const url = rawUrl.replace(/%5C/gi, '/').replace(/\\\\/g, '/');
|
|
@@ -4420,5 +4420,5 @@ export async function load(url, context, nextLoad) {
|
|
|
4420
4420
|
? nextLoad(url, { ...context, format: 'module' })
|
|
4421
4421
|
: nextLoad(url, context);
|
|
4422
4422
|
}
|
|
4423
|
-
`),import.meta.url);function
|
|
4423
|
+
`),import.meta.url);function wJ(){return"0.19.1"}var CJ={init:async n=>{await n3(n)},build:async n=>{await XM(n)},lint:async n=>{await Nj(n)},drift:async n=>{await $j(n)},check:async(n,r)=>{await Yj(n,r)},new:async(n,r)=>{await Zj(n,r)},impact:async(n,r)=>{await Kj(n,r)},insights:async n=>{await e3(n)},scaffold:async n=>{await w3(n)},convert:async(n,r)=>{await i3(n,r)},auditRequirements:n=>x3(n),proposeTraceLinks:n=>k3(n),explainImpact:n=>R3(n),proposeAcceptanceCriteria:(n,r)=>N3(n,r),review:async n=>{let r=await P3(n);process.exitCode=r},reviewIngest:async(n,r)=>{let f=await M3(n,r);process.exitCode=f},reviewRebaseline:async n=>{let r=await j3(n);process.exitCode=r},agents:async n=>{let r=await Promise.resolve().then(()=>nh(ih(),1)),f=n.format??"yaml";try{console.log(f==="json"?JSON.stringify(qy,null,2):r.stringify(qy,{lineWidth:120}))}catch(h){console.error(`Failed to output DSL: ${h.message}`),process.exitCode=1}}};e7(CJ,wJ()).parseAsync().catch(n=>{console.error(Xs.red(n instanceof Error?n.message:String(n))),process.exitCode=n.exitCode??1});
|
|
4424
4424
|
//# sourceMappingURL=speckeeper.bundle.mjs.map
|