@neurynae/toolcairn-mcp 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -165,8 +165,8 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
165
165
  `);let e=new Vn("!xml"),n=e,r="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;let i=new z1(this.options.processEntities);for(let o=0;o<t.length;o++)if(t[o]==="<")if(t[o+1]==="/"){let c=un(t,">",o,"Closing Tag is not closed."),l=t.substring(o+2,c).trim();if(this.options.removeNSPrefix){let h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(r=this.saveTextToParentTag(r,n,s));let u=s.substring(s.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let f=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(f=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):f=s.lastIndexOf("."),s=s.substring(0,f),n=this.tagsNodeStack.pop(),r="",o=c}else if(t[o+1]==="?"){let c=gl(t,o,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,s),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){let l=new Vn(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,s,c.tagName)),this.addChild(n,l,s,o)}o=c.closeIndex+1}else if(t.substr(o+1,3)==="!--"){let c=un(t,"-->",o+4,"Comment is not closed.");if(this.options.commentPropName){let l=t.substring(o+4,c-2);r=this.saveTextToParentTag(r,n,s),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}o=c}else if(t.substr(o+1,2)==="!D"){let c=i.readDocType(t,o);this.docTypeEntities=c.entities,o=c.i}else if(t.substr(o+1,2)==="!["){let c=un(t,"]]>",o,"CDATA is not closed.")-2,l=t.substring(o+9,c);r=this.saveTextToParentTag(r,n,s);let u=this.parseTextData(l,n.tagname,s,!0,!1,!0,!0);u==null&&(u=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,u),o=c+2}else{let c=gl(t,o,this.options.removeNSPrefix),l=c.tagName,u=c.rawTagName,f=c.tagExp,h=c.attrExpPresent,g=c.closeIndex;if(this.options.transformTagName){let y=this.options.transformTagName(l);f===l&&(f=y),l=y}if(this.options.strictReservedNames&&(l===this.options.commentPropName||l===this.options.cdataPropName||l===this.options.textNodeName||l===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,s,!1));let p=n;p&&this.options.unpairedTags.indexOf(p.tagname)!==-1&&(n=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),l!==e.tagname&&(s+=s?"."+l:l);let m=o;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,l)){let y="";if(f.length>0&&f.lastIndexOf("/")===f.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),s=s.substr(0,s.length-1),f=l):f=f.substr(0,f.length-1),o=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)o=c.closeIndex;else{let v=this.readStopNodeData(t,u,g+1);if(!v)throw new Error(`Unexpected end of ${u}`);o=v.i,y=v.tagContent}let b=new Vn(l);l!==f&&h&&(b[":@"]=this.buildAttributesMap(f,s,l)),y&&(y=this.parseTextData(y,l,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),b.add(this.options.textNodeName,y),this.addChild(n,b,s,m)}else{if(f.length>0&&f.lastIndexOf("/")===f.length-1){if(l[l.length-1]==="/"?(l=l.substr(0,l.length-1),s=s.substr(0,s.length-1),f=l):f=f.substr(0,f.length-1),this.options.transformTagName){let b=this.options.transformTagName(l);f===l&&(f=b),l=b}let y=new Vn(l);l!==f&&h&&(y[":@"]=this.buildAttributesMap(f,s,l)),this.addChild(n,y,s,m),s=s.substr(0,s.lastIndexOf("."))}else if(this.options.unpairedTags.indexOf(l)!==-1){let y=new Vn(l);l!==f&&h&&(y[":@"]=this.buildAttributesMap(f,s)),this.addChild(n,y,s,m),s=s.substr(0,s.lastIndexOf(".")),o=c.closeIndex;continue}else{let y=new Vn(l);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),l!==f&&h&&(y[":@"]=this.buildAttributesMap(f,s,l)),this.addChild(n,y,s),n=y}r="",o=g}}else r+=t[o];return e.child};function sA(t,e,n,r){this.options.captureMetaData||(r=void 0);let s=this.options.updateTag(e.tagname,n,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),t.addChild(e,r))}var iA=function(t,e,n){if(t.indexOf("&")===-1)return t;let r=this.options.processEntities;if(!r.enabled||r.allowedTags&&!r.allowedTags.includes(e)||r.tagFilter&&!r.tagFilter(e,n))return t;for(let s in this.docTypeEntities){let i=this.docTypeEntities[s],o=t.match(i.regx);if(o){if(this.entityExpansionCount+=o.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);let a=t.length;if(t=t.replace(i.regx,i.val),r.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>r.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${r.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let s of Object.keys(this.lastEntities)){let i=this.lastEntities[s],o=t.match(i.regex);if(o&&(this.entityExpansionCount+=o.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}if(t.indexOf("&")===-1)return t;if(this.options.htmlEntities)for(let s of Object.keys(this.htmlEntities)){let i=this.htmlEntities[s],o=t.match(i.regex);if(o&&(this.entityExpansionCount+=o.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t};function oA(t,e,n,r){return t&&(r===void 0&&(r=e.child.length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function aA(t,e,n,r){return!!(e&&e.has(r)||t&&t.has(n))}function cA(t,e,n=">"){let r,s="";for(let i=e;i<t.length;i++){let o=t[i];if(r)o===r&&(r="");else if(o==='"'||o==="'")r=o;else if(o===n[0])if(n[1]){if(t[i+1]===n[1])return{data:s,index:i}}else return{data:s,index:i};else o===" "&&(o=" ");s+=o}}function un(t,e,n,r){let s=t.indexOf(e,n);if(s===-1)throw new Error(r);return s+e.length-1}function gl(t,e,n,r=">"){let s=cA(t,e+1,r);if(!s)return;let i=s.data,o=s.index,a=i.search(/\s/),c=i,l=!0;a!==-1&&(c=i.substring(0,a),i=i.substring(a+1).trimStart());let u=c;if(n){let f=c.indexOf(":");f!==-1&&(c=c.substr(f+1),l=c!==s.data.substr(f+1))}return{tagName:c,tagExp:i,closeIndex:o,attrExpPresent:l,rawTagName:u}}function lA(t,e,n){let r=n,s=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){let i=un(t,">",n,`${e} is not closed`);if(t.substring(n+2,i).trim()===e&&(s--,s===0))return{tagContent:t.substring(r,n),i};n=i}else if(t[n+1]==="?")n=un(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=un(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=un(t,"]]>",n,"StopNode is not closed.")-2;else{let i=gl(t,n,">");i&&((i&&i.tagName)===e&&i.tagExp[i.tagExp.length-1]!=="/"&&s++,n=i.closeIndex)}}function yl(t,e,n){if(e&&typeof t=="string"){let r=t.trim();return r==="true"?!0:r==="false"?!1:H1(t,n)}else return Ci.isExist(t)?t:""}function yg(t,e,n){let r=Number.parseInt(t,e);return r>=0&&r<=1114111?String.fromCodePoint(r):n+t+";"}function uA(t,e){if(Ci.criticalProperties.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Ci.DANGEROUS_PROPERTY_NAMES.includes(t)?e.onDangerousProperty(t):t}_g.exports=ml});var Sg=S(vg=>{"use strict";d();function fA(t,e){return bg(t,e)}function bg(t,e,n){let r,s={};for(let i=0;i<t.length;i++){let o=t[i],a=dA(o),c="";if(n===void 0?c=a:c=n+"."+a,a===e.textNodeName)r===void 0?r=o[a]:r+=""+o[a];else{if(a===void 0)continue;if(o[a]){let l=bg(o[a],e,c),u=pA(l,e);o[":@"]?hA(l,o[":@"],c,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),s[a]!==void 0&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(l)):e.isArray(a,c,u)?s[a]=[l]:s[a]=l}}}return typeof r=="string"?r.length>0&&(s[e.textNodeName]=r):r!==void 0&&(s[e.textNodeName]=r),s}function dA(t){let e=Object.keys(t);for(let n=0;n<e.length;n++){let r=e[n];if(r!==":@")return r}}function hA(t,e,n,r){if(e){let s=Object.keys(e),i=s.length;for(let o=0;o<i;o++){let a=s[o];r.isArray(a,n+"."+a,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function pA(t,e){let{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}vg.prettify=fA});var kg=S((rF,Eg)=>{"use strict";d();var{buildOptions:mA}=cg(),gA=wg(),{prettify:yA}=Sg(),_A=ul(),_l=class{constructor(e){this.externalEntities={},this.options=mA(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});let i=_A.validate(e,n);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let r=new gA(this.options);r.addExternalEntities(this.externalEntities);let s=r.parseXml(e);return this.options.preserveOrder||s===void 0?s:yA(s,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};Eg.exports=_l});var Ng=S((iF,Og)=>{"use strict";d();function wA(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=`
