@entrydesk/cli 2.0.0 → 2.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +279 -0
  2. package/dist/add-Lh_kLR85.js +2 -0
  3. package/dist/agents-CLcXSbBp.js +2 -0
  4. package/dist/billing-DHrYi0SU.js +2 -0
  5. package/dist/{budget-DcULs51p.js → budget-D_DDPBBb.js} +1 -1
  6. package/dist/build-task-request-config-Y9X2h9Ia.js +2 -0
  7. package/dist/commands-3Yqb38G_.js +2 -0
  8. package/dist/commands-CdnyYMrx.js +2 -0
  9. package/dist/{config-CI3k8CUK.js → config-hGzOCx4u.js} +2 -2
  10. package/dist/connectors-CxzG22No.js +3 -0
  11. package/dist/file-upload-BmP4AJY0.js +16 -0
  12. package/dist/format-C3tQC6LL.js +2 -0
  13. package/dist/index.js +83 -10
  14. package/dist/instruction-CRCyBKQf.js +2 -0
  15. package/dist/{login-y8SlHgZ4.js → login-CwXjzUnO.js} +1 -1
  16. package/dist/{logout-CGGEe0it.js → logout-BYCFpaxh.js} +1 -1
  17. package/dist/{marketplace-CaIuJP0T.js → marketplace-NSEUjhXf.js} +1 -1
  18. package/dist/{mcp-Yz1qXxIb.js → mcp-B7wo_sRO.js} +2 -2
  19. package/dist/mcp-client-DMOEcmul.js +2 -0
  20. package/dist/meeting-yS83In45.js +3 -0
  21. package/dist/models-AN9cWKSj.js +3 -0
  22. package/dist/notifications-QF11-X32.js +2 -0
  23. package/dist/options-D6fCp3Q_.js +2 -0
  24. package/dist/paginate-CfIrho1f.js +2 -0
  25. package/dist/paths-C9BPsZVF.js +2 -0
  26. package/dist/{profile-1uJ5EHdo.js → profile-WtKtO0yp.js} +1 -1
  27. package/dist/profile-storage-Dv0xRb8J.js +58 -0
  28. package/dist/project-BhPYRsaZ.js +2 -0
  29. package/dist/project-context-Cc_Js6n4.js +2 -0
  30. package/dist/project-governance-C7rl6gDW.js +2 -0
  31. package/dist/project-sources-CzylP6oS.js +2 -0
  32. package/dist/project-sources-write-6cBfdUfV.js +2 -0
  33. package/dist/project-tasks-DaGBt4Cp.js +2 -0
  34. package/dist/push-Ce79oiu0.js +2 -0
  35. package/dist/{recordings-C0Ij3tfP.js → recordings-DoExjM1F.js} +1 -1
  36. package/dist/remove-bHAmCTdf.js +2 -0
  37. package/dist/resolve-f238uD6C.js +6 -0
  38. package/dist/schedules-tDaIGaad.js +21 -0
  39. package/dist/{skills-16msznfK.js → skills-CDd-emMc.js} +1 -1
  40. package/dist/status-CDMSNVD8.js +2 -0
  41. package/dist/{status-D6ebFbsw.js → status-gK3MA1oe.js} +1 -1
  42. package/dist/stdin-DzzLUF6W.js +2 -0
  43. package/dist/task-CHnFR-Zp.js +103 -0
  44. package/dist/tasks-D4RIFT8Y.js +14 -0
  45. package/dist/tasks-acCatE6n.js +2 -0
  46. package/dist/{tool-3NEPlGNR.js → tool-BEivzspP.js} +1 -1
  47. package/dist/update-CJlVgq8V.js +2 -0
  48. package/dist/usage-DOI9sowA.js +3 -0
  49. package/dist/{usage-audit-e6kpW0LZ.js → usage-audit-1GZx4VBG.js} +3 -3
  50. package/dist/version-C37EX5li.js +2 -0
  51. package/dist/workflow-DhomAltH.js +6 -0
  52. package/dist/{workspaces-BQiFZ5pV.js → workspaces-D0VOrP2A.js} +1 -1
  53. package/package.json +8 -4
  54. package/dist/add-CDlJBikf.js +0 -2
  55. package/dist/agents-vivPBsWo.js +0 -2
  56. package/dist/billing-BietwbvI.js +0 -2
  57. package/dist/build-task-request-config-Bbffa_rv.js +0 -2
  58. package/dist/commands-BCLJEd6x.js +0 -2
  59. package/dist/commands-CpuinJar.js +0 -2
  60. package/dist/connectors-CbkKDKQQ.js +0 -3
  61. package/dist/custom-connector-CxGNx65S.js +0 -2
  62. package/dist/format-BNEUX5Xv.js +0 -2
  63. package/dist/mcp-client-DdryEToX.js +0 -2
  64. package/dist/meeting-CWv3iUU6.js +0 -3
  65. package/dist/models-DFEIoTPH.js +0 -2
  66. package/dist/notifications-CBLIBZtc.js +0 -2
  67. package/dist/paths-Cqjaa_lJ.js +0 -2
  68. package/dist/profile-storage-DYUIMuP0.js +0 -72
  69. package/dist/push-BBY3QXxO.js +0 -2
  70. package/dist/remove-D-UQJ0IM.js +0 -2
  71. package/dist/schedules-CFjtG3p4.js +0 -21
  72. package/dist/status-kRSNf0Ap.js +0 -2
  73. package/dist/task-DKK82ixE.js +0 -115
  74. package/dist/tasks-DX7CQir8.js +0 -14
  75. package/dist/update-DhNwkiwD.js +0 -2
  76. package/dist/usage-050zvE6Q.js +0 -3
  77. package/dist/version-orM51hu_.js +0 -2
  78. package/dist/workflow-DHTrGTRn.js +0 -6
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ import{n as e,t}from"./rolldown-runtime-CIdiawuB.js";import n from"node:fs";import r from"node:os";import i from"node:path";import a,{HTTPError as o,TimeoutError as s,isHTTPError as c}from"ky";import{isToolUIPart as l}from"ai";import u from"node:crypto";import{execFile as d}from"node:child_process";import{setTimeout as f}from"node:timers/promises";import{decodeJwt as p}from"jose";function m(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ee(e,t=`|`){return e.map(e=>ge(e)).join(t)}function te(e,t){return typeof t==`bigint`?t.toString():t}function ne(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function re(e){return e==null}function ie(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ae(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function h(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function g(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function oe(e){return JSON.stringify(e)}function se(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const ce=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ue=ne(()=>{if(b.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function de(e){if(le(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return le(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function fe(e){return de(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const pe=new Set([`string`,`number`,`symbol`]);function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function he(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ge(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function _e(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const ve={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ye(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return he(e,g(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&h(e,r,n.shape[r])}return h(this,`shape`,e),e},checks:[]}))}function be(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return he(e,g(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return h(this,`shape`,r),r},checks:[]}))}function xe(e,t){if(!de(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return he(e,g(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return h(this,`shape`,n),n}}))}function Se(e,t){if(!de(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return he(e,g(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return h(this,`shape`,n),n}}))}function Ce(e,t){if(!t?._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.`);return he(e,g(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return h(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function we(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return he(t,g(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return h(this,`shape`,i),i},checks:[]}))}function Te(e,t,n){return he(t,g(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return h(this,`shape`,i),i}}))}function Ee(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function De(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Oe(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ke(e){return typeof e==`string`?e:e?.message}function Ae(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function je(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:ke(e.inst?._zod.def?.error?.(e))??ke(a?.(e))??ke(t?.error?.(e))??ke(n.customError?.(e))??ke(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}const Me=/[\uD800-\uDBFF]/;function Ne(e){let t=e.length;if(!Me.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Pe(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Fe(e){let t=typeof e;switch(t){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 t}function Ie(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Le(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Be(e,n,r.value)}}function Re(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ze(e,t,n){return Re(e,t,n,!1)}function Be(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Re(this,t,n.bind(this))},set(e){Re(this,t,e)}})}function Ve(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let He,Ue=!1;const We={configurable:!0,get(){Ue=!0}};function v(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&He!==e._zod){He=void 0;return}He=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,We);let e=Ue;Ue=!1;try{let r=n(this);return Ue?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Ue||=e,r}catch(n){throw delete this[t],Ue||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Ge(e,t,n,r){let i=Ve(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Ke(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var qe;const Je={value:void 0,enumerable:!1};let Ye=`captureStackTrace`in Error?Error:null;function Xe(e){let t=Ye;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ye=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function y(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Je.value=new a(r);try{Object.defineProperty(n,"_zod",Je)}finally{Je.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Le(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Xe(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ze=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Qe=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(qe=globalThis).__zod_globalConfig??(qe.__zod_globalConfig={});const b=globalThis.__zod_globalConfig;function $e(e){return e&&Object.assign(b,e),b}function et(){let e=this._zod;return e.message??=JSON.stringify(e.def,te,2),e.message}function tt(e){this._zod.message=e}const nt={get:et,set:tt,enumerable:!0,configurable:!0},rt={value:void 0,enumerable:!1},it={value:void 0,enumerable:!1},at=new WeakSet([Object.prototype,Error.prototype]),ot=(e,t)=>{e.name=`$ZodError`,rt.value=e._zod,Object.defineProperty(e,"_zod",rt),it.value=t,Object.defineProperty(e,"issues",it),rt.value=void 0,it.value=void 0,Object.defineProperty(e,"message",nt);let n=Object.getPrototypeOf(e);at.has(n)||(at.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},st=y(`$ZodError`,ot),ct=y(`$ZodError`,ot,void 0,{Parent:Error});function lt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ut(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?lt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function dt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function ft(e,t){return{callee:t?.callee??e,Err:t?.Err}}const pt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ze;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>je(e,o,$e())));throw ce(n,a?.callee??t),n}return s.value};return t},mt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>je(e,o,$e())));throw ce(n,a?.callee??t),n}return s.value};return t},ht=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ze;return a.issues.length?{success:!1,error:new(e??st)(a.issues.map(e=>je(e,i,$e())))}:{success:!0,data:a.value}},gt=ht(ct),_t=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>je(e,i,$e())))}:{success:!0,data:a.value}},vt=_t(ct),yt=e=>{let t=pt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,ft(n,a))};return n},bt=e=>{let t=pt(e),n=(e,r,i,a)=>t(e,r,i,ft(n,a));return n},xt=e=>{let t=mt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,ft(n,a))};return n},St=e=>{let t=mt(e),n=async(e,r,i,a)=>await t(e,r,i,ft(n,a));return n},Ct=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ht(e)(t,n,i)},wt=e=>(t,n,r)=>ht(e)(t,n,r),Tt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _t(e)(t,n,i)},Et=e=>async(t,n,r)=>_t(e)(t,n,r),Dt=/^[cC][0-9a-z]{6,}$/,Ot=/^[0-9a-z]+$/,kt=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,At=/^[0-9a-vA-V]{20}$/,jt=/^[A-Za-z0-9]{27}$/,Mt=/^[a-zA-Z0-9_-]{21}$/;function Nt(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Pt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ft=/^([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})$/,It=e=>e?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})$`):/^([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)$/,Lt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Rt(){return RegExp(`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const zt=/^(?:(?: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])$/,Bt=/^(([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}|:))$/,Vt=/^((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])$/,Ht=/^(([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])$/,Ut=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wt=/^[A-Za-z0-9_-]*$/,Gt=/^https?$/,Kt=/^\+[1-9]\d{6,14}$/,qt=`(?:(?:\\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 Jt(e){return RegExp(`^${e}$`)}const Yt=Jt(qt);function Xt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zt(e){return RegExp(`^${Xt(e)}$`)}function Qt(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Xt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Xt({precision:e.precision})}`:n;return RegExp(`^${qt}T(?:${r})$`)}const $t=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},en=/^-?\d+$/,tn=/^-?\d+(?:\.\d+)?$/,nn=/^(?:true|false)$/i,rn=/^null$/i,an=/^[^A-Z]*$/,on=/^[^a-z]*$/,x=y(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sn=e=>{let t=e.value;return!re(t)&&t.length!==void 0},cn={number:`number`,bigint:`bigint`,object:`date`},ln=y(`$ZodCheckLessThan`,(e,t)=>{x.init(e,t);let n=cn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:cn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),un=y(`$ZodCheckGreaterThan`,(e,t)=>{x.init(e,t);let n=cn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:cn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dn=y(`$ZodCheckMultipleOf`,(e,t)=>{x.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ae(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),fn=y(`$ZodCheckNumberFormat`,(e,t)=>{x.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ve[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=en)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),pn=y(`$ZodCheckMaxLength`,(e,t)=>{var n;x.init(e,t),(n=e._zod.def).when??(n.when=sn),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ne(r):i)<=t.maximum)return;let a=Pe(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mn=y(`$ZodCheckMinLength`,(e,t)=>{var n;x.init(e,t),(n=e._zod.def).when??(n.when=sn),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ne(r):i)>=t.minimum)return;let a=Pe(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hn=y(`$ZodCheckLengthEquals`,(e,t)=>{var n;x.init(e,t),(n=e._zod.def).when??(n.when=sn),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ne(r):i;if(a===t.length)return;let o=Pe(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),gn=y(`$ZodCheckStringFormat`,(e,t)=>{var n,r;x.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_n=y(`$ZodCheckRegex`,(e,t)=>{gn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vn=y(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=an,gn.init(e,t)}),yn=y(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=on,gn.init(e,t)}),bn=y(`$ZodCheckIncludes`,(e,t)=>{x.init(e,t);let n=me(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),xn=y(`$ZodCheckStartsWith`,(e,t)=>{x.init(e,t);let n=RegExp(`^${me(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Sn=y(`$ZodCheckEndsWith`,(e,t)=>{x.init(e,t);let n=RegExp(`.*${me(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Cn=y(`$ZodCheckOverwrite`,(e,t)=>{x.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var wn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
3
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
4
+ `)}\n};`)(...Object.values(this.closed))}};const Tn={major:4,minor:5,patch:4},S=y(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tn;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Ee(t),a;for(let o of n){if(o._zod.def.when){if(De(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ze;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ae(t.issues,n,e),i||=Ee(t,n))});else{if(t.issues.length===n)continue;Ae(t.issues,n,e),i||=Ee(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Ee(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ze;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ze;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ze(this,`~standard`,Dn(this))},set"~standard"(e){Re(this,`~standard`,e)}}),En=e=>e.success?{value:e.data}:{issues:e.error?.issues};function Dn(e){return{validate:t=>{try{return En(gt(e,t))}catch{return vt(e,t).then(En)}},vendor:`zod`,version:1}}const On=y(`$ZodString`,(e,t)=>{S.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$t(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),C=y(`$ZodStringFormat`,(e,t)=>{gn.init(e,t),On.init(e,t)}),kn=y(`$ZodGUID`,(e,t)=>{t.pattern??=Ft,C.init(e,t)}),An=y(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=It(e)}else t.pattern??=It();C.init(e,t)}),jn=y(`$ZodEmail`,(e,t)=>{t.pattern??=Lt,C.init(e,t)});function Mn(e,t){if(!t.normalize&&t.protocol?.source===Gt.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}const Nn=/[\t\n\r]/g;function Pn(e){return e.replace(Nn,``)}function Fn(e,t){return t.lastIndex=0,t.test(e.hostname)}function In(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Ln=y(`$ZodURL`,(e,t)=>{C.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Mn(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!Fn(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!In(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Pn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Rn=y(`$ZodEmoji`,(e,t)=>{t.pattern??=Rt(),C.init(e,t)}),zn=y(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Mt:Nt(t.length),C.init(e,t)}),Bn=y(`$ZodCUID`,(e,t)=>{t.pattern??=Dt,C.init(e,t)}),Vn=y(`$ZodCUID2`,(e,t)=>{t.pattern??=Ot,C.init(e,t)}),Hn=y(`$ZodULID`,(e,t)=>{t.pattern??=kt,C.init(e,t)}),Un=y(`$ZodXID`,(e,t)=>{t.pattern??=At,C.init(e,t)}),Wn=y(`$ZodKSUID`,(e,t)=>{t.pattern??=jt,C.init(e,t)}),Gn=y(`$ZodISODateTime`,(e,t)=>{t.pattern??=Qt(t),C.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),Kn=y(`$ZodISODate`,(e,t)=>{t.pattern??=Yt,C.init(e,t)}),qn=y(`$ZodISOTime`,(e,t)=>{t.pattern??=Zt(t),C.init(e,t)}),Jn=y(`$ZodISODuration`,(e,t)=>{t.pattern??=Pt,C.init(e,t)}),Yn=y(`$ZodIPv4`,(e,t)=>{t.pattern??=zt,C.init(e,t),e._zod.bag.format=`ipv4`}),Xn=/^[0-9a-fA-F:.]+$/;function Zn(e){if(!Xn.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const Qn=y(`$ZodIPv6`,(e,t)=>{t.pattern??=Bt,C.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{Zn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),$n=y(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Vt,C.init(e,t)});function er(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Zn(n)}const tr=y(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ht,C.init(e,t),e._zod.check=n=>{er(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function nr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const rr=y(`$ZodBase64`,(e,t)=>{t.pattern??=Ut,C.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{nr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ir(e){if(!Wt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return nr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const ar=y(`$ZodBase64URL`,(e,t)=>{t.pattern??=Wt,C.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{ir(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),or=y(`$ZodE164`,(e,t)=>{t.pattern??=Kt,C.init(e,t)});function sr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const cr=y(`$ZodJWT`,(e,t)=>{C.init(e,t),e._zod.check=n=>{sr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),lr=y(`$ZodNumber`,(e,t)=>{S.init(e,t),e._zod.pattern=e._zod.bag.pattern??tn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ur=y(`$ZodNumberFormat`,(e,t)=>{fn.init(e,t),lr.init(e,t)}),dr=y(`$ZodBoolean`,(e,t)=>{S.init(e,t),e._zod.pattern=nn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),fr=y(`$ZodNull`,(e,t)=>{S.init(e,t),e._zod.pattern=rn,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),pr=y(`$ZodAny`,(e,t)=>{S.init(e,t),e._zod.parse=e=>e}),mr=y(`$ZodUnknown`,(e,t)=>{S.init(e,t),e._zod.parse=e=>e}),hr=y(`$ZodNever`,(e,t)=>{S.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),gr=y(`$ZodDate`,(e,t)=>{S.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function _r(e,t,n){e.issues.length&&t.issues.push(...Oe(n,e.issues)),t.value[n]=e.value}const vr=y(`$ZodArray`,(e,t)=>{S.init(e,t);let n=b.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>_r(t,r,e))):_r(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function yr(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Oe(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}const br=[];function xr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:br,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=_e(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Sr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>yr(e,n,i,t,u,d))):yr(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Cr=new WeakMap,wr=y(`$ZodObject`,(e,t)=>{if(S.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Cr.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),Cr.set(t,n),n}})}let n=ne(()=>xr(t));v(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||h(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let r=le,i=t.catchall,a,o=b.memoizer;o?.attach(e),e._zod.parse=(t,s)=>{a??=n.value;let c=t.value;if(!r(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=o?o.alloc(e,t,{},s):{};let l=[],u=a.shape;for(let e of a.allKeys){if(e===`__proto__`)continue;let n=u[e],r=n._zod.optin,i=n._zod.optout,a=n._zod.run({value:c[e],issues:[]},s);a instanceof Promise?l.push(a.then(n=>yr(n,t,e,c,r,i))):yr(a,t,e,c,r,i)}return i?Sr(l,c,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Tr=y(`$ZodObjectJIT`,(e,t)=>{wr.init(e,t);let n=e._zod.parse,r=ne(()=>xr(t)),i=b.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new wn([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
5
+ for (let i = 0; i < ${e}.issues.length; i++) {
6
+ const iss = ${e}.issues[i];
7
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
8
+ payload.issues.push(iss);
9
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:oe(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
10
+ const ${n}_present = ${i};
11
+ if (!${n}.issues.length || ${n}_present) {
12
+ if (${n}.issues.length) {${c(n,r)}
13
+ }
14
+
15
+ if (${e}) {
16
+ newResult[${r}] = ${n}.value;
17
+ }
18
+ }
19
+
20
+ `)}else f?o.write(`
21
+ if (${n}.issues.length) {${c(n,r)}
22
+ }
23
+
24
+ if (${n}.value === undefined) {
25
+ if (${i}) {
26
+ newResult[${r}] = undefined;
27
+ }
28
+ } else {
29
+ newResult[${r}] = ${n}.value;
30
+ }
31
+
32
+ `):o.write(`
33
+ const ${n}_present = ${i};
34
+ if (${n}.issues.length) {${c(n,r)}
35
+ }
36
+ if (!${n}_present && !${n}.issues.length) {
37
+ payload.issues.push({
38
+ code: "invalid_type",
39
+ expected: "nonoptional",
40
+ input: undefined,
41
+ path: [${r}]
42
+ });
43
+ }
44
+
45
+ if (${n}_present) {
46
+ newResult[${r}] = ${n}.value;
47
+ }
48
+
49
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=le,c=!b.jitless,l=c&&ue.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Sr([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Er(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ee(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>je(e,r,$e())))}),t)}const Dr=y(`$ZodUnion`,(e,t)=>{S.init(e,t),v(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),v(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),v(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),v(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ie(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Er(t,r,e,i)):Er(o,r,e,i)}}),Or=y(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Dr.init(e,t);let n=e._zod.parse;v(e,`propValues`,e=>{let t={};for(let n of e.def.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(n)}"`);for(let[e,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(t,e)||h(t,e,new Set);for(let r of n)t[e].add(r)}}return t}),t.options.forEach((e,n)=>{let r=Cr.get(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ne(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!le(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),kr=y(`$ZodIntersection`,(e,t)=>{S.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>jr(e,t,n)):jr(e,i,a)}});function Ar(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(de(e)&&de(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ar(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ar(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function jr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ar(t.value,n.value);if(!c.valid){if(Ee(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Mr=y(`$ZodTuple`,(e,t)=>{S.init(e,t);let n=t.items,r=b.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Nr(n,`optin`),l=Nr(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):u[e]=t}if(t.rest){let e=n.length-1,r=o.slice(n.length);for(let n of r){e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Pr(t,i,e))):Pr(r,i,e)}}return s.length?Promise.all(s).then(()=>Fr(u,i,n,o,l)):Fr(u,i,n,o,l)}});function Nr(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Pr(e,t,n){e.issues.length&&t.issues.push(...Oe(n,e.issues)),t.value[n]=e.value}function Fr(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...Oe(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}const Ir=y(`$ZodRecord`,(e,t)=>{S.init(e,t);let n=b.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!de(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>je(e,i,$e())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Oe(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Oe(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e))if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e);l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&tn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>je(e,i,$e())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Oe(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Oe(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Lr=y(`$ZodEnum`,(e,t)=>{S.init(e,t);let n=m(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>pe.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>me(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Rr=y(`$ZodLiteral`,(e,t)=>{S.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?me(e):e?me(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),zr=y(`$ZodTransform`,(e,t)=>{S.init(e,t),e._zod.optin=`optional`,b.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Qe(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Ze;return n.value=i,n}});function Br(e,t){return e.value=t.issues.length?void 0:t.value,e}const Vr=y(`$ZodOptional`,(e,t)=>{S.init(e,t),v(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,v(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),v(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ie(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Br(e,t)):Br(e,r)}return t.innerType._zod.run(e,n)}}),Hr=y(`$ZodExactOptional`,(e,t)=>{Vr.init(e,t),v(e,`values`,e=>e.def.innerType._zod.values),v(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ur=y(`$ZodNullable`,(e,t)=>{S.init(e,t),v(e,`optin`,e=>e.def.innerType._zod.optin),v(e,`optout`,e=>e.def.innerType._zod.optout),v(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ie(t.source)}|null)$`):void 0}),v(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Wr=y(`$ZodDefault`,(e,t)=>{S.init(e,t),e._zod.optin=`defaulted`,v(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Gr(e,t)):Gr(r,t)}});function Gr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Kr=y(`$ZodPrefault`,(e,t)=>{S.init(e,t),e._zod.optin=`defaulted`,v(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),qr=y(`$ZodNonOptional`,(e,t)=>{S.init(e,t),v(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Jr(t,e)):Jr(i,e)}});function Jr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Yr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>je(e,r,$e()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Xr=y(`$ZodCatch`,(e,t)=>{S.init(e,t),v(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),v(e,`optout`,e=>e.def.innerType._zod.optout),v(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Yr(e,r,t,n)):Yr(e,r,t,n)}}),Zr=y(`$ZodPipe`,(e,t)=>{S.init(e,t),v(e,`values`,e=>e.def.in._zod.values),v(e,`optin`,e=>e.def.in._zod.optin),v(e,`optout`,e=>e.def.out._zod.optout),v(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Qr(e,t.in,n)):Qr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Qr(e,t.out,n)):Qr(r,t.out,n)}});function Qr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const $r=y(`$ZodCodec`,(e,t)=>{S.init(e,t),v(e,`values`,e=>e.def.in._zod.values),v(e,`optin`,e=>e.def.in._zod.optin),v(e,`optout`,e=>e.def.out._zod.optout),v(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ei(e,t,n)):ei(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ei(e,t,n)):ei(r,t,n)}}});function ei(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>ti(e,r,t.out,n)):ti(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>ti(e,r,t.in,n)):ti(e,r,t.in,n)}}function ti(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const ni=y(`$ZodPreprocess`,(e,t)=>{Zr.init(e,t)}),ri=y(`$ZodReadonly`,(e,t)=>{S.init(e,t),v(e,`propValues`,e=>e.def.innerType._zod.propValues),v(e,`values`,e=>e.def.innerType._zod.values),v(e,`optin`,e=>e.def.innerType?._zod?.optin),v(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ii):ii(r)}});function ii(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ai=y(`$ZodCustom`,(e,t)=>{x.init(e,t),S.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>oi(t,n,r,e));oi(i,n,r,e)}});function oi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ie(e))}}var si=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const ci=`~memo`,li=[];function ui(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const di=new WeakMap;function fi(e,t){let n=di.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&fi(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);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 e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),di.set(e,r),r}function pi(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let mi;const hi=[],gi={alloc(e,t,n){let r=mi;if(!r)return n;mi=void 0;let i={value:n,issues:null};return r.set(t.value,i),hi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&vi(n,e.value))throw new si;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=fi(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[ci];l||(l={buckets:new Map,backEdges:void 0},s[ci]=l);let u;r===s?u=i:(u=pi(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...ui(d.issues)):(o.memo=!0,l.backEdges??=new Set,l.backEdges.add(d.value)),o;mi=u;let f=hi.length,p=t(o,s);mi=void 0;let m=hi.length>f?hi.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?ui(e.issues):li),e)):(m&&(m.issues=p.issues.length?ui(p.issues):li),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function _i(){return gi}function vi(e,t){let n=e[ci]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}const yi=()=>{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 t(t){return e[t]??null}let n={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`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Fe(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ge(e.values[0])}`:`Invalid option: expected one of ${ee(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${ee(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function bi(){return{localeError:yi()}}var xi,Si=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...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 Ci(){return new Si}(xi=globalThis).__zod_globalRegistry??(xi.__zod_globalRegistry=Ci());const wi=globalThis.__zod_globalRegistry;function Ti(e,t){return new e({type:`string`,..._(t)})}function Ei(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,..._(t)})}function Di(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,..._(t)})}function Oi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,..._(t)})}function ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,..._(t)})}function Ai(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,..._(t)})}function ji(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,..._(t)})}function Mi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,..._(t)})}function Ni(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,..._(t)})}function Pi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,..._(t)})}function Fi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,..._(t)})}function Ii(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,..._(t)})}function Li(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,..._(t)})}function Ri(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,..._(t)})}function zi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,..._(t)})}function Bi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,..._(t)})}function Vi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,..._(t)})}function Hi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,..._(t)})}function Ui(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,..._(t)})}function Wi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,..._(t)})}function Gi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,..._(t)})}function Ki(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,..._(t)})}function qi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,..._(t)})}function Ji(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,..._(t)})}function Yi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,..._(t)})}function Xi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,..._(t)})}function Zi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,..._(t)})}function Qi(e,t){return new e({type:`number`,checks:[],..._(t)})}function $i(e,t){return new e({type:`number`,coerce:!0,checks:[],..._(t)})}function ea(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,..._(t)})}function ta(e,t){return new e({type:`boolean`,..._(t)})}function na(e,t){return new e({type:`null`,..._(t)})}function ra(e){return new e({type:`any`})}function ia(e){return new e({type:`unknown`})}function aa(e,t){return new e({type:`never`,..._(t)})}function oa(e,t){return new e({type:`date`,coerce:!0,..._(t)})}function sa(e,t){return new ln({check:`less_than`,..._(t),value:e,inclusive:!1})}function ca(e,t){return new ln({check:`less_than`,..._(t),value:e,inclusive:!0})}function la(e,t){return new un({check:`greater_than`,..._(t),value:e,inclusive:!1})}function ua(e,t){return new un({check:`greater_than`,..._(t),value:e,inclusive:!0})}function da(e,t){return new dn({check:`multiple_of`,..._(t),value:e})}function fa(e,t){return new pn({check:`max_length`,..._(t),maximum:e})}function pa(e,t){return new mn({check:`min_length`,..._(t),minimum:e})}function ma(e,t){return new hn({check:`length_equals`,..._(t),length:e})}function ha(e,t){return new _n({check:`string_format`,format:`regex`,..._(t),pattern:e})}function ga(e){return new vn({check:`string_format`,format:`lowercase`,..._(e)})}function _a(e){return new yn({check:`string_format`,format:`uppercase`,..._(e)})}function va(e,t){return new bn({check:`string_format`,format:`includes`,..._(t),includes:e})}function ya(e,t){return new xn({check:`string_format`,format:`starts_with`,..._(t),prefix:e})}function ba(e,t){return new Sn({check:`string_format`,format:`ends_with`,..._(t),suffix:e})}function xa(e){return new Cn({check:`overwrite`,tx:e})}function Sa(e){return xa(t=>t.normalize(e))}function Ca(){return xa(e=>e.trim())}function wa(){return xa(e=>e.toLowerCase())}function Ta(){return xa(e=>e.toUpperCase())}function Ea(){return xa(e=>se(e))}function Da(e,t,n){return new e({type:`array`,element:t,..._(n)})}function Oa(e,t,n){let r=_(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ka(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,..._(n)})}function Aa(e,t){let n=ja(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ie(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ie(r))}},e(t.value,t)),t);return n}function ja(e,t){let n=new x({check:`custom`,..._(t)});return n._zod.check=e,n}function Ma(e,t){let n=_(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??$r,c=e.Boolean??dr,l=new s({type:`pipe`,in:new(e.String??On)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:o.has(r)?!1:(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l._zod.bag.truthy=r,l._zod.bag.falsy=i,l._zod.bag.case=n.case??`insensitive`,l}function Na(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&h(e,t,n[t]);return e}function Pa(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??wi,target:t,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 Fa(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function w(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,w(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Na(o.schema,c),t.io===`input`&&T(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ia(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function La(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ia(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ia(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
50
+
51
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ra(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ra(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const za=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ba=[`oneOf`,`anyOf`];function Va(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ha(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!za.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Va(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}h(n,r,e.length===1?e[0]:Ha(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Va(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ua(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of za)if(t in e)return;let n=t.filter(e=>Ba.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ha(t);else{let e=n[0],i=Ba.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ha([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Na(e,r))}function Wa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Na(i,s),Na(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ra(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ua(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Na(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,h(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ka(t,`input`,e.processors),output:Ka(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function T(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return T(r.element,n);if(r.type===`set`)return T(r.valueType,n);if(r.type===`lazy`)return T(r.getter(),n);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 T(r.innerType,n);if(r.type===`intersection`)return T(r.left,n)||T(r.right,n);if(r.type===`record`||r.type===`map`)return T(r.keyType,n)||T(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:T(r.in,n)||T(r.out,n);if(r.type===`object`){for(let e in r.shape)if(T(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(T(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(T(e,n))return!0;return!!(r.rest&&T(r.rest,n))}return!1}const Ga=(e,t={})=>n=>{let r=Pa({...n,processors:t});return w(e,r),La(r,e),Wa(r,e)},Ka=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pa({...i??{},target:a,io:t,processors:n});return w(e,o),La(o,e),Wa(o,e)},qa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ja=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=qa[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ya=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):Fa(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},Xa=(e,t,n,r)=>{n.type=`boolean`},Za=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Qa=(e,t,n,r)=>{n.not={}},$a=(e,t,n,r)=>{Fa(e,t,n,r,`Date cannot be represented in JSON Schema`)},eo=(e,t,n,r)=>{let i=e._zod.def,a=m(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},to=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Fa(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Fa(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},no=(e,t,n,r)=>{Fa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ro=(e,t,n,r)=>{Fa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},io=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=w(a.element,t,{...r,path:[...r.path,`items`]})};function ao(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ao(t.out):t.type===`catch`?ao(t.innerType):e._zod.optin}const oo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Fa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)h(i.properties,e,w(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?ao(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=w(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},so=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>w(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},co=(e,t,n,r)=>{let i=e._zod.def,a=w(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=w(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},lo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>w(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?w(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?ao(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function uo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=uo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>uo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?tn:en).source),p):p}const fo=new WeakMap;function po(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of fo.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=uo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const mo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=w(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)h(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=w(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=fo.get(t);n||(n=[],fo.set(t,n),t.deferred.push(()=>po(t))),n.push(e)}i.additionalProperties=w(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ao(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ho=(e,t,n,r)=>{let i=e._zod.def,a=w(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},go=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_o=Symbol();function vo(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Fa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),_o):JSON.parse(o)}const yo=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=vo(i.defaultValue,e,t,n,r);o!==_o&&(n.default=o)},bo=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=vo(i.defaultValue,e,t,n,r);o!==_o&&(n._prefault=o)},xo=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Fa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},So=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;w(o,t,r);let s=t.seen.get(e);s.ref=o},Co=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wo=(e,t,n,r)=>{let i=e._zod.def;w(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},To=new WeakSet([Object.prototype,Error.prototype]);function Eo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const E=y(`ZodError`,(e,t)=>{st.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);To.has(n)||(To.add(n),Eo(n,`format`,e=>t=>dt(e,t)),Eo(n,`flatten`,e=>t=>ut(e,t)),Eo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,te,2)}),Eo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,te,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Do=pt(E),Oo=mt(E),ko=ht(E),Ao=_t(E),jo=yt(E),Mo=bt(E),No=xt(E),Po=St(E),Fo=Ct(E),Io=wt(E),Lo=Tt(E),Ro=Et(E);function zo(){b.localeError||$e(bi())}function Bo(){b.memoizer||$e({memoizer:_i()})}const D=y(`ZodType`,(e,t)=>(zo(),S.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(g(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return he(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(lc(e,t))},superRefine(e,t){return this.check(uc(e,t))},overwrite(e){return this.check(xa(e))},optional(){return Hs(this)},exactOptional(){return Ws(this)},nullable(){return Ks(this)},nullish(){return Hs(Ks(this))},nonoptional(e){return Qs(this,e)},array(){return I(this)},or(e){return R([this,e])},and(e){return js(this,e)},transform(e){return nc(this,Bs(e))},default(e){return Js(this,e)},prefault(e){return Xs(this,e)},catch(e){return ec(this,e)},pipe(e){return nc(this,e)},readonly(){return oc(this)},describe(e){let t=this.clone();return wi.add(t,{description:e}),t},meta(...e){if(e.length===0)return wi.get(this);let t=this.clone();return wi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ze(this,`~standard`,{...Dn(this),jsonSchema:{input:Ka(this,`input`),output:Ka(this,`output`)}})},set"~standard"(e){Re(this,`~standard`,e)},parse:function e(t,n){return Do(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Oo(this,t,n,{callee:e})},safeParse(e,t){return ko(this,e,t)},async safeParseAsync(e,t){return Ao(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Re(this,`spa`,e)},encode:function e(t,n){return jo(this,t,n,{callee:e})},decode:function e(t,n){return Mo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await No(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Po(this,t,n,{callee:e})},safeEncode(e,t){return Fo(this,e,t)},safeDecode(e,t){return Io(this,e,t)},async safeEncodeAsync(e,t){return Lo(this,e,t)},async safeDecodeAsync(e,t){return Ro(this,e,t)},toJSONSchema(e){return Ga(this,{})(e)},get description(){return wi.get(this)?.description},get _def(){return this._zod.def}}),Vo=y(`_ZodString`,(e,t)=>{On.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(ha(...e))},includes(...e){return this.check(va(...e))},startsWith(...e){return this.check(ya(...e))},endsWith(...e){return this.check(ba(...e))},min(...e){return this.check(pa(...e))},max(...e){return this.check(fa(...e))},length(...e){return this.check(ma(...e))},nonempty(...e){return this.check(pa(1,...e))},lowercase(e){return this.check(ga(e))},uppercase(e){return this.check(_a(e))},trim(){return this.check(Ca())},normalize(...e){return this.check(Sa(...e))},toLowerCase(){return this.check(wa())},toUpperCase(){return this.check(Ta())},slugify(){return this.check(Ea())}}),Ho=y(`ZodString`,(e,t)=>{On.init(e,t),Vo.init(e,t)},{email(e){return this.check(Ei(qo,e))},url(e){return this.check(Mi(Xo,e))},jwt(e){return this.check(qi(fs,e))},emoji(e){return this.check(Ni(Zo,e))},guid(e){return this.check(Di(Jo,e))},uuid(e){return this.check(Oi(Yo,e))},uuidv4(e){return this.check(ki(Yo,e))},uuidv6(e){return this.check(Ai(Yo,e))},uuidv7(e){return this.check(ji(Yo,e))},nanoid(e){return this.check(Pi(Qo,e))},cuid(e){return this.check(Fi($o,e))},cuid2(e){return this.check(Ii(es,e))},ulid(e){return this.check(Li(ts,e))},base64(e){return this.check(Wi(cs,e))},base64url(e){return this.check(Gi(us,e))},xid(e){return this.check(Ri(ns,e))},ksuid(e){return this.check(zi(rs,e))},ipv4(e){return this.check(Bi(is,e))},ipv6(e){return this.check(Vi(as,e))},cidrv4(e){return this.check(Hi(os,e))},cidrv6(e){return this.check(Ui(ss,e))},e164(e){return this.check(Ki(ds,e))},datetime(e){return this.check(Ji(Uo,e))},date(e){return this.check(Yi(Wo,e))},time(e){return this.check(Xi(Go,e))},duration(e){return this.check(Zi(Ko,e))}});function O(e){return Ti(Ho,e)}const k=y(`ZodStringFormat`,(e,t)=>{C.init(e,t),Vo.init(e,t)}),Uo=y(`ZodISODateTime`,(e,t)=>{Gn.init(e,t),k.init(e,t)}),Wo=y(`ZodISODate`,(e,t)=>{Kn.init(e,t),k.init(e,t)}),Go=y(`ZodISOTime`,(e,t)=>{qn.init(e,t),k.init(e,t)}),Ko=y(`ZodISODuration`,(e,t)=>{Jn.init(e,t),k.init(e,t)}),qo=y(`ZodEmail`,(e,t)=>{jn.init(e,t),k.init(e,t)});function A(e){return Ei(qo,e)}const Jo=y(`ZodGUID`,(e,t)=>{kn.init(e,t),k.init(e,t)}),Yo=y(`ZodUUID`,(e,t)=>{An.init(e,t),k.init(e,t)});function j(e){return Oi(Yo,e)}const Xo=y(`ZodURL`,(e,t)=>{Ln.init(e,t),k.init(e,t)});function M(e){return Mi(Xo,e)}const Zo=y(`ZodEmoji`,(e,t)=>{Rn.init(e,t),k.init(e,t)}),Qo=y(`ZodNanoID`,(e,t)=>{zn.init(e,t),k.init(e,t)}),$o=y(`ZodCUID`,(e,t)=>{Bn.init(e,t),k.init(e,t)}),es=y(`ZodCUID2`,(e,t)=>{Vn.init(e,t),k.init(e,t)}),ts=y(`ZodULID`,(e,t)=>{Hn.init(e,t),k.init(e,t)}),ns=y(`ZodXID`,(e,t)=>{Un.init(e,t),k.init(e,t)}),rs=y(`ZodKSUID`,(e,t)=>{Wn.init(e,t),k.init(e,t)}),is=y(`ZodIPv4`,(e,t)=>{Yn.init(e,t),k.init(e,t)}),as=y(`ZodIPv6`,(e,t)=>{Qn.init(e,t),k.init(e,t)}),os=y(`ZodCIDRv4`,(e,t)=>{$n.init(e,t),k.init(e,t)}),ss=y(`ZodCIDRv6`,(e,t)=>{tr.init(e,t),k.init(e,t)}),cs=y(`ZodBase64`,(e,t)=>{rr.init(e,t),k.init(e,t)});function ls(e){return Wi(cs,e)}const us=y(`ZodBase64URL`,(e,t)=>{ar.init(e,t),k.init(e,t)}),ds=y(`ZodE164`,(e,t)=>{or.init(e,t),k.init(e,t)}),fs=y(`ZodJWT`,(e,t)=>{cr.init(e,t),k.init(e,t)}),ps=y(`ZodNumber`,(e,t)=>{lr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(la(e,t))},gte(e,t){return this.check(ua(e,t))},min(e,t){return this.check(ua(e,t))},lt(e,t){return this.check(sa(e,t))},lte(e,t){return this.check(ca(e,t))},max(e,t){return this.check(ca(e,t))},int(e){return this.check(hs(e))},safe(e){return this.check(hs(e))},positive(e){return this.check(la(0,e))},nonnegative(e){return this.check(ua(0,e))},negative(e){return this.check(sa(0,e))},nonpositive(e){return this.check(ca(0,e))},multipleOf(e,t){return this.check(da(e,t))},step(e,t){return this.check(da(e,t))},finite(){return this}});function N(e){return Qi(ps,e)}const ms=y(`ZodNumberFormat`,(e,t)=>{ur.init(e,t),ps.init(e,t)});function hs(e){return ea(ms,e)}const gs=y(`ZodBoolean`,(e,t)=>{dr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r)});function P(e){return ta(gs,e)}const _s=y(`ZodNull`,(e,t)=>{fr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r)});function vs(e){return na(_s,e)}const ys=y(`ZodAny`,(e,t)=>{pr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bs(){return ra(ys)}const xs=y(`ZodUnknown`,(e,t)=>{mr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function F(){return ia(xs)}const Ss=y(`ZodNever`,(e,t)=>{hr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r)});function Cs(e){return aa(Ss,e)}const ws=y(`ZodDate`,(e,t)=>{gr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.min=(t,n)=>e.check(ua(t,n)),e.max=(t,n)=>e.check(ca(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null}),Ts=y(`ZodArray`,(e,t)=>{Bo(),vr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r),e.element=t.element},{min(e,t){return this.check(pa(e,t))},nonempty(e){return this.check(pa(1,e))},max(e,t){return this.check(fa(e,t))},length(e,t){return this.check(ma(e,t))},unwrap(){return this.element}});function I(e,t){return Da(Ts,e,t)}const Es=y(`ZodObject`,(e,t)=>{Bo(),Tr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r),Ge(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return B(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:F()})},loose(){return this.clone({...this._zod.def,catchall:F()})},strict(){return this.clone({...this._zod.def,catchall:Cs()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return xe(this,e)},safeExtend(e){return Se(this,e)},merge(e){return Ce(this,e)},pick(e){return ye(this,e)},omit(e){return be(this,e)},partial(...e){return we(Vs,this,e[0])},exactPartial(...e){return we(Us,this,e[0],`exactPartial`)},required(...e){return Te(Zs,this,e[0])}});function L(e,t){let n={type:`object`,shape:e??{},..._(t)};return new Es(n)}function Ds(e,t){return new Es({type:`object`,shape:e,catchall:F(),..._(t)})}const Os=y(`ZodUnion`,(e,t)=>{Dr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),e.options=t.options});function R(e,t){return new Os({type:`union`,options:e,..._(t)})}const ks=y(`ZodDiscriminatedUnion`,(e,t)=>{Os.init(e,t),Or.init(e,t)});function z(e,t,n){return new ks({type:`union`,options:t,discriminator:e,..._(n)})}const As=y(`ZodIntersection`,(e,t)=>{kr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function js(e,t){return new As({type:`intersection`,left:e,right:t})}const Ms=y(`ZodTuple`,(e,t)=>{Bo(),Mr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Vs({type:`optional`,innerType:e}))})}});function Ns(e,t,n){let r=t instanceof S;return new Ms({type:`tuple`,items:e,rest:r?t:null,..._(r?n:t)})}const Ps=y(`ZodRecord`,(e,t)=>{Bo(),Ir.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Fs(e,t,n){return!t||!t._zod?new Ps({type:`record`,keyType:O(),valueType:e,..._(t)}):new Ps({type:`record`,keyType:e,valueType:t,..._(n)})}function Is(e,t,n){return new Ps({type:`record`,keyType:e,valueType:t,..._(n),partial:!0})}const Ls=y(`ZodEnum`,(e,t)=>{Lr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ls({...t,checks:[],..._(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ls({...t,checks:[],..._(r),entries:i})}});function B(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ls({type:`enum`,entries:n,..._(t)})}const Rs=y(`ZodLiteral`,(e,t)=>{Rr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function V(e,t){return new Rs({type:`literal`,values:Array.isArray(e)?e:[e],..._(t)})}const zs=y(`ZodTransform`,(e,t)=>{Bo(),zr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Qe(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ie(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ie(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Bs(e){return new zs({type:`transform`,transform:e})}const Vs=y(`ZodOptional`,(e,t)=>{Vr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hs(e){return new Vs({type:`optional`,innerType:e})}const Us=y(`ZodExactOptional`,(e,t)=>{Hr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}const Gs=y(`ZodNullable`,(e,t)=>{Ur.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`nullable`,innerType:e})}const qs=y(`ZodDefault`,(e,t)=>{Wr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Js(e,t){return new qs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():fe(t)}})}const Ys=y(`ZodPrefault`,(e,t)=>{Kr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xs(e,t){return new Ys({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():fe(t)}})}const Zs=y(`ZodNonOptional`,(e,t)=>{qr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`nonoptional`,innerType:e,..._(t)})}const $s=y(`ZodCatch`,(e,t)=>{Xr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ec(e,t){return new $s({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ke(t)})}const tc=y(`ZodPipe`,(e,t)=>{Zr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.in=t.in,e.out=t.out});function nc(e,t){return new tc({type:`pipe`,in:e,out:t})}const rc=y(`ZodCodec`,(e,t)=>{tc.init(e,t),$r.init(e,t)}),ic=y(`ZodPreprocess`,(e,t)=>{tc.init(e,t),ni.init(e,t)}),ac=y(`ZodReadonly`,(e,t)=>{ri.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oc(e){return new ac({type:`readonly`,innerType:e})}const sc=y(`ZodCustom`,(e,t)=>{ai.init(e,t),D.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r)});function cc(e,t){return Oa(sc,e??(()=>!0),t)}function lc(e,t={}){return ka(sc,e,t)}function uc(e,t){return Aa(e,t)}const dc=(...e)=>Ma({Codec:rc,Boolean:gs,String:Ho},...e);function fc(e,t){return new ic({type:`pipe`,in:Bs(e),out:t})}function H(e){return Ji(Uo,e)}function U(e){return $i(ps,e)}function pc(e){return oa(ws,e)}const W=R([H(),H({precision:-1})]);R([H({offset:!0}),H({offset:!0,precision:-1})]);const mc=B([`mobile_to_desktop`,`desktop_to_mobile`]),hc=B([`project`,`task`,`asset`,`asset_conflict`]),gc=L({kind:B([`project`,`task`]),id:j()});L({direction:mc,target:gc}),L({workspaceId:j()}),L({workspaceId:j(),notificationId:j()}),L({target:gc});const _c=[`en`,`zh-TW`,`de`,`fr`,`es-ES`,`es-419`,`ja`,`ko`,`it`,`pt-BR`],vc=B(_c).default(`en`);function yc(e){return e?_c.includes(e):!1}function bc(e){return yc(e)?e:`en`}const xc=[`usage_exhausted`,`payment_failed`,`auto_reload_threshold_exceeded`,`role_changed`,`schedules_agent_deleted`,`agent_binding_removed`,`schedule_run_completed`,`publish_submitted`,`publish_approved`,`publish_rejected`,`task_complete`,`task_waiting_approval`,`workspace_join_request`,`access_request`,`meeting_shared`,`meeting_shared_workspace`,`project_member_added`,`task_shared_to_project`,`task_shared_with_member`,`schedules_calendar_auth_expired`,`agent_monthly_cap_threshold`,`handoff_requested`,`announcement`],Sc=[`info`,`action`],Cc=[`all`,`action`,`info`],wc=[`low`,`medium`,`high`],Tc=[`web`,`ios`,`android`],G=j(),Ec=B(_c),Dc=B(xc),Oc=B(Sc),kc=B(wc),Ac=B(Tc);L({workspaceId:G}),L({workspaceId:G,notificationId:G}),L({workspaceId:G,deviceId:G}),L({tab:B(Cc).default(`all`),eventType:R([Dc,I(Dc)]).transform(e=>Array.isArray(e)?e:[e]).optional(),cursor:O().optional(),limit:U().int().min(1).max(100).default(20),lang:Ec.optional()});const jc=L({id:O().min(1),labelKey:O().min(1),method:V(`POST`),path:O().min(1),requiresInput:I(L({fieldName:O().min(1),displayNameKey:O().min(1)})).min(1).optional(),style:B([`primary`,`destructive`,`secondary`]).optional()}),Mc=L({scope:B([`workspace`,`team`]),scopeName:O(),oldRole:O(),newRole:O(),canManageMember:P()}),Nc=L({workspaceName:O().min(1)}),Pc=L({workspaceName:O().min(1),invoiceId:O().min(1)}),Fc=L({workspaceName:O().min(1),thresholdUsd:O().min(1),reloadAmountUsd:O().min(1)}),Ic=L({scheduleName:O().min(1),agentName:O().min(1),scheduleId:G}),Lc=L({scheduleName:O().min(1),scheduleId:G}),Rc=V([100,80]),zc=L({agentName:O().min(1),agentId:G,threshold:Rc,spentUsd:O().min(1),capUsd:O().min(1)}),Bc=L({agentName:O().min(1),resourceName:O().min(1),resourceType:B([`model`,`connector`]),agentId:G}),Vc=L({requesterName:O().min(1),resourceName:O().min(1),resourceType:B([`agent`,`connector`,`skill`]),scope:B([`team`,`workspace`]),teamId:G.optional(),scopeName:O().min(1),inlineActions:I(jc),publishId:G}),Hc=L({approverName:O().min(1),resourceName:O().min(1),resourceType:B([`agent`,`connector`,`skill`]),resourceId:G}),Uc=L({approverName:O().min(1),resourceName:O().min(1),resourceType:B([`agent`,`connector`,`skill`]),reason:O(),actions:I(L({id:B([`resubmit`,`viewResource`]),labelKey:O().min(1),href:O().min(1)})),resourceId:G}),Wc=L({workspaceName:O().min(1),requesterEmail:A(),invitationId:G});B([`task`,`preview`,`meeting`]);const Gc=L({requesterName:O().min(1),resourceName:O().min(1),resourceId:G}),Kc=z(`resourceType`,[Gc.extend({resourceType:V([`task`,`preview`]),parentTaskId:G}),Gc.extend({resourceType:V(`meeting`),meetingId:G})]),qc=L({meetingId:G,meetingTitle:O().min(1),sharedByName:O().min(1),role:B([`viewer`,`editor`])}),Jc=L({meetingId:G,meetingTitle:O().min(1),sharedByName:O().min(1)}),Yc=L({projectId:G,projectName:O().min(1),addedByName:O().min(1)}),Xc=L({direction:mc,targetKind:hc,targetId:G}),Zc=L({taskId:G,taskTitle:O(),projectId:G,projectName:O().min(1),sharedByName:O().min(1)}),Qc=L({taskId:G,taskTitle:O(),projectId:G,projectName:O().min(1),sharedByName:O().min(1)}),$c=L({name:O(),taskTitle:O(),taskId:G}),el=L({aiResponseSnippet:O(),taskId:G}),tl=L({aiResponseSnippet:O(),taskId:G}),nl=L({title:O().min(1).max(200),body:O().min(1).max(2e3),ctaLabel:O().max(80).optional()}),rl=L({en:nl}).catchall(nl),il=L({notification:V(!0),webPush:P(),mobilePush:P(),email:P()}),al=B([`notification`,`popup`]),ol=L({announcementId:G,contentI18n:rl,channels:il,category:Oc,ctaUrl:O().optional(),surface:al.optional(),mediaKey:O().optional()}),sl=L({id:O().min(1),label:O().min(1),method:V(`POST`),path:O().min(1),style:B([`primary`,`destructive`,`secondary`]).optional(),requiresInput:I(L({fieldName:O().min(1),displayName:O().min(1)})).min(1).optional()}),cl=O().refine(e=>e.startsWith(`/`)||/^https?:\/\//.test(e),{message:`ctaUrl must be an absolute URL or a path starting with /`}),ll=L({title:O(),body:O(),ctaLabel:O().optional(),ctaUrl:cl.optional(),inlineActions:I(sl).optional()}),ul=L({id:G,urgency:kc,category:Oc,relatedEntityId:O().nullable(),rendered:ll,renderedLocale:Ec,readAt:H().nullable(),processedAt:H().nullable(),createdAt:H()}),dl=z(`eventType`,[L({eventType:V(`role_changed`),payload:Mc}),L({eventType:V(`usage_exhausted`),payload:Nc}),L({eventType:V(`payment_failed`),payload:Pc}),L({eventType:V(`auto_reload_threshold_exceeded`),payload:Fc}),L({eventType:V(`schedules_agent_deleted`),payload:Ic}),L({eventType:V(`schedules_calendar_auth_expired`),payload:Lc}),L({eventType:V(`agent_binding_removed`),payload:Bc}),L({eventType:V(`agent_monthly_cap_threshold`),payload:zc}),L({eventType:V(`schedule_run_completed`),payload:$c}),L({eventType:V(`publish_submitted`),payload:Vc}),L({eventType:V(`publish_approved`),payload:Hc}),L({eventType:V(`publish_rejected`),payload:Uc}),L({eventType:V(`task_complete`),payload:el}),L({eventType:V(`task_waiting_approval`),payload:tl}),L({eventType:V(`workspace_join_request`),payload:Wc}),L({eventType:V(`access_request`),payload:Kc}),L({eventType:V(`meeting_shared`),payload:qc}),L({eventType:V(`meeting_shared_workspace`),payload:Jc}),L({eventType:V(`project_member_added`),payload:Yc}),L({eventType:V(`task_shared_to_project`),payload:Zc}),L({eventType:V(`task_shared_with_member`),payload:Qc}),L({eventType:V(`handoff_requested`),payload:Xc}),L({eventType:V(`announcement`),payload:ol})]),fl=ul.and(dl);L({items:I(fl),nextKey:O().optional()}),L({item:fl.nullable()}),L({count:N().int().min(0),capped:P().optional()}),L({deviceType:Ac,fcmToken:O().min(1),description:O().max(500).optional()}),L({id:G,createdAt:H()}),L({}).strict();const pl=z(`kind`,[L({kind:V(`all`)}),L({kind:V(`admins`)}),L({kind:V(`specific`),userIds:I(G).min(1)})]);L({workspaceId:G.nullish(),contentI18n:rl,ctaUrl:M({protocol:/^https?$/}).max(2e3).optional(),urgency:kc,category:Oc,audience:pl,channels:il,surface:al.default(`notification`),mediaKey:O().min(1).max(100).optional()}).refine(e=>e.audience.kind===`all`||e.workspaceId!=null,{message:`workspaceId is required when audience.kind is 'admins' or 'specific'`,path:[`workspaceId`]}).refine(e=>e.surface!==`popup`||e.ctaUrl!=null,{message:`ctaUrl is required when surface is 'popup'`,path:[`ctaUrl`]}),L({id:G,createdAt:H()});const ml=L({limit:U().int().min(1).max(100).default(20),nextKey:O().optional()}),hl=L({limit:U().int().min(1).max(100).default(20),offset:U().int().nonnegative().default(0)});L({limit:U().int().min(1).max(100).default(50),beforeVersionNumber:U().int().positive().optional()}).extend({versionNumber:U().int().positive().optional()});const gl=[`asc`,`desc`];function _l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function vl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?_l(Object(n),!0).forEach(function(t){yl(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function yl(e,t,n){return t=bl(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bl(e){var t=xl(e,`string`);return typeof t==`symbol`?t:String(t)}function xl(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}Sl({});function Sl(e){return t.withOptions=t=>Sl(vl(vl({},e),t)),t;function t(t,...n){let r=typeof t==`string`?[t]:t.raw,{alignValues:i=!1,escapeSpecialCharacters:a=Array.isArray(t),trimWhitespace:o=!0}=e,s=``;for(let e=0;e<r.length;e++){let t=r[e];if(a&&(t=t.replace(/\\\n[ \t]*/g,``).replace(/\\`/g,"`").replace(/\\\$/g,`$`).replace(/\\\{/g,`{`)),s+=t,e<n.length){let t=i?Cl(n[e],s):n[e];s+=t}}let c=s.split(`
52
+ `),l=null;for(let e of c){let t=e.match(/^(\s+)\S+/);if(t){let e=t[1].length;l=l?Math.min(l,e):e}}if(l!==null){let e=l;s=c.map(t=>t[0]===` `||t[0]===` `?t.slice(e):t).join(`
53
+ `)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
54
+ `).replace(/\\t/g,` `).replace(/\\r/g,`\r`).replace(/\\v/g,`\v`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\0/g,`\0`).replace(/\\x([\da-fA-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/\\u([\da-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))),typeof Bun<`u`&&(s=s.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,(e,t,n)=>{let r=t??n??``;return String.fromCodePoint(parseInt(r,16))})),s}}function Cl(e,t){if(typeof e!=`string`||!e.includes(`
55
+ `))return e;let n=t.slice(t.lastIndexOf(`
56
+ `)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}const wl={blue:`#0360f0`,yellow:`#ffce25`,cyan:`#00d2ff`},Tl=[{tag:`polygon`,points:`893.15 145.4 764.8 145.4 764.8 171.11 816.12 171.11 816.12 265.19 841.83 265.19 841.83 171.11 893.15 171.11 893.15 145.4`},{tag:`path`,commands:`M935.9,183.97c0-7.1,5.76-12.86,12.86-12.86h86.93v-25.71h-95.26c-16.7,0-30.24,13.54-30.24,30.24v59.31c0,16.7,13.54,30.24,30.24,30.24h95.26v-25.71h-86.93c-7.1,0-12.86-5.76-12.86-12.86v-42.65Z`},{tag:`path`,commands:`M717.67,145.14v89.92l-66.31-85.23h0c-2.36-2.86-5.93-4.68-9.92-4.68-.33,0-13.61,0-13.61,0-7.1,0-12.86,5.76-12.86,12.86v107.19h25.71v-89l66.31,84.32h0c2.36,2.86,5.93,4.68,9.92,4.68q1.25,0,0,0h13.62q-2.5,0,0,0c7.04,0,12.75-5.66,12.85-12.68v-107.37h-25.71Z`},{tag:`path`,commands:`M495.48,145.14c-16.7,0-30.24,13.54-30.24,30.24v59.57c0,16.07,12.53,29.2,28.35,30.18h87.25c7.07,0,12.81-5.76,12.81-12.87v-47.1c0-7.11-5.73-12.87-12.81-12.87h-64.29v25.71h51.39v21.44h-64.15c-7.06,0-12.78-5.69-12.86-12.73v-43.1c.07-7.04,5.8-12.73,12.86-12.73l89.85-.02v-25.71h-98.17`}],El=[{tag:`path`,commands:`M1378.44,219.45c0,30.39-18.05,46.04-44.94,46.04s-44.94-15.47-44.94-46.04v-47.33h21.92v47.33c0,17.31,9.21,25.6,23.02,25.6s23.02-8.29,23.02-25.6v-47.33h21.92v47.33Z`},{tag:`path`,commands:`M1396.49,230.5v-88.22h21.92v32.23h46.96v19.89h-46.96v36.1c0,12.15,6.26,16.94,15.29,16.94s15.29-4.6,15.29-16.94v-2.39h21.92v2.39c0,25.23-15.1,37.39-37.2,37.39s-37.2-12.16-37.2-37.39Z`},{tag:`path`,commands:`M1485.49,218.16c0-30.39,18.05-46.04,44.94-46.04s44.94,15.47,44.94,46.04v47.33h-21.92v-47.33c0-17.31-9.21-25.6-23.02-25.6s-23.02,8.29-23.02,25.6v47.33h-21.92v-47.33Z`},{tag:`rect`,x:`1485.49`,y:`133.11`,width:`21.92`,height:`132.38`},{tag:`path`,commands:`M1172.56,217.04c0-29.54,22.45-48.9,48.41-48.9s48.61,19.36,48.61,48.9-22.64,49.1-48.61,49.1-48.41-19.56-48.41-49.1ZM1248.03,217.04c0-16.77-12.3-28.71-27.06-28.71s-26.85,11.95-26.85,28.71,12.09,28.92,26.85,28.92,27.06-11.74,27.06-28.92Z`},{tag:`rect`,x:`1248.21`,y:`172.2`,width:`21.92`,height:`93.29`},{tag:`rect`,x:`1077.07`,y:`193.92`,width:`55.68`,height:`21.92`}],Dl=[{tag:`polygon`,fill:wl.cyan,points:`232.67 341.7 241.66 346.89 250.66 341.68 361.69 277.59 297.18 240.35 297.17 240.35 250.66 267.2 241.66 272.4 232.67 267.21 186.15 240.35 121.63 277.59 232.67 341.7`},{tag:`polygon`,fill:wl.yellow,points:`177.15 224.77 177.15 160.66 186.14 155.47 232.67 128.6 232.67 54.11 121.63 118.23 112.64 123.42 112.64 262.01 177.15 224.77`},{tag:`polygon`,fill:wl.blue,points:`306.17 160.66 306.17 224.77 370.68 262.01 370.68 123.42 361.69 118.23 250.66 54.12 250.66 128.61 297.18 155.47 306.17 160.66`}];[...Tl,...El,...Dl],new TextEncoder,new TextDecoder(`utf-8`,{fatal:!1});const Ol=B([`starter`,`pro`,`premium`]);B([`pro`,`premium`]).options,B([`basic_window`,`granted_pool`,`purchased_pool`]);const kl=B([`purchased`,`granted`]);B([`task`,`title_generate`,`agent`,`schedule`,`sandbox_llm`,`sandbox_runtime`,`web_search`,`image_generation`,`agent_icon_generation`,`auto_routing`,`chatbot`,`meeting`,`mcp_tool_api_call`]);const K={TASK_MESSAGE:`task_message`,TITLE_GENERATION:`title_generation`,SENSITIVITY_CHECK:`sensitivity_check`,TOOL_CALL_EXTRA_TOKENS:`tool_call_extra_tokens`,TASK_SUMMARY:`task_summary`,SUBAGENT:`subagent`,WORKFLOW_AGENT:`workflow_agent`,LLM_PROXY:`llm_proxy`,IMAGE_GENERATION:`image_generation`,WEB_SEARCH:`web_search`,SANDBOX_RUNTIME:`sandbox_runtime`,MEETING:`meeting`,MEETING_RECORDING_TRANSCRIPTION:`meeting_recording_transcription`,MEETING_RECORDING_SUMMARY:`meeting_recording_summary`,MEETING_RECORDING_REFINE:`meeting_recording_refine`,MEETING_RECORDING_TITLE:`meeting_recording_title`,TOOL_CALL_RISK_ASSESSMENT:`tool_call_risk_assessment`,SCHEDULE_JUDGE:`schedule_judge`,SCHEDULE_JUDGE_REVIEW:`schedule_judge_review`,SCHEDULE_JUDGE_EXTRACT:`schedule_judge_extract`,PROJECT_KNOWLEDGE_DESCRIPTION:`project_knowledge_description`,PROJECT_KNOWLEDGE_EXTRACTION:`project_knowledge_extraction`,PUBLISH_CHANGE_SUMMARY:`publish_change_summary`};K.MEETING,K.MEETING_RECORDING_TRANSCRIPTION,K.MEETING_RECORDING_SUMMARY,K.MEETING_RECORDING_REFINE,K.MEETING_RECORDING_TITLE,K.WORKFLOW_AGENT,K.SCHEDULE_JUDGE_EXTRACT,K.WEB_SEARCH,K.PROJECT_KNOWLEDGE_DESCRIPTION,K.PROJECT_KNOWLEDGE_EXTRACTION,K.SENSITIVITY_CHECK,K.PUBLISH_CHANGE_SUMMARY;const Al={WEB_SEARCH:K.WEB_SEARCH,SANDBOX_RUNTIME:K.SANDBOX_RUNTIME};B([Al.WEB_SEARCH,Al.SANDBOX_RUNTIME]);const jl={SEARCH:`search`,SCRAPE:`scrape`};B([jl.SEARCH,jl.SCRAPE]),L({workspaceId:j()});const Ml=L({usedPercent:N().min(0).max(100),resetAt:H().nullable()});L({seatType:Ol,hourly:Ml.nullable(),weekly:Ml,trial:L({endsAt:H(),remainingDays:N().int().positive()}).optional(),extraUsage:L({spentUsd:N().nonnegative(),resetAt:H().nullable()}),availability:L({allowed:P(),reason:B([`usage_exhausted`,`budget_exceeded`]).nullable(),resetAt:H().nullable()})});const Nl=L({startAt:H(),endAt:H(),previousStartAt:H().optional()}),Pl=L({period:Nl,balanceUsd:N().nonnegative(),nextExpiry:L({amountUsd:N().positive(),expiresAt:H()}).optional(),currentSpentUsd:N().nonnegative(),currentSpentUsedPercent:N().nonnegative().nullable(),monthlyExtraUsageLimitUsd:N().positive().nullable(),memberMonthlyExtraUsageLimitUsd:N().positive().nullable()});L({periodStart:W.optional()}),L({period:Nl,spentUsd:N().nonnegative(),purchasedUsd:N().nonnegative()});const Fl=B([`extraUsage:desc`,`extraUsage:asc`]);L({periodStart:W.optional(),limit:U().int().min(1).max(100).default(20),offset:U().int().nonnegative().default(0),sort:Fl.default(`extraUsage:desc`),search:O().trim().max(200).optional()}),L({items:I(L({id:j(),user:L({id:j(),name:O(),email:A()}),seatType:Ol,extraUsage:N().nonnegative(),monthlyLimitOverride:L({limitUsd:N().positive().nullable()}).nullable().optional()})),total:N().int().nonnegative()}),L({id:j(),poolType:kl,balanceUsd:N().nonnegative(),initialAmountUsd:N().positive(),expiresAt:H().nullable(),isAutoReload:P().nullable(),purchaseId:j().nullable(),createdBy:j(),createdAt:H(),updatedAt:H()}),L({amountUsd:N().positive().max(1e5),expiresAt:W.optional()}),L({id:j(),workspaceId:j(),amountUsd:O(),expiresAt:H().nullable(),createdAt:H()}),L({enabled:P(),thresholdUsd:N().positive(),reloadAmountUsd:N().positive()}).nullable(),L({enabled:P(),thresholdUsd:N().positive(),reloadAmountUsd:N().positive()}),L({checkoutUrl:O().url().nullable()}),L({limitUsd:N().positive().nullable()}),L({limitUsd:N().positive().nullable()});const Il=L({id:j(),name:O(),email:A()});L({items:I(L({user:Il,limitUsd:N().positive().nullable()}))}),L({workspaceId:j(),userId:j()}),L({limitUsd:N().min(.01).max(999999.99).nullable()});const Ll=O().regex(/^\d+(\.\d+)?$/,`Budget must be a valid positive decimal number`).refine(e=>Number(e)>0,{message:`Budget must be a valid positive decimal number`});L({items:I(L({user:Il,budget:O().nullable()}))}),L({workspaceId:j(),userId:j()}),L({budget:Ll.nullable()}),L({periodStart:W.optional()});const Rl=L({model:O(),costUsd:N(),tokens:N()}),zl=L({costUsd:N(),totalTokens:N(),tokens:L({input:N(),output:N(),cachedInput:N(),cacheCreation:N()}),byModel:I(Rl)});L({taskId:j(),totalCostUsd:N(),totalTokens:N(),tokens:zl.shape.tokens,byModel:zl.shape.byModel}),L({taskId:j(),scheduleId:j(),scheduleRunId:j(),work:zl,extraction:zl,judgePrimary:zl,judgeReview:zl,runTotal:zl,includingExtraction:zl});const Bl=[`google`,`password`];L({users:I(L({id:j(),name:O(),email:A(),image:O().nullable().optional(),role:O(),loginMethods:I(B(Bl)),createdAt:H(),seatType:Ol.nullable(),pendingSeatType:Ol.nullable(),pendingEffectiveAt:H().nullable()})),total:N().int().nonnegative()}),hl.extend({search:O().trim().max(200).optional()});const Vl=O().min(10,`Password must be at least 10 characters long`).regex(/[a-z]/,`Password must contain at least one lowercase letter`).regex(/[A-Z]/,`Password must contain at least one uppercase letter`).regex(/[0-9]/,`Password must contain at least one number`).regex(/[^a-zA-Z0-9]/,`Password must contain at least one special character`);L({currentPassword:O().min(1,`Current password is required`),newPassword:Vl}),L({message:O()});const Hl=B(_c);L({email:A(),name:O(),image:O().nullable().optional(),locale:Hl,hasPassword:P()}),L({locale:Hl});const Ul=[`super_admin`,`operator`];B([`vertex/gemini-3.7-flash`,`vertex/gemini-3.5-flash`]),L({provider:V(`gemini`),model:O().min(1),estimatedHourlyCostUsd:N().nonnegative()}),L({model:O().min(1)});const Wl=L({id:j(),email:O()});L({admins:I(L({id:j(),email:O(),role:B(Ul),createdBy:Wl.nullable(),createdAt:H(),updatedAt:H()}))}),L({id:j(),role:B(Ul)}),L({email:A(),role:B(Ul)}),L({adminId:j()});const Gl=B([`owner`,`admin`,`member`]);L({email:A(),name:O().trim().min(1).max(100).optional(),password:Vl,workspaceId:j().optional(),role:Gl.default(`member`)});const Kl=L({id:j(),email:A(),name:O(),createdAt:H()}),ql=L({resetPasswordUrl:M(),resetPasswordExpiresAt:H()});Kl.extend(ql.shape),L({email:A(),role:Gl.default(`member`),sendPasswordSetupEmail:P().default(!1)}),L({id:j(),email:A(),name:O(),role:O(),passwordSetupEmailSent:P()}),L({workspaceId:j(),userId:j()}),L({sendEmail:P().default(!1)}),ql.extend({emailSentAt:H().nullable()}),L({role:B(Ul)});const Jl=[`create`,`update`,`delete`],Yl=[`workspace`,`admin`,`user`,`extra_usage`,`marketplace_agent`,`marketplace_skill`,`azure_openai_deployment`,`connector`,`model_tier`,`announcement`],Xl=[`success`,`failure`],Zl=L({adminId:j(),email:O().nullable(),isRemoved:P()}),Ql=L({ipAddress:O().optional(),details:Fs(O(),F()).optional(),errorMessage:O().optional()}),$l=L({id:j(),actor:Zl,action:B(Jl),resourceType:B(Yl),resourceId:O().nullable(),resourceLabel:O().nullable(),status:B(Xl),metadata:Ql,createdAt:H()});hl.extend({actorAdminId:j().optional(),action:B(Jl).optional(),resourceType:B(Yl).optional(),status:B(Xl).optional(),workspaceSearch:O().trim().max(200).optional(),from:W.optional(),to:W.optional()}),L({items:I($l),total:N().int().nonnegative()});const eu=L({id:j(),workspaceId:j().nullable(),contentI18n:rl,ctaUrl:O().nullable(),urgency:kc,category:Oc,audience:pl,channels:il,surface:al,mediaKey:O().nullable(),createdBy:j().nullable(),createdAt:H()});hl.extend({surface:al.optional()}),L({items:I(eu),total:N().int().nonnegative()}),L({announcementId:j()});const tu={"user:read":`Read your profile information`,"user:write":`Update your profile and preferences`,"user:email":`Read your email address`,"workspaces:read":`List and read your workspaces`,"workspaces:write":`Create and modify workspaces`,"tasks:read":`Read your task history and messages`,"tasks:write":`Create and send messages`,"tasks:delete":`Delete your tasks`,"projects:read":`List and read your projects`,"projects:write":`Create and modify projects`,"agents:read":`List and read agents`,"agents:write":`Create and modify agents`,"agents:execute":`Execute agents via the external API`,"connectors:read":`List available connectors`,"connectors:write":`Configure connector settings`,"tools:read":`List available tools`,"tools:execute":`Execute tools`,"skills:read":`List and read skills`,"skills:write":`Create and modify skills`,"meetings:read":`Read meetings and recordings`,"meetings:write":`Create and modify meetings and recordings`,"notifications:read":`Read your notifications`,"notifications:write":`Manage notification state and device registrations`,"publishes:read":`List and read publish requests`,"publishes:write":`Submit, approve, reject, and revoke publishes`,"calendar:read":`Read your calendar accounts and events`,"calendar:write":`Manage calendar accounts and sync settings`,"schedules:read":`Read your schedules`,"schedules:write":`Create and modify schedules`,"subscriptions:read":`Read your personal subscription connections`,"subscriptions:write":`Connect and disconnect personal subscriptions`,"workflows:read":`Read your workflows and their runs`,"workflows:write":`Create, modify, and run workflows`,"chatbot:read":`List and read chatbot installations and configurations`,"chatbot:write":`Manage chatbot installations and configurations`,"llm:chat":`Call LLM models via the proxy endpoint`,offline_access:`Access your data when you are not present`},nu=[`offline_access`,`user:email`],ru=Object.keys(tu).filter(e=>!nu.includes(e));if(ru.length===0)throw Error(`PAT_AVAILABLE_SCOPES must not be empty`);const iu=B(ru),au=L({id:j(),name:O(),tokenPrefix:O(),scopes:I(O()).nullable(),resources:L({agents:I(O()).optional(),skills:I(O()).optional(),connectors:I(O()).optional()}).nullable(),expiresAt:H().nullable(),lastUsedAt:H().nullable(),createdAt:H()});L({name:O().trim().min(1).max(200),expiresInDays:N().int().min(1).max(3650).nullable(),scopes:I(iu).min(1).transform(e=>[...new Set(e)]).nullable().default(null)}).refine(e=>!e.scopes?.includes(`agents:execute`),{message:`issue execute keys via POST /agents/:agentId/apiKeys`,path:[`scopes`]});const ou=L({token:O(),data:au});L({tokens:I(au)});var su=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}else if(t=e.match(r.twoOctet))return(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})();else if(t=e.match(r.threeOctet))return(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})();else return null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[new e([100,65435,0,0,0,0,0,0]),96],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString(),n=0,r=-1,i;for(;i=e.exec(t);)i[0].length>r&&(n=i.index,r=i[0].length);return r<0?t:`${t.substring(0,n)}::${t.substring(n+r)}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.parse=function(e){let t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1);function cu(e){return su.default.isValid(e)&&su.default.parse(e).range()===`unicast`}function lu(e){try{let{hostname:t}=new URL(e),n=t.toLowerCase().replace(/\.$/u,``);if(n===`localhost`||n.endsWith(`.localhost`))return!1;let r=n.startsWith(`[`)&&n.endsWith(`]`)?n.slice(1,-1):n;return!su.default.isValid(r)||cu(r)}catch{return!1}}const uu=M().min(1).max(4096).refine(e=>{try{return[`http:`,`https:`].includes(new URL(e).protocol)}catch{return!1}},{message:`Only HTTP/HTTPS protocols are allowed`}).refine(lu,{message:`Access to private network addresses is not allowed`}),du=B([`queued`,`running`,`completed`,`failed`]),fu=L({tool:O(),connectorId:O().optional(),summary:O(),status:O()});L({executionId:j(),status:du,agentVersionId:j().optional(),output:L({text:O(),structured:F().optional()}).optional(),actions:I(fu).optional(),cost:N().optional()}),L({executionId:j(),status:V(`running`)}),L({input:O().min(1).max(1e5),agentVersionId:j().optional(),webhookUrl:uu.optional(),metadata:Fs(O().max(100),O().max(1e3)).refine(e=>Object.keys(e).length<=20,{message:`metadata supports at most 20 keys`}).optional()}),L({requestsPerMinute:N().int().min(1).max(1e4).nullable()}),L({requestsPerMinute:N().int().nullable()}),L({items:I(au.pick({id:!0,name:!0,createdAt:!0,lastUsedAt:!0}))}),L({name:O().trim().min(1).max(200),expiresInDays:N().int().min(1).max(3650).nullable()}),ou.extend({webhookSecret:O()});const q={AGENT:`agent`,ASSET:`asset`,AUDIT_LOG:`audit_log`,CHART:`chart`,IMAGE_GENERATION:`image_generation`,MEETING:`meeting`,MEMORY:`memory`,PROJECT:`project`,SANDBOX:`sandbox`,SCHEDULE:`schedule`,SKILL:`skill`,SKILL_MANAGEMENT:`skill_management`,SLIDES:`slides`,SUBAGENT:`subagent`,TASK:`task`,WEB_SEARCH:`web_search`,WORKFLOW:`workflow`};Object.values(q);const pu=[q.WEB_SEARCH,q.IMAGE_GENERATION],J={SANDBOX:`sandbox`,MULTITASKING:`multitasking`,HISTORY:`history`,CREATION:`creation`,PROJECT:`project`,WEB_SEARCH:`web_search`,SCHEDULE:`schedule`,AGENTS_AND_SKILLS:`agents_and_skills`,AUDIT_LOG:`audit_log`},mu=Object.values(J);J.SANDBOX,q.SANDBOX,q.SKILL,J.MULTITASKING,q.SUBAGENT,q.WORKFLOW,J.HISTORY,q.TASK,q.MEETING,q.MEMORY,J.CREATION,q.ASSET,q.SLIDES,q.IMAGE_GENERATION,J.PROJECT,q.PROJECT,q.ASSET,J.WEB_SEARCH,q.WEB_SEARCH,J.SCHEDULE,q.SCHEDULE,J.AGENTS_AND_SKILLS,q.AGENT,q.SKILL_MANAGEMENT,J.AUDIT_LOG,q.AUDIT_LOG;const hu=Is(B(mu),P());function gu(e,t){return e===void 0?!0:e[t]??t!==J.AUDIT_LOG}function _u(e){return Object.fromEntries(mu.map(t=>[t,e.includes(t)]))}function vu(e){return mu.filter(t=>gu(e,t))}const yu=Object.freeze(_u([J.SANDBOX,J.AGENTS_AND_SKILLS]));q.CHART;const bu=B([`create`,`user_edit`,`agent_tool`,`restore`,`marketplace_install`,`publish`,`migration`]),xu=L({id:j(),versionNumber:N().int(),origin:bu,note:O().nullable(),restoredFromVersionNumber:N().int().nullable(),createdBy:L({id:j(),name:O(),image:O().nullable()}).nullable(),createdAt:H()});L({versions:I(xu.extend({publishedTargets:L({workspace:P(),teams:I(L({id:j(),name:O()}))})})),nextVersionNumber:N().int().nullable()});const Su=L({id:j(),name:O(),available:P()}),Cu=xu.extend({name:O(),description:O(),systemPrompt:O(),modelId:O(),connectorIds:I(j()),capabilities:hu,conversationStarters:I(O()),tools:I(O()).nullable(),iconId:j().nullable(),iconUrl:O().optional(),skillIds:I(j()),delegatableAgentIds:I(j()),connectors:I(Su),skills:I(Su),delegatableAgents:I(Su)});L({workspaceId:j(),agentId:j(),versionId:j()}),L({expectedHeadVersionId:j(),note:O().trim().max(500).optional()}),L({version:L({id:j(),versionNumber:N().int().positive()}).nullable()});const wu=[`updatedAt`,`name`],Tu={BUILT_IN:`built_in`,CUSTOM_SOURCE_CODE:`custom_source_code`,CUSTOM_REMOTE_URL:`custom_remote_url`},Eu=[Tu.BUILT_IN,Tu.CUSTOM_SOURCE_CODE,Tu.CUSTOM_REMOTE_URL],Du={PENDING:`pending`,APPROVED:`approved`,REJECTED:`rejected`,PENDING_UPDATE:`pending_update`};Du.APPROVED,Du.PENDING_UPDATE,Du.PENDING,Du.PENDING_UPDATE;const Ou={CONNECTOR:`connector`,AGENT:`agent`,SKILL:`skill`,MEETING:`meeting`};({...Ou});const ku={OWNER:`owner`,MANAGER:`manager`,MEMBER:`member`},Au={VISIBLE:`visible`,HIDDEN:`hidden`},ju={OWNER:`owner`,EDITOR:`editor`,VIEWER:`viewer`},Mu=B([ju.OWNER,ju.EDITOR,ju.VIEWER]);ju.OWNER,ju.EDITOR,ju.VIEWER;const Nu={USER:`user`,TEAM:`team`},Pu=B([Nu.USER,Nu.TEAM]),Fu=Mu.nullable(),Iu=B([Ou.CONNECTOR,Ou.AGENT,Ou.SKILL]),Lu=[Du.PENDING,Du.APPROVED,Du.REJECTED,Du.PENDING_UPDATE],Ru=L({id:j(),name:O()}),zu=L({id:j(),type:Iu,name:O(),description:O().optional(),connectorType:B(Eu).optional(),iconUrl:O().optional(),provider:O().optional()});L({rejectReason:O().trim().max(500).optional()}),L({search:O().trim().max(200).optional(),status:R([B(Lu),I(B(Lu)).min(1)]).optional(),resourceType:Iu.optional(),limit:U().int().min(1).max(100).default(20),nextKey:O().optional()});const Bu=L({id:j(),name:O(),versionNumber:N().int().nullable(),versionId:j().nullable(),publishId:j(),status:B(Lu),rejectReason:O().nullable()}),Vu=L({workspace:L({published:P(),versionNumber:N().int().nullable(),versionId:j().nullable(),publishId:j().nullable(),status:B(Lu).nullable(),rejectReason:O().nullable()}),teams:I(Bu)}),Hu=L({type:O(),provider:O().optional(),scopes:I(O()).optional(),tutorial:O().optional()}),Uu=L({type:V(`connector`),id:j(),name:O(),description:O(),iconUrl:O().optional(),toolPrefix:O(),url:O(),transport:O(),authorization:Hu.optional()}),Wu=L({id:j(),name:O(),hasPermission:P()}),Gu=L({id:O(),name:O(),available:P()}),Ku=L({previous:Cu,current:Cu}),qu=L({type:V(`agent`),id:j(),name:O(),description:O(),iconUrl:O().optional(),systemPrompt:O(),conversationStarters:I(O()),model:Gu,connectors:I(Wu),capabilities:hu,diff:Ku.optional(),changeSummary:O().nullable().optional()}),Ju=L({id:j(),description:O(),createdBy:L({id:j(),name:O()}),createdAt:H()}),Yu=Ju.extend({name:O(),downloadUrl:O(),contentChanged:P()});z(`type`,[Uu,qu,L({type:V(`skill`),id:j(),name:O(),description:O(),currentVersion:Ju,downloadUrl:O(),previousVersion:Yu.optional(),changeSummary:O().nullable().optional()})]);const Xu=[`private`,`review`,`live`,`rejected`],Zu=L({private:N().int().nonnegative(),review:N().int().nonnegative(),live:N().int().nonnegative(),rejected:N().int().nonnegative()}),Qu=L({id:j(),versionNumber:N().int().positive()});function $u(e){let t=e;for(;typeof t==`string`;)try{let e=JSON.parse(t);if(e===t)break;t=e}catch{break}return t}const ed=e=>fc($u,R([e,O()])),td=e=>fc($u,e),nd=L({name:O().describe(`Identifier: file path, resource id, URL, or title.`),detail:O().describe(`What it is plus what was done to it or why it matters — detailed enough to act on again.`)});L({overview:O().describe(`1–3 sentences: what this session is about and where it stands now.`),userRequests:ed(I(O())).describe(`Every distinct thing the user has asked for, in their own framing, oldest → newest. Never drop an ask — even a completed one (record completion in state). Merge near-duplicate or sub-divided asks into a single entry so this list stays bounded across repeated compactions.`),keyFacts:ed(I(O())).describe(`Durable facts, decisions made, concepts/constraints discovered, and errors with their fixes. Omit facts later turns made obsolete.`),artifacts:ed(I(nd)).optional().default([]).describe(`Concrete things touched that may need further action: files, resources, documents, datasets, URLs, IDs.`),constraints:ed(L({preferences:I(O()).describe(`How the user wants output: format, tone, language, style.`),negativeConstraints:I(O()).describe(`What the user explicitly said NOT to do.`)})).describe(`What the user wants and explicitly does not want.`),state:ed(L({status:B([`pending_input`,`in_progress`,`completed`]).describe(`Overall task state at the point of truncation.`),currentWork:O().describe(`What was actively in progress at truncation, detailed enough to resume immediately.`),nextStep:O().describe(`The single most logical next action. Empty only if genuinely blocked or awaiting the user.`),pendingQuestions:I(O()).describe(`Questions the agent still needs answered to proceed.`)})).describe(`Resumption state — how to pick the work back up seamlessly.`)});const rd=1500,id=2e3;function ad(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function od(e){return[...new Set(e)].slice(0,12)}function sd(e){let t=new Set;return e.filter(e=>{let n=JSON.stringify([e.value,e.context]);return t.has(n)?!1:(t.add(n),!0)}).slice(0,12)}const cd=I(O().overwrite(e=>ad(e,500)).max(500)).overwrite(od).max(12),ld=I(L({value:O().overwrite(e=>ad(e,id)).max(id).describe(`Exact identifier, path, URL, value, resource id, or title.`),context:O().overwrite(e=>ad(e,500)).max(500).describe(`Why this reference still matters for the continuation.`)})).overwrite(sd).max(12);L({version:N().min(2).max(2).transform(()=>2),overview:O().overwrite(e=>ad(e,rd)).max(rd).describe(`A concise orientation to the current conversation and active objective.`),userRequests:td(cd).describe(`Active or still-relevant user requests. Merge repetitions and omit superseded requests whose effects are preserved elsewhere.`),keyFacts:td(cd).describe(`Facts and observations whose loss would change later reasoning. Preserve uncertainty and exact values.`),decisions:td(cd).describe(`Still-relevant accepted, rejected, superseded, or abandoned decisions with enough rationale to apply them consistently and avoid repeating discarded approaches.`),reportedProgress:td(cd).describe(`Relevant work, observations, and outcomes reported in the conversation. Preserve who or what reported uncertain claims; narration is not runtime-verified progress.`),references:td(ld).describe(`Exact identifiers and artifacts that remain necessary for continuation.`),constraints:td(cd).describe(`Still-governing requirements, preferences, and prohibitions.`),currentFocus:O().overwrite(e=>ad(e,rd)).max(rd).describe(`The current conversational focus, not a lifecycle state.`),openQuestions:td(cd).describe(`Unresolved questions, dependencies, or user decisions that still matter.`),continuationHint:O().overwrite(e=>ad(e,rd)).max(rd).describe(`Advisory conversational guidance only. It never grants permission or defines an executable runtime transition.`)});const ud=L({key:O(),value:O()});L({summary:O(),sessionMeta:ed(L({currentIntent:O()})),knowledgeBase:ed(L({entities:I(ud),factsEstablished:I(O())})),userConstraints:ed(L({formatPreferences:O(),toneStyle:O(),negativeConstraints:I(O())})),workflowStatus:ed(L({lastAction:O(),pendingQuestions:I(O())}))});const dd=B([`pending`,`ready`,`failed`]),fd=2e3,pd=L({id:j(),projectId:j(),fileId:j(),name:O(),mimeType:O(),size:N().int().nonnegative(),url:O().nullable(),description:O().nullable(),addedBy:j(),createdAt:H(),updatedAt:H()}),md=L({id:j(),projectId:j(),url:O(),title:O().nullable(),status:dd,description:O().nullable(),fetchError:O().nullable(),lastFetchedAt:H().nullable(),addedBy:j(),createdAt:H(),updatedAt:H()});L({fileId:j()}),L({url:uu});const hd=L({description:O().max(fd)});L({files:I(pd)}),L({links:I(md)});const gd=1e5;L({content:O().trim().min(1).max(gd),title:O().trim().min(1).max(100).optional()}),L({taskId:j(),projectId:j()});const _d=B([`task`,`file`,`link`]);L({q:O().trim().min(1).max(200),type:R([_d,I(_d).min(1)]).optional().transform(e=>{if(e!==void 0)return[...new Set(Array.isArray(e)?e:[e])]}),limit:U().int().min(1).max(20).default(10)}),L({results:I(z(`type`,[L({type:V(`task`),taskId:j(),title:O(),updatedAt:H(),snippet:O().optional()}),L({type:V(`file`),sourceId:j(),title:O(),description:O().optional(),snippet:O().optional()}),L({type:V(`link`),sourceId:j(),title:O(),description:O().optional(),snippet:O().optional()})]))}),L({depth:B([`summary`,`full`]).default(`summary`),offset:U().int().min(0).optional()}),z(`status`,[L({status:V(`text`),sourceType:_d,sourceId:j(),title:O(),content:O(),truncated:P(),nextOffset:N().int().nonnegative().optional()}),L({status:V(`download`),sourceType:B([`file`,`link`]),sourceId:j(),title:O(),downloadUrl:M()}),L({status:V(`pending`),sourceType:V(`link`),sourceId:j(),title:O()}),L({status:V(`failed`),sourceType:V(`link`),sourceId:j(),title:O(),error:O()})]);const vd=2e3,yd=1e4,bd=B([`owner`,`member`]),xd=L({id:j(),workspaceId:j(),name:O(),description:O().nullable(),instruction:O().nullable(),createdAt:H(),updatedAt:H()}),Sd=L({userId:j(),role:bd,name:O(),email:A(),image:O().nullable().optional()}),Cd=O().max(yd,`Instruction is too long: the maximum is ${yd} characters.`);L({name:O().trim().min(1).max(255),description:O().max(vd).nullable().optional(),instruction:Cd.nullable().optional()}).partial();const wd=L({userId:j(),name:O(),email:A(),image:O().nullable()}),Td=xd.extend({role:bd,creator:wd.nullable(),isShared:P(),hasOtherMembers:P()}),Ed=B([`all`,`mine`,`shared`]);L({limit:U().int().min(1).max(100).default(50),nextKey:O().optional(),filter:Ed.default(`all`),search:O().trim().max(200).optional()}),L({projects:I(Td),nextKey:O().optional()}),xd.extend({role:bd,creator:wd.nullable(),isShared:P(),members:I(Sd),taskCount:N().int().nonnegative(),sourceCount:N().int().nonnegative(),assetCount:N().int().nonnegative(),assetVersionCount:N().int().nonnegative()}),L({userId:j()}),L({role:bd}),L({projectId:j().nullable(),confirmAssetSharing:P().optional()}),L({taskId:j(),projectId:j().nullable()});const Dd=L({id:j(),name:O()}),Od=[`personal`,`managed`],kd=`always_allow`,Ad={ALWAYS_ASK:`always_ask`,AUTO:`auto`,ALWAYS_ALLOW:`always_allow`},jd=B(Ad);jd.exclude([`ALWAYS_ASK`]);const Md={BY_USER:`The user denied this tool call, so it did not run.`,UNATTENDED:`This tool call needs human approval and this run has no one to ask, so it did not run.`,INSTRUCTION:`Do not call it again unless the user explicitly asks you to, and do not reach the same result through another tool or route. Continue with the parts of the task that do not depend on it. In your reply, say which call was refused and what you left out; if the task cannot be completed without it, stop and ask the user how to proceed.`},Nd={ASK:`ask`,DENY:`deny`,BYPASS:`bypass`},Pd=B(Nd);Ad.ALWAYS_ALLOW,Ad.AUTO,Ad.ALWAYS_ASK,Nd.BYPASS,Nd.ASK,Nd.DENY,B([`allow_all`,`auto_ask`,`auto_deny`]);const Fd=[{id:`allow_all`,toolApprovalMode:Ad.ALWAYS_ALLOW,approvalHandling:Nd.BYPASS},{id:`auto_ask`,toolApprovalMode:Ad.AUTO,approvalHandling:Nd.ASK},{id:`auto_deny`,toolApprovalMode:Ad.AUTO,approvalHandling:Nd.DENY}];function Id(e,t){return Fd.find(n=>n.toolApprovalMode===e&&n.approvalHandling===t)?.id}const Ld={always_ask:`Always Ask`,auto:`Auto`,always_allow:`Always Allow`},Rd={always_ask:`Show approval dialog for every tool execution`,auto:`Ask only before high-risk tools; auto-approve the rest`,always_allow:`Never ask for approval (trust mode)`},zd=new Set(Object.values({WORKSPACE_POLICY:`workspace_policy_need_approval`,TASK_POLICY:`task_policy_need_approval`,USER_POLICY:`user_policy_need_approval`,ALWAYS_ASK_MODE:`always_ask_mode`,REQUIRES_USER_INTERACTION:`tool_requires_user_interaction`,HIGH_SENSITIVITY:`high_sensitivity`,MUTATING_TOOL:`mutating_tool`,NO_SIGNALS:`no_signals`,ASSESSMENT_HIGH_RISK:`assessment_high_risk`,ASSESSMENT_FAILED:`assessment_failed`,POLICY_LOOKUP_FAILED:`policy_lookup_failed`,INNER_TOOL_NOT_FOUND:`inner_tool_not_found`,INPUT_MISSING_TOOL_NAME:`input_missing_tool_name`,INNER_RESOLUTION_FAILED:`inner_resolution_failed`}));function Bd(e){return zd.has(e)}function Vd(e){return e!==void 0&&Bd(e)?e:`generic`}const Hd=`This tool's policy could not be resolved, so it needs your approval.`,Ud={workspace_policy_need_approval:`Your workspace requires approval before this tool runs.`,task_policy_need_approval:`This task is set to ask before this tool runs.`,user_policy_need_approval:`You chose to be asked before this tool runs.`,always_ask_mode:`Your approval mode asks before every tool.`,tool_requires_user_interaction:`This tool needs your input to continue.`,high_sensitivity:`This tool is marked high risk.`,mutating_tool:`This tool can change data.`,no_signals:`This tool has not declared what it changes.`,assessment_high_risk:`This call was assessed as high risk.`,assessment_failed:`The risk check was unavailable, so it needs your approval.`,policy_lookup_failed:Hd,inner_tool_not_found:Hd,input_missing_tool_name:Hd,inner_resolution_failed:Hd,generic:`This tool needs your approval before it runs.`};function Wd(e){return Ud[Vd(e)]}const Gd={ALWAYS_ALLOW:`always_allow`,NEED_APPROVAL:`need_approval`,BLOCK:`block`},Kd=B([Gd.ALWAYS_ALLOW,Gd.NEED_APPROVAL,Gd.BLOCK]),qd=L({toolName:O().trim().min(1).max(200),policy:Kd});I(qd).refine(e=>{let t=e.map(e=>e.toolName);return new Set(t).size===t.length},{message:`Duplicate toolName in toolPolicies`});const Jd={[Gd.ALWAYS_ALLOW]:0,[Gd.NEED_APPROVAL]:1,[Gd.BLOCK]:2};function Yd(...e){let t=new Map;for(let n of e)for(let{toolName:e,policy:r}of n??[]){let n=t.get(e);(n===void 0||Jd[r]>Jd[n])&&t.set(e,r)}return t}const Xd=L({hour:N().int().min(0).max(23),minute:N().int().min(0).max(59)}).describe(`Wall-clock local time in the schedule's own utcOffset timezone (NOT UTC). E.g. { "hour": 9, "minute": 0 } means 9:00 AM in that timezone, regardless of what utcOffset is — do not convert a user-stated local time to UTC before setting this field.`),Zd=O().trim().min(1).max(2e3),Qd=L({enabled:P().optional(),criteria:Zd.optional(),extracted:L({outcomes:I(Zd).min(1).max(20),extractedAt:H(),inputFingerprint:O().regex(/^[a-f0-9]{64}$/u).optional(),extractorVersion:N().int().positive().optional()}).optional()});L({completed:V(!1),reason:Zd,unmet:I(Zd).max(20),criteriaSource:B([`inferred`,`explicit`,`extracted`]),analysis:O().trim().min(1).max(1e3).optional(),escalated:P().optional(),reviewSkipped:P().optional()});const $d=e=>e.hour*60+e.minute,ef=I(L({start:Xd,end:Xd}).refine(e=>$d(e.end)>$d(e.start),{message:`Run window end must be after start (no cross-midnight)`,path:[`end`]})).min(1).max(5),tf=I(Xd).min(1).max(5).refine(e=>new Set(e.map(e=>e.hour*60+e.minute)).size===e.length,{message:`Trigger times must not contain duplicates`}).optional(),nf=I(N().int().min(0).max(6)).min(1);z(`type`,[L({type:V(`no-repeat`)}),L({type:V(`repeat`),interval:z(`unit`,[L({unit:V(`minutes`),every:N().int().min(15,`Minimum interval is 15 minutes`).max(1440,`Maximum interval is 1440 minutes (24 hours)`),dailyWindows:ef.optional(),daysOfWeek:nf.optional()}),L({unit:V(`hours`),every:N().int().min(1),minute:N().int().min(0).max(59),dailyWindows:ef.optional(),daysOfWeek:nf.optional()}),L({unit:V(`days`),every:N().int().min(1),time:Xd,times:tf,daysOfWeek:nf.optional()}),L({unit:V(`weeks`),every:N().int().min(1),daysOfWeek:I(N().int().min(0).max(6)).min(1),time:Xd}),L({unit:V(`months`),every:N().int().min(1),daysOfMonth:I(N().int().min(1).max(31)),lastDayOfMonth:P(),time:Xd})])})]).superRefine((e,t)=>{if(e.type!==`repeat`)return;let n=e.interval;if(n.unit===`months`&&n.daysOfMonth.length===0&&!n.lastDayOfMonth&&t.addIssue({code:`custom`,message:`lastDayOfMonth must be true when daysOfMonth is empty`,path:[`interval`,`daysOfMonth`]}),n.unit===`hours`&&n.every>=24&&(n.daysOfWeek?.length??0)>0&&t.addIssue({code:`custom`,message:`Weekday filter is not available for hourly intervals of 24 hours or more`,path:[`interval`,`daysOfWeek`]}),n.unit===`days`&&n.every%7==0&&(n.daysOfWeek?.length??0)>0&&t.addIssue({code:`custom`,message:`Weekday filter is not supported for day intervals that are a multiple of 7 (the weekday never changes); use the weeks unit instead`,path:[`interval`,`daysOfWeek`]}),n.unit===`hours`&&n.every>=24&&(n.dailyWindows?.length??0)>0&&t.addIssue({code:`custom`,message:`Active windows are not available for hourly intervals of 24 hours or more`,path:[`interval`,`dailyWindows`]}),n.unit!==`minutes`&&n.unit!==`hours`||n.unit===`hours`&&n.every>=24)return;let r=n.dailyWindows;if(!r)return;let i=n.unit===`minutes`?n.every:n.every*60;r.some(e=>$d(e.end)-$d(e.start)<i)&&t.addIssue({code:`custom`,message:`Each run window must be at least as long as the interval`,path:[`interval`,`dailyWindows`]});let a=[...r].toSorted((e,t)=>$d(e.start)-$d(t.start));for(let e=1;e<a.length;e++){let n=a[e],r=a[e-1];if(n&&r&&$d(n.start)<$d(r.end)){t.addIssue({code:`custom`,message:`Run windows must not overlap`,path:[`interval`,`dailyWindows`]});break}}});const rf=L({id:j(),name:O(),kind:B(Od).optional(),iconUrl:O().optional(),deletedAt:H().optional(),specifiedVersion:Qu.nullable().optional(),updatableToVersion:Qu.nullable().optional()});j().nullable().optional();const af=L({id:O(),name:O()}),of=L({id:j(),title:O(),read:P(),deletedAt:H().nullable()}),sf=L({id:j(),name:O(),isWorkspaceMember:P()}),cf=L({id:j(),name:O(),prompt:O(),user:sf.optional(),agent:rf.optional(),model:af.optional(),startsAt:H(),isActive:P(),unreadTasks:N().int(),nextRunAt:H().nullable(),utcOffset:O(),config:cc().meta({type:`object`}),judge:Qd.nullish(),toolApprovalMode:jd.nullish(),approvalHandling:Pd.nullish(),holidayCalendarIds:I(j()).nullish(),recentTasks:I(of).optional(),createdAt:H(),updatedAt:H()});cf.extend({toolPolicies:I(qd)}),L({schedules:I(cf),nextKey:O().optional()}),ml.extend({search:O().trim().max(200).optional(),sortBy:B([`nextRunAt`,`name`]).optional(),isActive:dc().optional(),agentId:j().optional()});const lf=B([`queued`,`running`,`completed`,`failed`,`skipped`]),uf=L({type:O().optional().transform(e=>e===`runtime`||e===`judge`?e:void 0),message:O(),code:O().optional()}),df=L({id:j(),name:O()}),ff=B([`approval`]);L({runs:I(L({id:j(),scheduledAt:H(),agent:rf.optional(),model:af.optional(),task:of.nullable(),error:uf.nullish(),status:lf.optional(),skipReason:O().nullish(),resolvedAt:H().nullish(),resolvedBy:df.nullish(),waitingReason:ff.nullish()})),nextKey:O().optional()}),L({resolvedAt:H(),resolvedBy:df.nullable()});const Y={SELF:`self`,WORKSPACE:`workspace`,PUBLIC:`public`},pf=B([Y.SELF,Y.WORKSPACE,Y.PUBLIC]);Y.SELF,Y.WORKSPACE,Y.PUBLIC;const mf=B([Y.PUBLIC,Y.WORKSPACE,`none`]);Y.PUBLIC,Y.WORKSPACE;const hf=N().int().positive().optional(),gf=j().nullable(),_f=L({id:j(),name:O(),mimeType:O(),size:N(),url:M()}),vf=z(`type`,[L({id:j(),type:V(`file`),projectId:gf,file:_f,versionNumber:hf,createdAt:H(),updatedAt:H()}),L({id:j(),type:V(`website`),projectId:gf,url:M(),sandboxId:O().nullable(),title:O().optional(),visibility:pf.default(Y.SELF),source:_f.optional(),hasUnsavedWork:P().optional(),versionNumber:hf,createdAt:H(),updatedAt:H()}),L({id:j(),type:V(`deck`),projectId:gf,title:O(),pdf:_f,pptx:_f.optional(),hasUnsavedWork:P().optional(),versionNumber:hf,createdAt:H(),updatedAt:H()})]);L({data:I(vf),nextKey:O().optional()}),L({data:vf}),L({data:L({webViewLink:M()})}),L({visibility:pf});const yf=L({id:j(),versionNumber:N().int().positive(),title:O().nullable(),summary:O().nullable(),editor:L({id:j(),name:O(),email:A(),image:O().nullable()}),createdAt:H(),sourceTask:R([L({visible:V(!0),id:j(),title:O().nullable()}),L({visible:V(!1)})]).nullable(),revertedFrom:N().int().positive().nullable()});L({data:L({headVersionId:j(),canRevert:P(),versions:I(yf)})}),L({summary:O().trim().min(1).max(500).optional()}),L({data:z(`status`,[L({status:V(`saved`),versionId:j(),versionNumber:N().int().positive()}),L({status:V(`unchanged`),versionNumber:N().int().positive()})])});const bf=L({id:j(),name:O()});L({assetProjectId:j().nullable(),assetName:O(),assetHasPreviewableVersions:P(),currentVersionNumber:N().int().positive(),currentVersionSavedAt:H(),currentVersionEditor:bf,baseVersionNumber:N().int().positive()}).extend({assetId:j()}),L({expectedHeadVersionId:j()}),L({data:L({versionId:j(),versionNumber:N().int().positive(),revertedFrom:N().int().positive()})});const xf=B([Y.SELF,`project`,Y.WORKSPACE,Y.PUBLIC]);Y.SELF,Y.WORKSPACE,Y.PUBLIC,L({shareId:j(),assetId:j()}),L({data:vf}),L({visibility:xf}),L({id:j(),visibility:xf,createdAt:H(),updatedAt:H()});const Sf=L({userId:j(),name:O(),email:A(),image:O().nullable().optional(),grantedAt:H()});L({data:I(Sf)}),L({data:Sf}),B([`running`,`completed`,`failed`]);const Cf=L({id:j(),name:O(),iconId:j().optional(),iconUrl:O().optional(),deletedAt:H().optional(),specifiedVersion:Qu.nullable().optional()}),wf=[`chat`,`chatbot`,`schedule`,`agent_api`],Tf=B(wf);L({tasks:I(L({id:j(),title:O(),read:P(),toolApprovalMode:jd.optional(),userId:j(),workspaceId:j(),source:Tf,waitingReason:V(`approval`).optional(),share:L({id:j(),visibility:xf}).optional(),isSharedWithOthers:P().optional(),isOwn:P().optional(),agent:Cf.optional(),schedule:L({id:j(),name:O()}).optional(),scheduleRun:L({runId:j(),status:lf,error:uf.nullish(),resolvedAt:H().nullable(),resolvedBy:df.nullish(),canResolve:P()}).optional(),project:Dd.nullable().optional(),containsSensitiveContent:P().optional(),createdAt:H(),updatedAt:H()})),nextKey:O().optional()}),L({id:j(),title:O(),visibility:xf,workspace:L({id:j()}),agent:Cf.optional(),createdAt:H()}),L({results:I(L({id:j(),title:O(),titleHighlight:O().nullable(),contentSnippet:O().nullable(),project:Dd.nullable().optional(),createdAt:H(),updatedAt:H()})),nextKey:O().optional()});const Ef=[`enabled`,`disabled`];L({userId:j()}),L({status:B(Ef)}),L({monthlyCapUsd:N().positive().nullable()}),L({items:I(L({connectorId:j(),name:O(),authorizedBy:L({id:j(),name:O(),disabled:P()}),updatedAt:H()}))});const Df=wf,Of=[`completed`,`failed`,`running`];ml.extend({limit:U().int().min(1).max(100).default(30),source:B(Df).optional(),status:B(Of).optional(),initiatorId:j().optional(),from:W.optional(),to:W.optional(),q:O().trim().max(200).optional()}).refine(e=>e.from===void 0||e.to===void 0||new Date(e.from)<=new Date(e.to),{message:`to must be greater than or equal to from`,path:[`to`]}),L({items:I(L({taskId:j(),title:O(),source:B(Df),initiator:L({userId:j().nullable(),name:O(),unlinked:P()}).nullable(),status:B(Of),actionCount:N().int(),cost:N(),createdAt:H()})),nextKey:O().nullable()});const kf=L({conversationCount:N().int(),actionCount:N().int(),cost:N(),errorRate:N()});L({today:kf,week:kf,monthCost:N(),monthlyCapUsd:N().nullable()}),L({items:I(L({id:j(),name:O(),missingConnectorNames:I(O()),disabled:P()})),nextKey:O().nullable()});const Af={[J.SANDBOX]:`Sandbox`,[J.MULTITASKING]:`Multitasking`,[J.HISTORY]:`History`,[J.CREATION]:`Content Creation`,[J.PROJECT]:`Project Knowledge`,[J.WEB_SEARCH]:`Web Search`,[J.SCHEDULE]:`Schedules`,[J.AGENTS_AND_SKILLS]:`Agents & Skills`,[J.AUDIT_LOG]:`Audit Logs`};function jf(e){return Af[e]??e}L({id:j(),versionNumber:N().int().positive()}).nullable(),L({iconId:j(),url:M()});const Mf=[`updatedAt`,`usedAt`,`name`];L({search:O().trim().max(200).optional(),nextKey:O().optional(),limit:U().int().min(1).max(100).default(20),sortBy:B(Mf).optional()});const Nf=L({id:j(),name:O(),isMe:P()}),Pf=L({id:j()}).nullable();L({agents:I(L({id:j(),name:O(),description:O(),kind:B(Od),managedStatus:B(Ef).optional(),provider:O(),author:Nf,iconUrl:O().optional(),publish:Pf,myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional()}),L({search:O().trim().max(200).optional(),status:B(Xu).optional(),nextKey:O().optional(),limit:U().int().min(1).max(100).default(20),sortBy:B(Mf).optional()}),L({agents:I(L({id:j(),name:O(),description:O(),kind:B(Od),managedStatus:B(Ef).optional(),iconUrl:O().optional(),hasUnpublishedChanges:P(),latestVersionNumber:N().int().nullable(),publishedTo:Vu.optional(),myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional(),totalCount:N().int().nonnegative(),statusCounts:Zu}),L({id:j(),name:O(),deletedAt:H().optional()});const Ff=L({id:O(),name:O(),available:P()}),If=L({id:j(),name:O(),hasPermission:P(),added:P()}),Lf=L({name:O(),isMe:P()}),Rf=L({sponsor:L({id:j(),name:O(),image:O().nullable().optional()}),monthlyCapUsd:N().nullable(),skills:I(L({id:j(),name:O()})),delegatableAgents:I(L({id:j(),name:O()})),apiRateLimit:N().int().nullable()});L({id:j(),name:O(),description:O(),kind:B(Od),managedStatus:B(Ef).optional(),managed:Rf.optional(),model:Ff.optional(),systemPrompt:O().optional(),conversationStarters:I(O()),connectors:I(If).optional(),capabilities:hu.optional(),provider:O(),author:Lf,iconId:j().optional(),iconUrl:O().optional(),versionNumber:N().int().nullable(),selectableVersions:I(Qu).optional(),latestVersionNumber:N().int().nullable().optional(),publishedTo:Vu.optional(),myRole:Fu,createdAt:H(),updatedAt:H()}),L({agents:I(L({id:j(),name:O(),description:O(),iconUrl:O().optional(),versionNumber:N().int().nullable(),createdAt:H(),updatedAt:H()}))}),L({agents:I(L({id:j(),name:O(),description:O(),kind:B(Od),managedStatus:B(Ef).optional(),conversationStarters:I(O()),provider:O().nullable(),author:Lf,publishedTo:Vu.optional(),team:L({id:j(),name:O()}).optional(),iconUrl:O().optional(),versionNumber:N().int().nullable(),myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional()});const zf=B([`true`,`false`]).transform(e=>e===`true`);ml.extend({createdBy:B([`workspace`,`team`,`me`]).optional(),teamId:j().optional(),search:O().trim().max(200).optional(),executableOnly:zf.optional(),sortBy:B(Mf).optional()}).refine(e=>!e.teamId||e.createdBy===`team`,{message:`teamId can only be used with createdBy: team`,path:[`teamId`]}),L({workspaceId:j(),agentId:j()}),L({limit:U().int().min(1).max(100).default(20),offset:U().int().nonnegative().default(0)});const Bf=L({taskId:j(),title:O(),source:Tf,amountUsd:N().nonnegative().nullable(),amountCredits:N().nonnegative().nullable(),usageCount:N().int().nonnegative(),lastUsageAt:H(),createdAt:H(),updatedAt:H()}),Vf=L({toolName:O(),input:O().optional(),output:O().optional()}),Hf=L({role:B([`user`,`assistant`]),texts:I(O()),toolCalls:I(Vf).optional()}),Uf=L({taskId:j(),title:O(),amountUsd:N().nonnegative().nullable(),amountCredits:N().nonnegative().nullable(),promptTexts:I(O()),messages:I(Hf).optional()});L({agentName:O().optional(),totalAmountUsd:N().nonnegative().nullable(),totalAmountCredits:N().nonnegative().nullable(),runCount:N().int().nonnegative(),total:N().int().nonnegative(),runs:I(Bf),promptSamples:I(Uf).optional(),promptSamplesTruncated:P().optional()});const Wf=L({agentId:j(),agentName:O(),amountUsd:N().nonnegative().nullable(),amountCredits:N().nonnegative().nullable(),runCount:N().int().nonnegative(),usageCount:N().int().nonnegative(),lastUsageAt:H()});L({periodDays:N().int().positive(),since:H(),totalAmountUsd:N().nonnegative().nullable(),totalAmountCredits:N().nonnegative().nullable(),totalAgents:N().int().nonnegative(),agents:I(Wf)});const Gf=L({p50AmountUsdPerRun:N().nonnegative().nullable(),p50AmountCreditsPerRun:N().nonnegative().nullable(),percentile:N().min(0).max(100).nullable(),workspaceAgentCount:N().int().nonnegative()}),Kf=L({avgInputTokensPerRun:N().nonnegative(),avgOutputTokensPerRun:N().nonnegative(),avgCachedInputTokensPerRun:N().nonnegative(),avgTotalTokensPerRun:N().nonnegative(),inputToOutputRatio:N().nonnegative(),cachedInputRatio:N().min(0).max(1),avgLlmCallsPerRun:N().nonnegative()}),qf=L({usageType:O(),amountUsd:N().nonnegative().nullable(),amountCredits:N().nonnegative().nullable()});L({agentId:j(),agentName:O(),modelId:O(),periodDays:N().int().positive(),since:H(),runCount:N().int().nonnegative(),totalAmountUsd:N().nonnegative().nullable(),totalAmountCredits:N().nonnegative().nullable(),avgAmountUsdPerRun:N().nonnegative().nullable(),avgAmountCreditsPerRun:N().nonnegative().nullable(),scheduleRunCount:N().int().nonnegative(),manualRunCount:N().int().nonnegative(),runsPerDay:N().nonnegative(),benchmark:Gf,tokenProfile:Kf.nullable(),costByType:I(qf),llmCostRatio:N().min(0).max(1).nullable(),highCostPerRun:P(),highFrequency:P(),systemPrompt:O(),systemPromptLength:N().int().nonnegative()}),L({capabilities:I(B(mu)),workspaceCapabilities:I(B(pu))});const Jf={invalidInput:`invalid_input`,staleRef:`stale_ref`,noMatch:`no_match`,ambiguousLocator:`ambiguous_locator`,resolutionFailed:`resolution_failed`,permissionDenied:`permission_denied`,userCancelled:`user_cancelled`,navigationFailed:`navigation_failed`,timeout:`timeout`,sensitiveContext:`sensitive_context`,backendFailure:`backend_failure`};Jf.permissionDenied,Jf.userCancelled,Jf.sensitiveContext;const Yf={DIRECT:`direct`,HINTED:`hinted`};Yf.DIRECT,Yf.HINTED,new TextEncoder;function Xf(e,t){return e.map(e=>({...e,disclosureMode:e.disclosureMode??t}))}const Zf=[`single_select`,`multi_select`],Qf=L({label:O().min(1).max(200).describe(`Display text for this option`),description:O().max(500).optional().describe(`Optional explanation of what this option means`)});L({questions:I(L({question:O().min(1).max(500).describe(`The question to ask the user`),type:B(Zf).describe(`single_select: user picks one option. multi_select: user picks one or more options.`),options:I(Qf).min(2).max(4).describe(`The available choices (2-4 options)`)})).min(1).max(3).describe(`One to three structured questions to ask the user`)}),L({answers:I(L({questionIndex:N().int().min(0).describe(`Index of the question answered`),type:B(Zf).describe(`Question type`),selectedOptions:I(O()).describe(`Labels of selected options (empty if skipped)`),customText:O().optional().describe(`Free text if user chose "Something else"`),skipped:P().describe(`Whether the user skipped this question`)})).describe(`Answers for each question`),dismissed:P().describe(`True if the user dismissed the entire wizard without answering`)});const $f=B([`all`,`agent`,`general-task`,`connector`,`skill`,`system`]),ep=B([`workspace_owner`,`agent_owner`]),tp=B([`success`,`failure`]),np=B([`personal`,`managed`]),rp=B([`manual`,`scheduled`]);L({workspaceId:j()}),L({...L({category:$f.optional(),targetId:O().trim().min(1).optional(),agentType:np.optional(),executionSource:rp.optional(),result:tp.optional(),actorId:j().optional(),search:O().trim().max(200).optional()}).shape,category:$f.optional().default(`all`),snapshot:O().min(1).max(2048).optional(),beforeOccurredAt:W.optional(),beforeId:O().min(1).optional(),limit:U().int().min(1).max(100).default(50),offset:U().int().min(0).default(0)}).refine(e=>!!e.beforeOccurredAt==!!e.beforeId,{message:`beforeOccurredAt and beforeId must be provided together`,path:[`beforeOccurredAt`]});const ip=L({id:j(),name:O(),email:O()}),ap=L({type:O(),id:O(),name:O(),agentId:j().optional()}),op=z(`type`,[L({type:V(`role`),from:O().optional(),to:O()})]),sp=L({type:B([`user`,`team`,`email`]),id:O().optional(),name:O(),email:O().optional(),role:O().optional()}),cp=L({id:O(),occurredAt:H(),actor:ip.nullable(),event:O(),category:$f.exclude([`all`]),result:tp,resource:ap,change:op.optional(),subject:sp.optional(),changedFields:I(O()).optional(),detail:O().optional(),taskUrl:O().optional()}),lp=L({id:O(),name:O(),category:$f.exclude([`all`])}),up=L({all:N().int().nonnegative(),agent:N().int().nonnegative(),"general-task":N().int().nonnegative(),connector:N().int().nonnegative(),skill:N().int().nonnegative(),system:N().int().nonnegative()});L({items:I(cp),asOf:H(),snapshot:O().min(1),total:N().int().nonnegative(),scope:ep,counts:up,targets:I(lp),actors:I(ip),retentionDays:N().int().positive()}),L({items:I(cp),asOf:H(),maxRows:N().int().positive()}),L({canAccess:P(),scope:ep.nullable()});const dp=[`openai`,`anthropic`,`vertex-anthropic`,`vertex-google`,`google`,`openrouter`,`selfhosted`,`apmic`,`cerebras`],fp=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],pp=[{id:`gpt-5.6-sol`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.6 Sol`,description:`Frontier model for complex professional work`,hiddenInTask:!1,active:!0,contextWindowTokens:105e4,maxOutputTokens:128e3,pricing:{input:`0.000_005`,output:`0.000_030`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,longContext:{input:`0.000_010`,output:`0.000_045`,cachedInput:`0.000_001`,cacheCreation:`0.000_012_5`}},capabilities:{reasoning:!0},tokenCalculator:{kind:`input-context`,thresholdTokens:272e3}},{id:`gpt-5.6-terra`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.6 Terra`,description:`GPT-5.6 model that balances intelligence and cost`,hiddenInTask:!1,active:!0,contextWindowTokens:105e4,maxOutputTokens:128e3,pricing:{input:`0.000_002`,output:`0.000_012`,cachedInput:`0.000_000_2`,cacheCreation:`0.000_002_5`,longContext:{input:`0.000_004`,output:`0.000_018`,cachedInput:`0.000_000_4`,cacheCreation:`0.000_005`}},capabilities:{reasoning:!0},tokenCalculator:{kind:`input-context`,thresholdTokens:272e3}},{id:`gpt-5.6-luna`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.6 Luna`,description:`GPT-5.6 model optimized for cost-sensitive workloads`,hiddenInTask:!1,active:!0,contextWindowTokens:105e4,maxOutputTokens:128e3,pricing:{input:`0.000_000_2`,output:`0.000_001_2`,cachedInput:`0.000_000_02`,cacheCreation:`0.000_000_25`,longContext:{input:`0.000_000_4`,output:`0.000_001_8`,cachedInput:`0.000_000_04`,cacheCreation:`0.000_000_5`}},capabilities:{reasoning:!0},tokenCalculator:{kind:`input-context`,thresholdTokens:272e3}},{id:`gpt-5.5`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.5`,description:`A new class of intelligence for coding and professional work`,hiddenInTask:!1,active:!0,contextWindowTokens:272e3,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_030`,cachedInput:`0.000_000_5`,longContext:{input:`0.000_010`,output:`0.000_045`,cachedInput:`0.000_001`}},capabilities:{reasoning:!0},tokenCalculator:{kind:`input-context`,thresholdTokens:272e3}},{id:`gpt-5.4`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.4`,description:`A more affordable model for coding and professional work`,hiddenInTask:!1,active:!0,contextWindowTokens:272e3,maxOutputTokens:64e3,pricing:{input:`0.000_002_5`,output:`0.000_015`,cachedInput:`0.000_000_25`,longContext:{input:`0.000_005`,output:`0.000_022_5`,cachedInput:`0.000_000_5`}},capabilities:{reasoning:!0},tokenCalculator:{kind:`input-context`,thresholdTokens:272e3}},{id:`gpt-5.4-mini`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.4 mini`,description:`Our strongest mini model yet for coding, computer use, and subagents`,hiddenInTask:!1,active:!0,contextWindowTokens:272e3,maxOutputTokens:32e3,pricing:{input:`0.000_000_75`,output:`0.000_004_5`,cachedInput:`0.000_000_075`},capabilities:{reasoning:!0}},{id:`gpt-5.2`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.2`,description:`The most advanced frontier model for professional work and long-running agents`,hiddenInTask:!1,active:!1,contextWindowTokens:272e3,maxOutputTokens:64e3,pricing:{input:`0.000_001_75`,output:`0.000_014`,cachedInput:`0.000_000_175`},capabilities:{reasoning:!0}},{id:`gpt-5.1`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5.1`,description:`Smarter, more conversational TaskGPT`,hiddenInTask:!1,active:!1,contextWindowTokens:272e3,maxOutputTokens:64e3,pricing:{input:`0.000_001_25`,output:`0.000_010`,cachedInput:`0.000_000_125`},capabilities:{reasoning:!0}},{id:`gpt-5`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5`,description:`Smartest, fastest, most useful model from OpenAI`,hiddenInTask:!1,active:!1,contextWindowTokens:272e3,maxOutputTokens:64e3,pricing:{input:`0.000_001_25`,output:`0.000_010`,cachedInput:`0.000_000_125`},capabilities:{reasoning:!0}},{id:`gpt-5-mini`,provider:`openai`,reasoning:{effort:`medium`},name:`GPT-5 mini`,description:`Fast for everyday tasks in low-cost`,hiddenInTask:!1,active:!1,contextWindowTokens:272e3,maxOutputTokens:32e3,pricing:{input:`0.000_000_25`,output:`0.000_002`,cachedInput:`0.000_000_025`},capabilities:{reasoning:!0}},{id:`o3`,provider:`openai`,reasoning:{effort:`medium`},name:`o3`,description:`Great for advanced reasoning`,hiddenInTask:!1,active:!1,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_002`,output:`0.000_008`,cachedInput:`0.000_000_5`},capabilities:{reasoning:!0}},{id:`gpt-4o`,provider:`openai`,name:`GPT-4o`,description:`Great for most tasks`,hiddenInTask:!1,active:!1,contextWindowTokens:2e5,maxOutputTokens:16e3,pricing:{input:`0.000_002_5`,output:`0.000_010`,cachedInput:`0.000_001_25`}},{id:`gpt-4.1-mini`,provider:`openai`,name:`GPT-4.1 mini`,description:`Fast for everyday tasks in low-cost`,hiddenInTask:!1,active:!1,contextWindowTokens:2e5,maxOutputTokens:32e3,pricing:{input:`0.000_000_4`,output:`0.000_001_6`,cachedInput:`0.000_000_1`}},{id:`gpt-image-2`,provider:`openai`,name:`GPT Image 2`,description:`OpenAI state-of-the-art image generation model. Supports text + image input; outputs images.`,hiddenInTask:!0,active:!0,contextWindowTokens:2e5,pricing:{input:`0.000_005`,output:`0.000_030`},imageGeneration:`gpt-image-2`,imageModel:!0},{id:`claude-haiku-4-5-20251001`,provider:`anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Haiku 4.5`,description:`Near-frontier performance with much greater cost-efficiency`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_001`,output:`0.000_005`,cachedInput:`0.000_000_1`,cacheCreation:`0.000_001_25`,cacheCreation1h:`0.000_002`}},{id:`claude-sonnet-4-20250514`,provider:`anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Sonnet 4`,description:`Smart, efficient model for everyday use`,hiddenInTask:!1,active:!1,contextWindowTokens:2e5,extendedContextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`,cacheCreation:`0.000_003_75`,cacheCreation1h:`0.000_006`,longContext:{input:`0.000_006`,output:`0.000_022_5`,cachedInput:`0.000_000_6`,cacheCreation:`0.000_007_5`,cacheCreation1h:`0.000_012`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`claude-sonnet-4-5-20250929`,provider:`anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Sonnet 4.5`,description:`Anthropic's best model for complex agents and coding`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,extendedContextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`,cacheCreation:`0.000_003_75`,cacheCreation1h:`0.000_006`,longContext:{input:`0.000_006`,output:`0.000_022_5`,cachedInput:`0.000_000_6`,cacheCreation:`0.000_007_5`,cacheCreation1h:`0.000_012`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`claude-sonnet-4-6`,provider:`anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},name:`Claude Sonnet 4.6`,description:`Anthropic's best model for complex agents and coding`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`,cacheCreation:`0.000_003_75`,cacheCreation1h:`0.000_006`}},{id:`claude-sonnet-5`,provider:`anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},name:`Claude Sonnet 5`,description:`Best combination of speed and intelligence for agents and coding`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,output:`0.000_010`,cachedInput:`0.000_000_2`,cacheCreation:`0.000_002_5`,cacheCreation1h:`0.000_004`}},{id:`claude-opus-4-1-20250805`,provider:`anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Opus 4.1`,description:`Powerful model for complex challenges with 5x money cost`,hiddenInTask:!1,active:!1,contextWindowTokens:2e5,maxOutputTokens:32e3,pricing:{input:`0.000_015`,output:`0.000_075`,cachedInput:`0.000_001_5`,cacheCreation:`0.000_018_75`,cacheCreation1h:`0.000_030`}},{id:`claude-opus-4-6`,provider:`anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},name:`Claude Opus 4.6`,description:`Most powerful model for complex challenges`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`claude-opus-4-8`,provider:`anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},name:`Claude Opus 4.8`,description:`Most powerful model for complex challenges`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`claude-opus-5`,provider:`anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},name:`Claude Opus 5`,description:`Most powerful model for complex challenges`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`claude-haiku-4-5@20251001`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Haiku 4.5`,description:`Near-frontier performance with much greater cost-efficiency (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_001`,output:`0.000_005`,cachedInput:`0.000_000_1`,cacheCreation:`0.000_001_25`,cacheCreation1h:`0.000_002`}},{id:`claude-sonnet-4-5@20250929`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Sonnet 4.5`,description:`Anthropic's best model for complex agents and coding (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,extendedContextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`,cacheCreation:`0.000_003_75`,cacheCreation1h:`0.000_006`,longContext:{input:`0.000_006`,output:`0.000_022_5`,cachedInput:`0.000_000_6`,cacheCreation:`0.000_007_5`,cacheCreation1h:`0.000_012`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`vertex/claude-sonnet-4-6`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},providerModelId:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`,description:`Anthropic's best model for complex agents and coding (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`,cacheCreation:`0.000_003_75`,cacheCreation1h:`0.000_006`}},{id:`vertex/claude-sonnet-5`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},providerModelId:`claude-sonnet-5`,name:`Claude Sonnet 5`,description:`Best combination of speed and intelligence for agents and coding (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,output:`0.000_010`,cachedInput:`0.000_000_2`,cacheCreation:`0.000_002_5`,cacheCreation1h:`0.000_004`}},{id:`claude-opus-4-5@20251101`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`enabled`,budgetTokens:12e3}},name:`Claude Opus 4.5`,description:`Latest Opus model for most complex tasks (via Vertex AI)`,hiddenInTask:!1,active:!1,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_015`,output:`0.000_075`,cachedInput:`0.000_001_5`,cacheCreation:`0.000_018_75`,cacheCreation1h:`0.000_030`}},{id:`vertex/claude-opus-4-6`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},providerModelId:`claude-opus-4-6`,name:`Claude Opus 4.6`,description:`Most powerful model for complex challenges (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`vertex/claude-opus-4-8`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},providerModelId:`claude-opus-4-8`,name:`Claude Opus 4.8`,description:`Most powerful model for complex challenges (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`vertex/claude-opus-5`,provider:`vertex-anthropic`,reasoning:{thinking:{type:`adaptive`},effort:`high`},providerModelId:`claude-opus-5`,name:`Claude Opus 5`,description:`Most powerful model for complex challenges (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_005`,output:`0.000_025`,cachedInput:`0.000_000_5`,cacheCreation:`0.000_006_25`,cacheCreation1h:`0.000_010`}},{id:`vertex/gemini-3.8-flash`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3.8-flash`,name:`Gemini 3.8 Flash (Vertex)`,description:`Most intelligent Flash model for long-horizon software engineering and autonomous agents (via Vertex AI).`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_75`,output:`0.000_003_75`,cachedInput:`0.000_000_075`}},{id:`vertex/gemini-3.7-flash`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3.7-flash`,name:`Gemini 3.7 Flash (Vertex)`,description:`Fast, efficient model for agentic, multimodal, and coding workflows (via Vertex AI).`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_75`,output:`0.000_003_75`,cachedInput:`0.000_000_075`}},{id:`vertex/gemini-3.5-flash`,provider:`vertex-google`,reasoning:{type:`level`,level:`medium`},providerModelId:`gemini-3.5-flash`,name:`Gemini 3.5 Flash (Vertex)`,description:`Frontier-level intelligence optimized for fast agentic and coding workflows (via Vertex AI).`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_001_5`,output:`0.000_009`,cachedInput:`0.000_000_15`}},{id:`vertex/gemini-3.1-pro-preview`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3.1-pro-preview`,name:`Gemini 3.1 Pro (Vertex)`,description:`Next-generation model with enhanced reasoning capabilities and improved performance (via Vertex AI).`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,cachedInput:`0.000_000_2`,output:`0.000_012`,longContext:{input:`0.000_004`,cachedInput:`0.000_000_4`,output:`0.000_018`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`vertex/gemini-3.5-flash-lite`,provider:`vertex-google`,reasoning:{type:`level`,level:`medium`},providerModelId:`gemini-3.5-flash-lite`,name:`Gemini 3.5 Flash Lite (Vertex)`,description:`Most cost-efficient model for high-volume agentic tasks (via Vertex AI).`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_3`,output:`0.000_002_5`,cachedInput:`0.000_000_03`}},{id:`vertex/gemini-3.1-flash-lite-preview`,provider:`vertex-google`,reasoning:{type:`level`,level:`minimal`},providerModelId:`gemini-3.1-flash-lite-preview`,name:`Gemini 3.1 Flash Lite (Vertex)`,description:`Lightweight and fast (via Vertex AI).`,hiddenInTask:!0,active:!1,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_25`,output:`0.000_001_5`,cachedInput:`0.000_000_025`}},{id:`vertex/gemini-3-pro-preview`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3-pro-preview`,name:`Gemini 3 Pro (Vertex)`,description:`The most powerful agentic model yet combines state-of-the-art reasoning with richer visuals and deep interactivity (via Vertex AI).`,hiddenInTask:!1,active:!1,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,cachedInput:`0.000_000_2`,output:`0.000_012`,longContext:{input:`0.000_004`,cachedInput:`0.000_000_4`,output:`0.000_018`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e4}},{id:`vertex/gemini-3-pro-image-preview`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3-pro-image-preview`,name:`Gemini 3 Pro Image Preview (Vertex)`,description:`The most powerful image generation model that lets you generate and edit images conversationally with state-of-the-art quality (via Vertex AI).`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:32e3,pricing:{input:`0.000_002`,output:`0.000_012`,outputImage:`0.000_12`,cachedInput:`0.000_000_2`},tokenCalculator:{kind:`image-output`},imageGeneration:`gemini-3-pro`},{id:`vertex/gemini-3-flash-preview`,provider:`vertex-google`,reasoning:{type:`level`,level:`high`},providerModelId:`gemini-3-flash-preview`,name:`Gemini 3 Flash (Vertex)`,description:`Fast and efficient preview model (via Vertex AI)`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_5`,output:`0.000_003`,cachedInput:`0.000_000_05`}},{id:`vertex/gemini-2.5-flash-image`,provider:`vertex-google`,reasoning:{type:`budget`,budgetTokens:12e3},providerModelId:`gemini-2.5-flash-image`,name:`Gemini 2.5 Flash Image (Vertex)`,description:`Latest, fastest, and most efficient natively multimodal model that lets you generate and edit images conversationally (via Vertex AI).`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:32e3,pricing:{input:`0.000_000_3`,output:`0.000_002_5`,outputImage:`0.000_03`,cachedInput:`0.000_000_03`,cacheCreation:`0.000_001`},tokenCalculator:{kind:`image-output`},imageGeneration:`gemini-2.5-flash`},{id:`vertex/gemini-2.5-flash-lite`,provider:`vertex-google`,reasoning:{type:`budget`,budgetTokens:12e3},providerModelId:`gemini-2.5-flash-lite`,name:`Gemini 2.5 Flash Lite (Vertex)`,description:`Lightweight and fast (via Vertex AI).`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_1`,output:`0.000_000_4`,cachedInput:`0.000_000_01`,cacheCreation:`0.000_001`}},{id:`gemini-3.8-flash`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3.8 Flash`,description:`Most intelligent Flash model for long-horizon software engineering and autonomous agents`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_75`,output:`0.000_003_75`,cachedInput:`0.000_000_075`}},{id:`gemini-3.7-flash`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3.7 Flash`,description:`Fast, efficient model for agentic, multimodal, and coding workflows`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_75`,output:`0.000_003_75`,cachedInput:`0.000_000_075`}},{id:`gemini-3.5-flash`,provider:`google`,reasoning:{type:`level`,level:`medium`},name:`Gemini 3.5 Flash`,description:`Frontier-level intelligence optimized for fast agentic and coding workflows`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_001_5`,output:`0.000_009`,cachedInput:`0.000_000_15`}},{id:`gemini-3.1-pro-preview`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3.1 Pro`,description:`Next-generation model with enhanced reasoning capabilities and improved performance.`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,cachedInput:`0.000_000_2`,output:`0.000_012`,longContext:{input:`0.000_004`,cachedInput:`0.000_000_4`,output:`0.000_018`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`gemini-3.5-flash-lite`,provider:`google`,reasoning:{type:`level`,level:`medium`},name:`Gemini 3.5 Flash Lite`,description:`Most cost-efficient model for high-volume agentic tasks`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_3`,output:`0.000_002_5`,cachedInput:`0.000_000_03`}},{id:`gemini-3.1-flash-lite-preview`,provider:`google`,reasoning:{type:`level`,level:`minimal`},name:`Gemini 3.1 Flash Lite`,description:`Lightweight and fast`,hiddenInTask:!0,active:!1,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_25`,output:`0.000_001_5`,cachedInput:`0.000_000_025`}},{id:`gemini-3-pro-preview`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3 Pro`,description:`The most powerful agentic model yet combines state-of-the-art reasoning with richer visuals and deep interactivity.`,hiddenInTask:!1,active:!1,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_002`,cachedInput:`0.000_000_2`,output:`0.000_012`,longContext:{input:`0.000_004`,cachedInput:`0.000_000_4`,output:`0.000_018`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e4}},{id:`gemini-3-pro-image-preview`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3 Pro Image Preview`,description:`The most powerful image generation model that lets you generate and edit images conversationally with state-of-the-art quality.`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:32e3,pricing:{input:`0.000_002`,output:`0.000_012`,outputImage:`0.000_12`,cachedInput:`0.000_000_2`},tokenCalculator:{kind:`image-output`},imageGeneration:`gemini-3-pro`},{id:`gemini-3-flash-preview`,provider:`google`,reasoning:{type:`level`,level:`high`},name:`Gemini 3 Flash`,description:`Fast and efficient preview model`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_5`,output:`0.000_003`,cachedInput:`0.000_000_05`}},{id:`gemini-2.5-pro`,provider:`google`,reasoning:{type:`budget`,budgetTokens:12e3},name:`Gemini 2.5 Pro`,description:`For reasoning, mathematics and programming`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_001_25`,output:`0.000_010`,cachedInput:`0.000_000_125`,cacheCreation:`0.000_004_5`,longContext:{input:`0.000_002_5`,output:`0.000_015`,cachedInput:`0.000_000_25`,cacheCreation:`0.000_004_5`}},tokenCalculator:{kind:`long-context`,thresholdTokens:2e5}},{id:`gemini-2.5-flash`,provider:`google`,reasoning:{type:`budget`,budgetTokens:12e3},name:`Gemini 2.5 Flash`,description:`Get quick assistance for various types`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_3`,output:`0.000_002_5`,cachedInput:`0.000_000_03`,cacheCreation:`0.000_001`}},{id:`gemini-2.5-flash-image`,provider:`google`,reasoning:{type:`budget`,budgetTokens:12e3},name:`Gemini 2.5 Flash Image `,description:`Latest, fastest, and most efficient natively multimodal model that lets you generate and edit images conversationally.`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:32e3,pricing:{input:`0.000_000_3`,output:`0.000_002_5`,outputImage:`0.000_03`,cachedInput:`0.000_000_03`,cacheCreation:`0.000_001`},tokenCalculator:{kind:`image-output`},imageGeneration:`gemini-2.5-flash`},{id:`gemini-2.5-flash-lite`,provider:`google`,reasoning:{type:`budget`,budgetTokens:12e3},name:`Gemini 2.5 Flash Lite`,description:`Lightweight and fast`,hiddenInTask:!0,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_1`,output:`0.000_000_4`,cachedInput:`0.000_000_01`,cacheCreation:`0.000_001`}},{id:`openai/gpt-oss-120b`,provider:`openrouter`,reasoning:{type:`effort`,effort:`medium`},name:`GPT-OSS 120B`,description:`Open source model from OpenAI`,hiddenInTask:!1,active:!0,contextWindowTokens:131072,maxOutputTokens:64e3,pricing:{input:`0.000_000_1`,output:`0.000_000_5`}},{id:`z-ai/glm-4.6`,provider:`openrouter`,reasoning:{type:`enabled`},name:`GLM 4.6`,description:`GLM-4.6 with 200K context window, superior coding performance, advanced reasoning, and refined writing`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_000_6`,output:`0.000_002_2`,cachedInput:`0.000_000_11`}},{id:`moonshotai/kimi-k2-thinking`,provider:`openrouter`,reasoning:{type:`enabled`},name:`Kimi K2 Thinking`,description:`Moonshot AI's most advanced open reasoning model with 256K context window, optimized for persistent step-by-step thought and complex reasoning workflows`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_000_6`,output:`0.000_002_5`,cachedInput:`0.000_000_15`}},{id:`minimax/minimax-m2`,provider:`openrouter`,reasoning:{type:`enabled`},name:`MiniMax M2`,description:`Compact, high-efficiency model optimized for end-to-end coding and agentic workflows with 204.8K context window`,hiddenInTask:!1,active:!0,contextWindowTokens:2e5,maxOutputTokens:64e3,pricing:{input:`0.000_000_3`,output:`0.000_001_2`}},{id:`meta/muse-glimmer-30b`,provider:`openrouter`,reasoning:{type:`effort`,effort:`medium`},name:`Muse Glimmer 30B`,description:`Dense, open-weight multimodal model from Meta Superintelligence Labs, distilled from Muse Spark and optimized for autonomous agents on consumer hardware`,hiddenInTask:!1,active:!0,contextWindowTokens:131072,maxOutputTokens:64e3,pricing:{input:`0.000_000_35`,output:`0.000_001_5`,cachedInput:`0.000_000_04`}},{id:`moonshotai/kimi-k3`,provider:`openrouter`,reasoning:{type:`effort`,effort:`max`},name:`Kimi K3`,description:`Moonshot AI's multimodal reasoning model with a 1M context window, built for long-horizon agentic workflows`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_003`,output:`0.000_015`,cachedInput:`0.000_000_3`}},{id:`z-ai/glm-5.2`,provider:`openrouter`,reasoning:{type:`effort`,effort:`high`},name:`GLM 5.2`,description:`GLM-5.2 with strong coding and agentic performance, advanced reasoning, and long-context support`,hiddenInTask:!1,active:!0,contextWindowTokens:262144,maxOutputTokens:64e3,pricing:{input:`0.000_000_76`,output:`0.000_002_42`,cachedInput:`0.000_000_14`}},{id:`deepseek/deepseek-v4-flash-0731`,provider:`openrouter`,reasoning:{type:`effort`,effort:`high`},name:`DeepSeek V4 Flash`,description:`Low-cost, high-throughput DeepSeek model with a 1M context window, suited for high-volume agentic and coding workloads`,hiddenInTask:!1,active:!0,contextWindowTokens:1e6,maxOutputTokens:64e3,pricing:{input:`0.000_000_08`,output:`0.000_000_18`,cachedInput:`0.000_000_016`}},{id:`gpt-oss-120b`,provider:`selfhosted`,name:`GPT-OSS 120B`,description:`Open source model from OpenAI`,hiddenInTask:!1,active:!0,contextWindowTokens:131072,maxOutputTokens:64e3,pricing:{input:`0.000_000_1`,output:`0.000_000_5`}},{id:`apmic/qwen3.8-27b`,provider:`apmic`,providerModelId:`Qwen3.8-27B`,name:`Qwen3.8 27B`,description:`Qwen 3.8 27B served by APMIC`,hiddenInTask:!1,active:!0,contextWindowTokens:262144,maxOutputTokens:64e3,pricing:{input:`0`,output:`0`}},{id:`cerebras/qwen-3.8-27b`,provider:`cerebras`,providerModelId:`qwen-3.8-27b`,reasoning:{effort:`medium`},name:`Qwen3.8 27B (Cerebras)`,description:`Qwen 3.8 27B served on Cerebras wafer-scale inference`,hiddenInTask:!1,active:!0,capabilities:{reasoning:!0},contextWindowTokens:131072,maxOutputTokens:4e4,pricing:{input:`0.000_000_99`,output:`0.000_001_49`}},{id:`cerebras/gpt-oss-120b`,provider:`cerebras`,providerModelId:`gpt-oss-120b`,reasoning:{effort:`medium`},name:`GPT-OSS 120B (Cerebras)`,description:`Open source model from OpenAI served on Cerebras wafer-scale inference`,hiddenInTask:!1,active:!0,capabilities:{reasoning:!0},contextWindowTokens:131e3,maxOutputTokens:4e4,pricing:{input:`0.000_000_35`,output:`0.000_000_75`}}],mp=B([`chat`,`image`]),hp=O().refine(e=>{if(e===``)return!1;let t=e.replace(/_/g,``),n=Number(t);return!Number.isNaN(n)&&Number.isFinite(n)&&n>=0},{message:`Invalid decimal string`}),gp=L({input:O(),output:O(),cachedInput:O().optional(),cacheCreation:O().optional()}),_p=L({input:hp,output:hp,cachedInput:hp.optional(),cacheCreation:hp.optional()}),vp=L({effort:B(fp)}),yp=L({modelId:O(),deploymentName:O(),workspaceId:O().nullable(),kind:mp,name:O(),description:O(),pricing:gp,reasoning:vp.nullable(),createdAt:H(),updatedAt:H()});L({deployments:I(yp),nextKey:O().optional()}),L({deploymentName:O().min(1),name:O().min(1),description:O().default(``),pricing:_p,reasoning:vp.nullable().default(null)}),L({name:O().min(1).optional(),description:O().optional(),pricing:_p.optional(),reasoning:vp.nullable().optional()}),L({deploymentName:O().min(1),kind:mp,name:O().min(1),description:O().default(``),pricing:_p,reasoning:vp.nullable().default(null)}),L({name:O().min(1).optional(),description:O().optional(),kind:mp.optional(),pricing:_p.optional(),reasoning:vp.nullable().optional()}),L({deploymentName:O().min(1)}),L({deployments:I(yp)}),L({workspaceId:j()}),L({amountUsd:N().positive().max(1e4)}),L({checkoutUrl:M()}),L({id:j(),workspaceId:j(),amountUsd:O(),purchasedBy:j().nullable(),stripeCheckoutSessionId:O(),stripePaymentIntentId:O().nullable(),isAutoReload:P(),createdAt:H()}),L({workspaceId:j()}),L({checkoutUrl:M()}),B([`incomplete`,`incomplete_expired`,`trialing`,`active`,`past_due`,`canceled`,`unpaid`,`paused`]);const bp=B([`draft`,`open`,`paid`,`uncollectible`,`void`]);B([`upgrade`,`downgrade`,`invite_accept`,`member_join`]),B([`pending`,`processing`,`processed`,`failed`]),B([`seat_change`,`extra_usage_purchase`]),B([`pending`,`processing`,`requires_action`,`succeeded`,`failed`,`expired`,`superseded`]),B([`pending`,`applied`,`failed`,`canceled`]);const xp=B([`subscription`,`extra_usage`]),Sp=L({id:j(),type:xp,status:bp,totalUsd:N().nonnegative(),billingDate:H(),hostedInvoiceUrl:M().nullable()});L({workspaceId:j()}),L({limit:U().int().min(1).max(100).default(20),nextKey:O().optional()}),L({invoices:I(Sp),nextKey:O().optional()});const Cp=B([`pro`,`premium`]),wp=L({pro:N().int().nonnegative(),premium:N().int().nonnegative()});L({pro:N().int(),premium:N().int()});const Tp=L({lineItems:I(L({seatType:Cp,quantity:N().int(),amountUsd:O()})),subtotalUsd:O(),taxUsd:O(),totalUsd:O()}),Ep=B([`seat_pool_invariant`,`subscription_canceling`,`payment_required`,`unsupported_billing_state`]);L({workspaceId:j()});const Dp=L({targetPurchasedSeats:wp,seatAssignment:L({userId:j(),seatType:Cp}).optional()});z(`outcome`,[L({outcome:V(`unchanged`),quoteHash:O().min(1),targetPurchasedSeats:wp,nextMonthlyAmountUsd:O()}),L({outcome:V(`immediate`),quoteHash:O().min(1),targetPurchasedSeats:wp,nextMonthlyAmountUsd:O(),dueToday:Tp}),L({outcome:V(`scheduled`),quoteHash:O().min(1),targetPurchasedSeats:wp,nextMonthlyAmountUsd:O(),dueToday:Tp,effectiveAt:H()}),L({outcome:V(`split`),quoteHash:O().min(1),immediatePurchasedSeats:wp,targetPurchasedSeats:wp,nextMonthlyAmountUsd:O(),dueToday:Tp,effectiveAt:H()}),L({outcome:V(`blocked`),reason:Ep})]),L({workspaceId:j()}),Dp.extend({expectedQuoteHash:O().min(1)}),z(`kind`,[L({kind:V(`completed`),operationId:j().nullable()}),L({kind:V(`processing`),operationId:j()}),L({kind:V(`redirect`),operationId:j().nullable(),url:M()})]),L({workspaceId:j()});const Op=L({startAt:H(),endAt:H()}),kp=L({cancelAtPeriodEnd:P(),canceledAt:H().nullable()}),Ap=L({reason:B([`invoice_payment_failed`,`checkout_incomplete`,`subscription_unpaid`,`subscription_paused`,`unsupported_state`]),startedAt:H().nullable(),retryEndsAt:H().nullable(),stripeInvoiceId:O().min(1).nullable(),hostedInvoiceUrl:M().nullable()});L({lifecycle:z(`kind`,[L({kind:V(`default`),period:vs(),cancellation:vs(),paymentIssue:vs()}),L({kind:V(`active`),period:Op,cancellation:kp,paymentIssue:vs()}),L({kind:V(`payment_required`),period:Op.nullable(),cancellation:vs(),paymentIssue:Ap}),L({kind:V(`canceled`),period:vs(),cancellation:kp,paymentIssue:vs()}),L({kind:V(`unavailable`),period:Op.nullable(),cancellation:vs(),paymentIssue:Ap})]),subscription:L({planName:O().min(1),estimatedMonthlyChargeUsd:N().nonnegative(),nextInvoiceDueAt:H().nullable()}).nullable(),seats:L({purchased:wp,assigned:wp,available:wp,totalPurchased:N().int().nonnegative(),totalAssigned:N().int().nonnegative(),totalAvailable:N().int().nonnegative()}),extraUsage:Pl.extend({currentPurchasedUsd:N().nonnegative()})}),L({workspaceId:j()}),L({portalUrl:M()}),L({workspaceId:j(),userId:j()}),L({seatType:Ol});const jp=B([`google`,`outlook`,`caldav`]),Mp=B([`confirmed`,`tentative`,`cancelled`]),Np=L({email:O(),displayName:O().optional(),responseStatus:B([`needsAction`,`declined`,`tentative`,`accepted`]).optional(),organizer:P().optional(),self:P().optional(),resource:P().optional()}),Pp=L({type:B([`hangoutsMeet`,`zoom`,`teams`,`webex`,`other`]),uri:O().optional(),label:O().optional()}),Fp=L({id:j(),providerCalendarId:O(),name:O(),color:O().nullable(),isVisible:P()});L({accounts:I(L({id:j(),provider:jp,email:O(),isActive:P(),lastSyncAt:O().nullable(),reminderEnabled:P(),reminderMinutesBefore:N(),createdAt:H(),calendars:I(Fp)}))}),L({events:I(L({id:j(),calendarId:j(),calendarName:O(),calendarColor:O().nullable(),provider:jp,providerEventId:O(),title:O(),description:O().nullable(),location:O().nullable(),startTime:O(),endTime:O(),isAllDay:P(),status:Mp,conferenceLink:O().nullable(),conferenceData:Pp.nullable(),attendees:I(Np).nullable(),organizerEmail:O().nullable()}).extend({meetingId:j().nullable(),hasRecordings:P(),hasAudioFile:P()})),nextCursor:j().nullable(),hasMore:P()}),L({startTime:W.optional(),endTime:W.optional(),limit:U().int().min(1).max(500).default(50),cursor:j().optional()}).refine(e=>e.startTime&&e.endTime?new Date(e.startTime)<new Date(e.endTime):!0,{message:`endTime must be greater than startTime`,path:[`endTime`]}),L({hours:U().int().min(1).max(168).default(24),limit:U().int().min(1).max(50).default(10),cursor:j().optional()}),L({id:j(),reminderEnabled:P(),reminderMinutesBefore:N()}),L({updated:N()}),q.IMAGE_GENERATION,q.PROJECT,q.SANDBOX,q.WEB_SEARCH,q.SKILL,q.SLIDES,q.WORKFLOW;const Ip=L({inputTokens:N().optional(),outputTokens:N().optional(),totalTokens:N().optional(),reasoningTokens:N().optional(),cachedInputTokens:N().optional(),cachedCreationTokens:N().optional()});L({modelId:O().optional(),usage:Ip.optional(),totalUsage:Ip.optional(),platformMessageTs:O().optional(),postedMessageTs:I(O()).optional()}),L({id:j(),name:O(),mimeType:O(),size:N(),url:O().optional().describe(`The signed URL for the file, only available if the file is not expired`),expired:P(),createdAt:H(),updatedAt:H()}),L({phase:B([`running`,`done`])});const Lp=B([`step_limit`,`output_limit`,`retry_limit`]);L({reason:Lp,toolCallIds:I(O()).optional()});function Rp(e){return e.state===`approval-requested`&&e.approval?.isAutomatic!==!0}const zp=L({reason:Lp,sourceMessageId:j()}),Bp=new TextEncoder;function Vp(e){try{let t=JSON.stringify(e);return typeof t==`string`?Bp.encode(t).byteLength:null}catch{return null}}const Hp=L({sourceMessageId:j(),action:V(`continueConversation`),values:F().refine(e=>{let t=Vp(e);return t!==null&&t<=65536},`Widget interaction values must be JSON and at most 64 KiB`)});L({context:O()}),L({runs:I(L({runId:O(),kind:B([`subagent`,`workflow`]),status:O(),summary:O()}))});const Up=L({system:N(),tools:N(),history:N()});L({totalTokens:N(),breakdown:Up,contextWindowTokens:N().optional(),compactionTriggerTokens:N().optional()});const Wp=L({text:O(),type:V(`text`)}),Gp=L({type:V(`data-widget-interaction`),data:Hp}),Kp=L({type:V(`data-task-continuation`),data:zp}),qp=L({id:j(),createdAt:pc().optional(),role:V(`user`),parts:R([Ns([Wp]),Ns([Gp]),Ns([Kp])])}),Jp=R([O().startsWith(`tool-`),V(`dynamic-tool`)]),Yp=L({id:O(),approved:P(),reason:O().optional()}),Xp=L({type:Jp,toolCallId:O(),state:V(`approval-responded`),input:bs().optional(),approval:Yp}),Zp=L({type:Jp,toolCallId:O(),state:V(`output-available`),output:bs(),approval:Yp.optional()}),Qp=L({type:Jp,toolCallId:O(),state:V(`output-error`),errorText:O(),approval:Yp.optional()}),$p=L({id:O(),approved:V(!1),reason:O().optional()}),em=L({type:Jp,toolCallId:O(),state:V(`output-denied`),errorText:O().optional(),approval:$p.optional()}).refine(e=>e.errorText!==void 0||e.approval!==void 0,{message:`An output-denied part must carry the refusal, as errorText or as approval.reason`,path:[`errorText`]});z(`role`,[qp,L({id:j(),createdAt:pc().optional(),role:V(`assistant`),parts:I(z(`state`,[Xp,Zp,Qp,em])).min(1)})]);const tm=[`approval-responded`,`output-available`,`output-error`,`output-denied`],nm=[`output-available`,`output-error`,`output-denied`];function rm(e){for(let t=e.length-1;t>=0;--t)if(e[t]?.type===`step-start`)return t;return-1}function im(e){return tm.includes(e)}function am(e){return nm.includes(e)}function om(e){return e?.role===`assistant`?e.parts.filter(l).filter(e=>!e.providerExecuted):[]}function sm(e){if(e?.role!==`assistant`)return[];let t=rm(e.parts);return om({role:e.role,parts:e.parts.slice(t+1)})}function cm(e,t){return t(e)?am(e.state):im(e.state)}function lm(e,t){return t(e)?am(e.state):e.state===`approval-responded`||e.state===`output-denied`}function um(e){let t=`approval`in e?e.approval:void 0;return{type:e.type,toolCallId:e.toolCallId,state:e.state,...e.state===`output-available`&&{output:e.output},...`errorText`in e&&e.errorText!==void 0&&{errorText:e.errorText},...t!==void 0&&{approval:t}}}function dm(e,{isClientTool:t}){return e?.role===`assistant`?{id:e.id,role:`assistant`,parts:sm(e).filter(e=>lm(e,t)).map(um)}:e}function fm(e){let t=e?.message?.parts;return Array.isArray(t)?t.flatMap(e=>{let t=e?.toolCallId;return typeof t==`string`?[t]:[]}):[]}function pm({messages:e,isClientTool:t,suppressAutomaticSend:n=!1,submittedToolCallIds:r}){if(n)return!1;let i=sm(e.at(-1));return!i.some(e=>!cm(e,t))&&i.some(e=>lm(e,t)&&!r.has(e.toolCallId))}function mm(e){if(e.reason!==void 0)return e.reason;let t=Error(`The operation was aborted.`);return t.name=`AbortError`,t}function hm(e,t){if(!t)return e;let n=()=>mm(t),r,i,a=()=>{i&&=(t.removeEventListener(`abort`,i),void 0)};return new ReadableStream({start(a){if(i=()=>{a.error(n()),(r??e).cancel(n()).catch(()=>{})},t.aborted){i();return}t.addEventListener(`abort`,i,{once:!0})},async pull(n){r??=e.getReader();try{let{done:e,value:t}=await r.read();if(e){n.close(),a();return}n.enqueue(t)}catch(e){t.aborted||n.error(e),a()}},cancel(t){a(),(r??e).cancel(t).catch(()=>{})}})}const gm={schemaVersion:V(2),siteKey:O().min(1),assetId:j(),title:O()};z(`state`,[L({...gm,state:V(`working`),revision:O().min(1)}),L({...gm,state:V(`saved`),versionId:j(),versionNumber:N().int().positive()})]);const _m=B([`pending`,`generating`,`ready`,`error`]),vm=L({page:N().int().positive(),heading:O(),status:_m,version:N().int().nonnegative().default(0),imageUrl:O().optional(),assetId:O().optional(),note:O().optional()});L({deckId:O().min(1),title:O(),style:O(),aspectRatio:O(),status:B([`generating`,`partial`,`ready`]),outputs:L({pdfUrl:O().optional(),pptxUrl:O().optional(),pdfAssetId:O().optional(),pptxAssetId:O().optional()}).default({}),slides:I(vm)});const ym=L({slideId:j(),position:N().int().positive(),heading:O(),status:_m,note:O().optional()}),bm={schemaVersion:V(2),deckKey:O().min(1),assetId:j(),title:O(),style:O(),aspectRatio:O(),slides:I(ym)};z(`state`,[L({...bm,state:V(`working`),revision:O().min(1)}),L({...bm,state:V(`saved`),versionId:j(),versionNumber:N().int().positive()})]),L({data:L({assetId:j(),versionId:j(),versionNumber:N().int().positive(),title:O(),style:O(),aspectRatio:O(),slides:I(L({slideId:j(),position:N().int().positive(),heading:O(),imageUrl:M()})),pdfUrl:M(),pptxUrl:M().optional()})});const xm=[`slack`,`teams`],Sm=[`active`,`inactive`,`needs_reauth`],Cm=B(xm),wm=B(Sm),Tm=L({id:j(),platform:Cm,platformWorkspaceId:O(),platformWorkspaceName:O(),botUserId:O(),status:wm,autoBindEnabled:P(),createdAt:H(),updatedAt:H()});L({platform:Cm.optional(),limit:U().int().min(1).max(100).default(20),cursor:j().optional()}),L({installations:I(Tm),nextKey:O().optional()}),L({status:B([`active`,`inactive`]).optional()});const Em=L({id:j(),workspaceInstallationId:j(),platform:Cm,platformWorkspaceName:O(),platformUserId:O(),createdAt:H()});L({installations:I(Em)}),L({workspaceInstallation:Tm.nullable(),userInstallation:Em.nullable(),canManageChatbot:P()}).extend({installUrl:M().nullable()}),L({userInstallation:Em}),L({autoBindEnabled:P()}),L({workspaceInstallation:Tm}),L({bindings:I(L({id:j().nullable(),workspaceInstallationId:j().nullable(),userId:j(),userName:O(),userEmail:A(),platformUserId:O().nullable(),createdAt:H().nullable(),updatedAt:H().nullable()})),total:N().int().nonnegative()}),hl.extend({search:O().trim().max(200).optional()}),L({authorizeUrl:O()});const Dm=2048,Om=B([`self`,`anyone`]),km=L({id:j(),platform:Cm,userInstallationId:j(),platformChannelId:O(),channelName:O().nullable(),platformThreadId:O().nullable(),keyword:O().nullable(),triggerScope:Om,agentId:j().nullable(),agentName:O().nullable(),sourceKeywordListenerIds:I(j()),taskId:j().nullable(),titlePreview:O().nullable(),threadUrl:M().nullable(),lastInteractedAt:H().nullable(),enabled:P(),createdAt:H(),updatedAt:H()});L({installationId:j().optional()}),L({listeners:I(km)}),L({installationId:j(),platformChannelId:O().trim().min(1).max(Dm).regex(/^(?:(?:slack:)?[CG][A-Z0-9]+|teams:[A-Za-z0-9_-]+:[A-Za-z0-9_-]+)$/u,`Must be a valid Slack or Microsoft Teams channel id.`),keyword:O().trim().min(1).max(200),triggerScope:Om.optional(),agentId:j().nullable().optional()}),L({listener:km}),L({keyword:O().trim().min(1).max(200).optional(),triggerScope:Om.optional(),agentId:j().nullable().optional(),enabled:P().optional()}).refine(e=>e.keyword!==void 0||e.triggerScope!==void 0||e.agentId!==void 0||e.enabled!==void 0,{message:`At least one field must be provided`}),L({installationId:j(),platformChannelId:O().trim().min(1).max(Dm),keyword:O().trim().min(1).max(200)}),L({count:N().int().nonnegative()}),L({installationId:j()}),L({channels:I(L({id:O(),name:O(),isPrivate:P()}))}),L({}).optional(),L({ok:V(!0),messageTs:O()}),L({olderThanDays:N().int().min(1).max(365).default(14).optional()}).optional(),L({deletedCount:N().int().min(0)});const Am=B([`enabled`,`disabled`]);L({items:I(L({agentId:j(),agentName:O(),status:Am,capReached:P(),connectorNames:I(O())}))}),L({items:I(L({agentId:j(),agentName:O(),connectorNames:I(O())}))}),L({agentId:j()}),L({archiveContext:dc().optional()}),L({activeConversationCount:N().int(),suppressedListenerCount:N().int()});const jm=O().regex(/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/),Mm=L({minSupportedVersion:jm,latestVersion:jm});L({ios:Mm,android:Mm});const Nm=`usage_audit__`,Pm={GET_DAILY_SUMMARY:`${Nm}get_daily_summary`,GET_MONTHLY_COSTS:`${Nm}get_monthly_costs`,GET_USER_BREAKDOWN:`${Nm}get_user_breakdown`,GET_USER_DAILY_TREND:`${Nm}get_user_daily_trend`,FIND_USAGE_DROPS:`${Nm}find_usage_drops`,FIND_STALE_SCHEDULES:`${Nm}find_stale_schedules`,GET_SCHEDULE_TOOL_CALLS:`${Nm}get_schedule_tool_calls`,GET_COST_RANKING:`${Nm}get_cost_ranking`,GET_WORKSPACE_TOTALS:`${Nm}get_workspace_totals`},Fm=`subagent__`,Im={SPAWN:`${Fm}spawn`,GET_RUN:`${Fm}get_run`},Lm=[`browser__`,`task__`,`project__`,`asset__`,`agent__`,`connector__`,`filesystem__`,`image__`,`meeting__`,`memory__`,`sandbox__`,`schedule__`,`skill__`,`site__`,`slides__`,`tool_result__`,`meta_tool__`,Nm,`audit_log__`,Fm,`ui__`,`web__`,`workflow__`].map(e=>e.slice(0,-2)),Rm=B([`pat`,`oauth`,`dcard-dual`,`google-iap`,`credentials`,`mcp-oauth`,`composio`]),zm=/^[a-z][a-z0-9-]*$/,Bm=[`pat`,`credentials`],Vm=L({key:O().regex(zm).max(32),label:O().min(1).max(50),description:O().max(200).optional(),placeholder:O().max(100).optional(),required:P()}),Hm=I(Vm).max(10).refine(e=>new Set(e.map(e=>e.key)).size===e.length,{message:`config field keys must be unique`});Fs(O().regex(zm).max(32),O().min(1).max(256).regex(/^[\u0020-\u007E]*$/,`must be printable ASCII`));const Um={pat:!1,oauth:!0,"dcard-dual":!0,"google-iap":!0,credentials:!1,"mcp-oauth":!0,composio:!0};function Wm(e){let t=Rm.safeParse(e);return t.success&&Um[t.data]}const Gm=B([`pending`,`running`,`failed`]),Km=B([`pending`,`in_review`,`approved`,`rejected`]),qm=L({name:O(),isMe:P()}),Jm=L({id:O(),name:O(),configured:P(),builtIn:P()}),Ym=L({type:Rm,tutorial:O().optional(),configFields:I(Vm).optional(),tokenless:P().optional().describe(`PAT connectors whose connect step is a pure opt-in: the client submits a constant token without asking the user for input`),provider:Jm.optional().describe(`The OAuth provider, only present for OAuth authorization`)});L({iconId:j(),url:M()}),L({connectors:I(L({id:j(),name:O(),description:O(),provider:O().nullable().describe(`The provider of the connector, either EntryDesk (for built-in connectors) or Workspace name`),author:L(qm.shape).optional().describe(`The author of the connector, not available for built-in connectors`),connected:P().describe(`Whether the user has connected the connector to the workspace`),iconUrl:O().optional().describe(`The URL of the connector icon`),team:L({id:j(),name:O()}).optional().describe(`The team this connector is published to, only present when createdBy is team`),hasPermission:P().describe(`Whether the user has permission to use the connector`),added:P().describe(`Whether the connector has a workspace_connectors record. Without one it has no tool registry, so the per-connector tool endpoints answer 404`),hasWorkspaceToken:P().describe(`Whether the workspace has a workspace token configured for this connector`),tokenMode:B([`personal`,`workspace`]).describe(`Token mode: personal (each member connects) or workspace (admin provides shared token)`),reviewStatus:Km.optional().describe(`The review status of the connector, not available for built-in connectors`),authorization:Ym.optional(),versionNumber:N().int().nullable(),myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional()}),ml.extend({reviewStatus:Km.optional().describe(`Filter connectors by review status (only applies to custom connectors)`),includeNotAdded:R([V(`true`).transform(()=>!0),V(`false`).transform(()=>!1),P()]).optional().describe(`Include connectors that have not been added to the workspace (no workspace_connectors record)`),type:B(Eu).optional().describe(`Filter connectors by type`),sortBy:B(wu).optional()}).refine(e=>!(e.type===Tu.BUILT_IN&&e.reviewStatus),{message:`reviewStatus parameter is not applicable when type is built_in`,path:[`reviewStatus`]}),ml.extend({createdBy:B([`workspace`,`team`,`me`]).optional(),teamId:j().optional(),connectionStatus:B([`all`,`connected`]).optional().default(`all`).describe(`Filter connectors by connection status`),strict:R([V(`true`).transform(()=>!0),V(`false`).transform(()=>!1),P()]).optional().default(!0).describe(`Whether to filter out connectors that the user does not have permission to use`),search:O().trim().max(200).optional().describe(`Search connectors by name using SQL LIKE query`),connectorIds:R([j(),I(j())]).optional().transform(e=>{if(e!==void 0)return Array.isArray(e)?e:[e]}).describe(`Filter connectors by specific IDs`),sortBy:B(wu).optional()}).refine(e=>!e.teamId||e.createdBy===`team`,{message:`teamId can only be used with createdBy: team`,path:[`teamId`]});const Xm=L({id:O(),name:O()}),Zm=L({id:j()}).nullable();L({connectors:I(L({id:j(),type:B(Eu),name:O(),description:O(),provider:O().describe(`The provider of the connector, either EntryDesk (for built-in connectors) or Workspace name`),iconUrl:O().optional().describe(`The URL of the connector icon`),author:qm.optional().describe(`The author of the connector, not available for built-in connectors`),roles:I(Xm).describe(`The roles of the user who has access to the connector`),executionStatus:Gm.optional().describe(`The execution status of the connector, not available for built-in connectors`),reviewStatus:Km.optional().describe(`The review status of the connector, not available for built-in connectors`),hasWorkspaceToken:P().describe(`Whether the workspace has a workspace token configured for this connector`),tokenMode:B([`personal`,`workspace`]).describe(`Token mode: personal (each member connects) or workspace (admin provides shared token)`),added:P().describe(`Whether the connector has been added to the workspace`),toolPrefix:O().optional().describe(`The prefix of the tool name, available when the connector is added to the workspace`),authorization:Ym.optional().describe(`The authorization of the connector.`),publish:Zm,myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional()});const Qm=B([`pat`,`oauth`,`google-iap`,`credentials`,`mcp-oauth`]),$m=L({type:Qm,provider:O().optional(),scopes:I(O()).optional(),tutorial:O().optional(),configFields:I(Vm).optional()}),eh=L({type:Qm,provider:O().optional(),scopes:I(O()).optional(),tutorial:M().max(100).optional(),configFields:Hm.optional()}).refine(e=>e.type===`oauth`||e.type===`google-iap`?e.provider!==void 0&&e.scopes!==void 0:!0,{message:`provider and scopes are required when type is oauth or google-iap`,path:[`provider`,`scopes`]}).refine(e=>!(e.tutorial&&![`pat`,`credentials`].includes(e.type)),{message:`tutorial is only allowed for PAT and CREDENTIALS authorization types`,path:[`tutorial`]}).refine(e=>!(e.configFields?.length&&!Bm.some(t=>t===e.type)),{message:`configFields is only allowed for PAT and CREDENTIALS authorization types`,path:[`configFields`]}),th=/^[A-Za-z0-9\s]+$/u,nh=/^[a-z0-9_-]+$/u,rh=[`empty`,`too_long`,`invalid_characters`,`consecutive_underscores`,`reserved`],ih={empty:e=>e.length===0,too_long:e=>e.length>20,invalid_characters:e=>!nh.test(e),consecutive_underscores:e=>e.includes(`__`),reserved:e=>Lm.includes(e)},ah={empty:`must not be empty`,too_long:`must be at most 20 characters`,invalid_characters:`must use only lowercase letters, digits, hyphen and underscore`,consecutive_underscores:`must not contain consecutive underscores`,reserved:`is reserved for a built-in EntryDesk tool namespace`};function oh(e,t=rh){return t.find(t=>ih[t](e))}function sh(e=rh){return O().superRefine((t,n)=>{let r=oh(t,e);r&&n.addIssue({code:`custom`,message:`Tool namespace "${t}" ${ah[r]}`})})}function ch(e){return e.toLowerCase().replaceAll(/\s+/gu,`_`)}const lh=B([`streamable_http`,`sse`]);L({id:j(),type:V(Tu.CUSTOM_REMOTE_URL),name:O(),description:O(),url:O(),transport:lh,toolPrefix:O(),author:qm.optional(),authorization:$m.optional(),executionStatus:Gm.optional(),reviewStatus:Km.optional(),createdAt:H(),updatedAt:H(),iconId:j().nullable().optional(),iconUrl:O().optional(),publish:L({id:j()}).nullable(),myRole:Fu}),L({id:j(),type:V(Tu.CUSTOM_REMOTE_URL),name:O(),description:O(),transport:lh,url:O(),executionStatus:Gm,reviewStatus:Km,toolPrefix:O(),createdAt:H(),updatedAt:H()}),L({type:V(Tu.CUSTOM_REMOTE_URL),name:O().min(1),description:O().min(1),transport:lh,url:M(),toolPrefix:sh().describe(`The tool prefix for the connector`),authorization:eh.optional().nullable(),iconId:j().nullable().optional()});const uh=[`composio`,`mcp`],dh=[`stdio`,`sse`,`streamable_http`];lh.options;const fh=Rm.exclude([`composio`]);fh.options;const ph=[`pat`,`credentials`];L({items:I(L({id:j(),name:O(),description:O(),iconUrl:O().nullable(),kind:B(uh),toolkit:O().nullable(),transport:B(dh),authorizationType:Rm.nullable(),createdAt:H()}))});const mh=L({kind:V(`composio`),name:O().min(1).max(100),description:O().min(1),toolkit:O().min(1),tools:I(O().min(1)).optional(),extraTools:I(O().min(1)).optional(),composioAuthConfigId:O().min(1).optional()}),hh=L({kind:V(`mcp`),name:O().min(1).max(100),description:O().min(1),url:M(),transport:lh,authorization:L({type:fh,provider:O().min(1).optional(),scopes:I(O().min(1)).optional(),tutorial:M().max(100).optional(),configFields:Hm.optional()}).optional()}).refine(e=>e.authorization?.type!==`oauth`||e.authorization.provider!==void 0&&e.authorization.scopes!==void 0,{message:`provider and scopes are required when type is oauth`,path:[`authorization`]}).refine(e=>!e.authorization?.tutorial||ph.some(t=>t===e.authorization?.type),{message:`tutorial is only allowed for pat and credentials authorization types`,path:[`authorization`,`tutorial`]}).refine(e=>!e.authorization?.configFields?.length||Bm.some(t=>t===e.authorization?.type),{message:`configFields is only allowed for pat and credentials authorization types`,path:[`authorization`,`configFields`]});L({toolkit:O().min(1)});const gh=L({name:O(),mode:O(),scopes:I(O())});L({slug:O(),name:O(),managedAuthSchemes:I(O()),auths:I(gh)}),z(`kind`,[mh,hh]);const _h={en:{authLink:[`auth`,`oauth`,`authorize`,`authorization`,`connect`,`login`,`sign in`,`sign-in`,`signin`],authGlossVerbs:[`authorize`,`connect`,`login`,`sign in`,`sign-in`,`signin`],placement:[`button`,`buttons`,`link`,`links`,`click`,`below`,`following`]},"zh-TW":{authLink:[`授權`,`授权`,`連接`,`连接`,`認證`,`认证`,`登入`,`登录`],authGlossVerbs:[`授權`,`授权`,`連接`,`连接`,`認證`,`认证`,`登入`,`登录`],placement:[`按鈕`,`按钮`,`連結`,`链接`,`點擊`,`点击`,`下方`,`以下`]},de:{authLink:[`autorisieren`,`autorisierung`,`verbinden`,`anmelden`,`login`],authGlossVerbs:[`autorisieren`,`verbinden`,`anmelden`,`login`],placement:[`schaltfläche`,`schaltflächen`,`button`,`buttons`,`link`,`links`,`klicken`,`unten`,`folgende`,`folgenden`]},fr:{authLink:[`autoriser`,`autorisation`,`connecter`,`connexion`,`login`,`se connecter`],authGlossVerbs:[`autoriser`,`connecter`,`connexion`,`login`,`se connecter`],placement:[`bouton`,`boutons`,`lien`,`liens`,`cliquer`,`cliquez`,`ci-dessous`,`suivant`,`suivants`]},"es-ES":{authLink:[`autorizar`,`autorización`,`conectar`,`conexión`,`iniciar sesión`,`login`],authGlossVerbs:[`autorizar`,`conectar`,`iniciar sesión`,`login`],placement:[`botón`,`botones`,`enlace`,`enlaces`,`clic`,`haz clic`,`hacer clic`,`abajo`,`siguiente`,`siguientes`]},"es-419":{authLink:[`autorizar`,`autorización`,`conectar`,`conexión`,`iniciar sesión`,`login`],authGlossVerbs:[`autorizar`,`conectar`,`iniciar sesión`,`login`],placement:[`botón`,`botones`,`enlace`,`enlaces`,`clic`,`haz clic`,`hacer clic`,`abajo`,`siguiente`,`siguientes`]},ja:{authLink:[`認可`,`承認`,`認証`,`接続`,`ログイン`],authGlossVerbs:[`認可`,`承認`,`認証`,`接続`,`ログイン`],placement:[`ボタン`,`リンク`,`クリック`,`下`,`以下`,`次`]},ko:{authLink:[`인증`,`승인`,`권한`,`연결`,`로그인`],authGlossVerbs:[`인증`,`승인`,`연결`,`로그인`],placement:[`버튼`,`링크`,`클릭`,`아래`,`다음`]},it:{authLink:[`autorizza`,`autorizzare`,`autorizzazione`,`connetti`,`connettere`,`accesso`,`login`],authGlossVerbs:[`autorizza`,`autorizzare`,`connetti`,`connettere`,`accedi`,`login`],placement:[`pulsante`,`pulsanti`,`link`,`collegamento`,`collegamenti`,`clic`,`fare clic`,`sotto`,`seguente`,`seguenti`]},"pt-BR":{authLink:[`autorizar`,`autorização`,`conectar`,`conexão`,`entrar`,`login`],authGlossVerbs:[`autorizar`,`conectar`,`entrar`,`login`],placement:[`botão`,`botões`,`link`,`links`,`clicar`,`clique`,`abaixo`,`seguinte`,`seguintes`]}},vh=/[.*+?^${}()|[\]\\]/g;function yh(e){return e.replace(vh,`\\$&`)}function bh(e){let t=new Set,n=[];for(let r of e){let e=r.trim();e.length>0&&!t.has(e)&&(t.add(e),n.push(e))}return n}function xh(e){return bh(Object.values(_h).flatMap(t=>t[e]))}function Sh(e){let t=xh(e).toSorted((e,t)=>t.length-e.length).map(yh).join(`|`);return new RegExp(t,`iu`)}function Ch(){let e=xh(`authGlossVerbs`).toSorted((e,t)=>t.length-e.length).map(yh).join(`|`);return RegExp(`^(?:${e})(?=\\s|$|[^\\p{Letter}\\p{Number}])`,`iu`)}Sh(`authLink`),Sh(`placement`),Ch(),L({toolkit:O(),tools:I(O()).optional(),extraTools:I(O()).optional()}),L({search:O().trim().max(200).optional(),status:B(Xu).optional(),nextKey:O().optional(),limit:U().int().min(1).max(100).default(20),sortBy:B(wu).optional()}),L({connectors:I(L({id:j(),name:O(),iconUrl:O().optional(),hasUnpublishedChanges:P(),latestVersionNumber:N().int().nullable(),publishedTo:Vu.optional(),myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional(),totalCount:N().int().nonnegative(),statusCounts:Zu});const wh=B([`user_configurable`,`need_approval`,`block`]),Th=B([`need_approval`,`always_allow`,`block`]),Eh=L({id:j(),name:O(),toolName:O(),description:O(),workspacePolicy:wh,userPolicy:Th.nullable()});L({tools:I(Eh)}),L({tools:I(Eh.extend({schedulePolicy:Kd.nullable()}))});const Dh=B([`saas`,`on-premises`]);L({path:O(),value:F().optional()});const Oh=B([`scheduled`,`in_progress`,`completed`,`cancelled`]),kh=B([`manual`,`calendar`,`recording`]),Ah=B([`local`,`upload`,`zoom`,`youtube`,`media`,`bot`]),jh=B([`chrome_extension`]),Mh=B([`pending`,`extracting_subtitles`,`downloading`,`transcribing`,`refining`,`completed`,`failed`]),Nh=B([`recall`]),Ph=B([`scheduled`,`joining`,`in_call`,`recording`,`done`,`failed`,`removed`]),Fh=B([`manual`,`api`,`connector`,`calendar_subscription`]),Ih=B([`idle`,`queued`,`generating`,`completed`,`failed`]),Lh=B([`generated`,`import`,`user_edit`,`restore`,`migration`]),Rh=L({type:B([`hangoutsMeet`,`zoom`,`teams`,`webex`,`other`]),uri:O().optional(),label:O().optional()}),zh=L({email:O(),displayName:O().nullable().optional(),role:B([`organizer`,`attendee`,`optional`]).optional(),responseStatus:B([`needsAction`,`declined`,`tentative`,`accepted`]).nullable().optional(),userId:j().nullable().optional()}),Bh=L({start:N(),end:N(),text:O()}),Vh=Fs(O().regex(/^[A-Z0-9]{1,2}$/u),O().trim().min(1).max(100).regex(/^[^\r\n]+$/u)),Hh=L({description:O(),assignee:O().nullable().optional(),dueDate:O().nullable().optional(),completed:P()}),Uh=B([`private`,`workspace`]),Wh=B([`viewer`,`editor`]),Gh=B([`owner`,`editor`,`viewer`]),Kh=B([`explicit`,`workspace`]),qh=L({userId:j(),userName:O(),userEmail:A(),userImage:O().nullable().optional(),role:Wh,grantedBy:j().nullable(),createdAt:H()}),Jh=L({teamId:j(),teamName:O(),memberCount:N(),role:Wh,grantedBy:j().nullable(),createdAt:H()});L({visibility:Uh,userGrants:I(qh),teamGrants:I(Jh)}),L({role:Wh}),L({title:O().trim().min(1).max(500),description:O().optional(),location:O().optional(),startTime:W.optional(),endTime:W.optional(),conferenceLink:M().optional(),conferenceData:Rh.optional(),calendarEventId:j().optional(),notes:O().optional()}),L({title:O().trim().min(1).max(500).optional(),description:O().nullable().optional(),location:O().nullable().optional(),startTime:W.nullable().optional(),endTime:W.nullable().optional(),status:Oh.optional(),conferenceLink:M().nullable().optional(),conferenceData:Rh.nullable().optional(),notes:O().nullable().optional(),summary:O().nullable().optional(),expectedSummary:O().nullable().optional(),calendarEventId:j().nullable().optional(),visibility:Uh.optional()});const Yh=L({processedChunks:N().int().nonnegative(),totalChunks:N().int().positive()}),Xh=B([`preparing`,`queued`,`transcribing`,`validating`,`finalizing`,`falling_back`]),Zh=L({percentage:N().int().min(0).max(100),batchStage:Xh.optional(),batchStartedAt:H().optional(),batchElapsedSeconds:N().int().nonnegative().optional()}),Qh=L({provisionalCoverageRatio:N().min(0).max(1),finalTranscription:Yh}),$h=L({transcript:O(),transcriptWithTimestamps:O(),segments:I(Bh),summary:O().nullable(),actionItems:I(Hh).nullable().optional(),generatedAt:H(),stability:L({coverageRatio:N().min(0).max(1),eligible:P(),failedChunkCount:N().int().nonnegative(),maxGapSec:N().nonnegative(),missingRangeCount:N().int().nonnegative(),pendingChunkCount:N().int().nonnegative(),reason:O()})}),eg=$h.pick({summary:!0,actionItems:!0});L({id:j(),uploadedBy:j(),meetingId:j(),title:O(),duration:N().nullable(),transcript:O().nullable(),transcriptWithTimestamps:O().nullable(),segments:I(Bh).nullable(),speakerNames:Vh,transcriptRevision:N().int().nonnegative(),needsSummaryRefresh:P(),isSummaryStale:P(),summary:O().nullable(),actionItems:I(Hh).nullable(),summaryStatus:Ih,audioStorageKey:O().nullable(),canRetranscribe:P().optional(),captureClient:jh.nullable().optional(),processingStatus:Mh.nullable(),processingProgress:Zh.nullable().optional(),hybridProgress:Qh.nullable().optional(),provisionalResult:$h.nullable().optional(),transcriptionProgress:Yh.nullable().optional(),recordedAt:H().nullable(),createdAt:H(),updatedAt:H()});const tg=L({id:j(),title:O(),duration:N().nullable(),hasSummary:P(),hasTranscript:P(),canRetry:P().optional(),needsSummaryRefresh:P(),isSummaryStale:P(),summary:O().nullable().optional(),actionItems:I(Hh).nullable().optional(),summaryStatus:Ih,source:Ah.nullable().optional(),captureClient:jh.nullable().optional(),processingStatus:Mh.nullable(),processingProgress:Zh.nullable().optional(),hybridProgress:Qh.nullable().optional(),provisionalResult:eg.nullable().optional(),transcriptionProgress:Yh.nullable().optional(),recordedAt:H().nullable(),createdAt:H(),updatedAt:H().optional()}),ng=B([`transcript`,`summary`]),rg=L({id:j(),name:O()}),ig=L({id:j(),versionNumber:N().int().nonnegative(),origin:Lh,restoredFromVersionId:j().nullable(),createdBy:rg.nullable(),createdAt:H(),excerpt:O().nullable()});L({contentType:ng,currentVersionId:j().nullable(),canRestore:P(),versions:I(ig),nextVersionNumber:N().int().nonnegative().nullable()});const ag=ig.omit({excerpt:!0});z(`contentType`,[ag.extend({contentType:V(`transcript`),transcript:O().nullable(),transcriptWithTimestamps:O().nullable(),rawTranscript:O().nullable(),segments:I(Bh).nullable(),speakerNames:Vh}),ag.extend({contentType:V(`summary`),summary:O(),actionItems:I(Hh).nullable(),sourceTranscriptRevision:N().int().nonnegative().nullable()})]),L({expectedHeadVersionId:j()}),L({currentVersionId:j().nullable(),canRestore:P(),versions:I(ig),nextVersionNumber:N().int().positive().nullable()}),ag.extend({summary:O(),actionItems:I(Hh).nullable(),sourceRecordingSummaryVersionIds:I(j())});const og=L({id:j(),meetingRecordingId:j().nullable(),provider:Nh,meetingUrl:O(),botName:O().nullable(),status:Ph,statusDetail:O().nullable(),dispatchSource:Fh,joinedAt:H().nullable(),endedAt:H().nullable(),recordingReadyAt:H().nullable(),createdAt:H(),updatedAt:H()});L({relatedActiveBot:L({meetingId:j(),status:Ph,dispatchedAt:H(),dispatchedBy:L({id:j(),name:O().nullable()}).nullable(),canAccess:P()}).nullable()});const sg=B([`all`,`matching_rules`,`none`]),cg=L({field:B([`meeting_type`,`meeting_title`]),matchType:B([`is`,`is_not`,`contains`,`does_not_contain`]),value:O().trim().min(1).max(200)}).superRefine((e,t)=>{if(e.field===`meeting_type`){e.matchType!==`is`&&e.matchType!==`is_not`&&t.addIssue({code:`custom`,path:[`matchType`],message:`meeting_type conditions must use is / is_not`}),e.value!==`internal`&&e.value!==`external`&&t.addIssue({code:`custom`,path:[`value`],message:`meeting_type conditions must match internal / external`});return}e.matchType!==`contains`&&e.matchType!==`does_not_contain`&&t.addIssue({code:`custom`,path:[`matchType`],message:`meeting_title conditions must use contains / does_not_contain`})});L({settings:L({recorderAgentName:O().trim().min(1).max(100),recordingPolicy:sg,conditions:I(cg).max(20)}).superRefine((e,t)=>{e.recordingPolicy===`matching_rules`&&e.conditions.length===0&&t.addIssue({code:`custom`,path:[`conditions`],message:`matching_rules requires at least one condition`})}).nullable(),hasCalendarAccounts:P()}),L({policyVersion:O(),segmentSeconds:N().int().positive(),minFlushSegmentSeconds:N().positive(),maxSegmentDurationSeconds:N().int().positive(),idlePollIntervalMs:N().int().positive(),pendingPollBackoffIntervalsMs:I(N().int().positive()).min(1),pendingPollIntervalMs:N().int().positive(),pollJitterRatio:N().min(0).max(1),uploadTimeoutMs:N().int().positive(),liveTranscriptionModelTimeoutMs:N().int().positive(),maxQueuedSegments:N().int().positive(),maxPendingChunks:N().int().positive(),maxUploadBytes:N().int().positive(),displayLagSeconds:N().nonnegative(),timelineCatchUpIntervalMs:N().int().positive(),timelineGapRevealAheadChunks:N().int().nonnegative(),timelineMaxBurstSegments:N().int().positive(),timelineMaxDisplaySegmentDurationSeconds:N().positive(),timelineMinDisplaySegmentDurationSeconds:N().positive(),timelineTypingCriticalBacklogChars:N().int().positive(),timelineTypingCriticalCharsPerSecond:N().int().positive(),timelineTypingHighBacklogChars:N().int().positive(),timelineTypingHighBacklogCharsPerSecond:N().int().positive(),timelineTypingLowBacklogChars:N().int().positive(),timelineTypingLowBacklogCharsPerSecond:N().int().positive(),timelineTypingNormalCharsPerSecond:N().int().positive(),timelineTypingRevealTickMs:N().int().positive()});const lg=L({userId:j(),name:O().nullable(),email:O(),image:O().nullable().optional()});L({id:j(),workspaceId:j(),createdBy:j(),owner:lg.optional(),calendarEventId:j().nullable(),title:O(),description:O().nullable(),location:O().nullable(),startTime:O().nullable(),endTime:O().nullable(),status:Oh,source:kh,conferenceLink:O().nullable(),conferenceData:Rh.nullable(),notes:O().nullable(),summary:O().nullable(),actionItems:I(Hh).nullable().optional(),calendarEvent:L({title:O(),providerEventId:O(),calendarId:O(),provider:B([`google`,`outlook`,`caldav`]),providerCalendarId:O(),startTime:O(),endTime:O()}).nullable(),participants:I(zh).optional(),recordings:I(tg).optional(),hasEverRecorded:P().optional(),meetingBots:I(og).optional(),isOwner:P().optional(),sharedVia:Kh.optional(),visibility:Uh,myRole:Gh.optional(),createdAt:H(),updatedAt:H()});const ug=L({id:j(),title:O(),sortTime:O(),createdAt:H(),updatedAt:H(),startTime:O().nullable(),endTime:O().nullable(),status:Oh.nullable(),source:kh.nullable(),conferenceLink:O().nullable(),hasRecordings:P(),hasNotes:P().optional(),hasEverRecorded:P().optional(),participantCount:N().nullable(),isOwner:P(),myRole:Gh,owner:lg.optional(),sharedVia:Kh.optional(),isSharedWithOthers:P().optional(),duration:N().nullable(),hasTranscript:P(),hasSummary:P(),summaryStatus:Ih,recordingSource:Ah.nullable(),processingStatus:Mh.nullable(),hasActiveMeetingBot:P().optional(),activeMeetingBot:og.optional()}),dg=L({meetingId:O(),userId:O(),userName:O(),userEmail:O(),userImage:O().nullable().optional(),createdAt:H()});L({recordings:I(tg),nextKey:O().optional()}),L({meetings:I(ug),nextKey:O().optional()}),L({shares:I(dg)}),L({meetings:I(L({id:O(),title:O(),startTime:O().nullable()}))}),L({photos:Fs(O(),O())}),L({previous:L({meetingId:j(),title:O(),startTime:O().nullable(),summary:O(),actionItems:I(Hh)}).nullable()}),ml.extend({search:O().trim().max(200).optional(),filter:B([`mine`,`shared`,`all`]).default(`all`),sortBy:B([`updated_at`,`start_time`]).default(`updated_at`),hasContent:dc().optional(),hasActiveMeetingBot:dc().optional()});function fg(e){return e.summary?e.summary:e.recordings?.find(e=>e.summary)?.summary||e.recordings?.find(e=>e.provisionalResult?.summary)?.provisionalResult?.summary}const pg=[`chatgpt`,`claude`],mg={chatgpt:{modelProvider:`chatgpt-subscription`,modelIdPrefix:`chatgpt-sub/`,connectionFlow:`device-code`},claude:{modelProvider:`claude-subscription`,modelIdPrefix:`claude-sub/`,connectionFlow:`authorization-code`}},hg=B(pg);L({connections:I(L({provider:hg,status:B([`pending`,`connected`,`expired`,`error`]),accountLabel:O().nullable(),plan:O().nullable(),lastError:O().nullable(),connectedAt:H().nullable()})),connectableProviders:I(hg)}),z(`connectionFlow`,[L({userCode:O(),verificationUrl:M(),expiresAt:H(),pollIntervalSeconds:N().int().positive()}).extend({connectionFlow:V(`device-code`)}),L({connectionFlow:V(`authorization-code`),authorizationUrl:M(),expiresAt:H()})]),L({code:O().trim().min(1).max(4096)}),L({models:I(L({id:O(),name:O(),provider:hg}))});const gg=[...dp,`azure-openai`],_g=pg.map(e=>mg[e].modelProvider),vg=[...gg,..._g];function yg(e){return pp.filter(t=>t.provider===e).map(e=>e.id)}yg(`openai`),yg(`anthropic`),yg(`vertex-anthropic`),yg(`vertex-google`),yg(`google`),yg(`openrouter`),yg(`selfhosted`),yg(`apmic`),yg(`cerebras`);const bg=[`chatgpt-sub/gpt-5.6-sol`,`chatgpt-sub/gpt-5.6-terra`,`chatgpt-sub/gpt-5.6-luna`,`chatgpt-sub/gpt-5.5`,`claude-sub/opus-5`,`claude-sub/sonnet-5`,`claude-sub/haiku-4-5`],xg=[`chatgpt-pool/gpt-5.6-sol`,`chatgpt-pool/gpt-5.6-terra`,`chatgpt-pool/gpt-5.6-luna`,`chatgpt-pool/gpt-5.5`],Sg=pp.map(e=>e.id);function Cg(e){return e.startsWith(`azure-`)}const wg=[`lite`,`pro`,`max`],Tg=[`image`,`image-lite`],Eg=[`functionality`],Dg=[...wg,...Tg,...Eg],Og=R([B(Sg),B(wg),O().refine(e=>Cg(e)),B(bg),B(xg)]),kg=R([Og,V(`auto`)]),Ag=L({id:O(),name:O(),shortName:O().optional(),description:O(),shortDescription:O().optional(),enabled:P().optional(),tags:I(O()).optional()});L({models:I(Ag)}),L({tiers:I(L({tier:O(),model:Ag.optional()}))}),L({modelId:O()}),L({providers:I(L({id:O(),name:O(),baseUrl:O().nullable().optional(),verified:P(),models:I(L({id:O(),name:O(),enabled:P().optional(),additional:P().optional()})),options:Fs(O(),bs()).optional()}))}),L({models:I(L({id:O(),name:O(),provider:B(vg),supportsChat:P(),supportsImageGeneration:P(),availableForAdvanced:P()}))}),L({tiers:I(L({tier:B(Dg),modelId:O(),fallbackModelId:O().nullable()}))}),L({tier:B(Dg)}),L({modelId:O().min(1),fallbackModelId:O().min(1).nullable().optional()});const jg=Object.values({AGENT:`agent`,SKILL:`skill`}),Mg={ROLE:`role`,BADGE:`badge`,USE_CASE:`use_case`},Ng=Object.values(Mg),Pg=L({speaker:B([`user`,`assistant`]),text:O()}),Fg=L({id:j(),name:O(),provider:O(),iconUrl:O().nullable(),purpose:O()}),Ig=L({tag:O(),category:B(Ng),label:O()}),Lg=L({slug:O(),type:B(jg),name:O(),description:O(),iconUrl:O().nullable(),tags:I(Ig)}),Rg=O().optional().transform(e=>bc(e));L({type:B(jg).optional(),tag:O().optional(),limit:U().int().min(1).max(100).default(30),cursor:O().optional(),lang:Rg}),L({items:I(Lg),nextCursor:O().nullable()}),z(`type`,[L({slug:O(),type:V(`agent`),name:O(),description:O(),iconUrl:O().nullable(),tags:I(Ig),starterPrompts:I(O()),exampleConversation:I(Pg),connectors:I(Fg)}),L({slug:O(),type:V(`skill`),name:O(),description:O(),iconUrl:O().nullable(),tags:I(Ig),exampleConversation:I(Pg)})]),L({items:I(L({tag:O(),name:O(),tagline:O()}))}),L({toolApprovalMode:jd.optional()}).default({}),L({resourceId:j(),resourceType:B(jg),workspaceId:j(),taskId:j().nullable(),resourceSlug:O()}),L({type:B(jg),slug:O().min(1)}),L({lang:Rg});const zg=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Bg=L({connectorId:j(),purpose:O().trim().min(1,`Purpose is required`)}),Vg={name:O().trim().min(1).max(120),description:O().trim().min(1).max(2e3),iconId:j().nullable().optional(),tags:I(O()).default([]),model:kg,systemPrompt:O().trim().min(1),conversationStarters:I(O().trim().min(1)).max(5).default([]),exampleConversation:I(Pg).min(1,`At least one example turn is required`),connectors:I(Bg).refine(e=>new Set(e.map(e=>e.connectorId)).size===e.length,{message:`Each connector can only be added once`}).default([])};L({slug:O().trim().regex(zg,`Use lowercase-kebab-case`).max(120),...Vg}),L(Vg),L({id:j()}),L({type:B(jg).optional(),limit:U().int().min(1).max(100).default(30),offset:U().int().min(0).default(0)}),L({items:I(L({id:j(),type:B(jg),slug:O(),name:O(),description:O(),tags:I(O()),isDelisted:P(),createdAt:H(),updatedAt:H()})),total:N().int().min(0)});const Hg=L({connectorId:j(),name:O(),purpose:O()});L({id:j(),slug:O(),name:O(),description:O(),iconId:j().nullable(),tags:I(O()),model:O(),systemPrompt:O(),conversationStarters:I(O()),exampleConversation:I(Pg),connectors:I(Hg),isDelisted:P(),createdAt:H(),updatedAt:H()}),L({items:I(L({tag:O(),category:B([Mg.ROLE,Mg.BADGE,Mg.USE_CASE])}))}),L({items:I(L({id:j(),name:O(),description:O()}))});const Ug={description:O().trim().min(1).max(2e3),iconId:j().nullable().optional(),tags:I(O()).default([]),exampleConversation:I(Pg).min(1,`At least one example turn is required`)};L({slug:O().trim().regex(zg,`Use lowercase-kebab-case`).max(120),...Ug}),L(Ug),L({id:j()}),L({id:j(),slug:O(),name:O(),description:O(),iconId:j().nullable(),tags:I(O()),exampleConversation:I(Pg),hasPackagedContent:P(),isDelisted:P(),createdAt:H(),updatedAt:H()}),L({name:O(),description:O()});const Wg=L({id:N(),content:O(),createdAt:H(),updatedAt:H()});L({limit:U().int().min(1).max(100).default(100),nextKey:O().optional()}),L({memories:I(Wg),nextKey:O().optional()}),L({workspaceId:j()}),L({workspaceId:j(),memoryId:U().int()}),L({providers:I(L({id:O(),name:O(),clientId:O().nullable(),authUrl:O(),tokenUrl:O(),usePKCE:P(),defaultScopes:I(O()).nullable(),strategy:O(),configured:P(),builtIn:P(),iconUrl:O().optional()}))});const Gg={AGENT:`agent`,SKILL:`skill`,WORKFLOW:`workflow`,CONNECTOR:`connector`,SCHEDULE:`schedule`,PROJECT:`project`};function Kg({resourceType:e,resourceId:t}){return`${e}:${t}`}const qg=B([Gg.AGENT,Gg.SKILL,Gg.WORKFLOW,Gg.CONNECTOR,Gg.SCHEDULE,Gg.PROJECT]),Jg=L({resourceType:qg,resourceId:j(),name:O(),managedAgent:L({channelCount:N().int().nonnegative()}).optional()});L({hash:O().regex(/^[0-9a-f]{64}$/),items:I(Jg)});const Yg=z(`action`,[L({resourceType:qg,resourceId:j(),action:V(`transfer`),successorUserId:j()}),L({resourceType:qg,resourceId:j(),action:V(`delete`)})]),Xg=z(`action`,[L({action:V(`transfer`),successorUserId:j()}),L({action:V(`delete`)})]);L({inventoryHash:O().min(1),defaultAction:Xg.optional(),decisions:I(Yg).max(1e3).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=Kg(i);n.has(e)?t.addIssue({code:`custom`,path:[r],message:`Duplicate decision for resource`}):n.add(e)}})}),L({transferred:N(),deleted:N()});const X={Access:`access`,ManageWorkspace:`manage_workspace`,ManageRole:`manage_role`,ManageMember:`manage_member`,ManagePayment:`manage_payment`,SubmitCustomConnector:`submit_custom_connector`,ReviewCustomConnector:`review_custom_connector`,ManageConnector:`manage_connector`,ManageModel:`manage_model`,ManageCapability:`manage_capability`,ManageTeam:`manage_team`,ReviewResourcePublish:`review_resource_publish`,CreateAgent:`create_agent`,PublishAgent:`publish_agent`,CreateSkill:`create_skill`,PublishSkill:`publish_skill`,CreateWorkflow:`create_workflow`,CreateCustomConnector:`create_custom_connector`,PublishCustomConnector:`publish_custom_connector`,ManageAllTeams:`manage_all_teams`,ManageChatbot:`manage_chatbot`,ManageChannelAgents:`manage_channel_agents`,ViewAuditLogs:`view_audit_logs`};X.ManageWorkspace,X.ManageRole,X.ManageMember,X.ManagePayment,X.ManageModel,X.ManageCapability,X.ManageConnector,X.ManageChatbot,X.ManageChannelAgents,X.CreateCustomConnector,X.PublishCustomConnector,X.CreateAgent,X.PublishAgent,X.CreateSkill,X.PublishSkill,X.ReviewResourcePublish,X.ManageTeam,X.ManageAllTeams,X.ViewAuditLogs,X.ManageMember,X.ManageCapability,X.ManageConnector,X.ManageChatbot,X.ManageChannelAgents,X.CreateCustomConnector,X.PublishCustomConnector,X.CreateAgent,X.PublishAgent,X.CreateSkill,X.PublishSkill,X.ManageTeam,X.CreateCustomConnector,X.PublishCustomConnector,X.CreateAgent,X.PublishAgent,X.CreateSkill,X.PublishSkill;const Zg=B([`workspace`,`resource`,`team`]),Qg=L({id:B(Object.values(X)),name:O(),descriptions:I(O()).min(1),category:Zg});L({lang:vc}),L({permissions:I(Qg)});const $g=B([{id:`manage_role`,category:`workspace`},{id:`manage_member`,category:`workspace`},{id:`manage_workspace`,category:`workspace`},{id:`manage_payment`,category:`workspace`},{id:`manage_model`,category:`workspace`},{id:`view_audit_logs`,category:`workspace`},{id:`manage_capability`,category:`resource`},{id:`create_custom_connector`,category:`resource`},{id:`publish_custom_connector`,category:`resource`},{id:`create_agent`,category:`resource`},{id:`publish_agent`,category:`resource`},{id:`create_skill`,category:`resource`},{id:`publish_skill`,category:`resource`},{id:`create_workflow`,category:`resource`},{id:`review_resource_publish`,category:`resource`},{id:`manage_team`,category:`team`},{id:`manage_all_teams`,category:`team`},{id:`manage_chatbot`,category:`workspace`},{id:`manage_channel_agents`,category:`workspace`}].map(e=>e.id));L({permissions:I($g)});const e_=L({en:B([`en-US`,`en-GB`]).optional(),zh:B([`zh-CN`,`zh-HK`,`zh-TW`]).optional(),es:B([`es-MX`,`es-ES`,`es-US`]).optional(),fr:B([`fr-FR`,`fr-CA`]).optional(),pt:B([`pt-PT`,`pt-BR`]).optional()}).strict(),t_=L({displayName:O().nullable(),jobTitle:O().nullable(),language:O().nullable(),customPreferences:O().nullable(),voiceLanguageVariants:e_.nullable(),updatedAt:H()});L({displayName:O().trim().max(100).nullable().optional(),jobTitle:O().trim().max(100).nullable().optional(),language:O().trim().max(100).nullable().optional(),customPreferences:O().trim().max(1e3).nullable().optional(),voiceLanguageVariants:e_.nullable().optional()}),L({workspaceId:j()}),t_.extend({updatedAt:H().nullable()}),L({workspaceId:j()}),L({workspaceId:j(),teamId:j(),publishId:j()}),L({workspaceId:j(),teamId:j()});const n_=[ku.MEMBER,ku.MANAGER,ku.OWNER];L({resourceType:Iu,resourceId:j(),versionId:j().optional(),teamIds:I(j()).min(1).max(20).refine(e=>new Set(e).size===e.length,{message:`teamIds must not contain duplicates`}),message:O().trim().max(500).optional()}),L({roles:I(B(n_)).min(1).refine(e=>new Set(e).size===e.length,{message:`Roles must be unique`})}),L({roles:I(B(n_)).min(1).refine(e=>new Set(e).size===e.length,{message:`Roles must be unique`})}),L({items:I(L({id:j(),resource:zu,author:Ru,requester:Ru,teamId:j(),versionNumber:N().int().nullable(),status:B(Lu),message:O().nullable(),roles:I(B(n_)).nullable(),reviewer:Ru.nullable(),reviewedAt:H().nullable(),rejectReason:O().nullable(),createdAt:H(),updatedAt:H()})),nextKey:O().optional()}),L({count:N().int()}),L({workspaceId:j()}),L({workspaceId:j(),publishId:j()}),L({resourceType:Iu,resourceId:j(),versionId:j().optional(),message:O().trim().max(500).optional()}),L({roleIds:I(j()).min(1).optional()}),L({roleIds:I(j()).nullable().optional()}),L({items:I(L({id:j(),resource:zu,author:Ru.nullable(),requester:Ru.nullable(),versionNumber:N().int().nullable(),workspaceId:j(),status:B(Lu),message:O().nullable(),roleIds:I(j()).nullable(),reviewer:Ru.nullable(),reviewedAt:H().nullable(),rejectReason:O().nullable(),createdAt:H(),updatedAt:H()})),total:N().int().nonnegative(),nextKey:O().optional()}),L({resourceType:Iu.optional()}),L({count:N().int()}),[{extension:`mp3`,mimeTypes:[`audio/mpeg`]},{extension:`m4a`,mimeTypes:[`audio/mp4`,`audio/x-m4a`]},{extension:`wav`,mimeTypes:[`audio/wav`,`audio/wave`]},{extension:`mp4`,mimeTypes:[`video/mp4`]},{extension:`webm`,mimeTypes:[`audio/webm`,`video/webm`]},{extension:`aac`,mimeTypes:[`audio/aac`]},{extension:`ogg`,mimeTypes:[`audio/ogg`]},{extension:`flac`,mimeTypes:[`audio/flac`]},{extension:`mpeg`,mimeTypes:[`audio/mpeg`]}].map(({extension:e})=>`.${e}`),L({url:M(),title:O().trim().min(1).max(500).optional(),preferredLanguage:O().trim().min(2).max(10).regex(/^[a-zA-Z]{2,3}(-[a-zA-Z]{2,8})?$/,`Invalid language code format`).optional()}),L({recordingId:j(),source:V(`media`),message:O()}),L({url:M()}),L({url:O(),type:V(`media`),title:O(),duration:N().optional(),thumbnailUrl:O().optional(),contentType:O().optional(),fileSize:N().optional(),extractor:O().optional(),channelName:O().optional(),uploadDate:O().optional()}),L({downloadUrl:O(),playbackPending:P(),url:O()}),L({deploymentMode:Dh,features:L({enableCapability:P(),enableCapabilityProviderSwitch:P(),enableChatbotSlack:P(),enableChatbotTeams:P(),enableProject:P(),enableScheduleActiveWindows:P(),enableScheduleJudge:P(),scheduleJudgeDefaultEnabled:P()})});const r_=L({id:j(),name:O(),email:A(),image:O().nullable().optional()}),i_=L({id:j(),name:O()});L({subjectType:Pu,subjectId:j()}),L({grants:I(z(`subjectType`,[L({subjectType:V(Nu.USER),subjectId:j(),userId:j(),role:Mu,user:r_}),L({subjectType:V(Nu.TEAM),subjectId:j(),teamId:j(),role:Mu,team:i_})]))}),L({role:Mu});function a_(e){return e.subjectType===Nu.USER}function o_(e){return e.grants.filter(a_)}L({workspaceId:j(),resourceType:Iu}),L({teams:I(L({id:j(),name:O()}))}),L({roles:I(L({id:j(),name:O(),description:O().optional(),isDefault:P(),memberCount:N().int(),permissions:I(O()),createdAt:H(),updatedAt:H()})),nextKey:O().optional()}),L({name:O().trim().min(1).max(100),description:O().trim().max(500).optional(),permissions:I($g).min(1)}),L({name:O().trim().min(1).max(100),description:O().trim().max(500).optional(),permissions:I($g).min(1)});const s_={},c_={};function l_(e,t){try{let n=(s_[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in c_?c_[n]:d_(n,n.split(`:`))}catch{if(e in c_)return c_[e];let t=e?.match(u_);return t?d_(e,t.slice(1)):NaN}}const u_=/([+-]\d\d):?(\d\d)?/;function d_(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return c_[e]=n*60+r>0?n*60+r+i:n*60-r-i}var f_=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(l_(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),g_(this,e)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-l_(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),m_(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};const p_=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!p_.test(e))return;let t=e.replace(p_,`$1UTC`);f_.prototype[t]&&(e.startsWith(`get`)?f_.prototype[e]=function(){return this.internal[t]()}:(f_.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),h_(this),+this},f_.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),m_(this),+this}))});function m_(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-l_(e.timeZone,e)*60))}function h_(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),g_(e)}function g_(e,t){let n=Array.isArray(t)?__(t):+e.internal,r=l_(e.timeZone,e),i=r>0?Math.floor(r):Math.ceil(r),a=new Date(+e);a.setUTCHours(a.getUTCHours()-1);let o=-new Date(+e).getTimezoneOffset(),s=-new Date(+a).getTimezoneOffset(),c=o-s,l=o;if(c&&o!==i&&Date.prototype.getHours.apply(e)!==(Array.isArray(t)?t[3]||0:e.internal.getUTCHours())){let t=new Date(+e),n=o-i;n&&t.setUTCMinutes(t.getUTCMinutes()+n);let r=l_(e.timeZone,t);(r>0?Math.floor(r):Math.ceil(r))===i&&(l=s)}let u=l-i;u&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+u);let d=new Date(+e);d.setUTCSeconds(0);let f=o>0?d.getSeconds():(d.getSeconds()-60)%60,p=Math.round(-(l_(e.timeZone,e)*60))%60;(p||f)&&Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+p+f);let m=l_(e.timeZone,e),ee=m>0?Math.floor(m):Math.ceil(m),te=-new Date(+e).getTimezoneOffset()-ee,ne=ee!==i,re=te-u,ie=ee-i,ae=n-ee*60*1e3,h=ie>0&&v_(e)-n===ie*60*1e3&&v_(e,ae)!==n;if(ne&&re&&!h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+re);let t=l_(e.timeZone,e),n=ee-(t>0?Math.floor(t):Math.ceil(t));n&&re<0&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n)}m_(e);let g=(t?n:n+p*1e3)-+e.internal;g&&Math.abs(g)<1800*1e3&&(Date.prototype.setTime.call(e,+e+g),m_(e))}function __(e){return Date.UTC(e[0],e.length>1?e[1]:0,e.length>2?e[2]:1,...e.slice(3))}function v_(e,t){let n=new Date(t??+e);return n.setUTCSeconds(n.getUTCSeconds()-Math.round(-l_(e.timeZone,n)*60)),+n}const y_=O().length(12).regex(/^[a-z0-9]+$/u),b_=R([z(`mode`,[L({mode:V(`version`),versionId:j()}),L({mode:V(`work`),taskId:j()})]),L({mode:V(`file`),fileId:j()}),L({mode:V(`live`)})]);Ds({siteKey:y_,env:O().min(1),serve:b_,iat:N().optional(),exp:N().optional()});const x_=[`preview_site_ready`,`preview_site_publish`,`preview_site_read`,`preview_site_delete`];function S_(e,t){let n=new Set;for(let r of e){let e=t(r);if(n.has(e))return e;n.add(e)}}const C_=I(O().min(1)).superRefine((e,t)=>{let n=S_(e,e=>e);n&&t.addIssue({code:`custom`,message:`Duplicate path: ${n}`})});B(x_);const w_={env:O().min(1),sandboxDomain:O().min(1),sandboxId:O().min(1)},T_={...w_,siteDir:O().min(1).default(`app`)},E_={env:O().min(1),siteKey:y_},D_={...E_,serve:b_};z(`op`,[L({op:V(`preview_site_ready`),...T_}),L({op:V(`preview_site_publish`),...T_}),L({op:V(`preview_site_delete`),...w_})]),z(`op`,[L({op:V(`preview_site_ready`),...D_}),L({op:V(`preview_site_publish`),...D_}),L({op:V(`preview_site_read`),...D_}),L({op:V(`preview_site_delete`),...E_})]),L({files:I(L({path:O().min(1),contentBase64:ls(`Invalid base64 content`),contentType:O().optional()})).max(128).superRefine((e,t)=>{let n=S_(e,e=>e.path);n&&t.addIssue({code:`custom`,message:`Duplicate path: ${n}`})}),finalize:P().default(!0),manifestFiles:C_.optional()}).superRefine((e,t)=>{if(!e.finalize||!e.manifestFiles)return;let n=new Set(e.manifestFiles);for(let r of e.files)if(!n.has(r.path)){t.addIssue({code:`custom`,message:`Manifest is missing published file: ${r.path}`});return}}),L({filesUploaded:N().int().nonnegative(),filesDeleted:N().int().nonnegative()}),L({files:C_});const O_=Object.values({BUILT_IN:`built_in`,CUSTOM:`custom`}),k_=[`updatedAt`,`name`];ml.extend({createdBy:B([`me`]).optional(),search:O().trim().max(200).optional(),sortBy:B(k_).optional()});const A_=L({id:j(),name:O(),isMe:P()}),j_=L({id:j()}).nullable(),M_=L({id:j(),name:O(),description:O(),type:B(O_).optional(),provider:O().nullable(),author:A_.nullable(),publish:j_,publishedTo:Vu.optional(),team:L({id:j(),name:O()}).optional().describe(`The team this skill is published to, only present when createdBy is team`),versionNumber:N().int().nullable().optional(),isEnabled:P(),myRole:Fu,createdAt:H(),updatedAt:H()});L({skills:I(M_),nextKey:O().optional()}),L({workspaceId:j(),skillId:j(),versionId:j()});const N_=L({id:j(),name:O()}),P_=L({id:j(),versionNumber:N().int().min(1),description:O(),createdBy:N_,createdAt:H()});L({skillId:j(),skillName:O(),versions:I(P_)}),L({url:M()}),L({search:O().trim().max(200).optional(),status:B(Xu).optional(),nextKey:O().optional(),limit:U().int().min(1).max(100).default(20),sortBy:B(k_).optional()}),L({skills:I(L({id:j(),name:O(),description:O().optional(),hasUnpublishedChanges:P(),latestVersionNumber:N().int().nullable(),publishedTo:Vu.optional(),myRole:Fu,createdAt:H(),updatedAt:H()})),nextKey:O().optional(),totalCount:N().int().nonnegative(),statusCounts:Zu}),ml.extend({createdBy:B([`workspace`,`team`,`me`]).optional(),teamId:j().optional(),search:O().trim().max(200).optional(),sortBy:B(k_).optional()}).refine(e=>!e.teamId||e.createdBy===`team`,{message:`teamId can only be used with createdBy: team`,path:[`teamId`]}),L({field:O(),message:O()}),L({workspaceId:j(),skillId:j()}),L({isEnabled:P()}),L({isEnabled:P()}),L({skills:I(M_),nextKey:O().optional()}),L({workspaceId:j(),skillId:j()});const F_=L({path:O(),size:N().int().nonnegative()});L({skillId:j(),skillName:O(),description:O(),versionId:j(),files:I(F_)}),L({workspaceId:j(),skillId:j()}),L({path:O().trim().min(1).max(1024)}),z(`kind`,[L({kind:V(`text`),path:O(),size:N().int().nonnegative(),content:O()}),L({kind:V(`image`),path:O(),size:N().int().nonnegative(),content:O()}),L({kind:V(`binary`),path:O(),size:N().int().nonnegative()}),L({kind:V(`too_large`),path:O(),size:N().int().nonnegative()})]);const I_=B([`queued`,`running`,`completed`,`failed`,`cancelled`]),L_=I_,R_=B([`subagent`,`workflow`]);function z_(e){return e===`subagent`?`subagentRuns`:`workflowRuns`}const B_=new Set([`completed`,`failed`,`cancelled`]);function V_(e){return B_.has(e)}function H_(e){return e.at(-1)?.toolCallCount??0}L({runs:I(L({runId:O(),kind:R_,status:L_,label:O(),startedAt:O().nullable(),createdAt:O()}))}),L({runId:j(),status:I_,startedAt:O().nullable(),progress:cc().nullable().meta({type:`object`}),result:cc().nullable().meta({type:`object`}),error:cc().nullable().meta({type:`object`})});const U_=B([`chatgpt`]),W_=B([`active`,`expired`,`needs_reauth`,`quota_exhausted`,`error`]),G_=Ml,K_=L({observedAt:H(),windows:Fs(O(),G_)}),q_=L({id:j(),provider:U_,label:O(),accountId:O(),status:W_,quotaResetAt:H().nullable(),quota:K_.nullable(),lastCheckedAt:H().nullable(),createdAt:H()});L({accounts:I(q_)}),L({accountIds:I(j()).min(1)}),L({provider:U_,label:O().trim().min(1).max(100).optional()}),L({provider:U_}),L({status:B([`pending`,`connected`,`error`]),account:q_.nullable(),lastError:O().nullable()}),L({errorMessage:O().min(1).max(1e3),url:M().max(2e3).optional(),userAgent:O().max(500),workspaceId:j().optional(),sentryEventId:O().max(64).optional(),description:O().max(5e3).nullable()}),L({requestId:N().int()}),B([`step_limit`,`usage_exhausted`,`output_limit`,`retry_limit`]);const J_=[`pending`,`running`,`completed`,`failed`,`cancelled`],Y_=[`input`,`output`],X_=B(J_),Z_=B(Y_),Q_=L({taskAssetId:j(),role:Z_}),$_=L({id:j(),position:N().int().positive().nullable(),title:O(),status:X_,startedAt:pc().nullable(),finishedAt:pc().nullable(),assets:I(Q_)}),ev=L({id:j(),taskRunId:j(),revision:N().int().nonnegative(),items:I($_)}),tv=$_.extend({startedAt:H().nullable(),finishedAt:H().nullable()});ev.extend({items:I(tv)}),L({workspaceId:j()}),L({workspaceId:j(),teamId:j()}),L({workspaceId:j(),teamId:j(),userId:j()});const nv=[ku.OWNER,ku.MANAGER,ku.MEMBER],rv=[Au.VISIBLE,Au.HIDDEN],iv=[ku.OWNER,ku.MANAGER,ku.MEMBER],av=L({email:A(),role:B(iv)});L({name:O().trim().min(1).max(100),description:O().trim().max(500).nullable().default(null),visibility:B(rv).optional(),requireReview:P().optional(),acceptExternalSubmissions:P().optional(),members:I(av).min(1).max(50).optional()}),L({name:O().trim().min(1).max(100).optional(),description:O().trim().max(500).nullable().optional(),visibility:B(rv).optional(),requireReview:P().optional(),acceptExternalSubmissions:P().optional()}).refine(e=>e.name!==void 0||e.description!==void 0||e.visibility!==void 0||e.requireReview!==void 0||e.acceptExternalSubmissions!==void 0,{message:`At least one field must be provided`}),L({members:I(av).min(1).max(50)}),L({role:B(iv)});const ov=L({id:j(),name:O()});L({teams:I(L({id:j(),name:O(),description:O().nullable(),visibility:B(rv),requireReview:P(),acceptExternalSubmissions:P(),memberCount:N().int(),currentUserRole:B(nv).nullable(),createdBy:ov,createdAt:H(),updatedAt:H()}).extend({publishPendingCount:N().int(),published:P().optional()})),nextKey:O().optional()}),ml.extend({search:O().trim().max(200).optional(),resourceType:Iu.optional(),resourceId:j().optional()}),L({members:I(L({userId:j(),name:O(),email:O(),role:B(nv),createdAt:H()})),total:N().int().nonnegative()}),hl.extend({search:O().trim().max(200).optional()}),L({platform:B([`posthog`,`sentry`,`zendesk`])}),L({id:j()});const sv={MANUAL:`manual`,AUTO_LEARNED:`auto_learned`},cv=L({id:j(),word:O(),source:B([sv.MANUAL,sv.AUTO_LEARNED]),createdAt:H()});L({word:O().trim().min(1).max(200)}),L({limit:U().int().min(1).max(100).default(100),nextKey:O().optional()}),L({words:I(cv),nextKey:O().optional()}),L({workspaceId:j(),wordId:j()}),L({workspaceId:j()});const lv=1e3,uv=B([`personal`,`team`,`workspace`]),dv=B([`manual`,`auto_learned`]),fv=L({id:j(),workspaceId:j(),scope:uv,userId:j().nullable(),teamId:j().nullable(),term:O(),usageContext:O().nullable(),source:dv,createdBy:j().nullable(),createdAt:H(),updatedAt:H()}),pv=L({workspaceId:j()}),mv=pv.extend({teamId:j()});pv.extend({entryId:j()}),mv.extend({entryId:j()}),L({limit:U().int().min(1).max(100).default(100),nextKey:O().optional()}),L({entries:I(fv),nextKey:O().optional()});const hv=O().trim().min(1).max(200);L({term:hv,usageContext:O().trim().max(lv).nullable().optional()}),L({term:hv.optional(),usageContext:O().trim().max(lv).nullable().optional()}).refine(e=>Object.keys(e).length>0,{message:`At least one field is required`});const gv=Fs(O(),F()),_v=O().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,`node id must be lower_snake_case`),vv=B(wg),yv=R([V(`auto`),vv]),bv=B([`routine`,`reasoning`,`judgment`]),xv=B([`implicit_auto`,`fanout_max_excluded`,`only_enabled_tier`,`single_eligible_tier`,`tier_unavailable`]),Sv=L({requestedTier:yv,classifiedDemand:bv.optional(),selectedTier:vv,source:B([`pinned`,`classified`,`fallback`,`policy`,`chat-router`]),constraints:I(xv),policyVersion:B([`chat-router-v1`,`workflow-v1`])});L({id:_v,label:O().min(1).max(120)}).extend({kind:V(`agent`),promptTemplate:O().min(1),agentId:j().optional(),toolAllowlist:I(O()).optional(),outputSchema:gv.optional(),modelSelection:yv.optional(),maxSteps:N().int().min(1).max(50).optional()}),L({status:B([`queued`,`running`,`done`,`failed`]),output:F().optional(),error:O().optional(),durationMs:N().int().optional(),tokens:N().int().optional(),usage:L({inputTokens:N().int(),outputTokens:N().int(),totalTokens:N().int(),reasoningTokens:N().int(),cachedInputTokens:N().int(),cachedCreationTokens:N().int(),model:O().optional()}).optional(),fanOut:L({total:N().int(),done:N().int(),failed:N().int(),running:N().int()}).optional(),label:O().optional(),kind:B([`agent`,`fan_out`]).optional(),seq:N().int().optional(),prompt:O().optional(),invocation:L({schema:F().optional(),toolAllowlist:I(O()).optional(),agentId:O().optional(),maxSteps:N().int().optional(),model:yv.optional()}).optional(),modelAllocation:Sv.optional(),stepCount:N().int().optional(),toolCalls:I(L({name:O(),summary:O()})).optional(),phaseId:O().optional(),phaseSeq:N().int().optional()}),L({workflows:I(L({id:j(),name:O(),description:O().nullable(),scriptSource:O(),isActive:P(),createdAt:H(),updatedAt:H(),myRole:Fu})),nextKey:O().optional()});const Cv=B([`queued`,`running`,`completed`,`failed`,`cancelled`]),wv=L({id:j(),status:Cv,startedAt:H().nullable(),completedAt:H().nullable(),error:F().nullable(),createdAt:H()});L({runs:I(wv),nextKey:O().optional()}),wv.extend({workflowId:j(),context:cc().meta({type:`object`}),scriptSnapshot:O(),args:F().nullable()});const Tv=B([`invite-only`,`open`]),Ev=O().min(1,`Workspace name is required`).max(50,`Workspace name must be 50 characters or less`).regex(/^[\p{L}\p{N} ._-]+$/u,`Workspace name can only contain letters, numbers, spaces, dashes, underscores, and periods`).refine(e=>e===e.trim(),{message:`Workspace name cannot start or end with spaces`}),Dv=L({name:O().trim().min(1).max(50),latinName:O().trim().max(50).nullable().optional(),logoIconId:j(),faviconIconId:j().nullable().optional()}),Ov=L({name:O().trim().min(1).max(50),latinName:O().trim().max(50).nullable().optional(),logoUrl:O().min(1),faviconUrl:O().nullable().optional()}),kv=L({id:O(),name:O(),userCount:N(),config:L({branding:Ov.nullable().optional(),additionalModelsEnabled:P().optional(),subscriptionModelsEnabled:P().optional(),subscriptionPoolEnabled:P().optional(),managedAgentEnabled:P().optional(),autopilotEnabled:P().optional(),subscriptionPoolFallbackModelId:Og.nullable().optional()}).optional(),createdAt:H(),updatedAt:H()});L({workspaces:I(kv)}),L({workspaces:I(kv.extend({config:L({joinPolicy:Tv})}))}),L({joined:P()}),L({name:Ev,ownerId:j()}),L({name:Ev});const Av=O().trim().toLowerCase().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,`Invalid email domain`);L({hideThinking:P().optional(),joinPolicy:Tv.optional(),allowedDomains:I(O()),defaultToolApprovalMode:jd.optional(),requireReview:P().optional(),shareSensitiveScanEnabled:P().optional(),maxShareVisibility:mf.optional(),maxPreviewVisibility:mf.optional(),disabledModelTiers:I(B(wg)).optional(),additionalModelsEnabled:P().optional(),subscriptionModelsEnabled:P().optional(),subscriptionPoolEnabled:P().optional(),managedAgentEnabled:P().optional(),autopilotEnabled:P().optional(),subscriptionPoolFallbackModelId:Og.nullable().optional(),autoTierDisabled:P().optional(),chatbotSlackEffectivelyEnabled:P().optional(),chatbotTeamsEffectivelyEnabled:P().optional(),systemPrompt:O().trim().max(1e3).nullable().optional()}),L({email:A(),name:O(),roles:I(O()),permissions:I($g)});const jv=B([`requested`,`approved`,`rejected`]);L({workspaceId:j(),invitationId:j()}),L({email:A(),status:jv,workspace:L({id:j(),name:O()})}),L({invitations:I(L({id:j(),workspaceId:j(),email:A(),status:jv,role:O(),requestedSeatType:Ol,invitedBy:L({email:A(),name:O(),isMe:P()}).optional(),invitedAt:H().optional(),expiresAt:H().optional(),createdAt:H(),updatedAt:H()})),total:N().int().nonnegative()}),hl.extend({status:jv.optional(),search:O().trim().max(200).optional()});const Mv=L({starter:N().int().nonnegative(),pro:N().int().nonnegative(),premium:N().int().nonnegative()}),Nv=L({id:O(),email:O()}),Pv=L({id:O(),name:O(),owners:I(Nv),userCount:N().int().nonnegative(),paidSeatCount:N().int().nonnegative(),seatCountsByType:Mv,createdAt:H(),updatedAt:H()});hl.extend({search:O().trim().max(200).optional(),exact:dc().optional(),sortBy:B([`createdAt`,`userCount`,`paidSeatCount`]).default(`createdAt`),order:B(gl).default(`desc`)}),L({workspaces:I(Pv),total:N().int().nonnegative()}),L({workspaceId:j()});const Fv=L({purchasedUsd:N().nonnegative(),grantedUsd:N().nonnegative(),totalUsd:N().nonnegative(),nextExpiry:L({amountUsd:N().nonnegative(),expiresAt:H()}).nullable()}),Iv=L({id:O(),email:O(),name:O(),seatType:Ol.nullable(),joinedAt:H(),loginMethods:I(B(Bl)),lastLoginAt:H().nullable(),passwordSetupEmailSentAt:H().nullable()}),Lv=L({enabled:P(),modelIds:I(O())}),Rv=L({id:O(),name:O()}),zv=L({slackEnabled:P(),slackAvailable:P(),teamsEnabled:P(),teamsAvailable:P(),defaultAgentId:O().nullable(),ownerPanelDisabled:P(),inheritsLegacySettings:P(),agents:I(Rv)});L({slackEnabled:P(),teamsEnabled:P(),defaultAgentId:j().nullable(),ownerPanelDisabled:P()});const Bv=Dv.extend({logoUrl:O(),faviconUrl:O().nullable().optional()});L({branding:Dv.nullable()}),L({logoIconId:j(),faviconIconId:j(),logoUrl:O(),faviconUrl:O()}),L({id:O(),name:O(),owners:I(Nv),userCount:N().int().nonnegative(),paidSeatCount:N().int().nonnegative(),seatCountsByType:Mv,extraUsage:Fv,members:I(Iv),allowedDomains:I(O()),advancedModels:Lv,chatbotSettings:zv,managedAgentEnabled:P(),autopilotEnabled:P(),branding:Bv.nullable(),createdAt:H(),updatedAt:H()}),L({allowedDomains:I(Av).max(50)}),L({enabled:P(),modelIds:I(O().trim().min(1).max(200)).max(100)}),L({enabled:P()}),L({enabled:P()});const Vv=L({id:j(),userId:j(),workspaceId:j(),year:N(),month:N(),totalCost:O(),operationCount:N(),createdAt:H(),updatedAt:H(),user:L({id:j(),name:O(),email:O()}),budgetOverride:L({budget:O().nullable()}).nullable().optional()});ml.extend({search:O().trim().max(200).optional()}),L({monthlyUsages:I(Vv),nextKey:O().optional()});const Hv=[`apiUrl`,`hubUrl`];function Uv(e){let t=$.getEffectiveProfileName(e);return $.getProfileConfigFile(t)}function Z(e){let t=Uv(e);try{if(!n.existsSync(t))return{};let e=n.readFileSync(t,`utf-8`);return JSON.parse(e)}catch{return{}}}function Wv(e,t){let r=$.getEffectiveProfileName(t);$.ensureProfileDir(r);let i=$.getProfileConfigFile(r);n.writeFileSync(i,JSON.stringify(e,null,2),{mode:384});try{n.chmodSync(i,384)}catch{}}const Gv={getApiUrl(e){return Z(e).apiUrl??null},setApiUrl(e,t){let n=Z(t);n.apiUrl=e,Wv(n,t)},clearApiUrl(e){let t=Z(e);delete t.apiUrl,Wv(t,e)},getHubUrl(e){return Z(e).hubUrl??null},setHubUrl(e,t){let n=Z(t);n.hubUrl=e,Wv(n,t)},getAll(e){return Z(e)},setAll(e,t){Wv(e,t)},set(e,t,n){let r=Z(n);r[e]=t,Wv(r,n)},get(e,t){return Z(t)[e]},unset(e,t){let n=Z(t);delete n[e],Wv(n,t)},getDefaultModel(e){return Z(e).model?.default??null},setDefaultModel(e,t){let n=Z(t);n.model={...n.model,default:e},Wv(n,t)},getDefaultConnectorIds(e){return Z(e).connectors?.defaults??null},setDefaultConnectorIds(e,t){let n=Z(t);n.connectors={...n.connectors,defaults:e},Wv(n,t)},getLocalTools(e){return Z(e).localTools??null},setLocalTools(e,t){let n=Z(t);n.localTools={...n.localTools,...e},Wv(n,t)},getToolApprovalMode(e){let t=jd.safeParse(Z(e).toolApprovalMode);return t.success?t.data:null},setToolApprovalMode(e,t){let n=Z(t);n.toolApprovalMode=e,Wv(n,t)},clearToolApprovalMode(e){let t=Z(e);delete t.toolApprovalMode,Wv(t,e)}},Kv=`ENTRYDESK_MCP_TIMEOUT`,qv=`ENTRYDESK_MCP_MAX_TIMEOUT`;function Jv(e,t){let n=process.env[e];if(!n)return t;let r=Number(n);return Number.isSafeInteger(r)&&r>0?Math.min(r,2147483647):t}function Yv(e){let t=Jv(Kv,3e5);return{apiUrl:process.env.ENTRYDESK_API_URL||Gv.getApiUrl(e)||`https://api.entrydesk.com`,hubUrl:process.env.ENTRYDESK_HUB_URL||Gv.getHubUrl(e)||`https://app.entrydesk.com`,mcp:{httpPort:3100,requestTimeout:t,requestMaxTotalTimeout:Math.max(Jv(qv,18e5),t)},auth:{loginTimeout:3e5,ignoreSslErrors:process.env.ENTRYDESK_IGNORE_SSL_ERRORS===`true`||!1}}}function Xv(e){return Yv(e).apiUrl}function Zv(e){return Yv(e).hubUrl}function Qv(e,t){return`${Zv(t).replace(/\/$/u,``)}${e}`}function $v(){return Yv().auth}function ey(){return Yv().mcp}function ty(e){if(typeof e!=`object`||!e)return{error:``};let t=e;return{code:typeof t.code==`string`?t.code:void 0,error:typeof t.error==`string`?t.error:``}}const ny=/^[a-z0-9_.-]{1,64}$/iu;function ry(e){let t=ty(e).code;return t&&ny.test(t)?t:void 0}function iy(e){return[...e].filter(e=>{let t=e.codePointAt(0)??0;return!(t<=31)&&t!==127&&!(t>=128&&t<=159)}).join(``)}const ay=`EntryDesk CLI`,oy={keychain:!1,permissions:!1,corruptFile:!1,windowsFile:!1};function sy(e,t){oy[e]||(oy[e]=!0,console.error(t))}function cy(){return process.env.ENTRYDESK_DEBUG?.toLowerCase()===`true`}function ly(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(!(`accessToken`in t||`refreshToken`in t||`email`in t||`workspaceId`in t)||`accessToken`in t&&typeof t.accessToken!=`string`||`refreshToken`in t&&typeof t.refreshToken!=`string`||`email`in t&&typeof t.email!=`string`||`workspaceId`in t&&typeof t.workspaceId!=`string`)}function uy(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.getPassword==`function`&&typeof t.setPassword==`function`&&typeof t.deletePassword==`function`}function dy(e){return $.getProfileCredentialsFile(e)}var fy=class{getKeyFilePath(e){return i.join($.getProfileDir(e),`.credentials.key`)}loadEncryptionKey(e){let t=this.getKeyFilePath(e);try{if(!n.existsSync(t))return null;let e=n.readFileSync(t);return e.length===32?(this.ensureSecureFilePermissions(t),e):null}catch{return null}}createEncryptionKey(e){$.ensureProfileDir(e);let t=this.getKeyFilePath(e),r=u.randomBytes(32);return n.writeFileSync(t,r,{mode:384}),this.ensureSecureFilePermissions(t),r}getOrCreateEncryptionKey(e){return this.loadEncryptionKey(e)||this.createEncryptionKey(e)}encrypt(e,t){let n=u.randomBytes(16),r=u.createCipheriv(`aes-256-gcm`,t,n),i=r.update(e,`utf8`,`hex`);i+=r.final(`hex`);let a=r.getAuthTag();return`${n.toString(`hex`)}:${a.toString(`hex`)}:${i}`}decrypt(e,t){let n=e.split(`:`);if(n.length!==3)throw Error(`Invalid encrypted data format`);let r=Buffer.from(n[0],`hex`),i=Buffer.from(n[1],`hex`),a=n[2],o=u.createDecipheriv(`aes-256-gcm`,t,r,{authTagLength:16});o.setAuthTag(i);let s=o.update(a,`hex`,`utf8`);return s+=o.final(`utf8`),s}tryDecrypt(e,t){try{return this.decrypt(e,t)}catch{return null}}tryParseCredentials(e){try{let t=JSON.parse(e);return ly(t)?t:null}catch{return null}}ensureSecureFilePermissions(e){if(process.platform!==`win32`){try{n.chmodSync(e,384)}catch{sy(`permissions`,`Warning: Failed to set secure permissions on credentials file.`);return}try{(n.statSync(e).mode&511)!=384&&sy(`permissions`,`Warning: Credentials file permissions are too permissive.`)}catch{sy(`permissions`,`Warning: Failed to verify credentials file permissions.`)}}}async getCredentials(e){let t=dy(e);try{if(!n.existsSync(t))return null;let r=n.readFileSync(t,`utf-8`).trim();if(!r)return null;let i=this.loadEncryptionKey(e),a=i?this.tryDecrypt(r,i):null;if(a){let e=this.tryParseCredentials(a);if(e)return e}return sy(`corruptFile`,"Warning: Credentials file is unreadable. Run `entrydesk login` again."),null}catch{return null}}async setCredentials(e,t){$.ensureProfileDir(e);let r=dy(e),i=this.getOrCreateEncryptionKey(e),a=this.encrypt(JSON.stringify(t),i);n.writeFileSync(r,a,{mode:384}),this.ensureSecureFilePermissions(r)}async deleteCredentials(e){let t=dy(e);try{n.existsSync(t)&&n.unlinkSync(t)}catch{}}},py=class{keytarModule=null;keytarLoadAttempted=!1;keychainAvailable=null;async getKeytar(){if(this.keytarLoadAttempted)return this.keytarModule;this.keytarLoadAttempted=!0;try{let e=await import(`keytar`),t=e&&typeof e==`object`&&`default`in e?e.default:e;this.keytarModule=uy(t)?t:null}catch{this.keytarModule=null}return this.keytarModule}getAccount(e){return`profile:${e}`}async checkKeychainAvailability(){if(this.keychainAvailable!==null)return this.keychainAvailable;try{let e=await this.getKeytar();if(!e)return this.keychainAvailable=!1,!1;let t=`__entrydesk_keychain_test__${u.randomBytes(8).toString(`hex`)}`,n=`test`;await e.setPassword(ay,t,n);let r=await e.getPassword(ay,t),i=await e.deletePassword(ay,t);return this.keychainAvailable=i&&r===n,this.keychainAvailable}catch{return this.keychainAvailable=!1,!1}}async isAvailable(){return this.checkKeychainAvailability()}async getCredentials(e){if(!await this.checkKeychainAvailability())throw Error(`Keychain is not available`);let t=await this.getKeytar();if(!t)throw Error(`Keytar module not available`);let n=await t.getPassword(ay,this.getAccount(e));if(!n)return null;let r=this.tryParseKeychainPayload(n);return r||sy(`corruptFile`,`Warning: Keychain entry for profile "${e}" is unreadable.`),r}async setCredentials(e,t){if(!await this.checkKeychainAvailability())throw Error(`Keychain is not available`);let n=await this.getKeytar();if(!n)throw Error(`Keytar module not available`);let r=JSON.stringify(t);await n.setPassword(ay,this.getAccount(e),r)}async deleteCredentials(e){if(!await this.checkKeychainAvailability())throw Error(`Keychain is not available`);let t=await this.getKeytar();if(!t)throw Error(`Keytar module not available`);await t.deletePassword(ay,this.getAccount(e))}tryParseKeychainPayload(e){try{let t=JSON.parse(e);return ly(t)?t:null}catch{return null}}};const Q=new class{keychainStorage=null;fileStorage=new fy;keychainAvailable=null;initPromise=null;shouldForceFileStorage(){return process.env.ENTRYDESK_FORCE_FILE_STORAGE?.toLowerCase()===`true`}async initializeStorage(){if(this.shouldForceFileStorage()){this.keychainAvailable=!1,this.keychainStorage=null;return}try{let e=new py,t=await e.isAvailable();this.keychainAvailable=t,this.keychainStorage=t?e:null}catch{this.keychainAvailable=!1,this.keychainStorage=null}!this.keychainAvailable&&!this.shouldForceFileStorage()&&(cy()&&sy(`keychain`,`Keychain unavailable. Falling back to file-based credentials.`),process.platform===`win32`&&sy(`windowsFile`,`Warning: File-based credentials on Windows may be readable by other users.`))}async ensureInitialized(){if(this.shouldForceFileStorage()){this.keychainAvailable=!1,this.keychainStorage=null;return}this.keychainAvailable===null&&(this.initPromise??=this.initializeStorage(),await this.initPromise)}disableKeychain(){this.shouldForceFileStorage()||sy(`keychain`,`Keychain error encountered. Falling back to file-based credentials.`),this.keychainAvailable=!1,this.keychainStorage=null}async getKeychainStorage(){return await this.ensureInitialized(),this.shouldForceFileStorage()?null:this.keychainAvailable?this.keychainStorage:null}async getCredentials(e){let t=await this.getKeychainStorage();if(!t)return this.fileStorage.getCredentials(e);try{let n=await t.getCredentials(e);if(n)return n}catch{return this.disableKeychain(),this.fileStorage.getCredentials(e)}let n=await this.fileStorage.getCredentials(e);if(n)try{await t.setCredentials(e,n),await this.fileStorage.deleteCredentials(e)}catch{}return n}async setCredentials(e,t){let n=await this.getKeychainStorage();if(!n){await this.fileStorage.setCredentials(e,t);return}try{await n.setCredentials(e,t),await this.fileStorage.deleteCredentials(e)}catch{this.disableKeychain(),await this.fileStorage.setCredentials(e,t)}}async deleteCredentials(e){let t=await this.getKeychainStorage();if(t)try{await t.deleteCredentials(e)}catch{this.disableKeychain()}await this.fileStorage.deleteCredentials(e)}},my={async saveAccessToken(e,t){let n=$.getEffectiveProfileName(t),r=await Q.getCredentials(n)??{};r.accessToken=e,await Q.setCredentials(n,r)},async getAccessToken(e){let t=$.getEffectiveProfileName(e);return(await Q.getCredentials(t))?.accessToken??null},async saveRefreshToken(e,t){let n=$.getEffectiveProfileName(t),r=await Q.getCredentials(n)??{};r.refreshToken=e,await Q.setCredentials(n,r)},async getRefreshToken(e){let t=$.getEffectiveProfileName(e);return(await Q.getCredentials(t))?.refreshToken??null},async saveEmail(e,t){let n=$.getEffectiveProfileName(t),r=await Q.getCredentials(n)??{};r.email=e,await Q.setCredentials(n,r)},async getEmail(e){let t=$.getEffectiveProfileName(e);return(await Q.getCredentials(t))?.email??null},async saveWorkspaceId(e,t){let n=$.getEffectiveProfileName(t),r=await Q.getCredentials(n)??{};r.workspaceId=e,await Q.setCredentials(n,r)},async getWorkspaceId(e){let t=$.getEffectiveProfileName(e);return(await Q.getCredentials(t))?.workspaceId??null},async saveAll(e,t){let n=$.getEffectiveProfileName(t);await Q.setCredentials(n,e)},async getAll(e){let t=$.getEffectiveProfileName(e);return Q.getCredentials(t)},async clear(e){let t=$.getEffectiveProfileName(e);await Q.deleteCredentials(t)},async moveProfileCredentials(e,t){let n=await Q.getCredentials(e);n&&(await Q.setCredentials(t,n),await Q.deleteCredentials(e))},async deleteProfileCredentials(e){await Q.deleteCredentials(e)},async isLoggedIn(e){let t=$.getEffectiveProfileName(e);return(await Q.getCredentials(t))?.accessToken!=null}};function hy(){let e=process.env.X_WEB_PROXY_ID;return e?{"x-web-proxy-id":e}:{}}function gy(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return;let{code:n}=t;return typeof n==`string`?n:void 0}catch{return}}function _y(e){return{...e,title:iy(e.title),...e.project&&{project:{...e.project,name:iy(e.project.name)}}}}function vy(e){return{...e,tasks:e.tasks.map(_y)}}function yy(e){return{...e,results:e.results.map(e=>({...e,title:iy(e.title),titleHighlight:e.titleHighlight&&iy(e.titleHighlight),contentSnippet:e.contentSnippet&&iy(e.contentSnippet)}))}}var by=class extends Error{status;code;constructor(e,t){super(`Task API failed (${e}): ${t}`),this.status=e,this.name=`TaskApiError`,this.code=gy(t)}},xy=class e{client;baseUrl;runtimeConfigCache;constructor(e,t){this.baseUrl=e||Xv(t),$v().ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED=`0`,process.env.DEBUG&&console.log(`[DEBUG] ApiClient: SSL certificate validation disabled`)),this.client=a.create({baseUrl:this.baseUrl.replace(/\/?$/,`/`),timeout:3e4,headers:hy(),retry:{limit:3,methods:[`get`,`put`,`head`,`delete`,`options`,`trace`],statusCodes:[408,413,429,500,502,503,504]},hooks:{beforeError:[({error:e})=>(c(e)&&(e.request.headers.delete(`authorization`),e.request.headers.delete(`Authorization`),e.request.headers.delete(`x-web-proxy-id`)),e)]}})}getBaseUrl(){return this.baseUrl}async refreshOAuthToken(e){return this.client.post(`v1/oauth/token`,{json:{grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:e.clientId}}).json()}async revokeOAuthToken(e){await this.client.post(`v1/oauth/revoke`,{json:{token:e.token,token_type_hint:`refresh_token`,client_id:e.clientId}})}async getWorkspaces(e){try{return process.env.DEBUG&&console.log(`[DEBUG] Calling getWorkspaces API: ${this.baseUrl}/v1/workspaces`),await this.client.get(`v1/workspaces`,{headers:{Authorization:`Bearer ${e}`}}).json()}catch(e){throw process.env.DEBUG&&(console.error(`[DEBUG] getWorkspaces error:`,e),e instanceof Error&&`cause`in e&&console.error(`[DEBUG] Error cause:`,e.cause)),e}}async getAgents(e,t,n){let r={limit:n?.limit??100};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),await this.client.get(`v1/workspaces/${t}/availableAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async createAgent(e,t,n){return await this.client.post(`v1/workspaces/${t}/agents`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async updateAgent(e,t,n,r){await this.client.put(`v1/workspaces/${t}/agents/${n}`,{headers:{Authorization:`Bearer ${e}`},json:r})}async deleteAgent(e,t,n){await this.client.delete(`v1/workspaces/${t}/agents/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getMyAgents(e,t,n){let r={limit:n?.limit??100};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),await this.client.get(`v1/workspaces/${t}/myAgents`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async publishAgent(e,t,n){await this.client.post(`v1/workspaces/${t}/agents/${n}/publish`,{headers:{Authorization:`Bearer ${e}`}})}async getAgentGrants(e,t,n){return await this.client.get(`v1/workspaces/${t}/agents/${n}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertAgentGrant(e,t,n,r,i){return await this.client.put(`v1/workspaces/${t}/agents/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeAgentGrant(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/agents/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async getMeetings(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),n?.filter&&(r.filter=n.filter),n?.sortBy&&(r.sortBy=n.sortBy),await this.client.get(`v1/workspaces/${t}/meetings`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getMeeting(e,t,n){return await this.client.get(`v1/workspaces/${t}/meetings/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createMeeting(e,t,n){return await this.client.post(`v1/workspaces/${t}/meetings`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async updateMeeting(e,t,n,r){return await this.client.patch(`v1/workspaces/${t}/meetings/${n}`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async deleteMeeting(e,t,n){await this.client.delete(`v1/workspaces/${t}/meetings/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getMeetingPreviousBrief(e,t,n){return await this.client.get(`v1/workspaces/${t}/meetings/${n}/previous`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getRecording(e,t,n){return await this.client.get(`v1/workspaces/${t}/recordings/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getMeetingShares(e,t,n){return await this.client.get(`v1/workspaces/${t}/meetings/${n}/shares`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertMeetingUserGrant(e,t,n,r,i){return await this.client.put(`v1/workspaces/${t}/meetings/${n}/shares/users/${r}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeMeetingUserGrant(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/meetings/${n}/shares/users/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async upsertMeetingTeamGrant(e,t,n,r,i){return await this.client.put(`v1/workspaces/${t}/meetings/${n}/shares/teams/${r}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeMeetingTeamGrant(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/meetings/${n}/shares/teams/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async getWorkflows(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),await this.client.get(`v1/workspaces/${t}/workflows`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getWorkflow(e,t,n){return await this.client.get(`v1/workspaces/${t}/workflows/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createWorkflow(e,t,n){return await this.client.post(`v1/workspaces/${t}/workflows`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async updateWorkflow(e,t,n,r){await this.client.put(`v1/workspaces/${t}/workflows/${n}`,{headers:{Authorization:`Bearer ${e}`},json:r})}async triggerWorkflowRun(e,t,n,r){return await this.client.post(`v1/workspaces/${t}/workflows/${n}/runs`,{headers:{Authorization:`Bearer ${e}`},json:r===void 0?{}:{args:r}}).json()}async getWorkflowRuns(e,t,n,r){let i={limit:r?.limit??20};return r?.nextKey&&(i.nextKey=r.nextKey),await this.client.get(`v1/workspaces/${t}/workflows/${n}/runs`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async getWorkflowRun(e,t,n,r){return await this.client.get(`v1/workspaces/${t}/workflows/${n}/runs/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getWorkflowGrants(e,t,n){return await this.client.get(`v1/workspaces/${t}/workflows/${n}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertWorkflowGrant(e,t,n,r,i){return await this.client.put(`v1/workspaces/${t}/workflows/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeWorkflowGrant(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/workflows/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async listProjects(e,t,n){let r={limit:n.limit};return n.nextKey&&(r.nextKey=n.nextKey),n.filter&&(r.filter=n.filter),this.client.get(`v1/workspaces/${t}/projects`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getProject(e,t,n){return this.client.get(`v1/workspaces/${t}/projects/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async updateProject(e,t,n,r){return this.client.patch(`v1/workspaces/${t}/projects/${n}`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async createProjectNote(e,t,n,r){return this.client.post(`v1/workspaces/${t}/projects/${n}/notes`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async createProject(e,t,n){return this.client.post(`v1/workspaces/${t}/projects`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async deleteProject(e,t,n){await this.client.delete(`v1/workspaces/${t}/projects/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async addProjectMember(e,t,n,r){return this.client.post(`v1/workspaces/${t}/projects/${n}/members`,{headers:{Authorization:`Bearer ${e}`},json:{userId:r}}).json()}async updateProjectMemberRole(e,t,n,r,i){await this.client.patch(`v1/workspaces/${t}/projects/${n}/members/${r}`,{headers:{Authorization:`Bearer ${e}`},json:i})}async removeProjectMember(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/projects/${n}/members/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async listProjectFiles(e,t,n){return this.client.get(`v1/workspaces/${t}/projects/${n}/files`,{headers:{Authorization:`Bearer ${e}`}}).json()}async listProjectLinks(e,t,n){return this.client.get(`v1/workspaces/${t}/projects/${n}/links`,{headers:{Authorization:`Bearer ${e}`}}).json()}async searchProjectContext(e,t,n,r){let i={q:r.q};return r.type&&(i.type=r.type),r.limit!==void 0&&(i.limit=r.limit),this.client.get(`v1/workspaces/${t}/projects/${n}/context/search`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async readProjectContext(e,t,n,r,i){let a={depth:i.depth};return i.offset!==void 0&&(a.offset=i.offset),this.client.get(`v1/workspaces/${t}/projects/${n}/context/${r.sourceType}/${encodeURIComponent(r.sourceId)}`,{headers:{Authorization:`Bearer ${e}`},searchParams:a}).json()}async assignTaskProject(e,t,n,r){return this.client.put(`v1/workspaces/${t}/tasks/${n}/project`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async grantTaskShareMember(e,t,n,r){let{data:i}=await this.client.put(`v1/workspaces/${t}/tasks/${n}/shares/members/${r}`,{headers:{Authorization:`Bearer ${e}`}}).json();return{...i,name:iy(i.name),email:iy(i.email)}}async revokeTaskShareMember(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/tasks/${n}/shares/members/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async upsertTaskShare(e,t,n,r){return this.client.post(`v1/workspaces/${t}/tasks/${n}/shares`,{headers:{Authorization:`Bearer ${e}`},json:{visibility:r}}).json()}async attachProjectFile(e,t,n,r){return this.client.post(`v1/workspaces/${t}/projects/${n}/files`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateProjectFileDescription(e,t,n,r,i){return this.client.patch(`v1/workspaces/${t}/projects/${n}/files/${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`},json:i}).json()}async removeProjectFile(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/projects/${n}/files/${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`}})}async addProjectLink(e,t,n,r){return this.client.post(`v1/workspaces/${t}/projects/${n}/links`,{headers:{Authorization:`Bearer ${e}`},json:r}).json()}async updateProjectLinkDescription(e,t,n,r,i){return this.client.patch(`v1/workspaces/${t}/projects/${n}/links/${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`},json:i}).json()}async removeProjectLink(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/projects/${n}/links/${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`}})}async refetchProjectLink(e,t,n,r){return this.client.post(`v1/workspaces/${t}/projects/${n}/links/${encodeURIComponent(r)}/refetch`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getNotifications(e,t,n){let r={limit:n?.limit??20};return n?.tab&&(r.tab=n.tab),n?.eventType&&(r.eventType=n.eventType),n?.cursor&&(r.cursor=n.cursor),await this.client.get(`v1/workspaces/${t}/notifications`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getNotificationUnreadCount(e,t){return await this.client.get(`v1/workspaces/${t}/notifications/unreadCount`,{headers:{Authorization:`Bearer ${e}`}}).json()}async markNotificationRead(e,t,n){await this.client.post(`v1/workspaces/${t}/notifications/${n}/read`,{headers:{Authorization:`Bearer ${e}`}})}async markAllNotificationsRead(e,t){await this.client.post(`v1/workspaces/${t}/notifications/readAll`,{headers:{Authorization:`Bearer ${e}`}})}async getRuntimeConfig(){if(this.runtimeConfigCache)return this.runtimeConfigCache;let e=await this.client.get(`v1/runtimeConfig`).json();return this.runtimeConfigCache=e,e}async getModels(e,t){return await this.client.get(`v1/workspaces/${t}/models`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getWorkspaceConfig(e,t){return await this.client.get(`v1/workspaces/${t}/config`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getModelTiers(e,t){return await this.client.get(`v1/workspaces/${t}/modelTiers`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getModelTierMappings(e,t){return await this.client.get(`v1/workspaces/${t}/modelTierMappings`,{headers:{Authorization:`Bearer ${e}`}}).json()}async listSelectableModels(e,t){let{deploymentMode:n}=await this.getRuntimeConfig(),{models:r}=n===`saas`?await this.getModelTiers(e,t):await this.getModels(e,t);return{models:r.filter(e=>e.enabled!==!1)}}async getConnectors(e,t,n){let r={limit:n?.limit??100,connectionStatus:n?.connectionStatus??`connected`};return n?.search&&(r.search=n.search),n?.nextKey&&(r.nextKey=n.nextKey),await this.client.get(`v1/workspaces/${t}/availableConnectors`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getConnectorTools(e,t,n){return this.client.get(`v1/workspaces/${t}/connectors/${n}/tools`,{headers:{Authorization:`Bearer ${e}`}}).json()}async connectConnectorToken(e,t,n,r){await this.client.put(`v1/workspaces/${t}/connectors/${n}/token`,{headers:{Authorization:`Bearer ${e}`},json:r})}async getConnectorAuthUrl(e,t,n){return this.client.post(`v1/workspaces/${t}/connectors/${n}/authUrl`,{headers:{Authorization:`Bearer ${e}`},json:{}}).json()}async createCustomConnector(e,t,n){return this.client.post(`v1/workspaces/${t}/customConnectors`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async disconnectConnector(e,t,n){await this.client.delete(`v1/workspaces/${t}/connectors/${n}/token`,{headers:{Authorization:`Bearer ${e}`}})}async getTasks(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),this.client.get(n?.projectId?`v1/workspaces/${t}/projects/${n.projectId}/tasks`:`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json().then(vy)}async searchTasks(e,t,n,r){let i={q:n,limit:r?.limit??20};return r?.nextKey&&(i.nextKey=r.nextKey),r?.projectId&&(i.projectId=r.projectId),yy(await this.client.get(`v1/workspaces/${t}/tasks/search`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json())}async getMessages(e,t,n,r=50){return await this.client.get(`v1/workspaces/${t}/tasks/${n}/messages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{limit:r}}).json()}async getAgent(e,t,n){return await this.client.get(`v1/workspaces/${t}/agents/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getAgentVersionByNumber(e,t,n,r){return(await this.client.get(`v1/workspaces/${t}/agents/${n}/versions`,{headers:{Authorization:`Bearer ${e}`},searchParams:{versionNumber:r,limit:1}}).json()).versions.at(0)}async listAvailableSkills(e,t,n){return await this.client.get(`v1/workspaces/${t}/availableSkills`,{headers:{Authorization:`Bearer ${e}`},searchParams:{createdBy:n?.createdBy,nextKey:n?.nextKey,limit:n?.limit??20}}).json()}async uploadSkill(e,t,n){return await this.client.post(`v1/workspaces/${t}/skills`,{headers:{Authorization:`Bearer ${e}`},body:n}).json()}async deleteSkill(e,t,n){await this.client.delete(`v1/workspaces/${t}/skills/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async updateSkillPreference(e,t,n,r){return await this.client.patch(`v1/workspaces/${t}/skills/${n}/preference`,{headers:{Authorization:`Bearer ${e}`},json:{isEnabled:r}}).json()}async getSkillVersions(e,t,n){return await this.client.get(`v1/workspaces/${t}/skills/${n}/versions`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getSkillGrants(e,t,n){return await this.client.get(`v1/workspaces/${t}/skills/${n}/grants`,{headers:{Authorization:`Bearer ${e}`}}).json()}async upsertSkillGrant(e,t,n,r,i){return await this.client.put(`v1/workspaces/${t}/skills/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`},json:{role:i}}).json()}async removeSkillGrant(e,t,n,r){await this.client.delete(`v1/workspaces/${t}/skills/${n}/grants/${r}`,{headers:{Authorization:`Bearer ${e}`}})}async downloadSkillCurrent(e,t,n){return await this.client.get(`v1/workspaces/${t}/skills/${n}/download`,{headers:{Authorization:`Bearer ${e}`}}).json()}async task(e,t,n,r){try{let i=await this.client.post(`v1/workspaces/${t}/tasks`,{headers:{Authorization:`Bearer ${e}`},json:n,timeout:6e4,throwHttpErrors:!1});if(!i.ok){let e=await i.text();throw new by(i.status,e)}let a=await i.json();return r?.(),a.noop||!a.streamId?new Response(`data: [DONE]
57
+
58
+ `,{headers:{"Content-Type":`text/event-stream`}}):await this.taskStream(e,t,a.taskId)}catch(e){throw e instanceof s?TypeError(`Request timed out. Check your connection and try again.`,{cause:e}):e}}async taskStream(e,t,n){let r=await this.client.get(`v1/workspaces/${t}/tasks/${n}/stream`,{headers:{Authorization:`Bearer ${e}`,Accept:`text/event-stream`},timeout:!1,throwHttpErrors:!1});if(!r.ok){let e=await r.text();throw Error(`Task stream failed (${r.status}): ${e}`)}return r}resumeTaskStream(e,t,n){return this.taskStream(e,t,n)}async getSubagentRun(e,t,n,r){return this.client.get(`v1/workspaces/${t}/subagentRuns/${n}`,{headers:{Authorization:`Bearer ${e}`},signal:r}).json()}async openSubagentRunEvents(e,t,n,r){let i=await this.client.get(`v1/workspaces/${t}/subagentRuns/${n}/events`,{headers:{Authorization:`Bearer ${e}`,Accept:`text/event-stream`},timeout:!1,throwHttpErrors:!1,signal:r});if(!i.ok){let e=await i.text();throw Error(`Subagent run events stream failed (${i.status}): ${e}`)}return i}async listBackgroundRuns(e,t,n){return this.client.get(`v1/workspaces/${t}/tasks/${n}/backgroundRuns`,{headers:{Authorization:`Bearer ${e}`}}).json()}async stopBackgroundRun(e,t,n,r,i){let a=z_(i);return(await this.client.post(`v1/workspaces/${t}/tasks/${n}/${a}/${r}/stop`,{headers:{Authorization:`Bearer ${e}`}})).status===202?`stopping`:`already-finished`}async openWakeEvents(e,t,n,r){let i=await this.client.get(`v1/workspaces/${t}/tasks/${n}/wakeEvents`,{headers:{Authorization:`Bearer ${e}`,Accept:`text/event-stream`},timeout:!1,throwHttpErrors:!1,signal:r});if(!i.ok){let e=await i.text();throw Error(`Wake events stream failed (${i.status}): ${e}`)}return i}async getBudget(e,t){return await this.client.get(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`}}).json()}async updateBudget(e,t,n){await this.client.put(`v1/workspaces/${t}/budget`,{headers:{Authorization:`Bearer ${e}`},json:{budget:n}})}async getMonthlyUsages(e,t,n){return await this.client.get(`v1/workspaces/${t}/monthlyUsages`,{headers:{Authorization:`Bearer ${e}`},searchParams:{nextKey:n?.nextKey,limit:n?.limit??20}}).json()}async getBillingOverview(e,t){return await this.client.get(`v1/workspaces/${t}/billing/overview`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getBillingInvoices(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),await this.client.get(`v1/workspaces/${t}/billing/invoices`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getUsageOverview(e,t){return await this.client.get(`v1/workspaces/${t}/usage/overview`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getUsageMe(e,t){return await this.client.get(`v1/workspaces/${t}/usage/me`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getUsageConsumptions(e,t,n){let r={limit:n?.limit??20,offset:n?.offset??0};return n?.periodStart&&(r.periodStart=n.periodStart),await this.client.get(`v1/workspaces/${t}/usage/consumptions`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async exportUsageCsv(e,t,n){let r={};return n&&(r.periodStart=n),await this.client.get(`v1/workspaces/${t}/usage/export`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).text()}async createTaskShare(e,t,n,r=`public`){try{return await this.upsertTaskShare(e,t,n,r)}catch(e){if(c(e)&&e.response.status===403){let t=await e.response.json().catch(()=>null);if(t?.code===`sharing_disabled`)throw Error(`Sharing is turned off for this workspace by an admin.`,{cause:e});if(t?.code===`share_visibility_not_allowed`)throw Error(`Public sharing is turned off for this workspace by an admin.`,{cause:e})}throw e}}async getSharedTask(e,t){let n={};return t&&(n.Authorization=`Bearer ${t}`),await this.client.get(`v1/shares/${e}`,{headers:n}).json()}async getSharedMessages(e,t=50,n){let r={};return n&&(r.Authorization=`Bearer ${n}`),await this.client.get(`v1/shares/${e}/messages`,{headers:r,searchParams:{limit:t}}).json()}async getTask(e,t,n){return this.client.get(`v1/workspaces/${t}/tasks/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json().then(_y)}async updateTaskToolApprovalMode(e,t,n,r){await this.client.patch(`v1/workspaces/${t}/tasks/${n}/toolApprovalMode`,{headers:{Authorization:`Bearer ${e}`},json:{toolApprovalMode:r}})}async deleteTask(e,t,n){await this.client.delete(`v1/workspaces/${t}/tasks/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async getModelProviders(e,t){return await this.client.get(`v1/workspaces/${t}/modelProviders`,{headers:{Authorization:`Bearer ${e}`}}).json()}async uploadFile(e,t,n,r){let i=new FormData,a=new Blob([n.buffer],{type:n.mimeType});return i.append(`file`,a,n.filename),i.append(`modelProviderId`,r),await this.client.post(`v1/workspaces/${t}/files`,{headers:{Authorization:`Bearer ${e}`},body:i,timeout:12e4}).json()}async getCalendarAccounts(e,t){return await this.client.get(`v1/workspaces/${t}/calendar/accounts`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getSchedules(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),await this.client.get(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getSchedule(e,t,n){return await this.client.get(`v1/workspaces/${t}/schedules/${n}`,{headers:{Authorization:`Bearer ${e}`}}).json()}async createSchedule(e,t,n){return await this.client.post(`v1/workspaces/${t}/schedules`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async updateSchedule(e,t,n,r){await this.client.put(`v1/workspaces/${t}/schedules/${n}`,{headers:{Authorization:`Bearer ${e}`},json:r})}async deleteSchedule(e,t,n){await this.client.delete(`v1/workspaces/${t}/schedules/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async activateSchedule(e,t,n){await this.client.post(`v1/workspaces/${t}/schedules/${n}/activate`,{headers:{Authorization:`Bearer ${e}`}})}async deactivateSchedule(e,t,n){await this.client.post(`v1/workspaces/${t}/schedules/${n}/deactivate`,{headers:{Authorization:`Bearer ${e}`}})}async runScheduleNow(e,t,n){return await this.client.post(`v1/workspaces/${t}/schedules/${n}/run`,{headers:{Authorization:`Bearer ${e}`}}).json()}async getScheduleRuns(e,t,n,r){let i={limit:r?.limit??20};return r?.nextKey&&(i.nextKey=r.nextKey),await this.client.get(`v1/workspaces/${t}/schedules/${n}/runs`,{headers:{Authorization:`Bearer ${e}`},searchParams:i}).json()}async listRecordings(e,t,n){let r={limit:n?.limit??20};return n?.nextKey&&(r.nextKey=n.nextKey),n?.search&&(r.search=n.search),this.client.get(`v1/workspaces/${t}/recordings`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async importRecordingMedia(e,t,n){return this.client.post(`v1/workspaces/${t}/recordings/import/media`,{headers:{Authorization:`Bearer ${e}`},json:n}).json()}async previewRecordingMedia(e,t,n){let r={url:n};return this.client.get(`v1/workspaces/${t}/recordings/preview/media`,{headers:{Authorization:`Bearer ${e}`},searchParams:r}).json()}async getRecordingAudioUrl(e,t,n){return this.client.get(`v1/workspaces/${t}/recordings/${n}/audioUrl`,{headers:{Authorization:`Bearer ${e}`}}).json()}async retryRecording(e,t,n){return this.client.post(`v1/workspaces/${t}/recordings/${n}/retry`,{headers:{Authorization:`Bearer ${e}`}}).json()}async deleteRecording(e,t,n){await this.client.delete(`v1/workspaces/${t}/recordings/${n}`,{headers:{Authorization:`Bearer ${e}`}})}async searchMarketplace(e){let t={};return e?.type&&(t.type=e.type),e?.tag&&(t.tag=e.tag),e?.limit&&(t.limit=e.limit),e?.cursor&&(t.cursor=e.cursor),this.client.get(`v1/marketplace/resources`,{searchParams:t}).json()}async getMarketplaceAgent(e){return this.client.get(`v1/marketplace/agents/${encodeURIComponent(e)}`).json()}async getMarketplaceSkill(e){return this.client.get(`v1/marketplace/skills/${encodeURIComponent(e)}`).json()}async listMarketplaceRoles(){return this.client.get(`v1/marketplace/roles`).json()}async installMarketplaceResource(e,t,n,r,i){return this.client.post(`v1/workspaces/${t}/marketplace/${n}s/${encodeURIComponent(r)}/install`,{headers:{Authorization:`Bearer ${e}`},json:{toolApprovalMode:i}}).json()}static async getAuthenticatedClient(t){let n=await my.getAll(t);return n?{client:new e(void 0,t),accessToken:n.accessToken,workspaceId:n.workspaceId??null}:null}};function Sy(){return process.env.ENTRYDESK_SANDBOX===`true`}function Cy(){if(!Sy())return null;let e=process.env.ENTRYDESK_SANDBOX_ACCESS_TOKEN?.trim(),t=process.env.ENTRYDESK_SANDBOX_WORKSPACE_ID?.trim();if(!e||!t){let n=[];throw e||n.push(`ENTRYDESK_SANDBOX_ACCESS_TOKEN`),t||n.push(`ENTRYDESK_SANDBOX_WORKSPACE_ID`),Error(`Sandbox mode enabled but missing credentials: ${n.join(`, `)}`)}return{accessToken:e,workspaceId:t}}function wy(){return!!process.env.ENTRYDESK_TOKEN?.trim()}function Ty(){let e=process.env.ENTRYDESK_TOKEN?.trim();if(!e)return null;let t=process.env.ENTRYDESK_WORKSPACE_ID?.trim();if(!t)throw Error(`ENTRYDESK_TOKEN is set but ENTRYDESK_WORKSPACE_ID is missing. Both are required for PAT authentication.`);return{accessToken:e,workspaceId:t}}const Ey=`sandbox environment (ENTRYDESK_SANDBOX)`;function Dy(){let e=Cy();if(e)return{authSource:`sandbox-env`,label:Ey,workspaceId:e.workspaceId};let t=Ty();return t?{authSource:`pat-env`,label:`personal access token (ENTRYDESK_TOKEN)`,workspaceId:t.workspaceId}:null}const Oy=`entrydesk-cli`;function ky(e,t){let n=new Set(t.split(/[\s,]+/).filter(Boolean)),r=e.split(` `).filter(Boolean);return{rejected:r.filter(e=>n.has(e)),remaining:r.filter(e=>!n.has(e))}}async function Ay(e,t,n){try{return await e.post(`v1/oauth/device/code`,{json:{client_id:Oy,scope:t}}).json()}catch(r){if(!(r instanceof o))throw r;let{code:i,error:a}=ty(r.data);if(i===`invalid_scope`){let{rejected:r,remaining:i}=ky(t,a);if(r.length>0&&i.length>0)return n?.onWarning?.(`This server doesn't support these scopes: ${r.join(`, `)}. Continuing without them — commands that need them may be unavailable.`),e.post(`v1/oauth/device/code`,{json:{client_id:Oy,scope:i.join(` `)}}).json()}throw Error(a?`Failed to request device code: ${a}`:`Failed to request device code`,{cause:r})}}const jy=new Set([`localhost`,`0.0.0.0`,`::`,`::1`]);function My(e){let t=e.replace(/^\[|\]$/gu,``).replace(/\.$/u,``).toLowerCase(),n=t.replace(/^::ffff:/u,``);return jy.has(t)||/^127(?:\.\d{1,3}){3}$/u.test(n)||t.startsWith(`::ffff:7f`)}const Ny=/^[A-Za-z0-9\-._~/]*$/u,Py=/^[A-Za-z0-9-]{1,64}$/u;function Fy(e,t,n){let r=null;if(e)try{let t=new URL(e);(t.protocol===`https:`||t.protocol===`http:`)&&t.username===``&&t.password===``&&t.hostname!==``&&!My(t.hostname)&&Ny.test(t.pathname)&&(r=new URL(t.pathname,t.origin))}catch{}return r??=new URL(`/oauth/device`,t),Py.test(n)&&r.searchParams.set(`user_code`,n),r.toString()}function Iy(e){return new Promise((t,n)=>{let r=process.platform,i,a;switch(r){case`darwin`:i=`open`,a=[e];break;case`win32`:i=`cmd`,a=[`/c`,`start`,``,e];break;default:i=`xdg-open`,a=[e];break}d(i,a,r=>{r?n(Error(`Could not open the browser. Visit this URL to continue: ${e}`,{cause:r})):t()})})}async function Ly(e){let t=Xv(),n=Zv(),r=$v(),i=process.env.NODE_TLS_REJECT_UNAUTHORIZED;r.ignoreSslErrors&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED=`0`,console.error(`WARNING: SSL certificate validation is disabled globally for this process during the login flow. All connections in this process will skip TLS verification. Only use ENTRYDESK_IGNORE_SSL_ERRORS for local development.`));try{let r=a.create({baseUrl:t.replace(/\/?$/,`/`),timeout:3e4,headers:hy(),hooks:{beforeError:[({error:e})=>(c(e)&&(e.request.headers.delete(`authorization`),e.request.headers.delete(`Authorization`),e.request.headers.delete(`x-web-proxy-id`)),e)]}}),i;try{i=await Ay(r,`offline_access workspaces:read tasks:read tasks:write tasks:delete projects:read projects:write agents:read agents:write connectors:read connectors:write tools:read tools:execute skills:read skills:write meetings:read meetings:write workflows:read workflows:write notifications:read notifications:write publishes:read publishes:write calendar:read calendar:write schedules:read schedules:write user:read user:write`,e)}catch(t){let n=t instanceof Error?t:Error(`Failed to request device code`);throw e?.onError?.(n),n}let{device_code:s,user_code:l,expires_in:u,interval:d}=i,m=Fy(i.verification_uri,n,l);e?.onDeviceCodeReceived?.(l,m),e?.onBrowserOpening?.();try{await Iy(m)}catch(e){process.env.DEBUG&&console.error(`[DEBUG] Failed to open browser:`,e)}e?.onWaitingForAuthorization?.();let ee=Math.max(d,5)*1e3,te=Date.now()+u*1e3;for(;Date.now()<te;){await f(ee);try{let t=await r.post(`v1/oauth/token`,{json:{grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:s,client_id:Oy}}).json();e?.onAuthorized?.();let n={};try{n=p(t.access_token)}catch{}return{accessToken:t.access_token,refreshToken:t.refresh_token??void 0,email:n.email||``,scopes:t.scope.split(` `).filter(e=>e.length>0)}}catch(t){if(t instanceof o){let{code:e,error:n}=ty(t.data),r=e||n;if(!r)continue;switch(r){case`authorization_pending`:continue;case`slow_down`:ee+=5e3;continue;case`access_denied`:throw Error(`Authorization denied.`,{cause:t});case`expired_token`:throw Error("Device code expired. Run `entrydesk login` again.",{cause:t});default:throw Error(`Authorization failed: ${r||`Unknown error`}`,{cause:t})}}let n=t instanceof Error?t:Error(`Unknown error during authorization`);throw e?.onError?.(n),n}}throw Error("Device code expired. Run `entrydesk login` again.")}finally{i===void 0?delete process.env.NODE_TLS_REJECT_UNAUTHORIZED:process.env.NODE_TLS_REJECT_UNAUTHORIZED=i}}function Ry(e){if(e instanceof o){let t=e.response.status;return t===400||t===401}return!1}var zy=class extends Error{code;constructor(e,t){super(t),this.name=`AuthError`,this.code=e}};function By(e){try{let t=e.split(`.`);if(t.length<2)return null;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=(4-n.length%4)%4,i=n.padEnd(n.length+r,`=`),a=Buffer.from(i,`base64`).toString(`utf8`);return JSON.parse(a)}catch{return null}}function Vy(e,t=300){let n=By(e)?.exp;return typeof n==`number`&&n-Math.floor(Date.now()/1e3)<=t}async function Hy(e){let t=e.accessToken;if(!Vy(t))return t;if(!e.refreshToken)throw await my.clear(),new zy(`session-expired`,"Session expired. Run `entrydesk login` again.");let n=e.refreshToken;try{let t=await new xy().refreshOAuthToken({refreshToken:n,clientId:Oy}),r=await my.getAll();return r?.accessToken&&r.refreshToken&&r.refreshToken!==n?r.accessToken:(await my.saveAll({...r??e,accessToken:t.access_token,refreshToken:t.refresh_token??r?.refreshToken??n}),t.access_token)}catch(e){if(!Ry(e))throw new zy(`refresh-failed`,`Could not refresh your session — the auth server is unreachable. Try again in a moment.`);let t=await my.getAll();if(t?.accessToken&&t.refreshToken&&t.refreshToken!==n)return t.accessToken;throw await my.clear(),new zy(`session-expired`,"Session expired. Run `entrydesk login` again.")}}async function Uy(){let e=Cy();if(e)return e.accessToken;let t=await my.getAll();if(!t?.accessToken)throw new zy(`not-logged-in`,"Not logged in. Run `entrydesk login` first.");return Hy(t)}async function Wy(){let e=Cy();if(e)return{accessToken:e.accessToken,workspaceId:e.workspaceId};let t=Ty();if(t)return t;let n=await my.getAll();if(!n?.accessToken)throw new zy(`not-logged-in`,"Not logged in. Run `entrydesk login` first.");if(!n.workspaceId)throw new zy(`no-workspace`,"No workspace selected. Run `entrydesk workspaces` first.");return{accessToken:await Hy(n),workspaceId:n.workspaceId}}function Gy(e){let t=``;try{t=` by ${Xv()}`}catch{}let n=ry(e.data),r=n?` (server code: ${n})`:``,i;return i=n===`missing_token`||n===`bearer_not_supported`?process.env.ENTRYDESK_API_URL?`The API did not accept your Authorization header (stripped or refused en route) — the URL likely points at a browser-facing proxy path (such as a Hub "/api" URL). It comes from the ENTRYDESK_API_URL environment variable, which overrides profile config — update or unset ENTRYDESK_API_URL.`:'The API did not accept your Authorization header (stripped or refused en route) — the URL likely points at a browser-facing proxy path (such as a Hub "/api" URL). Set apiUrl to the API server URL with `entrydesk config set apiUrl <url>`.':Sy()?`Requests are authenticated via ${Ey} — ask the sandbox owner to issue fresh credentials.`:wy()?"ENTRYDESK_TOKEN is set and takes priority over `entrydesk login` credentials for workspace commands — unset it or replace it with a valid token; if this command does not use it, run `entrydesk login`.":"Your session may have expired — run `entrydesk login`. If this is not the environment you expect, check `entrydesk config get apiUrl`.",`Not authorized (401)${t}${r}. ${i}`}function Ky(e){let t=Math.round(e/1e3);return t%60==0&&t>=60?`${t/60}m`:`${t}s`}function qy(e){return e instanceof Error&&e.name===`SdkError`&&`code`in e&&e.code===`REQUEST_TIMEOUT`}function Jy(){let{requestTimeout:e,requestMaxTotalTimeout:t}=ey();return`The request timed out after ${Ky(e)} without a response or progress update (absolute cap ${Ky(t)}). Raise the limit with ${Kv}=<milliseconds>, and ${qv}=<milliseconds> for the absolute cap.`}var Yy=class extends Error{exitCode;cause;constructor(e,t=1,n){super(e),this.exitCode=t,this.cause=n,this.name=`CLIError`}};function Xy(e){if(e instanceof Yy)return{message:`Error: ${e.message}`,exitCode:e.exitCode,cause:e.cause,stack:e.cause?.stack};if(e instanceof zy)return{message:e.message,exitCode:1,stack:e.stack};if(qy(e))return{message:Jy(),exitCode:1,stack:e instanceof Error?e.stack:void 0};if(e instanceof s)return{message:`Request timed out. Check your connection and try again.`,exitCode:1,stack:e.stack};if(e instanceof o){let t=e.response.status;if(t===401)return{message:Gy(e),exitCode:1,stack:e.stack};if(t===403)return{message:"Forbidden (403). Your account or token lacks permission for this action. If your token predates a recently added feature, run `entrydesk login` to refresh its scopes; otherwise you may lack permission in this workspace.",exitCode:1,stack:e.stack};let n=ty(e.data),r=ry(e.data),i=r?` (server code: ${r})`:``,a=iy(n.error),o=iy(e.response.statusText);return{message:`Request failed (${t}): ${a||o}${i}`,exitCode:1,stack:e.stack}}return e instanceof Error?{message:`Unexpected error: ${e.message}`,exitCode:1,stack:e.stack}:{message:`An unknown error occurred`,exitCode:1}}function Zy(e){let t=Xy(e);console.error(t.message),t.cause&&console.error(`Cause: ${t.cause.message}`),process.env.DEBUG&&t.stack&&console.error(t.stack),process.exit(t.exitCode)}const Qy=`default`,$y=/^[A-Za-z0-9_-]+$/;let eb=null;function tb(){return i.join(r.homedir(),`.entrydesk`)}function nb(){return i.join(tb(),`profiles`)}function rb(){return i.join(tb(),`profiles.json`)}function ib(e){return i.join(nb(),e)}function ab(e){if(n.existsSync(e))try{n.chmodSync(e,448)}catch{}else n.mkdirSync(e,{mode:448,recursive:!0})}function ob(){ab(tb())}function sb(){ab(nb())}function cb(){let e=rb();try{if(!n.existsSync(e))return null;let t=n.readFileSync(e,`utf-8`);return JSON.parse(t)}catch{return null}}function lb(e){ob();let t=rb();n.writeFileSync(t,JSON.stringify(e,null,2),{mode:384});try{n.chmodSync(t,384)}catch{}}function ub(e){let t=e.profiles?.length?[...new Set(e.profiles)]:[],n=e.currentProfile&&t.includes(e.currentProfile)?e.currentProfile:t[0]||Qy;return t.length===0&&t.push(Qy),t.includes(n)||t.unshift(n),{currentProfile:n,profiles:t}}function db(e){sb(),ab(ib(e))}function fb(){let e=cb();if(!e){let e={currentProfile:Qy,profiles:[Qy]};return lb(e),sb(),db(Qy),e}let t=ub(e);return(t.currentProfile!==e.currentProfile||t.profiles.length!==e.profiles.length)&&lb(t),sb(),t}function pb(e){if(!e)throw new Yy(`Profile name is required.`);if(!$y.test(e))throw new Yy(`Invalid profile name. Use letters, numbers, dash, or underscore.`)}function mb(e,t){if(!e.profiles.includes(t))throw new Yy(`Profile not found: ${t}`)}function hb(e,t){if(e.profiles.includes(t))throw new Yy(`Profile already exists: ${t}`)}const $={DEFAULT_PROFILE:Qy,setOverrideProfile(e){eb=e},getOverrideProfile(){return eb},getProfileDir(e){return ib(e)},getProfileConfigFile(e){return i.join($.getProfileDir(e),`config.json`)},getProfileCredentialsFile(e){return i.join($.getProfileDir(e),`credentials.json`)},getProfileNames(){return[...fb().profiles]},getProfileCount(){return $.getProfileNames().length},getCurrentProfileName(){return fb().currentProfile},getEffectiveProfileName(e){let t=fb(),n=e||eb||t.currentProfile;return pb(n),mb(t,n),n},ensureProfileExists(e){let t=fb();pb(e),mb(t,e)},createProfile(e){pb(e);let t=fb();hb(t,e),lb({currentProfile:t.currentProfile,profiles:[...t.profiles,e]}),db(e)},deleteProfile(e){pb(e);let t=fb();if(mb(t,e),t.profiles.length===1)throw new Yy(`Cannot delete the last profile.`);let r=t.profiles.filter(t=>t!==e),i=t.currentProfile;i===e&&(i=r.includes(Qy)?Qy:r[0]),lb({currentProfile:i,profiles:r});try{n.rmSync($.getProfileDir(e),{recursive:!0,force:!0})}catch{}return{currentProfile:i}},renameProfile(e,t){pb(e),pb(t);let r=fb();mb(r,e),hb(r,t);let i=ib(e),a=ib(t);if(n.existsSync(i))try{n.renameSync(i,a)}catch(e){throw new Yy(`Failed to rename profile directory.`,1,e)}else db(t);let o=r.profiles.map(n=>n===e?t:n),s=r.currentProfile===e?t:r.currentProfile;return lb({currentProfile:s,profiles:o}),{currentProfile:s}},setCurrentProfile(e){pb(e);let t=fb();mb(t,e),lb({currentProfile:e,profiles:t.profiles}),db(e)},ensureProfileDir:db};export{dm as $,ey as A,vu as At,Uh as B,my as C,_d as Ct,Yv as D,yu as Dt,Xv as E,Tu as Et,o_ as F,lh as G,th as H,jg as I,Im as J,Wm as K,fg as L,Gv as M,uu as Mt,H_ as N,Cc as Nt,Qv as O,J as Ot,V_ as P,fm as Q,Wh as R,hy as S,gd as St,iy as T,Mu as Tt,oh as U,ah as V,Qm as W,hm as X,Pm as Y,sm as Z,Cy as _,vd as _t,Xy as a,xf as at,xy as b,bd as bt,zy as c,kd as ct,Vy as d,Rd as dt,pm as et,Hy as f,Ld as ft,Dy as g,jd as gt,Ey as h,Id as ht,Jy as i,jf as it,Hv as j,_u as jt,Zv as k,mu as kt,Uy as l,Fd as lt,Ly as m,Wd as mt,tb as n,Yf as nt,Zy as o,Gd as ot,Oy as p,Md as pt,ch as q,Yy as r,Xf as rt,qy as s,Yd as st,$ as t,Rp as tt,Wy as u,Ad as ut,Ty as v,yd as vt,ry as w,hd as wt,by as x,fd as xt,wy as y,Ed as yt,Oh as z};