@kubitnodes/stellaris 0.3.22 → 0.3.23

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 (54) hide show
  1. package/README.md +4 -4
  2. package/dist/cli/index.js +556 -413
  3. package/dist/server/index.js +666 -473
  4. package/package.json +1 -1
  5. package/web/dist/assets/BackLink-DGYs80bb.js +1 -0
  6. package/web/dist/assets/{Button-Yoe21NQ2.js → Button-f4jgBZY1.js} +1 -1
  7. package/web/dist/assets/{ChannelForms-55otlg-m.js → ChannelForms-q9zdj4p2.js} +1 -1
  8. package/web/dist/assets/{ChannelView-DJvLzg0N.js → ChannelView-CGs_aWL3.js} +2 -2
  9. package/web/dist/assets/{CitizenView-m1K2aTvK.js → CitizenView-gcIo_sKt.js} +2 -2
  10. package/web/dist/assets/CitizensView-DZ7S8vnJ.js +1 -0
  11. package/web/dist/assets/{CliIcon-DbMYJdlU.js → CliIcon-CLHaA65A.js} +1 -1
  12. package/web/dist/assets/{CronsView-B4kXk5Ld.js → CronsView-1wns6Uwv.js} +1 -1
  13. package/web/dist/assets/{KnowledgeView-aSGxDDKy.js → KnowledgeView-Cxfi2-Pt.js} +1 -1
  14. package/web/dist/assets/Markdown-BhtIFcWc.js +30 -0
  15. package/web/dist/assets/MessageItem-Bk9eBp1U.js +1 -0
  16. package/web/dist/assets/MetricsView-CTEH6rJn.js +1 -0
  17. package/web/dist/assets/NeedsYouView-2VNqH2Sb.js +1 -0
  18. package/web/dist/assets/{Overview-BveU1yJj.js → Overview-CS9HCSmm.js} +1 -1
  19. package/web/dist/assets/{Pane-CLjdfBMM.js → Pane-CJYRVkwh.js} +1 -1
  20. package/web/dist/assets/{Picker-CXOe5Xdu.js → Picker-DoxCN6C7.js} +1 -1
  21. package/web/dist/assets/{ProjectView-oa4Z46ED.js → ProjectView-CJ3r4UdN.js} +1 -1
  22. package/web/dist/assets/ProposalView-DLn9dNPp.js +2 -0
  23. package/web/dist/assets/{ProposalsView-BZHivSEm.js → ProposalsView-B-cOxTsQ.js} +1 -1
  24. package/web/dist/assets/{Quota-BC7dpnwd.js → Quota-Bo7UdWTV.js} +1 -1
  25. package/web/dist/assets/{RunnersView-BrJF-aLU.js → RunnersView-DlQruhwp.js} +1 -1
  26. package/web/dist/assets/{SocietyView-C1yosPuf.js → SocietyView-Bl4ErnV8.js} +1 -1
  27. package/web/dist/assets/{StickyList-7tAlUDCN.js → StickyList-MVP34ytV.js} +1 -1
  28. package/web/dist/assets/{SubjectThread-CCq6ZAnR.js → SubjectThread-BFFnHxIF.js} +1 -1
  29. package/web/dist/assets/{TaskFileView-BEXQJQQ6.js → TaskFileView-GZ0eQFUb.js} +2 -2
  30. package/web/dist/assets/{TaskView-Cfhb7NuO.js → TaskView-DppFelLW.js} +2 -2
  31. package/web/dist/assets/{TasksView-3XljXcoi.js → TasksView-DDNXzeG4.js} +1 -1
  32. package/web/dist/assets/{ThreadForms-D2y5dXSC.js → ThreadForms-C846TvtS.js} +1 -1
  33. package/web/dist/assets/{ThreadItem-DeIhhmyu.js → ThreadItem-C8cou6wD.js} +1 -1
  34. package/web/dist/assets/{ThreadView-CbUnt9WL.js → ThreadView-DvSGDYoD.js} +1 -1
  35. package/web/dist/assets/{citizen--bqux6i_.js → citizen-B2Dlbcpe.js} +1 -1
  36. package/web/dist/assets/{compose-DNc3_c5x.js → compose-BmqQmcZH.js} +1 -1
  37. package/web/dist/assets/{format-B6fjC0_a.js → format-DT52SbbR.js} +1 -1
  38. package/web/dist/assets/{governance-RBQ4Lam0.js → governance-Cr5OlQnw.js} +1 -1
  39. package/web/dist/assets/index-BTVy_xFF.js +23 -0
  40. package/web/dist/assets/index-DzV6CCnG.css +2 -0
  41. package/web/dist/assets/{mentions-B2Qchd_6.js → mentions-D5hNgtg6.js} +1 -1
  42. package/web/dist/assets/{tasks-DCUj5w_d.js → tasks-R3YgpYTe.js} +1 -1
  43. package/web/dist/assets/useMatch-pEF6RJ6Q.js +1 -0
  44. package/web/dist/index.html +9 -9
  45. package/web/dist/assets/BackLink-CD-iuy-h.js +0 -1
  46. package/web/dist/assets/CitizensView-BeTgmrKE.js +0 -1
  47. package/web/dist/assets/Markdown-c9bCCLHg.js +0 -30
  48. package/web/dist/assets/MessageItem-DKJKMqs-.js +0 -1
  49. package/web/dist/assets/MetricsView-D2TTry5O.js +0 -1
  50. package/web/dist/assets/NeedsYouView-C3celRei.js +0 -1
  51. package/web/dist/assets/ProposalView-B4T-EoX9.js +0 -2
  52. package/web/dist/assets/index-CyCty7a2.js +0 -23
  53. package/web/dist/assets/index-GRqxKN35.css +0 -2
  54. package/web/dist/assets/useMatch-CfbBQirn.js +0 -1
@@ -52,4 +52,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
52
52
 