166
166
  `),Tg(t,e,"",n)}function Tg(t,e,n,r){let s="",i=!1;if(!Array.isArray(t)){if(t!=null){let o=t.toString();return o=wl(o,e),o}return""}for(let o=0;o<t.length;o++){let a=t[o],c=bA(a);if(c===void 0)continue;let l="";if(n.length===0?l=c:l=`${n}.${c}`,c===e.textNodeName){let p=a[c];vA(l,e)||(p=e.tagValueProcessor(c,p),p=wl(p,e)),i&&(s+=r),s+=p,i=!1;continue}else if(c===e.cdataPropName){i&&(s+=r),s+=`<![CDATA[${a[c][0][e.textNodeName]}]]>`,i=!1;continue}else if(c===e.commentPropName){s+=r+`<!--${a[c][0][e.textNodeName]}-->`,i=!0;continue}else if(c[0]==="?"){let p=xg(a[":@"],e),m=c==="?xml"?"":r,y=a[c][0][e.textNodeName];y=y.length!==0?" "+y:"",s+=m+`<${c}${y}${p}?>`,i=!0;continue}let u=r;u!==""&&(u+=e.indentBy);let f=xg(a[":@"],e),h=r+`<${c}${f}`,g=Tg(a[c],e,l,u);e.unpairedTags.indexOf(c)!==-1?e.suppressUnpairedNode?s+=h+">":s+=h+"/>":(!g||g.length===0)&&e.suppressEmptyNode?s+=h+"/>":g&&g.endsWith(">")?s+=h+`>${g}${r}</${c}>`:(s+=h+">",g&&r!==""&&(g.includes("/>")||g.includes("</"))?s+=r+e.indentBy+g+r:s+=g,s+=`</${c}>`),i=!0}return s}function bA(t){let e=Object.keys(t);for(let n=0;n<e.length;n++){let r=e[n];if(Object.prototype.hasOwnProperty.call(t,r)&&r!==":@")return r}}function xg(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let s=e.attributeValueProcessor(r,t[r]);s=wl(s,e),s===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${s}"`}return n}function vA(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function wl(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){let r=e.entities[n];t=t.replace(r.regex,r.val)}return t}Og.exports=wA});var Cg=S((aF,Ag)=>{"use strict";d();var SA=Ng(),EA=pl(),kA={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function Nt(t){this.options=Object.assign({},kA,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=EA(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=OA),this.processTextOrObjNode=xA,this.options.format?(this.indentate=TA,this.tagEndChar=`>
167
167
  `,this.newLine=`
168
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Nt.prototype.build=function(t){return this.options.preserveOrder?SA(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};Nt.prototype.j2x=function(t,e,n){let r="",s="",i=n.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(s+="");else if(t[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?s+="":o[0]==="?"?s+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)s+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){let a=this.isAttribute(o);if(a&&!this.ignoreAttributesFn(a,i))r+=this.buildAttrPairStr(a,""+t[o]);else if(!a)if(o===this.options.textNodeName){let c=this.options.tagValueProcessor(o,""+t[o]);s+=this.replaceEntitiesValue(c)}else s+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){let a=t[o].length,c="",l="";for(let u=0;u<a;u++){let f=t[o][u];if(!(typeof f>"u"))if(f===null)o[0]==="?"?s+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){let h=this.j2x(f,e+1,n.concat(o));c+=h.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(l+=h.attrStr)}else c+=this.processTextOrObjNode(f,o,e,n);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(o,f);h=this.replaceEntitiesValue(h),c+=h}else c+=this.buildTextValNode(f,o,"",e)}this.options.oneListGroup&&(c=this.buildObjectNode(c,o,l,e)),s+=c}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let a=Object.keys(t[o]),c=a.length;for(let l=0;l<c;l++)r+=this.buildAttrPairStr(a[l],""+t[o][a[l]])}else s+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:s}};Nt.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function xA(t,e,n,r){let s=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,s.attrStr,n):this.buildObjectNode(s.val,e,s.attrStr,n)}Nt.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let s="</"+e+this.tagEndChar,i="";return e[0]==="?"&&(i="?",s=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+i+">"+t+s:this.options.commentPropName!==!1&&e===this.options.commentPropName&&i.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+i+this.tagEndChar+t+this.indentate(r)+s}};Nt.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};Nt.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(e,t);return s=this.replaceEntitiesValue(s),s===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+s+"</"+e+this.tagEndChar}};Nt.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){let n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function TA(t){return this.options.indentBy.repeat(t)}function OA(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}Ag.exports=Nt});var Kr=S((lF,Ig)=>{"use strict";d();var NA=ul(),AA=kg(),CA=Cg();Ig.exports={XMLParser:AA,XMLValidator:NA,XMLBuilder:CA}});var Jy=S((lU,Ll)=>{"use strict";d();(function(){var t;function e(n,r){var s=this instanceof e?this:t;if(s.reset(r),typeof n=="string"&&n.length>0&&s.hash(n),s!==this)return s}e.prototype.hash=function(n){var r,s,i,o,a;switch(a=n.length,this.len+=a,s=this.k1,i=0,this.rem){case 0:s^=a>i?n.charCodeAt(i++)&65535:0;case 1:s^=a>i?(n.charCodeAt(i++)&65535)<<8:0;case 2:s^=a>i?(n.charCodeAt(i++)&65535)<<16:0;case 3:s^=a>i?(n.charCodeAt(i)&255)<<24:0,s^=a>i?(n.charCodeAt(i++)&65280)>>8:0}if(this.rem=a+this.rem&3,a-=this.rem,a>0){for(r=this.h1;s=s*11601+(s&65535)*3432906752&4294967295,s=s<<15|s>>>17,s=s*13715+(s&65535)*461832192&4294967295,r^=s,r=r<<13|r>>>19,r=r*5+3864292196&4294967295,!(i>=a);)s=n.charCodeAt(i++)&65535^(n.charCodeAt(i++)&65535)<<8^(n.charCodeAt(i++)&65535)<<16,o=n.charCodeAt(i++),s^=(o&255)<<24^(o&65280)>>8;switch(s=0,this.rem){case 3:s^=(n.charCodeAt(i+2)&65535)<<16;case 2:s^=(n.charCodeAt(i+1)&65535)<<8;case 1:s^=n.charCodeAt(i)&65535}this.h1=r}return this.k1=s,this},e.prototype.result=function(){var n,r;return n=this.k1,r=this.h1,n>0&&(n=n*11601+(n&65535)*3432906752&4294967295,n=n<<15|n>>>17,n=n*13715+(n&65535)*461832192&4294967295,r^=n),r^=this.len,r^=r>>>16,r=r*51819+(r&65535)*2246770688&4294967295,r^=r>>>13,r=r*44597+(r&65535)*3266445312&4294967295,r^=r>>>16,r>>>0},e.prototype.reset=function(n){return this.h1=typeof n=="number"?n:0,this.rem=this.k1=this.len=0,this},t=new e,typeof Ll<"u"?Ll.exports=e:this.MurmurHash3=e})()});var Yy=S(fn=>{"use strict";d();Object.defineProperty(fn,"__esModule",{value:!0});fn.signals=void 0;fn.signals=[];fn.signals.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&fn.signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&fn.signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});var zy=S(nt=>{"use strict";d();var Fi;Object.defineProperty(nt,"__esModule",{value:!0});nt.unload=nt.load=nt.onExit=nt.signals=void 0;var Bi=Yy();Object.defineProperty(nt,"signals",{enumerable:!0,get:function(){return Bi.signals}});var Di=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Rl=Symbol.for("signal-exit emitter"),jl=globalThis,sI=Object.defineProperty.bind(Object),$l=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(jl[Rl])return jl[Rl];sI(jl,Rl,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,n){this.listeners[e].push(n)}removeListener(e,n){let r=this.listeners[e],s=r.indexOf(n);s!==-1&&(s===0&&r.length===1?r.length=0:r.splice(s,1))}emit(e,n,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(n,r)===!0||s;return e==="exit"&&(s=this.emit("afterExit",n,r)||s),s}},Ui=class{},iI=t=>({onExit(e,n){return t.onExit(e,n)},load(){return t.load()},unload(){return t.unload()}}),Ml=class extends Ui{onExit(){return()=>{}}load(){}unload(){}},ql=class extends Ui{#n=Fl.platform==="win32"?"SIGINT":"SIGHUP";#t=new $l;#e;#i;#o;#s={};#r=!1;constructor(e){super(),this.#e=e,this.#s={};for(let n of Bi.signals)this.#s[n]=()=>{let r=this.#e.listeners(n),{count:s}=this.#t,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),r.length===s){this.unload();let o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#n:n;o||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#i=e.emit}onExit(e,n){if(!Di(this.#e))return()=>{};this.#r===!1&&this.load();let r=n?.alwaysLast?"afterExit":"exit";return this.#t.on(r,e),()=>{this.#t.removeListener(r,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(let e of Bi.signals)try{let n=this.#s[e];n&&this.#e.on(e,n)}catch{}this.#e.emit=(e,...n)=>this.#c(e,...n),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#r&&(this.#r=!1,Bi.signals.forEach(e=>{let n=this.#s[e];if(!n)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,n)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#o,this.#t.count-=1)}#a(e){return Di(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#o.call(this.#e,this.#e.exitCode)):0}#c(e,...n){let r=this.#i;if(e==="exit"&&Di(this.#e)){typeof n[0]=="number"&&(this.#e.exitCode=n[0]);let s=r.call(this.#e,e,...n);return this.#t.emit("exit",this.#e.exitCode,null),s}else return r.call(this.#e,e,...n)}},Fl=globalThis.process;Fi=iI(Di(Fl)?new ql(Fl):new Ml),nt.onExit=Fi.onExit,nt.load=Fi.load,nt.unload=Fi.unload});var Ki=S((mU,Jr)=>{"use strict";d();Jr.exports=dI;Jr.exports.sync=hI;Jr.exports._getTmpname=Bl;Jr.exports._cleanupOnExit=Dl;var ae=X("fs"),oI=Jy(),{onExit:Hy}=zy(),aI=X("path"),{promisify:$e}=X("util"),At={},cI=(function(){try{return X("worker_threads").threadId}catch{return 0}})(),lI=0;function Bl(t){return t+"."+oI(w).hash(String(process.pid)).hash(String(cI)).hash(String(++lI)).result()}function Dl(t){return()=>{try{ae.unlinkSync(typeof t=="function"?t():t)}catch{}}}function uI(t){return new Promise(e=>{At[t]||(At[t]=[]),At[t].push(e),At[t].length===1&&e()})}function Vi(t){return t.code==="ENOSYS"||(!process.getuid||process.getuid()!==0)&&(t.code==="EINVAL"||t.code==="EPERM")}async function fI(t,e,n={}){typeof n=="string"&&(n={encoding:n});let r,s,i=Hy(Dl(()=>s)),o=aI.resolve(t);try{await uI(o);let a=await $e(ae.realpath)(t).catch(()=>t);if(s=Bl(a),!n.mode||!n.chown){let c=await $e(ae.stat)(a).catch(()=>{});c&&(n.mode==null&&(n.mode=c.mode),n.chown==null&&process.getuid&&(n.chown={uid:c.uid,gid:c.gid}))}r=await $e(ae.open)(s,"w",n.mode),n.tmpfileCreated&&await n.tmpfileCreated(s),ArrayBuffer.isView(e)?await $e(ae.write)(r,e,0,e.length,0):e!=null&&await $e(ae.write)(r,String(e),0,String(n.encoding||"utf8")),n.fsync!==!1&&await $e(ae.fsync)(r),await $e(ae.close)(r),r=null,n.chown&&await $e(ae.chown)(s,n.chown.uid,n.chown.gid).catch(c=>{if(!Vi(c))throw c}),n.mode&&await $e(ae.chmod)(s,n.mode).catch(c=>{if(!Vi(c))throw c}),await $e(ae.rename)(s,a)}finally{r&&await $e(ae.close)(r).catch(()=>{}),i(),await $e(ae.unlink)(s).catch(()=>{}),At[o].shift(),At[o].length>0?At[o][0]():delete At[o]}}async function dI(t,e,n,r){n instanceof Function&&(r=n,n={});let s=fI(t,e,n);if(r)try{let i=await s;return r(i)}catch(i){return r(i)}return s}function hI(t,e,n){typeof n=="string"?n={encoding:n}:n||(n={});try{t=ae.realpathSync(t)}catch{}let r=Bl(t);if(!n.mode||!n.chown)try{let c=ae.statSync(t);n=Object.assign({},n),n.mode||(n.mode=c.mode),!n.chown&&process.getuid&&(n.chown={uid:c.uid,gid:c.gid})}catch{}let s,i=Dl(r),o=Hy(i),a=!0;try{if(s=ae.openSync(r,"w",n.mode||438),n.tmpfileCreated&&n.tmpfileCreated(r),ArrayBuffer.isView(e)?ae.writeSync(s,e,0,e.length,0):e!=null&&ae.writeSync(s,String(e),0,String(n.encoding||"utf8")),n.fsync!==!1&&ae.fsyncSync(s),ae.closeSync(s),s=null,n.chown)try{ae.chownSync(r,n.chown.uid,n.chown.gid)}catch(c){if(!Vi(c))throw c}if(n.mode)try{ae.chmodSync(r,n.mode)}catch(c){if(!Vi(c))throw c}ae.renameSync(r,t),a=!1}finally{if(s)try{ae.closeSync(s)}catch{}o(),a&&i()}}});var t_=S((CU,e_)=>{"use strict";d();var Pt=X("constants"),wI=process.cwd,Ji=null,bI=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Ji||(Ji=wI.call(process)),Ji};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Jl=process.chdir,process.chdir=function(t){Ji=null,Jl.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Jl));var Jl;e_.exports=vI;function vI(t){Pt.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||n(t),t.chown=i(t.chown),t.fchown=i(t.fchown),t.lchown=i(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=s(t.chmodSync),t.fchmodSync=s(t.fchmodSync),t.lchmodSync=s(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=c(t.statSync),t.fstatSync=c(t.fstatSync),t.lstatSync=c(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,f,h){h&&process.nextTick(h)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,f,h,g){g&&process.nextTick(g)},t.lchownSync=function(){}),bI==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(u){function f(h,g,p){var m=Date.now(),y=0;u(h,g,function b(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){t.stat(g,function(k,N){k&&k.code==="ENOENT"?u(h,g,b):p(v)})},y),y<100&&(y+=10);return}p&&p(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(u){function f(h,g,p,m,y,b){var v;if(b&&typeof b=="function"){var k=0;v=function(N,L,$){if(N&&N.code==="EAGAIN"&&k<10)return k++,u.call(t,h,g,p,m,y,v);b.apply(this,arguments)}}return u.call(t,h,g,p,m,y,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(u){return function(f,h,g,p,m){for(var y=0;;)try{return u.call(t,f,h,g,p,m)}catch(b){if(b.code==="EAGAIN"&&y<10){y++;continue}throw b}}})(t.readSync);function e(u){u.lchmod=function(f,h,g){u.open(f,Pt.O_WRONLY|Pt.O_SYMLINK,h,function(p,m){if(p){g&&g(p);return}u.fchmod(m,h,function(y){u.close(m,function(b){g&&g(y||b)})})})},u.lchmodSync=function(f,h){var g=u.openSync(f,Pt.O_WRONLY|Pt.O_SYMLINK,h),p=!0,m;try{m=u.fchmodSync(g,h),p=!1}finally{if(p)try{u.closeSync(g)}catch{}else u.closeSync(g)}return m}}function n(u){Pt.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(f,h,g,p){u.open(f,Pt.O_SYMLINK,function(m,y){if(m){p&&p(m);return}u.futimes(y,h,g,function(b){u.close(y,function(v){p&&p(b||v)})})})},u.lutimesSync=function(f,h,g){var p=u.openSync(f,Pt.O_SYMLINK),m,y=!0;try{m=u.futimesSync(p,h,g),y=!1}finally{if(y)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}):u.futimes&&(u.lutimes=function(f,h,g,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function r(u){return u&&function(f,h,g){return u.call(t,f,h,function(p){l(p)&&(p=null),g&&g.apply(this,arguments)})}}function s(u){return u&&function(f,h){try{return u.call(t,f,h)}catch(g){if(!l(g))throw g}}}function i(u){return u&&function(f,h,g,p){return u.call(t,f,h,g,function(m){l(m)&&(m=null),p&&p.apply(this,arguments)})}}function o(u){return u&&function(f,h,g){try{return u.call(t,f,h,g)}catch(p){if(!l(p))throw p}}}function a(u){return u&&function(f,h,g){typeof h=="function"&&(g=h,h=null);function p(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),g&&g.apply(this,arguments)}return h?u.call(t,f,h,p):u.call(t,f,p)}}function c(u){return u&&function(f,h){var g=h?u.call(t,f,h):u.call(t,f);return g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),g}}function l(u){if(!u||u.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var s_=S((PU,r_)=>{"use strict";d();var n_=X("stream").Stream;r_.exports=SI;function SI(t){return{ReadStream:e,WriteStream:n};function e(r,s){if(!(this instanceof e))return new e(r,s);n_.call(this);var i=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,s=s||{};for(var o=Object.keys(s),a=0,c=o.length;a<c;a++){var l=o[a];this[l]=s[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}t.open(this.path,this.flags,this.mode,function(u,f){if(u){i.emit("error",u),i.readable=!1;return}i.fd=f,i.emit("open",f),i._read()})}function n(r,s){if(!(this instanceof n))return new n(r,s);n_.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var i=Object.keys(s),o=0,a=i.length;o<a;o++){var c=i[o];this[c]=s[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var o_=S((RU,i_)=>{"use strict";d();i_.exports=kI;var EI=Object.getPrototypeOf||function(t){return t.__proto__};function kI(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:EI(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}});var Zl=S(($U,Hl)=>{"use strict";d();var le=X("fs"),xI=t_(),TI=s_(),OI=o_(),Yi=X("util"),_e,Hi;typeof Symbol=="function"&&typeof Symbol.for=="function"?(_e=Symbol.for("graceful-fs.queue"),Hi=Symbol.for("graceful-fs.previous")):(_e="___graceful-fs.queue",Hi="___graceful-fs.previous");function NI(){}function l_(t,e){Object.defineProperty(t,_e,{get:function(){return e}})}var dn=NI;Yi.debuglog?dn=Yi.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(dn=function(){var t=Yi.format.apply(Yi,arguments);t="GFS4: "+t.split(/\n/).join(`
169
- GFS4: `),console.error(t)});le[_e]||(a_=global[_e]||[],l_(le,a_),le.close=(function(t){function e(n,r){return t.call(le,n,function(s){s||c_(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(e,Hi,{value:t}),e})(le.close),le.closeSync=(function(t){function e(n){t.apply(le,arguments),c_()}return Object.defineProperty(e,Hi,{value:t}),e})(le.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){dn(le[_e]),X("assert").equal(le[_e].length,0)}));var a_;global[_e]||l_(global,le[_e]);Hl.exports=Yl(OI(le));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!le.__patched&&(Hl.exports=Yl(le),le.__patched=!0);function Yl(t){xI(t),t.gracefulify=Yl,t.createReadStream=L,t.createWriteStream=$;var e=t.readFile;t.readFile=n;function n(O,M,x){return typeof M=="function"&&(x=M,M=null),I(O,M,x);function I(j,U,J,D){return e(j,U,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?Jn([I,[j,U,J],Q,D||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var r=t.writeFile;t.writeFile=s;function s(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return r(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var i=t.appendFile;i&&(t.appendFile=o);function o(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return i(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=c);function c(O,M,x,I){return typeof x=="function"&&(I=x,x=0),j(O,M,x,I);function j(U,J,D,Q,re){return a(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=t.readdir;t.readdir=f;var u=/^v[0-5]\./;function f(O,M,x){typeof M=="function"&&(x=M,M=null);var I=u.test(process.version)?function(J,D,Q,re){return l(J,j(J,D,Q,re))}:function(J,D,Q,re){return l(J,D,j(J,D,Q,re))};return I(O,M,x);function j(U,J,D,Q){return function(re,ne){re&&(re.code==="EMFILE"||re.code==="ENFILE")?Jn([I,[U,J,D],re,Q||Date.now(),Date.now()]):(ne&&ne.sort&&ne.sort(),typeof D=="function"&&D.call(this,re,ne))}}}if(process.version.substr(0,4)==="v0.8"){var h=TI(t);b=h.ReadStream,k=h.WriteStream}var g=t.ReadStream;g&&(b.prototype=Object.create(g.prototype),b.prototype.open=v);var p=t.WriteStream;p&&(k.prototype=Object.create(p.prototype),k.prototype.open=N),Object.defineProperty(t,"ReadStream",{get:function(){return b},set:function(O){b=O},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return k},set:function(O){k=O},enumerable:!0,configurable:!0});var m=b;Object.defineProperty(t,"FileReadStream",{get:function(){return m},set:function(O){m=O},enumerable:!0,configurable:!0});var y=k;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(O){y=O},enumerable:!0,configurable:!0});function b(O,M){return this instanceof b?(g.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function v(){var O=this;E(O.path,O.flags,O.mode,function(M,x){M?(O.autoClose&&O.destroy(),O.emit("error",M)):(O.fd=x,O.emit("open",x),O.read())})}function k(O,M){return this instanceof k?(p.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function N(){var O=this;E(O.path,O.flags,O.mode,function(M,x){M?(O.destroy(),O.emit("error",M)):(O.fd=x,O.emit("open",x))})}function L(O,M){return new t.ReadStream(O,M)}function $(O,M){return new t.WriteStream(O,M)}var F=t.open;t.open=E;function E(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return F(U,J,D,function(ne,Xr){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return t}function Jn(t){dn("ENQUEUE",t[0].name,t[1]),le[_e].push(t),zl()}var zi;function c_(){for(var t=Date.now(),e=0;e<le[_e].length;++e)le[_e][e].length>2&&(le[_e][e][3]=t,le[_e][e][4]=t);zl()}function zl(){if(clearTimeout(zi),zi=void 0,le[_e].length!==0){var t=le[_e].shift(),e=t[0],n=t[1],r=t[2],s=t[3],i=t[4];if(s===void 0)dn("RETRY",e.name,n),e.apply(null,n);else if(Date.now()-s>=6e4){dn("TIMEOUT",e.name,n);var o=n.pop();typeof o=="function"&&o.call(null,r)}else{var a=Date.now()-i,c=Math.max(i-s,1),l=Math.min(c*1.2,100);a>=l?(dn("RETRY",e.name,n),e.apply(null,n.concat([s]))):le[_e].push(t)}zi===void 0&&(zi=setTimeout(zl,0))}}});var f_=S((qU,u_)=>{"use strict";d();function Me(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}u_.exports=Me;Me.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Me.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Me.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,s=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&s.unref(),!0};Me.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Me.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Me.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Me.prototype.start=Me.prototype.try;Me.prototype.errors=function(){return this._errors};Me.prototype.attempts=function(){return this._attempts};Me.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var s=this._errors[r],i=s.message,o=(t[i]||0)+1;t[i]=o,o>=n&&(e=s,n=o)}return e}});var d_=S(hn=>{"use strict";d();var AI=f_();hn.operation=function(t){var e=hn.timeouts(t);return new AI(e,{forever:t&&t.forever,unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};hn.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],s=0;s<e.retries;s++)r.push(this.createTimeout(s,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(s,e)),r.sort(function(i,o){return i-o}),r};hn.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*e.minTimeout*Math.pow(e.factor,t));return r=Math.min(r,e.maxTimeout),r};hn.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var r in t)typeof t[r]=="function"&&n.push(r)}for(var s=0;s<n.length;s++){var i=n[s],o=t[i];t[i]=function(c){var l=hn.operation(e),u=Array.prototype.slice.call(arguments,1),f=u.pop();u.push(function(h){l.retry(h)||(h&&(arguments[0]=l.mainError()),f.apply(this,arguments))}),l.attempt(function(){c.apply(t,u)})}.bind(t,o),t[i].options=e}}});var p_=S((UU,h_)=>{"use strict";d();h_.exports=d_()});var m_=S((KU,Zi)=>{"use strict";d();Zi.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Zi.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Zi.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var b_=S((WU,Hn)=>{"use strict";d();var ce=global.process,pn=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};pn(ce)?(g_=X("assert"),Yn=m_(),y_=/^win/i.test(ce.platform),Yr=X("events"),typeof Yr!="function"&&(Yr=Yr.EventEmitter),ce.__signal_exit_emitter__?me=ce.__signal_exit_emitter__:(me=ce.__signal_exit_emitter__=new Yr,me.count=0,me.emitted={}),me.infinite||(me.setMaxListeners(1/0),me.infinite=!0),Hn.exports=function(t,e){if(!pn(global.process))return function(){};g_.equal(typeof t,"function","a callback must be provided for exit handler"),zn===!1&&Xl();var n="exit";e&&e.alwaysLast&&(n="afterexit");var r=function(){me.removeListener(n,t),me.listeners("exit").length===0&&me.listeners("afterexit").length===0&&Xi()};return me.on(n,t),r},Xi=function(){!zn||!pn(global.process)||(zn=!1,Yn.forEach(function(e){try{ce.removeListener(e,Qi[e])}catch{}}),ce.emit=eo,ce.reallyExit=Ql,me.count-=1)},Hn.exports.unload=Xi,mn=function(e,n,r){me.emitted[e]||(me.emitted[e]=!0,me.emit(e,n,r))},Qi={},Yn.forEach(function(t){Qi[t]=function(){if(pn(global.process)){var n=ce.listeners(t);n.length===me.count&&(Xi(),mn("exit",null,t),mn("afterexit",null,t),y_&&t==="SIGHUP"&&(t="SIGINT"),ce.kill(ce.pid,t))}}}),Hn.exports.signals=function(){return Yn},zn=!1,Xl=function(){zn||!pn(global.process)||(zn=!0,me.count+=1,Yn=Yn.filter(function(e){try{return ce.on(e,Qi[e]),!0}catch{return!1}}),ce.emit=w_,ce.reallyExit=__)},Hn.exports.load=Xl,Ql=ce.reallyExit,__=function(e){pn(global.process)&&(ce.exitCode=e||0,mn("exit",ce.exitCode,null),mn("afterexit",ce.exitCode,null),Ql.call(ce,ce.exitCode))},eo=ce.emit,w_=function(e,n){if(e==="exit"&&pn(global.process)){n!==void 0&&(ce.exitCode=n);var r=eo.apply(this,arguments);return mn("exit",ce.exitCode,null),mn("afterexit",ce.exitCode,null),r}else return eo.apply(this,arguments)}):Hn.exports=function(){return function(){}};var g_,Yn,y_,Yr,me,Xi,mn,Qi,zn,Xl,Ql,__,eo,w_});var S_=S((YU,eu)=>{"use strict";d();var v_=Symbol();function CI(t,e,n){let r=e[v_];if(r)return e.stat(t,(i,o)=>{if(i)return n(i);n(null,o.mtime,r)});let s=new Date(Math.ceil(Date.now()/1e3)*1e3+5);e.utimes(t,s,s,i=>{if(i)return n(i);e.stat(t,(o,a)=>{if(o)return n(o);let c=a.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(e,v_,{value:c}),n(null,a.mtime,c)})})}function II(t){let e=Date.now();return t==="s"&&(e=Math.ceil(e/1e3)*1e3),new Date(e)}eu.exports.probe=CI;eu.exports.getMtime=II});var O_=S((HU,Hr)=>{"use strict";d();var PI=X("path"),ru=Zl(),LI=p_(),RI=b_(),E_=S_(),dt={};function zr(t,e){return e.lockfilePath||`${t}.lock`}function su(t,e,n){if(!e.realpath)return n(null,PI.resolve(t));e.fs.realpath(t,n)}function nu(t,e,n){let r=zr(t,e);e.fs.mkdir(r,s=>{if(!s)return E_.probe(r,e.fs,(i,o,a)=>{if(i)return e.fs.rmdir(r,()=>{}),n(i);n(null,o,a)});if(s.code!=="EEXIST")return n(s);if(e.stale<=0)return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:t}));e.fs.stat(r,(i,o)=>{if(i)return i.code==="ENOENT"?nu(t,{...e,stale:0},n):n(i);if(!k_(o,e))return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:t}));x_(t,e,a=>{if(a)return n(a);nu(t,{...e,stale:0},n)})})})}function k_(t,e){return t.mtime.getTime()<Date.now()-e.stale}function x_(t,e,n){e.fs.rmdir(zr(t,e),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function to(t,e){let n=dt[t];n.updateTimeout||(n.updateDelay=n.updateDelay||e.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,e.fs.stat(n.lockfilePath,(r,s)=>{let i=n.lastUpdate+e.stale<Date.now();if(r)return r.code==="ENOENT"||i?tu(t,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,to(t,e));if(!(n.mtime.getTime()===s.mtime.getTime()))return tu(t,n,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let a=E_.getMtime(n.mtimePrecision);e.fs.utimes(n.lockfilePath,a,a,c=>{let l=n.lastUpdate+e.stale<Date.now();if(!n.released){if(c)return c.code==="ENOENT"||l?tu(t,n,Object.assign(c,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,to(t,e));n.mtime=a,n.lastUpdate=Date.now(),n.updateDelay=null,to(t,e)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function tu(t,e,n){e.released=!0,e.updateTimeout&&clearTimeout(e.updateTimeout),dt[t]===e&&delete dt[t],e.options.onCompromised(n)}function jI(t,e,n){e={stale:1e4,update:null,realpath:!0,retries:0,fs:ru,onCompromised:r=>{throw r},...e},e.retries=e.retries||0,e.retries=typeof e.retries=="number"?{retries:e.retries}:e.retries,e.stale=Math.max(e.stale||0,2e3),e.update=e.update==null?e.stale/2:e.update||0,e.update=Math.max(Math.min(e.update,e.stale/2),1e3),su(t,e,(r,s)=>{if(r)return n(r);let i=LI.operation(e.retries);i.attempt(()=>{nu(s,e,(o,a,c)=>{if(i.retry(o))return;if(o)return n(i.mainError());let l=dt[s]={lockfilePath:zr(s,e),mtime:a,mtimePrecision:c,options:e,lastUpdate:Date.now()};to(s,e),n(null,u=>{if(l.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));T_(s,{...e,realpath:!1},u)})})})})}function T_(t,e,n){e={fs:ru,realpath:!0,...e},su(t,e,(r,s)=>{if(r)return n(r);let i=dt[s];if(!i)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete dt[s],x_(s,e,n)})}function $I(t,e,n){e={stale:1e4,realpath:!0,fs:ru,...e},e.stale=Math.max(e.stale||0,2e3),su(t,e,(r,s)=>{if(r)return n(r);e.fs.stat(zr(s,e),(i,o)=>i?i.code==="ENOENT"?n(null,!1):n(i):n(null,!k_(o,e)))})}function MI(){return dt}RI(()=>{for(let t in dt){let e=dt[t].options;try{e.fs.rmdirSync(zr(t,e))}catch{}}});Hr.exports.lock=jI;Hr.exports.unlock=T_;Hr.exports.check=$I;Hr.exports.getLocks=MI});var A_=S((XU,N_)=>{"use strict";d();var qI=Zl();function FI(t){let e=["mkdir","realpath","stat","rmdir","utimes"],n={...t};return e.forEach(r=>{n[r]=(...s)=>{let i=s.pop(),o;try{o=t[`${r}Sync`](...s)}catch(a){return i(a)}i(null,o)}}),n}function BI(t){return(...e)=>new Promise((n,r)=>{e.push((s,i)=>{s?r(s):n(i)}),t(...e)})}function DI(t){return(...e)=>{let n,r;if(e.push((s,i)=>{n=s,r=i}),t(...e),n)throw n;return r}}function UI(t){if(t={...t},t.fs=FI(t.fs||qI),typeof t.retries=="number"&&t.retries>0||t.retries&&typeof t.retries.retries=="number"&&t.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return t}N_.exports={toPromise:BI,toSync:DI,toSyncOptions:UI}});var ou=S((eV,Lt)=>{"use strict";d();var Zn=O_(),{toPromise:no,toSync:ro,toSyncOptions:iu}=A_();async function C_(t,e){let n=await no(Zn.lock)(t,e);return no(n)}function VI(t,e){let n=ro(Zn.lock)(t,iu(e));return ro(n)}function KI(t,e){return no(Zn.unlock)(t,e)}function GI(t,e){return ro(Zn.unlock)(t,iu(e))}function WI(t,e){return no(Zn.check)(t,e)}function JI(t,e){return ro(Zn.check)(t,iu(e))}Lt.exports=C_;Lt.exports.lock=C_;Lt.exports.unlock=KI;Lt.exports.lockSync=VI;Lt.exports.unlockSync=GI;Lt.exports.check=WI;Lt.exports.checkSync=JI});var C={};gw(C,{BRAND:()=>Ww,DIRTY:()=>jt,EMPTY_PATH:()=>kw,INVALID:()=>V,NEVER:()=>Cb,OK:()=>we,ParseStatus:()=>ge,Schema:()=>Y,ZodAny:()=>mt,ZodArray:()=>at,ZodBigInt:()=>Mt,ZodBoolean:()=>qt,ZodBranded:()=>er,ZodCatch:()=>zt,ZodDate:()=>Ft,ZodDefault:()=>Yt,ZodDiscriminatedUnion:()=>ts,ZodEffects:()=>Ie,ZodEnum:()=>Wt,ZodError:()=>ve,ZodFirstPartyTypeKind:()=>K,ZodFunction:()=>rs,ZodIntersection:()=>Vt,ZodIssueCode:()=>A,ZodLazy:()=>Kt,ZodLiteral:()=>Gt,ZodMap:()=>kn,ZodNaN:()=>Tn,ZodNativeEnum:()=>Jt,ZodNever:()=>Fe,ZodNull:()=>Dt,ZodNullable:()=>Ye,ZodNumber:()=>$t,ZodObject:()=>Se,ZodOptional:()=>Ae,ZodParsedType:()=>q,ZodPipeline:()=>tr,ZodPromise:()=>gt,ZodReadonly:()=>Ht,ZodRecord:()=>ns,ZodSchema:()=>Y,ZodSet:()=>xn,ZodString:()=>pt,ZodSymbol:()=>Sn,ZodTransformer:()=>Ie,ZodTuple:()=>Je,ZodType:()=>Y,ZodUndefined:()=>Bt,ZodUnion:()=>Ut,ZodUnknown:()=>ot,ZodVoid:()=>En,addIssueToContext:()=>R,any:()=>tb,array:()=>ib,bigint:()=>Hw,boolean:()=>Tu,coerce:()=>Ab,custom:()=>Eu,date:()=>Zw,datetimeRegex:()=>vu,defaultErrorMap:()=>st,discriminatedUnion:()=>lb,effect:()=>vb,enum:()=>_b,function:()=>mb,getErrorMap:()=>wn,getParsedType:()=>We,instanceof:()=>Yw,intersection:()=>ub,isAborted:()=>Qr,isAsync:()=>bn,isDirty:()=>es,isValid:()=>ht,late:()=>Jw,lazy:()=>gb,literal:()=>yb,makeIssue:()=>Qn,map:()=>hb,nan:()=>zw,nativeEnum:()=>wb,never:()=>rb,null:()=>eb,nullable:()=>Eb,number:()=>xu,object:()=>ob,objectUtil:()=>po,oboolean:()=>Nb,onumber:()=>Ob,optional:()=>Sb,ostring:()=>Tb,pipeline:()=>xb,preprocess:()=>kb,promise:()=>bb,quotelessJson:()=>vw,record:()=>db,set:()=>pb,setErrorMap:()=>Ew,strictObject:()=>ab,string:()=>ku,symbol:()=>Xw,transformer:()=>vb,tuple:()=>fb,undefined:()=>Qw,union:()=>cb,unknown:()=>nb,util:()=>z,void:()=>sb});d();d();d();d();d();var z;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(z||(z={}));var po;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(po||(po={}));var q=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),We=t=>{switch(typeof t){case"undefined":return q.undefined;case"string":return q.string;case"number":return Number.isNaN(t)?q.nan:q.number;case"boolean":return q.boolean;case"function":return q.function;case"bigint":return q.bigint;case"symbol":return q.symbol;case"object":return Array.isArray(t)?q.array:t===null?q.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?q.promise:typeof Map<"u"&&t instanceof Map?q.map:typeof Set<"u"&&t instanceof Set?q.set:typeof Date<"u"&&t instanceof Date?q.date:q.object;default:return q.unknown}};var A=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vw=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ve=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ve.create=t=>new ve(t);var Sw=(t,e)=>{let n;switch(t.code){case A.invalid_type:t.received===q.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case A.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,z.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:n=`Unrecognized key(s) in object: ${z.joinValues(t.keys,", ")}`;break;case A.invalid_union:n="Invalid input";break;case A.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${z.joinValues(t.options)}`;break;case A.invalid_enum_value:n=`Invalid enum value. Expected ${z.joinValues(t.options)}, received '${t.received}'`;break;case A.invalid_arguments:n="Invalid function arguments";break;case A.invalid_return_type:n="Invalid function return type";break;case A.invalid_date:n="Invalid date";break;case A.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:z.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case A.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case A.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case A.custom:n="Invalid input";break;case A.invalid_intersection_types:n="Intersection results could not be merged";break;case A.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case A.not_finite:n="Number must be finite";break;default:n=e.defaultError,z.assertNever(t)}return{message:n}},st=Sw;var gu=st;function Ew(t){gu=t}function wn(){return gu}d();var Qn=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},kw=[];function R(t,e){let n=wn(),r=Qn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===st?void 0:st].filter(s=>!!s)});t.common.issues.push(r)}var ge=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return V;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return V;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},V=Object.freeze({status:"aborted"}),jt=t=>({status:"dirty",value:t}),we=t=>({status:"valid",value:t}),Qr=t=>t.status==="aborted",es=t=>t.status==="dirty",ht=t=>t.status==="valid",bn=t=>typeof Promise<"u"&&t instanceof Promise;d();d();var B;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(B||(B={}));var Ce=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},yu=(t,e)=>{if(ht(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ve(t.common.issues);return this._error=n,this._error}}};function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}var Y=class{get description(){return this._def.description}_getType(e){return We(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:We(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ge,ctx:{common:e.parent.common,data:e.data,parsedType:We(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(bn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)},s=this._parseSync({data:e,path:r.path,parent:r});return yu(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ht(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ht(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(bn(s)?s:Promise.resolve(s));return yu(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:A.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new Ie({schema:this,typeName:K.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ae.create(this,this._def)}nullable(){return Ye.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return at.create(this)}promise(){return gt.create(this,this._def)}or(e){return Ut.create([this,e],this._def)}and(e){return Vt.create(this,e,this._def)}transform(e){return new Ie({...G(this._def),schema:this,typeName:K.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Yt({...G(this._def),innerType:this,defaultValue:n,typeName:K.ZodDefault})}brand(){return new er({typeName:K.ZodBranded,type:this,...G(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new zt({...G(this._def),innerType:this,catchValue:n,typeName:K.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tr.create(this,e)}readonly(){return Ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xw=/^c[^\s-]{8,}$/i,Tw=/^[0-9a-z]+$/,Ow=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Nw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Aw=/^[a-z0-9_-]{21}$/i,Cw=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Iw=/^[-+]?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)?)??$/,Pw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mo,Rw=/^(?:(?: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])$/,jw=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$w=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Mw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fw=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wu="((\\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])))",Bw=new RegExp(`^${wu}$`);function bu(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Dw(t){return new RegExp(`^${bu(t)}$`)}function vu(t){let e=`${wu}T${bu(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Uw(t,e){return!!((e==="v4"||!e)&&Rw.test(t)||(e==="v6"||!e)&&$w.test(t))}function Vw(t,e){if(!Cw.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Kw(t,e){return!!((e==="v4"||!e)&&jw.test(t)||(e==="v6"||!e)&&Mw.test(t))}var pt=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==q.string){let i=this._getOrReturnCtx(e);return R(i,{code:A.invalid_type,expected:q.string,received:i.parsedType}),V}let r=new ge,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?R(s,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&R(s,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Pw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"email",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")mo||(mo=new RegExp(Lw,"u")),mo.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"emoji",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Nw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"uuid",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Aw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"nanoid",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cuid",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Tw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cuid2",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Ow.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"ulid",code:A.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),R(s,{validation:"url",code:A.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"regex",code:A.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?vu(i).test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Bw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Dw(i).test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:A.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Iw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"duration",code:A.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Uw(e.data,i.version)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"ip",code:A.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Vw(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"jwt",code:A.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Kw(e.data,i.version)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cidr",code:A.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?qw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"base64",code:A.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Fw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"base64url",code:A.invalid_string,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:A.invalid_string,...B.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...B.errToObj(e)})}url(e){return this._addCheck({kind:"url",...B.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...B.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...B.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...B.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...B.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...B.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...B.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...B.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...B.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...B.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...B.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...B.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...B.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...B.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...B.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...B.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...B.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...B.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...B.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...B.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...B.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...B.errToObj(n)})}nonempty(e){return this.min(1,B.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};pt.create=t=>new pt({checks:[],typeName:K.ZodString,coerce:t?.coerce??!1,...G(t)});function Gw(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var $t=class t extends Y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==q.number){let i=this._getOrReturnCtx(e);return R(i,{code:A.invalid_type,expected:q.number,received:i.parsedType}),V}let r,s=new ge;for(let i of this._def.checks)i.kind==="int"?z.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:A.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Gw(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:A.not_finite,message:i.message}),s.dirty()):z.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,B.toString(n))}gt(e,n){return this.setLimit("min",e,!1,B.toString(n))}lte(e,n){return this.setLimit("max",e,!0,B.toString(n))}lt(e,n){return this.setLimit("max",e,!1,B.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:B.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:B.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:B.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:B.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:B.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:B.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:B.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&z.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};$t.create=t=>new $t({checks:[],typeName:K.ZodNumber,coerce:t?.coerce||!1,...G(t)});var Mt=class t extends Y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==q.bigint)return this._getInvalidInput(e);let r,s=new ge;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),R(r,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):z.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return R(n,{code:A.invalid_type,expected:q.bigint,received:n.parsedType}),V}gte(e,n){return this.setLimit("min",e,!0,B.toString(n))}gt(e,n){return this.setLimit("min",e,!1,B.toString(n))}lte(e,n){return this.setLimit("max",e,!0,B.toString(n))}lt(e,n){return this.setLimit("max",e,!1,B.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:B.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:B.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:B.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Mt.create=t=>new Mt({checks:[],typeName:K.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var qt=class extends Y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==q.boolean){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.boolean,received:r.parsedType}),V}return we(e.data)}};qt.create=t=>new qt({typeName:K.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var Ft=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==q.date){let i=this._getOrReturnCtx(e);return R(i,{code:A.invalid_type,expected:q.date,received:i.parsedType}),V}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return R(i,{code:A.invalid_date}),V}let r=new ge,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:A.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:A.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):z.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:B.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:B.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ft.create=t=>new Ft({checks:[],coerce:t?.coerce||!1,typeName:K.ZodDate,...G(t)});var Sn=class extends Y{_parse(e){if(this._getType(e)!==q.symbol){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.symbol,received:r.parsedType}),V}return we(e.data)}};Sn.create=t=>new Sn({typeName:K.ZodSymbol,...G(t)});var Bt=class extends Y{_parse(e){if(this._getType(e)!==q.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.undefined,received:r.parsedType}),V}return we(e.data)}};Bt.create=t=>new Bt({typeName:K.ZodUndefined,...G(t)});var Dt=class extends Y{_parse(e){if(this._getType(e)!==q.null){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.null,received:r.parsedType}),V}return we(e.data)}};Dt.create=t=>new Dt({typeName:K.ZodNull,...G(t)});var mt=class extends Y{constructor(){super(...arguments),this._any=!0}_parse(e){return we(e.data)}};mt.create=t=>new mt({typeName:K.ZodAny,...G(t)});var ot=class extends Y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return we(e.data)}};ot.create=t=>new ot({typeName:K.ZodUnknown,...G(t)});var Fe=class extends Y{_parse(e){let n=this._getOrReturnCtx(e);return R(n,{code:A.invalid_type,expected:q.never,received:n.parsedType}),V}};Fe.create=t=>new Fe({typeName:K.ZodNever,...G(t)});var En=class extends Y{_parse(e){if(this._getType(e)!==q.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.void,received:r.parsedType}),V}return we(e.data)}};En.create=t=>new En({typeName:K.ZodVoid,...G(t)});var at=class t extends Y{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==q.array)return R(n,{code:A.invalid_type,expected:q.array,received:n.parsedType}),V;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(R(n,{code:o?A.too_big:A.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(R(n,{code:A.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(R(n,{code:A.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new Ce(n,o,n.path,a)))).then(o=>ge.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new Ce(n,o,n.path,a)));return ge.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:B.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:B.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:B.toString(n)}})}nonempty(e){return this.min(1,e)}};at.create=(t,e)=>new at({type:t,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...G(e)});function vn(t){if(t instanceof Se){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ae.create(vn(r))}return new Se({...t._def,shape:()=>e})}else return t instanceof at?new at({...t._def,type:vn(t.element)}):t instanceof Ae?Ae.create(vn(t.unwrap())):t instanceof Ye?Ye.create(vn(t.unwrap())):t instanceof Je?Je.create(t.items.map(e=>vn(e))):t}var Se=class t extends Y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=z.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==q.object){let l=this._getOrReturnCtx(e);return R(l,{code:A.invalid_type,expected:q.object,received:l.parsedType}),V}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let l in s.data)o.includes(l)||a.push(l);let c=[];for(let l of o){let u=i[l],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Ce(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Fe){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(R(s,{code:A.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Ce(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let f=await u.key,h=await u.value;l.push({key:f,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>ge.mergeObjectSync(r,l)):ge.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return B.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:B.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:K.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of z.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of z.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return vn(this)}partial(e){let n={};for(let r of z.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of z.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ae;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Su(z.objectKeys(this.shape))}};Se.create=(t,e)=>new Se({shape:()=>t,unknownKeys:"strip",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});Se.strictCreate=(t,e)=>new Se({shape:()=>t,unknownKeys:"strict",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});Se.lazycreate=(t,e)=>new Se({shape:t,unknownKeys:"strip",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});var Ut=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new ve(a.ctx.common.issues));return R(n,{code:A.invalid_union,unionErrors:o}),V}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new ve(c));return R(n,{code:A.invalid_union,unionErrors:a}),V}}get options(){return this._def.options}};Ut.create=(t,e)=>new Ut({options:t,typeName:K.ZodUnion,...G(e)});var it=t=>t instanceof Kt?it(t.schema):t instanceof Ie?it(t.innerType()):t instanceof Gt?[t.value]:t instanceof Wt?t.options:t instanceof Jt?z.objectValues(t.enum):t instanceof Yt?it(t._def.innerType):t instanceof Bt?[void 0]:t instanceof Dt?[null]:t instanceof Ae?[void 0,...it(t.unwrap())]:t instanceof Ye?[null,...it(t.unwrap())]:t instanceof er||t instanceof Ht?it(t.unwrap()):t instanceof zt?it(t._def.innerType):[],ts=class t extends Y{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.object)return R(n,{code:A.invalid_type,expected:q.object,received:n.parsedType}),V;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(R(n,{code:A.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=it(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:K.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...G(r)})}};function go(t,e){let n=We(t),r=We(e);if(t===e)return{valid:!0,data:t};if(n===q.object&&r===q.object){let s=z.objectKeys(e),i=z.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=go(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===q.array&&r===q.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=go(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===q.date&&r===q.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Vt=class extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Qr(i)||Qr(o))return V;let a=go(i.value,o.value);return a.valid?((es(i)||es(o))&&n.dirty(),{status:n.value,value:a.data}):(R(r,{code:A.invalid_intersection_types}),V)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Vt.create=(t,e,n)=>new Vt({left:t,right:e,typeName:K.ZodIntersection,...G(n)});var Je=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.array)return R(r,{code:A.invalid_type,expected:q.array,received:r.parsedType}),V;if(r.data.length<this._def.items.length)return R(r,{code:A.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&r.data.length>this._def.items.length&&(R(r,{code:A.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Ce(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>ge.mergeArray(n,o)):ge.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Je.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Je({items:t,typeName:K.ZodTuple,rest:null,...G(e)})};var ns=class t extends Y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.object)return R(r,{code:A.invalid_type,expected:q.object,received:r.parsedType}),V;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new Ce(r,a,r.path,a)),value:o._parse(new Ce(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ge.mergeObjectAsync(n,s):ge.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof Y?new t({keyType:e,valueType:n,typeName:K.ZodRecord,...G(r)}):new t({keyType:pt.create(),valueType:e,typeName:K.ZodRecord,...G(n)})}},kn=class extends Y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.map)return R(r,{code:A.invalid_type,expected:q.map,received:r.parsedType}),V;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new Ce(r,a,r.path,[l,"key"])),value:i._parse(new Ce(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return V;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return V;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};kn.create=(t,e,n)=>new kn({valueType:e,keyType:t,typeName:K.ZodMap,...G(n)});var xn=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.set)return R(r,{code:A.invalid_type,expected:q.set,received:r.parsedType}),V;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(R(r,{code:A.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(R(r,{code:A.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return V;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>i._parse(new Ce(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:B.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:B.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};xn.create=(t,e)=>new xn({valueType:t,minSize:null,maxSize:null,typeName:K.ZodSet,...G(e)});var rs=class t extends Y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.function)return R(n,{code:A.invalid_type,expected:q.function,received:n.parsedType}),V;function r(a,c){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wn(),st].filter(l=>!!l),issueData:{code:A.invalid_arguments,argumentsError:c}})}function s(a,c){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wn(),st].filter(l=>!!l),issueData:{code:A.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof gt){let a=this;return we(async function(...c){let l=new ve([]),u=await a._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(r(c,g)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw l.addIssue(s(f,g)),l})})}else{let a=this;return we(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new ve([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new ve([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Je.create(e).rest(ot.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Je.create([]).rest(ot.create()),returns:n||ot.create(),typeName:K.ZodFunction,...G(r)})}},Kt=class extends Y{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Kt.create=(t,e)=>new Kt({getter:t,typeName:K.ZodLazy,...G(e)});var Gt=class extends Y{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return R(n,{received:n.data,code:A.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:e.data}}get value(){return this._def.value}};Gt.create=(t,e)=>new Gt({value:t,typeName:K.ZodLiteral,...G(e)});function Su(t,e){return new Wt({values:t,typeName:K.ZodEnum,...G(e)})}var Wt=class t extends Y{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return R(n,{expected:z.joinValues(r),received:n.parsedType,code:A.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return R(n,{received:n.data,code:A.invalid_enum_value,options:r}),V}return we(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Wt.create=Su;var Jt=class extends Y{_parse(e){let n=z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==q.string&&r.parsedType!==q.number){let s=z.objectValues(n);return R(r,{expected:z.joinValues(s),received:r.parsedType,code:A.invalid_type}),V}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=z.objectValues(n);return R(r,{received:r.data,code:A.invalid_enum_value,options:s}),V}return we(e.data)}get enum(){return this._def.values}};Jt.create=(t,e)=>new Jt({values:t,typeName:K.ZodNativeEnum,...G(e)});var gt=class extends Y{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.promise&&n.common.async===!1)return R(n,{code:A.invalid_type,expected:q.promise,received:n.parsedType}),V;let r=n.parsedType===q.promise?n.data:Promise.resolve(n.data);return we(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};gt.create=(t,e)=>new gt({type:t,typeName:K.ZodPromise,...G(e)});var Ie=class extends Y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{R(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return V;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?V:c.status==="dirty"?jt(c.value):n.value==="dirty"?jt(c.value):c});{if(n.value==="aborted")return V;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?V:a.status==="dirty"?jt(a.value):n.value==="dirty"?jt(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?V:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?V:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ht(o))return V;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ht(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):V);z.assertNever(s)}};Ie.create=(t,e,n)=>new Ie({schema:t,typeName:K.ZodEffects,effect:e,...G(n)});Ie.createWithPreprocess=(t,e,n)=>new Ie({schema:e,effect:{type:"preprocess",transform:t},typeName:K.ZodEffects,...G(n)});var Ae=class extends Y{_parse(e){return this._getType(e)===q.undefined?we(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ae.create=(t,e)=>new Ae({innerType:t,typeName:K.ZodOptional,...G(e)});var Ye=class extends Y{_parse(e){return this._getType(e)===q.null?we(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:K.ZodNullable,...G(e)});var Yt=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===q.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Yt.create=(t,e)=>new Yt({innerType:t,typeName:K.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var zt=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return bn(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};zt.create=(t,e)=>new zt({innerType:t,typeName:K.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var Tn=class extends Y{_parse(e){if(this._getType(e)!==q.nan){let r=this._getOrReturnCtx(e);return R(r,{code:A.invalid_type,expected:q.nan,received:r.parsedType}),V}return{status:"valid",value:e.data}}};Tn.create=t=>new Tn({typeName:K.ZodNaN,...G(t)});var Ww=Symbol("zod_brand"),er=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},tr=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?V:i.status==="dirty"?(n.dirty(),jt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?V:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:K.ZodPipeline})}},Ht=class extends Y{_parse(e){let n=this._def.innerType._parse(e),r=s=>(ht(s)&&(s.value=Object.freeze(s.value)),s);return bn(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Ht.create=(t,e)=>new Ht({innerType:t,typeName:K.ZodReadonly,...G(e)});function _u(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Eu(t,e={},n){return t?mt.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=_u(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=_u(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):mt.create()}var Jw={object:Se.lazycreate},K;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(K||(K={}));var Yw=(t,e={message:`Input not instance of ${t.name}`})=>Eu(n=>n instanceof t,e),ku=pt.create,xu=$t.create,zw=Tn.create,Hw=Mt.create,Tu=qt.create,Zw=Ft.create,Xw=Sn.create,Qw=Bt.create,eb=Dt.create,tb=mt.create,nb=ot.create,rb=Fe.create,sb=En.create,ib=at.create,ob=Se.create,ab=Se.strictCreate,cb=Ut.create,lb=ts.create,ub=Vt.create,fb=Je.create,db=ns.create,hb=kn.create,pb=xn.create,mb=rs.create,gb=Kt.create,yb=Gt.create,_b=Wt.create,wb=Jt.create,bb=gt.create,vb=Ie.create,Sb=Ae.create,Eb=Ye.create,kb=Ie.createWithPreprocess,xb=tr.create,Tb=()=>ku().optional(),Ob=()=>xu().optional(),Nb=()=>Tu().optional(),Ab={string:(t=>pt.create({...t,coerce:!0})),number:(t=>$t.create({...t,coerce:!0})),boolean:(t=>qt.create({...t,coerce:!0})),bigint:(t=>Mt.create({...t,coerce:!0})),date:(t=>Ft.create({...t,coerce:!0}))};var Cb=V;d();d();var jd=H(oe(),1),mk=3e4,ba=class{baseUrl;apiKey;timeoutMs;accessToken;constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey,this.accessToken=e.accessToken,this.timeoutMs=e.timeoutMs??mk}async searchTools(e){return this.post("/v1/search",e)}async searchToolsRespond(e){return this.post("/v1/search/respond",e)}async checkCompatibility(e){return this.post("/v1/graph/compatibility",e)}async compareTools(e){return this.post("/v1/graph/compare",e)}async getStack(e){return this.post("/v1/graph/stack",e)}async refineRequirement(e){return this.post("/v1/intelligence/refine",e)}async verifySuggestion(e){return this.post("/v1/intelligence/verify",e)}async checkIssue(e){return this.post("/v1/intelligence/issue",e)}async batchResolve(e){let n=[],r=new Map,s=new Map;if(e.length===0)return{results:[],warnings:n,methods:r,githubUrls:s};try{let i=await this.rawPost("/v1/tools/batch-resolve",{api_version:"1",tools:e});if(i.status===404)return n.push({scope:"batch-resolve",message:"/v1/tools/batch-resolve not deployed on this engine \u2014 falling back to offline classification (source: non_oss)."}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};if(!i.ok)return n.push({scope:"batch-resolve",message:`batch-resolve returned HTTP ${i.status} \u2014 all tools marked as non_oss.`}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};let o=await i.json();if(!Array.isArray(o.resolved))return n.push({scope:"batch-resolve",message:"batch-resolve returned unexpected body shape \u2014 falling back."}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};let a=[];for(let c of o.resolved){let l=c.match_method??(c.matched?"tool_name_exact":"none"),u=c.matched??l!=="none",f=`${c.input.ecosystem}:${c.input.name}`;r.set(f,l),c.tool?.github_url&&s.set(f,c.tool.github_url),a.push({input:c.input,matched:u,match_method:l,tool:c.tool})}return{results:a,warnings:n,methods:r,githubUrls:s}}catch(i){return n.push({scope:"batch-resolve",message:`batch-resolve network failure: ${i instanceof Error?i.message:String(i)}. Tools classified as non_oss.`}),{results:e.map(o=>({input:o,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s}}}async reportOutcome(e){return this.post("/v1/feedback/outcome",e)}async suggestGraphUpdate(e){return this.post("/v1/feedback/suggest",e)}async register(e){return(await this.rawPost("/v1/register",{client_id:e})).json()}async healthCheck(){try{return(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(5e3)})).ok}catch{return!1}}async post(e,n){try{let r=await this.rawPost(e,n);if(r.status===429&&r.headers.get("x-toolcairn-limit-exhausted")==="1")try{return{content:[{type:"text",text:(await r.clone().json()).message??"ToolCairn daily limit reached. Join the Pro waitlist for 1 month free: https://toolcairn.neurynae.com/waitlist?source=limit_exhausted"}]}}catch{}let s=await r.json();return s&&typeof s=="object"&&"content"in s?s:{content:[{type:"text",text:JSON.stringify(s)}]}}catch(r){let s=r instanceof Error?r.message:String(r);return{content:[{type:"text",text:JSON.stringify({ok:!1,error:jd.ErrorCode.ERR_NETWORK_UNREACHABLE,message:`ToolCairn API unreachable: ${s}. Check your internet connection or try again later.`})}],isError:!0}}}rawPost(e,n){let r={"Content-Type":"application/json","X-ToolCairn-Key":this.apiKey,"Accept-Encoding":"gzip"};return this.accessToken&&(r.Authorization=`Bearer ${this.accessToken}`),fetch(`${this.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:AbortSignal.timeout(this.timeoutMs)})}};d();import{chmod as $d,mkdir as gk,readFile as Md,writeFile as yk}from"fs/promises";import{homedir as _k}from"os";import{join as Sa}from"path";var Ns=Sa(_k(),".toolcairn"),qd=Sa(Ns,"credentials.json"),Ea=Sa(Ns,"pending-auth.json"),va=process.platform==="win32";async function Fd(t,e){if(await gk(Ns,{recursive:!0,mode:va?void 0:448}),await yk(t,e,{encoding:"utf-8",mode:va?void 0:384}),!va){try{await $d(t,384)}catch{}try{await $d(Ns,448)}catch{}}}async function ka(t){await Fd(Ea,JSON.stringify(t,null,2))}async function xa(){try{let t=await Md(Ea,"utf-8"),e=JSON.parse(t);return new Date(e.expires_at)<new Date?(await or(),null):e}catch{return null}}async function or(){try{let{unlink:t}=await import("fs/promises");await t(Ea)}catch{}}function wk(t){if(!t.access_token)return!1;try{let e=t.access_token.split(".");if(e.length!==3)return!1;let n=JSON.parse(Buffer.from(e[1]??"","base64url").toString("utf-8"));return!(n.exp&&n.exp<Date.now()/1e3+300)}catch{return!1}}async function Bd(){try{let t=await Md(qd,"utf-8");return JSON.parse(t)}catch{return null}}async function Ta(){let t=await Bd();if(t)return t;let e={client_id:crypto.randomUUID(),created_at:new Date().toISOString()};return await As(e),e}async function As(t){await Fd(qd,JSON.stringify(t,null,2))}async function Oa(t,e,n){let r=await Ta();await As({...r,client_id:e,access_token:t,user_id:n.id,user_email:n.email??void 0,user_name:n.name??void 0,authenticated_at:new Date().toISOString()})}async function bk(){let t=await Ta();await As({client_id:t.client_id,created_at:t.created_at,api_url:t.api_url})}d();var lt=H(oe(),1);async function vk(t){let{spawn:e}=await import("child_process");try{let n=process.platform,r,s;n==="win32"?(r="cmd",s=["/c","start","",t]):n==="darwin"?(r="open",s=[t]):(r="xdg-open",s=[t]),e(r,s,{detached:!0,stdio:"ignore",shell:!1}).unref()}catch{}}async function Dd(t){let e=await fetch(`${t}/v1/auth/device-code`,{method:"POST"});if(!e.ok)throw new lt.NetworkError({code:lt.ErrorCode.ERR_NETWORK_UNREACHABLE,message:"Failed to start device auth. Check your internet connection."});let n=await e.json();return await ka({device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_at:new Date(Date.now()+n.expires_in*1e3).toISOString(),api_url:t}),process.stderr.write(`
168
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Nt.prototype.build=function(t){return this.options.preserveOrder?SA(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};Nt.prototype.j2x=function(t,e,n){let r="",s="",i=n.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(s+="");else if(t[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?s+="":o[0]==="?"?s+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)s+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){let a=this.isAttribute(o);if(a&&!this.ignoreAttributesFn(a,i))r+=this.buildAttrPairStr(a,""+t[o]);else if(!a)if(o===this.options.textNodeName){let c=this.options.tagValueProcessor(o,""+t[o]);s+=this.replaceEntitiesValue(c)}else s+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){let a=t[o].length,c="",l="";for(let u=0;u<a;u++){let f=t[o][u];if(!(typeof f>"u"))if(f===null)o[0]==="?"?s+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){let h=this.j2x(f,e+1,n.concat(o));c+=h.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(l+=h.attrStr)}else c+=this.processTextOrObjNode(f,o,e,n);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(o,f);h=this.replaceEntitiesValue(h),c+=h}else c+=this.buildTextValNode(f,o,"",e)}this.options.oneListGroup&&(c=this.buildObjectNode(c,o,l,e)),s+=c}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let a=Object.keys(t[o]),c=a.length;for(let l=0;l<c;l++)r+=this.buildAttrPairStr(a[l],""+t[o][a[l]])}else s+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:s}};Nt.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function xA(t,e,n,r){let s=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,s.attrStr,n):this.buildObjectNode(s.val,e,s.attrStr,n)}Nt.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let s="</"+e+this.tagEndChar,i="";return e[0]==="?"&&(i="?",s=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+i+">"+t+s:this.options.commentPropName!==!1&&e===this.options.commentPropName&&i.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+i+this.tagEndChar+t+this.indentate(r)+s}};Nt.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};Nt.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(e,t);return s=this.replaceEntitiesValue(s),s===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+s+"</"+e+this.tagEndChar}};Nt.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){let n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function TA(t){return this.options.indentBy.repeat(t)}function OA(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}Ag.exports=Nt});var Kr=S((lF,Ig)=>{"use strict";d();var NA=ul(),AA=kg(),CA=Cg();Ig.exports={XMLParser:AA,XMLValidator:NA,XMLBuilder:CA}});var Jy=S((uU,Ll)=>{"use strict";d();(function(){var t;function e(n,r){var s=this instanceof e?this:t;if(s.reset(r),typeof n=="string"&&n.length>0&&s.hash(n),s!==this)return s}e.prototype.hash=function(n){var r,s,i,o,a;switch(a=n.length,this.len+=a,s=this.k1,i=0,this.rem){case 0:s^=a>i?n.charCodeAt(i++)&65535:0;case 1:s^=a>i?(n.charCodeAt(i++)&65535)<<8:0;case 2:s^=a>i?(n.charCodeAt(i++)&65535)<<16:0;case 3:s^=a>i?(n.charCodeAt(i)&255)<<24:0,s^=a>i?(n.charCodeAt(i++)&65280)>>8:0}if(this.rem=a+this.rem&3,a-=this.rem,a>0){for(r=this.h1;s=s*11601+(s&65535)*3432906752&4294967295,s=s<<15|s>>>17,s=s*13715+(s&65535)*461832192&4294967295,r^=s,r=r<<13|r>>>19,r=r*5+3864292196&4294967295,!(i>=a);)s=n.charCodeAt(i++)&65535^(n.charCodeAt(i++)&65535)<<8^(n.charCodeAt(i++)&65535)<<16,o=n.charCodeAt(i++),s^=(o&255)<<24^(o&65280)>>8;switch(s=0,this.rem){case 3:s^=(n.charCodeAt(i+2)&65535)<<16;case 2:s^=(n.charCodeAt(i+1)&65535)<<8;case 1:s^=n.charCodeAt(i)&65535}this.h1=r}return this.k1=s,this},e.prototype.result=function(){var n,r;return n=this.k1,r=this.h1,n>0&&(n=n*11601+(n&65535)*3432906752&4294967295,n=n<<15|n>>>17,n=n*13715+(n&65535)*461832192&4294967295,r^=n),r^=this.len,r^=r>>>16,r=r*51819+(r&65535)*2246770688&4294967295,r^=r>>>13,r=r*44597+(r&65535)*3266445312&4294967295,r^=r>>>16,r>>>0},e.prototype.reset=function(n){return this.h1=typeof n=="number"?n:0,this.rem=this.k1=this.len=0,this},t=new e,typeof Ll<"u"?Ll.exports=e:this.MurmurHash3=e})()});var Yy=S(fn=>{"use strict";d();Object.defineProperty(fn,"__esModule",{value:!0});fn.signals=void 0;fn.signals=[];fn.signals.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&fn.signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&fn.signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});var zy=S(nt=>{"use strict";d();var Fi;Object.defineProperty(nt,"__esModule",{value:!0});nt.unload=nt.load=nt.onExit=nt.signals=void 0;var Bi=Yy();Object.defineProperty(nt,"signals",{enumerable:!0,get:function(){return Bi.signals}});var Di=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Rl=Symbol.for("signal-exit emitter"),jl=globalThis,sI=Object.defineProperty.bind(Object),$l=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(jl[Rl])return jl[Rl];sI(jl,Rl,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,n){this.listeners[e].push(n)}removeListener(e,n){let r=this.listeners[e],s=r.indexOf(n);s!==-1&&(s===0&&r.length===1?r.length=0:r.splice(s,1))}emit(e,n,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(n,r)===!0||s;return e==="exit"&&(s=this.emit("afterExit",n,r)||s),s}},Ui=class{},iI=t=>({onExit(e,n){return t.onExit(e,n)},load(){return t.load()},unload(){return t.unload()}}),Ml=class extends Ui{onExit(){return()=>{}}load(){}unload(){}},ql=class extends Ui{#n=Fl.platform==="win32"?"SIGINT":"SIGHUP";#t=new $l;#e;#i;#o;#s={};#r=!1;constructor(e){super(),this.#e=e,this.#s={};for(let n of Bi.signals)this.#s[n]=()=>{let r=this.#e.listeners(n),{count:s}=this.#t,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),r.length===s){this.unload();let o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#n:n;o||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#i=e.emit}onExit(e,n){if(!Di(this.#e))return()=>{};this.#r===!1&&this.load();let r=n?.alwaysLast?"afterExit":"exit";return this.#t.on(r,e),()=>{this.#t.removeListener(r,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(let e of Bi.signals)try{let n=this.#s[e];n&&this.#e.on(e,n)}catch{}this.#e.emit=(e,...n)=>this.#c(e,...n),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#r&&(this.#r=!1,Bi.signals.forEach(e=>{let n=this.#s[e];if(!n)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,n)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#o,this.#t.count-=1)}#a(e){return Di(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#o.call(this.#e,this.#e.exitCode)):0}#c(e,...n){let r=this.#i;if(e==="exit"&&Di(this.#e)){typeof n[0]=="number"&&(this.#e.exitCode=n[0]);let s=r.call(this.#e,e,...n);return this.#t.emit("exit",this.#e.exitCode,null),s}else return r.call(this.#e,e,...n)}},Fl=globalThis.process;Fi=iI(Di(Fl)?new ql(Fl):new Ml),nt.onExit=Fi.onExit,nt.load=Fi.load,nt.unload=Fi.unload});var Ki=S((gU,Jr)=>{"use strict";d();Jr.exports=dI;Jr.exports.sync=hI;Jr.exports._getTmpname=Bl;Jr.exports._cleanupOnExit=Dl;var ae=X("fs"),oI=Jy(),{onExit:Hy}=zy(),aI=X("path"),{promisify:$e}=X("util"),At={},cI=(function(){try{return X("worker_threads").threadId}catch{return 0}})(),lI=0;function Bl(t){return t+"."+oI(w).hash(String(process.pid)).hash(String(cI)).hash(String(++lI)).result()}function Dl(t){return()=>{try{ae.unlinkSync(typeof t=="function"?t():t)}catch{}}}function uI(t){return new Promise(e=>{At[t]||(At[t]=[]),At[t].push(e),At[t].length===1&&e()})}function Vi(t){return t.code==="ENOSYS"||(!process.getuid||process.getuid()!==0)&&(t.code==="EINVAL"||t.code==="EPERM")}async function fI(t,e,n={}){typeof n=="string"&&(n={encoding:n});let r,s,i=Hy(Dl(()=>s)),o=aI.resolve(t);try{await uI(o);let a=await $e(ae.realpath)(t).catch(()=>t);if(s=Bl(a),!n.mode||!n.chown){let c=await $e(ae.stat)(a).catch(()=>{});c&&(n.mode==null&&(n.mode=c.mode),n.chown==null&&process.getuid&&(n.chown={uid:c.uid,gid:c.gid}))}r=await $e(ae.open)(s,"w",n.mode),n.tmpfileCreated&&await n.tmpfileCreated(s),ArrayBuffer.isView(e)?await $e(ae.write)(r,e,0,e.length,0):e!=null&&await $e(ae.write)(r,String(e),0,String(n.encoding||"utf8")),n.fsync!==!1&&await $e(ae.fsync)(r),await $e(ae.close)(r),r=null,n.chown&&await $e(ae.chown)(s,n.chown.uid,n.chown.gid).catch(c=>{if(!Vi(c))throw c}),n.mode&&await $e(ae.chmod)(s,n.mode).catch(c=>{if(!Vi(c))throw c}),await $e(ae.rename)(s,a)}finally{r&&await $e(ae.close)(r).catch(()=>{}),i(),await $e(ae.unlink)(s).catch(()=>{}),At[o].shift(),At[o].length>0?At[o][0]():delete At[o]}}async function dI(t,e,n,r){n instanceof Function&&(r=n,n={});let s=fI(t,e,n);if(r)try{let i=await s;return r(i)}catch(i){return r(i)}return s}function hI(t,e,n){typeof n=="string"?n={encoding:n}:n||(n={});try{t=ae.realpathSync(t)}catch{}let r=Bl(t);if(!n.mode||!n.chown)try{let c=ae.statSync(t);n=Object.assign({},n),n.mode||(n.mode=c.mode),!n.chown&&process.getuid&&(n.chown={uid:c.uid,gid:c.gid})}catch{}let s,i=Dl(r),o=Hy(i),a=!0;try{if(s=ae.openSync(r,"w",n.mode||438),n.tmpfileCreated&&n.tmpfileCreated(r),ArrayBuffer.isView(e)?ae.writeSync(s,e,0,e.length,0):e!=null&&ae.writeSync(s,String(e),0,String(n.encoding||"utf8")),n.fsync!==!1&&ae.fsyncSync(s),ae.closeSync(s),s=null,n.chown)try{ae.chownSync(r,n.chown.uid,n.chown.gid)}catch(c){if(!Vi(c))throw c}if(n.mode)try{ae.chmodSync(r,n.mode)}catch(c){if(!Vi(c))throw c}ae.renameSync(r,t),a=!1}finally{if(s)try{ae.closeSync(s)}catch{}o(),a&&i()}}});var t_=S((IU,e_)=>{"use strict";d();var Pt=X("constants"),wI=process.cwd,Ji=null,bI=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Ji||(Ji=wI.call(process)),Ji};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Jl=process.chdir,process.chdir=function(t){Ji=null,Jl.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Jl));var Jl;e_.exports=vI;function vI(t){Pt.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||n(t),t.chown=i(t.chown),t.fchown=i(t.fchown),t.lchown=i(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=s(t.chmodSync),t.fchmodSync=s(t.fchmodSync),t.lchmodSync=s(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=c(t.statSync),t.fstatSync=c(t.fstatSync),t.lstatSync=c(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,f,h){h&&process.nextTick(h)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,f,h,g){g&&process.nextTick(g)},t.lchownSync=function(){}),bI==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(u){function f(h,g,p){var m=Date.now(),y=0;u(h,g,function b(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){t.stat(g,function(k,N){k&&k.code==="ENOENT"?u(h,g,b):p(v)})},y),y<100&&(y+=10);return}p&&p(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(u){function f(h,g,p,m,y,b){var v;if(b&&typeof b=="function"){var k=0;v=function(N,L,$){if(N&&N.code==="EAGAIN"&&k<10)return k++,u.call(t,h,g,p,m,y,v);b.apply(this,arguments)}}return u.call(t,h,g,p,m,y,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(u){return function(f,h,g,p,m){for(var y=0;;)try{return u.call(t,f,h,g,p,m)}catch(b){if(b.code==="EAGAIN"&&y<10){y++;continue}throw b}}})(t.readSync);function e(u){u.lchmod=function(f,h,g){u.open(f,Pt.O_WRONLY|Pt.O_SYMLINK,h,function(p,m){if(p){g&&g(p);return}u.fchmod(m,h,function(y){u.close(m,function(b){g&&g(y||b)})})})},u.lchmodSync=function(f,h){var g=u.openSync(f,Pt.O_WRONLY|Pt.O_SYMLINK,h),p=!0,m;try{m=u.fchmodSync(g,h),p=!1}finally{if(p)try{u.closeSync(g)}catch{}else u.closeSync(g)}return m}}function n(u){Pt.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(f,h,g,p){u.open(f,Pt.O_SYMLINK,function(m,y){if(m){p&&p(m);return}u.futimes(y,h,g,function(b){u.close(y,function(v){p&&p(b||v)})})})},u.lutimesSync=function(f,h,g){var p=u.openSync(f,Pt.O_SYMLINK),m,y=!0;try{m=u.futimesSync(p,h,g),y=!1}finally{if(y)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}):u.futimes&&(u.lutimes=function(f,h,g,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function r(u){return u&&function(f,h,g){return u.call(t,f,h,function(p){l(p)&&(p=null),g&&g.apply(this,arguments)})}}function s(u){return u&&function(f,h){try{return u.call(t,f,h)}catch(g){if(!l(g))throw g}}}function i(u){return u&&function(f,h,g,p){return u.call(t,f,h,g,function(m){l(m)&&(m=null),p&&p.apply(this,arguments)})}}function o(u){return u&&function(f,h,g){try{return u.call(t,f,h,g)}catch(p){if(!l(p))throw p}}}function a(u){return u&&function(f,h,g){typeof h=="function"&&(g=h,h=null);function p(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),g&&g.apply(this,arguments)}return h?u.call(t,f,h,p):u.call(t,f,p)}}function c(u){return u&&function(f,h){var g=h?u.call(t,f,h):u.call(t,f);return g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),g}}function l(u){if(!u||u.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var s_=S((LU,r_)=>{"use strict";d();var n_=X("stream").Stream;r_.exports=SI;function SI(t){return{ReadStream:e,WriteStream:n};function e(r,s){if(!(this instanceof e))return new e(r,s);n_.call(this);var i=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,s=s||{};for(var o=Object.keys(s),a=0,c=o.length;a<c;a++){var l=o[a];this[l]=s[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}t.open(this.path,this.flags,this.mode,function(u,f){if(u){i.emit("error",u),i.readable=!1;return}i.fd=f,i.emit("open",f),i._read()})}function n(r,s){if(!(this instanceof n))return new n(r,s);n_.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var i=Object.keys(s),o=0,a=i.length;o<a;o++){var c=i[o];this[c]=s[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var o_=S((jU,i_)=>{"use strict";d();i_.exports=kI;var EI=Object.getPrototypeOf||function(t){return t.__proto__};function kI(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:EI(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}});var Zl=S((MU,Hl)=>{"use strict";d();var le=X("fs"),xI=t_(),TI=s_(),OI=o_(),Yi=X("util"),_e,Hi;typeof Symbol=="function"&&typeof Symbol.for=="function"?(_e=Symbol.for("graceful-fs.queue"),Hi=Symbol.for("graceful-fs.previous")):(_e="___graceful-fs.queue",Hi="___graceful-fs.previous");function NI(){}function l_(t,e){Object.defineProperty(t,_e,{get:function(){return e}})}var dn=NI;Yi.debuglog?dn=Yi.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(dn=function(){var t=Yi.format.apply(Yi,arguments);t="GFS4: "+t.split(/\n/).join(`
169
+ GFS4: `),console.error(t)});le[_e]||(a_=global[_e]||[],l_(le,a_),le.close=(function(t){function e(n,r){return t.call(le,n,function(s){s||c_(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(e,Hi,{value:t}),e})(le.close),le.closeSync=(function(t){function e(n){t.apply(le,arguments),c_()}return Object.defineProperty(e,Hi,{value:t}),e})(le.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){dn(le[_e]),X("assert").equal(le[_e].length,0)}));var a_;global[_e]||l_(global,le[_e]);Hl.exports=Yl(OI(le));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!le.__patched&&(Hl.exports=Yl(le),le.__patched=!0);function Yl(t){xI(t),t.gracefulify=Yl,t.createReadStream=L,t.createWriteStream=$;var e=t.readFile;t.readFile=n;function n(O,M,x){return typeof M=="function"&&(x=M,M=null),I(O,M,x);function I(j,U,J,D){return e(j,U,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?Jn([I,[j,U,J],Q,D||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var r=t.writeFile;t.writeFile=s;function s(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return r(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var i=t.appendFile;i&&(t.appendFile=o);function o(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return i(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=c);function c(O,M,x,I){return typeof x=="function"&&(I=x,x=0),j(O,M,x,I);function j(U,J,D,Q,re){return a(U,J,D,function(ne){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=t.readdir;t.readdir=f;var u=/^v[0-5]\./;function f(O,M,x){typeof M=="function"&&(x=M,M=null);var I=u.test(process.version)?function(J,D,Q,re){return l(J,j(J,D,Q,re))}:function(J,D,Q,re){return l(J,D,j(J,D,Q,re))};return I(O,M,x);function j(U,J,D,Q){return function(re,ne){re&&(re.code==="EMFILE"||re.code==="ENFILE")?Jn([I,[U,J,D],re,Q||Date.now(),Date.now()]):(ne&&ne.sort&&ne.sort(),typeof D=="function"&&D.call(this,re,ne))}}}if(process.version.substr(0,4)==="v0.8"){var h=TI(t);b=h.ReadStream,k=h.WriteStream}var g=t.ReadStream;g&&(b.prototype=Object.create(g.prototype),b.prototype.open=v);var p=t.WriteStream;p&&(k.prototype=Object.create(p.prototype),k.prototype.open=N),Object.defineProperty(t,"ReadStream",{get:function(){return b},set:function(O){b=O},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return k},set:function(O){k=O},enumerable:!0,configurable:!0});var m=b;Object.defineProperty(t,"FileReadStream",{get:function(){return m},set:function(O){m=O},enumerable:!0,configurable:!0});var y=k;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(O){y=O},enumerable:!0,configurable:!0});function b(O,M){return this instanceof b?(g.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function v(){var O=this;E(O.path,O.flags,O.mode,function(M,x){M?(O.autoClose&&O.destroy(),O.emit("error",M)):(O.fd=x,O.emit("open",x),O.read())})}function k(O,M){return this instanceof k?(p.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function N(){var O=this;E(O.path,O.flags,O.mode,function(M,x){M?(O.destroy(),O.emit("error",M)):(O.fd=x,O.emit("open",x))})}function L(O,M){return new t.ReadStream(O,M)}function $(O,M){return new t.WriteStream(O,M)}var F=t.open;t.open=E;function E(O,M,x,I){return typeof x=="function"&&(I=x,x=null),j(O,M,x,I);function j(U,J,D,Q,re){return F(U,J,D,function(ne,Xr){ne&&(ne.code==="EMFILE"||ne.code==="ENFILE")?Jn([j,[U,J,D,Q],ne,re||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return t}function Jn(t){dn("ENQUEUE",t[0].name,t[1]),le[_e].push(t),zl()}var zi;function c_(){for(var t=Date.now(),e=0;e<le[_e].length;++e)le[_e][e].length>2&&(le[_e][e][3]=t,le[_e][e][4]=t);zl()}function zl(){if(clearTimeout(zi),zi=void 0,le[_e].length!==0){var t=le[_e].shift(),e=t[0],n=t[1],r=t[2],s=t[3],i=t[4];if(s===void 0)dn("RETRY",e.name,n),e.apply(null,n);else if(Date.now()-s>=6e4){dn("TIMEOUT",e.name,n);var o=n.pop();typeof o=="function"&&o.call(null,r)}else{var a=Date.now()-i,c=Math.max(i-s,1),l=Math.min(c*1.2,100);a>=l?(dn("RETRY",e.name,n),e.apply(null,n.concat([s]))):le[_e].push(t)}zi===void 0&&(zi=setTimeout(zl,0))}}});var f_=S((FU,u_)=>{"use strict";d();function Me(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}u_.exports=Me;Me.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Me.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Me.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,s=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&s.unref(),!0};Me.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Me.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Me.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Me.prototype.start=Me.prototype.try;Me.prototype.errors=function(){return this._errors};Me.prototype.attempts=function(){return this._attempts};Me.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var s=this._errors[r],i=s.message,o=(t[i]||0)+1;t[i]=o,o>=n&&(e=s,n=o)}return e}});var d_=S(hn=>{"use strict";d();var AI=f_();hn.operation=function(t){var e=hn.timeouts(t);return new AI(e,{forever:t&&t.forever,unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};hn.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],s=0;s<e.retries;s++)r.push(this.createTimeout(s,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(s,e)),r.sort(function(i,o){return i-o}),r};hn.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*e.minTimeout*Math.pow(e.factor,t));return r=Math.min(r,e.maxTimeout),r};hn.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var r in t)typeof t[r]=="function"&&n.push(r)}for(var s=0;s<n.length;s++){var i=n[s],o=t[i];t[i]=function(c){var l=hn.operation(e),u=Array.prototype.slice.call(arguments,1),f=u.pop();u.push(function(h){l.retry(h)||(h&&(arguments[0]=l.mainError()),f.apply(this,arguments))}),l.attempt(function(){c.apply(t,u)})}.bind(t,o),t[i].options=e}}});var p_=S((VU,h_)=>{"use strict";d();h_.exports=d_()});var m_=S((GU,Zi)=>{"use strict";d();Zi.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Zi.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Zi.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var b_=S((JU,Hn)=>{"use strict";d();var ce=global.process,pn=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};pn(ce)?(g_=X("assert"),Yn=m_(),y_=/^win/i.test(ce.platform),Yr=X("events"),typeof Yr!="function"&&(Yr=Yr.EventEmitter),ce.__signal_exit_emitter__?me=ce.__signal_exit_emitter__:(me=ce.__signal_exit_emitter__=new Yr,me.count=0,me.emitted={}),me.infinite||(me.setMaxListeners(1/0),me.infinite=!0),Hn.exports=function(t,e){if(!pn(global.process))return function(){};g_.equal(typeof t,"function","a callback must be provided for exit handler"),zn===!1&&Xl();var n="exit";e&&e.alwaysLast&&(n="afterexit");var r=function(){me.removeListener(n,t),me.listeners("exit").length===0&&me.listeners("afterexit").length===0&&Xi()};return me.on(n,t),r},Xi=function(){!zn||!pn(global.process)||(zn=!1,Yn.forEach(function(e){try{ce.removeListener(e,Qi[e])}catch{}}),ce.emit=eo,ce.reallyExit=Ql,me.count-=1)},Hn.exports.unload=Xi,mn=function(e,n,r){me.emitted[e]||(me.emitted[e]=!0,me.emit(e,n,r))},Qi={},Yn.forEach(function(t){Qi[t]=function(){if(pn(global.process)){var n=ce.listeners(t);n.length===me.count&&(Xi(),mn("exit",null,t),mn("afterexit",null,t),y_&&t==="SIGHUP"&&(t="SIGINT"),ce.kill(ce.pid,t))}}}),Hn.exports.signals=function(){return Yn},zn=!1,Xl=function(){zn||!pn(global.process)||(zn=!0,me.count+=1,Yn=Yn.filter(function(e){try{return ce.on(e,Qi[e]),!0}catch{return!1}}),ce.emit=w_,ce.reallyExit=__)},Hn.exports.load=Xl,Ql=ce.reallyExit,__=function(e){pn(global.process)&&(ce.exitCode=e||0,mn("exit",ce.exitCode,null),mn("afterexit",ce.exitCode,null),Ql.call(ce,ce.exitCode))},eo=ce.emit,w_=function(e,n){if(e==="exit"&&pn(global.process)){n!==void 0&&(ce.exitCode=n);var r=eo.apply(this,arguments);return mn("exit",ce.exitCode,null),mn("afterexit",ce.exitCode,null),r}else return eo.apply(this,arguments)}):Hn.exports=function(){return function(){}};var g_,Yn,y_,Yr,me,Xi,mn,Qi,zn,Xl,Ql,__,eo,w_});var S_=S((zU,eu)=>{"use strict";d();var v_=Symbol();function CI(t,e,n){let r=e[v_];if(r)return e.stat(t,(i,o)=>{if(i)return n(i);n(null,o.mtime,r)});let s=new Date(Math.ceil(Date.now()/1e3)*1e3+5);e.utimes(t,s,s,i=>{if(i)return n(i);e.stat(t,(o,a)=>{if(o)return n(o);let c=a.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(e,v_,{value:c}),n(null,a.mtime,c)})})}function II(t){let e=Date.now();return t==="s"&&(e=Math.ceil(e/1e3)*1e3),new Date(e)}eu.exports.probe=CI;eu.exports.getMtime=II});var O_=S((ZU,Hr)=>{"use strict";d();var PI=X("path"),ru=Zl(),LI=p_(),RI=b_(),E_=S_(),dt={};function zr(t,e){return e.lockfilePath||`${t}.lock`}function su(t,e,n){if(!e.realpath)return n(null,PI.resolve(t));e.fs.realpath(t,n)}function nu(t,e,n){let r=zr(t,e);e.fs.mkdir(r,s=>{if(!s)return E_.probe(r,e.fs,(i,o,a)=>{if(i)return e.fs.rmdir(r,()=>{}),n(i);n(null,o,a)});if(s.code!=="EEXIST")return n(s);if(e.stale<=0)return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:t}));e.fs.stat(r,(i,o)=>{if(i)return i.code==="ENOENT"?nu(t,{...e,stale:0},n):n(i);if(!k_(o,e))return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:t}));x_(t,e,a=>{if(a)return n(a);nu(t,{...e,stale:0},n)})})})}function k_(t,e){return t.mtime.getTime()<Date.now()-e.stale}function x_(t,e,n){e.fs.rmdir(zr(t,e),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function to(t,e){let n=dt[t];n.updateTimeout||(n.updateDelay=n.updateDelay||e.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,e.fs.stat(n.lockfilePath,(r,s)=>{let i=n.lastUpdate+e.stale<Date.now();if(r)return r.code==="ENOENT"||i?tu(t,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,to(t,e));if(!(n.mtime.getTime()===s.mtime.getTime()))return tu(t,n,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let a=E_.getMtime(n.mtimePrecision);e.fs.utimes(n.lockfilePath,a,a,c=>{let l=n.lastUpdate+e.stale<Date.now();if(!n.released){if(c)return c.code==="ENOENT"||l?tu(t,n,Object.assign(c,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,to(t,e));n.mtime=a,n.lastUpdate=Date.now(),n.updateDelay=null,to(t,e)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function tu(t,e,n){e.released=!0,e.updateTimeout&&clearTimeout(e.updateTimeout),dt[t]===e&&delete dt[t],e.options.onCompromised(n)}function jI(t,e,n){e={stale:1e4,update:null,realpath:!0,retries:0,fs:ru,onCompromised:r=>{throw r},...e},e.retries=e.retries||0,e.retries=typeof e.retries=="number"?{retries:e.retries}:e.retries,e.stale=Math.max(e.stale||0,2e3),e.update=e.update==null?e.stale/2:e.update||0,e.update=Math.max(Math.min(e.update,e.stale/2),1e3),su(t,e,(r,s)=>{if(r)return n(r);let i=LI.operation(e.retries);i.attempt(()=>{nu(s,e,(o,a,c)=>{if(i.retry(o))return;if(o)return n(i.mainError());let l=dt[s]={lockfilePath:zr(s,e),mtime:a,mtimePrecision:c,options:e,lastUpdate:Date.now()};to(s,e),n(null,u=>{if(l.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));T_(s,{...e,realpath:!1},u)})})})})}function T_(t,e,n){e={fs:ru,realpath:!0,...e},su(t,e,(r,s)=>{if(r)return n(r);let i=dt[s];if(!i)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete dt[s],x_(s,e,n)})}function $I(t,e,n){e={stale:1e4,realpath:!0,fs:ru,...e},e.stale=Math.max(e.stale||0,2e3),su(t,e,(r,s)=>{if(r)return n(r);e.fs.stat(zr(s,e),(i,o)=>i?i.code==="ENOENT"?n(null,!1):n(i):n(null,!k_(o,e)))})}function MI(){return dt}RI(()=>{for(let t in dt){let e=dt[t].options;try{e.fs.rmdirSync(zr(t,e))}catch{}}});Hr.exports.lock=jI;Hr.exports.unlock=T_;Hr.exports.check=$I;Hr.exports.getLocks=MI});var A_=S((QU,N_)=>{"use strict";d();var qI=Zl();function FI(t){let e=["mkdir","realpath","stat","rmdir","utimes"],n={...t};return e.forEach(r=>{n[r]=(...s)=>{let i=s.pop(),o;try{o=t[`${r}Sync`](...s)}catch(a){return i(a)}i(null,o)}}),n}function BI(t){return(...e)=>new Promise((n,r)=>{e.push((s,i)=>{s?r(s):n(i)}),t(...e)})}function DI(t){return(...e)=>{let n,r;if(e.push((s,i)=>{n=s,r=i}),t(...e),n)throw n;return r}}function UI(t){if(t={...t},t.fs=FI(t.fs||qI),typeof t.retries=="number"&&t.retries>0||t.retries&&typeof t.retries.retries=="number"&&t.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return t}N_.exports={toPromise:BI,toSync:DI,toSyncOptions:UI}});var ou=S((tV,Lt)=>{"use strict";d();var Zn=O_(),{toPromise:no,toSync:ro,toSyncOptions:iu}=A_();async function C_(t,e){let n=await no(Zn.lock)(t,e);return no(n)}function VI(t,e){let n=ro(Zn.lock)(t,iu(e));return ro(n)}function KI(t,e){return no(Zn.unlock)(t,e)}function GI(t,e){return ro(Zn.unlock)(t,iu(e))}function WI(t,e){return no(Zn.check)(t,e)}function JI(t,e){return ro(Zn.check)(t,iu(e))}Lt.exports=C_;Lt.exports.lock=C_;Lt.exports.unlock=KI;Lt.exports.lockSync=VI;Lt.exports.unlockSync=GI;Lt.exports.check=WI;Lt.exports.checkSync=JI});var A={};gw(A,{BRAND:()=>Ww,DIRTY:()=>jt,EMPTY_PATH:()=>kw,INVALID:()=>V,NEVER:()=>Cb,OK:()=>we,ParseStatus:()=>ge,Schema:()=>Y,ZodAny:()=>mt,ZodArray:()=>at,ZodBigInt:()=>Mt,ZodBoolean:()=>qt,ZodBranded:()=>er,ZodCatch:()=>zt,ZodDate:()=>Ft,ZodDefault:()=>Yt,ZodDiscriminatedUnion:()=>ts,ZodEffects:()=>Ie,ZodEnum:()=>Wt,ZodError:()=>ve,ZodFirstPartyTypeKind:()=>K,ZodFunction:()=>rs,ZodIntersection:()=>Vt,ZodIssueCode:()=>C,ZodLazy:()=>Kt,ZodLiteral:()=>Gt,ZodMap:()=>kn,ZodNaN:()=>Tn,ZodNativeEnum:()=>Jt,ZodNever:()=>Fe,ZodNull:()=>Dt,ZodNullable:()=>Ye,ZodNumber:()=>$t,ZodObject:()=>Se,ZodOptional:()=>Ae,ZodParsedType:()=>q,ZodPipeline:()=>tr,ZodPromise:()=>gt,ZodReadonly:()=>Ht,ZodRecord:()=>ns,ZodSchema:()=>Y,ZodSet:()=>xn,ZodString:()=>pt,ZodSymbol:()=>Sn,ZodTransformer:()=>Ie,ZodTuple:()=>Je,ZodType:()=>Y,ZodUndefined:()=>Bt,ZodUnion:()=>Ut,ZodUnknown:()=>ot,ZodVoid:()=>En,addIssueToContext:()=>R,any:()=>tb,array:()=>ib,bigint:()=>Hw,boolean:()=>Tu,coerce:()=>Ab,custom:()=>Eu,date:()=>Zw,datetimeRegex:()=>vu,defaultErrorMap:()=>st,discriminatedUnion:()=>lb,effect:()=>vb,enum:()=>_b,function:()=>mb,getErrorMap:()=>wn,getParsedType:()=>We,instanceof:()=>Yw,intersection:()=>ub,isAborted:()=>Qr,isAsync:()=>bn,isDirty:()=>es,isValid:()=>ht,late:()=>Jw,lazy:()=>gb,literal:()=>yb,makeIssue:()=>Qn,map:()=>hb,nan:()=>zw,nativeEnum:()=>wb,never:()=>rb,null:()=>eb,nullable:()=>Eb,number:()=>xu,object:()=>ob,objectUtil:()=>po,oboolean:()=>Nb,onumber:()=>Ob,optional:()=>Sb,ostring:()=>Tb,pipeline:()=>xb,preprocess:()=>kb,promise:()=>bb,quotelessJson:()=>vw,record:()=>db,set:()=>pb,setErrorMap:()=>Ew,strictObject:()=>ab,string:()=>ku,symbol:()=>Xw,transformer:()=>vb,tuple:()=>fb,undefined:()=>Qw,union:()=>cb,unknown:()=>nb,util:()=>z,void:()=>sb});d();d();d();d();d();var z;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(z||(z={}));var po;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(po||(po={}));var q=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),We=t=>{switch(typeof t){case"undefined":return q.undefined;case"string":return q.string;case"number":return Number.isNaN(t)?q.nan:q.number;case"boolean":return q.boolean;case"function":return q.function;case"bigint":return q.bigint;case"symbol":return q.symbol;case"object":return Array.isArray(t)?q.array:t===null?q.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?q.promise:typeof Map<"u"&&t instanceof Map?q.map:typeof Set<"u"&&t instanceof Set?q.set:typeof Date<"u"&&t instanceof Date?q.date:q.object;default:return q.unknown}};var C=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vw=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ve=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ve.create=t=>new ve(t);var Sw=(t,e)=>{let n;switch(t.code){case C.invalid_type:t.received===q.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,z.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:n=`Unrecognized key(s) in object: ${z.joinValues(t.keys,", ")}`;break;case C.invalid_union:n="Invalid input";break;case C.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${z.joinValues(t.options)}`;break;case C.invalid_enum_value:n=`Invalid enum value. Expected ${z.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:n="Invalid function arguments";break;case C.invalid_return_type:n="Invalid function return type";break;case C.invalid_date:n="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:z.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case C.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case C.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case C.custom:n="Invalid input";break;case C.invalid_intersection_types:n="Intersection results could not be merged";break;case C.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:n="Number must be finite";break;default:n=e.defaultError,z.assertNever(t)}return{message:n}},st=Sw;var gu=st;function Ew(t){gu=t}function wn(){return gu}d();var Qn=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},kw=[];function R(t,e){let n=wn(),r=Qn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===st?void 0:st].filter(s=>!!s)});t.common.issues.push(r)}var ge=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return V;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return V;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},V=Object.freeze({status:"aborted"}),jt=t=>({status:"dirty",value:t}),we=t=>({status:"valid",value:t}),Qr=t=>t.status==="aborted",es=t=>t.status==="dirty",ht=t=>t.status==="valid",bn=t=>typeof Promise<"u"&&t instanceof Promise;d();d();var B;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(B||(B={}));var Ce=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},yu=(t,e)=>{if(ht(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ve(t.common.issues);return this._error=n,this._error}}};function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}var Y=class{get description(){return this._def.description}_getType(e){return We(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:We(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ge,ctx:{common:e.parent.common,data:e.data,parsedType:We(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(bn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)},s=this._parseSync({data:e,path:r.path,parent:r});return yu(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ht(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ht(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:We(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(bn(s)?s:Promise.resolve(s));return yu(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:C.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new Ie({schema:this,typeName:K.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ae.create(this,this._def)}nullable(){return Ye.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return at.create(this)}promise(){return gt.create(this,this._def)}or(e){return Ut.create([this,e],this._def)}and(e){return Vt.create(this,e,this._def)}transform(e){return new Ie({...G(this._def),schema:this,typeName:K.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Yt({...G(this._def),innerType:this,defaultValue:n,typeName:K.ZodDefault})}brand(){return new er({typeName:K.ZodBranded,type:this,...G(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new zt({...G(this._def),innerType:this,catchValue:n,typeName:K.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tr.create(this,e)}readonly(){return Ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xw=/^c[^\s-]{8,}$/i,Tw=/^[0-9a-z]+$/,Ow=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Nw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Aw=/^[a-z0-9_-]{21}$/i,Cw=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Iw=/^[-+]?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)?)??$/,Pw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mo,Rw=/^(?:(?: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])$/,jw=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$w=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Mw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fw=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wu="((\\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])))",Bw=new RegExp(`^${wu}$`);function bu(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Dw(t){return new RegExp(`^${bu(t)}$`)}function vu(t){let e=`${wu}T${bu(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Uw(t,e){return!!((e==="v4"||!e)&&Rw.test(t)||(e==="v6"||!e)&&$w.test(t))}function Vw(t,e){if(!Cw.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Kw(t,e){return!!((e==="v4"||!e)&&jw.test(t)||(e==="v6"||!e)&&Mw.test(t))}var pt=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==q.string){let i=this._getOrReturnCtx(e);return R(i,{code:C.invalid_type,expected:q.string,received:i.parsedType}),V}let r=new ge,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:C.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?R(s,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&R(s,{code:C.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Pw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"email",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")mo||(mo=new RegExp(Lw,"u")),mo.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"emoji",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Nw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"uuid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Aw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"nanoid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cuid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Tw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cuid2",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Ow.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"ulid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),R(s,{validation:"url",code:C.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"regex",code:C.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?vu(i).test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Bw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Dw(i).test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{code:C.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Iw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"duration",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Uw(e.data,i.version)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"ip",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Vw(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"jwt",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Kw(e.data,i.version)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"cidr",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?qw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"base64",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Fw.test(e.data)||(s=this._getOrReturnCtx(e,s),R(s,{validation:"base64url",code:C.invalid_string,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:C.invalid_string,...B.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...B.errToObj(e)})}url(e){return this._addCheck({kind:"url",...B.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...B.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...B.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...B.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...B.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...B.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...B.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...B.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...B.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...B.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...B.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...B.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...B.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...B.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...B.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...B.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...B.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...B.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...B.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...B.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...B.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...B.errToObj(n)})}nonempty(e){return this.min(1,B.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};pt.create=t=>new pt({checks:[],typeName:K.ZodString,coerce:t?.coerce??!1,...G(t)});function Gw(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var $t=class t extends Y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==q.number){let i=this._getOrReturnCtx(e);return R(i,{code:C.invalid_type,expected:q.number,received:i.parsedType}),V}let r,s=new ge;for(let i of this._def.checks)i.kind==="int"?z.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:C.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Gw(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:C.not_finite,message:i.message}),s.dirty()):z.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,B.toString(n))}gt(e,n){return this.setLimit("min",e,!1,B.toString(n))}lte(e,n){return this.setLimit("max",e,!0,B.toString(n))}lt(e,n){return this.setLimit("max",e,!1,B.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:B.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:B.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:B.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:B.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:B.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:B.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:B.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&z.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};$t.create=t=>new $t({checks:[],typeName:K.ZodNumber,coerce:t?.coerce||!1,...G(t)});var Mt=class t extends Y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==q.bigint)return this._getInvalidInput(e);let r,s=new ge;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),R(r,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):z.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return R(n,{code:C.invalid_type,expected:q.bigint,received:n.parsedType}),V}gte(e,n){return this.setLimit("min",e,!0,B.toString(n))}gt(e,n){return this.setLimit("min",e,!1,B.toString(n))}lte(e,n){return this.setLimit("max",e,!0,B.toString(n))}lt(e,n){return this.setLimit("max",e,!1,B.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:B.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:B.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:B.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Mt.create=t=>new Mt({checks:[],typeName:K.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var qt=class extends Y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==q.boolean){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.boolean,received:r.parsedType}),V}return we(e.data)}};qt.create=t=>new qt({typeName:K.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var Ft=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==q.date){let i=this._getOrReturnCtx(e);return R(i,{code:C.invalid_type,expected:q.date,received:i.parsedType}),V}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return R(i,{code:C.invalid_date}),V}let r=new ge,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:C.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),R(s,{code:C.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):z.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:B.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:B.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ft.create=t=>new Ft({checks:[],coerce:t?.coerce||!1,typeName:K.ZodDate,...G(t)});var Sn=class extends Y{_parse(e){if(this._getType(e)!==q.symbol){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.symbol,received:r.parsedType}),V}return we(e.data)}};Sn.create=t=>new Sn({typeName:K.ZodSymbol,...G(t)});var Bt=class extends Y{_parse(e){if(this._getType(e)!==q.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.undefined,received:r.parsedType}),V}return we(e.data)}};Bt.create=t=>new Bt({typeName:K.ZodUndefined,...G(t)});var Dt=class extends Y{_parse(e){if(this._getType(e)!==q.null){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.null,received:r.parsedType}),V}return we(e.data)}};Dt.create=t=>new Dt({typeName:K.ZodNull,...G(t)});var mt=class extends Y{constructor(){super(...arguments),this._any=!0}_parse(e){return we(e.data)}};mt.create=t=>new mt({typeName:K.ZodAny,...G(t)});var ot=class extends Y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return we(e.data)}};ot.create=t=>new ot({typeName:K.ZodUnknown,...G(t)});var Fe=class extends Y{_parse(e){let n=this._getOrReturnCtx(e);return R(n,{code:C.invalid_type,expected:q.never,received:n.parsedType}),V}};Fe.create=t=>new Fe({typeName:K.ZodNever,...G(t)});var En=class extends Y{_parse(e){if(this._getType(e)!==q.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.void,received:r.parsedType}),V}return we(e.data)}};En.create=t=>new En({typeName:K.ZodVoid,...G(t)});var at=class t extends Y{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==q.array)return R(n,{code:C.invalid_type,expected:q.array,received:n.parsedType}),V;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(R(n,{code:o?C.too_big:C.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(R(n,{code:C.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(R(n,{code:C.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new Ce(n,o,n.path,a)))).then(o=>ge.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new Ce(n,o,n.path,a)));return ge.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:B.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:B.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:B.toString(n)}})}nonempty(e){return this.min(1,e)}};at.create=(t,e)=>new at({type:t,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...G(e)});function vn(t){if(t instanceof Se){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ae.create(vn(r))}return new Se({...t._def,shape:()=>e})}else return t instanceof at?new at({...t._def,type:vn(t.element)}):t instanceof Ae?Ae.create(vn(t.unwrap())):t instanceof Ye?Ye.create(vn(t.unwrap())):t instanceof Je?Je.create(t.items.map(e=>vn(e))):t}var Se=class t extends Y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=z.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==q.object){let l=this._getOrReturnCtx(e);return R(l,{code:C.invalid_type,expected:q.object,received:l.parsedType}),V}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let l in s.data)o.includes(l)||a.push(l);let c=[];for(let l of o){let u=i[l],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Ce(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Fe){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(R(s,{code:C.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Ce(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let f=await u.key,h=await u.value;l.push({key:f,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>ge.mergeObjectSync(r,l)):ge.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return B.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:B.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:K.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of z.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of z.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return vn(this)}partial(e){let n={};for(let r of z.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of z.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ae;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Su(z.objectKeys(this.shape))}};Se.create=(t,e)=>new Se({shape:()=>t,unknownKeys:"strip",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});Se.strictCreate=(t,e)=>new Se({shape:()=>t,unknownKeys:"strict",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});Se.lazycreate=(t,e)=>new Se({shape:t,unknownKeys:"strip",catchall:Fe.create(),typeName:K.ZodObject,...G(e)});var Ut=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new ve(a.ctx.common.issues));return R(n,{code:C.invalid_union,unionErrors:o}),V}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new ve(c));return R(n,{code:C.invalid_union,unionErrors:a}),V}}get options(){return this._def.options}};Ut.create=(t,e)=>new Ut({options:t,typeName:K.ZodUnion,...G(e)});var it=t=>t instanceof Kt?it(t.schema):t instanceof Ie?it(t.innerType()):t instanceof Gt?[t.value]:t instanceof Wt?t.options:t instanceof Jt?z.objectValues(t.enum):t instanceof Yt?it(t._def.innerType):t instanceof Bt?[void 0]:t instanceof Dt?[null]:t instanceof Ae?[void 0,...it(t.unwrap())]:t instanceof Ye?[null,...it(t.unwrap())]:t instanceof er||t instanceof Ht?it(t.unwrap()):t instanceof zt?it(t._def.innerType):[],ts=class t extends Y{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.object)return R(n,{code:C.invalid_type,expected:q.object,received:n.parsedType}),V;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(R(n,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=it(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:K.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...G(r)})}};function go(t,e){let n=We(t),r=We(e);if(t===e)return{valid:!0,data:t};if(n===q.object&&r===q.object){let s=z.objectKeys(e),i=z.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=go(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===q.array&&r===q.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=go(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===q.date&&r===q.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Vt=class extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Qr(i)||Qr(o))return V;let a=go(i.value,o.value);return a.valid?((es(i)||es(o))&&n.dirty(),{status:n.value,value:a.data}):(R(r,{code:C.invalid_intersection_types}),V)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Vt.create=(t,e,n)=>new Vt({left:t,right:e,typeName:K.ZodIntersection,...G(n)});var Je=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.array)return R(r,{code:C.invalid_type,expected:q.array,received:r.parsedType}),V;if(r.data.length<this._def.items.length)return R(r,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&r.data.length>this._def.items.length&&(R(r,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Ce(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>ge.mergeArray(n,o)):ge.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Je.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Je({items:t,typeName:K.ZodTuple,rest:null,...G(e)})};var ns=class t extends Y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.object)return R(r,{code:C.invalid_type,expected:q.object,received:r.parsedType}),V;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new Ce(r,a,r.path,a)),value:o._parse(new Ce(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ge.mergeObjectAsync(n,s):ge.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof Y?new t({keyType:e,valueType:n,typeName:K.ZodRecord,...G(r)}):new t({keyType:pt.create(),valueType:e,typeName:K.ZodRecord,...G(n)})}},kn=class extends Y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.map)return R(r,{code:C.invalid_type,expected:q.map,received:r.parsedType}),V;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new Ce(r,a,r.path,[l,"key"])),value:i._parse(new Ce(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return V;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return V;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};kn.create=(t,e,n)=>new kn({valueType:e,keyType:t,typeName:K.ZodMap,...G(n)});var xn=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==q.set)return R(r,{code:C.invalid_type,expected:q.set,received:r.parsedType}),V;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(R(r,{code:C.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(R(r,{code:C.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return V;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>i._parse(new Ce(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:B.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:B.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};xn.create=(t,e)=>new xn({valueType:t,minSize:null,maxSize:null,typeName:K.ZodSet,...G(e)});var rs=class t extends Y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.function)return R(n,{code:C.invalid_type,expected:q.function,received:n.parsedType}),V;function r(a,c){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wn(),st].filter(l=>!!l),issueData:{code:C.invalid_arguments,argumentsError:c}})}function s(a,c){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wn(),st].filter(l=>!!l),issueData:{code:C.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof gt){let a=this;return we(async function(...c){let l=new ve([]),u=await a._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(r(c,g)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw l.addIssue(s(f,g)),l})})}else{let a=this;return we(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new ve([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new ve([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Je.create(e).rest(ot.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Je.create([]).rest(ot.create()),returns:n||ot.create(),typeName:K.ZodFunction,...G(r)})}},Kt=class extends Y{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Kt.create=(t,e)=>new Kt({getter:t,typeName:K.ZodLazy,...G(e)});var Gt=class extends Y{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return R(n,{received:n.data,code:C.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:e.data}}get value(){return this._def.value}};Gt.create=(t,e)=>new Gt({value:t,typeName:K.ZodLiteral,...G(e)});function Su(t,e){return new Wt({values:t,typeName:K.ZodEnum,...G(e)})}var Wt=class t extends Y{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return R(n,{expected:z.joinValues(r),received:n.parsedType,code:C.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return R(n,{received:n.data,code:C.invalid_enum_value,options:r}),V}return we(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Wt.create=Su;var Jt=class extends Y{_parse(e){let n=z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==q.string&&r.parsedType!==q.number){let s=z.objectValues(n);return R(r,{expected:z.joinValues(s),received:r.parsedType,code:C.invalid_type}),V}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=z.objectValues(n);return R(r,{received:r.data,code:C.invalid_enum_value,options:s}),V}return we(e.data)}get enum(){return this._def.values}};Jt.create=(t,e)=>new Jt({values:t,typeName:K.ZodNativeEnum,...G(e)});var gt=class extends Y{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==q.promise&&n.common.async===!1)return R(n,{code:C.invalid_type,expected:q.promise,received:n.parsedType}),V;let r=n.parsedType===q.promise?n.data:Promise.resolve(n.data);return we(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};gt.create=(t,e)=>new gt({type:t,typeName:K.ZodPromise,...G(e)});var Ie=class extends Y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{R(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return V;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?V:c.status==="dirty"?jt(c.value):n.value==="dirty"?jt(c.value):c});{if(n.value==="aborted")return V;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?V:a.status==="dirty"?jt(a.value):n.value==="dirty"?jt(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?V:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?V:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ht(o))return V;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ht(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):V);z.assertNever(s)}};Ie.create=(t,e,n)=>new Ie({schema:t,typeName:K.ZodEffects,effect:e,...G(n)});Ie.createWithPreprocess=(t,e,n)=>new Ie({schema:e,effect:{type:"preprocess",transform:t},typeName:K.ZodEffects,...G(n)});var Ae=class extends Y{_parse(e){return this._getType(e)===q.undefined?we(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ae.create=(t,e)=>new Ae({innerType:t,typeName:K.ZodOptional,...G(e)});var Ye=class extends Y{_parse(e){return this._getType(e)===q.null?we(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:K.ZodNullable,...G(e)});var Yt=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===q.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Yt.create=(t,e)=>new Yt({innerType:t,typeName:K.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var zt=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return bn(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};zt.create=(t,e)=>new zt({innerType:t,typeName:K.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var Tn=class extends Y{_parse(e){if(this._getType(e)!==q.nan){let r=this._getOrReturnCtx(e);return R(r,{code:C.invalid_type,expected:q.nan,received:r.parsedType}),V}return{status:"valid",value:e.data}}};Tn.create=t=>new Tn({typeName:K.ZodNaN,...G(t)});var Ww=Symbol("zod_brand"),er=class extends Y{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},tr=class t extends Y{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?V:i.status==="dirty"?(n.dirty(),jt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?V:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:K.ZodPipeline})}},Ht=class extends Y{_parse(e){let n=this._def.innerType._parse(e),r=s=>(ht(s)&&(s.value=Object.freeze(s.value)),s);return bn(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Ht.create=(t,e)=>new Ht({innerType:t,typeName:K.ZodReadonly,...G(e)});function _u(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Eu(t,e={},n){return t?mt.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=_u(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=_u(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):mt.create()}var Jw={object:Se.lazycreate},K;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(K||(K={}));var Yw=(t,e={message:`Input not instance of ${t.name}`})=>Eu(n=>n instanceof t,e),ku=pt.create,xu=$t.create,zw=Tn.create,Hw=Mt.create,Tu=qt.create,Zw=Ft.create,Xw=Sn.create,Qw=Bt.create,eb=Dt.create,tb=mt.create,nb=ot.create,rb=Fe.create,sb=En.create,ib=at.create,ob=Se.create,ab=Se.strictCreate,cb=Ut.create,lb=ts.create,ub=Vt.create,fb=Je.create,db=ns.create,hb=kn.create,pb=xn.create,mb=rs.create,gb=Kt.create,yb=Gt.create,_b=Wt.create,wb=Jt.create,bb=gt.create,vb=Ie.create,Sb=Ae.create,Eb=Ye.create,kb=Ie.createWithPreprocess,xb=tr.create,Tb=()=>ku().optional(),Ob=()=>xu().optional(),Nb=()=>Tu().optional(),Ab={string:(t=>pt.create({...t,coerce:!0})),number:(t=>$t.create({...t,coerce:!0})),boolean:(t=>qt.create({...t,coerce:!0})),bigint:(t=>Mt.create({...t,coerce:!0})),date:(t=>Ft.create({...t,coerce:!0}))};var Cb=V;d();d();var jd=H(oe(),1),mk=3e4,ba=class{baseUrl;apiKey;timeoutMs;accessToken;constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey,this.accessToken=e.accessToken,this.timeoutMs=e.timeoutMs??mk}async searchTools(e){return this.post("/v1/search",e)}async searchToolsRespond(e){return this.post("/v1/search/respond",e)}async checkCompatibility(e){return this.post("/v1/graph/compatibility",e)}async compareTools(e){return this.post("/v1/graph/compare",e)}async getStack(e){return this.post("/v1/graph/stack",e)}async refineRequirement(e){return this.post("/v1/intelligence/refine",e)}async verifySuggestion(e){return this.post("/v1/intelligence/verify",e)}async checkIssue(e){return this.post("/v1/intelligence/issue",e)}async batchResolve(e){let n=[],r=new Map,s=new Map;if(e.length===0)return{results:[],warnings:n,methods:r,githubUrls:s};try{let i=await this.rawPost("/v1/tools/batch-resolve",{api_version:"1",tools:e});if(i.status===404)return n.push({scope:"batch-resolve",message:"/v1/tools/batch-resolve not deployed on this engine \u2014 falling back to offline classification (source: non_oss)."}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};if(!i.ok)return n.push({scope:"batch-resolve",message:`batch-resolve returned HTTP ${i.status} \u2014 all tools marked as non_oss.`}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};let o=await i.json();if(!Array.isArray(o.resolved))return n.push({scope:"batch-resolve",message:"batch-resolve returned unexpected body shape \u2014 falling back."}),{results:e.map(c=>({input:c,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s};let a=[];for(let c of o.resolved){let l=c.match_method??(c.matched?"tool_name_exact":"none"),u=c.matched??l!=="none",f=`${c.input.ecosystem}:${c.input.name}`;r.set(f,l),c.tool?.github_url&&s.set(f,c.tool.github_url),a.push({input:c.input,matched:u,match_method:l,tool:c.tool})}return{results:a,warnings:n,methods:r,githubUrls:s}}catch(i){return n.push({scope:"batch-resolve",message:`batch-resolve network failure: ${i instanceof Error?i.message:String(i)}. Tools classified as non_oss.`}),{results:e.map(o=>({input:o,matched:!1,match_method:"none"})),warnings:n,methods:r,githubUrls:s}}}async reportOutcome(e){return this.post("/v1/feedback/outcome",e)}async suggestGraphUpdate(e){return this.post("/v1/feedback/suggest",e)}async feedback(e){return this.post("/v1/feedback/agent-feedback",e)}async register(e){return(await this.rawPost("/v1/register",{client_id:e})).json()}async healthCheck(){try{return(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(5e3)})).ok}catch{return!1}}async post(e,n){try{let r=await this.rawPost(e,n);if(r.status===429&&r.headers.get("x-toolcairn-limit-exhausted")==="1")try{return{content:[{type:"text",text:(await r.clone().json()).message??"ToolCairn daily limit reached. Join the Pro waitlist for 1 month free: https://toolcairn.neurynae.com/waitlist?source=limit_exhausted"}]}}catch{}let s=await r.json();return s&&typeof s=="object"&&"content"in s?s:{content:[{type:"text",text:JSON.stringify(s)}]}}catch(r){let s=r instanceof Error?r.message:String(r);return{content:[{type:"text",text:JSON.stringify({ok:!1,error:jd.ErrorCode.ERR_NETWORK_UNREACHABLE,message:`ToolCairn API unreachable: ${s}. Check your internet connection or try again later.`})}],isError:!0}}}rawPost(e,n){let r={"Content-Type":"application/json","X-ToolCairn-Key":this.apiKey,"Accept-Encoding":"gzip"};return this.accessToken&&(r.Authorization=`Bearer ${this.accessToken}`),fetch(`${this.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:AbortSignal.timeout(this.timeoutMs)})}};d();import{chmod as $d,mkdir as gk,readFile as Md,writeFile as yk}from"fs/promises";import{homedir as _k}from"os";import{join as Sa}from"path";var Ns=Sa(_k(),".toolcairn"),qd=Sa(Ns,"credentials.json"),Ea=Sa(Ns,"pending-auth.json"),va=process.platform==="win32";async function Fd(t,e){if(await gk(Ns,{recursive:!0,mode:va?void 0:448}),await yk(t,e,{encoding:"utf-8",mode:va?void 0:384}),!va){try{await $d(t,384)}catch{}try{await $d(Ns,448)}catch{}}}async function ka(t){await Fd(Ea,JSON.stringify(t,null,2))}async function xa(){try{let t=await Md(Ea,"utf-8"),e=JSON.parse(t);return new Date(e.expires_at)<new Date?(await or(),null):e}catch{return null}}async function or(){try{let{unlink:t}=await import("fs/promises");await t(Ea)}catch{}}function wk(t){if(!t.access_token)return!1;try{let e=t.access_token.split(".");if(e.length!==3)return!1;let n=JSON.parse(Buffer.from(e[1]??"","base64url").toString("utf-8"));return!(n.exp&&n.exp<Date.now()/1e3+300)}catch{return!1}}async function Bd(){try{let t=await Md(qd,"utf-8");return JSON.parse(t)}catch{return null}}async function Ta(){let t=await Bd();if(t)return t;let e={client_id:crypto.randomUUID(),created_at:new Date().toISOString()};return await As(e),e}async function As(t){await Fd(qd,JSON.stringify(t,null,2))}async function Oa(t,e,n){let r=await Ta();await As({...r,client_id:e,access_token:t,user_id:n.id,user_email:n.email??void 0,user_name:n.name??void 0,authenticated_at:new Date().toISOString()})}async function bk(){let t=await Ta();await As({client_id:t.client_id,created_at:t.created_at,api_url:t.api_url})}d();var lt=H(oe(),1);async function vk(t){let{spawn:e}=await import("child_process");try{let n=process.platform,r,s;n==="win32"?(r="cmd",s=["/c","start","",t]):n==="darwin"?(r="open",s=[t]):(r="xdg-open",s=[t]),e(r,s,{detached:!0,stdio:"ignore",shell:!1}).unref()}catch{}}async function Dd(t){let e=await fetch(`${t}/v1/auth/device-code`,{method:"POST"});if(!e.ok)throw new lt.NetworkError({code:lt.ErrorCode.ERR_NETWORK_UNREACHABLE,message:"Failed to start device auth. Check your internet connection."});let n=await e.json();return await ka({device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_at:new Date(Date.now()+n.expires_in*1e3).toISOString(),api_url:t}),process.stderr.write(`
170
170
  \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\u2500\u2500\u2500\u2500\u2500
171
171
  `),process.stderr.write(` ToolCairn \u2014 Sign In Required
172
172
  `),process.stderr.write(`\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\u2500\u2500\u2500\u2500\u2500
@@ -213,7 +213,7 @@ ${i}`,n),this.line=r,this.column=s,this.codeblock=i}};function Dk(t,e){let n=0;f
213
213
  `),r=0,s=!1;for(let i of n){let o=i.split("#")[0]?.trim()??"";if(!o)continue;let a=o.match(/^group\s+(:[\w,\s:]+?)\s*do\s*$/);if(a&&a[1]){r++,s=/\b(development|test)\b/.test(a[1]);continue}if(o==="end"&&r>0){r--,r===0&&(s=!1);continue}let c=o.match(/^gem\s+(['"])([A-Za-z0-9_\-.]+)\1(?:\s*,\s*(['"])([^'"]+)\3)?/);c?.[2]&&e.push({name:c[2],constraint:c[4],dev:s})}return e}var Qg=async({workspace_dir:t,workspace_rel:e})=>{let n=[],r=[],s=Zg(t,"Gemfile.lock"),i=Zg(t,"Gemfile");if(await P(s))try{let o=await kl(s,"utf-8"),a=e?`${e}/Gemfile.lock`:"Gemfile.lock",c=new Set;if(await P(i))try{let l=await kl(i,"utf-8");for(let u of Xg(l))c.add(u.name)}catch{}for(let l of YA(o))c.size>0&&!c.has(l.name)||r.push({name:l.name,ecosystem:"rubygems",version_constraint:void 0,resolved_version:l.version,section:"dep",manifest_file:a,workspace_path:e});if(r.length>0)return{ecosystem:"rubygems",tools:r,warnings:n}}catch(o){n.push({scope:"parser:ruby",path:s,message:`Failed to parse Gemfile.lock: ${o instanceof Error?o.message:String(o)}`})}if(await P(i))try{let o=await kl(i,"utf-8"),a=e?`${e}/Gemfile`:"Gemfile";for(let c of Xg(o))r.push({name:c.name,ecosystem:"rubygems",version_constraint:c.constraint,section:c.dev?"dev":"dep",manifest_file:a,workspace_path:e});n.push({scope:"parser:ruby",path:a,message:"No Gemfile.lock \u2014 resolved_version unavailable."})}catch(o){n.push({scope:"parser:ruby",path:i,message:`Failed to parse Gemfile: ${o instanceof Error?o.message:String(o)}`})}return{ecosystem:"rubygems",tools:r,warnings:n}};d();import{readFile as ey}from"fs/promises";import{join as ty}from"path";function zA(t){let e;try{e=JSON.parse(t)}catch{return[]}let n=[];for(let r of e.pins??[])r.identity&&n.push({name:r.identity,version:r.state?.version});for(let r of e.object?.pins??[])r.package&&n.push({name:r.package,version:r.state?.version});return n}function HA(t){let e=[],n=/\.package\(\s*(?:name:\s*"[^"]+"\s*,\s*)?url:\s*"([^"]+)"\s*,\s*([^)]+)\)/g,r;for(;(r=n.exec(t))!==null;){let s=r[1],i=r[2]?.trim();if(!s)continue;let o=s.split("/").pop()?.replace(/\.git$/,"");o&&e.push({name:o,constraint:i})}return e}var ny=async({workspace_dir:t,workspace_rel:e})=>{let n=[],r=[],s=ty(t,"Package.resolved");if(await P(s))try{let o=await ey(s,"utf-8"),a=e?`${e}/Package.resolved`:"Package.resolved";for(let c of zA(o))r.push({name:c.name,ecosystem:"swift-pm",resolved_version:c.version,section:"dep",manifest_file:a,workspace_path:e});if(r.length>0)return{ecosystem:"swift-pm",tools:r,warnings:n}}catch(o){n.push({scope:"parser:swift",path:s,message:`Failed to parse Package.resolved: ${o instanceof Error?o.message:String(o)}`})}let i=ty(t,"Package.swift");if(await P(i))try{let o=await ey(i,"utf-8"),a=e?`${e}/Package.swift`:"Package.swift";for(let c of HA(o))r.push({name:c.name,ecosystem:"swift-pm",version_constraint:c.constraint,section:"dep",manifest_file:a,workspace_path:e});n.push({scope:"parser:swift",path:a,message:"No Package.resolved \u2014 resolved_version unavailable."})}catch(o){n.push({scope:"parser:swift",path:i,message:`Failed to parse Package.swift: ${o instanceof Error?o.message:String(o)}`})}return{ecosystem:"swift-pm",tools:r,warnings:n}};var ry={npm:zg,pypi:Hg,cargo:th,go:qg,rubygems:Qg,maven:Kg,gradle:Dg,composer:ih,hex:Jg,pub:Hm,nuget:Mg,"swift-pm":ny};d();d();var iy=H(oe(),1);import{readFile as ZA,readdir as sy}from"fs/promises";import{homedir as XA}from"os";import{join as xl}from"path";d();function ie(t){if(!t)return;let e=t.trim();if(!e||(e.startsWith("git+")&&(e=e.slice(4)),e.startsWith("github:")&&(e=`https://github.com/${e.slice(7)}`),/^[A-Za-z0-9_.\-]+\/[A-Za-z0-9_.\-]+$/.test(e)&&(e=`https://github.com/${e}`),e=e.replace(/^git@github\.com:/,"https://github.com/"),e=e.replace(/^ssh:\/\/git@github\.com\//,"https://github.com/"),e=e.replace(/^http:\/\//,"https://"),!/^https:\/\/github\.com\//.test(e)))return;e=e.replace(/\.git$/,""),e=e.replace(/\/$/,"");let n=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)/);if(n)return`https://github.com/${n[1]}/${n[2]}`}var QA=(0,iy.createMcpLogger)({name:"@toolcairn/tools:resolver:cargo"});async function eC(t,e){let n=xl(XA(),".cargo","registry","src");if(!await fe(n))return null;let r;try{r=await sy(n)}catch{return null}let s=[];for(let i of r){let o=xl(n,i);if(!await fe(o))continue;let a;try{a=await sy(o)}catch{continue}for(let c of a){if(!c.startsWith(`${t}-`)||e&&c!==`${t}-${e}`)continue;let l=xl(o,c,"Cargo.toml");await P(l)&&s.push(l)}}return s.length===0?null:(s.sort(),s[s.length-1]??null)}async function oy(t,e,n,r={}){let s=await eC(n,r.resolved_version);if(!s)return{};try{let i=await ZA(s,"utf-8"),a=Ue(i).package;if(!a)return{};let c={};a.name&&a.name!==n&&(c.canonical_package_name=a.name),a.version&&(c.resolved_version=a.version);let l=ie(a.repository??a.homepage);return l&&(c.github_url=l),c}catch(i){return QA.debug({err:i instanceof Error?i.message:String(i),manifestPath:s},"Failed to parse cached Cargo.toml"),{}}}d();var ay=H(oe(),1);import{readFile as tC}from"fs/promises";import{join as nC}from"path";var rC=(0,ay.createMcpLogger)({name:"@toolcairn/tools:resolver:composer"});async function cy(t,e,n){let r=nC(t,"vendor",n,"composer.json");if(!await P(r))return{};try{let s=JSON.parse(await tC(r,"utf-8")),i={};s.name&&s.name!==n&&(i.canonical_package_name=s.name),s.version&&(i.resolved_version=s.version);let o=s.source?.url??s.support?.source??s.homepage,a=ie(o);return a&&(i.github_url=a),i}catch(s){return rC.debug({err:s instanceof Error?s.message:String(s),path:r},"Failed to parse installed composer.json"),{}}}d();function ly(t,e,n){if(!n.startsWith("github.com/"))return{};let s=n.slice(11).split("/");if(s.length<2||!s[0]||!s[1])return{};let i=s[0],o=s[1];o=o.replace(/\.git$/,"");let a=ie(`https://github.com/${i}/${o}`);return a?{github_url:a}:{}}d();import{readdir as dy}from"fs/promises";import{homedir as oC}from"os";import{join as Tl}from"path";d();var uy=H(oe(),1),fy=H(Kr(),1);import{readFile as sC}from"fs/promises";var iC=(0,uy.createMcpLogger)({name:"@toolcairn/tools:resolver:pom"});async function Li(t,e){if(!await P(t))return{};try{let n=await sC(t,"utf-8"),i=new fy.XMLParser({ignoreAttributes:!0,parseTagValue:!0}).parse(n).project;if(!i)return{};let o={},a=i.groupId&&i.artifactId?`${i.groupId}:${i.artifactId}`:void 0;a&&a!==e&&(o.canonical_package_name=a),i.version&&(o.resolved_version=i.version);let c=[i.scm?.url,i.scm?.connection,i.scm?.developerConnection,i.url];for(let l of c){let u=ie(l);if(u){o.github_url=u;break}}return o}catch(n){return iC.debug({err:n instanceof Error?n.message:String(n),path:t},"Failed to parse .pom"),{}}}async function aC(t,e,n){let r=Tl(oC(),".gradle","caches","modules-2","files-2.1",t,e);if(!await fe(r))return null;let s;try{s=await dy(r)}catch{return null}let i=n&&s.includes(n)?n:s.sort().at(-1);if(!i)return null;let o=Tl(r,i),a;try{a=await dy(o)}catch{return null}for(let c of a)return Tl(o,c,`${e}-${i}.pom`);return null}async function hy(t,e,n,r={}){let s=n.indexOf(":");if(s<0)return{};let i=n.slice(0,s),o=n.slice(s+1);if(!i||!o)return{};let a=await aC(i,o,r.resolved_version);return a?Li(a,n):{}}d();var my=H(oe(),1);import{readFile as py}from"fs/promises";import{join as Ol}from"path";var cC=(0,my.createMcpLogger)({name:"@toolcairn/tools:resolver:hex"});function lC(t){let e=t.match(/<<"GitHub">>\s*,\s*<<"([^"]+)">>/i);if(e?.[1]||(e=t.match(/<<"[^"]*github[^"]*">>\s*,\s*<<"(https?:\/\/[^"]+)">>/i),e?.[1]))return e[1]}function uC(t){let e=t.match(/@source_url\s*\(?\s*["']([^"']+)["']/);if(e?.[1])return e[1];let n=t.match(/\bsource_url\s*:\s*["']([^"']+)["']/);if(n?.[1])return n[1]}async function gy(t,e,n){let r=Ol(t,"deps",n),s={},i=Ol(r,"hex_metadata.config");if(await P(i))try{let o=await py(i,"utf-8"),a=lC(o),c=ie(a);c&&(s.github_url=c)}catch(o){cC.debug({err:o instanceof Error?o.message:String(o),metaPath:i},"Failed to read hex_metadata.config")}if(!s.github_url){let o=Ol(r,"mix.exs");if(await P(o))try{let a=await py(o,"utf-8"),c=uC(a),l=ie(c);l&&(s.github_url=l)}catch{}}return s}d();import{readdir as fC}from"fs/promises";import{homedir as dC}from"os";import{join as yy}from"path";async function hC(t,e,n){let r=t.replace(/\./g,"/"),s=yy(dC(),".m2","repository",r,e);if(!await fe(s))return null;let i;try{i=await fC(s)}catch{return null}let o;return n&&i.includes(n)?o=n:(i.sort(),o=i[i.length-1]),o?yy(s,o,`${e}-${o}.pom`):null}async function _y(t,e,n,r={}){let s=n.indexOf(":");if(s<0)return{};let i=n.slice(0,s),o=n.slice(s+1);if(!i||!o)return{};let a=await hC(i,o,r.resolved_version);return a?Li(a,n):{}}d();var by=H(oe(),1);import{readFile as pC}from"fs/promises";import{join as wy}from"path";var mC=(0,by.createMcpLogger)({name:"@toolcairn/tools:resolver:npm"});function gC(t){let e=t.repository;if(e)return typeof e=="string"?e:e.url}async function yC(t,e,n){let r=t,s=e;for(let i=0;i<10;i++){let o=wy(r,"node_modules",n,"package.json");if(await P(o))return o;if(r===s)break;let a=wy(r,"..");if(a===r)break;r=a}return null}async function vy(t,e,n){let r=await yC(t,e,n);if(!r)return{};let s;try{s=JSON.parse(await pC(r,"utf-8"))}catch(c){return mC.debug({err:c instanceof Error?c.message:String(c),manifestPath:r},"Failed to parse installed package.json \u2014 skipping url resolution"),{}}let i={};s.name&&s.name!==n&&(i.canonical_package_name=s.name),s.version&&(i.resolved_version=s.version);let o=gC(s),a=ie(o);return a&&(i.github_url=a),i}d();var Ey=H(oe(),1),ky=H(Kr(),1);import{readFile as _C,readdir as wC}from"fs/promises";import{homedir as bC}from"os";import{join as Sy}from"path";var vC=(0,Ey.createMcpLogger)({name:"@toolcairn/tools:resolver:nuget"});async function SC(t,e){let n=Sy(bC(),".nuget","packages",t.toLowerCase());if(!await fe(n))return null;let r;try{r=await wC(n)}catch{return null}let s=e&&r.includes(e)?e:r.sort().at(-1);if(!s)return null;let i=Sy(n,s,`${t.toLowerCase()}.nuspec`);return await P(i)?i:null}async function xy(t,e,n,r={}){let s=await SC(n,r.resolved_version);if(!s)return{};try{let i=await _C(s,"utf-8"),c=new ky.XMLParser({ignoreAttributes:!1}).parse(i).package?.metadata;if(!c)return{};let l={};c.id&&c.id!==n&&(l.canonical_package_name=c.id),c.version&&(l.resolved_version=c.version);let u=c.repository?.["@_url"]??c.repository?.url,f=ie(u??c.projectUrl);return f&&(l.github_url=f),l}catch(i){return vC.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to parse .nuspec"),{}}}d();var Ty=H(oe(),1),Oy=H(Br(),1);import{readFile as EC}from"fs/promises";import{homedir as kC,platform as xC}from"os";import{join as Ri}from"path";var TC=(0,Ty.createMcpLogger)({name:"@toolcairn/tools:resolver:pub"});function OC(){if(xC()==="win32"){let t=process.env.LOCALAPPDATA;if(t)return Ri(t,"Pub","Cache","hosted","pub.dev")}return Ri(kC(),".pub-cache","hosted","pub.dev")}async function NC(t,e){let n=OC();if(e){let r=Ri(n,`${t}-${e}`,"pubspec.yaml");return await P(r)?r:null}try{let{readdir:r}=await import("fs/promises"),o=(await r(n)).filter(c=>c.startsWith(`${t}-`)).sort().at(-1);if(!o)return null;let a=Ri(n,o,"pubspec.yaml");return await P(a)?a:null}catch{return null}}async function Ny(t,e,n,r={}){let s=await NC(n,r.resolved_version);if(!s)return{};try{let i=await EC(s,"utf-8"),o=(0,Oy.parse)(i),a={};o.name&&o.name!==n&&(a.canonical_package_name=o.name),o.version&&(a.resolved_version=o.version);let c=ie(o.repository??o.homepage);return c&&(a.github_url=c),a}catch(i){return TC.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to parse pubspec.yaml"),{}}}d();var Cy=H(oe(),1);import{readFile as AC,readdir as Ay}from"fs/promises";import{join as Gr}from"path";var CC=(0,Cy.createMcpLogger)({name:"@toolcairn/tools:resolver:pypi"});async function IC(t){let e=[],n=[".venv","venv",".virtualenv"];for(let r of n){let s=Gr(t,r);if(!await fe(s))continue;let i=Gr(s,"Lib","site-packages");await fe(i)&&e.push(i);let o=Gr(s,"lib");if(await fe(o))try{for(let a of await Ay(o)){if(!a.startsWith("python"))continue;let c=Gr(o,a,"site-packages");await fe(c)&&e.push(c)}}catch{}}return e}function ji(t){return t.toLowerCase().replace(/[._]+/g,"-")}async function PC(t,e){let n=ji(e),r;try{r=await Ay(t)}catch{return null}for(let s of r){if(!s.endsWith(".dist-info"))continue;let i=s.replace(/-[^-]+\.dist-info$/,"");if(ji(i)===n){let o=Gr(t,s,"METADATA");if(await P(o))return o}}return null}function LC(t){let e=[],n,r,s=t.split(`
214
214
  `);for(let i of s){if(i.trim()==="")break;let o=i.indexOf(":");if(o<0)continue;let a=i.slice(0,o).trim(),c=i.slice(o+1).trim();if(a==="Name"&&!n)n=c;else if(a==="Version"&&!r)r=c;else if(a==="Home-page")e.push(c);else if(a==="Project-URL"){let l=c.indexOf(",");l>=0?e.push(c.slice(l+1).trim()):e.push(c)}}return{name:n,version:r,urls:e}}async function Iy(t,e,n){let r=await IC(t);for(let s of r){let i=await PC(s,n);if(i)try{let o=await AC(i,"utf-8"),{name:a,version:c,urls:l}=LC(o),u={};a&&ji(a)!==ji(n)&&(u.canonical_package_name=a),c&&(u.resolved_version=c);for(let f of l){let h=ie(f);if(h){u.github_url=h;break}}return u}catch(o){CC.debug({err:o instanceof Error?o.message:String(o),path:i},"Failed to parse METADATA")}}return{}}d();var Ly=H(oe(),1);import{readFile as RC,readdir as Py}from"fs/promises";import{homedir as jC}from"os";import{join as $i}from"path";var $C=(0,Ly.createMcpLogger)({name:"@toolcairn/tools:resolver:ruby"});async function MC(t,e,n){let r=[],s=$i(t,"vendor","bundle","ruby");if(await fe(s))try{for(let o of await Py(s)){let a=$i(s,o,"specifications");await fe(a)&&r.push(a)}}catch{}let i=$i(jC(),".gem","specifications");await fe(i)&&r.push(i);for(let o of r){let a;try{a=await Py(o)}catch{continue}let l=a.filter(u=>u.endsWith(".gemspec")&&u.startsWith(`${e}-`)).filter(u=>n?u===`${e}-${n}.gemspec`:!0).sort().at(-1);if(l){let u=$i(o,l);if(await P(u))return u}}return null}function qC(t){let e={},n=r=>{let s=t.match(r);return s?s[1]:void 0};return e.name=n(/(?:s|spec)\.name\s*=\s*(['"])([^'"]+)\1/)?t.match(/(?:s|spec)\.name\s*=\s*['"]([^'"]+)['"]/)?.[1]:void 0,e.version=t.match(/(?:s|spec)\.version\s*=\s*['"]([^'"]+)['"]/)?.[1],e.homepage=t.match(/(?:s|spec)\.homepage\s*=\s*['"]([^'"]+)['"]/)?.[1],e.source_code_uri=t.match(/["']source_code_uri["']\s*=>\s*["']([^'"]+)["']/)?.[1],e}async function Ry(t,e,n,r={}){let s=await MC(t,n,r.resolved_version);if(!s)return{};try{let i=await RC(s,"utf-8"),o=qC(i),a={};o.name&&o.name!==n&&(a.canonical_package_name=o.name),o.version&&(a.resolved_version=o.version);let c=ie(o.source_code_uri??o.homepage);return c&&(a.github_url=c),a}catch(i){return $C.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to read/parse gemspec"),{}}}d();var jy=H(oe(),1);import{readFile as FC}from"fs/promises";import{join as BC}from"path";var DC=(0,jy.createMcpLogger)({name:"@toolcairn/tools:resolver:swift-pm"});async function $y(t,e,n){let r=BC(t,"Package.resolved");if(!await P(r))return{};try{let s=await FC(r,"utf-8"),i=JSON.parse(s),o={};for(let a of i.pins??[])if(a.identity===n){a.state?.version&&(o.resolved_version=a.state.version);let c=ie(a.location);return c&&(o.github_url=c),o}for(let a of i.object?.pins??[])if(a.package===n){a.state?.version&&(o.resolved_version=a.state.version);let c=ie(a.repositoryURL);return c&&(o.github_url=c),o}return{}}catch(s){return DC.debug({err:s instanceof Error?s.message:String(s),path:r},"Failed to parse Package.resolved during resolve"),{}}}var My={npm:vy,pypi:Iy,cargo:oy,go:(t,e,n)=>ly(t,e,n),rubygems:Ry,maven:_y,gradle:hy,composer:cy,hex:gy,pub:Ny,nuget:xy,"swift-pm":$y};d();import{readdir as qy}from"fs/promises";import{join as Nl,relative as UC,sep as VC}from"path";async function Fy(t,e){let n=new Set,r=new Set;for(let s of e){let i=s.trim();if(!i)continue;let o=i.startsWith("!"),c=(o?i.slice(1):i).replace(/\\/g,"/"),l=await KC(t,c),u=o?n:r;for(let f of l)u.add(f)}return[...r].filter(s=>!n.has(s)).sort()}async function KC(t,e){let n=e.split("/").filter(Boolean),r=[];return await Wr(t,t,n,0,r),r}async function Wr(t,e,n,r,s){if(r>=n.length){await fe(e)&&s.push(e);return}let i=n[r];if(i){if(i==="**"){await Wr(t,e,n,r+1,s);try{let o=await qy(e,{withFileTypes:!0});for(let a of o)!a.isDirectory()||tn.has(a.name)||await Wr(t,Nl(e,a.name),n,r,s)}catch{}return}if(i.includes("*")){let o=GC(i);try{let a=await qy(e,{withFileTypes:!0});for(let c of a)!c.isDirectory()||tn.has(c.name)||o.test(c.name)&&await Wr(t,Nl(e,c.name),n,r+1,s)}catch{}return}await Wr(t,Nl(e,i),n,r+1,s)}}function GC(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${e}$`)}function Mi(t,e){return UC(t,e).split(VC).join("/")}d();import{readFile as Kn}from"fs/promises";import{join as Gn}from"path";var By=H(Br(),1);async function qi(t,e=5){let n=[],r=new Set([t]),s=new Set,i=[{dir:t,depth:0}];for(;i.length>0;){let{dir:o,depth:a}=i.shift();if(s.has(o)||a>e)continue;s.add(o);let c=await WC(o,n);if(c.length===0)continue;let l=await Fy(o,c);for(let u of l)r.has(u)||(r.add(u),i.push({dir:u,depth:a+1}))}return{paths:[...r].sort(),warnings:n}}async function WC(t,e){let n=[],r=Gn(t,"pnpm-workspace.yaml");if(await P(r))try{let l=(0,By.parse)(await Kn(r,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:pnpm",path:r,message:`Failed to parse pnpm-workspace.yaml: ${l instanceof Error?l.message:String(l)}`})}let s=Gn(t,"package.json");if(await P(s))try{let l=JSON.parse(await Kn(s,"utf-8"));Array.isArray(l.workspaces)?n.push(...l.workspaces):l.workspaces&&Array.isArray(l.workspaces.packages)&&n.push(...l.workspaces.packages)}catch(l){e.push({scope:"workspace:package-json",path:s,message:`Failed to parse package.json#workspaces: ${l instanceof Error?l.message:String(l)}`})}let i=Gn(t,"Cargo.toml");if(await P(i))try{let l=Ue(await Kn(i,"utf-8"));Array.isArray(l.workspace?.members)&&n.push(...l.workspace.members)}catch(l){e.push({scope:"workspace:cargo",path:i,message:`Failed to parse Cargo workspace: ${l instanceof Error?l.message:String(l)}`})}let o=Gn(t,"go.work");if(await P(o))try{let l=await Kn(o,"utf-8"),u=l.match(/use\s*\(([^)]*)\)/s);if(u?.[1])for(let f of u[1].split(`
215
215
  `)){let h=f.trim().replace(/^['"]|['"]$/g,"");h&&!h.startsWith("//")&&n.push(h)}else for(let f of l.split(`
216
- `)){let h=f.match(/^\s*use\s+(.+)$/);h?.[1]&&n.push(h[1].trim().replace(/^['"]|['"]$/g,""))}}catch(l){e.push({scope:"workspace:go",path:o,message:`Failed to parse go.work: ${l instanceof Error?l.message:String(l)}`})}let a=Gn(t,"lerna.json");if(await P(a))try{let l=JSON.parse(await Kn(a,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:lerna",path:a,message:`Failed to parse lerna.json: ${l instanceof Error?l.message:String(l)}`})}let c=Gn(t,"nx.json");if(await P(c))try{let u=JSON.parse(await Kn(c,"utf-8")).workspaceLayout?.projectsDir??"packages";n.push(`${u}/*`)}catch(l){e.push({scope:"workspace:nx",path:c,message:`Failed to parse nx.json: ${l instanceof Error?l.message:String(l)}`})}return n}var Al=(0,Dy.createMcpLogger)({name:"@toolcairn/tools:scan-project"});async function Il(t,e={}){let n=Date.now(),{batchResolve:r,maxDepth:s=5}=e,i=Cl(t),o=[];Al.info({projectRoot:i},"Starting project scan");let{paths:a,warnings:c}=await qi(i,s);o.push(...c);let l=[],u=new Set,f=[],h=[],g=[];for(let x of a){let I=Mi(i,x),j=await Ud(x);for(let U of j){u.add(U);let J=ry[U];g.push(J({workspace_dir:x,workspace_rel:I,project_root:i}).then(D=>{l.push(...D.tools),o.push(...D.warnings),D.tools.length>0&&I!==""&&(h.find(re=>re.path===I&&re.ecosystem===U)||h.push({path:I,manifest:zC(U),ecosystem:U}))}).catch(D=>{f.push(`${U}@${I||"."}`),o.push({scope:`parser:${U}`,path:I||".",message:`Parser crashed: ${D instanceof Error?D.message:String(D)}`})}))}}await Promise.all(g);let p=new Map;for(let x of l){let I=`${x.ecosystem}:${x.name}`,j={workspace_path:x.workspace_path,manifest_file:x.manifest_file,section:x.section,ecosystem:x.ecosystem,version_constraint:x.version_constraint,resolved_version:x.resolved_version},U=p.get(I);U?U.locations.some(D=>D.workspace_path===j.workspace_path&&D.manifest_file===j.manifest_file&&D.section===j.section)||U.locations.push(j):p.set(I,{name:x.name,ecosystem:x.ecosystem,locations:[j]})}await Promise.all([...p.values()].map(async x=>{let I=My[x.ecosystem];if(I)for(let j of x.locations){let U=Cl(i,j.workspace_path),J={resolved_version:j.resolved_version};try{let D=await I(U,i,x.name,J);if(D.canonical_package_name&&(x.canonical_package_name=D.canonical_package_name),D.github_url&&(x.local_github_url=D.github_url),D.canonical_package_name||D.github_url)break}catch(D){Al.debug({ecosystem:x.ecosystem,name:x.name,workspace:j.workspace_path,err:D instanceof Error?D.message:String(D)},"Resolver threw \u2014 skipping this location")}}}));let m=a.map(x=>Mi(i,x)),y=await Kd(i,m),b=[...p.values()].map(({name:x,ecosystem:I,canonical_package_name:j,local_github_url:U})=>({name:x,ecosystem:I,canonical_package_name:j,github_url:U})),v=new Map,k=new Map,N=new Map;if(r&&b.length>0)try{let x=await r(b);for(let I of x.results){let j=`${I.input.ecosystem}:${I.input.name}`;v.set(j,I)}for(let[I,j]of x.methods)k.set(I,j);for(let[I,j]of x.githubUrls)N.set(I,j);o.push(...x.warnings)}catch(x){o.push({scope:"batch-resolve",message:`Failed to resolve tools against graph: ${x instanceof Error?x.message:String(x)}. Falling back to local classification.`})}else r||o.push({scope:"batch-resolve",message:"No batchResolve client provided \u2014 running in offline-only mode; all tools classified as non_oss."});let L=Vd(l,v),$=new Date().toISOString(),F=[],E=0;for(let{name:x,ecosystem:I,locations:j,local_github_url:U}of p.values()){let J=`${I}:${x}`,D=v.get(J),Q=k.get(J)??"none",re=D?.matched===!0;re&&E++;let ne=re?"toolcairn":"non_oss",Xr=D?.tool?.canonical_name,ow=D?.tool?.categories,aw=N.get(J)??U,cw=j.find(fo=>fo.resolved_version)?.resolved_version??j[0]?.version_constraint,qe=D?.tool,uo=qe?.docs?{readme_url:qe.docs.readme_url??void 0,docs_url:qe.docs.docs_url??void 0,api_url:qe.docs.api_url??void 0,changelog_url:qe.docs.changelog_url??void 0}:void 0,lw=uo&&Object.values(uo).some(fo=>fo!==void 0);F.push({name:x,source:ne,github_url:aw,version:cw,chosen_at:$,chosen_reason:"Auto-detected from manifest during toolcairn_init scan",alternatives_considered:[],canonical_name:Xr,categories:ow,match_method:Q,locations:j,description:qe?.description??void 0,license:qe?.license??void 0,homepage_url:qe?.homepage_url??void 0,docs:lw?uo:void 0,package_managers:qe?.package_managers&&qe.package_managers.length>0?qe.package_managers:void 0})}F.sort((x,I)=>{let j=U=>U.source==="toolcairn"?0:1;return j(x)!==j(I)?j(x)-j(I):x.name.localeCompare(I.name)}),h.sort((x,I)=>x.path.localeCompare(I.path));let O=await HC(i),M={ecosystems_scanned:[...u].sort(),parsers_failed:f.sort(),tools_resolved:E,tools_unresolved:F.length-E,duration_ms:Date.now()-n,completed_at:$};return Al.info({projectRoot:i,workspaces:a.length,ecosystems:M.ecosystems_scanned,tools:F.length,resolved:E,languages:y.map(x=>x.name),frameworks:L.map(x=>x.name),duration_ms:M.duration_ms},"Project scan complete"),{name:O,languages:y,frameworks:L,subprojects:h,tools:F,warnings:o,scan_metadata:M}}function zC(t){switch(t){case"npm":return"package.json";case"pypi":return"pyproject.toml";case"cargo":return"Cargo.toml";case"go":return"go.mod";case"rubygems":return"Gemfile";case"maven":return"pom.xml";case"gradle":return"build.gradle";case"composer":return"composer.json";case"hex":return"mix.exs";case"pub":return"pubspec.yaml";case"nuget":return"*.csproj";case"swift-pm":return"Package.swift"}}async function HC(t){let e=Cl(t,"package.json");if(await P(e))try{let n=JSON.parse(await JC(e,"utf-8"));if(n.name)return n.name}catch{}return YC(t)}d();d();var Ky=H(oe(),1);import{readdir as Vy}from"fs/promises";import{resolve as Pl}from"path";var Uy=(0,Ky.createMcpLogger)({name:"@toolcairn/tools:discover-roots"}),ZC=["package.json","Cargo.toml","pyproject.toml","requirements.txt","setup.py","setup.cfg","go.mod","Gemfile","pom.xml","build.gradle","build.gradle.kts","composer.json","mix.exs","pubspec.yaml","Package.swift"],XC=[".csproj",".fsproj",".sln"];async function QC(t,e={}){let{maxDepth:n=5}=e,r=Pl(t),s=await eI(r,n);if(s.length===0)return Uy.info({cwd:r},"No project roots discovered \u2014 falling back to cwd itself"),{roots:[r],usedFallback:!0};s.sort((a,c)=>a.split(/[\\/]/).length-c.split(/[\\/]/).length||a.localeCompare(c));let i=new Set(s);for(let a of s){if(!i.has(a))continue;let c=await qi(a,n).catch(()=>({paths:[a]}));if(!(c.paths.length<=1))for(let l of c.paths)l!==a&&i.has(l)&&i.delete(l)}let o=[...i].sort();return Uy.info({cwd:r,candidates:s.length,roots:o.length},"Discovered project roots"),{roots:o,usedFallback:!1}}async function eI(t,e){let n=[],r=[{dir:t,depth:0}];for(;r.length>0;){let s=r.shift();if(!s)break;let{dir:i,depth:o}=s;if(o>e)continue;await tI(i)&&n.push(i);let a;try{a=await Vy(i,{withFileTypes:!0})}catch{continue}for(let c of a)c.isDirectory()&&(tn.has(c.name)||c.name.startsWith(".")||r.push({dir:Pl(i,c.name),depth:o+1}))}return[...new Set(n)]}async function tI(t){if(!await fe(t))return!1;for(let n of ZC)if(await P(Pl(t,n)))return!0;let e;try{e=await Vy(t)}catch{return!1}for(let n of e)for(let r of XC)if(n.endsWith(r))return!0;return!1}d();d();var UD={query:C.string().min(1).max(500),context:C.object({filters:C.record(C.string(),C.unknown())}).optional(),query_id:C.string().uuid().optional(),user_id:C.string().optional()},VD={query_id:C.string().uuid(),answers:C.array(C.object({dimension:C.string(),value:C.string()}))},KD={query_id:C.string().uuid(),chosen_tool:C.string(),reason:C.string().optional(),outcome:C.enum(["success","failure","replaced","pending"]),feedback:C.string().optional(),replaced_by:C.string().optional()},GD={use_case:C.string().min(1),sub_needs:C.array(C.union([C.string().min(1),C.object({sub_need_type:C.string().min(1).max(50).describe('Stack layer type, e.g. "database", "auth", "web-framework"'),keyword_sentence:C.string().min(1).max(500).describe("Comma-separated keywords matching tool vocabulary, max 20 keywords")})])).min(1).max(8).optional().describe("Structured sub-needs from refine_requirement. Each is {sub_need_type, keyword_sentence} for keyword-matched search, or a plain string (legacy). The structured format dramatically improves accuracy."),constraints:C.object({deployment_model:C.enum(["self-hosted","cloud","embedded","serverless"]).optional(),language:C.string().optional(),license:C.string().optional()}).optional(),limit:C.number().int().positive().max(10).default(5)},WD={tool_name:C.string(),issue_title:C.string(),retry_count:C.number().int().min(0).default(0),docs_consulted:C.boolean().default(!1),issue_url:C.string().url().optional()},JD={tool_a:C.string(),tool_b:C.string(),tool_a_version:C.string().optional().describe('Specific version of tool_a to evaluate (e.g., "14.0.0"). Default: latest.'),tool_b_version:C.string().optional().describe('Specific version of tool_b to evaluate (e.g., "18.2.0"). Default: latest.')},YD={suggestion_type:C.enum(["new_tool","new_edge","update_health","new_use_case"]),data:C.object({tool_name:C.string().optional(),github_url:C.string().url().optional(),description:C.string().optional(),tools:C.array(C.object({tool_name:C.string().min(1),github_url:C.string().url().optional(),description:C.string().optional(),ecosystem:C.string().min(1).optional()})).min(1).max(200).optional().describe('Batch of tools to stage for admin review. Use with suggestion_type="new_tool". Each entry may include `ecosystem` (npm/pypi/cargo/\u2026) so the engine can cross-check the authoritative github_url from the package registry. Overrides single-tool fields when present.'),ecosystem:C.string().min(1).optional(),relationship:C.object({source_tool:C.string(),target_tool:C.string(),edge_type:C.enum(["SOLVES","REQUIRES","INTEGRATES_WITH","REPLACES","CONFLICTS_WITH","POPULAR_WITH","BREAKS_FROM","COMPATIBLE_WITH"]),evidence:C.string().optional()}).optional(),use_case:C.object({name:C.string(),description:C.string(),tools:C.array(C.string()).optional()}).optional()}),query_id:C.string().uuid().optional(),confidence:C.number().min(0).max(1).default(.5)},zD={tool_a:C.string().min(1),tool_b:C.string().min(1),use_case:C.string().optional(),project_config:C.string().max(1e5).optional()},HD={agent:C.enum(["claude","cursor","windsurf","copilot","copilot-cli","opencode","generic"]),project_root:C.string().min(1),server_path:C.string().optional()},ZD={project_root:C.string().min(1),include_locations:C.boolean().optional()},XD={project_root:C.string().min(1),action:C.enum(["add_tool","remove_tool","update_tool","add_evaluation","mark_suggestions_sent"]),tool_name:C.string().min(1).optional(),data:C.record(C.string(),C.unknown()).optional()},QD={prompt:C.string().min(1).max(2e3),project_tools:C.array(C.string()).optional()},eU={query:C.string().min(1).max(500),agent_suggestions:C.array(C.string().min(1)).min(1).max(10)},tU={prompt:C.string().min(1).max(2e3),classification:C.enum(["tool_discovery","stack_building","tool_comparison","tool_configuration"]),project_context:C.object({existing_tools:C.array(C.string()).optional(),language:C.string().optional(),framework:C.string().optional()}).optional()};d();function tt(t){return{content:[{type:"text",text:JSON.stringify({ok:!0,data:t})}]}}function je(t,e){return{content:[{type:"text",text:JSON.stringify({ok:!1,error:t,message:e})}],isError:!0}}d();var Wy=H(oe(),1);var Gy=(0,Wy.createMcpLogger)({name:"@toolcairn/tools:classify-prompt"}),nI=["tool_discovery","stack_building","tool_comparison"];async function rI(t){try{Gy.info({promptLen:t.prompt.length},"classify_prompt called");let e=t.project_tools&&t.project_tools.length>0?`
216
+ `)){let h=f.match(/^\s*use\s+(.+)$/);h?.[1]&&n.push(h[1].trim().replace(/^['"]|['"]$/g,""))}}catch(l){e.push({scope:"workspace:go",path:o,message:`Failed to parse go.work: ${l instanceof Error?l.message:String(l)}`})}let a=Gn(t,"lerna.json");if(await P(a))try{let l=JSON.parse(await Kn(a,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:lerna",path:a,message:`Failed to parse lerna.json: ${l instanceof Error?l.message:String(l)}`})}let c=Gn(t,"nx.json");if(await P(c))try{let u=JSON.parse(await Kn(c,"utf-8")).workspaceLayout?.projectsDir??"packages";n.push(`${u}/*`)}catch(l){e.push({scope:"workspace:nx",path:c,message:`Failed to parse nx.json: ${l instanceof Error?l.message:String(l)}`})}return n}var Al=(0,Dy.createMcpLogger)({name:"@toolcairn/tools:scan-project"});async function Il(t,e={}){let n=Date.now(),{batchResolve:r,maxDepth:s=5}=e,i=Cl(t),o=[];Al.info({projectRoot:i},"Starting project scan");let{paths:a,warnings:c}=await qi(i,s);o.push(...c);let l=[],u=new Set,f=[],h=[],g=[];for(let x of a){let I=Mi(i,x),j=await Ud(x);for(let U of j){u.add(U);let J=ry[U];g.push(J({workspace_dir:x,workspace_rel:I,project_root:i}).then(D=>{l.push(...D.tools),o.push(...D.warnings),D.tools.length>0&&I!==""&&(h.find(re=>re.path===I&&re.ecosystem===U)||h.push({path:I,manifest:zC(U),ecosystem:U}))}).catch(D=>{f.push(`${U}@${I||"."}`),o.push({scope:`parser:${U}`,path:I||".",message:`Parser crashed: ${D instanceof Error?D.message:String(D)}`})}))}}await Promise.all(g);let p=new Map;for(let x of l){let I=`${x.ecosystem}:${x.name}`,j={workspace_path:x.workspace_path,manifest_file:x.manifest_file,section:x.section,ecosystem:x.ecosystem,version_constraint:x.version_constraint,resolved_version:x.resolved_version},U=p.get(I);U?U.locations.some(D=>D.workspace_path===j.workspace_path&&D.manifest_file===j.manifest_file&&D.section===j.section)||U.locations.push(j):p.set(I,{name:x.name,ecosystem:x.ecosystem,locations:[j]})}await Promise.all([...p.values()].map(async x=>{let I=My[x.ecosystem];if(I)for(let j of x.locations){let U=Cl(i,j.workspace_path),J={resolved_version:j.resolved_version};try{let D=await I(U,i,x.name,J);if(D.canonical_package_name&&(x.canonical_package_name=D.canonical_package_name),D.github_url&&(x.local_github_url=D.github_url),D.canonical_package_name||D.github_url)break}catch(D){Al.debug({ecosystem:x.ecosystem,name:x.name,workspace:j.workspace_path,err:D instanceof Error?D.message:String(D)},"Resolver threw \u2014 skipping this location")}}}));let m=a.map(x=>Mi(i,x)),y=await Kd(i,m),b=[...p.values()].map(({name:x,ecosystem:I,canonical_package_name:j,local_github_url:U})=>({name:x,ecosystem:I,canonical_package_name:j,github_url:U})),v=new Map,k=new Map,N=new Map;if(r&&b.length>0)try{let x=await r(b);for(let I of x.results){let j=`${I.input.ecosystem}:${I.input.name}`;v.set(j,I)}for(let[I,j]of x.methods)k.set(I,j);for(let[I,j]of x.githubUrls)N.set(I,j);o.push(...x.warnings)}catch(x){o.push({scope:"batch-resolve",message:`Failed to resolve tools against graph: ${x instanceof Error?x.message:String(x)}. Falling back to local classification.`})}else r||o.push({scope:"batch-resolve",message:"No batchResolve client provided \u2014 running in offline-only mode; all tools classified as non_oss."});let L=Vd(l,v),$=new Date().toISOString(),F=[],E=0;for(let{name:x,ecosystem:I,locations:j,local_github_url:U}of p.values()){let J=`${I}:${x}`,D=v.get(J),Q=k.get(J)??"none",re=D?.matched===!0;re&&E++;let ne=re?"toolcairn":"non_oss",Xr=D?.tool?.canonical_name,ow=D?.tool?.categories,aw=N.get(J)??U,cw=j.find(fo=>fo.resolved_version)?.resolved_version??j[0]?.version_constraint,qe=D?.tool,uo=qe?.docs?{readme_url:qe.docs.readme_url??void 0,docs_url:qe.docs.docs_url??void 0,api_url:qe.docs.api_url??void 0,changelog_url:qe.docs.changelog_url??void 0}:void 0,lw=uo&&Object.values(uo).some(fo=>fo!==void 0);F.push({name:x,source:ne,github_url:aw,version:cw,chosen_at:$,chosen_reason:"Auto-detected from manifest during toolcairn_init scan",alternatives_considered:[],canonical_name:Xr,categories:ow,match_method:Q,locations:j,description:qe?.description??void 0,license:qe?.license??void 0,homepage_url:qe?.homepage_url??void 0,docs:lw?uo:void 0,package_managers:qe?.package_managers&&qe.package_managers.length>0?qe.package_managers:void 0})}F.sort((x,I)=>{let j=U=>U.source==="toolcairn"?0:1;return j(x)!==j(I)?j(x)-j(I):x.name.localeCompare(I.name)}),h.sort((x,I)=>x.path.localeCompare(I.path));let O=await HC(i),M={ecosystems_scanned:[...u].sort(),parsers_failed:f.sort(),tools_resolved:E,tools_unresolved:F.length-E,duration_ms:Date.now()-n,completed_at:$};return Al.info({projectRoot:i,workspaces:a.length,ecosystems:M.ecosystems_scanned,tools:F.length,resolved:E,languages:y.map(x=>x.name),frameworks:L.map(x=>x.name),duration_ms:M.duration_ms},"Project scan complete"),{name:O,languages:y,frameworks:L,subprojects:h,tools:F,warnings:o,scan_metadata:M}}function zC(t){switch(t){case"npm":return"package.json";case"pypi":return"pyproject.toml";case"cargo":return"Cargo.toml";case"go":return"go.mod";case"rubygems":return"Gemfile";case"maven":return"pom.xml";case"gradle":return"build.gradle";case"composer":return"composer.json";case"hex":return"mix.exs";case"pub":return"pubspec.yaml";case"nuget":return"*.csproj";case"swift-pm":return"Package.swift"}}async function HC(t){let e=Cl(t,"package.json");if(await P(e))try{let n=JSON.parse(await JC(e,"utf-8"));if(n.name)return n.name}catch{}return YC(t)}d();d();var Ky=H(oe(),1);import{readdir as Vy}from"fs/promises";import{resolve as Pl}from"path";var Uy=(0,Ky.createMcpLogger)({name:"@toolcairn/tools:discover-roots"}),ZC=["package.json","Cargo.toml","pyproject.toml","requirements.txt","setup.py","setup.cfg","go.mod","Gemfile","pom.xml","build.gradle","build.gradle.kts","composer.json","mix.exs","pubspec.yaml","Package.swift"],XC=[".csproj",".fsproj",".sln"];async function QC(t,e={}){let{maxDepth:n=5}=e,r=Pl(t),s=await eI(r,n);if(s.length===0)return Uy.info({cwd:r},"No project roots discovered \u2014 falling back to cwd itself"),{roots:[r],usedFallback:!0};s.sort((a,c)=>a.split(/[\\/]/).length-c.split(/[\\/]/).length||a.localeCompare(c));let i=new Set(s);for(let a of s){if(!i.has(a))continue;let c=await qi(a,n).catch(()=>({paths:[a]}));if(!(c.paths.length<=1))for(let l of c.paths)l!==a&&i.has(l)&&i.delete(l)}let o=[...i].sort();return Uy.info({cwd:r,candidates:s.length,roots:o.length},"Discovered project roots"),{roots:o,usedFallback:!1}}async function eI(t,e){let n=[],r=[{dir:t,depth:0}];for(;r.length>0;){let s=r.shift();if(!s)break;let{dir:i,depth:o}=s;if(o>e)continue;await tI(i)&&n.push(i);let a;try{a=await Vy(i,{withFileTypes:!0})}catch{continue}for(let c of a)c.isDirectory()&&(tn.has(c.name)||c.name.startsWith(".")||r.push({dir:Pl(i,c.name),depth:o+1}))}return[...new Set(n)]}async function tI(t){if(!await fe(t))return!1;for(let n of ZC)if(await P(Pl(t,n)))return!0;let e;try{e=await Vy(t)}catch{return!1}for(let n of e)for(let r of XC)if(n.endsWith(r))return!0;return!1}d();d();var UD={query:A.string().min(1).max(500),context:A.object({filters:A.record(A.string(),A.unknown())}).optional(),query_id:A.string().uuid().optional(),user_id:A.string().optional()},VD={query_id:A.string().uuid(),answers:A.array(A.object({dimension:A.string(),value:A.string()}))},KD={query_id:A.string().uuid(),chosen_tool:A.string(),reason:A.string().optional(),outcome:A.enum(["success","failure","replaced","pending"]),feedback:A.string().optional(),replaced_by:A.string().optional()},GD={use_case:A.string().min(1),sub_needs:A.array(A.union([A.string().min(1),A.object({sub_need_type:A.string().min(1).max(50).describe('Stack layer type, e.g. "database", "auth", "web-framework"'),keyword_sentence:A.string().min(1).max(500).describe("Comma-separated keywords matching tool vocabulary, max 20 keywords")})])).min(1).max(8).optional().describe("Structured sub-needs from refine_requirement. Each is {sub_need_type, keyword_sentence} for keyword-matched search, or a plain string (legacy). The structured format dramatically improves accuracy."),constraints:A.object({deployment_model:A.enum(["self-hosted","cloud","embedded","serverless"]).optional(),language:A.string().optional(),license:A.string().optional()}).optional(),limit:A.number().int().positive().max(10).default(5)},WD={tool_name:A.string(),issue_title:A.string(),retry_count:A.number().int().min(0).default(0),docs_consulted:A.boolean().default(!1),issue_url:A.string().url().optional()},JD={tool_a:A.string(),tool_b:A.string(),tool_a_version:A.string().optional().describe('Specific version of tool_a to evaluate (e.g., "14.0.0"). Default: latest.'),tool_b_version:A.string().optional().describe('Specific version of tool_b to evaluate (e.g., "18.2.0"). Default: latest.')},YD={suggestion_type:A.enum(["new_tool","new_edge","update_health","new_use_case"]),data:A.object({tool_name:A.string().optional(),github_url:A.string().url().optional(),description:A.string().optional(),tools:A.array(A.object({tool_name:A.string().min(1),github_url:A.string().url().optional(),description:A.string().optional(),ecosystem:A.string().min(1).optional()})).min(1).max(200).optional().describe('Batch of tools to stage for admin review. Use with suggestion_type="new_tool". Each entry may include `ecosystem` (npm/pypi/cargo/\u2026) so the engine can cross-check the authoritative github_url from the package registry. Overrides single-tool fields when present.'),ecosystem:A.string().min(1).optional(),relationship:A.object({source_tool:A.string(),target_tool:A.string(),edge_type:A.enum(["SOLVES","REQUIRES","INTEGRATES_WITH","REPLACES","CONFLICTS_WITH","POPULAR_WITH","BREAKS_FROM","COMPATIBLE_WITH"]),evidence:A.string().optional()}).optional(),use_case:A.object({name:A.string(),description:A.string(),tools:A.array(A.string()).optional()}).optional()}),query_id:A.string().uuid().optional(),confidence:A.number().min(0).max(1).default(.5)},zD={tool_a:A.string().min(1),tool_b:A.string().min(1),use_case:A.string().optional(),project_config:A.string().max(1e5).optional()},HD={agent:A.enum(["claude","cursor","windsurf","copilot","copilot-cli","opencode","generic"]),project_root:A.string().min(1),server_path:A.string().optional()},ZD={project_root:A.string().min(1),include_locations:A.boolean().optional()},XD={project_root:A.string().min(1),action:A.enum(["add_tool","remove_tool","update_tool","add_evaluation","mark_suggestions_sent"]),tool_name:A.string().min(1).optional(),data:A.record(A.string(),A.unknown()).optional()},QD={prompt:A.string().min(1).max(2e3),project_tools:A.array(A.string()).optional()},eU={query:A.string().min(1).max(500),agent_suggestions:A.array(A.string().min(1)).min(1).max(10)},tU={prompt:A.string().min(1).max(2e3),classification:A.enum(["tool_discovery","stack_building","tool_comparison","tool_configuration"]),project_context:A.object({existing_tools:A.array(A.string()).optional(),language:A.string().optional(),framework:A.string().optional()}).optional()},nU={tool_name:A.enum(["classify_prompt","search_tools","search_tools_respond","get_stack","check_compatibility","compare_tools","refine_requirement","check_issue","verify_suggestion","report_outcome","suggest_graph_update","toolcairn_init","read_project_config","update_project_config","toolcairn_auth"]),severity:A.enum(["broken","wrong_result","low_quality","missing_capability","confusing"]),message:A.string().min(20).max(2e3),query_id:A.string().uuid().optional(),expected:A.string().max(1e3).optional(),actual:A.string().max(1e3).optional()};d();function tt(t){return{content:[{type:"text",text:JSON.stringify({ok:!0,data:t})}]}}function je(t,e){return{content:[{type:"text",text:JSON.stringify({ok:!1,error:t,message:e})}],isError:!0}}d();var Wy=H(oe(),1);var Gy=(0,Wy.createMcpLogger)({name:"@toolcairn/tools:classify-prompt"}),nI=["tool_discovery","stack_building","tool_comparison"];async function rI(t){try{Gy.info({promptLen:t.prompt.length},"classify_prompt called");let e=t.project_tools&&t.project_tools.length>0?`
217
217
 
218
218
  The project already uses: ${t.project_tools.join(", ")}. Consider whether the prompt relates to tools already confirmed in the project.`:"",n=`Classify the following developer prompt into exactly ONE of these categories:
219
219
 
@@ -241,7 +241,7 @@ Your response (one category name only):`;return tt({classification_prompt:n,need
241
241
  Respond with 1 if the classification is one of: tool_discovery, stack_building, tool_comparison
242
242
  Respond with 0 if the classification is: tool_configuration, debugging, general_coding
243
243
  Respond with ONLY 0 or 1.`,valid_classifications:["tool_discovery","stack_building","tool_comparison","tool_configuration","debugging","general_coding"],tool_required_if:nI,instructions:"Step 1: Send classification_prompt to the LLM and get a classification. Step 2: If classification is in tool_required_if, call refine_requirement with the classification. Otherwise, proceed without ToolCairn search."})}catch(e){return Gy.error({err:e},"classify_prompt failed"),je("classify_error",e instanceof Error?e.message:String(e))}}d();var tw=H(oe(),1);d();var Y_=H(oe(),1),Xn=H(Ki(),1);import{readFile as du}from"fs/promises";import{resolve as co}from"path";d();d();import{join as Gi}from"path";var Ct=".toolcairn",Ul="config.json",Vl="audit-log.jsonl",Kl="audit-log.archive.jsonl";function rt(t){return Gi(t,Ct)}function Oe(t){return Gi(t,Ct,Ul)}function It(t){return Gi(t,Ct,Vl)}function Gl(t){return Gi(t,Ct,Kl)}d();var Zy=H(oe(),1);import{readFile as pI,rename as mI}from"fs/promises";import{join as gI}from"path";var Wl=(0,Zy.createMcpLogger)({name:"@toolcairn/tools:config-store"});async function Wn(t){let e=Oe(t);if(!await P(e))return{config:null,path:e,corrupt_backup_path:null};let n;try{n=await pI(e,"utf-8")}catch(r){throw Wl.error({err:r,configPath:e},"Failed to read config.json"),r}try{return{config:JSON.parse(n),path:e,corrupt_backup_path:null}}catch(r){let s=new Date().toISOString().replace(/[:.]/g,"-"),i=gI(t,Ct,`config.json.corrupt.${s}`);try{await mI(e,i),Wl.warn({configPath:e,backup:i,err:r},"config.json was unparseable \u2014 moved to backup")}catch(o){Wl.error({err:o,configPath:e,backup:i},"Failed to rename corrupt config.json")}return{config:null,path:e,corrupt_backup_path:i}}}d();var Xy=H(oe(),1),Qy=H(Ki(),1);import{mkdir as yI}from"fs/promises";var _I=(0,Xy.createMcpLogger)({name:"@toolcairn/tools:config-store"});async function Wi(t,e){await yI(rt(t),{recursive:!0});let n=Oe(t),r=`${JSON.stringify(e,null,2)}
244
- `;await(0,Qy.default)(n,r),_I.debug({configPath:n,bytes:r.length},"config.json written atomically")}d();var L_=H(oe(),1),R_=H(ou(),1),j_=H(Ki(),1);import{appendFile as au,mkdir as cu,readFile as P_,rm as iV,writeFile as YI}from"fs/promises";d();function gn(t=""){return{version:"1.2",project:{name:t,languages:[],frameworks:[],subprojects:[]},tools:{confirmed:[],pending_evaluation:[],unknown_in_graph:[]},last_audit_entry:null}}var Zr=(0,L_.createMcpLogger)({name:"@toolcairn/tools:audit-log"}),zI=5e3,I_=2500;async function yn(t,e){await cu(rt(t),{recursive:!0});let n=It(t),r=`${JSON.stringify($_(e))}
244
+ `;await(0,Qy.default)(n,r),_I.debug({configPath:n,bytes:r.length},"config.json written atomically")}d();var L_=H(oe(),1),R_=H(ou(),1),j_=H(Ki(),1);import{appendFile as au,mkdir as cu,readFile as P_,rm as oV,writeFile as YI}from"fs/promises";d();function gn(t=""){return{version:"1.2",project:{name:t,languages:[],frameworks:[],subprojects:[]},tools:{confirmed:[],pending_evaluation:[],unknown_in_graph:[]},last_audit_entry:null}}var Zr=(0,L_.createMcpLogger)({name:"@toolcairn/tools:audit-log"}),zI=5e3,I_=2500;async function yn(t,e){await cu(rt(t),{recursive:!0});let n=It(t),r=`${JSON.stringify($_(e))}
245
245
  `;await au(n,r,"utf-8"),await q_(t,n)}function $_(t){return{action:t.action,tool:t.tool,timestamp:t.timestamp,reason:t.reason,mcp_tool:t.mcp_tool??null,query_id:t.query_id??null,duration_ms:t.duration_ms??null,status:t.status??"ok",outcome:t.outcome??null,replaced_by:t.replaced_by??null,candidates:t.candidates??null,metadata:t.metadata??null}}async function so(t,e){if(e.length===0)return;await cu(rt(t),{recursive:!0});let n=It(t),r=e.map(s=>`${JSON.stringify($_(s))}
246
246
  `).join("");await au(n,r,"utf-8"),await q_(t,n)}async function M_(t,e){try{await HI(t)}catch(s){Zr.debug({err:s,projectRoot:t},"audit-log: bootstrap skipped (read-only?) \u2014 abandoning");return}let n=Oe(t),r=null;try{r=await R_.default.lock(n,{stale:1e4,retries:{retries:5,minTimeout:50,factor:2,maxTimeout:500},realpath:!1}),await yn(t,e)}catch(s){Zr.warn({err:s,projectRoot:t},"audit-log: tool-call append failed")}finally{if(r)try{await r()}catch(s){Zr.debug({err:s},"audit-log: lock release failed (likely already stale)")}}}async function HI(t){await cu(rt(t),{recursive:!0});let e=Oe(t);await P(e)||await YI(e,`${JSON.stringify(gn(),null,2)}
247
247
  `,"utf-8")}async function io(t){let e=It(t);if(!await P(e))return[];let n=await P_(e,"utf-8");return ZI(n)}async function q_(t,e){let r=(await P_(e,"utf-8")).split(`
@@ -314,7 +314,7 @@ ${V_}`;function nP(){return{file_path:"CLAUDE.md",mode:"append",content:_n}}func
314
314
  `,o),u=l===-1?s.length:l+1;a=s.slice(0,c)+r+s.slice(u)}else{let c=s.endsWith(`
315
315
  `)?"":`
316
316
  `;a=`${s}${c}${r}`}return a===s?{file:e,action:"append",applied:!1,reason:"block already up to date"}:(await(0,Xn.default)(t,a,"utf-8"),{file:e,action:"append",applied:!0})}catch(n){let r=n instanceof Error?n.message:String(n);return lo.warn({err:n,file:e},"Failed to write .gitignore"),{file:e,action:"append",applied:!1,reason:r}}}var ew=(0,tw.createMcpLogger)({name:"@toolcairn/tools:toolcairn-init"});async function pP(t,e={}){try{ew.info({agent:t.agent,project_root:t.project_root},"toolcairn_init called");let n=await hu({projectRoot:t.project_root,agent:t.agent,batchResolve:e.batchResolve,serverPath:t.server_path,reason:"Explicit toolcairn_init call from agent"});return tt({agent:t.agent,instruction_file:n.instruction_file,config_path:n.config_path,audit_log_path:n.audit_log_path,events_path:n.events_path,mcp_config_entry:n.mcp_config_entry,setup_steps:n.setup_steps,scan_summary:n.scan_summary,bootstrapped:n.bootstrapped,migrated:n.migrated,last_audit_entry:n.last_audit_entry,unknown_tools:n.unknown_tools,first_turn_directive:mP(n.unknown_tools.length),next_steps:'Config written. Apply setup_steps (CLAUDE.md / .mcp.json / .gitignore). If unknown_tools is non-empty, drain it via suggest_graph_update (batch) + update_project_config action="mark_suggestions_sent" before responding to the user.'})}catch(n){return ew.error({err:n},"toolcairn_init failed"),je("init_error",n instanceof Error?n.message:String(n))}}function mP(t){return t===0?"":[`The scan found ${t} tool(s) not currently in the ToolCairn graph.`,'BEFORE responding to the user, call `suggest_graph_update` with suggestion_type="new_tool"',"and `data.tools = <unknown_tools array>` to STAGE them for admin review (they do NOT go live",'until approved). Then call `update_project_config` action="mark_suggestions_sent" with the',"tool_names that staged successfully."].join(" ")}d();var rw=H(oe(),1);var pu=(0,rw.createMcpLogger)({name:"@toolcairn/tools:read-project-config"}),gP=90,yP=7,_P=new Set(["search_tools","search_tools_respond","get_stack"]);function wP(t){let e=Date.now()-yP*24*60*60*1e3,n=new Map;for(let r of t){if(r.action!=="tool_call"||!r.query_id||r.status==="error")continue;let s=Date.parse(r.timestamp);if(!(Number.isNaN(s)||s<e))if(r.mcp_tool&&_P.has(r.mcp_tool)){let i=typeof r.metadata?.query=="string"?r.metadata.query:typeof r.metadata?.use_case=="string"?r.metadata.use_case:null;n.set(r.query_id,{query_id:r.query_id,mcp_tool:r.mcp_tool,selected_at:r.timestamp,age_hours:Math.round((Date.now()-s)/(1e3*60*60)),candidates:r.candidates??[],query:i})}else r.mcp_tool==="report_outcome"&&n.delete(r.query_id)}return Array.from(n.values()).sort((r,s)=>Date.parse(r.selected_at)-Date.parse(s.selected_at))}function nw(t){return(Date.now()-new Date(t).getTime())/(1e3*60*60*24)}async function bP(t){try{pu.info({project_root:t.project_root},"read_project_config called");let{config:e,corrupt_backup_path:n}=await Wn(t.project_root);if(!e)return tt({status:"not_initialized",project_root:t.project_root,config_path:Oe(t.project_root),audit_log_path:It(t.project_root),corrupt_backup_path:n,agent_instructions:n?`.toolcairn/config.json was unparseable \u2014 moved to ${n}. Call toolcairn_init with the project_root to re-discover and write a fresh config.`:"No .toolcairn/config.json present. Call toolcairn_init with the project_root to auto-discover the project and bootstrap the config."});let r=e,s=!1;(e.version==="1.0"||e.version==="1.1")&&(r=(await Rt(t.project_root,()=>{},{action:"migrate",tool:"__schema__",reason:`Lazy migration on first read: ${e.version} \u2192 1.2`})).config,s=!0);let i=r.tools.confirmed.map(m=>m.name),o=r.tools.pending_evaluation.map(m=>m.name),a=r.tools.confirmed.filter(m=>{let y=m.last_verified??m.chosen_at??m.confirmed_at;return y?nw(y)>gP:!0}).map(m=>{let y=m.last_verified??m.chosen_at??m.confirmed_at,b=y?Math.round(nw(y)):-1;return{name:m.name,last_verified:y??"unknown",days_since_verified:b,recommendation:"Consider using check_issue to verify no new known issues"}}),c=r.tools.confirmed.filter(m=>m.source==="non_oss").map(m=>m.name),l=(r.tools.unknown_in_graph??[]).filter(m=>!m.suggested),u=[];try{let m=await io(t.project_root);u=wP(m)}catch(m){pu.debug({err:m},"pending_outcomes derivation skipped (audit-log unreadable)")}let f=r.tools.confirmed.filter(m=>m.source==="toolcairn"||m.source==="toolpilot").map(m=>m.name),g=t.include_locations===!0?r.tools.confirmed.map(m=>({name:m.name,source:m.source,canonical_name:m.canonical_name,categories:m.categories??[],match_method:m.match_method??"none",github_url:m.github_url,locations:m.locations??[]})):void 0,p=[`Project: ${r.project.name}`,r.project.languages&&r.project.languages.length>0?`Languages: ${r.project.languages.map(m=>`${m.name} (${m.file_count} files)`).join(", ")}`:"",r.project.frameworks&&r.project.frameworks.length>0?`Frameworks: ${r.project.frameworks.map(m=>`${m.name}@${m.workspace}`).join(", ")}`:"",`Confirmed tools (${i.length}): ${i.join(", ")||"none"}`,"When recommending tools, skip any already in confirmed_tools.",c.length>0?`Non-OSS tools in project (handle separately): ${c.join(", ")}`:"",a.length>0?`Tools that may be stale \u2014 worth re-checking: ${a.map(m=>m.name).join(", ")}`:"",l.length>0?`Unknown-to-graph tools awaiting submission (${l.length}): ${l.map(m=>m.name).join(", ")}. BEFORE answering the user, call suggest_graph_update (suggestion_type="new_tool", data.tools=<this list>) to STAGE them for admin review, then update_project_config action="mark_suggestions_sent" with the successful tool_names.`:"",u.length>0?`Pending outcomes (${u.length}) \u2014 recommendations the user used but you have not yet reported on. As soon as the user uses (or replaces) one of the suggested tools, call report_outcome with the matching query_id: ${u.map(m=>`${m.query_id} (${m.mcp_tool}, ${m.age_hours}h ago${m.candidates.length>0?`, candidates: ${m.candidates.slice(0,3).join("/")}`:""})`).join("; ")}.`:""].filter(Boolean);return tt({status:"ready",schema_version:r.version,migrated:s,project:{name:r.project.name,languages:r.project.languages??[],frameworks:r.project.frameworks??[],subprojects:r.project.subprojects??[]},confirmed_tools:i,pending_tools:o,non_oss_tools:c,toolcairn_indexed_tools:f,stale_tools:a,unknown_tools:l,total_confirmed:i.length,total_pending:o.length,total_unknown_undrained:l.length,pending_outcomes:u,total_pending_outcomes:u.length,last_audit_entry:r.last_audit_entry??null,scan_metadata:r.scan_metadata??null,confirmed_tools_detail:g,agent_instructions:p.join(`
317
- `)})}catch(e){return pu.error({err:e},"read_project_config failed"),je("read_config_error",e instanceof Error?e.message:String(e))}}d();var iw=H(oe(),1);var sw=(0,iw.createMcpLogger)({name:"@toolcairn/tools:update-project-config"});async function vP(t){try{sw.info({project_root:t.project_root,action:t.action,tool:t.tool_name},"update_project_config called");let e=t.data??{},n=t.action==="mark_suggestions_sent",r=n?Array.isArray(e.tool_names)?e.tool_names.filter(f=>typeof f=="string"):[]:[];if(!n&&!t.tool_name)return je("missing_field",`tool_name is required for action "${t.action}"`);if(n&&r.length===0)return je("missing_field","mark_suggestions_sent requires data.tool_names: string[] with at least one entry");let s=!1,i=0,o=new Date().toISOString(),a={action:t.action,tool:n?`__batch__:${r.length}`:t.tool_name,reason:e.reason??e.chosen_reason??EP(t.action),...t.query_id?{query_id:t.query_id}:{},metadata:SP(t,e)},{config:c,audit_entry:l,bootstrapped:u}=await Rt(t.project_root,f=>{switch(t.action){case"add_tool":{let h=t.tool_name;if(f.tools.pending_evaluation=f.tools.pending_evaluation.filter(g=>g.name!==h),!f.tools.confirmed.some(g=>g.name===h)){let g={name:h,source:e.source??"toolcairn",github_url:e.github_url,version:e.version,chosen_at:o,chosen_reason:e.chosen_reason??"Selected via ToolCairn",alternatives_considered:e.alternatives_considered??[],query_id:e.query_id,notes:e.notes,locations:[]};f.tools.confirmed.push(g)}break}case"remove_tool":{let h=t.tool_name;f.tools.confirmed=f.tools.confirmed.filter(g=>g.name!==h),f.tools.pending_evaluation=f.tools.pending_evaluation.filter(g=>g.name!==h);break}case"update_tool":{let h=t.tool_name,g=f.tools.confirmed.findIndex(m=>m.name===h);if(g===-1){s=!0;return}let p=f.tools.confirmed[g];if(!p){s=!0;return}f.tools.confirmed[g]={...p,...e.version!==void 0?{version:e.version}:{},...e.notes!==void 0?{notes:e.notes}:{},...e.chosen_reason!==void 0?{chosen_reason:e.chosen_reason}:{},...e.alternatives_considered!==void 0?{alternatives_considered:e.alternatives_considered}:{},last_verified:o};break}case"add_evaluation":{let h=t.tool_name,g=f.tools.confirmed.some(m=>m.name===h),p=f.tools.pending_evaluation.some(m=>m.name===h);if(!g&&!p){let m={name:h,category:e.category??"other",added_at:o};f.tools.pending_evaluation.push(m)}break}case"mark_suggestions_sent":{let h=f.tools.unknown_in_graph??[],g=new Set(r);for(let p of h)g.has(p.name)&&!p.suggested&&(p.suggested=!0,p.suggested_at=o,i++);f.tools.unknown_in_graph=h;break}}},a);return s?je("not_found",`Tool "${t.tool_name}" is not in the confirmed list \u2014 cannot update.`):tt({action_applied:t.action,tool_name:t.tool_name,tool_names:n?r:void 0,marked_count:n?i:void 0,undrained_unknown_count:(c.tools.unknown_in_graph??[]).filter(f=>!f.suggested).length,confirmed_count:c.tools.confirmed.length,pending_count:c.tools.pending_evaluation.length,last_audit_entry:l,bootstrapped:u,config_path:".toolcairn/config.json",audit_log_path:".toolcairn/audit-log.jsonl"})}catch(e){return sw.error({err:e},"update_project_config failed"),je("update_config_error",e instanceof Error?e.message:String(e))}}function SP(t,e){let n={config_action:t.action};switch(t.action){case"add_tool":{t.tool_name&&(n.tool_name=t.tool_name),typeof e.source=="string"&&(n.source=e.source),typeof e.version=="string"&&(n.version=e.version),typeof e.github_url=="string"&&(n.github_url=e.github_url),Array.isArray(e.alternatives_considered)&&(n.alternatives_count=e.alternatives_considered.length);break}case"remove_tool":case"update_tool":{t.tool_name&&(n.tool_name=t.tool_name),typeof e.version=="string"&&(n.version=e.version);break}case"add_evaluation":{t.tool_name&&(n.tool_name=t.tool_name);break}case"mark_suggestions_sent":{let r=Array.isArray(e.tool_names)?e.tool_names.filter(s=>typeof s=="string"):[];n.tool_names=r,n.tool_count=r.length;break}}return n}function EP(t){switch(t){case"add_tool":return"Added via ToolCairn recommendation";case"remove_tool":return"Removed from project";case"update_tool":return"Tool details updated";case"add_evaluation":return"Added for evaluation";case"mark_suggestions_sent":return"Agent successfully staged unknown tools via suggest_graph_update"}}export{S as a,gw as b,H as c,d,Ae as e,K as f,ob as g,C as h,oe as i,ba as j,xa as k,wk as l,Bd as m,bk as n,Dd as o,Sk as p,UD as q,VD as r,KD as s,GD as t,WD as u,JD as v,YD as w,zD as x,HD as y,ZD as z,XD as A,QD as B,eU as C,tU as D,rI as E,rt as F,M_ as G,io as H,Rt as I,Il as J,QC as K,hu as L,uP as M,pP as N,bP as O,vP as P};
317
+ `)})}catch(e){return pu.error({err:e},"read_project_config failed"),je("read_config_error",e instanceof Error?e.message:String(e))}}d();var iw=H(oe(),1);var sw=(0,iw.createMcpLogger)({name:"@toolcairn/tools:update-project-config"});async function vP(t){try{sw.info({project_root:t.project_root,action:t.action,tool:t.tool_name},"update_project_config called");let e=t.data??{},n=t.action==="mark_suggestions_sent",r=n?Array.isArray(e.tool_names)?e.tool_names.filter(f=>typeof f=="string"):[]:[];if(!n&&!t.tool_name)return je("missing_field",`tool_name is required for action "${t.action}"`);if(n&&r.length===0)return je("missing_field","mark_suggestions_sent requires data.tool_names: string[] with at least one entry");let s=!1,i=0,o=new Date().toISOString(),a={action:t.action,tool:n?`__batch__:${r.length}`:t.tool_name,reason:e.reason??e.chosen_reason??EP(t.action),...t.query_id?{query_id:t.query_id}:{},metadata:SP(t,e)},{config:c,audit_entry:l,bootstrapped:u}=await Rt(t.project_root,f=>{switch(t.action){case"add_tool":{let h=t.tool_name;if(f.tools.pending_evaluation=f.tools.pending_evaluation.filter(g=>g.name!==h),!f.tools.confirmed.some(g=>g.name===h)){let g={name:h,source:e.source??"toolcairn",github_url:e.github_url,version:e.version,chosen_at:o,chosen_reason:e.chosen_reason??"Selected via ToolCairn",alternatives_considered:e.alternatives_considered??[],query_id:e.query_id,notes:e.notes,locations:[]};f.tools.confirmed.push(g)}break}case"remove_tool":{let h=t.tool_name;f.tools.confirmed=f.tools.confirmed.filter(g=>g.name!==h),f.tools.pending_evaluation=f.tools.pending_evaluation.filter(g=>g.name!==h);break}case"update_tool":{let h=t.tool_name,g=f.tools.confirmed.findIndex(m=>m.name===h);if(g===-1){s=!0;return}let p=f.tools.confirmed[g];if(!p){s=!0;return}f.tools.confirmed[g]={...p,...e.version!==void 0?{version:e.version}:{},...e.notes!==void 0?{notes:e.notes}:{},...e.chosen_reason!==void 0?{chosen_reason:e.chosen_reason}:{},...e.alternatives_considered!==void 0?{alternatives_considered:e.alternatives_considered}:{},last_verified:o};break}case"add_evaluation":{let h=t.tool_name,g=f.tools.confirmed.some(m=>m.name===h),p=f.tools.pending_evaluation.some(m=>m.name===h);if(!g&&!p){let m={name:h,category:e.category??"other",added_at:o};f.tools.pending_evaluation.push(m)}break}case"mark_suggestions_sent":{let h=f.tools.unknown_in_graph??[],g=new Set(r);for(let p of h)g.has(p.name)&&!p.suggested&&(p.suggested=!0,p.suggested_at=o,i++);f.tools.unknown_in_graph=h;break}}},a);return s?je("not_found",`Tool "${t.tool_name}" is not in the confirmed list \u2014 cannot update.`):tt({action_applied:t.action,tool_name:t.tool_name,tool_names:n?r:void 0,marked_count:n?i:void 0,undrained_unknown_count:(c.tools.unknown_in_graph??[]).filter(f=>!f.suggested).length,confirmed_count:c.tools.confirmed.length,pending_count:c.tools.pending_evaluation.length,last_audit_entry:l,bootstrapped:u,config_path:".toolcairn/config.json",audit_log_path:".toolcairn/audit-log.jsonl"})}catch(e){return sw.error({err:e},"update_project_config failed"),je("update_config_error",e instanceof Error?e.message:String(e))}}function SP(t,e){let n={config_action:t.action};switch(t.action){case"add_tool":{t.tool_name&&(n.tool_name=t.tool_name),typeof e.source=="string"&&(n.source=e.source),typeof e.version=="string"&&(n.version=e.version),typeof e.github_url=="string"&&(n.github_url=e.github_url),Array.isArray(e.alternatives_considered)&&(n.alternatives_count=e.alternatives_considered.length);break}case"remove_tool":case"update_tool":{t.tool_name&&(n.tool_name=t.tool_name),typeof e.version=="string"&&(n.version=e.version);break}case"add_evaluation":{t.tool_name&&(n.tool_name=t.tool_name);break}case"mark_suggestions_sent":{let r=Array.isArray(e.tool_names)?e.tool_names.filter(s=>typeof s=="string"):[];n.tool_names=r,n.tool_count=r.length;break}}return n}function EP(t){switch(t){case"add_tool":return"Added via ToolCairn recommendation";case"remove_tool":return"Removed from project";case"update_tool":return"Tool details updated";case"add_evaluation":return"Added for evaluation";case"mark_suggestions_sent":return"Agent successfully staged unknown tools via suggest_graph_update"}}export{S as a,gw as b,H as c,d,Ae as e,K as f,ob as g,A as h,oe as i,ba as j,xa as k,wk as l,Bd as m,bk as n,Dd as o,Sk as p,UD as q,VD as r,KD as s,GD as t,WD as u,JD as v,YD as w,zD as x,HD as y,ZD as z,XD as A,QD as B,eU as C,tU as D,nU as E,rI as F,rt as G,M_ as H,io as I,Rt as J,Il as K,QC as L,hu as M,uP as N,pP as O,bP as P,vP as Q};
318
318
  /*! Bundled license information:
319
319
 
320
320
  imurmurhash/imurmurhash.js: