@oomol-lab/open-flow 0.1.0-beta.61 → 0.1.0-beta.63

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.
Files changed (55) hide show
  1. package/dist/browser/{createResourceDialog-D71fO68i.js → createResourceDialog-BAJXbzNH.js} +20 -7
  2. package/dist/browser/flow-authoring.js +8 -7
  3. package/dist/browser/flow-change-schema.d.ts +1 -0
  4. package/dist/browser/flow-change.d.ts +1 -0
  5. package/dist/browser/flow-change.js +8 -7
  6. package/dist/browser/{flowChanges-DSA0FxxN.js → flowChanges-DpZOQuJE.js} +3001 -2588
  7. package/dist/browser/{flowRunInputEditorStore-Dsxyfwae.js → flowRunInputEditorStore-B2Rw4VsT.js} +1 -1
  8. package/dist/browser/{flowWorkspace-0sUJ5JhQ.js → flowWorkspace-B7a5NNA_.js} +217 -83
  9. package/dist/browser/{icons-DVJvrj1H.js → icons-Db2Jb2iX.js} +2907 -2887
  10. package/dist/browser/preview.css +5 -6
  11. package/dist/browser/preview.js +889 -541
  12. package/dist/browser/{typeScriptSession-fXPMFGjW.js → typeScriptSession-D0bjYDeg.js} +1 -1
  13. package/dist/browser/ui.css +4 -5
  14. package/dist/browser/ui.js +2 -2
  15. package/dist/browser/{value-DL_poNiC.js → value-BADHeZ9I.js} +12 -1
  16. package/dist/browser/workbench-contract.d.ts +10 -0
  17. package/dist/browser/workbench.css +9 -26
  18. package/dist/browser/workbench.d.ts +5 -3
  19. package/dist/browser/workbench.js +272 -178
  20. package/dist/browser/{workbenchSelect-cr4-mKq3.js → workbenchSelect-C-jf6NIM.js} +1 -1
  21. package/dist/command/index.js +45 -44
  22. package/dist/common/authoring.d.ts +1 -1
  23. package/dist/common/authoringSchema.d.ts +1 -0
  24. package/dist/common/connector-action.d.ts +1 -0
  25. package/dist/common/connector-action.js +15 -12
  26. package/dist/common/control-api-conformance.js +1371 -1207
  27. package/dist/common/control-api-errors.d.ts +0 -4
  28. package/dist/common/control-api.d.ts +18 -11
  29. package/dist/common/control-api.js +2053 -2274
  30. package/dist/common/control-requests.d.ts +6 -0
  31. package/dist/common/control-requests.js +64 -33
  32. package/dist/common/decision.js +8 -7
  33. package/dist/common/flow-connectionUsage.d.ts +1 -0
  34. package/dist/common/flow-encoding.d.ts +1 -0
  35. package/dist/common/flow-encoding.js +202 -10
  36. package/dist/common/flow-semantics.js +64 -46
  37. package/dist/common/flow-workflowFile.d.ts +23 -0
  38. package/dist/common/integration-trigger.js +8 -7
  39. package/dist/common/liveDetails.d.ts +138 -0
  40. package/dist/common/localization.d.ts +1 -0
  41. package/dist/common/localization.js +12 -1
  42. package/dist/common/mcp.d.ts +55 -26
  43. package/dist/common/mcp.js +377 -245
  44. package/dist/common/openapi.js +8 -7
  45. package/dist/common/poll-trigger.js +8 -7
  46. package/dist/common/runtime-contract.js +1 -1
  47. package/dist/common/scheduler.d.ts +22 -2
  48. package/dist/common/scheduler.js +354 -83
  49. package/dist/common/trigger-config.d.ts +2 -0
  50. package/dist/common/webhook-trigger.js +8 -7
  51. package/dist/index.d.ts +2 -2
  52. package/package.json +1 -1
  53. package/skills/open-flow/SKILL.md +6 -3
  54. package/skills/open-flow/references/flow-authoring.md +48 -24
  55. package/dist/common/publicationResources.d.ts +0 -29
@@ -1,40 +1,40 @@
1
1
  // @bun
2
- var la="0.1.0-beta.61";var Co=["en","zh-CN","zh-TW","ja","ko","ru","fr"],da="en";var Eo=new Map(Co.map((e)=>[e.toLowerCase(),e])),Gm=new Set(["hk","mo","tw"]);function pa(e){return typeof e=="string"&&Eo.get(e.toLowerCase())==e}function or(e,n="en"){for(let t of e){let r=t==null?void 0:Wm(t);if(r!=null)return r}return n}function Wm(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=Eo.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>Gm.has(o))?"zh-TW":"zh-CN"}return Eo.get(r[0])}import{spawn as sx}from"child_process";import{readFile as ax}from"fs/promises";import{setTimeout as cx}from"timers/promises";var fa=Object.prototype.hasOwnProperty;function ze(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)while(r--&&ze(e[r],n[r]));return r===-1}if(!t||typeof e==="object"){r=0;for(t in e){if(fa.call(e,t)&&++r&&!fa.call(n,t))return!1;if(!(t in n)||!ze(e[t],n[t]))return!1}return Object.keys(n).length===r}}return e!==e&&n!==n}function Oo(e){for(let n of Object.values(e.graph.nodes)){if(n.kind!="task"||!("executor"in n.task)||n.task.executor.kind!="openapi")continue;for(let[t,r]of Object.entries(n.inputs))if(t.startsWith("auth.")&&r.kind=="value")throw TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.")}}function it(e){let n=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,o])=>n.indexOf(+r)===-1).map(([r,o])=>o)}function Ao(e,n="|"){return e.map((t)=>jo(t)).join(n)}function st(e,n){if(typeof n==="bigint")return n.toString();return n}class ga{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function at(e){return new ga(e)}function ha(e){return e===null||e===void 0}function ir(e){let n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}function ya(e,n){let t=e/n,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);if(Math.abs(t-r)<o)return 0;return t-r}var ma=Symbol("evaluating");function ba(e,n,t){let r=void 0;Object.defineProperty(e,n,{get(){if(r===ma)return;if(r===void 0)r=ma,r=t();return r},set(o){Object.defineProperty(e,n,{value:o})},configurable:!0})}function De(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function ct(e){let n=Object.getOwnPropertyDescriptor(e,"shape");return n?.get?n.get.raw:n?.value}function nn(e){return ct(e._zod.def)??e._zod.def.shape}function wa(e,n,t){Object.defineProperty(e,n,{get(){let r=t();return De(this,n,r),r},enumerable:!0,configurable:!0})}function xa(e,n,t){if(n in e)De(e,n,t);else e[n]=t}function vn(e,n,t,r){let o=nn(n);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)wa(e,i,()=>{let a=n._zod.def.shape[i];return r?r(a,i):a});else xa(e,i,r?r(s.value,i):s.value)}}function Hm(e,n){for(let t of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,t);if(!r.enumerable)continue;if(r.get)wa(e,t,()=>n[t]);else xa(e,t,r.value)}}function Ve(...e){let n={};for(let t of e){let r=Object.getOwnPropertyDescriptors(t);Object.assign(n,r)}return Object.defineProperties({},n)}function va(e){return JSON.stringify(e)}function ka(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Po="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function zn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Sa=at(()=>{if(Pe.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function kn(e){if(zn(e)===!1)return!1;let n=e.constructor;if(n===void 0)return!0;if(typeof n!=="function")return!0;let t=n.prototype;if(zn(t)===!1)return!1;if(Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)return!1;return!0}function _o(e){if(kn(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Ia=new Set(["string","number","symbol"]);function an(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(e,n,t){let r=new e._zod.constr(n??e._zod.def);if(!n||t?.parent)r._zod.parent=e;return r}function j(e){let n=e;if(!n)return{};if(typeof n==="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");n.error=n.message}if(delete n.message,typeof n.error==="string")return{...n,error:()=>n.error};return n}function jo(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Ea(e){return Object.keys(e).filter((n)=>e[n]._zod.optin!==void 0&&e[n]._zod.optout==="optional")}var sr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),$o={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Qm(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return vn(i,e,ar(e,n)),We(e,Ve(t,{shape:i,checks:[]}))}function ar(e,n){let t=nn(e),r=[];for(let o of Reflect.ownKeys(n)){if(!Object.getOwnPropertyDescriptor(t,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(n[o])r.push(o)}return r}function Ym(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(ar(e,n)),s={};return vn(s,e,Reflect.ownKeys(nn(e)).filter((a)=>!i.has(a))),We(e,Ve(t,{shape:s,checks:[]}))}function Xm(e,n){if(!kn(n))throw Error("Invalid input to extend: expected a plain object");let t=e._zod.def.checks;if(t&&t.length>0){let o=nn(e);for(let i of Reflect.ownKeys(n))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return We(e,Ve(e._zod.def,{shape:Ca(e,n)}))}function Ca(e,n){let t={};return vn(t,e,Reflect.ownKeys(nn(e))),Hm(t,n),t}function eg(e,n){if(!kn(n))throw Error("Invalid input to safeExtend: expected a plain object");return We(e,Ve(e._zod.def,{shape:Ca(e,n)}))}function ng(e,n){if(!n?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};vn(t,e,Reflect.ownKeys(nn(e))),vn(t,n,Reflect.ownKeys(nn(n)));let r=Ve(e._zod.def,{shape:t,get catchall(){return n._zod.def.catchall},checks:n._zod.def.checks??[]});return We(e,r)}function Oa(e,n,t,r="partial"){let i=n._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=t?new Set(ar(n,t)):void 0,c={};return vn(c,n,Reflect.ownKeys(nn(n)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),We(n,Ve(n._zod.def,{shape:c,checks:[]}))}function tg(e,n,t){let r=t?new Set(ar(n,t)):void 0,o={};return vn(o,n,Reflect.ownKeys(nn(n)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),We(n,Ve(n._zod.def,{shape:o}))}function He(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue!==!0)return!0;return!1}function Ra(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue===!1)return!0;return!1}function cn(e,n){return n.map((t)=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function ot(e){return typeof e==="string"?e:e?.message}function No(e,n,t){var r;for(let o=n;o<e.length;o++)(r=e[o]).schema??(r.schema=t)}function Qe(e,n,t){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:ot(e.inst?._zod.def?.error?.(e))??ot(i?.(e))??ot(n?.error?.(e))??ot(t.customError?.(e))??ot(t.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,n?.reportInput)a.input=e.input;return a}var rg=/[\uD800-\uDBFF]/;function cr(e){let n=e.length;if(!rg.test(e))return n;let t=n;for(let r=0;r<n-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)t--,r++;return t}function ur(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Aa(e){let n=typeof e;switch(n){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return n}function Sn(...e){let[n,t,r]=e;if(typeof n==="string")return{message:n,code:"custom",input:t,inst:r};return{...n}}function Pa(e,n){for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);if(r.get)Object.defineProperty(e,t,{...r,enumerable:!1});else og(e,t,r.value)}}function tn(e,n,t,r=!0){return Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function lr(e,n,t){return tn(e,n,t,!1)}function _a(e,n){for(let t in e){let r=e[t];Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get(){return tn(this,t,r(this))},set(o){tn(this,t,o)}})}return n}function og(e,n,t){Object.defineProperty(e,n,{configurable:!0,get(){return this==null?t:tn(this,n,t.bind(this))},set(r){tn(this,n,r)}})}function ig(e,n){let t=Object.getPrototypeOf(e);return n in t?void 0:t}var Ro,sn=!1,sg={configurable:!0,get(){sn=!0;return}};function U(e,n,t){let r=Object.getPrototypeOf(e._zod);if(n in r&&Ro!==e._zod){Ro=void 0;return}Ro=e._zod,Object.defineProperty(r,n,{configurable:!0,get(){Object.defineProperty(this,n,sg);let o=sn;sn=!1;try{let i=t(this);if(sn)delete this[n];else Object.defineProperty(this,n,{configurable:!0,writable:!0,value:i});return sn=sn||o,i}catch(i){throw delete this[n],sn=sn||o,i}},set(o){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:o})}})}function ag(e,n,t,r){let o=ig(e,n);if(!o)return;Object.defineProperty(o,n,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,n,i),i.value=t(this),Object.defineProperty(this,n,i),i.value},set(i){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var cg="~constantCatch";function ja(e){let n=()=>e;return n[cg]=!0,n}var $a;var To={value:void 0,enumerable:!1},Na="captureStackTrace"in Error?Error:null;function ug(e){let n=Na;if(n){let t=n.stackTraceLimit;if(typeof t==="number"){try{n.stackTraceLimit=0}catch{return Na=null,new e}try{return new e}finally{n.stackTraceLimit=t}}}return new e}function b(e,n,t,r){let o={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function c(m,g){if(!m._zod){To.value=new i(g);try{Object.defineProperty(m,"_zod",To)}finally{To.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),n(m,g),a){let S=Object.getPrototypeOf(m),R=m._zod.constr.prototype,N=S;while(N&&N!==R)N=Object.getPrototypeOf(N);let L=N??S;if(!a.has(L))a.add(L),Pa(L,s)}let h=p.prototype;for(let S in h){if(!Object.prototype.hasOwnProperty.call(h,S))continue;if(!(S in m))m[S]=h[S].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(m){let g=r?.Parent?ug(l):this;c(g,m);let h=g._zod.deferred;if(h){for(let R of h)R();g._zod.deferred=void 0}let S=globalThis.__zod_globalConfig?.postProcessor;if(S)S(g);return g}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Ye extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ut extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($a=globalThis).__zod_globalConfig??($a.__zod_globalConfig={});var Pe=globalThis.__zod_globalConfig;function Ze(e){if(e)Object.assign(Pe,e);return Pe}function lg(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,st,2)),e.message}function dg(e){this._zod.message=e}var pg={get:lg,set:dg,enumerable:!0,configurable:!0},Do={value:void 0,enumerable:!1},Ta=new WeakSet([Object.prototype,Error.prototype]),za=(e,n)=>{e.name="$ZodError",Do.value=n,Object.defineProperty(e,"issues",Do),Do.value=void 0,Object.defineProperty(e,"message",pg);let t=Object.getPrototypeOf(e);if(!Ta.has(t))Ta.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Da=b("$ZodError",za),bx=b("$ZodError",za,void 0,{Parent:Error});function fg(e,n,t){if(!Object.prototype.hasOwnProperty.call(e,n))if(n==="__proto__")Object.defineProperty(e,n,{value:t(),writable:!0,enumerable:!0,configurable:!0});else e[n]=t();return e[n]}function Va(e,n=(t)=>t.message){let t={},r=[];for(let o of e.issues)if(o.path.length>0)fg(t,o.path[0],()=>[]).push(n(o));else r.push(n(o));return{formErrors:r,fieldErrors:t}}function Za(e,n=(t)=>t.message){let t={_errors:[]},r=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)t._errors.push(n(s));else{let c=t,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(n(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(p)m._errors.push(n(s));c=m,u++}}}};return r(e),t}function dr(e,n){return{callee:n?.callee??e,Err:n?.Err}}var pr=(e)=>{let n=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ye;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Qe(u,s,Ze())));throw Po(c,i?.callee??n),c}return a.value};return n};var fr=(e)=>{let n=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Qe(u,s,Ze())));throw Po(c,i?.callee??n),c}return a.value};return n};var mr=(e)=>(n,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new Ye;return i.issues.length?Ma(e,i.issues,o):{success:!0,data:i.value}};function Ma(e,n,t){let r;return{success:!1,get error(){if(!r)r=new e(n.map((o)=>Qe(o,t,Ze()))),n=void 0,t=void 0;return r},set error(o){r=o,n=void 0,t=void 0}}}var gr=(e)=>async(n,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Ma(e,i.issues,o):{success:!0,data:i.value}};var mg=Symbol.for("zod.compile.invalid"),gg=Symbol.for("zod.compile.fallback"),Vo=(e,n,t)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(n)!==mg)return!0;if(r.definite===!0&&t===void 0)return!1}return hg(e,n,t)};function hg(e,n,t){let r=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[gg]=!0,i=o({value:n,issues:[]},r);else i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Ye;return i.issues.length===0}var Zo=async(e,n,t)=>{let r=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:n,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},Fa=(e)=>{let n=pr(e),t=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return n(r,o,a,dr(t,s))};return t};var Ja=(e)=>{let n=pr(e),t=(r,o,i,s)=>n(r,o,i,dr(t,s));return t};var La=(e)=>{let n=fr(e),t=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await n(r,o,a,dr(t,s))};return t};var qa=(e)=>{let n=fr(e),t=async(r,o,i,s)=>await n(r,o,i,dr(t,s));return t};var Ua=(e)=>(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return mr(e)(n,t,o)};var Ka=(e)=>(n,t,r)=>mr(e)(n,t,r);var Ba=(e)=>async(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return gr(e)(n,t,o)};var Ga=(e)=>async(n,t,r)=>gr(e)(n,t,r);var Wa=/^[cC][0-9a-z]{6,}$/,Ha=/^[0-9a-z]+$/,Qa=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ya=/^[0-9a-vA-V]{20}$/,Xa=/^[A-Za-z0-9]{27}$/,ec=/^[a-zA-Z0-9_-]{21}$/;function nc(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var tc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var rc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Fo=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var oc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var yg="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ic(){return new RegExp(yg,"u")}var sc=/^(?:(?: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])$/,ac=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var cc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,uc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pc=/^https?$/,fc=/^\+[1-9]\d{6,14}$/;var mc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function bg(e){return new RegExp(`^${e}$`)}var gc=bg(mc);function Mo(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function hc(e){return new RegExp(`^${Mo(e)}$`)}function yc(e){let n=["Z"];if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let t=`${Mo({precision:e.precision,seconds:!0})}(?:${n.join("|")})`,r=e.local?`${t}|${Mo({precision:e.precision})}`:t;return new RegExp(`^${mc}T(?:${r})$`)}var bc=/^[\s\S]{0,}$/;var Jo=/^-?\d+$/,lt=/^-?\d+(?:\.\d+)?$/,wc=/^(?:true|false)$/i,xc=/^null$/i;var vc=/^[^A-Z]*$/,kc=/^[^a-z]*$/;var we=b("$ZodCheck",(e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])});var Lo=(e)=>{let n=e.value;return!ha(n)&&n.length!==void 0},hr={number:"number",bigint:"bigint",object:"date"},qo=b("$ZodCheckLessThan",(e,n)=>{we.init(e,n);let t=hr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value<=n.value:r.value<n.value)return;r.issues.push({origin:hr[typeof r.value]??t,code:"too_big",maximum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),Uo=b("$ZodCheckGreaterThan",(e,n)=>{we.init(e,n);let t=hr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value>=n.value:r.value>n.value)return;r.issues.push({origin:hr[typeof r.value]??t,code:"too_small",minimum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),Sc=b("$ZodCheckMultipleOf",(e,n)=>{we.init(e,n),e._zod.check=(t)=>{if(typeof t.value!==typeof n.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof t.value==="bigint"?n.value!==BigInt(0)&&t.value%n.value===BigInt(0):ya(t.value,n.value)===0)return;t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}}),Ic=b("$ZodCheckNumberFormat",(e,n)=>{we.init(e,n),n.format=n.format||"float64";let t=n.format?.includes("int"),r=t?"int":"number",[o,i]=sr[n.format];e._zod.check=(s)=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!n.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}});var Ec=b("$ZodCheckMaxLength",(e,n)=>{var t;we.init(e,n),(t=e._zod.def).when??(t.when=Lo),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>n.maximum?cr(o):i)<=n.maximum)return;let a=ur(o);r.issues.push({origin:a,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Cc=b("$ZodCheckMinLength",(e,n)=>{var t;we.init(e,n),(t=e._zod.def).when??(t.when=Lo),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=n.minimum&&i<n.minimum*2?cr(o):i)>=n.minimum)return;let a=ur(o);r.issues.push({origin:a,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Oc=b("$ZodCheckLengthEquals",(e,n)=>{var t;we.init(e,n),(t=e._zod.def).when??(t.when=Lo),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=n.length&&i<=n.length*2?cr(o):i;if(s===n.length)return;let a=ur(o),c=s>n.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!n.abort})}}),pt=b("$ZodCheckStringFormat",(e,n)=>{var t,r;if(we.init(e,n),n.pattern)(t=e._zod).check??(t.check=(o)=>{if(n.pattern.lastIndex=0,n.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:n.format,input:o.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})});else(r=e._zod).check??(r.check=()=>{})}),Rc=b("$ZodCheckRegex",(e,n)=>{pt.init(e,n),e._zod.check=(t)=>{if(n.pattern.lastIndex=0,n.pattern.test(t.value))return;t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}}),Ac=b("$ZodCheckLowerCase",(e,n)=>{n.pattern??(n.pattern=vc),pt.init(e,n)}),Pc=b("$ZodCheckUpperCase",(e,n)=>{n.pattern??(n.pattern=kc),pt.init(e,n)}),_c=b("$ZodCheckIncludes",(e,n)=>{we.init(e,n);let t=an(n.includes),r=new RegExp(typeof n.position==="number"?`^.{${n.position},}${t}`:t);n.pattern=r,e._zod.check=(o)=>{if(o.value.includes(n.includes,n.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:o.value,inst:e,continue:!n.abort})}}),jc=b("$ZodCheckStartsWith",(e,n)=>{we.init(e,n);let t=new RegExp(`^${an(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.startsWith(n.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:r.value,inst:e,continue:!n.abort})}}),$c=b("$ZodCheckEndsWith",(e,n)=>{we.init(e,n);let t=new RegExp(`.*${an(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.endsWith(n.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:r.value,inst:e,continue:!n.abort})}});var Nc=b("$ZodCheckOverwrite",(e,n)=>{we.init(e,n),e._zod.check=(t)=>{t.value=n.tx(t.value)}});class Ko{constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split(`
2
+ var ya="0.1.0-beta.63";var To=["en","zh-CN","zh-TW","ja","ko","ru","fr"],ba="en";var No=new Map(To.map((e)=>[e.toLowerCase(),e])),ig=new Set(["hk","mo","tw"]);function wa(e){return typeof e=="string"&&No.get(e.toLowerCase())==e}function pr(e,n="en"){for(let t of e){let r=t==null?void 0:sg(t);if(r!=null)return r}return n}function sg(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=No.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>ig.has(o))?"zh-TW":"zh-CN"}return No.get(r[0])}function xa(e){return{en:"Imported workflow","zh-CN":"\u5BFC\u5165\u7684\u5DE5\u4F5C\u6D41","zh-TW":"\u532F\u5165\u7684\u5DE5\u4F5C\u6D41",ja:"\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u305F\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",ko:"\uAC00\uC838\uC628 \uC6CC\uD06C\uD50C\uB85C",fr:"Workflow import\xE9",ru:"\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441"}[e]}import{spawn as Ix}from"child_process";import{readFile as Ex}from"fs/promises";import{setTimeout as Cx}from"timers/promises";function dt(e){let n=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,o])=>n.indexOf(+r)===-1).map(([r,o])=>o)}function Do(e,n="|"){return e.map((t)=>Fo(t)).join(n)}function pt(e,n){if(typeof n==="bigint")return n.toString();return n}class ka{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function ft(e){return new ka(e)}function Sa(e){return e===null||e===void 0}function fr(e){let n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}function Ia(e,n){let t=e/n,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);if(Math.abs(t-r)<o)return 0;return t-r}var va=Symbol("evaluating");function Ea(e,n,t){let r=void 0;Object.defineProperty(e,n,{get(){if(r===va)return;if(r===void 0)r=va,r=t();return r},set(o){Object.defineProperty(e,n,{value:o})},configurable:!0})}function De(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function mt(e){let n=Object.getOwnPropertyDescriptor(e,"shape");return n?.get?n.get.raw:n?.value}function nn(e){return mt(e._zod.def)??e._zod.def.shape}function Ca(e,n,t){Object.defineProperty(e,n,{get(){let r=t();return De(this,n,r),r},enumerable:!0,configurable:!0})}function Oa(e,n,t){if(n in e)De(e,n,t);else e[n]=t}function In(e,n,t,r){let o=nn(n);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)Ca(e,i,()=>{let a=n._zod.def.shape[i];return r?r(a,i):a});else Oa(e,i,r?r(s.value,i):s.value)}}function ag(e,n){for(let t of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,t);if(!r.enumerable)continue;if(r.get)Ca(e,t,()=>n[t]);else Oa(e,t,r.value)}}function Ve(...e){let n={};for(let t of e){let r=Object.getOwnPropertyDescriptors(t);Object.assign(n,r)}return Object.defineProperties({},n)}function Ra(e){return JSON.stringify(e)}function Aa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Vo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ja=ft(()=>{if(Pe.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function En(e){if(Vn(e)===!1)return!1;let n=e.constructor;if(n===void 0)return!0;if(typeof n!=="function")return!0;let t=n.prototype;if(Vn(t)===!1)return!1;if(Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)return!1;return!0}function Zo(e){if(En(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Pa=new Set(["string","number","symbol"]);function un(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(e,n,t){let r=new e._zod.constr(n??e._zod.def);if(!n||t?.parent)r._zod.parent=e;return r}function _(e){let n=e;if(!n)return{};if(typeof n==="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");n.error=n.message}if(delete n.message,typeof n.error==="string")return{...n,error:()=>n.error};return n}function Fo(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function _a(e){return Object.keys(e).filter((n)=>e[n]._zod.optin!==void 0&&e[n]._zod.optout==="optional")}var mr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Mo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function cg(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return In(i,e,gr(e,n)),Ge(e,Ve(t,{shape:i,checks:[]}))}function gr(e,n){let t=nn(e),r=[];for(let o of Reflect.ownKeys(n)){if(!Object.getOwnPropertyDescriptor(t,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(n[o])r.push(o)}return r}function ug(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(gr(e,n)),s={};return In(s,e,Reflect.ownKeys(nn(e)).filter((a)=>!i.has(a))),Ge(e,Ve(t,{shape:s,checks:[]}))}function lg(e,n){if(!En(n))throw Error("Invalid input to extend: expected a plain object");let t=e._zod.def.checks;if(t&&t.length>0){let o=nn(e);for(let i of Reflect.ownKeys(n))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ge(e,Ve(e._zod.def,{shape:$a(e,n)}))}function $a(e,n){let t={};return In(t,e,Reflect.ownKeys(nn(e))),ag(t,n),t}function dg(e,n){if(!En(n))throw Error("Invalid input to safeExtend: expected a plain object");return Ge(e,Ve(e._zod.def,{shape:$a(e,n)}))}function pg(e,n){if(!n?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};In(t,e,Reflect.ownKeys(nn(e))),In(t,n,Reflect.ownKeys(nn(n)));let r=Ve(e._zod.def,{shape:t,get catchall(){return n._zod.def.catchall},checks:n._zod.def.checks??[]});return Ge(e,r)}function Na(e,n,t,r="partial"){let i=n._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=t?new Set(gr(n,t)):void 0,c={};return In(c,n,Reflect.ownKeys(nn(n)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Ge(n,Ve(n._zod.def,{shape:c,checks:[]}))}function fg(e,n,t){let r=t?new Set(gr(n,t)):void 0,o={};return In(o,n,Reflect.ownKeys(nn(n)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),Ge(n,Ve(n._zod.def,{shape:o}))}function He(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue!==!0)return!0;return!1}function Ta(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue===!1)return!0;return!1}function ln(e,n){return n.map((t)=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function lt(e){return typeof e==="string"?e:e?.message}function Jo(e,n,t){var r;for(let o=n;o<e.length;o++)(r=e[o]).schema??(r.schema=t)}function Qe(e,n,t){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:lt(e.inst?._zod.def?.error?.(e))??lt(i?.(e))??lt(n?.error?.(e))??lt(t.customError?.(e))??lt(t.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,n?.reportInput)a.input=e.input;return a}var mg=/[\uD800-\uDBFF]/;function hr(e){let n=e.length;if(!mg.test(e))return n;let t=n;for(let r=0;r<n-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)t--,r++;return t}function yr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function za(e){let n=typeof e;switch(n){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return n}function Cn(...e){let[n,t,r]=e;if(typeof n==="string")return{message:n,code:"custom",input:t,inst:r};return{...n}}function Da(e,n){for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);if(r.get)Object.defineProperty(e,t,{...r,enumerable:!1});else gg(e,t,r.value)}}function tn(e,n,t,r=!0){return Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function br(e,n,t){return tn(e,n,t,!1)}function Va(e,n){for(let t in e){let r=e[t];Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get(){return tn(this,t,r(this))},set(o){tn(this,t,o)}})}return n}function gg(e,n,t){Object.defineProperty(e,n,{configurable:!0,get(){return this==null?t:tn(this,n,t.bind(this))},set(r){tn(this,n,r)}})}function hg(e,n){let t=Object.getPrototypeOf(e);return n in t?void 0:t}var zo,cn=!1,yg={configurable:!0,get(){cn=!0;return}};function U(e,n,t){let r=Object.getPrototypeOf(e._zod);if(n in r&&zo!==e._zod){zo=void 0;return}zo=e._zod,Object.defineProperty(r,n,{configurable:!0,get(){Object.defineProperty(this,n,yg);let o=cn;cn=!1;try{let i=t(this);if(cn)delete this[n];else Object.defineProperty(this,n,{configurable:!0,writable:!0,value:i});return cn=cn||o,i}catch(i){throw delete this[n],cn=cn||o,i}},set(o){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:o})}})}function bg(e,n,t,r){let o=hg(e,n);if(!o)return;Object.defineProperty(o,n,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,n,i),i.value=t(this),Object.defineProperty(this,n,i),i.value},set(i){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var wg="~constantCatch";function Za(e){let n=()=>e;return n[wg]=!0,n}var Fa;var Lo={value:void 0,enumerable:!1},Ma="captureStackTrace"in Error?Error:null;function xg(e){let n=Ma;if(n){let t=n.stackTraceLimit;if(typeof t==="number"){try{n.stackTraceLimit=0}catch{return Ma=null,new e}try{return new e}finally{n.stackTraceLimit=t}}}return new e}function b(e,n,t,r){let o={};function i(m){this.def=m,this.constr=d,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function c(m,g){if(!m._zod){Lo.value=new i(g);try{Object.defineProperty(m,"_zod",Lo)}finally{Lo.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),n(m,g),a){let I=Object.getPrototypeOf(m),R=m._zod.constr.prototype,N=I;while(N&&N!==R)N=Object.getPrototypeOf(N);let L=N??I;if(!a.has(L))a.add(L),Da(L,s)}let h=d.prototype;for(let I in h){if(!Object.prototype.hasOwnProperty.call(h,I))continue;if(!(I in m))m[I]=h[I].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(m){let g=r?.Parent?xg(l):this;c(g,m);let h=g._zod.deferred;if(h){for(let R of h)R();g._zod.deferred=void 0}let I=globalThis.__zod_globalConfig?.postProcessor;if(I)I(g);return g}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Ye extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Fa=globalThis).__zod_globalConfig??(Fa.__zod_globalConfig={});var Pe=globalThis.__zod_globalConfig;function Ze(e){if(e)Object.assign(Pe,e);return Pe}function vg(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pt,2)),e.message}function kg(e){this._zod.message=e}var Sg={get:vg,set:kg,enumerable:!0,configurable:!0},Uo={value:void 0,enumerable:!1},Ja=new WeakSet([Object.prototype,Error.prototype]),La=(e,n)=>{e.name="$ZodError",Uo.value=n,Object.defineProperty(e,"issues",Uo),Uo.value=void 0,Object.defineProperty(e,"message",Sg);let t=Object.getPrototypeOf(e);if(!Ja.has(t))Ja.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},qa=b("$ZodError",La),$x=b("$ZodError",La,void 0,{Parent:Error});function Ig(e,n,t){if(!Object.prototype.hasOwnProperty.call(e,n))if(n==="__proto__")Object.defineProperty(e,n,{value:t(),writable:!0,enumerable:!0,configurable:!0});else e[n]=t();return e[n]}function Ua(e,n=(t)=>t.message){let t={},r=[];for(let o of e.issues)if(o.path.length>0)Ig(t,o.path[0],()=>[]).push(n(o));else r.push(n(o));return{formErrors:r,fieldErrors:t}}function Ka(e,n=(t)=>t.message){let t={_errors:[]},r=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)t._errors.push(n(s));else{let c=t,u=0;while(u<a.length){let l=a[u],d=u===a.length-1;if(l==="_errors"){if(d)c._errors.push(n(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(d)m._errors.push(n(s));c=m,u++}}}};return r(e),t}function wr(e,n){return{callee:n?.callee??e,Err:n?.Err}}var xr=(e)=>{let n=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ye;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Qe(u,s,Ze())));throw Vo(c,i?.callee??n),c}return a.value};return n};var vr=(e)=>{let n=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Qe(u,s,Ze())));throw Vo(c,i?.callee??n),c}return a.value};return n};var kr=(e)=>(n,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new Ye;return i.issues.length?Ba(e,i.issues,o):{success:!0,data:i.value}};function Ba(e,n,t){let r;return{success:!1,get error(){if(!r)r=new e(n.map((o)=>Qe(o,t,Ze()))),n=void 0,t=void 0;return r},set error(o){r=o,n=void 0,t=void 0}}}var Sr=(e)=>async(n,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Ba(e,i.issues,o):{success:!0,data:i.value}};var Eg=Symbol.for("zod.compile.invalid"),Cg=Symbol.for("zod.compile.fallback"),Ko=(e,n,t)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(n)!==Eg)return!0;if(r.definite===!0&&t===void 0)return!1}return Og(e,n,t)};function Og(e,n,t){let r=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[Cg]=!0,i=o({value:n,issues:[]},r);else i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Ye;return i.issues.length===0}var Bo=async(e,n,t)=>{let r=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:n,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},Wa=(e)=>{let n=xr(e),t=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return n(r,o,a,wr(t,s))};return t};var Ga=(e)=>{let n=xr(e),t=(r,o,i,s)=>n(r,o,i,wr(t,s));return t};var Ha=(e)=>{let n=vr(e),t=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await n(r,o,a,wr(t,s))};return t};var Qa=(e)=>{let n=vr(e),t=async(r,o,i,s)=>await n(r,o,i,wr(t,s));return t};var Ya=(e)=>(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return kr(e)(n,t,o)};var Xa=(e)=>(n,t,r)=>kr(e)(n,t,r);var ec=(e)=>async(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Sr(e)(n,t,o)};var nc=(e)=>async(n,t,r)=>Sr(e)(n,t,r);var tc=/^[cC][0-9a-z]{6,}$/,rc=/^[0-9a-z]+$/,oc=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ic=/^[0-9a-vA-V]{20}$/,sc=/^[A-Za-z0-9]{27}$/,ac=/^[a-zA-Z0-9_-]{21}$/;function cc(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var uc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var lc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Go=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var dc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Rg="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function pc(){return new RegExp(Rg,"u")}var fc=/^(?:(?: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])$/,mc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var gc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var wc=/^https?$/,xc=/^\+[1-9]\d{6,14}$/;var vc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Ag(e){return new RegExp(`^${e}$`)}var kc=Ag(vc);function Wo(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Sc(e){return new RegExp(`^${Wo(e)}$`)}function Ic(e){let n=["Z"];if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let t=`${Wo({precision:e.precision,seconds:!0})}(?:${n.join("|")})`,r=e.local?`${t}|${Wo({precision:e.precision})}`:t;return new RegExp(`^${vc}T(?:${r})$`)}var Ec=/^[\s\S]{0,}$/;var Ho=/^-?\d+$/,ht=/^-?\d+(?:\.\d+)?$/,Cc=/^(?:true|false)$/i,Oc=/^null$/i;var Rc=/^[^A-Z]*$/,Ac=/^[^a-z]*$/;var ve=b("$ZodCheck",(e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])});var Qo=(e)=>{let n=e.value;return!Sa(n)&&n.length!==void 0},Ir={number:"number",bigint:"bigint",object:"date"},Yo=b("$ZodCheckLessThan",(e,n)=>{ve.init(e,n);let t=Ir[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value<=n.value:r.value<n.value)return;r.issues.push({origin:Ir[typeof r.value]??t,code:"too_big",maximum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),Xo=b("$ZodCheckGreaterThan",(e,n)=>{ve.init(e,n);let t=Ir[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value>=n.value:r.value>n.value)return;r.issues.push({origin:Ir[typeof r.value]??t,code:"too_small",minimum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),jc=b("$ZodCheckMultipleOf",(e,n)=>{ve.init(e,n),e._zod.check=(t)=>{if(typeof t.value!==typeof n.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof t.value==="bigint"?n.value!==BigInt(0)&&t.value%n.value===BigInt(0):Ia(t.value,n.value)===0)return;t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}}),Pc=b("$ZodCheckNumberFormat",(e,n)=>{ve.init(e,n),n.format=n.format||"float64";let t=n.format?.includes("int"),r=t?"int":"number",[o,i]=mr[n.format];e._zod.check=(s)=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!n.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}});var _c=b("$ZodCheckMaxLength",(e,n)=>{var t;ve.init(e,n),(t=e._zod.def).when??(t.when=Qo),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>n.maximum?hr(o):i)<=n.maximum)return;let a=yr(o);r.issues.push({origin:a,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),$c=b("$ZodCheckMinLength",(e,n)=>{var t;ve.init(e,n),(t=e._zod.def).when??(t.when=Qo),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=n.minimum&&i<n.minimum*2?hr(o):i)>=n.minimum)return;let a=yr(o);r.issues.push({origin:a,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Nc=b("$ZodCheckLengthEquals",(e,n)=>{var t;ve.init(e,n),(t=e._zod.def).when??(t.when=Qo),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=n.length&&i<=n.length*2?hr(o):i;if(s===n.length)return;let a=yr(o),c=s>n.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!n.abort})}}),bt=b("$ZodCheckStringFormat",(e,n)=>{var t,r;if(ve.init(e,n),n.pattern)(t=e._zod).check??(t.check=(o)=>{if(n.pattern.lastIndex=0,n.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:n.format,input:o.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})});else(r=e._zod).check??(r.check=()=>{})}),Tc=b("$ZodCheckRegex",(e,n)=>{bt.init(e,n),e._zod.check=(t)=>{if(n.pattern.lastIndex=0,n.pattern.test(t.value))return;t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}}),zc=b("$ZodCheckLowerCase",(e,n)=>{n.pattern??(n.pattern=Rc),bt.init(e,n)}),Dc=b("$ZodCheckUpperCase",(e,n)=>{n.pattern??(n.pattern=Ac),bt.init(e,n)}),Vc=b("$ZodCheckIncludes",(e,n)=>{ve.init(e,n);let t=un(n.includes),r=new RegExp(typeof n.position==="number"?`^.{${n.position},}${t}`:t);n.pattern=r,e._zod.check=(o)=>{if(o.value.includes(n.includes,n.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:o.value,inst:e,continue:!n.abort})}}),Zc=b("$ZodCheckStartsWith",(e,n)=>{ve.init(e,n);let t=new RegExp(`^${un(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.startsWith(n.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:r.value,inst:e,continue:!n.abort})}}),Fc=b("$ZodCheckEndsWith",(e,n)=>{ve.init(e,n);let t=new RegExp(`.*${un(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.endsWith(n.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:r.value,inst:e,continue:!n.abort})}});var Mc=b("$ZodCheckOverwrite",(e,n)=>{ve.init(e,n),e._zod.check=(t)=>{t.value=n.tx(t.value)}});class ei{constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split(`
3
3
  `).filter((i)=>i),r=Math.min(...t.map((i)=>i.length-i.trimStart().length)),o=t.map((i)=>i.slice(r)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,n=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
4
  ${n.join(`
5
5
  `)}
6
- };`)(...Object.values(this.closed))}}var zc={major:4,minor:6,patch:5};var te=b("$ZodType",(e,n)=>{var t;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=zc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=He(a),p;for(let m of c){if(m._zod.def.when){if(Ra(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let g=a.issues.length,h=m._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new Ye;if(p||h instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await h,a.issues.length===g)return;if(No(a.issues,g,e),!l)l=He(a,g)});else{if(a.issues.length===g)continue;if(No(a.issues,g,e),!l)l=He(a,g)}}if(p)return p.then(()=>a);return a},s=(a,c,u)=>{if(He(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Ye;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ye;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return lr(this,"~standard",Go(this))},set "~standard"(e){tn(this,"~standard",e)}}),Bc=(e,n)=>e.issues.length?{issues:e.issues.map((t)=>Qe(t,n,Ze()))}:{value:e.value};async function wg(e,n){let t={async:!0};return Bc(await e._zod.run({value:n,issues:[]},t),t)}function Go(e){return{validate:(n)=>{let t={async:!1};try{let r=e._zod.run({value:n,issues:[]},t);if(!(r instanceof Promise))return Bc(r,t)}catch(r){}return wg(e,n)},vendor:"zod",version:1}}var xr=b("$ZodString",(e,n)=>{te.init(e,n),e._zod.pattern=n.pattern??bc,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=String(t.value)}catch(o){}if(typeof t.value==="string")return t;return t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}}),ie=b("$ZodStringFormat",(e,n)=>{pt.init(e,n),xr.init(e,n)}),Gc=b("$ZodGUID",(e,n)=>{n.pattern??(n.pattern=rc),ie.init(e,n)}),Wc=b("$ZodUUID",(e,n)=>{if(n.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(r===void 0)throw Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=Fo(r))}else n.pattern??(n.pattern=Fo());ie.init(e,n)}),Hc=b("$ZodEmail",(e,n)=>{n.pattern??(n.pattern=oc),ie.init(e,n)}),Qc=1,br=2;function Yc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function xg(e,n){if(!("normalize"in n)&&!("hostname"in n)&&!("protocol"in n))return Yc(e)||br;return vg(e,n)}function vg(e,n){if(!n.normalize&&n.protocol?.source===pc.source&&!/^https?:\/\//i.test(e))return Qc;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse==="function")return t.parse(e)??br}return new URL(e)}catch{return br}}var kg=/[\t\n\r]/g;function Dc(e){return e.replace(kg,"")}function Sg(e,n){return n.lastIndex=0,n.test(e.hostname)}function Ig(e,n){return n.lastIndex=0,n.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Xc=b("$ZodURL",(e,n)=>{ie.init(e,n),e._zod.check=(t)=>{try{let r=t.value.trim(),o=xg(r,n);if(o===Qc){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:e,continue:!n.abort});return}if(o===br){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort});return}if(o===!0){t.value=Dc(r);return}if(n.hostname&&!Sg(o,n.hostname))t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort});if(n.protocol&&!Ig(o,n.protocol))t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort});t.value=n.normalize?o.href:Dc(r);return}catch(r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}}),eu=b("$ZodEmoji",(e,n)=>{n.pattern??(n.pattern=ic()),ie.init(e,n)}),nu=b("$ZodNanoID",(e,n)=>{if(n.length!==void 0&&(!Number.isInteger(n.length)||n.length<1))throw Error(`Invalid nanoid length: ${n.length}`);n.pattern??(n.pattern=n.length===void 0?ec:nc(n.length)),ie.init(e,n)}),tu=b("$ZodCUID",(e,n)=>{n.pattern??(n.pattern=Wa),ie.init(e,n)}),ru=b("$ZodCUID2",(e,n)=>{n.pattern??(n.pattern=Ha),ie.init(e,n)}),ou=b("$ZodULID",(e,n)=>{n.pattern??(n.pattern=Qa),ie.init(e,n)}),iu=b("$ZodXID",(e,n)=>{n.pattern??(n.pattern=Ya),ie.init(e,n)}),su=b("$ZodKSUID",(e,n)=>{n.pattern??(n.pattern=Xa),ie.init(e,n)}),au=b("$ZodISODateTime",(e,n)=>{n.pattern??(n.pattern=yc(n)),ie.init(e,n)}),cu=b("$ZodISODate",(e,n)=>{n.pattern??(n.pattern=gc),ie.init(e,n)}),uu=b("$ZodISOTime",(e,n)=>{n.pattern??(n.pattern=hc(n)),ie.init(e,n)}),lu=b("$ZodISODuration",(e,n)=>{n.pattern??(n.pattern=tc),ie.init(e,n)}),du=b("$ZodIPv4",(e,n)=>{n.pattern??(n.pattern=sc),ie.init(e,n)}),Eg=/^[0-9a-fA-F:.]+$/;function pu(e){if(!Eg.test(e))return!1;return Yc(`http://[${e}]`)}var fu=b("$ZodIPv6",(e,n)=>{n.pattern??(n.pattern=ac),ie.init(e,n),e._zod.check=(t)=>{if(!pu(t.value))t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}});var mu=b("$ZodCIDRv4",(e,n)=>{n.pattern??(n.pattern=cc),ie.init(e,n)});function Cg(e){let n=e.split("/");if(n.length!==2)return!1;let[t,r]=n;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return pu(t)}var gu=b("$ZodCIDRv6",(e,n)=>{n.pattern??(n.pattern=uc),ie.init(e,n),e._zod.check=(t)=>{if(!Cg(t.value))t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}});function hu(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Wo=/^[0-9a-zA-Z+/]*={0,2}$/,yu=b("$ZodBase64",(e,n)=>{n.pattern??(n.pattern=Wo),ie.init(e,n),e._zod.check=(t)=>{if(hu(t.value))return;t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}),vr=/^[A-Za-z0-9_-]*$/;function Og(e){if(!vr.test(e))return!1;let n=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),t=n.padEnd(Math.ceil(n.length/4)*4,"=");return hu(t)}var bu=b("$ZodBase64URL",(e,n)=>{n.pattern??(n.pattern=vr),ie.init(e,n),e._zod.check=(t)=>{if(Og(t.value))return;t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}}),wu=b("$ZodE164",(e,n)=>{n.pattern??(n.pattern=fc),ie.init(e,n)});function Rg(e,n=null){try{let t=e.split(".");if(t.length!==3)return!1;let[r]=t;if(!r)return!1;let o=JSON.parse(atob(r));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(n&&(!("alg"in o)||o.alg!==n))return!1;return!0}catch{return!1}}var xu=b("$ZodJWT",(e,n)=>{ie.init(e,n),e._zod.check=(t)=>{if(Rg(t.value,n.alg))return;t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}});var Ho=b("$ZodNumber",(e,n)=>{te.init(e,n),e._zod.pattern=lt,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Number(t.value)}catch(s){}let o=t.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),t}}),vu=b("$ZodNumberFormat",(e,n)=>{Ic.init(e,n),Ho.init(e,n)}),ku=b("$ZodBoolean",(e,n)=>{te.init(e,n),e._zod.pattern=wc,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(i){}let o=t.value;if(typeof o==="boolean")return t;return t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),t}});var Su=b("$ZodNull",(e,n)=>{te.init(e,n),e._zod.pattern=xc,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let o=t.value;if(o===null)return t;return t.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),t}});var Iu=b("$ZodUnknown",(e,n)=>{te.init(e,n),e._zod.parse=(t)=>t}),Eu=b("$ZodNever",(e,n)=>{te.init(e,n),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Vc(e,n,t){if(e.issues.length)n.issues.push(...cn(t,e.issues));n.value[t]=e.value}var Cu=b("$ZodArray",(e,n)=>{te.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=t?t.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=n.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Vc(p,r,c)));else if(Vc(l,r,c),a&&l.issues.length!==0&&He(l))break}if(s.length)return Promise.all(s).then(()=>r);return r}});function wr(e,n,t,r,o,i){let s=t in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;n.issues.push(...cn(t,e.issues))}if(!s&&o===void 0){if(!e.issues.length)n.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)n.value[t]=void 0}else n.value[t]=e.value}var Ag=[];function Ou(e){let n=Object.keys(e.shape),t=Object.getOwnPropertySymbols(e.shape),r=t.length?t:Ag,o=r.length?[...n,...r]:n;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Ea(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(i)}}function Ru(e,n,t,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:m}=u,g=0;for(let h in n){if(s&&t.issues.length!==g){if(He(t,g))break;g=t.issues.length}if(c.has(h))continue;if(h==="__proto__"){if(l==="never")a.push(h);continue}if(l==="never"){a.push(h);continue}let S=u.run({value:n[h],issues:[]},r);if(S instanceof Promise)e.push(S.then((R)=>wr(R,t,h,n,p,m)));else wr(S,t,h,n,p,m)}if(a.length)t.issues.push({code:"unrecognized_keys",keys:a,input:n,inst:i,continue:!0});if(!e.length)return t;return Promise.all(e).then(()=>t)}var Pg=b("$ZodObject",(e,n)=>{te.init(e,n);let t=Object.getOwnPropertyDescriptor(n,"shape"),r=t?.get?t.get.raw:n.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(n,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(n,"shape",{get:u})}let o=at(()=>Ou(n));U(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let m in l){let g=l[m]._zod;if(g.values){if(!Object.prototype.hasOwnProperty.call(p,m))De(p,m,new Set);for(let h of g.values)p[m].add(h);if(g.optin!==void 0)p[m].add(void 0)}}return p});let i=zn,s=n.catchall,a,c=Pe.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],g=a.shape,h=l?.abortEarly,S=u.issues.length;for(let R of a.allKeys){if(h&&u.issues.length!==S){if(He(u,S))break;S=u.issues.length}if(R==="__proto__")continue;let N=g[R],L=N._zod.optin,K=N._zod.optout,Te=N._zod.run({value:p[R],issues:[]},l);if(Te instanceof Promise)m.push(Te.then((ue)=>wr(ue,u,R,p,L,K)));else wr(Te,u,R,p,L,K)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Ru(m,p,u,l,o.value,e,h===!0)}}),Au=b("$ZodObjectJIT",(e,n)=>{Pg.init(e,n);let t=e._zod.parse,r=at(()=>Ou(n)),o=Pe.memoizer,i=(g)=>{let h=r.value,S=h.symbolKeys,R=new Ko(["payload","ctx"],{shape:g,inst:e,memo:o,syms:S}),N=(ue)=>`shape[${ue}]._zod.run({ value: input[${ue}], issues: [] }, ctx)`,L=(ue,H)=>`
7
- let ${ue}_ab = false;
8
- for (let i = 0; i < ${ue}.issues.length; i++) {
9
- const iss = ${ue}.issues[i];
6
+ };`)(...Object.values(this.closed))}}var Lc={major:4,minor:6,patch:5};var te=b("$ZodType",(e,n)=>{var t;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Lc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=He(a),d;for(let m of c){if(m._zod.def.when){if(Ta(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let g=a.issues.length,h=m._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new Ye;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await h,a.issues.length===g)return;if(Jo(a.issues,g,e),!l)l=He(a,g)});else{if(a.issues.length===g)continue;if(Jo(a.issues,g,e),!l)l=He(a,g)}}if(d)return d.then(()=>a);return a},s=(a,c,u)=>{if(He(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Ye;return l.then((d)=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((d)=>s(d,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ye;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return br(this,"~standard",ti(this))},set "~standard"(e){tn(this,"~standard",e)}}),eu=(e,n)=>e.issues.length?{issues:e.issues.map((t)=>Qe(t,n,Ze()))}:{value:e.value};async function jg(e,n){let t={async:!0};return eu(await e._zod.run({value:n,issues:[]},t),t)}function ti(e){return{validate:(n)=>{let t={async:!1};try{let r=e._zod.run({value:n,issues:[]},t);if(!(r instanceof Promise))return eu(r,t)}catch(r){}return jg(e,n)},vendor:"zod",version:1}}var Rr=b("$ZodString",(e,n)=>{te.init(e,n),e._zod.pattern=n.pattern??Ec,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=String(t.value)}catch(o){}if(typeof t.value==="string")return t;return t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}}),ae=b("$ZodStringFormat",(e,n)=>{bt.init(e,n),Rr.init(e,n)}),nu=b("$ZodGUID",(e,n)=>{n.pattern??(n.pattern=lc),ae.init(e,n)}),tu=b("$ZodUUID",(e,n)=>{if(n.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(r===void 0)throw Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=Go(r))}else n.pattern??(n.pattern=Go());ae.init(e,n)}),ru=b("$ZodEmail",(e,n)=>{n.pattern??(n.pattern=dc),ae.init(e,n)}),ou=1,Cr=2;function iu(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Pg(e,n){if(!("normalize"in n)&&!("hostname"in n)&&!("protocol"in n))return iu(e)||Cr;return _g(e,n)}function _g(e,n){if(!n.normalize&&n.protocol?.source===wc.source&&!/^https?:\/\//i.test(e))return ou;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse==="function")return t.parse(e)??Cr}return new URL(e)}catch{return Cr}}var $g=/[\t\n\r]/g;function qc(e){return e.replace($g,"")}function Ng(e,n){return n.lastIndex=0,n.test(e.hostname)}function Tg(e,n){return n.lastIndex=0,n.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var su=b("$ZodURL",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{try{let r=t.value.trim(),o=Pg(r,n);if(o===ou){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:e,continue:!n.abort});return}if(o===Cr){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort});return}if(o===!0){t.value=qc(r);return}if(n.hostname&&!Ng(o,n.hostname))t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort});if(n.protocol&&!Tg(o,n.protocol))t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort});t.value=n.normalize?o.href:qc(r);return}catch(r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}}),au=b("$ZodEmoji",(e,n)=>{n.pattern??(n.pattern=pc()),ae.init(e,n)}),cu=b("$ZodNanoID",(e,n)=>{if(n.length!==void 0&&(!Number.isInteger(n.length)||n.length<1))throw Error(`Invalid nanoid length: ${n.length}`);n.pattern??(n.pattern=n.length===void 0?ac:cc(n.length)),ae.init(e,n)}),uu=b("$ZodCUID",(e,n)=>{n.pattern??(n.pattern=tc),ae.init(e,n)}),lu=b("$ZodCUID2",(e,n)=>{n.pattern??(n.pattern=rc),ae.init(e,n)}),du=b("$ZodULID",(e,n)=>{n.pattern??(n.pattern=oc),ae.init(e,n)}),pu=b("$ZodXID",(e,n)=>{n.pattern??(n.pattern=ic),ae.init(e,n)}),fu=b("$ZodKSUID",(e,n)=>{n.pattern??(n.pattern=sc),ae.init(e,n)}),mu=b("$ZodISODateTime",(e,n)=>{n.pattern??(n.pattern=Ic(n)),ae.init(e,n)}),gu=b("$ZodISODate",(e,n)=>{n.pattern??(n.pattern=kc),ae.init(e,n)}),hu=b("$ZodISOTime",(e,n)=>{n.pattern??(n.pattern=Sc(n)),ae.init(e,n)}),yu=b("$ZodISODuration",(e,n)=>{n.pattern??(n.pattern=uc),ae.init(e,n)}),bu=b("$ZodIPv4",(e,n)=>{n.pattern??(n.pattern=fc),ae.init(e,n)}),zg=/^[0-9a-fA-F:.]+$/;function wu(e){if(!zg.test(e))return!1;return iu(`http://[${e}]`)}var xu=b("$ZodIPv6",(e,n)=>{n.pattern??(n.pattern=mc),ae.init(e,n),e._zod.check=(t)=>{if(!wu(t.value))t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}});var vu=b("$ZodCIDRv4",(e,n)=>{n.pattern??(n.pattern=gc),ae.init(e,n)});function Dg(e){let n=e.split("/");if(n.length!==2)return!1;let[t,r]=n;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return wu(t)}var ku=b("$ZodCIDRv6",(e,n)=>{n.pattern??(n.pattern=hc),ae.init(e,n),e._zod.check=(t)=>{if(!Dg(t.value))t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}});function Su(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ri=/^[0-9a-zA-Z+/]*={0,2}$/,Iu=b("$ZodBase64",(e,n)=>{n.pattern??(n.pattern=ri),ae.init(e,n),e._zod.check=(t)=>{if(Su(t.value))return;t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}),Ar=/^[A-Za-z0-9_-]*$/;function Vg(e){if(!Ar.test(e))return!1;let n=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),t=n.padEnd(Math.ceil(n.length/4)*4,"=");return Su(t)}var Eu=b("$ZodBase64URL",(e,n)=>{n.pattern??(n.pattern=Ar),ae.init(e,n),e._zod.check=(t)=>{if(Vg(t.value))return;t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}}),Cu=b("$ZodE164",(e,n)=>{n.pattern??(n.pattern=xc),ae.init(e,n)});function Zg(e,n=null){try{let t=e.split(".");if(t.length!==3)return!1;let[r]=t;if(!r)return!1;let o=JSON.parse(atob(r));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(n&&(!("alg"in o)||o.alg!==n))return!1;return!0}catch{return!1}}var Ou=b("$ZodJWT",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{if(Zg(t.value,n.alg))return;t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}});var oi=b("$ZodNumber",(e,n)=>{te.init(e,n),e._zod.pattern=ht,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Number(t.value)}catch(s){}let o=t.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),t}}),Ru=b("$ZodNumberFormat",(e,n)=>{Pc.init(e,n),oi.init(e,n)}),Au=b("$ZodBoolean",(e,n)=>{te.init(e,n),e._zod.pattern=Cc,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(i){}let o=t.value;if(typeof o==="boolean")return t;return t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),t}});var ju=b("$ZodNull",(e,n)=>{te.init(e,n),e._zod.pattern=Oc,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let o=t.value;if(o===null)return t;return t.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),t}});var Pu=b("$ZodUnknown",(e,n)=>{te.init(e,n),e._zod.parse=(t)=>t}),_u=b("$ZodNever",(e,n)=>{te.init(e,n),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Uc(e,n,t){if(e.issues.length)n.issues.push(...ln(t,e.issues));n.value[t]=e.value}var $u=b("$ZodArray",(e,n)=>{te.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=t?t.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=n.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((d)=>Uc(d,r,c)));else if(Uc(l,r,c),a&&l.issues.length!==0&&He(l))break}if(s.length)return Promise.all(s).then(()=>r);return r}});function Or(e,n,t,r,o,i){let s=t in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;n.issues.push(...ln(t,e.issues))}if(!s&&o===void 0){if(!e.issues.length)n.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)n.value[t]=void 0}else n.value[t]=e.value}var Fg=[];function Nu(e){let n=Object.keys(e.shape),t=Object.getOwnPropertySymbols(e.shape),r=t.length?t:Fg,o=r.length?[...n,...r]:n;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=_a(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(i)}}function Tu(e,n,t,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:d,optout:m}=u,g=0;for(let h in n){if(s&&t.issues.length!==g){if(He(t,g))break;g=t.issues.length}if(c.has(h))continue;if(h==="__proto__"){if(l==="never")a.push(h);continue}if(l==="never"){a.push(h);continue}let I=u.run({value:n[h],issues:[]},r);if(I instanceof Promise)e.push(I.then((R)=>Or(R,t,h,n,d,m)));else Or(I,t,h,n,d,m)}if(a.length)t.issues.push({code:"unrecognized_keys",keys:a,input:n,inst:i,continue:!0});if(!e.length)return t;return Promise.all(e).then(()=>t)}var Mg=b("$ZodObject",(e,n)=>{te.init(e,n);let t=Object.getOwnPropertyDescriptor(n,"shape"),r=t?.get?t.get.raw:n.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(n,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(n,"shape",{get:u})}let o=ft(()=>Nu(n));U(e,"propValues",(u)=>{let l=u.def.shape,d={};for(let m in l){let g=l[m]._zod;if(g.values){if(!Object.prototype.hasOwnProperty.call(d,m))De(d,m,new Set);for(let h of g.values)d[m].add(h);if(g.optin!==void 0)d[m].add(void 0)}}return d});let i=Vn,s=n.catchall,a,c=Pe.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],g=a.shape,h=l?.abortEarly,I=u.issues.length;for(let R of a.allKeys){if(h&&u.issues.length!==I){if(He(u,I))break;I=u.issues.length}if(R==="__proto__")continue;let N=g[R],L=N._zod.optin,K=N._zod.optout,ze=N._zod.run({value:d[R],issues:[]},l);if(ze instanceof Promise)m.push(ze.then((le)=>Or(le,u,R,d,L,K)));else Or(ze,u,R,d,L,K)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Tu(m,d,u,l,o.value,e,h===!0)}}),zu=b("$ZodObjectJIT",(e,n)=>{Mg.init(e,n);let t=e._zod.parse,r=ft(()=>Nu(n)),o=Pe.memoizer,i=(g)=>{let h=r.value,I=h.symbolKeys,R=new ei(["payload","ctx"],{shape:g,inst:e,memo:o,syms:I}),N=(le)=>`shape[${le}]._zod.run({ value: input[${le}], issues: [] }, ctx)`,L=(le,H)=>`
7
+ let ${le}_ab = false;
8
+ for (let i = 0; i < ${le}.issues.length; i++) {
9
+ const iss = ${le}.issues[i];
10
10
  iss.path = iss.path ? [${H}, ...iss.path] : [${H}];
11
11
  payload.issues.push(iss);
12
- if (iss.continue !== true) ${ue}_ab = true;
12
+ if (iss.continue !== true) ${le}_ab = true;
13
13
  }
14
- if (${ue}_ab && ctx && ctx.abortEarly) {
14
+ if (${le}_ab && ctx && ctx.abortEarly) {
15
15
  payload.value = newResult;
16
16
  return payload;
17
- }`;R.write("const input = payload.value;");let K=Object.create(null),Te=0;for(let ue of h.allKeys)K[ue]=`key_${Te++}`;R.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let ue of h.allKeys){if(ue==="__proto__")continue;let H=K[ue],Ae=typeof ue==="symbol"?`syms[${S.indexOf(ue)}]`:va(ue),jn=`${Ae} in input`,$n=g[ue],Nn=$n?._zod?.optin,Tn=Nn!==void 0,nt=$n?._zod?.optout==="optional";if(R.write(`const ${H} = ${N(Ae)};`),Tn&&nt){let nr=Nn==="optional"?`${H}_present`:`${H}.value !== undefined || ${H}_present`;R.write(`
18
- const ${H}_present = ${jn};
17
+ }`;R.write("const input = payload.value;");let K=Object.create(null),ze=0;for(let le of h.allKeys)K[le]=`key_${ze++}`;R.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let le of h.allKeys){if(le==="__proto__")continue;let H=K[le],je=typeof le==="symbol"?`syms[${I.indexOf(le)}]`:Ra(le),Nn=`${je} in input`,Tn=g[le],zn=Tn?._zod?.optin,Dn=zn!==void 0,at=Tn?._zod?.optout==="optional";if(R.write(`const ${H} = ${N(je)};`),Dn&&at){let ur=zn==="optional"?`${H}_present`:`${H}.value !== undefined || ${H}_present`;R.write(`
18
+ const ${H}_present = ${Nn};
19
19
  if (!${H}.issues.length || ${H}_present) {
20
- if (${H}.issues.length) {${L(H,Ae)}
20
+ if (${H}.issues.length) {${L(H,je)}
21
21
  }
22
22
 
23
- if (${nr}) {
24
- newResult[${Ae}] = ${H}.value;
23
+ if (${ur}) {
24
+ newResult[${je}] = ${H}.value;
25
25
  }
26
26
  }
27
27
 
28
- `)}else if(!Tn)R.write(`
29
- const ${H}_present = ${jn};
30
- if (${H}.issues.length) {${L(H,Ae)}
28
+ `)}else if(!Dn)R.write(`
29
+ const ${H}_present = ${Nn};
30
+ if (${H}.issues.length) {${L(H,je)}
31
31
  }
32
32
  if (!${H}_present && !${H}.issues.length) {
33
33
  payload.issues.push({
34
34
  code: "invalid_type",
35
35
  expected: "nonoptional",
36
36
  input: undefined,
37
- path: [${Ae}]
37
+ path: [${je}]
38
38
  });
39
39
  if (ctx && ctx.abortEarly) {
40
40
  payload.value = newResult;
@@ -43,42 +43,43 @@ ${n.join(`
43
43
  }
44
44
 
45
45
  if (${H}_present) {
46
- newResult[${Ae}] = ${H}.value;
46
+ newResult[${je}] = ${H}.value;
47
47
  }
48
48
 
49
49
  `);else if(R.write(`
50
- if (${H}.issues.length) {${L(H,Ae)}
50
+ if (${H}.issues.length) {${L(H,je)}
51
51
  }
52
- `),Nn==="defaulted")R.write(`newResult[${Ae}] = ${H}.value;`);else R.write(`
53
- if (${H}.value !== undefined || ${jn}) {
54
- newResult[${Ae}] = ${H}.value;
52
+ `),zn==="defaulted")R.write(`newResult[${je}] = ${H}.value;`);else R.write(`
53
+ if (${H}.value !== undefined || ${Nn}) {
54
+ newResult[${je}] = ${H}.value;
55
55
  }
56
- `)}return R.write("payload.value = newResult;"),R.write("return payload;"),R.compile()},s,a=zn,c=!Pe.jitless,l=c&&Sa.value,p=n.catchall,m;e._zod.parse=(g,h)=>{m??(m=r.value);let S=g.value;if(!a(S))return g.issues.push({expected:"object",code:"invalid_type",input:S,inst:e}),g;if(c&&l&&h?.async===!1&&h.jitless!==!0){if(!s)s=i(n.shape);if(g=s(g,h),!p)return g;return Ru([],S,g,h,m,e,h?.abortEarly===!0)}return t(g,h)}});function Zc(e,n,t,r){for(let i of e)if(i.issues.length===0)return n.value=i.value,n;let o=e.filter((i)=>!He(i));if(o.length===1)return n.value=o[0].value,o[0];return n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((i)=>i.issues.map((s)=>Qe(s,r,Ze())))}),n}var Qo=b("$ZodUnion",(e,n)=>{te.init(e,n),U(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),U(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),U(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),U(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>ir(i.source)).join("|")})$`)}return});let t=n.options.length===1?n.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of n.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Zc(s,r,e,o);return Promise.all(s).then((a)=>Zc(a,r,e,o))}});function _g(e){let n=new Map;for(let t of e.options){let r=t._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(t)}"`);for(let o of r)if(n.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);n.set(o,null)}else n.set(o,t)}return n}var Pu=b("$ZodDiscriminatedUnion",(e,n)=>{n.inclusive=!1,Qo.init(e,n);let t=e._zod.parse;U(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))De(i,u,new Set);for(let p of l)i[u].add(p)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),n.options.forEach((o,i)=>{let s=ct(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,n.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=at(()=>_g(n));e._zod.parse=(o,i)=>{let s=o.value;if(!zn(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[n.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(n.unionFallback||i.direction==="backward")return t(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[n.discriminator],inst:e}),o}}),_u=b("$ZodIntersection",(e,n)=>{te.init(e,n),e._zod.parse=(t,r)=>{let o=t.value,i=n.left._zod.run({value:o,issues:[]},r),s=n.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Mc(t,c,u));return Mc(t,i,s)}});function Bo(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e===+n)return{valid:!0,data:e};if(kn(e)&&kn(n)){let t=Object.keys(n),r=Object.keys(e).filter((i)=>t.indexOf(i)!==-1),o={...e,...n};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=Bo(e[i],n[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n[r],s=Bo(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};t.push(s.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Mc(e,n,t){let r=new Map,o,i=new Map,s=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);p=[m]}else return!1;for(let m of p){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of n.issues)if(!s(u,"l"))e.issues.push(u);for(let u of t.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=Bo(n.value,t.value);if(!c.valid){if(He(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var ju=b("$ZodRecord",(e,n)=>{te.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!kn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=n.keyType._zod.values;if(a&&!n.partial){r.value=t?t.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=n.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((h)=>Qe(h,o,Ze())),input:l,path:[l],inst:e});continue}let m=p.value;if(m==="__proto__")continue;let g=n.valueType._zod.run({value:i[l],issues:[]},o);if(g instanceof Promise)s.push(g.then((h)=>{if(h.issues.length)r.issues.push(...cn(l,h.issues));r.value[m]=h.value}));else{if(g.issues.length)r.issues.push(...cn(l,g.issues));r.value[m]=g.value}}let u;for(let l in i)if(!c.has(l))if(n.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=t?t.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=n.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&lt.test(u)&&l.issues.length){let h=n.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(n.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>Qe(h,o,Ze())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let g=n.valueType._zod.run({value:i[u],issues:[]},o);if(g instanceof Promise)s.push(g.then((h)=>{if(h.issues.length)r.issues.push(...cn(u,h.issues));r.value[m]=h.value}));else{if(g.issues.length)r.issues.push(...cn(u,g.issues));r.value[m]=g.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var $u=b("$ZodEnum",(e,n)=>{te.init(e,n);let t=it(n.entries),r=new Set(t);e._zod.values=r,U(e,"pattern",(o)=>{let i=it(o.def.entries).filter((s)=>Ia.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>an(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t,input:s,inst:e}),o}}),Nu=b("$ZodLiteral",(e,n)=>{te.init(e,n);let t=new Set(n.values);e._zod.values=t,U(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?an(i):i?an(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(t.has(i))return r;return r.issues.push({code:"invalid_value",values:n.values,input:i,inst:e}),r}});var Tu=b("$ZodTransform",(e,n)=>{te.init(e,n),e._zod.optin="optional",Pe.memoizer?.guard(e),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new ut(e.constructor.name);let o=n.transform(t.value,t);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(t.value=s,t));if(o instanceof Promise)throw new Ye;return t.value=o,t}});function Fc(e,n){return e.value=n.issues.length?void 0:n.value,e}var Yo=b("$ZodOptional",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),U(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${ir(r.source)})?$`):void 0}),e._zod.parse=(t,r)=>{if(t.value===void 0){if(n.innerType._zod.optin!=="defaulted")return t;let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Fc(t,i));return Fc(t,o)}return n.innerType._zod.run(t,r)}}),zu=b("$ZodExactOptional",(e,n)=>{Yo.init(e,n),U(e,"values",(t)=>t.def.innerType._zod.values),U(e,"pattern",(t)=>t.def.innerType._zod.pattern),e._zod.parse=(t,r)=>n.innerType._zod.run(t,r)}),Du=b("$ZodNullable",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin),U(e,"optout",(t)=>t.def.innerType._zod.optout),U(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${ir(r.source)}|null)$`):void 0}),U(e,"values",(t)=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),e._zod.parse=(t,r)=>{if(t.value===null)return t;return n.innerType._zod.run(t,r)}}),Vu=b("$ZodDefault",(e,n)=>{te.init(e,n),e._zod.optin="defaulted",U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)return t.value=n.defaultValue,t;let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Jc(i,n));return Jc(o,n)}});function Jc(e,n){if(e.value===void 0)e.value=n.defaultValue;return e}var Zu=b("$ZodPrefault",(e,n)=>{te.init(e,n),e._zod.optin="defaulted",U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)t.value=n.defaultValue;return n.innerType._zod.run(t,r)}}),Mu=b("$ZodNonOptional",(e,n)=>{te.init(e,n),U(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(t,r)=>{let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Lc(i,e));return Lc(o,e)}});function Lc(e,n){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n});return e}function qc(e,n,t,r){if(!n.issues.length){if(e.value=n.value,n.memo)e.memo=!0;return e}return e.value=t.catchValue({...n,value:e.value,error:{issues:n.issues.map((o)=>Qe(o,r,Ze()))},input:e.value}),e}var Fu=b("$ZodCatch",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),U(e,"optout",(t)=>t.def.innerType._zod.optout),U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>qc(t,i,n,r));return qc(t,o,n,r)}});var Xo=b("$ZodPipe",(e,n)=>{te.init(e,n),U(e,"values",(t)=>t.def.in._zod.values),U(e,"optin",(t)=>t.def.in._zod.optin),U(e,"optout",(t)=>t.def.out._zod.optout),U(e,"propValues",(t)=>t.def.in._zod.propValues),e._zod.parse=(t,r)=>{if(r.direction==="backward"){let i=n.out._zod.run(t,r);if(i instanceof Promise)return i.then((s)=>yr(s,n.in,r));return yr(i,n.in,r)}let o=n.in._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>yr(i,n.out,r));return yr(o,n.out,r)}});function yr(e,n,t){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return n._zod.run({value:e.value,issues:e.issues},t)}var Ju=b("$ZodPreprocess",(e,n)=>{Xo.init(e,n)}),Lu=b("$ZodReadonly",(e,n)=>{te.init(e,n),U(e,"propValues",(t)=>t.def.innerType._zod.propValues),U(e,"values",(t)=>t.def.innerType._zod.values),U(e,"optin",(t)=>t.def.innerType?._zod?.optin),U(e,"optout",(t)=>t.def.innerType?._zod?.optout),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then(Uc);return Uc(o)}});function Uc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var qu=b("$ZodLazy",(e,n)=>{te.init(e,n),ba(e._zod,"innerType",()=>{let t=n;if(!t._cachedInner)t._cachedInner=n.getter();return t._cachedInner}),U(e,"pattern",(t)=>t.innerType?._zod?.pattern),U(e,"propValues",(t)=>t.innerType?._zod?.propValues),U(e,"optin",(t)=>t.innerType?._zod?.optin??void 0),U(e,"optout",(t)=>t.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),Uu=b("$ZodCustom",(e,n)=>{we.init(e,n),te.init(e,n),e._zod.parse=(t,r)=>t,e._zod.check=(t)=>{let r=t.value,o=n.fn(r);if(o instanceof Promise)return o.then((i)=>Kc(i,t,r,e));Kc(o,t,r,e);return}});function Kc(e,n,t,r){if(!e){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;n.issues.push(Sn(o))}}class Bu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ni="~memo",Ku=[];function Gu(e){return e!==null&&typeof e==="object"}function ei(e){return e.map((n)=>n.path?{...n,path:n.path.slice()}:{...n})}var Wu=new WeakMap,ft=0,Ir=1,mt=2;function Er(e,n,t){let r=Wu.get(e);if(r!==void 0)return r?mt:ft;if(n.has(e))return mt;n.add(e);let o=ft,i=(l)=>{if(o!==mt&&l?._zod){let p=Er(l,n,t);if(p>o)o=p}},s=(l,p)=>{let m=ft;for(let g of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,g);if(p&&!h.enumerable)continue;let S=h.get?Ir:h.value?._zod?Er(h.value,n,t):ft;if(S>m)m=S}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=ct(c);a(l?s(l,!0):Ir),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(t?e._zod.innerType:void 0);a(l?Er(l,n,!1):Ir);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let m=p.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let g of m)i(g)}}return n.delete(e),jg(e,o)}function jg(e,n){if(n!==Ir)Wu.set(e,n===mt);return n}function $g(e,n){let t=e.buckets.get(n);if(!t)t=new WeakMap,e.buckets.set(n,t);return t}var kr,Sr=[],Ng={alloc(e,n,t){let r=kr;if(!r)return t;kr=void 0;let o={value:t,issues:null};return r.set(n.value,o),Sr.push(o),t},guard(e){var n;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Tg(i,o.value))throw new Bu;return t(o,i)};if(e._zod.parse=r,e._zod.run===t)e._zod.run=r})},attach(e){var n;let t,r=!1,o,i;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(t===void 0){let N=Er(e,new Set,!1);if(N===ft){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(N===mt||r)t=!0;else r=!0}let l=c.value;if(!Gu(l))return s(c,u);let p=u[ni];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[ni]=p;let m;if(o===u)m=i;else m=$g(p,e),o=u,i=m;let g=m.get(l);if(g){if(c.value=g.value,g.issues){if(g.issues.length)c.issues.push(...ei(g.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(g.value);return c}kr=m;let h=Sr.length,S=s(c,u);kr=void 0;let R=Sr.length>h?Sr.pop():void 0;if(S instanceof Promise)return S.then((N)=>{if(R)R.issues=N.issues.length?ei(N.issues):Ku;return N});if(R)R.issues=S.issues.length?ei(S.issues):Ku;return S};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function Hu(){return Ng}function Tg(e,n){let t=e[ni]?.backEdges;return t!==void 0&&Gu(n)&&t.has(n)}var zg=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(i){return e[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Aa(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${jo(i.values[0])}`;return`Invalid option: expected one of ${Ao(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=n(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=n(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Ao(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function ti(){return{localeError:zg()}}var Qu;class Yu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){let t=n[0];if(this._map.set(e,t),t&&typeof t==="object"&&"id"in t)this._idmap.set(t.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let n=this._map.get(e);if(n&&typeof n==="object"&&"id"in n)this._idmap.delete(n.id);return this._map.delete(e),this}get(e){let n=e._zod.parent;if(n){let t={...this.get(n)??{}};delete t.id;let r={...t,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Dg(){return new Yu}(Qu=globalThis).__zod_globalRegistry??(Qu.__zod_globalRegistry=Dg());var In=globalThis.__zod_globalRegistry;function Xu(e){if(e.checks)e.checks=[...e.checks];return e}function el(e,n){return new e(Xu({type:"string",...j(n)}))}function nl(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...j(n)})}function tl(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...j(n)})}function rl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...j(n)})}function ol(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(n)})}function il(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(n)})}function sl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(n)})}function al(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...j(n)})}function cl(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...j(n)})}function ul(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(n)})}function ll(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...j(n)})}function dl(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(n)})}function pl(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...j(n)})}function fl(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...j(n)})}function ml(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(n)})}function gl(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(n)})}function hl(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(n)})}function yl(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(n)})}function bl(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(n)})}function wl(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...j(n)})}function xl(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...j(n)})}function vl(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...j(n)})}function kl(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...j(n)})}function Sl(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(n)})}function Il(e,n){return new e({type:"string",format:"date",check:"string_format",...j(n)})}function El(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...j(n)})}function Cl(e,n){return new e({type:"string",format:"duration",check:"string_format",...j(n)})}function Ol(e,n){return new e(Xu({type:"number",checks:[],...j(n)}))}function Rl(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...j(n)})}function Al(e,n){return new e({type:"boolean",...j(n)})}function Pl(e,n){return new e({type:"null",...j(n)})}function _l(e){return new e({type:"unknown"})}function jl(e,n){return new e({type:"never",...j(n)})}function Cr(e,n){return new qo({check:"less_than",...j(n),value:e,inclusive:!1})}function gt(e,n){return new qo({check:"less_than",...j(n),value:e,inclusive:!0})}function Or(e,n){return new Uo({check:"greater_than",...j(n),value:e,inclusive:!1})}function ht(e,n){return new Uo({check:"greater_than",...j(n),value:e,inclusive:!0})}function Rr(e,n){return new Sc({check:"multiple_of",...j(n),value:e})}function Ar(e,n){return new Ec({check:"max_length",...j(n),maximum:e})}function Dn(e,n){return new Cc({check:"min_length",...j(n),minimum:e})}function Pr(e,n){return new Oc({check:"length_equals",...j(n),length:e})}function ri(e,n){return new Rc({check:"string_format",format:"regex",...j(n),pattern:e})}function oi(e){return new Ac({check:"string_format",format:"lowercase",...j(e)})}function ii(e){return new Pc({check:"string_format",format:"uppercase",...j(e)})}function si(e,n){return new _c({check:"string_format",format:"includes",...j(n),includes:e})}function ai(e,n){return new jc({check:"string_format",format:"starts_with",...j(n),prefix:e})}function ci(e,n){return new $c({check:"string_format",format:"ends_with",...j(n),suffix:e})}function un(e){return new Nc({check:"overwrite",tx:e})}function ui(e){return un((n)=>n.normalize(e))}function li(){return un((e)=>e.trim())}function di(){return un((e)=>e.toLowerCase())}function pi(){return un((e)=>e.toUpperCase())}function fi(){return un((e)=>ka(e))}function $l(e,n,t){return new e({type:"array",element:n,...j(t)})}function Nl(e,n,t){return new e({type:"custom",check:"custom",fn:n,...j(t)})}function Tl(e,n){let t=Vg((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Sn(o,r.value,t._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(Sn(i))}},e(r.value,r)),n);return t}function Vg(e,n){let t=new we({check:"custom",...j(n)});return t._zod.check=e,t}function yt(e,...n){for(let t of n)for(let r of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,r))De(e,r,t[r]);return e}function wt(e){let n=e?.target??"draft-2020-12";if(n==="draft-4")n="draft-04";if(n==="draft-7")n="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??In,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function be(e,n,t,r,o){let i=typeof n.unrepresentable==="function"?n.unrepresentable({zodSchema:e,path:r.path,message:o}):n.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(t,i),!0}function X(e,n,t={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=n.seen.get(e);if(i){if(i.count++,t.schemaPath.includes(e))i.cycle=t.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,s),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,s.schema,l);else{let m=s.schema,g=n.processors[o.type];if(!g)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,n,m,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;X(p,n,l),n.seen.get(p).isParent=!0}}let c=n.metadataRegistry.get(e);if(c)yt(s.schema,c);if(n.io==="input"&&Ee(e))delete s.schema.examples,delete s.schema.default;if(n.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,n.seen.get(e).schema}function zl(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function xt(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((h)=>h);if(p)return{ref:m(p)};let g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${m("__shared")}#/${a}/${zl(g)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===t&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+zl(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
56
+ `)}return R.write("payload.value = newResult;"),R.write("return payload;"),R.compile()},s,a=Vn,c=!Pe.jitless,l=c&&ja.value,d=n.catchall,m;e._zod.parse=(g,h)=>{m??(m=r.value);let I=g.value;if(!a(I))return g.issues.push({expected:"object",code:"invalid_type",input:I,inst:e}),g;if(c&&l&&h?.async===!1&&h.jitless!==!0){if(!s)s=i(n.shape);if(g=s(g,h),!d)return g;return Tu([],I,g,h,m,e,h?.abortEarly===!0)}return t(g,h)}});function Kc(e,n,t,r){for(let i of e)if(i.issues.length===0)return n.value=i.value,n;let o=e.filter((i)=>!He(i));if(o.length===1)return n.value=o[0].value,o[0];return n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((i)=>i.issues.map((s)=>Qe(s,r,Ze())))}),n}var ii=b("$ZodUnion",(e,n)=>{te.init(e,n),U(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),U(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),U(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),U(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>fr(i.source)).join("|")})$`)}return});let t=n.options.length===1?n.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of n.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Kc(s,r,e,o);return Promise.all(s).then((a)=>Kc(a,r,e,o))}});function Jg(e){let n=new Map;for(let t of e.options){let r=t._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(t)}"`);for(let o of r)if(n.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);n.set(o,null)}else n.set(o,t)}return n}var Du=b("$ZodDiscriminatedUnion",(e,n)=>{n.inclusive=!1,ii.init(e,n);let t=e._zod.parse;U(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))De(i,u,new Set);for(let d of l)i[u].add(d)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),n.options.forEach((o,i)=>{let s=mt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,n.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=ft(()=>Jg(n));e._zod.parse=(o,i)=>{let s=o.value;if(!Vn(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[n.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(n.unionFallback||i.direction==="backward")return t(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[n.discriminator],inst:e}),o}}),Vu=b("$ZodIntersection",(e,n)=>{te.init(e,n),e._zod.parse=(t,r)=>{let o=t.value,i=n.left._zod.run({value:o,issues:[]},r),s=n.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Bc(t,c,u));return Bc(t,i,s)}});function ni(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e===+n)return{valid:!0,data:e};if(En(e)&&En(n)){let t=Object.keys(n),r=Object.keys(e).filter((i)=>t.indexOf(i)!==-1),o={...e,...n};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=ni(e[i],n[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n[r],s=ni(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};t.push(s.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Bc(e,n,t){let r=new Map,o,i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);d=[m]}else return!1;for(let m of d){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of n.issues)if(!s(u,"l"))e.issues.push(u);for(let u of t.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=ni(n.value,t.value);if(!c.valid){if(He(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Zu=b("$ZodRecord",(e,n)=>{te.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!En(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=n.keyType._zod.values;if(a&&!n.partial){r.value=t?t.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let d=n.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((h)=>Qe(h,o,Ze())),input:l,path:[l],inst:e});continue}let m=d.value;if(m==="__proto__")continue;let g=n.valueType._zod.run({value:i[l],issues:[]},o);if(g instanceof Promise)s.push(g.then((h)=>{if(h.issues.length)r.issues.push(...ln(l,h.issues));r.value[m]=h.value}));else{if(g.issues.length)r.issues.push(...ln(l,g.issues));r.value[m]=g.value}}let u;for(let l in i)if(!c.has(l))if(n.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=t?t.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=n.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&ht.test(u)&&l.issues.length){let h=n.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(n.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>Qe(h,o,Ze())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let g=n.valueType._zod.run({value:i[u],issues:[]},o);if(g instanceof Promise)s.push(g.then((h)=>{if(h.issues.length)r.issues.push(...ln(u,h.issues));r.value[m]=h.value}));else{if(g.issues.length)r.issues.push(...ln(u,g.issues));r.value[m]=g.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Fu=b("$ZodEnum",(e,n)=>{te.init(e,n);let t=dt(n.entries),r=new Set(t);e._zod.values=r,U(e,"pattern",(o)=>{let i=dt(o.def.entries).filter((s)=>Pa.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>un(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t,input:s,inst:e}),o}}),Mu=b("$ZodLiteral",(e,n)=>{te.init(e,n);let t=new Set(n.values);e._zod.values=t,U(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?un(i):i?un(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(t.has(i))return r;return r.issues.push({code:"invalid_value",values:n.values,input:i,inst:e}),r}});var Ju=b("$ZodTransform",(e,n)=>{te.init(e,n),e._zod.optin="optional",Pe.memoizer?.guard(e),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new gt(e.constructor.name);let o=n.transform(t.value,t);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(t.value=s,t));if(o instanceof Promise)throw new Ye;return t.value=o,t}});function Wc(e,n){return e.value=n.issues.length?void 0:n.value,e}var si=b("$ZodOptional",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),U(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${fr(r.source)})?$`):void 0}),e._zod.parse=(t,r)=>{if(t.value===void 0){if(n.innerType._zod.optin!=="defaulted")return t;let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Wc(t,i));return Wc(t,o)}return n.innerType._zod.run(t,r)}}),Lu=b("$ZodExactOptional",(e,n)=>{si.init(e,n),U(e,"values",(t)=>t.def.innerType._zod.values),U(e,"pattern",(t)=>t.def.innerType._zod.pattern),e._zod.parse=(t,r)=>n.innerType._zod.run(t,r)}),qu=b("$ZodNullable",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin),U(e,"optout",(t)=>t.def.innerType._zod.optout),U(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${fr(r.source)}|null)$`):void 0}),U(e,"values",(t)=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),e._zod.parse=(t,r)=>{if(t.value===null)return t;return n.innerType._zod.run(t,r)}}),Uu=b("$ZodDefault",(e,n)=>{te.init(e,n),e._zod.optin="defaulted",U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)return t.value=n.defaultValue,t;let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Gc(i,n));return Gc(o,n)}});function Gc(e,n){if(e.value===void 0)e.value=n.defaultValue;return e}var Ku=b("$ZodPrefault",(e,n)=>{te.init(e,n),e._zod.optin="defaulted",U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)t.value=n.defaultValue;return n.innerType._zod.run(t,r)}}),Bu=b("$ZodNonOptional",(e,n)=>{te.init(e,n),U(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(t,r)=>{let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Hc(i,e));return Hc(o,e)}});function Hc(e,n){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n});return e}function Qc(e,n,t,r){if(!n.issues.length){if(e.value=n.value,n.memo)e.memo=!0;return e}return e.value=t.catchValue({...n,value:e.value,error:{issues:n.issues.map((o)=>Qe(o,r,Ze()))},input:e.value}),e}var Wu=b("$ZodCatch",(e,n)=>{te.init(e,n),U(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),U(e,"optout",(t)=>t.def.innerType._zod.optout),U(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Qc(t,i,n,r));return Qc(t,o,n,r)}});var ai=b("$ZodPipe",(e,n)=>{te.init(e,n),U(e,"values",(t)=>t.def.in._zod.values),U(e,"optin",(t)=>t.def.in._zod.optin),U(e,"optout",(t)=>t.def.out._zod.optout),U(e,"propValues",(t)=>t.def.in._zod.propValues),e._zod.parse=(t,r)=>{if(r.direction==="backward"){let i=n.out._zod.run(t,r);if(i instanceof Promise)return i.then((s)=>Er(s,n.in,r));return Er(i,n.in,r)}let o=n.in._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Er(i,n.out,r));return Er(o,n.out,r)}});function Er(e,n,t){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return n._zod.run({value:e.value,issues:e.issues},t)}var Gu=b("$ZodPreprocess",(e,n)=>{ai.init(e,n)}),Hu=b("$ZodReadonly",(e,n)=>{te.init(e,n),U(e,"propValues",(t)=>t.def.innerType._zod.propValues),U(e,"values",(t)=>t.def.innerType._zod.values),U(e,"optin",(t)=>t.def.innerType?._zod?.optin),U(e,"optout",(t)=>t.def.innerType?._zod?.optout),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then(Yc);return Yc(o)}});function Yc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Qu=b("$ZodLazy",(e,n)=>{te.init(e,n),Ea(e._zod,"innerType",()=>{let t=n;if(!t._cachedInner)t._cachedInner=n.getter();return t._cachedInner}),U(e,"pattern",(t)=>t.innerType?._zod?.pattern),U(e,"propValues",(t)=>t.innerType?._zod?.propValues),U(e,"optin",(t)=>t.innerType?._zod?.optin??void 0),U(e,"optout",(t)=>t.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),Yu=b("$ZodCustom",(e,n)=>{ve.init(e,n),te.init(e,n),e._zod.parse=(t,r)=>t,e._zod.check=(t)=>{let r=t.value,o=n.fn(r);if(o instanceof Promise)return o.then((i)=>Xc(i,t,r,e));Xc(o,t,r,e);return}});function Xc(e,n,t,r){if(!e){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;n.issues.push(Cn(o))}}class el extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ui="~memo",Xu=[];function nl(e){return e!==null&&typeof e==="object"}function ci(e){return e.map((n)=>n.path?{...n,path:n.path.slice()}:{...n})}var tl=new WeakMap,wt=0,_r=1,xt=2;function $r(e,n,t){let r=tl.get(e);if(r!==void 0)return r?xt:wt;if(n.has(e))return xt;n.add(e);let o=wt,i=(l)=>{if(o!==xt&&l?._zod){let d=$r(l,n,t);if(d>o)o=d}},s=(l,d)=>{let m=wt;for(let g of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,g);if(d&&!h.enumerable)continue;let I=h.get?_r:h.value?._zod?$r(h.value,n,t):wt;if(I>m)m=I}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=mt(c);a(l?s(l,!0):_r),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(t?e._zod.innerType:void 0);a(l?$r(l,n,!1):_r);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let m=d.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let g of m)i(g)}}return n.delete(e),Lg(e,o)}function Lg(e,n){if(n!==_r)tl.set(e,n===xt);return n}function qg(e,n){let t=e.buckets.get(n);if(!t)t=new WeakMap,e.buckets.set(n,t);return t}var jr,Pr=[],Ug={alloc(e,n,t){let r=jr;if(!r)return t;jr=void 0;let o={value:t,issues:null};return r.set(n.value,o),Pr.push(o),t},guard(e){var n;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Kg(i,o.value))throw new el;return t(o,i)};if(e._zod.parse=r,e._zod.run===t)e._zod.run=r})},attach(e){var n;let t,r=!1,o,i;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(t===void 0){let N=$r(e,new Set,!1);if(N===wt){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(N===xt||r)t=!0;else r=!0}let l=c.value;if(!nl(l))return s(c,u);let d=u[ui];if(!d)d={buckets:new WeakMap,backEdges:void 0},u[ui]=d;let m;if(o===u)m=i;else m=qg(d,e),o=u,i=m;let g=m.get(l);if(g){if(c.value=g.value,g.issues){if(g.issues.length)c.issues.push(...ci(g.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(g.value);return c}jr=m;let h=Pr.length,I=s(c,u);jr=void 0;let R=Pr.length>h?Pr.pop():void 0;if(I instanceof Promise)return I.then((N)=>{if(R)R.issues=N.issues.length?ci(N.issues):Xu;return N});if(R)R.issues=I.issues.length?ci(I.issues):Xu;return I};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function rl(){return Ug}function Kg(e,n){let t=e[ui]?.backEdges;return t!==void 0&&nl(n)&&t.has(n)}var Bg=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(i){return e[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=za(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Fo(i.values[0])}`;return`Invalid option: expected one of ${Do(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=n(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=n(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Do(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function li(){return{localeError:Bg()}}var ol;class il{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){let t=n[0];if(this._map.set(e,t),t&&typeof t==="object"&&"id"in t)this._idmap.set(t.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let n=this._map.get(e);if(n&&typeof n==="object"&&"id"in n)this._idmap.delete(n.id);return this._map.delete(e),this}get(e){let n=e._zod.parent;if(n){let t={...this.get(n)??{}};delete t.id;let r={...t,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Wg(){return new il}(ol=globalThis).__zod_globalRegistry??(ol.__zod_globalRegistry=Wg());var On=globalThis.__zod_globalRegistry;function sl(e){if(e.checks)e.checks=[...e.checks];return e}function al(e,n){return new e(sl({type:"string",..._(n)}))}function cl(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(n)})}function ul(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(n)})}function ll(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(n)})}function dl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(n)})}function pl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(n)})}function fl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(n)})}function ml(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(n)})}function gl(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(n)})}function hl(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(n)})}function yl(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(n)})}function bl(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(n)})}function wl(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(n)})}function xl(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(n)})}function vl(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(n)})}function kl(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(n)})}function Sl(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(n)})}function Il(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(n)})}function El(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(n)})}function Cl(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(n)})}function Ol(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(n)})}function Rl(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(n)})}function Al(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(n)})}function jl(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(n)})}function Pl(e,n){return new e({type:"string",format:"date",check:"string_format",..._(n)})}function _l(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(n)})}function $l(e,n){return new e({type:"string",format:"duration",check:"string_format",..._(n)})}function Nl(e,n){return new e(sl({type:"number",checks:[],..._(n)}))}function Tl(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(n)})}function zl(e,n){return new e({type:"boolean",..._(n)})}function Dl(e,n){return new e({type:"null",..._(n)})}function Vl(e){return new e({type:"unknown"})}function Zl(e,n){return new e({type:"never",..._(n)})}function Nr(e,n){return new Yo({check:"less_than",..._(n),value:e,inclusive:!1})}function vt(e,n){return new Yo({check:"less_than",..._(n),value:e,inclusive:!0})}function Tr(e,n){return new Xo({check:"greater_than",..._(n),value:e,inclusive:!1})}function kt(e,n){return new Xo({check:"greater_than",..._(n),value:e,inclusive:!0})}function zr(e,n){return new jc({check:"multiple_of",..._(n),value:e})}function Dr(e,n){return new _c({check:"max_length",..._(n),maximum:e})}function Zn(e,n){return new $c({check:"min_length",..._(n),minimum:e})}function Vr(e,n){return new Nc({check:"length_equals",..._(n),length:e})}function di(e,n){return new Tc({check:"string_format",format:"regex",..._(n),pattern:e})}function pi(e){return new zc({check:"string_format",format:"lowercase",..._(e)})}function fi(e){return new Dc({check:"string_format",format:"uppercase",..._(e)})}function mi(e,n){return new Vc({check:"string_format",format:"includes",..._(n),includes:e})}function gi(e,n){return new Zc({check:"string_format",format:"starts_with",..._(n),prefix:e})}function hi(e,n){return new Fc({check:"string_format",format:"ends_with",..._(n),suffix:e})}function dn(e){return new Mc({check:"overwrite",tx:e})}function yi(e){return dn((n)=>n.normalize(e))}function bi(){return dn((e)=>e.trim())}function wi(){return dn((e)=>e.toLowerCase())}function xi(){return dn((e)=>e.toUpperCase())}function vi(){return dn((e)=>Aa(e))}function Fl(e,n,t){return new e({type:"array",element:n,..._(t)})}function Ml(e,n,t){return new e({type:"custom",check:"custom",fn:n,..._(t)})}function Jl(e,n){let t=Gg((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Cn(o,r.value,t._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(Cn(i))}},e(r.value,r)),n);return t}function Gg(e,n){let t=new ve({check:"custom",..._(n)});return t._zod.check=e,t}function St(e,...n){for(let t of n)for(let r of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,r))De(e,r,t[r]);return e}function Et(e){let n=e?.target??"draft-2020-12";if(n==="draft-4")n="draft-04";if(n==="draft-7")n="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??On,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function be(e,n,t,r,o){let i=typeof n.unrepresentable==="function"?n.unrepresentable({zodSchema:e,path:r.path,message:o}):n.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(t,i),!0}function ee(e,n,t={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=n.seen.get(e);if(i){if(i.count++,t.schemaPath.includes(e))i.cycle=t.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,s),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,s.schema,l);else{let m=s.schema,g=n.processors[o.type];if(!g)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,n,m,l)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;ee(d,n,l),n.seen.get(d).isParent=!0}}let c=n.metadataRegistry.get(e);if(c)St(s.schema,c);if(n.io==="input"&&Ce(e))delete s.schema.examples,delete s.schema.default;if(n.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,n.seen.get(e).schema}function Ll(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ct(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,m=e.external.uri??((h)=>h);if(d)return{ref:m(d)};let g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${m("__shared")}#/${a}/${Ll(g)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===t&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Ll(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
57
57
 
58
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(n===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(n!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Zl(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let t=[];for(let r of n){if(!r||typeof r!=="object")return;Zl(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!t.includes(s))t.push(s)}}delete e.anyOf,e.type=t.length===1?t[0]:t}var Ml=new Set(["type","properties","required","additionalProperties"]),Dl=["oneOf","anyOf"];function Vl(e){let n=e.additionalProperties;if(n===void 0||n===!1||typeof n!=="object"||n===null)return null;return Object.keys(n).length?n:null}function mi(e){let n=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Ml.has(s))return null;n.push(i)}let t={},r=new Set;for(let i of n){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(t,s))continue;let a=[];for(let u of n){let l=u.properties?.[s]??Vl(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:mi(a)??{allOf:a};De(t,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:t};if(r.size)o.required=[...r];if(n.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of n){let a=Vl(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function Zg(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let o of Ml)if(o in e)return;let t=n.filter((o)=>Dl.some((i)=>Array.isArray(o[i]))),r=null;if(!t.length)r=mi(n);else{let o=t[0],i=Dl.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=n.filter((c)=>c!==o),a=o[i].map((c)=>mi([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,yt(e,r)}function vt(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){r(p);let g=e.seen.get(p),h=g.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(h);else yt(u,h);if(yt(u,l),a._zod.parent===p)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(!(R in l))delete u[R]}if(h.$ref&&g.def)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(R in g.def&&JSON.stringify(u[R])===JSON.stringify(g.def[R]))delete u[R]}}let m=a._zod.parent;if(m&&m!==p){r(m);let g=e.seen.get(m);if(g?.schema.$ref){if(u.$ref=g.schema.$ref,g.def)for(let h in u){if(h==="$ref"||h==="allOf")continue;if(h in g.def&&JSON.stringify(u[h])===JSON.stringify(g.def[h]))delete u[h]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Zl(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Zg(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(n)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}yt(o,t.defId?t.schema:t.def??t.schema);let i=e.metadataRegistry.get(n)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;De(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...n["~standard"],jsonSchema:{input:bt(n,"input",e.processors),output:bt(n,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Ee(e,n){let t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ee(r.element,t);if(r.type==="set")return Ee(r.valueType,t);if(r.type==="lazy")return Ee(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Ee(r.innerType,t);if(r.type==="intersection")return Ee(r.left,t)||Ee(r.right,t);if(r.type==="record"||r.type==="map")return Ee(r.keyType,t)||Ee(r.valueType,t);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Ee(r.in,t)||Ee(r.out,t)}if(r.type==="object"){for(let o in r.shape)if(Ee(r.shape[o],t))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(Ee(o,t))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(Ee(o,t))return!0;if(r.rest&&Ee(r.rest,t))return!0;return!1}return!1}var Fl=(e,n={})=>(t)=>{let r=wt({...t,processors:n});return X(e,r),xt(r,e),vt(r,e)},bt=(e,n,t={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=wt({...o??{},target:i,io:n,processors:t});return X(e,s),xt(s,e),vt(s,e)};var Vn=(e,n,t)=>{if(e[n]===void 0||t>e[n])e[n]=t},Zn=(e,n,t)=>{if(e[n]===void 0||t<e[n])e[n]=t},Jl=(e,n)=>{Vn(e,"minimum",n),Zn(e,"maximum",n)},Bl=(e,n)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(n))e.multipleOf.push(n)},Gl=(e,n)=>{e.patterns??(e.patterns=new Set),e.patterns.add(n)},Wl=(e,n)=>{e.mime=e.mime?e.mime.filter((t)=>n.includes(t)):[...n]},Hl=(e,n)=>{if(e.format=n,n.includes("int"))e.isInt=!0},Ll=(e,n)=>Vn(e,"minimum",n.minimum),ql=(e,n)=>Zn(e,"maximum",n.maximum),Ul=(e)=>(n,t)=>{Hl(n,t.format);let[r,o]=e[t.format];Vn(n,"minimum",r),Zn(n,"maximum",o)},Mg={greater_than:(e,n)=>Vn(e,n.inclusive?"minimum":"exclusiveMinimum",n.value),less_than:(e,n)=>Zn(e,n.inclusive?"maximum":"exclusiveMaximum",n.value),multiple_of:(e,n)=>Bl(e,n.value),number_format:Ul(sr),bigint_format:Ul($o),min_length:Ll,max_length:ql,length_equals:(e,n)=>Jl(e,n.length),min_size:Ll,max_size:ql,size_equals:(e,n)=>Jl(e,n.size),string_format:(e,n)=>{if(Hl(e,n.format),n.pattern)Gl(e,n.pattern);if(n.format==="base64"||n.format==="base64url")e.contentEncoding=n.format;if(n.local||n.precision===-1)e.laxFormat=!0},mime_type:(e,n)=>Wl(e,n.mime)};function _e(e){let n={},t=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...t.checks??[]]:t.checks??[];for(let i of r)Mg[i._zod.def.check]?.(n,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Vn(n,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Vn(n,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Zn(n,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Zn(n,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Bl(n,o.multipleOf);if(o.format!==void 0){if(n.format??(n.format=o.format),o.format.includes("int"))n.isInt=!0}if(o.mime)Wl(n,o.mime);for(let i of o.patterns??[])Gl(n,i);return n}var Fg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jg=new Map([[Wo,lc],[vr,dc]]),Ql=(e)=>Jg.get(e)??e,yi=(e,n,t,r)=>{let o=t;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=_e(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=Fg[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map(Ql);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((m)=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},bi=(e,n,t,r)=>{let o=t,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=_e(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),g=n.target==="draft-04"||n.target==="openapi-3.0";if(p)if(g)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(g)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let h=new Set;for(let N of a)if(Number.isFinite(N)&&N!==0)h.add(Math.abs(N));else be(e,n,o,r,`A multipleOf divisor of ${N} cannot be represented in JSON Schema`);let[S,...R]=h;if(S!==void 0)o.multipleOf=S;if(R.length)o.allOf=[...o.allOf??[],...R.map((N)=>({multipleOf:N}))]}},wi=(e,n,t,r)=>{t.type="boolean"},Yl=(e,n,t,r)=>{be(e,n,t,r,"BigInt cannot be represented in JSON Schema")},Xl=(e,n,t,r)=>{be(e,n,t,r,"Symbols cannot be represented in JSON Schema")},xi=(e,n,t,r)=>{if(n.target==="openapi-3.0")t.type="string",t.nullable=!0,t.enum=[null];else t.type="null"},ed=(e,n,t,r)=>{be(e,n,t,r,"Undefined cannot be represented in JSON Schema")},nd=(e,n,t,r)=>{be(e,n,t,r,"Void cannot be represented in JSON Schema")},vi=(e,n,t,r)=>{t.not={}},td=(e,n,t,r)=>{},ki=(e,n,t,r)=>{},rd=(e,n,t,r)=>{be(e,n,t,r,"Date cannot be represented in JSON Schema")},Si=(e,n,t,r)=>{let o=e._zod.def,i=it(o.entries);if(i.length===0){t.not={};return}if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";t.enum=i},Ii=(e,n,t,r)=>{let o=e._zod.def;if(o.values.length===0){t.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(be(e,n,t,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(be(e,n,t,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(t.type=s===null?"null":typeof s,n.target==="draft-04"||n.target==="openapi-3.0")t.enum=[s];else t.const=s}else{if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";if(i.every((s)=>typeof s==="boolean"))t.type="boolean";if(i.every((s)=>s===null))t.type="null";t.enum=i}},od=(e,n,t,r)=>{be(e,n,t,r,"NaN cannot be represented in JSON Schema")},id=(e,n,t,r)=>{let o=t,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},sd=(e,n,t,r)=>{let o=t;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=_e(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},ad=(e,n,t,r)=>{t.type="boolean"},Ei=(e,n,t,r)=>{be(e,n,t,r,"Custom types cannot be represented in JSON Schema")},cd=(e,n,t,r)=>{be(e,n,t,r,"Function types cannot be represented in JSON Schema")},Ci=(e,n,t,r)=>{be(e,n,t,r,"Transforms cannot be represented in JSON Schema")},ud=(e,n,t,r)=>{be(e,n,t,r,"Map cannot be represented in JSON Schema")},ld=(e,n,t,r)=>{be(e,n,t,r,"Set cannot be represented in JSON Schema")},Oi=(e,n,t,r)=>{let o=t,i=e._zod.def,{minimum:s,maximum:a}=_e(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=X(i.element,n,{...r,path:[...r.path,"items"]})};function kt(e){let n=e._zod.def;if(n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform"))return kt(n.out);if(n.type==="catch")return kt(n.innerType);return e._zod.optin}var Ri=(e,n,t,r)=>{let o=t,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&be(e,n,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)De(o.properties,u,X(s[u],n,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(n.io==="input"?kt(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(n.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=X(i.catchall,n,{...r,path:[...r.path,"additionalProperties"]})},Ai=(e,n,t,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>X(a,n,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)t.oneOf=s;else t.anyOf=s},Pi=(e,n,t,r)=>{let o=e._zod.def,i=X(o.left,n,{...r,path:[...r.path,"allOf",0]}),s=X(o.right,n,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];t.allOf=c,n.intersections.push(c)},dd=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="array";let s=n.target==="draft-2020-12"?"prefixItems":"items",a=n.target==="draft-2020-12"?"items":n.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((S,R)=>X(S,n,{...r,path:[...r.path,s,R]})),u=i.rest?X(i.rest,n,{...r,path:[...r.path,a,...n.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let S=i.items[l-1];if(!(n.io==="input"?kt(S)!==void 0:S._zod.optout==="optional"))break;l--}let p=i.items.length,m=!i.rest;if(n.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}else if(n.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=p}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}let{minimum:g,maximum:h}=_e(e);if(typeof g==="number")o.minItems=g;if(typeof h==="number")o.maxItems=h};function gi(e,n,t){if(n.$ref){if(t.has(n))return n;t.add(n);let h=e.get(n)?.def;if(!h)return n;let S=gi(e,h,t);return S===h?n:S}for(let h of["anyOf","oneOf"]){let S=n[h];if(!Array.isArray(S))continue;let R=S.map((N)=>gi(e,N,t));if(R.some((N,L)=>N!==S[L]))n={...n,[h]:R}}let r=Array.isArray(n.type)?n.type:[n.type],o=!r.includes("string")&&r.some((h)=>h==="number"||h==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!o&&!i?.some((h)=>typeof h==="number"))return n;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:m,...g}=n;if(g.enum)g.enum=g.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof g.const==="number")g.const=String(g.const);if(!o)return g;if(g.type="string",!i)g.pattern=(r.includes("number")?lt:Jo).source;return g}var hi=new WeakMap;function Lg(e){let n=new Map;for(let r of e.seen.values())if(r.def&&!n.has(r.schema))n.set(r.schema,r);let t=new Map;for(let r of hi.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||t.has(i))continue;let s=gi(n,i,new Set);if(s!==i)t.set(i,s)}if(!t.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&t.get(o.propertyNames);if(i)o.propertyNames=i}}var _i=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="object";let s=i.keyType,a=_e(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=X(i.valueType,n,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)De(o.patternProperties,Ql(p).source,l)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){o.propertyNames=X(i.keyType,n,{...r,path:[...r.path,"propertyNames"]});let l=hi.get(n);if(!l)l=[],hi.set(n,l),n.deferred.push(()=>Lg(n));l.push(e)}o.additionalProperties=X(i.valueType,n,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=n.io==="input"&&kt(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},ji=(e,n,t,r)=>{let o=e._zod.def,i=X(o.innerType,n,r),s=n.seen.get(e);if(n.target==="openapi-3.0")s.ref=o.innerType,t.nullable=!0;else t.anyOf=[i,{type:"null"}]},$i=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Ni=Symbol();function pd(e,n,t,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return be(n,t,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ni}var Ti=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s=pd(o.defaultValue,e,n,t,r);if(s!==Ni)t.default=s},zi=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);if(i.ref=o.innerType,n.io!=="input")return;let s=pd(o.defaultValue,e,n,t,r);if(s!==Ni)t._prefault=s},Di=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{be(e,n,t,r,"Dynamic catch values are not supported in JSON Schema");return}t.default=s},Vi=(e,n,t,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=n.io==="input"?i?o.out:o.in:o.out;X(s,n,r);let a=n.seen.get(e);a.ref=s},Zi=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType,t.readOnly=!0},fd=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},_r=(e,n,t,r)=>{let o=e._zod.def;X(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Mi=(e,n,t,r)=>{let o=e._zod.innerType;X(o,n,r);let i=n.seen.get(e);i.ref=o},Kl={string:yi,number:bi,boolean:wi,bigint:Yl,symbol:Xl,null:xi,undefined:ed,void:nd,never:vi,any:td,unknown:ki,date:rd,enum:Si,literal:Ii,nan:od,template_literal:id,file:sd,success:ad,custom:Ei,function:cd,transform:Ci,map:ud,set:ld,array:Oi,object:Ri,union:Ai,intersection:Pi,tuple:dd,record:_i,nullable:ji,nonoptional:$i,default:Ti,prefault:zi,catch:Di,pipe:Vi,readonly:Zi,promise:fd,optional:_r,lazy:Mi};function jr(e,n){if("_idmap"in e){let r=e,o=wt({...n,processors:Kl}),i={};for(let c of r._idmap.entries()){let[u,l]=c;X(l,o)}let s={},a={registry:r,uri:n?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;xt(o,l),De(s,u,vt(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let t=wt({...n,processors:Kl});return X(e,t),xt(t,e),vt(t,e)}var md=new WeakSet([Object.prototype,Error.prototype]);function Nr(e,n,t){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let r=t(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0})}})}var gd=(e,n)=>{Da.init(e,n),e.name="ZodError";let t=Object.getPrototypeOf(e);if(md.has(t))return;md.add(t),Nr(t,"format",(r)=>(o)=>Za(r,o)),Nr(t,"flatten",(r)=>(o)=>Va(r,o)),Nr(t,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,st,2)}),Nr(t,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,st,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},Yg=b("ZodError",gd),Me=b("ZodError",gd,void 0,{Parent:Error});var hd=pr(Me),yd=fr(Me),bd=mr(Me),wd=gr(Me),xd=Fa(Me),vd=Ja(Me),kd=La(Me),Sd=qa(Me),Id=Ua(Me),Ed=Ka(Me),Cd=Ba(Me),Od=Ga(Me);function eh(){if(!Pe.localeError)Ze(ti())}function Dr(){if(!Pe.memoizer)Ze({memoizer:Hu()})}var re=b("ZodType",(e,n)=>(eh(),te.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(Ve(n,{checks:[...n.checks??[],...e.map((t)=>typeof t==="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return We(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(Qh(e,n))},superRefine(e,n){return this.check(Yh(e,n))},overwrite(e){return this.check(un(e))},optional(){return Ad(this)},exactOptional(){return zh(this)},nullable(){return Pd(this)},nullish(){return Ad(Pd(this))},nonoptional(e){return Jh(this,e)},array(){return P(this)},or(e){return Q([this,e])},and(e){return $h(this,e)},transform(e){return _d(this,zd(e))},default(e){return Zh(this,e)},prefault(e){return Fh(this,e)},catch(e){return qh(this,e)},pipe(e){return _d(this,e)},readonly(){return Bh(this)},describe(e){let n=this.clone();return In.add(n,{description:e}),n},meta(...e){if(e.length===0)return In.get(this);let n=this.clone();return In.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get "~standard"(){return lr(this,"~standard",{...Go(this),jsonSchema:{input:bt(this,"input"),output:bt(this,"output")}})},set "~standard"(e){tn(this,"~standard",e)},parse:function e(n,t){return hd(this,n,t,{callee:e})},parseAsync:async function e(n,t){return await yd(this,n,t,{callee:e})},safeParse(e,n){return bd(this,e,n)},async safeParseAsync(e,n){return wd(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){tn(this,"spa",e)},validate(e,n){return Vo(this,e,n)},validateAsync(e,n){return Zo(this,e,n)},encode:function e(n,t){return xd(this,n,t,{callee:e})},decode:function e(n,t){return vd(this,n,t,{callee:e})},encodeAsync:async function e(n,t){return await kd(this,n,t,{callee:e})},decodeAsync:async function e(n,t){return await Sd(this,n,t,{callee:e})},safeEncode(e,n){return Id(this,e,n)},safeDecode(e,n){return Ed(this,e,n)},async safeEncodeAsync(e,n){return Cd(this,e,n)},async safeDecodeAsync(e,n){return Od(this,e,n)},toJSONSchema(e){return Fl(this,{})(e)},get description(){return In.get(this)?.description},get _def(){return this._zod.def}}),jd=b("_ZodString",(e,n)=>{xr.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>yi(e,t,r,o)},_a({format:(e)=>_e(e).format??null,minLength:(e)=>_e(e).minimum??null,maxLength:(e)=>_e(e).maximum??null},{regex(...e){return this.check(ri(...e))},includes(...e){return this.check(si(...e))},startsWith(...e){return this.check(ai(...e))},endsWith(...e){return this.check(ci(...e))},min(...e){return this.check(Dn(...e))},max(...e){return this.check(Ar(...e))},length(...e){return this.check(Pr(...e))},nonempty(...e){return this.check(Dn(1,...e))},lowercase(e){return this.check(oi(e))},uppercase(e){return this.check(ii(e))},trim(){return this.check(li())},normalize(...e){return this.check(ui(...e))},toLowerCase(){return this.check(di())},toUpperCase(){return this.check(pi())},slugify(){return this.check(fi())}})),nh=b("ZodString",(e,n)=>{xr.init(e,n),jd.init(e,n)},{email(e){return this.check(nl(sh,e))},url(e){return this.check(al(ch,e))},jwt(e){return this.check(kl(Sh,e))},emoji(e){return this.check(cl(uh,e))},guid(e){return this.check(tl(ah,e))},uuid(e){return this.check(rl(Tr,e))},uuidv4(e){return this.check(ol(Tr,e))},uuidv6(e){return this.check(il(Tr,e))},uuidv7(e){return this.check(sl(Tr,e))},nanoid(e){return this.check(ul(lh,e))},cuid(e){return this.check(ll(dh,e))},cuid2(e){return this.check(dl(ph,e))},ulid(e){return this.check(pl(fh,e))},base64(e){return this.check(wl(xh,e))},base64url(e){return this.check(xl(vh,e))},xid(e){return this.check(fl(mh,e))},ksuid(e){return this.check(ml(gh,e))},ipv4(e){return this.check(gl(hh,e))},ipv6(e){return this.check(hl(yh,e))},cidrv4(e){return this.check(yl(bh,e))},cidrv6(e){return this.check(bl(wh,e))},e164(e){return this.check(vl(kh,e))},datetime(e){return this.check(Sl(th,e))},date(e){return this.check(Il(rh,e))},time(e){return this.check(El(oh,e))},duration(e){return this.check(Cl(ih,e))}});function _(e){return el(nh,e)}var le=b("ZodStringFormat",(e,n)=>{ie.init(e,n),jd.init(e,n)}),th=b("ZodISODateTime",(e,n)=>{au.init(e,n),le.init(e,n)}),rh=b("ZodISODate",(e,n)=>{cu.init(e,n),le.init(e,n)}),oh=b("ZodISOTime",(e,n)=>{uu.init(e,n),le.init(e,n)}),ih=b("ZodISODuration",(e,n)=>{lu.init(e,n),le.init(e,n)}),sh=b("ZodEmail",(e,n)=>{Hc.init(e,n),le.init(e,n)});var ah=b("ZodGUID",(e,n)=>{Gc.init(e,n),le.init(e,n)});var Tr=b("ZodUUID",(e,n)=>{Wc.init(e,n),le.init(e,n)});var ch=b("ZodURL",(e,n)=>{Xc.init(e,n),le.init(e,n)});var uh=b("ZodEmoji",(e,n)=>{eu.init(e,n),le.init(e,n)});var lh=b("ZodNanoID",(e,n)=>{nu.init(e,n),le.init(e,n)});var dh=b("ZodCUID",(e,n)=>{tu.init(e,n),le.init(e,n)});var ph=b("ZodCUID2",(e,n)=>{ru.init(e,n),le.init(e,n)});var fh=b("ZodULID",(e,n)=>{ou.init(e,n),le.init(e,n)});var mh=b("ZodXID",(e,n)=>{iu.init(e,n),le.init(e,n)});var gh=b("ZodKSUID",(e,n)=>{su.init(e,n),le.init(e,n)});var hh=b("ZodIPv4",(e,n)=>{du.init(e,n),le.init(e,n)});var yh=b("ZodIPv6",(e,n)=>{fu.init(e,n),le.init(e,n)});var bh=b("ZodCIDRv4",(e,n)=>{mu.init(e,n),le.init(e,n)});var wh=b("ZodCIDRv6",(e,n)=>{gu.init(e,n),le.init(e,n)});var xh=b("ZodBase64",(e,n)=>{yu.init(e,n),le.init(e,n)});var vh=b("ZodBase64URL",(e,n)=>{bu.init(e,n),le.init(e,n)});var kh=b("ZodE164",(e,n)=>{wu.init(e,n),le.init(e,n)});var Sh=b("ZodJWT",(e,n)=>{xu.init(e,n),le.init(e,n)});var $d=b("ZodNumber",(e,n)=>{Ho.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>bi(e,t,r,o),e.isFinite=!0},_a({minValue:(e)=>{let{minimum:n,exclusiveMinimum:t}=_e(e);return Math.max(n??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:n,exclusiveMaximum:t}=_e(e);return Math.min(n??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:n,multipleOf:t}=_e(e);return!!n||!!t?.some(Number.isSafeInteger)},format:(e)=>_e(e).format??null},{gt(e,n){return this.check(Or(e,n))},gte(e,n){return this.check(ht(e,n))},min(e,n){return this.check(ht(e,n))},lt(e,n){return this.check(Cr(e,n))},lte(e,n){return this.check(gt(e,n))},max(e,n){return this.check(gt(e,n))},int(e){return this.check(ge(e))},safe(e){return this.check(ge(e))},positive(e){return this.check(Or(0,e))},nonnegative(e){return this.check(ht(0,e))},negative(e){return this.check(Cr(0,e))},nonpositive(e){return this.check(gt(0,e))},multipleOf(e,n){return this.check(Rr(e,n))},step(e,n){return this.check(Rr(e,n))},finite(){return this}}));function me(e){return Ol($d,e)}var Ih=b("ZodNumberFormat",(e,n)=>{vu.init(e,n),$d.init(e,n)});function ge(e){return Rl(Ih,e)}var Eh=b("ZodBoolean",(e,n)=>{ku.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>wi(e,t,r,o)});function he(e){return Al(Eh,e)}var Ch=b("ZodNull",(e,n)=>{Su.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>xi(e,t,r,o)});function Oh(e){return Pl(Ch,e)}var Rh=b("ZodUnknown",(e,n)=>{Iu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>ki(e,t,r,o)});function zr(){return _l(Rh)}var Ah=b("ZodNever",(e,n)=>{Eu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>vi(e,t,r,o)});function ln(e){return jl(Ah,e)}var Ph=b("ZodArray",(e,n)=>{Dr(),Cu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Oi(e,t,r,o),e.element=n.element},{min(e,n){return this.check(Dn(e,n))},nonempty(e){return this.check(Dn(1,e))},max(e,n){return this.check(Ar(e,n))},length(e,n){return this.check(Pr(e,n))},unwrap(){return this.element}});function P(e,n){return $l(Ph,e,n)}var Nd=b("ZodObject",(e,n)=>{Dr(),Au.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ri(e,t,r,o),ag(e,"shape",(t)=>t._zod.def.shape,!1)},{keyof(){return ae(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ve(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ve(this._zod.def,{catchall:zr()}))},loose(){return this.clone(Ve(this._zod.def,{catchall:zr()}))},strict(){return this.clone(Ve(this._zod.def,{catchall:ln()}))},strip(){return this.clone(Ve(this._zod.def,{catchall:void 0}))},extend(e){return Xm(this,e)},safeExtend(e){return eg(this,e)},merge(e){return ng(this,e)},pick(e){return Qm(this,e)},omit(e){return Ym(this,e)},partial(...e){return Oa(Dd,this,e[0])},exactPartial(...e){return Oa(Vd,this,e[0],"exactPartial")},required(...e){return tg(Zd,this,e[0])}});function A(e,n){let t={type:"object",shape:e??{},...j(n)};return new Nd(t)}function v(e,n){return new Nd({type:"object",shape:e,catchall:ln(),...j(n)})}var Td=b("ZodUnion",(e,n)=>{Qo.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ai(e,t,r,o),e.options=n.options});function Q(e,n){return new Td({type:"union",options:e,...j(n)})}var _h=b("ZodDiscriminatedUnion",(e,n)=>{Td.init(e,n),Pu.init(e,n)});function Vr(e,n,t){return new _h({type:"union",options:n,discriminator:e,...j(t)})}var jh=b("ZodIntersection",(e,n)=>{_u.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Pi(e,t,r,o)});function $h(e,n){return new jh({type:"intersection",left:e,right:n})}var Rd=b("ZodRecord",(e,n)=>{Dr(),ju.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_i(e,t,r,o),e.keyType=n.keyType,e.valueType=n.valueType});function se(e,n,t){if(!n||!n._zod)return new Rd({type:"record",keyType:_(),valueType:e,...j(n)});return new Rd({type:"record",keyType:e,valueType:n,...j(t)})}var Fi=b("ZodEnum",(e,n)=>{$u.init(e,n),re.init(e,n),e._zod.processJSONSchema=(r,o,i)=>Si(e,r,o,i),e.enum=n.entries,e.options=[...e._zod.values];let t=new Set(Object.keys(n.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(t.has(s))i[s]=n.entries[s];else throw Error(`Key ${s} not found in enum`);return new Fi({...n,checks:[],...j(o),entries:i})},e.exclude=(r,o)=>{let i={...n.entries};for(let s of r)if(t.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Fi({...n,checks:[],...j(o),entries:i})}});function ae(e,n){let t=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Fi({type:"enum",entries:t,...j(n)})}var Nh=b("ZodLiteral",(e,n)=>{Nu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ii(e,t,r,o),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function E(e,n){return new Nh({type:"literal",values:Array.isArray(e)?e:[e],...j(n)})}var Th=b("ZodTransform",(e,n)=>{Dr(),Tu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ci(e,t,r,o),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new ut(e.constructor.name);t.addIssue=(i)=>{if(typeof i==="string")t.issues.push(Sn(i,t.value,n));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=t.value;s.inst??(s.inst=e),t.issues.push(Sn(s))}};let o=n.transform(t.value,t);if(o instanceof Promise)return o.then((i)=>(t.value=i,t));return t.value=o,t}});function zd(e){return new Th({type:"transform",transform:e})}var Dd=b("ZodOptional",(e,n)=>{Yo.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_r(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Ad(e){return new Dd({type:"optional",innerType:e})}var Vd=b("ZodExactOptional",(e,n)=>{zu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_r(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function zh(e){return new Vd({type:"optional",innerType:e})}var Dh=b("ZodNullable",(e,n)=>{Du.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>ji(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Pd(e){return new Dh({type:"nullable",innerType:e})}var Vh=b("ZodDefault",(e,n)=>{Vu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ti(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Zh(e,n){return new Vh({type:"default",innerType:e,get defaultValue(){return typeof n==="function"?n():_o(n)}})}var Mh=b("ZodPrefault",(e,n)=>{Zu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>zi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Fh(e,n){return new Mh({type:"prefault",innerType:e,get defaultValue(){return typeof n==="function"?n():_o(n)}})}var Zd=b("ZodNonOptional",(e,n)=>{Mu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>$i(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Jh(e,n){return new Zd({type:"nonoptional",innerType:e,...j(n)})}var Lh=b("ZodCatch",(e,n)=>{Fu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Di(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qh(e,n){return new Lh({type:"catch",innerType:e,catchValue:typeof n==="function"?n:ja(n)})}var Md=b("ZodPipe",(e,n)=>{Xo.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Vi(e,t,r,o),e.in=n.in,e.out=n.out});function _d(e,n){return new Md({type:"pipe",in:e,out:n})}var Uh=b("ZodPreprocess",(e,n)=>{Md.init(e,n),Ju.init(e,n)}),Kh=b("ZodReadonly",(e,n)=>{Lu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Bh(e){return new Kh({type:"readonly",innerType:e})}var Gh=b("ZodLazy",(e,n)=>{qu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Mi(e,t,r,o),e.unwrap=()=>e._zod.def.getter()});function Wh(e){return new Gh({type:"lazy",getter:e})}var Hh=b("ZodCustom",(e,n)=>{Uu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ei(e,t,r,o)});function Qh(e,n={}){return Nl(Hh,e,n)}function Yh(e,n){return Tl(e,n)}function Ke(e){let n=Wh(()=>Q([_(e),me(),he(),Oh(),P(n),se(_(),n)]));return n}function Xh(e,n){return new Uh({type:"pipe",in:zd(e),out:n})}function St(e,n=0){if(n>64)throw TypeError("Value exceeds the maximum JSON depth.");if(e!=null&&typeof e=="object")for(let t of Object.values(e))St(t,n+1)}var dn=P(Q([A({type:E("cron"),expression:_(),timezone:_()}),A({type:E("every"),unit:ae(["day","hour","minute","month","week"]),value:me()})]));var Ji=["GET","POST","PUT","PATCH","DELETE"];var Lr=6,x=_(),Cn=Ke(),Et=P(x),qr=A({description:x.optional(),jsonSchema:Cn,nullable:he(),handle:x}),Je=qr.extend({value:Cn.optional()}),Fd=A({collapsed:he().optional(),group:x}),ey=A({kind:E("node"),nodeId:x,output:x,field:x.optional()}),qd=Q([ey,A({kind:E("binding"),bindingId:x})]),Ct=Q([A({kind:E("unset")}),A({kind:E("value"),value:Cn})]),Li=Q([Ct,A({kind:E("sources"),sources:P(qd)})]),ny=se(x,Li),Jn={inputs:P(Q([Je,Fd])),outputs:P(Q([qr,Fd]))},ty=v({kind:E("connector"),action:x,connectionId:x.optional(),connections:P(v({connectionId:x,alias:x.optional()}))}),Mr=Q([ty,v({kind:E("connector"),mode:E("shared")}),v({kind:E("connector"),mode:E("independent"),actions:P(v({action:x,connectionId:x.optional()}))}),v({kind:E("connector"),actionHints:P(x).optional(),connectionHints:P(v({action:x,connectionId:x,alias:x.optional()})).optional()})]),qi=A({...Jn,name:x,moduleId:x,capabilities:P(Mr).optional()}),Ud=Q([A({kind:E("value"),value:Cn}),A({kind:E("input"),input:x})]),ry=Q([Ud,A({kind:E("model")})]),oy=Vr("type",[v({name:x,instructions:x,type:E("noul"),criteria:v({true:x.optional(),false:x.optional()}).optional()}),v({name:x,instructions:x,type:E("choice"),criteria:P(v({name:x,description:x}))}),v({name:x,instructions:x,type:E("score"),criteria:Et})]),Fn=A({...Jn,name:x,executor:Q([A({kind:E("connector"),action:x,connectionId:x.optional()}),A({kind:E("openapi"),sourceUrl:x,method:x,path:x,serverUrl:x,document:Cn,auth:P(A({id:x,type:ae(["bearer","basic","apiKey"]),name:x.optional(),in:ae(["header","query"]).optional()}))}),v({kind:E("decision"),questions:P(oy)}),A({kind:E("llm"),mode:ae(["chat","json"])}),A({kind:E("agent"),code:he().optional(),model:x,prompt:x,maxRounds:me(),tools:P(A({id:x,name:x,description:x,action:x,connectionId:x.optional(),approval:he(),inputs:P(Je.extend({source:ry}))})),notification:A({action:x,connectionId:x.optional(),inputDefinitions:P(Je),messageHandle:x,inputs:se(x,Ud)}).optional()})])}),Ui=Fn.transform(Qd),Jd=Q([A({kind:E("value"),value:Cn.optional(),jsonSchema:Cn.optional()}),A({kind:E("source"),source:qd})]),Fr={matchMode:ae(["first","all"]),cases:P(A({description:x.optional(),output:x,groups:P(A({expressions:P(A({left:Jd,operator:ae(["!=","<","<=","==",">",">=","contains","endsWith","hasKey","hasValue","isEmpty","isFalse","isNotEmpty","isNotNull","isNull","isTrue","notContains","notHasKey","notHasValue","startsWith"]),right:Jd.optional()}))}))}))},Ot={inputDefinitions:P(Je),prompt:x},iy=A({allowedMethods:ln().optional(),allowedOrigins:Et.optional(),noResponseBody:ln().optional(),responseData:x.optional(),responseHeaders:se(x,x).optional(),responseStatusCode:me().int().min(200).max(599).optional()}),Jr={bodyFields:P(Je),method:ae(Ji),options:iy.optional()},Ld={configInputs:Jn.inputs,definitionVersion:E(2),description:x,displayName:x,key:x,name:x,outputs:P(qr).refine((e)=>new Set(e.map((n)=>n.handle)).size===e.length,"Duplicate Trigger output handle."),provider:x},sy=A({body:A({allowArray:he(),allowEmpty:he(),formats:P(ae(["form","json","multipart","text"]))}),methods:P(ae(["DELETE","GET","HEAD","PATCH","POST","PUT"])),successStatus:me()}),Ki=P(x.min(1)).refine((e)=>new Set(e).size===e.length,"Duplicate source Flow ID."),Mn={name:x,description:x.optional(),icon:x.optional()},It={maxExecutions:me().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),inputs:ny,name:x.optional(),description:x.optional(),icon:x.optional(),timeoutMs:me().optional()},Zr=Q([A({...It,inputs:se(x,ln()),kind:E("condition"),...Fr}),A({...It,inputs:zr().transform(()=>({})).default({}),kind:E("value"),values:P(Je)}),A({...It,kind:E("task"),task:Q([qi,Ui]),additionalInputs:P(Je).optional()}),v({...It,kind:E("approval"),...Ot}).omit({timeoutMs:!0}),v({...It,kind:E("wait"),...Ot}).omit({timeoutMs:!0}),A({...Mn,kind:E("manual")}),v({...Mn,kind:E("error"),sourceFlowIds:Ki.optional()}),A({...Mn,kind:E("webhook"),...Jr}),A({...Mn,kind:E("cron"),cronTimes:dn}),A({...Mn,kind:E("poll"),connectionId:x.min(1).optional(),config:se(x,Ct),definition:A({...Ld,type:E("poll")}),pollTimes:dn}),A({...Mn,kind:E("integration"),connectionId:x.min(1).optional(),config:se(x,Ct),definition:A({...Ld,type:E("integration"),endpoint:sy})})]),Le={input:Je,port:qr,ports:Jn,condition:v(Fr),wait:v(Ot),webhook:v(Jr),schedule:dn,capabilities:P(Mr),connector:Fn.shape.executor.options[0].omit({kind:!0}).strict(),openapi:Fn.shape.executor.options[1].omit({kind:!0}).strict(),decision:Fn.shape.executor.options[2].omit({kind:!0}).strict(),llm:Fn.shape.executor.options[3].omit({kind:!0}).strict(),agent:Fn.shape.executor.options[4].omit({kind:!0,notification:!0}).strict()},Bi=A({source:x,target:x,sourceHandle:x.optional()}),xe={nodeId:x,target:ln().optional()},ay=A({nodes:se(x,Zr),edges:P(Bi).default([])}),Kd=A({kind:E("variable"),target:x}),Bd=A({name:x,imports:Et,source:x}),cy=Xh(uy,A({bindings:se(x,Kd),graph:ay})),Gd=A({modelVersion:Q([E(2),E(4),E(5),E(Lr)]),document:cy,modules:se(x,Bd)}),Tk=Gd.extend({kind:E("open-flow-flow-revision"),version:E(1)});function uy(e){let n=En(e);if(n.tasks!==void 0&&(n.tasks===null||typeof n.tasks!=="object"||Array.isArray(n.tasks)||Object.keys(n.tasks).length>0))throw TypeError("Independent Task definitions are no longer supported.");if(Object.values(En(En(n.graph).nodes)).some((r)=>Object.hasOwn(En(r),"taskId")))throw TypeError("Task references are no longer supported.");let t=n.subflows;if(t!==void 0&&(t===null||typeof t!=="object"||Array.isArray(t)||Object.keys(t).length>0))throw TypeError("Subflows are no longer supported.");if(Object.values(En(En(n.graph).nodes)).some((r)=>En(r).kind==="subflow"))throw TypeError("Subflow nodes are no longer supported.");return e}function En(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Gi(e){St(e);let n=Gd.parse(e);return dy(n),Oo(n.document),n}var ly={"graph.trigger.sources.set":{nodeId:x,before:Ki.optional(),value:Ki.optional()},"binding.create":{bindingId:x,binding:Kd},"binding.delete":{bindingId:x},"binding.target.set":{bindingId:x,before:x,value:x},"graph.edge.connect":{edge:Bi,target:ln().optional()},"graph.edge.disconnect":{edge:Bi,target:ln().optional()},"graph.node.create":{...xe,node:Zr},"graph.node.replace":{...xe,before:Zr,node:Zr},"graph.node.delete":xe,"graph.node.field.set":Q([A({...xe,kind:E("graph.node.field.set"),field:E("connectionId"),before:x.min(1).optional(),value:x.min(1).optional()}),A({...xe,kind:E("graph.node.field.set"),field:ae(["description","icon","name"]),before:x.optional(),value:x.optional()}),A({...xe,kind:E("graph.node.field.set"),field:E("maxExecutions"),before:me().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),value:me().int().positive().max(Number.MAX_SAFE_INTEGER).optional()}),A({...xe,kind:E("graph.node.field.set"),field:E("timeoutMs"),before:me().optional(),value:me().optional()})]),"graph.node.input.set":{...xe,handle:x,before:Li.optional(),value:Li.optional()},"graph.node.additional-inputs.set":{...xe,before:P(Je).optional(),value:P(Je).optional()},"graph.node.condition.set":{...xe,before:A(Fr),value:A(Fr)},"graph.node.values.set":{...xe,before:P(Je),value:P(Je)},"graph.node.resolution.set":{...xe,before:A(Ot),value:A(Ot)},"graph.node.webhook.set":{...xe,before:A(Jr),value:A(Jr)},"graph.node.task.ports.set":{...xe,before:A(Jn),value:A(Jn)},"graph.node.task.name.set":{...xe,before:x,value:x},"graph.node.task.capabilities.set":{...xe,before:P(Mr).optional(),value:P(Mr).optional()},"graph.trigger.config.set":{nodeId:x,name:x,before:Ct.optional(),value:Ct.optional()},"graph.trigger.schedule.set":{nodeId:x,before:dn,value:dn},"module.create":{moduleId:x,module:Bd},"module.delete":{moduleId:x},"module.rename":{moduleId:x,before:x,name:x},"module.source.replace":{moduleId:x,beforeImports:Et,beforeSource:x,imports:Et,source:x},"graph.node.task.set":{...xe,before:Q([qi,Ui]),value:Q([qi,Ui])}},Wd=new Map(Object.entries(ly).map(([e,n])=>[e,n instanceof re?n:A({kind:E(e),...n})])),zk=P(Q([...Wd.values()])).min(1);function Rt(e,n,t){try{return t(e)}catch(r){if(!(r instanceof Yg))throw r;throw TypeError(`operations[${n}]: ${r.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,{cause:r})}}function Hd(e,n){let{kind:t}=Rt(e,n,A({kind:x}).parse),r=Wd.get(t);if(r==null)throw TypeError(`operations[${n}]: Unknown operation ${JSON.stringify(t)}.`);return Rt(e,n,r.parse)}function dy(e){if(e.modelVersion<6&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="task"&&("executor"in n.task)))throw TypeError("Node-owned managed Tasks require Flow model version 6.");if(e.modelVersion<5&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="error"))throw TypeError("Error workflows require Flow model version 5.")}var yy=new Set(["const","enum","exclusiveMaximum","exclusiveMinimum","maximum","maxItems","maxLength","maxProperties","minimum","minItems","minLength","minProperties","multipleOf","pattern","required","type"]);function Hi(e){return yy.has(e)}var Qi=80;function Ur(e){let n=e.trim();if(n.length==0)return"empty";if(n.length>Qi)return"tooLong";for(let t of n){let r=t.charCodeAt(0);if(r<=31||r>=127&&r<=159)return"controlCharacter"}if(!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(n))return"specialCharacter"}var Yd=0;function pn(){let e=Yd;return Yd+=1,e}function qn(e){if(typeof e==="object"&&e!==null&&!Object.isFrozen(e)){for(let n of Object.getOwnPropertyNames(e)){let t=Reflect.get(e,n);qn(t)}Object.freeze(e)}return e}function Yi(e,n){let t={};for(let r of n)if(r in e)t[r]=e[r];return t}function Kr(e){if(typeof e!=="object"||e===null)return e;else if(Array.isArray(e)){let n=[];for(let[t,r]of e.entries())n[t]=Kr(r);return n}else{let n={};for(let t in e)n[t]=Kr(e[t]);return n}}function Ln(e,n){if(e===n)return!0;if(e===null)return!1;if(typeof e!=="object")return!1;if(typeof e!==typeof n)return!1;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!==n.length)return!1;for(let[t,r]of e.entries())if(!Ln(r,n[t]))return!1}else{if(Array.isArray(n))return!1;for(let t in e){if(!(t in n))return!1;if(!Ln(e[t],n[t]))return!1}for(let t in n)if(!(t in e))return!1}return!0}var y=Object.freeze({Equals:0,Containing:1,ContainedBy:2,Rejection:3,Intersection:4}),J=fn(y.Equals),V=fn(y.Containing),Z=fn(y.ContainedBy),q=fn(y.Rejection),G=fn(y.Intersection),rn=qn([[y.Equals,J],[y.Containing,V],[y.ContainedBy,Z],[y.Rejection,q],[y.Intersection,G]]),ee=0,Fe=(()=>{let e=ee;for(let[n,t]of rn)e|=t;return e})();function At(e){return!!(e&J)}function Pt(e){return!!(e&V)}function _t(e){return!!(e&Z)}function jt(e){return!!(e&q)}function $t(e){return!!(e&G)}function fn(e){return 1<<e}function Xi(e){let n=ee,t=0,r={push:(o)=>{if(t===0)n=o;else n=by(n,o,e);return t+=1,n}};return Object.defineProperties(r,{result:{get:()=>n},count:{get:()=>t}}),r}function by(e,n,t){let r=ee;for(let[o,i]of rn)if(i&e){for(let[s,a]of rn)if(a&n){if(r|=t(o,s),r===Fe)return r}}return r}var ce=Object.freeze({Save:0,OneOf:1,AllOf:2,AnyOf:3,Not:4,Swap:5});function Xd(e,n){switch(e){case ce.Save:return n[0];case ce.OneOf:return wy(n);case ce.AllOf:case ce.AnyOf:return Nt(e,n);case ce.Not:case ce.Swap:return es(e,n[0])}}function mn(e){return es(ce.Swap,e)}function wy(e){if(e.length===1)return e[0];let n=Nt(ce.AnyOf,e),t=[];for(let i=0;i<e.length;++i)for(let s=i+1;s<e.length;++s){let a=e[i],c=e[s],u=Nt(ce.AllOf,[a,c]);t.push(u)}let r=Nt(ce.AnyOf,t),o=es(ce.Not,r);return Nt(ce.AllOf,[n,o])}function Nt(e,n){if(n.length<0)throw Error("invalid expressions: empty array");let t;switch(e){case ce.AllOf:{t=Xi(xy);break}case ce.AnyOf:{t=Xi(vy);break}default:throw Error(`invalid operator ${e}`)}for(let r of n)t.push(r);return t.result}function es(e,n){let t,r=ee;switch(e){case ce.Not:{t=ky;break}case ce.Swap:{t=Sy;break}default:throw Error(`invalid operator ${e}`)}for(let[o,i]of rn)if(i&n)r|=t(o);return r}function xy(e,n){let t=ee;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=ee;break}case y.Intersection:{t=Z;break}}break}case y.Containing:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J|V;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=G|Z;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=ee;break}case y.Intersection:{t=Z;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=ee;break}case y.Containing:{t=q;break}case y.ContainedBy:{t=ee;break}case y.Rejection:{t=q;break}case y.Intersection:{t=q;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=G|Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=Z|q|G;break}}break}}return t}function vy(e,n){let t=ee;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=J;break}case y.Rejection:{t=V;break}case y.Intersection:{t=V;break}}break}case y.Containing:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=V;break}case y.Rejection:{t=V;break}case y.Intersection:{t=V;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=J|Z;break}case y.Rejection:{t=G;break}case y.Intersection:{t=V|G;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=G;break}case y.Rejection:{t=q;break}case y.Intersection:{t=G;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=V|G;break}case y.Rejection:{t=G;break}case y.Intersection:{t=V|G;break}}break}}return t}function ky(e){let n=ee;switch(e){case y.Equals:{n=q;break}case y.Containing:{n=q;break}case y.ContainedBy:{n=G;break}case y.Rejection:{n=J|V;break}case y.Intersection:{n=Z|G;break}}return n}function Sy(e){let n=ee;switch(e){case y.Equals:{n=J;break}case y.Containing:{n=Z;break}case y.ContainedBy:{n=V;break}case y.Rejection:{n=q;break}case y.Intersection:{n=G;break}}return n}var je=Object.freeze({Leaf:0,Not:1,AllOf:2,AnyOf:3,OneOf:4});var ns=(e)=>(n,t)=>{let r={parent:null,swapped:!1,expressions:null,calculation:{operator:ce.Save,results:[ee],willSwap:!1,count:0}},o=[{parent:{node:r,index:0},swapped:!1,expressions:[n,t],calculation:null}],i=[];while(o.length>0||i.length>0){while(o.length>0){let l=o.pop();s(l)}while(i.length>0){let l=i.pop();c(l)}}function s(l){let p=J,[m,g]=l.expressions;if(!e.equals(m,g)){let h=e.describe(m);if(h.kind!==je.Leaf){let[N,L]=a(h,!1);l.expressions=null,l.calculation=N;for(let[K,Te]of L.entries())o.push({parent:{node:l,index:K},swapped:l.swapped,expressions:[Te,g],calculation:null});return}let S=e.describe(g);if(S.kind!==je.Leaf){let[N,L]=a(S,!0);l.expressions=null,l.calculation=N;for(let[K,Te]of L.entries())o.push({parent:{node:l,index:K},swapped:!l.swapped,expressions:[Te,m],calculation:null});return}if(p=e.calculate(m,g),e.observeCalculation?.(m,g,p,l.swapped),p===ee)throw Error("cannot response expression as none")}l.expressions=null,l.calculation={operator:ce.Save,results:[p],willSwap:!1,count:0},i.push(l)}function a(l,p){let m=ce.Save,g;switch(l.kind){case je.Not:{m=ce.Not,g=[l.expression];break}case je.AllOf:{m=ce.AllOf,g=[...l.expressions];break}case je.AnyOf:{m=ce.AnyOf,g=[...l.expressions];break}case je.OneOf:{m=ce.OneOf,g=[...l.expressions];break}default:throw Error(`invalid kind ${l.kind}`)}return[{operator:m,willSwap:p,count:0,results:Array(g.length).fill(-1)},g]}function c(l){let{calculation:p,parent:m}=l,g=Xd(p.operator,p.results);if(g===ee)g=Z;if(p.willSwap)g=mn(g);if(m){let h=m.node.calculation,S=h.results;if(S[m.index]=g,h.count+=1,h.count>=S.length)i.push(m.node)}}let u=r.calculation.results[0];if(u===0)throw Error("cannot find result of root");return u};class Br extends Error{constructor(e=[]){super(Iy(e));this.name="SchemaError",this.items=e}}var Un=Object.freeze({Compiled:0,External:1});function Kn(e){switch(e.kind){case Un.Compiled:{let{message:n,path:t}=e;return`${n} (at ${t.length>0?t.join("."):"$root"})`}case Un.External:return String(e.error)}}function Iy(e){switch(e.length){case 0:return"without any items";case 1:return Kn(e[0]);default:return`${Kn(e[0])} ... omit the rest ${e.length-1} items`}}var Ey=new Set(["type","enum","const","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","items","additionalItems","maxItems","minItems","uniqueItems","contains","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames","if","then","else","allOf","anyOf","oneOf","not","format","contentMediaType","contentEncoding","definitions"]);function Xe(e){return Ey.has(e)}function ep(e){for(let n in e)if(Xe(n))return!1;return!0}function Oe(e,...n){return{...e,path:[...e.path,...n]}}function $e(e){if(typeof e==="boolean")throw Error("JSONSchema7Definition cannot be boolean");return e}function gn({path:e,errors:n},t,...r){n.push(np(e,r,t))}function W({path:e,warns:n},t,...r){n.push(np(e,r,t))}function np(e,n,t){return{kind:Un.Compiled,message:t,path:[...e,...n]}}function Gr(e){for(let n in e){let t=e[n];if(t===void 0)delete e[n];else if(t&&typeof t==="object"){if(Array.isArray(t)){if(t.length===0)delete e[n]}else if(Cy(t))delete e[n]}}return e}function Cy(e){for(let n in e)return!1;return!0}var Tt=Symbol("compiledId"),ts=Symbol("compiledKind"),rs=Symbol("compiledPath"),tp=Symbol("validatorLoader"),k=Object.freeze({Extends:0,Never:1,Any:2,Null:3,String:4,Numeric:5,Boolean:6,Object:7,Array:8,Not:9,Combination:10,EnumOrConst:11}),hn=qn(Wr(k.Any,pn(),{},()=>()=>!0)),zt=qn(Wr(k.Never,pn(),{type:"string",maxLength:0,minLength:1},()=>()=>!1));function Dt(e){if(e===null||typeof e!=="object")return!1;return Tt in e}function Ne(e){if(e===null||typeof e!=="object")return!1;return Tt in e&&ts in e}function B(e){if(Ne(e))return e[ts];else return k.Extends}function On(e){if(Ne(e)||Dt(e))return e[Tt];else return e.id}function os(e){return Ne(e)?e[rs]:void 0}function is(e){if(e===null||typeof e!=="object")return e;return Object.defineProperty(e,Tt,{value:pn(),configurable:!1,writable:!1,enumerable:!1}),e}function de(e,n,t,r=[]){return Wr(e,pn(),n,t&&(()=>t.compile(n)),r)}function Vt(e){return Wr(k.Never,pn(),{...e},e[tp],e[rs])}function Wr(e,n,t,r,o=[]){let i=null;return Object.defineProperties(t,{[ts]:{value:e,configurable:!1,writable:!1,enumerable:!1},[Tt]:{value:n,configurable:!1,writable:!1,enumerable:!1},[rs]:{value:o,configurable:!1,writable:!1,enumerable:!1},[tp]:{value:r,configurable:!1,writable:!1,enumerable:!1},isValid:{configurable:!1,enumerable:!1,get:()=>{if(r){if(!i)i=r();return i}else return}}}),t}function ip(e,n){let t=Oy(e,n),r=rp(e,"maxItems",n),o=rp(e,"minItems",n),i=Ry(e,n),s=n.uniqueItems,a;if(Array.isArray(t))a=Ay(e,n);else if(n.additionalItems)W(e,"it is needless when items is not array","additionalItems");if(!t||!i||a===null)return null;let c=!1,u=!1;if(Array.isArray(t)){if(r!==void 0&&r<=t.length)t=t.splice(r),a=op(a,e.delegate);let m=t.findIndex((g)=>B(g)===k.Never);if(m!==-1){if(t=t.splice(m),a=op(a,e.delegate),r===void 0)r=t.length,u=!0}if(o!==void 0&&t.length<o)W(e,`length(${t.length}) of items if less than minItems(${o})`),c=!0;if(t.length===0&&a&&B(a)===k.Never)c=!0}else if(B(t)===k.Never)c=!0;if(r!==void 0&&o!==void 0&&r<o){if(!u)W(e,`maxItems(${r}) is less than minItems(${o})`);c=!0}let l=c?k.Never:k.Array,p=Gr({type:"array",items:t,contains:i,uniqueItems:s,maxItems:r,minItems:o,additionalItems:a});return de(l,p,e.delegate,e.path)}function Oy(e,{items:n}){if(!n)return de(k.Any,{},e.delegate,e.path);if(Array.isArray(n)){let t=[],r=!1;for(let[o,i]of n.entries()){let s=Oe(e,"items",o),a=Re(s,$e(i));if(!a){r=!0;continue}t.push(a)}if(r)return null;return t}else{let t=Oe(e,"items"),r=$e(n);return Re(t,r)}}function rp(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){W(e,"find NaN",n);return}if(r<0){W(e,`find invalid number ${r}`,n);return}return r}function Ry(e,{contains:n}){if(!n)return de(k.Any,{},e.delegate,e.path);let t=Oe(e,"contains"),r=$e(n);return Re(t,r)}function Ay(e,{additionalItems:n}){switch(typeof n){case"boolean":if(n)return de(k.Any,{},e.delegate,e.path);else return!1;case"object":{let t=Oe(e,"additionalItems");return Re(t,n)}default:return de(k.Any,{},e.delegate,e.path)}}function op(e,n){if(e===void 0)return de(k.Never,{type:"string",maxLength:0,minLength:1},n);else if(Ne(e))return B(e)===k.Never?e:Vt(e);else return e}var sp=Object.freeze(["allOf","anyOf","oneOf"]);function ss(e,n,t,r){if(t.length===0)return gn(e,"disable empty list",n),null;let o=[];for(let[c,u]of t.entries()){let l=Oe(e,n,c),p=$e(u),m=Re(l,p);if(m)o.push(m)}if(o.length<t.length)return null;let i=0,s=0;for(let c of o)switch(B(c)){case k.Any:{i+=1;break}case k.Never:{s+=1;break}}let a=k.Combination;switch(n){case"allOf":{if(s>0)a=k.Never;else if(i===o.length)a=k.Any;else if(!Py(o))a=k.Never;break}case"anyOf":{if(i>0)a=k.Any;else if(s===o.length)a=k.Never;break}case"oneOf":{if(i>1)a=k.Never;else if(s===o.length)a=k.Never;else if(i===1&&s===o.length-1)a=k.Any;break}}return de(a,{[n]:o},r,e.path)}function Py(e){let n=null;for(let t of e){let r=B(t);switch(r){case k.Any:case k.Never:break;default:{if(n===null)n=r;else if(n!==r)return!1;break}}}return!0}var Se=Object.freeze({Valid:0,Invalid:1,Unknown:2});function en(e,n){let t=e.isValid;if(t)if(t(n)===!0)return Se.Valid;else return Se.Invalid;else return Se.Unknown}function ap(e,n,t,r){let o,i=!1;if(n){if(n.length===0)return gn(e,"disable empty list","enum"),null;o=[];for(let[c,u]of n.entries())switch(en(r,u)){case Se.Valid:{o.push(is(u));break}case Se.Invalid:{W(e,"cannot pass JSON schema of currently schema object","enum",c);break}}if(o.length===0)W(e,"all of elements from list is rejected by currently schema object","enum")}if(t&&en(r,t)===Se.Invalid)i=!0;if(o){if(o.length===0)i=!0;else if(t){let c=!1;for(let u of o)if(Ln(u,t)){c=!0;break}if(!c)i=!0}}let s=i?k.Never:k.EnumOrConst,a={};if(r.type)a.type=r.type;if(o)a.enum=o;if(t)a.const=is(Kr(t));return de(s,a,e.delegate,e.path)}var _y=new Set(["type","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames"]);function up(e,n){let t=Object.keys(n).filter((h)=>!_y.has(h)&&Xe(h));if(t.length>0)W(e,`type="object" will exclude other keys: ${t.toSorted().join(", ")}`);let r=cp(e,"maxProperties",n),o=cp(e,"minProperties",n),i=jy(e,n),s=$y(e,n),a=Ny(e,n),c=zy(e,n);if(!i||!s||!a||!c)return null;let u=Ty(e,s,a,n);if(!u)return null;let l=Dy(i,s,a,u),p=Vy(e,l,c,n),m=Zy(e,i,u,p,r,o)?k.Never:k.Object,g=Gr({type:"object",required:p,properties:u,minProperties:o,maxProperties:r,additionalProperties:i,patternProperties:Jy(s),dependencies:Ly(c,n),propertyNames:a});return de(m,g,e.delegate,e.path)}function cp(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){W(e,"find NaN",n);return}if(r<0){W(e,`find invalid number ${r}`,n);return}return r}function jy(e,{additionalProperties:n}){if(n===!1)return de(k.Never,{type:"string",maxLength:0,minLength:1},e.delegate,e.path);if(typeof n!=="object")return de(k.Any,{},e.delegate,e.path);let t=Oe(e,"additionalProperties"),r=$e(n);return Re(t,r)}function $y(e,{patternProperties:n}){let t=!1,r={};for(let o in n){let i=Fy(o);if(i instanceof Error){W(e,`property name invalid. ${o}`,"patternProperties",o);continue}let s=$e(n[o]),a=Oe(e,"patternProperties",o),c=Re(a,s);if(!c){t=!0;continue}r[o]=[c,i]}if(t)return null;return r}function Ny(e,{propertyNames:n}){if(!n)return de(k.Any,{},e.delegate,e.path);n=$e(n);let t=Oe(e,"propertyNames"),r=Re(t,n);if(!r)return null;let o=B(r);if(o!==k.String&&o!==k.Any)return Vt(r);return r}function Ty(e,n,t,{properties:r}){let o=!1;if(!r)return{};let i={};for(let s in r){if(en(t,s)===Se.Invalid){W(e,`key ${JSON.stringify(s)} cannot pass JSON schema from propertyNames`,"properties");continue}let a=dp(n,s);if(a&&B(a)===k.Never){W(e,`key ${JSON.stringify(s)} matches a pattern that has a impossible(never) schema`,"properties");continue}let c=$e(r[s]),u=Oe(e,"properties",s),l=Re(u,c);if(!l){o=!0;continue}i[s]=l}if(o)return null;return i}function zy(e,{dependencies:n}){if(!n)return[{},{}];let t={},r={};for(let o in n){let i=$e(n[o]);if(Array.isArray(i)){let{keys:s,duplicated:a}=lp(i);if(a)W(e,`found duplicated property names: ${a.join(", ")}`,"dependencies",o);t[o]=s}else{let s=Oe(e,"dependencies",o),a=Re(s,i);if(a){let c=B(a);if(c===k.Object||c===k.Any)r[o]=a;else if(c===k.Extends)r[o]=zt;else r[o]=Vt(a)}}}return[t,r]}function Dy(e,n,t,r){return(o)=>{if(en(t,o)===Se.Invalid)return!0;let i=dp(n,o);if(i&&B(i)===k.Never)return!0;let s=r[o]??e;if(B(s)===k.Never)return!0;return!1}}function Vy(e,n,t,{required:r}){if(!r)return[];let o=lp(r);if(o.duplicated)W(e,`found duplicated required keys: ${o.duplicated.join(", ")}`,"required");let i=[],s=[];for(let a of o.keys)if(My(t,a).some((u)=>n(u)))s.push(a);else i.push(a);if(s.length>0)W(e,`key ${s.map((a)=>JSON.stringify(a)).join(", ")} will ban by another condition`,"required");return i}function Zy(e,n,t,r,o,i){if(o!==void 0&&i!==void 0&&o<i)return W(e,`maxProperties(${o}) is less than minProperties(${i})`),!0;if(o!==void 0&&r.length>o)return W(e,`length(${r.length}) of required is greater than maxProperties(${o})`),!0;if(i!==void 0&&r.length<i)return W(e,`length(${r.length}) of required is less than minProperties(${i})`),!0;if(B(n)!==k.Never)return!1;for(let s in t){let a=t[s];if(B(a)!==k.Never)return!1}return!0}function My([e,n],t){let r=[t],o=new Set(r);while(r.length>0){let s=r.pop(),a=n[s],c=e[s];if(a){if(B(a)===k.Object)i(a.required)}if(c)i(c)}function i(s){if(s){for(let a of s)if(!o.has(a))o.add(a),r.push(a)}}return[...o]}function lp(e){let n=new Set,t=new Set;for(let r of e)if(n.has(r))t.add(r);else n.add(r);if(t.size===0)return{keys:[...e],duplicated:null};else return{keys:[...n],duplicated:[...t]}}function dp(e,n){for(let t in e){let[r,o]=e[t];if(o.test(n))return r}return null}function Fy(e){try{return new RegExp(e,"i")}catch(n){if(n instanceof SyntaxError)return n;else throw n}}function Jy(e){let n={};for(let t in e)n[t]=e[t][0];return n}function Ly([e,n],{dependencies:t}){let r={};for(let o in t){let i=e[o],s=n[o];r[o]=i||s}return r}var as=new Set(["type","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"]),pp=new Set(["type","format","maxLength","minLength","pattern"]);function mp(e,n){let{type:t}=n;switch(t){case"number":case"integer":return qy(e,n);case"string":return Ky(e,n);case"boolean":case"null":{let r=Object.keys(n).filter((s)=>Xe(s)&&s!=="type");if(r.length>0)W(e,`key "type" will exclude other keys: ${r.toSorted().join(", ")}`);let o=t==="null"?k.Null:k.Boolean;return de(o,{type:t},e.delegate,e.path)}default:return gn(e,`invalid type ${JSON.stringify(t)}`),null}}function qy(e,n){let t=Object.keys(n).filter((l)=>!as.has(l)&&Xe(l));if(t.length>0)W(e,`type=${JSON.stringify(n.type)} will exclude other keys: ${t.toSorted().join(", ")}`);let r=Yi(n,as);for(let l of as){let p=r[l];if(l!=="type"&&p!==void 0&&Number.isNaN(p))W(e,"found NaN",l),delete r[l]}let{maximum:o,exclusiveMaximum:i,minimum:s,exclusiveMinimum:a}=r;if(o!==void 0&&i!==void 0){if(o===i)delete r.maximum;else if(o<i)delete r.exclusiveMaximum;else if(o>i)delete r.maximum}if(s!==void 0&&a!==void 0){if(s===a)delete r.minimum;else if(s<a)delete r.exclusiveMinimum;else if(s>a)delete r.minimum}let{multipleOf:c}=r;if(c===0)delete r.multipleOf,r.type="number",W(e,"cannot be 0","multipleOf");let u=k.Numeric;if(!Uy(r))u=k.Never;return de(u,r,e.delegate,e.path)}function Uy(e){let{maximum:n,exclusiveMaximum:t,minimum:r,exclusiveMinimum:o}=e;if(n!==void 0&&r!==void 0)return n>=r;else if(t!==void 0&&r!==void 0)return t>r;else if(n!==void 0&&o!==void 0)return n>o;else if(t!==void 0&&o!==void 0)return t>o;else return!0}function Ky(e,n){let t=Object.keys(n).filter((a)=>!pp.has(a)&&Xe(a));if(t.length>0)W(e,`type="string" will exclude other keys: ${t.toSorted().join(", ")}`);let r=Yi(n,pp);fp(e,r,"maxLength"),fp(e,r,"minLength");let{maxLength:o,minLength:i}=r,s=k.String;if(o!==void 0){if(o<0)s=k.Never;else if(o!==void 0&&i!==void 0&&o<i)s=k.Never}return de(s,r,e.delegate,e.path)}function fp(e,n,t){let r=n[t];if(r!==void 0){if(Number.isNaN(r))W(e,"found NaN",t),delete n[t]}}var gp=Object.freeze([]);function Hr(e,n,t,r){if(Ne(e))return{schema:e,warns:gp};if(n.isExtendsSchema(e))return{schema:e,warns:gp};if(r){let s=r.isSchema(e);if(typeof s==="object"){let a=[];for(let c of s)a.push({kind:Un.External,error:c});if(a.length>0)return a}else if(s===!1)throw Error("it is not a JSON Schema 7")}let o={delegate:r,payload:t,extends:n,path:[],errors:[],warns:[]},i=Re(o,e);if(i)hp(o.errors.length===0,"found errors (it should be empty)");else return hp(o.errors.length>0,"cannot found any errors"),o.errors;return{schema:i,warns:o.warns}}function hp(e,n){if(!e)throw Error(n)}function Re(e,n){if(e.extends.isExtendsSchema(n))return n;if(Ne(n))return n;let t=e.extends.tryCompiledExtendsSchema(n,e.payload);if(t)return t;let r=n,o=!1,{enum:i,const:s}=n;if(i||s){let{enum:c,const:u,...l}=n;r=l,o=!0}let a=By(e,r);if(a&&o)a=ap(e,i,s,a);if(!a)return null;return a}function By(e,n){for(let t of sp){let r=n[t];if(r){let o=Object.keys(n).filter((s)=>Xe(s)&&s!==t);if(o.length>0)W(e,`composition key ${JSON.stringify(t)} will exclude other keys: ${o.toSorted().join(", ")}`);let i=ss(e,t,r);if(!i)return null;return i}}{let t=$e(n.not);if(t){let r=Object.keys(n).filter((a)=>Xe(a)&&a!=="not");if(r.length>0)W(e,`key "not" will exclude other keys: ${r.toSorted().join(", ")}`);let o=Oe(e,"not"),i=Re(o,t);if(!i)return null;let s=k.Not;switch(B(i)){case k.Never:{s=k.Any;break}case k.Any:{s=k.Never;break}}return de(s,{not:i},e.delegate,e.path)}}if(n.type){let{type:t}=n;if(Array.isArray(t)){let{type:r,...o}=n;return ss(e,"anyOf",t.map((i)=>({...o,type:i})))}switch(t){case"object":return up(e,n);case"array":return ip(e,n);default:return mp(e,n)}}if(ep(n))return de(k.Any,{},e.delegate,e.path);return gn(e,"unrecognized"),null}class cs{constructor(e){let n=Object.freeze(e.toSorted());if(n.length>32)throw Error(`cannot define ${n.length} keys which is greater than 32`);this.keys=n,this.clazz=class extends yp{constructor(t){super(n,t)}};for(let[t,r]of this.keys.entries()){let o=1<<t;Object.defineProperty(this.clazz.prototype,r,{enumerable:!0,get:function(){return!!(this.int32&o)},set:function(s){if(s)this.int32|=o;else this.int32&=~o}})}}toBundle(e){let n=0;if(typeof e==="number")n=e;else if(e){for(let[t,r]of this.keys.entries())if(e[r])n|=1<<t}return new this.clazz(n)}}class yp{constructor(e,n){this.keys=e,this.int32=n}toInt32(){return this.int32}toString(){let e={};for(let n of this.keys)e[n]=this[n];return JSON.stringify(e)}}function Qr(e){return new bp(e)}class bp{constructor(e){this.description=new cs(e)}get keys(){return this.description.keys}variable(e){let n;if(e)n=this.description.toBundle(e).toInt32();return new wp(this.description,n)}}class wp{constructor(e,n){this.values=new Set;if(this.description=e,n!==void 0)this.values.add(n)}[Symbol.iterator](){let e=this.values[Symbol.iterator]();return{next:()=>{let n=e.next();if(n.done)return n;else return{done:!1,value:this.description.toBundle(n.value)}}}}assign(e){let{values:n}=e;for(let t of n)this.values.add(t);return this}push(e,n){let t=new Set;for(let r of this.values)for(let[o,i]of rn)if(e&i){let s=this.description.toBundle(r);n(o,s),t.add(s.toInt32())}this.values=t}update(e){let n=new Set;for(let t of this.values){let r=this.description.toBundle(t);e(r),n.add(r.toInt32())}this.values=n}}function yn(e,n){let[t]=e,[r]=n;if(t.num<r.num)return Gy(e,n);else if(t.num>r.num)return Wy(e,n);else return Hy(e,n)}function Gy(e,n){let[t,r]=e,[o,i]=n;if(r.num<=o.num){let s=r.exclusive,a=o.exclusive;if(r.num<o.num||s||a)return{left:{fromLeft:!0,range:e},right:{fromLeft:!1,range:n}}}if(r.num<=i.num){let s=!0,a=!1;if(r.num===i.num){let c=r.exclusive,u=i.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!1,range:[qe(r),i]};return{left:{fromLeft:!0,range:[t,qe(o)]},center:[o,r],right:c}}}return{left:{fromLeft:!0,range:[t,qe(o)]},center:[o,i],right:{fromLeft:!0,range:[qe(i),r]}}}function Wy(e,n){let[t,r]=e,[o,i]=n;if(t.num>=i.num){let s=i.exclusive,a=t.exclusive;if(t.num>i.num||s||a)return{left:{fromLeft:!1,range:n},right:{fromLeft:!0,range:e}}}if(i.num<=r.num){let s=!0,a=!1;if(r.num===i.num){let c=i.exclusive,u=r.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!0,range:[qe(i),r]};return{left:{fromLeft:!1,range:[o,qe(t)]},center:[t,i],right:c}}}return{left:{fromLeft:!1,range:[o,qe(t)]},center:[t,r],right:{fromLeft:!1,range:[qe(r),i]}}}function Hy(e,n){let[t,r]=e,[o,i]=n,s=t.exclusive,a=o.exclusive,c,u=t;if(!s&&a)u=o,c={fromLeft:!0,range:[t,qe(o)]};else if(s&&!a)c={fromLeft:!1,range:[o,qe(t)]};if(r.num<=i.num){let l=!0,p=!1;if(r.num===i.num){let m=r.exclusive,g=i.exclusive;l=m!==g,p=!m&&g}if(!p){let m;if(l)m={fromLeft:!1,range:[qe(r),i]};return{left:c,center:[u,r],right:m}}}return{left:c,center:[u,i],right:{fromLeft:!0,range:[qe(i),r]}}}function qe(e){return{num:e.num,exclusive:!e.exclusive}}var Bn=(e)=>(n=e,t=Number.POSITIVE_INFINITY,r=e,o=Number.POSITIVE_INFINITY)=>{let{left:i,center:s,right:a}=yn([{num:n,exclusive:!1},{num:t,exclusive:!1}],[{num:r,exclusive:!1},{num:o,exclusive:!1}]),c,u,l;if(i)c={min:i.range[0].num,max:i.range[1].num,isFrom1:i.fromLeft};if(a)u={min:a.range[0].num,max:a.range[1].num,isFrom1:a.fromLeft};if(s)l={min:s[0].num,max:s[1].num};return{left:c,right:u,intersection:l}};function Gn({left:e,right:n,intersection:t}){if(!t)return y.Rejection;let r=!1,o=!1;if(e)if(e.isFrom1)r=!0;else o=!0;if(n)if(n.isFrom1)r=!0;else o=!0;if(r&&o)return y.Intersection;if(r)return y.Containing;if(o)return y.ContainedBy;return y.Equals}var Qy=Bn(0),Yy=Qr(["hasCommon","hasExtra1","hasExtra2","hasRejection","hasCommonBroken"]);function vp({calculate:e},n,t){let r=Qy(n.minItems,n.maxItems,t.minItems,t.maxItems),o=Gn(r);if(o===y.Rejection)return q;let[i,s]=xp(n),[a,c]=xp(t),u=Math.max(i.length,a.length)+1,l=Math.min(u,r.intersection.max),p=Yy.variable({}),m=Math.min(n.minItems??0,t.minItems??0);for(let h=0;h<l;h++){let S=i[h]??s,R=a[h]??c,N=e(S,R);p.push(N,(L,K)=>{switch(L){case y.Equals:{if(!K.hasRejection)K.hasCommon=!0;break}case y.Containing:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra1=!0;break}case y.ContainedBy:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra2=!0;break}case y.Intersection:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra1=!0,K.hasExtra2=!0;break}case y.Rejection:{if(h<m)K.hasCommonBroken=!0;K.hasRejection=!0,K.hasExtra1=!0,K.hasExtra2=!0;break}}})}p.update((h)=>{switch(o){case y.Containing:{h.hasExtra1=!0;break}case y.ContainedBy:{h.hasExtra2=!0;break}case y.Intersection:{h.hasExtra1=!0,h.hasExtra2=!0;break}}if(n.uniqueItems&&!t.uniqueItems&&(t.maxItems??Number.POSITIVE_INFINITY)>1)h.hasExtra2=!0;else if(!n.uniqueItems&&t.uniqueItems&&(n.maxItems??Number.POSITIVE_INFINITY)>1)h.hasExtra1=!0;if(n.maxItems===0||t.maxItems===0){if(h.hasCommon=!0,n.maxItems!==0)h.hasExtra1=!0;if(t.maxItems!==0)h.hasExtra2=!0}});let g=ee;for(let{hasExtra1:h,hasExtra2:S,hasCommon:R,hasCommonBroken:N}of p){let L=R;if(N)L=!1;if(!L)g|=q;else if(h&&S)g|=G;else if(h)g|=V;else if(S)g|=Z;else g|=J}return g}function xp({items:e,additionalItems:n}){if(Array.isArray(e))return[e,n??hn];else return[[],e??hn]}function kp(e){let n=new Map;return(t,r)=>{let o=Dt(t),i=Dt(r);if(o!==i)return!1;if(!o)return t===r;return Ip(n,t,r,e)}}function Sp(e){let n=new Map;return(t,r)=>Ip(n,t,r,e)}function Ip(e,n,t,r){let o=On(n),i=On(t),s=`${o}/${i}`,a=e.get(s);if(a===void 0)e.set(s,a=r(n,t));return a}function Cp(e,n,t){let r=us(n),o=us(t),i=!1,s=!1,a=!1;for(let c of r){if(Ep(e,o,c))a=!0;else i=!0;if(i&&a)break}for(let c of o){if(Ep(e,r,c))a=!0;else s=!0;if(s&&a)break}if(!a)return q;if(i&&s)return G;if(i)return V;if(s)return Z;return J}function ls(e,n){let t=!1,r=!1;for(let o of us(e)){switch(en(n,o)){case Se.Valid:{t=!0;break}case Se.Invalid:{r=!0;break}case Se.Unknown:return Fe}if(t&&r)break}if(t&&r)return G;if(t)return J|Z;if(r)return q;if(B(n)===k.Never)return J;return Z}function us({const:e,enum:n}){if(e!==void 0)return[e];if(n)return n;throw Error("invalid branch")}function Ep({isEquals:e},n,t){for(let r of n)if(e(r,t))return!0;return!1}function Op(e){function n(s,a){let c=e.isExtendsSchema(s),u=e.isExtendsSchema(a);if(c||u)return e.equals(s,a);else return r(s,a)}let t=new Map;function r(s,a){let c=On(s),u=On(a);if(c===u)return!0;let l=`${c}/${u}`,p=t.get(l);if(p===void 0)p=o(s,a),t.set(l,p);return p}function o(s,a){if(Array.isArray(s)){if(!Array.isArray(a))return!1;if(s.length!==a.length)return!1;for(let[c,u]of s.entries())if(!i(u,a[c]))return!1}else{if(Array.isArray(a))return!1;for(let c in s){if(!(c in a))return!1;let u=Reflect.get(s,c),l=Reflect.get(a,c);if(!i(u,l))return!1}for(let c in a)if(!(c in s))return!1}return!0}function i(s,a){if(s===a)return!0;if(s===null)return!1;if(typeof s!=="object")return!1;if(typeof s!==typeof a)return!1;if(Ne(s)&&Ne(a))return r(s,a);return o(s,a)}return n}function Zt(e){let n=Mt(e),t=e.multipleOf??1,r=Be(n,t);if(!r)return null;return{multipleOf:t,range:r}}function Rp([e,n]){if(e.num!==n.num)return!1;if(e.exclusive)return!1;if(n.exclusive)return!1;return!0}function Be(e,n){if(!e)return;let[t,r]=e,o=Xy(t.num,n),i=eb(r.num,n);if(o===t.num&&t.exclusive)o+=n;if(i===r.num&&r.exclusive)i-=n;if(o>i)return;if(o===i){if(o===Number.POSITIVE_INFINITY)return;if(o===Number.NEGATIVE_INFINITY)return}return[{num:o,exclusive:!1},{num:i,exclusive:!1}]}function Xy(e,n){return Math.ceil(e/n)*n}function eb(e,n){return Math.floor(e/n)*n}function Pp(e,n){let t=Mt(e),r=Mt(n),{left:o,right:i,center:s}=yn(t,r);if(!s)return q;let a=!1,c=!1;if(o)if(o.fromLeft)a=!0;else c=!0;if(i)if(i.fromLeft)a=!0;else c=!0;if(a&&c)return G;if(a)return V;if(c)return Z;return J}function ds(e,n){let t=Mt(e),r=Zt(n);if(!r)return V;let o=yn(t,r.range),i=Be(o.center,r.multipleOf),s=Ap(o.left,r.multipleOf),a=Ap(o.right,r.multipleOf);if(!o.center)return q;let c=!1,u=!1;if(o.left?.fromLeft)c=!0;if(o.right?.fromLeft)c=!0;if(!i||!Rp(o.center))c=!0;if(s)u=!0;if(a)u=!0;if(c&&u)return G;if(c)return V;if(u)return Z;return J}function Mt(e){let n,t;if(e.exclusiveMinimum!==void 0)n={num:e.exclusiveMinimum,exclusive:!0};else if(e.minimum!==void 0)n={num:e.minimum,exclusive:!1};else n={num:Number.NEGATIVE_INFINITY,exclusive:!0};if(e.exclusiveMaximum!==void 0)t={num:e.exclusiveMaximum,exclusive:!0};else if(e.maximum!==void 0)t={num:e.maximum,exclusive:!1};else t={num:Number.POSITIVE_INFINITY,exclusive:!0};return[n,t]}function Ap(e,n){if(!e)return;if(e.fromLeft)return;return Be(e.range,n)}function $p(e,n){let t=Zt(e),r=Zt(n);if(!t&&!r)return J;if(!t)return Z;if(!r)return V;let{range:o,multipleOf:i}=t,{range:s,multipleOf:a}=r,c=yn(o,s),u,l=0;if(c.center)l=nb(i,a),u=Be(c.center,l);if(!u)return q;let p=!1,m=!1,{left:g,right:h}=c;if(g&&Be(g.range,g.fromLeft?i:a))if(g.fromLeft)p=!0;else m=!0;if(h&&Be(h.range,h.fromLeft?i:a))if(h.fromLeft)p=!0;else m=!0;if(p=p||_p(t,u,l),m=m||_p(r,u,l),p&&m)return G;if(p)return V;if(m)return Z;return J}function _p({range:e,multipleOf:n},t,r){let o=yn(e,t);if(Be(o.left?.range,n))return!0;if(Be(o.right?.range,n))return!0;let i=Be(o.center,n);if(!i)return!1;let s=jp(t);if(jp(i)>s)return!0;if(s===1)return!1;if(n<r)return!0;return!1}function nb(e,n){return e*n/Np(e,n)}function Np(e,n){if(e===0)return n;return Np(n%e,e)}function jp(e){if(!e)return 0;let[n,t]=e;return t.num-n.num+1}function ps(e,n){if(Tp(e)||Tp(n))return Fe;let t=zp(e),r=zp(n);if(t&&r)return Pp(e,n);else if(t)return ds(e,n);else if(r)return mn(ds(n,e));else return $p(e,n)}function Tp(e){let{multipleOf:n}=e;if(n===void 0)return!1;if(!Number.isInteger(n))return!0;if(n<0)return!0;return!1}function zp(e){let{multipleOf:n}=e;if(n!==void 0&&Number.isInteger(n))return!1;if(e.type==="integer")return!1;return!0}var tb=Bn(0),rb=Qr(["hasCommonInRequired","hasCommonOutRequired","hasExtra1","hasExtra2","hasRejection"]);function Zp(e,n,t){if(ob(n,t))return q;let r=ib(n,t);if(!r)return q;let o=Dp(n),i=Dp(t),s=(S)=>{let R=o(S),N=i(S);if(Vp(R,N))return e.calculate(R,N);else return ee},{commonRequired:a,extraRequired1:c,extraRequired2:u}=r,l=rb.variable({});for(let S of[...a].toSorted())l.push(s(S),ab);for(let S of[...c].toSorted())l.push(s(S),cb);for(let S of[...u].toSorted())l.push(s(S),ub);let{hasOptional1:p,hasOptional2:m}=r;if(p||m){let S=lb(p,m);for(let L of[...sb(n,t)].toSorted()){let K=s(L);if(K!==ee)l.push(K,S)}let R=n.additionalProperties??hn,N=t.additionalProperties??hn;if(Vp(R,N)){let L=e.calculate(R,N);l.push(L,S)}}l.update((S)=>{if(!S.hasRejection){if(c.size>0)S.hasExtra2=!0;if(u.size>0)S.hasExtra1=!0}});let{requiredKeysCount:g}=r,h=ee;for(let{hasExtra1:S,hasExtra2:R,hasCommonInRequired:N,hasCommonOutRequired:L,hasRejection:K}of l)if(!N&&g>0)h|=q;else if(!L&&g===0)h|=q;else if(K)h|=q;else if(S&&R)h|=G;else if(S)h|=V;else if(R)h|=Z;else h|=J;return h}function ob(e,n){let t=tb(e.minProperties,e.maxProperties,n.minProperties,n.maxProperties);return Gn(t)===y.Rejection}function ib(e,n){let t=new Set(e.required),r=new Set(n.required),o=new Set,i=new Set,s=t.size,a=r.size;for(let p of t){if(r.has(p))o.add(p);i.add(p)}for(let p of r){if(t.has(p))o.add(p);i.add(p)}let c=i.size;for(let p of o)t.delete(p),r.delete(p);let u=e.maxProperties??Number.MAX_SAFE_INTEGER,l=n.maxProperties??Number.MAX_SAFE_INTEGER;if(c>u||c>l)return null;return{requiredKeysCount:c,extraRequired1:t,extraRequired2:r,commonRequired:o,hasOptional1:u>s,hasOptional2:l>a}}function sb(e,n){let t=new Set(e.required),r=e.properties,o=n.properties,i=e.required,s=n.required;if(r)for(let a in r)t.add(a);if(o)for(let a in o)t.add(a);if(i)for(let a of i)t.delete(a);if(s)for(let a of s)t.delete(a);return t}var ab=(e,n)=>{switch(e){case y.Equals:{n.hasCommonInRequired=!0;break}case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Intersection:{n.hasExtra1=!0,n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},cb=(e,n)=>{switch(e){case y.Equals:case y.ContainedBy:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},ub=(e,n)=>{switch(e){case y.Equals:case y.Containing:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},lb=(e,n)=>(t,r)=>{if(r.hasRejection)return;let o=!1,i=!1,s=!1;switch(t){case y.Equals:{s=!0;break}case y.Containing:{o=!0,s=!0;break}case y.ContainedBy:{i=!0,s=!0;break}case y.Intersection:{o=!0,i=!0,s=!0;break}case y.Rejection:{o=!0,i=!0;break}}if(e&&o)r.hasExtra1=!0;if(n&&i)r.hasExtra2=!0;if(e&&n&&s)r.hasCommonOutRequired=!0};function Dp(e){let{properties:n,propertyNames:t,additionalProperties:r}=e,o=[];if(e.patternProperties)for(let i in e.patternProperties){let s=e.patternProperties[i],a=new RegExp(i,"i");o.push({pattern:a,schema:s})}return(i)=>{if(t&&en(t,i)===Se.Invalid)return zt;for(let{pattern:a,schema:c}of o)if(a.test(i))return c;let s=(n&&n[i])??r;if(!s)return hn;return s}}function Vp(e,n){let t=B(e),r=B(n);return t!==k.Never||r!==k.Never}var db=Bn(0);function Mp(e,n){if(n.format&&!e.format)return V;if(e.format&&n.format&&e.format!==n.format)return Fe;let t=db(e.minLength,e.maxLength,n.minLength,n.maxLength),r=Gn(t),o=!!e.pattern,i=!!n.pattern;switch(r){case y.Rejection:return q;case y.Containing:return o?Fe:V;case y.ContainedBy:return i?Fe:Z;case y.Equals:{if(o&&i)return e.pattern===n.pattern?J:Fe;if(o)return J|Z;if(i)return J|V;return J}case y.Intersection:{if(o&&i)return Fe;if(o)return G|q|Z;if(i)return G|q|V;return G}}}function Jp(e,n,t){let r={},o=[],i=Sp(fb(e,r)),s=pb(),a=Op(e);r.isEquals=kp(Ln),r.calculate=ns({describe:s,equals:a,calculate:i,observeCalculation:(u,l,p,m)=>{let g=m?mn(p):p;if(!mb(g))return;let h=m?Fp(l,u):Fp(u,l);if(h)o.push(h)}}),Object.freeze(r);let c=r.calculate(n,t);return{errorPath:o[0],expression:c}}var pb=()=>(e)=>{let n;switch(B(e)){case k.Not:{n={kind:je.Not,expression:e.not};break}case k.Combination:{if("allOf"in e)n={kind:je.AllOf,expressions:fs(e.allOf,k.Any)};else if("anyOf"in e)n={kind:je.AnyOf,expressions:fs(e.anyOf,k.Never)};else if("oneOf"in e)n={kind:je.OneOf,expressions:fs(e.oneOf,k.Never)};else throw Error(`invalid combination JSON Schema: ${JSON.stringify(e)}`);break}default:{n={kind:je.Leaf};break}}return n},fb=(e,n)=>(t,r)=>{let o=B(t),i=B(r);if(o===k.Extends||i===k.Extends)return e.calculate(t,r);switch(o){case k.Any:return i===k.Any?J:V;case k.Never:return i===k.Never?J:Z}switch(i){case k.Any:return Z;case k.Never:return V}if(o===k.EnumOrConst&&i===k.EnumOrConst)return Cp(n,t,r);if(o===k.EnumOrConst)return ls(t,r);if(i===k.EnumOrConst)return mn(ls(r,t));if(o!==i)return q;switch(o){case k.Null:return J;case k.Numeric:return ps(t,r);case k.String:return Mp(t,r);case k.Boolean:return J;case k.Object:return Zp(n,t,r);case k.Array:return vp(n,t,r);default:throw Error(`invalid kind ${o}`)}};function fs(e,n){return e.filter((t)=>B(t)!==n)}function mb(e){return!At(e)&&!_t(e)&&(Pt(e)||$t(e)||jt(e))}function Fp(e,n){let t=os(n);if(!t)return;let r=B(e),o=B(n);if(r!==o)return[...t,"type"];let i=e,s=n;switch(o){case k.String:{if((i.minLength??0)<(s.minLength??0))return[...t,"minLength"];if((i.maxLength??Number.POSITIVE_INFINITY)>(s.maxLength??Number.POSITIVE_INFINITY))return[...t,"maxLength"];if(i.pattern!==s.pattern&&s.pattern)return[...t,"pattern"];if(i.format!==s.format&&s.format)return[...t,"format"];break}case k.Numeric:{if((i.minimum??i.exclusiveMinimum??Number.NEGATIVE_INFINITY)<(s.minimum??s.exclusiveMinimum??Number.NEGATIVE_INFINITY))return[...t,s.exclusiveMinimum==null?"minimum":"exclusiveMinimum"];if((i.maximum??i.exclusiveMaximum??Number.POSITIVE_INFINITY)>(s.maximum??s.exclusiveMaximum??Number.POSITIVE_INFINITY))return[...t,s.exclusiveMaximum==null?"maximum":"exclusiveMaximum"];if(i.multipleOf!==s.multipleOf&&s.multipleOf!=null)return[...t,"multipleOf"];break}case k.Array:{if((i.minItems??0)<(s.minItems??0))return[...t,"minItems"];if((i.maxItems??Number.POSITIVE_INFINITY)>(s.maxItems??Number.POSITIVE_INFINITY))return[...t,"maxItems"];if(!i.uniqueItems&&s.uniqueItems)return[...t,"uniqueItems"];break}case k.Object:{let a=new Set(i.required??[]);if((s.required??[]).some((c)=>!a.has(c)))return[...t,"required"];if((i.minProperties??0)<(s.minProperties??0))return[...t,"minProperties"];if((i.maxProperties??Number.POSITIVE_INFINITY)>(s.maxProperties??Number.POSITIVE_INFINITY))return[...t,"maxProperties"];break}case k.EnumOrConst:return[...t,s.const==null?"enum":"const"]}return t}class Ft{constructor(e=[]){this.extendsSchemaClasses=Object.freeze([...e])}tryCompiledExtendsSchema(e,n){for(let t of this.extendsSchemaClasses)if(t.isMatch(e))return new t(pn(),e,n);return null}isExtendsSchema(e){for(let n of this.extendsSchemaClasses)if(e instanceof n)return!0;return!1}calculate(e,n){let t=this.findMatchedClass(e,n),r=!(e instanceof t),o=ee,i;if(r)i=n.compare(e);else i=e.compare(n);for(let s of i){if(r)s=Ft.swap(s);o|=fn(s)}return o}equals(e,n){let t=this.findMatchedClass(e,n);if(!(e instanceof t))return n.equals(e);else return e.equals(n)}findMatchedClass(e,n){for(let t of this.extendsSchemaClasses){if(e instanceof t)return t;if(n instanceof t)return t}throw Error("Invalid schema")}static swap(e){switch(e){case y.Containing:return y.ContainedBy;case y.ContainedBy:return y.Containing;default:return e}}}function Lp(e,n,t=!1){let r=n(e);if(Array.isArray(r)){let s=[];throw ms(s,r,"$"),new Br(s)}let{schema:o,warns:i}=r;if(t&&i.length>0){console.warn(`found ${i.length} warns after compile schema`);for(let s of i)console.warn(Kn(s))}return o}function qp(e,n,t,r=!1){let o=t(e),i=t(n);if(Array.isArray(o)||Array.isArray(i)){let l=[];if(Array.isArray(o))ms(l,o,"$1");if(Array.isArray(i))ms(l,i,"$2");throw new Br(l)}let{schema:s,warns:a}=o,{schema:c,warns:u}=i;if(r){if(a.length>0)console.warn(`found ${a.length} warns after compile superSchema`);for(let l of a)console.warn(Kn(l));if(u.length>0)console.warn(`found ${u.length} warns after compile subSchema`);for(let l of u)console.warn(Kn(l))}return[s,c]}function ms(e,n,t){for(let r of n){let o={...r,path:[t,...r.path]};e.push(o)}}var Jt=Object.freeze({True:0,False:1,Unknown:2});function gs({extendsSchemaClasses:e,delegate:n}={}){let t=new Ft(e);return Object.freeze({compile:(o,i,s)=>Lp(o,(c)=>Hr(c,t,i,n),s),isSubset:(o,i,s=!1)=>{let a=(h)=>Hr(h,t,void 0,n),[c,u]=qp(o,i,a,s),{errorPath:l,expression:p}=Jp(t,c,u),m=At(p)||_t(p),g=Pt(p)||$t(p)||jt(p);if(m&&!g)return{result:Jt.True};if(!m&&g)return{errorPath:l,result:Jt.False};return{result:Jt.Unknown}}})}var Yr=(e)=>typeof e==="string";var gb=Array.isArray;var hb=(e)=>e!==null&&typeof e==="object";var yb=(e)=>hb(e)&&!gb(e),Rn=(e)=>yb(e)?e:void 0;function bb(e){return Rn(e)?.type==="string"}function wb(e){let n=Rn(e),t=Rn(n?.error);if(n==null||t==null||n.packageId!=null&&!Yr(n.packageId)||t.message!=null&&!Yr(t.message))throw TypeError("Invalid schema comparison context.")}function xb(e){if(e==null)return{error:{}};return wb(e),e}class bn{static setError(e,n,t){if(e instanceof bn)e.context.error.message=t;else if(n instanceof bn)n.context.error.message=t}constructor(e,n,t){this.id=e,this.value=n,this.context=xb(t)}compare(e){if(Ne(e)&&B(e)===k.Any)return[y.ContainedBy];return this.compareImpl(e)}}class Lt extends bn{static isMatch(e){let n=Rn(e)?.enum;return Array.isArray(n)&&n.every((t)=>Yr(t))}constructor(e,n,t){if(!Lt.isMatch(n))throw TypeError("Invalid single-select schema.");super(e,n,t)}compareImpl(e){if(bb(e))return[y.ContainedBy];if(e instanceof Lt){let n=new Set(this.value.enum),t=y.Equals;for(let r of e.value.enum){if(!n.has(r))t=y.ContainedBy;n.delete(r)}if(n.size===0)return[t];if(n.size===this.value.enum.length)return[y.Rejection];return[y.Intersection]}return[y.Rejection]}equals(e){if(e instanceof Lt){let n=new Set(this.value.enum);for(let t of e.value.enum){if(!n.has(t))return!1;n.delete(t)}return n.size===0}return!1}}class qt extends bn{static isMatch(e){return Rn(e)?.contentMediaType==="oomol/bin"}constructor(e,n,t){if(!qt.isMatch(n))throw TypeError("Invalid binary schema.");super(e,n,t)}compareImpl(e){if(e instanceof qt)return[y.Equals];else return bn.setError(this,e,"edgeError.binDiffType"),[y.Rejection]}equals(e){return e instanceof qt}}class Ut extends bn{static isMatch(e){return Rn(e)?.contentMediaType==="oomol/artifact"}constructor(e,n,t){if(!Ut.isMatch(n))throw TypeError("Invalid Artifact schema.");super(e,n,t)}compareImpl(e){if(e instanceof Ut)return[y.Equals];return bn.setError(this,e,"edgeError.artifactDiffType"),[y.Rejection]}equals(e){return e instanceof Ut}}function Up(){return gs({extendsSchemaClasses:[Lt,qt,Ut]})}var zE=Up();var hs={choice:255,score:10};function Kp(e){if(e.type==="noul"||e.criteria.length<=hs[e.type])return e;if(e.type==="choice")return{...e,criteria:e.criteria.slice(0,hs.choice)};return{...e,criteria:e.criteria.slice(0,hs.score)}}function vb(e){let n=e.map(Kp);return n.every((t,r)=>t===e[r])?e:n}function Qd(e){if(e.executor.kind!=="decision")return e;let n=e.executor.questions,t=vb(n);if(t===n)return e;let r=e.outputs.map((o)=>{if(!("handle"in o))return o;let i=n.findIndex((s)=>s.name===o.handle);if(i<0||n[i]===t[i]||!ze(o.jsonSchema,Bp(n[i])))return o;return{...o,jsonSchema:kb(t[i])}});return{...e,executor:{...e.executor,questions:t},outputs:r}}var ys={type:"number",minimum:0,maximum:1};function kb(e){return Bp(Kp(e))}function Bp(e){let n={type:{const:e.type}};if(e.type==="noul")n.noul=ys;else{let t=e.type==="choice"?e.criteria.map((r)=>r.name):e.criteria.map((r,o)=>String(o));if(n.confidence=ys,n.probabilities={type:"object",properties:Object.fromEntries(t.map((r)=>[r,ys])),required:t,additionalProperties:!1},e.type==="choice")n.choice={type:"string",...t.length?{enum:t}:{}};else n.score={type:"number",minimum:0,maximum:Math.max(0,t.length-1)},n.legend={type:"object",properties:Object.fromEntries(t.map((r)=>[r,{type:"string"}])),required:t,additionalProperties:!1}}return{type:"object",properties:n,required:Object.keys(n)}}var Gp=v({mode:ae(["chat","json"]),resultSchema:Ke(),model:Ke().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),template:Ke().optional().describe('Default message templates: [{role: "system" | "user" | "assistant", content: "Text with {{namedInput}}"}].'),messages:Ke().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")});var Ab=Q([v({schemes:P(_().min(1)).describe("One complete security alternative advertised by this operation; [] selects no authentication.")}),v({type:ae(["bearer","basic"])}),v({type:E("apiKey"),name:_().min(1),in:ae(["header","query"])})]),Wp=v({sourceUrl:_().min(1),path:_().min(1),method:_().min(1),serverUrl:_().optional(),authentication:Ab.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")});var T=_().min(1),Ge=Ke(),vs=se(T,Ge),eo=["manual","webhook","cron","error","poll","integration","code","connector","agent","llm","decision","openapi","condition","value","wait","approval"],ks=ae(eo),wn=T.describe('An existing node reference returned by read/search, or $alias for a preceding node.add in this edit batch. For node.add.as "step", reference "$step", never bare "step". Aliases are local to one batch.'),bs=v({kind:E("output"),node:wn,port:T.optional().describe("Omit for a node with one output. For multiple outputs, choose a name from node details."),field:_().optional()}),ws=v({kind:E("variable"),name:T}),Hp=Q([bs,ws,v({kind:E("value"),value:Ge}),v({kind:E("unset")}),v({kind:E("default")}),v({kind:E("sources"),sources:P(Q([bs,ws])).min(1)})]),Qp=Q([v({kind:E("value"),value:Ge.optional(),schema:Ge.optional()}),bs,ws]),Pb=Le.agent.shape.tools.element.omit({id:!0,inputs:!0}).extend({inputs:se(T,Le.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.")}).strict(),_b=v({...Le.connector.shape,messageHandle:T,inputs:se(T,Q([v({kind:E("value"),value:Ge}),v({kind:E("input"),input:T})]))}),nf=v({schema:Ge.optional(),nullable:he().optional(),description:_().optional()}),Wn=se(T,nf.extend({default:Ge.optional()})).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data."),Yp=se(T,nf).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true."),xs=v({left:Qp,operator:Le.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,right:Qp.optional()}),Xp=v({all:P(xs)}),jb=Q([xs,Xp,v({any:P(Q([xs,Xp]))})]),tf={manual:v({}),error:v({sourceFlowIds:P(T).optional()}),webhook:Le.webhook.omit({bodyFields:!0}).extend({body:Wn}).strict(),cron:v({schedule:Le.schedule}),poll:v({key:T,connectionId:T.optional(),schedule:Le.schedule}),integration:v({key:T,connectionId:T.optional()}),code:v({inputs:Wn,outputs:Yp,capabilities:Le.capabilities.optional()}),connector:Le.connector.strict(),openapi:Wp,agent:Le.agent.omit({prompt:!0,tools:!0}).extend({inputs:Wn,resultSchema:Ge.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),tools:P(Pb),notification:_b.optional()}).strict(),llm:Gp.extend({inputs:Wn}),decision:Le.decision,condition:v({match:ae(["first","all"]),branches:P(v({name:T,description:_().optional(),when:jb}))}),value:v({values:vs,outputs:Yp}),wait:v({inputs:Wn}),approval:v({inputs:Wn})},$b={name:T.optional(),description:_().optional(),icon:_().optional(),maxExecutions:ge().positive().optional(),timeoutMs:me().nonnegative().optional()},Nb=v({...$b,config:vs.optional().describe('Recursively merge configuration; omitted fields remain unchanged and arrays replace as a whole. This includes schema objects: {} does not clear an existing schema. Use clear paths to remove fields, e.g. ["config","inputs","amount","schema","type"].')}),Tb=Vr("op",[v({op:E("node.add"),as:T.regex(/^[A-Za-z][\w-]*$/).describe("Unique batch-local alias without the $ prefix. Later edits must reference this new node as $alias; the bare alias is not its node ID."),type:ks,name:T,config:vs.optional(),inputs:se(T,Hp).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),code:_().optional(),prompt:_().optional()}),v({op:E("node.update"),node:wn,set:Nb.optional(),clear:P(P(T).min(1)).optional()}),v({op:E("node.remove"),node:wn}),v({op:E("input.set"),node:wn,input:T,source:Hp}),v({op:ae(["edge.connect","edge.disconnect"]),source:wn,target:wn,branch:T.optional()}),v({op:E("text.edit"),node:wn,field:ae(["code","prompt"]),oldText:T,newText:_()}),v({op:E("text.set"),node:wn,field:ae(["code","prompt"]),text:_()})]),Kt=v({baseRevision:T,requestId:T.max(256),edits:P(Tb).min(1).max(1000)}),no=v({revision:T.optional().describe("Fixed revision from a previous read; omit to read the current draft."),nodes:P(T).min(1).max(100).optional().describe("Node references to read in one batch. Mutually exclusive with text. Long texts return metadata."),text:v({node:T,field:ae(["code","prompt"]),start:ge().positive().default(1),lines:ge().min(1).max(200).default(80)}).optional().describe("Read code or prompt by line (1-based). Mutually exclusive with nodes. Follow nextStart at the same revision until truncated is false.")}).refine((e)=>e.nodes==null||e.text==null,"Choose nodes or text.").meta({not:{required:["nodes","text"]},description:"Omit nodes and text for an outline; provide nodes for details, or text for an excerpt."}),Ss=v({revisionId:T}),to=v({revision:T.optional(),query:T.max(1000),type:ks.optional(),offset:ge().nonnegative().default(0),limit:ge().min(1).max(100).default(20)}),rf=v({type:ks.optional(),action:T.optional()}).refine((e)=>e.type==null||e.action==null,"Choose type or action."),ef={read:{schema:no,guidance:"Choose one mode: outline (omit nodes and text), node details (nodes), or text excerpt (text). nodes and text are mutually exclusive. Text defaults to 80 lines, at most 200 lines and 24000 characters. For the complete text, repeat at nextStart with the same revision until truncated is false.",examples:[{},{revision:"REVISION",nodes:["NODE"]},{revision:"REVISION",text:{node:"NODE",field:"prompt",start:1,lines:80}}]},search:{schema:to,guidance:"Search names, configurations and text. Keep the returned revision when following nextOffset or reading a match.",examples:[{query:"Customer summary",type:"agent"}]},edit:{schema:Kt,guidance:"Use the observed revision as baseRevision and a stable requestId. Edits are ordered and atomic. node.add.as declares a batch-local alias without $. Every later reference to that new node must use $alias, including node, edge source/target and output source node fields; a bare alias is not the node ID. Use returned node references in later batches. Updates recursively merge objects (including schemas); {} preserves existing fields. Arrays replace as a whole. Remove fields with clear paths. Text replacement requires exactly one match. Read the target text first. A saved draft can have validation diagnostics.",examples:[{baseRevision:"REVISION",requestId:"CREATE_REQUEST",edits:[{op:"node.add",as:"start",type:"manual",name:"Start"},{op:"node.add",as:"step",type:"code",name:"Process",code:"export default ({value}) => ({result:value})"},{op:"edge.connect",source:"$start",target:"$step"},{op:"node.update",node:"$step",set:{description:"Created and connected in one atomic edit."}}]},{baseRevision:"REVISION",requestId:"REQUEST",edits:[{op:"text.edit",node:"NODE",field:"prompt",oldText:"Original rule.",newText:"Updated rule."}]}]},check:{schema:Ss,guidance:"Check a fixed revision. In the CLI, pass this identity with --revision REVISION.",examples:[{revisionId:"REVISION"}]}};function Is(e){if(!Object.hasOwn(ef,e))return;let n=ef[e];return{request:jr(n.schema,{io:"input"}),guidance:n.guidance,examples:n.examples}}function Es(e){return e==null?{types:eo,request:jr(Kt),guidance:"Read a node type schema before creating or configuring it. Use $alias to reference a preceding node.add in the same batch. Read returns stable node references. Long code and prompt fields use text reads and edits. Changes use the observed baseRevision and a stable requestId."}:{type:e,inputSources:["poll","integration"].includes(e)?["value","unset","default"]:["manual","error","cron","webhook","value","condition"].includes(e)?[]:["value","unset","default","output","variable","sources"],extensibleInputs:["code","agent","llm","wait","approval"].includes(e),guidance:e=="condition"?"Edit branch operands through config.branches. A branch can test one expression, all expressions, or any alternatives. Unmatched execution uses branch otherwise.":["poll","integration"].includes(e)?"Configure static parameters with node.add.inputs or input.set. Definitions come from the selected Trigger key; execution output and variable sources are unavailable.":e=="llm"?"Configure model settings, message templates and history as defaults. Input bindings with the same names override these defaults; named business inputs can be bound directly. Template strings interpolate {{name}}.":e=="openapi"?"Select an operation; the tool resolves its ports and authentication. Read authenticationChoices from node details. authentication is replaced as a complete choice. Bind advertised credentials through inputs.":"Supply business configuration and input data. Fixed definitions are assembled by the tool. Existing constraints and defaults are preserved on partial updates.",example:{op:"node.add",as:"step",type:e,name:"Step",...{connector:{config:{action:"<Action ID>",connectionId:"<Connection ID>"}},poll:{config:{key:"<Trigger key>",schedule:[{type:"every",unit:"minute",value:5}]}},integration:{config:{key:"<Trigger key>"}},openapi:{config:{sourceUrl:"https://example.com/openapi.json",path:"/items",method:"get"}},code:{code:"export default ({value}) => ({result:value})",inputs:{value:{kind:"value",value:"Hello"}}},condition:{config:{match:"first",branches:[{name:"yes",when:{left:{kind:"value",value:120},operator:">",right:{kind:"value",value:100}}}]}},value:{config:{values:{threshold:100,region:"EU"}}},webhook:{config:{method:"POST",body:{orderId:{schema:{type:"string"},nullable:!1}}}},wait:{prompt:"Continue processing this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},approval:{prompt:"Approve this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},llm:{config:{model:{model:"deepseek-v4-flash"},template:[{role:"user",content:"Summarize {{order}}."}]},inputs:{order:{kind:"value",value:{orderId:"A-1",total:42}}}},agent:{config:{model:"deepseek-v4-flash"},inputs:{orders:{kind:"value",value:[{orderId:"A-1",total:42}]}},prompt:"Summarize {{orders}}."}}[e]},configuration:jr(tf[e].partial()),texts:e=="code"?["code"]:["agent","wait","approval"].includes(e)?["prompt"]:[]}}var of=A({code:T,message:_(),nodes:P(T),field:_().optional(),line:me().optional(),column:me().optional()}),sf=A({flowId:T,revisionId:T,valid:he(),diagnostics:P(of),version:E(1)}),af=A({flowId:T,saved:E(!0),revision:T,nodes:se(T,T),changes:P(A({index:ge(),op:T,node:T.optional()})),validation:A({status:ae(["valid","invalid","unavailable"]),diagnostics:P(of).optional()}),version:E(1)}),cf=A({flowId:T,revision:T,data:A({nodes:P(se(_(),Ge)).optional(),edges:P(Ge).optional(),text:se(_(),Ge).optional()}),version:E(1)}),uf=A({flowId:T,revision:T,data:A({matches:P(A({node:T,field:T,line:ge().optional(),excerpt:_()})),total:ge(),nextOffset:ge().optional()}),version:E(1)});var z={authenticationRequired:"authentication.required",authorizationDenied:"authorization.denied",bindingUnresolved:"binding.unresolved",connectorActionNotFound:"connector.action-not-found",connectorAccessConflict:"connector.access-conflict",connectorAccessInvalid:"connector.access-invalid",connectorAccessRequired:"connector.access-required",connectorAccessUnsupported:"connector.access-unsupported",connectorUnconfigured:"connector.unconfigured",connectorUnavailable:"connector.unavailable",connectorConsoleUnconfigured:"connector.console-unconfigured",engineUnavailable:"engine.unavailable",engineUnsupported:"engine.unsupported",eventSourceInvalid:"event-source.invalid",eventSourceIdentityUnavailable:"event-source.identity-unavailable",eventSourceNotFound:"event-source.not-found",eventSourceConflict:"event-source.conflict",flowInvalid:"flow.invalid",flowRepairRequired:"flow.repair-required",flowUpgradeRequired:"flow.upgrade-required",flowNotFound:"flow.not-found",flowBusy:"flow.busy",flowConflict:"flow.conflict",flowPresentationConflict:"flow.presentation-conflict",flowRevisionConflict:"flow.revision-conflict",liveConflict:"live.conflict",liveNotFound:"live.not-found",pageInvalidCursor:"page.invalid-cursor",publicationConflict:"publication.conflict",publicationNotFound:"publication.not-found",publicationUnsupported:"publication.unsupported",resourceNotFound:"resource.not-found",publishOperationNotFound:"publication.operation-not-found",routeNotFound:"route.not-found",runConflict:"run.conflict",runEventsExpired:"run.events-expired",runInvalid:"run.invalid",runNotFound:"run.not-found",runNotTerminal:"run.not-terminal",runOverloaded:"run.overloaded",runWaitNotFound:"run.wait-not-found",triggerKeyInvalid:"trigger-key.invalid",triggerKeyNotFound:"trigger-key.not-found",triggerNotFound:"trigger.not-found",variableInvalid:"variable.invalid",variableLimitReached:"variable.limit-reached",variableNotFound:"variable.not-found"},Bb={[z.eventSourceInvalid]:{status:400},[z.eventSourceIdentityUnavailable]:{status:409},[z.eventSourceNotFound]:{status:404},[z.eventSourceConflict]:{status:409},[z.authenticationRequired]:{status:401},[z.authorizationDenied]:{status:403},[z.bindingUnresolved]:{status:409},[z.connectorActionNotFound]:{status:404},[z.connectorAccessConflict]:{status:412},[z.connectorAccessInvalid]:{status:409},[z.connectorAccessRequired]:{status:409},[z.connectorAccessUnsupported]:{status:409},[z.connectorUnconfigured]:{status:503},[z.connectorUnavailable]:{status:503},[z.connectorConsoleUnconfigured]:{status:503},[z.engineUnavailable]:{status:503},[z.engineUnsupported]:{status:409},[z.flowInvalid]:{status:400},[z.flowRepairRequired]:{status:409},[z.flowUpgradeRequired]:{status:409},[z.flowNotFound]:{status:404},[z.flowBusy]:{status:409},[z.flowConflict]:{status:409},[z.flowPresentationConflict]:{status:412},[z.flowRevisionConflict]:{status:412},[z.liveConflict]:{status:412},[z.liveNotFound]:{status:404},[z.pageInvalidCursor]:{status:400},[z.publicationConflict]:{status:409},[z.publicationNotFound]:{status:404},[z.publicationUnsupported]:{status:409},[z.resourceNotFound]:{status:404},[z.publishOperationNotFound]:{status:404},[z.routeNotFound]:{status:404},[z.runConflict]:{status:409},[z.runEventsExpired]:{status:410},[z.runInvalid]:{status:400},[z.runNotFound]:{status:404},[z.runNotTerminal]:{status:409},[z.runOverloaded]:{status:429},[z.runWaitNotFound]:{status:404},[z.triggerKeyInvalid]:{status:409},[z.triggerKeyNotFound]:{status:404},[z.triggerNotFound]:{status:404},[z.variableInvalid]:{status:400},[z.variableLimitReached]:{status:409},[z.variableNotFound]:{status:404}};class Ie extends Error{constructor(e,n,t,r){super(t);this.code=n,this.details=r,this.name="ApiError",this.status=e}}class lf extends Ie{constructor(e){super(502,"response.invalid",`The Control API returned an invalid response.${e==null?"":` ${e}`}`);this.detail=e}}function f(e){throw new lf(e)}function w(e){if(e==null||typeof e!="object"||Array.isArray(e))return f("Expected an object.");return e}function d(e){return typeof e=="string"&&e.length>0?e:f("Expected a non-empty string.")}function D(e,n){let t=Object.keys(e);if(t.length!=n.length||t.some((r)=>!n.includes(r))){let r=n.filter((i)=>!Object.hasOwn(e,i)),o=t.filter((i)=>!n.includes(i));f([r.length>0?`Missing fields: ${r.join(", ")}.`:"",o.length>0?`Unexpected fields: ${o.join(", ")}.`:""].filter(Boolean).join(" "))}}function oe(e){return Number.isSafeInteger(e)?e:f("Expected a safe integer.")}function pe(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map(pe);let n=w(e);return Object.fromEntries(Object.entries(n).map(([t,r])=>[t,pe(r)]))}function ro(e){if(e==null)return;return d(e)}var df=P(Q([v({handle:_().min(1),description:_().optional(),jsonSchema:Ke(),nullable:he(),value:Ke().optional()}),v({group:_(),collapsed:he().optional()})]));function Cs(e){let n=w(e),t=n.type;if(t!="integration"&&t!="poll")return f();return{description:typeof n.description=="string"?n.description:f(),displayName:d(n.displayName),key:d(n.key),name:d(n.name),provider:d(n.provider),type:t}}function Bt(e){let n=w(e),t=Cs(n),r={configInputs:df.parse(n.configInputs),definitionVersion:n.definitionVersion===2?2:f(),description:t.description,displayName:t.displayName,key:t.key,name:t.name,outputs:(Array.isArray(n.outputs)?n.outputs:f()).map((u)=>{let l=w(u);return Object.assign({handle:d(l.handle),jsonSchema:pe(l.jsonSchema),nullable:typeof l.nullable==="boolean"?l.nullable:f()},l.description==null?{}:{description:d(l.description)})}),provider:t.provider};if(t.type=="poll")return{...r,type:"poll"};let o=w(n.endpoint),i=w(o.body);if(!Array.isArray(o.methods)||!Array.isArray(i.formats)||typeof i.allowArray!="boolean"||typeof i.allowEmpty!="boolean")return f();let s=o.methods.map(d),a=i.formats.map(d),c=oe(o.successStatus);if(s.some((u)=>!["DELETE","GET","HEAD","PATCH","POST","PUT"].includes(u))||a.some((u)=>!["form","json","multipart","text"].includes(u))||c<200||c>299)return f();return{...r,endpoint:{body:{allowArray:i.allowArray,allowEmpty:i.allowEmpty,formats:a},methods:s,successStatus:c},type:"integration"}}var Gb=new Set(["error","cron","integration","poll","webhook"]),Wb=new Set(["failed","healthy","initializing","needs_reauth","suspended"]),Hb=new Set(["delivery.failed","health.failed","health.needs_reauth","health.recovered","health.suspended","operator.paused","operator.resumed"]);function Gt(e){let n=w(e),t=n.health,r=n.listener==null?void 0:w(n.listener);if(r!=null&&r.health!="healthy"&&r.health!="failed"&&r.health!="needs_reauth")return f();let o=n.kind,i=oe(n.runtimeVersion);if(n.version!=1||typeof t!="string"||!Wb.has(t))return f();if(typeof o!="string"||!Gb.has(o))return f();if(i<=0)return f();return{...n.currentPublicationId==null?{}:{currentPublicationId:d(n.currentPublicationId)},...n.currentRevisionId==null?{}:{currentRevisionId:d(n.currentRevisionId)},...n.endpointUrl==null?{}:{endpointUrl:d(n.endpointUrl)},...r==null?{}:{listener:{health:r.health,...r.lastErrorCode==null?{}:{lastErrorCode:d(r.lastErrorCode)}}},flowId:d(n.flowId),health:t,kind:o,...n.lastErrorCode==null?{}:{lastErrorCode:d(n.lastErrorCode)},runtimeVersion:i,triggerNodeId:d(n.triggerNodeId),updatedAt:d(n.updatedAt),version:1}}function pf(e){let n=w(e);if(n.version!=1)return f();return{binding:Gt(n.binding),version:1}}function Qb(e){let n=w(e),t=n.kind;if(typeof t!="string"||!Hb.has(t))return f();let r=ro(n.errorCode),o=ro(n.errorMessage);if(o!=null&&o.length>512)return f();return{activityId:d(n.activityId),createdAt:d(n.createdAt),...r==null?{}:{errorCode:r},...o==null?{}:{errorMessage:o},kind:t}}function ff(e){let n=w(e),t=ro(n.nextCursor);if(n.version!=1||!Array.isArray(n.activities))return f();return{activities:n.activities.map(Qb),...t==null?{}:{nextCursor:t},version:1}}function mf(e){let n=w(e),t=oe(n.filtered);if(n.version!=1||!Array.isArray(n.events)||typeof n.hasMore!="boolean"||t<0)return f();return{events:n.events.map((r)=>{let o=w(r);return Object.fromEntries(Object.entries(o).map(([i,s])=>[i,pe(s)]))}),filtered:t,hasMore:n.hasMore,version:1}}function gf(e){if(e.version!=1||e.status!="live"&&e.status!="historical")return f();if(e.status=="live"?typeof e.enabled!="boolean":e.enabled!==void 0)return f();return{flowId:d(e.flowId),publicationId:d(e.publicationId),revisionId:d(e.revisionId),status:e.status,...e.enabled==null?{}:{enabled:e.enabled},version:1}}function hf(e,n){let t=w(e),r=t.type;if(t.kind!="trigger"||r!="webhook"&&r!="cron"&&r!="poll"&&r!="integration"&&r!="error")return f();if(t.description!=null&&typeof t.description!="string")return f();let o=d(t.resourceId),i=t.runtime==null?void 0:Gt(t.runtime);if(i!=null&&(n.status!="live"||i.flowId!=n.flowId||i.currentPublicationId!=n.publicationId||i.currentRevisionId!=n.revisionId||i.triggerNodeId!=o||i.kind!=r))return f();return{resourceId:o,kind:"trigger",type:r,name:d(t.name),...t.description==null?{}:{description:t.description},config:pe(t.config),inputs:pe(t.inputs),...i==null?{}:{runtime:i}}}function yf(e){let n=w(e),t=gf(n);if(!Array.isArray(n.resources))return f();return{...t,resources:n.resources.map((r)=>hf(r,t))}}function bf(e){let n=w(e),t=gf(n);return{...t,resource:hf(n.resource,t)}}function oo(e,n){if(!e||typeof e!="object"||!n||typeof n!="object")return{};let t=e,r=n;if(typeof t.version!="string"||![t.pixelRatio,t.iconSize,t.width,t.height].every((o)=>Number.isInteger(o)&&o>0)||![t.bleed,r.x,r.y].every((o)=>Number.isInteger(o)&&o>=0)||r.x+t.iconSize>t.width||r.y+t.iconSize>t.height)return{};try{for(let o of[t.lightUrl,t.darkUrl])if(typeof o!="string"||!["https:","http:","data:"].includes(new URL(o).protocol))return{}}catch{return{}}return{iconSprite:t,iconSpritePosition:{x:r.x,y:r.y}}}var Yb=Vr("kind",[v({kind:E("admin-delegation")}),v({kind:E("policy"),ruleId:_().min(1).nullable()})]);function io(e){return Yb.parse(e)}function Xb(e){let n=w(e);if(D(n,["actionIds","allActions","triggerIds","allTriggers","configured","proxy"]),!Array.isArray(n.actionIds))return f("permissions.actionIds: expected an array.");if(!Array.isArray(n.triggerIds))return f("permissions.triggerIds: expected an array.");if(typeof n.allActions!="boolean")return f("permissions.allActions: expected a boolean.");if(typeof n.allTriggers!="boolean")return f("permissions.allTriggers: expected a boolean.");if(typeof n.configured!="boolean")return f("permissions.configured: expected a boolean.");if(typeof n.proxy!="boolean")return f("permissions.proxy: expected a boolean.");let t=n.actionIds.map(d),r=n.triggerIds.map(d);if(new Set(t).size!=t.length)return f("permissions.actionIds: duplicate IDs.");if(n.allActions&&t.length!=0)return f("permissions.actionIds: must be empty when allActions is true.");if(new Set(r).size!=r.length)return f("permissions.triggerIds: duplicate IDs.");if(n.allTriggers&&r.length!=0)return f("permissions.triggerIds: must be empty when allTriggers is true.");if(n.proxy&&(!n.allActions||!n.allTriggers||n.configured))return f("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");return{actionIds:t,triggerIds:r,allTriggers:n.allTriggers,allActions:n.allActions,configured:n.configured,proxy:n.proxy}}function vf(e,n){let t=w(e),{policyRevision:r,status:o,isDefault:i}=t,s=Object.hasOwn(t,"displayName")&&!Object.hasOwn(t,"connectionDisplayName"),a=n&&Object.hasOwn(t,"permissions")?Xb(t.permissions):void 0,c=t.permissionGroupName;if(D(t,["accessBindingId","connectionId","source",s?"displayName":"connectionDisplayName",...n&&Object.hasOwn(t,"isDefault")?["isDefault"]:[],...n&&a!=null?["permissions"]:[],...Object.hasOwn(t,"permissionGroupName")?["permissionGroupName"]:[],...r==null?[]:["policyRevision"],"providerId",...n?[]:["status"]]),r!=null&&typeof r!="string")return f("policyRevision: expected a string.");if(n&&i!==void 0&&typeof i!="boolean")return f("isDefault: expected a boolean.");if(c!==void 0&&c!==null&&typeof c!="string")return f("permissionGroupName: expected a string or null.");if(!n&&o!="active"&&o!="forbidden"&&o!="invalid"&&o!="missing")return f();let u;try{u=io(t.source)}catch{return f("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.")}return{accessBindingId:d(t.accessBindingId),connectionId:d(t.connectionId),source:u,connectionDisplayName:d(s?t.displayName:t.connectionDisplayName),...n&&typeof i=="boolean"?{isDefault:i}:{},...a==null?{}:{permissions:a},...c===void 0?{}:{permissionGroupName:c},...r==null?{}:{policyRevision:r},providerId:d(t.providerId),...n?{}:{status:o}}}function Os(e){if(e!="implicit"&&e!="selectable")return f("mode: expected implicit or selectable.");return e}function Hn(e){let n=w(e);D(n,["accessRevision","bindings","mode","sharedAccessDigest",..."providerIds"in n?["providerIds"]:[],..."discardedBindingCount"in n?["discardedBindingCount"]:[],"version"]);let t=oe(n.accessRevision);if(n.version!=1||t<0||!Array.isArray(n.bindings))return f();if("providerIds"in n&&!Array.isArray(n.providerIds))return f();let r=n.providerIds==null?void 0:n.providerIds.map((s)=>d(s));if(r!=null&&new Set(r).size!=r.length)return f();let o=n.discardedBindingCount==null?0:oe(n.discardedBindingCount);if(o<0)return f();let i=[];for(let s of n.bindings)try{i.push(vf(s,!1))}catch(a){if(!(a instanceof Ie)||a.code!="response.invalid")throw a;if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.accessBindingId=="string"&&s.accessBindingId.length>0&&typeof s.providerId=="string"&&s.providerId.length>0)i.push({accessBindingId:s.accessBindingId,providerId:s.providerId,connectionId:null,source:null,status:"invalid",connectionDisplayName:typeof s.connectionDisplayName=="string"&&s.connectionDisplayName.length>0?s.connectionDisplayName:typeof s.displayName=="string"&&s.displayName.length>0?s.displayName:s.providerId,permissionGroupName:typeof s.permissionGroupName=="string"?s.permissionGroupName:null});else o++}if(new Set(i.map((s)=>s.accessBindingId)).size!=i.length)return f();return{accessRevision:t,...o==0?{}:{discardedBindingCount:o},...r==null?{}:{providerIds:r},bindings:i,mode:Os(n.mode),sharedAccessDigest:d(n.sharedAccessDigest),version:1}}function wf(e){if(!Array.isArray(e))return f();let n=e.map((t)=>{let r=w(t);D(r,["accessBindingId","connectionId","providerId","source","connectionDisplayName",..."permissionGroupName"in r?["permissionGroupName"]:[]]);let o;try{o=io(r.source)}catch{return f()}if(r.permissionGroupName!=null&&typeof r.permissionGroupName!="string")return f();return{accessBindingId:d(r.accessBindingId),connectionId:d(r.connectionId),providerId:d(r.providerId),source:o,connectionDisplayName:d(r.connectionDisplayName),..."permissionGroupName"in r?{permissionGroupName:r.permissionGroupName}:{}}});if(new Set(n.map((t)=>t.accessBindingId)).size!=n.length)return f();return n}function Rs(e){let n=w(e);if(D(n,["mode","sharedAccessDigest","sharedBindings","selectedBindings","version"]),n.version!=2)return f();let t=Os(n.mode),r=wf(n.sharedBindings),o=wf(n.selectedBindings);if(t=="implicit"&&(r.length>0||o.length>0))return f();return{mode:t,sharedAccessDigest:d(n.sharedAccessDigest),sharedBindings:r,selectedBindings:o,version:2}}function ew(e,n){let t=w(e);if(D(t,["candidates","mode","providerId","version"]),t.version!=1)return f("version: expected 1.");if(d(t.providerId)!=n)return f("providerId: does not match the requested provider.");if(!Array.isArray(t.candidates))return f("candidates: expected an array.");let r=t.candidates.map((o)=>vf(o,!0));if(r.some((o)=>o.providerId!=n))return f("candidates[].providerId: does not match the requested provider.");if(new Set(r.map((o)=>o.accessBindingId)).size!=r.length)return f("candidates[].accessBindingId: duplicate IDs.");return{candidates:r,mode:Os(t.mode),providerId:n,version:1}}function kf(e,n){let t=w(e);if(D(t,["results","version"]),t.version!=1)return f("version: expected 1.");if(!Array.isArray(t.results))return f("results: expected an array.");let r=new Set(n),o=t.results.map((i)=>{let s=w(i),a=d(s.providerId);if(!r.delete(a))return f("results[].providerId: duplicate or unrequested provider.");if(!Object.hasOwn(s,"error"))return ew(s,a);D(s,["providerId","error"]);let c=w(s.error);return D(c,["code","message"]),{providerId:a,error:{code:d(c.code),message:d(c.message)}}});if(r.size!=0)return f("results: missing requested providers.");return{results:o,version:1}}function Qn(e){let n=w(e);if(D(n,[...Object.hasOwn(n,"providerAccountId")?["providerAccountId"]:[],...Object.hasOwn(n,"alias")?["alias"]:[],...Object.hasOwn(n,"builtInAccount")?["builtInAccount"]:[],"connectionId","displayName","isDefault","serviceId","status"]),n.builtInAccount!==void 0&&typeof n.builtInAccount!="boolean")return f();let t=n.status;if(t!="active"&&t!="disconnected"&&t!="error"&&t!="reauth_required")return f();if(typeof n.isDefault!="boolean")return f();return{...n.providerAccountId===void 0?{}:{providerAccountId:d(n.providerAccountId)},...n.alias===void 0?{}:{alias:d(n.alias)},...n.builtInAccount===void 0?{}:{builtInAccount:n.builtInAccount},connectionId:d(n.connectionId),displayName:d(n.displayName),isDefault:n.isDefault,serviceId:d(n.serviceId),status:t}}function Sf(e,n=!1){let t=w(e),r=t.description,o=n&&Object.hasOwn(t,"value");if(D(t,["jsonSchema","nullable",...r==null?[]:["description"],...o?["value"]:[]]),r!=null&&typeof r!="string")return f();if(typeof t.nullable!="boolean")return f();return{...r==null?{}:{description:r},jsonSchema:pe(t.jsonSchema),nullable:t.nullable,...o?{value:pe(t.value)}:{}}}function nw(e){return Sf(e,!0)}function xf(e,n){return Object.fromEntries(Object.entries(w(e)).map(([t,r])=>[t,n(r)]))}function tw(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(D(n,["actionId",...Object.hasOwn(n,"operationType")?["operationType"]:[],...Object.hasOwn(n,"inputSchema")?["inputSchema"]:[],...Object.hasOwn(n,"outputSchema")?["outputSchema"]:[],"authenticated","description",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[],"inputs","name","outputs","serviceId","serviceName"]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return f();return{...n.inputSchema===void 0?{}:{inputSchema:pe(n.inputSchema)},...n.outputSchema===void 0?{}:{outputSchema:pe(n.outputSchema)},actionId:d(n.actionId),...n.operationType==null?{}:{operationType:d(n.operationType)},authenticated:typeof n.authenticated=="boolean"?n.authenticated:f(),description:typeof n.description=="string"?n.description:f(),...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...oo(n.iconSprite,n.iconSpritePosition),inputs:xf(n.inputs,nw),name:d(n.name),outputs:xf(n.outputs,Sf),serviceId:d(n.serviceId),serviceName:d(n.serviceName)}}function so(e){let{defaultConnection:n,...t}=w(e),r=tw(t);if(n==null)return r;let o=Qn(n);if(o.serviceId!=r.serviceId||o.status!="active")return f();return{...r,defaultConnection:o}}function If(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(n.noSetup!==void 0&&typeof n.noSetup!="boolean")return f();if(D(n,[...Object.hasOwn(n,"noSetup")?["noSetup"]:[],"serviceId","serviceName",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[]]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return f();return{...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...oo(n.iconSprite,n.iconSpritePosition),serviceId:d(n.serviceId),serviceName:d(n.serviceName),...n.noSetup===void 0?{}:{noSetup:n.noSetup}}}function As(e){return{actionId:e.actionId,authenticated:e.authenticated,...e.defaultConnection==null?{}:{defaultConnection:{connectionId:e.defaultConnection.connectionId,displayName:e.defaultConnection.displayName,status:e.defaultConnection.status}},description:e.description,name:e.name,serviceId:e.serviceId,serviceName:e.serviceName}}var An=_().min(1).max(256),rw=_().regex(/^[a-z][a-z0-9_.]{0,127}$/),ow=_().trim().min(1).max(128),Ef=v({version:E(1),sourceId:An,revision:ge().positive(),name:ow,provider:ae(["feishu","feishu_app_bot"]),appId:An,connectionId:An,teamId:An.nullable(),enabled:he(),eventTypes:P(rw),manageSubscriptions:he(),verificationTokenConfigured:he(),encryptKeyConfigured:he(),endpointUrl:_().nullable(),verifiedAt:_().nullable(),lastReceivedAt:_().nullable(),updatedAt:_(),consumers:P(v({flowId:An,flowName:_(),triggerNodeId:An}))});function ao(e){return Ef.parse(e)}function Ps(e){return v({version:E(1),sources:P(Ef),teamId:An.nullable().optional()}).parse(e)}function _s(e){let n=w(e);if(D(n,["version","locale","definitions","display"]),n.version!=3||!pa(n.locale)||!Array.isArray(n.definitions))return f();let t=n.definitions.map(Bt),r=w(n.display),o=new Set(t.map((s)=>s.key));if(o.size!=t.length||Object.keys(r).length!=o.size)return f();let i=Object.fromEntries(t.map((s)=>{let{key:a}=s,c=w(r[a]);return D(c,["configInputs","configInputLabels","displayName","description","outputs"]),[a,{configInputs:Cf(c.configInputs,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),configInputLabels:iw(c.configInputLabels,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),displayName:d(c.displayName),description:d(c.description),outputs:Cf(c.outputs,s.outputs.map((u)=>u.handle))}]}));return{version:3,locale:n.locale,definitions:t,display:i}}function Cf(e,n){let t=w(e);return D(t,n),Object.fromEntries(Object.entries(t).map(([r,o])=>[r,d(o)]))}function iw(e,n){let t=w(e);if(Object.keys(t).some((r)=>!n.includes(r)))return f();return Object.fromEntries(Object.entries(t).map(([r,o])=>{let i=d(o);return i.trim().length==0?f():[r,i]}))}function js(e,n){if(n==null)return e;let t=n.toLowerCase();return e.filter((r)=>[r.description,r.displayName,r.key,r.name,r.provider,r.type].some((o)=>o.toLowerCase().includes(t)))}var sw=v({pointer:_().max(4096).default(""),offset:me().int().nonnegative().default(0),limit:me().int().min(1).max(100).default(20),maxBytes:me().int().min(1).max(1048576).default(15000)});var aw=Ke(),Of=v({pointer:_(),type:ae(["object","array","string","number","boolean","null"]),length:me().int().nonnegative().optional(),complete:he(),value:aw.optional()}),cw=Of.extend({offset:me().int().nonnegative(),nextOffset:me().int().positive().optional(),entries:P(Of).optional()}),Rf=v({resultId:_().min(1),callId:_().min(1),toolId:_().min(1),source:Vr("kind",[v({kind:E("connector"),action:_().min(1)}),v({kind:E("code")})]),bytes:me().int().nonnegative(),digest:_().regex(/^[a-f0-9]{64}$/),createdAt:_().datetime()}),uw=v({version:E(1),runId:_(),results:P(Rf),nextAfter:_().optional()}),lw=v({version:E(1),runId:_(),result:Rf,page:cw});function $s(e){return uw.parse(e)}function Ns(e){return lw.parse(e)}function Af(e){if(!Array.isArray(e))return f();return e.map((n)=>typeof n=="string"||Number.isSafeInteger(n)?n:f())}function dw(e){let n=w(e),t=d(n.kind);if(t=="artifact"||t=="binary"||t=="nullable")return{kind:t};if(t=="schema")return{kind:t,path:n.path==null?void 0:Af(n.path)};if(t!="keyword"||typeof n.keyword!="string"||!Hi(n.keyword))return f();return{kind:t,keyword:n.keyword,path:Af(n.path),source:n.source===void 0?void 0:pe(n.source),target:n.target===void 0?void 0:pe(n.target)}}function pw(e){let n=w(e),t=n.values==null?void 0:w(n.values);return{code:d(n.code),column:oe(n.column),...n.fields===void 0?{}:{fields:Array.isArray(n.fields)?n.fields.map(d):f()},line:oe(n.line),message:d(n.message),mismatch:n.mismatch==null?void 0:dw(n.mismatch),path:typeof n.path=="string"?n.path:f(),...t==null?{}:{values:Object.fromEntries(Object.entries(t).map(([r,o])=>[r,typeof o=="string"||typeof o=="number"?o:f()]))}}}function Pf(e){let n=w(e);if(n.version!=1||typeof n.valid!="boolean"||!Array.isArray(n.diagnostics))return f();return{closureDigest:d(n.closureDigest),diagnostics:n.diagnostics.map(pw),engineContract:d(n.engineContract),flowId:d(n.flowId),modelVersion:oe(n.modelVersion),revisionDigest:d(n.revisionDigest),revisionId:d(n.revisionId),valid:n.valid,version:1}}var _f=(e)=>e==null?"":`?flowId=${encodeURIComponent(e)}`;function jf(e,n){let t=new URLSearchParams({...e==null?{}:{flowId:e},...n==null?{}:{locale:n}}).toString();return{path:`/v1/connector/providers${t?`?${t}`:""}`,decode:(r)=>{let o=w(r);if(D(o,["providers","version"]),o.version!=1||!Array.isArray(o.providers))return f();return o.providers.map(If)}}}function $f(e,n,t){let r=new URLSearchParams({...n==null?{}:{flowId:n},...t==null?{}:{locale:t}}).toString();return{path:`/v1/connector/actions/${encodeURIComponent(e)}${r?`?${r}`:""}`,decode:(o)=>{let i=w(o);if(D(i,["action","version"]),i.version!=1)return f();return so(i.action)}}}function Nf(e){return{path:`/v1/connector/connections${_f(e)}`,decode:(n)=>{let t=w(n);if(D(t,["connections","version"]),t.version!=1||!Array.isArray(t.connections))return f();return t.connections.map(Qn)}}}function Tf(e,n){return{path:`/v1/connector/connections/${encodeURIComponent(e)}${_f(n)}`,decode:(t)=>{let r=w(t);if(D(r,["connections","serviceId","version"]),r.version!=1||d(r.serviceId)!=e||!Array.isArray(r.connections))return f();return r.connections.map(Qn)}}}function Ts(e){return Array.isArray(e)?e.map(d):f()}function fw(e){let n=w(e),t=n.draft===null?null:w(n.draft),r=w(n.sharedAccess);if(t!=null&&!Array.isArray(t.connections))return f();if(!Array.isArray(r.bindings))return f();let o=oe(r.accessRevision);if(o<0)return f();return{draft:t==null?null:{variableNames:Ts(t.variableNames),errorSourceFlowIds:Ts(t.errorSourceFlowIds),connections:t.connections.map((i)=>{let s=w(i);return{providerId:d(s.providerId),connectionId:d(s.connectionId)}})},sharedAccess:{accessRevision:o,providerIds:Ts(r.providerIds),bindings:r.bindings.map((i)=>{let s=w(i);return{providerId:d(s.providerId),connectionId:s.connectionId===null?null:d(s.connectionId),accessBindingId:d(s.accessBindingId)}})}}}function xn(e){let n=w(e),t=n.status;if(n.version!=1)return f();if(t!="active"&&t!="retiring")return f();let r=n.live==null?void 0:w(n.live);if(r!=null&&typeof r.enabled!="boolean")return f();return{...r==null?{}:{live:{enabled:r.enabled,publicationId:d(r.publicationId),revisionId:d(r.revisionId)}},createdAt:d(n.createdAt),...n.connectorTeamId==null?{}:{connectorTeamId:d(n.connectorTeamId)},draftRevisionId:d(n.draftRevisionId),resourceReferences:fw(n.resourceReferences),flowId:d(n.flowId),name:d(n.name),status:t,updatedAt:d(n.updatedAt),version:1}}function zf(e){let n=w(e);if(n.version!=1||!Array.isArray(n.flows))return f();let{nextCursor:t,total:r}=n;if(t!=null&&typeof t!="string")return f();if(r!=null&&!Number.isSafeInteger(r))return f();return{...t==null?{}:{nextCursor:t},flows:n.flows.map(xn),...r==null?{}:{total:r},version:1}}function co(e){let n=w(e);if(D(n,["name","updatedAt","value","version"]),n.version!=1||typeof n.value!="string")return f();let t=d(n.updatedAt);try{if(new Date(t).toISOString()!=t)return f()}catch{return f()}return{name:d(n.name),updatedAt:t,value:n.value,version:1}}function Df(e){let n=w(e);if(typeof n.enabled!="boolean")return f();return{flowId:d(n.flowId),flowName:d(n.flowName),nodeId:d(n.nodeId),nodeName:d(n.nodeName),enabled:n.enabled}}function Vf(e){let n=w(e);if(D(n,["version","references","unknown"]),n.version!=1||!Array.isArray(n.references)||!Array.isArray(n.unknown))return f();return{version:1,references:n.references.map((t)=>{let r=w(t);if(D(r,["flowId","flowName","draft","live"]),typeof r.draft!="boolean")return f();let o=r.live===null?null:w(r.live);if(o!=null){if(D(o,["publicationId","enabled"]),typeof o.enabled!="boolean")return f()}return{flowId:d(r.flowId),flowName:d(r.flowName),draft:r.draft,live:o==null?null:{publicationId:d(o.publicationId),enabled:o.enabled}}}),unknown:n.unknown.map((t)=>{let r=w(t);if(D(r,["flowId","flowName","scope"]),r.scope!=="draft"&&r.scope!=="live")return f();return{flowId:d(r.flowId),flowName:d(r.flowName),scope:r.scope}})}}function uo(e){let n=w(e),t=n.liveEnd==null?void 0:w(n.liveEnd);if(t!=null&&typeof t.enabled!="boolean")return f();let{operation:r,sourcePublicationId:o}=n;if(n.version!=1)return f();if(r!="publish"&&r!="rollback")return f();if(o!=null&&typeof o!="string")return f();return{...t==null?{}:{liveEnd:{enabled:t.enabled,endedAt:d(t.endedAt)}},actorId:d(n.actorId),closureDigest:d(n.closureDigest),createdAt:d(n.createdAt),engineContract:d(n.engineContract),flowId:d(n.flowId),modelVersion:oe(n.modelVersion),operation:r,publicationId:d(n.publicationId),sharedAccessDigest:d(n.sharedAccessDigest),revisionDigest:d(n.revisionDigest),revisionId:d(n.revisionId),...o==null?{}:{sourcePublicationId:o},version:1}}function zs(e){let n=w(e),t=n.status,r={createdAt:d(n.createdAt),flowId:d(n.flowId),operationId:d(n.operationId),revisionId:d(n.revisionId),updatedAt:d(n.updatedAt),version:1};if(n.version!=1)return f();switch(t){case"pending":return D(n,["createdAt","flowId","operationId","revisionId","status","updatedAt","version"]),{...r,status:t};case"succeeded":return D(n,["createdAt","flowId","operationId","publicationId","revisionId","status","updatedAt","version"]),{...r,publicationId:d(n.publicationId),status:t};case"failed":{D(n,["createdAt","flowId","issue","operationId","revisionId","status","updatedAt","version"]);let o=w(n.issue),i=o.nodeId;return D(o,["code","message",...i==null?[]:["nodeId"]]),{...r,issue:{code:d(o.code),message:d(o.message),...i==null?{}:{nodeId:d(i)}},status:t}}default:return f()}}function Ds(e){let n=w(e),{status:t,publication:r}=n;if(n.version!=1||typeof n.hasUnpublishedChanges!="boolean")return f();if(t!="not-published"&&t!="runnable"&&t!="suspended")return f();if(t=="not-published"&&r!==null)return f();if(t!="not-published"&&r===null)return f();return{flowId:d(n.flowId),hasUnpublishedChanges:n.hasUnpublishedChanges,publication:r===null?null:uo(r),revision:oe(n.revision),status:t,version:1}}function Zf(e){let n=w(e),{nextCursor:t,total:r}=n;if(n.version!=1||!Array.isArray(n.publications))return f();if(t!=null&&typeof t!="string")return f();if(r!=null&&!Number.isSafeInteger(r))return f();return{...t==null?{}:{nextCursor:t},publications:n.publications.map(uo),...r==null?{}:{total:r},version:1}}function Mf(e){let n=w(e),t=n.parentRevisionId;if(n.version!=1||t!==null&&typeof t!="string")return f();return{actorId:d(n.actorId),createdAt:d(n.createdAt),digest:d(n.digest),flowId:d(n.flowId),modelVersion:oe(n.modelVersion),parentRevisionId:t,revisionId:d(n.revisionId),version:1}}function Wt(e){let n=w(e);try{return{...Mf(n),content:Gi(n.content)}}catch{return f()}}function lo(e){let n=w(e);if(n.version!=1||oe(n.revision)<1)return f();return{revision:oe(n.revision),updatedAt:d(n.updatedAt),value:Object.fromEntries(Object.entries(w(n.value)).map(([t,r])=>[t,pe(r)])),version:1}}function po(e){let n=w(e);if(n.version!=1)return f();return{revision:Mf(n.revision),version:1}}function Ff(e){let n=w(e);if(n.version!=1||n.kind!="snapshot")return f();return{draft:Wt(n.draft),kind:"snapshot",version:1}}var mw=["canceled","completed","failed","indeterminate"],fo=[...mw,"queued","running","starting","waiting"];var gw=new Set(fo);function Vs(e){return typeof e=="string"&&gw.has(e)?e:f()}function Lf(e){let n=w(e),{source:t,startedAt:r,finishedAt:o}=n;if(n.version!=1||t!="draft"&&t!="live")return f();if(r!=null&&typeof r!="string")return f();if(o!=null&&typeof o!="string")return f();return{createdAt:d(n.createdAt),...o==null?{}:{finishedAt:o},flowId:d(n.flowId),revisionId:d(n.revisionId),runId:d(n.runId),source:t,...r==null?{}:{startedAt:r},status:Vs(n.status),version:1}}function hw(e){let n=w(e);D(n,["actions","expiresAt","nodeId","prompt","waitId","waitingSince"]);let t=n.actions;if(!Array.isArray(t)||!(t.length==1&&t[0]=="continue"||t.length==2&&t[0]=="approve"&&t[1]=="reject"))return f();return{actions:t,expiresAt:d(n.expiresAt),nodeId:d(n.nodeId),prompt:d(n.prompt),waitId:d(n.waitId),waitingSince:d(n.waitingSince)}}function mo(e){let n=w(e),t=Lf(n),r=n.eventsExpiresAt;if(r!=null&&typeof r!="string")return f();if(n.waiting!==void 0||!Array.isArray(n.waits))return f();let o=n.waits.map(hw);if(new Set(o.map((a)=>a.waitId)).size!=o.length||t.status=="waiting"&&o.length==0||["completed","failed","canceled","indeterminate"].includes(t.status)&&o.length>0)return f();if(n.occurrenceId===void 0!=(n.triggerNodeId===void 0))return f();let i={status:t.status,waits:o},s={...t,...yw(n),closureDigest:d(n.closureDigest),engineContract:d(n.engineContract),engineDigest:d(n.engineDigest),...r==null?{}:{eventsExpiresAt:r},modelVersion:oe(n.modelVersion),sharedAccessDigest:d(n.sharedAccessDigest),revisionDigest:d(n.revisionDigest),...i};switch(t.source){case"draft":return{...s,source:"draft"};case"live":return{...s,publicationId:d(n.publicationId),source:"live",...n.occurrenceId===void 0?{}:{occurrenceId:d(n.occurrenceId),triggerNodeId:d(n.triggerNodeId)}}}}function qf(e){let n=w(e),t=n.nextCursor;if(n.version!=1||!Array.isArray(n.runs))return f();if(t!=null&&typeof t!="string")return f();return{flowId:d(n.flowId),...t==null?{}:{nextCursor:t},runs:n.runs.map(Lf),version:1}}function Uf(e){let n=w(e),t=Vs(n.status);if(n.version!=1||typeof n.cancelAccepted!="boolean"||t=="queued"||t=="starting"||t=="running"||t=="waiting")return f();return{cancelAccepted:n.cancelAccepted,runId:d(n.runId),status:t,version:1}}function Kf(e){let n=w(e);D(n,["action","comment","resolutionAccepted","resolvedAt","runId","status","version","waitId"]);let{action:t,resolvedAt:r}=n;if(n.version!=1||typeof n.resolutionAccepted!="boolean"||n.comment!==null&&typeof n.comment!="string"||t!==null&&t!="approve"&&t!="continue"&&t!="reject"||r!==null&&typeof r!="string"||t===null!=(r===null)||n.resolutionAccepted&&t===null)return f();return{action:t,comment:n.comment,resolutionAccepted:n.resolutionAccepted,resolvedAt:r,runId:d(n.runId),status:Vs(n.status),version:1,waitId:d(n.waitId)}}function Bf(e){let n=w(e),t=n.status;if(n.version!=1)return f();let r={finishedAt:d(n.finishedAt),runId:d(n.runId),version:1};if(t=="completed"){if(!Object.hasOwn(n,"result"))return f();return{...r,result:n.result,status:"completed"}}if(t=="canceled")return{...r,status:"canceled"};if(t=="failed"){let o=w(n.error);return{...r,error:Jf(o),status:"failed"}}if(t=="indeterminate"){let o=w(n.error);return{...r,error:Jf(o),status:"indeterminate"}}return f()}function yw(e){let n=e.errorSource==null?void 0:w(e.errorSource);if(e.errorDispatches!=null&&!Array.isArray(e.errorDispatches))return f();return{...n==null?{}:{errorSource:{flowId:d(n.flowId),runId:d(n.runId)}},...e.errorDispatches==null?{}:{errorDispatches:e.errorDispatches.map((t)=>{let r=w(t),o=d(r.flowId);switch(r.status){case"pending":return{status:"pending",flowId:o};case"dispatched":return{status:"dispatched",flowId:o,runId:d(r.runId)};case"failed":return{status:"failed",flowId:o,message:d(r.message)};default:return f()}})}}}function Jf(e){return{code:d(e.code),message:d(e.message),...e.nodeId===void 0?{}:{nodeId:d(e.nodeId)},...e.jobId===void 0?{}:{jobId:d(e.jobId)},...e.path===void 0?{}:{path:(Array.isArray(e.path)?e.path:f()).map(d)}}}function Zs(){let e=globalThis.crypto;if(e!=null){try{if(typeof e.randomUUID=="function")return e.randomUUID()}catch{}if(typeof e.getRandomValues=="function"){let n=e.getRandomValues(new Uint8Array(16));n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let t=Array.from(n,(r)=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Wf(e){return e?.kind=="run.completed"||e?.kind=="run.failed"||e?.kind=="run.canceled"||e?.kind=="run.indeterminate"}function bw(e){let n=w(e),t=oe(n.sequence);if(t<0)return f();let r={createdAt:d(n.createdAt),sequence:t},o=w(n.payload),i=n.kind;switch(i){case"run.queued":return{...r,kind:i,payload:{}};case"run.started":return{...r,kind:i,payload:{flowId:d(o.flowId),scopeId:d(o.scopeId),...o.parentScopeId===void 0?{}:{parentScopeId:d(o.parentScopeId)}}};case"run.progress":return{...r,kind:i,payload:{flowId:d(o.flowId),scopeId:d(o.scopeId),progress:Gf(o.progress)}};case"run.waiting":if(!Array.isArray(o.waitIds))return f();return{...r,kind:i,payload:{waitIds:o.waitIds.map((s)=>d(s))}};case"wait.created":return{...r,kind:i,payload:{expiresAt:d(o.expiresAt),nodeId:d(o.nodeId),waitId:d(o.waitId),waitingSince:d(o.waitingSince)}};case"run.resolved":{let s=o.action;if(s!=="approve"&&s!=="continue"&&s!=="reject")return f();if(o.comment!==null&&typeof o.comment!="string")return f();return{...r,kind:i,payload:{action:s,comment:o.comment,resolvedAt:d(o.resolvedAt),waitId:d(o.waitId)}}}case"run.completed":case"run.canceled":case"run.failed":case"run.indeterminate":return{...r,kind:i,payload:{result:pe(o.result)}};case"run.events-truncated":return{...r,kind:i,payload:Object.fromEntries(Object.entries(o).map(([s,a])=>[s,pe(a)]))};case"node.started":case"node.completed":case"node.failed":case"node.log":case"node.progress":case"node.artifact":{let s={flowId:d(o.flowId),scopeId:d(o.scopeId),nodeId:d(o.nodeId),executionId:d(o.executionId)};switch(i){case"node.started":{let a=o.nodeKind;if(a!==void 0&&a!=="approval"&&a!=="condition"&&a!=="connector"&&a!=="javascript"&&a!=="decision"&&a!=="openapi"&&a!=="llm"&&a!=="agent"&&a!=="value"&&a!=="wait")return f();return{...r,kind:i,payload:{...s,...a===void 0?{}:{nodeKind:a},...o.nodeTitle===void 0?{}:{nodeTitle:d(o.nodeTitle)},...o.operation===void 0?{}:{operation:d(o.operation)}}}}case"node.completed":return{...r,kind:i,payload:{...s,outputs:Object.fromEntries(Object.entries(w(o.outputs)).map(([a,c])=>[a,pe(c)]))}};case"node.failed":{let a=w(o.error);return{...r,kind:i,payload:{...s,error:{code:d(a.code),message:d(a.message)}}}}case"node.log":{let a=o.level;if(a!=="debug"&&a!=="info"&&a!=="warn"&&a!=="error")return f();return{...r,kind:i,payload:{...s,level:a,message:d(o.message)}}}case"node.progress":return{...r,kind:i,payload:{...s,progress:Gf(o.progress)}};case"node.artifact":{let a=w(o.artifact),c=oe(a.size),u=d(a.digest);if(a.kind!="artifact"||c<0||!/^sha256:[0-9a-f]{64}$/.test(u))return f();return{...r,kind:i,payload:{...s,artifact:{kind:"artifact",id:d(a.id),name:d(a.name),size:c,digest:u,...a.mediaType===void 0?{}:{mediaType:d(a.mediaType)}}}}}}}default:return f()}}function Gf(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=100?e:f()}function ww(e){let n=w(e),t=n.eventsExpiresAt,r=oe(n.nextAfter);if(n.version!=1||!Array.isArray(n.events)||typeof n.done!="boolean"||typeof n.historyComplete!="boolean")return f();if(t!=null&&typeof t!="string")return f();if(r<0)return f();return{done:n.done,events:n.events.map(bw),...t==null?{}:{eventsExpiresAt:t},historyComplete:n.historyComplete,nextAfter:r,runId:d(n.runId),version:1}}var C=encodeURIComponent;function Yn(e){return`${e}-${Zs()}`}class Ms{constructor(e){this.requestControl=e}async loadOpenApiDocument(e,n){let t=w(await this.request("/v1/openapi/document",{method:"POST",body:JSON.stringify({url:e,version:1}),signal:n}));if(t.version!=1)return f();return pe(t.document)}async listFlows(e={}){let n=new URLSearchParams;if(e.cursor!=null)n.set("cursor",e.cursor);if(e.limit!=null)n.set("limit",String(e.limit));if(e.includeTotal!=null)n.set("includeTotal",String(e.includeTotal));let t=n.size==0?"":`?${n}`;return zf(await this.request(`/v1/flows${t}`))}async listEventSources(e,n){return Ps(await this.request("/v1/event-sources"+(e==null?"":`?flowId=${C(e)}`),{signal:n}))}async listEventSourceConnections(e,n){let t=w(await this.request(`/v1/event-sources/connections${e==null?"":`?teamId=${C(e)}`}`,{signal:n}));if(D(t,["version","connections"]),t.version!=1||!Array.isArray(t.connections))return f();return t.connections.map(Qn)}async createEventSource(e){return ao(await this.request("/v1/event-sources",{method:"POST",body:JSON.stringify(e)}))}async updateEventSource(e,n){return ao(await this.request(`/v1/event-sources/${C(e)}`,{method:"PUT",body:JSON.stringify(n)}))}async deleteEventSource(e,n){await this.request(`/v1/event-sources/${C(e)}`,{method:"DELETE",body:JSON.stringify({version:1,expectedRevision:n})})}async listVariables(){let e=w(await this.request("/v1/variables"));if(D(e,["variables","version"]),e.version!=1||!Array.isArray(e.variables))return f();return{variables:e.variables.map(co),version:1}}async getVariableReferences(e,n){return Vf(await this.request(`/v1/variables/${C(e)}/references`,{signal:n}))}async getVariable(e){return co(await this.request(`/v1/variables/${C(e)}`))}async putVariable(e,n){return co(await this.request(`/v1/variables/${C(e)}`,{body:JSON.stringify({value:n}),method:"PUT"}))}async deleteVariable(e){let n=w(await this.request(`/v1/variables/${C(e)}`,{method:"DELETE"}));if(D(n,["version"]),n.version!=1)return f()}async createFlow(e,n=`flow-${Zs()}`,t){return xn(await this.request("/v1/flows",{body:JSON.stringify({name:e,...t==null?{}:{teamId:t},version:1}),headers:{"idempotency-key":n},method:"POST"}))}async getFlow(e){return xn(await this.request(`/v1/flows/${C(e)}`))}async getErrorListeners(e,n){let t=w(await this.request(`/v1/flows/${C(e)}/error-listeners`,{signal:n}));if(t.version!=1||!Array.isArray(t.listeners))return f();return t.listeners.map(Df)}async renameFlow(e,n){return xn(await this.request(`/v1/flows/${C(e)}`,{body:JSON.stringify({name:n,version:1}),method:"PATCH"}))}async deleteFlow(e){return xn(await this.request(`/v1/flows/${C(e)}`,{method:"DELETE"}))}async listTriggerKeys(e,n){let t=w(await this.request(`/v1/trigger-keys${n==null?"":`?locale=${encodeURIComponent(n)}`}`,{signal:e}));if(t.version!=1||!Array.isArray(t.keys))return f();return t.keys.map(Cs)}async listTriggerDefinitions(e){let n=w(await this.request("/v1/trigger-keys/catalog",{signal:e}));if(n.version!=2||!Array.isArray(n.definitions))return f();return n.definitions.map(Bt)}async readCatalog(e,n,t){let r=new Headers;if(n)r.set("if-none-match",n);let o=await this.response(e.path,{headers:r,signal:t},!0),i=o.headers.get("etag")?.trim()||null;if(o.status==304)return{modified:!1,etag:i};return{modified:!0,data:e.decode(await o.json()),etag:i}}async getTriggerCatalog(e,n,t){let r=new Headers;if(n?.etag)r.set("if-none-match",n.etag);let o=await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(e)}`,{headers:r,signal:t},!0);if(o.status==304){if(n==null)return f();return{...n,etag:o.headers.get("etag")?.trim()||n.etag}}return{data:_s(await o.json()),etag:o.headers.get("etag")?.trim()||null}}async getTriggerKey(e,n){let t=w(await this.request(`/v1/trigger-keys/${C(e)}`,{signal:n}));if(t.version!=1)return f();return Bt(t.definition)}async listFlowTriggerBindings(e,n){let t=w(await this.request(`/v1/flows/${C(e)}/triggers`,{signal:n}));if(t.version!=1||d(t.flowId)!=e||!Array.isArray(t.bindings))return f();return t.bindings.map(Gt)}async getFlowTriggerBinding(e,n){return pf(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}`))}async listFlowTriggerActivities(e,n,t={}){let r=new URLSearchParams;if(t.cursor!=null)r.set("cursor",t.cursor);if(t.limit!=null)r.set("limit",String(t.limit));let o=r.size==0?"":`?${r}`;return ff(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/activities${o}`))}async testFlowPollTrigger(e,n){return mf(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/test`,{body:JSON.stringify({version:1}),method:"POST"}))}async getEditor(e){let n=w(await this.request(`/v1/flows/${C(e)}/editor`));if(n.version!=1)return f();let t={flow:xn(n.flow),draft:Wt(n.draft),live:Ds(n.live),presentation:lo(n.presentation),version:1};if(t.flow.flowId!=e||t.draft.flowId!=e||t.live.flowId!=e||t.flow.draftRevisionId!=t.draft.revisionId)return f();return t}async getPublicationPresentation(e,n,t){let r=w(await this.request(`/v1/flows/${C(e)}/publications/${C(n)}/presentation`,{signal:t}));if(r.version!=1)return f();return{version:1,presentation:r.presentation===null?null:lo(r.presentation)}}async getPresentation(e){return lo(await this.request(`/v1/flows/${C(e)}/presentation`))}async getDraft(e){return Wt(await this.request(`/v1/flows/${C(e)}/draft`))}async syncDraft(e){return Ff(await this.request(`/v1/flows/${C(e)}/draft/sync`))}async getRevision(e,n,t){return Wt(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}`,{signal:t}))}async listTriggerConfigOptions(e,n,t,r){let o=w(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/options/${C(t)}`,{signal:r}));if(D(o,["options","version"]),o.version!=1||!Array.isArray(o.options)||o.options.length>1000)return f();return o.options.map((i)=>{let s=w(i);D(s,["value","label",...s.color==null?[]:["color"]]);let a=s.color==null?void 0:d(s.color);if(a!=null&&!/^#[0-9a-fA-F]{6}$/.test(a))return f();return a==null?{value:d(s.value),label:d(s.label)}:{value:d(s.value),label:d(s.label),color:a}})}async listConnectorTeams(e){let n=w(await this.request("/v1/connector/teams",{signal:e}));if(D(n,["enabled","teams","version"]),n.version!=1||typeof n.enabled!="boolean"||!Array.isArray(n.teams))return f();return{enabled:n.enabled,teams:n.teams.map((t)=>{let r=w(t);if(D(r,["id","name","systemCreated"]),typeof r.systemCreated!="boolean")return f();return{id:d(r.id),name:d(r.name),systemCreated:r.systemCreated}}),version:1}}async listConnectorProviders(e,n,t){let r=jf(n,t);return this.connectorRequest(r.path,"providers",e,r.decode)}async removeConnectionUsage(e,n,t,r,o){return po(await this.request(`/v1/flows/${C(e)}/connection-usage/remove`,{method:"POST",headers:{"idempotency-key":o},body:JSON.stringify({connectionId:n,expectedRevisionId:t,expectedAccessRevision:r,version:1})}))}async getConnectorAccess(e,n){return Hn(await this.request(`/v1/flows/${C(e)}/connector-access`,{signal:n}))}async getPublishedConnectorAccess(e,n,t){return Rs(await this.request(`/v1/flows/${C(e)}/connector-access?publicationId=${C(n)}`,{signal:t}))}async listProviderAccessBindingCandidates(e,n,t){return kf(await this.request(`/v1/flows/${C(e)}/connector-access/candidates/query`,{method:"POST",body:JSON.stringify({providerIds:n,version:1}),signal:t}),n)}async setConnectorService(e,n,t,r){return Hn(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}/service`,{body:JSON.stringify({expectedAccessRevision:r,version:1}),method:t?"PUT":"DELETE"}))}async addProviderAccessBinding(e,n,t,r){return Hn(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"PUT"}))}async removeProviderAccessBinding(e,n,t,r){return Hn(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"DELETE"}))}async listConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},...e==null?{}:{service:e}},n)}async searchConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},q:e.trim()},n)}async getConnectorAction(e,n,t,r,o=!1){let i=$f(e,t,r);return this.connectorRequest(i.path,"actions",n,i.decode,o)}async listAllConnectorConnections(e,n,t=!1){let r=Nf(n);return this.connectorRequest(r.path,"connections",e,r.decode,t)}async listConnectorConnections(e,n,t,r=!1){let o=Tf(e,t);return this.connectorRequest(o.path,"connections",n,o.decode,r)}async createConnectorConnectionPage(e,n,t){let r=new URLSearchParams;if(n!=null)r.set("flowId",n);if(t!=null)r.set("teamId",t);let o=w(await this.request(`/v1/connector/connections/${C(e)}/page${r.size==0?"":`?${r}`}`,{body:JSON.stringify({version:1}),method:"POST"}));if(D(o,["url","version"]),o.version!=1)return f();try{let i=new URL(d(o.url));if(i.protocol!="http:"&&i.protocol!="https:")return f();return i.href}catch{return f()}}async readAuthoring(e,n={}){return cf.parse(await this.request(`/v1/flows/${C(e)}/authoring/read`,{method:"POST",body:JSON.stringify(n)}))}async searchAuthoring(e,n){return uf.parse(await this.request(`/v1/flows/${C(e)}/authoring/search`,{method:"POST",body:JSON.stringify(n)}))}async authoringSchema(e,n){return w(await this.request(`/v1/flows/${C(e)}/authoring/schema`,{method:"POST",body:JSON.stringify(n)}))}async editAuthoring(e,n){return af.parse(await this.request(`/v1/flows/${C(e)}/authoring/edit`,{method:"POST",headers:{"idempotency-key":n.requestId},body:JSON.stringify(n)}))}async checkAuthoring(e,n){return sf.parse(await this.request(`/v1/flows/${C(e)}/authoring/check`,{method:"POST",body:JSON.stringify({revisionId:n})}))}async changeDraft(e,n,t,r=Yn("change")){return po(await this.request(`/v1/flows/${C(e)}/draft/changes`,{body:JSON.stringify({expectedRevisionId:n,operations:t,version:1}),headers:{"idempotency-key":r},method:"POST"}))}async repairDraft(e,n,t=Yn("repair")){return po(await this.request(`/v1/flows/${C(e)}/draft/repair`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t},method:"POST"}))}async checkFlow(e,n){return Pf(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/check`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",version:1}),method:"POST"}))}async getLive(e,n){return Ds(await this.request(`/v1/flows/${C(e)}/live`,{signal:n}))}async listPublicationResources(e,n){let t=n==null?"":`?publicationId=${encodeURIComponent(n)}`,r=yf(await this.request(`/v1/flows/${C(e)}/resources${t}`));if(r.flowId!=e||n!=null&&r.publicationId!=n)return f();return r}async getPublicationResource(e,n,t){let r=t==null?"":`?publicationId=${encodeURIComponent(t)}`,o=bf(await this.request(`/v1/flows/${C(e)}/resources/${C(n)}${r}`));if(o.flowId!=e||o.resource.resourceId!=n||t!=null&&o.publicationId!=t)return f();return o}async listPublications(e,n={},t){let r=new URLSearchParams;if(n.cursor!=null)r.set("cursor",n.cursor);if(n.limit!=null)r.set("limit",String(n.limit));if(n.includeTotal!=null)r.set("includeTotal",String(n.includeTotal));let o=r.size==0?"":`?${r}`;return Zf(await this.request(`/v1/flows/${C(e)}/publications${o}`,{signal:t}))}async createDraftRun(e,n,t){let r=mo(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/runs`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",inputs:t.inputs??{},trigger:t.trigger,version:2}),headers:{"idempotency-key":t.idempotencyKey??Yn("run")},method:"POST"}));return r.source=="draft"?r:f()}async createLiveRun(e,n){let t=mo(await this.request("/v1/runs",{body:JSON.stringify({inputs:n.inputs??{},trigger:n.trigger,publicationId:e,version:2}),headers:{"idempotency-key":n.idempotencyKey??Yn("run")},method:"POST"}));return t.source=="live"?t:f()}async setFlowEnabled(e,n,t){return xn(await this.request(`/v1/flows/${C(e)}/enabled`,{method:"PUT",body:JSON.stringify({enabled:t,expectedPublicationId:n,version:1})}))}async publishFlow(e,n,t,r={}){return zs(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/publications`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Yn("publication")},method:"POST"}))}async getPublishOperation(e,n,t){return zs(await this.request(`/v1/flows/${C(e)}/publish-operations/${C(n)}`,{signal:t}))}async rollbackFlow(e,n,t,r={}){return uo(await this.request(`/v1/flows/${C(e)}/publications/${C(n)}/rollback`,{body:JSON.stringify({expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Yn("publication")},method:"POST"}))}async getRun(e,n){return mo(await this.request(`/v1/runs/${C(e)}`,{signal:n}))}async listRuns(e,n={}){let t=new URLSearchParams;if(n.cursor!=null)t.set("cursor",n.cursor);if(n.limit!=null)t.set("limit",String(n.limit));if(n.status!=null)t.set("status",n.status);if(n.pendingWait!=null)t.set("pendingWait",String(n.pendingWait));if(n.source!=null)t.set("source",n.source);if(n.createdFrom!=null)t.set("createdFrom",n.createdFrom);if(n.createdBefore!=null)t.set("createdBefore",n.createdBefore);if(n.runId!=null)t.set("runId",n.runId);let r=t.size==0?"":`?${t}`;return qf(await this.request(`/v1/flows/${C(e)}/runs${r}`))}async getRunEvents(e,n={},t){let r=new URLSearchParams;if(n.after!=null)r.set("after",String(n.after));if(n.limit!=null)r.set("limit",String(n.limit));let o=r.size==0?"":`?${r}`;return ww(await this.request(`/v1/runs/${C(e)}/events${o}`,{signal:t}))}async listRunResults(e,n,t){return $s(await this.request(`/v1/runs/${C(e)}/results${n==null?"":`?after=${encodeURIComponent(n)}`}`,{signal:t}))}async readRunResult(e,n,t={},r){let o=new URLSearchParams(Object.entries(t).map(([i,s])=>[i,String(s)]));return Ns(await this.request(`/v1/runs/${C(e)}/results/${C(n)}?${o}`,{signal:r}))}async downloadRunResult(e,n,t){return(await this.response(`/v1/runs/${C(e)}/results/${C(n)}/content`,{signal:t})).blob()}async getRunResult(e,n){return Bf(await this.request(`/v1/runs/${C(e)}/result`,{signal:n}))}async cancelRun(e){return Uf(await this.request(`/v1/runs/${C(e)}/cancel`,{body:JSON.stringify({version:1}),method:"POST"}))}async resolveRunWait(e,n,t,r){return Kf(await this.request(`/v1/runs/${C(e)}/waits/${C(n)}/resolve`,{body:JSON.stringify({action:t,comment:r,version:1}),method:"POST"}))}async connectorActions(e,n){let t=Object.entries(e).map(([o,i])=>`${C(o)}=${C(i)}`).join("&"),r=t==""?"":`?${t}`;return this.connectorRequest(`/v1/connector/actions${r}`,"actions",n,(o)=>{let i=w(o);if(D(i,["actions","version"]),i.version!=1||!Array.isArray(i.actions))return f();return i.actions.map(so)})}async connectorRequest(e,n,t,r,o=!1){return r(await this.request(e,{signal:t}))}async response(e,n,t=!1){let r=new Headers(n.headers);if(n.body!=null)r.set("content-type","application/json");let o=await this.requestControl(e,{...n,headers:r});if(!o.ok&&!(t&&o.status==304)){let i;try{i=await o.json()}catch{return f()}let s=w(i).error,a=s==null?void 0:w(s);throw new Ie(o.status,typeof a?.code=="string"?a.code:"request.failed",typeof a?.message=="string"?a.message:`Request failed with status ${o.status}.`,a?.details==null?void 0:w(a.details))}return o}async request(e,n={}){let t=await this.response(e,n);try{return await t.json()}catch{return f()}}}import{randomUUID as Ew}from"crypto";class I extends Error{constructor(e,n,t){super(n);this.code=e,this.details=t,this.name="CliError"}}function Fs(e,n){let t=e.trim();if(Ur(t)!=null)throw new I("cli.invalid-arguments",`${n} name must be between 1 and ${Qi} characters and use only letters, numbers, spaces, hyphens, or underscores.`);return t}var xw=100,Js=100,Ls=100,vw=new Set(["canceled","completed","failed","indeterminate"]);async function kw(e){let n=[],t=new Set,r;do{let o=await e.listFlows({cursor:r,limit:xw});if(n.push(...o.flows),r=o.nextCursor,r!=null&&t.has(r))throw new I("page.invalid-cursor","The deployment returned a repeated Flow cursor.");if(r!=null)t.add(r)}while(r!=null);return n}function Sw(e,n){let t=e.find((o)=>o.flowId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new I("flow.ambiguous",`Flow name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({flowId:o,name:i})=>({flowId:o,name:i}))});throw new I("flow.not-found",`Flow ${JSON.stringify(n)} was not found.`)}async function ye(e,n){try{return await e.getFlow(n)}catch(t){if(!(t instanceof Ie)||t.code!="flow.invalid"&&t.code!="flow.not-found")throw t}return Sw(await kw(e),n)}async function Hf(e,n,t){if(t.expectedRevision!=null&&t.expectedRevision!=n.draftRevisionId&&!t.options.includes("idempotency-key"))throw new I("flow.revision-conflict","The Flow Draft changed. Inspect it before submitting a new mutation.",{expectedRevisionId:t.expectedRevision,actualRevisionId:n.draftRevisionId,flowId:n.flowId});let r=await e.getRevision(n.flowId,t.expectedRevision??n.draftRevisionId);return{draft:r,flow:n,graph:r.content.document.graph}}function Iw(e,n){let t=e.find((o)=>o.actionId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new I("connector.action-ambiguous",`Connector Action name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({actionId:o,name:i,serviceId:s})=>({actionId:o,name:i,serviceId:s}))});throw new I("connector.action-not-found",`Connector Action ${JSON.stringify(n)} was not found.`)}async function Qf(e,n,t){try{return await e.getConnectorAction(n,void 0,t)}catch(r){if(!(r instanceof Ie)||r.status!=404)throw r}return Iw(await e.searchConnectorActions(n,void 0,t),n)}function Yf(e,n){let t=Object.entries(e.document.graph.nodes).filter((i)=>!("inputs"in i[1])),r=t?.find(([i])=>i==n);if(r!=null)return{trigger:r[1],triggerId:r[0]};let o=t?.filter(([,i])=>i.name==n)??[];if(o.length==1)return{trigger:o[0][1],triggerId:o[0][0]};if(o.length>1)throw new I("trigger.ambiguous",`Trigger name ${JSON.stringify(n)} is ambiguous.`,{candidates:o.map(([i,s])=>({name:s.name,triggerId:i}))});throw new I("trigger.not-found",`Trigger ${JSON.stringify(n)} was not found.`)}function qs(e){return`${e.displayName} ${e.key} ${e.provider} ${e.type}`}async function Xf(e,n){try{return await e.getTriggerKey(n)}catch(o){if(!(o instanceof Ie)||o.status!=404)throw o}let r=(await e.listTriggerKeys()).filter((o)=>o.name==n||o.displayName==n);if(r.length==1)return await e.getTriggerKey(r[0].key);if(r.length>1)throw new I("trigger-key.ambiguous",`Trigger Key name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({displayName:o,key:i,provider:s})=>({displayName:o,key:i,provider:s}))});throw new I("trigger-key.not-found",`Trigger Key ${JSON.stringify(n)} was not found.`)}function em(e){return`${e.displayName} ${e.connectionId} ${e.serviceId} ${e.status}${e.isDefault?"\tdefault":""}`}function Us(e){return`${e.name} ${e.actionId} ${e.serviceName} ${e.serviceId}`}function fe(e,n,t){if(e.length!=n)throw new I("cli.invalid-arguments",`Usage: ${t}`)}function M(e,n,t,r){e.stdout.write(n?`${JSON.stringify(t)}
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(n===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(n!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Kl(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let t=[];for(let r of n){if(!r||typeof r!=="object")return;Kl(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!t.includes(s))t.push(s)}}delete e.anyOf,e.type=t.length===1?t[0]:t}var Bl=new Set(["type","properties","required","additionalProperties"]),ql=["oneOf","anyOf"];function Ul(e){let n=e.additionalProperties;if(n===void 0||n===!1||typeof n!=="object"||n===null)return null;return Object.keys(n).length?n:null}function ki(e){let n=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Bl.has(s))return null;n.push(i)}let t={},r=new Set;for(let i of n){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(t,s))continue;let a=[];for(let u of n){let l=u.properties?.[s]??Ul(u);if(l===null||l===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:ki(a)??{allOf:a};De(t,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:t};if(r.size)o.required=[...r];if(n.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of n){let a=Ul(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function Hg(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let o of Bl)if(o in e)return;let t=n.filter((o)=>ql.some((i)=>Array.isArray(o[i]))),r=null;if(!t.length)r=ki(n);else{let o=t[0],i=ql.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=n.filter((c)=>c!==o),a=o[i].map((c)=>ki([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,St(e,r)}function Ot(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){r(d);let g=e.seen.get(d),h=g.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(h);else St(u,h);if(St(u,l),a._zod.parent===d)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(!(R in l))delete u[R]}if(h.$ref&&g.def)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(R in g.def&&JSON.stringify(u[R])===JSON.stringify(g.def[R]))delete u[R]}}let m=a._zod.parent;if(m&&m!==d){r(m);let g=e.seen.get(m);if(g?.schema.$ref){if(u.$ref=g.schema.$ref,g.def)for(let h in u){if(h==="$ref"||h==="allOf")continue;if(h in g.def&&JSON.stringify(u[h])===JSON.stringify(g.def[h]))delete u[h]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Kl(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);if(d)d.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Hg(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(n)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}St(o,t.defId?t.schema:t.def??t.schema);let i=e.metadataRegistry.get(n)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;De(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...n["~standard"],jsonSchema:{input:It(n,"input",e.processors),output:It(n,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Ce(e,n){let t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ce(r.element,t);if(r.type==="set")return Ce(r.valueType,t);if(r.type==="lazy")return Ce(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Ce(r.innerType,t);if(r.type==="intersection")return Ce(r.left,t)||Ce(r.right,t);if(r.type==="record"||r.type==="map")return Ce(r.keyType,t)||Ce(r.valueType,t);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Ce(r.in,t)||Ce(r.out,t)}if(r.type==="object"){for(let o in r.shape)if(Ce(r.shape[o],t))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(Ce(o,t))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(Ce(o,t))return!0;if(r.rest&&Ce(r.rest,t))return!0;return!1}return!1}var Wl=(e,n={})=>(t)=>{let r=Et({...t,processors:n});return ee(e,r),Ct(r,e),Ot(r,e)},It=(e,n,t={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=Et({...o??{},target:i,io:n,processors:t});return ee(e,s),Ct(s,e),Ot(s,e)};var Fn=(e,n,t)=>{if(e[n]===void 0||t>e[n])e[n]=t},Mn=(e,n,t)=>{if(e[n]===void 0||t<e[n])e[n]=t},Gl=(e,n)=>{Fn(e,"minimum",n),Mn(e,"maximum",n)},ed=(e,n)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(n))e.multipleOf.push(n)},nd=(e,n)=>{e.patterns??(e.patterns=new Set),e.patterns.add(n)},td=(e,n)=>{e.mime=e.mime?e.mime.filter((t)=>n.includes(t)):[...n]},rd=(e,n)=>{if(e.format=n,n.includes("int"))e.isInt=!0},Hl=(e,n)=>Fn(e,"minimum",n.minimum),Ql=(e,n)=>Mn(e,"maximum",n.maximum),Yl=(e)=>(n,t)=>{rd(n,t.format);let[r,o]=e[t.format];Fn(n,"minimum",r),Mn(n,"maximum",o)},Qg={greater_than:(e,n)=>Fn(e,n.inclusive?"minimum":"exclusiveMinimum",n.value),less_than:(e,n)=>Mn(e,n.inclusive?"maximum":"exclusiveMaximum",n.value),multiple_of:(e,n)=>ed(e,n.value),number_format:Yl(mr),bigint_format:Yl(Mo),min_length:Hl,max_length:Ql,length_equals:(e,n)=>Gl(e,n.length),min_size:Hl,max_size:Ql,size_equals:(e,n)=>Gl(e,n.size),string_format:(e,n)=>{if(rd(e,n.format),n.pattern)nd(e,n.pattern);if(n.format==="base64"||n.format==="base64url")e.contentEncoding=n.format;if(n.local||n.precision===-1)e.laxFormat=!0},mime_type:(e,n)=>td(e,n.mime)};function _e(e){let n={},t=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...t.checks??[]]:t.checks??[];for(let i of r)Qg[i._zod.def.check]?.(n,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Fn(n,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Fn(n,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Mn(n,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Mn(n,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)ed(n,o.multipleOf);if(o.format!==void 0){if(n.format??(n.format=o.format),o.format.includes("int"))n.isInt=!0}if(o.mime)td(n,o.mime);for(let i of o.patterns??[])nd(n,i);return n}var Yg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xg=new Map([[ri,yc],[Ar,bc]]),od=(e)=>Xg.get(e)??e,Ei=(e,n,t,r)=>{let o=t;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=_e(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=Yg[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let d=[...c].map(od);if(d.length===1)o.pattern=d[0].source;else if(d.length>1)o.allOf=[...d.map((m)=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},Ci=(e,n,t,r)=>{let o=t,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=_e(e);o.type=l?"integer":"number";let d=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),g=n.target==="draft-04"||n.target==="openapi-3.0";if(d)if(g)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(g)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let h=new Set;for(let N of a)if(Number.isFinite(N)&&N!==0)h.add(Math.abs(N));else be(e,n,o,r,`A multipleOf divisor of ${N} cannot be represented in JSON Schema`);let[I,...R]=h;if(I!==void 0)o.multipleOf=I;if(R.length)o.allOf=[...o.allOf??[],...R.map((N)=>({multipleOf:N}))]}},Oi=(e,n,t,r)=>{t.type="boolean"},id=(e,n,t,r)=>{be(e,n,t,r,"BigInt cannot be represented in JSON Schema")},sd=(e,n,t,r)=>{be(e,n,t,r,"Symbols cannot be represented in JSON Schema")},Ri=(e,n,t,r)=>{if(n.target==="openapi-3.0")t.type="string",t.nullable=!0,t.enum=[null];else t.type="null"},ad=(e,n,t,r)=>{be(e,n,t,r,"Undefined cannot be represented in JSON Schema")},cd=(e,n,t,r)=>{be(e,n,t,r,"Void cannot be represented in JSON Schema")},Ai=(e,n,t,r)=>{t.not={}},ud=(e,n,t,r)=>{},ji=(e,n,t,r)=>{},ld=(e,n,t,r)=>{be(e,n,t,r,"Date cannot be represented in JSON Schema")},Pi=(e,n,t,r)=>{let o=e._zod.def,i=dt(o.entries);if(i.length===0){t.not={};return}if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";t.enum=i},_i=(e,n,t,r)=>{let o=e._zod.def;if(o.values.length===0){t.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(be(e,n,t,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(be(e,n,t,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(t.type=s===null?"null":typeof s,n.target==="draft-04"||n.target==="openapi-3.0")t.enum=[s];else t.const=s}else{if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";if(i.every((s)=>typeof s==="boolean"))t.type="boolean";if(i.every((s)=>s===null))t.type="null";t.enum=i}},dd=(e,n,t,r)=>{be(e,n,t,r,"NaN cannot be represented in JSON Schema")},pd=(e,n,t,r)=>{let o=t,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},fd=(e,n,t,r)=>{let o=t;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=_e(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},md=(e,n,t,r)=>{t.type="boolean"},$i=(e,n,t,r)=>{be(e,n,t,r,"Custom types cannot be represented in JSON Schema")},gd=(e,n,t,r)=>{be(e,n,t,r,"Function types cannot be represented in JSON Schema")},Ni=(e,n,t,r)=>{be(e,n,t,r,"Transforms cannot be represented in JSON Schema")},hd=(e,n,t,r)=>{be(e,n,t,r,"Map cannot be represented in JSON Schema")},yd=(e,n,t,r)=>{be(e,n,t,r,"Set cannot be represented in JSON Schema")},Ti=(e,n,t,r)=>{let o=t,i=e._zod.def,{minimum:s,maximum:a}=_e(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=ee(i.element,n,{...r,path:[...r.path,"items"]})};function Rt(e){let n=e._zod.def;if(n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform"))return Rt(n.out);if(n.type==="catch")return Rt(n.innerType);return e._zod.optin}var zi=(e,n,t,r)=>{let o=t,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&be(e,n,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)De(o.properties,u,ee(s[u],n,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(n.io==="input"?Rt(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(n.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=ee(i.catchall,n,{...r,path:[...r.path,"additionalProperties"]})},Di=(e,n,t,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>ee(a,n,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)t.oneOf=s;else t.anyOf=s},Vi=(e,n,t,r)=>{let o=e._zod.def,i=ee(o.left,n,{...r,path:[...r.path,"allOf",0]}),s=ee(o.right,n,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];t.allOf=c,n.intersections.push(c)},bd=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="array";let s=n.target==="draft-2020-12"?"prefixItems":"items",a=n.target==="draft-2020-12"?"items":n.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((I,R)=>ee(I,n,{...r,path:[...r.path,s,R]})),u=i.rest?ee(i.rest,n,{...r,path:[...r.path,a,...n.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let I=i.items[l-1];if(!(n.io==="input"?Rt(I)!==void 0:I._zod.optout==="optional"))break;l--}let d=i.items.length,m=!i.rest;if(n.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=d}else if(n.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=d}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=d}let{minimum:g,maximum:h}=_e(e);if(typeof g==="number")o.minItems=g;if(typeof h==="number")o.maxItems=h};function Si(e,n,t){if(n.$ref){if(t.has(n))return n;t.add(n);let h=e.get(n)?.def;if(!h)return n;let I=Si(e,h,t);return I===h?n:I}for(let h of["anyOf","oneOf"]){let I=n[h];if(!Array.isArray(I))continue;let R=I.map((N)=>Si(e,N,t));if(R.some((N,L)=>N!==I[L]))n={...n,[h]:R}}let r=Array.isArray(n.type)?n.type:[n.type],o=!r.includes("string")&&r.some((h)=>h==="number"||h==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!o&&!i?.some((h)=>typeof h==="number"))return n;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:m,...g}=n;if(g.enum)g.enum=g.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof g.const==="number")g.const=String(g.const);if(!o)return g;if(g.type="string",!i)g.pattern=(r.includes("number")?ht:Ho).source;return g}var Ii=new WeakMap;function eh(e){let n=new Map;for(let r of e.seen.values())if(r.def&&!n.has(r.schema))n.set(r.schema,r);let t=new Map;for(let r of Ii.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||t.has(i))continue;let s=Si(n,i,new Set);if(s!==i)t.set(i,s)}if(!t.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&t.get(o.propertyNames);if(i)o.propertyNames=i}}var Zi=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="object";let s=i.keyType,a=_e(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=ee(i.valueType,n,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)De(o.patternProperties,od(d).source,l)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){o.propertyNames=ee(i.keyType,n,{...r,path:[...r.path,"propertyNames"]});let l=Ii.get(n);if(!l)l=[],Ii.set(n,l),n.deferred.push(()=>eh(n));l.push(e)}o.additionalProperties=ee(i.valueType,n,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=n.io==="input"&&Rt(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(l.length>0)o.required=l.map(String)}},Fi=(e,n,t,r)=>{let o=e._zod.def,i=ee(o.innerType,n,r),s=n.seen.get(e);if(n.target==="openapi-3.0")s.ref=o.innerType,t.nullable=!0;else t.anyOf=[i,{type:"null"}]},Mi=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Ji=Symbol();function wd(e,n,t,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return be(n,t,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ji}var Li=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s=wd(o.defaultValue,e,n,t,r);if(s!==Ji)t.default=s},qi=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);if(i.ref=o.innerType,n.io!=="input")return;let s=wd(o.defaultValue,e,n,t,r);if(s!==Ji)t._prefault=s},Ui=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{be(e,n,t,r,"Dynamic catch values are not supported in JSON Schema");return}t.default=s},Ki=(e,n,t,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=n.io==="input"?i?o.out:o.in:o.out;ee(s,n,r);let a=n.seen.get(e);a.ref=s},Bi=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType,t.readOnly=!0},xd=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Zr=(e,n,t,r)=>{let o=e._zod.def;ee(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Wi=(e,n,t,r)=>{let o=e._zod.innerType;ee(o,n,r);let i=n.seen.get(e);i.ref=o},Xl={string:Ei,number:Ci,boolean:Oi,bigint:id,symbol:sd,null:Ri,undefined:ad,void:cd,never:Ai,any:ud,unknown:ji,date:ld,enum:Pi,literal:_i,nan:dd,template_literal:pd,file:fd,success:md,custom:$i,function:gd,transform:Ni,map:hd,set:yd,array:Ti,object:zi,union:Di,intersection:Vi,tuple:bd,record:Zi,nullable:Fi,nonoptional:Mi,default:Li,prefault:qi,catch:Ui,pipe:Ki,readonly:Bi,promise:xd,optional:Zr,lazy:Wi};function Fr(e,n){if("_idmap"in e){let r=e,o=Et({...n,processors:Xl}),i={};for(let c of r._idmap.entries()){let[u,l]=c;ee(l,o)}let s={},a={registry:r,uri:n?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;Ct(o,l),De(s,u,Ot(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let t=Et({...n,processors:Xl});return ee(e,t),Ct(t,e),Ot(t,e)}var vd=new WeakSet([Object.prototype,Error.prototype]);function Jr(e,n,t){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let r=t(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0})}})}var kd=(e,n)=>{qa.init(e,n),e.name="ZodError";let t=Object.getPrototypeOf(e);if(vd.has(t))return;vd.add(t),Jr(t,"format",(r)=>(o)=>Ka(r,o)),Jr(t,"flatten",(r)=>(o)=>Ua(r,o)),Jr(t,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,pt,2)}),Jr(t,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,pt,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},uh=b("ZodError",kd),Fe=b("ZodError",kd,void 0,{Parent:Error});var Sd=xr(Fe),Id=vr(Fe),Ed=kr(Fe),Cd=Sr(Fe),Od=Wa(Fe),Rd=Ga(Fe),Ad=Ha(Fe),jd=Qa(Fe),Pd=Ya(Fe),_d=Xa(Fe),$d=ec(Fe),Nd=nc(Fe);function dh(){if(!Pe.localeError)Ze(li())}function qr(){if(!Pe.memoizer)Ze({memoizer:rl()})}var re=b("ZodType",(e,n)=>(dh(),te.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(Ve(n,{checks:[...n.checks??[],...e.map((t)=>typeof t==="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return Ge(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(cy(e,n))},superRefine(e,n){return this.check(uy(e,n))},overwrite(e){return this.check(dn(e))},optional(){return zd(this)},exactOptional(){return Bh(this)},nullable(){return Dd(this)},nullish(){return zd(Dd(this))},nonoptional(e){return Xh(this,e)},array(){return P(this)},or(e){return Y([this,e])},and(e){return qh(this,e)},transform(e){return Vd(this,Ld(e))},default(e){return Hh(this,e)},prefault(e){return Yh(this,e)},catch(e){return ny(this,e)},pipe(e){return Vd(this,e)},readonly(){return oy(this)},describe(e){let n=this.clone();return On.add(n,{description:e}),n},meta(...e){if(e.length===0)return On.get(this);let n=this.clone();return On.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get "~standard"(){return br(this,"~standard",{...ti(this),jsonSchema:{input:It(this,"input"),output:It(this,"output")}})},set "~standard"(e){tn(this,"~standard",e)},parse:function e(n,t){return Sd(this,n,t,{callee:e})},parseAsync:async function e(n,t){return await Id(this,n,t,{callee:e})},safeParse(e,n){return Ed(this,e,n)},async safeParseAsync(e,n){return Cd(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){tn(this,"spa",e)},validate(e,n){return Ko(this,e,n)},validateAsync(e,n){return Bo(this,e,n)},encode:function e(n,t){return Od(this,n,t,{callee:e})},decode:function e(n,t){return Rd(this,n,t,{callee:e})},encodeAsync:async function e(n,t){return await Ad(this,n,t,{callee:e})},decodeAsync:async function e(n,t){return await jd(this,n,t,{callee:e})},safeEncode(e,n){return Pd(this,e,n)},safeDecode(e,n){return _d(this,e,n)},async safeEncodeAsync(e,n){return $d(this,e,n)},async safeDecodeAsync(e,n){return Nd(this,e,n)},toJSONSchema(e){return Wl(this,{})(e)},get description(){return On.get(this)?.description},get _def(){return this._zod.def}}),Zd=b("_ZodString",(e,n)=>{Rr.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ei(e,t,r,o)},Va({format:(e)=>_e(e).format??null,minLength:(e)=>_e(e).minimum??null,maxLength:(e)=>_e(e).maximum??null},{regex(...e){return this.check(di(...e))},includes(...e){return this.check(mi(...e))},startsWith(...e){return this.check(gi(...e))},endsWith(...e){return this.check(hi(...e))},min(...e){return this.check(Zn(...e))},max(...e){return this.check(Dr(...e))},length(...e){return this.check(Vr(...e))},nonempty(...e){return this.check(Zn(1,...e))},lowercase(e){return this.check(pi(e))},uppercase(e){return this.check(fi(e))},trim(){return this.check(bi())},normalize(...e){return this.check(yi(...e))},toLowerCase(){return this.check(wi())},toUpperCase(){return this.check(xi())},slugify(){return this.check(vi())}})),ph=b("ZodString",(e,n)=>{Rr.init(e,n),Zd.init(e,n)},{email(e){return this.check(cl(yh,e))},url(e){return this.check(ml(wh,e))},jwt(e){return this.check(Al(Nh,e))},emoji(e){return this.check(gl(xh,e))},guid(e){return this.check(ul(bh,e))},uuid(e){return this.check(ll(Lr,e))},uuidv4(e){return this.check(dl(Lr,e))},uuidv6(e){return this.check(pl(Lr,e))},uuidv7(e){return this.check(fl(Lr,e))},nanoid(e){return this.check(hl(vh,e))},cuid(e){return this.check(yl(kh,e))},cuid2(e){return this.check(bl(Sh,e))},ulid(e){return this.check(wl(Ih,e))},base64(e){return this.check(Cl(Ph,e))},base64url(e){return this.check(Ol(_h,e))},xid(e){return this.check(xl(Eh,e))},ksuid(e){return this.check(vl(Ch,e))},ipv4(e){return this.check(kl(Oh,e))},ipv6(e){return this.check(Sl(Rh,e))},cidrv4(e){return this.check(Il(Ah,e))},cidrv6(e){return this.check(El(jh,e))},e164(e){return this.check(Rl($h,e))},datetime(e){return this.check(jl(fh,e))},date(e){return this.check(Pl(mh,e))},time(e){return this.check(_l(gh,e))},duration(e){return this.check($l(hh,e))}});function A(e){return al(ph,e)}var de=b("ZodStringFormat",(e,n)=>{ae.init(e,n),Zd.init(e,n)}),fh=b("ZodISODateTime",(e,n)=>{mu.init(e,n),de.init(e,n)}),mh=b("ZodISODate",(e,n)=>{gu.init(e,n),de.init(e,n)}),gh=b("ZodISOTime",(e,n)=>{hu.init(e,n),de.init(e,n)}),hh=b("ZodISODuration",(e,n)=>{yu.init(e,n),de.init(e,n)}),yh=b("ZodEmail",(e,n)=>{ru.init(e,n),de.init(e,n)});var bh=b("ZodGUID",(e,n)=>{nu.init(e,n),de.init(e,n)});var Lr=b("ZodUUID",(e,n)=>{tu.init(e,n),de.init(e,n)});var wh=b("ZodURL",(e,n)=>{su.init(e,n),de.init(e,n)});var xh=b("ZodEmoji",(e,n)=>{au.init(e,n),de.init(e,n)});var vh=b("ZodNanoID",(e,n)=>{cu.init(e,n),de.init(e,n)});var kh=b("ZodCUID",(e,n)=>{uu.init(e,n),de.init(e,n)});var Sh=b("ZodCUID2",(e,n)=>{lu.init(e,n),de.init(e,n)});var Ih=b("ZodULID",(e,n)=>{du.init(e,n),de.init(e,n)});var Eh=b("ZodXID",(e,n)=>{pu.init(e,n),de.init(e,n)});var Ch=b("ZodKSUID",(e,n)=>{fu.init(e,n),de.init(e,n)});var Oh=b("ZodIPv4",(e,n)=>{bu.init(e,n),de.init(e,n)});var Rh=b("ZodIPv6",(e,n)=>{xu.init(e,n),de.init(e,n)});var Ah=b("ZodCIDRv4",(e,n)=>{vu.init(e,n),de.init(e,n)});var jh=b("ZodCIDRv6",(e,n)=>{ku.init(e,n),de.init(e,n)});var Ph=b("ZodBase64",(e,n)=>{Iu.init(e,n),de.init(e,n)});var _h=b("ZodBase64URL",(e,n)=>{Eu.init(e,n),de.init(e,n)});var $h=b("ZodE164",(e,n)=>{Cu.init(e,n),de.init(e,n)});var Nh=b("ZodJWT",(e,n)=>{Ou.init(e,n),de.init(e,n)});var Fd=b("ZodNumber",(e,n)=>{oi.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ci(e,t,r,o),e.isFinite=!0},Va({minValue:(e)=>{let{minimum:n,exclusiveMinimum:t}=_e(e);return Math.max(n??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:n,exclusiveMaximum:t}=_e(e);return Math.min(n??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:n,multipleOf:t}=_e(e);return!!n||!!t?.some(Number.isSafeInteger)},format:(e)=>_e(e).format??null},{gt(e,n){return this.check(Tr(e,n))},gte(e,n){return this.check(kt(e,n))},min(e,n){return this.check(kt(e,n))},lt(e,n){return this.check(Nr(e,n))},lte(e,n){return this.check(vt(e,n))},max(e,n){return this.check(vt(e,n))},int(e){return this.check(he(e))},safe(e){return this.check(he(e))},positive(e){return this.check(Tr(0,e))},nonnegative(e){return this.check(kt(0,e))},negative(e){return this.check(Nr(0,e))},nonpositive(e){return this.check(vt(0,e))},multipleOf(e,n){return this.check(zr(e,n))},step(e,n){return this.check(zr(e,n))},finite(){return this}}));function fe(e){return Nl(Fd,e)}var Th=b("ZodNumberFormat",(e,n)=>{Ru.init(e,n),Fd.init(e,n)});function he(e){return Tl(Th,e)}var zh=b("ZodBoolean",(e,n)=>{Au.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Oi(e,t,r,o)});function ye(e){return zl(zh,e)}var Dh=b("ZodNull",(e,n)=>{ju.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ri(e,t,r,o)});function Vh(e){return Dl(Dh,e)}var Zh=b("ZodUnknown",(e,n)=>{Pu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>ji(e,t,r,o)});function Jn(){return Vl(Zh)}var Fh=b("ZodNever",(e,n)=>{_u.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ai(e,t,r,o)});function pn(e){return Zl(Fh,e)}var Mh=b("ZodArray",(e,n)=>{qr(),$u.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ti(e,t,r,o),e.element=n.element},{min(e,n){return this.check(Zn(e,n))},nonempty(e){return this.check(Zn(1,e))},max(e,n){return this.check(Dr(e,n))},length(e,n){return this.check(Vr(e,n))},unwrap(){return this.element}});function P(e,n){return Fl(Mh,e,n)}var Md=b("ZodObject",(e,n)=>{qr(),zu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>zi(e,t,r,o),bg(e,"shape",(t)=>t._zod.def.shape,!1)},{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ve(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ve(this._zod.def,{catchall:Jn()}))},loose(){return this.clone(Ve(this._zod.def,{catchall:Jn()}))},strict(){return this.clone(Ve(this._zod.def,{catchall:pn()}))},strip(){return this.clone(Ve(this._zod.def,{catchall:void 0}))},extend(e){return lg(this,e)},safeExtend(e){return dg(this,e)},merge(e){return pg(this,e)},pick(e){return cg(this,e)},omit(e){return ug(this,e)},partial(...e){return Na(qd,this,e[0])},exactPartial(...e){return Na(Ud,this,e[0],"exactPartial")},required(...e){return fg(Kd,this,e[0])}});function j(e,n){let t={type:"object",shape:e??{},..._(n)};return new Md(t)}function x(e,n){return new Md({type:"object",shape:e,catchall:pn(),..._(n)})}var Jd=b("ZodUnion",(e,n)=>{ii.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Di(e,t,r,o),e.options=n.options});function Y(e,n){return new Jd({type:"union",options:e,..._(n)})}var Jh=b("ZodDiscriminatedUnion",(e,n)=>{Jd.init(e,n),Du.init(e,n)});function Ln(e,n,t){return new Jh({type:"union",options:n,discriminator:e,..._(t)})}var Lh=b("ZodIntersection",(e,n)=>{Vu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Vi(e,t,r,o)});function qh(e,n){return new Lh({type:"intersection",left:e,right:n})}var Td=b("ZodRecord",(e,n)=>{qr(),Zu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zi(e,t,r,o),e.keyType=n.keyType,e.valueType=n.valueType});function oe(e,n,t){if(!n||!n._zod)return new Td({type:"record",keyType:A(),valueType:e,..._(n)});return new Td({type:"record",keyType:e,valueType:n,..._(t)})}var Gi=b("ZodEnum",(e,n)=>{Fu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(r,o,i)=>Pi(e,r,o,i),e.enum=n.entries,e.options=[...e._zod.values];let t=new Set(Object.keys(n.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(t.has(s))i[s]=n.entries[s];else throw Error(`Key ${s} not found in enum`);return new Gi({...n,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{let i={...n.entries};for(let s of r)if(t.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Gi({...n,checks:[],..._(o),entries:i})}});function ce(e,n){let t=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Gi({type:"enum",entries:t,..._(n)})}var Uh=b("ZodLiteral",(e,n)=>{Mu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_i(e,t,r,o),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function k(e,n){return new Uh({type:"literal",values:Array.isArray(e)?e:[e],..._(n)})}var Kh=b("ZodTransform",(e,n)=>{qr(),Ju.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ni(e,t,r,o),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new gt(e.constructor.name);t.addIssue=(i)=>{if(typeof i==="string")t.issues.push(Cn(i,t.value,n));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=t.value;s.inst??(s.inst=e),t.issues.push(Cn(s))}};let o=n.transform(t.value,t);if(o instanceof Promise)return o.then((i)=>(t.value=i,t));return t.value=o,t}});function Ld(e){return new Kh({type:"transform",transform:e})}var qd=b("ZodOptional",(e,n)=>{si.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zr(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function zd(e){return new qd({type:"optional",innerType:e})}var Ud=b("ZodExactOptional",(e,n)=>{Lu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zr(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Bh(e){return new Ud({type:"optional",innerType:e})}var Wh=b("ZodNullable",(e,n)=>{qu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Fi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Dd(e){return new Wh({type:"nullable",innerType:e})}var Gh=b("ZodDefault",(e,n)=>{Uu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Li(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hh(e,n){return new Gh({type:"default",innerType:e,get defaultValue(){return typeof n==="function"?n():Zo(n)}})}var Qh=b("ZodPrefault",(e,n)=>{Ku.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>qi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Yh(e,n){return new Qh({type:"prefault",innerType:e,get defaultValue(){return typeof n==="function"?n():Zo(n)}})}var Kd=b("ZodNonOptional",(e,n)=>{Bu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Mi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Xh(e,n){return new Kd({type:"nonoptional",innerType:e,..._(n)})}var ey=b("ZodCatch",(e,n)=>{Wu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ui(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ny(e,n){return new ey({type:"catch",innerType:e,catchValue:typeof n==="function"?n:Za(n)})}var Bd=b("ZodPipe",(e,n)=>{ai.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ki(e,t,r,o),e.in=n.in,e.out=n.out});function Vd(e,n){return new Bd({type:"pipe",in:e,out:n})}var ty=b("ZodPreprocess",(e,n)=>{Bd.init(e,n),Gu.init(e,n)}),ry=b("ZodReadonly",(e,n)=>{Hu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Bi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function oy(e){return new ry({type:"readonly",innerType:e})}var iy=b("ZodLazy",(e,n)=>{Qu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Wi(e,t,r,o),e.unwrap=()=>e._zod.def.getter()});function sy(e){return new iy({type:"lazy",getter:e})}var ay=b("ZodCustom",(e,n)=>{Yu.init(e,n),re.init(e,n),e._zod.processJSONSchema=(t,r,o)=>$i(e,t,r,o)});function cy(e,n={}){return Ml(ay,e,n)}function uy(e,n){return Jl(e,n)}function Me(e){let n=sy(()=>Y([A(e),fe(),ye(),Vh(),P(n),oe(A(),n)]));return n}function ly(e,n){return new ty({type:"pipe",in:Ld(e),out:n})}var Hi=["GET","POST","PUT","PATCH","DELETE"];function Ur(e){return e!=="GET"}var Wd=Object.prototype.hasOwnProperty;function Oe(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)while(r--&&Oe(e[r],n[r]));return r===-1}if(!t||typeof e==="object"){r=0;for(t in e){if(Wd.call(e,t)&&++r&&!Wd.call(n,t))return!1;if(!(t in n)||!Oe(e[t],n[t]))return!1}return Object.keys(n).length===r}}return e!==e&&n!==n}function Qi(e){for(let n of Object.values(e.graph.nodes)){if(n.kind!="task"||!("executor"in n.task)||n.task.executor.kind!="openapi")continue;for(let[t,r]of Object.entries(n.inputs))if(t.startsWith("auth.")&&r.kind=="value")throw TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.")}}function Gd(e){return e.kind=="source"&&e.source.kind=="binding"?{kind:"value"}:e}function Hd(e){return{...e,cases:e.cases.map((n)=>({...n,groups:n.groups.map((t)=>({...t,expressions:t.expressions.map((r)=>({...r,left:Gd(r.left),...r.right==null?{}:{right:Gd(r.right)}}))}))}))}}var my=new Set(["const","enum","exclusiveMaximum","exclusiveMinimum","maximum","maxItems","maxLength","maxProperties","minimum","minItems","minLength","minProperties","multipleOf","pattern","required","type"]);function Xi(e){return my.has(e)}var es=80;function Kr(e){let n=e.trim();if(n.length==0)return"empty";if(n.length>es)return"tooLong";for(let t of n){let r=t.charCodeAt(0);if(r<=31||r>=127&&r<=159)return"controlCharacter"}if(!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(n))return"specialCharacter"}var Qd=0;function fn(){let e=Qd;return Qd+=1,e}function Un(e){if(typeof e==="object"&&e!==null&&!Object.isFrozen(e)){for(let n of Object.getOwnPropertyNames(e)){let t=Reflect.get(e,n);Un(t)}Object.freeze(e)}return e}function ns(e,n){let t={};for(let r of n)if(r in e)t[r]=e[r];return t}function Wr(e){if(typeof e!=="object"||e===null)return e;else if(Array.isArray(e)){let n=[];for(let[t,r]of e.entries())n[t]=Wr(r);return n}else{let n={};for(let t in e)n[t]=Wr(e[t]);return n}}function qn(e,n){if(e===n)return!0;if(e===null)return!1;if(typeof e!=="object")return!1;if(typeof e!==typeof n)return!1;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!==n.length)return!1;for(let[t,r]of e.entries())if(!qn(r,n[t]))return!1}else{if(Array.isArray(n))return!1;for(let t in e){if(!(t in n))return!1;if(!qn(e[t],n[t]))return!1}for(let t in n)if(!(t in e))return!1}return!0}var y=Object.freeze({Equals:0,Containing:1,ContainedBy:2,Rejection:3,Intersection:4}),J=mn(y.Equals),V=mn(y.Containing),Z=mn(y.ContainedBy),q=mn(y.Rejection),W=mn(y.Intersection),rn=Un([[y.Equals,J],[y.Containing,V],[y.ContainedBy,Z],[y.Rejection,q],[y.Intersection,W]]),ne=0,Je=(()=>{let e=ne;for(let[n,t]of rn)e|=t;return e})();function At(e){return!!(e&J)}function jt(e){return!!(e&V)}function Pt(e){return!!(e&Z)}function _t(e){return!!(e&q)}function $t(e){return!!(e&W)}function mn(e){return 1<<e}function ts(e){let n=ne,t=0,r={push:(o)=>{if(t===0)n=o;else n=yy(n,o,e);return t+=1,n}};return Object.defineProperties(r,{result:{get:()=>n},count:{get:()=>t}}),r}function yy(e,n,t){let r=ne;for(let[o,i]of rn)if(i&e){for(let[s,a]of rn)if(a&n){if(r|=t(o,s),r===Je)return r}}return r}var ue=Object.freeze({Save:0,OneOf:1,AllOf:2,AnyOf:3,Not:4,Swap:5});function Yd(e,n){switch(e){case ue.Save:return n[0];case ue.OneOf:return by(n);case ue.AllOf:case ue.AnyOf:return Nt(e,n);case ue.Not:case ue.Swap:return rs(e,n[0])}}function gn(e){return rs(ue.Swap,e)}function by(e){if(e.length===1)return e[0];let n=Nt(ue.AnyOf,e),t=[];for(let i=0;i<e.length;++i)for(let s=i+1;s<e.length;++s){let a=e[i],c=e[s],u=Nt(ue.AllOf,[a,c]);t.push(u)}let r=Nt(ue.AnyOf,t),o=rs(ue.Not,r);return Nt(ue.AllOf,[n,o])}function Nt(e,n){if(n.length<0)throw Error("invalid expressions: empty array");let t;switch(e){case ue.AllOf:{t=ts(wy);break}case ue.AnyOf:{t=ts(xy);break}default:throw Error(`invalid operator ${e}`)}for(let r of n)t.push(r);return t.result}function rs(e,n){let t,r=ne;switch(e){case ue.Not:{t=vy;break}case ue.Swap:{t=ky;break}default:throw Error(`invalid operator ${e}`)}for(let[o,i]of rn)if(i&n)r|=t(o);return r}function wy(e,n){let t=ne;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=ne;break}case y.Intersection:{t=Z;break}}break}case y.Containing:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J|V;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W|Z;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=ne;break}case y.Intersection:{t=Z;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=ne;break}case y.Containing:{t=q;break}case y.ContainedBy:{t=ne;break}case y.Rejection:{t=q;break}case y.Intersection:{t=q;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=W|Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=Z|q|W;break}}break}}return t}function xy(e,n){let t=ne;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=J;break}case y.Rejection:{t=V;break}case y.Intersection:{t=V;break}}break}case y.Containing:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=V;break}case y.Rejection:{t=V;break}case y.Intersection:{t=V;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=J|Z;break}case y.Rejection:{t=W;break}case y.Intersection:{t=V|W;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=W;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=V;break}case y.Containing:{t=V;break}case y.ContainedBy:{t=V|W;break}case y.Rejection:{t=W;break}case y.Intersection:{t=V|W;break}}break}}return t}function vy(e){let n=ne;switch(e){case y.Equals:{n=q;break}case y.Containing:{n=q;break}case y.ContainedBy:{n=W;break}case y.Rejection:{n=J|V;break}case y.Intersection:{n=Z|W;break}}return n}function ky(e){let n=ne;switch(e){case y.Equals:{n=J;break}case y.Containing:{n=Z;break}case y.ContainedBy:{n=V;break}case y.Rejection:{n=q;break}case y.Intersection:{n=W;break}}return n}var $e=Object.freeze({Leaf:0,Not:1,AllOf:2,AnyOf:3,OneOf:4});var os=(e)=>(n,t)=>{let r={parent:null,swapped:!1,expressions:null,calculation:{operator:ue.Save,results:[ne],willSwap:!1,count:0}},o=[{parent:{node:r,index:0},swapped:!1,expressions:[n,t],calculation:null}],i=[];while(o.length>0||i.length>0){while(o.length>0){let l=o.pop();s(l)}while(i.length>0){let l=i.pop();c(l)}}function s(l){let d=J,[m,g]=l.expressions;if(!e.equals(m,g)){let h=e.describe(m);if(h.kind!==$e.Leaf){let[N,L]=a(h,!1);l.expressions=null,l.calculation=N;for(let[K,ze]of L.entries())o.push({parent:{node:l,index:K},swapped:l.swapped,expressions:[ze,g],calculation:null});return}let I=e.describe(g);if(I.kind!==$e.Leaf){let[N,L]=a(I,!0);l.expressions=null,l.calculation=N;for(let[K,ze]of L.entries())o.push({parent:{node:l,index:K},swapped:!l.swapped,expressions:[ze,m],calculation:null});return}if(d=e.calculate(m,g),e.observeCalculation?.(m,g,d,l.swapped),d===ne)throw Error("cannot response expression as none")}l.expressions=null,l.calculation={operator:ue.Save,results:[d],willSwap:!1,count:0},i.push(l)}function a(l,d){let m=ue.Save,g;switch(l.kind){case $e.Not:{m=ue.Not,g=[l.expression];break}case $e.AllOf:{m=ue.AllOf,g=[...l.expressions];break}case $e.AnyOf:{m=ue.AnyOf,g=[...l.expressions];break}case $e.OneOf:{m=ue.OneOf,g=[...l.expressions];break}default:throw Error(`invalid kind ${l.kind}`)}return[{operator:m,willSwap:d,count:0,results:Array(g.length).fill(-1)},g]}function c(l){let{calculation:d,parent:m}=l,g=Yd(d.operator,d.results);if(g===ne)g=Z;if(d.willSwap)g=gn(g);if(m){let h=m.node.calculation,I=h.results;if(I[m.index]=g,h.count+=1,h.count>=I.length)i.push(m.node)}}let u=r.calculation.results[0];if(u===0)throw Error("cannot find result of root");return u};class Gr extends Error{constructor(e=[]){super(Sy(e));this.name="SchemaError",this.items=e}}var Kn=Object.freeze({Compiled:0,External:1});function Bn(e){switch(e.kind){case Kn.Compiled:{let{message:n,path:t}=e;return`${n} (at ${t.length>0?t.join("."):"$root"})`}case Kn.External:return String(e.error)}}function Sy(e){switch(e.length){case 0:return"without any items";case 1:return Bn(e[0]);default:return`${Bn(e[0])} ... omit the rest ${e.length-1} items`}}var Iy=new Set(["type","enum","const","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","items","additionalItems","maxItems","minItems","uniqueItems","contains","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames","if","then","else","allOf","anyOf","oneOf","not","format","contentMediaType","contentEncoding","definitions"]);function Xe(e){return Iy.has(e)}function Xd(e){for(let n in e)if(Xe(n))return!1;return!0}function Re(e,...n){return{...e,path:[...e.path,...n]}}function Ne(e){if(typeof e==="boolean")throw Error("JSONSchema7Definition cannot be boolean");return e}function hn({path:e,errors:n},t,...r){n.push(ep(e,r,t))}function G({path:e,warns:n},t,...r){n.push(ep(e,r,t))}function ep(e,n,t){return{kind:Kn.Compiled,message:t,path:[...e,...n]}}function Hr(e){for(let n in e){let t=e[n];if(t===void 0)delete e[n];else if(t&&typeof t==="object"){if(Array.isArray(t)){if(t.length===0)delete e[n]}else if(Ey(t))delete e[n]}}return e}function Ey(e){for(let n in e)return!1;return!0}var Tt=Symbol("compiledId"),is=Symbol("compiledKind"),ss=Symbol("compiledPath"),np=Symbol("validatorLoader"),S=Object.freeze({Extends:0,Never:1,Any:2,Null:3,String:4,Numeric:5,Boolean:6,Object:7,Array:8,Not:9,Combination:10,EnumOrConst:11}),yn=Un(Qr(S.Any,fn(),{},()=>()=>!0)),zt=Un(Qr(S.Never,fn(),{type:"string",maxLength:0,minLength:1},()=>()=>!1));function Dt(e){if(e===null||typeof e!=="object")return!1;return Tt in e}function Te(e){if(e===null||typeof e!=="object")return!1;return Tt in e&&is in e}function B(e){if(Te(e))return e[is];else return S.Extends}function Rn(e){if(Te(e)||Dt(e))return e[Tt];else return e.id}function as(e){return Te(e)?e[ss]:void 0}function cs(e){if(e===null||typeof e!=="object")return e;return Object.defineProperty(e,Tt,{value:fn(),configurable:!1,writable:!1,enumerable:!1}),e}function pe(e,n,t,r=[]){return Qr(e,fn(),n,t&&(()=>t.compile(n)),r)}function Vt(e){return Qr(S.Never,fn(),{...e},e[np],e[ss])}function Qr(e,n,t,r,o=[]){let i=null;return Object.defineProperties(t,{[is]:{value:e,configurable:!1,writable:!1,enumerable:!1},[Tt]:{value:n,configurable:!1,writable:!1,enumerable:!1},[ss]:{value:o,configurable:!1,writable:!1,enumerable:!1},[np]:{value:r,configurable:!1,writable:!1,enumerable:!1},isValid:{configurable:!1,enumerable:!1,get:()=>{if(r){if(!i)i=r();return i}else return}}}),t}function op(e,n){let t=Cy(e,n),r=tp(e,"maxItems",n),o=tp(e,"minItems",n),i=Oy(e,n),s=n.uniqueItems,a;if(Array.isArray(t))a=Ry(e,n);else if(n.additionalItems)G(e,"it is needless when items is not array","additionalItems");if(!t||!i||a===null)return null;let c=!1,u=!1;if(Array.isArray(t)){if(r!==void 0&&r<=t.length)t=t.splice(r),a=rp(a,e.delegate);let m=t.findIndex((g)=>B(g)===S.Never);if(m!==-1){if(t=t.splice(m),a=rp(a,e.delegate),r===void 0)r=t.length,u=!0}if(o!==void 0&&t.length<o)G(e,`length(${t.length}) of items if less than minItems(${o})`),c=!0;if(t.length===0&&a&&B(a)===S.Never)c=!0}else if(B(t)===S.Never)c=!0;if(r!==void 0&&o!==void 0&&r<o){if(!u)G(e,`maxItems(${r}) is less than minItems(${o})`);c=!0}let l=c?S.Never:S.Array,d=Hr({type:"array",items:t,contains:i,uniqueItems:s,maxItems:r,minItems:o,additionalItems:a});return pe(l,d,e.delegate,e.path)}function Cy(e,{items:n}){if(!n)return pe(S.Any,{},e.delegate,e.path);if(Array.isArray(n)){let t=[],r=!1;for(let[o,i]of n.entries()){let s=Re(e,"items",o),a=Ae(s,Ne(i));if(!a){r=!0;continue}t.push(a)}if(r)return null;return t}else{let t=Re(e,"items"),r=Ne(n);return Ae(t,r)}}function tp(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function Oy(e,{contains:n}){if(!n)return pe(S.Any,{},e.delegate,e.path);let t=Re(e,"contains"),r=Ne(n);return Ae(t,r)}function Ry(e,{additionalItems:n}){switch(typeof n){case"boolean":if(n)return pe(S.Any,{},e.delegate,e.path);else return!1;case"object":{let t=Re(e,"additionalItems");return Ae(t,n)}default:return pe(S.Any,{},e.delegate,e.path)}}function rp(e,n){if(e===void 0)return pe(S.Never,{type:"string",maxLength:0,minLength:1},n);else if(Te(e))return B(e)===S.Never?e:Vt(e);else return e}var ip=Object.freeze(["allOf","anyOf","oneOf"]);function us(e,n,t,r){if(t.length===0)return hn(e,"disable empty list",n),null;let o=[];for(let[c,u]of t.entries()){let l=Re(e,n,c),d=Ne(u),m=Ae(l,d);if(m)o.push(m)}if(o.length<t.length)return null;let i=0,s=0;for(let c of o)switch(B(c)){case S.Any:{i+=1;break}case S.Never:{s+=1;break}}let a=S.Combination;switch(n){case"allOf":{if(s>0)a=S.Never;else if(i===o.length)a=S.Any;else if(!Ay(o))a=S.Never;break}case"anyOf":{if(i>0)a=S.Any;else if(s===o.length)a=S.Never;break}case"oneOf":{if(i>1)a=S.Never;else if(s===o.length)a=S.Never;else if(i===1&&s===o.length-1)a=S.Any;break}}return pe(a,{[n]:o},r,e.path)}function Ay(e){let n=null;for(let t of e){let r=B(t);switch(r){case S.Any:case S.Never:break;default:{if(n===null)n=r;else if(n!==r)return!1;break}}}return!0}var Ie=Object.freeze({Valid:0,Invalid:1,Unknown:2});function en(e,n){let t=e.isValid;if(t)if(t(n)===!0)return Ie.Valid;else return Ie.Invalid;else return Ie.Unknown}function sp(e,n,t,r){let o,i=!1;if(n){if(n.length===0)return hn(e,"disable empty list","enum"),null;o=[];for(let[c,u]of n.entries())switch(en(r,u)){case Ie.Valid:{o.push(cs(u));break}case Ie.Invalid:{G(e,"cannot pass JSON schema of currently schema object","enum",c);break}}if(o.length===0)G(e,"all of elements from list is rejected by currently schema object","enum")}if(t!==void 0&&en(r,t)===Ie.Invalid)i=!0;if(o){if(o.length===0)i=!0;else if(t!==void 0){let c=!1;for(let u of o)if(qn(u,t)){c=!0;break}if(!c)i=!0}}let s=i?S.Never:S.EnumOrConst,a={};if(r.type)a.type=r.type;if(o)a.enum=o;if(t!==void 0)a.const=cs(Wr(t));return pe(s,a,e.delegate,e.path)}var jy=new Set(["type","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames"]);function cp(e,n){let t=Object.keys(n).filter((h)=>!jy.has(h)&&Xe(h));if(t.length>0)G(e,`type="object" will exclude other keys: ${t.toSorted().join(", ")}`);let r=ap(e,"maxProperties",n),o=ap(e,"minProperties",n),i=Py(e,n),s=_y(e,n),a=$y(e,n),c=Ty(e,n);if(!i||!s||!a||!c)return null;let u=Ny(e,s,a,n);if(!u)return null;let l=zy(i,s,a,u),d=Dy(e,l,c,n),m=Vy(e,i,u,d,r,o)?S.Never:S.Object,g=Hr({type:"object",required:d,properties:u,minProperties:o,maxProperties:r,additionalProperties:i,patternProperties:My(s),dependencies:Jy(c,n),propertyNames:a});return pe(m,g,e.delegate,e.path)}function ap(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function Py(e,{additionalProperties:n}){if(n===!1)return pe(S.Never,{type:"string",maxLength:0,minLength:1},e.delegate,e.path);if(typeof n!=="object")return pe(S.Any,{},e.delegate,e.path);let t=Re(e,"additionalProperties"),r=Ne(n);return Ae(t,r)}function _y(e,{patternProperties:n}){let t=!1,r={};for(let o in n){let i=Fy(o);if(i instanceof Error){G(e,`property name invalid. ${o}`,"patternProperties",o);continue}let s=Ne(n[o]),a=Re(e,"patternProperties",o),c=Ae(a,s);if(!c){t=!0;continue}r[o]=[c,i]}if(t)return null;return r}function $y(e,{propertyNames:n}){if(!n)return pe(S.Any,{},e.delegate,e.path);n=Ne(n);let t=Re(e,"propertyNames"),r=Ae(t,n);if(!r)return null;let o=B(r);if(o!==S.String&&o!==S.Any)return Vt(r);return r}function Ny(e,n,t,{properties:r}){let o=!1;if(!r)return{};let i={};for(let s in r){if(en(t,s)===Ie.Invalid){G(e,`key ${JSON.stringify(s)} cannot pass JSON schema from propertyNames`,"properties");continue}let a=lp(n,s);if(a&&B(a)===S.Never){G(e,`key ${JSON.stringify(s)} matches a pattern that has a impossible(never) schema`,"properties");continue}let c=Ne(r[s]),u=Re(e,"properties",s),l=Ae(u,c);if(!l){o=!0;continue}i[s]=l}if(o)return null;return i}function Ty(e,{dependencies:n}){if(!n)return[{},{}];let t={},r={};for(let o in n){let i=Ne(n[o]);if(Array.isArray(i)){let{keys:s,duplicated:a}=up(i);if(a)G(e,`found duplicated property names: ${a.join(", ")}`,"dependencies",o);t[o]=s}else{let s=Re(e,"dependencies",o),a=Ae(s,i);if(a){let c=B(a);if(c===S.Object||c===S.Any)r[o]=a;else if(c===S.Extends)r[o]=zt;else r[o]=Vt(a)}}}return[t,r]}function zy(e,n,t,r){return(o)=>{if(en(t,o)===Ie.Invalid)return!0;let i=lp(n,o);if(i&&B(i)===S.Never)return!0;let s=r[o]??e;if(B(s)===S.Never)return!0;return!1}}function Dy(e,n,t,{required:r}){if(!r)return[];let o=up(r);if(o.duplicated)G(e,`found duplicated required keys: ${o.duplicated.join(", ")}`,"required");let i=[],s=[];for(let a of o.keys)if(Zy(t,a).some((u)=>n(u)))s.push(a);else i.push(a);if(s.length>0)G(e,`key ${s.map((a)=>JSON.stringify(a)).join(", ")} will ban by another condition`,"required");return i}function Vy(e,n,t,r,o,i){if(o!==void 0&&i!==void 0&&o<i)return G(e,`maxProperties(${o}) is less than minProperties(${i})`),!0;if(o!==void 0&&r.length>o)return G(e,`length(${r.length}) of required is greater than maxProperties(${o})`),!0;if(i!==void 0&&r.length<i)return G(e,`length(${r.length}) of required is less than minProperties(${i})`),!0;if(B(n)!==S.Never)return!1;for(let s in t){let a=t[s];if(B(a)!==S.Never)return!1}return!0}function Zy([e,n],t){let r=[t],o=new Set(r);while(r.length>0){let s=r.pop(),a=n[s],c=e[s];if(a){if(B(a)===S.Object)i(a.required)}if(c)i(c)}function i(s){if(s){for(let a of s)if(!o.has(a))o.add(a),r.push(a)}}return[...o]}function up(e){let n=new Set,t=new Set;for(let r of e)if(n.has(r))t.add(r);else n.add(r);if(t.size===0)return{keys:[...e],duplicated:null};else return{keys:[...n],duplicated:[...t]}}function lp(e,n){for(let t in e){let[r,o]=e[t];if(o.test(n))return r}return null}function Fy(e){try{return new RegExp(e,"i")}catch(n){if(n instanceof SyntaxError)return n;else throw n}}function My(e){let n={};for(let t in e)n[t]=e[t][0];return n}function Jy([e,n],{dependencies:t}){let r={};for(let o in t){let i=e[o],s=n[o];r[o]=i||s}return r}var ls=new Set(["type","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"]),dp=new Set(["type","format","maxLength","minLength","pattern"]);function fp(e,n){let{type:t}=n;switch(t){case"number":case"integer":return Ly(e,n);case"string":return Uy(e,n);case"boolean":case"null":{let r=Object.keys(n).filter((s)=>Xe(s)&&s!=="type");if(r.length>0)G(e,`key "type" will exclude other keys: ${r.toSorted().join(", ")}`);let o=t==="null"?S.Null:S.Boolean;return pe(o,{type:t},e.delegate,e.path)}default:return hn(e,`invalid type ${JSON.stringify(t)}`),null}}function Ly(e,n){let t=Object.keys(n).filter((l)=>!ls.has(l)&&Xe(l));if(t.length>0)G(e,`type=${JSON.stringify(n.type)} will exclude other keys: ${t.toSorted().join(", ")}`);let r=ns(n,ls);for(let l of ls){let d=r[l];if(l!=="type"&&d!==void 0&&Number.isNaN(d))G(e,"found NaN",l),delete r[l]}let{maximum:o,exclusiveMaximum:i,minimum:s,exclusiveMinimum:a}=r;if(o!==void 0&&i!==void 0){if(o===i)delete r.maximum;else if(o<i)delete r.exclusiveMaximum;else if(o>i)delete r.maximum}if(s!==void 0&&a!==void 0){if(s===a)delete r.minimum;else if(s<a)delete r.exclusiveMinimum;else if(s>a)delete r.minimum}let{multipleOf:c}=r;if(c===0)delete r.multipleOf,r.type="number",G(e,"cannot be 0","multipleOf");let u=S.Numeric;if(!qy(r))u=S.Never;return pe(u,r,e.delegate,e.path)}function qy(e){let{maximum:n,exclusiveMaximum:t,minimum:r,exclusiveMinimum:o}=e;if(n!==void 0&&r!==void 0)return n>=r;else if(t!==void 0&&r!==void 0)return t>r;else if(n!==void 0&&o!==void 0)return n>o;else if(t!==void 0&&o!==void 0)return t>o;else return!0}function Uy(e,n){let t=Object.keys(n).filter((a)=>!dp.has(a)&&Xe(a));if(t.length>0)G(e,`type="string" will exclude other keys: ${t.toSorted().join(", ")}`);let r=ns(n,dp);pp(e,r,"maxLength"),pp(e,r,"minLength");let{maxLength:o,minLength:i}=r,s=S.String;if(o!==void 0){if(o<0)s=S.Never;else if(o!==void 0&&i!==void 0&&o<i)s=S.Never}return pe(s,r,e.delegate,e.path)}function pp(e,n,t){let r=n[t];if(r!==void 0){if(Number.isNaN(r))G(e,"found NaN",t),delete n[t]}}var mp=Object.freeze([]);function Yr(e,n,t,r){if(Te(e))return{schema:e,warns:mp};if(n.isExtendsSchema(e))return{schema:e,warns:mp};if(r){let s=r.isSchema(e);if(typeof s==="object"){let a=[];for(let c of s)a.push({kind:Kn.External,error:c});if(a.length>0)return a}else if(s===!1)throw Error("it is not a JSON Schema 7")}let o={delegate:r,payload:t,extends:n,path:[],errors:[],warns:[]},i=Ae(o,e);if(i)gp(o.errors.length===0,"found errors (it should be empty)");else return gp(o.errors.length>0,"cannot found any errors"),o.errors;return{schema:i,warns:o.warns}}function gp(e,n){if(!e)throw Error(n)}function Ae(e,n){if(e.extends.isExtendsSchema(n))return n;if(Te(n))return n;let t=e.extends.tryCompiledExtendsSchema(n,e.payload);if(t)return t;let r=n,o=!1,{enum:i,const:s}=n;if(i||s!==void 0){let{enum:c,const:u,...l}=n;r=l,o=!0}let a=Ky(e,r);if(a&&o)a=sp(e,i,s,a);if(!a)return null;return a}function Ky(e,n){for(let t of ip){let r=n[t];if(r){let o=Object.keys(n).filter((s)=>Xe(s)&&s!==t);if(o.length>0)G(e,`composition key ${JSON.stringify(t)} will exclude other keys: ${o.toSorted().join(", ")}`);let i=us(e,t,r);if(!i)return null;return i}}{let t=Ne(n.not);if(t){let r=Object.keys(n).filter((a)=>Xe(a)&&a!=="not");if(r.length>0)G(e,`key "not" will exclude other keys: ${r.toSorted().join(", ")}`);let o=Re(e,"not"),i=Ae(o,t);if(!i)return null;let s=S.Not;switch(B(i)){case S.Never:{s=S.Any;break}case S.Any:{s=S.Never;break}}return pe(s,{not:i},e.delegate,e.path)}}if(n.type){let{type:t}=n;if(Array.isArray(t)){let{type:r,...o}=n;return us(e,"anyOf",t.map((i)=>({...o,type:i})))}switch(t){case"object":return cp(e,n);case"array":return op(e,n);default:return fp(e,n)}}if(Xd(n))return pe(S.Any,{},e.delegate,e.path);return hn(e,"unrecognized"),null}class ds{constructor(e){let n=Object.freeze(e.toSorted());if(n.length>32)throw Error(`cannot define ${n.length} keys which is greater than 32`);this.keys=n,this.clazz=class extends hp{constructor(t){super(n,t)}};for(let[t,r]of this.keys.entries()){let o=1<<t;Object.defineProperty(this.clazz.prototype,r,{enumerable:!0,get:function(){return!!(this.int32&o)},set:function(s){if(s)this.int32|=o;else this.int32&=~o}})}}toBundle(e){let n=0;if(typeof e==="number")n=e;else if(e){for(let[t,r]of this.keys.entries())if(e[r])n|=1<<t}return new this.clazz(n)}}class hp{constructor(e,n){this.keys=e,this.int32=n}toInt32(){return this.int32}toString(){let e={};for(let n of this.keys)e[n]=this[n];return JSON.stringify(e)}}function Xr(e){return new yp(e)}class yp{constructor(e){this.description=new ds(e)}get keys(){return this.description.keys}variable(e){let n;if(e)n=this.description.toBundle(e).toInt32();return new bp(this.description,n)}}class bp{constructor(e,n){this.values=new Set;if(this.description=e,n!==void 0)this.values.add(n)}[Symbol.iterator](){let e=this.values[Symbol.iterator]();return{next:()=>{let n=e.next();if(n.done)return n;else return{done:!1,value:this.description.toBundle(n.value)}}}}assign(e){let{values:n}=e;for(let t of n)this.values.add(t);return this}push(e,n){let t=new Set;for(let r of this.values)for(let[o,i]of rn)if(e&i){let s=this.description.toBundle(r);n(o,s),t.add(s.toInt32())}this.values=t}update(e){let n=new Set;for(let t of this.values){let r=this.description.toBundle(t);e(r),n.add(r.toInt32())}this.values=n}}function bn(e,n){let[t]=e,[r]=n;if(t.num<r.num)return By(e,n);else if(t.num>r.num)return Wy(e,n);else return Gy(e,n)}function By(e,n){let[t,r]=e,[o,i]=n;if(r.num<=o.num){let s=r.exclusive,a=o.exclusive;if(r.num<o.num||s||a)return{left:{fromLeft:!0,range:e},right:{fromLeft:!1,range:n}}}if(r.num<=i.num){let s=!0,a=!1;if(r.num===i.num){let c=r.exclusive,u=i.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!1,range:[Le(r),i]};return{left:{fromLeft:!0,range:[t,Le(o)]},center:[o,r],right:c}}}return{left:{fromLeft:!0,range:[t,Le(o)]},center:[o,i],right:{fromLeft:!0,range:[Le(i),r]}}}function Wy(e,n){let[t,r]=e,[o,i]=n;if(t.num>=i.num){let s=i.exclusive,a=t.exclusive;if(t.num>i.num||s||a)return{left:{fromLeft:!1,range:n},right:{fromLeft:!0,range:e}}}if(i.num<=r.num){let s=!0,a=!1;if(r.num===i.num){let c=i.exclusive,u=r.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!0,range:[Le(i),r]};return{left:{fromLeft:!1,range:[o,Le(t)]},center:[t,i],right:c}}}return{left:{fromLeft:!1,range:[o,Le(t)]},center:[t,r],right:{fromLeft:!1,range:[Le(r),i]}}}function Gy(e,n){let[t,r]=e,[o,i]=n,s=t.exclusive,a=o.exclusive,c,u=t;if(!s&&a)u=o,c={fromLeft:!0,range:[t,Le(o)]};else if(s&&!a)c={fromLeft:!1,range:[o,Le(t)]};if(r.num<=i.num){let l=!0,d=!1;if(r.num===i.num){let m=r.exclusive,g=i.exclusive;l=m!==g,d=!m&&g}if(!d){let m;if(l)m={fromLeft:!1,range:[Le(r),i]};return{left:c,center:[u,r],right:m}}}return{left:c,center:[u,i],right:{fromLeft:!0,range:[Le(i),r]}}}function Le(e){return{num:e.num,exclusive:!e.exclusive}}var Wn=(e)=>(n=e,t=Number.POSITIVE_INFINITY,r=e,o=Number.POSITIVE_INFINITY)=>{let{left:i,center:s,right:a}=bn([{num:n,exclusive:!1},{num:t,exclusive:!1}],[{num:r,exclusive:!1},{num:o,exclusive:!1}]),c,u,l;if(i)c={min:i.range[0].num,max:i.range[1].num,isFrom1:i.fromLeft};if(a)u={min:a.range[0].num,max:a.range[1].num,isFrom1:a.fromLeft};if(s)l={min:s[0].num,max:s[1].num};return{left:c,right:u,intersection:l}};function Gn({left:e,right:n,intersection:t}){if(!t)return y.Rejection;let r=!1,o=!1;if(e)if(e.isFrom1)r=!0;else o=!0;if(n)if(n.isFrom1)r=!0;else o=!0;if(r&&o)return y.Intersection;if(r)return y.Containing;if(o)return y.ContainedBy;return y.Equals}var Hy=Wn(0),Qy=Xr(["hasCommon","hasExtra1","hasExtra2","hasRejection","hasCommonBroken"]);function xp({calculate:e},n,t){let r=Hy(n.minItems,n.maxItems,t.minItems,t.maxItems),o=Gn(r);if(o===y.Rejection)return q;let[i,s]=wp(n),[a,c]=wp(t),u=Math.max(i.length,a.length)+1,l=Math.min(u,r.intersection.max),d=Qy.variable({}),m=Math.min(n.minItems??0,t.minItems??0);for(let h=0;h<l;h++){let I=i[h]??s,R=a[h]??c,N=e(I,R);d.push(N,(L,K)=>{switch(L){case y.Equals:{if(!K.hasRejection)K.hasCommon=!0;break}case y.Containing:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra1=!0;break}case y.ContainedBy:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra2=!0;break}case y.Intersection:{if(!K.hasRejection)K.hasCommon=!0;K.hasExtra1=!0,K.hasExtra2=!0;break}case y.Rejection:{if(h<m)K.hasCommonBroken=!0;K.hasRejection=!0,K.hasExtra1=!0,K.hasExtra2=!0;break}}})}d.update((h)=>{switch(o){case y.Containing:{h.hasExtra1=!0;break}case y.ContainedBy:{h.hasExtra2=!0;break}case y.Intersection:{h.hasExtra1=!0,h.hasExtra2=!0;break}}if(n.uniqueItems&&!t.uniqueItems&&(t.maxItems??Number.POSITIVE_INFINITY)>1)h.hasExtra2=!0;else if(!n.uniqueItems&&t.uniqueItems&&(n.maxItems??Number.POSITIVE_INFINITY)>1)h.hasExtra1=!0;if(n.maxItems===0||t.maxItems===0){if(h.hasCommon=!0,n.maxItems!==0)h.hasExtra1=!0;if(t.maxItems!==0)h.hasExtra2=!0}});let g=ne;for(let{hasExtra1:h,hasExtra2:I,hasCommon:R,hasCommonBroken:N}of d){let L=R;if(N)L=!1;if(!L)g|=q;else if(h&&I)g|=W;else if(h)g|=V;else if(I)g|=Z;else g|=J}return g}function wp({items:e,additionalItems:n}){if(Array.isArray(e))return[e,n??yn];else return[[],e??yn]}function vp(e){let n=new Map;return(t,r)=>{let o=Dt(t),i=Dt(r);if(o!==i)return!1;if(!o)return t===r;return Sp(n,t,r,e)}}function kp(e){let n=new Map;return(t,r)=>Sp(n,t,r,e)}function Sp(e,n,t,r){let o=Rn(n),i=Rn(t),s=`${o}/${i}`,a=e.get(s);if(a===void 0)e.set(s,a=r(n,t));return a}function Ep(e,n,t){let r=ps(n),o=ps(t),i=!1,s=!1,a=!1;for(let c of r){if(Ip(e,o,c))a=!0;else i=!0;if(i&&a)break}for(let c of o){if(Ip(e,r,c))a=!0;else s=!0;if(s&&a)break}if(!a)return q;if(i&&s)return W;if(i)return V;if(s)return Z;return J}function fs(e,n){let t=!1,r=!1;for(let o of ps(e)){switch(en(n,o)){case Ie.Valid:{t=!0;break}case Ie.Invalid:{r=!0;break}case Ie.Unknown:return Je}if(t&&r)break}if(t&&r)return W;if(t)return J|Z;if(r)return q;if(B(n)===S.Never)return J;return Z}function ps({const:e,enum:n}){if(e!==void 0)return[e];if(n)return n;throw Error("invalid branch")}function Ip({isEquals:e},n,t){for(let r of n)if(e(r,t))return!0;return!1}function Cp(e){function n(s,a){let c=e.isExtendsSchema(s),u=e.isExtendsSchema(a);if(c||u)return e.equals(s,a);else return r(s,a)}let t=new Map;function r(s,a){let c=Rn(s),u=Rn(a);if(c===u)return!0;let l=`${c}/${u}`,d=t.get(l);if(d===void 0)d=o(s,a),t.set(l,d);return d}function o(s,a){if(Array.isArray(s)){if(!Array.isArray(a))return!1;if(s.length!==a.length)return!1;for(let[c,u]of s.entries())if(!i(u,a[c]))return!1}else{if(Array.isArray(a))return!1;for(let c in s){if(!(c in a))return!1;let u=Reflect.get(s,c),l=Reflect.get(a,c);if(!i(u,l))return!1}for(let c in a)if(!(c in s))return!1}return!0}function i(s,a){if(s===a)return!0;if(s===null||a===null)return!1;if(typeof s!=="object")return!1;if(typeof s!==typeof a)return!1;if(Te(s)&&Te(a))return r(s,a);return o(s,a)}return n}function Zt(e){let n=Ft(e),t=e.multipleOf??1,r=Be(n,t);if(!r)return null;return{multipleOf:t,range:r}}function Op([e,n]){if(e.num!==n.num)return!1;if(e.exclusive)return!1;if(n.exclusive)return!1;return!0}function Be(e,n){if(!e)return;let[t,r]=e,o=Yy(t.num,n),i=Xy(r.num,n);if(o===t.num&&t.exclusive)o+=n;if(i===r.num&&r.exclusive)i-=n;if(o>i)return;if(o===i){if(o===Number.POSITIVE_INFINITY)return;if(o===Number.NEGATIVE_INFINITY)return}return[{num:o,exclusive:!1},{num:i,exclusive:!1}]}function Yy(e,n){return Math.ceil(e/n)*n}function Xy(e,n){return Math.floor(e/n)*n}function Ap(e,n){let t=Ft(e),r=Ft(n),{left:o,right:i,center:s}=bn(t,r);if(!s)return q;let a=!1,c=!1;if(o)if(o.fromLeft)a=!0;else c=!0;if(i)if(i.fromLeft)a=!0;else c=!0;if(a&&c)return W;if(a)return V;if(c)return Z;return J}function ms(e,n){let t=Ft(e),r=Zt(n);if(!r)return V;let o=bn(t,r.range),i=Be(o.center,r.multipleOf),s=Rp(o.left,r.multipleOf),a=Rp(o.right,r.multipleOf);if(!o.center)return q;let c=!1,u=!1;if(o.left?.fromLeft)c=!0;if(o.right?.fromLeft)c=!0;if(!i||!Op(o.center))c=!0;if(s)u=!0;if(a)u=!0;if(c&&u)return W;if(c)return V;if(u)return Z;return J}function Ft(e){let n,t;if(e.exclusiveMinimum!==void 0)n={num:e.exclusiveMinimum,exclusive:!0};else if(e.minimum!==void 0)n={num:e.minimum,exclusive:!1};else n={num:Number.NEGATIVE_INFINITY,exclusive:!0};if(e.exclusiveMaximum!==void 0)t={num:e.exclusiveMaximum,exclusive:!0};else if(e.maximum!==void 0)t={num:e.maximum,exclusive:!1};else t={num:Number.POSITIVE_INFINITY,exclusive:!0};return[n,t]}function Rp(e,n){if(!e)return;if(e.fromLeft)return;return Be(e.range,n)}function _p(e,n){let t=Zt(e),r=Zt(n);if(!t&&!r)return J;if(!t)return Z;if(!r)return V;let{range:o,multipleOf:i}=t,{range:s,multipleOf:a}=r,c=bn(o,s),u,l=0;if(c.center)l=eb(i,a),u=Be(c.center,l);if(!u)return q;let d=!1,m=!1,{left:g,right:h}=c;if(g&&Be(g.range,g.fromLeft?i:a))if(g.fromLeft)d=!0;else m=!0;if(h&&Be(h.range,h.fromLeft?i:a))if(h.fromLeft)d=!0;else m=!0;if(d=d||jp(t,u,l),m=m||jp(r,u,l),d&&m)return W;if(d)return V;if(m)return Z;return J}function jp({range:e,multipleOf:n},t,r){let o=bn(e,t);if(Be(o.left?.range,n))return!0;if(Be(o.right?.range,n))return!0;let i=Be(o.center,n);if(!i)return!1;let s=Pp(t);if(Pp(i)>s)return!0;if(s===1)return!1;if(n<r)return!0;return!1}function eb(e,n){return e*n/$p(e,n)}function $p(e,n){if(e===0)return n;return $p(n%e,e)}function Pp(e){if(!e)return 0;let[n,t]=e;return t.num-n.num+1}function gs(e,n){if(Np(e)||Np(n))return Je;let t=Tp(e),r=Tp(n);if(t&&r)return Ap(e,n);else if(t)return ms(e,n);else if(r)return gn(ms(n,e));else return _p(e,n)}function Np(e){let{multipleOf:n}=e;if(n===void 0)return!1;if(!Number.isInteger(n))return!0;if(n<0)return!0;return!1}function Tp(e){let{multipleOf:n}=e;if(n!==void 0&&Number.isInteger(n))return!1;if(e.type==="integer")return!1;return!0}var nb=Wn(0),tb=Xr(["hasCommonInRequired","hasCommonOutRequired","hasExtra1","hasExtra2","hasRejection"]);function Vp(e,n,t){if(rb(n,t))return q;let r=ob(n,t);if(!r)return q;let o=zp(n),i=zp(t),s=(I)=>{let R=o(I),N=i(I);if(Dp(R,N))return e.calculate(R,N);else return ne},{commonRequired:a,extraRequired1:c,extraRequired2:u}=r,l=tb.variable({});for(let I of[...a].toSorted())l.push(s(I),sb);for(let I of[...c].toSorted())l.push(s(I),ab);for(let I of[...u].toSorted())l.push(s(I),cb);let{hasOptional1:d,hasOptional2:m}=r;if(d||m){let I=ub(d,m);for(let L of[...ib(n,t)].toSorted()){let K=s(L);if(K!==ne)l.push(K,I)}let R=n.additionalProperties??yn,N=t.additionalProperties??yn;if(Dp(R,N)){let L=e.calculate(R,N);l.push(L,I)}}l.update((I)=>{if(!I.hasRejection){if(c.size>0)I.hasExtra2=!0;if(u.size>0)I.hasExtra1=!0}});let{requiredKeysCount:g}=r,h=ne;for(let{hasExtra1:I,hasExtra2:R,hasCommonInRequired:N,hasCommonOutRequired:L,hasRejection:K}of l)if(!N&&g>0)h|=q;else if(!L&&g===0)h|=q;else if(K)h|=q;else if(I&&R)h|=W;else if(I)h|=V;else if(R)h|=Z;else h|=J;return h}function rb(e,n){let t=nb(e.minProperties,e.maxProperties,n.minProperties,n.maxProperties);return Gn(t)===y.Rejection}function ob(e,n){let t=new Set(e.required),r=new Set(n.required),o=new Set,i=new Set,s=t.size,a=r.size;for(let d of t){if(r.has(d))o.add(d);i.add(d)}for(let d of r){if(t.has(d))o.add(d);i.add(d)}let c=i.size;for(let d of o)t.delete(d),r.delete(d);let u=e.maxProperties??Number.MAX_SAFE_INTEGER,l=n.maxProperties??Number.MAX_SAFE_INTEGER;if(c>u||c>l)return null;return{requiredKeysCount:c,extraRequired1:t,extraRequired2:r,commonRequired:o,hasOptional1:u>s,hasOptional2:l>a}}function ib(e,n){let t=new Set(e.required),r=e.properties,o=n.properties,i=e.required,s=n.required;if(r)for(let a in r)t.add(a);if(o)for(let a in o)t.add(a);if(i)for(let a of i)t.delete(a);if(s)for(let a of s)t.delete(a);return t}var sb=(e,n)=>{switch(e){case y.Equals:{n.hasCommonInRequired=!0;break}case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Intersection:{n.hasExtra1=!0,n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},ab=(e,n)=>{switch(e){case y.Equals:case y.ContainedBy:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},cb=(e,n)=>{switch(e){case y.Equals:case y.Containing:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},ub=(e,n)=>(t,r)=>{if(r.hasRejection)return;let o=!1,i=!1,s=!1;switch(t){case y.Equals:{s=!0;break}case y.Containing:{o=!0,s=!0;break}case y.ContainedBy:{i=!0,s=!0;break}case y.Intersection:{o=!0,i=!0,s=!0;break}case y.Rejection:{o=!0,i=!0;break}}if(e&&o)r.hasExtra1=!0;if(n&&i)r.hasExtra2=!0;if(e&&n&&s)r.hasCommonOutRequired=!0};function zp(e){let{properties:n,propertyNames:t,additionalProperties:r}=e,o=[];if(e.patternProperties)for(let i in e.patternProperties){let s=e.patternProperties[i],a=new RegExp(i,"i");o.push({pattern:a,schema:s})}return(i)=>{if(t&&en(t,i)===Ie.Invalid)return zt;for(let{pattern:a,schema:c}of o)if(a.test(i))return c;let s=(n&&n[i])??r;if(!s)return yn;return s}}function Dp(e,n){let t=B(e),r=B(n);return t!==S.Never||r!==S.Never}var lb=Wn(0);function Zp(e,n){if(n.format&&!e.format)return V;if(e.format&&n.format&&e.format!==n.format)return Je;let t=lb(e.minLength,e.maxLength,n.minLength,n.maxLength),r=Gn(t),o=!!e.pattern,i=!!n.pattern;switch(r){case y.Rejection:return q;case y.Containing:return o?Je:V;case y.ContainedBy:return i?Je:Z;case y.Equals:{if(o&&i)return e.pattern===n.pattern?J:Je;if(o)return J|Z;if(i)return J|V;return J}case y.Intersection:{if(o&&i)return Je;if(o)return W|q|Z;if(i)return W|q|V;return W}}}function Mp(e,n,t){let r={},o=[],i=kp(pb(e,r)),s=db(),a=Cp(e);r.isEquals=vp(qn),r.calculate=os({describe:s,equals:a,calculate:i,observeCalculation:(u,l,d,m)=>{let g=m?gn(d):d;if(!fb(g))return;let h=m?Fp(l,u):Fp(u,l);if(h)o.push(h)}}),Object.freeze(r);let c=r.calculate(n,t);return{errorPath:o[0],expression:c}}var db=()=>(e)=>{let n;switch(B(e)){case S.Not:{n={kind:$e.Not,expression:e.not};break}case S.Combination:{if("allOf"in e)n={kind:$e.AllOf,expressions:hs(e.allOf,S.Any)};else if("anyOf"in e)n={kind:$e.AnyOf,expressions:hs(e.anyOf,S.Never)};else if("oneOf"in e)n={kind:$e.OneOf,expressions:hs(e.oneOf,S.Never)};else throw Error(`invalid combination JSON Schema: ${JSON.stringify(e)}`);break}default:{n={kind:$e.Leaf};break}}return n},pb=(e,n)=>(t,r)=>{let o=B(t),i=B(r);if(o===S.Extends||i===S.Extends)return e.calculate(t,r);switch(o){case S.Any:return i===S.Any?J:V;case S.Never:return i===S.Never?J:Z}switch(i){case S.Any:return Z;case S.Never:return V}if(o===S.EnumOrConst&&i===S.EnumOrConst)return Ep(n,t,r);if(o===S.EnumOrConst)return fs(t,r);if(i===S.EnumOrConst)return gn(fs(r,t));if(o!==i)return q;switch(o){case S.Null:return J;case S.Numeric:return gs(t,r);case S.String:return Zp(t,r);case S.Boolean:return J;case S.Object:return Vp(n,t,r);case S.Array:return xp(n,t,r);default:throw Error(`invalid kind ${o}`)}};function hs(e,n){return e.filter((t)=>B(t)!==n)}function fb(e){return!At(e)&&!Pt(e)&&(jt(e)||$t(e)||_t(e))}function Fp(e,n){let t=as(n);if(!t)return;let r=B(e),o=B(n);if(r!==o)return[...t,"type"];let i=e,s=n;switch(o){case S.String:{if((i.minLength??0)<(s.minLength??0))return[...t,"minLength"];if((i.maxLength??Number.POSITIVE_INFINITY)>(s.maxLength??Number.POSITIVE_INFINITY))return[...t,"maxLength"];if(i.pattern!==s.pattern&&s.pattern)return[...t,"pattern"];if(i.format!==s.format&&s.format)return[...t,"format"];break}case S.Numeric:{if((i.minimum??i.exclusiveMinimum??Number.NEGATIVE_INFINITY)<(s.minimum??s.exclusiveMinimum??Number.NEGATIVE_INFINITY))return[...t,s.exclusiveMinimum==null?"minimum":"exclusiveMinimum"];if((i.maximum??i.exclusiveMaximum??Number.POSITIVE_INFINITY)>(s.maximum??s.exclusiveMaximum??Number.POSITIVE_INFINITY))return[...t,s.exclusiveMaximum==null?"maximum":"exclusiveMaximum"];if(i.multipleOf!==s.multipleOf&&s.multipleOf!=null)return[...t,"multipleOf"];break}case S.Array:{if((i.minItems??0)<(s.minItems??0))return[...t,"minItems"];if((i.maxItems??Number.POSITIVE_INFINITY)>(s.maxItems??Number.POSITIVE_INFINITY))return[...t,"maxItems"];if(!i.uniqueItems&&s.uniqueItems)return[...t,"uniqueItems"];break}case S.Object:{let a=new Set(i.required??[]);if((s.required??[]).some((c)=>!a.has(c)))return[...t,"required"];if((i.minProperties??0)<(s.minProperties??0))return[...t,"minProperties"];if((i.maxProperties??Number.POSITIVE_INFINITY)>(s.maxProperties??Number.POSITIVE_INFINITY))return[...t,"maxProperties"];break}case S.EnumOrConst:return[...t,s.const===void 0?"enum":"const"]}return t}class Mt{constructor(e=[]){this.extendsSchemaClasses=Object.freeze([...e])}tryCompiledExtendsSchema(e,n){for(let t of this.extendsSchemaClasses)if(t.isMatch(e))return new t(fn(),e,n);return null}isExtendsSchema(e){for(let n of this.extendsSchemaClasses)if(e instanceof n)return!0;return!1}calculate(e,n){let t=this.findMatchedClass(e,n),r=!(e instanceof t),o=ne,i;if(r)i=n.compare(e);else i=e.compare(n);for(let s of i){if(r)s=Mt.swap(s);o|=mn(s)}return o}equals(e,n){let t=this.findMatchedClass(e,n);if(!(e instanceof t))return n.equals(e);else return e.equals(n)}findMatchedClass(e,n){for(let t of this.extendsSchemaClasses){if(e instanceof t)return t;if(n instanceof t)return t}throw Error("Invalid schema")}static swap(e){switch(e){case y.Containing:return y.ContainedBy;case y.ContainedBy:return y.Containing;default:return e}}}function Jp(e,n,t=!1){let r=n(e);if(Array.isArray(r)){let s=[];throw ys(s,r,"$"),new Gr(s)}let{schema:o,warns:i}=r;if(t&&i.length>0){console.warn(`found ${i.length} warns after compile schema`);for(let s of i)console.warn(Bn(s))}return o}function Lp(e,n,t,r=!1){let o=t(e),i=t(n);if(Array.isArray(o)||Array.isArray(i)){let l=[];if(Array.isArray(o))ys(l,o,"$1");if(Array.isArray(i))ys(l,i,"$2");throw new Gr(l)}let{schema:s,warns:a}=o,{schema:c,warns:u}=i;if(r){if(a.length>0)console.warn(`found ${a.length} warns after compile superSchema`);for(let l of a)console.warn(Bn(l));if(u.length>0)console.warn(`found ${u.length} warns after compile subSchema`);for(let l of u)console.warn(Bn(l))}return[s,c]}function ys(e,n,t){for(let r of n){let o={...r,path:[t,...r.path]};e.push(o)}}var Jt=Object.freeze({True:0,False:1,Unknown:2});function bs({extendsSchemaClasses:e,delegate:n}={}){let t=new Mt(e);return Object.freeze({compile:(o,i,s)=>Jp(o,(c)=>Yr(c,t,i,n),s),isSubset:(o,i,s=!1)=>{let a=(h)=>Yr(h,t,void 0,n),[c,u]=Lp(o,i,a,s),{errorPath:l,expression:d}=Mp(t,c,u),m=At(d)||Pt(d),g=jt(d)||$t(d)||_t(d);if(m&&!g)return{result:Jt.True};if(!m&&g)return{errorPath:l,result:Jt.False};return{result:Jt.Unknown}}})}var eo=(e)=>typeof e==="string";var mb=Array.isArray;var gb=(e)=>e!==null&&typeof e==="object";var hb=(e)=>gb(e)&&!mb(e),An=(e)=>hb(e)?e:void 0;function yb(e){return An(e)?.type==="string"}function bb(e){let n=An(e),t=An(n?.error);if(n==null||t==null||n.packageId!=null&&!eo(n.packageId)||t.message!=null&&!eo(t.message))throw TypeError("Invalid schema comparison context.")}function wb(e){if(e==null)return{error:{}};return bb(e),e}class wn{static setError(e,n,t){if(e instanceof wn)e.context.error.message=t;else if(n instanceof wn)n.context.error.message=t}constructor(e,n,t){this.id=e,this.value=n,this.context=wb(t)}compare(e){if(Te(e)&&B(e)===S.Any)return[y.ContainedBy];return this.compareImpl(e)}}class Lt extends wn{static isMatch(e){let n=An(e)?.enum;return Array.isArray(n)&&n.every((t)=>eo(t))}constructor(e,n,t){if(!Lt.isMatch(n))throw TypeError("Invalid single-select schema.");super(e,n,t)}compareImpl(e){if(yb(e))return[y.ContainedBy];if(e instanceof Lt){let n=new Set(this.value.enum),t=y.Equals;for(let r of e.value.enum){if(!n.has(r))t=y.ContainedBy;n.delete(r)}if(n.size===0)return[t];if(n.size===this.value.enum.length)return[y.Rejection];return[y.Intersection]}return[y.Rejection]}equals(e){if(e instanceof Lt){let n=new Set(this.value.enum);for(let t of e.value.enum){if(!n.has(t))return!1;n.delete(t)}return n.size===0}return!1}}class qt extends wn{static isMatch(e){return An(e)?.contentMediaType==="oomol/bin"}constructor(e,n,t){if(!qt.isMatch(n))throw TypeError("Invalid binary schema.");super(e,n,t)}compareImpl(e){if(e instanceof qt)return[y.Equals];else return wn.setError(this,e,"edgeError.binDiffType"),[y.Rejection]}equals(e){return e instanceof qt}}class Ut extends wn{static isMatch(e){return An(e)?.contentMediaType==="oomol/artifact"}constructor(e,n,t){if(!Ut.isMatch(n))throw TypeError("Invalid Artifact schema.");super(e,n,t)}compareImpl(e){if(e instanceof Ut)return[y.Equals];return wn.setError(this,e,"edgeError.artifactDiffType"),[y.Rejection]}equals(e){return e instanceof Ut}}function qp(){return bs({extendsSchemaClasses:[Lt,qt,Ut]})}var JE=qp();var ws={choice:255,score:10};function Up(e){if(e.type==="noul"||e.criteria.length<=ws[e.type])return e;if(e.type==="choice")return{...e,criteria:e.criteria.slice(0,ws.choice)};return{...e,criteria:e.criteria.slice(0,ws.score)}}function xb(e){let n=e.map(Up);return n.every((t,r)=>t===e[r])?e:n}function Kp(e){if(e.executor.kind!=="decision")return e;let n=e.executor.questions,t=xb(n);if(t===n)return e;let r=e.outputs.map((o)=>{if(!("handle"in o))return o;let i=n.findIndex((s)=>s.name===o.handle);if(i<0||n[i]===t[i]||!Oe(o.jsonSchema,Bp(n[i])))return o;return{...o,jsonSchema:vb(t[i])}});return{...e,executor:{...e.executor,questions:t},outputs:r}}var xs={type:"number",minimum:0,maximum:1};function vb(e){return Bp(Up(e))}function Bp(e){let n={type:{const:e.type}};if(e.type==="noul")n.noul=xs;else{let t=e.type==="choice"?e.criteria.map((r)=>r.name):e.criteria.map((r,o)=>String(o));if(n.confidence=xs,n.probabilities={type:"object",properties:Object.fromEntries(t.map((r)=>[r,xs])),required:t,additionalProperties:!1},e.type==="choice")n.choice={type:"string",...t.length?{enum:t}:{}};else n.score={type:"number",minimum:0,maximum:Math.max(0,t.length-1)},n.legend={type:"object",properties:Object.fromEntries(t.map((r)=>[r,{type:"string"}])),required:t,additionalProperties:!1}}return{type:"object",properties:n,required:Object.keys(n)}}function jn(e,n=0){if(n>64)throw TypeError("Value exceeds the maximum JSON depth.");if(e!=null&&typeof e=="object")for(let t of Object.values(e))jn(t,n+1)}var xn=P(Y([j({type:k("cron"),expression:A(),timezone:A()}),j({type:k("every"),unit:ce(["day","hour","minute","month","week"]),value:fe()})]));var Br=6,v=A(),_n=Me(),Bt=P(v),so=j({description:v.optional(),jsonSchema:_n,nullable:ye(),handle:v}),qe=so.extend({value:_n.optional()}),Wp=j({collapsed:ye().optional(),group:v}),kb=j({kind:k("node"),nodeId:v,output:v,field:v.optional()}),Qp=Y([kb,j({kind:k("binding"),bindingId:v})]),Wt=Y([j({kind:k("unset")}),j({kind:k("value"),value:_n})]),vs=Y([Wt,j({kind:k("sources"),sources:P(Qp)})]),Sb=oe(v,vs),Yn={inputs:P(Y([qe,Wp])),outputs:P(Y([so,Wp]))},Ib=x({kind:k("connector"),action:v,connectionId:v.optional(),connections:P(x({connectionId:v,alias:v.optional()}))}),ro=Y([Ib,x({kind:k("connector"),mode:k("shared")}),x({kind:k("connector"),mode:k("independent"),actions:P(x({action:v,connectionId:v.optional()}))}),x({kind:k("connector"),actionHints:P(v).optional(),connectionHints:P(x({action:v,connectionId:v,alias:v.optional()})).optional()})]),ks=j({...Yn,name:v,moduleId:v,capabilities:P(ro).optional()}),Yp=Y([j({kind:k("value"),value:_n}),j({kind:k("input"),input:v})]),Eb=Y([Yp,j({kind:k("model")})]),Cb=Ln("type",[x({name:v,instructions:v,type:k("noul"),criteria:x({true:v.optional(),false:v.optional()}).optional()}),x({name:v,instructions:v,type:k("choice"),criteria:P(x({name:v,description:v}))}),x({name:v,instructions:v,type:k("score"),criteria:Bt})]),Qn=j({...Yn,name:v,executor:Y([j({kind:k("connector"),action:v,connectionId:v.optional(),outputMode:k("value").optional()}),j({kind:k("openapi"),sourceUrl:v,method:v,path:v,serverUrl:v,document:_n,auth:P(j({id:v,type:ce(["bearer","basic","apiKey"]),name:v.optional(),in:ce(["header","query"]).optional()}))}),x({kind:k("decision"),questions:P(Cb)}),j({kind:k("llm"),mode:ce(["chat","json"])}),j({kind:k("agent"),code:ye().optional(),model:v,prompt:v,maxRounds:fe(),tools:P(j({id:v,name:v,description:v,action:v,connectionId:v.optional(),approval:ye(),inputs:P(qe.extend({source:Eb}))})),notification:j({action:v,connectionId:v.optional(),inputDefinitions:P(qe),messageHandle:v,inputs:oe(v,Yp)}).optional()})])}),Ss=Qn.transform(Kp),Gp=Y([j({kind:k("value"),value:_n.optional(),jsonSchema:_n.optional()}),j({kind:k("source"),source:Qp})]),oo={matchMode:ce(["first","all"]),cases:P(j({description:v.optional(),output:v,groups:P(j({expressions:P(j({left:Gp,operator:ce(["!=","<","<=","==",">",">=","contains","endsWith","hasKey","hasValue","isEmpty","isFalse","isNotEmpty","isNotNull","isNull","isTrue","notContains","notHasKey","notHasValue","startsWith"]),right:Gp.optional()}))}))}))},Gt={inputDefinitions:P(qe),prompt:v},Ob=j({allowedMethods:pn().optional(),allowedOrigins:Bt.optional(),noResponseBody:pn().optional(),responseData:v.optional(),responseHeaders:oe(v,v).optional(),responseStatusCode:fe().int().min(200).max(599).optional()}),io={bodyFields:P(qe),method:ce(Hi),options:Ob.optional()},Hp={configInputs:Yn.inputs,definitionVersion:k(2),description:v,displayName:v,key:v,name:v,outputs:P(so).refine((e)=>new Set(e.map((n)=>n.handle)).size===e.length,"Duplicate Trigger output handle."),provider:v},Rb=j({body:j({allowArray:ye(),allowEmpty:ye(),formats:P(ce(["form","json","multipart","text"]))}),methods:P(ce(["DELETE","GET","HEAD","PATCH","POST","PUT"])),successStatus:fe()}),Is=P(v.min(1)).refine((e)=>new Set(e).size===e.length,"Duplicate source Flow ID."),Hn={name:v,description:v.optional(),icon:v.optional()},Kt={maxExecutions:fe().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),inputs:Sb,name:v.optional(),description:v.optional(),icon:v.optional(),timeoutMs:fe().optional()},to=Y([j({...Kt,inputs:oe(v,pn()),kind:k("condition"),...oo}),j({...Kt,inputs:Jn().transform(()=>({})).default({}),kind:k("value"),values:P(qe)}),j({...Kt,kind:k("task"),task:Y([ks,Ss]),additionalInputs:P(qe).optional()}),x({...Kt,kind:k("approval"),...Gt}).omit({timeoutMs:!0}),x({...Kt,kind:k("wait"),...Gt}).omit({timeoutMs:!0}),j({...Hn,kind:k("manual")}),x({...Hn,kind:k("error"),sourceFlowIds:Is.optional()}),j({...Hn,kind:k("webhook"),...io}),j({...Hn,kind:k("cron"),cronTimes:xn}),j({...Hn,kind:k("poll"),connectionId:v.min(1).optional(),config:oe(v,Wt),definition:j({...Hp,type:k("poll")}),pollTimes:xn}),j({...Hn,kind:k("integration"),connectionId:v.min(1).optional(),config:oe(v,Wt),definition:j({...Hp,type:k("integration"),endpoint:Rb})})]),Ue={input:qe,port:so,ports:Yn,condition:x(oo),wait:x(Gt),webhook:x(io),schedule:xn,capabilities:P(ro),connector:Qn.shape.executor.options[0].omit({kind:!0}).strict(),openapi:Qn.shape.executor.options[1].omit({kind:!0}).strict(),decision:Qn.shape.executor.options[2].omit({kind:!0}).strict(),llm:Qn.shape.executor.options[3].omit({kind:!0}).strict(),agent:Qn.shape.executor.options[4].omit({kind:!0,notification:!0}).strict()},Es=j({source:v,target:v,sourceHandle:v.optional()}),Se={nodeId:v,target:pn().optional()},Ab=j({nodes:oe(v,to),edges:P(Es).default([])}),Xp=j({kind:k("variable"),target:v}),ef=j({name:v,imports:Bt,source:v}),jb=ly(Pb,j({bindings:oe(v,Xp),graph:Ab})),nf=j({modelVersion:Y([k(2),k(4),k(5),k(Br)]),document:jb,modules:oe(v,ef)}),aC=nf.extend({kind:k("open-flow-flow-revision"),version:k(1)});function Pb(e){let n=Pn(e);if(n.tasks!==void 0&&(n.tasks===null||typeof n.tasks!=="object"||Array.isArray(n.tasks)||Object.keys(n.tasks).length>0))throw TypeError("Independent Task definitions are no longer supported.");if(Object.values(Pn(Pn(n.graph).nodes)).some((r)=>Object.hasOwn(Pn(r),"taskId")))throw TypeError("Task references are no longer supported.");let t=n.subflows;if(t!==void 0&&(t===null||typeof t!=="object"||Array.isArray(t)||Object.keys(t).length>0))throw TypeError("Subflows are no longer supported.");if(Object.values(Pn(Pn(n.graph).nodes)).some((r)=>Pn(r).kind==="subflow"))throw TypeError("Subflow nodes are no longer supported.");return e}function Pn(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Qt(e){jn(e);let n=nf.parse(e);return $b(n),Qi(n.document),n}var _b={"graph.trigger.sources.set":{nodeId:v,before:Is.optional(),value:Is.optional()},"binding.create":{bindingId:v,binding:Xp},"binding.delete":{bindingId:v},"binding.target.set":{bindingId:v,before:v,value:v},"graph.edge.connect":{edge:Es,target:pn().optional()},"graph.edge.disconnect":{edge:Es,target:pn().optional()},"graph.node.create":{...Se,node:to},"graph.node.replace":{...Se,before:to,node:to},"graph.node.delete":Se,"graph.node.field.set":Y([j({...Se,kind:k("graph.node.field.set"),field:k("connectionId"),before:v.min(1).optional(),value:v.min(1).optional()}),j({...Se,kind:k("graph.node.field.set"),field:ce(["description","icon","name"]),before:v.optional(),value:v.optional()}),j({...Se,kind:k("graph.node.field.set"),field:k("maxExecutions"),before:fe().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),value:fe().int().positive().max(Number.MAX_SAFE_INTEGER).optional()}),j({...Se,kind:k("graph.node.field.set"),field:k("timeoutMs"),before:fe().optional(),value:fe().optional()})]),"graph.node.input.set":{...Se,handle:v,before:vs.optional(),value:vs.optional()},"graph.node.additional-inputs.set":{...Se,before:P(qe).optional(),value:P(qe).optional()},"graph.node.condition.set":{...Se,before:j(oo),value:j(oo)},"graph.node.values.set":{...Se,before:P(qe),value:P(qe)},"graph.node.resolution.set":{...Se,before:j(Gt),value:j(Gt)},"graph.node.webhook.set":{...Se,before:j(io),value:j(io)},"graph.node.task.ports.set":{...Se,before:j(Yn),value:j(Yn)},"graph.node.task.name.set":{...Se,before:v,value:v},"graph.node.task.capabilities.set":{...Se,before:P(ro).optional(),value:P(ro).optional()},"graph.trigger.config.set":{nodeId:v,name:v,before:Wt.optional(),value:Wt.optional()},"graph.trigger.schedule.set":{nodeId:v,before:xn,value:xn},"module.create":{moduleId:v,module:ef},"module.delete":{moduleId:v},"module.rename":{moduleId:v,before:v,name:v},"module.source.replace":{moduleId:v,beforeImports:Bt,beforeSource:v,imports:Bt,source:v},"graph.node.task.set":{...Se,before:Y([ks,Ss]),value:Y([ks,Ss])}},tf=new Map(Object.entries(_b).map(([e,n])=>[e,n instanceof re?n:j({kind:k(e),...n})])),cC=P(Y([...tf.values()])).min(1);function Ht(e,n,t){try{return t(e)}catch(r){if(!(r instanceof uh))throw r;throw TypeError(`operations[${n}]: ${r.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,{cause:r})}}function rf(e,n){let{kind:t}=Ht(e,n,j({kind:v}).parse),r=tf.get(t);if(r==null)throw TypeError(`operations[${n}]: Unknown operation ${JSON.stringify(t)}.`);return Ht(e,n,r.parse)}function $b(e){if(e.modelVersion<6&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="task"&&("executor"in n.task)))throw TypeError("Node-owned managed Tasks require Flow model version 6.");if(e.modelVersion<5&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="error"))throw TypeError("Error workflows require Flow model version 5.")}var of=x({mode:ce(["chat","json"]),resultSchema:Me(),model:Me().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),template:Me().optional().describe('Default message templates: [{role: "system" | "user" | "assistant", content: "Text with {{namedInput}}"}].'),messages:Me().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")});var zb=Y([x({schemes:P(A().min(1)).describe("One complete security alternative advertised by this operation; [] selects no authentication.")}),x({type:ce(["bearer","basic"])}),x({type:k("apiKey"),name:A().min(1),in:ce(["header","query"])})]),sf=x({sourceUrl:A().min(1),path:A().min(1),method:A().min(1),serverUrl:A().optional(),authentication:zb.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")});var T=A().min(1),We=Me(),As=oe(T,We),ao=["manual","webhook","cron","error","poll","integration","code","connector","agent","llm","decision","openapi","condition","value","wait","approval"],js=ce(ao),vn=T.describe('An existing node reference returned by read/search, or $alias for a preceding node.add in this edit batch. For node.add.as "step", reference "$step", never bare "step". Aliases are local to one batch.'),Cs=x({kind:k("output"),node:vn,port:T.optional().describe("Omit for a node with one output. For multiple outputs, choose a name from node details."),field:A().optional()}),Os=x({kind:k("variable"),name:T}),af=Y([Cs,Os,x({kind:k("value"),value:We}),x({kind:k("unset")}),x({kind:k("default")}),x({kind:k("sources"),sources:P(Y([Cs,Os])).min(1)})]),cf=Y([x({kind:k("value"),value:We.optional(),schema:We.optional()}),Cs,Os]),Db=Ue.agent.shape.tools.element.omit({id:!0,inputs:!0}).extend({inputs:oe(T,Ue.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.")}).strict(),Vb=x({...Ue.connector.shape,messageHandle:T,inputs:oe(T,Y([x({kind:k("value"),value:We}),x({kind:k("input"),input:T})]))}),pf=x({schema:We.optional(),nullable:ye().optional(),description:A().optional()}),Xn=oe(T,pf.extend({default:We.optional()})).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data."),uf=oe(T,pf).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true."),Rs=x({left:cf,operator:Ue.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,right:cf.optional()}),lf=x({all:P(Rs)}),Zb=Y([Rs,lf,x({any:P(Y([Rs,lf]))})]),on={manual:x({}),error:x({sourceFlowIds:P(T).optional()}),webhook:Ue.webhook.omit({bodyFields:!0}).extend({body:Xn}).strict(),cron:x({schedule:Ue.schedule}),poll:x({key:T,connectionId:T.optional(),schedule:Ue.schedule}),integration:x({key:T,connectionId:T.optional()}),code:x({inputs:Xn,outputs:uf,capabilities:Ue.capabilities.optional()}),connector:Ue.connector.omit({outputMode:!0}).strict(),openapi:sf,agent:Ue.agent.omit({prompt:!0,tools:!0}).extend({inputs:Xn,resultSchema:We.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),tools:P(Db),notification:Vb.optional()}).strict(),llm:of.extend({inputs:Xn}),decision:Ue.decision,condition:x({match:ce(["first","all"]),branches:P(x({name:T,description:A().optional(),when:Zb}))}),value:x({values:As,outputs:uf}),wait:x({inputs:Xn}),approval:x({inputs:Xn})},Fb={name:T.optional(),description:A().optional(),icon:A().optional(),maxExecutions:he().positive().optional(),timeoutMs:fe().nonnegative().optional()},Mb=x({...Fb,config:As.optional().describe('Recursively merge configuration; omitted fields remain unchanged and arrays replace as a whole. This includes schema objects: {} does not clear an existing schema. Use clear paths to remove fields, e.g. ["config","inputs","amount","schema","type"].')}),Jb=Ln("op",[x({op:k("node.add"),as:T.regex(/^[A-Za-z][\w-]*$/).describe("Unique batch-local alias without the $ prefix. Later edits must reference this new node as $alias; the bare alias is not its node ID."),type:js,name:T,config:As.optional(),inputs:oe(T,af).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),code:A().optional(),prompt:A().optional()}),x({op:k("node.update"),node:vn,set:Mb.optional(),clear:P(P(T).min(1)).optional()}),x({op:k("node.remove"),node:vn}),x({op:k("input.set"),node:vn,input:T,source:af}),x({op:ce(["edge.connect","edge.disconnect"]),source:vn,target:vn,branch:T.optional()}),x({op:k("text.edit"),node:vn,field:ce(["code","prompt"]),oldText:T,newText:A()}),x({op:k("text.set"),node:vn,field:ce(["code","prompt"]),text:A()})]),Yt=x({baseRevision:T,requestId:T.max(256),edits:P(Jb).min(1).max(1000)}),co=x({revision:T.optional().describe("Fixed revision from a previous read; omit to read the current draft."),nodes:P(T).min(1).max(100).optional().describe("Node references to read in one batch. Mutually exclusive with text. Long texts return metadata."),text:x({node:T,field:ce(["code","prompt"]),start:he().positive().default(1),lines:he().min(1).max(200).default(80)}).optional().describe("Read code or prompt by line (1-based). Mutually exclusive with nodes. Follow nextStart at the same revision until truncated is false.")}).refine((e)=>e.nodes==null||e.text==null,"Choose nodes or text.").meta({not:{required:["nodes","text"]},description:"Omit nodes and text for an outline; provide nodes for details, or text for an excerpt."}),Ps=x({revisionId:T}),uo=x({revision:T.optional(),query:T.max(1000),type:js.optional(),offset:he().nonnegative().default(0),limit:he().min(1).max(100).default(20)}),ff=x({type:js.optional(),action:T.optional()}).refine((e)=>e.type==null||e.action==null,"Choose type or action."),df={read:{schema:co,guidance:"Choose one mode: outline (omit nodes and text), node details (nodes), or text excerpt (text). nodes and text are mutually exclusive. Text defaults to 80 lines, at most 200 lines and 24000 characters. For the complete text, repeat at nextStart with the same revision until truncated is false.",examples:[{},{revision:"REVISION",nodes:["NODE"]},{revision:"REVISION",text:{node:"NODE",field:"prompt",start:1,lines:80}}]},search:{schema:uo,guidance:"Search names, configurations and text. Keep the returned revision when following nextOffset or reading a match.",examples:[{query:"Customer summary",type:"agent"}]},edit:{schema:Yt,guidance:"Use the observed revision as baseRevision and a stable requestId. Edits are ordered and atomic. node.add.as declares a batch-local alias without $. Every later reference to that new node must use $alias, including node, edge source/target and output source node fields; a bare alias is not the node ID. Use returned node references in later batches. Updates recursively merge objects (including schemas); {} preserves existing fields. Arrays replace as a whole. Remove fields with clear paths. Text replacement requires exactly one match. Read the target text first. A saved draft can have validation diagnostics.",examples:[{baseRevision:"REVISION",requestId:"CREATE_REQUEST",edits:[{op:"node.add",as:"start",type:"manual",name:"Start"},{op:"node.add",as:"step",type:"code",name:"Process",code:"export default ({value}) => ({result:value})"},{op:"edge.connect",source:"$start",target:"$step"},{op:"node.update",node:"$step",set:{description:"Created and connected in one atomic edit."}}]},{baseRevision:"REVISION",requestId:"REQUEST",edits:[{op:"text.edit",node:"NODE",field:"prompt",oldText:"Original rule.",newText:"Updated rule."}]}]},check:{schema:Ps,guidance:"Check a fixed revision. In the CLI, pass this identity with --revision REVISION.",examples:[{revisionId:"REVISION"}]}};function _s(e){if(!Object.hasOwn(df,e))return;let n=df[e];return{request:Fr(n.schema,{io:"input"}),guidance:n.guidance,examples:n.examples}}function $s(e){return e==null?{types:ao,request:Fr(Yt),guidance:"Read a node type schema before creating or configuring it. Use $alias to reference a preceding node.add in the same batch. Read returns stable node references. Long code and prompt fields use text reads and edits. Changes use the observed baseRevision and a stable requestId."}:{type:e,inputSources:["poll","integration"].includes(e)?["value","unset","default"]:["manual","error","cron","webhook","value","condition"].includes(e)?[]:["value","unset","default","output","variable","sources"],extensibleInputs:["code","agent","llm","wait","approval"].includes(e),guidance:e=="condition"?"Edit branch operands through config.branches. A branch can test one expression, all expressions, or any alternatives. Unmatched execution uses branch otherwise.":["poll","integration"].includes(e)?"Configure static parameters with node.add.inputs or input.set. Definitions come from the selected Trigger key; execution output and variable sources are unavailable.":e=="llm"?"Configure model settings, message templates and history as defaults. Input bindings with the same names override these defaults; named business inputs can be bound directly. Template strings interpolate {{name}}.":e=="openapi"?"Select an operation; the tool resolves its ports and authentication. Read authenticationChoices from node details. authentication is replaced as a complete choice. Bind advertised credentials through inputs.":"Supply business configuration and input data. Fixed definitions are assembled by the tool. Existing constraints and defaults are preserved on partial updates.",example:{op:"node.add",as:"step",type:e,name:"Step",...{connector:{config:{action:"<Action ID>",connectionId:"<Connection ID>"}},poll:{config:{key:"<Trigger key>",schedule:[{type:"every",unit:"minute",value:5}]}},integration:{config:{key:"<Trigger key>"}},openapi:{config:{sourceUrl:"https://example.com/openapi.json",path:"/items",method:"get"}},code:{code:"export default ({value}) => ({result:value})",inputs:{value:{kind:"value",value:"Hello"}}},condition:{config:{match:"first",branches:[{name:"yes",when:{left:{kind:"value",value:120},operator:">",right:{kind:"value",value:100}}}]}},value:{config:{values:{threshold:100,region:"EU"}}},webhook:{config:{method:"POST",body:{orderId:{schema:{type:"string"},nullable:!1}}}},wait:{prompt:"Continue processing this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},approval:{prompt:"Approve this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},llm:{config:{model:{model:"deepseek-v4-flash"},template:[{role:"user",content:"Summarize {{order}}."}]},inputs:{order:{kind:"value",value:{orderId:"A-1",total:42}}}},agent:{config:{model:"deepseek-v4-flash"},inputs:{orders:{kind:"value",value:[{orderId:"A-1",total:42}]}},prompt:"Summarize {{orders}}."}}[e]},configuration:Fr(on[e].partial()),texts:e=="code"?["code"]:["agent","wait","approval"].includes(e)?["prompt"]:[]}}var mf=j({code:T,message:A(),nodes:P(T),field:A().optional(),line:fe().optional(),column:fe().optional()}),gf=j({flowId:T,revisionId:T,valid:ye(),diagnostics:P(mf),version:k(1)}),hf=j({flowId:T,saved:k(!0),revision:T,nodes:oe(T,T),changes:P(j({index:he(),op:T,node:T.optional()})),validation:j({status:ce(["valid","invalid","unavailable"]),diagnostics:P(mf).optional()}),version:k(1)}),yf=j({flowId:T,revision:T,data:j({nodes:P(oe(A(),We)).optional(),edges:P(We).optional(),text:oe(A(),We).optional()}),version:k(1)}),bf=j({flowId:T,revision:T,data:j({matches:P(j({node:T,field:T,line:he().optional(),excerpt:A()})),total:he(),nextOffset:he().optional()}),version:k(1)});var z={authenticationRequired:"authentication.required",authorizationDenied:"authorization.denied",bindingUnresolved:"binding.unresolved",connectorActionNotFound:"connector.action-not-found",connectorAccessConflict:"connector.access-conflict",connectorAccessInvalid:"connector.access-invalid",connectorAccessRequired:"connector.access-required",connectorAccessUnsupported:"connector.access-unsupported",connectorUnconfigured:"connector.unconfigured",connectorUnavailable:"connector.unavailable",connectorConsoleUnconfigured:"connector.console-unconfigured",engineUnavailable:"engine.unavailable",engineUnsupported:"engine.unsupported",eventSourceInvalid:"event-source.invalid",eventSourceIdentityUnavailable:"event-source.identity-unavailable",eventSourceNotFound:"event-source.not-found",eventSourceConflict:"event-source.conflict",flowInvalid:"flow.invalid",flowRepairRequired:"flow.repair-required",flowUpgradeRequired:"flow.upgrade-required",flowNotFound:"flow.not-found",flowBusy:"flow.busy",flowConflict:"flow.conflict",flowPresentationConflict:"flow.presentation-conflict",flowRevisionConflict:"flow.revision-conflict",liveConflict:"live.conflict",liveNotFound:"live.not-found",pageInvalidCursor:"page.invalid-cursor",publicationConflict:"publication.conflict",publicationNotFound:"publication.not-found",publicationUnsupported:"publication.unsupported",publishOperationNotFound:"publication.operation-not-found",routeNotFound:"route.not-found",runConflict:"run.conflict",runEventsExpired:"run.events-expired",runInvalid:"run.invalid",runNotFound:"run.not-found",runNotTerminal:"run.not-terminal",runOverloaded:"run.overloaded",runWaitNotFound:"run.wait-not-found",triggerKeyInvalid:"trigger-key.invalid",triggerKeyNotFound:"trigger-key.not-found",triggerNotFound:"trigger.not-found",variableInvalid:"variable.invalid",variableLimitReached:"variable.limit-reached",variableNotFound:"variable.not-found"},qb={[z.eventSourceInvalid]:{status:400},[z.eventSourceIdentityUnavailable]:{status:409},[z.eventSourceNotFound]:{status:404},[z.eventSourceConflict]:{status:409},[z.authenticationRequired]:{status:401},[z.authorizationDenied]:{status:403},[z.bindingUnresolved]:{status:409},[z.connectorActionNotFound]:{status:404},[z.connectorAccessConflict]:{status:412},[z.connectorAccessInvalid]:{status:409},[z.connectorAccessRequired]:{status:409},[z.connectorAccessUnsupported]:{status:409},[z.connectorUnconfigured]:{status:503},[z.connectorUnavailable]:{status:503},[z.connectorConsoleUnconfigured]:{status:503},[z.engineUnavailable]:{status:503},[z.engineUnsupported]:{status:409},[z.flowInvalid]:{status:400},[z.flowRepairRequired]:{status:409},[z.flowUpgradeRequired]:{status:409},[z.flowNotFound]:{status:404},[z.flowBusy]:{status:409},[z.flowConflict]:{status:409},[z.flowPresentationConflict]:{status:412},[z.flowRevisionConflict]:{status:412},[z.liveConflict]:{status:412},[z.liveNotFound]:{status:404},[z.pageInvalidCursor]:{status:400},[z.publicationConflict]:{status:409},[z.publicationNotFound]:{status:404},[z.publicationUnsupported]:{status:409},[z.publishOperationNotFound]:{status:404},[z.routeNotFound]:{status:404},[z.runConflict]:{status:409},[z.runEventsExpired]:{status:410},[z.runInvalid]:{status:400},[z.runNotFound]:{status:404},[z.runNotTerminal]:{status:409},[z.runOverloaded]:{status:429},[z.runWaitNotFound]:{status:404},[z.triggerKeyInvalid]:{status:409},[z.triggerKeyNotFound]:{status:404},[z.triggerNotFound]:{status:404},[z.variableInvalid]:{status:400},[z.variableLimitReached]:{status:409},[z.variableNotFound]:{status:404}};class Ee extends Error{constructor(e,n,t,r){super(t);this.code=n,this.details=r,this.name="ApiError",this.status=e}}class wf extends Ee{constructor(e){super(502,"response.invalid",`The Control API returned an invalid response.${e==null?"":` ${e}`}`);this.detail=e}}function p(e){throw new wf(e)}function w(e){if(e==null||typeof e!="object"||Array.isArray(e))return p("Expected an object.");return e}function f(e){return typeof e=="string"&&e.length>0?e:p("Expected a non-empty string.")}function D(e,n){let t=Object.keys(e);if(t.length!=n.length||t.some((r)=>!n.includes(r))){let r=n.filter((i)=>!Object.hasOwn(e,i)),o=t.filter((i)=>!n.includes(i));p([r.length>0?`Missing fields: ${r.join(", ")}.`:"",o.length>0?`Unexpected fields: ${o.join(", ")}.`:""].filter(Boolean).join(" "))}}function ie(e){return Number.isSafeInteger(e)?e:p("Expected a safe integer.")}function me(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map(me);let n=w(e);return Object.fromEntries(Object.entries(n).map(([t,r])=>[t,me(r)]))}function lo(e){if(e==null)return;return f(e)}function et(e){let n=w(e),t=n.liveEnd==null?void 0:w(n.liveEnd);if(t!=null&&typeof t.enabled!="boolean")return p();let{operation:r,sourcePublicationId:o}=n;if(n.version!=1)return p();if(r!="publish"&&r!="rollback")return p();if(o!=null&&typeof o!="string")return p();return{...t==null?{}:{liveEnd:{enabled:t.enabled,endedAt:f(t.endedAt)}},actorId:f(n.actorId),closureDigest:f(n.closureDigest),createdAt:f(n.createdAt),engineContract:f(n.engineContract),flowId:f(n.flowId),modelVersion:ie(n.modelVersion),operation:r,publicationId:f(n.publicationId),sharedAccessDigest:f(n.sharedAccessDigest),revisionDigest:f(n.revisionDigest),revisionId:f(n.revisionId),...o==null?{}:{sourcePublicationId:o},version:1}}function Ns(e){let n=w(e),t=n.status,r={createdAt:f(n.createdAt),flowId:f(n.flowId),operationId:f(n.operationId),revisionId:f(n.revisionId),updatedAt:f(n.updatedAt),version:1};if(n.version!=1)return p();switch(t){case"pending":return D(n,["createdAt","flowId","operationId","revisionId","status","updatedAt","version"]),{...r,status:t};case"succeeded":return D(n,["createdAt","flowId","operationId","publicationId","revisionId","status","updatedAt","version"]),{...r,publicationId:f(n.publicationId),status:t};case"failed":{D(n,["createdAt","flowId","issue","operationId","revisionId","status","updatedAt","version"]);let o=w(n.issue),i=o.nodeId;return D(o,["code","message",...i==null?[]:["nodeId"]]),{...r,issue:{code:f(o.code),message:f(o.message),...i==null?{}:{nodeId:f(i)}},status:t}}default:return p()}}function Ts(e){let n=w(e),{status:t,publication:r}=n;if(n.version!=1||typeof n.hasUnpublishedChanges!="boolean")return p();if(t!="not-published"&&t!="runnable"&&t!="suspended")return p();if(t=="not-published"&&r!==null)return p();if(t!="not-published"&&r===null)return p();return{flowId:f(n.flowId),hasUnpublishedChanges:n.hasUnpublishedChanges,publication:r===null?null:et(r),revision:ie(n.revision),status:t,version:1}}function xf(e){let n=w(e),{nextCursor:t,total:r}=n;if(n.version!=1||!Array.isArray(n.publications))return p();if(t!=null&&typeof t!="string")return p();if(r!=null&&!Number.isSafeInteger(r))return p();return{...t==null?{}:{nextCursor:t},publications:n.publications.map(et),...r==null?{}:{total:r},version:1}}var vf=P(Y([x({handle:A().min(1),description:A().optional(),jsonSchema:Me(),nullable:ye(),value:Me().optional()}),x({group:A(),collapsed:ye().optional()})]));function zs(e){let n=w(e),t=n.type;if(t!="integration"&&t!="poll")return p();return{description:typeof n.description=="string"?n.description:p(),displayName:f(n.displayName),key:f(n.key),name:f(n.name),provider:f(n.provider),type:t}}function Xt(e){let n=w(e),t=zs(n),r={configInputs:vf.parse(n.configInputs),definitionVersion:n.definitionVersion===2?2:p(),description:t.description,displayName:t.displayName,key:t.key,name:t.name,outputs:(Array.isArray(n.outputs)?n.outputs:p()).map((u)=>{let l=w(u);return Object.assign({handle:f(l.handle),jsonSchema:me(l.jsonSchema),nullable:typeof l.nullable==="boolean"?l.nullable:p()},l.description==null?{}:{description:f(l.description)})}),provider:t.provider};if(t.type=="poll")return{...r,type:"poll"};let o=w(n.endpoint),i=w(o.body);if(!Array.isArray(o.methods)||!Array.isArray(i.formats)||typeof i.allowArray!="boolean"||typeof i.allowEmpty!="boolean")return p();let s=o.methods.map(f),a=i.formats.map(f),c=ie(o.successStatus);if(s.some((u)=>!["DELETE","GET","HEAD","PATCH","POST","PUT"].includes(u))||a.some((u)=>!["form","json","multipart","text"].includes(u))||c<200||c>299)return p();return{...r,endpoint:{body:{allowArray:i.allowArray,allowEmpty:i.allowEmpty,formats:a},methods:s,successStatus:c},type:"integration"}}var Ub=new Set(["error","cron","integration","poll","webhook"]),Kb=new Set(["failed","healthy","initializing","needs_reauth","suspended"]),Bb=new Set(["delivery.failed","health.failed","health.needs_reauth","health.recovered","health.suspended","operator.paused","operator.resumed"]);function er(e){let n=w(e),t=n.health,r=n.listener==null?void 0:w(n.listener);if(r!=null&&r.health!="healthy"&&r.health!="failed"&&r.health!="needs_reauth")return p();let o=n.kind,i=ie(n.runtimeVersion);if(n.version!=1||typeof t!="string"||!Kb.has(t))return p();if(typeof o!="string"||!Ub.has(o))return p();if(i<=0)return p();return{...n.currentPublicationId==null?{}:{currentPublicationId:f(n.currentPublicationId)},...n.currentRevisionId==null?{}:{currentRevisionId:f(n.currentRevisionId)},...n.endpointUrl==null?{}:{endpointUrl:f(n.endpointUrl)},...r==null?{}:{listener:{health:r.health,...r.lastErrorCode==null?{}:{lastErrorCode:f(r.lastErrorCode)}}},flowId:f(n.flowId),health:t,kind:o,...n.lastErrorCode==null?{}:{lastErrorCode:f(n.lastErrorCode)},runtimeVersion:i,triggerNodeId:f(n.triggerNodeId),updatedAt:f(n.updatedAt),version:1}}function kf(e){let n=w(e);if(n.version!=1)return p();return{binding:er(n.binding),version:1}}function Wb(e){let n=w(e),t=n.kind;if(typeof t!="string"||!Bb.has(t))return p();let r=lo(n.errorCode),o=lo(n.errorMessage);if(o!=null&&o.length>512)return p();return{activityId:f(n.activityId),createdAt:f(n.createdAt),...r==null?{}:{errorCode:r},...o==null?{}:{errorMessage:o},kind:t}}function Sf(e){let n=w(e),t=lo(n.nextCursor);if(n.version!=1||!Array.isArray(n.activities))return p();return{activities:n.activities.map(Wb),...t==null?{}:{nextCursor:t},version:1}}function If(e){let n=w(e),t=ie(n.filtered);if(n.version!=1||!Array.isArray(n.events)||typeof n.hasMore!="boolean"||t<0)return p();return{events:n.events.map((r)=>{let o=w(r);return Object.fromEntries(Object.entries(o).map(([i,s])=>[i,me(s)]))}),filtered:t,hasMore:n.hasMore,version:1}}var nt={nodeId:A().min(1),name:A(),description:A().optional()},nr=Jn().transform(er),Ef={provider:A().min(1),inputs:oe(A(),Ln("kind",[x({kind:k("value"),value:Me()}),x({kind:k("unset")})]))},Hb=Ln("type",[x({...nt,type:k("manual"),config:on.manual}),x({...nt,type:k("webhook"),config:on.webhook,binding:nr}),x({...nt,type:k("cron"),config:on.cron,binding:nr}),x({...nt,type:k("error"),config:on.error,binding:nr}),x({...nt,...Ef,type:k("poll"),config:on.poll,binding:nr}),x({...nt,...Ef,type:k("integration"),config:on.integration,binding:nr})]);function Cf(e){let n=w(e),t=f(n.flowId);if(n.version!=1||!Array.isArray(n.entries))return p();if(n.publication===null){if(n.status!="not-published"||n.entries.length!=0||Object.hasOwn(n,"enabled"))return p();return{flowId:t,publication:null,status:"not-published",entries:[],version:1}}let r=et(n.publication),o=n.status;if(r.flowId!=t||typeof n.enabled!="boolean")return p();if(o!="runnable"&&o!="suspended")return p();if(!n.enabled&&n.status=="runnable")return p();return{flowId:t,publication:r,status:o,enabled:n.enabled,entries:Qb(n.entries,r),version:1}}function Qb(e,n){let t=P(Hb).safeParse(e);if(!t.success)return p();let r=new Set;for(let o of t.data){if(r.has(o.nodeId))return p();if(r.add(o.nodeId),o.type!="manual"&&(o.binding.flowId!=n.flowId||o.binding.triggerNodeId!=o.nodeId||o.binding.kind!=o.type||o.binding.currentPublicationId!=n.publicationId||o.binding.currentRevisionId!=n.revisionId))return p();if(o.type=="webhook"&&(!o.binding.endpointUrl||!Ur(o.config.method)&&Object.keys(o.config.body).length>0))return p()}return t.data}function po(e,n){if(!e||typeof e!="object"||!n||typeof n!="object")return{};let t=e,r=n;if(typeof t.version!="string"||![t.pixelRatio,t.iconSize,t.width,t.height].every((o)=>Number.isInteger(o)&&o>0)||![t.bleed,r.x,r.y].every((o)=>Number.isInteger(o)&&o>=0)||r.x+t.iconSize>t.width||r.y+t.iconSize>t.height)return{};try{for(let o of[t.lightUrl,t.darkUrl])if(typeof o!="string"||!["https:","http:","data:"].includes(new URL(o).protocol))return{}}catch{return{}}return{iconSprite:t,iconSpritePosition:{x:r.x,y:r.y}}}function Of(e,n){let t=e=="feishu_app_bot.on_event"?["sourceId","eventTypes","resource","chatIds"]:e=="linear.on_issue_changed"?["teamId","stateIds"]:[];return{...n,...Object.fromEntries(t.map((r)=>[r,{kind:"unset"}]))}}function Rf(e,n){return{...e,nodes:Object.fromEntries(Object.entries(e.nodes).map(([t,r])=>{if((r.kind=="poll"||r.kind=="integration")&&(n==null||r.connectionId==n)){let{connectionId:i,...s}=r;return[t,s]}if(r.kind!="task")return[t,r];if("executor"in r.task){let i=r.task.executor,s=(a)=>{if(n!=null&&a.connectionId!=n)return a;let{connectionId:c,...u}=a;return u};if(i.kind=="connector")return[t,{...r,task:{...r.task,executor:s(i)}}];if(i.kind=="agent")return[t,{...r,task:{...r.task,executor:{...i,tools:i.tools.map(s),...i.notification==null?{}:{notification:s(i.notification)}}}}];return[t,r]}let o=r.task.capabilities?.map((i)=>{if(!("mode"in i)){if("action"in i){let{connectionId:s,...a}=i;return{...a,connections:i.connections.filter((c)=>n!=null&&c.connectionId!=n),...s!=null&&n!=null&&s!=n?{connectionId:s}:{}}}return{...i,...n==null&&(i.connectionHints?.length??0)>0?{actionHints:[...new Set([...i.actionHints??[],...i.connectionHints.map((s)=>s.action)])]}:{},...i.connectionHints==null?{}:{connectionHints:i.connectionHints.filter((s)=>n!=null&&s.connectionId!=n)}}}if(i.mode!="independent")return i;return{...i,actions:i.actions.map((s)=>{if(n!=null&&s.connectionId!=n)return s;let{connectionId:a,...c}=s;return c})}});return[t,o==null?r:{...r,task:{...r.task,capabilities:o}}]}))}}var Yb=x({kind:k("open-flow-workflow"),version:k(1),name:A().optional(),content:Jn(),presentation:oe(A(),Me()).optional()});function fo(e){jn(e,-1);let n=Yb.parse(e);return{...n,content:Qt(n.content)}}function Af(e){return fo(JSON.parse(e))}function Xb(e){if(e.kind!="sources"||!e.sources.some((t)=>t.kind=="binding"))return e;let n=e.sources.filter((t)=>t.kind!="binding");return n.length==0?{kind:"unset"}:{kind:"sources",sources:n}}function ew(e){let n=fo(e),t=n.content.document.graph,r=Rf(t),o=Object.fromEntries(Object.entries(r.nodes).map(([i,s])=>{let a=s;if("inputs"in a)a={...a,inputs:Object.fromEntries(Object.entries(a.inputs).map(([c,u])=>[c,Xb(u)]))};if(a.kind=="condition")a=Hd(a);if(a.kind=="error"&&a.sourceFlowIds!=null)a={...a,sourceFlowIds:[]};if(a.kind=="poll"||a.kind=="integration")a={...a,config:Of(a.definition.key,a.config)};return[i,a]}));return{file:{...n,content:{...n.content,document:{...n.content.document,bindings:{},graph:{...r,nodes:o}}}},summary:{changedNodeIds:Object.keys(o).filter((i)=>!Oe(o[i],t.nodes[i])),removedBindings:Object.keys(n.content.document.bindings).length}}}function jf(e){return`${JSON.stringify(ew(e).file,null,2)}
59
+ `}function Pf(e){return e.replace(/(?:\.openflow)?\.json$/i,"")}var nw=Ln("kind",[x({kind:k("admin-delegation")}),x({kind:k("policy"),ruleId:A().min(1).nullable()})]);function mo(e){return nw.parse(e)}function tw(e){let n=w(e);if(D(n,["actionIds","allActions","triggerIds","allTriggers","configured","proxy"]),!Array.isArray(n.actionIds))return p("permissions.actionIds: expected an array.");if(!Array.isArray(n.triggerIds))return p("permissions.triggerIds: expected an array.");if(typeof n.allActions!="boolean")return p("permissions.allActions: expected a boolean.");if(typeof n.allTriggers!="boolean")return p("permissions.allTriggers: expected a boolean.");if(typeof n.configured!="boolean")return p("permissions.configured: expected a boolean.");if(typeof n.proxy!="boolean")return p("permissions.proxy: expected a boolean.");let t=n.actionIds.map(f),r=n.triggerIds.map(f);if(new Set(t).size!=t.length)return p("permissions.actionIds: duplicate IDs.");if(n.allActions&&t.length!=0)return p("permissions.actionIds: must be empty when allActions is true.");if(new Set(r).size!=r.length)return p("permissions.triggerIds: duplicate IDs.");if(n.allTriggers&&r.length!=0)return p("permissions.triggerIds: must be empty when allTriggers is true.");if(n.proxy&&(!n.allActions||!n.allTriggers||n.configured))return p("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");return{actionIds:t,triggerIds:r,allTriggers:n.allTriggers,allActions:n.allActions,configured:n.configured,proxy:n.proxy}}function Nf(e,n){let t=w(e),{policyRevision:r,status:o,isDefault:i}=t,s=Object.hasOwn(t,"displayName")&&!Object.hasOwn(t,"connectionDisplayName"),a=n&&Object.hasOwn(t,"permissions")?tw(t.permissions):void 0,c=t.permissionGroupName;if(D(t,["accessBindingId","connectionId","source",s?"displayName":"connectionDisplayName",...n&&Object.hasOwn(t,"isDefault")?["isDefault"]:[],...n&&a!=null?["permissions"]:[],...Object.hasOwn(t,"permissionGroupName")?["permissionGroupName"]:[],...r==null?[]:["policyRevision"],"providerId",...n?[]:["status"]]),r!=null&&typeof r!="string")return p("policyRevision: expected a string.");if(n&&i!==void 0&&typeof i!="boolean")return p("isDefault: expected a boolean.");if(c!==void 0&&c!==null&&typeof c!="string")return p("permissionGroupName: expected a string or null.");if(!n&&o!="active"&&o!="forbidden"&&o!="invalid"&&o!="missing")return p();let u;try{u=mo(t.source)}catch{return p("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.")}return{accessBindingId:f(t.accessBindingId),connectionId:f(t.connectionId),source:u,connectionDisplayName:f(s?t.displayName:t.connectionDisplayName),...n&&typeof i=="boolean"?{isDefault:i}:{},...a==null?{}:{permissions:a},...c===void 0?{}:{permissionGroupName:c},...r==null?{}:{policyRevision:r},providerId:f(t.providerId),...n?{}:{status:o}}}function Ds(e){if(e!="implicit"&&e!="selectable")return p("mode: expected implicit or selectable.");return e}function tt(e){let n=w(e);D(n,["accessRevision","bindings","mode","sharedAccessDigest",..."providerIds"in n?["providerIds"]:[],..."discardedBindingCount"in n?["discardedBindingCount"]:[],"version"]);let t=ie(n.accessRevision);if(n.version!=1||t<0||!Array.isArray(n.bindings))return p();if("providerIds"in n&&!Array.isArray(n.providerIds))return p();let r=n.providerIds==null?void 0:n.providerIds.map((s)=>f(s));if(r!=null&&new Set(r).size!=r.length)return p();let o=n.discardedBindingCount==null?0:ie(n.discardedBindingCount);if(o<0)return p();let i=[];for(let s of n.bindings)try{i.push(Nf(s,!1))}catch(a){if(!(a instanceof Ee)||a.code!="response.invalid")throw a;if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.accessBindingId=="string"&&s.accessBindingId.length>0&&typeof s.providerId=="string"&&s.providerId.length>0)i.push({accessBindingId:s.accessBindingId,providerId:s.providerId,connectionId:null,source:null,status:"invalid",connectionDisplayName:typeof s.connectionDisplayName=="string"&&s.connectionDisplayName.length>0?s.connectionDisplayName:typeof s.displayName=="string"&&s.displayName.length>0?s.displayName:s.providerId,permissionGroupName:typeof s.permissionGroupName=="string"?s.permissionGroupName:null});else o++}if(new Set(i.map((s)=>s.accessBindingId)).size!=i.length)return p();return{accessRevision:t,...o==0?{}:{discardedBindingCount:o},...r==null?{}:{providerIds:r},bindings:i,mode:Ds(n.mode),sharedAccessDigest:f(n.sharedAccessDigest),version:1}}function _f(e){if(!Array.isArray(e))return p();let n=e.map((t)=>{let r=w(t);D(r,["accessBindingId","connectionId","providerId","source","connectionDisplayName",..."permissionGroupName"in r?["permissionGroupName"]:[]]);let o;try{o=mo(r.source)}catch{return p()}if(r.permissionGroupName!=null&&typeof r.permissionGroupName!="string")return p();return{accessBindingId:f(r.accessBindingId),connectionId:f(r.connectionId),providerId:f(r.providerId),source:o,connectionDisplayName:f(r.connectionDisplayName),..."permissionGroupName"in r?{permissionGroupName:r.permissionGroupName}:{}}});if(new Set(n.map((t)=>t.accessBindingId)).size!=n.length)return p();return n}function Vs(e){let n=w(e);if(D(n,["mode","sharedAccessDigest","sharedBindings","selectedBindings","version"]),n.version!=2)return p();let t=Ds(n.mode),r=_f(n.sharedBindings),o=_f(n.selectedBindings);if(t=="implicit"&&(r.length>0||o.length>0))return p();return{mode:t,sharedAccessDigest:f(n.sharedAccessDigest),sharedBindings:r,selectedBindings:o,version:2}}function rw(e,n){let t=w(e);if(D(t,["candidates","mode","providerId","version"]),t.version!=1)return p("version: expected 1.");if(f(t.providerId)!=n)return p("providerId: does not match the requested provider.");if(!Array.isArray(t.candidates))return p("candidates: expected an array.");let r=t.candidates.map((o)=>Nf(o,!0));if(r.some((o)=>o.providerId!=n))return p("candidates[].providerId: does not match the requested provider.");if(new Set(r.map((o)=>o.accessBindingId)).size!=r.length)return p("candidates[].accessBindingId: duplicate IDs.");return{candidates:r,mode:Ds(t.mode),providerId:n,version:1}}function Tf(e,n){let t=w(e);if(D(t,["results","version"]),t.version!=1)return p("version: expected 1.");if(!Array.isArray(t.results))return p("results: expected an array.");let r=new Set(n),o=t.results.map((i)=>{let s=w(i),a=f(s.providerId);if(!r.delete(a))return p("results[].providerId: duplicate or unrequested provider.");if(!Object.hasOwn(s,"error"))return rw(s,a);D(s,["providerId","error"]);let c=w(s.error);return D(c,["code","message"]),{providerId:a,error:{code:f(c.code),message:f(c.message)}}});if(r.size!=0)return p("results: missing requested providers.");return{results:o,version:1}}function rt(e){let n=w(e);if(D(n,[...Object.hasOwn(n,"providerAccountId")?["providerAccountId"]:[],...Object.hasOwn(n,"alias")?["alias"]:[],...Object.hasOwn(n,"builtInAccount")?["builtInAccount"]:[],"connectionId","displayName","isDefault","serviceId","status"]),n.builtInAccount!==void 0&&typeof n.builtInAccount!="boolean")return p();let t=n.status;if(t!="active"&&t!="disconnected"&&t!="error"&&t!="reauth_required")return p();if(typeof n.isDefault!="boolean")return p();return{...n.providerAccountId===void 0?{}:{providerAccountId:f(n.providerAccountId)},...n.alias===void 0?{}:{alias:f(n.alias)},...n.builtInAccount===void 0?{}:{builtInAccount:n.builtInAccount},connectionId:f(n.connectionId),displayName:f(n.displayName),isDefault:n.isDefault,serviceId:f(n.serviceId),status:t}}function zf(e,n=!1){let t=w(e),r=t.description,o=n&&Object.hasOwn(t,"value");if(D(t,["jsonSchema","nullable",...r==null?[]:["description"],...o?["value"]:[]]),r!=null&&typeof r!="string")return p();if(typeof t.nullable!="boolean")return p();return{...r==null?{}:{description:r},jsonSchema:me(t.jsonSchema),nullable:t.nullable,...o?{value:me(t.value)}:{}}}function ow(e){return zf(e,!0)}function $f(e,n){return Object.fromEntries(Object.entries(w(e)).map(([t,r])=>[t,n(r)]))}function iw(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(D(n,["actionId",...Object.hasOwn(n,"operationType")?["operationType"]:[],...Object.hasOwn(n,"inputSchema")?["inputSchema"]:[],...Object.hasOwn(n,"outputSchema")?["outputSchema"]:[],"authenticated","description",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[],"inputs","name","outputs","serviceId","serviceName"]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return p();return{...n.inputSchema===void 0?{}:{inputSchema:me(n.inputSchema)},...n.outputSchema===void 0?{}:{outputSchema:me(n.outputSchema)},actionId:f(n.actionId),...n.operationType==null?{}:{operationType:f(n.operationType)},authenticated:typeof n.authenticated=="boolean"?n.authenticated:p(),description:typeof n.description=="string"?n.description:p(),...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...po(n.iconSprite,n.iconSpritePosition),inputs:$f(n.inputs,ow),name:f(n.name),outputs:$f(n.outputs,zf),serviceId:f(n.serviceId),serviceName:f(n.serviceName)}}function go(e){let{defaultConnection:n,...t}=w(e),r=iw(t);if(n==null)return r;let o=rt(n);if(o.serviceId!=r.serviceId||o.status!="active")return p();return{...r,defaultConnection:o}}function Df(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(n.noSetup!==void 0&&typeof n.noSetup!="boolean")return p();if(D(n,[...Object.hasOwn(n,"noSetup")?["noSetup"]:[],"serviceId","serviceName",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[]]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return p();return{...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...po(n.iconSprite,n.iconSpritePosition),serviceId:f(n.serviceId),serviceName:f(n.serviceName),...n.noSetup===void 0?{}:{noSetup:n.noSetup}}}function Zs(e){return{actionId:e.actionId,authenticated:e.authenticated,...e.defaultConnection==null?{}:{defaultConnection:{connectionId:e.defaultConnection.connectionId,displayName:e.defaultConnection.displayName,status:e.defaultConnection.status}},description:e.description,name:e.name,serviceId:e.serviceId,serviceName:e.serviceName}}var $n=A().min(1).max(256),uw=A().regex(/^[a-z][a-z0-9_.]{0,127}$/),lw=A().trim().min(1).max(128),Vf=x({version:k(1),sourceId:$n,revision:he().positive(),name:lw,provider:ce(["feishu","feishu_app_bot"]),appId:$n,connectionId:$n,teamId:$n.nullable(),enabled:ye(),eventTypes:P(uw),manageSubscriptions:ye(),verificationTokenConfigured:ye(),encryptKeyConfigured:ye(),endpointUrl:A().nullable(),verifiedAt:A().nullable(),lastReceivedAt:A().nullable(),updatedAt:A(),consumers:P(x({flowId:$n,flowName:A(),triggerNodeId:$n}))});function ho(e){return Vf.parse(e)}function Fs(e){return x({version:k(1),sources:P(Vf),teamId:$n.nullable().optional()}).parse(e)}function Ms(e){let n=w(e);if(D(n,["version","locale","definitions","display"]),n.version!=3||!wa(n.locale)||!Array.isArray(n.definitions))return p();let t=n.definitions.map(Xt),r=w(n.display),o=new Set(t.map((s)=>s.key));if(o.size!=t.length||Object.keys(r).length!=o.size)return p();let i=Object.fromEntries(t.map((s)=>{let{key:a}=s,c=w(r[a]);return D(c,["configInputs","configInputLabels","displayName","description","outputs"]),[a,{configInputs:Zf(c.configInputs,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),configInputLabels:dw(c.configInputLabels,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),displayName:f(c.displayName),description:f(c.description),outputs:Zf(c.outputs,s.outputs.map((u)=>u.handle))}]}));return{version:3,locale:n.locale,definitions:t,display:i}}function Zf(e,n){let t=w(e);return D(t,n),Object.fromEntries(Object.entries(t).map(([r,o])=>[r,f(o)]))}function dw(e,n){let t=w(e);if(Object.keys(t).some((r)=>!n.includes(r)))return p();return Object.fromEntries(Object.entries(t).map(([r,o])=>{let i=f(o);return i.trim().length==0?p():[r,i]}))}function Js(e,n){if(n==null)return e;let t=n.toLowerCase();return e.filter((r)=>[r.description,r.displayName,r.key,r.name,r.provider,r.type].some((o)=>o.toLowerCase().includes(t)))}var pw=x({pointer:A().max(4096).default(""),offset:fe().int().nonnegative().default(0),limit:fe().int().min(1).max(100).default(20),maxBytes:fe().int().min(1).max(1048576).default(15000)});var fw=Me(),Ff=x({pointer:A(),type:ce(["object","array","string","number","boolean","null"]),length:fe().int().nonnegative().optional(),complete:ye(),value:fw.optional()}),mw=Ff.extend({offset:fe().int().nonnegative(),nextOffset:fe().int().positive().optional(),entries:P(Ff).optional()}),Mf=x({resultId:A().min(1),callId:A().min(1),toolId:A().min(1),source:Ln("kind",[x({kind:k("connector"),action:A().min(1)}),x({kind:k("code")})]),bytes:fe().int().nonnegative(),digest:A().regex(/^[a-f0-9]{64}$/),createdAt:A().datetime()}),gw=x({version:k(1),runId:A(),results:P(Mf),nextAfter:A().optional()}),hw=x({version:k(1),runId:A(),result:Mf,page:mw});function Ls(e){return gw.parse(e)}function qs(e){return hw.parse(e)}function Jf(e){if(!Array.isArray(e))return p();return e.map((n)=>typeof n=="string"||Number.isSafeInteger(n)?n:p())}function yw(e){let n=w(e),t=f(n.kind);if(t=="artifact"||t=="binary"||t=="nullable")return{kind:t};if(t=="schema")return{kind:t,path:n.path==null?void 0:Jf(n.path)};if(t!="keyword"||typeof n.keyword!="string"||!Xi(n.keyword))return p();return{kind:t,keyword:n.keyword,path:Jf(n.path),source:n.source===void 0?void 0:me(n.source),target:n.target===void 0?void 0:me(n.target)}}function bw(e){let n=w(e),t=n.values==null?void 0:w(n.values);return{code:f(n.code),column:ie(n.column),...n.fields===void 0?{}:{fields:Array.isArray(n.fields)?n.fields.map(f):p()},line:ie(n.line),message:f(n.message),mismatch:n.mismatch==null?void 0:yw(n.mismatch),path:typeof n.path=="string"?n.path:p(),...t==null?{}:{values:Object.fromEntries(Object.entries(t).map(([r,o])=>[r,typeof o=="string"||typeof o=="number"?o:p()]))}}}function Lf(e){let n=w(e);if(n.version!=1||typeof n.valid!="boolean"||!Array.isArray(n.diagnostics))return p();return{closureDigest:f(n.closureDigest),diagnostics:n.diagnostics.map(bw),engineContract:f(n.engineContract),flowId:f(n.flowId),modelVersion:ie(n.modelVersion),revisionDigest:f(n.revisionDigest),revisionId:f(n.revisionId),valid:n.valid,version:1}}var qf=(e)=>e==null?"":`?flowId=${encodeURIComponent(e)}`;function Uf(e,n){let t=new URLSearchParams({...e==null?{}:{flowId:e},...n==null?{}:{locale:n}}).toString();return{path:`/v1/connector/providers${t?`?${t}`:""}`,decode:(r)=>{let o=w(r);if(D(o,["providers","version"]),o.version!=1||!Array.isArray(o.providers))return p();return o.providers.map(Df)}}}function Kf(e,n,t){let r=new URLSearchParams({...n==null?{}:{flowId:n},...t==null?{}:{locale:t}}).toString();return{path:`/v1/connector/actions/${encodeURIComponent(e)}${r?`?${r}`:""}`,decode:(o)=>{let i=w(o);if(D(i,["action","version"]),i.version!=1)return p();return go(i.action)}}}function Bf(e){return{path:`/v1/connector/connections${qf(e)}`,decode:(n)=>{let t=w(n);if(D(t,["connections","version"]),t.version!=1||!Array.isArray(t.connections))return p();return t.connections.map(rt)}}}function Wf(e,n){return{path:`/v1/connector/connections/${encodeURIComponent(e)}${qf(n)}`,decode:(t)=>{let r=w(t);if(D(r,["connections","serviceId","version"]),r.version!=1||f(r.serviceId)!=e||!Array.isArray(r.connections))return p();return r.connections.map(rt)}}}function Us(e){return Array.isArray(e)?e.map(f):p()}function ww(e){let n=w(e),t=n.draft===null?null:w(n.draft),r=w(n.sharedAccess);if(t!=null&&!Array.isArray(t.connections))return p();if(!Array.isArray(r.bindings))return p();let o=ie(r.accessRevision);if(o<0)return p();return{draft:t==null?null:{variableNames:Us(t.variableNames),errorSourceFlowIds:Us(t.errorSourceFlowIds),connections:t.connections.map((i)=>{let s=w(i);return{providerId:f(s.providerId),connectionId:f(s.connectionId)}})},sharedAccess:{accessRevision:o,providerIds:Us(r.providerIds),bindings:r.bindings.map((i)=>{let s=w(i);return{providerId:f(s.providerId),connectionId:s.connectionId===null?null:f(s.connectionId),accessBindingId:f(s.accessBindingId)}})}}}function sn(e){let n=w(e),t=n.status;if(n.version!=1)return p();if(t!="active"&&t!="retiring")return p();let r=n.live==null?void 0:w(n.live);if(r!=null&&typeof r.enabled!="boolean")return p();return{...r==null?{}:{live:{enabled:r.enabled,publicationId:f(r.publicationId),revisionId:f(r.revisionId)}},createdAt:f(n.createdAt),...n.connectorTeamId==null?{}:{connectorTeamId:f(n.connectorTeamId)},draftRevisionId:f(n.draftRevisionId),resourceReferences:ww(n.resourceReferences),flowId:f(n.flowId),name:f(n.name),status:t,updatedAt:f(n.updatedAt),version:1}}function Gf(e){let n=w(e);if(n.version!=1||!Array.isArray(n.flows))return p();let{nextCursor:t,total:r}=n;if(t!=null&&typeof t!="string")return p();if(r!=null&&!Number.isSafeInteger(r))return p();return{...t==null?{}:{nextCursor:t},flows:n.flows.map(sn),...r==null?{}:{total:r},version:1}}function yo(e){let n=w(e);if(D(n,["name","updatedAt","value","version"]),n.version!=1||typeof n.value!="string")return p();let t=f(n.updatedAt);try{if(new Date(t).toISOString()!=t)return p()}catch{return p()}return{name:f(n.name),updatedAt:t,value:n.value,version:1}}function Hf(e){let n=w(e);if(typeof n.enabled!="boolean")return p();return{flowId:f(n.flowId),flowName:f(n.flowName),nodeId:f(n.nodeId),nodeName:f(n.nodeName),enabled:n.enabled}}function Qf(e){let n=w(e);if(D(n,["version","references","unknown"]),n.version!=1||!Array.isArray(n.references)||!Array.isArray(n.unknown))return p();return{version:1,references:n.references.map((t)=>{let r=w(t);if(D(r,["flowId","flowName","draft","live"]),typeof r.draft!="boolean")return p();let o=r.live===null?null:w(r.live);if(o!=null){if(D(o,["publicationId","enabled"]),typeof o.enabled!="boolean")return p()}return{flowId:f(r.flowId),flowName:f(r.flowName),draft:r.draft,live:o==null?null:{publicationId:f(o.publicationId),enabled:o.enabled}}}),unknown:n.unknown.map((t)=>{let r=w(t);if(D(r,["flowId","flowName","scope"]),r.scope!=="draft"&&r.scope!=="live")return p();return{flowId:f(r.flowId),flowName:f(r.flowName),scope:r.scope}})}}function Yf(e){let n=w(e),t=n.parentRevisionId;if(n.version!=1||t!==null&&typeof t!="string")return p();return{actorId:f(n.actorId),createdAt:f(n.createdAt),digest:f(n.digest),flowId:f(n.flowId),modelVersion:ie(n.modelVersion),parentRevisionId:t,revisionId:f(n.revisionId),version:1}}function tr(e){let n=w(e);try{return{...Yf(n),content:Qt(n.content)}}catch{return p()}}function bo(e){let n=w(e);if(n.version!=1||ie(n.revision)<1)return p();return{revision:ie(n.revision),updatedAt:f(n.updatedAt),value:Object.fromEntries(Object.entries(w(n.value)).map(([t,r])=>[t,me(r)])),version:1}}function wo(e){let n=w(e);if(n.version!=1)return p();return{revision:Yf(n.revision),version:1}}function Xf(e){let n=w(e);if(n.version!=1||n.kind!="snapshot")return p();return{draft:tr(n.draft),kind:"snapshot",version:1}}var xw=["canceled","completed","failed","indeterminate"],xo=[...xw,"queued","running","starting","waiting"];var vw=new Set(xo);function Ks(e){return typeof e=="string"&&vw.has(e)?e:p()}function nm(e){let n=w(e),{source:t,startedAt:r,finishedAt:o}=n;if(n.version!=1||t!="draft"&&t!="live")return p();if(r!=null&&typeof r!="string")return p();if(o!=null&&typeof o!="string")return p();return{createdAt:f(n.createdAt),...o==null?{}:{finishedAt:o},flowId:f(n.flowId),revisionId:f(n.revisionId),runId:f(n.runId),source:t,...r==null?{}:{startedAt:r},status:Ks(n.status),version:1}}function kw(e){let n=w(e);D(n,["actions","expiresAt","nodeId","prompt","waitId","waitingSince"]);let t=n.actions;if(!Array.isArray(t)||!(t.length==1&&t[0]=="continue"||t.length==2&&t[0]=="approve"&&t[1]=="reject"))return p();return{actions:t,expiresAt:f(n.expiresAt),nodeId:f(n.nodeId),prompt:f(n.prompt),waitId:f(n.waitId),waitingSince:f(n.waitingSince)}}function vo(e){let n=w(e),t=nm(n),r=n.eventsExpiresAt;if(r!=null&&typeof r!="string")return p();if(n.waiting!==void 0||!Array.isArray(n.waits))return p();let o=n.waits.map(kw);if(new Set(o.map((a)=>a.waitId)).size!=o.length||t.status=="waiting"&&o.length==0||["completed","failed","canceled","indeterminate"].includes(t.status)&&o.length>0)return p();if(n.occurrenceId===void 0!=(n.triggerNodeId===void 0))return p();let i={status:t.status,waits:o},s={...t,...Sw(n),closureDigest:f(n.closureDigest),engineContract:f(n.engineContract),engineDigest:f(n.engineDigest),...r==null?{}:{eventsExpiresAt:r},modelVersion:ie(n.modelVersion),sharedAccessDigest:f(n.sharedAccessDigest),revisionDigest:f(n.revisionDigest),...i};switch(t.source){case"draft":return{...s,source:"draft"};case"live":return{...s,publicationId:f(n.publicationId),source:"live",...n.occurrenceId===void 0?{}:{occurrenceId:f(n.occurrenceId),triggerNodeId:f(n.triggerNodeId)}}}}function tm(e){let n=w(e),t=n.nextCursor;if(n.version!=1||!Array.isArray(n.runs))return p();if(t!=null&&typeof t!="string")return p();return{flowId:f(n.flowId),...t==null?{}:{nextCursor:t},runs:n.runs.map(nm),version:1}}function rm(e){let n=w(e),t=Ks(n.status);if(n.version!=1||typeof n.cancelAccepted!="boolean"||t=="queued"||t=="starting"||t=="running"||t=="waiting")return p();return{cancelAccepted:n.cancelAccepted,runId:f(n.runId),status:t,version:1}}function om(e){let n=w(e);D(n,["action","comment","resolutionAccepted","resolvedAt","runId","status","version","waitId"]);let{action:t,resolvedAt:r}=n;if(n.version!=1||typeof n.resolutionAccepted!="boolean"||n.comment!==null&&typeof n.comment!="string"||t!==null&&t!="approve"&&t!="continue"&&t!="reject"||r!==null&&typeof r!="string"||t===null!=(r===null)||n.resolutionAccepted&&t===null)return p();return{action:t,comment:n.comment,resolutionAccepted:n.resolutionAccepted,resolvedAt:r,runId:f(n.runId),status:Ks(n.status),version:1,waitId:f(n.waitId)}}function im(e){let n=w(e),t=n.status;if(n.version!=1)return p();let r={finishedAt:f(n.finishedAt),runId:f(n.runId),version:1};if(t=="completed"){if(!Object.hasOwn(n,"result"))return p();return{...r,result:n.result,status:"completed"}}if(t=="canceled")return{...r,status:"canceled"};if(t=="failed"){let o=w(n.error);return{...r,error:em(o),status:"failed"}}if(t=="indeterminate"){let o=w(n.error);return{...r,error:em(o),status:"indeterminate"}}return p()}function Sw(e){let n=e.errorSource==null?void 0:w(e.errorSource);if(e.errorDispatches!=null&&!Array.isArray(e.errorDispatches))return p();return{...n==null?{}:{errorSource:{flowId:f(n.flowId),runId:f(n.runId)}},...e.errorDispatches==null?{}:{errorDispatches:e.errorDispatches.map((t)=>{let r=w(t),o=f(r.flowId);switch(r.status){case"pending":return{status:"pending",flowId:o};case"dispatched":return{status:"dispatched",flowId:o,runId:f(r.runId)};case"failed":return{status:"failed",flowId:o,message:f(r.message)};default:return p()}})}}}function em(e){return{code:f(e.code),message:f(e.message),...e.nodeId===void 0?{}:{nodeId:f(e.nodeId)},...e.jobId===void 0?{}:{jobId:f(e.jobId)},...e.path===void 0?{}:{path:(Array.isArray(e.path)?e.path:p()).map(f)}}}function ko(){let e=globalThis.crypto;if(e!=null){try{if(typeof e.randomUUID=="function")return e.randomUUID()}catch{}if(typeof e.getRandomValues=="function"){let n=e.getRandomValues(new Uint8Array(16));n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let t=Array.from(n,(r)=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function am(e){return e?.kind=="run.completed"||e?.kind=="run.failed"||e?.kind=="run.canceled"||e?.kind=="run.indeterminate"}function Iw(e){let n=w(e),t=ie(n.sequence);if(t<0)return p();let r={createdAt:f(n.createdAt),sequence:t},o=w(n.payload),i=n.kind;switch(i){case"run.queued":return{...r,kind:i,payload:{}};case"run.started":return{...r,kind:i,payload:{flowId:f(o.flowId),scopeId:f(o.scopeId),...o.parentScopeId===void 0?{}:{parentScopeId:f(o.parentScopeId)}}};case"run.progress":return{...r,kind:i,payload:{flowId:f(o.flowId),scopeId:f(o.scopeId),progress:sm(o.progress)}};case"run.waiting":if(!Array.isArray(o.waitIds))return p();return{...r,kind:i,payload:{waitIds:o.waitIds.map((s)=>f(s))}};case"wait.created":return{...r,kind:i,payload:{expiresAt:f(o.expiresAt),nodeId:f(o.nodeId),waitId:f(o.waitId),waitingSince:f(o.waitingSince)}};case"run.resolved":{let s=o.action;if(s!=="approve"&&s!=="continue"&&s!=="reject")return p();if(o.comment!==null&&typeof o.comment!="string")return p();return{...r,kind:i,payload:{action:s,comment:o.comment,resolvedAt:f(o.resolvedAt),waitId:f(o.waitId)}}}case"run.completed":case"run.canceled":case"run.failed":case"run.indeterminate":return{...r,kind:i,payload:{result:me(o.result)}};case"run.events-truncated":return{...r,kind:i,payload:Object.fromEntries(Object.entries(o).map(([s,a])=>[s,me(a)]))};case"node.started":case"node.completed":case"node.failed":case"node.log":case"node.progress":case"node.artifact":{let s={flowId:f(o.flowId),scopeId:f(o.scopeId),nodeId:f(o.nodeId),executionId:f(o.executionId)};switch(i){case"node.started":{let a=o.nodeKind;if(a!==void 0&&a!=="approval"&&a!=="condition"&&a!=="connector"&&a!=="javascript"&&a!=="decision"&&a!=="openapi"&&a!=="llm"&&a!=="agent"&&a!=="value"&&a!=="wait")return p();return{...r,kind:i,payload:{...s,...a===void 0?{}:{nodeKind:a},...o.nodeTitle===void 0?{}:{nodeTitle:f(o.nodeTitle)},...o.operation===void 0?{}:{operation:f(o.operation)}}}}case"node.completed":return{...r,kind:i,payload:{...s,outputs:Object.fromEntries(Object.entries(w(o.outputs)).map(([a,c])=>[a,me(c)]))}};case"node.failed":{let a=w(o.error);return{...r,kind:i,payload:{...s,error:{code:f(a.code),message:f(a.message)}}}}case"node.log":{let a=o.level;if(a!=="debug"&&a!=="info"&&a!=="warn"&&a!=="error")return p();return{...r,kind:i,payload:{...s,level:a,message:f(o.message)}}}case"node.progress":return{...r,kind:i,payload:{...s,progress:sm(o.progress)}};case"node.artifact":{let a=w(o.artifact),c=ie(a.size),u=f(a.digest);if(a.kind!="artifact"||c<0||!/^sha256:[0-9a-f]{64}$/.test(u))return p();return{...r,kind:i,payload:{...s,artifact:{kind:"artifact",id:f(a.id),name:f(a.name),size:c,digest:u,...a.mediaType===void 0?{}:{mediaType:f(a.mediaType)}}}}}}}default:return p()}}function sm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=100?e:p()}function Ew(e){let n=w(e),t=n.eventsExpiresAt,r=ie(n.nextAfter);if(n.version!=1||!Array.isArray(n.events)||typeof n.done!="boolean"||typeof n.historyComplete!="boolean")return p();if(t!=null&&typeof t!="string")return p();if(r<0)return p();return{done:n.done,events:n.events.map(Iw),...t==null?{}:{eventsExpiresAt:t},historyComplete:n.historyComplete,nextAfter:r,runId:f(n.runId),version:1}}var C=encodeURIComponent;function ot(e){return`${e}-${ko()}`}class Bs{constructor(e){this.requestControl=e}async loadOpenApiDocument(e,n){let t=w(await this.request("/v1/openapi/document",{method:"POST",body:JSON.stringify({url:e,version:1}),signal:n}));if(t.version!=1)return p();return me(t.document)}async listFlows(e={}){let n=new URLSearchParams;if(e.cursor!=null)n.set("cursor",e.cursor);if(e.limit!=null)n.set("limit",String(e.limit));if(e.includeTotal!=null)n.set("includeTotal",String(e.includeTotal));let t=n.size==0?"":`?${n}`;return Gf(await this.request(`/v1/flows${t}`))}async listEventSources(e,n){return Fs(await this.request("/v1/event-sources"+(e==null?"":`?flowId=${C(e)}`),{signal:n}))}async listEventSourceConnections(e,n){let t=w(await this.request(`/v1/event-sources/connections${e==null?"":`?teamId=${C(e)}`}`,{signal:n}));if(D(t,["version","connections"]),t.version!=1||!Array.isArray(t.connections))return p();return t.connections.map(rt)}async createEventSource(e){return ho(await this.request("/v1/event-sources",{method:"POST",body:JSON.stringify(e)}))}async updateEventSource(e,n){return ho(await this.request(`/v1/event-sources/${C(e)}`,{method:"PUT",body:JSON.stringify(n)}))}async deleteEventSource(e,n){await this.request(`/v1/event-sources/${C(e)}`,{method:"DELETE",body:JSON.stringify({version:1,expectedRevision:n})})}async listVariables(){let e=w(await this.request("/v1/variables"));if(D(e,["variables","version"]),e.version!=1||!Array.isArray(e.variables))return p();return{variables:e.variables.map(yo),version:1}}async getVariableReferences(e,n){return Qf(await this.request(`/v1/variables/${C(e)}/references`,{signal:n}))}async getVariable(e){return yo(await this.request(`/v1/variables/${C(e)}`))}async putVariable(e,n){return yo(await this.request(`/v1/variables/${C(e)}`,{body:JSON.stringify({value:n}),method:"PUT"}))}async deleteVariable(e){let n=w(await this.request(`/v1/variables/${C(e)}`,{method:"DELETE"}));if(D(n,["version"]),n.version!=1)return p()}async exportFlow(e){let n=await this.request(`/v1/flows/${C(e)}/export`);try{return fo(n)}catch{return p()}}async importFlow(e,n={}){return sn(await this.request("/v1/flows/import",{method:"POST",headers:{"Idempotency-Key":n.idempotencyKey??`flow-${ko()}`},body:JSON.stringify({file:e,name:n.name,teamId:n.teamId,version:1})}))}async createFlow(e,n=`flow-${ko()}`,t){return sn(await this.request("/v1/flows",{body:JSON.stringify({name:e,...t==null?{}:{teamId:t},version:1}),headers:{"idempotency-key":n},method:"POST"}))}async getFlow(e){return sn(await this.request(`/v1/flows/${C(e)}`))}async getErrorListeners(e,n){let t=w(await this.request(`/v1/flows/${C(e)}/error-listeners`,{signal:n}));if(t.version!=1||!Array.isArray(t.listeners))return p();return t.listeners.map(Hf)}async renameFlow(e,n){return sn(await this.request(`/v1/flows/${C(e)}`,{body:JSON.stringify({name:n,version:1}),method:"PATCH"}))}async deleteFlow(e){return sn(await this.request(`/v1/flows/${C(e)}`,{method:"DELETE"}))}async listTriggerKeys(e,n){let t=w(await this.request(`/v1/trigger-keys${n==null?"":`?locale=${encodeURIComponent(n)}`}`,{signal:e}));if(t.version!=1||!Array.isArray(t.keys))return p();return t.keys.map(zs)}async listTriggerDefinitions(e){let n=w(await this.request("/v1/trigger-keys/catalog",{signal:e}));if(n.version!=2||!Array.isArray(n.definitions))return p();return n.definitions.map(Xt)}async readCatalog(e,n,t){let r=new Headers;if(n)r.set("if-none-match",n);let o=await this.response(e.path,{headers:r,signal:t},!0),i=o.headers.get("etag")?.trim()||null;if(o.status==304)return{modified:!1,etag:i};return{modified:!0,data:e.decode(await o.json()),etag:i}}async getTriggerCatalog(e,n,t){let r=new Headers;if(n?.etag)r.set("if-none-match",n.etag);let o=await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(e)}`,{headers:r,signal:t},!0);if(o.status==304){if(n==null)return p();return{...n,etag:o.headers.get("etag")?.trim()||n.etag}}return{data:Ms(await o.json()),etag:o.headers.get("etag")?.trim()||null}}async getTriggerKey(e,n){let t=w(await this.request(`/v1/trigger-keys/${C(e)}`,{signal:n}));if(t.version!=1)return p();return Xt(t.definition)}async listFlowTriggerBindings(e,n){let t=w(await this.request(`/v1/flows/${C(e)}/triggers`,{signal:n}));if(t.version!=1||f(t.flowId)!=e||!Array.isArray(t.bindings))return p();return t.bindings.map(er)}async getFlowTriggerBinding(e,n){return kf(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}`))}async listFlowTriggerActivities(e,n,t={}){let r=new URLSearchParams;if(t.cursor!=null)r.set("cursor",t.cursor);if(t.limit!=null)r.set("limit",String(t.limit));let o=r.size==0?"":`?${r}`;return Sf(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/activities${o}`))}async testFlowPollTrigger(e,n){return If(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/test`,{body:JSON.stringify({version:1}),method:"POST"}))}async getEditor(e){let n=w(await this.request(`/v1/flows/${C(e)}/editor`));if(n.version!=1)return p();let t={flow:sn(n.flow),draft:tr(n.draft),live:Ts(n.live),presentation:bo(n.presentation),version:1};if(t.flow.flowId!=e||t.draft.flowId!=e||t.live.flowId!=e||t.flow.draftRevisionId!=t.draft.revisionId)return p();return t}async getPublicationPresentation(e,n,t){let r=w(await this.request(`/v1/flows/${C(e)}/publications/${C(n)}/presentation`,{signal:t}));if(r.version!=1)return p();return{version:1,presentation:r.presentation===null?null:bo(r.presentation)}}async getPresentation(e){return bo(await this.request(`/v1/flows/${C(e)}/presentation`))}async getDraft(e){return tr(await this.request(`/v1/flows/${C(e)}/draft`))}async syncDraft(e){return Xf(await this.request(`/v1/flows/${C(e)}/draft/sync`))}async getRevision(e,n,t){return tr(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}`,{signal:t}))}async listTriggerConfigOptions(e,n,t,r){let o=w(await this.request(`/v1/flows/${C(e)}/triggers/${C(n)}/options/${C(t)}`,{signal:r}));if(D(o,["options","version"]),o.version!=1||!Array.isArray(o.options)||o.options.length>1000)return p();return o.options.map((i)=>{let s=w(i);D(s,["value","label",...s.color==null?[]:["color"]]);let a=s.color==null?void 0:f(s.color);if(a!=null&&!/^#[0-9a-fA-F]{6}$/.test(a))return p();return a==null?{value:f(s.value),label:f(s.label)}:{value:f(s.value),label:f(s.label),color:a}})}async listConnectorTeams(e){let n=w(await this.request("/v1/connector/teams",{signal:e}));if(D(n,["enabled","teams","version"]),n.version!=1||typeof n.enabled!="boolean"||!Array.isArray(n.teams))return p();return{enabled:n.enabled,teams:n.teams.map((t)=>{let r=w(t);if(D(r,["id","name","systemCreated"]),typeof r.systemCreated!="boolean")return p();return{id:f(r.id),name:f(r.name),systemCreated:r.systemCreated}}),version:1}}async listConnectorProviders(e,n,t){let r=Uf(n,t);return this.connectorRequest(r.path,"providers",e,r.decode)}async removeConnectionUsage(e,n,t,r,o){return wo(await this.request(`/v1/flows/${C(e)}/connection-usage/remove`,{method:"POST",headers:{"idempotency-key":o},body:JSON.stringify({connectionId:n,expectedRevisionId:t,expectedAccessRevision:r,version:1})}))}async getConnectorAccess(e,n){return tt(await this.request(`/v1/flows/${C(e)}/connector-access`,{signal:n}))}async getPublishedConnectorAccess(e,n,t){return Vs(await this.request(`/v1/flows/${C(e)}/connector-access?publicationId=${C(n)}`,{signal:t}))}async listProviderAccessBindingCandidates(e,n,t){return Tf(await this.request(`/v1/flows/${C(e)}/connector-access/candidates/query`,{method:"POST",body:JSON.stringify({providerIds:n,version:1}),signal:t}),n)}async setConnectorService(e,n,t,r){return tt(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}/service`,{body:JSON.stringify({expectedAccessRevision:r,version:1}),method:t?"PUT":"DELETE"}))}async addProviderAccessBinding(e,n,t,r){return tt(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"PUT"}))}async removeProviderAccessBinding(e,n,t,r){return tt(await this.request(`/v1/flows/${C(e)}/connector-access/${C(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"DELETE"}))}async listConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},...e==null?{}:{service:e}},n)}async searchConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},q:e.trim()},n)}async getConnectorAction(e,n,t,r,o=!1){let i=Kf(e,t,r);return this.connectorRequest(i.path,"actions",n,i.decode,o)}async listAllConnectorConnections(e,n,t=!1){let r=Bf(n);return this.connectorRequest(r.path,"connections",e,r.decode,t)}async listConnectorConnections(e,n,t,r=!1){let o=Wf(e,t);return this.connectorRequest(o.path,"connections",n,o.decode,r)}async createConnectorConnectionPage(e,n,t){let r=new URLSearchParams;if(n!=null)r.set("flowId",n);if(t!=null)r.set("teamId",t);let o=w(await this.request(`/v1/connector/connections/${C(e)}/page${r.size==0?"":`?${r}`}`,{body:JSON.stringify({version:1}),method:"POST"}));if(D(o,["url","version"]),o.version!=1)return p();try{let i=new URL(f(o.url));if(i.protocol!="http:"&&i.protocol!="https:")return p();return i.href}catch{return p()}}async readAuthoring(e,n={}){return yf.parse(await this.request(`/v1/flows/${C(e)}/authoring/read`,{method:"POST",body:JSON.stringify(n)}))}async searchAuthoring(e,n){return bf.parse(await this.request(`/v1/flows/${C(e)}/authoring/search`,{method:"POST",body:JSON.stringify(n)}))}async authoringSchema(e,n){return w(await this.request(`/v1/flows/${C(e)}/authoring/schema`,{method:"POST",body:JSON.stringify(n)}))}async editAuthoring(e,n){return hf.parse(await this.request(`/v1/flows/${C(e)}/authoring/edit`,{method:"POST",headers:{"idempotency-key":n.requestId},body:JSON.stringify(n)}))}async checkAuthoring(e,n){return gf.parse(await this.request(`/v1/flows/${C(e)}/authoring/check`,{method:"POST",body:JSON.stringify({revisionId:n})}))}async changeDraft(e,n,t,r=ot("change")){return wo(await this.request(`/v1/flows/${C(e)}/draft/changes`,{body:JSON.stringify({expectedRevisionId:n,operations:t,version:1}),headers:{"idempotency-key":r},method:"POST"}))}async repairDraft(e,n,t=ot("repair")){return wo(await this.request(`/v1/flows/${C(e)}/draft/repair`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t},method:"POST"}))}async checkFlow(e,n){return Lf(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/check`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",version:1}),method:"POST"}))}async getLiveDetails(e,n){let t=Cf(await this.request(`/v1/flows/${C(e)}/live/details`,{signal:n}));if(t.flowId!=e)return p();return t}async getLive(e,n){return Ts(await this.request(`/v1/flows/${C(e)}/live`,{signal:n}))}async listPublications(e,n={},t){let r=new URLSearchParams;if(n.cursor!=null)r.set("cursor",n.cursor);if(n.limit!=null)r.set("limit",String(n.limit));if(n.includeTotal!=null)r.set("includeTotal",String(n.includeTotal));let o=r.size==0?"":`?${r}`;return xf(await this.request(`/v1/flows/${C(e)}/publications${o}`,{signal:t}))}async createDraftRun(e,n,t){let r=vo(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/runs`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",inputs:t.inputs??{},trigger:t.trigger,version:2}),headers:{"idempotency-key":t.idempotencyKey??ot("run")},method:"POST"}));return r.source=="draft"?r:p()}async createLiveRun(e,n){let t=vo(await this.request("/v1/runs",{body:JSON.stringify({inputs:n.inputs??{},trigger:n.trigger,publicationId:e,version:2}),headers:{"idempotency-key":n.idempotencyKey??ot("run")},method:"POST"}));return t.source=="live"?t:p()}async setFlowEnabled(e,n,t){return sn(await this.request(`/v1/flows/${C(e)}/enabled`,{method:"PUT",body:JSON.stringify({enabled:t,expectedPublicationId:n,version:1})}))}async publishFlow(e,n,t,r={}){return Ns(await this.request(`/v1/flows/${C(e)}/revisions/${C(n)}/publications`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??ot("publication")},method:"POST"}))}async getPublishOperation(e,n,t){return Ns(await this.request(`/v1/flows/${C(e)}/publish-operations/${C(n)}`,{signal:t}))}async rollbackFlow(e,n,t,r={}){return et(await this.request(`/v1/flows/${C(e)}/publications/${C(n)}/rollback`,{body:JSON.stringify({expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??ot("publication")},method:"POST"}))}async getRun(e,n){return vo(await this.request(`/v1/runs/${C(e)}`,{signal:n}))}async listRuns(e,n={}){let t=new URLSearchParams;if(n.cursor!=null)t.set("cursor",n.cursor);if(n.limit!=null)t.set("limit",String(n.limit));if(n.status!=null)t.set("status",n.status);if(n.pendingWait!=null)t.set("pendingWait",String(n.pendingWait));if(n.source!=null)t.set("source",n.source);if(n.createdFrom!=null)t.set("createdFrom",n.createdFrom);if(n.createdBefore!=null)t.set("createdBefore",n.createdBefore);if(n.runId!=null)t.set("runId",n.runId);let r=t.size==0?"":`?${t}`;return tm(await this.request(`/v1/flows/${C(e)}/runs${r}`))}async getRunEvents(e,n={},t){let r=new URLSearchParams;if(n.after!=null)r.set("after",String(n.after));if(n.limit!=null)r.set("limit",String(n.limit));let o=r.size==0?"":`?${r}`;return Ew(await this.request(`/v1/runs/${C(e)}/events${o}`,{signal:t}))}async listRunResults(e,n,t){return Ls(await this.request(`/v1/runs/${C(e)}/results${n==null?"":`?after=${encodeURIComponent(n)}`}`,{signal:t}))}async readRunResult(e,n,t={},r){let o=new URLSearchParams(Object.entries(t).map(([i,s])=>[i,String(s)]));return qs(await this.request(`/v1/runs/${C(e)}/results/${C(n)}?${o}`,{signal:r}))}async downloadRunResult(e,n,t){return(await this.response(`/v1/runs/${C(e)}/results/${C(n)}/content`,{signal:t})).blob()}async getRunResult(e,n){return im(await this.request(`/v1/runs/${C(e)}/result`,{signal:n}))}async cancelRun(e){return rm(await this.request(`/v1/runs/${C(e)}/cancel`,{body:JSON.stringify({version:1}),method:"POST"}))}async resolveRunWait(e,n,t,r){return om(await this.request(`/v1/runs/${C(e)}/waits/${C(n)}/resolve`,{body:JSON.stringify({action:t,comment:r,version:1}),method:"POST"}))}async connectorActions(e,n){let t=Object.entries(e).map(([o,i])=>`${C(o)}=${C(i)}`).join("&"),r=t==""?"":`?${t}`;return this.connectorRequest(`/v1/connector/actions${r}`,"actions",n,(o)=>{let i=w(o);if(D(i,["actions","version"]),i.version!=1||!Array.isArray(i.actions))return p();return i.actions.map(go)})}async connectorRequest(e,n,t,r,o=!1){return r(await this.request(e,{signal:t}))}async response(e,n,t=!1){let r=new Headers(n.headers);if(n.body!=null)r.set("content-type","application/json");let o=await this.requestControl(e,{...n,headers:r});if(!o.ok&&!(t&&o.status==304)){let i;try{i=await o.json()}catch{return p()}let s=w(i).error,a=s==null?void 0:w(s);throw new Ee(o.status,typeof a?.code=="string"?a.code:"request.failed",typeof a?.message=="string"?a.message:`Request failed with status ${o.status}.`,a?.details==null?void 0:w(a.details))}return o}async request(e,n={}){let t=await this.response(e,n);try{return await t.json()}catch{return p()}}}import{randomUUID as Pw}from"crypto";class E extends Error{constructor(e,n,t){super(n);this.code=e,this.details=t,this.name="CliError"}}function So(e,n){let t=e.trim();if(Kr(t)!=null)throw new E("cli.invalid-arguments",`${n} name must be between 1 and ${es} characters and use only letters, numbers, spaces, hyphens, or underscores.`);return t}var Cw=100,Ws=100,Gs=100,Ow=new Set(["canceled","completed","failed","indeterminate"]);async function Rw(e){let n=[],t=new Set,r;do{let o=await e.listFlows({cursor:r,limit:Cw});if(n.push(...o.flows),r=o.nextCursor,r!=null&&t.has(r))throw new E("page.invalid-cursor","The deployment returned a repeated Flow cursor.");if(r!=null)t.add(r)}while(r!=null);return n}function Aw(e,n){let t=e.find((o)=>o.flowId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new E("flow.ambiguous",`Flow name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({flowId:o,name:i})=>({flowId:o,name:i}))});throw new E("flow.not-found",`Flow ${JSON.stringify(n)} was not found.`)}async function ge(e,n){try{return await e.getFlow(n)}catch(t){if(!(t instanceof Ee)||t.code!="flow.invalid"&&t.code!="flow.not-found")throw t}return Aw(await Rw(e),n)}async function cm(e,n,t){if(t.expectedRevision!=null&&t.expectedRevision!=n.draftRevisionId&&!t.options.includes("idempotency-key"))throw new E("flow.revision-conflict","The Flow Draft changed. Inspect it before submitting a new mutation.",{expectedRevisionId:t.expectedRevision,actualRevisionId:n.draftRevisionId,flowId:n.flowId});let r=await e.getRevision(n.flowId,t.expectedRevision??n.draftRevisionId);return{draft:r,flow:n,graph:r.content.document.graph}}function jw(e,n){let t=e.find((o)=>o.actionId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new E("connector.action-ambiguous",`Connector Action name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({actionId:o,name:i,serviceId:s})=>({actionId:o,name:i,serviceId:s}))});throw new E("connector.action-not-found",`Connector Action ${JSON.stringify(n)} was not found.`)}async function um(e,n,t){try{return await e.getConnectorAction(n,void 0,t)}catch(r){if(!(r instanceof Ee)||r.status!=404)throw r}return jw(await e.searchConnectorActions(n,void 0,t),n)}function lm(e,n){let t=Object.entries(e.document.graph.nodes).filter((i)=>!("inputs"in i[1])),r=t?.find(([i])=>i==n);if(r!=null)return{trigger:r[1],triggerId:r[0]};let o=t?.filter(([,i])=>i.name==n)??[];if(o.length==1)return{trigger:o[0][1],triggerId:o[0][0]};if(o.length>1)throw new E("trigger.ambiguous",`Trigger name ${JSON.stringify(n)} is ambiguous.`,{candidates:o.map(([i,s])=>({name:s.name,triggerId:i}))});throw new E("trigger.not-found",`Trigger ${JSON.stringify(n)} was not found.`)}function Hs(e){return`${e.displayName} ${e.key} ${e.provider} ${e.type}`}async function dm(e,n){try{return await e.getTriggerKey(n)}catch(o){if(!(o instanceof Ee)||o.status!=404)throw o}let r=(await e.listTriggerKeys()).filter((o)=>o.name==n||o.displayName==n);if(r.length==1)return await e.getTriggerKey(r[0].key);if(r.length>1)throw new E("trigger-key.ambiguous",`Trigger Key name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({displayName:o,key:i,provider:s})=>({displayName:o,key:i,provider:s}))});throw new E("trigger-key.not-found",`Trigger Key ${JSON.stringify(n)} was not found.`)}function pm(e){return`${e.displayName} ${e.connectionId} ${e.serviceId} ${e.status}${e.isDefault?"\tdefault":""}`}function Qs(e){return`${e.name} ${e.actionId} ${e.serviceName} ${e.serviceId}`}function se(e,n,t){if(e.length!=n)throw new E("cli.invalid-arguments",`Usage: ${t}`)}function F(e,n,t,r){e.stdout.write(n?`${JSON.stringify(t)}
59
60
  `:`${r}
60
- `)}function Pn(e){return`${e.name} ${e.flowId} ${e.status}`}function Ht(e){return`${e.operation} ${e.publicationId} ${e.revisionId} ${e.createdAt}`}function Qt(e){let n=e.source=="draft"?"":` ${e.publicationId}`;return`${e.source} ${e.status} ${e.runId} ${e.revisionId}${n}${e.waits.length==0?"":`
61
- ${JSON.stringify(e.waits)}`}`}function nm(e){return`${e.source} ${e.status} ${e.runId} ${e.revisionId}`}function tm(e){return`${e.sequence} ${e.kind} ${JSON.stringify(e.payload)}`}async function _n(e,n,t,r){try{if(e=="-")return await r.readStdin();if(!e.startsWith("@"))return e;let o=e.slice(1);if(o.length==0)throw new I("cli.invalid-arguments",`${n} @ requires a file path.`);return await r.readFile(o)}catch(o){if(o instanceof I)throw o;throw new I(t,o instanceof Error?o.message:String(o))}}async function rm(e,n){if(e.input==null)return{};let t=await _n(e.input,"--input","run.input-unreadable",n),r;try{r=JSON.parse(t)}catch{throw new I("run.input-invalid","Run input must be valid JSON.")}if(r==null||typeof r!="object"||Array.isArray(r))throw new I("run.input-invalid","Run input must be an object keyed by node ID.");for(let o of Object.values(r))if(o==null||typeof o!="object"||Array.isArray(o))throw new I("run.input-invalid","Each Run input node must contain an object keyed by input handle.");return r}async function Yt(e,n,t){let r=new Set,o;do{let i=await e.listPublications(n,{cursor:o,limit:Js}),s=i.publications.find((a)=>a.publicationId==t);if(s!=null)return s;if(o=i.nextCursor,o!=null&&r.has(o))throw new I("page.invalid-cursor","The deployment returned a repeated Publication cursor.");if(o!=null)r.add(o)}while(o!=null);throw new I("publication.not-found",`Publication ${JSON.stringify(t)} was not found.`)}async function Ks(e,n,t,r=60000){let o=Date.now()+r,i=n;while(!vw.has(i.status)&&i.waits.length==0){let s=o-Date.now();if(s<=0)return{run:i,timedOut:!0};if(await t.wait(Math.min(1000,s)),Date.now()>=o)return{run:i,timedOut:!0};try{i=await e.getRun(i.runId,AbortSignal.timeout(Math.max(1,o-Date.now())))}catch(a){if(Date.now()>=o||a instanceof Error&&a.name=="TimeoutError")return{run:i,timedOut:!0};throw new I("run.wait-failed",a instanceof Error?a.message:String(a),{runId:i.runId})}}return{run:i,timedOut:!1}}function Xt(e,n=!1){if(n)return 3;if(e.waits.length>0)return 2;return e.status=="failed"||e.status=="canceled"||e.status=="indeterminate"?1:0}function om(e){return new I(e.code,e.message,{status:e.status,...e.details})}async function Bs(e,n,t,r,o=60000){let i=Date.now()+o,s=t;while(s.status=="pending"){let a=i-Date.now();if(a<=0)return{operation:s,timedOut:!0};if(await r.wait(Math.min(1000,a)),Date.now()>=i)return{operation:s,timedOut:!0};try{s=await e.getPublishOperation(n,s.operationId,AbortSignal.timeout(Math.max(1,i-Date.now())))}catch(c){if(Date.now()>=i||c instanceof Error&&c.name=="TimeoutError")return{operation:s,timedOut:!0};throw new I("publication.wait-failed",c instanceof Error?c.message:String(c),{flowId:n,operationId:s.operationId})}}return{operation:s,timedOut:!1}}var Cw=new Set(fo);function im(e){let n=Ew(),t,r=[],o=[],i,s,a,c,u,l,p,m,g,h,S,R,N,L,K,Te,ue,H,Ae,jn=!1,$n,Nn=!1,Tn,nt,nr=[],ia="draft",xo,vo,sa=!1,ko,So,Io,aa=[],ca=!1,ua=!1;for(let tt=0;tt<e.length;tt+=1){let rt=e[tt],tr=rt.startsWith("--")?rt.indexOf("="):-1,O=tr<0?rt:rt.slice(0,tr),rr=tr<0?void 0:rt.slice(tr+1);if(rr!=null&&["--json","--follow","--wait","--yes","--full","--pending-wait"].includes(O))throw new I("cli.invalid-arguments",`${O} does not accept a value.`);if(O.startsWith("--")){let F=O.slice(2);if(o.includes(F)&&F!="set"&&F!="unset")throw new I("cli.invalid-arguments",`Duplicate option --${F}.`);o.push(F)}if(O=="--json")Nn=!0;else if(O=="--follow")jn=!0;else if(O=="--wait")ca=!0;else if(O=="--yes")ua=!0;else if(O=="--pending-wait")xo=!0;else if(O=="--full")sa=!0;else if(O=="--idempotency-key"||O=="--expected-publication"||O=="--revision"||O=="--publication"||O=="--pointer"||O=="--offset"||O=="--max-bytes"||O=="--code"||O=="--connection"||O=="--cron"||O=="--description"||O=="--every"||O=="--expected-revision"||O=="--file"||O=="--flow"||O=="--name"||O=="--source"||O=="--input"||O=="--trigger"||O=="--outputs"||O=="--status"||O=="--cursor"||O=="--limit"||O=="--after"||O=="--comment"||O=="--timeout"||O=="--timezone"||O=="--set"||O=="--unset"){let F=rr??e[tt+1];if(F==null||F.length==0||rr==null&&F.startsWith("-")&&F!="-")throw new I("cli.invalid-arguments",`${O} requires a value.`);if(rr==null)tt++;if(O=="--idempotency-key")n=F;else if(O=="--expected-publication")t=F;else if(O=="--revision")a=F;else if(O=="--publication")c=F;else if(O=="--pointer")u=F;else if(O=="--after")g=F;else if(O=="--code")S=F;else if(O=="--connection")R=F;else if(O=="--cron")N=F;else if(O=="--description")K=F;else if(O=="--every")Te=F;else if(O=="--expected-revision")ue=F;else if(O=="--file")H=F;else if(O=="--flow")Ae=F;else if(O=="--name")nt=F;else if(O=="--comment")ko=F;else if(O=="--input")$n=F;else if(O=="--trigger")i=F;else if(O=="--outputs")s=F;else if(O=="--cursor")L=F;else if(O=="--timezone")Io=F;else if(O=="--set")nr.push(F);else if(O=="--unset")aa.push(F);else if(O=="--source"){if(F!="draft"&&F!="live")throw new I("cli.invalid-arguments","--source must be draft or live.");ia=F}else if(O=="--status"){if(!Cw.has(F))throw new I("cli.invalid-arguments",`Unknown Run status ${JSON.stringify(F)}.`);vo=F}else{let on=Number(F),Km=O=="--offset"?0:1;if(!Number.isSafeInteger(on)||on<Km||O=="--limit"&&on>100||O=="--max-bytes"&&on>1048576)throw new I("cli.invalid-arguments",`${O} has an invalid value.`);if(O=="--limit")Tn=on;else if(O=="--offset")l=on;else if(O=="--max-bytes")p=on;else So=on}}else if(O.startsWith("-"))throw new I("cli.invalid-arguments",`Unknown option ${JSON.stringify(O)}.`);else r.push(O)}if(g!=null){if(r[0]=="runs"&&r[1]=="results")m=g;else if(h=Number(g),!Number.isSafeInteger(h)||h<0)throw new I("cli.invalid-arguments","--after must be a non-negative event sequence.")}return{idempotencyKey:n,...m==null?{}:{resultAfter:m},...p==null?{}:{maxBytes:p},...l==null?{}:{offset:l},...u==null?{}:{pointer:u},...a==null?{}:{revision:a},...c==null?{}:{publication:c},...ko==null?{}:{comment:ko},...t==null?{}:{expectedPublication:t},...h==null?{}:{after:h},...S==null?{}:{code:S},...R==null?{}:{connection:R},...N==null?{}:{cron:N},...L==null?{}:{cursor:L},...K==null?{}:{description:K},...Te==null?{}:{every:Te},...ue==null?{}:{expectedRevision:ue},...H==null?{}:{file:H},...Ae==null?{}:{flow:Ae},follow:jn,...$n==null?{}:{input:$n},json:Nn,...Tn==null?{}:{limit:Tn},...nt==null?{}:{name:nt},positionals:r,options:o,...i==null?{}:{trigger:i},...s==null?{}:{outputs:s},sets:nr,source:ia,...vo==null?{}:{status:vo},...xo==null?{}:{pendingWait:xo},full:sa,...So==null?{}:{timeoutMs:So},...Io==null?{}:{timezone:Io},unsets:aa,wait:ca,yes:ua}}var Gs=_().trim().refine((e)=>[...e].length<=2000,"Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();var Xn=_().min(1),Ow=Ke(),Rw=v({kind:E("graph.trigger.create"),nodeId:Xn,key:Xn,connectionId:Xn.optional(),name:Xn.optional(),config:se(Xn,Ow),schedule:dn.readonly().optional()});function Ws(e){return St(e),P(zr()).min(1).parse(e).map((n,t)=>{let{kind:r}=Rt(n,t,A({kind:Xn}).parse);return r=="graph.trigger.create"?Rt(n,t,Rw.parse):Hd(n,t)})}var sm=_().min(1).max(256),am=_().regex(/^[a-z][a-z0-9_.]{0,127}$/),cm=_().trim().min(1).max(128),go=_().min(1).max(256),um=v({version:E(1),name:cm,connectionId:sm,teamId:sm.nullable(),verificationToken:go,encryptKey:go,eventTypes:P(am).min(1).max(200).refine((e)=>new Set(e).size==e.length),manageSubscriptions:he()}),lm=v({version:E(1),expectedRevision:ge().positive(),name:cm,enabled:he(),eventTypes:P(am).min(1).max(200).refine((e)=>new Set(e).size==e.length),verificationToken:go.optional(),encryptKey:go.optional()}),dm=v({version:E(1),expectedRevision:ge().positive()});var pm={manual:"A Manual start node.",error:"A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",webhook:"A Webhook start node.",cron:"An hourly scheduled start node.",poll:"Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",integration:"Telegram webhook integration by key; replace CONNECTION_ID with an active Telegram connection.",decision:"AI Decision evaluates named questions against target and returns a complete answer object per output. Configure target before running.",openapi:"A fixed JSON API operation. Replace the example document and URL before running.",connector:"A Connector Task and its node. Replace ACTION_ID, CONNECTION_ID and port definitions using connector_get / connector show.",code:"A JavaScript module and its node. Use Code for custom computation; use Connector Tasks for existing actions.",condition:"A condition with true and false execution branches.",value:"A fixed value node.",approval:"An Approval with approve and reject decision branches and a built-in notification output.",wait:"A Wait with a continue action and a built-in notification output.",agent:"An Agent with code computation enabled. Configure a model available in the deployment.","llm-chat":"An LLM chat Task and its node; configure a model available in the deployment.","llm-json":"An LLM JSON Task and its node; configure a model available in the deployment.","poll-notification":"Gmail events \u2192 JavaScript text formatting \u2192 Connector notification. Replace connection/action IDs and match the notification input ports."},Aw=Object.keys(pm),Pw=Aw.map((e)=>({name:e,description:pm[e]}));var gP=v({comment:Gs}),ho=Ke(),ke=_().min(1),ve=E(1),fm=ke.refine((e)=>e==e.trim()&&Ur(e)==null,"Flow name is invalid."),mm=se(_(),se(_(),ho)),gm=v({nodeId:ke,outputs:se(_(),ho)}),Y={authoringCheck:Ss,authoringEdit:Kt,authoringRead:no,authoringSearch:to,authoringSchema:rf,loadOpenApiDocument:v({url:_().min(1).max(8192),version:ve}),createEventSource:um,updateEventSource:lm,eventSourceRevision:dm,createFlow:v({name:fm,teamId:ke.optional(),version:ve}),renameFlow:v({name:fm,version:ve}),changeDraft:v({expectedRevisionId:ke,operations:P(ho).min(1),version:ve}),repairDraft:v({expectedRevisionId:ke,version:ve}),setEnabled:v({enabled:he(),expectedPublicationId:ke,version:ve}),updatePresentation:v({expectedRevision:ge().positive(),value:se(_(),ho),version:ve}),checkFlow:v({engineContract:ke,version:ve}),publishFlow:v({engineContract:ke,expectedLivePublicationId:ke.nullable(),version:ve}),rollbackFlow:v({expectedLivePublicationId:ke,version:ve}),createDraftRun:v({engineContract:ke,inputs:mm,trigger:gm,version:E(2)}),createLiveRun:v({publicationId:ke,inputs:mm,trigger:gm,version:E(2)}),resolveWait:v({action:ae(["approve","continue","reject"]),comment:Gs,version:ve}),putVariable:v({value:_().refine((e)=>new TextEncoder().encode(e).byteLength<=65536,"Variable value is too large.")}),queryConnectorAccessCandidates:v({providerIds:P(ke.max(256)).min(1).refine((e)=>new Set(e).size==e.length,"Duplicate provider IDs."),version:ve}),removeConnectionUsage:v({connectionId:ke,expectedRevisionId:ke,expectedAccessRevision:ge().nonnegative(),version:ve}),setConnectorService:v({expectedAccessRevision:ge().nonnegative(),version:ve}),addProviderAccessBinding:v({accessBindingId:ke,expectedAccessRevision:ge().nonnegative(),version:ve}),removeProviderAccessBinding:v({accessBindingId:ke,expectedAccessRevision:ge().nonnegative(),version:ve}),versionOnly:v({version:ve})};function ne(e){return(n)=>e.parse(n)}var yo={authoringCheck:ne(Y.authoringCheck),authoringEdit:ne(Y.authoringEdit),authoringRead:ne(Y.authoringRead),authoringSearch:ne(Y.authoringSearch),authoringSchema:ne(Y.authoringSchema),loadOpenApiDocument:ne(Y.loadOpenApiDocument),createEventSource:ne(Y.createEventSource),updateEventSource:ne(Y.updateEventSource),eventSourceRevision:ne(Y.eventSourceRevision),createFlow:ne(Y.createFlow),renameFlow:ne(Y.renameFlow),changeDraft(e){let n=Y.changeDraft.parse(e);return{...n,operations:Ws(n.operations)}},repairDraft:ne(Y.repairDraft),setEnabled:ne(Y.setEnabled),updatePresentation:ne(Y.updatePresentation),checkFlow:ne(Y.checkFlow),publishFlow:ne(Y.publishFlow),rollbackFlow:ne(Y.rollbackFlow),createDraftRun:ne(Y.createDraftRun),createLiveRun:ne(Y.createLiveRun),resolveWait:ne(Y.resolveWait),putVariable:ne(Y.putVariable),queryConnectorAccessCandidates:ne(Y.queryConnectorAccessCandidates),removeConnectionUsage:ne(Y.removeConnectionUsage),setConnectorService:ne(Y.setConnectorService),addProviderAccessBinding:ne(Y.addProviderAccessBinding),removeProviderAccessBinding:ne(Y.removeProviderAccessBinding),versionOnly:ne(Y.versionOnly)};var Hs=["expected-revision","idempotency-key"],Qs=["cursor","limit"],hm=[["read","<flow> [--input JSON|@file|- | --file path|-]",["input","file"]],["search","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["edit","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["list","[--cursor <cursor>] [--limit <count>]",Qs],["create","<name>",["idempotency-key"]],["show","<flow>",[]],["resources","<flow> [resource-id] [--publication <publicationId>]",["publication"]],["rename","<flow> <new-name>",[]],["delete","<flow> --yes",["yes"]],["check","<flow> [--revision <revisionId>]",["revision"]],["enable","<flow> --expected-publication <publicationId>",["expected-publication"]],["disable","<flow> --expected-publication <publicationId>",["expected-publication"]],["connector code-access","<flow> [--publication <publicationId>]",["publication"]],["connector candidates","<flow> <provider> [provider ...]",[]],["connector code-allow","<flow> <provider> <binding> <access-revision>",[]],["connector code-remove","<flow> <provider> <binding> <access-revision>",[]],["connector remove-usage","<flow> <connection> <access-revision>",Hs],["connector providers","[--flow <flow>]",["flow"]],["connector teams","",[]],["connector search","<query> [--flow <flow>]",["flow"]],["connector show","<action> [--flow <flow>]",["flow"]],["connector connections","<service> [--flow <flow>]",["flow"]],["event-source list","",[]],["trigger search","[query]",[]],["trigger show","<key>",[]],["run","<flow>",[...Hs,"expected-publication","source","trigger","outputs","input","wait","timeout"]],["runs list","--flow <flow>",["flow","status","pending-wait",...Qs]],["runs show","<run>",[]],["runs wait","<run>",["timeout"]],["runs resolve","<run> <wait> <continue|approve|reject>",["comment"]],["runs events","<run>",["after","limit","follow","timeout"]],["runs result","<run>",[]],["runs results","<run> [--after <resultId>]",["after"]],["runs read-result","<run> <result>",["pointer","offset","limit","max-bytes"]],["runs download-result","<run> <result>",[]],["runs cancel","<run>",[]],["publish","<flow>",[...Hs,"expected-publication","timeout"]],["publications list","<flow>",Qs],["publications show","<flow> <publication>",[]],["publications wait","<flow> <operation>",["timeout"]],["publications operation","<flow> <operation>",[]],["rollback","<flow> <publication>",["expected-publication","idempotency-key"]],["open","[flow]",[]],["workbench","[flow]",[]],["schema","[read|search|edit|check|node-type]",["flow","input"]]],jw={revision:{description:"Exact Revision to read or check; defaults to the current Draft.",type:"string"},publication:{description:"Exact Publication ID whose fixed Code connections are read; defaults to the Draft.",type:"string"},pointer:{description:"JSON Pointer within the stored result; defaults to the root.",type:"string"},offset:{description:"Page offset at the selected pointer.",type:"integer",minimum:0,default:0},"max-bytes":{description:"Maximum result page bytes.",type:"integer",minimum:1,maximum:1048576,default:15000},"expected-revision":{description:"Base Revision ID from read. Required with an explicit idempotency key for draft edits and draft runs.",type:"string"},"expected-publication":{description:"Fixed Publication ID. Use none when publishing without a Live Publication.",type:"string"},"idempotency-key":{description:"Stable identity of one mutation. Reuse only with the identical arguments and base identity.",type:"string"},source:{description:"Execution source.",type:"string",enum:["draft","live"],default:"draft"},trigger:{description:"Exact Trigger ID or unambiguous name. A sole Manual Trigger is selected automatically.",type:"string"},timeout:{description:"Wait budget in milliseconds; expiration does not cancel the operation. For node set, the node execution timeout.",type:"integer",minimum:1,default:60000},limit:{description:"Maximum items in one page.",type:"integer",minimum:1,maximum:100,default:100},after:{description:"Resume events after this sequence number; use nextAfter from the preceding response.",type:"integer",minimum:0,default:0},cursor:{description:"Opaque nextCursor from the preceding page; keep the same filters.",type:"string"},comment:{description:"Optional plain-text Wait decision comment (up to 2,000 Unicode code points).",type:"string"},"pending-wait":{description:"List runs with unresolved waits, including running and queued runs.",type:"boolean"},status:{description:"Filter runs by status.",type:"string",enum:["queued","starting","running","waiting","completed","failed","canceled","indeterminate"]},file:{description:"Authoring request JSON file path or - for stdin.",type:"string"},code:{description:"JavaScript source, @file, or - for stdin.",type:"string"},input:{description:"Authoring request JSON; literal JSON, @file, or -. For run, node ID to input values.",type:"string"},outputs:{description:"Trigger outputs: literal JSON, @file, or -. Defaults to {}.",type:"string"},set:{description:"handle=value; repeat for multiple fields. Values use port schemas, JSON, @file, or -.",type:"string"},unset:{description:"Input/config handle to remove; repeat for multiple fields.",type:"string"},connection:{description:"Exact active Connection ID, unambiguous display name, or default.",type:"string"},flow:{description:"Exact Flow ID or unambiguous name; fixes Connector Team scope.",type:"string"},name:{description:"Display name.",type:"string"},description:{description:"Trigger description.",type:"string"},cron:{description:"Cron expression; combine with --timezone. Mutually exclusive with --every.",type:"string"},timezone:{description:"IANA time zone for --cron.",type:"string"},every:{description:"Interval such as 5m, 1h, or 1d. Mutually exclusive with --cron.",type:"string"},wait:{description:"Wait until terminal, waiting for an action, or the wait budget expires."},follow:{description:"Stream event pages as NDJSON with --json; stop on terminal, Wait, or timeout."},full:{description:"Include complete Revision content, schemas, source code and revision metadata."},yes:{description:"Confirm the requested deletion."},json:{description:"Machine-readable JSON results and errors; NDJSON for followed events."},help:{description:"Show this command contract without contacting the host."}};function Ys(e,n="oo flow"){let t=e.join(" ");return hm.filter(([r])=>t==""||r==t||r.startsWith(`${t} `)).map(([r,o,i])=>({command:r,usage:`${n} ${r} ${o} [--json]`,options:[...i,"json","help"].map((s)=>Object.assign({name:`--${s}`,value:!["json","help","wait","follow","full","yes","pending-wait"].includes(s),repeatable:s=="set"||s=="unset"},jw[s],r=="runs results"&&s=="after"?{type:"string",minimum:void 0,default:void 0,description:"Result ID from nextAfter on the preceding page."}:{},r=="runs read-result"&&s=="limit"?{default:20}:{},r=="resources"&&s=="publication"?{description:"Exact Publication ID to inspect; defaults to current Live. Historical resources include configuration only."}:{}))}))}function ym(e){return hm.find(([n])=>n==e.slice(0,n.split(" ").length).join(" "))?.[2]}function bm(e="edits"){let n=Is(e);if(n!=null)return n;if(e=="edits")return Es();if(eo.includes(e))return Es(e);if(e=="outputs")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",description:"Named JSON trigger outputs. The selected trigger defines its outputs contract."};if(e=="input")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:{type:"object",additionalProperties:!0},description:"Node ID -> input handle -> JSON value."};return}function Xs(e){return Is(e)}function wm(e,n="oo flow"){if(e=="schema")return[`${n} schema read --json`,`${n} schema agent --json`,`${n} schema --flow FLOW_ID --input '{"action":"ACTION_ID"}' --json`];let t=Xs(e);if(t==null)return $w(n);if(e=="check")return[`${n} check FLOW_ID --revision REVISION --json`];return t.examples.map((r)=>`${n} ${e} FLOW_ID${Object.keys(r).length==0?"":` --input '${JSON.stringify(r)}'`} --json`)}function $w(e){return[`${e} list --limit 20 --json`,`${e} read FLOW_ID --json`,`${e} schema code --json`,`${e} edit FLOW_ID --file edits.json --json`,`${e} connector search email --flow FLOW_ID --json`,`${e} run FLOW_ID --expected-revision REVISION_ID --idempotency-key RUN_KEY --wait --timeout 60000 --json`,`${e} runs wait RUN_ID --timeout 60000 --json`,`${e} runs resolve RUN_ID WAIT_ID approve --json`,`${e} runs events RUN_ID --after 0 --follow --timeout 60000 --json`]}async function xm(e,n,t,r,o){let[i,s,a,...c]=t;switch(i){case"code-access":case"candidates":case"code-allow":case"code-remove":case"remove-usage":{let u=i=="code-access"?1:i=="candidates"?2:i=="remove-usage"?3:4;if(i=="candidates"?t.length<u+1:t.length!=u+1)throw new I("cli.invalid-arguments",`Invalid arguments for connector ${i}. See --help.`);let l=Nw(n),p;if(i=="code-access")p=r.publication==null?await e.getConnectorAccess(l):await e.getPublishedConnectorAccess(l,r.publication);else if(i=="candidates")p=await e.listProviderAccessBindingCandidates(l,t.slice(2));else{let m=Number(t.at(-1));if(!Number.isSafeInteger(m)||m<0)throw new I("cli.invalid-arguments","Access revision must be a nonnegative integer.");if(i=="remove-usage"){let g=await Hf(e,n,r);p=await e.removeConnectionUsage(l,a,g.draft.revisionId,m,r.idempotencyKey)}else if(i=="code-allow")p=await e.addProviderAccessBinding(l,a,c[0],m);else p=await e.removeProviderAccessBinding(l,a,c[0],m)}M(o,r.json,{...p,kind:`connector.${i}`},JSON.stringify(p,null,2));return}case"providers":{if(s!=null)throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector providers [--flow <flow>] [--json]`);let u=await e.listConnectorProviders(void 0,n?.flowId);M(o,r.json,{providers:u,kind:"connector.providers",version:1},u.map((l)=>`${l.serviceName} ${l.serviceId}`).join(`
62
- `));return}case"teams":{if(s!=null)throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector teams [--json]`);let u=await e.listConnectorTeams();M(o,r.json,{...u,kind:"connector.teams"},u.teams.map((l)=>`${l.name} ${l.id}`).join(`
63
- `));return}case"search":{if(s==null||a!=null)throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector search <query> [--json]`);let u=s.trim();if(u.length==0||u.length>256)throw new I("cli.invalid-arguments","Connector search query must contain 1\u2013256 characters.");let l=await e.searchConnectorActions(u,void 0,n?.flowId);M(o,r.json,{actions:l.map(As),kind:"connector.search",query:u,version:1},l.map(Us).join(`
64
- `));return}case"show":{if(s==null||a!=null)throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector show <action> [--json]`);let u=await Qf(e,s,n?.flowId);M(o,r.json,{action:u,kind:"connector.show",version:1},Us(u));return}case"connections":{if(s==null||a!=null)throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector connections <service> [--json]`);let u=await e.listConnectorConnections(s,void 0,n?.flowId);M(o,r.json,{connections:u,kind:"connector.connections",serviceId:s,version:1},u.map(em).join(`
65
- `));return}default:throw new I("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector <providers|teams|search|show|connections> ...`)}}async function vm(e,n,t,r){let[o,i,s]=n;switch(o){case"search":{if(s!=null)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger search [query] [--json]`);let a=i?.trim().toLowerCase();if(a!=null&&(a.length==0||a.length>256))throw new I("cli.invalid-arguments","Trigger search query must contain 1\u2013256 characters.");let c=js(await e.listTriggerKeys(),a);M(r,t.json,{keys:c,kind:"trigger.search",query:a,version:1},c.map(qs).join(`
66
- `));return}case"show":{if(i==null||s!=null)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger show <key> [--json]`);let a=await Xf(e,i);M(r,t.json,{definition:a,kind:"trigger.show",version:1},qs(a));return}default:throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger <search|show> ...`)}}function Nw(e){if(e==null)throw new I("cli.invalid-arguments","A Flow reference is required.");return e.flowId}async function km(e,n,t,r){fe(n,1,`${r.commandPrefix??"oo flow"} run <flow> [--source draft|live] [--trigger <name|id>] [--outputs <json|@file|->] [--input <json|@file|->] [--wait] [--json]`);let o=await ye(e,n[0]),i=await rm(t,r),s=t.source=="live"?t.expectedPublication==null?await e.getLive(o.flowId):{publication:await Yt(e,o.flowId,t.expectedPublication)}:void 0;if(t.source=="live"&&s?.publication==null)throw new I("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=s?.publication?.revisionId??t.expectedRevision??o.draftRevisionId,c=await e.getRevision(o.flowId,a),u=Object.entries(c.content.document.graph.nodes).filter(([,N])=>!("inputs"in N)),l=u.length==1&&u[0]?.[1].kind=="manual"?u[0][0]:void 0,p=t.trigger??l;if(p==null)throw new I("run.trigger-required","Choose a start node with --trigger <name|id>.",{candidates:u.map(([N,L])=>({triggerId:N,name:L.name}))});let m=Yf(c.content,p),g={};if(t.outputs!=null){let N=await _n(t.outputs,"--outputs","run.input-unreadable",r);try{let L=JSON.parse(N);if(L==null||typeof L!=="object"||Array.isArray(L))throw Error("Expected output object.");g=L}catch{throw new I("run.input-invalid","Trigger outputs must be valid JSON.")}}let h={nodeId:m.triggerId,outputs:g},S;if(s?.publication!=null)S=await e.createLiveRun(s.publication.publicationId,{inputs:i,trigger:h,idempotencyKey:t.idempotencyKey});else S=await e.createDraftRun(o.flowId,a,{inputs:i,trigger:h,idempotencyKey:t.idempotencyKey});let R=t.wait?await Ks(e,S,r,t.timeoutMs):{run:S,timedOut:!1};return M(r,t.json,{kind:"run.create",idempotencyKey:t.idempotencyKey,...R,version:1},Qt(R.run)),Xt(R.run,R.timedOut)}async function Sm(e,n,t,r){let[o,...i]=n;switch(o){case"list":{if(fe(i,0,`${r.commandPrefix??"oo flow"} runs list --flow <flow> [--status <status>] [--pending-wait] [--cursor <cursor>] [--limit <count>] [--json]`),t.flow==null)throw new I("cli.invalid-arguments",`${r.commandPrefix??"oo flow"} runs list requires --flow <flow>.`);let s=await ye(e,t.flow),a=await e.listRuns(s.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??Ls,...t.status==null?{}:{status:t.status},...t.pendingWait==null?{}:{pendingWait:t.pendingWait}});M(r,t.json,{kind:"run.list",...a,version:1},a.runs.map(nm).join(`
67
- `));return}case"show":{fe(i,1,`${r.commandPrefix??"oo flow"} runs show <run> [--json]`);let s=await e.getRun(i[0]);M(r,t.json,{kind:"run.show",run:s,version:1},Qt(s));return}case"wait":{fe(i,1,`${r.commandPrefix??"oo flow"} runs wait <run> [--timeout <milliseconds>] [--json]`);let s=i[0],a=Date.now()+(t.timeoutMs??60000);try{let c=await e.getRun(s,AbortSignal.timeout(t.timeoutMs??60000)),u=await Ks(e,c,r,Math.max(0,a-Date.now()));return M(r,t.json,{kind:"run.wait",runId:s,...u,version:1},Qt(u.run)),Xt(u.run,u.timedOut)}catch(c){if(Date.now()>=a||c instanceof Error&&c.name=="TimeoutError")return M(r,t.json,{kind:"run.wait",runId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(c instanceof I)throw c;throw new I("run.wait-failed",c instanceof Error?c.message:String(c),{runId:s})}}case"resolve":{fe(i,3,`${r.commandPrefix??"oo flow"} runs resolve <run> <wait> <continue|approve|reject> [--comment <text>] [--json]`);let[s,a,c]=i;if(c!="continue"&&c!="approve"&&c!="reject")throw new I("cli.invalid-arguments","Invalid Wait action.");let u=await e.resolveRunWait(s,a,c,t.comment);M(r,t.json,{kind:"run.resolve",resolution:u,version:1},JSON.stringify(u));return}case"events":{fe(i,1,`${r.commandPrefix??"oo flow"} runs events <run> [--after <sequence>] [--limit <count>] [--follow] [--timeout <milliseconds>] [--json]`);let s=i[0],a=t.after??0,c=Date.now()+(t.timeoutMs??60000),u;try{do{if(t.follow&&Date.now()>=c)break;let l=await e.getRunEvents(s,{after:a,limit:t.limit??Ls},t.follow?AbortSignal.timeout(Math.max(1,c-Date.now())):void 0);if(a=l.nextAfter,M(r,t.json,{...l,kind:"run.events",runId:s,version:1},l.events.map(tm).join(`
68
- `)),!t.follow)return;if(u=await e.getRun(s,AbortSignal.timeout(Math.max(1,c-Date.now()))),Wf(l.events.at(-1)))return Xt(u);if(t.after!=null&&l.events.length==0&&l.done)return Xt(u);if(u.waits.length>0)return M(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!1,version:1},Qt(u)),2;let p=c-Date.now();if(p<=0)break;if(l.events.length==0)await r.wait(Math.min(1000,p))}while(t.follow)}catch(l){if(!t.follow||Date.now()<c&&!(l instanceof Error&&l.name=="TimeoutError"))throw new I("run.events-failed",l instanceof Error?l.message:String(l),{runId:s,nextAfter:a})}return M(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!0,version:1},`timeout ${s} ${a}`),3}case"results":{fe(i,1,`${r.commandPrefix??"oo flow"} runs results <run> [--after <resultId>]`);let s=await e.listRunResults(i[0],t.resultAfter);M(r,t.json,{kind:"run.results",...s},JSON.stringify(s));return}case"read-result":{fe(i,2,`${r.commandPrefix??"oo flow"} runs read-result <run> <result> [--pointer <pointer>] [--offset <offset>] [--limit <limit>] [--max-bytes <bytes>]`);let s=await e.readRunResult(i[0],i[1],{pointer:t.pointer??"",offset:t.offset??0,...t.limit==null?{}:{limit:t.limit},...t.maxBytes==null?{}:{maxBytes:t.maxBytes}});M(r,t.json,{kind:"run.result-page",...s},JSON.stringify(s));return}case"download-result":{fe(i,2,`${r.commandPrefix??"oo flow"} runs download-result <run> <result>`);let s=await e.downloadRunResult(i[0],i[1]);r.stdout.write(await s.text());return}case"result":{fe(i,1,`${r.commandPrefix??"oo flow"} runs result <run> [--json]`);let s=await e.getRunResult(i[0]);return M(r,t.json,{kind:"run.result",result:s,version:1},JSON.stringify(s)),s.status=="completed"?0:1}case"cancel":{fe(i,1,`${r.commandPrefix??"oo flow"} runs cancel <run> [--json]`);let s=await e.cancelRun(i[0]);M(r,t.json,{cancellation:s,kind:"run.cancel",version:1},`${s.status} ${s.runId} ${s.cancelAccepted?"accepted":"already-terminal"}`);return}default:throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} runs <list|show|wait|resolve|events|result|results|read-result|download-result|cancel>`)}}async function Im(e,n,t,r){fe(n,1,`${r.commandPrefix??"oo flow"} publish <flow> [--json]`);let o=await ye(e,n[0]),i=t.expectedPublication=="none"?null:t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId??null,s=await e.publishFlow(o.flowId,t.expectedRevision??o.draftRevisionId,i,{idempotencyKey:t.idempotencyKey}),a=await Bs(e,o.flowId,s,r,t.timeoutMs);if(s=a.operation,s.status=="pending")return M(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,flowId:o.flowId,...a,version:1},JSON.stringify(s)),3;if(s.status=="failed")throw new I(s.issue.code,s.issue.message,{...s.issue.nodeId==null?{}:{nodeId:s.issue.nodeId},operationId:s.operationId,flowId:o.flowId,idempotencyKey:t.idempotencyKey});let c;try{c=await Yt(e,o.flowId,s.publicationId)}catch(u){throw new I("publication.read-failed",u instanceof Error?u.message:String(u),{flowId:o.flowId,operationId:s.operationId,publicationId:s.publicationId,idempotencyKey:t.idempotencyKey})}M(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,publication:c,version:1},Ht(c))}async function Em(e,n,t,r){let[o,i,s,...a]=n;if(i==null||a.length>0)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`);let c=await ye(e,i);if(o=="list"){if(s!=null)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications list <flow> [--cursor <cursor>] [--limit <count>]`);let u=await e.listPublications(c.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??Js});M(r,t.json,{flow:c,kind:"publication.list",...u,version:1},u.publications.map(Ht).join(`
69
- `));return}if((o=="operation"||o=="wait")&&s!=null){let u=Date.now()+(t.timeoutMs??60000);try{let l=await e.getPublishOperation(c.flowId,s,o=="wait"?AbortSignal.timeout(t.timeoutMs??60000):void 0),p=o=="wait"?await Bs(e,c.flowId,l,r,Math.max(0,u-Date.now())):{operation:l,timedOut:!1};return M(r,t.json,{kind:`publication.${o}`,flowId:c.flowId,...p,version:1},JSON.stringify(p.operation)),p.operation.status=="failed"?1:p.operation.status=="pending"?3:0}catch(l){if(o=="wait"&&(Date.now()>=u||l instanceof Error&&l.name=="TimeoutError"))return M(r,t.json,{kind:"publication.wait",flowId:c.flowId,operationId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(l instanceof I)throw l;throw new I("publication.wait-failed",l instanceof Error?l.message:String(l),{flowId:c.flowId,operationId:s})}}if(o=="show"&&s!=null){let u=await Yt(e,c.flowId,s);M(r,t.json,{kind:"publication.show",publication:u,version:1},Ht(u));return}throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`)}async function Cm(e,n,t,r){fe(n,2,`${r.commandPrefix??"oo flow"} rollback <flow> <publication> [--json]`);let o=await ye(e,n[0]),i=await Yt(e,o.flowId,n[1]),s=t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId;if(s==null)throw new I("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=await e.rollbackFlow(o.flowId,i.publicationId,s,{idempotencyKey:t.idempotencyKey});M(r,t.json,{kind:"publication.rollback",expectedPublicationId:s,idempotencyKey:t.idempotencyKey,publication:a,version:1},Ht(a))}async function Om(e,n,t,r){let[o,...i]=t.positionals;switch(o){case"read":case"search":case"edit":{fe(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> [--input JSON|@file|-] [--file path|-] --json`);let s=await ye(e,i[0]);if(t.file!=null&&t.input!=null)throw new I("cli.invalid-arguments","Choose --input or --file.");let a=t.file==null?t.input:t.file=="-"?"-":`@${t.file}`,c=a==null?{}:JSON.parse(await _n(a,"input","flow.authoring-unreadable",r)),u=o=="read"?await e.readAuthoring(s.flowId,yo.authoringRead(c)):o=="search"?await e.searchAuthoring(s.flowId,yo.authoringSearch(c)):await e.editAuthoring(s.flowId,yo.authoringEdit(c));r.stdout.write(`${JSON.stringify(u)}
70
- `);return}case"connector":{let a=["code-access","candidates","code-allow","code-remove","remove-usage"].includes(i[0]??"")?await Tw(e,i.slice(1)):t.flow==null?void 0:await ye(e,t.flow);return await xm(e,a,i,t,r)}case"event-source":{if(i.length!=1||i[0]!="list")throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} event-source list [--json]`);let s=await e.listEventSources(),a=`No event sources are visible to this identity. Run "${r.commandPrefix??"oo flow"} workbench" to create and verify a Feishu event source, then list again.`;M(r,t.json,{...s,kind:"event-source.list",...s.sources.length==0?{guidance:a}:{}},s.sources.length==0?a:s.sources.map((c)=>[c.sourceId,c.name,c.teamId??"-",c.connectionId,!c.enabled?"disabled":c.verifiedAt==null?"unverified":"verified",c.eventTypes.join(",")].join("\t")).join(`
71
- `));return}case"run":return await km(e,i,t,r);case"runs":return await Sm(e,i,t,r);case"publish":return await Im(e,i,t,r);case"publications":return await Em(e,i,t,r);case"rollback":return await Cm(e,i,t,r);case"trigger":return await vm(e,i,t,r);case"open":case"workbench":{if(i.length>1)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} ${o} [flow] [--json]`);if(n.getWorkbenchUrl==null)throw new I("workbench.unavailable","This CLI host cannot provide a Workbench URL.");let s=i[0]==null?void 0:await ye(e,i[0]),a=await n.getWorkbenchUrl(s?.flowId);if(o=="open")await r.openUrl(a);M(r,t.json,{...s==null?{}:{flow:s},kind:`flow.${o}`,url:a,version:1},a);return}case"list":{fe(i,0,`${r.commandPrefix??"oo flow"} list [--json]`);let s=await e.listFlows({cursor:t.cursor,limit:t.limit??100});M(r,t.json,{...s,kind:"flow.list",version:1},s.flows.map(Pn).join(`
72
- `));return}case"create":{fe(i,1,`${r.commandPrefix??"oo flow"} create <name> [--json]`);let s=await e.createFlow(Fs(i[0],"Flow"),t.idempotencyKey);M(r,t.json,{flow:s,idempotencyKey:t.idempotencyKey,kind:"flow.create",version:1},Pn(s));return}case"show":{fe(i,1,`${r.commandPrefix??"oo flow"} show <flow> [--json]`);let s=await ye(e,i[0]);M(r,t.json,{flow:s,kind:"flow.show",version:1},Pn(s));return}case"resources":{if(i.length<1||i.length>2)throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} resources <flow> [resource-id] [--publication <publicationId>] [--json]`);let s=await ye(e,i[0]),a=i[1]==null?await e.listPublicationResources(s.flowId,t.publication):await e.getPublicationResource(s.flowId,i[1],t.publication),c=`${a.status} ${a.publicationId} ${a.revisionId}${a.enabled==null?"":` ${a.enabled?"enabled":"disabled"}`}`,u="resource"in a?`${c}
73
- ${JSON.stringify(a.resource,null,2)}`:[c,...a.resources.map((l)=>[l.resourceId,l.name,`${l.kind}.${l.type}`,l.runtime?.health??"-",l.runtime?.endpointUrl??"-"].join("\t"))].join(`
74
- `);M(r,t.json,{...a,kind:"resource"in a?"flow.resource":"flow.resources"},u);return}case"rename":{fe(i,2,`${r.commandPrefix??"oo flow"} rename <flow> <new-name> [--json]`);let s=await ye(e,i[0]),a=await e.renameFlow(s.flowId,Fs(i[1],"Flow"));M(r,t.json,{flow:a,kind:"flow.rename",version:1},Pn(a));return}case"delete":{if(fe(i,1,`${r.commandPrefix??"oo flow"} delete <flow> --yes [--json]`),!t.yes)throw new I("flow.confirmation-required","Flow deletion requires --yes.");let s=await ye(e,i[0]),a=await e.deleteFlow(s.flowId);M(r,t.json,{flow:a,kind:"flow.delete",version:1},Pn(a));return}case"enable":case"disable":{if(fe(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> --expected-publication <publicationId>`),t.expectedPublication==null||t.expectedPublication=="none")throw new I("cli.invalid-arguments","--expected-publication must identify the observed Live publication.");let s=await ye(e,i[0]),a=await e.setFlowEnabled(s.flowId,t.expectedPublication,o=="enable");M(r,t.json,{flow:a,kind:`flow.${o}`,version:1},Pn(a));return}case"check":{fe(i,1,`${r.commandPrefix??"oo flow"} check <flow> [--revision <revisionId>] [--json]`);let s=await ye(e,i[0]),a=t.revision??s.draftRevisionId,c=await e.checkAuthoring(s.flowId,a);return M(r,t.json,{check:c,valid:c.valid,revisionId:a,kind:"flow.check",scope:"revision",version:1},`${c.valid?"valid":"invalid"} revision ${s.name} ${s.flowId}`),c.valid?0:1}default:throw new I("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} <list|create|show|resources|read|search|edit|schema|rename|delete|check|enable|disable|connector|event-source|trigger|run|runs|publish|publications|rollback|workbench>`)}}async function Tw(e,n){let t=n[0];if(t==null)throw new I("cli.invalid-arguments","A Flow reference is required.");return await ye(e,t)}var et={};var Am=(e)=>e,bo=Object.is,zw=(e,n)=>{if(bo(e,n))return!0;if(!Array.isArray(e)||!Array.isArray(n))return!1;let t=e.length;if(n.length!==t)return!1;for(let r=0;r<t;r++)if(!bo(e[r],n[r]))return!1;return!0},Dw=(e)=>e.value,Vw=(e)=>e.map(Dw),Zw=(e)=>e.$version,wo=(e,n)=>{try{e(n)}catch(t){console.error(t)}},Pm=(e,n)=>(e.set=n,e);var Mw=Promise.resolve(),ea=new Set,Fw=new Set,er=ea,na,Jw=()=>{let e=er;er=er===ea?Fw:ea,na=!1;for(let n of e)n.t();e.clear()},Lw=(e)=>{er.add(e),na=na||Mw.then(Jw)},qw=(e)=>er.delete(e);var Rm=new FinalizationRegistry(wo),_m=class{constructor(e,n,t){if(this.#r=e,this.q=(n?.equal??bo)||void 0,this.e=n?.eager,this.m=n?.name,this.#n=n?.onDisposeValue,t){let r=new WeakRef(this),o=()=>{if(i){let s=i;i=void 0,s()}},i=t(()=>{let s=r.deref();if(s)s.n();else o()});if(i)Rm.register(this,this.#e=o)}}g=this;b=new Map;s=4;v;c=et;q;e;m;u=()=>{if(this.s&4){this.s&=-5;let e=this.#r();if(this.c===et)this.w(e);else if(!this.q?.(e,this.c)){if(this.w(e),this.s&1)this.s|=2}}return this.c};n=()=>{if(this.#o)console.error(this.c,Error(`${this.m||""} disposed`));if(this.s|=4,this.b.size){if(this.s|=1,this[3])this.#t(3);if(this[2]){if(this.u(),this.s&2)this.#t(2)}if(this[1])Lw(this);else this.s&=-4}};a(e,n){let t=this.b.get(e);if(t)this[t]--;return this.b.set(e,n),this[n]++,()=>this.r(e)}r(e){if(e){let n=this.b.get(e);if(n)this.b.delete(e),this[n]--}else this.b.clear(),this[1]=this[2]=this[3]=0,qw(this)}t(){if(this[1]){if(this.u(),this.s&2)this.#t(1)}this.s&=-4}d(){let e=this.c;if(this.r(),Rm.unregister(this),this.#e?.(),this.#o=!0,this.#n&&e!==et)this.#n(e)}w(e){this.w=this.q?.(e,e)?this.y:this.x,this.w(e)}x(e){let n=this.c;if(this.c=e,this.v=Symbol(),this.#n&&n!==et&&n!==e)this.#n(n)}y(e){let n=this.c;if(this.c=this.v=e,this.#n&&n!==et&&n!==e)this.#n(n)}[1]=0;[2]=0;[3]=0;#e;#n;#r;#t(e){for(let[n,t]of this.b)if(t===e)wo(n,this.c)}#o},Uw=class{#e=new WeakSet;constructor(e){this.g=e.g,this.e=e.e,this.u=e.u,this.n=e.n,this.b=e.b}get v(){return this.g.v}g;b;e;u;n;a(e,n){return this.#e.add(e),this.g.a(e,n)}r(e){if(e){if(this.#e.has(e))this.#e.delete(e),this.g.r(e)}else for(let n of this.g.b.keys())this.r(n)}d(){this.r()}},ta=class{#e;constructor(e){this.#e=e,this.get=e.u,e.u()}get name(){return this.#e.m}get $version(){return this.get(),this.#e.v}get value(){return this.get()}set value(e){this.set?.(e)}set;get;ref(e){let n=new ta(new Uw(this.#e));return e&&this.set?Pm(n,this.set):n}reaction(e,n=this.#e.e){return this.#e.a(e,n?2:1)}subscribe(e,n=this.#e.e){let t=this.reaction(e,n);return wo(e,this.get()),t}$valCompute(e){return this.#e.a(e,3)}unsubscribe(e){this.#e.r(e)}dispose(){this.#e.d()}toString(){return String(this.get())}toJSON(e){let n=this.get();return n&&n.toJSON?n.toJSON(e):n}},Kw=(e,n)=>{let t=e,o=new _m(()=>t,n),i=(a)=>{if(!o.q?.(a,t))t=a,o.n()};return[new ta(o),i]},ra=(e,n)=>Pm(...Kw(e,n));var jm=(e,n,t)=>new ta(new _m(e,t,n)),$m=(e,n=Am,t)=>{let r,o;return jm(()=>{let i=e.map(Zw);if(!o||!zw(i,o))o=i,r=n(Vw(e));return r},(i)=>{let s=e.map((a)=>a.$valCompute(i));return()=>s.forEach(wo)},t)};var oa=(e,n=Am,t)=>{let r,o=et;return jm(()=>{let i=e.$version;if(!bo(i,o))o=i,r=n(e.value);return r},(i)=>e.$valCompute(i),t)};var Nm=(e,n={},t="")=>{for(let[r,o]of Object.entries(e))if(typeof o==="string")n[t+r]=o;else Nm(o,n,t+r+".");return n},Bw=(e)=>{let n=[],t=[],r=/{{(\S+?)}}/gi,o,i=0;while(o=r.exec(e))n.push(e.slice(i,o.index),""),t.push(o[1]),i=o.index+o[0].length;if(n.push(e.slice(i)),t.length<=0)return!1;return(s)=>{for(let a=t.length-1;a>=0;a--)n[a*2+1]=s[t[a]]??t[a];return n.join("")}},Tm=class e{constructor(n,t,r){this.t=(i,s)=>this.t$.get()(i,s),this.fetcher=r?.fetcher;let o=new Map;this.locales$=ra(t),this.lang$=ra(n),this.locale$=$m([this.lang$,this.locales$],([i,s])=>s[i]||{}),this.a=oa(this.locale$,Nm),this.t$=oa(this.a,(i)=>((s,a,c)=>{if(c){let u=c["@"];if(u!=null){let l=`${a}@${u}`;if(s[l])a=l}else{let l=c[":option"];if(l!=null){let p;a=s[p=`${a}.${l}`]||s[p=`${a}.other`]?p:a}}if(s[a]){let l=o.get(a);if(l??o.set(a,l=Bw(s[a])),l)return l(c)}}return s[a]||a}).bind(o.clear(),i))}static async preload(n,t){return new e(n,{[n]:await t(n)},{fetcher:t})}get lang(){return this.lang$.value}get locales(){return this.locales$.value}get locale(){return this.locale$.value}async switchLang(n){if(!this.locales$.value[n]&&this.fetcher)this.addLocale(n,await this.fetcher(n));this.lang$.set(n)}hasKey(n){return!!this.a.value[n]}addLocale(n,t){this.locales$.set({...this.locales,[n]:t})}dispose(){this.lang$.dispose(),this.t$.dispose(),this.locales$.dispose(),this.locale$.dispose(),this.a.dispose()}};var zm={help:{usage:"Usage: {{command}}",title:"Open Flow commands",options:"Options: --json, --cursor <cursor>, --limit <count>"}};var Dm={help:{usage:"Utilisation : {{command}}",title:"Commandes Open Flow",options:"Options : --json, --cursor <cursor>, --limit <count>"}};var Vm={help:{usage:"\u4F7F\u3044\u65B9\uFF1A{{command}}",title:"Open Flow \u30B3\u30DE\u30F3\u30C9",options:"\u30AA\u30D7\u30B7\u30E7\u30F3\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var Zm={help:{usage:"\uC0AC\uC6A9\uBC95: {{command}}",title:"Open Flow \uBA85\uB839\uC5B4",options:"\uC635\uC158: --json, --cursor <cursor>, --limit <count>"}};var Mm={help:{usage:"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: {{command}}",title:"\u041A\u043E\u043C\u0430\u043D\u0434\u044B Open Flow",options:"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: --json, --cursor <cursor>, --limit <count>"}};var Fm={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9009\u9879\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var Jm={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9078\u9805\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var nx={en:zm,"zh-CN":Fm,"zh-TW":Jm,ja:Vm,ko:Zm,ru:Mm,fr:Dm},tx=Object.fromEntries(Co.map((e)=>[e,nx[e]]));function Lm(e=da){return new Tm(or([e]),tx)}function rx(e,n){let t=n.filter((i)=>!i.startsWith("-")),r=Ys(t,e.commandPrefix);while(r.length==0&&t.length>0)t.pop(),r=Ys(t,e.commandPrefix);let o=Lm(e.language);try{let i=r.length==1?Xs(r[0].command):void 0,s=wm(r.length==1?r[0].command:"",e.commandPrefix),a={kind:"cli.help",version:1,commands:r.length==1?r:r.map(({command:c,usage:u})=>({command:c,usage:u})),...i==null?{}:{request:i.request},examples:s,exitCodes:{0:"Success or accepted asynchronous operation.",1:"Error or unsuccessful terminal Run.",2:"Run is waiting for an explicit action; inspect run.waits.",3:"Waiting timed out or publication is pending; the operation continues."},notes:i==null?[...e.scopeGuidance??["The oo host selects the team for the whole invocation with --team <name>; Flow commands use that authenticated scope."],"--timeout is a wait budget in milliseconds (default 60000).","--follow --json writes NDJSON pages immediately; resume from nextAfter.","Use read/search to locate nodes, schema read|search|edit|check for requests, and schema <type> for configuration and ports.","Use edit with baseRevision, requestId and an ordered edits array. Read selected text before an exact text.edit.","Retry mutations with the same idempotency key, fixed revision/publication and identical arguments."]:[i.guidance,...r[0].command=="check"?[]:["Use either --input (literal JSON, @file, or - for stdin) or --file (path or -), never both."]]};return n.includes("--json")?JSON.stringify(a):[o.t("help.title"),"",...r.map((c)=>r.length!=1?c.usage:`${c.usage}
61
+ `)}function kn(e){return`${e.name} ${e.flowId} ${e.status}`}function rr(e){return`${e.operation} ${e.publicationId} ${e.revisionId} ${e.createdAt}`}function or(e){let n=e.source=="draft"?"":` ${e.publicationId}`;return`${e.source} ${e.status} ${e.runId} ${e.revisionId}${n}${e.waits.length==0?"":`
62
+ ${JSON.stringify(e.waits)}`}`}function fm(e){return`${e.source} ${e.status} ${e.runId} ${e.revisionId}`}function mm(e){return`${e.sequence} ${e.kind} ${JSON.stringify(e.payload)}`}async function Sn(e,n,t,r){try{if(e=="-")return await r.readStdin();if(!e.startsWith("@"))return e;let o=e.slice(1);if(o.length==0)throw new E("cli.invalid-arguments",`${n} @ requires a file path.`);return await r.readFile(o)}catch(o){if(o instanceof E)throw o;throw new E(t,o instanceof Error?o.message:String(o))}}async function gm(e,n){if(e.input==null)return{};let t=await Sn(e.input,"--input","run.input-unreadable",n),r;try{r=JSON.parse(t)}catch{throw new E("run.input-invalid","Run input must be valid JSON.")}if(r==null||typeof r!="object"||Array.isArray(r))throw new E("run.input-invalid","Run input must be an object keyed by node ID.");for(let o of Object.values(r))if(o==null||typeof o!="object"||Array.isArray(o))throw new E("run.input-invalid","Each Run input node must contain an object keyed by input handle.");return r}async function ir(e,n,t){let r=new Set,o;do{let i=await e.listPublications(n,{cursor:o,limit:Ws}),s=i.publications.find((a)=>a.publicationId==t);if(s!=null)return s;if(o=i.nextCursor,o!=null&&r.has(o))throw new E("page.invalid-cursor","The deployment returned a repeated Publication cursor.");if(o!=null)r.add(o)}while(o!=null);throw new E("publication.not-found",`Publication ${JSON.stringify(t)} was not found.`)}async function Ys(e,n,t,r=60000){let o=Date.now()+r,i=n;while(!Ow.has(i.status)&&i.waits.length==0){let s=o-Date.now();if(s<=0)return{run:i,timedOut:!0};if(await t.wait(Math.min(1000,s)),Date.now()>=o)return{run:i,timedOut:!0};try{i=await e.getRun(i.runId,AbortSignal.timeout(Math.max(1,o-Date.now())))}catch(a){if(Date.now()>=o||a instanceof Error&&a.name=="TimeoutError")return{run:i,timedOut:!0};throw new E("run.wait-failed",a instanceof Error?a.message:String(a),{runId:i.runId})}}return{run:i,timedOut:!1}}function sr(e,n=!1){if(n)return 3;if(e.waits.length>0)return 2;return e.status=="failed"||e.status=="canceled"||e.status=="indeterminate"?1:0}function hm(e){return new E(e.code,e.message,{status:e.status,...e.details})}async function Xs(e,n,t,r,o=60000){let i=Date.now()+o,s=t;while(s.status=="pending"){let a=i-Date.now();if(a<=0)return{operation:s,timedOut:!0};if(await r.wait(Math.min(1000,a)),Date.now()>=i)return{operation:s,timedOut:!0};try{s=await e.getPublishOperation(n,s.operationId,AbortSignal.timeout(Math.max(1,i-Date.now())))}catch(c){if(Date.now()>=i||c instanceof Error&&c.name=="TimeoutError")return{operation:s,timedOut:!0};throw new E("publication.wait-failed",c instanceof Error?c.message:String(c),{flowId:n,operationId:s.operationId})}}return{operation:s,timedOut:!1}}var _w=new Set(xo);function ym(e){let n=Pw(),t,r=[],o=[],i,s,a,c,u,l,d,m,g,h,I,R,N,L,K,ze,le,H,je,Nn=!1,Tn,zn=!1,Dn,at,ur=[],pa="draft",Ao,jo,fa=!1,Po,_o,$o,ma=[],ga=!1,ha=!1;for(let ct=0;ct<e.length;ct+=1){let ut=e[ct],lr=ut.startsWith("--")?ut.indexOf("="):-1,O=lr<0?ut:ut.slice(0,lr),dr=lr<0?void 0:ut.slice(lr+1);if(dr!=null&&["--json","--follow","--wait","--yes","--full","--pending-wait"].includes(O))throw new E("cli.invalid-arguments",`${O} does not accept a value.`);if(O.startsWith("--")){let M=O.slice(2);if(o.includes(M)&&M!="set"&&M!="unset")throw new E("cli.invalid-arguments",`Duplicate option --${M}.`);o.push(M)}if(O=="--json")zn=!0;else if(O=="--follow")Nn=!0;else if(O=="--wait")ga=!0;else if(O=="--yes")ha=!0;else if(O=="--pending-wait")Ao=!0;else if(O=="--full")fa=!0;else if(O=="--idempotency-key"||O=="--expected-publication"||O=="--revision"||O=="--publication"||O=="--pointer"||O=="--offset"||O=="--max-bytes"||O=="--code"||O=="--connection"||O=="--cron"||O=="--description"||O=="--every"||O=="--expected-revision"||O=="--file"||O=="--flow"||O=="--name"||O=="--source"||O=="--input"||O=="--trigger"||O=="--outputs"||O=="--status"||O=="--cursor"||O=="--limit"||O=="--after"||O=="--comment"||O=="--timeout"||O=="--timezone"||O=="--set"||O=="--unset"){let M=dr??e[ct+1];if(M==null||M.length==0||dr==null&&M.startsWith("-")&&M!="-")throw new E("cli.invalid-arguments",`${O} requires a value.`);if(dr==null)ct++;if(O=="--idempotency-key")n=M;else if(O=="--expected-publication")t=M;else if(O=="--revision")a=M;else if(O=="--publication")c=M;else if(O=="--pointer")u=M;else if(O=="--after")g=M;else if(O=="--code")I=M;else if(O=="--connection")R=M;else if(O=="--cron")N=M;else if(O=="--description")K=M;else if(O=="--every")ze=M;else if(O=="--expected-revision")le=M;else if(O=="--file")H=M;else if(O=="--flow")je=M;else if(O=="--name")at=M;else if(O=="--comment")Po=M;else if(O=="--input")Tn=M;else if(O=="--trigger")i=M;else if(O=="--outputs")s=M;else if(O=="--cursor")L=M;else if(O=="--timezone")$o=M;else if(O=="--set")ur.push(M);else if(O=="--unset")ma.push(M);else if(O=="--source"){if(M!="draft"&&M!="live")throw new E("cli.invalid-arguments","--source must be draft or live.");pa=M}else if(O=="--status"){if(!_w.has(M))throw new E("cli.invalid-arguments",`Unknown Run status ${JSON.stringify(M)}.`);jo=M}else{let an=Number(M),rg=O=="--offset"?0:1;if(!Number.isSafeInteger(an)||an<rg||O=="--limit"&&an>100||O=="--max-bytes"&&an>1048576)throw new E("cli.invalid-arguments",`${O} has an invalid value.`);if(O=="--limit")Dn=an;else if(O=="--offset")l=an;else if(O=="--max-bytes")d=an;else _o=an}}else if(O.startsWith("-"))throw new E("cli.invalid-arguments",`Unknown option ${JSON.stringify(O)}.`);else r.push(O)}if(g!=null){if(r[0]=="runs"&&r[1]=="results")m=g;else if(h=Number(g),!Number.isSafeInteger(h)||h<0)throw new E("cli.invalid-arguments","--after must be a non-negative event sequence.")}return{idempotencyKey:n,...m==null?{}:{resultAfter:m},...d==null?{}:{maxBytes:d},...l==null?{}:{offset:l},...u==null?{}:{pointer:u},...a==null?{}:{revision:a},...c==null?{}:{publication:c},...Po==null?{}:{comment:Po},...t==null?{}:{expectedPublication:t},...h==null?{}:{after:h},...I==null?{}:{code:I},...R==null?{}:{connection:R},...N==null?{}:{cron:N},...L==null?{}:{cursor:L},...K==null?{}:{description:K},...ze==null?{}:{every:ze},...le==null?{}:{expectedRevision:le},...H==null?{}:{file:H},...je==null?{}:{flow:je},follow:Nn,...Tn==null?{}:{input:Tn},json:zn,...Dn==null?{}:{limit:Dn},...at==null?{}:{name:at},positionals:r,options:o,...i==null?{}:{trigger:i},...s==null?{}:{outputs:s},sets:ur,source:pa,...jo==null?{}:{status:jo},...Ao==null?{}:{pendingWait:Ao},full:fa,..._o==null?{}:{timeoutMs:_o},...$o==null?{}:{timezone:$o},unsets:ma,wait:ga,yes:ha}}var ea=A().trim().refine((e)=>[...e].length<=2000,"Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();var it=A().min(1),qw=Me(),Uw=x({kind:k("graph.trigger.create"),nodeId:it,key:it,connectionId:it.optional(),name:it.optional(),config:oe(it,qw),schedule:xn.readonly().optional()});function na(e){return jn(e),P(Jn()).min(1).parse(e).map((n,t)=>{let{kind:r}=Ht(n,t,j({kind:it}).parse);return r=="graph.trigger.create"?Ht(n,t,Uw.parse):rf(n,t)})}var bm=A().min(1).max(256),wm=A().regex(/^[a-z][a-z0-9_.]{0,127}$/),xm=A().trim().min(1).max(128),Io=A().min(1).max(256),vm=x({version:k(1),name:xm,connectionId:bm,teamId:bm.nullable(),verificationToken:Io,encryptKey:Io,eventTypes:P(wm).min(1).max(200).refine((e)=>new Set(e).size==e.length),manageSubscriptions:ye()}),km=x({version:k(1),expectedRevision:he().positive(),name:xm,enabled:ye(),eventTypes:P(wm).min(1).max(200).refine((e)=>new Set(e).size==e.length),verificationToken:Io.optional(),encryptKey:Io.optional()}),Sm=x({version:k(1),expectedRevision:he().positive()});var Im={manual:"A Manual start node.",error:"A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",webhook:"A Webhook start node.",cron:"An hourly scheduled start node.",poll:"Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",integration:"Telegram webhook integration by key; replace CONNECTION_ID with an active Telegram connection.",decision:"AI Decision evaluates named questions against target and returns a complete answer object per output. Configure target before running.",openapi:"A fixed JSON API operation. Replace the example document and URL before running.",connector:"A Connector Task and its node. Replace ACTION_ID, CONNECTION_ID and port definitions using connector_get / connector show.",code:"A JavaScript module and its node. Use Code for custom computation; use Connector Tasks for existing actions.",condition:"A condition with true and false execution branches.",value:"A fixed value node.",approval:"An Approval with approve and reject decision branches and a built-in notification output.",wait:"A Wait with a continue action and a built-in notification output.",agent:"An Agent with code computation enabled. Configure a model available in the deployment.","llm-chat":"An LLM chat Task and its node; configure a model available in the deployment.","llm-json":"An LLM JSON Task and its node; configure a model available in the deployment.","poll-notification":"Gmail events \u2192 JavaScript text formatting \u2192 Connector notification. Replace connection/action IDs and match the notification input ports."},Kw=Object.keys(Im),Bw=Kw.map((e)=>({name:e,description:Im[e]}));var Yj=x({comment:ea}),ar=Me(),xe=A().min(1),we=k(1),ta=xe.refine((e)=>e==e.trim()&&Kr(e)==null,"Flow name is invalid."),Em=oe(A(),oe(A(),ar)),Cm=x({nodeId:xe,outputs:oe(A(),ar)}),Q={authoringCheck:Ps,authoringEdit:Yt,authoringRead:co,authoringSearch:uo,authoringSchema:ff,loadOpenApiDocument:x({url:A().min(1).max(8192),version:we}),createEventSource:vm,updateEventSource:km,eventSourceRevision:Sm,importFlow:x({file:ar,name:ta.optional(),teamId:xe.optional(),version:we}),createFlow:x({name:ta,teamId:xe.optional(),version:we}),renameFlow:x({name:ta,version:we}),changeDraft:x({expectedRevisionId:xe,operations:P(ar).min(1),version:we}),repairDraft:x({expectedRevisionId:xe,version:we}),setEnabled:x({enabled:ye(),expectedPublicationId:xe,version:we}),updatePresentation:x({expectedRevision:he().positive(),value:oe(A(),ar),version:we}),checkFlow:x({engineContract:xe,version:we}),publishFlow:x({engineContract:xe,expectedLivePublicationId:xe.nullable(),version:we}),rollbackFlow:x({expectedLivePublicationId:xe,version:we}),createDraftRun:x({engineContract:xe,inputs:Em,trigger:Cm,version:k(2)}),createLiveRun:x({publicationId:xe,inputs:Em,trigger:Cm,version:k(2)}),resolveWait:x({action:ce(["approve","continue","reject"]),comment:ea,version:we}),putVariable:x({value:A().refine((e)=>new TextEncoder().encode(e).byteLength<=65536,"Variable value is too large.")}),queryConnectorAccessCandidates:x({providerIds:P(xe.max(256)).min(1).refine((e)=>new Set(e).size==e.length,"Duplicate provider IDs."),version:we}),removeConnectionUsage:x({connectionId:xe,expectedRevisionId:xe,expectedAccessRevision:he().nonnegative(),version:we}),setConnectorService:x({expectedAccessRevision:he().nonnegative(),version:we}),addProviderAccessBinding:x({accessBindingId:xe,expectedAccessRevision:he().nonnegative(),version:we}),removeProviderAccessBinding:x({accessBindingId:xe,expectedAccessRevision:he().nonnegative(),version:we}),versionOnly:x({version:we})};function X(e){return(n)=>e.parse(n)}var Eo={authoringCheck:X(Q.authoringCheck),authoringEdit:X(Q.authoringEdit),authoringRead:X(Q.authoringRead),authoringSearch:X(Q.authoringSearch),authoringSchema:X(Q.authoringSchema),loadOpenApiDocument:X(Q.loadOpenApiDocument),createEventSource:X(Q.createEventSource),updateEventSource:X(Q.updateEventSource),eventSourceRevision:X(Q.eventSourceRevision),importFlow:X(Q.importFlow),createFlow:X(Q.createFlow),renameFlow:X(Q.renameFlow),changeDraft(e){let n=Q.changeDraft.parse(e);return{...n,operations:na(n.operations)}},repairDraft:X(Q.repairDraft),setEnabled:X(Q.setEnabled),updatePresentation:X(Q.updatePresentation),checkFlow:X(Q.checkFlow),publishFlow:X(Q.publishFlow),rollbackFlow:X(Q.rollbackFlow),createDraftRun:X(Q.createDraftRun),createLiveRun:X(Q.createLiveRun),resolveWait:X(Q.resolveWait),putVariable:X(Q.putVariable),queryConnectorAccessCandidates:X(Q.queryConnectorAccessCandidates),removeConnectionUsage:X(Q.removeConnectionUsage),setConnectorService:X(Q.setConnectorService),addProviderAccessBinding:X(Q.addProviderAccessBinding),removeProviderAccessBinding:X(Q.removeProviderAccessBinding),versionOnly:X(Q.versionOnly)};var ra=["expected-revision","idempotency-key"],oa=["cursor","limit"],Om=[["read","<flow> [--input JSON|@file|- | --file path|-]",["input","file"]],["search","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["edit","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["list","[--cursor <cursor>] [--limit <count>]",oa],["export","<flow>",[]],["import","--file <path|->",["file","name","idempotency-key"]],["create","<name>",["idempotency-key"]],["show","<flow>",[]],["live","<flow>",[]],["rename","<flow> <new-name>",[]],["delete","<flow> --yes",["yes"]],["check","<flow> [--revision <revisionId>]",["revision"]],["enable","<flow> --expected-publication <publicationId>",["expected-publication"]],["disable","<flow> --expected-publication <publicationId>",["expected-publication"]],["connector code-access","<flow> [--publication <publicationId>]",["publication"]],["connector candidates","<flow> <provider> [provider ...]",[]],["connector code-allow","<flow> <provider> <binding> <access-revision>",[]],["connector code-remove","<flow> <provider> <binding> <access-revision>",[]],["connector remove-usage","<flow> <connection> <access-revision>",ra],["connector providers","[--flow <flow>]",["flow"]],["connector teams","",[]],["connector search","<query> [--flow <flow>]",["flow"]],["connector show","<action> [--flow <flow>]",["flow"]],["connector connections","<service> [--flow <flow>]",["flow"]],["event-source list","",[]],["trigger search","[query]",[]],["trigger show","<key>",[]],["run","<flow>",[...ra,"expected-publication","source","trigger","outputs","input","wait","timeout"]],["runs list","--flow <flow>",["flow","status","pending-wait",...oa]],["runs show","<run>",[]],["runs wait","<run>",["timeout"]],["runs resolve","<run> <wait> <continue|approve|reject>",["comment"]],["runs events","<run>",["after","limit","follow","timeout"]],["runs result","<run>",[]],["runs results","<run> [--after <resultId>]",["after"]],["runs read-result","<run> <result>",["pointer","offset","limit","max-bytes"]],["runs download-result","<run> <result>",[]],["runs cancel","<run>",[]],["publish","<flow>",[...ra,"expected-publication","timeout"]],["publications list","<flow>",oa],["publications show","<flow> <publication>",[]],["publications wait","<flow> <operation>",["timeout"]],["publications operation","<flow> <operation>",[]],["rollback","<flow> <publication>",["expected-publication","idempotency-key"]],["open","[flow]",[]],["workbench","[flow]",[]],["schema","[read|search|edit|check|node-type]",["flow","input"]]],Gw={revision:{description:"Exact Revision to read or check; defaults to the current Draft.",type:"string"},publication:{description:"Exact Publication ID whose fixed Code connections are read; defaults to the Draft.",type:"string"},pointer:{description:"JSON Pointer within the stored result; defaults to the root.",type:"string"},offset:{description:"Page offset at the selected pointer.",type:"integer",minimum:0,default:0},"max-bytes":{description:"Maximum result page bytes.",type:"integer",minimum:1,maximum:1048576,default:15000},"expected-revision":{description:"Base Revision ID from read. Required with an explicit idempotency key for draft edits and draft runs.",type:"string"},"expected-publication":{description:"Fixed Publication ID. Use none when publishing without a Live Publication.",type:"string"},"idempotency-key":{description:"Stable identity of one mutation. Reuse only with the identical arguments and base identity.",type:"string"},source:{description:"Execution source.",type:"string",enum:["draft","live"],default:"draft"},trigger:{description:"Exact Trigger ID or unambiguous name. A sole Manual Trigger is selected automatically.",type:"string"},timeout:{description:"Wait budget in milliseconds; expiration does not cancel the operation. For node set, the node execution timeout.",type:"integer",minimum:1,default:60000},limit:{description:"Maximum items in one page.",type:"integer",minimum:1,maximum:100,default:100},after:{description:"Resume events after this sequence number; use nextAfter from the preceding response.",type:"integer",minimum:0,default:0},cursor:{description:"Opaque nextCursor from the preceding page; keep the same filters.",type:"string"},comment:{description:"Optional plain-text Wait decision comment (up to 2,000 Unicode code points).",type:"string"},"pending-wait":{description:"List runs with unresolved waits, including running and queued runs.",type:"boolean"},status:{description:"Filter runs by status.",type:"string",enum:["queued","starting","running","waiting","completed","failed","canceled","indeterminate"]},file:{description:"Authoring request or workflow JSON file path, or - for stdin.",type:"string"},code:{description:"JavaScript source, @file, or - for stdin.",type:"string"},input:{description:"Authoring request JSON; literal JSON, @file, or -. For run, node ID to input values.",type:"string"},outputs:{description:"Trigger outputs: literal JSON, @file, or -. Defaults to {}.",type:"string"},set:{description:"handle=value; repeat for multiple fields. Values use port schemas, JSON, @file, or -.",type:"string"},unset:{description:"Input/config handle to remove; repeat for multiple fields.",type:"string"},connection:{description:"Exact active Connection ID, unambiguous display name, or default.",type:"string"},flow:{description:"Exact Flow ID or unambiguous name; fixes Connector Team scope.",type:"string"},name:{description:"Display name.",type:"string"},description:{description:"Trigger description.",type:"string"},cron:{description:"Cron expression; combine with --timezone. Mutually exclusive with --every.",type:"string"},timezone:{description:"IANA time zone for --cron.",type:"string"},every:{description:"Interval such as 5m, 1h, or 1d. Mutually exclusive with --cron.",type:"string"},wait:{description:"Wait until terminal, waiting for an action, or the wait budget expires."},follow:{description:"Stream event pages as NDJSON with --json; stop on terminal, Wait, or timeout."},full:{description:"Include complete Revision content, schemas, source code and revision metadata."},yes:{description:"Confirm the requested deletion."},json:{description:"Machine-readable JSON results and errors; NDJSON for followed events."},help:{description:"Show this command contract without contacting the host."}};function ia(e,n="oo flow"){let t=e.join(" ");return Om.filter(([r])=>t==""||r==t||r.startsWith(`${t} `)).map(([r,o,i])=>({command:r,usage:`${n} ${r} ${o} [--json]`,options:[...i,"json","help"].map((s)=>Object.assign({name:`--${s}`,value:!["json","help","wait","follow","full","yes","pending-wait"].includes(s),repeatable:s=="set"||s=="unset"},Gw[s],r=="runs results"&&s=="after"?{type:"string",minimum:void 0,default:void 0,description:"Result ID from nextAfter on the preceding page."}:{},r=="runs read-result"&&s=="limit"?{default:20}:{}))}))}function Rm(e){return Om.find(([n])=>n==e.slice(0,n.split(" ").length).join(" "))?.[2]}function Am(e="edits"){let n=_s(e);if(n!=null)return n;if(e=="edits")return $s();if(ao.includes(e))return $s(e);if(e=="outputs")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",description:"Named JSON trigger outputs. The selected trigger defines its outputs contract."};if(e=="input")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:{type:"object",additionalProperties:!0},description:"Node ID -> input handle -> JSON value."};return}function sa(e){return _s(e)}function jm(e,n="oo flow"){if(e=="export")return[`${n} export FLOW_ID > template.openflow.json`];if(e=="import")return[`${n} import --file template.openflow.json --name "Imported workflow" --idempotency-key IMPORT_KEY --json`];if(e=="schema")return[`${n} schema read --json`,`${n} schema agent --json`,`${n} schema --flow FLOW_ID --input '{"action":"ACTION_ID"}' --json`];let t=sa(e);if(t==null)return Hw(n);if(e=="check")return[`${n} check FLOW_ID --revision REVISION --json`];return t.examples.map((r)=>`${n} ${e} FLOW_ID${Object.keys(r).length==0?"":` --input '${JSON.stringify(r)}'`} --json`)}function Hw(e){return[`${e} list --limit 20 --json`,`${e} read FLOW_ID --json`,`${e} live FLOW_ID --json`,`${e} schema code --json`,`${e} edit FLOW_ID --file edits.json --json`,`${e} connector search email --flow FLOW_ID --json`,`${e} run FLOW_ID --expected-revision REVISION_ID --idempotency-key RUN_KEY --wait --timeout 60000 --json`,`${e} runs wait RUN_ID --timeout 60000 --json`,`${e} runs resolve RUN_ID WAIT_ID approve --json`,`${e} runs events RUN_ID --after 0 --follow --timeout 60000 --json`]}import{basename as Yw}from"path";async function Pm(e,n,t,r,o){let[i,s,a,...c]=t;switch(i){case"code-access":case"candidates":case"code-allow":case"code-remove":case"remove-usage":{let u=i=="code-access"?1:i=="candidates"?2:i=="remove-usage"?3:4;if(i=="candidates"?t.length<u+1:t.length!=u+1)throw new E("cli.invalid-arguments",`Invalid arguments for connector ${i}. See --help.`);let l=Qw(n),d;if(i=="code-access")d=r.publication==null?await e.getConnectorAccess(l):await e.getPublishedConnectorAccess(l,r.publication);else if(i=="candidates")d=await e.listProviderAccessBindingCandidates(l,t.slice(2));else{let m=Number(t.at(-1));if(!Number.isSafeInteger(m)||m<0)throw new E("cli.invalid-arguments","Access revision must be a nonnegative integer.");if(i=="remove-usage"){let g=await cm(e,n,r);d=await e.removeConnectionUsage(l,a,g.draft.revisionId,m,r.idempotencyKey)}else if(i=="code-allow")d=await e.addProviderAccessBinding(l,a,c[0],m);else d=await e.removeProviderAccessBinding(l,a,c[0],m)}F(o,r.json,{...d,kind:`connector.${i}`},JSON.stringify(d,null,2));return}case"providers":{if(s!=null)throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector providers [--flow <flow>] [--json]`);let u=await e.listConnectorProviders(void 0,n?.flowId);F(o,r.json,{providers:u,kind:"connector.providers",version:1},u.map((l)=>`${l.serviceName} ${l.serviceId}`).join(`
63
+ `));return}case"teams":{if(s!=null)throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector teams [--json]`);let u=await e.listConnectorTeams();F(o,r.json,{...u,kind:"connector.teams"},u.teams.map((l)=>`${l.name} ${l.id}`).join(`
64
+ `));return}case"search":{if(s==null||a!=null)throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector search <query> [--json]`);let u=s.trim();if(u.length==0||u.length>256)throw new E("cli.invalid-arguments","Connector search query must contain 1\u2013256 characters.");let l=await e.searchConnectorActions(u,void 0,n?.flowId);F(o,r.json,{actions:l.map(Zs),kind:"connector.search",query:u,version:1},l.map(Qs).join(`
65
+ `));return}case"show":{if(s==null||a!=null)throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector show <action> [--json]`);let u=await um(e,s,n?.flowId);F(o,r.json,{action:u,kind:"connector.show",version:1},Qs(u));return}case"connections":{if(s==null||a!=null)throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector connections <service> [--json]`);let u=await e.listConnectorConnections(s,void 0,n?.flowId);F(o,r.json,{connections:u,kind:"connector.connections",serviceId:s,version:1},u.map(pm).join(`
66
+ `));return}default:throw new E("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector <providers|teams|search|show|connections> ...`)}}async function _m(e,n,t,r){let[o,i,s]=n;switch(o){case"search":{if(s!=null)throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger search [query] [--json]`);let a=i?.trim().toLowerCase();if(a!=null&&(a.length==0||a.length>256))throw new E("cli.invalid-arguments","Trigger search query must contain 1\u2013256 characters.");let c=Js(await e.listTriggerKeys(),a);F(r,t.json,{keys:c,kind:"trigger.search",query:a,version:1},c.map(Hs).join(`
67
+ `));return}case"show":{if(i==null||s!=null)throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger show <key> [--json]`);let a=await dm(e,i);F(r,t.json,{definition:a,kind:"trigger.show",version:1},Hs(a));return}default:throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger <search|show> ...`)}}function Qw(e){if(e==null)throw new E("cli.invalid-arguments","A Flow reference is required.");return e.flowId}function Co(e){if(e.publication==null)return`not-published ${e.flowId}`;return[`live ${e.flowId} ${e.publication.publicationId} ${e.publication.revisionId} ${e.status} enabled=${e.enabled}`,...e.entries.flatMap((n)=>[`${n.type} ${n.nodeId} ${n.name}`,..."binding"in n?[` health=${n.binding.health}${n.binding.lastErrorCode==null?"":` error=${n.binding.lastErrorCode}`}`,...n.binding.listener==null?[]:[` listener=${JSON.stringify(n.binding.listener)}`],...n.binding.endpointUrl==null?[]:[` url=${n.binding.endpointUrl}`]]:[],..."provider"in n?[` provider=${n.provider} inputs=${JSON.stringify(n.inputs)}`]:[],` config=${JSON.stringify(n.config)}`])].join(`
68
+ `)}async function $m(e,n,t,r){se(n,1,`${r.commandPrefix??"oo flow"} run <flow> [--source draft|live] [--trigger <name|id>] [--outputs <json|@file|->] [--input <json|@file|->] [--wait] [--json]`);let o=await ge(e,n[0]),i=await gm(t,r),s=t.source=="live"?t.expectedPublication==null?await e.getLive(o.flowId):{publication:await ir(e,o.flowId,t.expectedPublication)}:void 0;if(t.source=="live"&&s?.publication==null)throw new E("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=s?.publication?.revisionId??t.expectedRevision??o.draftRevisionId,c=await e.getRevision(o.flowId,a),u=Object.entries(c.content.document.graph.nodes).filter(([,N])=>!("inputs"in N)),l=u.length==1&&u[0]?.[1].kind=="manual"?u[0][0]:void 0,d=t.trigger??l;if(d==null)throw new E("run.trigger-required","Choose a start node with --trigger <name|id>.",{candidates:u.map(([N,L])=>({triggerId:N,name:L.name}))});let m=lm(c.content,d),g={};if(t.outputs!=null){let N=await Sn(t.outputs,"--outputs","run.input-unreadable",r);try{let L=JSON.parse(N);if(L==null||typeof L!=="object"||Array.isArray(L))throw Error("Expected output object.");g=L}catch{throw new E("run.input-invalid","Trigger outputs must be valid JSON.")}}let h={nodeId:m.triggerId,outputs:g},I;if(s?.publication!=null)I=await e.createLiveRun(s.publication.publicationId,{inputs:i,trigger:h,idempotencyKey:t.idempotencyKey});else I=await e.createDraftRun(o.flowId,a,{inputs:i,trigger:h,idempotencyKey:t.idempotencyKey});let R=t.wait?await Ys(e,I,r,t.timeoutMs):{run:I,timedOut:!1};return F(r,t.json,{kind:"run.create",idempotencyKey:t.idempotencyKey,...R,version:1},or(R.run)),sr(R.run,R.timedOut)}async function Nm(e,n,t,r){let[o,...i]=n;switch(o){case"list":{if(se(i,0,`${r.commandPrefix??"oo flow"} runs list --flow <flow> [--status <status>] [--pending-wait] [--cursor <cursor>] [--limit <count>] [--json]`),t.flow==null)throw new E("cli.invalid-arguments",`${r.commandPrefix??"oo flow"} runs list requires --flow <flow>.`);let s=await ge(e,t.flow),a=await e.listRuns(s.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??Gs,...t.status==null?{}:{status:t.status},...t.pendingWait==null?{}:{pendingWait:t.pendingWait}});F(r,t.json,{kind:"run.list",...a,version:1},a.runs.map(fm).join(`
69
+ `));return}case"show":{se(i,1,`${r.commandPrefix??"oo flow"} runs show <run> [--json]`);let s=await e.getRun(i[0]);F(r,t.json,{kind:"run.show",run:s,version:1},or(s));return}case"wait":{se(i,1,`${r.commandPrefix??"oo flow"} runs wait <run> [--timeout <milliseconds>] [--json]`);let s=i[0],a=Date.now()+(t.timeoutMs??60000);try{let c=await e.getRun(s,AbortSignal.timeout(t.timeoutMs??60000)),u=await Ys(e,c,r,Math.max(0,a-Date.now()));return F(r,t.json,{kind:"run.wait",runId:s,...u,version:1},or(u.run)),sr(u.run,u.timedOut)}catch(c){if(Date.now()>=a||c instanceof Error&&c.name=="TimeoutError")return F(r,t.json,{kind:"run.wait",runId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(c instanceof E)throw c;throw new E("run.wait-failed",c instanceof Error?c.message:String(c),{runId:s})}}case"resolve":{se(i,3,`${r.commandPrefix??"oo flow"} runs resolve <run> <wait> <continue|approve|reject> [--comment <text>] [--json]`);let[s,a,c]=i;if(c!="continue"&&c!="approve"&&c!="reject")throw new E("cli.invalid-arguments","Invalid Wait action.");let u=await e.resolveRunWait(s,a,c,t.comment);F(r,t.json,{kind:"run.resolve",resolution:u,version:1},JSON.stringify(u));return}case"events":{se(i,1,`${r.commandPrefix??"oo flow"} runs events <run> [--after <sequence>] [--limit <count>] [--follow] [--timeout <milliseconds>] [--json]`);let s=i[0],a=t.after??0,c=Date.now()+(t.timeoutMs??60000),u;try{do{if(t.follow&&Date.now()>=c)break;let l=await e.getRunEvents(s,{after:a,limit:t.limit??Gs},t.follow?AbortSignal.timeout(Math.max(1,c-Date.now())):void 0);if(a=l.nextAfter,F(r,t.json,{...l,kind:"run.events",runId:s,version:1},l.events.map(mm).join(`
70
+ `)),!t.follow)return;if(u=await e.getRun(s,AbortSignal.timeout(Math.max(1,c-Date.now()))),am(l.events.at(-1)))return sr(u);if(t.after!=null&&l.events.length==0&&l.done)return sr(u);if(u.waits.length>0)return F(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!1,version:1},or(u)),2;let d=c-Date.now();if(d<=0)break;if(l.events.length==0)await r.wait(Math.min(1000,d))}while(t.follow)}catch(l){if(!t.follow||Date.now()<c&&!(l instanceof Error&&l.name=="TimeoutError"))throw new E("run.events-failed",l instanceof Error?l.message:String(l),{runId:s,nextAfter:a})}return F(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!0,version:1},`timeout ${s} ${a}`),3}case"results":{se(i,1,`${r.commandPrefix??"oo flow"} runs results <run> [--after <resultId>]`);let s=await e.listRunResults(i[0],t.resultAfter);F(r,t.json,{kind:"run.results",...s},JSON.stringify(s));return}case"read-result":{se(i,2,`${r.commandPrefix??"oo flow"} runs read-result <run> <result> [--pointer <pointer>] [--offset <offset>] [--limit <limit>] [--max-bytes <bytes>]`);let s=await e.readRunResult(i[0],i[1],{pointer:t.pointer??"",offset:t.offset??0,...t.limit==null?{}:{limit:t.limit},...t.maxBytes==null?{}:{maxBytes:t.maxBytes}});F(r,t.json,{kind:"run.result-page",...s},JSON.stringify(s));return}case"download-result":{se(i,2,`${r.commandPrefix??"oo flow"} runs download-result <run> <result>`);let s=await e.downloadRunResult(i[0],i[1]);r.stdout.write(await s.text());return}case"result":{se(i,1,`${r.commandPrefix??"oo flow"} runs result <run> [--json]`);let s=await e.getRunResult(i[0]);return F(r,t.json,{kind:"run.result",result:s,version:1},JSON.stringify(s)),s.status=="completed"?0:1}case"cancel":{se(i,1,`${r.commandPrefix??"oo flow"} runs cancel <run> [--json]`);let s=await e.cancelRun(i[0]);F(r,t.json,{cancellation:s,kind:"run.cancel",version:1},`${s.status} ${s.runId} ${s.cancelAccepted?"accepted":"already-terminal"}`);return}default:throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} runs <list|show|wait|resolve|events|result|results|read-result|download-result|cancel>`)}}async function Tm(e,n,t,r){se(n,1,`${r.commandPrefix??"oo flow"} publish <flow> [--json]`);let o=await ge(e,n[0]),i=t.expectedPublication=="none"?null:t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId??null,s=await e.publishFlow(o.flowId,t.expectedRevision??o.draftRevisionId,i,{idempotencyKey:t.idempotencyKey}),a=await Xs(e,o.flowId,s,r,t.timeoutMs);if(s=a.operation,s.status=="pending")return F(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,flowId:o.flowId,...a,version:1},JSON.stringify(s)),3;if(s.status=="failed")throw new E(s.issue.code,s.issue.message,{...s.issue.nodeId==null?{}:{nodeId:s.issue.nodeId},operationId:s.operationId,flowId:o.flowId,idempotencyKey:t.idempotencyKey});let c=[],u=`${r.commandPrefix??"oo flow"} live ${o.flowId} --json`,l;try{if(l=await e.getLiveDetails(o.flowId),l.publication?.publicationId!=s.publicationId)c.push({code:"live.publication-changed",message:`Publication ${s.publicationId} succeeded. Current Live is ${l.publication?.publicationId??"not-published"}; the returned entries describe that current version.`})}catch{c.push({code:"live.details-read-failed",message:`Publication ${s.publicationId} succeeded, but its current online entries could not be read. Query ${u}.`})}let d=l?.publication?.publicationId==s.publicationId?l.publication:void 0;if(d==null)try{d=await ir(e,o.flowId,s.publicationId)}catch{c.push({code:"publication.read-failed",message:`Publication ${s.publicationId} succeeded, but its metadata could not be read. Query ${u}.`})}F(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,operation:s,...d==null?{}:{publication:d},...l==null?{}:{live:l},...c.length==0?{}:{warnings:c},version:1},[d==null?`published ${s.publicationId} ${s.revisionId}`:rr(d),...l==null?[]:[Co(l)],...c.map((m)=>`Warning: ${m.message}`)].join(`
71
+ `))}async function zm(e,n,t,r){let[o,i,s,...a]=n;if(i==null||a.length>0)throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`);let c=await ge(e,i);if(o=="list"){if(s!=null)throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications list <flow> [--cursor <cursor>] [--limit <count>]`);let u=await e.listPublications(c.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??Ws});F(r,t.json,{flow:c,kind:"publication.list",...u,version:1},u.publications.map(rr).join(`
72
+ `));return}if((o=="operation"||o=="wait")&&s!=null){let u=Date.now()+(t.timeoutMs??60000);try{let l=await e.getPublishOperation(c.flowId,s,o=="wait"?AbortSignal.timeout(t.timeoutMs??60000):void 0),d=o=="wait"?await Xs(e,c.flowId,l,r,Math.max(0,u-Date.now())):{operation:l,timedOut:!1};return F(r,t.json,{kind:`publication.${o}`,flowId:c.flowId,...d,version:1},JSON.stringify(d.operation)),d.operation.status=="failed"?1:d.operation.status=="pending"?3:0}catch(l){if(o=="wait"&&(Date.now()>=u||l instanceof Error&&l.name=="TimeoutError"))return F(r,t.json,{kind:"publication.wait",flowId:c.flowId,operationId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(l instanceof E)throw l;throw new E("publication.wait-failed",l instanceof Error?l.message:String(l),{flowId:c.flowId,operationId:s})}}if(o=="show"&&s!=null){let u=await ir(e,c.flowId,s);F(r,t.json,{kind:"publication.show",publication:u,version:1},rr(u));return}throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`)}async function Dm(e,n,t,r){se(n,2,`${r.commandPrefix??"oo flow"} rollback <flow> <publication> [--json]`);let o=await ge(e,n[0]),i=await ir(e,o.flowId,n[1]),s=t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId;if(s==null)throw new E("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=await e.rollbackFlow(o.flowId,i.publicationId,s,{idempotencyKey:t.idempotencyKey});F(r,t.json,{kind:"publication.rollback",expectedPublicationId:s,idempotencyKey:t.idempotencyKey,publication:a,version:1},rr(a))}async function Vm(e,n,t,r){let[o,...i]=t.positionals;switch(o){case"read":case"search":case"edit":{se(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> [--input JSON|@file|-] [--file path|-] --json`);let s=await ge(e,i[0]);if(t.file!=null&&t.input!=null)throw new E("cli.invalid-arguments","Choose --input or --file.");let a=t.file==null?t.input:t.file=="-"?"-":`@${t.file}`,c=a==null?{}:JSON.parse(await Sn(a,"input","flow.authoring-unreadable",r)),u=o=="read"?await e.readAuthoring(s.flowId,Eo.authoringRead(c)):o=="search"?await e.searchAuthoring(s.flowId,Eo.authoringSearch(c)):await e.editAuthoring(s.flowId,Eo.authoringEdit(c));r.stdout.write(`${JSON.stringify(u)}
73
+ `);return}case"connector":{let a=["code-access","candidates","code-allow","code-remove","remove-usage"].includes(i[0]??"")?await Xw(e,i.slice(1)):t.flow==null?void 0:await ge(e,t.flow);return await Pm(e,a,i,t,r)}case"event-source":{if(i.length!=1||i[0]!="list")throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} event-source list [--json]`);let s=await e.listEventSources(),a=`No event sources are visible to this identity. Run "${r.commandPrefix??"oo flow"} workbench" to create and verify a Feishu event source, then list again.`;F(r,t.json,{...s,kind:"event-source.list",...s.sources.length==0?{guidance:a}:{}},s.sources.length==0?a:s.sources.map((c)=>[c.sourceId,c.name,c.teamId??"-",c.connectionId,!c.enabled?"disabled":c.verifiedAt==null?"unverified":"verified",c.eventTypes.join(",")].join("\t")).join(`
74
+ `));return}case"run":return await $m(e,i,t,r);case"runs":return await Nm(e,i,t,r);case"publish":return await Tm(e,i,t,r);case"publications":return await zm(e,i,t,r);case"rollback":return await Dm(e,i,t,r);case"trigger":return await _m(e,i,t,r);case"open":case"workbench":{if(i.length>1)throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} ${o} [flow] [--json]`);if(n.getWorkbenchUrl==null)throw new E("workbench.unavailable","This CLI host cannot provide a Workbench URL.");let s=i[0]==null?void 0:await ge(e,i[0]),a=await n.getWorkbenchUrl(s?.flowId);if(o=="open")await r.openUrl(a);F(r,t.json,{...s==null?{}:{flow:s},kind:`flow.${o}`,url:a,version:1},a);return}case"list":{se(i,0,`${r.commandPrefix??"oo flow"} list [--json]`);let s=await e.listFlows({cursor:t.cursor,limit:t.limit??100});F(r,t.json,{...s,kind:"flow.list",version:1},s.flows.map(kn).join(`
75
+ `));return}case"export":{se(i,1,`${r.commandPrefix??"oo flow"} export <flow>`);let s=await ge(e,i[0]);r.stdout.write(jf(await e.exportFlow(s.flowId)));return}case"import":{if(se(i,0,`${r.commandPrefix??"oo flow"} import --file <path|-> [--name name] [--json]`),t.file==null)throw new E("cli.invalid-arguments","Import requires --file <path|->.");let s=Af(await Sn(t.file=="-"?"-":`@${t.file}`,"file","flow.import-unreadable",r)),a=t.name??s.name??(t.file=="-"?xa(r.language??"en"):Pf(Yw(t.file))),c=await e.importFlow(s,{name:So(a,"Flow"),idempotencyKey:t.idempotencyKey});F(r,t.json,{flow:c,idempotencyKey:t.idempotencyKey,kind:"flow.import",version:1},kn(c));return}case"create":{se(i,1,`${r.commandPrefix??"oo flow"} create <name> [--json]`);let s=await e.createFlow(So(i[0],"Flow"),t.idempotencyKey);F(r,t.json,{flow:s,idempotencyKey:t.idempotencyKey,kind:"flow.create",version:1},kn(s));return}case"live":{se(i,1,`${r.commandPrefix??"oo flow"} live <flow> [--json]`);let s=await ge(e,i[0]),a=await e.getLiveDetails(s.flowId);F(r,t.json,{kind:"flow.live",live:a,version:1},Co(a));return}case"show":{se(i,1,`${r.commandPrefix??"oo flow"} show <flow> [--json]`);let s=await ge(e,i[0]);F(r,t.json,{flow:s,kind:"flow.show",version:1},kn(s));return}case"rename":{se(i,2,`${r.commandPrefix??"oo flow"} rename <flow> <new-name> [--json]`);let s=await ge(e,i[0]),a=await e.renameFlow(s.flowId,So(i[1],"Flow"));F(r,t.json,{flow:a,kind:"flow.rename",version:1},kn(a));return}case"delete":{if(se(i,1,`${r.commandPrefix??"oo flow"} delete <flow> --yes [--json]`),!t.yes)throw new E("flow.confirmation-required","Flow deletion requires --yes.");let s=await ge(e,i[0]),a=await e.deleteFlow(s.flowId);F(r,t.json,{flow:a,kind:"flow.delete",version:1},kn(a));return}case"enable":case"disable":{if(se(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> --expected-publication <publicationId>`),t.expectedPublication==null||t.expectedPublication=="none")throw new E("cli.invalid-arguments","--expected-publication must identify the observed Live publication.");let s=await ge(e,i[0]),a=await e.setFlowEnabled(s.flowId,t.expectedPublication,o=="enable");F(r,t.json,{flow:a,kind:`flow.${o}`,version:1},kn(a));return}case"check":{se(i,1,`${r.commandPrefix??"oo flow"} check <flow> [--revision <revisionId>] [--json]`);let s=await ge(e,i[0]),a=t.revision??s.draftRevisionId,c=await e.checkAuthoring(s.flowId,a);return F(r,t.json,{check:c,valid:c.valid,revisionId:a,kind:"flow.check",scope:"revision",version:1},`${c.valid?"valid":"invalid"} revision ${s.name} ${s.flowId}`),c.valid?0:1}default:throw new E("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} <list|create|show|live|read|search|edit|schema|rename|delete|check|enable|disable|connector|event-source|trigger|run|runs|publish|publications|rollback|workbench>`)}}async function Xw(e,n){let t=n[0];if(t==null)throw new E("cli.invalid-arguments","A Flow reference is required.");return await ge(e,t)}var st={};var Fm=(e)=>e,Oo=Object.is,ex=(e,n)=>{if(Oo(e,n))return!0;if(!Array.isArray(e)||!Array.isArray(n))return!1;let t=e.length;if(n.length!==t)return!1;for(let r=0;r<t;r++)if(!Oo(e[r],n[r]))return!1;return!0},nx=(e)=>e.value,tx=(e)=>e.map(nx),rx=(e)=>e.$version,Ro=(e,n)=>{try{e(n)}catch(t){console.error(t)}},Mm=(e,n)=>(e.set=n,e);var ox=Promise.resolve(),aa=new Set,ix=new Set,cr=aa,ca,sx=()=>{let e=cr;cr=cr===aa?ix:aa,ca=!1;for(let n of e)n.t();e.clear()},ax=(e)=>{cr.add(e),ca=ca||ox.then(sx)},cx=(e)=>cr.delete(e);var Zm=new FinalizationRegistry(Ro),Jm=class{constructor(e,n,t){if(this.#r=e,this.q=(n?.equal??Oo)||void 0,this.e=n?.eager,this.m=n?.name,this.#n=n?.onDisposeValue,t){let r=new WeakRef(this),o=()=>{if(i){let s=i;i=void 0,s()}},i=t(()=>{let s=r.deref();if(s)s.n();else o()});if(i)Zm.register(this,this.#e=o)}}g=this;b=new Map;s=4;v;c=st;q;e;m;u=()=>{if(this.s&4){this.s&=-5;let e=this.#r();if(this.c===st)this.w(e);else if(!this.q?.(e,this.c)){if(this.w(e),this.s&1)this.s|=2}}return this.c};n=()=>{if(this.#o)console.error(this.c,Error(`${this.m||""} disposed`));if(this.s|=4,this.b.size){if(this.s|=1,this[3])this.#t(3);if(this[2]){if(this.u(),this.s&2)this.#t(2)}if(this[1])ax(this);else this.s&=-4}};a(e,n){let t=this.b.get(e);if(t)this[t]--;return this.b.set(e,n),this[n]++,()=>this.r(e)}r(e){if(e){let n=this.b.get(e);if(n)this.b.delete(e),this[n]--}else this.b.clear(),this[1]=this[2]=this[3]=0,cx(this)}t(){if(this[1]){if(this.u(),this.s&2)this.#t(1)}this.s&=-4}d(){let e=this.c;if(this.r(),Zm.unregister(this),this.#e?.(),this.#o=!0,this.#n&&e!==st)this.#n(e)}w(e){this.w=this.q?.(e,e)?this.y:this.x,this.w(e)}x(e){let n=this.c;if(this.c=e,this.v=Symbol(),this.#n&&n!==st&&n!==e)this.#n(n)}y(e){let n=this.c;if(this.c=this.v=e,this.#n&&n!==st&&n!==e)this.#n(n)}[1]=0;[2]=0;[3]=0;#e;#n;#r;#t(e){for(let[n,t]of this.b)if(t===e)Ro(n,this.c)}#o},ux=class{#e=new WeakSet;constructor(e){this.g=e.g,this.e=e.e,this.u=e.u,this.n=e.n,this.b=e.b}get v(){return this.g.v}g;b;e;u;n;a(e,n){return this.#e.add(e),this.g.a(e,n)}r(e){if(e){if(this.#e.has(e))this.#e.delete(e),this.g.r(e)}else for(let n of this.g.b.keys())this.r(n)}d(){this.r()}},ua=class{#e;constructor(e){this.#e=e,this.get=e.u,e.u()}get name(){return this.#e.m}get $version(){return this.get(),this.#e.v}get value(){return this.get()}set value(e){this.set?.(e)}set;get;ref(e){let n=new ua(new ux(this.#e));return e&&this.set?Mm(n,this.set):n}reaction(e,n=this.#e.e){return this.#e.a(e,n?2:1)}subscribe(e,n=this.#e.e){let t=this.reaction(e,n);return Ro(e,this.get()),t}$valCompute(e){return this.#e.a(e,3)}unsubscribe(e){this.#e.r(e)}dispose(){this.#e.d()}toString(){return String(this.get())}toJSON(e){let n=this.get();return n&&n.toJSON?n.toJSON(e):n}},lx=(e,n)=>{let t=e,o=new Jm(()=>t,n),i=(a)=>{if(!o.q?.(a,t))t=a,o.n()};return[new ua(o),i]},la=(e,n)=>Mm(...lx(e,n));var Lm=(e,n,t)=>new ua(new Jm(e,t,n)),qm=(e,n=Fm,t)=>{let r,o;return Lm(()=>{let i=e.map(rx);if(!o||!ex(i,o))o=i,r=n(tx(e));return r},(i)=>{let s=e.map((a)=>a.$valCompute(i));return()=>s.forEach(Ro)},t)};var da=(e,n=Fm,t)=>{let r,o=st;return Lm(()=>{let i=e.$version;if(!Oo(i,o))o=i,r=n(e.value);return r},(i)=>e.$valCompute(i),t)};var Um=(e,n={},t="")=>{for(let[r,o]of Object.entries(e))if(typeof o==="string")n[t+r]=o;else Um(o,n,t+r+".");return n},dx=(e)=>{let n=[],t=[],r=/{{(\S+?)}}/gi,o,i=0;while(o=r.exec(e))n.push(e.slice(i,o.index),""),t.push(o[1]),i=o.index+o[0].length;if(n.push(e.slice(i)),t.length<=0)return!1;return(s)=>{for(let a=t.length-1;a>=0;a--)n[a*2+1]=s[t[a]]??t[a];return n.join("")}},Km=class e{constructor(n,t,r){this.t=(i,s)=>this.t$.get()(i,s),this.fetcher=r?.fetcher;let o=new Map;this.locales$=la(t),this.lang$=la(n),this.locale$=qm([this.lang$,this.locales$],([i,s])=>s[i]||{}),this.a=da(this.locale$,Um),this.t$=da(this.a,(i)=>((s,a,c)=>{if(c){let u=c["@"];if(u!=null){let l=`${a}@${u}`;if(s[l])a=l}else{let l=c[":option"];if(l!=null){let d;a=s[d=`${a}.${l}`]||s[d=`${a}.other`]?d:a}}if(s[a]){let l=o.get(a);if(l??o.set(a,l=dx(s[a])),l)return l(c)}}return s[a]||a}).bind(o.clear(),i))}static async preload(n,t){return new e(n,{[n]:await t(n)},{fetcher:t})}get lang(){return this.lang$.value}get locales(){return this.locales$.value}get locale(){return this.locale$.value}async switchLang(n){if(!this.locales$.value[n]&&this.fetcher)this.addLocale(n,await this.fetcher(n));this.lang$.set(n)}hasKey(n){return!!this.a.value[n]}addLocale(n,t){this.locales$.set({...this.locales,[n]:t})}dispose(){this.lang$.dispose(),this.t$.dispose(),this.locales$.dispose(),this.locale$.dispose(),this.a.dispose()}};var Bm={help:{usage:"Usage: {{command}}",title:"Open Flow commands",options:"Options: --json, --cursor <cursor>, --limit <count>"}};var Wm={help:{usage:"Utilisation : {{command}}",title:"Commandes Open Flow",options:"Options : --json, --cursor <cursor>, --limit <count>"}};var Gm={help:{usage:"\u4F7F\u3044\u65B9\uFF1A{{command}}",title:"Open Flow \u30B3\u30DE\u30F3\u30C9",options:"\u30AA\u30D7\u30B7\u30E7\u30F3\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var Hm={help:{usage:"\uC0AC\uC6A9\uBC95: {{command}}",title:"Open Flow \uBA85\uB839\uC5B4",options:"\uC635\uC158: --json, --cursor <cursor>, --limit <count>"}};var Qm={help:{usage:"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: {{command}}",title:"\u041A\u043E\u043C\u0430\u043D\u0434\u044B Open Flow",options:"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: --json, --cursor <cursor>, --limit <count>"}};var Ym={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9009\u9879\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var Xm={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9078\u9805\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var wx={en:Bm,"zh-CN":Ym,"zh-TW":Xm,ja:Gm,ko:Hm,ru:Qm,fr:Wm},xx=Object.fromEntries(To.map((e)=>[e,wx[e]]));function eg(e=ba){return new Km(pr([e]),xx)}function vx(e,n){let t=n.filter((i)=>!i.startsWith("-")),r=ia(t,e.commandPrefix);while(r.length==0&&t.length>0)t.pop(),r=ia(t,e.commandPrefix);let o=eg(e.language);try{let i=r.length==1?sa(r[0].command):void 0,s=jm(r.length==1?r[0].command:"",e.commandPrefix),a={kind:"cli.help",version:1,commands:r.length==1?r:r.map(({command:c,usage:u})=>({command:c,usage:u})),...i==null?{}:{request:i.request},examples:s,exitCodes:{0:"Success or accepted asynchronous operation.",1:"Error or unsuccessful terminal Run.",2:"Run is waiting for an explicit action; inspect run.waits.",3:"Waiting timed out or publication is pending; the operation continues."},notes:i==null?[...e.scopeGuidance??["The oo host selects the team for the whole invocation with --team <name>; Flow commands use that authenticated scope."],"--timeout is a wait budget in milliseconds (default 60000).","--follow --json writes NDJSON pages immediately; resume from nextAfter.","Use read/search to locate nodes, schema read|search|edit|check for requests, and schema <type> for configuration and ports.","Use edit with baseRevision, requestId and an ordered edits array. Read selected text before an exact text.edit.","Retry mutations with the same idempotency key, fixed revision/publication and identical arguments."]:[i.guidance,...r[0].command=="check"?[]:["Use either --input (literal JSON, @file, or - for stdin) or --file (path or -), never both."]]};return n.includes("--json")?JSON.stringify(a):[o.t("help.title"),"",...r.map((c)=>r.length!=1?c.usage:`${c.usage}
75
76
  Options: ${c.options.map((u)=>u.name+(u.value?" <value>":"")+(u.description==null?"":`: ${u.description}`)).join(`
76
77
  `)}`),"",o.t("help.options"),"",...a.notes,"",...s].join(`
77
- `)}finally{o.dispose()}}function ox(e){return e.length==0||e.includes("--help")||e.includes("-h")}function ix(e){return e.positionals[0]=="schema"&&e.flow==null}async function qm(e,n,t){let r,o;try{if(ox(e))return t.stdout.write(`${rx(t,e)}
78
- `),0;r=im(e);let i=ym(r.positionals);if(i==null)throw new I("cli.invalid-arguments",`Unknown command. Use ${t.commandPrefix??"oo flow"} --help.`);for(let a of r.options)if(a!="json"&&!i.includes(a))throw new I("cli.invalid-arguments",`Option --${a} is not supported by this command.`);if(r.options.includes("idempotency-key")){let a=r.positionals[0]=="run"&&r.source=="live";if(i.includes("expected-revision")&&!a&&r.expectedRevision==null)throw new I("cli.invalid-arguments","An explicit idempotency key requires --expected-revision for a repeatable mutation.");if((a||r.positionals[0]=="publish"||r.positionals[0]=="rollback")&&r.expectedPublication==null)throw new I("cli.invalid-arguments","An explicit idempotency key requires --expected-publication (use none for the first publication).")}if(r.timeoutMs!=null&&r.positionals[0]=="run"&&!r.wait)throw new I("cli.invalid-arguments","--timeout requires --wait for run.");if(r.timeoutMs!=null&&r.positionals[0]=="runs"&&r.positionals[1]=="events"&&!r.follow)throw new I("cli.invalid-arguments","--timeout requires --follow for events.");if(r.positionals[0]=="run"&&(r.source=="live"&&r.expectedRevision!=null||r.source=="draft"&&r.expectedPublication!=null))throw new I("cli.invalid-arguments","Use --expected-revision for draft runs and --expected-publication for live runs.");if(ix(r)){if(r.positionals.length>2)throw new I("cli.invalid-arguments",`Usage: ${t.commandPrefix??"oo flow"} schema [read|search|edit|check|edits|node-type|input|outputs]`);let a=bm(r.positionals[1]);if(a==null)throw new I("cli.invalid-arguments","Unknown schema. Use read, search, edit, check, or a node type such as agent or code.");return t.stdout.write(`${JSON.stringify(a)}
79
- `),0}let s=new Ms(async(a,c)=>{let u=new Headers(c?.headers).get("idempotency-key");return o=u==null?void 0:{path:a,idempotencyKey:u,...typeof c?.body=="string"?{request:JSON.parse(c.body)}:{}},await n.request(a,c)});if(r.positionals[0]=="schema"&&r.flow!=null){let a=r.input==null?{type:r.positionals[1]}:JSON.parse(await _n(r.input,"input","flow.authoring-unreadable",t)),c=await ye(s,r.flow);return t.stdout.write(`${JSON.stringify(await s.authoringSchema(c.flowId,a))}
80
- `),0}return await Om(s,n,r,t)??0}catch(i){let s;if(i instanceof I)s=i;else if(i instanceof Ie)s=om(i);else s=new I("flow.unexpected",i instanceof Error?i.message:String(i));if(o!=null&&(!(i instanceof Ie)&&!(i instanceof I)||i instanceof Ie&&i.code=="response.invalid"))s=new I("flow.mutation-outcome-unknown","The mutation outcome is unknown. Retry the exact request with the same idempotency key.",o);if(e.includes("--json"))t.stderr.write(`${JSON.stringify({error:{code:s.code,...s.details==null?{}:{details:s.details},message:s.message},version:1})}
78
+ `)}finally{o.dispose()}}function kx(e){return e.length==0||e.includes("--help")||e.includes("-h")}function Sx(e){return e.positionals[0]=="schema"&&e.flow==null}async function ng(e,n,t){let r,o;try{if(kx(e))return t.stdout.write(`${vx(t,e)}
79
+ `),0;r=ym(e);let i=Rm(r.positionals);if(i==null)throw new E("cli.invalid-arguments",`Unknown command. Use ${t.commandPrefix??"oo flow"} --help.`);for(let a of r.options)if(a!="json"&&!i.includes(a))throw new E("cli.invalid-arguments",`Option --${a} is not supported by this command.`);if(r.options.includes("idempotency-key")){let a=r.positionals[0]=="run"&&r.source=="live";if(i.includes("expected-revision")&&!a&&r.expectedRevision==null)throw new E("cli.invalid-arguments","An explicit idempotency key requires --expected-revision for a repeatable mutation.");if((a||r.positionals[0]=="publish"||r.positionals[0]=="rollback")&&r.expectedPublication==null)throw new E("cli.invalid-arguments","An explicit idempotency key requires --expected-publication (use none for the first publication).")}if(r.timeoutMs!=null&&r.positionals[0]=="run"&&!r.wait)throw new E("cli.invalid-arguments","--timeout requires --wait for run.");if(r.timeoutMs!=null&&r.positionals[0]=="runs"&&r.positionals[1]=="events"&&!r.follow)throw new E("cli.invalid-arguments","--timeout requires --follow for events.");if(r.positionals[0]=="run"&&(r.source=="live"&&r.expectedRevision!=null||r.source=="draft"&&r.expectedPublication!=null))throw new E("cli.invalid-arguments","Use --expected-revision for draft runs and --expected-publication for live runs.");if(Sx(r)){if(r.positionals.length>2)throw new E("cli.invalid-arguments",`Usage: ${t.commandPrefix??"oo flow"} schema [read|search|edit|check|edits|node-type|input|outputs]`);let a=Am(r.positionals[1]);if(a==null)throw new E("cli.invalid-arguments","Unknown schema. Use read, search, edit, check, or a node type such as agent or code.");return t.stdout.write(`${JSON.stringify(a)}
80
+ `),0}let s=new Bs(async(a,c)=>{let u=new Headers(c?.headers).get("idempotency-key");return o=u==null?void 0:{path:a,idempotencyKey:u,...typeof c?.body=="string"?{request:JSON.parse(c.body)}:{}},await n.request(a,c)});if(r.positionals[0]=="schema"&&r.flow!=null){let a=r.input==null?{type:r.positionals[1]}:JSON.parse(await Sn(r.input,"input","flow.authoring-unreadable",t)),c=await ge(s,r.flow);return t.stdout.write(`${JSON.stringify(await s.authoringSchema(c.flowId,a))}
81
+ `),0}return await Vm(s,n,r,t)??0}catch(i){let s;if(i instanceof E)s=i;else if(i instanceof Ee)s=hm(i);else s=new E("flow.unexpected",i instanceof Error?i.message:String(i));if(o!=null&&(!(i instanceof Ee)&&!(i instanceof E)||i instanceof Ee&&i.code=="response.invalid"))s=new E("flow.mutation-outcome-unknown","The mutation outcome is unknown. Retry the exact request with the same idempotency key.",o);if(e.includes("--json"))t.stderr.write(`${JSON.stringify({error:{code:s.code,...s.details==null?{}:{details:s.details},message:s.message},version:1})}
81
82
  `);else t.stderr.write(`${s.code}: ${s.message}
82
- `);return 1}}async function ux(e){let n=process.platform=="darwin"?["open",e]:process.platform=="win32"?["rundll32","url.dll,FileProtocolHandler",e]:["xdg-open",e],t=sx(n[0],n.slice(1),{stdio:"ignore"});if(await new Promise((o,i)=>{t.once("error",i),t.once("exit",o)})!=0)throw Error("The system browser could not be opened.")}async function Um(e,n,t){if(e.includes("--version")||e.includes("-v"))return process.stdout.write(e.includes("--json")?`${JSON.stringify({version:t.version})}
83
+ `);return 1}}async function Ox(e){let n=process.platform=="darwin"?["open",e]:process.platform=="win32"?["rundll32","url.dll,FileProtocolHandler",e]:["xdg-open",e],t=Ix(n[0],n.slice(1),{stdio:"ignore"});if(await new Promise((o,i)=>{t.once("error",i),t.once("exit",o)})!=0)throw Error("The system browser could not be opened.")}async function tg(e,n,t){if(e.includes("--version")||e.includes("-v"))return process.stdout.write(e.includes("--json")?`${JSON.stringify({version:t.version})}
83
84
  `:`${t.version}
84
- `),0;return await qm(e,{request:n.cloudRequest??(async()=>{throw new I("host.unavailable","Open Flow Control API is not configured in this CLI host.")}),getWorkbenchUrl:n.getWorkbenchUrl},{commandPrefix:t.commandPrefix,scopeGuidance:t.scopeGuidance,env:process.env,language:or([n.language]),openUrl:ux,readFile:async(r)=>await ax(r,"utf8"),readStdin:async()=>{let r="";for await(let o of process.stdin)r+=String(o);return r},stderr:process.stderr,stdout:process.stdout,wait:async(r)=>await cx(r)})}async function x_(e,n={}){return await Um(e,n,{version:la})}export{x_ as runOpenFlowCommand};
85
+ `),0;return await ng(e,{request:n.cloudRequest??(async()=>{throw new E("host.unavailable","Open Flow Control API is not configured in this CLI host.")}),getWorkbenchUrl:n.getWorkbenchUrl},{commandPrefix:t.commandPrefix,scopeGuidance:t.scopeGuidance,env:process.env,language:pr([n.language]),openUrl:Ox,readFile:async(r)=>await Ex(r,"utf8"),readStdin:async()=>{let r="";for await(let o of process.stdin)r+=String(o);return r},stderr:process.stderr,stdout:process.stdout,wait:async(r)=>await Cx(r)})}async function u_(e,n={}){return await tg(e,n,{version:ya})}export{u_ as runOpenFlowCommand};