53
53
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Rn,c=!Pr.jitless,l=c&&zn.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?so([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function uo(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=>!ir(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=>lr(e,r,Fr())))}),t)}var fo=D(`$ZodUnion`,(e,t)=>{k.init(e,t),E(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),E(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(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)))}),E(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=>En(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=>uo(t,r,e,i)):uo(o,r,e,i)}});function po(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var mo=D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,fo.init(e,t);let n=e._zod.parse;E(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||On(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=kn(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=wn(()=>po(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Rn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._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()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),ho=D(`$ZodIntersection`,(e,t)=>{k.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])=>_o(e,t,n)):_o(e,i,a)}});function go(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Bn(e)&&Bn(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=go(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=go(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 _o(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=go(t.value,n.value);if(!c.valid){if(ir(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var vo=D(`$ZodRecord`,(e,t)=>{k.init(e,t);let n=Pr.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Bn(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=>lr(e,i,Fr())),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(...or(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...or(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`&&Bi.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=>lr(e,i,Fr())),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(...or(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...or(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}}),yo=D(`$ZodEnum`,(e,t)=>{k.init(e,t);let n=bn(t.entries),r=new Set(n);e._zod.values=r,E(e,`pattern`,e=>{let t=bn(e.def.entries).filter(e=>Hn.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Un(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}}),bo=D(`$ZodLiteral`,(e,t)=>{k.init(e,t);let n=new Set(t.values);e._zod.values=n,E(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Un(e):e?Un(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}}),xo=D(`$ZodTransform`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,Pr.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Nr(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 Mr;return n.value=i,n}});function So(e,t){return e.value=t.issues.length?void 0:t.value,e}var Co=D(`$ZodOptional`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,E(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${En(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=>So(e,t)):So(e,r)}return t.innerType._zod.run(e,n)}}),wo=D(`$ZodExactOptional`,(e,t)=>{Co.init(e,t),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),To=D(`$ZodNullable`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin),E(e,`optout`,e=>e.def.innerType._zod.optout),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${En(t.source)}|null)$`):void 0}),E(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)}),Eo=D(`$ZodDefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,E(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=>Do(e,t)):Do(r,t)}});function Do(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Oo=D(`$ZodPrefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,E(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))}),ko=D(`$ZodNonOptional`,(e,t)=>{k.init(e,t),E(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=>Ao(t,e)):Ao(i,e)}});function Ao(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 jo(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>lr(e,r,Fr()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Mo=D(`$ZodCatch`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),E(e,`optout`,e=>e.def.innerType._zod.optout),E(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=>jo(e,r,t,n)):jo(e,r,t,n)}}),No=D(`$ZodPipe`,(e,t)=>{k.init(e,t),E(e,`values`,e=>e.def.in._zod.values),E(e,`optin`,e=>e.def.in._zod.optin),E(e,`optout`,e=>e.def.out._zod.optout),E(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=>Po(e,t.in,n)):Po(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Po(e,t.out,n)):Po(r,t.out,n)}});function Po(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)}var Fo=D(`$ZodPreprocess`,(e,t)=>{No.init(e,t)}),Io=D(`$ZodReadonly`,(e,t)=>{k.init(e,t),E(e,`propValues`,e=>e.def.innerType._zod.propValues),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`optin`,e=>e.def.innerType?._zod?.optin),E(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(Lo):Lo(r)}});function Lo(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ro=D(`$ZodCustom`,(e,t)=>{O.init(e,t),k.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=>zo(t,n,r,e));zo(i,n,r,e)}});function zo(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(mr(e))}}var Bo=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Vo=`~memo`,Ho=[];function Uo(e){return typeof e==`object`&&!!e}function Wo(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Go=new WeakMap,Ko=0,qo=1,Jo=2;function Yo(e,t,n){let r=Go.get(e);if(r!==void 0)return r?Jo:Ko;if(t.has(e))return Jo;t.add(e);let i=Ko,a=e=>{if(i!==Jo&&e?._zod){let r=Yo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Ko;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?qo:o.value?._zod?Yo(o.value,t,n):Ko;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=kn(c);s(e?o(e,!0):qo),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Yo(r,t,!1):qo);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 c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Xo(e,i)}function Xo(e,t){return t!==qo&&Go.set(e,t===Jo),t}function Zo(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Qo,$o=[],es={alloc(e,t,n){let r=Qo;if(!r)return n;Qo=void 0;let i={value:n,issues:null};return r.set(t.value,i),$o.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`&&ns(n,e.value))throw new Bo;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Yo(e,new Set,!1);if(i===Ko)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Jo||r?n=!0:r=!0}let l=s.value;if(!Uo(l))return t(s,c);let u=c[Vo];u||(u={buckets:new WeakMap,backEdges:void 0},c[Vo]=u);let d;i===c?d=a:(d=Zo(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Wo(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Qo=d;let p=$o.length,m=t(s,c);Qo=void 0;let h=$o.length>p?$o.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Wo(e.issues):Ho),e)):(h&&(h.issues=m.issues.length?Wo(m.issues):Ho),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ts(){return es}function ns(e,t){let n=e[Vo]?.backEdges;return n!==void 0&&Uo(t)&&n.has(t)}var rs=()=>{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`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,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(pr(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Gn(e.values[0])}`:`Invalid option: expected one of ${xn(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`:``}: ${xn(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 is(){return{localeError:rs()}}var as,os=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 ss(){return new os}(as=globalThis).__zod_globalRegistry??(as.__zod_globalRegistry=ss());var cs=globalThis.__zod_globalRegistry;function ls(e){return e.checks&&=[...e.checks],e}function us(e,t){return new e(ls({type:`string`,...T(t)}))}function ds(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}function fs(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}function ps(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}function ms(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}function hs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}function gs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}function _s(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}function vs(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}function ys(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}function bs(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}function xs(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}function Ss(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}function Cs(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}function ws(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}function Ts(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}function Es(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}function Ds(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}function Os(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}function ks(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}function As(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}function js(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}function Ms(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}function Ns(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}function Ps(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}function Fs(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}function Is(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}function Ls(e,t){return new e(ls({type:`number`,checks:[],...T(t)}))}function Rs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}function zs(e,t){return new e({type:`boolean`,...T(t)})}function Bs(e){return new e({type:`unknown`})}function Vs(e,t){return new e({type:`never`,...T(t)})}function Hs(e,t){return new Ki({check:`less_than`,...T(t),value:e,inclusive:!1})}function Us(e,t){return new Ki({check:`less_than`,...T(t),value:e,inclusive:!0})}function Ws(e,t){return new qi({check:`greater_than`,...T(t),value:e,inclusive:!1})}function Gs(e,t){return new qi({check:`greater_than`,...T(t),value:e,inclusive:!0})}function Ks(e,t){return new Ji({check:`multiple_of`,...T(t),value:e})}function qs(e,t){return new Xi({check:`max_length`,...T(t),maximum:e})}function Js(e,t){return new Zi({check:`min_length`,...T(t),minimum:e})}function Ys(e,t){return new Qi({check:`length_equals`,...T(t),length:e})}function Xs(e,t){return new ea({check:`string_format`,format:`regex`,...T(t),pattern:e})}function Zs(e){return new ta({check:`string_format`,format:`lowercase`,...T(e)})}function Qs(e){return new na({check:`string_format`,format:`uppercase`,...T(e)})}function $s(e,t){return new ra({check:`string_format`,format:`includes`,...T(t),includes:e})}function ec(e,t){return new ia({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}function tc(e,t){return new aa({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}function nc(e){return new oa({check:`overwrite`,tx:e})}function rc(e){return nc(t=>t.normalize(e))}function ic(){return nc(e=>e.trim())}function ac(){return nc(e=>e.toLowerCase())}function oc(){return nc(e=>e.toUpperCase())}function sc(){return nc(e=>In(e))}function cc(e,t,n){return new e({type:`array`,element:t,...T(n)})}function lc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}function uc(e,t){let n=dc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(mr(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(mr(r))}},e(t.value,t)),t);return n}function dc(e,t){let n=new O({check:`custom`,...T(t)});return n._zod.check=e,n}function fc(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&On(e,t,n[t]);return e}function pc(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??cs,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 mc(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 j(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,j(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&fc(o.schema,c),t.io===`input`&&M(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 hc(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function gc(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}/${hc(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+hc(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>
54
54
 
55
- 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}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function _c(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;_c(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}var vc=new Set([`type`,`properties`,`required`,`additionalProperties`]),yc=[`oneOf`,`anyOf`];function bc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function xc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!vc.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]??bc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}On(n,r,e.length===1?e[0]:xc(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=bc(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 Sc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of vc)if(t in e)return;let n=t.filter(e=>yc.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=xc(t);else{let e=n[0],i=yc.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=>xc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,fc(e,r))}function Cc(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)):fc(i,s),fc(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())_c(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)??[])Sc(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)}fc(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,On(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:Tc(t,`input`,e.processors),output:Tc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function M(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 M(r.element,n);if(r.type===`set`)return M(r.valueType,n);if(r.type===`lazy`)return M(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 M(r.innerType,n);if(r.type===`intersection`)return M(r.left,n)||M(r.right,n);if(r.type===`record`||r.type===`map`)return M(r.keyType,n)||M(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:M(r.in,n)||M(r.out,n);if(r.type===`object`){for(let e in r.shape)if(M(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(M(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(M(e,n))return!0;return!!(r.rest&&M(r.rest,n))}return!1}var wc=(e,t={})=>n=>{let r=pc({...n,processors:t});return j(e,r),gc(r,e),Cc(r,e)},Tc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=pc({...i??{},target:a,io:t,processors:n});return j(e,o),gc(o,e),Cc(o,e)},Ec=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Dc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Oc=(e,t)=>{Ec(e,`minimum`,t),Dc(e,`maximum`,t)},kc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ac=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},jc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Mc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Nc=(e,t)=>Ec(e,`minimum`,t.minimum),Pc=(e,t)=>Dc(e,`maximum`,t.maximum),Fc=e=>(t,n)=>{Mc(t,n.format);let[r,i]=e[n.format];Ec(t,`minimum`,r),Dc(t,`maximum`,i)},Ic={greater_than:(e,t)=>Ec(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Dc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>kc(e,t.value),number_format:Fc(qn),bigint_format:Fc(Jn),min_length:Nc,max_length:Pc,length_equals:(e,t)=>Oc(e,t.length),min_size:Nc,max_size:Pc,size_equals:(e,t)=>Oc(e,t.size),string_format:(e,t)=>{Mc(e,t.format),t.pattern&&Ac(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>jc(e,t.mime)};function Lc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ic[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ec(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ec(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Dc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Dc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&kc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&jc(t,i.mime);for(let e of i.patterns??[])Ac(t,e);return t}var Rc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},zc=new Map([[Ua,Oi],[Ga,ki]]),Bc=e=>zc.get(e)??e,Vc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Lc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Rc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Bc);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}))])}},Hc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Lc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):mc(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Uc=(e,t,n,r)=>{n.type=`boolean`},Wc=(e,t,n,r)=>{n.not={}},Gc=(e,t,n,r)=>{let i=e._zod.def,a=bn(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},Kc=(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(mc(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(mc(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}},qc=(e,t,n,r)=>{mc(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Jc=(e,t,n,r)=>{mc(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Yc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Lc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})};function Xc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Xc(t.out):t.type===`catch`?Xc(t.innerType):e._zod.optin}var Zc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&mc(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)On(i.properties,e,j(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Xc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Qc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},$c=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(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)};function el(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=el(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=>el(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`)?Bi:zi).source),p):p}var tl=new WeakMap;function nl(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 tl.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=el(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)}}var rl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Lc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=j(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)On(i.patternProperties,Bc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=j(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=tl.get(t);n||(n=[],tl.set(t,n),t.deferred.push(()=>nl(t))),n.push(e)}i.additionalProperties=j(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Xc(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))}},il=(e,t,n,r)=>{let i=e._zod.def,a=j(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`}]},al=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ol=Symbol();function sl(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(mc(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ol):JSON.parse(o)}var cl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=sl(i.defaultValue,e,t,n,r);o!==ol&&(n.default=o)},ll=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=sl(i.defaultValue,e,t,n,r);o!==ol&&(n._prefault=o)},ul=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{mc(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},dl=(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;j(o,t,r);let s=t.seen.get(e);s.ref=o},fl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ml=new WeakSet([Object.prototype,Error.prototype]);function hl(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})}})}var N=D(`ZodError`,(e,t)=>{Hr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ml.has(n)||(ml.add(n),hl(n,`format`,e=>t=>Gr(e,t)),hl(n,`flatten`,e=>t=>Wr(e,t)),hl(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Sn,2)}),hl(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Sn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),gl=qr(N),_l=Jr(N),vl=Yr(N),yl=Zr(N),bl=ri(N),xl=ii(N),Sl=ai(N),Cl=oi(N),wl=si(N),Tl=ci(N),El=li(N),Dl=ui(N);function Ol(){Pr.localeError||Fr(is())}function kl(){Pr.memoizer||Fr({memoizer:ts()})}var P=D(`ZodType`,(e,t)=>(Ol(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(w(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 Wn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qu(e,t))},superRefine(e,t){return this.check(Ju(e,t))},overwrite(e){return this.check(nc(e))},optional(){return Ou(this)},exactOptional(){return Au(this)},nullable(){return Mu(this)},nullish(){return Ou(Mu(this))},nonoptional(e){return Ru(this,e)},array(){return z(this)},or(e){return hu([this,e])},and(e){return yu(this,e)},transform(e){return Hu(this,Eu(e))},default(e){return Pu(this,e)},prefault(e){return Iu(this,e)},catch(e){return Bu(this,e)},pipe(e){return Hu(this,e)},readonly(){return Gu(this)},describe(e){let t=this.clone();return cs.add(t,{description:e}),t},meta(...e){if(e.length===0)return cs.get(this);let t=this.clone();return cs.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 _r(this,`~standard`,{...da(this),jsonSchema:{input:Tc(this,`input`),output:Tc(this,`output`)}})},set"~standard"(e){gr(this,`~standard`,e)},parse:function e(t,n){return gl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await _l(this,t,n,{callee:e})},safeParse(e,t){return vl(this,e,t)},async safeParseAsync(e,t){return yl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){gr(this,`spa`,e)},validate(e,t){return ei(this,e,t)},validateAsync(e,t){return ni(this,e,t)},encode:function e(t,n){return bl(this,t,n,{callee:e})},decode:function e(t,n){return xl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Sl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Cl(this,t,n,{callee:e})},safeEncode(e,t){return wl(this,e,t)},safeDecode(e,t){return Tl(this,e,t)},async safeEncodeAsync(e,t){return El(this,e,t)},async safeDecodeAsync(e,t){return Dl(this,e,t)},toJSONSchema(e){return wc(this,{})(e)},get description(){return cs.get(this)?.description},get _def(){return this._zod.def}}),Al=D(`_ZodString`,(e,t)=>{fa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r)},vr({format:e=>Lc(e).format??null,minLength:e=>Lc(e).minimum??null,maxLength:e=>Lc(e).maximum??null},{regex(...e){return this.check(Xs(...e))},includes(...e){return this.check($s(...e))},startsWith(...e){return this.check(ec(...e))},endsWith(...e){return this.check(tc(...e))},min(...e){return this.check(Js(...e))},max(...e){return this.check(qs(...e))},length(...e){return this.check(Ys(...e))},nonempty(...e){return this.check(Js(1,...e))},lowercase(e){return this.check(Zs(e))},uppercase(e){return this.check(Qs(e))},trim(){return this.check(ic())},normalize(...e){return this.check(rc(...e))},toLowerCase(){return this.check(ac())},toUpperCase(){return this.check(oc())},slugify(){return this.check(sc())}})),jl=D(`ZodString`,(e,t)=>{fa.init(e,t),Al.init(e,t)},{email(e){return this.check(ds(Il,e))},url(e){return this.check(_s(Bl,e))},jwt(e){return this.check(Ms(nu,e))},emoji(e){return this.check(vs(Hl,e))},guid(e){return this.check(fs(Ll,e))},uuid(e){return this.check(ps(Rl,e))},uuidv4(e){return this.check(ms(Rl,e))},uuidv6(e){return this.check(hs(Rl,e))},uuidv7(e){return this.check(gs(Rl,e))},nanoid(e){return this.check(ys(Ul,e))},cuid(e){return this.check(bs(Wl,e))},cuid2(e){return this.check(xs(Gl,e))},ulid(e){return this.check(Ss(Kl,e))},base64(e){return this.check(ks($l,e))},base64url(e){return this.check(As(eu,e))},xid(e){return this.check(Cs(ql,e))},ksuid(e){return this.check(ws(Jl,e))},ipv4(e){return this.check(Ts(Yl,e))},ipv6(e){return this.check(Es(Xl,e))},cidrv4(e){return this.check(Ds(Zl,e))},cidrv6(e){return this.check(Os(Ql,e))},e164(e){return this.check(js(tu,e))},datetime(e){return this.check(Ns(Ml,e))},date(e){return this.check(Ps(Nl,e))},time(e){return this.check(Fs(Pl,e))},duration(e){return this.check(Is(Fl,e))}});function F(e){return us(jl,e)}var I=D(`ZodStringFormat`,(e,t)=>{A.init(e,t),Al.init(e,t)}),Ml=D(`ZodISODateTime`,(e,t)=>{ja.init(e,t),I.init(e,t)}),Nl=D(`ZodISODate`,(e,t)=>{Ma.init(e,t),I.init(e,t)}),Pl=D(`ZodISOTime`,(e,t)=>{Na.init(e,t),I.init(e,t)}),Fl=D(`ZodISODuration`,(e,t)=>{Pa.init(e,t),I.init(e,t)}),Il=D(`ZodEmail`,(e,t)=>{ha.init(e,t),I.init(e,t)}),Ll=D(`ZodGUID`,(e,t)=>{pa.init(e,t),I.init(e,t)}),Rl=D(`ZodUUID`,(e,t)=>{ma.init(e,t),I.init(e,t)});function zl(e){return ps(Rl,e)}var Bl=D(`ZodURL`,(e,t)=>{Ca.init(e,t),I.init(e,t)});function Vl(e){return _s(Bl,e)}var Hl=D(`ZodEmoji`,(e,t)=>{wa.init(e,t),I.init(e,t)}),Ul=D(`ZodNanoID`,(e,t)=>{Ta.init(e,t),I.init(e,t)}),Wl=D(`ZodCUID`,(e,t)=>{Ea.init(e,t),I.init(e,t)}),Gl=D(`ZodCUID2`,(e,t)=>{Da.init(e,t),I.init(e,t)}),Kl=D(`ZodULID`,(e,t)=>{Oa.init(e,t),I.init(e,t)}),ql=D(`ZodXID`,(e,t)=>{ka.init(e,t),I.init(e,t)}),Jl=D(`ZodKSUID`,(e,t)=>{Aa.init(e,t),I.init(e,t)}),Yl=D(`ZodIPv4`,(e,t)=>{Fa.init(e,t),I.init(e,t)}),Xl=D(`ZodIPv6`,(e,t)=>{Ra.init(e,t),I.init(e,t)}),Zl=D(`ZodCIDRv4`,(e,t)=>{za.init(e,t),I.init(e,t)}),Ql=D(`ZodCIDRv6`,(e,t)=>{Va.init(e,t),I.init(e,t)}),$l=D(`ZodBase64`,(e,t)=>{Wa.init(e,t),I.init(e,t)}),eu=D(`ZodBase64URL`,(e,t)=>{qa.init(e,t),I.init(e,t)}),tu=D(`ZodE164`,(e,t)=>{Ja.init(e,t),I.init(e,t)}),nu=D(`ZodJWT`,(e,t)=>{Xa.init(e,t),I.init(e,t)}),ru=D(`ZodNumber`,(e,t)=>{Za.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.isFinite=!0},vr({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Lc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Lc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Lc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Lc(e).format??null},{gt(e,t){return this.check(Ws(e,t))},gte(e,t){return this.check(Gs(e,t))},min(e,t){return this.check(Gs(e,t))},lt(e,t){return this.check(Hs(e,t))},lte(e,t){return this.check(Us(e,t))},max(e,t){return this.check(Us(e,t))},int(e){return this.check(au(e))},safe(e){return this.check(au(e))},positive(e){return this.check(Ws(0,e))},nonnegative(e){return this.check(Gs(0,e))},negative(e){return this.check(Hs(0,e))},nonpositive(e){return this.check(Us(0,e))},multipleOf(e,t){return this.check(Ks(e,t))},step(e,t){return this.check(Ks(e,t))},finite(){return this}}));function L(e){return Ls(ru,e)}var iu=D(`ZodNumberFormat`,(e,t)=>{Qa.init(e,t),ru.init(e,t)});function au(e){return Rs(iu,e)}var ou=D(`ZodBoolean`,(e,t)=>{$a.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)});function R(e){return zs(ou,e)}var su=D(`ZodUnknown`,(e,t)=>{eo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function cu(){return Bs(su)}var lu=D(`ZodNever`,(e,t)=>{to.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r)});function uu(e){return Vs(lu,e)}var du=D(`ZodArray`,(e,t)=>{kl(),ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Js(e,t))},nonempty(e){return this.check(Js(1,e))},max(e,t){return this.check(qs(e,t))},length(e,t){return this.check(Ys(e,t))},unwrap(){return this.element}});function z(e,t){return cc(du,e,t)}var fu=D(`ZodObject`,(e,t)=>{kl(),lo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),wr(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return V(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(w(this._zod.def,{catchall:e}))},passthrough(){return this.clone(w(this._zod.def,{catchall:cu()}))},loose(){return this.clone(w(this._zod.def,{catchall:cu()}))},strict(){return this.clone(w(this._zod.def,{catchall:uu()}))},strip(){return this.clone(w(this._zod.def,{catchall:void 0}))},extend(e){return Qn(this,e)},safeExtend(e){return er(this,e)},merge(e){return tr(this,e)},pick(e){return Yn(this,e)},omit(e){return Zn(this,e)},partial(...e){return nr(Du,this,e[0])},exactPartial(...e){return nr(ku,this,e[0],`exactPartial`)},required(...e){return rr(Lu,this,e[0])}});function B(e,t){return new fu({type:`object`,shape:e??{},...T(t)})}function pu(e,t){return new fu({type:`object`,shape:e,catchall:uu(),...T(t)})}var mu=D(`ZodUnion`,(e,t)=>{fo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.options=t.options});function hu(e,t){return new mu({type:`union`,options:e,...T(t)})}var gu=D(`ZodDiscriminatedUnion`,(e,t)=>{mu.init(e,t),mo.init(e,t)});function _u(e,t,n){return new gu({type:`union`,options:t,discriminator:e,...T(n)})}var vu=D(`ZodIntersection`,(e,t)=>{ho.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r)});function yu(e,t){return new vu({type:`intersection`,left:e,right:t})}var bu=D(`ZodRecord`,(e,t)=>{kl(),vo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function xu(e,t,n){return!t||!t._zod?new bu({type:`record`,keyType:F(),valueType:e,...T(t)}):new bu({type:`record`,keyType:e,valueType:t,...T(n)})}function Su(e,t,n){return new bu({type:`record`,keyType:e,valueType:t,...T(n),partial:!0})}var Cu=D(`ZodEnum`,(e,t)=>{yo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Cu({...t,checks:[],...T(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 Cu({...t,checks:[],...T(r),entries:i})}});function V(e,t){return new Cu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}var wu=D(`ZodLiteral`,(e,t)=>{bo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(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 H(e,t){return new wu({type:`literal`,values:Array.isArray(e)?e:[e],...T(t)})}var Tu=D(`ZodTransform`,(e,t)=>{kl(),xo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Nr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(mr(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(mr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Eu(e){return new Tu({type:`transform`,transform:e})}var Du=D(`ZodOptional`,(e,t)=>{Co.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new Du({type:`optional`,innerType:e})}var ku=D(`ZodExactOptional`,(e,t)=>{wo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new ku({type:`optional`,innerType:e})}var ju=D(`ZodNullable`,(e,t)=>{To.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new ju({type:`nullable`,innerType:e})}var Nu=D(`ZodDefault`,(e,t)=>{Eo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pu(e,t){return new Nu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}var Fu=D(`ZodPrefault`,(e,t)=>{Oo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e,t){return new Fu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}var Lu=D(`ZodNonOptional`,(e,t)=>{ko.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ru(e,t){return new Lu({type:`nonoptional`,innerType:e,...T(t)})}var zu=D(`ZodCatch`,(e,t)=>{Mo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Bu(e,t){return new zu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Er(t)})}var Vu=D(`ZodPipe`,(e,t)=>{No.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}var Uu=D(`ZodPreprocess`,(e,t)=>{Vu.init(e,t),Fo.init(e,t)}),Wu=D(`ZodReadonly`,(e,t)=>{Io.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gu(e){return new Wu({type:`readonly`,innerType:e})}var Ku=D(`ZodCustom`,(e,t)=>{Ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r)});function qu(e,t={}){return lc(Ku,e,t)}function Ju(e,t){return uc(e,t)}function Yu(e,t){return new Uu({type:`pipe`,in:Eu(e),out:t})}function Xu(e){return Ns(Ml,e)}var U=F().regex(/^[a-z0-9][a-z0-9-]{0,31}$/,`expected 1-32 lowercase letters, digits, or hyphens, starting with a letter or digit`),W=F().regex(/^[0-9A-HJKMNP-TV-Z]{26}$/,`expected a ULID`),G=F().regex(/^(?:[a-z0-9][a-z0-9-]{0,31}\/)?[a-z0-9][a-z0-9-]{0,31}$/,`expected <channel> or <project>/<channel>`);function Zu(e,t){return e===null?t:`${e}/${t}`}var K=Yu(e=>e instanceof Date?e.toISOString():e,Xu()),Qu=V(`post_message.read_inbox.search.open_thread.close_thread.create_task.claim_task.release_task.update_task.get_task.subscribe.unsubscribe.propose.approve.reject.create_project.join_project.leave_project.write_knowledge.plan_task.advance_task.configure_project.archive_project.remove_knowledge.create_channel.archive_channel.update_dashboard.create_cron.update_cron.remove_cron.remove_skill`.split(`.`)),$u=V([`user_post`,`ops_event`,`heartbeat`]),ed=B({name:U,purpose:F().min(1),verbs:z(Qu),wakeTriggers:z($u).default([`heartbeat`]),reviewDate:F().optional(),maxReplicas:L().int().min(1).default(1),backlogThreshold:L().positive().default(3),resident:R().default(!1),societyScope:R().default(!1),reflects:R().default(!0)}),td=`user`,nd=`user`,rd=[`post_message`,`read_inbox`,`search`,`open_thread`,`close_thread`,`create_task`,`claim_task`,`release_task`,`update_task`,`get_task`,`subscribe`,`unsubscribe`,`propose`,`join_project`,`leave_project`,`write_knowledge`,`remove_knowledge`,`plan_task`,`advance_task`,`update_dashboard`,`create_cron`,`update_cron`,`remove_cron`],id=[`approve`,`reject`],ad=[`create_project`],od=[`configure_project`,`create_channel`,`archive_channel`],sd=[`archive_project`],cd=[`remove_skill`];[...rd,...id,...ad,...od,...sd,...cd],[...rd,...id,...od,...cd],[...rd,...ad,...od];function ld(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function ud(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function dd(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?hd(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):hd(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function fd(e,t,n){return pd(dd(e,t),n)}function pd(e,t){let n=new Date(ld(e)),r=md(n,e.tz),i=ld(e)-ld(r),a=new Date(n.getTime()+i),o=md(a,e.tz);if(ud(o,e)){let t=new Date(a.getTime()-36e5);return ud(md(t,e.tz),e)?t:a}let s=new Date(a.getTime()+ld(e)-ld(o));if(ud(md(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function md(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function hd(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var gd=[1,2,4,8,16],_d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,e);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|gd[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},vd=[31,28,31,30,31,30,31,31,30,31,30,31],q=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],J=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date){if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`)}else if(t==null)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():vd[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&63&&gd[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0){if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=md(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>vd[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}return!1}fromString(e){if(typeof this.tz==`number`){let t=fd(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(fd(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,q[n][0],e,q[n][2]);if(r>1){let i=n+1;for(;i<q.length;)this[q[i][0]]=-q[i][2],i++;if(r===3){if(this[q[n][1]]++,this[q[n][0]]=-q[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=q.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,q[n][0],e,q[n][2]);if(i>1){let a=n+1;for(;a<q.length;){let t=q[a][0],n=q[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[q[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1){if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():vd[t];this.day>n&&(this.day=n)}}this.apply();let i=q[n][0],a=q[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=q[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,q[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,q[3][2]),this.second=this.getMaxPatternValue(`second`,e,q[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=q.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):pd(hd(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<q.length;n++){let r=q[n][0],i=q[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function yd(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=e.paused!==void 0&&e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch!==void 0&&e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref!==void 0&&e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays!==void 0&&e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges!==void 0&&e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&(e.startAt=new J(e.startAt,e.timezone)),e.stopAt&&(e.stopAt=new J(e.stopAt,e.timezone)),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function bd(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function xd(e){return bd(e)}function Sd(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Cd=3e4,wd=[],Td=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(bd(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(bd(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=yd(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new _d(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new J(e,this.getTz()):this._states.pattern=new _d(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(wd.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);wd.push(this)}return i!==void 0&&xd(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new J(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new J(e,this.getTz());t.ms=0;let n=new J(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new J(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof J||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new J(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=wd.indexOf(this);e>=0&&wd.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Cd&&(t=Cd),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&Sd(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new J(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(bd(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new J(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&bd(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new J(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new J(e,this.getTz());return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_previous(e){let t=new J(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new J(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new J(void 0,this.getTz()),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new J(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},Ed=9e5,Dd=6e4,Od=200;function kd(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).resolvedOptions().timeZone}catch{return null}}var Ad=F().trim().min(1).max(64).transform((e,t)=>{let n=kd(e);return n===null?(t.addIssue({code:`custom`,message:`${e} is not a time zone; name one as IANA does, such as Europe/Berlin, America/New_York, or UTC`}),Or):n});function jd(e,t){return new Td(e,{mode:`5-part`,timezone:t,paused:!0})}function Md(e){try{return jd(e,`UTC`),null}catch(e){return e instanceof Error?e.message:String(e)}}var Nd=F().trim().min(1).max(120).superRefine((e,t)=>{let n=Md(e);n!==null&&t.addIssue({code:`custom`,message:`not a five-field cron expression (minute, hour, day of month, month, day of week): ${n}`})}),Pd=hu([B({cron:Nd,timezone:Ad.optional()}),B({at:K})]),Fd=B({turnId:W,at:K,outcome:V([`completed`,`failed`,`stopped`])}),Id=B({id:W,title:F().trim().min(1).max(120),agent:U,scope:U,thread:W.optional(),channel:U.optional(),schedule:Pd,createdBy:U,createdAt:K,since:K,paused:B({at:K,by:U}).optional(),lastFiredAt:K.optional(),lastSkippedAt:K.optional(),lastRun:Fd.optional(),failures:L().int().nonnegative().default(0),ended:B({at:K,by:U,reason:F().min(1)}).optional()});function Ld(e){return`at`in e}function Rd(e,t){return Ld(e)?t:e.timezone??t}function zd(e,t,n,r){if(Ld(e)){let t=new Date(e.at);return t>n&&r>0?[t]:[]}return jd(e.cron,Rd(e,t)).nextRuns(r,n)}function Bd(e,t,n){let r=zd(e,t,n,Od),i=null;for(let e=1;e<r.length;e+=1){let t=(r[e]?.getTime()??0)-(r[e-1]?.getTime()??0);i=i===null?t:Math.min(i,t)}return i}function Vd(e,t,n=Ed){if(e.ended!==void 0||e.paused!==void 0)return null;let r=e.lastFiredAt===void 0?null:Date.parse(e.lastFiredAt),i=Date.parse(e.since);if(Ld(e.schedule))return r!==null&&r>=i?null:new Date(e.schedule.at);let a=Math.max(i,r===null?i:r+n-Dd,e.lastSkippedAt===void 0?i:Date.parse(e.lastSkippedAt));return zd(e.schedule,t,new Date(a),1)[0]??null}function Hd(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,weekday:`long`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??``;return`${r(`weekday`)} ${r(`year`)}-${r(`month`)}-${r(`day`)} ${r(`hour`)}:${r(`minute`)}`}var Ud=B({key:F().min(1).max(80),label:F().min(1).max(80).optional(),minutes:L().int().positive().nullable().default(null),usedPercent:L().nonnegative().nullable().default(null),resetsAt:K.nullable().default(null),observedAt:K}),Wd=V([`allowed`,`warning`,`limited`,`none`]),Gd=B({hasCredits:R(),unlimited:R(),balance:F().max(40).nullable()}),Kd=B({enabled:R(),monthlyLimit:L().nonnegative().nullable(),usedCredits:L().nonnegative().nullable(),currency:F().min(1).max(8).nullable()}),qd=B({observedAt:K,source:V([`turn`,`read`]),status:Wd,limitedUntil:K.nullable().default(null),limitedBy:F().min(1).max(80).nullable().default(null),plan:F().min(1).max(40).nullable().default(null),windows:z(Ud).max(24).default([]),credits:Gd.nullable().default(null),extraUsage:Kd.nullable().default(null)});function Jd(e,t){return e.resetsAt===null||Date.parse(e.resetsAt)>t.getTime()}function Yd(e,t){if(e.status===`none`)return`none`;if(e.status===`limited`&&(e.limitedUntil===null||Date.parse(e.limitedUntil)>t.getTime()))return`limited`;let n=e.windows.some(e=>Jd(e,t)&&e.usedPercent!==null&&e.usedPercent>=80);return e.status===`warning`||n?`warning`:`ok`}var Xd={five_hour:`5h`,seven_day:`7d`,seven_day_opus:`7d Opus`,seven_day_sonnet:`7d Sonnet`,seven_day_oauth_apps:`7d apps`,seven_day_overage_included:`7d extra`,overage:`extra usage`};function Zd(e){if(e.label!==void 0)return e.minutes===10080?`7d ${e.label}`:e.label;let t=Xd[e.key];return t===void 0?e.minutes===null?e.key:e.minutes%1440==0?`${e.minutes/1440}d`:e.minutes%60==0?`${e.minutes/60}h`:`${e.minutes}m`:t}function Qd(e){return e.windows.map(e=>`${e.key}=${e.usedPercent===null?`?`:Math.round(e.usedPercent)}@${e.resetsAt===null?`?`:Math.round(Date.parse(e.resetsAt)/6e4)}`).toSorted().join(`,`)}function $d(e,t){return e.windows.some(e=>e.resetsAt!==null)&&e.plan===t.plan&&e.status===t.status&&e.limitedUntil===t.limitedUntil&&Qd(e)===Qd(t)}var ef=`asks`,tf=[`general`,`governance`,ef],nf=[`general`];function rf(e,t){return(e===null?tf:nf).includes(t)}var af=`society`,Y=V([`claude`,`codex`]),of=B({name:U,at:K,by:U,reason:F().min(1)}),sf=B({name:F().min(1),version:H(1),createdAt:K,channels:z(U),archivedChannels:z(of).default([]),timezone:Ad.default(`UTC`)}),cf=V([`none`,`merge`,`ghpr`]),lf=F().trim().regex(/^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)\/pull\/([1-9]\d*)\/?$/,`a pull request's address, https://github.com/<owner>/<repo>/pull/<number>`),uf=F().trim().min(1).max(300).regex(/^[^\n]+$/,`a merge commit's subject is one line`),df=B({url:lf,number:L().int().positive(),subject:uf.optional(),body:F().max(2e4).optional(),linkedBy:U,linkedAt:K,closed:B({at:K,ok:R(),detail:F()}).optional()}),ff=F().trim().min(1).max(100).regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,`a branch name is letters, digits, and . _ / -`).refine(e=>!e.includes(`..`)&&!e.includes(`//`)&&!e.endsWith(`/`)&&!e.endsWith(`.`)&&!e.endsWith(`.lock`),`not a branch name git takes`).refine(e=>!e.startsWith(`task/`)&&!e.startsWith(`agent/`),`task/ and agent/ hold the board's own branches`),pf=F().regex(/^s[1-9][0-9]*$/,`expected a stage id such as s1`),mf={name:F().trim().min(1).max(120),role:U.optional(),agent:U.optional(),gate:R().default(!1)};function hf(e){return e.role===void 0||e.agent===void 0}var gf={message:`a stage names a role or an agent, not both`},_f=B(mf).refine(hf,gf),vf=B({id:pf.optional(),...mf}).refine(hf,gf),yf=B({slug:U,name:F().min(1),repo:F().nullable(),defaultBranch:F().min(1),channels:z(U),archivedChannels:z(of).default([]),members:z(U),approvers:z(U),requiredCapabilities:z(F()),createdAt:K,onDone:cf.default(`none`),runner:U.optional(),archived:B({at:K,by:U,reason:F().min(1)}).optional()}),bf=hu([B({action:V([`advanced`,`returned`,`abandoned`,`landed`,`reopened`]),stage:pf,to:pf.nullable()}),B({action:V([`approved`,`rejected`])})]);function xf(e){return`stage`in e}var Sf=_u(`kind`,[B({kind:H(`knowledge`),action:V([`written`,`updated`,`removed`]),topic:U,project:U.nullable()})]),Cf=B({id:W,author:U,channel:G,thread:W.optional(),task:W.optional(),closes:W.optional(),step:bf.optional(),notice:Sf.optional(),ts:K,mentions:z(U)}),wf=Cf.pick({id:!0,author:!0,channel:!0,thread:!0,ts:!0}),Tf=V([`open`,`claimed`,`done`,`abandoned`]),Ef=V([`open`,`closed`]),Df=B({kind:V([`task`,`proposal`]),id:W}),Of=B({id:W,channel:G,title:F().min(1).max(200),subject:Df.optional(),state:Ef,openedBy:U,openedAt:K,closedBy:U.optional(),closedAt:K.optional()}),kf=B({id:pf,name:F().min(1),role:U.optional(),agent:U.optional(),gate:R().default(!1),holders:z(U).default([]),completedBy:U.optional(),completedAt:K.optional()}),Af=B({from:pf,by:U,at:K}),jf=B({id:W,project:U,channel:U.default(`general`),title:F().min(1),status:Tf,createdBy:U,createdAt:K,updatedAt:K,claimedBy:U.optional(),leaseExpiresAt:K.optional(),parentId:W.optional(),blockedBy:z(W),requiredCapabilities:z(F()),stages:z(kf).min(1),stage:pf,stageSince:K,stageSeq:L().int().positive(),onDone:cf.default(`none`),pullRequest:df.optional(),completing:R().default(!1),returned:Af.optional()});function Mf(e,t){return e.stages.findIndex(e=>e.id===t)}function Nf(e){return e.stages.find(t=>t.id===e.stage)}var Pf=F().trim().min(1).max(120).regex(/^[\w.:/[\]-]+$/,`a model name is one word of letters, digits, and . _ : / - [ ]`),Ff=F().trim().min(1).max(32).regex(/^[a-z][a-z0-9_-]*$/,`an effort is one lowercase word, such as high`),If=B({id:Ff,description:F().default(``)}),Lf=B({runner:U,cli:Y,models:z(B({id:Pf,name:F(),description:F().default(``),isDefault:R().default(!1),efforts:z(If).default([]),defaultEffort:Ff.optional()}))}),Rf=V([`active`,`retired`]),zf=B({name:U,role:U,cli:Y.nullable(),model:F().optional(),effort:F().optional(),homeRunner:U.optional(),memberships:z(U),subscriptions:z(G),status:Rf,createdAt:K,tokenHash:F().min(1),retiredAt:K.optional(),retiredReason:F().optional()}),Bf=B({name:U,role:U,cli:Y.nullable(),homeRunner:U.optional(),status:Rf,resident:R().default(!1),model:F().optional(),lastModel:F().optional(),effort:F().optional(),skills:z(U).default([]),memberships:z(U),subscriptions:z(G),claimsHeld:L().int().nonnegative().default(0),tasksDone:L().int().nonnegative().default(0),lastTurnAt:K.optional(),lastTurnOutcome:F().optional(),createdAt:K,retiredAt:K.optional()}),Vf=V([`linux`,`windows`,`darwin`]),Hf=V([`name`,`email`]),Uf=B({name:U,os:Vf,clis:z(Y),capabilities:z(F()),version:F().optional(),gitIdentityMissing:z(Hf).optional(),status:V([`connected`,`disconnected`]),lastSeen:K.optional(),quotas:Su(Y,qd).optional()}),Wf=V([`role`,`member`,`channel`,`reallocation`,`retirement`,`skill`,`archive`]),Gf=V([`proposed`,`approved`,`rejected`,`provisioned`,`retired`]),Kf=B({name:U,role:U,cli:Y,model:F().optional(),homeRunner:U.optional(),memberships:z(U).default([]),subscriptions:z(G).default([]),seedInstructions:F().optional()}),qf=B({project:U.nullable().default(null),name:U,purpose:F().min(1)}),Jf=B({role:U,changes:pu({maxReplicas:L().int().min(1).optional(),backlogThreshold:L().positive().optional(),wakeTriggers:z($u).optional(),verbs:z(Qu).optional()}).refine(e=>Object.values(e).some(e=>e!==void 0),{message:`a reallocation changes at least one of maxReplicas, backlogThreshold, wakeTriggers, verbs`}),description:F().min(1)}),Yf=B({description:F().min(1)});function Xf(e,t){return{...e,...t.maxReplicas===void 0?{}:{maxReplicas:t.maxReplicas},...t.backlogThreshold===void 0?{}:{backlogThreshold:t.backlogThreshold},...t.wakeTriggers===void 0?{}:{wakeTriggers:[...t.wakeTriggers]},...t.verbs===void 0?{}:{verbs:[...t.verbs]}}}function Zf(e){return e.length===0?`none`:e.join(`, `)}function Qf(e,t){let n=[];t.maxReplicas!==void 0&&t.maxReplicas!==e.maxReplicas&&n.push(`maxReplicas ${e.maxReplicas} → ${t.maxReplicas}`),t.backlogThreshold!==void 0&&t.backlogThreshold!==e.backlogThreshold&&n.push(`backlogThreshold ${e.backlogThreshold} → ${t.backlogThreshold}`);let r=t.wakeTriggers;if(r!==void 0&&(r.length!==e.wakeTriggers.length||r.some(t=>!e.wakeTriggers.includes(t)))&&n.push(`wakeTriggers ${Zf(e.wakeTriggers)} → ${Zf(r)}`),t.verbs!==void 0){let r=t.verbs,i=r.filter(t=>!e.verbs.includes(t)).map(e=>`+${e}`),a=e.verbs.filter(e=>!r.includes(e)).map(e=>`−${e}`);i.length+a.length>0&&n.push(`verbs ${[...i,...a].join(` `)}`)}return n}var $f=B({agent:U,reason:F().min(1)}),ep=B({project:U,reason:F().min(1)}),tp=B({name:U,summary:F().min(1).max(200),body:F().min(1).optional()}),np={role:[td],member:[td],retirement:[td],archive:[td],channel:[td,`steward`],reallocation:[td,`steward`],skill:[td,`steward`]},rp=[`verbs`,`maxReplicas`];function ip(e,t){if(e===`reallocation`){let e=Jf.safeParse(t);if(e.success&&rp.some(t=>e.data.changes[t]!==void 0))return[td]}return np[e]}function ap(e){let t=[];return e.maxReplicas!==void 0&&t.push(`up to ${e.maxReplicas} per project`),e.backlogThreshold!==void 0&&t.push(`backlog threshold ${e.backlogThreshold}`),e.wakeTriggers!==void 0&&t.push(e.wakeTriggers.length===0?`no ambient wakes`:`wakes on ${e.wakeTriggers.join(`, `)}`),e.verbs!==void 0&&t.push(`${e.verbs.length} verbs`),t.join(`, `)}function op(e,t){switch(e){case`member`:{let e=Kf.safeParse(t);if(!e.success)break;let{name:n,role:r,cli:i,memberships:a}=e.data;return`member ${n} as ${r} on ${i}${a.length===0?``:` for ${a.join(`, `)}`}`}case`role`:{let e=ed.safeParse(t);if(!e.success)break;let{name:n,verbs:r,maxReplicas:i}=e.data;return`role ${n} (${r.length} verbs, up to ${i} per project)`}case`channel`:{let e=qf.safeParse(t);if(!e.success)break;return`channel ${Zu(e.data.project,e.data.name)}: ${e.data.purpose}`}case`retirement`:{let e=$f.safeParse(t);if(!e.success)break;return`retirement of ${e.data.agent}: ${e.data.reason}`}case`reallocation`:{let e=Jf.safeParse(t);if(e.success){let{role:t,changes:n,description:r}=e.data;return`reallocation of role ${t} (${ap(n)}): ${r}`}let n=Yf.safeParse(t);if(!n.success)break;return`reallocation: ${n.data.description}`}case`skill`:{let e=tp.safeParse(t);if(!e.success)break;return`skill ${e.data.name}: ${e.data.summary.trim().replace(/\.+$/,``)}`}case`archive`:{let e=ep.safeParse(t);if(!e.success)break;return`archive of project ${e.data.project}: ${e.data.reason}`}}return`${e} ${JSON.stringify(t)}`}var sp=B({name:U,summary:F().default(``),scope:V([`own`,`society`]),path:F().min(1)}),cp=B({name:U,reason:F().min(1),removedBy:U,removedAt:K}),lp=B({path:F().min(1),file:F().min(1),since:K}),up=F().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/),dp=B({path:F().min(1),status:V([`added`,`modified`,`deleted`]),added:L().int().nonnegative().nullable(),removed:L().int().nonnegative().nullable()}),fp=B({changes:z(B({commit:up,at:K,kind:V([`turn`,`board`,`merge`]),author:F(),turnId:W.optional(),subject:F(),files:z(dp)})),more:R()}),pp=dp.pick({path:!0,status:!0}).extend({patch:F().nullable(),truncated:R()}),mp=B({topic:U,project:U.nullable(),revision:L().int().min(0),updatedBy:U,updatedAt:K}),hp=B({topic:U,project:U.nullable(),removedBy:U,removedAt:K}),gp=B({project:U,revision:L().int().min(0),updatedBy:U.optional(),updatedAt:K.optional(),body:F()}),_p=B({scope:U,thread:W.optional(),channel:U.optional()}),vp=B({path:F().min(1),size:L().int().nonnegative(),executable:R()}),yp=B({commit:up,takenAt:K,files:z(vp)}),bp=vp.extend({text:F().nullable(),truncated:R()}),xp=B({id:W,kind:Wf,proposedBy:U,status:Gf,createdAt:K,filedFrom:_p.optional(),skillFiles:yp.optional(),decidedBy:U.optional(),decidedAt:K.optional(),reason:F().optional(),charter:xu(F(),cu()),provisionedAt:K.optional(),provision:xu(F(),cu()).optional()}),Sp=B({id:W,proposalId:W,decidedBy:U,outcome:V([`approved`,`rejected`]),reason:F().optional(),ts:K}),Cp=Xu({offset:!0}),wp=F().trim().min(1).max(120),Tp=F().trim().min(1).max(4e3);B({channel:G.optional(),body:F().min(1),thread_id:W.optional()}),B({since_cursor:W.nullable().optional(),limit:L().int().positive().max(200).default(50),advance:R().default(!0)}),B({query:F().min(1),project:U.optional(),channel:G.optional(),limit:L().int().positive().max(100).default(20)}),B({task_id:W.optional(),proposal_id:W.optional(),channel:G.optional(),title:F().min(1).max(200).optional()}),B({thread_id:W,summary:F().min(1)}),B({project:U,title:F().min(1).max(200),body:F().default(``),parent_id:W.optional(),required_capabilities:z(F()).default([]),stages:z(_f).min(1).optional(),channel:U.default(`general`)}),B({task_id:W}),B({task_id:W}),B({task_id:W,stage:pf.optional(),status:V([`abandoned`]).optional(),note:F().min(1).optional(),blocked_by:z(W).optional(),pull_request:B({url:lf,merge_subject:uf.optional(),merge_body:F().max(2e4).optional()}).nullable().optional()}),B({task_id:W}),B({channel:G}),B({channel:G}),B({kind:Wf,charter:xu(F(),cu()),rationale:F().default(``)}),B({proposal_id:W,reason:F().optional()}),B({proposal_id:W,reason:F().min(1)}),B({slug:U,name:F().min(1).optional(),repo:F().min(1).nullable().default(null),default_branch:ff.default(`main`),on_done:cf.optional()}),B({project:U,agent:U.optional()}),B({project:U,agent:U.optional()}),B({project:U.nullable().default(null),topic:U,body:F().min(1),revision:L().int().min(0)}),B({project:U.nullable().default(null),topic:U}),B({task_id:W,stages:z(vf),on_done:cf.optional()}),B({task_id:W,note:F().min(1).optional()}),B({project:U,on_done:cf.optional(),name:F().trim().min(1).max(120).optional(),default_branch:ff.optional()}),B({project:U,reason:F().min(1)}),B({project:U.nullable().default(null),name:U,purpose:F().min(1)}),B({channel:G,reason:F().min(1)}),B({project:U,body:F().min(1),revision:L().int().min(0)}),B({title:wp,note:Tp,cron:Nd.optional(),timezone:Ad.optional(),at:Cp.optional(),agent:U.optional(),project:U.optional(),thread_id:W.optional(),channel:U.optional()}),B({cron_id:W,paused:R().optional(),title:wp.optional(),note:Tp.optional(),cron:Nd.optional(),timezone:Ad.nullable().optional(),at:Cp.optional()}),B({cron_id:W,reason:F().trim().min(1)}),B({name:U,reason:F().trim().min(1)});var Ep=B({id:W,ts:K,type:V(`society.initialized,project.added,project.configured,project.archived,project.placed,agent.added,agent.configured,agent.placed,message.posted,thread.opened,thread.closed,task.created,task.claimed,task.released,task.updated,task.planned,task.advanced,task.moved,task.completing,task.completed,task.reopened,lease.expired,subscription.changed,proposal.created,proposal.decided,proposal.provisioned,proposal.files_taken,channel.added,channel.archived,role.added,agent.retired,agent.joined,agent.left,knowledge.written,knowledge.removed,dashboard.updated,skill.promoted,skill.removed,runner.added,user.signed_in,user.signed_out,user.token_rotated,runner.changed,runner.quota,ops.signal,paused.changed,wake.requested,turn.started,turn.steered,turn.stopped,turn.completed,turn.failed,merge.completed,merge.failed,pull_request.closed,pull_request.close_failed,workspace.leftovers,society.configured,cron.created,cron.updated,cron.fired,cron.skipped,cron.ended`.split(`,`)),actor:U,payload:xu(F(),cu())}),Dp=B({inputTokens:L().int().nonnegative(),outputTokens:L().int().nonnegative(),cacheReadTokens:L().int().nonnegative().default(0),cacheWriteTokens:L().int().nonnegative().default(0)});function Op(e,t){return{inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens+t.cacheWriteTokens}}var kp=B({summary:F().min(1),claimsHeld:z(W).default([]),blockedOn:z(F()).default([]),needsUserDecision:R().default(!1),memoryUpdated:R().default(!1)}),Ap=V([`completed`,`timeout`,`error`,`interrupted`,`blocked`,`stopped`]),jp=_u(`type`,[B({type:H(`turn_started`),agent:U,session:F(),runner:U,model:F().optional()}),B({type:H(`steered`),steer:F().min(1),messages:z(W).optional(),text:F().optional()}),B({type:H(`text`),delta:F()}),B({type:H(`tool_call`),name:F(),input:cu()}),B({type:H(`tool_result`),name:F(),ok:R(),output:F().optional()}),B({type:H(`approval_requested`),kind:F(),detail:cu()}),B({type:H(`turn_completed`),usage:Dp,costUsd:L().nonnegative(),status:kp.nullable(),exitReason:Ap}),B({type:H(`error`),message:F()})]),Mp=B({ts:K,event:jp}),Np=B({seq:L().int().positive(),ts:K,agent:U,project:U,thread:W.optional(),channel:U.optional(),event:jp});B({protocol:L().int().positive(),version:F().min(1),os:Vf,clis:z(Y),residentClis:z(Y).default([]),steerableClis:z(Y).default([]),stoppableClis:z(Y).default([]),branchReads:R().default(!1),branchChanges:R().default(!1),quotaReads:R().default(!1),capabilities:z(F()).default([]),gitIdentityMissing:z(Hf).optional(),slots:L().int().positive().nullable(),turns:z(W).default([])}),B({name:U,version:F()}),B({protocol:L().int().positive(),version:F().min(1).max(64),hostname:F().min(1).max(253),os:Vf,clis:z(Y).max(8),capabilities:z(F().min(1).max(64)).max(32).default([])}),B({deviceCode:F().min(1),userCode:F().min(1),expiresAt:K,intervalMs:L().int().positive()}),B({deviceCode:F().min(1)}),_u(`status`,[B({status:H(`pending`)}),B({status:H(`approved`),name:U,token:F().min(1)}),B({status:H(`denied`)})]);var Pp=B({userCode:F().min(1),hostname:F(),os:Vf,clis:z(Y),capabilities:z(F()),version:F(),requestedAt:K,expiresAt:K}),Fp=B({slug:U,origin:F().nullable(),defaultBranch:F().min(1),boardLands:R()}),Ip=_u(`kind`,[B({kind:H(`home`),thread:W.optional(),channel:U.optional()}),B({kind:H(`project`),repo:Fp,branches:z(F().min(1)),thread:W.optional(),channel:U.optional()}),B({kind:H(`task`),repo:Fp,taskId:W})]),Lp=B({turnId:W,agent:U,role:U,cli:Y,model:F().optional(),effort:F().optional(),scope:U,thread:W.optional(),channel:U.optional(),session:F().min(1).nullable(),costSoFarUsd:L().nonnegative(),instructions:F(),prompt:F(),mcp:B({url:F().min(1),token:F().min(1)}),limits:B({timeoutMs:L().int().positive().nullable(),maxTurns:L().int().positive().nullable()}),resident:B({key:F().min(1),idleMs:L().int().positive()}).optional(),workspace:Ip}),Rp=B({branch:F().min(1),head:F().min(1)});B({entries:z(Mp)}),B({exitReason:Ap,status:kp.nullable(),error:F().nullable(),usage:Dp,costUsd:L().nonnegative(),sessionCostUsd:L().nonnegative().optional(),session:F().min(1),model:F().nullable(),work:Rp.nullable(),leftovers:R().default(!1),quota:qd.optional()}),B({dropWorkspace:R()});var zp=B({repo:Fp,branch:F().min(1),pullRequest:B({url:F().min(1),subject:F().min(1).optional(),body:F().optional()}).optional()}),Bp=B({repo:Fp,url:F().min(1),comment:F().min(1)});B({ok:R(),detail:F()});var Vp=8388608,Hp=F().max(4096).refine(e=>e===``||e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&!e.includes(`\0`)),{message:"a path inside the branch, with no empty, `.`, or `..` segment"}),Up=F().regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/),Wp=B({repo:Fp,branch:Up,path:Hp}),Gp=B({id:F().min(1),at:K,author:F()}),Kp=_u(`kind`,[B({kind:H(`file`),path:Hp,commit:Gp,size:L().int().nonnegative(),content:F().nullable()}),B({kind:H(`dir`),path:Hp,commit:Gp,entries:z(B({name:F().min(1),kind:V([`file`,`dir`]),size:L().int().nonnegative().nullable()}))})]),qp=B({repo:Fp,branch:Up}),Jp=B({path:F().min(1),status:V([`added`,`modified`,`deleted`]),added:L().int().nonnegative().nullable(),removed:L().int().nonnegative().nullable(),lastChange:B({author:F(),at:K}).optional()}),Yp=B({head:Gp,files:z(Jp),total:L().int().nonnegative()}),Xp=B({repo:Fp,branch:Up,path:Hp.min(1)}),Zp=B({head:Gp,path:Hp,status:Jp.shape.status,patch:F().nullable(),truncated:R()}),Qp=_u(`kind`,[B({kind:H(`thread`),id:W}),B({kind:H(`channel`),scope:U,name:U})]),$p=B({agent:U,scope:U,conversation:Qp});B({workspaces:z($p)}),B({kept:z($p)});var em=B({id:zl(),text:F().min(1)});_u(`type`,[B({type:H(`turn`),job:Lp}),B({type:H(`land`),request:F().min(1),land:zp}),B({type:H(`close`),request:F().min(1),close:Bp}),B({type:H(`models`),request:F().min(1),cli:Y}),B({type:H(`quota`),request:F().min(1),cli:Y}),B({type:H(`file`),request:F().min(1),read:Wp}),B({type:H(`changes`),request:F().min(1),read:qp}),B({type:H(`diff`),request:F().min(1),read:Xp}),B({type:H(`steer`),request:F().min(1),turnId:W,steer:em}),B({type:H(`stop`),request:F().min(1),turnId:W}),B({type:H(`sweep`),request:F().min(1),conversation:Qp})]),_u(`ok`,[B({ok:H(!0),value:cu()}),B({ok:H(!1),error:F()})]),B({warm:z(F())}),B({files:xu(F(),F())}),B({paths:z(F())}),B({files:xu(F(),F())});var tm=B({kind:V([`mention`,`stage`,`task_done`,`proposal_decided`,`heartbeat`,`reflection`,`onboarding`,`manual`,`ops_event`,`user_post`,`closing`,`cron`]),from:U.optional(),fromUser:R().default(!1),reason:F().default(``),taskId:W.optional(),messageId:W.optional(),channel:G.optional(),cronId:W.optional()});B({agent:U,project:U,thread:B({id:W,task:R()}).optional(),channel:U.optional(),trigger:tm,priority:L().int().min(0).max(2),onboarding:R().default(!1),crons:z(W).optional()});function nm(e){return e.thread??(e.channel===void 0?void 0:`#${e.channel}`)}function rm(e,t,n){return n===void 0?`${e}/${t}`:`${e}/${t}/${n}`}function im(e){let[t,n,r,i]=e.split(`/`);return t===void 0||n===void 0||i!==void 0?null:r===void 0?{agent:t,scope:n}:r.startsWith(`#`)?{agent:t,scope:n,channel:r.slice(1)}:{agent:t,scope:n,thread:r}}B({id:W.optional(),agent:U,project:U,thread:W.optional(),channel:U.optional(),runner:U,cli:Y.nullable(),session:F().nullable(),trigger:tm,startedAt:K,endedAt:K.nullable(),exitReason:Ap.nullable(),status:kp.nullable(),error:F().nullable(),usage:Dp.nullable(),costUsd:L().nonnegative().default(0),sessionCostUsd:L().nonnegative().optional(),toolCalls:L().int().nonnegative().default(0),model:F().nullable().default(null),work:Rp.optional(),stoppedBy:U.optional(),crons:z(W).optional()});var am=B({turnId:W,agent:U,scope:U,thread:W.optional(),channel:U.optional(),cli:Y,askedIn:G.optional(),steerable:R(),stoppable:R()});B({claude:F().optional(),codex:F().optional(),runner:U.optional()}),B({agent:U,project:U,reason:F().default(`manual wake`),kind:V([`manual`,`reflection`]).default(`manual`)});var om=B({id:W,turnId:W.optional(),ts:K,outcome:V([`completed`,`failed`]),project:U,thread:W.optional(),channel:U.optional(),trigger:F(),exitReason:F().nullable(),costUsd:L(),usage:Dp.optional(),model:F().nullable(),summary:F().nullable(),error:F().nullable(),startedAt:K.optional(),toolCalls:L().int().nonnegative().optional()}),sm=V([`waiting_stage`,`backlog`,`role_gap`,`churn`,`stale_thread`,`idle_member`,`blocked_capability`,`turn_cost`,`scaled`,`runner`,`home_conflict`,`stuck_workspace`,`cron_failing`]),cm=[`backlog`,`role_gap`,`churn`,`stale_thread`,`idle_member`,`blocked_capability`,`scaled`],lm=B({kind:sm,key:F().min(1),summary:F().min(1),value:L(),threshold:L().optional(),project:U.optional(),agent:U.optional(),role:U.optional(),taskId:W.optional()}),um=V([`24h`,`7d`,`all`]),X=L().int().nonnegative(),dm=L().nonnegative(),fm=B({window:um,since:K.nullable(),until:K,idle:B({turns:X,idle:X,unknown:X,byTrigger:z(B({trigger:F(),turns:X,idle:X})),byAgent:z(B({agent:U,role:U.nullable(),turns:X,idle:X}))}),sentBack:B({finished:X,sendBacks:X,tasksSentBack:X,byStage:z(B({project:U,stage:F(),count:X})),bySender:z(B({agent:U,count:X}))}),messages:B({finished:X,messages:X,byProject:z(B({project:U,finished:X,messages:X})),busiest:z(B({taskId:W,title:F(),project:U,messages:X}))}),latency:B({mentions:X,unanswered:X,medianMs:dm.nullable(),slowestMs:dm.nullable(),byAgent:z(B({agent:U,mentions:X,medianMs:dm,slowestMs:dm}))}),decisions:B({total:X,byDay:z(B({day:F(),proposals:X,answers:X,stages:X}))}),blocked:z(B({taskId:W,title:F().nullable(),project:U.nullable(),summary:F(),firstAt:K,lastAt:K,holds:R()}))}),pm=B({agent:U,turns:X,withUsage:X,usage:Dp.nullable()}),mm=B({window:um,since:K.nullable(),until:K,citizens:z(pm)}),hm=V([`trace`,`debug`,`info`,`warn`,`error`,`fatal`]),gm=B({clientId:F().min(1),clientSecret:F().min(1),users:z(F().min(1)).min(1)});B({dataDir:F().min(1),host:F().min(1),port:L().int().positive().max(65535),publicUrl:F().min(1).nullable(),logLevel:hm,concurrency:L().int().positive().nullable(),turnTimeoutMs:L().int().positive().nullable(),toolRounds:L().int().positive().nullable(),residentIdleMs:L().int().positive(),github:gm.nullable(),trustedProxies:L().int().min(0).max(16)}),B({serverUrl:F().url(),token:F().min(1).nullable(),dataDir:F().min(1),logLevel:hm,slots:L().int().positive().nullable(),clis:z(Y).min(1),capabilities:z(F())});var _m=`stellaris.token`;function vm(){return localStorage.getItem(_m)}function ym(e){localStorage.setItem(_m,e)}function bm(){localStorage.removeItem(_m)}var xm=B({github:R()});async function Sm(){try{let e=xm.safeParse(await(await fetch(`/auth/config`)).json());return e.success?e.data:{github:!1}}catch{return{github:!1}}}var Cm=class extends Error{status;constructor(e,t){super(t),this.status=e}},wm=B({name:U,role:U,signIn:B({login:F().min(1),avatarUrl:Vl()}).optional()}),Tm=Bf.extend({profile:F()}).array(),Em=B({paused:R(),running:z(F()),pending:z(F()),resident:z(F()),signals:z(F()),turns:z(am).default([])});function Dm(e){return e.flatMap(e=>{let t=im(e);return t===null?[]:[t]})}var Om=Cf.extend({body:F()}),km=Om.array(),Am=B({ref:G,project:U.nullable(),name:U,messages:L().int(),lastMessageId:W.nullable(),lastAt:F().nullable(),archived:of.optional()}),jm=Of.extend({body:F()}),Mm=jm.extend({messages:L().int(),lastMessageId:W.nullable(),lastAuthor:U.nullable().default(null)}),Nm=B({thread:jm,messages:km}),Pm=B({message:Om,thread:jm.nullable()}),Fm=jf.extend({body:F()}),Im=xp.extend({body:F()}),Lm=mp.extend({body:F()}),Rm=Id.extend({note:F()}),zm=B({body:F()});function Bm(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Vm(e){return e.split(`/`).filter(e=>e!==``).map(e=>`/${encodeURIComponent(e)}`).join(``)}var Hm=B({message:F()});async function Z(e,t,n){let r;try{r=await fetch(e,{headers:{authorization:`Bearer ${t}`}})}catch{throw new Cm(0,`The board server is not reachable.`)}if(!r.ok){let t=Hm.safeParse(await r.json().catch(()=>null));throw new Cm(r.status,t.success?t.data.message:`${e} answered ${r.status}`)}return n.parse(await r.json())}async function Um(e,t,n,r,i){let a;try{a=await fetch(t,{method:e,headers:{authorization:`Bearer ${n}`,"content-type":`application/json`},body:JSON.stringify(r)})}catch{throw new Cm(0,`The board server is not reachable.`)}if(!a.ok){let e=Hm.safeParse(await a.json().catch(()=>null));throw new Cm(a.status,e.success?e.data.message:`${t} answered ${a.status}`)}return i.parse(await a.json())}function Q(e,t,n,r){return Um(`POST`,`/api/verbs/${e}`,t,n,r)}var Wm=B({paused:R()}),Gm=B({version:F()}),Km=B({id:W,ts:F(),signal:lm}),qm=zf.omit({tokenHash:!0}),Jm=B({signedOut:R()}),Ym=B({denied:R()}),Xm=B({stopped:R()});function Zm(e){return{me:()=>Z(`/api/me`,e,wm),signOut:()=>Um(`DELETE`,`/api/sign-in`,e,{},Jm),society:()=>Z(`/api/society`,e,sf),version:async()=>(await Z(`/api/version`,e,Gm)).version,members:()=>Z(`/api/members`,e,Tm),projects:()=>Z(`/api/projects`,e,yf.array()),roles:()=>Z(`/api/roles`,e,ed.array()),scheduler:()=>Z(`/api/scheduler`,e,Em),signals:t=>Z(`/api/signals?limit=${t}`,e,Km.array()),metrics:t=>Z(`/api/metrics?window=${t}`,e,fm),tokens:t=>Z(`/api/tokens?window=${t}`,e,mm),channels:()=>Z(`/api/channels`,e,Am.array()),channel:t=>Z(`/api/channels/${Bm(t)}`,e,km),threads:()=>Z(`/api/threads`,e,Mm.array()),requests:()=>Z(`/api/requests`,e,Pm.array()),thread:t=>Z(`/api/threads/${encodeURIComponent(t)}`,e,Nm),tasks:t=>Z(`/api/projects/${encodeURIComponent(t)}/tasks`,e,Fm.array()),task:t=>Z(`/api/tasks/${encodeURIComponent(t)}`,e,Fm),taskFile:(t,n)=>Z(`/api/tasks/${encodeURIComponent(t)}/files${Vm(n)}`,e,Kp),taskChanges:t=>Z(`/api/tasks/${encodeURIComponent(t)}/changes`,e,Yp),taskDiff:(t,n)=>Z(`/api/tasks/${encodeURIComponent(t)}/diff${Vm(n)}`,e,Zp),proposals:()=>Z(`/api/proposals`,e,Im.array()),crons:()=>Z(`/api/crons`,e,Rm.array()),createCron:t=>Q(`create_cron`,e,t,Rm),pauseCron:(t,n)=>Q(`update_cron`,e,{cron_id:t,paused:n},Rm),removeCron:(t,n)=>Q(`remove_cron`,e,{cron_id:t,reason:n},Rm),setTimezone:t=>Um(`PUT`,`/api/society/timezone`,e,{timezone:t},sf),proposal:t=>Z(`/api/proposals/${encodeURIComponent(t)}`,e,Im),messages:t=>Z(`/api/messages?ids=${t.join(`,`)}`,e,wf.array()),proposalFiles:t=>Z(`/api/proposals/${encodeURIComponent(t)}/files`,e,bp.array()),skills:()=>Z(`/api/skills`,e,sp.array()),turns:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/turns?limit=${n}`,e,om.array()),transcript:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/turns/${encodeURIComponent(n)}`,e,Mp.array()),memory:t=>Z(`/api/agents/${encodeURIComponent(t)}/memory`,e,zm),agentSkills:t=>Z(`/api/agents/${encodeURIComponent(t)}/skills`,e,sp.array()),history:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/history?limit=${n}`,e,fp),change:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/history/${encodeURIComponent(n)}`,e,pp.array()),conflicts:t=>Z(`/api/agents/${encodeURIComponent(t)}/conflicts`,e,lp.array()),dashboard:t=>Z(`/api/projects/${encodeURIComponent(t)}/dashboard`,e,gp),knowledge:t=>Z(t===`society`?`/api/society/knowledge`:`/api/projects/${encodeURIComponent(t)}/knowledge`,e,Lm.array()),sendMessage:t=>Q(`post_message`,e,t,Om),openThread:t=>Q(`open_thread`,e,t,jm),closeThread:t=>Q(`close_thread`,e,t,Om),approve:t=>Q(`approve`,e,t,Sp),reject:t=>Q(`reject`,e,t,Sp),advanceTask:t=>Q(`advance_task`,e,t,Fm),configureProject:(t,n)=>Q(`configure_project`,e,{project:t,...n},yf),createChannel:t=>Q(`create_channel`,e,t,G),archiveChannel:t=>Q(`archive_channel`,e,t,of),removeKnowledge:t=>Q(`remove_knowledge`,e,t,hp),removeSkill:t=>Q(`remove_skill`,e,t,cp),wake:t=>Um(`POST`,`/api/wake`,e,t,Ep),setPaused:t=>Um(`POST`,t?`/api/pause`:`/api/resume`,e,{},Wm),stopTurn:t=>Um(`POST`,`/api/turns/${encodeURIComponent(t)}/stop`,e,{},Xm),agentModels:t=>Z(`/api/agents/${encodeURIComponent(t)}/models`,e,Lf),runners:()=>Z(`/api/runners`,e,Uf.array()),readQuota:(t,n)=>Um(`POST`,`/api/runners/${encodeURIComponent(t)}/quota/${n}`,e,{},qd),enrollments:()=>Z(`/api/enrollments`,e,Pp.array()),approveEnrollment:(t,n)=>Um(`POST`,`/api/enrollments/${encodeURIComponent(t)}/approve`,e,{name:n},Uf),denyEnrollment:t=>Um(`POST`,`/api/enrollments/${encodeURIComponent(t)}/deny`,e,{},Ym),setRunner:(t,n)=>Um(`PUT`,`/api/agents/${encodeURIComponent(t)}/runner`,e,{runner:n},qm),setModel:(t,n)=>Um(`PUT`,`/api/agents/${encodeURIComponent(t)}/model`,e,{model:n},qm),setEffort:(t,n)=>Um(`PUT`,`/api/agents/${encodeURIComponent(t)}/effort`,e,{effort:n},qm)}}var Qm=(0,m.createContext)(null);function $(){let e=(0,m.useContext)(Qm);if(e===null)throw Error(`useSession needs a signed-in SessionContext`);return e}function $m(){let{api:e}=$();return C({queryKey:[`society`],queryFn:e.society,staleTime:6e4})}function eh(){let{api:e}=$();return C({queryKey:[`server-version`],queryFn:e.version,staleTime:1/0})}function th(){let{api:e}=$();return C({queryKey:[`me`],queryFn:e.me,staleTime:1/0})}function nh(){let{api:e}=$();return C({queryKey:[`members`],queryFn:e.members,refetchInterval:3e4})}function rh(){let{api:e}=$();return C({queryKey:[`projects`],queryFn:e.projects,refetchInterval:6e4})}function ih(){let{api:e}=$();return C({queryKey:[`roles`],queryFn:e.roles,refetchInterval:6e4})}function ah(){let{api:e}=$();return C({queryKey:[`scheduler`],queryFn:e.scheduler,refetchInterval:3e3})}function oh(){let{api:e}=$();return C({queryKey:[`requests`],queryFn:e.requests,refetchInterval:6e4})}function sh(e){let{api:t}=$();return C({queryKey:[`signals`],queryFn:()=>t.signals(200),enabled:e,refetchInterval:6e4})}function ch(e){let{api:t}=$();return C({queryKey:[`metrics`,e],queryFn:()=>t.metrics(e),refetchInterval:6e4})}function lh(e){let{api:t}=$();return C({queryKey:[`tokens`,e],queryFn:()=>t.tokens(e),refetchInterval:6e4})}function uh(){let{api:e}=$();return C({queryKey:[`channels`],queryFn:e.channels,refetchInterval:6e4})}function dh(){let{api:e}=$();return C({queryKey:[`threads`],queryFn:e.threads,refetchInterval:6e4})}function fh(e){let{api:t}=$();return C({queryKey:[`tasks`,e],queryFn:()=>t.tasks(e),refetchInterval:6e4})}function ph(e){return e.flatMap(e=>e.data??[])}function mh(){let{api:e}=$();return ut({queries:(rh().data??[]).map(t=>({queryKey:[`tasks`,t.slug],queryFn:()=>e.tasks(t.slug),refetchInterval:6e4})),combine:ph})}function hh(e){let{api:t}=$();return C({queryKey:[`task`,e],queryFn:()=>t.task(e??``),enabled:e!==null})}function gh(e){let{api:t}=$();return C({queryKey:[`thread`,e],queryFn:()=>t.thread(e??``),enabled:e!==null})}function _h(e,t){let{api:n}=$();return C({queryKey:[`task-file`,e,t],queryFn:()=>n.taskFile(e,t),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof Cm&&(t.status===404||t.status===503))})}function vh(e){let{api:t}=$();return C({queryKey:[`task-changes`,e],queryFn:()=>t.taskChanges(e),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof Cm&&(t.status===404||t.status===503))})}function yh(e,t){let{api:n}=$();return C({queryKey:[`task-diff`,e,t],queryFn:()=>n.taskDiff(e,t),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof Cm&&(t.status===404||t.status===503))})}function bh(){let{api:e}=$();return C({queryKey:[`crons`],queryFn:e.crons,refetchInterval:6e4})}function xh(){let{api:e}=$();return C({queryKey:[`proposals`],queryFn:e.proposals,refetchInterval:6e4})}function Sh(e){let{api:t}=$();return C({queryKey:[`proposal`,e],queryFn:()=>t.proposal(e)})}function Ch(e,t){let{api:n}=$();return C({queryKey:[`proposal`,e,`files`],queryFn:()=>n.proposalFiles(e),enabled:t})}function wh(){let{api:e}=$();return C({queryKey:[`skills`],queryFn:e.skills,staleTime:6e4})}function Th(e,t){let{api:n}=$();return C({queryKey:[`turns`,e,t],queryFn:()=>n.turns(e,t),refetchInterval:6e4})}function Eh(e,t){let{api:n}=$();return C({queryKey:[`transcript`,e,t],queryFn:()=>n.transcript(e,t??``),enabled:t!==null,staleTime:1/0})}function Dh(e){let{api:t}=$();return C({queryKey:[`memory`,e],queryFn:()=>t.memory(e)})}function Oh(e){let{api:t}=$();return C({queryKey:[`agent-skills`,e],queryFn:()=>t.agentSkills(e)})}function kh(e,t){let{api:n}=$();return C({queryKey:[`history`,e,t],queryFn:()=>n.history(e,t),placeholderData:ve})}function Ah(e,t,n){let{api:r}=$();return C({queryKey:[`home-change`,e,t],queryFn:()=>r.change(e,t),enabled:n,staleTime:1/0})}function jh(e){let{api:t}=$();return C({queryKey:[`conflicts`,e],queryFn:()=>t.conflicts(e)})}function Mh(e){let{api:t}=$();return C({queryKey:[`dashboard`,e],queryFn:()=>t.dashboard(e),refetchInterval:12e4})}function Nh(e){let{api:t}=$();return C({queryKey:[`knowledge`,e],queryFn:()=>t.knowledge(e),refetchInterval:12e4})}function Ph(){let{api:e}=$();return C({queryKey:[`runners`],queryFn:()=>e.runners(),refetchInterval:6e4})}function Fh(){let{api:e}=$();return C({queryKey:[`enrollments`],queryFn:e.enrollments,refetchInterval:5e3})}function Ih(e){let{api:t}=$();return C({queryKey:[`models`,`agent`,e],queryFn:()=>t.agentModels(e),staleTime:6e5,retry:!1})}function Lh(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Rh=[[`day`,86400],[`hour`,3600],[`minute`,60]],zh=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});function Bh(e,t){let n=Math.round((Date.parse(e)-t)/1e3);for(let[e,t]of Rh)if(Math.abs(n)>=t)return zh.format(Math.round(n/t),e);return`just now`}function Vh(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Hh(e,t=220){let n=(e.split(/\n\s*\n/).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith(`#`))??``).replaceAll(/[*_`>]/g,``).replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`}export{nm as $,Ft as $t,$ as A,ce as An,zd as At,dh as B,d as Bn,R as Bt,Ch as C,je as Cn,Yd as Ct,Ph as D,ue as Dn,Ed as Dt,ih as E,oe as En,Zd as Et,vh as F,Ce as Fn,nd as Ft,Sm as G,tn as Gt,Eh as H,s as Hn,xu as Ht,yh as I,xe as In,td as It,Dm as J,Gt as Jt,bm as K,Yt as Kt,_h as L,te as Ln,W as Lt,wh as M,de as Mn,Vd as Mt,$m as N,y as Nn,Bd as Nt,ah as O,le as On,kd as Ot,hh as P,me as Pn,ed as Pt,cm as Q,Lt as Qt,fh as R,g as Rn,Zu as Rt,Sh as S,Me as Sn,Mf as St,oh as T,De as Tn,Jd as Tt,Th as U,l as Un,F as Ut,lh as V,o as Vn,B as Vt,Cm as W,vn as Wt,vm as X,Rt as Xt,ym as Y,Mt as Yt,um as Z,Vt as Zt,nh as _,vt as _n,op as _t,Ih as a,kt as an,Op as at,Lh as b,Le as bn,ip as bt,uh as c,pt as cn,qf as ct,Fh as d,mt as dn,Jf as dt,Nt as en,im as et,Ah as f,Ot as fn,$f as ft,th as g,Dt as gn,Nf as gt,Nh as h,_t as hn,Xf as ht,Qm as i,gt as in,Np as it,sh as j,ae as jn,Hd as jt,eh as k,b as kn,Md as kt,bh as l,Et as ln,Yf as lt,kh as m,ft as mn,tp as mt,Hh as n,Tt as nn,Vp as nt,Oh as o,bt as on,ef as ot,jh as p,xt as pn,af as pt,Zm as q,Jt as qt,Vh as r,jt as rn,Ep as rt,mh as s,At as sn,ep as st,Bh as t,Pt as tn,rm as tt,Mh as u,ht as un,Kf as ut,Dh as v,C as vn,rf as vt,xh as w,Oe as wn,$d as wt,rh as x,Ie as xn,Qf as xt,ch as y,Ve as yn,xf as yt,gh as z,p as zn,z as zt};
55
+ 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}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function _c(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;_c(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}var vc=new Set([`type`,`properties`,`required`,`additionalProperties`]),yc=[`oneOf`,`anyOf`];function bc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function xc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!vc.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]??bc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}On(n,r,e.length===1?e[0]:xc(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=bc(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 Sc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of vc)if(t in e)return;let n=t.filter(e=>yc.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=xc(t);else{let e=n[0],i=yc.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=>xc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,fc(e,r))}function Cc(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)):fc(i,s),fc(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())_c(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)??[])Sc(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)}fc(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,On(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:Tc(t,`input`,e.processors),output:Tc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function M(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 M(r.element,n);if(r.type===`set`)return M(r.valueType,n);if(r.type===`lazy`)return M(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 M(r.innerType,n);if(r.type===`intersection`)return M(r.left,n)||M(r.right,n);if(r.type===`record`||r.type===`map`)return M(r.keyType,n)||M(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:M(r.in,n)||M(r.out,n);if(r.type===`object`){for(let e in r.shape)if(M(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(M(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(M(e,n))return!0;return!!(r.rest&&M(r.rest,n))}return!1}var wc=(e,t={})=>n=>{let r=pc({...n,processors:t});return j(e,r),gc(r,e),Cc(r,e)},Tc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=pc({...i??{},target:a,io:t,processors:n});return j(e,o),gc(o,e),Cc(o,e)},Ec=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Dc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Oc=(e,t)=>{Ec(e,`minimum`,t),Dc(e,`maximum`,t)},kc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ac=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},jc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Mc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Nc=(e,t)=>Ec(e,`minimum`,t.minimum),Pc=(e,t)=>Dc(e,`maximum`,t.maximum),Fc=e=>(t,n)=>{Mc(t,n.format);let[r,i]=e[n.format];Ec(t,`minimum`,r),Dc(t,`maximum`,i)},Ic={greater_than:(e,t)=>Ec(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Dc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>kc(e,t.value),number_format:Fc(qn),bigint_format:Fc(Jn),min_length:Nc,max_length:Pc,length_equals:(e,t)=>Oc(e,t.length),min_size:Nc,max_size:Pc,size_equals:(e,t)=>Oc(e,t.size),string_format:(e,t)=>{Mc(e,t.format),t.pattern&&Ac(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>jc(e,t.mime)};function Lc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ic[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ec(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ec(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Dc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Dc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&kc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&jc(t,i.mime);for(let e of i.patterns??[])Ac(t,e);return t}var Rc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},zc=new Map([[Ua,Oi],[Ga,ki]]),Bc=e=>zc.get(e)??e,Vc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Lc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Rc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Bc);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}))])}},Hc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Lc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):mc(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Uc=(e,t,n,r)=>{n.type=`boolean`},Wc=(e,t,n,r)=>{n.not={}},Gc=(e,t,n,r)=>{let i=e._zod.def,a=bn(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},Kc=(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(mc(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(mc(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}},qc=(e,t,n,r)=>{mc(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Jc=(e,t,n,r)=>{mc(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Yc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Lc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})};function Xc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Xc(t.out):t.type===`catch`?Xc(t.innerType):e._zod.optin}var Zc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&mc(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)On(i.properties,e,j(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Xc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Qc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},$c=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(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)};function el(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=el(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=>el(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`)?Bi:zi).source),p):p}var tl=new WeakMap;function nl(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 tl.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=el(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)}}var rl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Lc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=j(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)On(i.patternProperties,Bc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=j(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=tl.get(t);n||(n=[],tl.set(t,n),t.deferred.push(()=>nl(t))),n.push(e)}i.additionalProperties=j(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Xc(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))}},il=(e,t,n,r)=>{let i=e._zod.def,a=j(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`}]},al=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ol=Symbol();function sl(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(mc(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ol):JSON.parse(o)}var cl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=sl(i.defaultValue,e,t,n,r);o!==ol&&(n.default=o)},ll=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=sl(i.defaultValue,e,t,n,r);o!==ol&&(n._prefault=o)},ul=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{mc(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},dl=(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;j(o,t,r);let s=t.seen.get(e);s.ref=o},fl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pl=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ml=new WeakSet([Object.prototype,Error.prototype]);function hl(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})}})}var N=D(`ZodError`,(e,t)=>{Hr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ml.has(n)||(ml.add(n),hl(n,`format`,e=>t=>Gr(e,t)),hl(n,`flatten`,e=>t=>Wr(e,t)),hl(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Sn,2)}),hl(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Sn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),gl=qr(N),_l=Jr(N),vl=Yr(N),yl=Zr(N),bl=ri(N),xl=ii(N),Sl=ai(N),Cl=oi(N),wl=si(N),Tl=ci(N),El=li(N),Dl=ui(N);function Ol(){Pr.localeError||Fr(is())}function kl(){Pr.memoizer||Fr({memoizer:ts()})}var P=D(`ZodType`,(e,t)=>(Ol(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(w(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 Wn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qu(e,t))},superRefine(e,t){return this.check(Ju(e,t))},overwrite(e){return this.check(nc(e))},optional(){return Ou(this)},exactOptional(){return Au(this)},nullable(){return Mu(this)},nullish(){return Ou(Mu(this))},nonoptional(e){return Ru(this,e)},array(){return z(this)},or(e){return hu([this,e])},and(e){return yu(this,e)},transform(e){return Hu(this,Eu(e))},default(e){return Pu(this,e)},prefault(e){return Iu(this,e)},catch(e){return Bu(this,e)},pipe(e){return Hu(this,e)},readonly(){return Gu(this)},describe(e){let t=this.clone();return cs.add(t,{description:e}),t},meta(...e){if(e.length===0)return cs.get(this);let t=this.clone();return cs.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 _r(this,`~standard`,{...da(this),jsonSchema:{input:Tc(this,`input`),output:Tc(this,`output`)}})},set"~standard"(e){gr(this,`~standard`,e)},parse:function e(t,n){return gl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await _l(this,t,n,{callee:e})},safeParse(e,t){return vl(this,e,t)},async safeParseAsync(e,t){return yl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){gr(this,`spa`,e)},validate(e,t){return ei(this,e,t)},validateAsync(e,t){return ni(this,e,t)},encode:function e(t,n){return bl(this,t,n,{callee:e})},decode:function e(t,n){return xl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Sl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Cl(this,t,n,{callee:e})},safeEncode(e,t){return wl(this,e,t)},safeDecode(e,t){return Tl(this,e,t)},async safeEncodeAsync(e,t){return El(this,e,t)},async safeDecodeAsync(e,t){return Dl(this,e,t)},toJSONSchema(e){return wc(this,{})(e)},get description(){return cs.get(this)?.description},get _def(){return this._zod.def}}),Al=D(`_ZodString`,(e,t)=>{fa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r)},vr({format:e=>Lc(e).format??null,minLength:e=>Lc(e).minimum??null,maxLength:e=>Lc(e).maximum??null},{regex(...e){return this.check(Xs(...e))},includes(...e){return this.check($s(...e))},startsWith(...e){return this.check(ec(...e))},endsWith(...e){return this.check(tc(...e))},min(...e){return this.check(Js(...e))},max(...e){return this.check(qs(...e))},length(...e){return this.check(Ys(...e))},nonempty(...e){return this.check(Js(1,...e))},lowercase(e){return this.check(Zs(e))},uppercase(e){return this.check(Qs(e))},trim(){return this.check(ic())},normalize(...e){return this.check(rc(...e))},toLowerCase(){return this.check(ac())},toUpperCase(){return this.check(oc())},slugify(){return this.check(sc())}})),jl=D(`ZodString`,(e,t)=>{fa.init(e,t),Al.init(e,t)},{email(e){return this.check(ds(Il,e))},url(e){return this.check(_s(Bl,e))},jwt(e){return this.check(Ms(nu,e))},emoji(e){return this.check(vs(Hl,e))},guid(e){return this.check(fs(Ll,e))},uuid(e){return this.check(ps(Rl,e))},uuidv4(e){return this.check(ms(Rl,e))},uuidv6(e){return this.check(hs(Rl,e))},uuidv7(e){return this.check(gs(Rl,e))},nanoid(e){return this.check(ys(Ul,e))},cuid(e){return this.check(bs(Wl,e))},cuid2(e){return this.check(xs(Gl,e))},ulid(e){return this.check(Ss(Kl,e))},base64(e){return this.check(ks($l,e))},base64url(e){return this.check(As(eu,e))},xid(e){return this.check(Cs(ql,e))},ksuid(e){return this.check(ws(Jl,e))},ipv4(e){return this.check(Ts(Yl,e))},ipv6(e){return this.check(Es(Xl,e))},cidrv4(e){return this.check(Ds(Zl,e))},cidrv6(e){return this.check(Os(Ql,e))},e164(e){return this.check(js(tu,e))},datetime(e){return this.check(Ns(Ml,e))},date(e){return this.check(Ps(Nl,e))},time(e){return this.check(Fs(Pl,e))},duration(e){return this.check(Is(Fl,e))}});function F(e){return us(jl,e)}var I=D(`ZodStringFormat`,(e,t)=>{A.init(e,t),Al.init(e,t)}),Ml=D(`ZodISODateTime`,(e,t)=>{ja.init(e,t),I.init(e,t)}),Nl=D(`ZodISODate`,(e,t)=>{Ma.init(e,t),I.init(e,t)}),Pl=D(`ZodISOTime`,(e,t)=>{Na.init(e,t),I.init(e,t)}),Fl=D(`ZodISODuration`,(e,t)=>{Pa.init(e,t),I.init(e,t)}),Il=D(`ZodEmail`,(e,t)=>{ha.init(e,t),I.init(e,t)}),Ll=D(`ZodGUID`,(e,t)=>{pa.init(e,t),I.init(e,t)}),Rl=D(`ZodUUID`,(e,t)=>{ma.init(e,t),I.init(e,t)});function zl(e){return ps(Rl,e)}var Bl=D(`ZodURL`,(e,t)=>{Ca.init(e,t),I.init(e,t)});function Vl(e){return _s(Bl,e)}var Hl=D(`ZodEmoji`,(e,t)=>{wa.init(e,t),I.init(e,t)}),Ul=D(`ZodNanoID`,(e,t)=>{Ta.init(e,t),I.init(e,t)}),Wl=D(`ZodCUID`,(e,t)=>{Ea.init(e,t),I.init(e,t)}),Gl=D(`ZodCUID2`,(e,t)=>{Da.init(e,t),I.init(e,t)}),Kl=D(`ZodULID`,(e,t)=>{Oa.init(e,t),I.init(e,t)}),ql=D(`ZodXID`,(e,t)=>{ka.init(e,t),I.init(e,t)}),Jl=D(`ZodKSUID`,(e,t)=>{Aa.init(e,t),I.init(e,t)}),Yl=D(`ZodIPv4`,(e,t)=>{Fa.init(e,t),I.init(e,t)}),Xl=D(`ZodIPv6`,(e,t)=>{Ra.init(e,t),I.init(e,t)}),Zl=D(`ZodCIDRv4`,(e,t)=>{za.init(e,t),I.init(e,t)}),Ql=D(`ZodCIDRv6`,(e,t)=>{Va.init(e,t),I.init(e,t)}),$l=D(`ZodBase64`,(e,t)=>{Wa.init(e,t),I.init(e,t)}),eu=D(`ZodBase64URL`,(e,t)=>{qa.init(e,t),I.init(e,t)}),tu=D(`ZodE164`,(e,t)=>{Ja.init(e,t),I.init(e,t)}),nu=D(`ZodJWT`,(e,t)=>{Xa.init(e,t),I.init(e,t)}),ru=D(`ZodNumber`,(e,t)=>{Za.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.isFinite=!0},vr({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Lc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Lc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Lc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Lc(e).format??null},{gt(e,t){return this.check(Ws(e,t))},gte(e,t){return this.check(Gs(e,t))},min(e,t){return this.check(Gs(e,t))},lt(e,t){return this.check(Hs(e,t))},lte(e,t){return this.check(Us(e,t))},max(e,t){return this.check(Us(e,t))},int(e){return this.check(au(e))},safe(e){return this.check(au(e))},positive(e){return this.check(Ws(0,e))},nonnegative(e){return this.check(Gs(0,e))},negative(e){return this.check(Hs(0,e))},nonpositive(e){return this.check(Us(0,e))},multipleOf(e,t){return this.check(Ks(e,t))},step(e,t){return this.check(Ks(e,t))},finite(){return this}}));function L(e){return Ls(ru,e)}var iu=D(`ZodNumberFormat`,(e,t)=>{Qa.init(e,t),ru.init(e,t)});function au(e){return Rs(iu,e)}var ou=D(`ZodBoolean`,(e,t)=>{$a.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)});function R(e){return zs(ou,e)}var su=D(`ZodUnknown`,(e,t)=>{eo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function cu(){return Bs(su)}var lu=D(`ZodNever`,(e,t)=>{to.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r)});function uu(e){return Vs(lu,e)}var du=D(`ZodArray`,(e,t)=>{kl(),ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Js(e,t))},nonempty(e){return this.check(Js(1,e))},max(e,t){return this.check(qs(e,t))},length(e,t){return this.check(Ys(e,t))},unwrap(){return this.element}});function z(e,t){return cc(du,e,t)}var fu=D(`ZodObject`,(e,t)=>{kl(),lo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),wr(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return V(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(w(this._zod.def,{catchall:e}))},passthrough(){return this.clone(w(this._zod.def,{catchall:cu()}))},loose(){return this.clone(w(this._zod.def,{catchall:cu()}))},strict(){return this.clone(w(this._zod.def,{catchall:uu()}))},strip(){return this.clone(w(this._zod.def,{catchall:void 0}))},extend(e){return Qn(this,e)},safeExtend(e){return er(this,e)},merge(e){return tr(this,e)},pick(e){return Yn(this,e)},omit(e){return Zn(this,e)},partial(...e){return nr(Du,this,e[0])},exactPartial(...e){return nr(ku,this,e[0],`exactPartial`)},required(...e){return rr(Lu,this,e[0])}});function B(e,t){return new fu({type:`object`,shape:e??{},...T(t)})}function pu(e,t){return new fu({type:`object`,shape:e,catchall:uu(),...T(t)})}var mu=D(`ZodUnion`,(e,t)=>{fo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.options=t.options});function hu(e,t){return new mu({type:`union`,options:e,...T(t)})}var gu=D(`ZodDiscriminatedUnion`,(e,t)=>{mu.init(e,t),mo.init(e,t)});function _u(e,t,n){return new gu({type:`union`,options:t,discriminator:e,...T(n)})}var vu=D(`ZodIntersection`,(e,t)=>{ho.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r)});function yu(e,t){return new vu({type:`intersection`,left:e,right:t})}var bu=D(`ZodRecord`,(e,t)=>{kl(),vo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function xu(e,t,n){return!t||!t._zod?new bu({type:`record`,keyType:F(),valueType:e,...T(t)}):new bu({type:`record`,keyType:e,valueType:t,...T(n)})}function Su(e,t,n){return new bu({type:`record`,keyType:e,valueType:t,...T(n),partial:!0})}var Cu=D(`ZodEnum`,(e,t)=>{yo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Cu({...t,checks:[],...T(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 Cu({...t,checks:[],...T(r),entries:i})}});function V(e,t){return new Cu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}var wu=D(`ZodLiteral`,(e,t)=>{bo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(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 H(e,t){return new wu({type:`literal`,values:Array.isArray(e)?e:[e],...T(t)})}var Tu=D(`ZodTransform`,(e,t)=>{kl(),xo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Nr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(mr(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(mr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Eu(e){return new Tu({type:`transform`,transform:e})}var Du=D(`ZodOptional`,(e,t)=>{Co.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new Du({type:`optional`,innerType:e})}var ku=D(`ZodExactOptional`,(e,t)=>{wo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new ku({type:`optional`,innerType:e})}var ju=D(`ZodNullable`,(e,t)=>{To.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new ju({type:`nullable`,innerType:e})}var Nu=D(`ZodDefault`,(e,t)=>{Eo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pu(e,t){return new Nu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}var Fu=D(`ZodPrefault`,(e,t)=>{Oo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e,t){return new Fu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}var Lu=D(`ZodNonOptional`,(e,t)=>{ko.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ru(e,t){return new Lu({type:`nonoptional`,innerType:e,...T(t)})}var zu=D(`ZodCatch`,(e,t)=>{Mo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Bu(e,t){return new zu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Er(t)})}var Vu=D(`ZodPipe`,(e,t)=>{No.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}var Uu=D(`ZodPreprocess`,(e,t)=>{Vu.init(e,t),Fo.init(e,t)}),Wu=D(`ZodReadonly`,(e,t)=>{Io.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gu(e){return new Wu({type:`readonly`,innerType:e})}var Ku=D(`ZodCustom`,(e,t)=>{Ro.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r)});function qu(e,t={}){return lc(Ku,e,t)}function Ju(e,t){return uc(e,t)}function Yu(e,t){return new Uu({type:`pipe`,in:Eu(e),out:t})}function Xu(e){return Ns(Ml,e)}var U=F().regex(/^[a-z0-9][a-z0-9-]{0,31}$/,`expected 1-32 lowercase letters, digits, or hyphens, starting with a letter or digit`),W=F().regex(/^[0-9A-HJKMNP-TV-Z]{26}$/,`expected a ULID`),G=F().regex(/^(?:[a-z0-9][a-z0-9-]{0,31}\/)?[a-z0-9][a-z0-9-]{0,31}$/,`expected <channel> or <project>/<channel>`);function Zu(e,t){return e===null?t:`${e}/${t}`}var K=Yu(e=>e instanceof Date?e.toISOString():e,Xu()),Qu=V(`post_message.read_inbox.search.open_thread.close_thread.create_task.claim_task.release_task.update_task.get_task.subscribe.unsubscribe.propose.approve.reject.create_project.join_project.leave_project.write_knowledge.plan_task.advance_task.configure_project.archive_project.remove_knowledge.create_channel.archive_channel.update_dashboard.create_cron.update_cron.remove_cron.remove_skill.upload_image`.split(`.`)),$u=V([`user_post`,`ops_event`,`heartbeat`]),ed=B({name:U,purpose:F().min(1),verbs:z(Qu),wakeTriggers:z($u).default([`heartbeat`]),reviewDate:F().optional(),maxReplicas:L().int().min(1).default(1),backlogThreshold:L().positive().default(3),resident:R().default(!1),societyScope:R().default(!1),reflects:R().default(!0)}),td=`user`,nd=`user`,rd=[`post_message`,`upload_image`,`read_inbox`,`search`,`open_thread`,`close_thread`,`create_task`,`claim_task`,`release_task`,`update_task`,`get_task`,`subscribe`,`unsubscribe`,`propose`,`join_project`,`leave_project`,`write_knowledge`,`remove_knowledge`,`plan_task`,`advance_task`,`update_dashboard`,`create_cron`,`update_cron`,`remove_cron`],id=[`approve`,`reject`],ad=[`create_project`],od=[`configure_project`,`create_channel`,`archive_channel`],sd=[`archive_project`],cd=[`remove_skill`];[...rd,...id,...ad,...od,...sd,...cd],[...rd,...id,...od,...cd],[...rd,...ad,...od];function ld(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function ud(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function dd(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?hd(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):hd(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function fd(e,t,n){return pd(dd(e,t),n)}function pd(e,t){let n=new Date(ld(e)),r=md(n,e.tz),i=ld(e)-ld(r),a=new Date(n.getTime()+i),o=md(a,e.tz);if(ud(o,e)){let t=new Date(a.getTime()-36e5);return ud(md(t,e.tz),e)?t:a}let s=new Date(a.getTime()+ld(e)-ld(o));if(ud(md(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function md(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function hd(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var gd=[1,2,4,8,16],_d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,e);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|gd[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},vd=[31,28,31,30,31,30,31,31,30,31,30,31],q=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],J=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date){if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`)}else if(t==null)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():vd[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&63&&gd[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0){if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=md(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>vd[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}return!1}fromString(e){if(typeof this.tz==`number`){let t=fd(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(fd(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,q[n][0],e,q[n][2]);if(r>1){let i=n+1;for(;i<q.length;)this[q[i][0]]=-q[i][2],i++;if(r===3){if(this[q[n][1]]++,this[q[n][0]]=-q[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=q.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,q[n][0],e,q[n][2]);if(i>1){let a=n+1;for(;a<q.length;){let t=q[a][0],n=q[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[q[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1){if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():vd[t];this.day>n&&(this.day=n)}}this.apply();let i=q[n][0],a=q[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=q[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,q[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,q[3][2]),this.second=this.getMaxPatternValue(`second`,e,q[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=q.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):pd(hd(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<q.length;n++){let r=q[n][0],i=q[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function yd(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=e.paused!==void 0&&e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch!==void 0&&e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref!==void 0&&e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays!==void 0&&e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges!==void 0&&e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&(e.startAt=new J(e.startAt,e.timezone)),e.stopAt&&(e.stopAt=new J(e.stopAt,e.timezone)),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function bd(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function xd(e){return bd(e)}function Sd(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Cd=3e4,wd=[],Td=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(bd(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(bd(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=yd(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new _d(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new J(e,this.getTz()):this._states.pattern=new _d(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(wd.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);wd.push(this)}return i!==void 0&&xd(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new J(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new J(e,this.getTz());t.ms=0;let n=new J(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new J(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof J||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new J(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=wd.indexOf(this);e>=0&&wd.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Cd&&(t=Cd),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&Sd(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new J(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(bd(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new J(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&bd(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new J(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new J(e,this.getTz());return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_previous(e){let t=new J(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new J(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new J(void 0,this.getTz()),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new J(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},Ed=9e5,Dd=6e4,Od=200;function kd(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).resolvedOptions().timeZone}catch{return null}}var Ad=F().trim().min(1).max(64).transform((e,t)=>{let n=kd(e);return n===null?(t.addIssue({code:`custom`,message:`${e} is not a time zone; name one as IANA does, such as Europe/Berlin, America/New_York, or UTC`}),Or):n});function jd(e,t){return new Td(e,{mode:`5-part`,timezone:t,paused:!0})}function Md(e){try{return jd(e,`UTC`),null}catch(e){return e instanceof Error?e.message:String(e)}}var Nd=F().trim().min(1).max(120).superRefine((e,t)=>{let n=Md(e);n!==null&&t.addIssue({code:`custom`,message:`not a five-field cron expression (minute, hour, day of month, month, day of week): ${n}`})}),Pd=hu([B({cron:Nd,timezone:Ad.optional()}),B({at:K})]),Fd=B({turnId:W,at:K,outcome:V([`completed`,`failed`,`stopped`])}),Id=B({id:W,title:F().trim().min(1).max(120),agent:U,scope:U,thread:W.optional(),channel:U.optional(),schedule:Pd,createdBy:U,createdAt:K,since:K,paused:B({at:K,by:U}).optional(),lastFiredAt:K.optional(),lastSkippedAt:K.optional(),lastRun:Fd.optional(),failures:L().int().nonnegative().default(0),ended:B({at:K,by:U,reason:F().min(1)}).optional()});function Ld(e){return`at`in e}function Rd(e,t){return Ld(e)?t:e.timezone??t}function zd(e,t,n,r){if(Ld(e)){let t=new Date(e.at);return t>n&&r>0?[t]:[]}return jd(e.cron,Rd(e,t)).nextRuns(r,n)}function Bd(e,t,n){let r=zd(e,t,n,Od),i=null;for(let e=1;e<r.length;e+=1){let t=(r[e]?.getTime()??0)-(r[e-1]?.getTime()??0);i=i===null?t:Math.min(i,t)}return i}function Vd(e,t,n=Ed){if(e.ended!==void 0||e.paused!==void 0)return null;let r=e.lastFiredAt===void 0?null:Date.parse(e.lastFiredAt),i=Date.parse(e.since);if(Ld(e.schedule))return r!==null&&r>=i?null:new Date(e.schedule.at);let a=Math.max(i,r===null?i:r+n-Dd,e.lastSkippedAt===void 0?i:Date.parse(e.lastSkippedAt));return zd(e.schedule,t,new Date(a),1)[0]??null}function Hd(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,weekday:`long`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??``;return`${r(`weekday`)} ${r(`year`)}-${r(`month`)}-${r(`day`)} ${r(`hour`)}:${r(`minute`)}`}var Ud=B({key:F().min(1).max(80),label:F().min(1).max(80).optional(),minutes:L().int().positive().nullable().default(null),usedPercent:L().nonnegative().nullable().default(null),resetsAt:K.nullable().default(null),observedAt:K}),Wd=V([`allowed`,`warning`,`limited`,`none`]),Gd=B({hasCredits:R(),unlimited:R(),balance:F().max(40).nullable()}),Kd=B({enabled:R(),monthlyLimit:L().nonnegative().nullable(),usedCredits:L().nonnegative().nullable(),currency:F().min(1).max(8).nullable()}),qd=B({observedAt:K,source:V([`turn`,`read`]),status:Wd,limitedUntil:K.nullable().default(null),limitedBy:F().min(1).max(80).nullable().default(null),plan:F().min(1).max(40).nullable().default(null),windows:z(Ud).max(24).default([]),credits:Gd.nullable().default(null),extraUsage:Kd.nullable().default(null)});function Jd(e,t){return e.resetsAt===null||Date.parse(e.resetsAt)>t.getTime()}function Yd(e,t){if(e.status===`none`)return`none`;if(e.status===`limited`&&(e.limitedUntil===null||Date.parse(e.limitedUntil)>t.getTime()))return`limited`;let n=e.windows.some(e=>Jd(e,t)&&e.usedPercent!==null&&e.usedPercent>=80);return e.status===`warning`||n?`warning`:`ok`}var Xd={five_hour:`5h`,seven_day:`7d`,seven_day_opus:`7d Opus`,seven_day_sonnet:`7d Sonnet`,seven_day_oauth_apps:`7d apps`,seven_day_overage_included:`7d extra`,overage:`extra usage`};function Zd(e){if(e.label!==void 0)return e.minutes===10080?`7d ${e.label}`:e.label;let t=Xd[e.key];return t===void 0?e.minutes===null?e.key:e.minutes%1440==0?`${e.minutes/1440}d`:e.minutes%60==0?`${e.minutes/60}h`:`${e.minutes}m`:t}function Qd(e){return e.windows.map(e=>`${e.key}=${e.usedPercent===null?`?`:Math.round(e.usedPercent)}@${e.resetsAt===null?`?`:Math.round(Date.parse(e.resetsAt)/6e4)}`).toSorted().join(`,`)}function $d(e,t){return e.windows.some(e=>e.resetsAt!==null)&&e.plan===t.plan&&e.status===t.status&&e.limitedUntil===t.limitedUntil&&Qd(e)===Qd(t)}var ef=`asks`,tf=[`general`,`governance`,ef],nf=[`general`];function rf(e,t){return(e===null?tf:nf).includes(t)}var af=`society`,Y=V([`claude`,`codex`]),of=B({name:U,at:K,by:U,reason:F().min(1)}),sf=B({name:F().min(1),version:H(1),createdAt:K,channels:z(U),archivedChannels:z(of).default([]),timezone:Ad.default(`UTC`)}),cf=V([`none`,`merge`,`ghpr`]),lf=F().trim().regex(/^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)\/pull\/([1-9]\d*)\/?$/,`a pull request's address, https://github.com/<owner>/<repo>/pull/<number>`),uf=F().trim().min(1).max(300).regex(/^[^\n]+$/,`a merge commit's subject is one line`),df=B({url:lf,number:L().int().positive(),subject:uf.optional(),body:F().max(2e4).optional(),linkedBy:U,linkedAt:K,closed:B({at:K,ok:R(),detail:F()}).optional()}),ff=F().trim().min(1).max(100).regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,`a branch name is letters, digits, and . _ / -`).refine(e=>!e.includes(`..`)&&!e.includes(`//`)&&!e.endsWith(`/`)&&!e.endsWith(`.`)&&!e.endsWith(`.lock`),`not a branch name git takes`).refine(e=>!e.startsWith(`task/`)&&!e.startsWith(`agent/`),`task/ and agent/ hold the board's own branches`),pf=F().regex(/^s[1-9][0-9]*$/,`expected a stage id such as s1`),mf={name:F().trim().min(1).max(120),role:U.optional(),agent:U.optional(),gate:R().default(!1)};function hf(e){return e.role===void 0||e.agent===void 0}var gf={message:`a stage names a role or an agent, not both`},_f=B(mf).refine(hf,gf),vf=B({id:pf.optional(),...mf}).refine(hf,gf),yf=B({slug:U,name:F().min(1),repo:F().nullable(),defaultBranch:F().min(1),channels:z(U),archivedChannels:z(of).default([]),members:z(U),approvers:z(U),requiredCapabilities:z(F()),createdAt:K,onDone:cf.default(`none`),runner:U.optional(),archived:B({at:K,by:U,reason:F().min(1)}).optional()}),bf=hu([B({action:V([`advanced`,`returned`,`abandoned`,`landed`,`reopened`]),stage:pf,to:pf.nullable()}),B({action:V([`approved`,`rejected`])})]);function xf(e){return`stage`in e}var Sf=_u(`kind`,[B({kind:H(`knowledge`),action:V([`written`,`updated`,`removed`]),topic:U,project:U.nullable()})]),Cf=B({id:W,author:U,channel:G,thread:W.optional(),task:W.optional(),closes:W.optional(),step:bf.optional(),notice:Sf.optional(),ts:K,mentions:z(U)}),wf=Cf.pick({id:!0,author:!0,channel:!0,thread:!0,ts:!0}),Tf=V([`open`,`claimed`,`done`,`abandoned`]),Ef=V([`open`,`closed`]),Df=B({kind:V([`task`,`proposal`]),id:W}),Of=B({id:W,channel:G,title:F().min(1).max(200),subject:Df.optional(),state:Ef,openedBy:U,openedAt:K,closedBy:U.optional(),closedAt:K.optional()}),kf=B({id:pf,name:F().min(1),role:U.optional(),agent:U.optional(),gate:R().default(!1),holders:z(U).default([]),completedBy:U.optional(),completedAt:K.optional()}),Af=B({from:pf,by:U,at:K}),jf=B({id:W,project:U,channel:U.default(`general`),title:F().min(1),status:Tf,createdBy:U,createdAt:K,updatedAt:K,claimedBy:U.optional(),leaseExpiresAt:K.optional(),parentId:W.optional(),blockedBy:z(W),requiredCapabilities:z(F()),stages:z(kf).min(1),stage:pf,stageSince:K,stageSeq:L().int().positive(),onDone:cf.default(`none`),pullRequest:df.optional(),completing:R().default(!1),returned:Af.optional()});function Mf(e,t){return e.stages.findIndex(e=>e.id===t)}function Nf(e){return e.stages.find(t=>t.id===e.stage)}var Pf=F().trim().min(1).max(120).regex(/^[\w.:/[\]-]+$/,`a model name is one word of letters, digits, and . _ : / - [ ]`),Ff=F().trim().min(1).max(32).regex(/^[a-z][a-z0-9_-]*$/,`an effort is one lowercase word, such as high`),If=B({id:Ff,description:F().default(``)}),Lf=B({runner:U,cli:Y,models:z(B({id:Pf,name:F(),description:F().default(``),isDefault:R().default(!1),efforts:z(If).default([]),defaultEffort:Ff.optional()}))}),Rf=V([`active`,`retired`]),zf=B({name:U,role:U,cli:Y.nullable(),model:F().optional(),effort:F().optional(),homeRunner:U.optional(),memberships:z(U),subscriptions:z(G),status:Rf,createdAt:K,tokenHash:F().min(1),retiredAt:K.optional(),retiredReason:F().optional()}),Bf=B({name:U,role:U,cli:Y.nullable(),homeRunner:U.optional(),status:Rf,resident:R().default(!1),model:F().optional(),lastModel:F().optional(),effort:F().optional(),skills:z(U).default([]),memberships:z(U),subscriptions:z(G),claimsHeld:L().int().nonnegative().default(0),tasksDone:L().int().nonnegative().default(0),lastTurnAt:K.optional(),lastTurnOutcome:F().optional(),createdAt:K,retiredAt:K.optional()}),Vf=V([`linux`,`windows`,`darwin`]),Hf=V([`name`,`email`]),Uf=B({name:U,os:Vf,clis:z(Y),capabilities:z(F()),version:F().optional(),gitIdentityMissing:z(Hf).optional(),status:V([`connected`,`disconnected`]),lastSeen:K.optional(),quotas:Su(Y,qd).optional()}),Wf=V([`role`,`member`,`channel`,`reallocation`,`retirement`,`skill`,`archive`]),Gf=V([`proposed`,`approved`,`rejected`,`provisioned`,`retired`]),Kf=B({name:U,role:U,cli:Y,model:F().optional(),homeRunner:U.optional(),memberships:z(U).default([]),subscriptions:z(G).default([]),seedInstructions:F().optional()}),qf=B({project:U.nullable().default(null),name:U,purpose:F().min(1)}),Jf=B({role:U,changes:pu({maxReplicas:L().int().min(1).optional(),backlogThreshold:L().positive().optional(),wakeTriggers:z($u).optional(),verbs:z(Qu).optional()}).refine(e=>Object.values(e).some(e=>e!==void 0),{message:`a reallocation changes at least one of maxReplicas, backlogThreshold, wakeTriggers, verbs`}),description:F().min(1)}),Yf=B({description:F().min(1)});function Xf(e,t){return{...e,...t.maxReplicas===void 0?{}:{maxReplicas:t.maxReplicas},...t.backlogThreshold===void 0?{}:{backlogThreshold:t.backlogThreshold},...t.wakeTriggers===void 0?{}:{wakeTriggers:[...t.wakeTriggers]},...t.verbs===void 0?{}:{verbs:[...t.verbs]}}}function Zf(e){return e.length===0?`none`:e.join(`, `)}function Qf(e,t){let n=[];t.maxReplicas!==void 0&&t.maxReplicas!==e.maxReplicas&&n.push(`maxReplicas ${e.maxReplicas} → ${t.maxReplicas}`),t.backlogThreshold!==void 0&&t.backlogThreshold!==e.backlogThreshold&&n.push(`backlogThreshold ${e.backlogThreshold} → ${t.backlogThreshold}`);let r=t.wakeTriggers;if(r!==void 0&&(r.length!==e.wakeTriggers.length||r.some(t=>!e.wakeTriggers.includes(t)))&&n.push(`wakeTriggers ${Zf(e.wakeTriggers)} → ${Zf(r)}`),t.verbs!==void 0){let r=t.verbs,i=r.filter(t=>!e.verbs.includes(t)).map(e=>`+${e}`),a=e.verbs.filter(e=>!r.includes(e)).map(e=>`−${e}`);i.length+a.length>0&&n.push(`verbs ${[...i,...a].join(` `)}`)}return n}var $f=B({agent:U,reason:F().min(1)}),ep=B({project:U,reason:F().min(1)}),tp=B({name:U,summary:F().min(1).max(200),body:F().min(1).optional()}),np={role:[td],member:[td],retirement:[td],archive:[td],channel:[td,`steward`],reallocation:[td,`steward`],skill:[td,`steward`]},rp=[`verbs`,`maxReplicas`];function ip(e,t){if(e===`reallocation`){let e=Jf.safeParse(t);if(e.success&&rp.some(t=>e.data.changes[t]!==void 0))return[td]}return np[e]}function ap(e){let t=[];return e.maxReplicas!==void 0&&t.push(`up to ${e.maxReplicas} per project`),e.backlogThreshold!==void 0&&t.push(`backlog threshold ${e.backlogThreshold}`),e.wakeTriggers!==void 0&&t.push(e.wakeTriggers.length===0?`no ambient wakes`:`wakes on ${e.wakeTriggers.join(`, `)}`),e.verbs!==void 0&&t.push(`${e.verbs.length} verbs`),t.join(`, `)}function op(e,t){switch(e){case`member`:{let e=Kf.safeParse(t);if(!e.success)break;let{name:n,role:r,cli:i,memberships:a}=e.data;return`member ${n} as ${r} on ${i}${a.length===0?``:` for ${a.join(`, `)}`}`}case`role`:{let e=ed.safeParse(t);if(!e.success)break;let{name:n,verbs:r,maxReplicas:i}=e.data;return`role ${n} (${r.length} verbs, up to ${i} per project)`}case`channel`:{let e=qf.safeParse(t);if(!e.success)break;return`channel ${Zu(e.data.project,e.data.name)}: ${e.data.purpose}`}case`retirement`:{let e=$f.safeParse(t);if(!e.success)break;return`retirement of ${e.data.agent}: ${e.data.reason}`}case`reallocation`:{let e=Jf.safeParse(t);if(e.success){let{role:t,changes:n,description:r}=e.data;return`reallocation of role ${t} (${ap(n)}): ${r}`}let n=Yf.safeParse(t);if(!n.success)break;return`reallocation: ${n.data.description}`}case`skill`:{let e=tp.safeParse(t);if(!e.success)break;return`skill ${e.data.name}: ${e.data.summary.trim().replace(/\.+$/,``)}`}case`archive`:{let e=ep.safeParse(t);if(!e.success)break;return`archive of project ${e.data.project}: ${e.data.reason}`}}return`${e} ${JSON.stringify(t)}`}var sp=B({name:U,summary:F().default(``),scope:V([`own`,`society`]),path:F().min(1)}),cp=B({name:U,reason:F().min(1),removedBy:U,removedAt:K}),lp=B({path:F().min(1),file:F().min(1),since:K}),up=F().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/),dp=B({path:F().min(1),status:V([`added`,`modified`,`deleted`]),added:L().int().nonnegative().nullable(),removed:L().int().nonnegative().nullable()}),fp=B({changes:z(B({commit:up,at:K,kind:V([`turn`,`board`,`merge`]),author:F(),turnId:W.optional(),subject:F(),files:z(dp)})),more:R()}),pp=dp.pick({path:!0,status:!0}).extend({patch:F().nullable(),truncated:R()}),mp=B({topic:U,project:U.nullable(),revision:L().int().min(0),updatedBy:U,updatedAt:K}),hp=B({topic:U,project:U.nullable(),removedBy:U,removedAt:K}),gp=B({project:U,revision:L().int().min(0),updatedBy:U.optional(),updatedAt:K.optional(),body:F()}),_p=B({scope:U,thread:W.optional(),channel:U.optional()}),vp=B({path:F().min(1),size:L().int().nonnegative(),executable:R()}),yp=B({commit:up,takenAt:K,files:z(vp)}),bp=vp.extend({text:F().nullable(),truncated:R()}),xp=B({id:W,kind:Wf,proposedBy:U,status:Gf,createdAt:K,filedFrom:_p.optional(),skillFiles:yp.optional(),decidedBy:U.optional(),decidedAt:K.optional(),reason:F().optional(),charter:xu(F(),cu()),provisionedAt:K.optional(),provision:xu(F(),cu()).optional()}),Sp=B({id:W,proposalId:W,decidedBy:U,outcome:V([`approved`,`rejected`]),reason:F().optional(),ts:K}),Cp=V([`png`,`jpeg`,`gif`,`webp`]),wp=F().min(1).max(4096).refine(e=>!e.includes(`\0`),{message:`a path with no NUL character`}),Tp=`image:`;function Ep(e){if(!e.startsWith(`image:`))return null;let t=e.slice(6);return W.safeParse(t).success?t:null}B({id:W,type:Cp,size:L().int().positive(),markdown:F()});var Dp=Xu({offset:!0}),Op=F().trim().min(1).max(120),kp=F().trim().min(1).max(4e3);B({channel:G.optional(),body:F().min(1),thread_id:W.optional()}),B({since_cursor:W.nullable().optional(),limit:L().int().positive().max(200).default(50),advance:R().default(!0)}),B({query:F().min(1),project:U.optional(),channel:G.optional(),limit:L().int().positive().max(100).default(20)}),B({task_id:W.optional(),proposal_id:W.optional(),channel:G.optional(),title:F().min(1).max(200).optional()}),B({thread_id:W,summary:F().min(1)}),B({project:U,title:F().min(1).max(200),body:F().default(``),parent_id:W.optional(),required_capabilities:z(F()).default([]),stages:z(_f).min(1).optional(),channel:U.default(`general`)}),B({task_id:W}),B({task_id:W}),B({task_id:W,stage:pf.optional(),status:V([`abandoned`]).optional(),note:F().min(1).optional(),blocked_by:z(W).optional(),pull_request:B({url:lf,merge_subject:uf.optional(),merge_body:F().max(2e4).optional()}).nullable().optional()}),B({task_id:W}),B({channel:G}),B({channel:G}),B({kind:Wf,charter:xu(F(),cu()),rationale:F().default(``)}),B({proposal_id:W,reason:F().optional()}),B({proposal_id:W,reason:F().min(1)}),B({slug:U,name:F().min(1).optional(),repo:F().min(1).nullable().default(null),default_branch:ff.default(`main`),on_done:cf.optional()}),B({project:U,agent:U.optional()}),B({project:U,agent:U.optional()}),B({project:U.nullable().default(null),topic:U,body:F().min(1),revision:L().int().min(0)}),B({project:U.nullable().default(null),topic:U}),B({task_id:W,stages:z(vf),on_done:cf.optional()}),B({task_id:W,note:F().min(1).optional()}),B({project:U,on_done:cf.optional(),name:F().trim().min(1).max(120).optional(),default_branch:ff.optional()}),B({project:U,reason:F().min(1)}),B({project:U.nullable().default(null),name:U,purpose:F().min(1)}),B({channel:G,reason:F().min(1)}),B({project:U,body:F().min(1),revision:L().int().min(0)}),B({title:Op,note:kp,cron:Nd.optional(),timezone:Ad.optional(),at:Dp.optional(),agent:U.optional(),project:U.optional(),thread_id:W.optional(),channel:U.optional()}),B({cron_id:W,paused:R().optional(),title:Op.optional(),note:kp.optional(),cron:Nd.optional(),timezone:Ad.nullable().optional(),at:Dp.optional()}),B({cron_id:W,reason:F().trim().min(1)}),B({name:U,reason:F().trim().min(1)}),B({path:wp});var Ap=B({id:W,ts:K,type:V(`society.initialized,project.added,project.configured,project.archived,project.placed,agent.added,agent.configured,agent.placed,message.posted,thread.opened,thread.closed,task.created,task.claimed,task.released,task.updated,task.planned,task.advanced,task.moved,task.completing,task.completed,task.reopened,lease.expired,subscription.changed,proposal.created,proposal.decided,proposal.provisioned,proposal.files_taken,channel.added,channel.archived,role.added,agent.retired,agent.joined,agent.left,knowledge.written,knowledge.removed,dashboard.updated,skill.promoted,skill.removed,runner.added,user.signed_in,user.signed_out,user.token_rotated,runner.changed,runner.quota,ops.signal,paused.changed,wake.requested,turn.started,turn.steered,turn.stopped,turn.completed,turn.failed,merge.completed,merge.failed,pull_request.closed,pull_request.close_failed,workspace.leftovers,society.configured,cron.created,cron.updated,cron.fired,cron.skipped,cron.ended,image.uploaded`.split(`,`)),actor:U,payload:xu(F(),cu())}),jp=B({inputTokens:L().int().nonnegative(),outputTokens:L().int().nonnegative(),cacheReadTokens:L().int().nonnegative().default(0),cacheWriteTokens:L().int().nonnegative().default(0)});function Mp(e,t){return{inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens+t.cacheWriteTokens}}var Np=B({summary:F().min(1),claimsHeld:z(W).default([]),blockedOn:z(F()).default([]),needsUserDecision:R().default(!1),memoryUpdated:R().default(!1)}),Pp=V([`completed`,`timeout`,`error`,`interrupted`,`blocked`,`stopped`]),Fp=_u(`type`,[B({type:H(`turn_started`),agent:U,session:F(),runner:U,model:F().optional()}),B({type:H(`steered`),steer:F().min(1),messages:z(W).optional(),text:F().optional()}),B({type:H(`text`),delta:F()}),B({type:H(`tool_call`),name:F(),input:cu()}),B({type:H(`tool_result`),name:F(),ok:R(),output:F().optional()}),B({type:H(`approval_requested`),kind:F(),detail:cu()}),B({type:H(`turn_completed`),usage:jp,costUsd:L().nonnegative(),status:Np.nullable(),exitReason:Pp}),B({type:H(`error`),message:F()})]),Ip=B({ts:K,event:Fp}),Lp=B({seq:L().int().positive(),ts:K,agent:U,project:U,thread:W.optional(),channel:U.optional(),event:Fp});B({protocol:L().int().positive(),version:F().min(1),os:Vf,clis:z(Y),residentClis:z(Y).default([]),steerableClis:z(Y).default([]),stoppableClis:z(Y).default([]),branchReads:R().default(!1),branchChanges:R().default(!1),quotaReads:R().default(!1),imageReads:R().default(!1),capabilities:z(F()).default([]),gitIdentityMissing:z(Hf).optional(),slots:L().int().positive().nullable(),turns:z(W).default([])}),B({name:U,version:F()}),B({protocol:L().int().positive(),version:F().min(1).max(64),hostname:F().min(1).max(253),os:Vf,clis:z(Y).max(8),capabilities:z(F().min(1).max(64)).max(32).default([])}),B({deviceCode:F().min(1),userCode:F().min(1),expiresAt:K,intervalMs:L().int().positive()}),B({deviceCode:F().min(1)}),_u(`status`,[B({status:H(`pending`)}),B({status:H(`approved`),name:U,token:F().min(1)}),B({status:H(`denied`)})]);var Rp=B({userCode:F().min(1),hostname:F(),os:Vf,clis:z(Y),capabilities:z(F()),version:F(),requestedAt:K,expiresAt:K}),zp=B({slug:U,origin:F().nullable(),defaultBranch:F().min(1),boardLands:R()}),Bp=_u(`kind`,[B({kind:H(`home`),thread:W.optional(),channel:U.optional()}),B({kind:H(`project`),repo:zp,branches:z(F().min(1)),thread:W.optional(),channel:U.optional()}),B({kind:H(`task`),repo:zp,taskId:W})]),Vp=B({turnId:W,agent:U,role:U,cli:Y,model:F().optional(),effort:F().optional(),scope:U,thread:W.optional(),channel:U.optional(),session:F().min(1).nullable(),costSoFarUsd:L().nonnegative(),instructions:F(),prompt:F(),mcp:B({url:F().min(1),token:F().min(1)}),limits:B({timeoutMs:L().int().positive().nullable(),maxTurns:L().int().positive().nullable()}),resident:B({key:F().min(1),idleMs:L().int().positive()}).optional(),workspace:Bp}),Hp=B({branch:F().min(1),head:F().min(1)});B({entries:z(Ip)}),B({exitReason:Pp,status:Np.nullable(),error:F().nullable(),usage:jp,costUsd:L().nonnegative(),sessionCostUsd:L().nonnegative().optional(),session:F().min(1),model:F().nullable(),work:Hp.nullable(),leftovers:R().default(!1),quota:qd.optional()}),B({dropWorkspace:R()});var Up=B({repo:zp,branch:F().min(1),pullRequest:B({url:F().min(1),subject:F().min(1).optional(),body:F().optional()}).optional()}),Wp=B({repo:zp,url:F().min(1),comment:F().min(1)});B({ok:R(),detail:F()});var Gp=8388608,Kp=F().max(4096).refine(e=>e===``||e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&!e.includes(`\0`)),{message:"a path inside the branch, with no empty, `.`, or `..` segment"}),qp=F().regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/),Jp=B({repo:zp,branch:qp,path:Kp}),Yp=B({id:F().min(1),at:K,author:F()}),Xp=_u(`kind`,[B({kind:H(`file`),path:Kp,commit:Yp,size:L().int().nonnegative(),content:F().nullable()}),B({kind:H(`dir`),path:Kp,commit:Yp,entries:z(B({name:F().min(1),kind:V([`file`,`dir`]),size:L().int().nonnegative().nullable()}))})]),Zp=B({repo:zp,branch:qp}),Qp=B({path:F().min(1),status:V([`added`,`modified`,`deleted`]),added:L().int().nonnegative().nullable(),removed:L().int().nonnegative().nullable(),lastChange:B({author:F(),at:K}).optional()}),$p=B({head:Yp,files:z(Qp),total:L().int().nonnegative()}),em=B({repo:zp,branch:qp,path:Kp.min(1)}),tm=B({head:Yp,path:Kp,status:Qp.shape.status,patch:F().nullable(),truncated:R()}),nm=B({turnId:W,path:wp}),rm=V([`missing`,`outside`,`not_image`,`too_big`]);_u(`kind`,[B({kind:H(`image`),type:Cp,size:L().int().positive(),content:F()}),B({kind:H(`refused`),why:rm,detail:F()})]);var im=_u(`kind`,[B({kind:H(`thread`),id:W}),B({kind:H(`channel`),scope:U,name:U})]),am=B({agent:U,scope:U,conversation:im});B({workspaces:z(am)}),B({kept:z(am)});var om=B({id:zl(),text:F().min(1)});_u(`type`,[B({type:H(`turn`),job:Vp}),B({type:H(`land`),request:F().min(1),land:Up}),B({type:H(`close`),request:F().min(1),close:Wp}),B({type:H(`models`),request:F().min(1),cli:Y}),B({type:H(`quota`),request:F().min(1),cli:Y}),B({type:H(`file`),request:F().min(1),read:Jp}),B({type:H(`changes`),request:F().min(1),read:Zp}),B({type:H(`diff`),request:F().min(1),read:em}),B({type:H(`image`),request:F().min(1),read:nm}),B({type:H(`steer`),request:F().min(1),turnId:W,steer:om}),B({type:H(`stop`),request:F().min(1),turnId:W}),B({type:H(`sweep`),request:F().min(1),conversation:im})]),_u(`ok`,[B({ok:H(!0),value:cu()}),B({ok:H(!1),error:F()})]),B({warm:z(F())}),B({files:xu(F(),F())}),B({paths:z(F())}),B({files:xu(F(),F())});var sm=B({kind:V([`mention`,`stage`,`task_done`,`proposal_decided`,`heartbeat`,`reflection`,`onboarding`,`manual`,`ops_event`,`user_post`,`closing`,`cron`]),from:U.optional(),fromUser:R().default(!1),reason:F().default(``),taskId:W.optional(),messageId:W.optional(),channel:G.optional(),cronId:W.optional()});B({agent:U,project:U,thread:B({id:W,task:R()}).optional(),channel:U.optional(),trigger:sm,priority:L().int().min(0).max(2),onboarding:R().default(!1),crons:z(W).optional()});function cm(e){return e.thread??(e.channel===void 0?void 0:`#${e.channel}`)}function lm(e,t,n){return n===void 0?`${e}/${t}`:`${e}/${t}/${n}`}function um(e){let[t,n,r,i]=e.split(`/`);return t===void 0||n===void 0||i!==void 0?null:r===void 0?{agent:t,scope:n}:r.startsWith(`#`)?{agent:t,scope:n,channel:r.slice(1)}:{agent:t,scope:n,thread:r}}B({id:W.optional(),agent:U,project:U,thread:W.optional(),channel:U.optional(),runner:U,cli:Y.nullable(),session:F().nullable(),trigger:sm,startedAt:K,endedAt:K.nullable(),exitReason:Pp.nullable(),status:Np.nullable(),error:F().nullable(),usage:jp.nullable(),costUsd:L().nonnegative().default(0),sessionCostUsd:L().nonnegative().optional(),toolCalls:L().int().nonnegative().default(0),model:F().nullable().default(null),work:Hp.optional(),stoppedBy:U.optional(),crons:z(W).optional()});var dm=B({turnId:W,agent:U,scope:U,thread:W.optional(),channel:U.optional(),cli:Y,askedIn:G.optional(),steerable:R(),stoppable:R()});B({claude:F().optional(),codex:F().optional(),runner:U.optional()}),B({agent:U,project:U,reason:F().default(`manual wake`),kind:V([`manual`,`reflection`]).default(`manual`)});var fm=B({id:W,turnId:W.optional(),ts:K,outcome:V([`completed`,`failed`]),project:U,thread:W.optional(),channel:U.optional(),trigger:F(),exitReason:F().nullable(),costUsd:L(),usage:jp.optional(),model:F().nullable(),summary:F().nullable(),error:F().nullable(),startedAt:K.optional(),toolCalls:L().int().nonnegative().optional()}),pm=V([`waiting_stage`,`backlog`,`role_gap`,`churn`,`stale_thread`,`idle_member`,`blocked_capability`,`turn_cost`,`scaled`,`runner`,`home_conflict`,`stuck_workspace`,`cron_failing`]),mm=[`backlog`,`role_gap`,`churn`,`stale_thread`,`idle_member`,`blocked_capability`,`scaled`],hm=B({kind:pm,key:F().min(1),summary:F().min(1),value:L(),threshold:L().optional(),project:U.optional(),agent:U.optional(),role:U.optional(),taskId:W.optional()}),gm=V([`24h`,`7d`,`all`]),X=L().int().nonnegative(),_m=L().nonnegative(),vm=B({window:gm,since:K.nullable(),until:K,idle:B({turns:X,idle:X,unknown:X,byTrigger:z(B({trigger:F(),turns:X,idle:X})),byAgent:z(B({agent:U,role:U.nullable(),turns:X,idle:X}))}),sentBack:B({finished:X,sendBacks:X,tasksSentBack:X,byStage:z(B({project:U,stage:F(),count:X})),bySender:z(B({agent:U,count:X}))}),messages:B({finished:X,messages:X,byProject:z(B({project:U,finished:X,messages:X})),busiest:z(B({taskId:W,title:F(),project:U,messages:X}))}),latency:B({mentions:X,unanswered:X,medianMs:_m.nullable(),slowestMs:_m.nullable(),byAgent:z(B({agent:U,mentions:X,medianMs:_m,slowestMs:_m}))}),decisions:B({total:X,byDay:z(B({day:F(),proposals:X,answers:X,stages:X}))}),blocked:z(B({taskId:W,title:F().nullable(),project:U.nullable(),summary:F(),firstAt:K,lastAt:K,holds:R()}))}),ym=B({agent:U,turns:X,withUsage:X,usage:jp.nullable()}),bm=B({window:gm,since:K.nullable(),until:K,citizens:z(ym)}),xm=V([`trace`,`debug`,`info`,`warn`,`error`,`fatal`]),Sm=B({clientId:F().min(1),clientSecret:F().min(1),users:z(F().min(1)).min(1)});B({dataDir:F().min(1),host:F().min(1),port:L().int().positive().max(65535),publicUrl:F().min(1).nullable(),logLevel:xm,concurrency:L().int().positive().nullable(),turnTimeoutMs:L().int().positive().nullable(),toolRounds:L().int().positive().nullable(),residentIdleMs:L().int().positive(),github:Sm.nullable(),trustedProxies:L().int().min(0).max(16)}),B({serverUrl:F().url(),token:F().min(1).nullable(),dataDir:F().min(1),logLevel:xm,slots:L().int().positive().nullable(),clis:z(Y).min(1),capabilities:z(F())});var Cm=`stellaris.token`;function wm(){return localStorage.getItem(Cm)}function Tm(e){localStorage.setItem(Cm,e)}function Em(){localStorage.removeItem(Cm)}var Dm=B({github:R()});async function Om(){try{let e=Dm.safeParse(await(await fetch(`/auth/config`)).json());return e.success?e.data:{github:!1}}catch{return{github:!1}}}var km=class extends Error{status;constructor(e,t){super(t),this.status=e}},Am=B({name:U,role:U,signIn:B({login:F().min(1),avatarUrl:Vl()}).optional()}),jm=Bf.extend({profile:F()}).array(),Mm=B({paused:R(),running:z(F()),pending:z(F()),resident:z(F()),signals:z(F()),turns:z(dm).default([])});function Nm(e){return e.flatMap(e=>{let t=um(e);return t===null?[]:[t]})}var Pm=Cf.extend({body:F()}),Fm=Pm.array(),Im=B({ref:G,project:U.nullable(),name:U,messages:L().int(),lastMessageId:W.nullable(),lastAt:F().nullable(),archived:of.optional()}),Lm=Of.extend({body:F()}),Rm=Lm.extend({messages:L().int(),lastMessageId:W.nullable(),lastAuthor:U.nullable().default(null)}),zm=B({thread:Lm,messages:Fm}),Bm=B({message:Pm,thread:Lm.nullable()}),Vm=jf.extend({body:F()}),Hm=xp.extend({body:F()}),Um=mp.extend({body:F()}),Wm=Id.extend({note:F()}),Gm=B({body:F()});function Km(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function qm(e){return e.split(`/`).filter(e=>e!==``).map(e=>`/${encodeURIComponent(e)}`).join(``)}var Jm=B({message:F()});async function Ym(e,t){let n;try{n=await fetch(e,{headers:{authorization:`Bearer ${t}`}})}catch{throw new km(0,`The board server is not reachable.`)}if(!n.ok){let t=Jm.safeParse(await n.json().catch(()=>null));throw new km(n.status,t.success?t.data.message:`${e} answered ${n.status}`)}return n}async function Z(e,t,n){return n.parse(await(await Ym(e,t)).json())}async function Xm(e,t){let n=await(await Ym(e,t)).blob();return new Promise((t,r)=>{let i=new FileReader;i.addEventListener(`load`,()=>typeof i.result==`string`?t(i.result):r(new km(0,`${e} could not be read`))),i.addEventListener(`error`,()=>r(new km(0,`${e} could not be read`))),i.readAsDataURL(n)})}async function Zm(e,t,n,r,i){let a;try{a=await fetch(t,{method:e,headers:{authorization:`Bearer ${n}`,"content-type":`application/json`},body:JSON.stringify(r)})}catch{throw new km(0,`The board server is not reachable.`)}if(!a.ok){let e=Jm.safeParse(await a.json().catch(()=>null));throw new km(a.status,e.success?e.data.message:`${t} answered ${a.status}`)}return i.parse(await a.json())}function Q(e,t,n,r){return Zm(`POST`,`/api/verbs/${e}`,t,n,r)}var Qm=B({paused:R()}),$m=B({version:F()}),eh=B({id:W,ts:F(),signal:hm}),th=zf.omit({tokenHash:!0}),nh=B({signedOut:R()}),rh=B({denied:R()}),ih=B({stopped:R()});function ah(e){return{me:()=>Z(`/api/me`,e,Am),signOut:()=>Zm(`DELETE`,`/api/sign-in`,e,{},nh),society:()=>Z(`/api/society`,e,sf),version:async()=>(await Z(`/api/version`,e,$m)).version,members:()=>Z(`/api/members`,e,jm),projects:()=>Z(`/api/projects`,e,yf.array()),roles:()=>Z(`/api/roles`,e,ed.array()),scheduler:()=>Z(`/api/scheduler`,e,Mm),signals:t=>Z(`/api/signals?limit=${t}`,e,eh.array()),metrics:t=>Z(`/api/metrics?window=${t}`,e,vm),tokens:t=>Z(`/api/tokens?window=${t}`,e,bm),channels:()=>Z(`/api/channels`,e,Im.array()),channel:t=>Z(`/api/channels/${Km(t)}`,e,Fm),threads:()=>Z(`/api/threads`,e,Rm.array()),requests:()=>Z(`/api/requests`,e,Bm.array()),thread:t=>Z(`/api/threads/${encodeURIComponent(t)}`,e,zm),tasks:t=>Z(`/api/projects/${encodeURIComponent(t)}/tasks`,e,Vm.array()),task:t=>Z(`/api/tasks/${encodeURIComponent(t)}`,e,Vm),taskFile:(t,n)=>Z(`/api/tasks/${encodeURIComponent(t)}/files${qm(n)}`,e,Xp),image:t=>Xm(`/api/images/${encodeURIComponent(t)}`,e),taskChanges:t=>Z(`/api/tasks/${encodeURIComponent(t)}/changes`,e,$p),taskDiff:(t,n)=>Z(`/api/tasks/${encodeURIComponent(t)}/diff${qm(n)}`,e,tm),proposals:()=>Z(`/api/proposals`,e,Hm.array()),crons:()=>Z(`/api/crons`,e,Wm.array()),createCron:t=>Q(`create_cron`,e,t,Wm),pauseCron:(t,n)=>Q(`update_cron`,e,{cron_id:t,paused:n},Wm),removeCron:(t,n)=>Q(`remove_cron`,e,{cron_id:t,reason:n},Wm),setTimezone:t=>Zm(`PUT`,`/api/society/timezone`,e,{timezone:t},sf),proposal:t=>Z(`/api/proposals/${encodeURIComponent(t)}`,e,Hm),messages:t=>Z(`/api/messages?ids=${t.join(`,`)}`,e,wf.array()),proposalFiles:t=>Z(`/api/proposals/${encodeURIComponent(t)}/files`,e,bp.array()),skills:()=>Z(`/api/skills`,e,sp.array()),turns:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/turns?limit=${n}`,e,fm.array()),transcript:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/turns/${encodeURIComponent(n)}`,e,Ip.array()),memory:t=>Z(`/api/agents/${encodeURIComponent(t)}/memory`,e,Gm),agentSkills:t=>Z(`/api/agents/${encodeURIComponent(t)}/skills`,e,sp.array()),history:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/history?limit=${n}`,e,fp),change:(t,n)=>Z(`/api/agents/${encodeURIComponent(t)}/history/${encodeURIComponent(n)}`,e,pp.array()),conflicts:t=>Z(`/api/agents/${encodeURIComponent(t)}/conflicts`,e,lp.array()),dashboard:t=>Z(`/api/projects/${encodeURIComponent(t)}/dashboard`,e,gp),knowledge:t=>Z(t===`society`?`/api/society/knowledge`:`/api/projects/${encodeURIComponent(t)}/knowledge`,e,Um.array()),sendMessage:t=>Q(`post_message`,e,t,Pm),openThread:t=>Q(`open_thread`,e,t,Lm),closeThread:t=>Q(`close_thread`,e,t,Pm),approve:t=>Q(`approve`,e,t,Sp),reject:t=>Q(`reject`,e,t,Sp),advanceTask:t=>Q(`advance_task`,e,t,Vm),configureProject:(t,n)=>Q(`configure_project`,e,{project:t,...n},yf),createChannel:t=>Q(`create_channel`,e,t,G),archiveChannel:t=>Q(`archive_channel`,e,t,of),removeKnowledge:t=>Q(`remove_knowledge`,e,t,hp),removeSkill:t=>Q(`remove_skill`,e,t,cp),wake:t=>Zm(`POST`,`/api/wake`,e,t,Ap),setPaused:t=>Zm(`POST`,t?`/api/pause`:`/api/resume`,e,{},Qm),stopTurn:t=>Zm(`POST`,`/api/turns/${encodeURIComponent(t)}/stop`,e,{},ih),agentModels:t=>Z(`/api/agents/${encodeURIComponent(t)}/models`,e,Lf),runners:()=>Z(`/api/runners`,e,Uf.array()),readQuota:(t,n)=>Zm(`POST`,`/api/runners/${encodeURIComponent(t)}/quota/${n}`,e,{},qd),enrollments:()=>Z(`/api/enrollments`,e,Rp.array()),approveEnrollment:(t,n)=>Zm(`POST`,`/api/enrollments/${encodeURIComponent(t)}/approve`,e,{name:n},Uf),denyEnrollment:t=>Zm(`POST`,`/api/enrollments/${encodeURIComponent(t)}/deny`,e,{},rh),setRunner:(t,n)=>Zm(`PUT`,`/api/agents/${encodeURIComponent(t)}/runner`,e,{runner:n},th),setModel:(t,n)=>Zm(`PUT`,`/api/agents/${encodeURIComponent(t)}/model`,e,{model:n},th),setEffort:(t,n)=>Zm(`PUT`,`/api/agents/${encodeURIComponent(t)}/effort`,e,{effort:n},th)}}var oh=(0,m.createContext)(null);function $(){let e=(0,m.useContext)(oh);if(e===null)throw Error(`useSession needs a signed-in SessionContext`);return e}function sh(){let{api:e}=$();return C({queryKey:[`society`],queryFn:e.society,staleTime:6e4})}function ch(){let{api:e}=$();return C({queryKey:[`server-version`],queryFn:e.version,staleTime:1/0})}function lh(){let{api:e}=$();return C({queryKey:[`me`],queryFn:e.me,staleTime:1/0})}function uh(){let{api:e}=$();return C({queryKey:[`members`],queryFn:e.members,refetchInterval:3e4})}function dh(){let{api:e}=$();return C({queryKey:[`projects`],queryFn:e.projects,refetchInterval:6e4})}function fh(){let{api:e}=$();return C({queryKey:[`roles`],queryFn:e.roles,refetchInterval:6e4})}function ph(){let{api:e}=$();return C({queryKey:[`scheduler`],queryFn:e.scheduler,refetchInterval:3e3})}function mh(){let{api:e}=$();return C({queryKey:[`requests`],queryFn:e.requests,refetchInterval:6e4})}function hh(e){let{api:t}=$();return C({queryKey:[`signals`],queryFn:()=>t.signals(200),enabled:e,refetchInterval:6e4})}function gh(e){let{api:t}=$();return C({queryKey:[`metrics`,e],queryFn:()=>t.metrics(e),refetchInterval:6e4})}function _h(e){let{api:t}=$();return C({queryKey:[`tokens`,e],queryFn:()=>t.tokens(e),refetchInterval:6e4})}function vh(){let{api:e}=$();return C({queryKey:[`channels`],queryFn:e.channels,refetchInterval:6e4})}function yh(){let{api:e}=$();return C({queryKey:[`threads`],queryFn:e.threads,refetchInterval:6e4})}function bh(e){let{api:t}=$();return C({queryKey:[`tasks`,e],queryFn:()=>t.tasks(e),refetchInterval:6e4})}function xh(e){return e.flatMap(e=>e.data??[])}function Sh(){let{api:e}=$();return ut({queries:(dh().data??[]).map(t=>({queryKey:[`tasks`,t.slug],queryFn:()=>e.tasks(t.slug),refetchInterval:6e4})),combine:xh})}function Ch(e){let{api:t}=$();return C({queryKey:[`task`,e],queryFn:()=>t.task(e??``),enabled:e!==null})}function wh(e){let{api:t}=$();return C({queryKey:[`thread`,e],queryFn:()=>t.thread(e??``),enabled:e!==null})}function Th(e,t){let{api:n}=$();return C({queryKey:[`task-file`,e,t],queryFn:()=>n.taskFile(e,t),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof km&&(t.status===404||t.status===503))})}function Eh(e){let{api:t}=$();return C({queryKey:[`image`,e],queryFn:()=>t.image(e),staleTime:1/0,retry:(e,t)=>e<1&&!(t instanceof km&&t.status>=400&&t.status<500)})}function Dh(e){let{api:t}=$();return C({queryKey:[`task-changes`,e],queryFn:()=>t.taskChanges(e),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof km&&(t.status===404||t.status===503))})}function Oh(e,t){let{api:n}=$();return C({queryKey:[`task-diff`,e,t],queryFn:()=>n.taskDiff(e,t),staleTime:3e4,retry:(e,t)=>e<1&&!(t instanceof km&&(t.status===404||t.status===503))})}function kh(){let{api:e}=$();return C({queryKey:[`crons`],queryFn:e.crons,refetchInterval:6e4})}function Ah(){let{api:e}=$();return C({queryKey:[`proposals`],queryFn:e.proposals,refetchInterval:6e4})}function jh(e){let{api:t}=$();return C({queryKey:[`proposal`,e],queryFn:()=>t.proposal(e)})}function Mh(e,t){let{api:n}=$();return C({queryKey:[`proposal`,e,`files`],queryFn:()=>n.proposalFiles(e),enabled:t})}function Nh(){let{api:e}=$();return C({queryKey:[`skills`],queryFn:e.skills,staleTime:6e4})}function Ph(e,t){let{api:n}=$();return C({queryKey:[`turns`,e,t],queryFn:()=>n.turns(e,t),refetchInterval:6e4})}function Fh(e,t){let{api:n}=$();return C({queryKey:[`transcript`,e,t],queryFn:()=>n.transcript(e,t??``),enabled:t!==null,staleTime:1/0})}function Ih(e){let{api:t}=$();return C({queryKey:[`memory`,e],queryFn:()=>t.memory(e)})}function Lh(e){let{api:t}=$();return C({queryKey:[`agent-skills`,e],queryFn:()=>t.agentSkills(e)})}function Rh(e,t){let{api:n}=$();return C({queryKey:[`history`,e,t],queryFn:()=>n.history(e,t),placeholderData:ve})}function zh(e,t,n){let{api:r}=$();return C({queryKey:[`home-change`,e,t],queryFn:()=>r.change(e,t),enabled:n,staleTime:1/0})}function Bh(e){let{api:t}=$();return C({queryKey:[`conflicts`,e],queryFn:()=>t.conflicts(e)})}function Vh(e){let{api:t}=$();return C({queryKey:[`dashboard`,e],queryFn:()=>t.dashboard(e),refetchInterval:12e4})}function Hh(e){let{api:t}=$();return C({queryKey:[`knowledge`,e],queryFn:()=>t.knowledge(e),refetchInterval:12e4})}function Uh(){let{api:e}=$();return C({queryKey:[`runners`],queryFn:()=>e.runners(),refetchInterval:6e4})}function Wh(){let{api:e}=$();return C({queryKey:[`enrollments`],queryFn:e.enrollments,refetchInterval:5e3})}function Gh(e){let{api:t}=$();return C({queryKey:[`models`,`agent`,e],queryFn:()=>t.agentModels(e),staleTime:6e5,retry:!1})}function Kh(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var qh=[[`day`,86400],[`hour`,3600],[`minute`,60]],Jh=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});function Yh(e,t){let n=Math.round((Date.parse(e)-t)/1e3);for(let[e,t]of qh)if(Math.abs(n)>=t)return Jh.format(Math.round(n/t),e);return`just now`}function Xh(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Zh(e,t=220){let n=(e.split(/\n\s*\n/).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith(`#`))??``).replaceAll(/[*_`>]/g,``).replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`}export{mm as $,Rt as $t,$ as A,ue as An,Ed as At,yh as B,te as Bn,W as Bt,Mh as C,Le as Cn,ip as Ct,Uh as D,Oe as Dn,$d as Dt,fh as E,je as En,Yd as Et,Dh as F,de as Fn,Vd as Ft,km as G,s as Gn,xu as Gt,Fh as H,p as Hn,z as Ht,Oh as I,y as In,Bd as It,ah as J,tn as Jt,Om as K,l as Kn,F as Kt,Th as L,me as Ln,ed as Lt,Nh as M,b as Mn,Md as Mt,sh as N,ce as Nn,zd as Nt,ph as O,De as On,Jd as Ot,Ch as P,ae as Pn,Hd as Pt,gm as Q,Mt as Qt,bh as R,Ce as Rn,nd as Rt,jh as S,Ve as Sn,xf as St,mh as T,Me as Tn,Mf as Tt,Ph as U,d as Un,R as Ut,_h as V,g as Vn,Zu as Vt,Eh as W,o as Wn,B as Wt,Tm as X,Jt as Xt,Nm as Y,Yt,wm as Z,Gt as Zt,uh as _,ft as _n,tp as _t,Gh as a,Tt as an,Lp as at,Kh as b,vt as bn,op as bt,vh as c,kt as cn,Ep as ct,Wh as d,pt as dn,qf as dt,Vt as en,cm as et,zh as f,Et as fn,Yf as ft,lh as g,xt as gn,af as gt,Hh as h,Ot as hn,$f as ht,oh as i,Pt as in,Ap as it,hh as j,le as jn,kd as jt,ch as k,oe as kn,Zd as kt,kh as l,bt as ln,ef as lt,Rh as m,mt as mn,Jf as mt,Zh as n,Ft as nn,lm as nt,Lh as o,jt as on,Mp as ot,Bh as p,ht as pn,Kf as pt,Em as q,vn as qt,Xh as r,Nt as rn,Gp as rt,Sh as s,gt as sn,Tp as st,Yh as t,Lt as tn,um as tt,Vh as u,At as un,ep as ut,Ih as v,_t as vn,Xf as vt,Ah as w,Ie as wn,Qf as wt,dh as x,C as xn,rf as xt,gh as y,Dt as yn,Nf as yt,wh as z,xe as zn,td as zt};
@@ -1 +1 @@
1
- import{Pt as e,Rt as t,_t as n,bt as r,ct as i,dt as a,ft as o,lt as s,mt as c,st as l,ut as u,xt as d}from"./format-B6fjC0_a.js";import{s as f}from"./tasks-DCUj5w_d.js";var p=[{group:`yours`,label:`Waiting on you`},{group:`others`,label:`Waiting on others`},{group:`decided`,label:`Decided`}];function m(e){let t=n(e.kind,e.charter);return t.charAt(0).toUpperCase()+t.slice(1)}function h(e){return e.status===`proposed`&&e.proposedBy!==`user`&&r(e.kind,e.charter).includes(`user`)}function g(e){return e.status===`proposed`?h(e)?`yours`:`others`:`decided`}function _(e){return p.map(({group:t})=>{let n=e.filter(e=>g(e)===t);return{group:t,proposals:t===`decided`?n.toSorted((e,t)=>(t.decidedAt??t.createdAt).localeCompare(e.decidedAt??e.createdAt)):n.toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}}).filter(e=>e.proposals.length>0)}var v=new Intl.ListFormat(`en`,{type:`disjunction`});function y(e,t){let n=r(e.kind,e.charter).flatMap(n=>n===`user`?e.proposedBy===`user`?[]:[`you`]:[n===t?`another ${n}`:`the ${n}`]);return n.length===0?`nobody`:v.format(n)}function b(t){let n=e.safeParse(t.charter);return t.kind===`role`&&n.success?n.data:null}function x(e){return e===void 0?`unset`:typeof e==`boolean`?e?`yes`:`no`:Array.isArray(e)?e.length===0?`none`:e.join(`, `):typeof e==`string`||typeof e==`number`?String(e):JSON.stringify(e)}var S=[[`wakeTriggers`,`wake triggers`],[`maxReplicas`,`replicas per project`],[`backlogThreshold`,`backlog per member before scaling`],[`resident`,`warm session`],[`societyScope`,`society role`],[`reflects`,`reflects`],[`reviewDate`,`review date`]];function C(e,t){return{verbsAdded:t.verbs.filter(t=>!e.verbs.includes(t)),verbsRemoved:e.verbs.filter(e=>!t.verbs.includes(e)),purposeChanged:e.purpose.trim()!==t.purpose.trim(),changes:S.flatMap(([n,r])=>{let i=x(e[n]),a=x(t[n]);return i===a?[]:[{field:r,from:i,to:a}]})}}function w(e){return e.replace(/^\s*---\n[\s\S]*?\n---[ \t]*\n?/,``).trim()}function T(e,n){switch(e.kind){case`member`:{let t=u.safeParse(e.charter);if(!t.success)break;let{name:n,role:r,cli:i,memberships:a}=t.data;return`Creates the citizen ${n} (${r}, ${i})${a.length===0?``:` in ${a.join(`, `)}`} and starts its first turn.`}case`role`:{let t=b(e);if(t===null)break;if(!n.roles.some(e=>e.name===t.name))return`Adds the role ${t.name}; nobody holds it until a member proposal is approved.`;let r=n.members.filter(e=>e.role===t.name&&e.status===`active`).length;return r===0?`Rewrites the ${t.name} charter; no active member holds the role.`:`Rewrites the ${t.name} charter for ${r===1?`its member`:`its ${r} members`}, from their next turn.`}case`channel`:{let n=i.safeParse(e.charter);if(!n.success)break;return`Creates #${t(n.data.project,n.data.name)}.`}case`retirement`:{let t=o.safeParse(e.charter);if(!t.success)break;return`Retires ${t.data.agent}: its stages go back to open and its home is archived, not deleted.`}case`skill`:{let t=c.safeParse(e.charter);if(!t.success)break;return n.skills.some(e=>e.name===t.data.name)?`Replaces the society's ${t.data.name} skill with ${t.data.body===void 0?`these files`:`this text`}.`:`Publishes ${t.data.name} to the society's skills, which every citizen's instructions list.`}case`archive`:{let t=l.safeParse(e.charter);if(!t.success)break;return`Archives ${t.data.project}: its members leave, its open threads close, and it takes no more work; its channels, tasks, and history stay readable.`}case`reallocation`:{let t=a.safeParse(e.charter);if(!t.success){if(!s.safeParse(e.charter).success)break;return`Records the decision; a reallocation from before reallocations changed roles applies nothing.`}let r=n.roles.find(e=>e.name===t.data.role);if(r===void 0)return`No role ${t.data.role} exists; approving it will fail.`;let i=d(r,t.data.changes);if(i.length===0)return`The ${r.name} role has these values already; approving it will fail.`;let o=n.members.filter(e=>e.role===r.name&&e.status===`active`).length,c=o===0?`; no active member holds the role`:` for ${o===1?`its member`:`its ${o} members`}, from their next turn`;return`Changes the ${r.name} charter (${i.join(`; `)})${c}.`}}return`The charter does not parse as its kind; approving it will fail.`}function E(e){let t=f(e);if(t===`landing`||t===`done`||t===`abandoned`)return null;let n=e.stages.find(t=>t.id===e.stage);return n===void 0||n.agent!==`user`&&n.role!==`user`?null:e.status===`open`||e.claimedBy===`user`?n:null}function D(e){let t=(e,t)=>e.since.localeCompare(t.since),n=e.proposals.filter(h).map(e=>({kind:`proposal`,since:e.createdAt,proposal:e})),r=e.tasks.flatMap(e=>{let t=E(e);return t===null?[]:[{kind:`stage`,since:e.stageSince,task:e,stage:t}]}),i=e.requests.map(({message:e,thread:t})=>({kind:`request`,since:e.ts,message:e,thread:t}));return[...n.toSorted(t),...r.toSorted(t),...i.toSorted(t)]}export{D as a,C as c,h as d,_ as i,w as l,T as n,m as o,y as r,b as s,p as t,E as u};
1
+ import{Ct as e,Lt as t,Vt as n,_t as r,bt as i,dt as a,ft as o,ht as s,mt as c,pt as l,ut as u,wt as d}from"./format-DT52SbbR.js";import{s as f}from"./tasks-R3YgpYTe.js";var p=[{group:`yours`,label:`Waiting on you`},{group:`others`,label:`Waiting on others`},{group:`decided`,label:`Decided`}];function m(e){let t=i(e.kind,e.charter);return t.charAt(0).toUpperCase()+t.slice(1)}function h(t){return t.status===`proposed`&&t.proposedBy!==`user`&&e(t.kind,t.charter).includes(`user`)}function g(e){return e.status===`proposed`?h(e)?`yours`:`others`:`decided`}function _(e){return p.map(({group:t})=>{let n=e.filter(e=>g(e)===t);return{group:t,proposals:t===`decided`?n.toSorted((e,t)=>(t.decidedAt??t.createdAt).localeCompare(e.decidedAt??e.createdAt)):n.toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}}).filter(e=>e.proposals.length>0)}var v=new Intl.ListFormat(`en`,{type:`disjunction`});function y(t,n){let r=e(t.kind,t.charter).flatMap(e=>e===`user`?t.proposedBy===`user`?[]:[`you`]:[e===n?`another ${e}`:`the ${e}`]);return r.length===0?`nobody`:v.format(r)}function b(e){let n=t.safeParse(e.charter);return e.kind===`role`&&n.success?n.data:null}function x(e){return e===void 0?`unset`:typeof e==`boolean`?e?`yes`:`no`:Array.isArray(e)?e.length===0?`none`:e.join(`, `):typeof e==`string`||typeof e==`number`?String(e):JSON.stringify(e)}var S=[[`wakeTriggers`,`wake triggers`],[`maxReplicas`,`replicas per project`],[`backlogThreshold`,`backlog per member before scaling`],[`resident`,`warm session`],[`societyScope`,`society role`],[`reflects`,`reflects`],[`reviewDate`,`review date`]];function C(e,t){return{verbsAdded:t.verbs.filter(t=>!e.verbs.includes(t)),verbsRemoved:e.verbs.filter(e=>!t.verbs.includes(e)),purposeChanged:e.purpose.trim()!==t.purpose.trim(),changes:S.flatMap(([n,r])=>{let i=x(e[n]),a=x(t[n]);return i===a?[]:[{field:r,from:i,to:a}]})}}function w(e){return e.replace(/^\s*---\n[\s\S]*?\n---[ \t]*\n?/,``).trim()}function T(e,t){switch(e.kind){case`member`:{let t=l.safeParse(e.charter);if(!t.success)break;let{name:n,role:r,cli:i,memberships:a}=t.data;return`Creates the citizen ${n} (${r}, ${i})${a.length===0?``:` in ${a.join(`, `)}`} and starts its first turn.`}case`role`:{let n=b(e);if(n===null)break;if(!t.roles.some(e=>e.name===n.name))return`Adds the role ${n.name}; nobody holds it until a member proposal is approved.`;let r=t.members.filter(e=>e.role===n.name&&e.status===`active`).length;return r===0?`Rewrites the ${n.name} charter; no active member holds the role.`:`Rewrites the ${n.name} charter for ${r===1?`its member`:`its ${r} members`}, from their next turn.`}case`channel`:{let t=a.safeParse(e.charter);if(!t.success)break;return`Creates #${n(t.data.project,t.data.name)}.`}case`retirement`:{let t=s.safeParse(e.charter);if(!t.success)break;return`Retires ${t.data.agent}: its stages go back to open and its home is archived, not deleted.`}case`skill`:{let n=r.safeParse(e.charter);if(!n.success)break;return t.skills.some(e=>e.name===n.data.name)?`Replaces the society's ${n.data.name} skill with ${n.data.body===void 0?`these files`:`this text`}.`:`Publishes ${n.data.name} to the society's skills, which every citizen's instructions list.`}case`archive`:{let t=u.safeParse(e.charter);if(!t.success)break;return`Archives ${t.data.project}: its members leave, its open threads close, and it takes no more work; its channels, tasks, and history stay readable.`}case`reallocation`:{let n=c.safeParse(e.charter);if(!n.success){if(!o.safeParse(e.charter).success)break;return`Records the decision; a reallocation from before reallocations changed roles applies nothing.`}let r=t.roles.find(e=>e.name===n.data.role);if(r===void 0)return`No role ${n.data.role} exists; approving it will fail.`;let i=d(r,n.data.changes);if(i.length===0)return`The ${r.name} role has these values already; approving it will fail.`;let a=t.members.filter(e=>e.role===r.name&&e.status===`active`).length,s=a===0?`; no active member holds the role`:` for ${a===1?`its member`:`its ${a} members`}, from their next turn`;return`Changes the ${r.name} charter (${i.join(`; `)})${s}.`}}return`The charter does not parse as its kind; approving it will fail.`}function E(e){let t=f(e);if(t===`landing`||t===`done`||t===`abandoned`)return null;let n=e.stages.find(t=>t.id===e.stage);return n===void 0||n.agent!==`user`&&n.role!==`user`?null:e.status===`open`||e.claimedBy===`user`?n:null}function D(e){let t=(e,t)=>e.since.localeCompare(t.since),n=e.proposals.filter(h).map(e=>({kind:`proposal`,since:e.createdAt,proposal:e})),r=e.tasks.flatMap(e=>{let t=E(e);return t===null?[]:[{kind:`stage`,since:e.stageSince,task:e,stage:t}]}),i=e.requests.map(({message:e,thread:t})=>({kind:`request`,since:e.ts,message:e,thread:t}));return[...n.toSorted(t),...r.toSorted(t),...i.toSorted(t)]}export{D as a,C as c,h as d,_ as i,w as l,T as n,m as o,y as r,b as s,p as t,E as u};