zion-mcp 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __nodeCreateRequire } from 'node:module';
2
2
  const require = __nodeCreateRequire(import.meta.url);
3
- import{a as B,c as v,d as ZE,e as Pt,g as d,h as y}from"./chunk-C7T2WMRH.js";var eu=v(KE=>{d();var Pf=class extends Error{constructor(e,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=e,this.nestedError=void 0}},HE=class extends Pf{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};KE.CommanderError=Pf;KE.InvalidArgumentError=HE});var Rf=v(YE=>{d();var{InvalidArgumentError:u3}=eu(),QE=class{constructor(e,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:(r.push(e),r)}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new u3(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function d3(t){let e=t.name()+(t.variadic===!0?"...":"");return t.required?"<"+e+">":"["+e+"]"}YE.Argument=QE;YE.humanReadableArgName=d3});var ev=v(XE=>{d();var{humanReadableArgName:p3}=Rf(),JE=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let r=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((i,o)=>i.name().localeCompare(o.name())),r}compareOptions(e,r){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(r))}visibleOptions(e){let r=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?r.push(n):n.long&&!o?r.push(e.createOption(n.long,n.description)):n.short&&!i&&r.push(e.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let r=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(o=>!o.hidden);r.push(...i)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(r=>{r.description=r.description||e._argsDescription[r.name()]||""}),e.registeredArguments.find(r=>r.description)?e.registeredArguments:[]}subcommandTerm(e){let r=e.registeredArguments.map(n=>p3(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,r){return r.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(i)))),0)}longestOptionTermLength(e,r){return r.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,r){return r.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestArgumentTermLength(e,r){return r.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(i)))),0)}commandUsage(e){let r=e._name;e._aliases[0]&&(r=r+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+r+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&r.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&r.push(`env: ${e.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,r,n){return r.length===0?[]:[n.styleTitle(e),...r,""]}groupItems(e,r,n){let i=new Map;return e.forEach(o=>{let a=n(o);i.has(a)||i.set(a,[])}),r.forEach(o=>{let a=n(o);i.has(a)||i.set(a,[]),i.get(a).push(o)}),i}formatHelp(e,r){let n=r.padWidth(e,r),i=r.helpWidth??80;function o(p,f){return r.formatItem(p,n,f,r)}let a=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(e))}`,""],s=r.commandDescription(e);s.length>0&&(a=a.concat([r.boxWrap(r.styleCommandDescription(s),i),""]));let c=r.visibleArguments(e).map(p=>o(r.styleArgumentTerm(r.argumentTerm(p)),r.styleArgumentDescription(r.argumentDescription(p))));if(a=a.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(e.options,r.visibleOptions(e),p=>p.helpGroupHeading??"Options:").forEach((p,f)=>{let h=p.map(m=>o(r.styleOptionTerm(r.optionTerm(m)),r.styleOptionDescription(r.optionDescription(m))));a=a.concat(this.formatItemList(f,h,r))}),r.showGlobalOptions){let p=r.visibleGlobalOptions(e).map(f=>o(r.styleOptionTerm(r.optionTerm(f)),r.styleOptionDescription(r.optionDescription(f))));a=a.concat(this.formatItemList("Global Options:",p,r))}return this.groupItems(e.commands,r.visibleCommands(e),p=>p.helpGroup()||"Commands:").forEach((p,f)=>{let h=p.map(m=>o(r.styleSubcommandTerm(r.subcommandTerm(m)),r.styleSubcommandDescription(r.subcommandDescription(m))));a=a.concat(this.formatItemList(f,h,r))}),a.join(`
3
+ import{a as B,c as v,d as ZE,e as Pt,g as d,h as y}from"./chunk-QII6CKVT.js";var eu=v(KE=>{d();var Pf=class extends Error{constructor(e,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=e,this.nestedError=void 0}},HE=class extends Pf{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};KE.CommanderError=Pf;KE.InvalidArgumentError=HE});var Rf=v(YE=>{d();var{InvalidArgumentError:u3}=eu(),QE=class{constructor(e,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:(r.push(e),r)}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new u3(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function d3(t){let e=t.name()+(t.variadic===!0?"...":"");return t.required?"<"+e+">":"["+e+"]"}YE.Argument=QE;YE.humanReadableArgName=d3});var ev=v(XE=>{d();var{humanReadableArgName:p3}=Rf(),JE=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let r=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((i,o)=>i.name().localeCompare(o.name())),r}compareOptions(e,r){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(r))}visibleOptions(e){let r=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?r.push(n):n.long&&!o?r.push(e.createOption(n.long,n.description)):n.short&&!i&&r.push(e.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let r=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(o=>!o.hidden);r.push(...i)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(r=>{r.description=r.description||e._argsDescription[r.name()]||""}),e.registeredArguments.find(r=>r.description)?e.registeredArguments:[]}subcommandTerm(e){let r=e.registeredArguments.map(n=>p3(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,r){return r.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(i)))),0)}longestOptionTermLength(e,r){return r.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,r){return r.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestArgumentTermLength(e,r){return r.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(i)))),0)}commandUsage(e){let r=e._name;e._aliases[0]&&(r=r+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+r+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&r.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&r.push(`env: ${e.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,r,n){return r.length===0?[]:[n.styleTitle(e),...r,""]}groupItems(e,r,n){let i=new Map;return e.forEach(o=>{let a=n(o);i.has(a)||i.set(a,[])}),r.forEach(o=>{let a=n(o);i.has(a)||i.set(a,[]),i.get(a).push(o)}),i}formatHelp(e,r){let n=r.padWidth(e,r),i=r.helpWidth??80;function o(p,f){return r.formatItem(p,n,f,r)}let a=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(e))}`,""],s=r.commandDescription(e);s.length>0&&(a=a.concat([r.boxWrap(r.styleCommandDescription(s),i),""]));let c=r.visibleArguments(e).map(p=>o(r.styleArgumentTerm(r.argumentTerm(p)),r.styleArgumentDescription(r.argumentDescription(p))));if(a=a.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(e.options,r.visibleOptions(e),p=>p.helpGroupHeading??"Options:").forEach((p,f)=>{let h=p.map(m=>o(r.styleOptionTerm(r.optionTerm(m)),r.styleOptionDescription(r.optionDescription(m))));a=a.concat(this.formatItemList(f,h,r))}),r.showGlobalOptions){let p=r.visibleGlobalOptions(e).map(f=>o(r.styleOptionTerm(r.optionTerm(f)),r.styleOptionDescription(r.optionDescription(f))));a=a.concat(this.formatItemList("Global Options:",p,r))}return this.groupItems(e.commands,r.visibleCommands(e),p=>p.helpGroup()||"Commands:").forEach((p,f)=>{let h=p.map(m=>o(r.styleSubcommandTerm(r.subcommandTerm(m)),r.styleSubcommandDescription(r.subcommandDescription(m))));a=a.concat(this.formatItemList(f,h,r))}),a.join(`
4
4
  `)}displayWidth(e){return v0(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,r){return Math.max(r.longestOptionTermLength(e,r),r.longestGlobalOptionTermLength(e,r),r.longestSubcommandTermLength(e,r),r.longestArgumentTermLength(e,r))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,r,n,i){let a=" ".repeat(2);if(!n)return a+e;let s=e.padEnd(r+e.length-i.displayWidth(e)),c=2,u=(this.helpWidth??80)-r-c-2,p;return u<this.minWidthToWrap||i.preformatted(n)?p=n:p=i.boxWrap(n,u).replace(/\n/g,`
5
5
  `+" ".repeat(r+c)),a+s+" ".repeat(c)+p.replace(/\n/g,`
6
6
  ${a}`)}boxWrap(e,r){if(r<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,o=[];return n.forEach(a=>{let s=a.match(i);if(s===null){o.push("");return}let c=[s.shift()],l=this.displayWidth(c[0]);s.forEach(u=>{let p=this.displayWidth(u);if(l+p<=r){c.push(u),l+=p;return}o.push(c.join(""));let f=u.trimStart();c=[f],l=this.displayWidth(f)}),o.push(c.join(""))}),o.join(`
@@ -1484,7 +1484,7 @@ ${String(t)}`)}catch(e){return e}},yq=t=>{if(typeof t!="object"||t===null)throw
1484
1484
  }
1485
1485
  }
1486
1486
  }
1487
- `;d();import{randomUUID as uge}from"crypto";var hV=Pt(q1(),1);d();var Xme=Pt(MB(),1),ege=Pt(gg(),1),tge=Pt(Vc(),1),rge=Pt(XI(),1),nge=Pt(rO(),1),ige=Pt(cO(),1),zB=Pt(vg(),1),oge=Pt(VB(),1);var WB=zB.default;d();var ZB=100*1024*1024,bg=class{current=Promise.resolve();async run(e){let r=this.current,n=()=>{};this.current=new Promise(i=>{n=i}),await r;try{return await e()}finally{n()}}},XB=async t=>{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to download CRDT model: ${e.status} ${e.statusText}`);let r=e.body?.getReader();if(!r)throw new Error("Failed to read CRDT model response body");let n=[],i=0;for(;;){let{done:s,value:c}=await r.read();if(s)break;if(i+=c.length,i>ZB)throw new Error(`CRDT model is larger than ${ZB} bytes`);n.push(c)}let o=new Uint8Array(i),a=0;for(let s of n)o.set(s,a),a+=s.length;return o},Rd=async(t,e)=>{try{return await e()}catch(r){return q.warn(`Optional runtime package unavailable: ${t}`,r.message),null}},HB=null,Ei=async()=>(HB??=Rd("@functorz/ztype",()=>import("./ztype-QWGIFPWM.js")).then(t=>(t?.default??t)?.com?.functorz?.ztype??null),HB),KB=null,eV=async()=>(KB??=Rd("@functorz/ztype",()=>import("./ztype-QWGIFPWM.js")).then(t=>(t?.default??t)?.kotlin?.collections??null),KB),QB=null,tV=async()=>(QB??=Ei().then(t=>t?.typesystem?.schema?.SCHEMA_VERSION??null),QB),YB=null,Sg=async()=>(YB??=Rd("@functorz/crdt-helper",()=>import("./index.cjs-BQF3BNLW.js")).then(t=>t?.Crdt??t?.default?.Crdt??null),YB),JB=null,rV=async()=>(JB??=Rd("json-joy/lib/json-crdt-patch/index.js",()=>import("./json-crdt-patch-KOQOV22P.js")).then(t=>t??Rd("json-joy/lib/json-crdt/index.js",()=>import("./json-crdt-FWGW5B2H.js"))).then(t=>t?.Patch??t?.default?.Patch??null),JB),uO=t=>t?.lastUploadedSchema??null,dO=t=>[t?.project?.lastDeployedServerSchemaExId,t?.lastDeployedServerSchemaExId,t?.project?.latestDeployedServerSchema?.exId,t?.latestDeployedServerSchema?.exId].find(r=>typeof r=="string"&&r.length>0)??null,pO=t=>t==null?t:structuredClone(t),nV=(t,e)=>t?.appExId?t.appExId:e?.name??"",iV=(t,e)=>{let r=t?.typesystem?.schema?.ClientType;if(r)return e==="WECHAT_MINI_PROGRAM"?r.WECHAT_MINI_PROGRAM??r.WECHAT??r.WEB:e==="MOBILE"?r.MOBILE??r.WEB:r.WEB},oV=t=>{let e=t?.typesystem?.schema?.Product?.[Ln];if(!e)throw new Error(`ztype runtime has no Product enum member for ${Ln}`);return e},aV=t=>{let e=t?.typesystem?.schema?.Locale?.EN;if(!e)throw new Error("ztype runtime has no Locale enum member for EN");return e},age=t=>{try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}},wg=t=>({componentId:t?.componentId??null,message:typeof t?.getLocalizedErrorMessage=="function"?t.getLocalizedErrorMessage("EN"):t?.message??String(t),zhMessage:typeof t?.getLocalizedErrorMessage=="function"?t.getLocalizedErrorMessage("ZH"):void 0,platform:t?.platform??null,isBackendError:!!t?.isBackendError,fullPath:age(t?.fullPath??[])}),Ig=t=>t.stableErrors.concat(t.betaErrors).filter(e=>!!e.isBackendError),sV=t=>Ig(t).length,cV=(t,e)=>{if(e.__typename==="DiffItem"){let r=e.pathComponents?.at(-1)?.key??"";if(e.operation==="delete"){delete t[r];return}t[r]=structuredClone(e.newValue);return}if(e.__typename==="ArrayDiffItem"){let r=e.pathComponents?.at(-1)?.index??-1;if(!Array.isArray(t)||r<0)throw new Error("Invalid array diff target");if(e.operation==="delete"){t.splice(r,1);return}if(e.operation==="insert"){t.splice(r,0,structuredClone(e.newValue));return}t[r]=structuredClone(e.newValue)}};d();var uV=Pt(uu(),1);import{createRequire as sge}from"module";import{fileURLToPath as cge}from"url";import lV from"path";var dV=sge(import.meta.url),Yi=typeof y>"u"?void 0:y,pV=()=>{if(Yi)return{version:Yi.agent};try{let t=lV.resolve(lV.dirname(cge(import.meta.url)),"../../package.json");return dV(t)}catch{return{}}},fO=()=>pV().version??"0.0.0",Og=t=>{if(Yi){if(t==="@functorz/ztype")return Yi.ztype;if(t==="@functorz/crdt-helper")return Yi.crdtHelper;if(t==="json-joy")return Yi.jsonJoy}try{return dV(`${t}/package.json`).version??"unknown"}catch{return"unavailable"}},lge=async()=>{if(Yi)return{ztypeVersion:Yi.ztype,ztypeSchemaVersion:Yi.ztypeSchemaVersion};try{let t=await Ei();return{ztypeVersion:t?.ZTypeSystem?.getZTypeVersion?.()??Og("@functorz/ztype"),ztypeSchemaVersion:t?.ZTypeSystem?.getSchemaVersion?.()??"unknown"}}catch{return{ztypeVersion:Og("@functorz/ztype"),ztypeSchemaVersion:"unavailable"}}};async function hO(){let t=pV(),e=await lge();return{agentVersion:t.version??"0.0.0",nodeMajor:process.versions.node.split(".")[0],platform:process.platform,arch:process.arch,ztypeVersion:e.ztypeVersion,ztypeSchemaVersion:e.ztypeSchemaVersion,crdtHelperVersion:Og("@functorz/crdt-helper"),jsonJoyVersion:Og("json-joy")}}async function Qc(t,e){let[r,n,i]=await Promise.all([hO(),gi(t),t.loadCredentials()]),o=i?uV.default.decode(i.access_token):null,a=typeof o=="object"&&o!==null?String(o.sub??o.exId??o.id??"authenticated"):"anonymous";return{...r,product:Xe,apiBaseUrl:n.apiBaseUrl,authUserId:a,workspaceRoot:t.getWorkspaceRoot(),typeSystemMode:Xs(),startupFlags:[...e].sort()}}function fV(t,e){return JSON.stringify(t)===JSON.stringify(e)}var mO=uge(),mV=`${Xe}/${fO()}`,dge=t=>{if(!t)return t;if(Array.isArray(t))return t.map(([r,n])=>[r,String(r).toLowerCase()==="authorization"?"Bearer <redacted>":n]);if(typeof t=="object"&&"forEach"in t&&typeof t.forEach=="function"){let r={};return t.forEach((n,i)=>{r[i]=i.toLowerCase()==="authorization"?"Bearer <redacted>":String(n)}),r}let e={};for(let[r,n]of Object.entries(t))e[r]=r.toLowerCase()==="authorization"?"Bearer <redacted>":String(n);return e};function gO(t){if(!Array.isArray(t)||t.length===0)return null;let e=t.map(r=>{let n=r,i=typeof n.operation=="string"?n.operation:null,o=typeof n.errorType=="string"?n.errorType:typeof n.extensions?.classification=="string"?n.extensions.classification:null,a=typeof n.message=="string"?n.message:null;return!a&&!i&&!o?null:`${i?`${i}: `:""}${a??"GraphQL error"}${o?` (${o})`:""}`}).filter(r=>!!r);return e.length>0?e.join("; "):null}var pge=t=>{if(typeof t=="string")return t;if(t instanceof Uint8Array)return Buffer.from(t).toString("utf8");try{return String(t)}catch{return"<unserializable body>"}},Yc=async(t,e)=>{let r=fh();q.debug(`[HTTP] Request URL: ${t.toString()}`),e?.headers&&q.debug(`[HTTP] Request Headers: ${JSON.stringify(dge(e.headers))}`),r&&e?.body!=null&&q.debug(`[GQL] Request Body: ${pge(e.body)}`);let n=await fetch(t,e),i=null;try{i=await n.clone().text()}catch(o){q.debug(`[GQL] Response read failed: ${String(o)}`)}if(r&&q.debug(`[GQL] Response ${n.status}: ${i??"<read failed>"}`),i&&i.includes('"errors"')){let o=null;try{o=JSON.parse(i).errors}catch{o=null}let a=gO(o);a&&q.warn(`[GQL] ${n.status} errors: ${a}`)}return n};async function yO(t,e){let r=await t.getValidToken(),n=await gi(e),i={Authorization:`Bearer ${r}`,"User-Locale":"en_US","X-SESSION-ID":mO,"X-Client":mV},o=await tV();return o&&(i["X-ZED-VERSION"]=o),process.env.REACT_APP_VERSION&&(i["X-REACT-APP-VERSION"]=process.env.REACT_APP_VERSION),new er(`${n.apiBaseUrl}/api/graphql`,{headers:i,fetch:Yc})}async function gV(t,e){let r=await t.getValidToken(),i=`${(await gi(e)).apiBaseUrl.replace(/^http:/,"ws:").replace(/^https:/,"wss:")}/api/graphql-subscription`;return async(o,a,s)=>{let c=fh(),l={authToken:r,"X-SESSION-ID":mO,"X-Client":mV};q.debug(`[SUB] connecting ${i} params=${JSON.stringify({...l,authToken:"Bearer <redacted>"})}`);let u=new hV.SubscriptionClient(i,{lazy:!0,reconnect:!0,minTimeout:3e3,connectionParams:l},WB);u.onConnected(()=>q.debug("[SUB] connected")),u.onReconnected(()=>q.debug("[SUB] reconnected")),u.onDisconnected(()=>q.debug("[SUB] disconnected")),u.onError(h=>q.debug(`[SUB] error ${h?.message??String(h)}`));let f=[{name:"onNewCrdtPatchV2",query:Qq,variables:{projectExId:o.projectExId,appExId:o.appExId??null,versionExId:o.appVersionExId??null,latestPatchExIdInClient:a}},{name:"onSchemaUploadV3",query:Yq,variables:{projectExId:o.projectExId,appExId:o.appExId??null,appVersionExId:o.appVersionExId??null}}].map(h=>(q.debug(`[SUB] subscribe ${h.name} vars=${JSON.stringify(h.variables)}`),u.request({query:h.query,variables:h.variables}).subscribe({next:m=>{c&&q.debug(`[SUB] ${h.name} event: ${JSON.stringify(m)}`),s()},error:m=>{q.warn("Schema subscription event failed",String(m)),s()}})));return{unsubscribe(){for(let h of f)h.unsubscribe();u.close(!1,!1)}}}}async function yV(t,e){if(e.projectExId)return await t.saveProjectContext(e.projectExId),e.projectExId;let r=await t.loadProjectContext();if(!r?.projectExId)throw new Error("No projectExId provided and no current project is set");return r.projectExId}async function _O(t,e,r,n){try{await t.request(fG,{projectExId:e,client:Xe,clientVersion:fO(),sessionId:n??mO,agent:r??null}),q.debug(`[agent-session] started for project ${e}`)}catch(i){q.debug(`[agent-session] skipped: ${String(i)}`)}}d();d();d();import{createHash as fge}from"crypto";var hge=t=>!!(t&&typeof t=="object"&&!Array.isArray(t)),EO=t=>{if(Array.isArray(t))return t.map(r=>r===void 0?null:EO(r));if(!hge(t))return t;let e={};for(let r of Object.keys(t).sort()){let n=t[r];n!==void 0&&(e[r]=EO(n))}return e},mge=t=>JSON.stringify(EO(t)),gge=t=>fge("sha256").update(mge(t)).digest("hex"),_V=t=>({projectExId:t.projectExId,appExId:t.appExId??null,appVersionExId:t.appVersionExId??null,schemaExId:t.schemaExId??null,lastPatchExId:t.lastPatchExId??null,snapshotHash:gge(t.snapshot),deployedSchemaExId:t.deployedSchemaExId??null,checkedAt:t.checkedAt??new Date().toISOString()}),EV=(t,e)=>!t||!e?t!==e:t.schemaExId!==e.schemaExId||t.lastPatchExId!==e.lastPatchExId||t.snapshotHash!==e.snapshotHash||t.deployedSchemaExId!==e.deployedSchemaExId,Ag=t=>t.changes.length>0;var vV=null,yge=()=>(vV??=Ei().then(t=>{let e=t?.typesystem?.schema?.diff?.computeSemanticSchemaChanges;return typeof e=="function"?e:null}),vV),vO=async(t,e)=>{let r=await yge();return r?r(t,e):{changes:[]}};d();var _ge="Functorz";function TV(t,e,r,n){let i=t?.typesystem?.settings,o=t?.typesystem?.schema,a=t?.api?.ZTypeCoreApi,s=e?.KtList,c=e?.KtMap;if(!i?.ExtraContext||!o?.CustomChatModelDescriptor||!o?.AIModelDescriptors||!o?.ActionFlowTemplateCodeDescriptor||!o?.Locale||!a||!s||!c)return q.warn("ztype ExtraContext symbols missing; schema graph will be built without custom models or AF templates"),null;try{let{ExtraContext:l}=i,{AIModelDescriptors:u,ActionFlowTemplateCodeDescriptor:p,Locale:f,CustomChatModelDescriptor:h,CustomEmbeddingModelDescriptor:m,ModelCustomParamDescriptor:_,CustomModelParam:E,CustomChatCompletionFeatures:T,Identifier:b,MediaOutputCardinality:S,Variable:O}=o,w=$=>c.fromJsMap(new Map(Object.entries($??{}))),N=$=>typeof $=="string"?$==="single"?S.SINGLE:$==="multiple"?S.MULTIPLE:S.NONE:typeof $=="boolean"&&$?S.MULTIPLE:S.NONE,L=$=>new _($.name,w($.displayName),$.type,w($.description)),R=$=>new E(L($.serverUrl),L($.apiToken),s.fromJsArray(($.extensionParams??[]).map(wt=>new _(wt.name,w(wt.displayName),wt.type,w(wt.displayName))))),ie=$=>$.provider===_ge&&$.customModelIdentifier?new b($.customModelIdentifier.id,$.customModelIdentifier.namespace):null,ae=$=>c.fromJsMap(new Map(($??[]).filter(wt=>wt!=null).map(wt=>[wt.name,new O(wt.type,null,!wt.required,null,null,null,null,wt.defaultValue==null?null:a.parseDataBindingFromJsObject(wt.defaultValue))]))),Ce=(r?.chatModelDescriptors??[]).map($=>new h($.provider,$.name,R($.paramToConfigure),$.delisted,new T($.features.streamResponse,$.features.multiModal,$.features.imageInput??!1,!1,$.features.videoInput??!1,$.features.imageMessageInput??!1,!1,$.features.videoMessageInput??!1,$.features.tools,$.features.reasoningContent,$.features.imageOutput,$.features.videoOutput,N($.features.imageOutput),N($.features.videoOutput),null,$.features.structuredOutput),ie($))),A=(r?.embeddingModelDescriptors??[]).map($=>new m($.provider,$.name,R($.paramToConfigure),ie($),$.delisted)),ue=c.fromJsMap(new Map((n??[]).map($=>[$.exId,new p($.exId,c.fromJsMap(new Map([[f.EN,$.displayName??""]])),$.logoUrl??"",s.fromJsArray([$.templateGroup??""]),$.async,ae($.inputType),ae($.outputType))])));return new l(new u(s.fromJsArray(Ce),s.fromJsArray(A)),ue)}catch(l){return q.warn("ztype ExtraContext construction failed; schema graph will be built without custom models or AF templates",l.message),null}}d();var Ya=class extends Error{constructor(r,n){super(r);this.diagnostics=n;this.name="ZtypeValidationError"}};d();function Ng(t,e,r){let n=iV(t,r?.appType);return t.api.ZTypeCoreApi.genZTypeApiContext(e,oV(t),n,nV(r,n),aV(t),null)}d();var bV={QUERY:"query",MUTATION:"mutation"},SV={SUCCESS:"2xx",PERMANENT_FAIL:"4xx",TEMPORARY_FAIL:"5xx"};function wV(t){let e=r=>{if(Array.isArray(r))return r.map(e);if(r&&typeof r=="object"){let n={};for(let[i,o]of Object.entries(r))i==="operation"&&typeof o=="string"&&bV[o]!==void 0?n[i]=bV[o]:i==="responseBranch"&&typeof o=="string"&&SV[o]!==void 0?n[i]=SV[o]:n[i]=e(o);return n}return r};return t.map(e)}function IV(t){let e=r=>typeof r=="string"&&!r.startsWith("http://")&&!r.startsWith("https://");for(let r of t){let n=r;if(!n?.args||typeof n.args!="object")continue;let i=n.args,o=[];if(n.name==="UPDATE_TPA_CONFIG")o.push(i.url);else if(n.name==="ADD_TPA_CONFIGS"&&Array.isArray(i.items))for(let a of i.items)a&&typeof a=="object"&&o.push(a.url);for(let a of o)if(e(a))return`url "${a}" is not an absolute URL. A TPA config url must include the scheme and host (e.g. https://api.example.com/v1/resource) \u2014 find the API's base URL in its documentation.`}return null}d();var zn=t=>t==null,Ege=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),OV=t=>{if(Ege(t)){if(!zn(t.id))return{key:"id",value:t.id};if(!zn(t.uniqueId))return{key:"uniqueId",value:t.uniqueId};if(!zn(t.mRef))return{key:"mRef",value:t.mRef}}},TO=(t,e)=>{if(zn(t)&&zn(e)||t===e)return!0;if(zn(t)||zn(e)||typeof t!="object"||typeof e!="object")return!1;let r=t,n=e,i=new Set([...Object.keys(r),...Object.keys(n)]);for(let o of i)if(!TO(r[o],n[o]))return!1;return!0},AV=t=>{if(t.__typename==="DiffItem")switch(t.operation){case"add":return{__typename:"DiffItem",oldValue:t.newValue,newValue:null,operation:"delete",pathComponents:t.pathComponents};case"delete":return{__typename:"DiffItem",oldValue:null,newValue:t.oldValue,operation:"add",pathComponents:t.pathComponents};case"update":return{__typename:"DiffItem",oldValue:t.newValue,newValue:t.oldValue,operation:"update",pathComponents:t.pathComponents}}else switch(t.operation){case"insert":return{__typename:"ArrayDiffItem",oldValue:t.newValue,newValue:null,previousValue:t.previousValue,nextValue:t.nextValue,operation:"delete",pathComponents:t.pathComponents};case"delete":return{__typename:"ArrayDiffItem",oldValue:null,newValue:t.oldValue,previousValue:t.previousValue,nextValue:t.nextValue,operation:"insert",pathComponents:t.pathComponents};case"update":return{__typename:"ArrayDiffItem",oldValue:t.newValue,newValue:t.oldValue,operation:"update",pathComponents:t.pathComponents}}throw new Error(`Cannot reverse diff item: ${JSON.stringify(t)}`)},vge=t=>t.key??t.index??"",Tge=(t,e)=>{let r=t;for(let n of e){if(r===null||typeof r!="object")return;r=r[n]}return r},bge=(t,e)=>{if(e.__typename!=="DiffItem")return null;let r=e.pathComponents.at(-1)?.key;if(r===void 0)return null;let n=OV(t[r]),i=n===void 0?TO(t[r],e.oldValue):n.value===e.oldValue?.[n.key];switch(e.operation){case"add":t[r]=e.newValue;break;case"update":if(!i)return null;t[r]=e.newValue;break;case"delete":if(!Object.prototype.hasOwnProperty.call(t,r)||!i)return null;delete t[r];break;default:return null}return e},Sge=(t,e)=>{if(e.__typename!=="ArrayDiffItem")return null;let r=e.pathComponents.at(-1)?.index;if(r===void 0||r>t.length)return null;let n=()=>{let i=OV(t[r]);return i===void 0?TO(t[r],e.oldValue):i.value===e.oldValue?.[i.key]};switch(e.operation){case"insert":t.splice(r,0,e.newValue);break;case"delete":if(!n())return null;t.splice(r,1);break;case"update":if(!n())return null;t.splice(r,1,e.newValue);break;default:return null}return e},NV=(t,e)=>{let r=t,n=new WeakSet,i=a=>{if(r===null||typeof r!="object")return r;n.has(r)||(r=Array.isArray(r)?[...r]:{...r},n.add(r));let s=r;for(let c of a){let l=s[c];if(l!==null&&typeof l=="object"){if(!n.has(l)){let u=Array.isArray(l)?[...l]:{...l};n.add(u),s[c]=u}s=s[c]}else s=l}return s},o=[];for(let a of e)try{let c=a.pathComponents.map(vge).slice(0,-1);if(zn(Tge(r,c)))continue;let l=i(c);if(Array.isArray(l)){let u=Sge(l,a);u&&o.push(u)}else if(l!==null&&typeof l=="object"){let u=bge(l,a);u&&o.push(u)}}catch{continue}return o};d();var wge=3e4,Cg=class{constructor(e){this.options=e}timer=null;subscriptionHandle=null;running=!1;isActive(){return this.timer!==null||this.subscriptionHandle!==null}start(){this.timer||this.subscriptionHandle||!this.options.subscriptionFactory||this.options.subscriptionFactory(this.options.sessionKey,this.options.getLastPatchExId(),()=>{this.run()}).then(e=>{this.subscriptionHandle=e}).catch(e=>{q.warn("Schema subscription failed; falling back to polling",e.message)}).finally(()=>{this.schedulePoll()})}dispose(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.subscriptionHandle?.unsubscribe(),this.subscriptionHandle=null}schedulePoll(){!this.options.subscriptionFactory||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.run().finally(()=>this.schedulePoll())},wge),this.timer.unref())}async run(){if(!this.running){this.running=!0;try{await this.options.refresh()}finally{this.running=!1}}}};d();d();var g={};ZE(g,{BRAND:()=>Qge,DIRTY:()=>Ja,EMPTY_PATH:()=>Nge,INVALID:()=>ce,NEVER:()=>xye,OK:()=>yr,ParseStatus:()=>ir,Schema:()=>Te,ZodAny:()=>Uo,ZodArray:()=>to,ZodBigInt:()=>es,ZodBoolean:()=>ts,ZodBranded:()=>xd,ZodCatch:()=>ps,ZodDate:()=>rs,ZodDefault:()=>ds,ZodDiscriminatedUnion:()=>Dg,ZodEffects:()=>Sn,ZodEnum:()=>ls,ZodError:()=>$r,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Lg,ZodIntersection:()=>as,ZodIssueCode:()=>x,ZodLazy:()=>ss,ZodLiteral:()=>cs,ZodMap:()=>nl,ZodNaN:()=>ol,ZodNativeEnum:()=>us,ZodNever:()=>Wn,ZodNull:()=>is,ZodNullable:()=>bi,ZodNumber:()=>Xa,ZodObject:()=>Fr,ZodOptional:()=>Ur,ZodParsedType:()=>G,ZodPipeline:()=>Ld,ZodPromise:()=>Fo,ZodReadonly:()=>fs,ZodRecord:()=>xg,ZodSchema:()=>Te,ZodSet:()=>il,ZodString:()=>$o,ZodSymbol:()=>tl,ZodTransformer:()=>Sn,ZodTuple:()=>Ti,ZodType:()=>Te,ZodUndefined:()=>ns,ZodUnion:()=>os,ZodUnknown:()=>eo,ZodVoid:()=>rl,addIssueToContext:()=>F,any:()=>oye,array:()=>lye,bigint:()=>eye,boolean:()=>UV,coerce:()=>Dye,custom:()=>MV,date:()=>tye,datetimeRegex:()=>LV,defaultErrorMap:()=>Ji,discriminatedUnion:()=>pye,effect:()=>wye,enum:()=>Tye,function:()=>_ye,getErrorMap:()=>Jc,getParsedType:()=>vi,instanceof:()=>Jge,intersection:()=>fye,isAborted:()=>Pg,isAsync:()=>Xc,isDirty:()=>Rg,isValid:()=>jo,late:()=>Yge,lazy:()=>Eye,literal:()=>vye,makeIssue:()=>Dd,map:()=>gye,nan:()=>Xge,nativeEnum:()=>bye,never:()=>sye,null:()=>iye,nullable:()=>Oye,number:()=>$V,object:()=>IO,objectUtil:()=>bO,oboolean:()=>Rye,onumber:()=>Pye,optional:()=>Iye,ostring:()=>Cye,pipeline:()=>Nye,preprocess:()=>Aye,promise:()=>Sye,quotelessJson:()=>Ige,record:()=>mye,set:()=>yye,setErrorMap:()=>Age,strictObject:()=>uye,string:()=>jV,symbol:()=>rye,transformer:()=>wye,tuple:()=>hye,undefined:()=>nye,union:()=>dye,unknown:()=>aye,util:()=>Oe,void:()=>cye});d();d();d();d();d();var Oe;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(let s of o)a[s]=i[s];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},t.find=(i,o)=>{for(let a of i)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Oe||(Oe={}));var bO;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(bO||(bO={}));var G=Oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vi=t=>{switch(typeof t){case"undefined":return G.undefined;case"string":return G.string;case"number":return Number.isNaN(t)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(t)?G.array:t===null?G.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?G.promise:typeof Map<"u"&&t instanceof Map?G.map:typeof Set<"u"&&t instanceof Set?G.set:typeof Date<"u"&&t instanceof Date?G.date:G.object;default:return G.unknown}};var x=Oe.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"]),Ige=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),$r=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},i=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(r(a))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return i(this),n}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,Oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};$r.create=t=>new $r(t);var Oge=(t,e)=>{let r;switch(t.code){case x.invalid_type:t.received===G.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Oe.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:r=`Unrecognized key(s) in object: ${Oe.joinValues(t.keys,", ")}`;break;case x.invalid_union:r="Invalid input";break;case x.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Oe.joinValues(t.options)}`;break;case x.invalid_enum_value:r=`Invalid enum value. Expected ${Oe.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:r="Invalid function arguments";break;case x.invalid_return_type:r="Invalid function return type";break;case x.invalid_date:r="Invalid date";break;case x.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Oe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case x.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case x.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case x.custom:r="Invalid input";break;case x.invalid_intersection_types:r="Intersection results could not be merged";break;case x.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:r="Number must be finite";break;default:r=e.defaultError,Oe.assertNever(t)}return{message:r}},Ji=Oge;var CV=Ji;function Age(t){CV=t}function Jc(){return CV}d();var Dd=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,o=[...r,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)s=l(a,{data:e,defaultError:s}).message;return{...i,path:o,message:s}},Nge=[];function F(t,e){let r=Jc(),n=Dd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ji?void 0:Ji].filter(i=>!!i)});t.common.issues.push(n)}var ir=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return ce;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let o=await i.key,a=await i.value;n.push({key:o,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return ce;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:e.value,value:n}}},ce=Object.freeze({status:"aborted"}),Ja=t=>({status:"dirty",value:t}),yr=t=>({status:"valid",value:t}),Pg=t=>t.status==="aborted",Rg=t=>t.status==="dirty",jo=t=>t.status==="valid",Xc=t=>typeof Promise<"u"&&t instanceof Promise;d();d();var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));var bn=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}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}},PV=(t,e)=>{if(jo(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 r=new $r(t.common.issues);return this._error=r,this._error}}};function _e(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var Te=class{get description(){return this._def.description}_getType(e){return vi(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:vi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:vi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Xc(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)},i=this._parseSync({data:e,path:n.path,parent:n});return PV(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return jo(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>jo(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await(Xc(i)?i:Promise.resolve(i));return PV(n,o)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let a=e(i),s=()=>o.addIssue({code:x.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Sn({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:r=>this["~validate"](r)}}optional(){return Ur.create(this,this._def)}nullable(){return bi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return to.create(this)}promise(){return Fo.create(this,this._def)}or(e){return os.create([this,e],this._def)}and(e){return as.create(this,e,this._def)}transform(e){return new Sn({..._e(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ds({..._e(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new xd({typeName:k.ZodBranded,type:this,..._e(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ps({..._e(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ld.create(this,e)}readonly(){return fs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Cge=/^c[^\s-]{8,}$/i,Pge=/^[0-9a-z]+$/,Rge=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Dge=/^[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,xge=/^[a-z0-9_-]{21}$/i,Lge=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kge=/^[-+]?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)?)??$/,Mge=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jge="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",SO,$ge=/^(?:(?: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])$/,Uge=/^(?:(?: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])$/,Fge=/^(([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]))$/,qge=/^(([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])$/,Gge=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bge=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DV="((\\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])))",Vge=new RegExp(`^${DV}$`);function xV(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function zge(t){return new RegExp(`^${xV(t)}$`)}function LV(t){let e=`${DV}T${xV(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Wge(t,e){return!!((e==="v4"||!e)&&$ge.test(t)||(e==="v6"||!e)&&Fge.test(t))}function Zge(t,e){if(!Lge.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Hge(t,e){return!!((e==="v4"||!e)&&Uge.test(t)||(e==="v6"||!e)&&qge.test(t))}var $o=class t extends Te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.string,received:o.parsedType}),ce}let n=new ir,i;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(e,i),a?F(i,{code:x.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&F(i,{code:x.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Mge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"email",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")SO||(SO=new RegExp(jge,"u")),SO.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"emoji",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Dge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"uuid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")xge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"nanoid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Cge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cuid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Pge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cuid2",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Rge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"ulid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),F(i,{validation:"url",code:x.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"regex",code:x.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?LV(o).test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Vge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?zge(o).test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?kge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"duration",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Wge(e.data,o.version)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"ip",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Zge(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"jwt",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Hge(e.data,o.version)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cidr",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Gge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"base64",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Bge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"base64url",code:x.invalid_string,message:o.message}),n.dirty()):Oe.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:x.invalid_string,...Q.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.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,...Q.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,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};$o.create=t=>new $o({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,..._e(t)});function Kge(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}var Xa=class t extends Te{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)!==G.number){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.number,received:o.parsedType}),ce}let n,i=new ir;for(let o of this._def.checks)o.kind==="int"?Oe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:x.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?Kge(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_finite,message:o.message}),i.dirty()):Oe.assertNever(o);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Oe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Xa.create=t=>new Xa({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,..._e(t)});var es=class t extends Te{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)!==G.bigint)return this._getInvalidInput(e);let n,i=new ir;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Oe.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return F(r,{code:x.invalid_type,expected:G.bigint,received:r.parsedType}),ce}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(i)}]})}_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:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};es.create=t=>new es({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,..._e(t)});var ts=class extends Te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.boolean,received:n.parsedType}),ce}return yr(e.data)}};ts.create=t=>new ts({typeName:k.ZodBoolean,coerce:t?.coerce||!1,..._e(t)});var rs=class t extends Te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.date,received:o.parsedType}),ce}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_date}),ce}let n=new ir,i;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Oe.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};rs.create=t=>new rs({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,..._e(t)});var tl=class extends Te{_parse(e){if(this._getType(e)!==G.symbol){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.symbol,received:n.parsedType}),ce}return yr(e.data)}};tl.create=t=>new tl({typeName:k.ZodSymbol,..._e(t)});var ns=class extends Te{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.undefined,received:n.parsedType}),ce}return yr(e.data)}};ns.create=t=>new ns({typeName:k.ZodUndefined,..._e(t)});var is=class extends Te{_parse(e){if(this._getType(e)!==G.null){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.null,received:n.parsedType}),ce}return yr(e.data)}};is.create=t=>new is({typeName:k.ZodNull,..._e(t)});var Uo=class extends Te{constructor(){super(...arguments),this._any=!0}_parse(e){return yr(e.data)}};Uo.create=t=>new Uo({typeName:k.ZodAny,..._e(t)});var eo=class extends Te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return yr(e.data)}};eo.create=t=>new eo({typeName:k.ZodUnknown,..._e(t)});var Wn=class extends Te{_parse(e){let r=this._getOrReturnCtx(e);return F(r,{code:x.invalid_type,expected:G.never,received:r.parsedType}),ce}};Wn.create=t=>new Wn({typeName:k.ZodNever,..._e(t)});var rl=class extends Te{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.void,received:n.parsedType}),ce}return yr(e.data)}};rl.create=t=>new rl({typeName:k.ZodVoid,..._e(t)});var to=class t extends Te{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==G.array)return F(r,{code:x.invalid_type,expected:G.array,received:r.parsedType}),ce;if(i.exactLength!==null){let a=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(a||s)&&(F(r,{code:a?x.too_big:x.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(F(r,{code:x.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(F(r,{code:x.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>i.type._parseAsync(new bn(r,a,r.path,s)))).then(a=>ir.mergeArray(n,a));let o=[...r.data].map((a,s)=>i.type._parseSync(new bn(r,a,r.path,s)));return ir.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}};to.create=(t,e)=>new to({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,..._e(e)});function el(t){if(t instanceof Fr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Ur.create(el(n))}return new Fr({...t._def,shape:()=>e})}else return t instanceof to?new to({...t._def,type:el(t.element)}):t instanceof Ur?Ur.create(el(t.unwrap())):t instanceof bi?bi.create(el(t.unwrap())):t instanceof Ti?Ti.create(t.items.map(e=>el(e))):t}var Fr=class t extends Te{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(),r=Oe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==G.object){let l=this._getOrReturnCtx(e);return F(l,{code:x.invalid_type,expected:G.object,received:l.parsedType}),ce}let{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Wn&&this._def.unknownKeys==="strip"))for(let l in i.data)a.includes(l)||s.push(l);let c=[];for(let l of a){let u=o[l],p=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new bn(i,p,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof Wn){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(l==="strict")s.length>0&&(F(i,{code:x.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of s){let p=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new bn(i,p,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let p=await u.key,f=await u.value;l.push({key:p,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>ir.mergeObjectSync(n,l)):ir.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Q.errToObj(e).message??i}:{message:i}}}:{}})}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,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Oe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of Oe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return el(this)}partial(e){let r={};for(let n of Oe.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of Oe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Ur;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return kV(Oe.objectKeys(this.shape))}};Fr.create=(t,e)=>new Fr({shape:()=>t,unknownKeys:"strip",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});Fr.strictCreate=(t,e)=>new Fr({shape:()=>t,unknownKeys:"strict",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});Fr.lazycreate=(t,e)=>new Fr({shape:t,unknownKeys:"strip",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});var os=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new $r(s.ctx.common.issues));return F(r,{code:x.invalid_union,unionErrors:a}),ce}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let o,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new $r(c));return F(r,{code:x.invalid_union,unionErrors:s}),ce}}get options(){return this._def.options}};os.create=(t,e)=>new os({options:t,typeName:k.ZodUnion,..._e(e)});var Xi=t=>t instanceof ss?Xi(t.schema):t instanceof Sn?Xi(t.innerType()):t instanceof cs?[t.value]:t instanceof ls?t.options:t instanceof us?Oe.objectValues(t.enum):t instanceof ds?Xi(t._def.innerType):t instanceof ns?[void 0]:t instanceof is?[null]:t instanceof Ur?[void 0,...Xi(t.unwrap())]:t instanceof bi?[null,...Xi(t.unwrap())]:t instanceof xd||t instanceof fs?Xi(t.unwrap()):t instanceof ps?Xi(t._def.innerType):[],Dg=class t extends Te{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.object)return F(r,{code:x.invalid_type,expected:G.object,received:r.parsedType}),ce;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(F(r,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let o of r){let a=Xi(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,o)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,..._e(n)})}};function wO(t,e){let r=vi(t),n=vi(e);if(t===e)return{valid:!0,data:t};if(r===G.object&&n===G.object){let i=Oe.objectKeys(e),o=Oe.objectKeys(t).filter(s=>i.indexOf(s)!==-1),a={...t,...e};for(let s of o){let c=wO(t[s],e[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===G.array&&n===G.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let a=t[o],s=e[o],c=wO(a,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===G.date&&n===G.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var as=class extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(o,a)=>{if(Pg(o)||Pg(a))return ce;let s=wO(o.value,a.value);return s.valid?((Rg(o)||Rg(a))&&r.dirty(),{status:r.value,value:s.data}):(F(n,{code:x.invalid_intersection_types}),ce)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};as.create=(t,e,r)=>new as({left:t,right:e,typeName:k.ZodIntersection,..._e(r)});var Ti=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:x.invalid_type,expected:G.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return F(n,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new bn(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>ir.mergeArray(r,a)):ir.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ti.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ti({items:t,typeName:k.ZodTuple,rest:null,..._e(e)})};var xg=class t extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:x.invalid_type,expected:G.object,received:n.parsedType}),ce;let i=[],o=this._def.keyType,a=this._def.valueType;for(let s in n.data)i.push({key:o._parse(new bn(n,s,n.path,s)),value:a._parse(new bn(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?ir.mergeObjectAsync(r,i):ir.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Te?new t({keyType:e,valueType:r,typeName:k.ZodRecord,..._e(n)}):new t({keyType:$o.create(),valueType:e,typeName:k.ZodRecord,..._e(r)})}},nl=class extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:x.invalid_type,expected:G.map,received:n.parsedType}),ce;let i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,c],l)=>({key:i._parse(new bn(n,s,n.path,[l,"key"])),value:o._parse(new bn(n,c,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}}}};nl.create=(t,e,r)=>new nl({valueType:e,keyType:t,typeName:k.ZodMap,..._e(r)});var il=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:x.invalid_type,expected:G.set,received:n.parsedType}),ce;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:x.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:x.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let l=new Set;for(let u of c){if(u.status==="aborted")return ce;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let s=[...n.data.values()].map((c,l)=>o._parse(new bn(n,c,n.path,l)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};il.create=(t,e)=>new il({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,..._e(e)});var Lg=class t extends Te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.function)return F(r,{code:x.invalid_type,expected:G.function,received:r.parsedType}),ce;function n(s,c){return Dd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jc(),Ji].filter(l=>!!l),issueData:{code:x.invalid_arguments,argumentsError:c}})}function i(s,c){return Dd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jc(),Ji].filter(l=>!!l),issueData:{code:x.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Fo){let s=this;return yr(async function(...c){let l=new $r([]),u=await s._def.args.parseAsync(c,o).catch(h=>{throw l.addIssue(n(c,h)),l}),p=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(p,o).catch(h=>{throw l.addIssue(i(p,h)),l})})}else{let s=this;return yr(function(...c){let l=s._def.args.safeParse(c,o);if(!l.success)throw new $r([n(c,l.error)]);let u=Reflect.apply(a,this,l.data),p=s._def.returns.safeParse(u,o);if(!p.success)throw new $r([i(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ti.create(e).rest(eo.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,r,n){return new t({args:e||Ti.create([]).rest(eo.create()),returns:r||eo.create(),typeName:k.ZodFunction,..._e(n)})}},ss=class extends Te{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ss.create=(t,e)=>new ss({getter:t,typeName:k.ZodLazy,..._e(e)});var cs=class extends Te{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return F(r,{received:r.data,code:x.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}};cs.create=(t,e)=>new cs({value:t,typeName:k.ZodLiteral,..._e(e)});function kV(t,e){return new ls({values:t,typeName:k.ZodEnum,..._e(e)})}var ls=class t extends Te{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return F(r,{expected:Oe.joinValues(n),received:r.parsedType,code:x.invalid_type}),ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return F(r,{received:r.data,code:x.invalid_enum_value,options:n}),ce}return yr(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ls.create=kV;var us=class extends Te{_parse(e){let r=Oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let i=Oe.objectValues(r);return F(n,{expected:Oe.joinValues(i),received:n.parsedType,code:x.invalid_type}),ce}if(this._cache||(this._cache=new Set(Oe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=Oe.objectValues(r);return F(n,{received:n.data,code:x.invalid_enum_value,options:i}),ce}return yr(e.data)}get enum(){return this._def.values}};us.create=(t,e)=>new us({values:t,typeName:k.ZodNativeEnum,..._e(e)});var Fo=class extends Te{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.promise&&r.common.async===!1)return F(r,{code:x.invalid_type,expected:G.promise,received:r.parsedType}),ce;let n=r.parsedType===G.promise?r.data:Promise.resolve(r.data);return yr(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Fo.create=(t,e)=>new Fo({type:t,typeName:k.ZodPromise,..._e(e)});var Sn=class extends Te{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:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:a=>{F(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return ce;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"?Ja(c.value):r.value==="dirty"?Ja(c.value):c});{if(r.value==="aborted")return ce;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?Ja(s.value):r.value==="dirty"?Ja(s.value):s}}if(i.type==="refinement"){let a=s=>{let c=i.refinement(s,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!jo(a))return ce;let s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>jo(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:r.value,value:s})):ce);Oe.assertNever(i)}};Sn.create=(t,e,r)=>new Sn({schema:t,typeName:k.ZodEffects,effect:e,..._e(r)});Sn.createWithPreprocess=(t,e,r)=>new Sn({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,..._e(r)});var Ur=class extends Te{_parse(e){return this._getType(e)===G.undefined?yr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ur.create=(t,e)=>new Ur({innerType:t,typeName:k.ZodOptional,..._e(e)});var bi=class extends Te{_parse(e){return this._getType(e)===G.null?yr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};bi.create=(t,e)=>new bi({innerType:t,typeName:k.ZodNullable,..._e(e)});var ds=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ds.create=(t,e)=>new ds({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});var ps=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xc(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ps.create=(t,e)=>new ps({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});var ol=class extends Te{_parse(e){if(this._getType(e)!==G.nan){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.nan,received:n.parsedType}),ce}return{status:"valid",value:e.data}}};ol.create=t=>new ol({typeName:k.ZodNaN,..._e(t)});var Qge=Symbol("zod_brand"),xd=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ld=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:o.status==="dirty"?(r.dirty(),Ja(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ce:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:k.ZodPipeline})}},fs=class extends Te{_parse(e){let r=this._def.innerType._parse(e),n=i=>(jo(i)&&(i.value=Object.freeze(i.value)),i);return Xc(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};fs.create=(t,e)=>new fs({innerType:t,typeName:k.ZodReadonly,..._e(e)});function RV(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function MV(t,e={},r){return t?Uo.create().superRefine((n,i)=>{let o=t(n);if(o instanceof Promise)return o.then(a=>{if(!a){let s=RV(e,n),c=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!o){let a=RV(e,n),s=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:s})}}):Uo.create()}var Yge={object:Fr.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 Jge=(t,e={message:`Input not instance of ${t.name}`})=>MV(r=>r instanceof t,e),jV=$o.create,$V=Xa.create,Xge=ol.create,eye=es.create,UV=ts.create,tye=rs.create,rye=tl.create,nye=ns.create,iye=is.create,oye=Uo.create,aye=eo.create,sye=Wn.create,cye=rl.create,lye=to.create,IO=Fr.create,uye=Fr.strictCreate,dye=os.create,pye=Dg.create,fye=as.create,hye=Ti.create,mye=xg.create,gye=nl.create,yye=il.create,_ye=Lg.create,Eye=ss.create,vye=cs.create,Tye=ls.create,bye=us.create,Sye=Fo.create,wye=Sn.create,Iye=Ur.create,Oye=bi.create,Aye=Sn.createWithPreprocess,Nye=Ld.create,Cye=()=>jV().optional(),Pye=()=>$V().optional(),Rye=()=>UV().optional(),Dye={string:(t=>$o.create({...t,coerce:!0})),number:(t=>Xa.create({...t,coerce:!0})),boolean:(t=>ts.create({...t,coerce:!0})),bigint:(t=>es.create({...t,coerce:!0})),date:(t=>rs.create({...t,coerce:!0}))};var xye=ce;var kg=[{name:"schema_action_menu",tier:"catalog",description:"\nChanges apply immediately; use schema_undo to revert the last change. Ops:\n- op=GET_SELECTABLE_COMPONENT_ACTIONS \u2014 The frontend actions attachable to a component event, as the same category tree the editor's action picker shows \u2014 already filtered to this client's platform, the project's configured authentication, and what the event accepts. Each leaf carries the `eventType` it resolved to here (a leaf like SIGN_IN becomes whichever login the project configured) and the `path` to address it. A leaf's `kind` is what you send to ADD_COMPONENT_ACTIONS to attach it. A leaf with no `kind` cannot be attached by that tool at all \u2014 say so and let the user add it in the editor, rather than attaching some other action that looks close. `kind` is necessary but not sufficient: one kind can cover several eventTypes and may not be able to express the one you want, so if the write is refused, follow that error instead of substituting a different action.",ops:{GET_SELECTABLE_COMPONENT_ACTIONS:"GET_SELECTABLE_COMPONENT_ACTIONS"},inputSchema:{componentId:g.string().optional(),displayName:g.string().optional(),eventType:g.string().optional()}},{name:"schema_actionflow",tier:"core",description:`Action flows \u2014 flow-level (addressed by actionFlowId). Discover types via op=SELECTABLE_TYPES and ids via op=GET_DETAIL. AI nodes require isAsync=true.
1487
+ `;d();import{randomUUID as uge}from"crypto";var hV=Pt(q1(),1);d();var Xme=Pt(MB(),1),ege=Pt(gg(),1),tge=Pt(Vc(),1),rge=Pt(XI(),1),nge=Pt(rO(),1),ige=Pt(cO(),1),zB=Pt(vg(),1),oge=Pt(VB(),1);var WB=zB.default;d();var ZB=100*1024*1024,bg=class{current=Promise.resolve();async run(e){let r=this.current,n=()=>{};this.current=new Promise(i=>{n=i}),await r;try{return await e()}finally{n()}}},XB=async t=>{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to download CRDT model: ${e.status} ${e.statusText}`);let r=e.body?.getReader();if(!r)throw new Error("Failed to read CRDT model response body");let n=[],i=0;for(;;){let{done:s,value:c}=await r.read();if(s)break;if(i+=c.length,i>ZB)throw new Error(`CRDT model is larger than ${ZB} bytes`);n.push(c)}let o=new Uint8Array(i),a=0;for(let s of n)o.set(s,a),a+=s.length;return o},Rd=async(t,e)=>{try{return await e()}catch(r){return q.warn(`Optional runtime package unavailable: ${t}`,r.message),null}},HB=null,Ei=async()=>(HB??=Rd("@functorz/ztype",()=>import("./ztype-RIHJWIR3.js")).then(t=>(t?.default??t)?.com?.functorz?.ztype??null),HB),KB=null,eV=async()=>(KB??=Rd("@functorz/ztype",()=>import("./ztype-RIHJWIR3.js")).then(t=>(t?.default??t)?.kotlin?.collections??null),KB),QB=null,tV=async()=>(QB??=Ei().then(t=>t?.typesystem?.schema?.SCHEMA_VERSION??null),QB),YB=null,Sg=async()=>(YB??=Rd("@functorz/crdt-helper",()=>import("./index.cjs-BFSLHGUW.js")).then(t=>t?.Crdt??t?.default?.Crdt??null),YB),JB=null,rV=async()=>(JB??=Rd("json-joy/lib/json-crdt-patch/index.js",()=>import("./json-crdt-patch-QTCJS73Y.js")).then(t=>t??Rd("json-joy/lib/json-crdt/index.js",()=>import("./json-crdt-IDYQG6MS.js"))).then(t=>t?.Patch??t?.default?.Patch??null),JB),uO=t=>t?.lastUploadedSchema??null,dO=t=>[t?.project?.lastDeployedServerSchemaExId,t?.lastDeployedServerSchemaExId,t?.project?.latestDeployedServerSchema?.exId,t?.latestDeployedServerSchema?.exId].find(r=>typeof r=="string"&&r.length>0)??null,pO=t=>t==null?t:structuredClone(t),nV=(t,e)=>t?.appExId?t.appExId:e?.name??"",iV=(t,e)=>{let r=t?.typesystem?.schema?.ClientType;if(r)return e==="WECHAT_MINI_PROGRAM"?r.WECHAT_MINI_PROGRAM??r.WECHAT??r.WEB:e==="MOBILE"?r.MOBILE??r.WEB:r.WEB},oV=t=>{let e=t?.typesystem?.schema?.Product?.[Ln];if(!e)throw new Error(`ztype runtime has no Product enum member for ${Ln}`);return e},aV=t=>{let e=t?.typesystem?.schema?.Locale?.EN;if(!e)throw new Error("ztype runtime has no Locale enum member for EN");return e},age=t=>{try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}},wg=t=>({componentId:t?.componentId??null,message:typeof t?.getLocalizedErrorMessage=="function"?t.getLocalizedErrorMessage("EN"):t?.message??String(t),zhMessage:typeof t?.getLocalizedErrorMessage=="function"?t.getLocalizedErrorMessage("ZH"):void 0,platform:t?.platform??null,isBackendError:!!t?.isBackendError,fullPath:age(t?.fullPath??[])}),Ig=t=>t.stableErrors.concat(t.betaErrors).filter(e=>!!e.isBackendError),sV=t=>Ig(t).length,cV=(t,e)=>{if(e.__typename==="DiffItem"){let r=e.pathComponents?.at(-1)?.key??"";if(e.operation==="delete"){delete t[r];return}t[r]=structuredClone(e.newValue);return}if(e.__typename==="ArrayDiffItem"){let r=e.pathComponents?.at(-1)?.index??-1;if(!Array.isArray(t)||r<0)throw new Error("Invalid array diff target");if(e.operation==="delete"){t.splice(r,1);return}if(e.operation==="insert"){t.splice(r,0,structuredClone(e.newValue));return}t[r]=structuredClone(e.newValue)}};d();var uV=Pt(uu(),1);import{createRequire as sge}from"module";import{fileURLToPath as cge}from"url";import lV from"path";var dV=sge(import.meta.url),Yi=typeof y>"u"?void 0:y,pV=()=>{if(Yi)return{version:Yi.agent};try{let t=lV.resolve(lV.dirname(cge(import.meta.url)),"../../package.json");return dV(t)}catch{return{}}},fO=()=>pV().version??"0.0.0",Og=t=>{if(Yi){if(t==="@functorz/ztype")return Yi.ztype;if(t==="@functorz/crdt-helper")return Yi.crdtHelper;if(t==="json-joy")return Yi.jsonJoy}try{return dV(`${t}/package.json`).version??"unknown"}catch{return"unavailable"}},lge=async()=>{if(Yi)return{ztypeVersion:Yi.ztype,ztypeSchemaVersion:Yi.ztypeSchemaVersion};try{let t=await Ei();return{ztypeVersion:t?.ZTypeSystem?.getZTypeVersion?.()??Og("@functorz/ztype"),ztypeSchemaVersion:t?.ZTypeSystem?.getSchemaVersion?.()??"unknown"}}catch{return{ztypeVersion:Og("@functorz/ztype"),ztypeSchemaVersion:"unavailable"}}};async function hO(){let t=pV(),e=await lge();return{agentVersion:t.version??"0.0.0",nodeMajor:process.versions.node.split(".")[0],platform:process.platform,arch:process.arch,ztypeVersion:e.ztypeVersion,ztypeSchemaVersion:e.ztypeSchemaVersion,crdtHelperVersion:Og("@functorz/crdt-helper"),jsonJoyVersion:Og("json-joy")}}async function Qc(t,e){let[r,n,i]=await Promise.all([hO(),gi(t),t.loadCredentials()]),o=i?uV.default.decode(i.access_token):null,a=typeof o=="object"&&o!==null?String(o.sub??o.exId??o.id??"authenticated"):"anonymous";return{...r,product:Xe,apiBaseUrl:n.apiBaseUrl,authUserId:a,workspaceRoot:t.getWorkspaceRoot(),typeSystemMode:Xs(),startupFlags:[...e].sort()}}function fV(t,e){return JSON.stringify(t)===JSON.stringify(e)}var mO=uge(),mV=`${Xe}/${fO()}`,dge=t=>{if(!t)return t;if(Array.isArray(t))return t.map(([r,n])=>[r,String(r).toLowerCase()==="authorization"?"Bearer <redacted>":n]);if(typeof t=="object"&&"forEach"in t&&typeof t.forEach=="function"){let r={};return t.forEach((n,i)=>{r[i]=i.toLowerCase()==="authorization"?"Bearer <redacted>":String(n)}),r}let e={};for(let[r,n]of Object.entries(t))e[r]=r.toLowerCase()==="authorization"?"Bearer <redacted>":String(n);return e};function gO(t){if(!Array.isArray(t)||t.length===0)return null;let e=t.map(r=>{let n=r,i=typeof n.operation=="string"?n.operation:null,o=typeof n.errorType=="string"?n.errorType:typeof n.extensions?.classification=="string"?n.extensions.classification:null,a=typeof n.message=="string"?n.message:null;return!a&&!i&&!o?null:`${i?`${i}: `:""}${a??"GraphQL error"}${o?` (${o})`:""}`}).filter(r=>!!r);return e.length>0?e.join("; "):null}var pge=t=>{if(typeof t=="string")return t;if(t instanceof Uint8Array)return Buffer.from(t).toString("utf8");try{return String(t)}catch{return"<unserializable body>"}},Yc=async(t,e)=>{let r=fh();q.debug(`[HTTP] Request URL: ${t.toString()}`),e?.headers&&q.debug(`[HTTP] Request Headers: ${JSON.stringify(dge(e.headers))}`),r&&e?.body!=null&&q.debug(`[GQL] Request Body: ${pge(e.body)}`);let n=await fetch(t,e),i=null;try{i=await n.clone().text()}catch(o){q.debug(`[GQL] Response read failed: ${String(o)}`)}if(r&&q.debug(`[GQL] Response ${n.status}: ${i??"<read failed>"}`),i&&i.includes('"errors"')){let o=null;try{o=JSON.parse(i).errors}catch{o=null}let a=gO(o);a&&q.warn(`[GQL] ${n.status} errors: ${a}`)}return n};async function yO(t,e){let r=await t.getValidToken(),n=await gi(e),i={Authorization:`Bearer ${r}`,"User-Locale":"en_US","X-SESSION-ID":mO,"X-Client":mV},o=await tV();return o&&(i["X-ZED-VERSION"]=o),process.env.REACT_APP_VERSION&&(i["X-REACT-APP-VERSION"]=process.env.REACT_APP_VERSION),new er(`${n.apiBaseUrl}/api/graphql`,{headers:i,fetch:Yc})}async function gV(t,e){let r=await t.getValidToken(),i=`${(await gi(e)).apiBaseUrl.replace(/^http:/,"ws:").replace(/^https:/,"wss:")}/api/graphql-subscription`;return async(o,a,s)=>{let c=fh(),l={authToken:r,"X-SESSION-ID":mO,"X-Client":mV};q.debug(`[SUB] connecting ${i} params=${JSON.stringify({...l,authToken:"Bearer <redacted>"})}`);let u=new hV.SubscriptionClient(i,{lazy:!0,reconnect:!0,minTimeout:3e3,connectionParams:l},WB);u.onConnected(()=>q.debug("[SUB] connected")),u.onReconnected(()=>q.debug("[SUB] reconnected")),u.onDisconnected(()=>q.debug("[SUB] disconnected")),u.onError(h=>q.debug(`[SUB] error ${h?.message??String(h)}`));let f=[{name:"onNewCrdtPatchV2",query:Qq,variables:{projectExId:o.projectExId,appExId:o.appExId??null,versionExId:o.appVersionExId??null,latestPatchExIdInClient:a}},{name:"onSchemaUploadV3",query:Yq,variables:{projectExId:o.projectExId,appExId:o.appExId??null,appVersionExId:o.appVersionExId??null}}].map(h=>(q.debug(`[SUB] subscribe ${h.name} vars=${JSON.stringify(h.variables)}`),u.request({query:h.query,variables:h.variables}).subscribe({next:m=>{c&&q.debug(`[SUB] ${h.name} event: ${JSON.stringify(m)}`),s()},error:m=>{q.warn("Schema subscription event failed",String(m)),s()}})));return{unsubscribe(){for(let h of f)h.unsubscribe();u.close(!1,!1)}}}}async function yV(t,e){if(e.projectExId)return await t.saveProjectContext(e.projectExId),e.projectExId;let r=await t.loadProjectContext();if(!r?.projectExId)throw new Error("No projectExId provided and no current project is set");return r.projectExId}async function _O(t,e,r,n){try{await t.request(fG,{projectExId:e,client:Xe,clientVersion:fO(),sessionId:n??mO,agent:r??null}),q.debug(`[agent-session] started for project ${e}`)}catch(i){q.debug(`[agent-session] skipped: ${String(i)}`)}}d();d();d();import{createHash as fge}from"crypto";var hge=t=>!!(t&&typeof t=="object"&&!Array.isArray(t)),EO=t=>{if(Array.isArray(t))return t.map(r=>r===void 0?null:EO(r));if(!hge(t))return t;let e={};for(let r of Object.keys(t).sort()){let n=t[r];n!==void 0&&(e[r]=EO(n))}return e},mge=t=>JSON.stringify(EO(t)),gge=t=>fge("sha256").update(mge(t)).digest("hex"),_V=t=>({projectExId:t.projectExId,appExId:t.appExId??null,appVersionExId:t.appVersionExId??null,schemaExId:t.schemaExId??null,lastPatchExId:t.lastPatchExId??null,snapshotHash:gge(t.snapshot),deployedSchemaExId:t.deployedSchemaExId??null,checkedAt:t.checkedAt??new Date().toISOString()}),EV=(t,e)=>!t||!e?t!==e:t.schemaExId!==e.schemaExId||t.lastPatchExId!==e.lastPatchExId||t.snapshotHash!==e.snapshotHash||t.deployedSchemaExId!==e.deployedSchemaExId,Ag=t=>t.changes.length>0;var vV=null,yge=()=>(vV??=Ei().then(t=>{let e=t?.typesystem?.schema?.diff?.computeSemanticSchemaChanges;return typeof e=="function"?e:null}),vV),vO=async(t,e)=>{let r=await yge();return r?r(t,e):{changes:[]}};d();var _ge="Functorz";function TV(t,e,r,n){let i=t?.typesystem?.settings,o=t?.typesystem?.schema,a=t?.api?.ZTypeCoreApi,s=e?.KtList,c=e?.KtMap;if(!i?.ExtraContext||!o?.CustomChatModelDescriptor||!o?.AIModelDescriptors||!o?.ActionFlowTemplateCodeDescriptor||!o?.Locale||!a||!s||!c)return q.warn("ztype ExtraContext symbols missing; schema graph will be built without custom models or AF templates"),null;try{let{ExtraContext:l}=i,{AIModelDescriptors:u,ActionFlowTemplateCodeDescriptor:p,Locale:f,CustomChatModelDescriptor:h,CustomEmbeddingModelDescriptor:m,ModelCustomParamDescriptor:_,CustomModelParam:E,CustomChatCompletionFeatures:T,Identifier:b,MediaOutputCardinality:S,Variable:O}=o,w=$=>c.fromJsMap(new Map(Object.entries($??{}))),N=$=>typeof $=="string"?$==="single"?S.SINGLE:$==="multiple"?S.MULTIPLE:S.NONE:typeof $=="boolean"&&$?S.MULTIPLE:S.NONE,L=$=>new _($.name,w($.displayName),$.type,w($.description)),R=$=>new E(L($.serverUrl),L($.apiToken),s.fromJsArray(($.extensionParams??[]).map(wt=>new _(wt.name,w(wt.displayName),wt.type,w(wt.displayName))))),ie=$=>$.provider===_ge&&$.customModelIdentifier?new b($.customModelIdentifier.id,$.customModelIdentifier.namespace):null,ae=$=>c.fromJsMap(new Map(($??[]).filter(wt=>wt!=null).map(wt=>[wt.name,new O(wt.type,null,!wt.required,null,null,null,null,wt.defaultValue==null?null:a.parseDataBindingFromJsObject(wt.defaultValue))]))),Ce=(r?.chatModelDescriptors??[]).map($=>new h($.provider,$.name,R($.paramToConfigure),$.delisted,new T($.features.streamResponse,$.features.multiModal,$.features.imageInput??!1,!1,$.features.videoInput??!1,$.features.imageMessageInput??!1,!1,$.features.videoMessageInput??!1,$.features.tools,$.features.reasoningContent,$.features.imageOutput,$.features.videoOutput,N($.features.imageOutput),N($.features.videoOutput),null,$.features.structuredOutput),ie($))),A=(r?.embeddingModelDescriptors??[]).map($=>new m($.provider,$.name,R($.paramToConfigure),ie($),$.delisted)),ue=c.fromJsMap(new Map((n??[]).map($=>[$.exId,new p($.exId,c.fromJsMap(new Map([[f.EN,$.displayName??""]])),$.logoUrl??"",s.fromJsArray([$.templateGroup??""]),$.async,ae($.inputType),ae($.outputType))])));return new l(new u(s.fromJsArray(Ce),s.fromJsArray(A)),ue)}catch(l){return q.warn("ztype ExtraContext construction failed; schema graph will be built without custom models or AF templates",l.message),null}}d();var Ya=class extends Error{constructor(r,n){super(r);this.diagnostics=n;this.name="ZtypeValidationError"}};d();function Ng(t,e,r){let n=iV(t,r?.appType);return t.api.ZTypeCoreApi.genZTypeApiContext(e,oV(t),n,nV(r,n),aV(t),null)}d();var bV={QUERY:"query",MUTATION:"mutation"},SV={SUCCESS:"2xx",PERMANENT_FAIL:"4xx",TEMPORARY_FAIL:"5xx"};function wV(t){let e=r=>{if(Array.isArray(r))return r.map(e);if(r&&typeof r=="object"){let n={};for(let[i,o]of Object.entries(r))i==="operation"&&typeof o=="string"&&bV[o]!==void 0?n[i]=bV[o]:i==="responseBranch"&&typeof o=="string"&&SV[o]!==void 0?n[i]=SV[o]:n[i]=e(o);return n}return r};return t.map(e)}function IV(t){let e=r=>typeof r=="string"&&!r.startsWith("http://")&&!r.startsWith("https://");for(let r of t){let n=r;if(!n?.args||typeof n.args!="object")continue;let i=n.args,o=[];if(n.name==="UPDATE_TPA_CONFIG")o.push(i.url);else if(n.name==="ADD_TPA_CONFIGS"&&Array.isArray(i.items))for(let a of i.items)a&&typeof a=="object"&&o.push(a.url);for(let a of o)if(e(a))return`url "${a}" is not an absolute URL. A TPA config url must include the scheme and host (e.g. https://api.example.com/v1/resource) \u2014 find the API's base URL in its documentation.`}return null}d();var zn=t=>t==null,Ege=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),OV=t=>{if(Ege(t)){if(!zn(t.id))return{key:"id",value:t.id};if(!zn(t.uniqueId))return{key:"uniqueId",value:t.uniqueId};if(!zn(t.mRef))return{key:"mRef",value:t.mRef}}},TO=(t,e)=>{if(zn(t)&&zn(e)||t===e)return!0;if(zn(t)||zn(e)||typeof t!="object"||typeof e!="object")return!1;let r=t,n=e,i=new Set([...Object.keys(r),...Object.keys(n)]);for(let o of i)if(!TO(r[o],n[o]))return!1;return!0},AV=t=>{if(t.__typename==="DiffItem")switch(t.operation){case"add":return{__typename:"DiffItem",oldValue:t.newValue,newValue:null,operation:"delete",pathComponents:t.pathComponents};case"delete":return{__typename:"DiffItem",oldValue:null,newValue:t.oldValue,operation:"add",pathComponents:t.pathComponents};case"update":return{__typename:"DiffItem",oldValue:t.newValue,newValue:t.oldValue,operation:"update",pathComponents:t.pathComponents}}else switch(t.operation){case"insert":return{__typename:"ArrayDiffItem",oldValue:t.newValue,newValue:null,previousValue:t.previousValue,nextValue:t.nextValue,operation:"delete",pathComponents:t.pathComponents};case"delete":return{__typename:"ArrayDiffItem",oldValue:null,newValue:t.oldValue,previousValue:t.previousValue,nextValue:t.nextValue,operation:"insert",pathComponents:t.pathComponents};case"update":return{__typename:"ArrayDiffItem",oldValue:t.newValue,newValue:t.oldValue,operation:"update",pathComponents:t.pathComponents}}throw new Error(`Cannot reverse diff item: ${JSON.stringify(t)}`)},vge=t=>t.key??t.index??"",Tge=(t,e)=>{let r=t;for(let n of e){if(r===null||typeof r!="object")return;r=r[n]}return r},bge=(t,e)=>{if(e.__typename!=="DiffItem")return null;let r=e.pathComponents.at(-1)?.key;if(r===void 0)return null;let n=OV(t[r]),i=n===void 0?TO(t[r],e.oldValue):n.value===e.oldValue?.[n.key];switch(e.operation){case"add":t[r]=e.newValue;break;case"update":if(!i)return null;t[r]=e.newValue;break;case"delete":if(!Object.prototype.hasOwnProperty.call(t,r)||!i)return null;delete t[r];break;default:return null}return e},Sge=(t,e)=>{if(e.__typename!=="ArrayDiffItem")return null;let r=e.pathComponents.at(-1)?.index;if(r===void 0||r>t.length)return null;let n=()=>{let i=OV(t[r]);return i===void 0?TO(t[r],e.oldValue):i.value===e.oldValue?.[i.key]};switch(e.operation){case"insert":t.splice(r,0,e.newValue);break;case"delete":if(!n())return null;t.splice(r,1);break;case"update":if(!n())return null;t.splice(r,1,e.newValue);break;default:return null}return e},NV=(t,e)=>{let r=t,n=new WeakSet,i=a=>{if(r===null||typeof r!="object")return r;n.has(r)||(r=Array.isArray(r)?[...r]:{...r},n.add(r));let s=r;for(let c of a){let l=s[c];if(l!==null&&typeof l=="object"){if(!n.has(l)){let u=Array.isArray(l)?[...l]:{...l};n.add(u),s[c]=u}s=s[c]}else s=l}return s},o=[];for(let a of e)try{let c=a.pathComponents.map(vge).slice(0,-1);if(zn(Tge(r,c)))continue;let l=i(c);if(Array.isArray(l)){let u=Sge(l,a);u&&o.push(u)}else if(l!==null&&typeof l=="object"){let u=bge(l,a);u&&o.push(u)}}catch{continue}return o};d();var wge=3e4,Cg=class{constructor(e){this.options=e}timer=null;subscriptionHandle=null;running=!1;isActive(){return this.timer!==null||this.subscriptionHandle!==null}start(){this.timer||this.subscriptionHandle||!this.options.subscriptionFactory||this.options.subscriptionFactory(this.options.sessionKey,this.options.getLastPatchExId(),()=>{this.run()}).then(e=>{this.subscriptionHandle=e}).catch(e=>{q.warn("Schema subscription failed; falling back to polling",e.message)}).finally(()=>{this.schedulePoll()})}dispose(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.subscriptionHandle?.unsubscribe(),this.subscriptionHandle=null}schedulePoll(){!this.options.subscriptionFactory||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.run().finally(()=>this.schedulePoll())},wge),this.timer.unref())}async run(){if(!this.running){this.running=!0;try{await this.options.refresh()}finally{this.running=!1}}}};d();d();var g={};ZE(g,{BRAND:()=>Qge,DIRTY:()=>Ja,EMPTY_PATH:()=>Nge,INVALID:()=>ce,NEVER:()=>xye,OK:()=>yr,ParseStatus:()=>ir,Schema:()=>Te,ZodAny:()=>Uo,ZodArray:()=>to,ZodBigInt:()=>es,ZodBoolean:()=>ts,ZodBranded:()=>xd,ZodCatch:()=>ps,ZodDate:()=>rs,ZodDefault:()=>ds,ZodDiscriminatedUnion:()=>Dg,ZodEffects:()=>Sn,ZodEnum:()=>ls,ZodError:()=>$r,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Lg,ZodIntersection:()=>as,ZodIssueCode:()=>x,ZodLazy:()=>ss,ZodLiteral:()=>cs,ZodMap:()=>nl,ZodNaN:()=>ol,ZodNativeEnum:()=>us,ZodNever:()=>Wn,ZodNull:()=>is,ZodNullable:()=>bi,ZodNumber:()=>Xa,ZodObject:()=>Fr,ZodOptional:()=>Ur,ZodParsedType:()=>G,ZodPipeline:()=>Ld,ZodPromise:()=>Fo,ZodReadonly:()=>fs,ZodRecord:()=>xg,ZodSchema:()=>Te,ZodSet:()=>il,ZodString:()=>$o,ZodSymbol:()=>tl,ZodTransformer:()=>Sn,ZodTuple:()=>Ti,ZodType:()=>Te,ZodUndefined:()=>ns,ZodUnion:()=>os,ZodUnknown:()=>eo,ZodVoid:()=>rl,addIssueToContext:()=>F,any:()=>oye,array:()=>lye,bigint:()=>eye,boolean:()=>UV,coerce:()=>Dye,custom:()=>MV,date:()=>tye,datetimeRegex:()=>LV,defaultErrorMap:()=>Ji,discriminatedUnion:()=>pye,effect:()=>wye,enum:()=>Tye,function:()=>_ye,getErrorMap:()=>Jc,getParsedType:()=>vi,instanceof:()=>Jge,intersection:()=>fye,isAborted:()=>Pg,isAsync:()=>Xc,isDirty:()=>Rg,isValid:()=>jo,late:()=>Yge,lazy:()=>Eye,literal:()=>vye,makeIssue:()=>Dd,map:()=>gye,nan:()=>Xge,nativeEnum:()=>bye,never:()=>sye,null:()=>iye,nullable:()=>Oye,number:()=>$V,object:()=>IO,objectUtil:()=>bO,oboolean:()=>Rye,onumber:()=>Pye,optional:()=>Iye,ostring:()=>Cye,pipeline:()=>Nye,preprocess:()=>Aye,promise:()=>Sye,quotelessJson:()=>Ige,record:()=>mye,set:()=>yye,setErrorMap:()=>Age,strictObject:()=>uye,string:()=>jV,symbol:()=>rye,transformer:()=>wye,tuple:()=>hye,undefined:()=>nye,union:()=>dye,unknown:()=>aye,util:()=>Oe,void:()=>cye});d();d();d();d();d();var Oe;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(let s of o)a[s]=i[s];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},t.find=(i,o)=>{for(let a of i)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Oe||(Oe={}));var bO;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(bO||(bO={}));var G=Oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vi=t=>{switch(typeof t){case"undefined":return G.undefined;case"string":return G.string;case"number":return Number.isNaN(t)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(t)?G.array:t===null?G.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?G.promise:typeof Map<"u"&&t instanceof Map?G.map:typeof Set<"u"&&t instanceof Set?G.set:typeof Date<"u"&&t instanceof Date?G.date:G.object;default:return G.unknown}};var x=Oe.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"]),Ige=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),$r=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},i=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(r(a))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return i(this),n}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,Oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};$r.create=t=>new $r(t);var Oge=(t,e)=>{let r;switch(t.code){case x.invalid_type:t.received===G.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Oe.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:r=`Unrecognized key(s) in object: ${Oe.joinValues(t.keys,", ")}`;break;case x.invalid_union:r="Invalid input";break;case x.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Oe.joinValues(t.options)}`;break;case x.invalid_enum_value:r=`Invalid enum value. Expected ${Oe.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:r="Invalid function arguments";break;case x.invalid_return_type:r="Invalid function return type";break;case x.invalid_date:r="Invalid date";break;case x.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Oe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case x.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case x.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case x.custom:r="Invalid input";break;case x.invalid_intersection_types:r="Intersection results could not be merged";break;case x.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:r="Number must be finite";break;default:r=e.defaultError,Oe.assertNever(t)}return{message:r}},Ji=Oge;var CV=Ji;function Age(t){CV=t}function Jc(){return CV}d();var Dd=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,o=[...r,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)s=l(a,{data:e,defaultError:s}).message;return{...i,path:o,message:s}},Nge=[];function F(t,e){let r=Jc(),n=Dd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ji?void 0:Ji].filter(i=>!!i)});t.common.issues.push(n)}var ir=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return ce;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let o=await i.key,a=await i.value;n.push({key:o,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return ce;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:e.value,value:n}}},ce=Object.freeze({status:"aborted"}),Ja=t=>({status:"dirty",value:t}),yr=t=>({status:"valid",value:t}),Pg=t=>t.status==="aborted",Rg=t=>t.status==="dirty",jo=t=>t.status==="valid",Xc=t=>typeof Promise<"u"&&t instanceof Promise;d();d();var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));var bn=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}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}},PV=(t,e)=>{if(jo(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 r=new $r(t.common.issues);return this._error=r,this._error}}};function _e(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var Te=class{get description(){return this._def.description}_getType(e){return vi(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:vi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:vi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Xc(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)},i=this._parseSync({data:e,path:n.path,parent:n});return PV(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return jo(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>jo(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vi(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await(Xc(i)?i:Promise.resolve(i));return PV(n,o)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let a=e(i),s=()=>o.addIssue({code:x.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Sn({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:r=>this["~validate"](r)}}optional(){return Ur.create(this,this._def)}nullable(){return bi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return to.create(this)}promise(){return Fo.create(this,this._def)}or(e){return os.create([this,e],this._def)}and(e){return as.create(this,e,this._def)}transform(e){return new Sn({..._e(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ds({..._e(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new xd({typeName:k.ZodBranded,type:this,..._e(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ps({..._e(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ld.create(this,e)}readonly(){return fs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Cge=/^c[^\s-]{8,}$/i,Pge=/^[0-9a-z]+$/,Rge=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Dge=/^[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,xge=/^[a-z0-9_-]{21}$/i,Lge=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kge=/^[-+]?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)?)??$/,Mge=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jge="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",SO,$ge=/^(?:(?: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])$/,Uge=/^(?:(?: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])$/,Fge=/^(([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]))$/,qge=/^(([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])$/,Gge=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bge=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DV="((\\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])))",Vge=new RegExp(`^${DV}$`);function xV(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function zge(t){return new RegExp(`^${xV(t)}$`)}function LV(t){let e=`${DV}T${xV(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Wge(t,e){return!!((e==="v4"||!e)&&$ge.test(t)||(e==="v6"||!e)&&Fge.test(t))}function Zge(t,e){if(!Lge.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Hge(t,e){return!!((e==="v4"||!e)&&Uge.test(t)||(e==="v6"||!e)&&qge.test(t))}var $o=class t extends Te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.string,received:o.parsedType}),ce}let n=new ir,i;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(e,i),a?F(i,{code:x.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&F(i,{code:x.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Mge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"email",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")SO||(SO=new RegExp(jge,"u")),SO.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"emoji",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Dge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"uuid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")xge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"nanoid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Cge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cuid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Pge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cuid2",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Rge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"ulid",code:x.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),F(i,{validation:"url",code:x.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"regex",code:x.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?LV(o).test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Vge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?zge(o).test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:x.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?kge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"duration",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Wge(e.data,o.version)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"ip",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Zge(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"jwt",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Hge(e.data,o.version)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"cidr",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Gge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"base64",code:x.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Bge.test(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{validation:"base64url",code:x.invalid_string,message:o.message}),n.dirty()):Oe.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:x.invalid_string,...Q.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.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,...Q.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,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};$o.create=t=>new $o({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,..._e(t)});function Kge(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}var Xa=class t extends Te{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)!==G.number){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.number,received:o.parsedType}),ce}let n,i=new ir;for(let o of this._def.checks)o.kind==="int"?Oe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:x.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?Kge(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_finite,message:o.message}),i.dirty()):Oe.assertNever(o);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Oe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Xa.create=t=>new Xa({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,..._e(t)});var es=class t extends Te{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)!==G.bigint)return this._getInvalidInput(e);let n,i=new ir;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),F(n,{code:x.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Oe.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return F(r,{code:x.invalid_type,expected:G.bigint,received:r.parsedType}),ce}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(i)}]})}_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:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};es.create=t=>new es({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,..._e(t)});var ts=class extends Te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.boolean,received:n.parsedType}),ce}return yr(e.data)}};ts.create=t=>new ts({typeName:k.ZodBoolean,coerce:t?.coerce||!1,..._e(t)});var rs=class t extends Te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_type,expected:G.date,received:o.parsedType}),ce}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return F(o,{code:x.invalid_date}),ce}let n=new ir,i;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),F(i,{code:x.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Oe.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};rs.create=t=>new rs({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,..._e(t)});var tl=class extends Te{_parse(e){if(this._getType(e)!==G.symbol){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.symbol,received:n.parsedType}),ce}return yr(e.data)}};tl.create=t=>new tl({typeName:k.ZodSymbol,..._e(t)});var ns=class extends Te{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.undefined,received:n.parsedType}),ce}return yr(e.data)}};ns.create=t=>new ns({typeName:k.ZodUndefined,..._e(t)});var is=class extends Te{_parse(e){if(this._getType(e)!==G.null){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.null,received:n.parsedType}),ce}return yr(e.data)}};is.create=t=>new is({typeName:k.ZodNull,..._e(t)});var Uo=class extends Te{constructor(){super(...arguments),this._any=!0}_parse(e){return yr(e.data)}};Uo.create=t=>new Uo({typeName:k.ZodAny,..._e(t)});var eo=class extends Te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return yr(e.data)}};eo.create=t=>new eo({typeName:k.ZodUnknown,..._e(t)});var Wn=class extends Te{_parse(e){let r=this._getOrReturnCtx(e);return F(r,{code:x.invalid_type,expected:G.never,received:r.parsedType}),ce}};Wn.create=t=>new Wn({typeName:k.ZodNever,..._e(t)});var rl=class extends Te{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.void,received:n.parsedType}),ce}return yr(e.data)}};rl.create=t=>new rl({typeName:k.ZodVoid,..._e(t)});var to=class t extends Te{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==G.array)return F(r,{code:x.invalid_type,expected:G.array,received:r.parsedType}),ce;if(i.exactLength!==null){let a=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(a||s)&&(F(r,{code:a?x.too_big:x.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(F(r,{code:x.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(F(r,{code:x.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>i.type._parseAsync(new bn(r,a,r.path,s)))).then(a=>ir.mergeArray(n,a));let o=[...r.data].map((a,s)=>i.type._parseSync(new bn(r,a,r.path,s)));return ir.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}};to.create=(t,e)=>new to({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,..._e(e)});function el(t){if(t instanceof Fr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Ur.create(el(n))}return new Fr({...t._def,shape:()=>e})}else return t instanceof to?new to({...t._def,type:el(t.element)}):t instanceof Ur?Ur.create(el(t.unwrap())):t instanceof bi?bi.create(el(t.unwrap())):t instanceof Ti?Ti.create(t.items.map(e=>el(e))):t}var Fr=class t extends Te{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(),r=Oe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==G.object){let l=this._getOrReturnCtx(e);return F(l,{code:x.invalid_type,expected:G.object,received:l.parsedType}),ce}let{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Wn&&this._def.unknownKeys==="strip"))for(let l in i.data)a.includes(l)||s.push(l);let c=[];for(let l of a){let u=o[l],p=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new bn(i,p,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof Wn){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(l==="strict")s.length>0&&(F(i,{code:x.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of s){let p=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new bn(i,p,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let p=await u.key,f=await u.value;l.push({key:p,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>ir.mergeObjectSync(n,l)):ir.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Q.errToObj(e).message??i}:{message:i}}}:{}})}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,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Oe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of Oe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return el(this)}partial(e){let r={};for(let n of Oe.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of Oe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Ur;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return kV(Oe.objectKeys(this.shape))}};Fr.create=(t,e)=>new Fr({shape:()=>t,unknownKeys:"strip",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});Fr.strictCreate=(t,e)=>new Fr({shape:()=>t,unknownKeys:"strict",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});Fr.lazycreate=(t,e)=>new Fr({shape:t,unknownKeys:"strip",catchall:Wn.create(),typeName:k.ZodObject,..._e(e)});var os=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new $r(s.ctx.common.issues));return F(r,{code:x.invalid_union,unionErrors:a}),ce}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let o,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new $r(c));return F(r,{code:x.invalid_union,unionErrors:s}),ce}}get options(){return this._def.options}};os.create=(t,e)=>new os({options:t,typeName:k.ZodUnion,..._e(e)});var Xi=t=>t instanceof ss?Xi(t.schema):t instanceof Sn?Xi(t.innerType()):t instanceof cs?[t.value]:t instanceof ls?t.options:t instanceof us?Oe.objectValues(t.enum):t instanceof ds?Xi(t._def.innerType):t instanceof ns?[void 0]:t instanceof is?[null]:t instanceof Ur?[void 0,...Xi(t.unwrap())]:t instanceof bi?[null,...Xi(t.unwrap())]:t instanceof xd||t instanceof fs?Xi(t.unwrap()):t instanceof ps?Xi(t._def.innerType):[],Dg=class t extends Te{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.object)return F(r,{code:x.invalid_type,expected:G.object,received:r.parsedType}),ce;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(F(r,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let o of r){let a=Xi(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,o)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,..._e(n)})}};function wO(t,e){let r=vi(t),n=vi(e);if(t===e)return{valid:!0,data:t};if(r===G.object&&n===G.object){let i=Oe.objectKeys(e),o=Oe.objectKeys(t).filter(s=>i.indexOf(s)!==-1),a={...t,...e};for(let s of o){let c=wO(t[s],e[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===G.array&&n===G.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let a=t[o],s=e[o],c=wO(a,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===G.date&&n===G.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var as=class extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(o,a)=>{if(Pg(o)||Pg(a))return ce;let s=wO(o.value,a.value);return s.valid?((Rg(o)||Rg(a))&&r.dirty(),{status:r.value,value:s.data}):(F(n,{code:x.invalid_intersection_types}),ce)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};as.create=(t,e,r)=>new as({left:t,right:e,typeName:k.ZodIntersection,..._e(r)});var Ti=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:x.invalid_type,expected:G.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return F(n,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new bn(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>ir.mergeArray(r,a)):ir.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ti.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ti({items:t,typeName:k.ZodTuple,rest:null,..._e(e)})};var xg=class t extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:x.invalid_type,expected:G.object,received:n.parsedType}),ce;let i=[],o=this._def.keyType,a=this._def.valueType;for(let s in n.data)i.push({key:o._parse(new bn(n,s,n.path,s)),value:a._parse(new bn(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?ir.mergeObjectAsync(r,i):ir.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Te?new t({keyType:e,valueType:r,typeName:k.ZodRecord,..._e(n)}):new t({keyType:$o.create(),valueType:e,typeName:k.ZodRecord,..._e(r)})}},nl=class extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:x.invalid_type,expected:G.map,received:n.parsedType}),ce;let i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,c],l)=>({key:i._parse(new bn(n,s,n.path,[l,"key"])),value:o._parse(new bn(n,c,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}}}};nl.create=(t,e,r)=>new nl({valueType:e,keyType:t,typeName:k.ZodMap,..._e(r)});var il=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:x.invalid_type,expected:G.set,received:n.parsedType}),ce;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:x.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:x.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let l=new Set;for(let u of c){if(u.status==="aborted")return ce;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let s=[...n.data.values()].map((c,l)=>o._parse(new bn(n,c,n.path,l)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};il.create=(t,e)=>new il({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,..._e(e)});var Lg=class t extends Te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.function)return F(r,{code:x.invalid_type,expected:G.function,received:r.parsedType}),ce;function n(s,c){return Dd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jc(),Ji].filter(l=>!!l),issueData:{code:x.invalid_arguments,argumentsError:c}})}function i(s,c){return Dd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jc(),Ji].filter(l=>!!l),issueData:{code:x.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Fo){let s=this;return yr(async function(...c){let l=new $r([]),u=await s._def.args.parseAsync(c,o).catch(h=>{throw l.addIssue(n(c,h)),l}),p=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(p,o).catch(h=>{throw l.addIssue(i(p,h)),l})})}else{let s=this;return yr(function(...c){let l=s._def.args.safeParse(c,o);if(!l.success)throw new $r([n(c,l.error)]);let u=Reflect.apply(a,this,l.data),p=s._def.returns.safeParse(u,o);if(!p.success)throw new $r([i(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ti.create(e).rest(eo.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,r,n){return new t({args:e||Ti.create([]).rest(eo.create()),returns:r||eo.create(),typeName:k.ZodFunction,..._e(n)})}},ss=class extends Te{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ss.create=(t,e)=>new ss({getter:t,typeName:k.ZodLazy,..._e(e)});var cs=class extends Te{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return F(r,{received:r.data,code:x.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}};cs.create=(t,e)=>new cs({value:t,typeName:k.ZodLiteral,..._e(e)});function kV(t,e){return new ls({values:t,typeName:k.ZodEnum,..._e(e)})}var ls=class t extends Te{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return F(r,{expected:Oe.joinValues(n),received:r.parsedType,code:x.invalid_type}),ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return F(r,{received:r.data,code:x.invalid_enum_value,options:n}),ce}return yr(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ls.create=kV;var us=class extends Te{_parse(e){let r=Oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let i=Oe.objectValues(r);return F(n,{expected:Oe.joinValues(i),received:n.parsedType,code:x.invalid_type}),ce}if(this._cache||(this._cache=new Set(Oe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=Oe.objectValues(r);return F(n,{received:n.data,code:x.invalid_enum_value,options:i}),ce}return yr(e.data)}get enum(){return this._def.values}};us.create=(t,e)=>new us({values:t,typeName:k.ZodNativeEnum,..._e(e)});var Fo=class extends Te{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==G.promise&&r.common.async===!1)return F(r,{code:x.invalid_type,expected:G.promise,received:r.parsedType}),ce;let n=r.parsedType===G.promise?r.data:Promise.resolve(r.data);return yr(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Fo.create=(t,e)=>new Fo({type:t,typeName:k.ZodPromise,..._e(e)});var Sn=class extends Te{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:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:a=>{F(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return ce;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"?Ja(c.value):r.value==="dirty"?Ja(c.value):c});{if(r.value==="aborted")return ce;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?Ja(s.value):r.value==="dirty"?Ja(s.value):s}}if(i.type==="refinement"){let a=s=>{let c=i.refinement(s,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!jo(a))return ce;let s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>jo(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:r.value,value:s})):ce);Oe.assertNever(i)}};Sn.create=(t,e,r)=>new Sn({schema:t,typeName:k.ZodEffects,effect:e,..._e(r)});Sn.createWithPreprocess=(t,e,r)=>new Sn({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,..._e(r)});var Ur=class extends Te{_parse(e){return this._getType(e)===G.undefined?yr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ur.create=(t,e)=>new Ur({innerType:t,typeName:k.ZodOptional,..._e(e)});var bi=class extends Te{_parse(e){return this._getType(e)===G.null?yr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};bi.create=(t,e)=>new bi({innerType:t,typeName:k.ZodNullable,..._e(e)});var ds=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ds.create=(t,e)=>new ds({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});var ps=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xc(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ps.create=(t,e)=>new ps({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});var ol=class extends Te{_parse(e){if(this._getType(e)!==G.nan){let n=this._getOrReturnCtx(e);return F(n,{code:x.invalid_type,expected:G.nan,received:n.parsedType}),ce}return{status:"valid",value:e.data}}};ol.create=t=>new ol({typeName:k.ZodNaN,..._e(t)});var Qge=Symbol("zod_brand"),xd=class extends Te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ld=class t extends Te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:o.status==="dirty"?(r.dirty(),Ja(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ce:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:k.ZodPipeline})}},fs=class extends Te{_parse(e){let r=this._def.innerType._parse(e),n=i=>(jo(i)&&(i.value=Object.freeze(i.value)),i);return Xc(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};fs.create=(t,e)=>new fs({innerType:t,typeName:k.ZodReadonly,..._e(e)});function RV(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function MV(t,e={},r){return t?Uo.create().superRefine((n,i)=>{let o=t(n);if(o instanceof Promise)return o.then(a=>{if(!a){let s=RV(e,n),c=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!o){let a=RV(e,n),s=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:s})}}):Uo.create()}var Yge={object:Fr.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 Jge=(t,e={message:`Input not instance of ${t.name}`})=>MV(r=>r instanceof t,e),jV=$o.create,$V=Xa.create,Xge=ol.create,eye=es.create,UV=ts.create,tye=rs.create,rye=tl.create,nye=ns.create,iye=is.create,oye=Uo.create,aye=eo.create,sye=Wn.create,cye=rl.create,lye=to.create,IO=Fr.create,uye=Fr.strictCreate,dye=os.create,pye=Dg.create,fye=as.create,hye=Ti.create,mye=xg.create,gye=nl.create,yye=il.create,_ye=Lg.create,Eye=ss.create,vye=cs.create,Tye=ls.create,bye=us.create,Sye=Fo.create,wye=Sn.create,Iye=Ur.create,Oye=bi.create,Aye=Sn.createWithPreprocess,Nye=Ld.create,Cye=()=>jV().optional(),Pye=()=>$V().optional(),Rye=()=>UV().optional(),Dye={string:(t=>$o.create({...t,coerce:!0})),number:(t=>Xa.create({...t,coerce:!0})),boolean:(t=>ts.create({...t,coerce:!0})),bigint:(t=>es.create({...t,coerce:!0})),date:(t=>rs.create({...t,coerce:!0}))};var xye=ce;var kg=[{name:"schema_action_menu",tier:"catalog",description:"\nChanges apply immediately; use schema_undo to revert the last change. Ops:\n- op=GET_SELECTABLE_COMPONENT_ACTIONS \u2014 The frontend actions attachable to a component event, as the same category tree the editor's action picker shows \u2014 already filtered to this client's platform, the project's configured authentication, and what the event accepts. Each leaf carries the `eventType` it resolved to here (a leaf like SIGN_IN becomes whichever login the project configured) and the `path` to address it. A leaf's `kind` is what you send to ADD_COMPONENT_ACTIONS to attach it. A leaf with no `kind` cannot be attached by that tool at all \u2014 say so and let the user add it in the editor, rather than attaching some other action that looks close. `kind` is necessary but not sufficient: one kind can cover several eventTypes and may not be able to express the one you want, so if the write is refused, follow that error instead of substituting a different action.",ops:{GET_SELECTABLE_COMPONENT_ACTIONS:"GET_SELECTABLE_COMPONENT_ACTIONS"},inputSchema:{componentId:g.string().optional(),displayName:g.string().optional(),eventType:g.string().optional()}},{name:"schema_actionflow",tier:"core",description:`Action flows \u2014 flow-level (addressed by actionFlowId). Discover types via op=SELECTABLE_TYPES and ids via op=GET_DETAIL. AI nodes require isAsync=true.
1488
1488
  Changes apply immediately; use schema_undo to revert the last change. Ops:
1489
1489
  - op=ADD \u2014 Result echoes each new flow's id.
1490
1490
  - op=ADD_GLOBAL_VARS \u2014 Result echoes each new variable's minted key.
@@ -1915,7 +1915,7 @@ ${Vg(e," ")}
1915
1915
  }`),Ez=()=>`mutation AgentRunCode($jsCode: String!, $args: JsonObject, $updateDb: Boolean!) {
1916
1916
  fz_debug_action_code(jsCode: $jsCode, args: $args, updateDb: $updateDb)
1917
1917
  }`;var Q_e=20,Y_e=200,J_e=20,RO="id",DO=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},Sz=t=>Array.isArray(t)?t:[],X_e=(t,e)=>typeof t=="boolean"?t:t==null?e:String(t).toLowerCase()==="true",vz=(t,e)=>typeof t=="number"&&Number.isFinite(t)?Math.trunc(t):e,Tz=(t,e)=>{let r=t[e];if(typeof r!="string"||r.trim()==="")throw new Error(`'${e}' is required.`);return r},bz=(t,e,r)=>{let n=DO(t.where);if(Object.keys(n).length>0)return n;if(t[r]===!0)return{};throw new Error(`'where' is required and must not be empty \u2014 this ${e} runs against the live app and there is no change-everything option.`)},zg=(t,e)=>{let r=Sz(t.fields).filter(n=>typeof n=="string"&&n.trim()!=="");return r.length>0?(PO(r,"fields"),r):e.length>0?e.slice(0,J_e):[RO]},eEe=t=>t.includes(RO)?t:[RO,...t],xO=(t,e,r=[])=>{if(t==="runtime.run_code")return{document:Ez(),variables:{jsCode:Tz(e,"jsCode"),args:DO(e.args),updateDb:X_e(e.updateDb,!1)},rootField:"fz_debug_action_code"};let n=Tz(e,"tableName");switch(Go(n,"tableName"),t){case"runtime.query":return{document:hz(n,zg(e,r)),variables:{where:e.where??{},limit:Math.min(vz(e.limit,Q_e),Y_e),offset:vz(e.offset,0),order_by:e.orderBy??null},rootField:n};case"runtime.aggregate":return{document:mz(n),variables:{where:e.where??{}},rootField:`${n}_aggregate`};case"runtime.insert":{let i=Sz(e.objects);if(i.length===0)throw new Error("'objects' must contain at least one row to insert.");if(i.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new Error("every entry in 'objects' must be an object of column values.");return{document:gz(n,eEe(zg(e,r))),variables:{objects:i},rootField:`insert_${n}`}}case"runtime.update":{let i=bz(e,"update","allowUpdateAll"),o=DO(e.set);if(Object.keys(o).length===0)throw new Error("'set' must contain at least one column to change.");return{document:yz(n,zg(e,r)),variables:{where:i,set:o},rootField:`update_${n}`}}case"runtime.delete":return{document:_z(n,zg(e,r)),variables:{where:bz(e,"delete","allowDeleteAll")},rootField:`delete_${n}`};default:throw new Error(`'${t}' is not a planned runtime operation.`)}},wz=t=>{if(!t||typeof t!="object"||Array.isArray(t))return t;let e=Object.keys(t);return e.length===1?t[e[0]]:t};async function Fd(t,e,r,n){let i=await r.checkSchema(e),o=await r.getProjectArgs(e),a=ms(e.tableName,"tableName"),[s,c]=await Promise.all([r.schemaManager.dataModel(Si(o.projectExId,o)),al(r.client,o)]);fz(s,a,hs(e.fields));let l=xO(t,{...e,tableName:a},VV(s,a)),u;try{u=await c.dataClient.request(l.document,l.variables)}catch(p){throw pz(p,a,s)}return r.ok(qr(n?wz(u):u,i))}var tEe=async(t,e)=>{let r=await e.checkSchema(t),n=await e.getProjectArgs(t),i=ms(t.query,"query"),a=await(await al(e.client,n)).dataClient.request(i,t.variables??{});return e.ok(qr(a,r))},rEe=async(t,e)=>Fd("runtime.query",t,e,!1),nEe=async(t,e)=>Fd("runtime.aggregate",t,e,!1),iEe=async(t,e)=>Fd("runtime.insert",t,e,!0),oEe=async(t,e)=>Fd("runtime.update",t,e,!0),aEe=async(t,e)=>Fd("runtime.delete",t,e,!0),sEe=async(t,e)=>{let r=await e.getProjectArgs(t),n=xO("runtime.run_code",t),o=await(await al(e.client,r)).adminClient.request(n.document,n.variables);return e.ok({keptWrites:n.variables.updateDb===!0,result:o?.fz_debug_action_code})},Iz={"runtime.graphql":tEe,"runtime.run_code":sEe,"runtime.query":rEe,"runtime.aggregate":nEe,"runtime.insert":iEe,"runtime.update":oEe,"runtime.delete":aEe};d();var cEe=["GATEWAY","ACTION_FLOW","ACTION_FLOW_NODE","ACTION_FLOW_CONTEXT_LOG","DEPLOYMENT","TPA","TRIGGER","SQL_GENERATION","GQL","ZAI"],lEe=["INFO","WARNING","ERROR"],uEe=50,dEe=100,Oz=5,Az=t=>`${t.toISOString().slice(0,19)}Z`,pEe=t=>{if(!t)return new Date;let e=new Date(t);return Number.isNaN(e.getTime())?new Date:e},Nz=(t,e)=>{if(!t)return;let r=t.map(n=>n.toUpperCase()).filter(n=>e.includes(n));return r.length>0?r:void 0},fEe=async(t,e)=>{let r=await e.getProjectArgs(t),i=(await al(e.client,r)).dataVisualizer.token;if(!i)throw new Error(`Log admin token is missing for project ${r.projectExId}`);let o=pEe(me(t.requestCreatedAt)),a={start:Az(new Date(o.getTime()-Oz*6e4)),end:Az(new Date(o.getTime()+Oz*6e4)),desc:!0},s=Nz(hs(t.types),cEe);s&&(a.type=s);let c=Nz(hs(t.levels),lEe);c&&(a.level=c);let l=me(t.customQueryCondition);l&&(a.customQueryCondition=l);let u=Math.min(dEe,_r(t.limit,uEe)),p=fr().logApiUrlTemplate.replace("{projectExId}",r.projectExId),m=((await new er(p,{headers:{authorization:`Bearer ${i}`},fetch:Yc}).request(SG,{queryCreation:a,paginator:{first:u}}))?.fetchLogsByPaginator?.edges??[]).map(_=>_?.node).filter(_=>!!_);return e.ok({entries:m})},Cz={"logs.search":fEe};d();d();d();d();import{readFileSync as bEe}from"node:fs";import{dirname as SEe,join as wEe}from"node:path";import{fileURLToPath as IEe}from"node:url";d();var zt,qd=null;function Wg(){return(qd===null||qd.byteLength===0)&&(qd=new Uint8Array(zt.memory.buffer)),qd}var Zg=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Zg.decode();var hEe=2146435072,LO=0;function mEe(t,e){return LO+=e,LO>=hEe&&(Zg=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}},Zg.decode(),LO=e),Zg.decode(Wg().subarray(t,t+e))}function kO(t,e){return t=t>>>0,mEe(t,e)}function MO(t){let e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){let i=t.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){let i=t.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){let i=t.length,o="[";i>0&&(o+=MO(t[0]));for(let a=1;a<i;a++)o+=", "+MO(t[a]);return o+="]",o}let r=/\[object ([^\]]+)\]/.exec(toString.call(t)),n;if(r&&r.length>1)n=r[1];else return toString.call(t);if(n=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}
1918
- ${t.stack}`:n}var Kg=0,Hg=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},gEe=typeof Hg.encodeInto=="function"?function(t,e){return Hg.encodeInto(t,e)}:function(t,e){let r=Hg.encode(t);return e.set(r),{read:t.length,written:r.length}};function Pz(t,e,r){if(r===void 0){let s=Hg.encode(t),c=e(s.length,1)>>>0;return Wg().subarray(c,c+s.length).set(s),Kg=s.length,c}let n=t.length,i=e(n,1)>>>0,o=Wg(),a=0;for(;a<n;a++){let s=t.charCodeAt(a);if(s>127)break;o[i+a]=s}if(a!==n){a!==0&&(t=t.slice(a)),i=r(i,n,n=a+t.length*3,1)>>>0;let s=Wg().subarray(i+a,i+n),c=gEe(t,s);a+=c.written,i=r(i,n,a,1)>>>0}return Kg=a,i}var gs=null;function jO(){return(gs===null||gs.buffer.detached===!0||gs.buffer.detached===void 0&&gs.buffer!==zt.memory.buffer)&&(gs=new DataView(zt.memory.buffer)),gs}function yEe(t){return t==null}function _Ee(t,e){t=t>>>0;let r=jO(),n=[];for(let i=t;i<t+4*e;i+=4)n.push(zt.__wbindgen_export_2.get(r.getUint32(i,!0)));return zt.__externref_drop_slice(t,e),n}function Rz(t,e){let r=Pz(t,zt.__wbindgen_malloc,zt.__wbindgen_realloc),n=Kg,i=zt.cut(r,n,yEe(e)?16777215:e?1:0);var o=_Ee(i[0],i[1]).slice();return zt.__wbindgen_free(i[0],i[1]*4,4),o}var EEe=new Set(["basic","cors","default"]);async function vEe(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.ok&&EEe.has(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function Dz(){let t={};return t.wbg={},t.wbg.__wbg_Error_0497d5bdba9362e5=function(e,r){return Error(kO(e,r))},t.wbg.__wbg_new_07b483f72211fd66=function(){return new Object},t.wbg.__wbg_set_3f1d0b984ed272ed=function(e,r,n){e[r]=n},t.wbg.__wbindgen_bigint_from_u64=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_debug_string=function(e,r){let n=MO(r),i=Pz(n,zt.__wbindgen_malloc,zt.__wbindgen_realloc),o=Kg;jO().setInt32(e+4,o,!0),jO().setInt32(e+0,i,!0)},t.wbg.__wbindgen_init_externref_table=function(){let e=zt.__wbindgen_export_2,r=e.grow(4);e.set(0,void 0),e.set(r+0,void 0),e.set(r+1,null),e.set(r+2,!0),e.set(r+3,!1)},t.wbg.__wbindgen_number_new=function(e){return e},t.wbg.__wbindgen_string_new=function(e,r){return kO(e,r)},t.wbg.__wbindgen_throw=function(e,r){throw new Error(kO(e,r))},t}function xz(t,e){return zt=t.exports,TEe.__wbindgen_wasm_module=e,gs=null,qd=null,zt.__wbindgen_start(),zt}function Lz(t){if(zt!==void 0)return zt;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=Dz();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return xz(r,t)}async function TEe(t){if(zt!==void 0)return zt;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("jieba_rs_wasm_bg.wasm",import.meta.url));let e=Dz();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await vEe(await t,e);return xz(r,n)}var kz=!1,Mz=(t,e)=>{if(!kz){let r=wEe(SEe(IEe(import.meta.url)),"jieba-engine.wasm");Lz({module:bEe(r)}),kz=!0}return Rz(t,e)};var OEe=new Set(["a","an","and","are","as","at","be","but","by","for","if","in","into","is","it","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]),AEe=/[a-z0-9]+/g,NEe=t=>{let e=t.toLowerCase().replace(/'s\b/g,""),r=[];for(let n of e.matchAll(AEe)){let i=n[0];OEe.has(i)||r.push(REe(i))}return r},CEe=/[㐀-鿿豈-﫿぀-ヿ가-힯]|[a-z0-9]/i,PEe=t=>Mz(t.toLowerCase(),!0).filter(e=>CEe.test(e)),cl=t=>{switch(Ln){case"ZION":return PEe(t);case"MOMEN":return NEe(t);default:throw new Error(`[analyzer] unknown PRODUCT '${Ln}'`)}},ys=(t,e)=>{let r=t[e];return r==="a"||r==="e"||r==="i"||r==="o"||r==="u"?!1:r==="y"?e===0?!0:!ys(t,e-1):!0},Bo=t=>{let e=0,r=!1;for(let n=0;n<t.length;n+=1){let i=!ys(t,n);r&&!i&&(e+=1),r=i}return e},$O=t=>{for(let e=0;e<t.length;e+=1)if(!ys(t,e))return!0;return!1},jz=t=>{let e=t.length;return e>=2&&t[e-1]===t[e-2]&&ys(t,e-1)},$z=t=>{let e=t.length;if(e<3||!ys(t,e-1)||ys(t,e-2)||!ys(t,e-3))return!1;let r=t[e-1];return r!=="w"&&r!=="x"&&r!=="y"},Qg=(t,e,r)=>t.slice(0,t.length-e.length)+r;function REe(t){let e=t;if(e.length<=2)return e;e.endsWith("sses")?e=Qg(e,"sses","ss"):e.endsWith("ies")?e=Qg(e,"ies","i"):e.endsWith("ss")||e.endsWith("s")&&(e=e.slice(0,-1));let r=!1;e.endsWith("eed")?Bo(e.slice(0,-3))>0&&(e=e.slice(0,-1)):e.endsWith("ed")&&$O(e.slice(0,-2))?(e=e.slice(0,-2),r=!0):e.endsWith("ing")&&$O(e.slice(0,-3))&&(e=e.slice(0,-3),r=!0),r&&(e.endsWith("at")||e.endsWith("bl")||e.endsWith("iz")?e+="e":jz(e)&&!/[lsz]$/.test(e)?e=e.slice(0,-1):Bo(e)===1&&$z(e)&&(e+="e")),e.endsWith("y")&&$O(e.slice(0,-1))&&(e=`${e.slice(0,-1)}i`);let n=[["ational","ate"],["tional","tion"],["enci","ence"],["anci","ance"],["izer","ize"],["bli","ble"],["alli","al"],["entli","ent"],["eli","e"],["ousli","ous"],["ization","ize"],["ation","ate"],["ator","ate"],["alism","al"],["iveness","ive"],["fulness","ful"],["ousness","ous"],["aliti","al"],["iviti","ive"],["biliti","ble"],["logi","log"]];for(let[s,c]of n)if(e.endsWith(s)){Bo(e.slice(0,e.length-s.length))>0&&(e=Qg(e,s,c));break}let i=[["icate","ic"],["ative",""],["alize","al"],["iciti","ic"],["ical","ic"],["ful",""],["ness",""]];for(let[s,c]of i)if(e.endsWith(s)){Bo(e.slice(0,e.length-s.length))>0&&(e=Qg(e,s,c));break}let o=["al","ance","ence","er","ic","able","ible","ant","ement","ment","ent","ou","ism","ate","iti","ous","ive","ize"],a=!1;for(let s of o)if(e.endsWith(s)){let c=e.slice(0,e.length-s.length);Bo(c)>1&&(e=c),a=!0;break}if(!a&&e.endsWith("ion")){let s=e.slice(0,-3);Bo(s)>1&&/[st]$/.test(s)&&(e=s)}if(e.endsWith("e")){let s=e.slice(0,-1),c=Bo(s);(c>1||c===1&&!$z(s))&&(e=s)}return Bo(e)>1&&jz(e)&&e.endsWith("l")&&(e=e.slice(0,-1)),e}d();var Uz=1.5,Fz=.75,UO=t=>{let e=[],r=new Map,n=0;for(let{ref:i,tokens:o}of t){let a=new Map;for(let s of o)a.set(s,(a.get(s)??0)+1);for(let s of a.keys())r.set(s,(r.get(s)??0)+1);e.push({ref:i,tf:a,length:o.length}),n+=o.length}return{docs:e,df:r,avgdl:e.length>0?n/e.length:0}},FO=(t,e)=>{let r=[...new Set(cl(e))],n=t.docs.length;return r.length===0||n===0?[]:t.docs.map(i=>{let o=0;for(let a of r){let s=i.tf.get(a);if(!s)continue;let c=t.df.get(a)??0,l=Math.log(1+(n-c+.5)/(c+.5)),u=s+Uz*(1-Fz+Fz*i.length/(t.avgdl||1));o+=l*(s*(Uz+1)/u)}return{ref:i.ref,score:o}})};var DEe=async()=>(await import("./corpus-DUMJBCUA.js")).DOCS_CORPUS,xEe=3,qz=null,LEe=t=>{let e=new Map,r=t.map(n=>{e.set(n.path,n);let i=cl(n.content),o=cl(n.title);for(let a=0;a<xEe;a+=1)i.push(...o);return{ref:n,tokens:i}});return{index:UO(r),byPath:e}},Gz=async()=>(qz??=LEe(await DEe()),qz),Bz=async(t,e=10)=>{let{index:r}=await Gz();return FO(r,t).filter(n=>n.score>0).sort((n,i)=>i.score-n.score).slice(0,Math.max(1,e)).map(n=>({path:n.ref.path,title:n.ref.title,url:n.ref.url}))},Vz=async t=>{let e=t.replace(/\.mdx$/,""),r=e.startsWith("/")?e:`/${e}`;return(await Gz()).byPath.get(r)??null};var kEe=async(t,e)=>{let r=me(t.query);if(!r)throw new Error("query is required");let n=_r(t.limit,10);return e.ok({results:await Bz(r,n)})},MEe=async(t,e)=>{let r=me(t.path);if(!r)throw new Error("path is required");let n=await Vz(r);if(!n)throw new Error(`No doc page found for path: ${r}`);return e.ok(n)},zz={"docs.search":kEe,"docs.get_page":MEe};d();var jEe=async(t,e)=>{let r=me(t.query);if(!r)throw new Error("query is required");let n=t.variables&&typeof t.variables=="object"?t.variables:{};return e.ok(await e.client.request(r,n))},Wz={"platform.graphql":jEe};d();var $Ee=async(t,e)=>{let n=((await e.client.request(Mq)).visibleAfCustomCodeTemplates??[]).map(i=>({templateCodeId:i.exId,displayName:i.displayName,group:i.templateGroup,async:i.async,inputs:i.inputType,outputs:i.outputType}));return e.ok({templates:n})},Zz={"actionflow.list_node_templates":$Ee};d();var XH=Pt(MH(),1);d();function pwe(t){let e;try{e=new URL(t)}catch{throw new Error(`Unsupported or malformed URL: ${t}`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error(`Only http/https URLs are allowed: ${t}`);return e}async function fwe(t,e){let r=t.body?.getReader();if(!r)throw new Error(`Empty response body from ${e}`);let n=[],i=0;for(;;){let{done:o,value:a}=await r.read();if(o)break;if(i+=a.byteLength,i>10485760)throw await r.cancel(),new Error("Response exceeds size limit of 10485760 bytes");n.push(a)}return Buffer.concat(n).toString("utf8")}async function TN(t){let e=t;for(let r=0;r<=5;r++){let n=pwe(e),i=await fetch(n,{redirect:"manual",signal:AbortSignal.timeout(2e4),headers:{Accept:"application/json, application/yaml, text/yaml, text/html, */*","User-Agent":"Momen-Agent-TpaImport"}});if(i.status>=300&&i.status<400){let o=i.headers.get("location");if(await i.body?.cancel(),!o)throw new Error(`Redirect without Location from ${e}`);e=new URL(o,n).toString();continue}if(!i.ok)throw await i.body?.cancel(),new Error(`HTTP ${i.status} fetching ${e}`);return{finalUrl:n.toString(),contentType:i.headers.get("content-type"),body:await fwe(i,e)}}throw new Error(`Too many redirects fetching ${t}`)}d();var hwe=/(?:href|src|url)\s*[=:]\s*["']?([^"'\s>)]+)/gi,mwe=/<(script|style|noscript|svg|iframe|canvas|template|nav|footer|aside)\b[\s\S]*?<\/\1\s*>/gi,gwe=new Set(["css","js","png","jpg","jpeg","gif","svg","ico","woff","woff2","ttf","webp","mp4","zip","pdf"]);function jH(t,e){if(t&&t.toLowerCase().includes("html"))return!0;let r=e.trimStart();return r.startsWith("<")&&!r.startsWith("<?xml")}function $H(t){let e=t.length>4e3?t.slice(0,4e3):t;return e.includes('"openapi"')||e.includes('"swagger"')||/(^|\n)\s*openapi\s*:/.test(e)||/(^|\n)\s*swagger\s*:/.test(e)}function UH(t,e){try{return new URL(e,t).toString()}catch{return e.startsWith("http")?e:null}}var ywe=/^https?:\/\/app\.swaggerhub\.com\/apis(?:-docs)?\/([^/?#]+)\/([^/?#]+)\/([^/?#]+)/i;function _we(t){let e=t.match(ywe);return e?`https://api.swaggerhub.com/apis/${e[1]}/${e[2]}/${e[3]}`:null}function FH(t,e){let r=[],n=i=>{i&&r.length<20&&!r.includes(i)&&r.push(i)};for(let i of t.matchAll(hwe)){if(r.length>=20)break;let o=i[1],a=o.toLowerCase();if(!(a.includes("openapi")||a.includes("swagger")||(a.endsWith(".json")||a.endsWith(".yaml")||a.endsWith(".yml"))&&a.includes("api")))continue;let c=UH(e,o);n(c&&_we(c)),n(c)}return r}function qH(t,e){let r=[],n;try{n=new URL(e).host}catch{return r}for(let i of t.matchAll(/<a\b[^>]*href\s*=\s*["']([^"'#]+)[^"']*["']/gi)){if(r.length>=40)break;let o;try{o=new URL(i[1],e)}catch{continue}if(o.host!==n)continue;o.hash="";let a=o.toString(),s=o.pathname.toLowerCase(),c=s.slice(s.lastIndexOf(".")+1);gwe.has(c)||a===e||r.includes(a)||r.push(a)}return r}var Ewe={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",copy:"\xA9"};function bN(t){return t.replace(/&#x([0-9a-f]+);/gi,(e,r)=>String.fromCodePoint(parseInt(r,16))).replace(/&#(\d+);/g,(e,r)=>String.fromCodePoint(parseInt(r,10))).replace(/&([a-z]+);/gi,(e,r)=>Ewe[r.toLowerCase()]??e)}var _p=t=>t.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();function GH(t,e){let r=t.replace(/<!--[\s\S]*?-->/g,"").replace(mwe,"");return r=r.replace(/<pre\b[^>]*>([\s\S]*?)<\/pre\s*>/gi,(n,i)=>`
1918
+ ${t.stack}`:n}var Kg=0,Hg=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},gEe=typeof Hg.encodeInto=="function"?function(t,e){return Hg.encodeInto(t,e)}:function(t,e){let r=Hg.encode(t);return e.set(r),{read:t.length,written:r.length}};function Pz(t,e,r){if(r===void 0){let s=Hg.encode(t),c=e(s.length,1)>>>0;return Wg().subarray(c,c+s.length).set(s),Kg=s.length,c}let n=t.length,i=e(n,1)>>>0,o=Wg(),a=0;for(;a<n;a++){let s=t.charCodeAt(a);if(s>127)break;o[i+a]=s}if(a!==n){a!==0&&(t=t.slice(a)),i=r(i,n,n=a+t.length*3,1)>>>0;let s=Wg().subarray(i+a,i+n),c=gEe(t,s);a+=c.written,i=r(i,n,a,1)>>>0}return Kg=a,i}var gs=null;function jO(){return(gs===null||gs.buffer.detached===!0||gs.buffer.detached===void 0&&gs.buffer!==zt.memory.buffer)&&(gs=new DataView(zt.memory.buffer)),gs}function yEe(t){return t==null}function _Ee(t,e){t=t>>>0;let r=jO(),n=[];for(let i=t;i<t+4*e;i+=4)n.push(zt.__wbindgen_export_2.get(r.getUint32(i,!0)));return zt.__externref_drop_slice(t,e),n}function Rz(t,e){let r=Pz(t,zt.__wbindgen_malloc,zt.__wbindgen_realloc),n=Kg,i=zt.cut(r,n,yEe(e)?16777215:e?1:0);var o=_Ee(i[0],i[1]).slice();return zt.__wbindgen_free(i[0],i[1]*4,4),o}var EEe=new Set(["basic","cors","default"]);async function vEe(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.ok&&EEe.has(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function Dz(){let t={};return t.wbg={},t.wbg.__wbg_Error_0497d5bdba9362e5=function(e,r){return Error(kO(e,r))},t.wbg.__wbg_new_07b483f72211fd66=function(){return new Object},t.wbg.__wbg_set_3f1d0b984ed272ed=function(e,r,n){e[r]=n},t.wbg.__wbindgen_bigint_from_u64=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_debug_string=function(e,r){let n=MO(r),i=Pz(n,zt.__wbindgen_malloc,zt.__wbindgen_realloc),o=Kg;jO().setInt32(e+4,o,!0),jO().setInt32(e+0,i,!0)},t.wbg.__wbindgen_init_externref_table=function(){let e=zt.__wbindgen_export_2,r=e.grow(4);e.set(0,void 0),e.set(r+0,void 0),e.set(r+1,null),e.set(r+2,!0),e.set(r+3,!1)},t.wbg.__wbindgen_number_new=function(e){return e},t.wbg.__wbindgen_string_new=function(e,r){return kO(e,r)},t.wbg.__wbindgen_throw=function(e,r){throw new Error(kO(e,r))},t}function xz(t,e){return zt=t.exports,TEe.__wbindgen_wasm_module=e,gs=null,qd=null,zt.__wbindgen_start(),zt}function Lz(t){if(zt!==void 0)return zt;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=Dz();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return xz(r,t)}async function TEe(t){if(zt!==void 0)return zt;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("jieba_rs_wasm_bg.wasm",import.meta.url));let e=Dz();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await vEe(await t,e);return xz(r,n)}var kz=!1,Mz=(t,e)=>{if(!kz){let r=wEe(SEe(IEe(import.meta.url)),"jieba-engine.wasm");Lz({module:bEe(r)}),kz=!0}return Rz(t,e)};var OEe=new Set(["a","an","and","are","as","at","be","but","by","for","if","in","into","is","it","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]),AEe=/[a-z0-9]+/g,NEe=t=>{let e=t.toLowerCase().replace(/'s\b/g,""),r=[];for(let n of e.matchAll(AEe)){let i=n[0];OEe.has(i)||r.push(REe(i))}return r},CEe=/[㐀-鿿豈-﫿぀-ヿ가-힯]|[a-z0-9]/i,PEe=t=>Mz(t.toLowerCase(),!0).filter(e=>CEe.test(e)),cl=t=>{switch(Ln){case"ZION":return PEe(t);case"MOMEN":return NEe(t);default:throw new Error(`[analyzer] unknown PRODUCT '${Ln}'`)}},ys=(t,e)=>{let r=t[e];return r==="a"||r==="e"||r==="i"||r==="o"||r==="u"?!1:r==="y"?e===0?!0:!ys(t,e-1):!0},Bo=t=>{let e=0,r=!1;for(let n=0;n<t.length;n+=1){let i=!ys(t,n);r&&!i&&(e+=1),r=i}return e},$O=t=>{for(let e=0;e<t.length;e+=1)if(!ys(t,e))return!0;return!1},jz=t=>{let e=t.length;return e>=2&&t[e-1]===t[e-2]&&ys(t,e-1)},$z=t=>{let e=t.length;if(e<3||!ys(t,e-1)||ys(t,e-2)||!ys(t,e-3))return!1;let r=t[e-1];return r!=="w"&&r!=="x"&&r!=="y"},Qg=(t,e,r)=>t.slice(0,t.length-e.length)+r;function REe(t){let e=t;if(e.length<=2)return e;e.endsWith("sses")?e=Qg(e,"sses","ss"):e.endsWith("ies")?e=Qg(e,"ies","i"):e.endsWith("ss")||e.endsWith("s")&&(e=e.slice(0,-1));let r=!1;e.endsWith("eed")?Bo(e.slice(0,-3))>0&&(e=e.slice(0,-1)):e.endsWith("ed")&&$O(e.slice(0,-2))?(e=e.slice(0,-2),r=!0):e.endsWith("ing")&&$O(e.slice(0,-3))&&(e=e.slice(0,-3),r=!0),r&&(e.endsWith("at")||e.endsWith("bl")||e.endsWith("iz")?e+="e":jz(e)&&!/[lsz]$/.test(e)?e=e.slice(0,-1):Bo(e)===1&&$z(e)&&(e+="e")),e.endsWith("y")&&$O(e.slice(0,-1))&&(e=`${e.slice(0,-1)}i`);let n=[["ational","ate"],["tional","tion"],["enci","ence"],["anci","ance"],["izer","ize"],["bli","ble"],["alli","al"],["entli","ent"],["eli","e"],["ousli","ous"],["ization","ize"],["ation","ate"],["ator","ate"],["alism","al"],["iveness","ive"],["fulness","ful"],["ousness","ous"],["aliti","al"],["iviti","ive"],["biliti","ble"],["logi","log"]];for(let[s,c]of n)if(e.endsWith(s)){Bo(e.slice(0,e.length-s.length))>0&&(e=Qg(e,s,c));break}let i=[["icate","ic"],["ative",""],["alize","al"],["iciti","ic"],["ical","ic"],["ful",""],["ness",""]];for(let[s,c]of i)if(e.endsWith(s)){Bo(e.slice(0,e.length-s.length))>0&&(e=Qg(e,s,c));break}let o=["al","ance","ence","er","ic","able","ible","ant","ement","ment","ent","ou","ism","ate","iti","ous","ive","ize"],a=!1;for(let s of o)if(e.endsWith(s)){let c=e.slice(0,e.length-s.length);Bo(c)>1&&(e=c),a=!0;break}if(!a&&e.endsWith("ion")){let s=e.slice(0,-3);Bo(s)>1&&/[st]$/.test(s)&&(e=s)}if(e.endsWith("e")){let s=e.slice(0,-1),c=Bo(s);(c>1||c===1&&!$z(s))&&(e=s)}return Bo(e)>1&&jz(e)&&e.endsWith("l")&&(e=e.slice(0,-1)),e}d();var Uz=1.5,Fz=.75,UO=t=>{let e=[],r=new Map,n=0;for(let{ref:i,tokens:o}of t){let a=new Map;for(let s of o)a.set(s,(a.get(s)??0)+1);for(let s of a.keys())r.set(s,(r.get(s)??0)+1);e.push({ref:i,tf:a,length:o.length}),n+=o.length}return{docs:e,df:r,avgdl:e.length>0?n/e.length:0}},FO=(t,e)=>{let r=[...new Set(cl(e))],n=t.docs.length;return r.length===0||n===0?[]:t.docs.map(i=>{let o=0;for(let a of r){let s=i.tf.get(a);if(!s)continue;let c=t.df.get(a)??0,l=Math.log(1+(n-c+.5)/(c+.5)),u=s+Uz*(1-Fz+Fz*i.length/(t.avgdl||1));o+=l*(s*(Uz+1)/u)}return{ref:i.ref,score:o}})};var DEe=async()=>(await import("./corpus-WJR5E4OY.js")).DOCS_CORPUS,xEe=3,qz=null,LEe=t=>{let e=new Map,r=t.map(n=>{e.set(n.path,n);let i=cl(n.content),o=cl(n.title);for(let a=0;a<xEe;a+=1)i.push(...o);return{ref:n,tokens:i}});return{index:UO(r),byPath:e}},Gz=async()=>(qz??=LEe(await DEe()),qz),Bz=async(t,e=10)=>{let{index:r}=await Gz();return FO(r,t).filter(n=>n.score>0).sort((n,i)=>i.score-n.score).slice(0,Math.max(1,e)).map(n=>({path:n.ref.path,title:n.ref.title,url:n.ref.url}))},Vz=async t=>{let e=t.replace(/\.mdx$/,""),r=e.startsWith("/")?e:`/${e}`;return(await Gz()).byPath.get(r)??null};var kEe=async(t,e)=>{let r=me(t.query);if(!r)throw new Error("query is required");let n=_r(t.limit,10);return e.ok({results:await Bz(r,n)})},MEe=async(t,e)=>{let r=me(t.path);if(!r)throw new Error("path is required");let n=await Vz(r);if(!n)throw new Error(`No doc page found for path: ${r}`);return e.ok(n)},zz={"docs.search":kEe,"docs.get_page":MEe};d();var jEe=async(t,e)=>{let r=me(t.query);if(!r)throw new Error("query is required");let n=t.variables&&typeof t.variables=="object"?t.variables:{};return e.ok(await e.client.request(r,n))},Wz={"platform.graphql":jEe};d();var $Ee=async(t,e)=>{let n=((await e.client.request(Mq)).visibleAfCustomCodeTemplates??[]).map(i=>({templateCodeId:i.exId,displayName:i.displayName,group:i.templateGroup,async:i.async,inputs:i.inputType,outputs:i.outputType}));return e.ok({templates:n})},Zz={"actionflow.list_node_templates":$Ee};d();var XH=Pt(MH(),1);d();function pwe(t){let e;try{e=new URL(t)}catch{throw new Error(`Unsupported or malformed URL: ${t}`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error(`Only http/https URLs are allowed: ${t}`);return e}async function fwe(t,e){let r=t.body?.getReader();if(!r)throw new Error(`Empty response body from ${e}`);let n=[],i=0;for(;;){let{done:o,value:a}=await r.read();if(o)break;if(i+=a.byteLength,i>10485760)throw await r.cancel(),new Error("Response exceeds size limit of 10485760 bytes");n.push(a)}return Buffer.concat(n).toString("utf8")}async function TN(t){let e=t;for(let r=0;r<=5;r++){let n=pwe(e),i=await fetch(n,{redirect:"manual",signal:AbortSignal.timeout(2e4),headers:{Accept:"application/json, application/yaml, text/yaml, text/html, */*","User-Agent":"Momen-Agent-TpaImport"}});if(i.status>=300&&i.status<400){let o=i.headers.get("location");if(await i.body?.cancel(),!o)throw new Error(`Redirect without Location from ${e}`);e=new URL(o,n).toString();continue}if(!i.ok)throw await i.body?.cancel(),new Error(`HTTP ${i.status} fetching ${e}`);return{finalUrl:n.toString(),contentType:i.headers.get("content-type"),body:await fwe(i,e)}}throw new Error(`Too many redirects fetching ${t}`)}d();var hwe=/(?:href|src|url)\s*[=:]\s*["']?([^"'\s>)]+)/gi,mwe=/<(script|style|noscript|svg|iframe|canvas|template|nav|footer|aside)\b[\s\S]*?<\/\1\s*>/gi,gwe=new Set(["css","js","png","jpg","jpeg","gif","svg","ico","woff","woff2","ttf","webp","mp4","zip","pdf"]);function jH(t,e){if(t&&t.toLowerCase().includes("html"))return!0;let r=e.trimStart();return r.startsWith("<")&&!r.startsWith("<?xml")}function $H(t){let e=t.length>4e3?t.slice(0,4e3):t;return e.includes('"openapi"')||e.includes('"swagger"')||/(^|\n)\s*openapi\s*:/.test(e)||/(^|\n)\s*swagger\s*:/.test(e)}function UH(t,e){try{return new URL(e,t).toString()}catch{return e.startsWith("http")?e:null}}var ywe=/^https?:\/\/app\.swaggerhub\.com\/apis(?:-docs)?\/([^/?#]+)\/([^/?#]+)\/([^/?#]+)/i;function _we(t){let e=t.match(ywe);return e?`https://api.swaggerhub.com/apis/${e[1]}/${e[2]}/${e[3]}`:null}function FH(t,e){let r=[],n=i=>{i&&r.length<20&&!r.includes(i)&&r.push(i)};for(let i of t.matchAll(hwe)){if(r.length>=20)break;let o=i[1],a=o.toLowerCase();if(!(a.includes("openapi")||a.includes("swagger")||(a.endsWith(".json")||a.endsWith(".yaml")||a.endsWith(".yml"))&&a.includes("api")))continue;let c=UH(e,o);n(c&&_we(c)),n(c)}return r}function qH(t,e){let r=[],n;try{n=new URL(e).host}catch{return r}for(let i of t.matchAll(/<a\b[^>]*href\s*=\s*["']([^"'#]+)[^"']*["']/gi)){if(r.length>=40)break;let o;try{o=new URL(i[1],e)}catch{continue}if(o.host!==n)continue;o.hash="";let a=o.toString(),s=o.pathname.toLowerCase(),c=s.slice(s.lastIndexOf(".")+1);gwe.has(c)||a===e||r.includes(a)||r.push(a)}return r}var Ewe={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",copy:"\xA9"};function bN(t){return t.replace(/&#x([0-9a-f]+);/gi,(e,r)=>String.fromCodePoint(parseInt(r,16))).replace(/&#(\d+);/g,(e,r)=>String.fromCodePoint(parseInt(r,10))).replace(/&([a-z]+);/gi,(e,r)=>Ewe[r.toLowerCase()]??e)}var _p=t=>t.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();function GH(t,e){let r=t.replace(/<!--[\s\S]*?-->/g,"").replace(mwe,"");return r=r.replace(/<pre\b[^>]*>([\s\S]*?)<\/pre\s*>/gi,(n,i)=>`
1919
1919
  \`\`\`
1920
1920
  ${bN(vwe(i))}
1921
1921
  \`\`\`
@@ -2375,7 +2375,7 @@ You can: create and delete tables, fields, relations, and unique constraints; ch
2375
2375
  Tables and fields are addressed by their displayName in every tool on this plugin.
2376
2376
 
2377
2377
  You CANNOT:
2378
- - Rename a table or a field. A systemName is fixed when the entity is created \u2014 only its displayName can change afterwards. If a systemName is genuinely wrong, delete and recreate it; recreating a field discards the data already stored in it. Choose systemNames carefully up front.
2378
+ - Rename a table or a field. An apiName is fixed when the entity is created \u2014 only its displayName can change afterwards. If an apiName is genuinely wrong, delete and recreate it; recreating a field discards the data already stored in it. Choose apiNames carefully up front.
2379
2379
  - Change an existing column's TYPE, or its uniqueness. To change either, delete the column and create a new one; uniqueness cannot be added later because existing rows may already hold duplicates.
2380
2380
  - Update an existing relation or constraint. To change one, delete it and recreate it.
2381
2381
  - Create formula / computed fields. If the user asks for one, explain that formulas must be configured manually in the editor; do not create them.
@@ -2384,15 +2384,17 @@ You CANNOT:
2384
2384
  Creating or deleting a table, and adding, retyping or deleting a field, rewrites the role permissions keyed to that table. Nobody asks for it, and a new table lands in every role including Anonymous User, so the grants you end up with are not the ones you chose. Each of those results names the roles it changed. Before changing one of them, read that role with GET_ROLE_DETAIL: a permission write is rejected until the role has been read in this session, and the role you would reach for is one your own table edit just moved.
2385
2385
 
2386
2386
  ### Column Types
2387
- A new field's 'basicTypeNameOrTypeId' is a bare primitive type NAME: string, decimal, bigint, boolean, timestamptz, timetz, date, jsonb, image, video, file, geo_point.
2387
+ A new field's 'typeIdentifier' is a bare primitive type NAME: string, decimal, bigint, boolean, timestamptz, timetz, date, jsonb, image, video, file, geo_point. Those are exactly the options GET_TABLE_FIELD_SELECTABLE_TYPES offers on this
2388
+ project; it prints them uppercase and either case is accepted.
2388
2389
 
2389
2390
  Pass the name on its own (for example "decimal"). Read results report a field's existing
2390
2391
  type using legacy uppercase names (TEXT, BIGINT); that is the read vocabulary only \u2014 when
2391
2392
  creating a field, still pass the primitive name (a column shown as TEXT is created with
2392
- "string"). This project has no enums, so an enum id is never a valid field type here.
2393
+ "string"). This project has no enums, so an enum id is never a valid field type here. The
2394
+ separate 'required' field controls nullability; never wrap a type in a null union.
2393
2395
 
2394
2396
  ### Naming
2395
- systemName: English snake_case. Tables are nouns or noun phrases, singular not plural ("order", not "orders"), concise (e.g. "user_profile"); fields are snake_case (e.g. "first_name", "is_active"). No name may contain a space \u2014 not tables, fields, relations, or constraints, and not even the displayName. A systemName is permanent once created; only the displayName can be changed later. displayName: user-visible; use the natural Chinese name as the displayName and derive the English snake_case systemName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 systemName "user_name").
2397
+ apiName \u2014 spelled 'tableApiName' on a table, 'apiName' on a field, and reported under those names by every read: English snake_case. Tables are nouns or noun phrases, singular not plural ("order", not "orders"), concise (e.g. "user_profile"); fields are snake_case (e.g. "first_name", "is_active"). No name may contain a space \u2014 not tables, fields, relations, or constraints, and not even the displayName. An apiName is permanent once created; only the displayName can be changed later. displayName: user-visible; use the natural Chinese name as the displayName and derive the English snake_case apiName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 apiName "user_name").
2396
2398
 
2397
2399
  ### System Built-ins & Product Context
2398
2400
  Every table has non-deletable built-in fields: id (BIGINT), created_at (TIMESTAMPTZ), updated_at (TIMESTAMPTZ). Do NOT include these when creating a table. Any table, field, or relation where 'editable' is false is system built-in and cannot be modified or deleted. System tables and timezone configurations for Zion:
@@ -2428,12 +2430,12 @@ Many-to-many: use an intermediate join table + two one-to-many relations.
2428
2430
  To unique-constrain a relation field, use the FK field name ("user_id"), not the virtual name.
2429
2431
 
2430
2432
  ### Geographic Location
2431
- Use GEO_POINT for coordinates. Never split into separate latitude/longitude fields. A GEO_POINT field auto-generates a companion DECIMAL hack field named "fz_distance_from_<systemName>", where <systemName> is the geo_point's systemName (may differ from its displayName). At request time it returns the distance from the stored geo_point to the user-supplied location in the request. Treat it as a distance-calculation hack \u2014 future migration: this will be replaced by formula fields.
2433
+ Use GEO_POINT for coordinates. Never split into separate latitude/longitude fields. A GEO_POINT field auto-generates a companion DECIMAL hack field named "fz_distance_from_<apiName>", where <apiName> is the geo_point's apiName (may differ from its displayName). At request time it returns the distance from the stored geo_point to the user-supplied location in the request. Treat it as a distance-calculation hack \u2014 future migration: this will be replaced by formula fields.
2432
2434
 
2433
2435
  ### Constraints
2434
2436
  Only unique constraints supported. Constraint name: lowercase English snake_case, no uppercase. Reference fields by their displayName \u2014 for a relation's foreign key use the generated FK field ("user_id"). Uniqueness is fixed when a field is created and cannot be turned on afterwards (existing rows could already hold duplicates), so to make an existing field unique, add a constraint over it. Use a constraint to span multiple fields (composite unique): list the fields' displayNames. Unique constraints are also the only DB-enforced invariant writers can lean on for atomic insert-if-absent / toggle semantics (insert with on_conflict): whenever the design has "at most one row per X" semantics (a join/like/save table, an idempotency key), create the unique constraint up front \u2014 read-check-then-insert cannot be made race-safe without it.
2435
2437
 
2436
- A relation's generated FK carries two names, and which one a call wants depends on the call. The schema tools here take displayNames, so a relation named \u8F6C\u8BD1\u884C gives a FK whose displayName is \`\u8F6C\u8BD1\u884C_id\` \u2014 that is what ADD_CONSTRAINTS matches on. The runtime API takes system names, so the same column is \`translation_row_id\` in a \`runtime.query\` filter or a \`runtime.insert\` object. Neither side accepts the other's name, and passing the wrong one reports the field as missing rather than as misnamed. Read both off the field record instead of transliterating one into the other.`},post:{available:!0,prompt:`## Database Domain Knowledge
2438
+ A relation's generated FK carries two names, and which one a call wants depends on the call. The schema tools here take displayNames, so a relation named \u8F6C\u8BD1\u884C gives a FK whose displayName is \`\u8F6C\u8BD1\u884C_id\` \u2014 that is what ADD_CONSTRAINTS matches on. The runtime API takes apiNames, so the same column is \`translation_row_id\` in a \`runtime.query\` filter or a \`runtime.insert\` object. Neither side accepts the other's name, and passing the wrong one reports the field as missing rather than as misnamed. Read both off the field record instead of transliterating one into the other.`},post:{available:!0,prompt:`## Database Domain Knowledge
2437
2439
  Zion uses PostgreSQL. Data model changes require "Sync Backend" to take effect online.
2438
2440
 
2439
2441
  ### Capabilities & Limitations
@@ -2441,7 +2443,7 @@ You can: create and delete tables, fields, relations, and unique constraints; ch
2441
2443
  Tables and fields are addressed by their displayName in every tool on this plugin.
2442
2444
  (Enums are created and edited via the 'type' plugin.)
2443
2445
  You CANNOT:
2444
- - Rename a table or a field. A systemName is fixed when the entity is created \u2014 only its displayName can change afterwards. If a systemName is genuinely wrong, delete and recreate it; recreating a field discards the data already stored in it. Choose systemNames carefully up front.
2446
+ - Rename a table or a field. An apiName is fixed when the entity is created \u2014 only its displayName can change afterwards. If an apiName is genuinely wrong, delete and recreate it; recreating a field discards the data already stored in it. Choose apiNames carefully up front.
2445
2447
  - Change an existing column's TYPE, or its uniqueness. To change either, delete the column and create a new one; uniqueness cannot be added later because existing rows may already hold duplicates.
2446
2448
  - Update an existing relation or constraint. To change one, delete it and recreate it.
2447
2449
  - Create formula / computed fields. If the user asks for one, explain that formulas must be configured manually in the editor; do not create them.
@@ -2450,24 +2452,23 @@ You CANNOT:
2450
2452
  Creating or deleting a table, and adding, retyping or deleting a field, rewrites the role permissions keyed to that table. Nobody asks for it, and a new table lands in every role including Anonymous User, so the grants you end up with are not the ones you chose. Each of those results names the roles it changed. Before changing one of them, read that role with GET_ROLE_DETAIL: a permission write is rejected until the role has been read in this session, and the role you would reach for is one your own table edit just moved.
2451
2453
 
2452
2454
  ### Column Types
2453
- A new field's 'basicTypeNameOrTypeId' is a bare primitive type NAME: string, decimal, bigint, boolean, timestamptz, timetz, date, jsonb, image, video, file, geo_point.
2454
- For an enum, pass the bare enum id returned by type.list_enums \u2014 or, for an enum you
2455
- created earlier this turn, the id you supplied when creating it.
2455
+ A new field's 'typeIdentifier' is copied verbatim from GET_TABLE_FIELD_SELECTABLE_TYPES, which lists every type a field on this project accepts. Its vocabulary is the wrapped identifier: s:p:string, s:p:decimal, s:p:bigint, s:p:boolean, s:p:timestamptz, s:p:timetz, s:p:date, s:p:jsonb, s:p:image, s:p:video, s:p:file, s:p:geo_point for the primitives, and "u:e:<enumId>" for an enum.
2456
2456
 
2457
- Pass the name or id on its own (for example "decimal", or "mja44si4" for an enum). Do NOT
2458
- pass a wrapped type identifier such as "s:p:decimal" or "u:e:<enumId>" \u2014 those are the
2459
- stored form, and the tool builds them for you. The separate 'required' field controls
2460
- nullability; never wrap a type in a null union.
2457
+ Never assemble one by hand, and never pass a bare name or a bare enum id \u2014 "decimal" and
2458
+ "mja44si4" are not field types here; "s:p:decimal" and "u:e:mja44si4" are. An enum the
2459
+ picker does not list does not exist yet: create it with the 'type' plugin (same turn,
2460
+ before the column), then call GET_TABLE_FIELD_SELECTABLE_TYPES again and copy what it returns. The
2461
+ separate 'required' field controls nullability; never wrap a type in a null union.
2461
2462
 
2462
2463
  Read results report a field's existing type using legacy uppercase names (TEXT, BIGINT).
2463
- That is the read vocabulary only \u2014 when creating a field, still pass the primitive name
2464
- (e.g. a column shown as TEXT is created with "string").
2464
+ That is the read vocabulary only \u2014 when creating a field, still pass the picker's
2465
+ identifier (e.g. a column shown as TEXT is created with "s:p:string").
2465
2466
 
2466
2467
  ### Formula Fields
2467
2468
  Formula (computed) fields \u2014 a column whose value is derived from other fields \u2014 are a post-refactor concept but are NOT yet authorable through these tools. If the user asks for a derived value, either compute it at write time (an action flow or mutation binding) or tell them to add the formula field in the editor; never fake one with a plain column.
2468
2469
 
2469
2470
  ### Naming
2470
- systemName: English snake_case. Tables are nouns or noun phrases, singular not plural ("order", not "orders"), concise (e.g. "user_profile"); fields are snake_case (e.g. "first_name", "is_active"). No name may contain a space \u2014 not tables, fields, relations, or constraints, and not even the displayName. A systemName is permanent once created; only the displayName can be changed later. displayName: user-visible; use the natural Chinese name as the displayName and derive the English snake_case systemName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 systemName "user_name").
2471
+ apiName \u2014 spelled 'tableApiName' on a table, 'apiName' on a field, and reported under those names by every read: English snake_case. Tables are nouns or noun phrases, singular not plural ("order", not "orders"), concise (e.g. "user_profile"); fields are snake_case (e.g. "first_name", "is_active"). No name may contain a space \u2014 not tables, fields, relations, or constraints, and not even the displayName. An apiName is permanent once created; only the displayName can be changed later. displayName: user-visible; use the natural Chinese name as the displayName and derive the English snake_case apiName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 apiName "user_name").
2471
2472
 
2472
2473
  ### System Built-ins & Product Context
2473
2474
  Every table has non-deletable built-in fields: id (s:p:bigint), created_at (s:p:timestamptz), updated_at (s:p:timestamptz). Do NOT include these when creating a table. Any table, field, or relation where 'editable' is false is system built-in and cannot be modified or deleted. System tables and timezone configurations for Zion:
@@ -2507,12 +2508,12 @@ To unique-constrain a relation field, use the FK field name ("user_id"), not the
2507
2508
  Enum types are created and edited via the 'type' plugin, not here. To use an enum as a column type, use "u:e:<enumId>" with the actual id from type.list_enums. Create the enum first via the 'type' plugin (same turn, before the column) if it does not yet exist \u2014 you supply the id there, so you can reference it immediately.
2508
2509
 
2509
2510
  ### Geographic Location
2510
- Use s:p:geo_point for coordinates. Never split into separate latitude/longitude fields. A s:p:geo_point field auto-generates a companion s:p:decimal hack field named "fz_distance_from_<systemName>", where <systemName> is the geo_point's systemName (may differ from its displayName). At request time it returns the distance from the stored geo_point to the user-supplied location in the request. Treat it as a distance-calculation hack \u2014 future migration: this will be replaced by formula fields.
2511
+ Use s:p:geo_point for coordinates. Never split into separate latitude/longitude fields. A s:p:geo_point field auto-generates a companion s:p:decimal hack field named "fz_distance_from_<apiName>", where <apiName> is the geo_point's apiName (may differ from its displayName). At request time it returns the distance from the stored geo_point to the user-supplied location in the request. Treat it as a distance-calculation hack \u2014 future migration: this will be replaced by formula fields.
2511
2512
 
2512
2513
  ### Constraints
2513
2514
  Only unique constraints supported. Constraint name: lowercase English snake_case, no uppercase. Reference fields by their displayName \u2014 for a relation's foreign key use the generated FK field ("user_id"). Uniqueness is fixed when a field is created and cannot be turned on afterwards (existing rows could already hold duplicates), so to make an existing field unique, add a constraint over it. Use a constraint to span multiple fields (composite unique): list the fields' displayNames. Unique constraints are also the only DB-enforced invariant writers can lean on for atomic insert-if-absent / toggle semantics (insert with on_conflict): whenever the design has "at most one row per X" semantics (a join/like/save table, an idempotency key), create the unique constraint up front \u2014 read-check-then-insert cannot be made race-safe without it.
2514
2515
 
2515
- A relation's generated FK carries two names, and which one a call wants depends on the call. The schema tools here take displayNames, so a relation named \u8F6C\u8BD1\u884C gives a FK whose displayName is \`\u8F6C\u8BD1\u884C_id\` \u2014 that is what ADD_CONSTRAINTS matches on. The runtime API takes system names, so the same column is \`translation_row_id\` in a \`runtime.query\` filter or a \`runtime.insert\` object. Neither side accepts the other's name, and passing the wrong one reports the field as missing rather than as misnamed. Read both off the field record instead of transliterating one into the other.`}},deploy:{pre:{available:!0,prompt:`## Backend Sync Domain Knowledge
2516
+ A relation's generated FK carries two names, and which one a call wants depends on the call. The schema tools here take displayNames, so a relation named \u8F6C\u8BD1\u884C gives a FK whose displayName is \`\u8F6C\u8BD1\u884C_id\` \u2014 that is what ADD_CONSTRAINTS matches on. The runtime API takes apiNames, so the same column is \`translation_row_id\` in a \`runtime.query\` filter or a \`runtime.insert\` object. Neither side accepts the other's name, and passing the wrong one reports the field as missing rather than as misnamed. Read both off the field record instead of transliterating one into the other.`}},deploy:{pre:{available:!0,prompt:`## Backend Sync Domain Knowledge
2516
2517
  A project's running backend serves the last SYNCED schema, not the one being edited. The data model, action flows, APIs, permissions, secrets, AI agents and triggers all live there, so until a sync lands, edits to any of them do not exist for a preview, a published app, or anything queried against the runtime \u2014 the editor shows the new schema while the backend still answers with the old one.
2517
2518
 
2518
2519
  project sync-backend saves the project, deploys that backend, waits for the pipeline, and reports what happened. It takes no arguments.
@@ -2890,7 +2891,7 @@ it anywhere else, use the id.
2890
2891
  MediaFormat: CSS, CSV, DOC, DOCX, GIF, HTML, ICO, JPEG, JPG, JSON, MOV, MP3, MP4, OTHER, PDF, PNG,
2891
2892
  PPT, PPTX, SVG, TXT, WAV, WEBP, XLS, XLSX, XML.
2892
2893
  CannedAccessControlList: AUTHENTICATE_READ, AWS_EXEC_READ, BUCKET_OWNER_FULL_CONTROL,
2893
- BUCKET_OWNER_READ, DEFAULT, LOG_DELIVERY_WRITE, PRIVATE, PUBLIC_READ, PUBLIC_READ_WRITE.`};d();function TJ(t,e){let r=Kl[t];if(!r)throw new Error(`No guide available for '${t}'.`);let n=r[e];if(!n.available||!n.prompt)throw new Error(`Plugin '${t}' is not available for ${e} projects.`);return n.prompt}var Mt={projectExId:g.string().optional(),appExId:g.string().nullable().optional(),appVersionExId:g.string().nullable().optional()},GE=t=>({content:[{type:"text",text:t.ok?t.message??JSON.stringify(t.data??{},null,2):JSON.stringify({error:t.error??"Unknown error",data:t.data},null,2)}],isError:!t.ok}),Sf=(t,e,r,n,i)=>{t.registerTool(e,{description:r,inputSchema:n},i)},bJ=(t,e,r)=>{for(let n of e)Sf(t,n.name,n.description,n.inputSchema??{},async(i,o)=>GE(await r({name:n.command,args:i},o.signal)))},SJ=(t,e,r)=>{for(let n of e){let{ops:i}=n,o={op:g.enum(Object.keys(i)),...n.inputSchema??{}};Sf(t,n.name,n.description,o,async(a,s)=>{let{op:c,...l}=a;return GE(await r({name:i[String(c)],args:l},s.signal))})}};var bke=t=>({content:[{type:"text",text:t}],isError:!1});var wJ=(t,e,r)=>{for(let n of e){let i={...Mt,op:g.enum(n.ops),args:g.record(g.any()).optional()};Sf(t,n.name,n.description,i,async(o,a)=>{let{op:s,projectExId:c,appExId:l,appVersionExId:u,args:p}=o;return GE(await r({name:"schema.ztype_tool_calls",args:{projectExId:c,appExId:l,appVersionExId:u,toolCalls:[{toolCallId:`${n.name}-${String(s)}-${Date.now()}`,name:String(s),args:p??{}}]}},a?.signal))})}},IJ=(t,e)=>{let r=Object.keys(Kl);Sf(t,"guide","Load the domain guide for a backend capability \u2014 the rules, conventions, and gotchas for a plugin area (database, type, bindings, actionflow, api, tpa, zai, component, permissions, payments, logs, agent). Returns guidance for the loaded project\u2019s type-system state. Call before editing an unfamiliar area, or when a meta-tool call is rejected.",{plugin:g.enum(r),projectExId:g.string().optional()},async(n,i)=>{let o=await Mg(e,n.projectExId,i?.signal);return bke(TJ(String(n.plugin),o))})},OJ=(t,e)=>{Sf(t,"agent_command","Advanced escape hatch for directly invoking an internal agent command.",{name:g.string(),args:g.record(g.any()).optional()},async(r,n)=>GE(await e({name:String(r.name),args:r.args??{}},n.signal)))};d();var Ske={"actionflow.list_node_templates":{description:"List the published preset action-flow integration nodes (the dynamic TEMPLATE_CODE catalog \u2014 e.g. SMS, video/AI generation). Returns each template\u2019s templateCodeId, displayName, group, async flag, and input/output param types. Pass a returned templateCodeId to schema tool-call ADD_ACTION_FLOW_NODE (TEMPLATE_CODE node) to insert it. The set is server-managed and changes over time, so query it rather than assuming a fixed provider.",tool:{name:"list_actionflow_node_templates"},cli:{path:"actionflow list-node-templates"}},"workspace.set":{description:"Set the workspace root for local credentials, daemon registry, and project context.",tool:{name:"set_current_working_directory",inputSchema:{cwd:g.string()}}},"auth.login":{description:"Start browser login and save credentials.",cli:{path:"login"}},"auth.logout":{description:"Delete local credentials and unload schema sessions.",cli:{path:"logout"}},"auth.whoami":{description:"Show the currently authenticated account token payload.",cli:{path:"whoami"}},"auth.reauth":{description:"Delete credentials and start login again.",cli:{path:"reauth"}},"account.profile":{description:"Fetch current account and organization/project-space metadata used for project creation.",tool:{name:"get_account_profile"},cli:{path:"account profile",alias:"account me"}},"projects.search":{description:"List/search projects with pagination.",tool:{name:"get_projects",inputSchema:{projectName:g.string().optional(),cursor:g.string().nullable().optional(),limit:g.number().optional()}},cli:{path:"projects search"}},"projects.list":{description:"List projects.",cli:{path:"projects list"}},"project.create":{description:"Create a new blank project. Defaults to the current account organization and waits for the project to appear in search. Creates a pre- or post-type-system-refactor project automatically based on the account rollout; pass useNewType/useRefactoredComponent to override.",tool:{name:"create_project",inputSchema:{projectName:g.string(),templateExId:g.string().nullable().optional(),platform:g.string().nullable().optional(),projectSpaceType:g.string().optional(),organizationExId:g.string().optional(),category:g.string().nullable().optional(),forBeginnerGuide:g.boolean().optional(),useRefactoredComponent:g.boolean().optional(),useNewType:g.boolean().optional(),wait:g.boolean().optional(),timeoutMs:g.number().optional()}},cli:{path:"project create"}},"project.set_current":{description:"Set the default project context by external id.",tool:{name:"set_current_project",inputSchema:{projectExId:g.string()}},cli:{path:"project set-current"}},"project.get_current":{description:"Get the current project context.",tool:{name:"get_current_project"},cli:{path:"project current",alias:"project get-current"}},"project.detail":{description:"Fetch the Zed project/app detail payload, including app list, project config, latest schema metadata, and deployment info.",cli:{path:"project detail"}},"project.metadata":{description:"Fetch a lean project summary: identity, platforms, publish/deploy state (incl. hasUndeployedChanges), configured integrations, plan, capabilities, and RPS. Pass raw=true for the full unshaped payload.",cli:{path:"project metadata",alias:"project inspect"}},"project.resources":{description:"Fetch project resource consumption, plan/capability limits, RPS stats, and optional resource history.",cli:{path:"project resources"}},"project.rename":{description:"Rename a project.",tool:{name:"rename_project",inputSchema:{...Mt,projectName:g.string()}},cli:{path:"project rename"}},"project.rename_app":{description:"Rename an app inside a project.",tool:{name:"rename_project_app",inputSchema:{projectExId:g.string(),appExId:g.string(),appName:g.string()}},cli:{path:"project rename-app"}},"project.delete":{description:"Delete a project. IRREVERSIBLE: requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve. Set MCP_HITL=off to fall back to the confirmProjectExId/force text gate in headless automation.",tool:{name:"delete_project",inputSchema:{projectExId:g.string(),confirmProjectExId:g.string().optional(),force:g.boolean().optional()}},cli:{path:"project delete"}},"project.reset":{description:"Reset a project. IRREVERSIBLE: requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve. Set MCP_HITL=off to fall back to the confirmProjectExId/force text gate in headless automation.",tool:{name:"reset_project",inputSchema:{projectExId:g.string(),confirmProjectExId:g.string().optional(),force:g.boolean().optional(),languageType:g.string().optional()}},cli:{path:"project reset"}},"project.sync_backend":{description:"Save the schema and deploy/sync the project runtime backend. Returns ztype diagnostics and blocks on backend validation errors by default.",tool:{name:"sync_backend",inputSchema:{...Mt,buildTarget:g.string().optional(),validateMultiClient:g.boolean().optional(),allowValidationErrors:g.boolean().optional()}},cli:{path:"project sync-backend",alias:"project deploy-backend"}},"schema.load":{description:"Load a project's CRDT schema into the daemon's in-memory headless schema session.",cli:{path:"schema load"}},"schema.reload":{description:"Force reload a project schema session from the backend CRDT model and patch log.",cli:{path:"schema reload"}},"schema.status":{description:"Show daemon schema sessions and TTL state.",tool:{name:"schema_status"},cli:{path:"schema status"}},"schema.state":{description:"Read the daemon's schema revision, stale state, and latest semantic schema-change event for a project.",cli:{path:"schema state"}},"schema.events":{description:"Read recent semantic schema-change events observed by the daemon for a project.",cli:{path:"schema events"}},"schema.sync":{description:"Catch up schema CRDT patches from the backend for the loaded project session.",cli:{path:"schema sync"}},"schema.snapshot":{description:"Return the data model of the loaded schema (tables, relations, enum types). Pass full=true for the entire raw ZSchema document (UI tree + all server configs), which is much larger.",cli:{path:"schema snapshot"}},"schema.validate":{description:"Run ztype validation/type checks against the loaded schema and return stable/beta/backend diagnostics.",cli:{path:"schema validate",alias:"schema type-check"}},"schema.ztype_tool_calls":{description:"Run ztype Copilot tool calls against the loaded schema. Any resulting CRDT patch is applied immediately; use schema_undo to revert the last change.",tool:{name:"ztype_tool_calls",inputSchema:{...Mt,toolCalls:g.array(g.record(g.any())),verbose:g.boolean().optional()}},cli:{path:"schema tool-call",alias:"schema tool-calls"}},"schema.undo":{description:"Undo the most recent schema change made in this session by applying a reverse CRDT patch. Refuses if a concurrent edit touched the same path. Pairs with schema_redo.",tool:{name:"schema_undo",inputSchema:{...Mt}},cli:{path:"schema undo"}},"schema.redo":{description:"Re-apply the schema change most recently undone via schema_undo in this session.",tool:{name:"schema_redo",inputSchema:{...Mt}},cli:{path:"schema redo"}},"secret.save_value":{description:"Prompt the user (native GUI dialog) to set a secret's plaintext value, store it, and attach the handle so the secret reports hasValue:true. Provide secretId (an existing secret) OR displayName (create a new one). The value is typed into the dialog and never passes through this tool call or the model. Requires a desktop session (fails on headless/SSH/CI).",tool:{name:"save_secret_value",inputSchema:{...Mt,secretId:g.string().optional(),displayName:g.string().optional(),description:g.string().optional()}},cli:{path:"secret save-value"}},"runtime.graphql":{description:"Run a raw GraphQL operation against the deployed project's runtime backend (the auto-generated data/actionflow/AI/TPA API), as admin.",tool:{name:"runtime_graphql",inputSchema:{...Mt,query:g.string(),variables:g.record(g.any()).optional()}},cli:{path:"runtime graphql"}},"runtime.run_code":{description:"Execute a JavaScript snippet in the deployed project's Run Code sandbox and return its result. Database writes are reverted unless updateDb is true, so this is the cheap way to check what a Run Code node will actually return before wiring it into a flow. Runs on the admin surface, as admin.",tool:{name:"runtime_run_code",inputSchema:{...Mt,jsCode:g.string(),args:g.record(g.any()).optional(),updateDb:g.boolean().optional()}},cli:{path:"runtime run-code"}},"runtime.query":{description:"Query rows from a deployed project's runtime table.",cli:{path:"runtime query"}},"runtime.aggregate":{description:"Count rows matching a filter in a deployed project's runtime table \u2014 the cheapest assertion available.",cli:{path:"runtime aggregate"}},"runtime.insert":{description:"Insert one or more rows into a deployed project's runtime table.",cli:{path:"runtime insert"}},"runtime.update":{description:"Update rows in a deployed project's runtime table.",cli:{path:"runtime update"}},"runtime.delete":{description:"Delete rows from a deployed project's runtime table. Requires where unless allowDeleteAll=true.",cli:{path:"runtime delete"}},"logs.search":{description:`Fetch recent runtime logs from the project's log endpoint. Window is \xB15 minutes around requestCreatedAt (ISO-8601, defaults to now). types: GATEWAY, ACTION_FLOW, ACTION_FLOW_NODE, ACTION_FLOW_CONTEXT_LOG, DEPLOYMENT, TPA, TRIGGER, SQL_GENERATION, GQL, ZAI. levels: INFO, WARNING, ERROR. customQueryCondition is an Elasticsearch condition (e.g. 'traceId: "abc-123"').`,tool:{name:"search_logs",inputSchema:{...Mt,requestCreatedAt:g.string().optional(),types:g.array(g.string()).optional(),levels:g.array(g.string()).optional(),customQueryCondition:g.string().optional(),limit:g.number().optional()}},cli:{path:"logs search"}},"docs.search":{description:"Full-text search the bundled product documentation. Returns the best-matching pages as { path, title, url }, where url is the public HTTPS docs link you can cite. Use docs.get_page with a returned path to read a page.",tool:{name:"search_docs",inputSchema:{query:g.string(),limit:g.number().optional()}},cli:{path:"docs search"}},"docs.get_page":{description:'Fetch a documentation page as markdown by its path (as returned by docs.search, e.g. "/02_design/01_layout_concepts").',tool:{name:"get_doc_page",inputSchema:{path:g.string()}},cli:{path:"docs get-page"}},"platform.graphql":{description:"Guarded raw GraphQL passthrough to the platform backend (projects, accounts, publishing \u2014 the editor/meta API, not the deployed runtime).",tool:{name:"platform_graphql",inputSchema:{query:g.string(),variables:g.record(g.any()).optional()}},cli:{path:"platform graphql"}},"tpa.import_from_openapi":{description:"Import one or more Third-Party API (TPA) configs from an OpenAPI v3 spec. Provide the spec as a `url` (fetched from this machine) or paste it as `specText` (JSON or YAML). Each operation becomes a TPA endpoint with its request parameters and success/fail response shape. Capped at 25 endpoints per call \u2014 use `pathsFilter` to scope larger specs. On any failure the whole import is rolled back. Duplicates are created (not merged) with a numbered name suffix. Works on every project generation.",tool:{name:"import_tpa_from_openapi",inputSchema:{...Mt,url:g.string().optional(),specText:g.string().optional(),pathsFilter:g.array(g.string()).optional()}},cli:{path:"tpa import-from-openapi"}},"tpa.fetch_doc":{description:"Fetch a web page or spec by URL for reading. Returns the page content (HTML converted to Markdown; long pages are windowed \u2014 pass `offset` with the same url to keep reading, guided by `totalLength`/`truncated`), same-site `pageLinks` to explore the documentation further, and any OpenAPI/Swagger `specLinks` found. Explore iteratively by fetching returned links, within a budget of 15 fetches per session (`fetchesRemaining`). Prefer importing a discovered spec via tpa import-from-openapi; otherwise author configs with the granular TPA schema ops.",tool:{name:"fetch_api_doc",inputSchema:{url:g.string(),offset:g.number().optional()}},cli:{path:"tpa fetch-doc"}},"site.deploy":{description:"Deploy a built frontend directory (e.g. ./dist) to the project\u2019s hosted static site and return the live url. Scans the directory, declares the manifest, uploads every asset to object storage, and switches the site over in one call \u2014 the agent never handles checksums or upload urls itself. `target` is BETA (default) or PROD; a PROD deploy takes the site live and requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve, and `force` does NOT approve it. Set MCP_HITL=off to fall back to the confirmProjectExId text gate in headless automation. An interrupted run resumes automatically when the directory is unchanged; pass `force` to discard it and start over. `dryRun` reports what would be uploaded without creating a deployment. The total size must fit the project\u2019s remaining object storage, and the directory must contain an index.html.",tool:{name:"deploy_static_site",inputSchema:{...Mt,dir:g.string(),target:g.string().optional(),dryRun:g.boolean().optional(),force:g.boolean().optional(),concurrency:g.number().optional(),confirmProjectExId:g.string().optional()}},cli:{path:"site deploy"}},"site.status":{description:"Report the project\u2019s static site: the currently live deployment (with its url) and any upload still in progress. Use to find the site url, or to see whether an interrupted deploy is still resumable.",tool:{name:"get_static_site_status",inputSchema:{...Mt,target:g.string().optional()}},cli:{path:"site status"}},"site.abort":{description:"Abandon an in-progress static site upload and delete whatever it already uploaded. Targets the current in-progress deployment unless `deploymentExId` names one. The live site is untouched.",tool:{name:"abort_static_site_deployment",inputSchema:{...Mt,target:g.string().optional(),deploymentExId:g.string().optional()}},cli:{path:"site abort"}},"wechat.deploy":{description:"Upload a locally-developed WeChat mini program source tree (the directory holding app.json) to the project and start the server-side build that commits it to WeChat as the \u4F53\u9A8C\u7248 (trial version). Scans the directory, declares the manifest, uploads every file to object storage, and hands off to the build job in one call \u2014 the agent never handles checksums or upload urls itself. By default it then WAITS for the build and returns the trial version number plus the path of the trial QR code image it saved (`wait: false` returns as soon as the build starts; `timeoutSeconds` bounds the wait). Requires the project to have granted Zion third-party platform authorization. An interrupted run resumes automatically when the directory is unchanged; pass `force` to discard it and start over. `dryRun` reports what would be uploaded without creating a deployment. This does NOT submit for audit or release \u2014 it only produces a trial version to verify; submitting it for review and releasing it are done by the user in the editor, not from here.",tool:{name:"deploy_wechat_source_code",inputSchema:{...Mt,dir:g.string(),dryRun:g.boolean().optional(),force:g.boolean().optional(),wait:g.boolean().optional(),timeoutSeconds:g.number().optional(),qrOut:g.string().optional(),concurrency:g.number().optional()}},cli:{path:"wechat deploy"}},"wechat.status":{description:"Report the project\u2019s WeChat mini program source upload: any upload still in progress and any build already running (with its deploymentRecordExId and start time). Use to poll a build after `wechat deploy`, or to see whether an interrupted upload is still resumable.",tool:{name:"get_wechat_source_code_status",inputSchema:{...Mt}},cli:{path:"wechat status"}},"wechat.abort":{description:"Abandon an in-progress WeChat mini program source upload and delete whatever it already uploaded. Targets the current in-progress deployment unless `deploymentExId` names one. A deployment that already reached BUILDING cannot be aborted.",tool:{name:"abort_wechat_source_code_deployment",inputSchema:{...Mt,deploymentExId:g.string().optional()}},cli:{path:"wechat abort"}},"wechat.qrcode":{description:"Save the WeChat trial version (\u4F53\u9A8C\u7248) QR code of the project\u2019s mini program to a local image file and return its path, along with the trial version number and the time it was committed. The QR code is written to disk rather than returned inline because it is a JPEG. Available once a `wechat deploy` build has succeeded; scanning it opens the trial version on a phone whose WeChat id is bound as a tester.",tool:{name:"get_wechat_trial_qrcode",inputSchema:{...Mt,out:g.string().optional()}},cli:{path:"wechat qrcode"}}},BE=Object.entries(Ske).map(([t,e])=>({command:t,...e})),AJ=[{name:"schema_session",description:"Schema session lifecycle for the loaded project. op: LOAD (warm the in-memory CRDT session) | RELOAD (force reload from backend) | SYNC (catch up patches) | SNAPSHOT (return the data model: tables, relations, enum types; pass full=true for the entire raw document) | VALIDATE (ztype type checks, stable/beta/backend diagnostics). Edits do not go live until sync_backend.",ops:{LOAD:"schema.load",RELOAD:"schema.reload",SYNC:"schema.sync",SNAPSHOT:"schema.snapshot",VALIDATE:"schema.validate"},inputSchema:{...Mt,full:g.boolean().optional()}},{name:"schema_observe",description:"Read the daemon's schema change-state for a project. op: STATE (revision, stale flag, latest change event) | EVENTS (recent semantic schema-change events; afterEventId/limit paginate).",ops:{STATE:"schema.state",EVENTS:"schema.events"},inputSchema:{projectExId:g.string().optional(),afterEventId:g.string().nullable().optional(),limit:g.number().optional()}},{name:"auth",description:"Authentication. op: LOGIN (browser login + save credentials) | LOGOUT (delete credentials, unload sessions) | WHOAMI (show authenticated account token payload) | REAUTH (delete credentials and log in again).",ops:{LOGIN:"auth.login",LOGOUT:"auth.logout",WHOAMI:"auth.whoami",REAUTH:"auth.reauth"}},{name:"project_inspect",description:"Inspect a project. op: DETAIL (app list, project config, latest schema metadata, deployment) | METADATA (plan/capability, deployment, app list, schema metadata, RPS summary) | RESOURCES (resource consumption, plan limits, RPS, optional history). includeSecrets applies to DETAIL/METADATA; refresh/resourceType/nonRealTimeDisplayedResourceTypes apply to RESOURCES.",ops:{DETAIL:"project.detail",METADATA:"project.metadata",RESOURCES:"project.resources"},inputSchema:{...Mt,includeSecrets:g.boolean().optional(),refresh:g.boolean().optional(),resourceType:g.string().optional(),nonRealTimeDisplayedResourceTypes:g.array(g.string()).optional()}}];d();var wke={schema_table:"database",schema_common:"database",schema_overview:"database",schema_type:"type",schema_binding_inspect:"bindings",schema_create_binding:"bindings",schema_conditional_branch:"bindings",schema_condition_expr:"bindings",schema_request_filter:"bindings",schema_actionflow:"actionflow",schema_actionflow_node:"actionflow",schema_trigger:"actionflow",schema_api:"api",schema_component:"component",schema_design_system:"component",schema_action_menu:"component",schema_theme:"component",schema_tab_bar:"component",schema_permission:"permissions",schema_secret:"tpa",schema_zai_config:"zai",schema_callback:"webhook",schema_payment:"payments"},NJ=t=>wke[t]??(t.includes("tpa")?"tpa":"UNMAPPED"),Ike={database:'Edit the data model \u2014 tables, columns, relations, unique constraints, display names. op is a schema ToolName from the enum; args is its payload. Call guide {plugin:"database"} first for the rules and per-op arg shapes.',type:'Edit enums and object/custom type definitions (post-type-system-refactor only). op is a schema ToolName; args is its payload. Call guide {plugin:"type"} for the rules and arg shapes.',bindings:'Create and edit data bindings \u2014 option/const/formula/conditional bindings, boolean condition expressions, and request filters (where + sort), all addressed by schemaPath. op is a schema ToolName; args is its payload. Call guide {plugin:"bindings"} for the rules and arg shapes.',actionflow:'Edit server-side action flows \u2014 flows, nodes, branches, I/O, global variables, and triggers (scheduled / database-change). op is a schema ToolName; args is its payload. Call guide {plugin:"actionflow"} for the rules and arg shapes.',api:'Edit the API-integration library \u2014 workspaces, APIs, request parameters, response configs, input variables, and workspace constants. op is a schema ToolName; args is its payload. Call guide {plugin:"api"} for the rules and arg shapes.',tpa:'Edit third-party API (TPA) configs used by the action-flow Call API node \u2014 configs, parameters, nested response trees, and paging. op is a schema ToolName; args is its payload. Call guide {plugin:"tpa"} for the rules and arg shapes.',zai:'Edit ZAI AI-agent configs \u2014 agents, input args, and model settings. op is a schema ToolName; args is its payload. Call guide {plugin:"zai"} for the rules and arg shapes.',component:'Build and edit the UI \u2014 pages, containers, components, slots, properties, styles and responsive breakpoints, plus the design system (color themes, style scale). op is a schema ToolName; args is its payload. Call guide {plugin:"component"} first for the tree rules, component templates, and per-op arg shapes.',permissions:'Edit roles and their table, API, action-flow, AI, TPA, and payment permissions. op is a schema ToolName; args is its payload. Call guide {plugin:"permissions"} for the rules and arg shapes.',webhook:'Edit incoming HTTP triggers (webhooks, called callbacks in the schema) \u2014 the bound action flow, request and response body shapes, body codecs, and the provider protocol. op is a schema ToolName; args is its payload. Call guide {plugin:"webhook"} for the rules and arg shapes.',payments:'Turn payments on and pick the order table. Provider credentials stay editor-only. op is a schema ToolName; args is its payload. Call guide {plugin:"payments"} for the rules and arg shapes.'},CJ=(()=>{let t=new Map;for(let e of kg){let r=NJ(e.name);if(r==="UNMAPPED")continue;let n=t.get(r)??new Set;for(let i of Object.values(e.ops))n.add(i);t.set(r,n)}return[...t.entries()].map(([e,r])=>({name:e,description:Ike[e]??`Edit ${e}.`,ops:[...r].sort()})).sort((e,r)=>e.name.localeCompare(r.name))})(),Ort=kg.filter(t=>NJ(t.name)==="UNMAPPED").map(t=>t.name);function Oke(){let t=[];for(let e of BE){if(!e.tool)continue;let{name:r,aliases:n,inputSchema:i}=e.tool;t.push({name:r,description:e.description,command:e.command,inputSchema:i});for(let o of n??[])t.push({name:o.name,description:o.description??e.description,command:e.command,inputSchema:i})}return t}function PJ(t,e){bJ(t,Oke(),e),SJ(t,AJ,e),wJ(t,CJ,e),IJ(t,e),OJ(t,e)}d();d();var Ake={productName:"Zion",utcOffset:"+08:00",accountTable:"\u5E10\u6237(\u8D26\u6237)",paymentTables:"\u652F\u4ED8, \u5468\u671F\u6027\u652F\u4ED8, \u9000\u6B3E",aiTables:"\u4F1A\u8BDD, \u6D88\u606F, \u5DE5\u5177\u4F7F\u7528\u8BB0\u5F55, \u6D88\u606F\u5185\u5BB9",displayNameRule:'user-visible; use the natural Chinese name as the displayName and derive the English snake_case systemName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 systemName "user_name").',enumDisplayNameRule:'use a natural Chinese phrase (enum displayName "\u8BA2\u5355\u72B6\u6001", option displayName "\u5F85\u5904\u7406"); the enum id and option values stay English.',runtimeGraphqlUrl:t=>fr().zeroApiUrlTemplate.replace("{projectExId}",t)},Nke={productName:"Momen",utcOffset:"+00:00",accountTable:"account",paymentTables:"payment_record, recurring_payment, refund",aiTables:"conversation, message, tool_usage_record, message_content",displayNameRule:'user-visible; prefer it IDENTICAL to the systemName (e.g. systemName "first_name" \u2192 displayName "first_name").',enumDisplayNameRule:'keep it close to the name/value itself (enum displayName \u2248 the enum name, e.g. "OrderStatus"; an option displayName \u2248 its value, e.g. "PENDING").',runtimeGraphqlUrl:t=>fr().zeroApiUrlTemplate.replace("{projectExId}",t)},Ql=()=>{switch(Ln){case"MOMEN":return Nke;case"ZION":return Ake;default:throw new Error(`[product-context] unknown PRODUCT '${Ln}'`)}};d();function RJ({brand:t,zeroApiUrl:e}){let r=e.replace(/^http:/,"ws:").replace(/^https:/,"wss:").replace("/api/graphql-v2","/api/graphql-subscription");return{brand:t,zeroApiUrl:e,zeroSubscriptionUrl:r}}function DJ(t){let e=t.brand==="Zion"?"Zion apps conventionally sign up / log in by phone number (SMS code); email and username work too.":"Momen apps conventionally sign up / log in by email; phone (SMS code) and username work too.";return`## App-user authentication (for the frontend you generate)
2894
+ BUCKET_OWNER_READ, DEFAULT, LOG_DELIVERY_WRITE, PRIVATE, PUBLIC_READ, PUBLIC_READ_WRITE.`};d();function TJ(t,e){let r=Kl[t];if(!r)throw new Error(`No guide available for '${t}'.`);let n=r[e];if(!n.available||!n.prompt)throw new Error(`Plugin '${t}' is not available for ${e} projects.`);return n.prompt}var Mt={projectExId:g.string().optional(),appExId:g.string().nullable().optional(),appVersionExId:g.string().nullable().optional()},GE=t=>({content:[{type:"text",text:t.ok?t.message??JSON.stringify(t.data??{},null,2):JSON.stringify({error:t.error??"Unknown error",data:t.data},null,2)}],isError:!t.ok}),Sf=(t,e,r,n,i)=>{t.registerTool(e,{description:r,inputSchema:n},i)},bJ=(t,e,r)=>{for(let n of e)Sf(t,n.name,n.description,n.inputSchema??{},async(i,o)=>GE(await r({name:n.command,args:i},o.signal)))},SJ=(t,e,r)=>{for(let n of e){let{ops:i}=n,o={op:g.enum(Object.keys(i)),...n.inputSchema??{}};Sf(t,n.name,n.description,o,async(a,s)=>{let{op:c,...l}=a;return GE(await r({name:i[String(c)],args:l},s.signal))})}};var bke=t=>({content:[{type:"text",text:t}],isError:!1});var wJ=(t,e,r)=>{for(let n of e){let i={...Mt,op:g.enum(n.ops),args:g.record(g.any()).optional()};Sf(t,n.name,n.description,i,async(o,a)=>{let{op:s,projectExId:c,appExId:l,appVersionExId:u,args:p}=o;return GE(await r({name:"schema.ztype_tool_calls",args:{projectExId:c,appExId:l,appVersionExId:u,toolCalls:[{toolCallId:`${n.name}-${String(s)}-${Date.now()}`,name:String(s),args:p??{}}]}},a?.signal))})}},IJ=(t,e)=>{let r=Object.keys(Kl);Sf(t,"guide","Load the domain guide for a backend capability \u2014 the rules, conventions, and gotchas for a plugin area (database, type, bindings, actionflow, api, tpa, zai, component, permissions, payments, logs, agent). Returns guidance for the loaded project\u2019s type-system state. Call before editing an unfamiliar area, or when a meta-tool call is rejected.",{plugin:g.enum(r),projectExId:g.string().optional()},async(n,i)=>{let o=await Mg(e,n.projectExId,i?.signal);return bke(TJ(String(n.plugin),o))})},OJ=(t,e)=>{Sf(t,"agent_command","Advanced escape hatch for directly invoking an internal agent command.",{name:g.string(),args:g.record(g.any()).optional()},async(r,n)=>GE(await e({name:String(r.name),args:r.args??{}},n.signal)))};d();var Ske={"actionflow.list_node_templates":{description:"List the published preset action-flow integration nodes (the dynamic TEMPLATE_CODE catalog \u2014 e.g. SMS, video/AI generation). Returns each template\u2019s templateCodeId, displayName, group, async flag, and input/output param types. Pass a returned templateCodeId to schema tool-call ADD_ACTION_FLOW_NODE (TEMPLATE_CODE node) to insert it. The set is server-managed and changes over time, so query it rather than assuming a fixed provider.",tool:{name:"list_actionflow_node_templates"},cli:{path:"actionflow list-node-templates"}},"workspace.set":{description:"Set the workspace root for local credentials, daemon registry, and project context.",tool:{name:"set_current_working_directory",inputSchema:{cwd:g.string()}}},"auth.login":{description:"Start browser login and save credentials.",cli:{path:"login"}},"auth.logout":{description:"Delete local credentials and unload schema sessions.",cli:{path:"logout"}},"auth.whoami":{description:"Show the currently authenticated account token payload.",cli:{path:"whoami"}},"auth.reauth":{description:"Delete credentials and start login again.",cli:{path:"reauth"}},"account.profile":{description:"Fetch current account and organization/project-space metadata used for project creation.",tool:{name:"get_account_profile"},cli:{path:"account profile",alias:"account me"}},"projects.search":{description:"List/search projects with pagination.",tool:{name:"get_projects",inputSchema:{projectName:g.string().optional(),cursor:g.string().nullable().optional(),limit:g.number().optional()}},cli:{path:"projects search"}},"projects.list":{description:"List projects.",cli:{path:"projects list"}},"project.create":{description:"Create a new blank project. Defaults to the current account organization and waits for the project to appear in search. Creates a pre- or post-type-system-refactor project automatically based on the account rollout; pass useNewType/useRefactoredComponent to override.",tool:{name:"create_project",inputSchema:{projectName:g.string(),templateExId:g.string().nullable().optional(),platform:g.string().nullable().optional(),projectSpaceType:g.string().optional(),organizationExId:g.string().optional(),category:g.string().nullable().optional(),forBeginnerGuide:g.boolean().optional(),useRefactoredComponent:g.boolean().optional(),useNewType:g.boolean().optional(),wait:g.boolean().optional(),timeoutMs:g.number().optional()}},cli:{path:"project create"}},"project.set_current":{description:"Set the default project context by external id.",tool:{name:"set_current_project",inputSchema:{projectExId:g.string()}},cli:{path:"project set-current"}},"project.get_current":{description:"Get the current project context.",tool:{name:"get_current_project"},cli:{path:"project current",alias:"project get-current"}},"project.detail":{description:"Fetch the Zed project/app detail payload, including app list, project config, latest schema metadata, and deployment info.",cli:{path:"project detail"}},"project.metadata":{description:"Fetch a lean project summary: identity, platforms, publish/deploy state (incl. hasUndeployedChanges), configured integrations, plan, capabilities, and RPS. Pass raw=true for the full unshaped payload.",cli:{path:"project metadata",alias:"project inspect"}},"project.resources":{description:"Fetch project resource consumption, plan/capability limits, RPS stats, and optional resource history.",cli:{path:"project resources"}},"project.rename":{description:"Rename a project.",tool:{name:"rename_project",inputSchema:{...Mt,projectName:g.string()}},cli:{path:"project rename"}},"project.rename_app":{description:"Rename an app inside a project.",tool:{name:"rename_project_app",inputSchema:{projectExId:g.string(),appExId:g.string(),appName:g.string()}},cli:{path:"project rename-app"}},"project.delete":{description:"Delete a project. IRREVERSIBLE: requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve. Set MCP_HITL=off to fall back to the confirmProjectExId/force text gate in headless automation.",tool:{name:"delete_project",inputSchema:{projectExId:g.string(),confirmProjectExId:g.string().optional(),force:g.boolean().optional()}},cli:{path:"project delete"}},"project.reset":{description:"Reset a project. IRREVERSIBLE: requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve. Set MCP_HITL=off to fall back to the confirmProjectExId/force text gate in headless automation.",tool:{name:"reset_project",inputSchema:{projectExId:g.string(),confirmProjectExId:g.string().optional(),force:g.boolean().optional(),languageType:g.string().optional()}},cli:{path:"project reset"}},"project.sync_backend":{description:"Save the schema and deploy/sync the project runtime backend. Returns ztype diagnostics and blocks on backend validation errors by default.",tool:{name:"sync_backend",inputSchema:{...Mt,buildTarget:g.string().optional(),validateMultiClient:g.boolean().optional(),allowValidationErrors:g.boolean().optional()}},cli:{path:"project sync-backend",alias:"project deploy-backend"}},"schema.load":{description:"Load a project's CRDT schema into the daemon's in-memory headless schema session.",cli:{path:"schema load"}},"schema.reload":{description:"Force reload a project schema session from the backend CRDT model and patch log.",cli:{path:"schema reload"}},"schema.status":{description:"Show daemon schema sessions and TTL state.",tool:{name:"schema_status"},cli:{path:"schema status"}},"schema.state":{description:"Read the daemon's schema revision, stale state, and latest semantic schema-change event for a project.",cli:{path:"schema state"}},"schema.events":{description:"Read recent semantic schema-change events observed by the daemon for a project.",cli:{path:"schema events"}},"schema.sync":{description:"Catch up schema CRDT patches from the backend for the loaded project session.",cli:{path:"schema sync"}},"schema.snapshot":{description:"Return the data model of the loaded schema (tables, relations, enum types). Pass full=true for the entire raw ZSchema document (UI tree + all server configs), which is much larger.",cli:{path:"schema snapshot"}},"schema.validate":{description:"Run ztype validation/type checks against the loaded schema and return stable/beta/backend diagnostics.",cli:{path:"schema validate",alias:"schema type-check"}},"schema.ztype_tool_calls":{description:"Run ztype Copilot tool calls against the loaded schema. Any resulting CRDT patch is applied immediately; use schema_undo to revert the last change.",tool:{name:"ztype_tool_calls",inputSchema:{...Mt,toolCalls:g.array(g.record(g.any())),verbose:g.boolean().optional()}},cli:{path:"schema tool-call",alias:"schema tool-calls"}},"schema.undo":{description:"Undo the most recent schema change made in this session by applying a reverse CRDT patch. Refuses if a concurrent edit touched the same path. Pairs with schema_redo.",tool:{name:"schema_undo",inputSchema:{...Mt}},cli:{path:"schema undo"}},"schema.redo":{description:"Re-apply the schema change most recently undone via schema_undo in this session.",tool:{name:"schema_redo",inputSchema:{...Mt}},cli:{path:"schema redo"}},"secret.save_value":{description:"Prompt the user (native GUI dialog) to set a secret's plaintext value, store it, and attach the handle so the secret reports hasValue:true. Provide secretId (an existing secret) OR displayName (create a new one). The value is typed into the dialog and never passes through this tool call or the model. Requires a desktop session (fails on headless/SSH/CI).",tool:{name:"save_secret_value",inputSchema:{...Mt,secretId:g.string().optional(),displayName:g.string().optional(),description:g.string().optional()}},cli:{path:"secret save-value"}},"runtime.graphql":{description:"Run a raw GraphQL operation against the deployed project's runtime backend (the auto-generated data/actionflow/AI/TPA API), as admin.",tool:{name:"runtime_graphql",inputSchema:{...Mt,query:g.string(),variables:g.record(g.any()).optional()}},cli:{path:"runtime graphql"}},"runtime.run_code":{description:"Execute a JavaScript snippet in the deployed project's Run Code sandbox and return its result. Database writes are reverted unless updateDb is true, so this is the cheap way to check what a Run Code node will actually return before wiring it into a flow. Runs on the admin surface, as admin.",tool:{name:"runtime_run_code",inputSchema:{...Mt,jsCode:g.string(),args:g.record(g.any()).optional(),updateDb:g.boolean().optional()}},cli:{path:"runtime run-code"}},"runtime.query":{description:"Query rows from a deployed project's runtime table.",cli:{path:"runtime query"}},"runtime.aggregate":{description:"Count rows matching a filter in a deployed project's runtime table \u2014 the cheapest assertion available.",cli:{path:"runtime aggregate"}},"runtime.insert":{description:"Insert one or more rows into a deployed project's runtime table.",cli:{path:"runtime insert"}},"runtime.update":{description:"Update rows in a deployed project's runtime table.",cli:{path:"runtime update"}},"runtime.delete":{description:"Delete rows from a deployed project's runtime table. Requires where unless allowDeleteAll=true.",cli:{path:"runtime delete"}},"logs.search":{description:`Fetch recent runtime logs from the project's log endpoint. Window is \xB15 minutes around requestCreatedAt (ISO-8601, defaults to now). types: GATEWAY, ACTION_FLOW, ACTION_FLOW_NODE, ACTION_FLOW_CONTEXT_LOG, DEPLOYMENT, TPA, TRIGGER, SQL_GENERATION, GQL, ZAI. levels: INFO, WARNING, ERROR. customQueryCondition is an Elasticsearch condition (e.g. 'traceId: "abc-123"').`,tool:{name:"search_logs",inputSchema:{...Mt,requestCreatedAt:g.string().optional(),types:g.array(g.string()).optional(),levels:g.array(g.string()).optional(),customQueryCondition:g.string().optional(),limit:g.number().optional()}},cli:{path:"logs search"}},"docs.search":{description:"Full-text search the bundled product documentation. Returns the best-matching pages as { path, title, url }, where url is the public HTTPS docs link you can cite. Use docs.get_page with a returned path to read a page.",tool:{name:"search_docs",inputSchema:{query:g.string(),limit:g.number().optional()}},cli:{path:"docs search"}},"docs.get_page":{description:'Fetch a documentation page as markdown by its path (as returned by docs.search, e.g. "/02_design/01_layout_concepts").',tool:{name:"get_doc_page",inputSchema:{path:g.string()}},cli:{path:"docs get-page"}},"platform.graphql":{description:"Guarded raw GraphQL passthrough to the platform backend (projects, accounts, publishing \u2014 the editor/meta API, not the deployed runtime).",tool:{name:"platform_graphql",inputSchema:{query:g.string(),variables:g.record(g.any()).optional()}},cli:{path:"platform graphql"}},"tpa.import_from_openapi":{description:"Import one or more Third-Party API (TPA) configs from an OpenAPI v3 spec. Provide the spec as a `url` (fetched from this machine) or paste it as `specText` (JSON or YAML). Each operation becomes a TPA endpoint with its request parameters and success/fail response shape. Capped at 25 endpoints per call \u2014 use `pathsFilter` to scope larger specs. On any failure the whole import is rolled back. Duplicates are created (not merged) with a numbered name suffix. Works on every project generation.",tool:{name:"import_tpa_from_openapi",inputSchema:{...Mt,url:g.string().optional(),specText:g.string().optional(),pathsFilter:g.array(g.string()).optional()}},cli:{path:"tpa import-from-openapi"}},"tpa.fetch_doc":{description:"Fetch a web page or spec by URL for reading. Returns the page content (HTML converted to Markdown; long pages are windowed \u2014 pass `offset` with the same url to keep reading, guided by `totalLength`/`truncated`), same-site `pageLinks` to explore the documentation further, and any OpenAPI/Swagger `specLinks` found. Explore iteratively by fetching returned links, within a budget of 15 fetches per session (`fetchesRemaining`). Prefer importing a discovered spec via tpa import-from-openapi; otherwise author configs with the granular TPA schema ops.",tool:{name:"fetch_api_doc",inputSchema:{url:g.string(),offset:g.number().optional()}},cli:{path:"tpa fetch-doc"}},"site.deploy":{description:"Deploy a built frontend directory (e.g. ./dist) to the project\u2019s hosted static site and return the live url. Scans the directory, declares the manifest, uploads every asset to object storage, and switches the site over in one call \u2014 the agent never handles checksums or upload urls itself. `target` is BETA (default) or PROD; a PROD deploy takes the site live and requires a human to approve a native GUI dialog by retyping the project id; the agent cannot self-approve, and `force` does NOT approve it. Set MCP_HITL=off to fall back to the confirmProjectExId text gate in headless automation. An interrupted run resumes automatically when the directory is unchanged; pass `force` to discard it and start over. `dryRun` reports what would be uploaded without creating a deployment. The total size must fit the project\u2019s remaining object storage, and the directory must contain an index.html.",tool:{name:"deploy_static_site",inputSchema:{...Mt,dir:g.string(),target:g.string().optional(),dryRun:g.boolean().optional(),force:g.boolean().optional(),concurrency:g.number().optional(),confirmProjectExId:g.string().optional()}},cli:{path:"site deploy"}},"site.status":{description:"Report the project\u2019s static site: the currently live deployment (with its url) and any upload still in progress. Use to find the site url, or to see whether an interrupted deploy is still resumable.",tool:{name:"get_static_site_status",inputSchema:{...Mt,target:g.string().optional()}},cli:{path:"site status"}},"site.abort":{description:"Abandon an in-progress static site upload and delete whatever it already uploaded. Targets the current in-progress deployment unless `deploymentExId` names one. The live site is untouched.",tool:{name:"abort_static_site_deployment",inputSchema:{...Mt,target:g.string().optional(),deploymentExId:g.string().optional()}},cli:{path:"site abort"}},"wechat.deploy":{description:"Upload a locally-developed WeChat mini program source tree (the directory holding app.json) to the project and start the server-side build that commits it to WeChat as the \u4F53\u9A8C\u7248 (trial version). Scans the directory, declares the manifest, uploads every file to object storage, and hands off to the build job in one call \u2014 the agent never handles checksums or upload urls itself. By default it then WAITS for the build and returns the trial version number plus the path of the trial QR code image it saved (`wait: false` returns as soon as the build starts; `timeoutSeconds` bounds the wait). Requires the project to have granted Zion third-party platform authorization. An interrupted run resumes automatically when the directory is unchanged; pass `force` to discard it and start over. `dryRun` reports what would be uploaded without creating a deployment. This does NOT submit for audit or release \u2014 it only produces a trial version to verify; submitting it for review and releasing it are done by the user in the editor, not from here.",tool:{name:"deploy_wechat_source_code",inputSchema:{...Mt,dir:g.string(),dryRun:g.boolean().optional(),force:g.boolean().optional(),wait:g.boolean().optional(),timeoutSeconds:g.number().optional(),qrOut:g.string().optional(),concurrency:g.number().optional()}},cli:{path:"wechat deploy"}},"wechat.status":{description:"Report the project\u2019s WeChat mini program source upload: any upload still in progress and any build already running (with its deploymentRecordExId and start time). Use to poll a build after `wechat deploy`, or to see whether an interrupted upload is still resumable.",tool:{name:"get_wechat_source_code_status",inputSchema:{...Mt}},cli:{path:"wechat status"}},"wechat.abort":{description:"Abandon an in-progress WeChat mini program source upload and delete whatever it already uploaded. Targets the current in-progress deployment unless `deploymentExId` names one. A deployment that already reached BUILDING cannot be aborted.",tool:{name:"abort_wechat_source_code_deployment",inputSchema:{...Mt,deploymentExId:g.string().optional()}},cli:{path:"wechat abort"}},"wechat.qrcode":{description:"Save the WeChat trial version (\u4F53\u9A8C\u7248) QR code of the project\u2019s mini program to a local image file and return its path, along with the trial version number and the time it was committed. The QR code is written to disk rather than returned inline because it is a JPEG. Available once a `wechat deploy` build has succeeded; scanning it opens the trial version on a phone whose WeChat id is bound as a tester.",tool:{name:"get_wechat_trial_qrcode",inputSchema:{...Mt,out:g.string().optional()}},cli:{path:"wechat qrcode"}}},BE=Object.entries(Ske).map(([t,e])=>({command:t,...e})),AJ=[{name:"schema_session",description:"Schema session lifecycle for the loaded project. op: LOAD (warm the in-memory CRDT session) | RELOAD (force reload from backend) | SYNC (catch up patches) | SNAPSHOT (return the data model: tables, relations, enum types; pass full=true for the entire raw document) | VALIDATE (ztype type checks, stable/beta/backend diagnostics). Edits do not go live until sync_backend.",ops:{LOAD:"schema.load",RELOAD:"schema.reload",SYNC:"schema.sync",SNAPSHOT:"schema.snapshot",VALIDATE:"schema.validate"},inputSchema:{...Mt,full:g.boolean().optional()}},{name:"schema_observe",description:"Read the daemon's schema change-state for a project. op: STATE (revision, stale flag, latest change event) | EVENTS (recent semantic schema-change events; afterEventId/limit paginate).",ops:{STATE:"schema.state",EVENTS:"schema.events"},inputSchema:{projectExId:g.string().optional(),afterEventId:g.string().nullable().optional(),limit:g.number().optional()}},{name:"auth",description:"Authentication. op: LOGIN (browser login + save credentials) | LOGOUT (delete credentials, unload sessions) | WHOAMI (show authenticated account token payload) | REAUTH (delete credentials and log in again).",ops:{LOGIN:"auth.login",LOGOUT:"auth.logout",WHOAMI:"auth.whoami",REAUTH:"auth.reauth"}},{name:"project_inspect",description:"Inspect a project. op: DETAIL (app list, project config, latest schema metadata, deployment) | METADATA (plan/capability, deployment, app list, schema metadata, RPS summary) | RESOURCES (resource consumption, plan limits, RPS, optional history). includeSecrets applies to DETAIL/METADATA; refresh/resourceType/nonRealTimeDisplayedResourceTypes apply to RESOURCES.",ops:{DETAIL:"project.detail",METADATA:"project.metadata",RESOURCES:"project.resources"},inputSchema:{...Mt,includeSecrets:g.boolean().optional(),refresh:g.boolean().optional(),resourceType:g.string().optional(),nonRealTimeDisplayedResourceTypes:g.array(g.string()).optional()}}];d();var wke={schema_table:"database",schema_common:"database",schema_overview:"database",schema_type:"type",schema_binding_inspect:"bindings",schema_create_binding:"bindings",schema_conditional_branch:"bindings",schema_condition_expr:"bindings",schema_request_filter:"bindings",schema_actionflow:"actionflow",schema_actionflow_node:"actionflow",schema_trigger:"actionflow",schema_api:"api",schema_component:"component",schema_design_system:"component",schema_action_menu:"component",schema_theme:"component",schema_tab_bar:"component",schema_permission:"permissions",schema_secret:"tpa",schema_zai_config:"zai",schema_callback:"webhook",schema_payment:"payments"},NJ=t=>wke[t]??(t.includes("tpa")?"tpa":"UNMAPPED"),Ike={database:'Edit the data model \u2014 tables, columns, relations, unique constraints, display names. op is a schema ToolName from the enum; args is its payload. Call guide {plugin:"database"} first for the rules and per-op arg shapes.',type:'Edit enums and object/custom type definitions (post-type-system-refactor only). op is a schema ToolName; args is its payload. Call guide {plugin:"type"} for the rules and arg shapes.',bindings:'Create and edit data bindings \u2014 option/const/formula/conditional bindings, boolean condition expressions, and request filters (where + sort), all addressed by schemaPath. op is a schema ToolName; args is its payload. Call guide {plugin:"bindings"} for the rules and arg shapes.',actionflow:'Edit server-side action flows \u2014 flows, nodes, branches, I/O, global variables, and triggers (scheduled / database-change). op is a schema ToolName; args is its payload. Call guide {plugin:"actionflow"} for the rules and arg shapes.',api:'Edit the API-integration library \u2014 workspaces, APIs, request parameters, response configs, input variables, and workspace constants. op is a schema ToolName; args is its payload. Call guide {plugin:"api"} for the rules and arg shapes.',tpa:'Edit third-party API (TPA) configs used by the action-flow Call API node \u2014 configs, parameters, nested response trees, and paging. op is a schema ToolName; args is its payload. Call guide {plugin:"tpa"} for the rules and arg shapes.',zai:'Edit ZAI AI-agent configs \u2014 agents, input args, and model settings. op is a schema ToolName; args is its payload. Call guide {plugin:"zai"} for the rules and arg shapes.',component:'Build and edit the UI \u2014 pages, containers, components, slots, properties, styles and responsive breakpoints, plus the design system (color themes, style scale). op is a schema ToolName; args is its payload. Call guide {plugin:"component"} first for the tree rules, component templates, and per-op arg shapes.',permissions:'Edit roles and their table, API, action-flow, AI, TPA, and payment permissions. op is a schema ToolName; args is its payload. Call guide {plugin:"permissions"} for the rules and arg shapes.',webhook:'Edit incoming HTTP triggers (webhooks, called callbacks in the schema) \u2014 the bound action flow, request and response body shapes, body codecs, and the provider protocol. op is a schema ToolName; args is its payload. Call guide {plugin:"webhook"} for the rules and arg shapes.',payments:'Turn payments on and pick the order table. Provider credentials stay editor-only. op is a schema ToolName; args is its payload. Call guide {plugin:"payments"} for the rules and arg shapes.'},CJ=(()=>{let t=new Map;for(let e of kg){let r=NJ(e.name);if(r==="UNMAPPED")continue;let n=t.get(r)??new Set;for(let i of Object.values(e.ops))n.add(i);t.set(r,n)}return[...t.entries()].map(([e,r])=>({name:e,description:Ike[e]??`Edit ${e}.`,ops:[...r].sort()})).sort((e,r)=>e.name.localeCompare(r.name))})(),Ort=kg.filter(t=>NJ(t.name)==="UNMAPPED").map(t=>t.name);function Oke(){let t=[];for(let e of BE){if(!e.tool)continue;let{name:r,aliases:n,inputSchema:i}=e.tool;t.push({name:r,description:e.description,command:e.command,inputSchema:i});for(let o of n??[])t.push({name:o.name,description:o.description??e.description,command:e.command,inputSchema:i})}return t}function PJ(t,e){bJ(t,Oke(),e),SJ(t,AJ,e),wJ(t,CJ,e),IJ(t,e),OJ(t,e)}d();d();var Ake={productName:"Zion",utcOffset:"+08:00",accountTable:"\u5E10\u6237(\u8D26\u6237)",paymentTables:"\u652F\u4ED8, \u5468\u671F\u6027\u652F\u4ED8, \u9000\u6B3E",aiTables:"\u4F1A\u8BDD, \u6D88\u606F, \u5DE5\u5177\u4F7F\u7528\u8BB0\u5F55, \u6D88\u606F\u5185\u5BB9",displayNameRule:'user-visible; use the natural Chinese name as the displayName and derive the English snake_case apiName from it (e.g. displayName "\u7528\u6237\u540D" \u2192 apiName "user_name").',enumDisplayNameRule:'use a natural Chinese phrase (enum displayName "\u8BA2\u5355\u72B6\u6001", option displayName "\u5F85\u5904\u7406"); the enum id and option values stay English.',runtimeGraphqlUrl:t=>fr().zeroApiUrlTemplate.replace("{projectExId}",t)},Nke={productName:"Momen",utcOffset:"+00:00",accountTable:"account",paymentTables:"payment_record, recurring_payment, refund",aiTables:"conversation, message, tool_usage_record, message_content",displayNameRule:'user-visible; prefer it IDENTICAL to the apiName (e.g. apiName "first_name" \u2192 displayName "first_name").',enumDisplayNameRule:'keep it close to the name/value itself (enum displayName \u2248 the enum name, e.g. "OrderStatus"; an option displayName \u2248 its value, e.g. "PENDING").',runtimeGraphqlUrl:t=>fr().zeroApiUrlTemplate.replace("{projectExId}",t)},Ql=()=>{switch(Ln){case"MOMEN":return Nke;case"ZION":return Ake;default:throw new Error(`[product-context] unknown PRODUCT '${Ln}'`)}};d();function RJ({brand:t,zeroApiUrl:e}){let r=e.replace(/^http:/,"ws:").replace(/^https:/,"wss:").replace("/api/graphql-v2","/api/graphql-subscription");return{brand:t,zeroApiUrl:e,zeroSubscriptionUrl:r}}function DJ(t){let e=t.brand==="Zion"?"Zion apps conventionally sign up / log in by phone number (SMS code); email and username work too.":"Momen apps conventionally sign up / log in by email; phone (SMS code) and username work too.";return`## App-user authentication (for the frontend you generate)
2894
2895
  The deployed app's end-users obtain a JWT by logging in / registering against the same GraphQL API;
2895
2896
  unauthenticated requests fall back to the anonymous role. Distinct from the developer \`login\` that
2896
2897
  authenticates THIS CLI to ${t.brand}. ${e}