local-operator-ui 0.57.3 → 0.57.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +669 -17
- package/out/preload/index.js +56 -1
- package/out/renderer/assets/{_basePickBy-BeAzmqgq.js → _basePickBy-CqOK9I5a.js} +1 -1
- package/out/renderer/assets/{_baseUniq-Clx9gdFs.js → _baseUniq-Dfknltze.js} +1 -1
- package/out/renderer/assets/{agent-details-page-BMztNR89.js → agent-details-page-DKOAeAlz.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-quUNNwcr.js → agent-hub-page-D75ZCD-T.js} +1 -1
- package/out/renderer/assets/{agents-page-BTYHgMAf.js → agents-page-Dy9dT2J6.js} +3 -3
- package/out/renderer/assets/{appearance-DCqlsN7S.js → appearance-RPtl24uV.js} +1 -1
- package/out/renderer/assets/{arc-BOZHzyJm.js → arc-CJgGs8E0.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CpE8Siol.js → architectureDiagram-IEHRJDOE-BO-PVfmy.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-BWJE7j7A.js → avatar-cropper-IPFrNOZH.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-D4LTtQ_H.js → blockDiagram-JOT3LUYC-D4kISdJw.js} +1 -1
- package/out/renderer/assets/{book-open-fa_DaJBq.js → book-open-DSEz_hQQ.js} +1 -1
- package/out/renderer/assets/browser-page-4rUf9E5f.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-VC7pNm9O.js → browser-webauthn-prompt-DUTEBHSl.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DRtUDXOF.js → c4Diagram-VJAJSXHY-jrrji_Tt.js} +1 -1
- package/out/renderer/assets/channel-DSbKlaIM.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Cw4VudrA.js → chunk-4BMEZGHF-34jCJWgL.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-0JOiKMb-.js → chunk-A2AXSNBT-D2utPfjC.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CAKCg9DA.js → chunk-AEK57VVT-Chv6UTYK.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-CFZ2DTGX.js → chunk-D6G4REZN-8au1oDUE.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-CupwUHva.js → chunk-RZ5BOZE2-DCRrSym3.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-B1vcbFku.js → chunk-XZIHB7SX-BFp6lbut.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-B3UBTKI6.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-B3UBTKI6.js +1 -0
- package/out/renderer/assets/clone-CI0Pk6Pw.js +1 -0
- package/out/renderer/assets/{console-mirror-IB35kNI8.js → console-mirror-COvJr604.js} +1 -1
- package/out/renderer/assets/{consoleCapture-D4G96kDb.js → consoleCapture-Cl0JWwqq.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-DlorrZ6B.js → conversation-input-sync-bGjigx3Z.js} +4 -4
- package/out/renderer/assets/{dagre-OKDRZEBW-CunvCCGM.js → dagre-OKDRZEBW-WWu0Yua1.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DlpXMePq.js → diagram-SSKATNLV-CS9Mvsr2.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-CtgMK6MT.js → diagram-VNBRO52H-qqdP8fjP.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-C-QNezLB.js → erDiagram-Q7BY3M3F-Dcxo6XZi.js} +1 -1
- package/out/renderer/assets/{error-boundary-C1x5W-AX.js → error-boundary-BQ911DnY.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DjwRYw0E.js → flowDiagram-4HSFHLVR-CrxBDmsr.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-Tb5F1KXD.js → ganttDiagram-APWFNJXF-Bx-sfLxO.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BokP9Y1T.js → gitGraphDiagram-7IBYFJ6S-CJxWCbNe.js} +1 -1
- package/out/renderer/assets/{graph-DEHYXN6b.js → graph-BNSj1GHJ.js} +1 -1
- package/out/renderer/assets/{heart-DqMMtrJ1.js → heart-i91yzAwW.js} +1 -1
- package/out/renderer/assets/{index-BnqyWEPM.css → index-BlC0KBYH.css} +1 -1
- package/out/renderer/assets/{index-CJ8BPUHQ.js → index-BvbUVrcK.js} +1 -1
- package/out/renderer/assets/{index-D7fnBkIK.js → index-BxFcVHbG.js} +1 -1
- package/out/renderer/assets/index-CdTxr8VM.js +852 -0
- package/out/renderer/assets/{index-BWQzFq0n.js → index-CxNjWpOb.js} +10 -10
- package/out/renderer/assets/infoDiagram-PH2N3AL5-PsB_DDDA.js +2 -0
- package/out/renderer/assets/{inline-error-boundary-ChbTvdIh.js → inline-error-boundary-CEz9_z6I.js} +1 -1
- package/out/renderer/assets/{installer-Bplg-bpo.js → installer-G-5Vi1J-.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BfXoBW-2.js → journeyDiagram-U35MCT3I-DoNy_9X6.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BeT3LOJG.js → kanban-definition-NDS4AKOZ-DdvklVql.js} +1 -1
- package/out/renderer/assets/{layout-B71SsWep.js → layout-qfLIC44U.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BaSX_kru.js → legacy-agents-page-vNWqLnJO.js} +1 -1
- package/out/renderer/assets/{library-page-BwmVBhNJ.js → library-page-CsKdpZoN.js} +3 -3
- package/out/renderer/assets/{log-in-C4tjIXzF.js → log-in-ge87dxtE.js} +1 -1
- package/out/renderer/assets/{mermaid.core-D7wfsRjY.js → mermaid.core-34ehUt9F.js} +5 -5
- package/out/renderer/assets/{mesh-page-DbC0RmVo.js → mesh-page-Drazw6sy.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BPTOzHuL.js → mindmap-definition-ALO5MXBD-DS9A7X_9.js} +1 -1
- package/out/renderer/assets/{mini-DXMqE-0u.js → mini-CiYAeR9E.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CQdB2BC5.js → notebook-pen-6_thWw32.js} +1 -1
- package/out/renderer/assets/{notifications-page-C9PU2typ.js → notifications-page-B9lBzyI_.js} +1 -1
- package/out/renderer/assets/{org-access-Fw38H9fZ.js → org-access-LWjiDIPH.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CKBjFWJL.js → org-surface-gate-DGeVPoHg.js} +1 -1
- package/out/renderer/assets/{page-header-CAW9G_fb.js → page-header-DsXvFR6j.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-C0JN0KMq.js → pieDiagram-IB7DONF6-BzNpgGTh.js} +1 -1
- package/out/renderer/assets/{projects-page-D9F4QotN.js → projects-page-BJV0JVfL.js} +1 -1
- package/out/renderer/assets/{publication-validation-DygSOQkj.js → publication-validation-BIxxMtE8.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-BRgjFQlM.js → quadrantDiagram-7GDLP6J5-BGFLFl2M.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-VE0niGVF.js → radar-MK3ICKWK-QP0xpCZj.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CXMLVkUO.js → radient-auth-buttons-GwvFtoOd.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DkwJBmMi.js → requirementDiagram-KVF5MWMF-d1hwIQYi.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DFv3zh8B.js → sankeyDiagram-QLVOVGJD-Bel2U3qO.js} +1 -1
- package/out/renderer/assets/{schedules-page-aTbxrD_M.js → schedules-page-CJV3Oiiy.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BXcr3er8.js → sequenceDiagram-X6HHIX6F-Et2XMzpI.js} +1 -1
- package/out/renderer/assets/{settings-page-DWZ3Mguh.js → settings-page-sfk5JVcx.js} +1 -1
- package/out/renderer/assets/{smartart-CWBh1X_F.js → smartart-Csc0zQan.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Cw08neDd.js → stateDiagram-DGXRK772-D2GwxW6w.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BHUZ7x6j.js +1 -0
- package/out/renderer/assets/{team-bridge-page-BHAdGSZS.js → team-bridge-page-CW5zV9mz.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-B-ZFBehC.js → timeline-definition-BDJGKUSR-BUZLWyEg.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-C8DUslhy.js → use-default-on-banner-CsqO83vJ.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-DMGaSxDK.js → use-download-agent-mutation-F8kNbCPE.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BGB8PPzY.js → xychartDiagram-VJFVF3MP-C9F7-D_T.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +6 -6
- package/package.json +1 -1
- package/out/renderer/assets/browser-page-AgwdXhLM.js +0 -1
- package/out/renderer/assets/channel-DMQl-cpj.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DJsxDWD8.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DJsxDWD8.js +0 -1
- package/out/renderer/assets/clone-B9GxWhWi.js +0 -1
- package/out/renderer/assets/index-Buuz619t.js +0 -852
- package/out/renderer/assets/infoDiagram-PH2N3AL5-bdAhVGkO.js +0 -2
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BtazAv7-.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,j as U_,b as Sd,D as B_,l as Vc,m as Ep,n as Zc,o as H_}from"./index-BWQzFq0n.js";import{c as sn,t as g,a as W_}from"./messages-B7aIuFuF.js";import{P as G_,i as Yc,a as Xc,p as Ip}from"./roles-D1pcbxAx.js";const Ed=new Map,Id=new Map,Ad=new Map,Rd=new Map;function Jc(e){return e===void 0?"":JSON.stringify(e)}function Qc(e,t){const n=`${e}\0${Jc(t)}`;let r=Ed.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),Ed.set(n,r)),r}function z_(e,t){const n=`${e}\0${Jc(t)}`;let r=Id.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Id.set(n,r)),r}function pM(e,t,n){return Qc(n??sn(),t).format(e)}const hM={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};function mM(e,t,n){return Qc(n??sn(),t).format(e)}function K_(e,t,n){return Qc(n??sn(),t).format(e)}function V_(e,t,n){return z_(n??sn(),t).format(e)}function gM(e,t,n,r){const o=r??sn(),i=`${o}\0${Jc(n)}`;let a=Ad.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(o,n),Ad.set(i,a)),a.format(e,t)}const Z_={B:"byte",KB:"kilobyte",MB:"megabyte",GB:"gigabyte",TB:"terabyte",PB:"petabyte"},xd=new Map,Td=new Map;function Y_(e){return e.split("-")[0]?.toLowerCase()==="en"}function X_(e,t){if(e==="KiB"||e==="MiB"||e==="GiB"||Y_(t))return e;const n=`${t}\0${e}`;let r=xd.get(n);if(r===void 0){r=e;try{r=new Intl.NumberFormat(t,{style:"unit",unit:Z_[e],unitDisplay:"narrow"}).formatToParts(1).find(i=>i.type==="unit")?.value??e}catch{}xd.set(n,r)}return r}function J_(e){let t=Td.get(e);if(t===void 0){t=" ";try{t=new Intl.NumberFormat(e,{style:"unit",unit:"kilobyte",unitDisplay:"short"}).formatToParts(1).find(r=>r.type==="literal")?.value??" "}catch{}Td.set(e,t)}return t}function wo(e,t,n,r){const o=sn();return`${V_(e,{useGrouping:!1,...n},o)}${J_(o)}${X_(t,o)}`}function Ni(e,t){const n=sn();let r=Rd.get(n);return r===void 0&&(r=new Intl.ListFormat(n,{type:"conjunction",style:"narrow"}),Rd.set(n,r)),r.format(e)}const Q_={zh:";",ja:";",ur:"؛ ",ar:"؛ "};function _M(e,t){const n=sn().split("-")[0]?.toLowerCase();return e.join(Q_[n??""]??"; ")}var ni=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ir=typeof window>"u"||"Deno"in globalThis;function Tt(){}function q_(e,t){return typeof e=="function"?e(t):e}function Fa(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ap(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Pr(e,t){return typeof e=="function"?e(t):e}function Ht(e,t){return typeof e=="function"?e(t):e}function Cd(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:a,stale:c}=e;if(a){if(r){if(t.queryHash!==qc(a,t.options))return!1}else if(!xo(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||i&&!i(t))}function Od(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ro(t.options.mutationKey)!==Ro(i))return!1}else if(!xo(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function qc(e,t){return(t?.queryKeyHashFn||Ro)(e)}function Ro(e){return JSON.stringify(e,(t,n)=>Ba(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function xo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>xo(e[n],t[n])):!1}function Rp(e,t){if(e===t)return e;const n=Pd(e)&&Pd(t);if(n||Ba(e)&&Ba(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),a=i.length,c=n?[]:{};let l=0;for(let d=0;d<a;d++){const u=n?d:i[d];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(c[u]=void 0,l++):(c[u]=Rp(e[u],t[u]),c[u]===e[u]&&e[u]!==void 0&&l++)}return o===a&&l===o?e:c}return t}function Ua(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Pd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ba(e){if(!Md(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Md(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Md(e){return Object.prototype.toString.call(e)==="[object Object]"}function eb(e){return new Promise(t=>{setTimeout(t,e)})}function Ha(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Rp(e,t):t}function tb(e){return e}function nb(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function rb(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var el=Symbol();function xp(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===el?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ob=class extends ni{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!ir&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},tl=new ob,ib=class extends ni{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!ir&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},Vi=new ib;function Wa(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function sb(e){return Math.min(1e3*2**e,3e4)}function Tp(e){return(e??"online")==="online"?Vi.isOnline():!0}var Cp=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Zs(e){return e instanceof Cp}function Op(e){let t=!1,n=0,r=!1,o;const i=Wa(),a=v=>{r||(h(new Cp(v)),e.abort?.())},c=()=>{t=!0},l=()=>{t=!1},d=()=>tl.isFocused()&&(e.networkMode==="always"||Vi.isOnline())&&e.canRun(),u=()=>Tp(e.networkMode)&&e.canRun(),f=v=>{r||(r=!0,e.onSuccess?.(v),o?.(),i.resolve(v))},h=v=>{r||(r=!0,e.onError?.(v),o?.(),i.reject(v))},_=()=>new Promise(v=>{o=b=>{(r||d())&&v(b)},e.onPause?.()}).then(()=>{o=void 0,r||e.onContinue?.()}),y=()=>{if(r)return;let v;const b=n===0?e.initialPromise:void 0;try{v=b??e.fn()}catch(p){v=Promise.reject(p)}Promise.resolve(v).then(f).catch(p=>{if(r)return;const A=e.retry??(ir?0:3),k=e.retryDelay??sb,M=typeof k=="function"?k(n,p):k,P=A===!0||typeof A=="number"&&n<A||typeof A=="function"&&A(n,p);if(t||!P){h(p);return}n++,e.onFail?.(n,p),eb(M).then(()=>d()?void 0:_()).then(()=>{t?h(p):y()})})};return{promise:i,cancel:a,continue:()=>(o?.(),i),cancelRetry:c,continueRetry:l,canStart:u,start:()=>(u()?y():_().then(y),i)}}var ab=e=>setTimeout(e,0);function cb(){let e=[],t=0,n=c=>{c()},r=c=>{c()},o=ab;const i=c=>{t?e.push(c):o(()=>{n(c)})},a=()=>{const c=e;e=[],c.length&&o(()=>{r(()=>{c.forEach(l=>{n(l)})})})};return{batch:c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},batchCalls:c=>(...l)=>{i(()=>{c(...l)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{o=c}}}var ot=cb(),Pp=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fa(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ir?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},lb=class extends Pp{#t;#e;#n;#r;#o;#a;#s;constructor(e){super(),this.#s=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=db(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#o?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=Ha(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#o?.promise;return this.#o?.cancel(e),t?t.then(Tt).catch(Tt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Ht(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===el||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Ap(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#o?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#o?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#o&&(this.#s?this.#o.cancel({revert:!0}):this.#o.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#o)return this.#o.continueRetry(),this.#o.promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,r=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},o=()=>{const c=xp(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#s=!1,this.options.persister?this.options.persister(c,l,this):c(l)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:o};r(i),this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#i({type:"fetch",meta:i.fetchOptions?.meta});const a=c=>{Zs(c)&&c.silent||this.#i({type:"error",error:c}),Zs(c)||(this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this)),this.scheduleGc()};return this.#o=Op({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:c=>{if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(l){a(l);return}this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,l)=>{this.#i({type:"failed",failureCount:c,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#o.start()}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Mp(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return Zs(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),ot.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function Mp(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Tp(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function db(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var ub=class extends ni{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,o=t.queryHash??qc(r,t);let i=this.get(o);return i||(i=new lb({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ot.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Cd(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Cd(e,n)):t}notify(e){ot.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ot.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ot.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},fb=class extends Pp{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||pb(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=Op({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,o)=>{this.#r({type:"failed",failureCount:r,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const o=await this.options.onMutate?.(e);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ot.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function pb(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var hb=class extends ni{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new fb({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=pi(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=pi(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=pi(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(o=>o.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=pi(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ot.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Od(t,n))}findAll(e={}){return this.getAll().filter(t=>Od(e,t))}notify(e){ot.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ot.batch(()=>Promise.all(e.map(t=>t.continue().catch(Tt))))}};function pi(e){return e.options.scope?.id}function jd(e){return{onFetch:(t,n)=>{const r=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const f=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},h=xp(t.options,t.fetchOptions),_=async(y,v,b)=>{if(u)return Promise.reject();if(v==null&&y.pages.length)return Promise.resolve(y);const p={client:t.client,queryKey:t.queryKey,pageParam:v,direction:b?"backward":"forward",meta:t.options.meta};f(p);const A=await h(p),{maxPages:k}=t.options,M=b?rb:nb;return{pages:M(y.pages,A,k),pageParams:M(y.pageParams,v,k)}};if(o&&i.length){const y=o==="backward",v=y?jp:Ga,b={pages:i,pageParams:a},p=v(r,b);c=await _(b,p,y)}else{const y=e??i.length;do{const v=l===0?a[0]??r.initialPageParam:Ga(r,c);if(l>0&&v==null)break;c=await _(c,v),l++}while(l<y)}return c};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function Ga(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function jp(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function bM(e,t){return t?Ga(e,t)!=null:!1}function vM(e,t){return!t||!e.getPreviousPageParam?!1:jp(e,t)!=null}var mb=class{#t;#e;#n;#r;#o;#a;#s;#i;constructor(e={}){this.#t=e.queryCache||new ub,this.#e=e.mutationCache||new hb,this.#n=e.defaultOptions||{},this.#r=new Map,this.#o=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#s=tl.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=Vi.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#s?.(),this.#s=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Pr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#t.get(r.queryHash)?.state.data,a=q_(t,i);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ot.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;ot.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return ot.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ot.batch(()=>this.#t.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Tt).catch(Tt)}invalidateQueries(e,t={}){return ot.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ot.batch(()=>this.#t.findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Tt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Tt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(Pr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Tt).catch(Tt)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Tt).catch(Tt)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Vi.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Ro(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{xo(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#o.set(Ro(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(r=>{xo(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=qc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===el&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},gb=class extends ni{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#s=Wa(),this.options.experimental_prefetchInRender||this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#o;#a;#s;#i;#m;#f;#p;#l;#d;#c;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),$d(this.#e,this.options)?this.#u():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return za(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return za(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ht(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#k(),this.#e.setOptions(this.options),t._defaulted&&!Ua(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Dd(this.#e,n,this.options,t)&&this.#u(),this.updateResult(),r&&(this.#e!==n||Ht(this.options.enabled,this.#e)!==Ht(t.enabled,this.#e)||Pr(this.options.staleTime,this.#e)!==Pr(t.staleTime,this.#e))&&this.#g();const o=this.#_();r&&(this.#e!==n||Ht(this.options.enabled,this.#e)!==Ht(t.enabled,this.#e)||o!==this.#c)&&this.#b(o)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return bb(this,n)&&(this.#r=n,this.#a=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#u(e){this.#k();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Tt)),t}#g(){this.#y();const e=Pr(this.options.staleTime,this.#e);if(ir||this.#r.isStale||!Fa(e))return;const n=Ap(this.#r.dataUpdatedAt,e)+1;this.#l=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#c=e,!(ir||Ht(this.options.enabled,this.#e)===!1||!Fa(this.#c)||this.#c===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||tl.isFocused())&&this.#u()},this.#c))}#v(){this.#g(),this.#b(this.#_())}#y(){this.#l&&(clearTimeout(this.#l),this.#l=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,t){const n=this.#e,r=this.options,o=this.#r,i=this.#o,a=this.#a,l=e!==n?e.state:this.#n,{state:d}=e;let u={...d},f=!1,h;if(t._optimisticResults){const m=this.hasListeners(),w=!m&&$d(e,t),S=m&&Dd(e,n,t,r);(w||S)&&(u={...u,...Mp(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:_,errorUpdatedAt:y,status:v}=u;h=u.data;let b=!1;if(t.placeholderData!==void 0&&h===void 0&&v==="pending"){let m;o?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(m=o.data,b=!0):m=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,m!==void 0&&(v="success",h=Ha(o?.data,m,t),f=!0)}if(t.select&&h!==void 0&&!b)if(o&&h===i?.data&&t.select===this.#m)h=this.#f;else try{this.#m=t.select,h=t.select(h),h=Ha(o?.data,h,t),this.#f=h,this.#i=null}catch(m){this.#i=m}this.#i&&(_=this.#i,h=this.#f,y=Date.now(),v="error");const p=u.fetchStatus==="fetching",A=v==="pending",k=v==="error",M=A&&p,P=h!==void 0,R={status:v,fetchStatus:u.fetchStatus,isPending:A,isSuccess:v==="success",isError:k,isInitialLoading:M,isLoading:M,data:h,dataUpdatedAt:u.dataUpdatedAt,error:_,errorUpdatedAt:y,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:p,isRefetching:p&&!A,isLoadingError:k&&!P,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:k&&P,isStale:nl(e,t),refetch:this.refetch,promise:this.#s};if(this.options.experimental_prefetchInRender){const m=T=>{R.status==="error"?T.reject(R.error):R.data!==void 0&&T.resolve(R.data)},w=()=>{const T=this.#s=R.promise=Wa();m(T)},S=this.#s;switch(S.status){case"pending":e.queryHash===n.queryHash&&m(S);break;case"fulfilled":(R.status==="error"||R.data!==S.value)&&w();break;case"rejected":(R.status!=="error"||R.error!==S.reason)&&w();break}}return R}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#a=this.options,this.#o.data!==void 0&&(this.#p=this.#e),Ua(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,o=typeof r=="function"?r():r;if(o==="all"||!o&&!this.#h.size)return!0;const i=new Set(o??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const c=a;return this.#r[c]!==e[c]&&i.has(c)})};this.#S({listeners:n()})}#k(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#S(e){ot.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function _b(e,t){return Ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function $d(e,t){return _b(e,t)||e.state.data!==void 0&&za(e,t,t.refetchOnMount)}function za(e,t,n){if(Ht(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&nl(e,t)}return!1}function Dd(e,t,n,r){return(e!==t||Ht(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&nl(e,n)}function nl(e,t){return Ht(t.enabled,e)!==!1&&e.isStaleByTime(Pr(t.staleTime,e))}function bb(e,t){return!Ua(e.getCurrentResult(),t)}var rl=x.createContext(void 0),vb=e=>{const t=x.useContext(rl);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},yM=({client:e,children:t})=>(x.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),U_.jsx(rl.Provider,{value:e,children:t})),$p=x.createContext(!1),yb=()=>x.useContext($p);$p.Provider;function wb(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kb=x.createContext(wb()),Sb=()=>x.useContext(kb);function Eb(e,t){return typeof e=="function"?e(...t):!!e}function Nd(){}var Ib=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ab=e=>{x.useEffect(()=>{e.clearReset()},[e])},Rb=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Eb(n,[e.error,r])),xb=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Tb=(e,t)=>e.isLoading&&e.isFetching&&!t,Cb=(e,t)=>e?.suspense&&t.isPending,Ld=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ob(e,t,n){const r=vb(n),o=yb(),i=Sb(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=o?"isRestoring":"optimistic",xb(a),Ib(a,i),Ab(i);const c=!r.getQueryCache().get(a.queryHash),[l]=x.useState(()=>new t(r,a)),d=l.getOptimisticResult(a),u=!o&&e.subscribed!==!1;if(x.useSyncExternalStore(x.useCallback(f=>{const h=u?l.subscribe(ot.batchCalls(f)):Nd;return l.updateResult(),h},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),x.useEffect(()=>{l.setOptions(a)},[a,l]),Cb(a,d))throw Ld(a,l,i);if(Rb({result:d,errorResetBoundary:i,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw d.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!ir&&Tb(d,o)&&(c?Ld(a,l,i):r.getQueryCache().get(a.queryHash)?.promise)?.catch(Nd).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?d:l.trackResult(d)}function Dp(e,t){return Ob(e,gb,t)}const Pb=()=>{const e=x.useContext(rl)??null,t=x.useMemo(()=>new mb({defaultOptions:{queries:{enabled:!1,retry:!1,gcTime:0}}}),[]);return x.useEffect(()=>{if(!e)return()=>t.clear()},[e,t]),x.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])};function wM(e){return e!=="detached"&&e!=="wedged"}function Np(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function kM(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=Np(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}var ve;(function(e){e.assertEqual=o=>o;function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{const i={};for(const a of o)i[a]=a;return i},e.getValidEnumValues=o=>{const i=e.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),a={};for(const c of i)a[c]=o[c];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const i=[];for(const a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(const a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(ve||(ve={}));var Ka;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ka||(Ka={}));const B=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),un=e=>{switch(typeof e){case"undefined":return B.undefined;case"string":return B.string;case"number":return isNaN(e)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(e)?B.array:e===null?B.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?B.promise:typeof Map<"u"&&e instanceof Map?B.map:typeof Set<"u"&&e instanceof Set?B.set:typeof Date<"u"&&e instanceof Date?B.date:B.object;default:return B.unknown}},j=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Mb=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class kt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},o=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){const d=a.path[l];l===a.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(a))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return o(this),r}static assert(t){if(!(t instanceof kt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const o of this.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}kt.create=e=>new kt(e);const Br=(e,t)=>{let n;switch(e.code){case j.invalid_type:e.received===B.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case j.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ve.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:n=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case j.invalid_union:n="Invalid input";break;case j.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case j.invalid_enum_value:n=`Invalid enum value. Expected ${ve.joinValues(e.options)}, received '${e.received}'`;break;case j.invalid_arguments:n="Invalid function arguments";break;case j.invalid_return_type:n="Invalid function return type";break;case j.invalid_date:n="Invalid date";break;case j.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ve.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case j.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case j.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case j.custom:n="Invalid input";break;case j.invalid_intersection_types:n="Intersection results could not be merged";break;case j.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case j.not_finite:n="Number must be finite";break;default:n=t.defaultError,ve.assertNever(e)}return{message:n}};let Lp=Br;function jb(e){Lp=e}function Zi(){return Lp}const Yi=e=>{const{data:t,path:n,errorMaps:r,issueData:o}=e,i=[...n,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let c="";const l=r.filter(d=>!!d).slice().reverse();for(const d of l)c=d(a,{data:t,defaultError:c}).message;return{...o,path:i,message:c}},$b=[];function L(e,t){const n=Zi(),r=Yi({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Br?void 0:Br].filter(o=>!!o)});e.common.issues.push(r)}class ut{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const o of n){if(o.status==="aborted")return ee;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const o of n){const i=await o.key,a=await o.value;r.push({key:i,value:a})}return ut.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const o of n){const{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return ee;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const ee=Object.freeze({status:"aborted"}),Rr=e=>({status:"dirty",value:e}),ft=e=>({status:"valid",value:e}),Va=e=>e.status==="aborted",Za=e=>e.status==="dirty",sr=e=>e.status==="valid",To=e=>typeof Promise<"u"&&e instanceof Promise;function Xi(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function Fp(e,t,n,r,o){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var K;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(K||(K={}));var ho,mo;class rn{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Fd=(e,t)=>{if(sr(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new kt(e.common.issues);return this._error=n,this._error}}};function ce(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,c)=>{var l,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:c.defaultError}},description:o}}class ue{get description(){return this._def.description}_getType(t){return un(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:un(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ut,ctx:{common:t.parent.common,data:t.data,parsedType:un(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(To(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const o={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)},i=this._parseSync({data:t,path:o.path,parent:o});return Fd(o,i)}"~validate"(t){var n,r;const o={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:o});return sr(i)?{value:i.value}:{issues:o.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),o.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:o}).then(i=>sr(i)?{value:i.value}:{issues:o.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)},o=this._parse({data:t,path:r.path,parent:r}),i=await(To(o)?o:Promise.resolve(o));return Fd(r,i)}refine(t,n){const r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{const a=t(o),c=()=>i.addIssue({code:j.custom,...r(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Vt({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return tn.create(this,this._def)}nullable(){return $n.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return zt.create(this)}promise(){return Wr.create(this,this._def)}or(t){return Mo.create([this,t],this._def)}and(t){return jo.create(this,t,this._def)}transform(t){return new Vt({...ce(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Fo({...ce(this._def),innerType:this,defaultValue:n,typeName:q.ZodDefault})}brand(){return new ol({typeName:q.ZodBranded,type:this,...ce(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Uo({...ce(this._def),innerType:this,catchValue:n,typeName:q.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return ri.create(this,t)}readonly(){return Bo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Db=/^c[^\s-]{8,}$/i,Nb=/^[0-9a-z]+$/,Lb=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fb=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ub=/^[a-z0-9_-]{21}$/i,Bb=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Wb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ys;const zb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Kb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Vb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Zb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Up="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Jb=new RegExp(`^${Up}$`);function Bp(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Qb(e){return new RegExp(`^${Bp(e)}$`)}function Hp(e){let t=`${Up}T${Bp(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function qb(e,t){return!!((t==="v4"||!t)&&zb.test(e)||(t==="v6"||!t)&&Vb.test(e))}function ev(e,t){if(!Bb.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||!o.typ||!o.alg||t&&o.alg!==t)}catch{return!1}}function tv(e,t){return!!((t==="v4"||!t)&&Kb.test(e)||(t==="v6"||!t)&&Zb.test(e))}class Gt extends ue{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==B.string){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.string,received:i.parsedType}),ee}const r=new ut;let o;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,c=t.data.length<i.value;(a||c)&&(o=this._getOrReturnCtx(t,o),a?L(o,{code:j.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&L(o,{code:j.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Wb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"email",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ys||(Ys=new RegExp(Gb,"u")),Ys.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"emoji",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Fb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"uuid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ub.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"nanoid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Db.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Nb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid2",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Lb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ulid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),L(o,{validation:"url",code:j.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"regex",code:j.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Hp(i).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Jb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Qb(i).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Hb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"duration",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?qb(t.data,i.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ip",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?ev(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"jwt",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?tv(t.data,i.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cidr",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Yb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Xb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64url",code:j.invalid_string,message:i.message}),r.dirty()):ve.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:j.invalid_string,...K.errToObj(r)})}_addCheck(t){return new Gt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...K.errToObj(t)})}url(t){return this._addCheck({kind:"url",...K.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...K.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...K.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...K.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...K.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...K.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...K.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...K.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...K.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...K.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...K.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...K.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...K.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...K.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...K.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...K.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...K.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...K.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...K.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...K.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...K.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...K.errToObj(n)})}nonempty(t){return this.min(1,K.errToObj(t))}trim(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Gt.create=e=>{var t;return new Gt({checks:[],typeName:q.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...ce(e)})};function nv(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,i=parseInt(e.toFixed(o).replace(".","")),a=parseInt(t.toFixed(o).replace(".",""));return i%a/Math.pow(10,o)}class Pn extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==B.number){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.number,received:i.parsedType}),ee}let r;const o=new ut;for(const i of this._def.checks)i.kind==="int"?ve.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),L(r,{code:j.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?nv(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_finite,message:i.message}),o.dirty()):ve.assertNever(i);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,K.toString(n))}gt(t,n){return this.setLimit("min",t,!1,K.toString(n))}lte(t,n){return this.setLimit("max",t,!0,K.toString(n))}lt(t,n){return this.setLimit("max",t,!1,K.toString(n))}setLimit(t,n,r,o){return new Pn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(o)}]})}_addCheck(t){return new Pn({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:K.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:K.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ve.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Pn.create=e=>new Pn({checks:[],typeName:q.ZodNumber,coerce:e?.coerce||!1,...ce(e)});class Mn extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==B.bigint)return this._getInvalidInput(t);let r;const o=new ut;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):ve.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return L(n,{code:j.invalid_type,expected:B.bigint,received:n.parsedType}),ee}gte(t,n){return this.setLimit("min",t,!0,K.toString(n))}gt(t,n){return this.setLimit("min",t,!1,K.toString(n))}lte(t,n){return this.setLimit("max",t,!0,K.toString(n))}lt(t,n){return this.setLimit("max",t,!1,K.toString(n))}setLimit(t,n,r,o){return new Mn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(o)}]})}_addCheck(t){return new Mn({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Mn.create=e=>{var t;return new Mn({checks:[],typeName:q.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...ce(e)})};class Co extends ue{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==B.boolean){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.boolean,received:r.parsedType}),ee}return ft(t.data)}}Co.create=e=>new Co({typeName:q.ZodBoolean,coerce:e?.coerce||!1,...ce(e)});class ar extends ue{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==B.date){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.date,received:i.parsedType}),ee}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_date}),ee}const r=new ut;let o;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):ve.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ar({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:K.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:K.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}ar.create=e=>new ar({checks:[],coerce:e?.coerce||!1,typeName:q.ZodDate,...ce(e)});class Ji extends ue{_parse(t){if(this._getType(t)!==B.symbol){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.symbol,received:r.parsedType}),ee}return ft(t.data)}}Ji.create=e=>new Ji({typeName:q.ZodSymbol,...ce(e)});class Oo extends ue{_parse(t){if(this._getType(t)!==B.undefined){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.undefined,received:r.parsedType}),ee}return ft(t.data)}}Oo.create=e=>new Oo({typeName:q.ZodUndefined,...ce(e)});class Po extends ue{_parse(t){if(this._getType(t)!==B.null){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.null,received:r.parsedType}),ee}return ft(t.data)}}Po.create=e=>new Po({typeName:q.ZodNull,...ce(e)});class Hr extends ue{constructor(){super(...arguments),this._any=!0}_parse(t){return ft(t.data)}}Hr.create=e=>new Hr({typeName:q.ZodAny,...ce(e)});class Jn extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ft(t.data)}}Jn.create=e=>new Jn({typeName:q.ZodUnknown,...ce(e)});class gn extends ue{_parse(t){const n=this._getOrReturnCtx(t);return L(n,{code:j.invalid_type,expected:B.never,received:n.parsedType}),ee}}gn.create=e=>new gn({typeName:q.ZodNever,...ce(e)});class Qi extends ue{_parse(t){if(this._getType(t)!==B.undefined){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.void,received:r.parsedType}),ee}return ft(t.data)}}Qi.create=e=>new Qi({typeName:q.ZodVoid,...ce(e)});class zt extends ue{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==B.array)return L(n,{code:j.invalid_type,expected:B.array,received:n.parsedType}),ee;if(o.exactLength!==null){const a=n.data.length>o.exactLength.value,c=n.data.length<o.exactLength.value;(a||c)&&(L(n,{code:a?j.too_big:j.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(L(n,{code:j.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(L(n,{code:j.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>o.type._parseAsync(new rn(n,a,n.path,c)))).then(a=>ut.mergeArray(r,a));const i=[...n.data].map((a,c)=>o.type._parseSync(new rn(n,a,n.path,c)));return ut.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new zt({...this._def,minLength:{value:t,message:K.toString(n)}})}max(t,n){return new zt({...this._def,maxLength:{value:t,message:K.toString(n)}})}length(t,n){return new zt({...this._def,exactLength:{value:t,message:K.toString(n)}})}nonempty(t){return this.min(1,t)}}zt.create=(e,t)=>new zt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...ce(t)});function wr(e){if(e instanceof He){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=tn.create(wr(r))}return new He({...e._def,shape:()=>t})}else return e instanceof zt?new zt({...e._def,type:wr(e.element)}):e instanceof tn?tn.create(wr(e.unwrap())):e instanceof $n?$n.create(wr(e.unwrap())):e instanceof on?on.create(e.items.map(t=>wr(t))):e}class He extends ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ve.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==B.object){const d=this._getOrReturnCtx(t);return L(d,{code:j.invalid_type,expected:B.object,received:d.parsedType}),ee}const{status:r,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof gn&&this._def.unknownKeys==="strip"))for(const d in o.data)a.includes(d)||c.push(d);const l=[];for(const d of a){const u=i[d],f=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new rn(o,f,o.path,d)),alwaysSet:d in o.data})}if(this._def.catchall instanceof gn){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of c)l.push({key:{status:"valid",value:u},value:{status:"valid",value:o.data[u]}});else if(d==="strict")c.length>0&&(L(o,{code:j.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of c){const f=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new rn(o,f,o.path,u)),alwaysSet:u in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of l){const f=await u.key,h=await u.value;d.push({key:f,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>ut.mergeObjectSync(r,d)):ut.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return K.errToObj,new He({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var o,i,a,c;const l=(a=(i=(o=this._def).errorMap)===null||i===void 0?void 0:i.call(o,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(c=K.errToObj(t).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new He({...this._def,unknownKeys:"strip"})}passthrough(){return new He({...this._def,unknownKeys:"passthrough"})}extend(t){return new He({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new He({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:q.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new He({...this._def,catchall:t})}pick(t){const n={};return ve.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new He({...this._def,shape:()=>n})}omit(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new He({...this._def,shape:()=>n})}deepPartial(){return wr(this)}partial(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{const o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}),new He({...this._def,shape:()=>n})}required(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof tn;)i=i._def.innerType;n[r]=i}}),new He({...this._def,shape:()=>n})}keyof(){return Wp(ve.objectKeys(this.shape))}}He.create=(e,t)=>new He({shape:()=>e,unknownKeys:"strip",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});He.strictCreate=(e,t)=>new He({shape:()=>e,unknownKeys:"strict",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});He.lazycreate=(e,t)=>new He({shape:e,unknownKeys:"strip",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});class Mo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function o(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;const a=i.map(c=>new kt(c.ctx.common.issues));return L(n,{code:j.invalid_union,unionErrors:a}),ee}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(o);{let i;const a=[];for(const l of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(l=>new kt(l));return L(n,{code:j.invalid_union,unionErrors:c}),ee}}get options(){return this._def.options}}Mo.create=(e,t)=>new Mo({options:e,typeName:q.ZodUnion,...ce(t)});const cn=e=>e instanceof Do?cn(e.schema):e instanceof Vt?cn(e.innerType()):e instanceof No?[e.value]:e instanceof jn?e.options:e instanceof Lo?ve.objectValues(e.enum):e instanceof Fo?cn(e._def.innerType):e instanceof Oo?[void 0]:e instanceof Po?[null]:e instanceof tn?[void 0,...cn(e.unwrap())]:e instanceof $n?[null,...cn(e.unwrap())]:e instanceof ol||e instanceof Bo?cn(e.unwrap()):e instanceof Uo?cn(e._def.innerType):[];class ws extends ue{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.object)return L(n,{code:j.invalid_type,expected:B.object,received:n.parsedType}),ee;const r=this.discriminator,o=n.data[r],i=this.optionsMap.get(o);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(L(n,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const o=new Map;for(const i of n){const a=cn(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of a){if(o.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);o.set(c,i)}}return new ws({typeName:q.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:o,...ce(r)})}}function Ya(e,t){const n=un(e),r=un(t);if(e===t)return{valid:!0,data:e};if(n===B.object&&r===B.object){const o=ve.objectKeys(t),i=ve.objectKeys(e).filter(c=>o.indexOf(c)!==-1),a={...e,...t};for(const c of i){const l=Ya(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===B.array&&r===B.array){if(e.length!==t.length)return{valid:!1};const o=[];for(let i=0;i<e.length;i++){const a=e[i],c=t[i],l=Ya(a,c);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===B.date&&r===B.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class jo extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=(i,a)=>{if(Va(i)||Va(a))return ee;const c=Ya(i.value,a.value);return c.valid?((Za(i)||Za(a))&&n.dirty(),{status:n.value,value:c.data}):(L(r,{code:j.invalid_intersection_types}),ee)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}jo.create=(e,t,n)=>new jo({left:e,right:t,typeName:q.ZodIntersection,...ce(n)});class on extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.array)return L(r,{code:j.invalid_type,expected:B.array,received:r.parsedType}),ee;if(r.data.length<this._def.items.length)return L(r,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&r.data.length>this._def.items.length&&(L(r,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new rn(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>ut.mergeArray(n,a)):ut.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new on({...this._def,rest:t})}}on.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new on({items:e,typeName:q.ZodTuple,rest:null,...ce(t)})};class $o extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.object)return L(r,{code:j.invalid_type,expected:B.object,received:r.parsedType}),ee;const o=[],i=this._def.keyType,a=this._def.valueType;for(const c in r.data)o.push({key:i._parse(new rn(r,c,r.path,c)),value:a._parse(new rn(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?ut.mergeObjectAsync(n,o):ut.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ue?new $o({keyType:t,valueType:n,typeName:q.ZodRecord,...ce(r)}):new $o({keyType:Gt.create(),valueType:t,typeName:q.ZodRecord,...ce(n)})}}class qi extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.map)return L(r,{code:j.invalid_type,expected:B.map,received:r.parsedType}),ee;const o=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],d)=>({key:o._parse(new rn(r,c,r.path,[d,"key"])),value:i._parse(new rn(r,l,r.path,[d,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of a){const d=await l.key,u=await l.value;if(d.status==="aborted"||u.status==="aborted")return ee;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}})}else{const c=new Map;for(const l of a){const d=l.key,u=l.value;if(d.status==="aborted"||u.status==="aborted")return ee;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}}}}qi.create=(e,t,n)=>new qi({valueType:t,keyType:e,typeName:q.ZodMap,...ce(n)});class cr extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.set)return L(r,{code:j.invalid_type,expected:B.set,received:r.parsedType}),ee;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(L(r,{code:j.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(L(r,{code:j.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const d=new Set;for(const u of l){if(u.status==="aborted")return ee;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const c=[...r.data.values()].map((l,d)=>i._parse(new rn(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,n){return new cr({...this._def,minSize:{value:t,message:K.toString(n)}})}max(t,n){return new cr({...this._def,maxSize:{value:t,message:K.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}cr.create=(e,t)=>new cr({valueType:e,minSize:null,maxSize:null,typeName:q.ZodSet,...ce(t)});class Mr extends ue{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.function)return L(n,{code:j.invalid_type,expected:B.function,received:n.parsedType}),ee;function r(c,l){return Yi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Zi(),Br].filter(d=>!!d),issueData:{code:j.invalid_arguments,argumentsError:l}})}function o(c,l){return Yi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Zi(),Br].filter(d=>!!d),issueData:{code:j.invalid_return_type,returnTypeError:l}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Wr){const c=this;return ft(async function(...l){const d=new kt([]),u=await c._def.args.parseAsync(l,i).catch(_=>{throw d.addIssue(r(l,_)),d}),f=await Reflect.apply(a,this,u);return await c._def.returns._def.type.parseAsync(f,i).catch(_=>{throw d.addIssue(o(f,_)),d})})}else{const c=this;return ft(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new kt([r(l,d.error)]);const u=Reflect.apply(a,this,d.data),f=c._def.returns.safeParse(u,i);if(!f.success)throw new kt([o(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Mr({...this._def,args:on.create(t).rest(Jn.create())})}returns(t){return new Mr({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Mr({args:t||on.create([]).rest(Jn.create()),returns:n||Jn.create(),typeName:q.ZodFunction,...ce(r)})}}class Do extends ue{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Do.create=(e,t)=>new Do({getter:e,typeName:q.ZodLazy,...ce(t)});class No extends ue{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return L(n,{received:n.data,code:j.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:t.data}}get value(){return this._def.value}}No.create=(e,t)=>new No({value:e,typeName:q.ZodLiteral,...ce(t)});function Wp(e,t){return new jn({values:e,typeName:q.ZodEnum,...ce(t)})}class jn extends ue{constructor(){super(...arguments),ho.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return L(n,{expected:ve.joinValues(r),received:n.parsedType,code:j.invalid_type}),ee}if(Xi(this,ho)||Fp(this,ho,new Set(this._def.values)),!Xi(this,ho).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return L(n,{received:n.data,code:j.invalid_enum_value,options:r}),ee}return ft(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return jn.create(t,{...this._def,...n})}exclude(t,n=this._def){return jn.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}ho=new WeakMap;jn.create=Wp;class Lo extends ue{constructor(){super(...arguments),mo.set(this,void 0)}_parse(t){const n=ve.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==B.string&&r.parsedType!==B.number){const o=ve.objectValues(n);return L(r,{expected:ve.joinValues(o),received:r.parsedType,code:j.invalid_type}),ee}if(Xi(this,mo)||Fp(this,mo,new Set(ve.getValidEnumValues(this._def.values))),!Xi(this,mo).has(t.data)){const o=ve.objectValues(n);return L(r,{received:r.data,code:j.invalid_enum_value,options:o}),ee}return ft(t.data)}get enum(){return this._def.values}}mo=new WeakMap;Lo.create=(e,t)=>new Lo({values:e,typeName:q.ZodNativeEnum,...ce(t)});class Wr extends ue{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.promise&&n.common.async===!1)return L(n,{code:j.invalid_type,expected:B.promise,received:n.parsedType}),ee;const r=n.parsedType===B.promise?n.data:Promise.resolve(n.data);return ft(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Wr.create=(e,t)=>new Wr({type:e,typeName:q.ZodPromise,...ce(t)});class Vt extends ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{L(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){const a=o.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return ee;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?ee:l.status==="dirty"||n.value==="dirty"?Rr(l.value):l});{if(n.value==="aborted")return ee;const c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?ee:c.status==="dirty"||n.value==="dirty"?Rr(c.value):c}}if(o.type==="refinement"){const a=c=>{const l=o.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?ee:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?ee:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(o.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!sr(a))return a;const c=o.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>sr(a)?Promise.resolve(o.transform(a.value,i)).then(c=>({status:n.value,value:c})):a);ve.assertNever(o)}}Vt.create=(e,t,n)=>new Vt({schema:e,typeName:q.ZodEffects,effect:t,...ce(n)});Vt.createWithPreprocess=(e,t,n)=>new Vt({schema:t,effect:{type:"preprocess",transform:e},typeName:q.ZodEffects,...ce(n)});class tn extends ue{_parse(t){return this._getType(t)===B.undefined?ft(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tn.create=(e,t)=>new tn({innerType:e,typeName:q.ZodOptional,...ce(t)});class $n extends ue{_parse(t){return this._getType(t)===B.null?ft(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}$n.create=(e,t)=>new $n({innerType:e,typeName:q.ZodNullable,...ce(t)});class Fo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===B.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Fo.create=(e,t)=>new Fo({innerType:e,typeName:q.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ce(t)});class Uo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return To(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kt(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new kt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Uo.create=(e,t)=>new Uo({innerType:e,typeName:q.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ce(t)});class es extends ue{_parse(t){if(this._getType(t)!==B.nan){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.nan,received:r.parsedType}),ee}return{status:"valid",value:t.data}}}es.create=e=>new es({typeName:q.ZodNaN,...ce(e)});const rv=Symbol("zod_brand");class ol extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class ri extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ee:i.status==="dirty"?(n.dirty(),Rr(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?ee:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new ri({in:t,out:n,typeName:q.ZodPipeline})}}class Bo extends ue{_parse(t){const n=this._def.innerType._parse(t),r=o=>(sr(o)&&(o.value=Object.freeze(o.value)),o);return To(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}}Bo.create=(e,t)=>new Bo({innerType:e,typeName:q.ZodReadonly,...ce(t)});function Ud(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Gp(e,t={},n){return e?Hr.create().superRefine((r,o)=>{var i,a;const c=e(r);if(c instanceof Promise)return c.then(l=>{var d,u;if(!l){const f=Ud(t,r),h=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;o.addIssue({code:"custom",...f,fatal:h})}});if(!c){const l=Ud(t,r),d=(a=(i=l.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;o.addIssue({code:"custom",...l,fatal:d})}}):Hr.create()}const ov={object:He.lazycreate};var q;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(q||(q={}));const iv=(e,t={message:`Input not instance of ${e.name}`})=>Gp(n=>n instanceof e,t),zp=Gt.create,Kp=Pn.create,sv=es.create,av=Mn.create,Vp=Co.create,cv=ar.create,lv=Ji.create,dv=Oo.create,uv=Po.create,fv=Hr.create,pv=Jn.create,hv=gn.create,mv=Qi.create,gv=zt.create,_v=He.create,bv=He.strictCreate,vv=Mo.create,yv=ws.create,wv=jo.create,kv=on.create,Sv=$o.create,Ev=qi.create,Iv=cr.create,Av=Mr.create,Rv=Do.create,xv=No.create,Tv=jn.create,Cv=Lo.create,Ov=Wr.create,Bd=Vt.create,Pv=tn.create,Mv=$n.create,jv=Vt.createWithPreprocess,$v=ri.create,Dv=()=>zp().optional(),Nv=()=>Kp().optional(),Lv=()=>Vp().optional(),Fv={string:e=>Gt.create({...e,coerce:!0}),number:e=>Pn.create({...e,coerce:!0}),boolean:e=>Co.create({...e,coerce:!0}),bigint:e=>Mn.create({...e,coerce:!0}),date:e=>ar.create({...e,coerce:!0})},Uv=ee;var s=Object.freeze({__proto__:null,defaultErrorMap:Br,setErrorMap:jb,getErrorMap:Zi,makeIssue:Yi,EMPTY_PATH:$b,addIssueToContext:L,ParseStatus:ut,INVALID:ee,DIRTY:Rr,OK:ft,isAborted:Va,isDirty:Za,isValid:sr,isAsync:To,get util(){return ve},get objectUtil(){return Ka},ZodParsedType:B,getParsedType:un,ZodType:ue,datetimeRegex:Hp,ZodString:Gt,ZodNumber:Pn,ZodBigInt:Mn,ZodBoolean:Co,ZodDate:ar,ZodSymbol:Ji,ZodUndefined:Oo,ZodNull:Po,ZodAny:Hr,ZodUnknown:Jn,ZodNever:gn,ZodVoid:Qi,ZodArray:zt,ZodObject:He,ZodUnion:Mo,ZodDiscriminatedUnion:ws,ZodIntersection:jo,ZodTuple:on,ZodRecord:$o,ZodMap:qi,ZodSet:cr,ZodFunction:Mr,ZodLazy:Do,ZodLiteral:No,ZodEnum:jn,ZodNativeEnum:Lo,ZodPromise:Wr,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:tn,ZodNullable:$n,ZodDefault:Fo,ZodCatch:Uo,ZodNaN:es,BRAND:rv,ZodBranded:ol,ZodPipeline:ri,ZodReadonly:Bo,custom:Gp,Schema:ue,ZodSchema:ue,late:ov,get ZodFirstPartyTypeKind(){return q},coerce:Fv,any:fv,array:gv,bigint:av,boolean:Vp,date:cv,discriminatedUnion:yv,effect:Bd,enum:Tv,function:Av,instanceof:iv,intersection:wv,lazy:Rv,literal:xv,map:Ev,nan:sv,nativeEnum:Cv,never:hv,null:uv,nullable:Mv,number:Kp,object:_v,oboolean:Lv,onumber:Nv,optional:Pv,ostring:Dv,pipeline:$v,preprocess:jv,promise:Ov,record:Sv,set:Iv,strictObject:bv,string:zp,symbol:lv,transformer:Bd,tuple:kv,undefined:dv,union:vv,unknown:pv,void:mv,NEVER:Uv,ZodIssueCode:j,quotelessJson:Mb,ZodError:kt});const Hd=s.enum(["app_start","sign_in","window_focus","surface_open"]),Zp=s.object({id:s.string().min(1),state:s.enum(["active","paused","disabled"])}).passthrough(),Bv=s.object({tenant_id:s.string().min(1),tenant_name:s.string().optional(),eligible:s.boolean(),endpoint:Zp.nullable()}).passthrough(),Hv=s.object({code:s.string(),message:s.string(),details:s.record(s.unknown()).optional(),retry_after_seconds:s.number().optional()}).passthrough(),Wv=s.object({code:s.string().min(1),count:s.number().int().nonnegative(),session:s.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),Gv=s.object({in_force:s.boolean(),notice_pending:s.boolean().catch(!1)}).passthrough().optional().catch(void 0),SM=s.object({capability:s.number(),consent_account_guard:s.boolean().optional(),state:s.enum(["ready","signed_out","unavailable","update_required"]),account_id:s.string().nullable(),tenant_id:s.string().nullable(),surface_state:s.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:s.object({settings:s.boolean(),inbox:s.boolean(),account_door:s.boolean(),onboarding:s.boolean()}),update_required:s.boolean(),local:s.object({enabled:s.boolean(),onboarding:s.string(),session:s.string()}),status:s.object({tenants:s.array(Bv)}).passthrough().nullable(),consent:s.object({version:s.string().min(1).max(128),text:s.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:s.enum(["served","cached","embedded"])}).nullable(),error:Hv.nullable(),state_note:s.string().nullable().optional(),read_only:s.boolean().optional(),trial_ended:s.object({tenant_id:s.string().min(1),trial_ended_at:s.string().min(1)}).passthrough().nullable().optional().catch(null),delivery_hold:Wv,default_on:Gv}).passthrough(),zv=s.object({version:s.string().min(1),consented_at:s.string().min(1),consented_via:s.string().min(1),current:s.boolean()}).passthrough(),EM=s.object({endpoint:Zp.extend({tenant_id:s.string().min(1),label:s.string().optional(),consent:zv.nullable().optional(),created_at:s.string().optional(),updated_at:s.string().optional()}).nullable(),settings:s.object({tenant_id:s.string().min(1),eligible:s.boolean(),consent_version:s.string().optional(),consent_required:s.boolean()}).passthrough(),default_on:s.boolean().optional().catch(void 0),share_typing:s.boolean().optional().catch(void 0)}).passthrough(),Kv=s.object({kind:s.enum(["endpoint","account"]).optional(),endpoint_id:s.string().min(1).optional(),account_id:s.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),Wd=s.object({direction:s.enum(["send","receive"]),effect:s.enum(["allow","deny"]),target:Kv,id:s.string().optional()}).passthrough(),Gd=s.object({mode:s.enum(["class_default","listed_only"]),allow:s.number(),deny:s.number()}).passthrough(),IM=s.object({allowlist:s.object({tenant_id:s.string().min(1),entries:s.array(Wd)}).passthrough(),view:s.object({tenant_id:s.string().nullable(),entries:s.array(Wd),directions:s.object({send:Gd,receive:Gd}),class_default:s.literal("cos_cos"),cues:s.object({allow_entry_switches_direction_to_listed_only:s.boolean(),listed_only_affects:s.string(),removing_allow_does_not_stop_open_thread:s.boolean(),deny_stops_pair_both_directions:s.boolean()}).passthrough()}).passthrough()}).passthrough(),AM=s.object({onboarding:s.literal("seen")}).passthrough();function Vv(e){return e?.default_on?.in_force===!0}function RM(e,t){const n=Zv(e),r=t?.endpoint?.consent?.version;return n&&r&&n.version===r?n.text:null}function xM(e,t){return e?.surface_state==="C"&&t?.default_on===!0&&t.endpoint?.state==="active"&&e.default_on?.notice_pending===!0}function TM(e,t){if(!e||!t||Vv(e)||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function Zv(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const Yv=8,Xa=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh","notifications"],Ho=200,Xv=6*1024,Jv=512;function ts(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const o=[];for(const i of n){if(o.length===Jv)break;const c=new URLSearchParams({order_ids:i}).toString().length+1;if(r+c>Xv)break;e.append("order_ids",i),o.push(i),r+=c}return o}function Qv(e,t,n){return ts(new URLSearchParams(n),t,e)}const CM=3,qv=4096,OM=128,PM=/^[0-9a-f]{32}$/,ey=/^\.+$/,ty=new RegExp("\\p{Cf}","u"),ny=/[/\\:]/,I=s.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),zd=s.string().min(1).max(256).regex(/^[a-zA-Z0-9_-]+(?::[a-zA-Z0-9_-]+)?$/),ry=s.string().min(1).max(128),hi=s.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),mi=s.string().min(1).max(32768),Yp=/^[a-f0-9]{12}$/,F=s.string().regex(Yp),oy=["network-credentials"],iy=e=>Yp.test(e)||oy.includes(e),Ja=s.string().refine(iy,"not a notifications session id"),Xs=s.string().regex(/^[a-f0-9]{12}$/),Js=s.string().min(1).max(128),sy=s.string().min(1).max(4096),eo=s.string().min(1).max(128).regex(/^[A-Za-z0-9_.-]+$/),Qs=s.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),gi=s.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),Kd=s.string().regex(/^[a-f0-9]{32}$/),ay=/^(\/|[A-Za-z]:[\\/])/,qs=s.string().min(1).max(4096).regex(ay),Vd=/^[a-f0-9]{32}$/,de=s.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Zd=s.string().min(1).max(512).nullish(),gr=s.string().regex(/^[A-Za-z0-9_-]{1,128}$/),_r=s.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),cy=/^pp_[0-9a-f]{16}$/,ea=s.string().regex(cy),ly=["credential_finite_share","credential_inheritance"],xr=/^sha256:[0-9a-f]{64}$/,Yd={operation:s.enum(ly),requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr)},to=s.string().regex(/^la_[0-9a-f]{16}$/),no=s.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),Xd=s.object({data_b64:s.string().min(1).max(1e6),mime_type:s.enum(["image/png","image/jpeg","image/gif","image/webp"]),origin_path:s.string().max(4096).optional()}).strict(),dy=s.object({digest:s.string().regex(/^[0-9a-f]{32}$/),name:s.string().max(1024).optional(),mime_type:s.string().max(255).optional(),bytes:s.number().int().min(0).optional(),path:s.string().max(4096).optional()}).strict(),Jd=2e5,Qd=8,uy=256,fy=100,qd=16,py=256,hy=100,my=200,gy=1e6,_y=s.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),rt=s.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),_i=s.object({kind:s.enum(["agent","team"]),name:rt}).strict(),Xp=s.enum(["claude","codex","omp"]),by=s.record(s.string(),s.array(s.string().min(1).max(512)).max(5e3)),eu={sources:s.array(Xp).max(3).optional(),sessionIds:by.optional(),all:s.boolean().optional(),includeSubagents:s.boolean().optional(),includeClearedSegments:s.boolean().optional(),includeMemory:s.boolean().optional(),includeInstructions:s.boolean().optional(),maxSessions:s.number().int().min(1).max(5e3).optional()},ta=s.object({provider:s.string().min(1).max(128),model_id:s.string().min(1).max(512),reasoning_effort:s.string().min(1).max(64).nullable(),fast_mode:s.boolean().nullable().optional()}).strict(),tu=s.object({kind:s.enum(["role","specialist"]).optional(),description:s.string().max(8e3).optional(),instructions:s.string().max(8e3).optional(),tools:s.array(s.string().min(1).max(128)).max(256).optional(),effort:s.string().max(64).optional(),delegate:s.boolean().optional(),action_class:s.enum(["reactive","proactive"]).optional()}).strict(),nu=s.object({name:s.string().min(1).max(64).optional(),description:s.string().max(8e3).optional(),manager:rt.optional(),members:s.array(s.object({role:rt,count:s.number().int().min(1).max(16),kind:s.enum(["agent","team"]),tier:s.enum(["lo","med","hi"]).nullable().optional(),effort:_y.nullable().optional()}).strict()).max(128).optional(),instructions:s.string().max(8e3).optional(),project:s.string().max(8e3).optional()}).strict(),vy=s.record(s.array(s.string().max(1024)).max(100)),na=s.array(I).max(4).refine(e=>new Set(e).size===e.length,"Duplicate attachment"),yy=s.array(s.object({kind:s.enum(["human","agent"]),account_id:I,endpoint_id:I.optional()}).strict()).max(50).refine(e=>new Set(e.map(t=>`${t.kind}:${t.account_id}:${t.endpoint_id??""}`)).size===e.length,"Duplicate mention"),ru=s.enum(["minutes","hours","days"]);function wy(e){return!ey.test(e)}const MM=e=>Li.safeParse(e).success,Li=s.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(wy),ou=s.enum(["str","int","float","bool","list","dict"]),iu=s.string().max(16384),ky=2e3,su=s.string().min(1).max(ky),au=s.string().min(1).max(64),Sy=s.string().min(1).max(64),Ey=s.string().min(1).max(64),cu=s.object({is_active:s.boolean().nullish(),one_time:s.boolean().nullish(),start_time_utc:s.string().max(64).nullish(),end_time_utc:s.string().max(64).nullish()}).strict(),Iy=s.object({conversation_length:s.number().int().optional(),detail_length:s.number().int().optional(),max_learnings_history:s.number().int().optional(),hosting:s.string().max(256).optional(),model_name:s.string().max(1024).optional(),auto_save_conversation:s.boolean().optional()}).strict(),Qa=128,lu=2e3,du=8e3,uu=64,fu=64,ks=e=>[...e].length,qa=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,Ay=e=>e===9||e===10||e===11||e===12||e===13||e===133,Ry=e=>e<=31||e>=127&&e<=159,xy=e=>ty.test(String.fromCodePoint(e)),Ty=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,bi=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Jp=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&qa(t[n].codePointAt(0)??0);)n++;for(;r>n&&qa(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},Cy=e=>{let t="",n=!1;for(const r of e){if(qa(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function Oy(e){const t=Jp(e);if(!t)return"must not be empty";if(ks(t)>Qa)return`must be at most ${Qa} characters`;if(ny.test(t))return'must not contain "/", "\\" or ":"';if(bi(t,Ty))return"must not contain Unicode bidirectional override characters";if(bi(t,Ay))return"must not contain whitespace";if(bi(t,Ry))return"must not contain control characters";if(bi(t,xy))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function jM(e){return Cy(Jp(e).normalize("NFKC").toLowerCase())}function Py(e){return e.trim()?ks(e)>lu?`must be at most ${lu} characters`:null:"must not be empty"}function My(e){return e.trim()?ks(e)>du?`must be at most ${du} characters`:null:"must not be empty"}function jy(e){if(e.length>fu)return`must hold at most ${fu} items`;for(const t of e)if(!t.trim()||ks(t)>uu)return`must hold items of 1 to ${uu} characters`;return null}const $y=e=>Oy(e)===null,Dy=s.string().refine($y,{message:"That is not a name the hub can publish."}),Ny=s.string().refine(e=>My(e)===null,{message:"That instruction body cannot be published."}),Ly=s.string().refine(e=>Py(e)===null,{message:"That description cannot be published."}),Fy=s.array(s.string()).refine(e=>jy(e)===null,{message:"That tool list cannot be published."}),ra={requestId:de.optional(),subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional()},pu=s.object({name:Dy,description:Ly,instructions:Ny,kind:s.enum(["role","specialist"]),when_to_use:s.string(),tools:Fy,effort:s.string(),delegate:s.boolean(),version:s.string(),categories:s.array(s.string()),tags:s.array(s.string())}).partial().strict(),Uy=s.enum(["team","agent"]),By=s.string().min(1).max(64),Hy=s.string().min(1).max(256),Qp=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,oa=s.string().regex(Qp,{message:"Letters, digits, dot, underscore and dash; no spaces."}),Wy=["planning","active","qa","validation","done","paused","archived"],hu=s.enum(Wy),vi=s.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),mu=s.array(s.string().min(1).max(24)).max(8),Sn=s.string().min(1).max(64),Gy=1e3,gu=240,_u=80,zy=256,Ky=100,Vy=200,Zy=/^[a-z0-9][a-z0-9_-]{0,23}$/;function $M(e){return e?Qp.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function DM(e){return Zy.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const yi=s.enum(["agent","team","skill"]),ia=s.string().min(1).max(128).regex(/\S/),bu=s.enum(Xa),Yy=s.object({visible:s.array(bu).max(Xa.length),more:s.array(bu).max(Xa.length)}).strict(),fn=s.string().min(3).max(256).regex(/^(?:n_[a-z2-7]{4,32}|ask:[A-Za-z0-9_-]+:[A-Za-z0-9_-]+)$/),vu=s.object({selectionToken:s.string().min(1).max(512),reconcileIds:s.array(fn).max(500).optional(),excludedIds:s.array(fn).max(500).optional()}).strict(),Xy=s.object({operationToken:s.string().min(1).max(512),reconcileIds:s.array(fn).max(500).optional()}).strict(),yu=s.union([s.object({throughSeq:s.number().int().min(0).optional(),receipt:s.literal(!0).optional(),reconcileIds:s.array(fn).max(500).optional(),items:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).min(1).max(500)}).strict(),s.object({sessionId:Ja,throughSeq:s.number().int().min(0),observed:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).max(500)}).strict(),s.object({all:s.literal(!0),throughSeq:s.number().int().min(0),observed:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).max(500)}).strict()]),Jy={pointer:"pointerdown",key:"keydown",wheel:"wheel"},Qy=s.discriminatedUnion("op",[s.object({op:s.literal("capabilities")}).strict(),s.object({op:s.literal("runtimes.list")}).strict(),s.object({op:s.literal("profiles.list")}).strict(),s.object({op:s.literal("profiles.get"),name:rt}).strict(),s.object({op:s.literal("imports.sources")}).strict(),s.object({op:s.literal("imports.sessions"),source:Xp,includeSubagents:s.boolean().optional()}).strict(),s.object({op:s.literal("imports.preview"),...eu}).strict(),s.object({op:s.literal("imports.start"),...eu}).strict(),s.object({op:s.literal("imports.status"),jobId:s.string().min(1).max(128)}).strict(),s.object({op:s.literal("imports.cancel"),jobId:s.string().min(1).max(128)}).strict(),s.object({op:s.literal("profiles.update"),name:rt,requestId:de,fields:tu,expectedDefinitionRevision:Zd.optional()}).strict(),s.object({op:s.literal("profiles.install"),name:rt,requestId:de}).strict(),s.object({op:s.literal("profiles.create"),name:rt,requestId:de,fields:tu.extend({description:s.string().max(8e3),instructions:s.string().min(1).max(8e3)})}).strict(),s.object({op:s.literal("hub.updates")}).strict(),s.object({op:s.literal("hub.skillPull"),requestId:de,hubId:I,hubSource:s.string().min(1).max(2048),visibility:s.enum(["public","org"]),tenantId:I.nullable(),localAlias:rt,subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional(),dryRun:s.boolean().optional(),adoptionStrategy:s.enum(["merge","keep-local","take-hub"]).optional(),allowLlm:s.boolean().optional(),confirm:s.boolean().optional(),adoptionReceipt:s.string().min(16).max(128).optional()}).strict(),s.object({op:s.literal("hub.skillSubscribe"),requestId:de,hubId:I,hubSource:s.string().min(1).max(2048),visibility:s.enum(["public","org"]),tenantId:I.nullable(),localAlias:rt}).strict(),s.object({op:s.literal("hub.skillUnpull"),requestId:de,linkId:s.string().min(1).max(256)}).strict(),s.object({op:s.literal("hub.skillPublish"),requestId:de,dryRun:s.boolean(),sourceSkill:rt,localAlias:rt,visibility:s.enum(["public","org"]),tenantId:I.nullable(),subscribe:s.boolean(),autoPush:s.boolean(),confirmPublicEgress:s.boolean(),previewReceipt:s.string().min(1).max(4096).optional(),confirmPublish:s.literal(!0).optional()}).strict(),s.object({op:s.literal("hub.links"),kind:s.enum(["agent","team","skill"]).optional()}).strict(),s.object({op:s.literal("hub.policy"),requestId:de,linkId:s.string().min(1).max(256),expectedPolicyRevision:s.string().min(1).max(256),subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional()}).strict(),s.object({op:s.literal("hub.check"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional()}).strict(),s.object({op:s.literal("hub.apply"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional(),prefer:s.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:s.boolean().optional(),dryRun:s.boolean().optional(),resolveSource:s.literal(!0).optional(),hubSource:s.string().min(1).max(2048).optional(),visibility:s.enum(["public","org"]).optional(),tenantId:s.string().min(1).max(128).nullable().optional()}).strict(),s.object({op:s.literal("hub.applyAll"),requestId:de,kind:yi.optional()}).strict(),s.object({op:s.literal("hub.retry"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional()}).strict(),s.object({op:s.literal("hub.push"),requestId:de,linkId:s.string().min(1).max(256),direction:s.literal("push"),dryRun:s.boolean(),previewReceipt:s.string().min(1).max(4096).optional(),confirmPublish:s.literal(!0).optional()}).strict(),s.object({op:s.literal("teams.list")}).strict(),s.object({op:s.literal("teams.get"),name:rt}).strict(),s.object({op:s.literal("teams.effective"),name:rt}).strict(),s.object({op:s.literal("teams.update"),name:rt,requestId:de,fields:nu,expectedDefinitionRevision:Zd.optional()}).strict(),s.object({op:s.literal("teams.create"),requestId:de,fields:nu.extend({name:s.string().min(1).max(64)})}).strict(),s.object({op:s.literal("sessions.list"),limit:s.number().int().min(1).max(500).optional(),include_archived:s.boolean().optional(),include_temporary:s.boolean().optional(),include_peers:s.boolean().optional(),scope_kind:Uy.optional(),scope_name:By.optional(),cursor:Hy.optional(),with_counts:s.boolean().optional(),sort:s.literal("activity").optional()}).strict(),s.object({op:s.literal("delegated_cleanup_notice.ack")}).strict(),s.object({op:s.literal("sessions.search"),q:s.string().min(1).max(uy),limit:s.number().int().min(1).max(500).optional(),include_archived:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.archive"),sessionId:F,archived:s.boolean()}).strict(),s.object({op:s.literal("sessions.temporary"),sessionId:F,temporary:s.boolean()}).strict(),s.object({op:s.literal("sessions.delete"),sessionId:F,confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.create"),requestId:de,cwd:s.string().min(1).max(4096).optional(),target:_i.optional(),purpose:s.literal("agents-config").optional(),model:ta.optional(),draftId:F.optional(),peer:gr.optional(),temporary:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.preview"),requestId:de,cwd:s.string().min(1).max(4096),target:_i.optional(),model:ta.optional()}).strict(),s.object({op:s.literal("sessions.draft"),requestId:de,cwd:s.string().min(1).max(4096),target:_i.optional(),model:ta.optional()}).strict(),s.object({op:s.literal("sessions.get"),sessionId:F,journalOrder:s.boolean().optional(),orderIds:s.array(s.string().min(1).max(128)).max(512).optional(),peerJournalSource:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.files"),sessionId:F,scope:s.enum(["family","self"]).optional(),kind:s.string().max(256).optional(),q:s.string().max(256).optional(),sort:s.enum(["recent","name","kind","modified","created","size"]).optional(),order:s.enum(["asc","desc"]).optional(),limit:s.number().int().min(1).max(200).optional(),cursor:s.string().max(8192).optional()}).strict(),s.object({op:s.literal("sessions.files.materialise"),sessionId:F,fileId:s.string().regex(/^[a-f0-9]{16}$/)}).strict(),s.object({op:s.literal("sessions.files.download"),sessionId:F,fileId:s.string().regex(/^[a-f0-9]{16}$/)}).strict(),s.object({op:s.literal("sessions.userAttachments"),sessionId:F}).strict(),s.object({op:s.literal("sessions.userAttachments.materialise"),sessionId:F,digest:s.string().regex(/^[a-f0-9]{32}$/)}).strict(),s.object({op:s.literal("sessions.history"),sessionId:F,beforeId:I.optional(),limit:s.number().int().min(1).max(500).optional(),openFrame:s.boolean().optional(),journalOrder:s.boolean().optional(),orderIds:s.array(s.string().min(1).max(128)).max(512).optional(),peerJournalSource:s.boolean().optional(),sourceRead:s.enum(["metadata","payload"]).optional(),expectedJournalGeneration:s.string().min(1).max(128).optional()}).strict(),s.object({op:s.literal("sessions.checkpoints"),sessionId:F}).strict(),s.object({op:s.literal("sessions.checkpoints.warm"),sessionId:F,ids:s.array(I).max(qd).optional(),limit:s.number().int().min(1).max(qd).optional()}).strict(),s.object({op:s.literal("sessions.find"),sessionId:F,q:s.string().min(1).max(py),limit:s.number().int().min(1).max(my).optional()}).strict(),s.object({op:s.literal("subagents.transcript"),sessionId:F,childId:F,beforeId:I.optional(),entryId:s.string().min(1).max(128).regex(/^[a-zA-Z0-9_:-]+$/).optional(),limit:s.number().int().min(1).max(500).optional()}).strict(),s.object({op:s.literal("sessions.diff"),sessionId:F,callId:zd,start:s.number().int().min(0).max(1e6),offset:s.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),limit:s.number().int().min(1).max(Ho)}).strict(),s.object({op:s.literal("subagents.diff"),sessionId:F,childId:F,callId:zd,start:s.number().int().min(0).max(1e6),offset:s.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),limit:s.number().int().min(1).max(Ho)}).strict(),s.object({op:s.literal("sessions.message"),sessionId:F,requestId:de,text:s.string().max(Jd),images:s.array(Xd).max(Qd).optional(),files:s.array(dy).max(Yv).optional(),mode:s.enum(["prompt","steer"]).optional(),inputMode:s.enum(["typed","dictated","mixed"]).optional(),inputPath:s.string().max(1024).optional()}).strict(),s.object({op:s.literal("sessions.command"),sessionId:F,requestId:de,command:s.string().regex(/^\/?[A-Za-z]+$/).max(64),args:s.string().max(Jd).optional(),images:s.array(Xd).max(Qd).optional()}).strict(),s.object({op:s.literal("sessions.move"),sessionId:F,requestId:de,cwd:s.string().min(1).max(4096)}).strict(),s.object({op:s.literal("settingsIntents.list"),sessionId:F.optional()}).strict(),s.object({op:s.literal("settingsIntents.submit"),sessionId:F,requestId:de,kind:s.enum(["model","effort","fast","cwd"]),value:s.union([s.string().min(1).max(4096),s.boolean()]),effort:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("settingsIntents.dismiss"),sessionId:F,kind:s.enum(["model","effort","fast","cwd"]),generation:s.number().int().nonnegative()}).strict(),s.object({op:s.literal("sessions.profileActionStatus"),sessionId:F,actionId:s.string().regex(/^prv_[A-Za-z0-9_-]{32}$/),receiptId:s.string().min(1).max(160),profileKind:s.enum(["agent","team"]),profileName:s.string().min(1).max(128),toolCallId:s.string().min(1).max(160)}).strict(),s.object({op:s.literal("sessions.answer"),sessionId:F,epoch:I.optional(),requestId:I.optional(),value:s.string().max(32768).optional(),approved:s.boolean().optional(),questionIndex:s.number().int().min(0).optional(),askId:I.optional(),answers:s.record(s.string(),s.array(s.string().max(32768))).optional(),decline:s.boolean().optional(),revise:s.boolean().optional(),dismiss:s.boolean().optional(),reason:s.enum(["answered_in_chat","moot"]).optional()}).strict(),s.object({op:s.literal("sessions.seen"),sessionId:F,completionToken:s.string().uuid()}).strict(),s.object({op:s.literal("attention.seen"),items:s.array(s.object({sessionId:F,completionToken:s.string().uuid()}).strict()).min(1).max(500)}).strict(),s.object({op:s.literal("sessions.notified"),sessionId:F,completionToken:s.string().uuid()}).strict(),s.object({op:s.literal("tags.list")}).strict(),s.object({op:s.literal("tags.replace"),tags:s.array(s.object({id:s.string().optional(),name:s.string()}).strict())}).strict(),s.object({op:s.literal("sessions.tags"),expected_revision:s.string().optional(),sessionId:F,tags:s.array(s.string()),primary:s.string().nullable()}).strict(),s.object({op:s.literal("sessions.pin"),sessionId:F,pinned:s.boolean()}).strict(),s.object({op:s.literal("sessions.watch"),sessionId:F,subscriptionId:s.string().regex(Vd),visible:s.boolean(),canNotify:s.boolean()}).strict(),s.object({op:s.literal("sessions.warm"),sessionId:F}).strict(),s.object({op:s.literal("sessions.interrupt"),sessionId:F,requestId:de}).strict(),s.object({op:s.literal("supplements.cancel"),sessionId:F,job:Xs,anchor:Js}).strict(),s.object({op:s.literal("supplements.restart"),sessionId:F,job:Xs,anchor:Js}).strict(),s.object({op:s.literal("supplements.steer"),sessionId:F,job:Xs,anchor:Js,text:s.string().min(1).max(500)}).strict(),s.object({op:s.literal("sessions.variables.list"),sessionId:F}).strict(),s.object({op:s.literal("sessions.variables.create"),sessionId:F,key:Li,value:iu,type:ou}).strict(),s.object({op:s.literal("sessions.variables.update"),sessionId:F,key:Li,value:iu,type:ou}).strict(),s.object({op:s.literal("sessions.variables.delete"),sessionId:F,key:Li}).strict(),s.object({op:s.literal("sessions.presence"),subscriptionId:s.string().regex(/^[a-f0-9]{1,64}$/),canNotify:s.boolean(),canNotifyKinds:s.array(s.enum(["complete","error"])).max(4),sessionId:s.string().regex(/^([a-f0-9]{12})?$/),window:s.object({exists:s.boolean(),focused:s.boolean(),visible:s.boolean(),minimized:s.boolean()}).strict()}).strict(),s.object({op:s.literal("legacy.models"),provider:s.string().max(128).optional(),sort:s.enum(["id","name","provider","recommended"]).optional(),direction:s.enum(["ascending","descending"]).optional()}).strict(),s.object({op:s.literal("legacy.models.providers")}).strict(),s.object({op:s.literal("auth.probe"),provider:I}).strict(),s.object({op:s.literal("legacy.agent.upload"),agentId:I}).strict(),s.object({op:s.literal("agent.publish"),agentId:I,document:pu.optional(),...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("agent.republish"),agentId:I,hubAgentId:I,expectedRemoteRevision:s.string().min(1).max(512).optional(),document:pu.optional(),...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("team.publish"),teamId:I,...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("team.pull"),teamId:I,tenantId:I.optional()}).strict(),s.object({op:s.literal("agent.nameAvailability"),name:s.string().min(1).max(Qa)}).strict(),s.object({op:s.literal("legacy.agents.list"),page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(500).optional(),name:s.string().max(256).optional(),sort:s.string().max(64).optional(),direction:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("legacy.agent.get"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.history"),agentId:I,page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(500).optional()}).strict(),s.object({op:s.literal("legacy.jobs.list"),agentId:I.optional(),status:s.string().max(64).optional()}).strict(),s.object({op:s.literal("legacy.job.get"),jobId:I}).strict(),s.object({op:s.literal("legacy.schedules.list"),page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("legacy.agent.schedules.list"),agentId:I,page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("legacy.agent.schedule.create"),agentId:I,schedule:cu.extend({prompt:s.string().max(64e3),interval:s.number().int().min(1),unit:ru})}).strict(),s.object({op:s.literal("legacy.schedule.get"),scheduleId:I}).strict(),s.object({op:s.literal("legacy.schedule.edit"),scheduleId:I,schedule:cu.extend({prompt:s.string().max(64e3).nullish(),interval:s.number().int().min(1).nullish(),unit:ru.nullish()})}).strict(),s.object({op:s.literal("legacy.schedule.remove"),scheduleId:I}).strict(),s.object({op:s.literal("legacy.agent.create"),agent:s.record(s.unknown())}).strict(),s.object({op:s.literal("legacy.agent.update"),agentId:I,update:s.record(s.unknown())}).strict(),s.object({op:s.literal("legacy.agent.delete"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.conversation.clear"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.systemPrompt.get"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.systemPrompt.update"),agentId:I,systemPrompt:s.string().max(gy)}).strict(),s.object({op:s.literal("legacy.agent.download"),agentId:I}).strict(),s.object({op:s.literal("legacy.job.cancel"),jobId:I}).strict(),s.object({op:s.literal("commands.list")}).strict(),s.object({op:s.literal("commands.entities"),sessionId:F,command:I,name:s.string().max(128).optional()}).strict(),s.object({op:s.literal("models.catalogue"),live:s.boolean().optional(),scope:s.enum(["usable","all"]).optional()}).strict(),s.object({op:s.literal("usage.get"),provider:I.optional(),live:s.boolean().optional(),refresh:s.boolean().optional()}).strict(),s.object({op:s.literal("usage.reset"),provider:I,credentialRef:ry.optional(),identity:s.string().min(1).max(256).optional(),redeemRequestId:s.string().uuid()}).strict(),s.object({op:s.literal("quota.notice"),provider:I.optional(),model:s.string().min(1).max(200).optional(),refresh:s.boolean().optional()}).strict(),s.object({op:s.literal("analytics.get"),sessionId:F.optional(),sinceMs:s.number().int().nonnegative().optional(),untilMs:s.number().int().nonnegative().optional(),days:s.number().int().min(1).max(366).optional()}).strict(),s.object({op:s.literal("analytics.models"),sessionId:F.optional(),sinceMs:s.number().int().nonnegative().optional(),untilMs:s.number().int().nonnegative().optional(),days:s.number().int().min(1).max(366).optional()}).strict(),s.object({op:s.literal("info.get")}).strict(),s.object({op:s.literal("sessions.report"),sessionId:F,recentLimit:s.number().int().min(0).max(50).optional()}).strict(),s.object({op:s.literal("skills.list"),sessionId:F.optional(),cwd:sy.optional(),name:eo.optional()}).strict(),s.object({op:s.literal("skills.create"),requestId:de,name:eo,copyFrom:eo}).strict(),s.object({op:s.literal("skills.update"),requestId:de,name:eo,expectedFingerprint:s.string().regex(/^[a-f0-9]{64}$/),files:s.array(s.object({path:s.string().min(1).max(240),content:s.string().max(1024*1024)}).strict()).min(1).max(64)}).strict(),s.object({op:s.literal("skills.remove"),requestId:de,name:eo,discardLocalChanges:s.boolean()}).strict(),s.object({op:s.literal("sessions.failovers"),sessionId:F}).strict(),s.object({op:s.literal("sessions.credential"),sessionId:F,action:s.enum(["list","store","forget"]),key:hi.optional(),value:mi.optional(),confirmed:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.fork"),sessionId:F,requestId:de,message:s.string().max(2e5).optional(),boundary:s.enum(["next_safe","at_entry"]).optional(),entryId:s.string().max(128).optional(),autoTag:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.stop"),requestId:de,targets:s.array(F).min(1).max(100),confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.aside"),sessionId:F,requestId:de,text:s.string().min(1).max(32768),asideId:de.optional(),subscriptionId:s.string().regex(Vd).optional()}).strict(),s.object({op:s.literal("sessions.adopt"),sessionId:F,requestId:de,asideId:de,confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.aside.get"),sessionId:F,asideId:de}).strict(),s.object({op:s.literal("sessions.aside.close"),sessionId:F,asideId:de}).strict(),s.object({op:s.literal("wakes.list"),limit:s.number().int().min(1).max(500).optional(),includeDormant:s.boolean().optional()}).strict(),s.object({op:s.literal("wakes.create"),requestId:de,sessionId:F.optional(),cwd:s.string().min(1).max(4096).optional(),target:_i.optional(),message:su,in:s.string().min(1).max(64).optional(),at:s.string().min(1).max(64).optional(),every:s.string().min(1).max(64).optional(),until:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).optional(),title:s.string().min(1).max(200).optional()}).strict(),s.object({op:s.literal("wakes.edit"),sessionId:F,wakeId:au,message:su.optional(),in:s.string().min(1).max(64).optional(),at:s.string().min(1).max(64).optional(),every:s.string().min(1).max(64).optional(),until:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).optional()}).strict(),s.object({op:s.literal("wakes.remove"),sessionId:F,wakeId:au}).strict(),s.object({op:s.literal("monitors.list"),limit:s.number().int().min(1).max(500).optional(),includeDormant:s.boolean().optional()}).strict(),s.object({op:s.literal("monitors.cancel"),sessionId:F,monitorId:Sy}).strict(),s.object({op:s.literal("jobs.cancel"),sessionId:F,jobId:Ey}).strict(),s.object({op:s.literal("mcp.list"),sessionId:F}).strict(),s.object({op:s.literal("mcp.credentials.store"),sessionId:F,name:s.string().min(1).max(256),values:s.record(s.string().min(1).max(128),s.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:s.array(s.string().min(1).max(128)).max(32)}).strict(),s.object({op:s.literal("mcp.control"),sessionId:F,control:s.object({action:s.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Qs.optional(),scope:s.enum(["global","project"]).optional(),command:s.string().min(1).max(4096).optional(),args:s.array(s.string().max(8192)).max(128).optional(),env:s.record(gi).optional(),url:s.string().max(4096).optional(),headers:s.record(gi).optional(),oauth:s.boolean().optional(),confirmed:s.boolean().optional(),operation_id:Kd.optional()}).strict()}).strict(),s.object({op:s.literal("mcp.catalog"),cwd:qs.optional(),sessionId:F.optional()}).strict(),s.object({op:s.literal("mcp.catalog.control"),cwd:qs.optional(),control:s.object({action:s.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Qs.optional(),scope:s.enum(["global","project"]).optional(),command:s.string().min(1).max(4096).optional(),args:s.array(s.string().max(8192)).max(128).optional(),env:s.record(gi).optional(),url:s.string().max(4096).optional(),headers:s.record(gi).optional(),confirmed:s.boolean().optional(),operation_id:Kd.optional()}).strict()}).strict(),s.object({op:s.literal("mcp.catalog.credentials"),header:s.string().min(1).max(128).optional(),cwd:qs.optional(),name:Qs,values:s.record(s.string().min(1).max(128),s.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:s.array(s.string().min(1).max(128)).max(32)}).strict(),s.object({op:s.literal("radient.request"),control:s.object({operation:s.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend","team_trial.eligibility","team_trial.start","team_trial.status"]),request_id:de.optional(),tenant_id:I.optional(),account_id:I.optional(),agent_id:I.optional(),comment_id:I.optional(),team_id:I.optional(),skill_id:I.optional(),query:s.record(s.union([s.string().max(1024),s.number().int()])).optional(),payload:s.record(s.unknown()).optional(),confirmed:s.boolean().optional()}).strict()}).strict(),s.object({op:s.literal("providers.list")}).strict(),s.object({op:s.literal("accounts.list")}).strict(),s.object({op:s.literal("accounts.remove"),accountId:s.number().int().positive(),confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("tunnel.setup.read"),credentialId:s.number().int().positive().optional()}).strict(),s.object({op:s.literal("tunnel.setup.plan"),credentialId:s.number().int().positive().optional()}).strict(),s.object({op:s.literal("tunnel.setup.run"),credentialId:s.number().int().positive(),acceptMonthlyPrice:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("mobile.doctor")}).strict(),s.object({op:s.literal("auth.start"),provider:I}).strict(),s.object({op:s.literal("auth.status"),id:I}).strict(),s.object({op:s.literal("auth.input"),id:I,promptId:I,value:mi}).strict(),s.object({op:s.literal("auth.cancel"),id:I}).strict(),s.object({op:s.literal("auth.key"),provider:I,value:mi}).strict(),s.object({op:s.literal("auth.logout"),provider:I}).strict(),s.object({op:s.literal("agent_messages.status"),boundary:Hd}).strict(),s.object({op:s.literal("agent_messages.enable"),expected_account_id:I,tenant_id:I,state:s.literal("active"),consent_version:s.string().min(1).max(128),consented_via:s.literal("dialog")}).strict(),s.object({op:s.literal("agent_messages.settings"),tenant_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.settings.put"),expected_account_id:I,tenant_id:I.optional(),consent_version:s.string().min(1).max(128).optional(),consented_via:s.enum(["dialog","settings"]).optional(),label:s.string().min(1).max(128).optional(),state:s.enum(["active","paused","disabled"])}).strict(),s.object({op:s.literal("agent_messages.onboarding.dismiss")}).strict(),s.object({op:s.literal("agent_messages.allowlist.get"),tenant_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.allowlist.put"),expected_account_id:I,tenant_id:I.optional(),entries:s.array(s.object({direction:s.enum(["send","receive"]),effect:s.enum(["allow","deny"]),target:s.object({endpoint_id:I.optional(),account_id:I.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),s.object({op:s.literal("team_bridge.conversations.list"),scope:s.literal("account").optional(),tenant_id:I.optional(),limit:s.number().int().min(1).max(100).optional(),cursor:s.string().min(1).max(512).optional(),before:s.string().min(1).max(64).optional(),status:s.enum(["open","archived"]).optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.get"),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.create"),expected_account_id:I.optional(),tenant_id:I.optional(),kind:s.enum(["dm","group","channel"]),name:s.string().min(1).max(128).optional(),topic:s.string().min(1).max(512).optional(),visibility:s.enum(["private","tenant"]).optional(),agent_capable:s.boolean().optional(),members:s.array(s.object({account_id:I,kind:s.enum(["human","agent"]),endpoint_id:I.optional(),display_label:s.string().min(1).max(64)}).strict()).max(500)}).strict(),s.object({op:s.literal("team_bridge.conversations.lifecycle"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I,action:s.enum(["archive","unarchive","join","leave"])}).strict(),s.object({op:s.literal("team_bridge.conversations.join"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.leave"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.notify"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),notify:s.enum(["all","mention","mute"])}).strict(),s.object({op:s.literal("team_bridge.conversations.agent_notify"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),notify:s.enum(["all","mention","mute"])}).strict(),s.object({op:s.literal("team_bridge.conversations.members.add"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),members:s.array(s.object({account_id:I,kind:s.enum(["human","agent"]),endpoint_id:I.optional(),display_label:s.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),s.object({op:s.literal("team_bridge.conversations.members.remove"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I,account_id:I}).strict(),s.object({op:s.literal("team_bridge.conversations.delete"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I}).strict(),s.object({op:s.literal("team_bridge.conversations.consent"),expected_account_id:I.optional(),conversation_id:I,account_id:I,decision:s.enum(["accept","decline","withdraw"]),consent_version:s.string().min(1).max(128).optional(),endpoint_id:I.optional(),tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.conversations"),expected_account_id:I,tenant_id:I,limit:s.number().int().min(1).max(100).optional(),cursor:s.string().min(1).optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.messages"),expected_account_id:I,tenant_id:I,conversation_id:I,limit:s.number().int().min(1).max(100).optional(),before_seq:s.number().int().nonnegative().optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.replies"),expected_account_id:I,tenant_id:I,conversation_id:I,message_id:I,limit:s.number().int().min(1).max(100).optional(),after_seq:s.number().int().nonnegative().optional(),before_seq:s.number().int().positive().optional(),order:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("team_bridge.messages.list"),conversation_id:I,tenant_id:I.optional(),limit:s.number().int().min(1).max(100).optional(),before_seq:s.number().int().nonnegative().optional(),endpoint_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.typing.get"),conversation_id:I,tenant_id:I}).strict(),s.object({op:s.enum(["team_bridge.typing.set","team_bridge.typing.clear"]),conversation_id:I,tenant_id:I,expected_account_id:I,thread_root_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.settings.share_typing"),expected_account_id:I,share_typing:s.boolean()}).strict(),s.object({op:s.literal("team_bridge.reactions.toggle"),conversation_id:I,message_id:I,expected_account_id:I,tenant_id:I,emoji:s.string().min(1),active:s.boolean()}).strict(),s.object({op:s.literal("team_bridge.messages.send"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),client_ref:I,body:s.string(),agent_label:s.string().min(1).max(64).optional(),thread_root_id:I.optional(),attachment_ids:na.optional(),files:s.array(I).min(1).max(10).refine(e=>new Set(e).size===e.length,"Duplicate file").optional(),mentions:yy.optional()}).strict(),s.object({op:s.literal("team_bridge.messages.replies"),conversation_id:I,message_id:I,expected_account_id:I,tenant_id:I,limit:s.number().int().min(1).max(100).optional(),after_seq:s.number().int().nonnegative().optional(),before_seq:s.number().int().positive().optional(),order:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("team_bridge.scheduled.list"),tenant_id:I}).strict(),s.object({op:s.literal("team_bridge.scheduled.create"),tenant_id:I,conversation_id:I,client_ref:I,body:s.string(),send_at:s.string().datetime({offset:!0}),attachment_ids:na.optional(),thread_root_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.scheduled.update"),tenant_id:I,scheduled_id:I,body:s.string().optional(),send_at:s.string().datetime({offset:!0}).optional(),attachment_ids:na.optional(),expected_version:s.number().int().nonnegative().optional()}).strict(),s.object({op:s.literal("team_bridge.attachments.delete"),tenant_id:I,conversation_id:I,attachment_id:I,expected_account_id:I}).strict(),s.object({op:s.literal("team_bridge.scheduled.cancel"),tenant_id:I,scheduled_id:I}).strict(),s.object({op:s.literal("team_bridge.read"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),seq:s.number().int().nonnegative().optional(),muted:s.boolean().optional()}).strict(),s.object({op:s.literal("team_bridge.thread_read"),expected_account_id:I,conversation_id:I,message_id:I,tenant_id:I,seq:s.number().int().nonnegative()}).strict(),s.object({op:s.literal("team_bridge.unread"),scope:s.literal("account").optional(),tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.directory"),tenant_id:I}).strict(),s.object({op:s.literal("team_bridge.status"),boundary:Hd.optional()}).strict(),s.object({op:s.literal("team_bridge.link_preview.resolve"),url:s.string().min(1).max(qv),index:s.number().int().nonnegative(),expectedAccountId:I}).strict(),s.object({op:s.literal("settings.list")}).strict(),s.object({op:s.literal("settings.edit"),key:hi,value:s.unknown().refine(e=>e!==void 0,"A setting value is required."),base:vy.optional()}).strict(),s.object({op:s.literal("settings.reset"),key:hi}).strict(),s.object({op:s.literal("tts.paths")}).strict(),s.object({op:s.literal("notification_sounds.list")}).strict(),s.object({op:s.literal("notification_sounds.rename"),id:s.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),name:s.string().min(1).max(200)}).strict(),s.object({op:s.literal("notification_sounds.remove"),id:s.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)}).strict(),s.object({op:s.literal("config.get")}).strict(),s.object({op:s.literal("config.update"),value:Iy}).strict(),s.object({op:s.literal("instructions.get")}).strict(),s.object({op:s.literal("instructions.update"),content:s.string().max(64e3)}).strict(),s.object({op:s.literal("credentials.list")}).strict(),s.object({op:s.literal("credentials.update"),key:hi,value:mi}).strict(),s.object({op:s.literal("peers.list")}).strict(),s.object({op:s.literal("networks.list")}).strict(),s.object({op:s.literal("networks.invite"),networkId:gr,role:s.enum(["read","drive","admin"]),deviceId:gr.optional()}).strict(),s.object({op:s.literal("networks.member.remove"),networkId:gr,deviceId:gr,confirm:s.string().min(1).max(256)}).strict(),s.object({op:s.literal("sessions.transfer"),sessionId:F,to:s.union([s.literal("local"),gr]),keep:s.boolean().optional(),waitS:s.number().min(0).max(300).optional(),requestId:de.optional()}).strict(),s.object({op:s.literal("profileProposals.list"),state:s.enum(["pending","all"]).optional()}).strict(),s.object({op:s.literal("profileProposals.get"),proposalId:ea}).strict(),s.object({op:s.literal("profileProposals.accept"),proposalId:ea,requestId:de,after:s.record(s.string().regex(/^[a-z][a-z0-9_]{0,63}$/),s.unknown()).optional()}).strict(),s.object({op:s.literal("profileProposals.reject"),proposalId:ea,requestId:de,note:s.string().max(2e3).optional()}).strict(),s.object({op:s.literal("approvals.list")}).strict(),s.object({op:s.literal("approvals.approve"),approvalId:_r}).strict(),s.object({op:s.literal("approvals.deny"),approvalId:_r}).strict(),...["approvals.approveOperation","approvals.applyOperation"].map(e=>s.object({op:s.literal(e),approvalId:_r,operation:s.enum(["profile_save","pair_phone"]),requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr)}).strict()),s.object({op:s.literal("approvals.pairAck"),approvalId:_r,requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr),code:s.string().min(1).max(32).optional()}).strict(),s.object({op:s.literal("devices.list")}).strict(),s.object({op:s.literal("devices.remove"),deviceId:s.string().regex(/^[A-Za-z0-9]{1,64}$/)}).strict(),s.object({op:s.literal("operator.setup.read")}).strict(),s.object({op:s.literal("operator.setup.run")}).strict(),s.object({op:s.literal("mobile.password")}).strict(),s.object({op:s.literal("approvals.approveCredential"),approvalId:_r,...Yd}).strict(),s.object({op:s.literal("approvals.applyCredential"),approvalId:_r,...Yd}).strict(),s.object({op:s.literal("asks.list")}).strict(),s.object({op:s.literal("projects.list")}).strict(),s.object({op:s.literal("projects.get"),key:Sn}).strict(),s.object({op:s.literal("projects.create"),name:oa,description:s.string().max(gu).optional(),status:hu.optional(),tags:mu.optional()}).strict(),s.object({op:s.literal("projects.update"),key:Sn,fields:s.object({name:oa.optional(),title:s.string().max(80).optional(),owner:s.string().max(80).optional(),team:s.string().max(80).optional(),description:s.string().max(gu).optional(),status:hu.optional(),progress:s.string().max(Gy).optional(),tags:mu.optional(),start_date:vi.optional(),target_date:vi.optional(),completed_at:vi.optional(),estimate:s.number().positive().max(1e3).optional(),estimate_unit:s.enum(["points","days"]).optional()}).strict(),force_done:s.boolean().optional()}).strict(),s.object({op:s.literal("projects.delete"),key:Sn,confirmed_name:oa}).strict(),s.object({op:s.literal("projects.link"),key:Sn,sessionId:F}).strict(),s.object({op:s.literal("projects.unlink"),key:Sn,sessionId:F}).strict(),s.object({op:s.literal("projects.milestone"),key:Sn,name:s.string().min(1).max(_u),targetDate:vi.optional(),completed:s.boolean().optional()}).strict(),s.object({op:s.literal("projects.milestone.remove"),key:Sn,name:s.string().min(1).max(_u)}).strict(),s.object({op:s.literal("projects.request_update"),key:Sn}).strict(),s.object({op:s.literal("projects.for_session"),sessionId:F}).strict(),s.object({op:s.literal("projects.search"),q:s.string().min(1).max(zy),limit:s.number().int().min(1).max(Vy).optional()}).strict(),s.object({op:s.literal("aida.status")}).strict(),s.object({op:s.literal("aida.control"),action:s.enum(["open","pause","resume","greet","status"])}).strict(),s.object({op:s.literal("code_requests.list"),sessionId:F}).strict(),s.object({op:s.literal("code_requests.refresh"),sessionId:F,keys:s.array(s.string().min(1).max(512)).max(256).optional(),force:s.boolean().optional()}).strict(),s.object({op:s.literal("static.sign"),route:s.enum(["images","videos","audio","html"]),path:s.string().min(1),ttlS:s.number().int().min(1).max(3600).optional()}).strict(),s.object({op:s.literal("library.list"),scope:s.enum(["final","all"]).optional(),q:s.string().max(512).optional(),category:s.string().min(1).max(64).optional(),kind:s.string().min(1).max(64).optional(),origin_group:s.enum(["generated","created","mentioned"]).optional(),origin:s.string().min(1).max(64).optional(),tag:s.string().min(1).max(128).optional(),tag_mode:s.enum(["all","any"]).optional(),highlighted:s.boolean().optional(),organized:s.boolean().optional(),favorite:s.boolean().optional(),session:s.string().min(1).max(12).optional(),session_id:s.string().min(1).max(512).optional(),sort:s.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:s.enum(["asc","desc"]).optional(),limit:s.number().int().min(1).max(200).optional(),cursor:s.string().max(512).optional()}).strict(),s.object({op:s.literal("library.get"),id:to}).strict(),s.object({op:s.literal("library.update"),id:to,fields:s.object({name:s.string().max(200).optional(),description:s.string().max(2e3).optional(),favorite:s.boolean().optional(),locked:s.boolean().optional(),archived:s.boolean().optional()}).strict()}).strict(),s.object({op:s.literal("library.tags")}).strict(),s.object({op:s.literal("library.tags.create"),name:s.string().trim().min(1).max(24),category:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("library.tags.update"),id:no,name:s.string().trim().min(1).max(24).optional(),category:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("library.tags.delete"),id:no}).strict(),s.object({op:s.literal("library.tags.merge"),id:no,into:no}).strict(),s.object({op:s.literal("library.tags.assign"),id:to,tags:s.array(no).max(64),primary:s.string().max(128).optional()}).strict(),s.object({op:s.literal("library.chat.link"),id:to,sessionId:F}).strict(),s.object({op:s.literal("library.chat.clear"),id:to}).strict(),s.object({op:s.literal("library.librarian"),action:s.enum(["status","open","pause","resume","run"]).optional()}).strict(),s.object({op:s.literal("sidebar_layout.get")}).strict(),s.object({op:s.literal("sidebar_layout.set"),layout:Yy}).strict(),s.object({op:s.literal("notifications.list"),preview:s.literal(!0).optional(),includeAskReads:s.boolean().optional(),countSessionIds:s.array(F).max(50).optional(),includeSessionCounts:s.literal(!0).optional(),kind:s.enum(["all","asks","updates"]).optional(),bulkPriority:s.enum(["any","high","normal_up"]).optional(),state:s.enum(["unread","all","dismissed"]).optional(),source:s.enum(["notify","ask"]).optional(),priority:s.enum(["high","normal","low"]).optional(),sessionId:Ja.optional(),throughSeq:s.number().int().min(0).optional(),cursor:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("notifications.get"),id:fn}).strict(),s.object({op:s.literal("notifications.count")}).strict(),s.object({op:s.literal("notifications.read"),verb:s.enum(["read","unread","undo"]),target:s.union([yu,vu,Xy])}).strict(),s.object({op:s.literal("notifications.dismiss"),verb:s.enum(["dismiss","undismiss"]),target:s.union([yu,vu])}).strict(),s.object({op:s.literal("notifications.seen"),items:s.array(s.object({id:fn,revision:s.number().int().min(1),anchorId:s.string().min(1).max(256),visibleSinceMs:s.number().int().min(0)}).strict()).min(1).max(50),evidence:s.object({sessionId:Ja,inputKind:s.enum(["pointer","key","wheel"]),inputAtMs:s.number().int().min(0),visibleSinceMs:s.number().int().min(0)}).strict()}).strict()]);Qy.superRefine((e,t)=>{if(e.op==="usage.reset"&&!e.credentialRef&&!e.identity&&t.addIssue({code:s.ZodIssueCode.custom,message:"A usage reset must name an account: send `credentialRef` or `identity`.",path:["credentialRef"]}),e.op==="team_bridge.conversations.consent"&&e.decision==="withdraw"!=(e.consent_version===void 0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"accept and decline require consent_version; withdraw carries none",path:["consent_version"]}),(e.op==="notifications.read"||e.op==="notifications.dismiss")&&"items"in e.target&&!!e.target.receipt!=(e.target.throughSeq!==void 0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"Receipt writes require a sequence boundary",path:["target"]}),e.op==="notifications.read"&&e.verb==="undo"!="operationToken"in e.target&&t.addIssue({code:s.ZodIssueCode.custom,message:"Undo requires an operation token, and only undo accepts one",path:["target"]}),e.op==="team_bridge.messages.send"&&e.files){const n=e.attachment_ids??[];(n.length+e.files.length>10||e.files.some(r=>n.includes(r)))&&t.addIssue({code:s.ZodIssueCode.custom,message:"Invalid combined attachment set",path:["files"]})}if((e.op==="team_bridge.messages.send"||e.op==="team_bridge.scheduled.create"||e.op==="team_bridge.scheduled.update"&&e.body!==void 0)&&e.body?.trim()===""&&(e.attachment_ids?.length??0)===0&&!(e.op==="team_bridge.messages.send"&&e.files?.length)){t.addIssue({code:s.ZodIssueCode.custom,message:"A message needs text or an image",path:["body"]});return}if(e.op.startsWith("team_bridge.")&&"expected_account_id"in e&&e.expected_account_id&&(!("tenant_id"in e)||!e.tenant_id)){t.addIssue({code:s.ZodIssueCode.custom,path:["tenant_id"],message:"Guarded conversation writes require an explicit tenant"});return}if(e.op==="team_bridge.messages.send"&&e.thread_root_id!==void 0&&!e.expected_account_id){t.addIssue({code:s.ZodIssueCode.custom,path:["expected_account_id"],message:"Thread replies require the captured account"});return}if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:s.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:s.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.name!==void 0,r=e.localId!==void 0,o=e.op!=="hub.check";if(n&&r||o&&!n&&!r||r&&e.kind===void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"A hub action addresses one item by name or local id, never both",path:["localId"]});return}}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.localId!==void 0||e.prefer!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, addressed by name, with no preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:s.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){if(e.askId||t.addIssue({code:s.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.dismiss===!0){(e.answers!==void 0||e.decline===!0||e.revise===!0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"A dismissal carries no answers, decline or revise",path:["dismiss"]});return}e.reason!==void 0?t.addIssue({code:s.ZodIssueCode.custom,message:"A reason applies to a dismissal",path:["reason"]}):e.decline!==!0&&!e.answers?t.addIssue({code:s.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:s.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:s.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:s.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:s.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:s.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:s.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]}),e.dismiss===!0&&t.addIssue({code:s.ZodIssueCode.custom,message:"dismiss applies to a queued ask",path:["dismiss"]}),e.reason!==void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:"reason applies to a queued ask",path:["reason"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:s.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:s.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const We={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed",serverUpdating:"transient.server-updating"},qp="service is preparing a safe reload; retry shortly",eh="serve_reloading";function qy(e,t){if(e!==503||t===null||typeof t!="object")return!1;const n=t.detail;return n===qp?!0:n!==null&&typeof n=="object"&&n.code===eh}function ew(e){return e!==null&&typeof e=="object"&&e.updating===!0}function tw(e){return e!==null&&typeof e=="object"&&e.update_stalled===!0}const nw={runtimeUnreachable:"runtime_unreachable"},Ss="runtime_busy",th="runtime_retiring";s.object({data:s.object({aside_id:s.string().optional(),status:s.union([s.enum(["adopted","queued"]),s.string()]).optional()}).passthrough()}).passthrough();const nh=s.object({name:s.string(),description:s.string().nullish(),source:s.string().nullish(),link_id:s.string().nullish(),editable:s.boolean().nullish(),installed:s.boolean().nullish(),fingerprint:s.string().nullish(),form:s.string().nullish()}).passthrough(),rw=s.object({path:s.string(),size:s.number().nullish(),preview:s.string().nullish(),preview_truncated:s.boolean().nullish()}).passthrough(),ow=nh.extend({body:s.string().nullish(),body_in_detail:s.boolean().nullish(),body_length:s.number().nullish(),body_bytes:s.number().nullish(),body_truncated:s.boolean().nullish(),files:s.array(rw).nullish(),files_total:s.number().nullish(),files_truncated:s.boolean().nullish(),publish_budget:s.object({limit:s.number(),total:s.number()}).passthrough().nullish()}).passthrough(),NM=s.object({skills:s.array(nh),scope:s.string().nullish(),detail:s.string().nullish(),skill_detail:ow.nullish(),warning_count:s.number().nullish(),version:s.string().nullish()}).passthrough(),LM=s.object({reset:s.object({outcome:s.union([s.enum(["reset","already_redeemed","no_credit","nothing_to_reset","failed","refused"]),s.string()]),windows_reset:s.number().int().nonnegative(),detail:s.string().default(""),refused:s.boolean()}).passthrough(),usage:s.object({reports:s.array(s.record(s.unknown())),source:s.string(),fetched_at:s.number()}).passthrough().nullish()}).passthrough(),FM="aside_adopt_refused",iw=["session_closed","open_tool_batch","turn_running"];function UM(e){if(typeof e!="object"||e===null)return;const t=e.reason;return iw.find(n=>n===t)}const sw={[We.noCredential]:"ui.common.errors.desktop_refusal.no_credential",[We.refused]:"ui.common.errors.desktop_refusal.refused",[We.planeClosed]:"ui.common.errors.desktop_refusal.plane_closed",[We.transportFailed]:"ui.common.errors.desktop_refusal.transport_failed",[We.serverUpdating]:"ui.common.errors.desktop_refusal.server_updating"},ec={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function Es(e){return e!==void 0&&Object.values(We).includes(e)}function aw(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return We.refused;if(t===503)return We.planeClosed}}const BM=s.object({step:s.string(),blocked_on:s.string(),configured:s.boolean(),ready:s.boolean(),verified:s.boolean(),url:s.string().nullable(),credential_id:s.number().int().positive().nullable(),identity_label:s.string().nullable(),credential_choices:s.array(s.object({id:s.number().int().positive(),identity_label:s.string().nullable().optional()}).passthrough()).default([]),quote:s.object({monthly_price_usd:s.string().nullable(),positive_balance:s.boolean(),eligible:s.boolean(),account_valid:s.boolean()}).passthrough().nullable(),receipts:s.array(s.object({step:s.string(),ok:s.boolean(),text:s.string()})).default([]),remedy:s.object({kind:s.string(),text:s.string(),command:s.string().nullable().optional(),url:s.string().nullable().optional()}).nullable(),source:s.string(),in_progress:s.boolean().default(!1),progress:s.array(s.string()).default([]),active_credential_id:s.number().int().positive().nullable().default(null),billing_outcome:s.string().optional(),reservation_outcome:s.string().optional(),failure_stage:s.string().optional(),transport:s.string().optional()}).passthrough();function HM(e){return e.transport!=="relay"?!1:e.blocked_on==="cloudflared"||e.remedy?.kind==="install_cloudflared"}const WM=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),cw=88e4,lw=11e5,dw=2e4,uw=9e4,fw=new Set(["analytics.get","analytics.models","sessions.report"]),pw=new Set(["usage.get"]),hw=new Set(["networks.list","peers.list"]),mw=new Set(["usage.reset"]),gw=new Set(["sessions.files.download"]),_w=new Set([...fw,...pw,...hw,...mw,...gw]),bw=90,vw=30,yw=300,ww=10,rh=15,kw=1e4;function Sw(e){const n=e.to==="local"||e.keep?yw:vw,r=Math.max(0,e.waitS??0);return(bw+n+ww+rh)*1e3+r*1e3}const Ew=18e4,sa=Ew+15e3,Iw=120,Aw=135e3,Rw=93e4,oh=(Iw+30+rh)*1e3,xw=6e4,Tw=5*oh,Cw=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function Ow(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return oh;case"hub.check":return xw;case"hub.applyAll":return Tw;default:return null}}function Pw(e){if(typeof e!="string"&&e.op==="sessions.transfer")return Sw(e)+kw;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve"||t==="approvals.approveCredential"||typeof e!="string"&&e.op==="approvals.approveOperation"&&e.operation==="pair_phone"||t==="devices.remove"||t==="operator.setup.run")return sa;if(t==="tunnel.setup.run")return Rw;if(t==="tunnel.setup.plan")return Aw;const n=Ow(t);return n!==null?n:_w.has(t)?uw:dw}const Mw=5e3;function ih(e){return Pw(e)+Mw}const il="deadline_exceeded",sh="foreground_required",ah="View these completions in the foreground before marking them read.",jw=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.owner_audit.conversations","team_bridge.owner_audit.messages","team_bridge.owner_audit.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","profileProposals.list","profileProposals.get","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","mobile.doctor","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.userAttachments","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","sessions.diff","subagents.diff","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","devices.list","operator.setup.read","mobile.password","usage.get"]),$w=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Dw(e,t){const n=Math.round(t/1e3),r=il;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"||e==="approvals.approveCredential"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:Cw.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:jw.has(e)?{code:r,message:$w.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const GM=cw,zM=lw;s.object({state:s.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:s.string(),kind:s.enum(["balance","subscription","radient","none"]),model_free:s.boolean(),title:s.string(),body:s.string(),actions:s.array(s.object({id:s.enum(["open_url","resend_verification","refresh"]),label:s.string(),url:s.string().nullable().optional()})),resets_at_ms:s.number().int().nullable().optional(),checked_at_ms:s.number().int(),age_ms:s.number().int().nullable().optional(),source:s.enum(["cached","live"])});function Nw(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function wu(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function aa(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function ca(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function ku(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function ro(e){const t=new URLSearchParams;return e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id),t.size?`?${t.toString()}`:""}function wi(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function Lw(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"profileProposals.list":return{path:`/v1/desktop/profile-proposals?state=${e.state??"pending"}`,method:"GET"};case"profileProposals.get":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}`,method:"GET"};case"profileProposals.accept":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}/accept`,method:"POST",body:{request_id:e.requestId,...e.after?{after:e.after}:{}}};case"profileProposals.reject":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}/reject`,method:"POST",body:{request_id:e.requestId,...e.note?{note:e.note}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"approvals.approveOperation":case"approvals.applyOperation":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/${e.op==="approvals.approveOperation"?"approve-operation":"apply-operation"}`,method:"POST",body:{operation:e.operation,request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest}};case"approvals.pairAck":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/pair-ack`,method:"POST",body:{request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest,...e.code!==void 0?{code:e.code}:{}}};case"devices.list":return{path:"/v1/desktop/devices",method:"GET"};case"devices.remove":return{path:`/v1/desktop/devices/${encodeURIComponent(e.deviceId)}`,method:"DELETE"};case"mobile.password":return{path:"/v1/desktop/mobile/password",method:"GET"};case"operator.setup.read":return{path:"/v1/desktop/operator/setup",method:"GET"};case"operator.setup.run":return{path:"/v1/desktop/operator/setup",method:"POST",body:{}};case"approvals.approveCredential":case"approvals.applyCredential":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/${e.op==="approvals.approveCredential"?"approve-credential":"apply-credential"}`,method:"POST",body:{operation:e.operation,request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest}};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:ku(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:ku(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.adoptionStrategy!==void 0?{adoption_strategy:e.adoptionStrategy}:{},...e.allowLlm!==void 0?{allow_llm:e.allowLlm}:{},...e.confirm!==void 0?{confirm:e.confirm}:{},...e.adoptionReceipt!==void 0?{adoption_receipt:e.adoptionReceipt}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),e.include_temporary&&t.set("include_temporary","true"),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??fy)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.temporary":return{path:`/v1/desktop/sessions/${e.sessionId}/temporary`,method:"POST",body:{temporary:e.temporary}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{},...e.temporary?{temporary:!0}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),ts(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.files.download":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/download`,method:"POST"};case"sessions.userAttachments":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments`,method:"GET"};case"sessions.userAttachments.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments/${encodeURIComponent(e.digest)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1"),t.set("diff_bindings","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),ts(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??hy)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.entryId&&t.set("entry_id",e.entryId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.diff":case"subagents.diff":{const t=new URLSearchParams({start:String(e.start),offset:String(e.offset??0),limit:String(e.limit)}),n=encodeURIComponent(e.callId);return{path:`/v1/desktop/sessions/${e.op==="subagents.diff"?`${e.sessionId}/children/${e.childId}`:e.sessionId}/tool-calls/${n}/diff?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],...e.files?.length?{files:e.files}:{},mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.profileActionStatus":return{path:`/v1/desktop/sessions/${e.sessionId}/profile-action-status`,method:"POST",body:{action_id:e.actionId,receipt_id:e.receiptId,profile_kind:e.profileKind,profile_name:e.profileName,tool_call_id:e.toolCallId}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{},...e.dismiss===!0?{dismiss:!0,...e.reason!==void 0?{reason:e.reason}:{}}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"settingsIntents.list":return{path:e.sessionId?`/v1/desktop/settings-intents?session_id=${e.sessionId}`:"/v1/desktop/settings-intents",method:"GET"};case"settingsIntents.submit":return{path:`/v1/desktop/sessions/${e.sessionId}/settings-intents`,method:"POST",body:{request_id:e.requestId,kind:e.kind,value:e.value,...e.effort!==void 0?{effort:e.effort}:{}}};case"settingsIntents.dismiss":return{path:`/v1/desktop/sessions/${e.sessionId}/settings-intents/${e.kind}?generation=${e.generation}`,method:"DELETE"};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{ca(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...aa(e)}}}case"agent.republish":{ca(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...aa(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{ca(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:aa(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...Nw(e),message:e.message,...wu(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...wu(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/monitors?${t}`:"/v1/desktop/monitors",method:"GET"}}case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"usage.reset":{const t={provider:e.provider,redeem_request_id:e.redeemRequestId};return e.credentialRef&&(t.credential_ref=e.credentialRef),e.identity&&(t.identity=e.identity),{path:"/v1/desktop/usage/reset",method:"POST",body:t}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"skills.create":return{path:"/v1/desktop/skills",method:"POST",body:{request_id:e.requestId,name:e.name,copy_from:e.copyFrom}};case"skills.update":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"PUT",body:{request_id:e.requestId,expected_fingerprint:e.expectedFingerprint,files:e.files}};case"skills.remove":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"DELETE",body:{request_id:e.requestId,discard_local_changes:e.discardLocalChanges}};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"mobile.doctor":return{path:"/v1/desktop/mobile/doctor",method:"GET"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${wi(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.onboarding.dismiss":return{path:"/v1/desktop/team-bridge/onboarding/dismiss",method:"POST"};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${wi(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),e.status&&t.set("status",e.status),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${wi(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}${e.action==="join"?"":ro(e)}`,method:"POST",...e.action==="join"&&(e.tenant_id||e.expected_account_id)?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id||e.expected_account_id?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.leave":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/leave${ro(e)}`,method:"POST"};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.agent_notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/agent-notify`,method:"PUT",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${ro(e)}`,method:"DELETE"};case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}${ro(e)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,...e.consent_version?{consent_version:e.consent_version}:{},...e.endpoint_id?{endpoint_id:e.endpoint_id}:{}}};case"team_bridge.owner_audit.conversations":case"team_bridge.owner_audit.messages":case"team_bridge.owner_audit.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit));let n="/v1/desktop/team-bridge/owner-audit/conversations";return e.op==="team_bridge.owner_audit.conversations"?e.cursor!==void 0&&t.set("cursor",e.cursor):(n+=`/${encodeURIComponent(e.conversation_id)}/messages`,e.op==="team_bridge.owner_audit.messages"?e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)):(n+=`/${encodeURIComponent(e.message_id)}/replies`,e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.order!==void 0&&t.set("order",e.order))),{path:`${n}?${t}`,method:"GET"}}case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.typing.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing${wi(e.tenant_id)}`,method:"GET"};case"team_bridge.typing.set":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing`,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.typing.clear":{const t=new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id});return e.thread_root_id&&t.set("thread_root_id",e.thread_root_id),{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing?${t}`,method:"DELETE"}}case"agent_messages.settings.share_typing":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,share_typing:e.share_typing}};case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id}}:{path:`${t}${ro(e)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{},...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.files?.length?{files:e.files}:{},...e.mentions?.length?{mentions:e.mentions}:{}}};case"team_bridge.scheduled.list":return{path:`/v1/desktop/team-bridge/scheduled?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"GET"};case"team_bridge.scheduled.create":return{path:"/v1/desktop/team-bridge/scheduled",method:"POST",body:{tenant_id:e.tenant_id,conversation_id:e.conversation_id,client_ref:e.client_ref,body:e.body,send_at:e.send_at,...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.scheduled.update":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"PATCH",body:{...e.body===void 0?{}:{body:e.body},...e.send_at===void 0?{}:{send_at:e.send_at},...e.attachment_ids===void 0?{}:{attachment_ids:e.attachment_ids},...e.expected_version===void 0?{}:{expected_version:e.expected_version}}};case"team_bridge.attachments.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/attachments/${encodeURIComponent(e.attachment_id)}?${new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id})}`,method:"DELETE"};case"team_bridge.scheduled.cancel":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"DELETE"};case"team_bridge.messages.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.order!==void 0&&t.set("order",e.order);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.thread_read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/read`,method:"POST",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,seq:e.seq}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.link_preview.resolve":return{path:"/v1/desktop/team-bridge/link-preview/resolve",method:"POST",body:{url:e.url,index:e.index,expected_account_id:e.expectedAccountId}};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"notification_sounds.list":return{path:"/v1/notification-sounds",method:"GET"};case"notification_sounds.rename":return{path:`/v1/notification-sounds/${e.id}`,method:"PATCH",body:{name:e.name}};case"notification_sounds.remove":return{path:`/v1/notification-sounds/${e.id}`,method:"DELETE"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.for_session":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/projects`,method:"GET"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??Ky)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}};case"notifications.list":{const t=new URLSearchParams;e.preview&&t.set("preview","true"),e.includeAskReads&&t.set("include_ask_reads","true"),e.includeSessionCounts&&t.set("include_session_counts","true");for(const n of e.countSessionIds??[])t.append("count_session_ids",n);return e.kind&&t.set("kind",e.kind),e.bulkPriority&&t.set("bulk_priority",e.bulkPriority),e.state&&t.set("state",e.state),e.source&&t.set("source",e.source),e.priority&&t.set("priority",e.priority),e.sessionId&&t.set("session_id",e.sessionId),e.cursor&&t.set("cursor",e.cursor),e.throughSeq!==void 0&&t.set("through_seq",String(e.throughSeq)),e.limit!==void 0&&t.set("limit",String(e.limit)),{path:`/v1/desktop/notifications${t.size?`?${t}`:""}`,method:"GET"}}case"notifications.get":return{path:`/v1/desktop/notifications/${encodeURIComponent(e.id)}`,method:"GET"};case"notifications.count":return{path:"/v1/desktop/notifications/count",method:"GET"};case"notifications.read":case"notifications.dismiss":return{path:"/v1/desktop/notifications",method:"PATCH",body:{op:e.verb,...Fw(e.target)}};case"notifications.seen":return{path:"/v1/desktop/notifications/seen",method:"POST",body:{items:e.items.map(t=>({id:t.id,revision:t.revision,anchor_id:t.anchorId,visible_since_ms:t.visibleSinceMs})),evidence:{surface:"desktop",session_id:e.evidence.sessionId,input_kind:Jy[e.evidence.inputKind],input_at_ms:e.evidence.inputAtMs,visible_since_ms:e.evidence.visibleSinceMs}}}}}function Fw(e){return"selectionToken"in e?{selection_token:e.selectionToken,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{},...e.excludedIds?{excluded_ids:e.excludedIds}:{}}:"operationToken"in e?{operation_token:e.operationToken,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{}}:"items"in e?{...e.receipt?{receipt:!0,through_seq:e.throughSeq,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{}}:{},ids:e.items.map(t=>({id:t.id,revision:t.revision}))}:"sessionId"in e?{session_id:e.sessionId,through_seq:e.throughSeq,observed:e.observed}:{all:!0,through_seq:e.throughSeq,observed:e.observed}}const KM=64,VM=64*1024*1024,ZM="superseded_completion_token",YM="store_busy",Uw="session_is_remote",Bw="owner_build_behind";function XM(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function Tr(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Hw(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const JM=e=>typeof e?.goal_status=="string",QM=e=>(e?.goal??"").trim().length>0;function Ww(e,t,n={}){return!e||e.epoch!==t.epoch?!0:t.seq>e.seq||n.allowEqual===!0&&t.seq===e.seq}function Gw(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const ko={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."};function zw(e){return e?e===ko.notPaired?"notPaired":e===ko.serverDown?"serverDown":e===ko.frameBudget?"frameTooLarge":"lost":"lost"}const Kw=/^[a-f0-9]{12}$/,Vw=/^[a-zA-Z0-9_-]{1,128}$/,Zw=()=>performance.timeOrigin+performance.now();function Yw(e){e&&(e.rendererEntryEpochMs=Zw())}function sl(e,t){e&&(e.delivery=t,e.deliveryAt=performance.now())}function Xw(e,t,n,r){const o=a=>a===void 0?"-":a.toFixed(3),i=(a,c)=>a===void 0||c===void 0?void 0:a-c;return["[snapshot-receipt]",`openToken=${t??"-"}`,`session=${Kw.test(e.sessionId)?e.sessionId:"?"}`,`streamId=${Vw.test(e.streamId)?e.streamId:"?"}`,"kind=snapshot",`chars=${e.chars}`,`mainRecordEpochMs=${o(e.mainRecordEpochMs)}`,`mainFoldMs=${o(e.mainFoldMs)}`,`mainObserverMs=${o(e.mainObserverMs)}`,`mainEmitMs=${o(e.mainEmitMs)}`,`mainSendEpochMs=${o(e.mainSendEpochMs)}`,`ipcApproxMs=${o(i(e.preloadReceiptEpochMs,e.mainSendEpochMs))}`,`preloadReceiptEpochMs=${o(e.preloadReceiptEpochMs)}`,`preloadReadyMs=${o(e.preloadReadyMs)}`,`bridgeApproxMs=${o(i(e.rendererEntryEpochMs,e.preloadReceiptEpochMs===void 0||e.preloadReadyMs===void 0?void 0:e.preloadReceiptEpochMs+e.preloadReadyMs))}`,`rendererEntryEpochMs=${o(e.rendererEntryEpochMs)}`,`delivery=${e.delivery??"-"}`,`bufferMs=${o(i(e.deliveryAt,e.bufferedAt))}`,`deliveryToParseMs=${o(i(n,e.deliveryAt))}`,`parseMs=${o(r-n)}`].join(" ")}const Su=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(r,o,c);return c},Jw=e=>e?Su(e):Su,Qw=e=>e;function qw(e,t=Qw){const n=Sd.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return Sd.useDebugValue(n),n}const Eu=e=>{const t=Jw(e),n=r=>qw(t,r);return Object.assign(n,t),n},oi=e=>e?Eu(e):Eu;function ch(e,t){let n;try{n=e()}catch{return}return{getItem:o=>{var i;const a=l=>l===null?null:JSON.parse(l,void 0),c=(i=n.getItem(o))!=null?i:null;return c instanceof Promise?c.then(a):a(c)},setItem:(o,i)=>n.setItem(o,JSON.stringify(i,void 0)),removeItem:o=>n.removeItem(o)}}const tc=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return tc(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return tc(r)(n)}}}},e0=(e,t)=>(n,r,o)=>{let i={storage:ch(()=>localStorage),partialize:v=>v,version:0,merge:(v,b)=>({...b,...v}),...t},a=!1;const c=new Set,l=new Set;let d=i.storage;if(!d)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...v)},r,o);const u=()=>{const v=i.partialize({...r()});return d.setItem(i.name,{state:v,version:i.version})},f=o.setState;o.setState=(v,b)=>{f(v,b),u()};const h=e((...v)=>{n(...v),u()},r,o);o.getInitialState=()=>h;let _;const y=()=>{var v,b;if(!d)return;a=!1,c.forEach(A=>{var k;return A((k=r())!=null?k:h)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(v=r())!=null?v:h))||void 0;return tc(d.getItem.bind(d))(i.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==i.version){if(i.migrate){const k=i.migrate(A.state,A.version);return k instanceof Promise?k.then(M=>[!0,M]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var k;const[M,P]=A;if(_=i.merge(P,(k=r())!=null?k:h),n(_,!0),M)return u()}).then(()=>{p?.(_,void 0),_=r(),a=!0,l.forEach(A=>A(_))}).catch(A=>{p?.(void 0,A)})};return o.persist={setOptions:v=>{i={...i,...v},v.storage&&(d=v.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>y(),hasHydrated:()=>a,onHydrate:v=>(c.add(v),()=>{c.delete(v)}),onFinishHydration:v=>(l.add(v),()=>{l.delete(v)})},i.skipHydration||y(),_||h},Is=e0,t0=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function n0(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,o)=>typeof r=="number"&&Number.isFinite(r)?r:o;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const lh=oi()(Is(e=>({notice:null,receive:t=>e(n=>t0(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:ch(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));function Qn(e){return g(sw[e])}let nc=null;function r0(e){if(e===null){nc=null;return}nc={openFrame:e.openFrame===!0,journalOrder:e.journalOrder===!0,peerJournalSource:e.peerJournalSource===!0}}function dh(){return nc}const Iu=()=>g("ui.common.errors.desktop_backend_offline"),o0=()=>g("ui.common.errors.desktop_backend_compatibility");async function uh(e){if(window.api?.desktop)try{return await i0(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ae?n:u0(n)?new _n(ah,sh):new Ae(null,Iu(),n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ae(null,Iu(),n)}if(!t.ok)throw new Ae(t.status,o0());return t.json()}function i0(e,t){const n=ih(t);let r;return Promise.race([e,new Promise((o,i)=>{r=setTimeout(()=>{const a=Dw(t.op,n);i(new Ae(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const fh="This server did not answer the request for its desktop controls.",s0=()=>g("ui.common.errors.desktop_refusal_placeholder");class Ae extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,o,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=o,this.retryAfterMs=i,this.detail=a}}class _n extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function al(e){return e instanceof Ae||e instanceof _n?e.code===We.serverUpdating?!0:e instanceof Ae&&ew(e.detail):!1}function qM(e){return e instanceof Ae&&tw(e.detail)}function ns(e,t){return al(e)?Qn(We.serverUpdating):e instanceof Ae||e instanceof _n?Es(e.code)?Qn(e.code):e.message===fh?s0():e.message:t}function a0(e,t,n,r){return r===eh&&t===503?We.serverUpdating:typeof r=="string"?r:n===qp&&t===503?We.serverUpdating:n===ec.noCredential?We.noCredential:n===ec.transportFailed?We.transportFailed:aw(Lw(e).path,t)}async function Ge(e){const t=await uh(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ae(t.status,r??fh,void 0,a0(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&c0(n?.result),n?.result}function c0(e){if(typeof e!="object"||e===null)return;const t=n0(e.delegated_cleanup_notice);t&&lh.getState().receive(t)}async function l0(){try{await Ge({op:"delegated_cleanup_notice.ack"})}catch{}}async function ej(){lh.getState().dismiss(),await l0()}function d0(e){return e instanceof Ae&&e.code===il}function tj(e){if(!(e instanceof Ae))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===Bw:e.code===Uw}function nj(e){return e instanceof _n&&e.code===sh}function u0(e){return e instanceof Error&&e.message.includes(ah)}async function rj(e){const t=await uh(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function oj(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Ge({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function f0(e,t,n){const r=b0(e);return r.record?(n?.("adopted"),Au(e.sessionId,"adopted","none",rc(e),null),w0(r.record,t)):(Kt&&pn(),n?.("requested"),Au(e.sessionId,"requested",r.refusal,rc(e),r.held),ph(e,t))}const p0=6e4,h0=512;function rc(e){return{openFrame:e.openFrame===!0,journalOrder:e.journalOrder===!0,peerJournalSource:e.peerJournalSource===!0}}let Kt=null,qn=null;function pn(){qn!==null&&(clearTimeout(qn),qn=null);const e=Kt;Kt=null,e&&(e.live=null,e.buffered=[],e.disposeTransport())}function m0(){return Kt?.sessionId??null}function g0(e){!e||Kt?.sessionId!==e||pn()}function _0(e,t){if(!e||Kt?.sessionId===e)return;pn();const n=dh(),r={openFrame:n?.openFrame===!0,journalOrder:n?.journalOrder===!0,peerJournalSource:n?.peerJournalSource===!0&&t?.remoteOwned===!0};let o=!1;const i={sessionId:e,negotiation:r,buffered:[],live:null,ended:!1,disposeTransport:()=>{}};if(i.disposeTransport=ph({sessionId:e,...r.openFrame?{openFrame:!0}:{},...r.journalOrder?{journalOrder:!0}:{},...r.peerJournalSource?{peerJournalSource:!0}:{}},c=>{if(i.live){sl(c.receipt,"live"),i.live(c);return}if(c.kind==="error"||c.kind==="end"){i.ended=!0,o=!0,pn();return}if(i.buffered.length>=h0){o=!0,pn();return}c.receipt&&(c.receipt.bufferedAt=performance.now()),i.buffered.push(c)}),o){i.disposeTransport();return}Kt=i;const a=setTimeout(()=>{Kt===i&&pn()},p0);typeof a.unref=="function"&&a.unref(),qn=a}function b0(e){const t=Kt;if(!t)return{record:null,refusal:"none",held:null};if(t.ended)return pn(),{record:null,refusal:"ended",held:t.negotiation};if(t.sessionId!==e.sessionId)return{record:null,refusal:"other-session",held:null};const n=rc(e);return e.epoch!==void 0||e.afterSeq!==void 0||(e.orderIds?.length??0)>0?(pn(),{record:null,refusal:"resuming",held:t.negotiation}):n.openFrame!==t.negotiation.openFrame||n.journalOrder!==t.negotiation.journalOrder||n.peerJournalSource!==t.negotiation.peerJournalSource?(pn(),{record:null,refusal:"negotiation",held:t.negotiation}):{record:t,refusal:null,held:t.negotiation}}const v0=/^[A-Za-z0-9_-]{1,80}$/,y0="[stream-prewarm]";function Au(e,t,n,r,o){if(t==="requested"&&n==="none")return;const i=v0.test(e)?e:"?",a=l=>[l.openFrame?"1":"0",l.journalOrder?"1":"0",l.peerJournalSource?"1":"0"].join(","),c=[y0,`session=${i}`,`decision=${t}`];t==="requested"&&(c.push(`why=${n}`,`asked=${a(r)}`),o&&c.push(`prewarm=${a(o)}`),n==="negotiation"&&c.push(`caps=${dh()?"recorded":"absent"}`)),console.warn(c.join(" "))}function w0(e,t){const n=e.buffered;e.buffered=[],e.live=t,qn!==null&&(clearTimeout(qn),qn=null),Kt===e&&(Kt=null);let r=!1;return queueMicrotask(()=>{if(!r)for(const o of n)sl(o.receipt,"replay"),t(o)}),()=>{r||(r=!0,e.live=null,e.disposeTransport())}}function ph(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,a=>{const c=a.receipt?{...a,receipt:{...a.receipt}}:a;Yw(c.receipt),sl(c.receipt,"direct"),t(c)});return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&(r.set("open_frame","1"),r.set("diff_bindings","1")),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),ts(r,"/__desktop/stream",e.orderIds??[]));const o=new EventSource(`/__desktop/stream?${r}`);return o.onmessage=i=>{t({kind:"data",data:i.data})},o.onerror=()=>{o.readyState===EventSource.CLOSED&&(t({kind:"error",detail:ko.ended}),o.close())},()=>{o.close(),t({kind:"end"})}}async function ij(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),o=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a,c;if(o.includes("application/json"))try{const l=await r.json();qy(r.status,l)&&(a=We.serverUpdating);const d=l?.detail;if(typeof d=="string")i=d;else if(typeof d=="object"&&d!==null){const u=d;typeof u.text=="string"&&u.text.trim()?i=u.text:typeof u.message=="string"&&u.message.trim()&&(i=u.message),typeof u.code=="string"&&a===void 0&&(a=u.code);const f=d.params;typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&Es(a)?a:i===ec.noCredential?We.noCredential:void 0,...e.op==="notification_sounds.upload"&&a!==void 0?{refusal:{code:a.slice(0,64),...c?{params:c}:{}}}:{}}}return o.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:o||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function sj(e){return e.kind==="error"?Es(e.code)?new _n(Qn(e.code),e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}function k0(e){if(al(e))return"updating";if(d0(e))return"deadline";const t=e instanceof Ae?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const hh={updating:"",unreachable:"",deadline:"",unauthorized:"",get outdated(){return g("ui.common.connection.backend.remedy_outdated")},unknown:""},Fi={get updating(){return Qn(We.serverUpdating)},get unreachable(){return g("ui.common.connection.backend.diagnosis_unreachable")},get deadline(){return g("ui.common.connection.backend.diagnosis_deadline")},get unauthorized(){return g("ui.common.connection.backend.diagnosis_unauthorized")},get outdated(){return g("ui.common.connection.backend.diagnosis_outdated")},unknown:""};function S0(e,t){const n=k0(t);return[e,Fi[n],hh[n]].filter(Boolean).join(" ")}const oc={get successor(){return g("ui.common.connection.backend.pairing_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.pairing_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.pairing_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.pairing_credential_refused")},get unpaired(){return g("ui.common.connection.backend.pairing_unpaired")}},E0={get successor(){return g("ui.common.connection.backend.pane_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.pane_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.pane_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.pane_credential_refused")},get unpaired(){return g("ui.common.connection.backend.pane_unpaired")}};function aj(e,t){return e!=="unpaired"?null:E0[t??"unpaired"]}function cj(e,t){return e!=="unpaired"?null:oc[t??"unpaired"]}function lj(e){const{kind:t,unpaired:n,answered:r,cause:o=null,servedByThisApp:i=!1}=e;return o==="pre-handshake"?i:o!==null||n?!1:r?i:t==="outdated"}function dj(e){const{kind:t,unpaired:n,missing:r,answered:o,cause:i=null}=e;if(i!==null)return oc[i];if(!o){if(t==="updating")return Fi.updating;if(t==="unreachable")return g("ui.common.connection.backend.compatibility_unreachable",{diagnosis:Fi.unreachable});if(t==="unauthorized")return g("ui.common.connection.backend.compatibility_unauthorized");if(t==="deadline")return g("ui.common.connection.backend.compatibility_deadline",{diagnosis:Fi.deadline});if(t==="outdated")return g("ui.common.connection.backend.compatibility_outdated",{remedy:hh.outdated})}return n?oc.unpaired:o?g("ui.common.connection.backend.compatibility_missing",{features:r.join(", ")}):g("ui.common.connection.backend.compatibility_unknown")}const I0=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function uj(e,t=null){return t!==null||!e?!0:I0.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function A0(e,t){return t instanceof Ae&&t.status===null?!1:e<1}function fj(e,t){return t instanceof Ae&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const R0={get successor(){return g("ui.common.connection.backend.card_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.card_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.card_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.card_credential_refused")},get unpaired(){return g("ui.common.connection.backend.card_unpaired")}};function pj(e,t,n){return e===null?{sentence:S0(t,n),remedy:!0}:{sentence:R0[e],remedy:Np(e)}}const mh={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],commandsFor:e=>["desktop","commands",e],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},x0=3e4,T0=15e3;function C0(e){return e?.desktop_available===!0}function hj(){const{client:e,provided:t}=Pb();return Dp({enabled:t,queryKey:mh.capabilities,queryFn:async()=>{try{const n=await Ge({op:"capabilities"});return r0(P0(n)),n}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>C0(n.state.data)?x0:T0,refetchIntervalInBackground:!0},e)}function O0(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function la(e,t,n=1){return O0(e,t,n)==="enabled"}function P0(e){return{openFrame:la(e,"open_frame"),journalOrder:la(e,"journal_order"),peerJournalSource:la(e,"peer_journal_source")}}function mj(e){return Dp({queryKey:mh.providers,queryFn:()=>Ge({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:A0})}let As=!1,rs=!1;const os=[];function gj(){typeof window>"u"||!window.__loDevDriver?.armed||(As=!0,rs=!1,os.length=0)}function M0(){return As}function j0(e){if(As)try{if(os.length>=256){rs=!0;return}os.push({carrier:e.carrier,sessionId:e.sessionId,epoch:typeof e.epoch=="string"?e.epoch:null,seq:typeof e.seq=="number"?e.seq:null,disposition:e.disposition})}catch{rs=!0}}function _j(){return{armed:As,fault:rs,receipts:os.map(e=>({...e}))}}const oo=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function gh(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const c=oo(a);return c===null||!n.has(c)});for(const a of t.upserted??[]){const c=oo(a);if(c===null){r.push(a);continue}const l=r.findIndex(d=>oo(d)===c);l===-1?r.push(a):r[l]=a}if(!t.order)return r;const o=new Map;for(const a of r){const c=oo(a);c!==null&&o.set(c,a)}const i=[];for(const a of t.order){const c=String(a),l=o.get(c);l&&(i.push(l),o.delete(c))}for(const a of r){const c=oo(a);c!==null&&o.has(c)?(i.push(a),o.delete(c)):c===null&&i.push(a)}return i}const ic=e=>({revision:xt(e),demand:e.orderDemand}),er=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Gr(e,t,n,r,o,i={}){let a=e;const c=t.journal_generation;if(t.reconcile===!0){const h=typeof c=="string"&&c.length>0?c:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===h?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:h,orderDemand:h!==void 0?{generation:h}:{}}}if(typeof c!="string"||c.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&o&&a.orderNeedsReconcile&&a.orderDemand===o.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),c!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===c?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:c,orderDemand:{generation:c}};let l=a.journalMode?a:{...a,journalMode:!0};if(c!==a.journalGeneration&&(l={...a,journalMode:!0,journalGeneration:c,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const h=(a.orderRevision??0)+1,_=new Map;for(const y of a.records){const v=y.sourceEntryId??(y.kind==="tool"||y.kind==="supplement"?null:y.id);typeof v=="string"&&v.length>0&&v.length<=128&&_.set(v,h)}l={...l,..._.size>0?{journalBodyOwed:_}:{},journalSourceVoid:void 0}}let d=l.journalPositions??new Map;const u=d,f=(h,_,y)=>{if(!er(y))return;const v=d.get(h);v&&v.seq>=y||(d===u&&(d=new Map(d)),d.set(h,{entryId:_,seq:y}))};for(const[h,_]of Object.entries(t.journal_ordinals??{}))f(h,h,_);for(const h of n)typeof h.id=="string"&&(f(h.id,h.id,h.journal_seq),h.role==="tool"&&typeof h.tool_call_id=="string"&&f(`tool:${h.tool_call_id}`,h.id,h.journal_seq),typeof h.anchor=="string"&&f(`supplement:${h.anchor}`,h.id,h.journal_seq));return d!==u&&(l={...l,journalPositions:d}),l}function cl(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const o=n,i=r;return t.tool_calls.forEach((a,c)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===o&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==c&&(r===i&&(r=new Map(r)),r.set(a.id,c)))}),n===o&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function _h(e,t){const n=new Set(e.map(i=>i.id));let r=!1,o;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){o=a;continue}if(a.sourcePrecedes!==void 0){if(a.sourceAdmissionAnchor!==void 0){const{sourceAdmissionAnchor:c,...l}=a;e[i]=l,r=!0}o=e[i];continue}!t(a)&&o&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:o.id},r=!0),o=e[i]}return r}function bh(e,t,n,r,o){const i=[],a=new Set;let c=e,l;for(;c!==void 0;){if(o.has(c.id)){l=o.get(c.id);break}if(n(c)){l=r(c);break}if(c.kind==="user"&&c.provisional===!0||a.has(c.id))break;a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor?t.get(c.sourceAdmissionAnchor):void 0}for(const d of i)o.set(d,l);return l}const $0=Number.MAX_SAFE_INTEGER;function D0(e,t){const n=new Map,r=new Map,o=new Map;for(const i of e){if(i.sourcePrecedes===void 0)continue;const a=t(i);if(a!==void 0)r.set(i.sourcePrecedes,a);else{const c=r.get(i.sourcePrecedes);c!==void 0&&n.set(i.id,{seq:c,slot:$0})}}for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.sourcePrecedes===void 0)continue;const c=t(a);if(c!==void 0)o.set(a.sourcePrecedes,c);else if(!n.has(a.id)){const l=o.get(a.sourcePrecedes);l!==void 0&&n.set(a.id,{seq:l,slot:-1})}}return n}function vh(e,t){return{floor:N0(e,t),position:new Map(e.map((n,r)=>[n.id,r])),page:D0(e,t)}}function yh(e,t,n,r){if(r===void 0||e.sourcePrecedes===void 0)return;const o=r.page.get(e.id);if(o!==void 0)return o;const i=new Set;let a=1,c=t.get(e.sourcePrecedes);for(;c!==void 0&&!i.has(c.id);){i.add(c.id);const l=n(c);if(l!==void 0)return{seq:l,slot:-a};const d=r.page.get(c.id);if(d!==void 0)return{seq:d.seq,slot:d.slot-a};a+=1,c=c.sourcePrecedes?t.get(c.sourcePrecedes):void 0}return r.floor===void 0?void 0:{seq:r.floor,slot:-a}}function wh(e,t,n){if(n===void 0||e.sourcePrecedes===void 0)return;const{position:r}=n,o=new Set;let i=1,a=t.get(e.sourcePrecedes);for(;a!==void 0&&!o.has(a.id);){if(a.sourcePrecedes===void 0){const c=r.get(a.id);return c===void 0?void 0:{slot:c,depth:i}}o.add(a.id),i+=1,a=t.get(a.sourcePrecedes)}}function N0(e,t){let n;for(const r of e){if(r.sourcePrecedes!==void 0)continue;const o=t(r);o!==void 0&&(n===void 0||o<n)&&(n=o)}return n}function kh(e,t){const n=new Map;return r=>{if(!r)return;const o=t(r);if(o===void 0)return;const i=[],a=new Set;let c=r,l=!0;for(;c;){if(n.has(c.id)){l=n.get(c.id)===!0;break}if(a.has(c.id)||t(c)===void 0){l=!1;break}a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor===void 0?void 0:e.get(c.sourceAdmissionAnchor)}for(const d of i)n.set(d,l);return l?o:void 0}}function is(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const o=new Map;t.forEach((a,c)=>{if(a.kind!=="tool")return;const l=n.get(a.toolCallId);if(l===void 0||!r.has(a.toolCallId))return;const d=o.get(l);d?d.push(c):o.set(l,[c])});let i=t;for(const a of o.values()){if(a.length<2)continue;const c=a.map(l=>t[l]).sort((l,d)=>(r.get(l.toolCallId)??0)-(r.get(d.toolCallId)??0));c.every((l,d)=>l===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((l,d)=>{i[l]=c[d]}))}return i}function Sh(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return L0(e,t);const n=e.journalGeneration,r=e.journalPositions;let o=!1,i=!1;const a=t.map(v=>{v.sourcePrecedes!==void 0&&(i=!0);let p=[r?.get(v.sourceEntryId??v.id),r?.get(v.id)].filter(M=>M!==void 0).sort((M,P)=>P.seq-M.seq)[0];if(v.journalGeneration===n&&er(v.journalSeq)&&(!p||v.journalSeq>p.seq)&&(p={entryId:v.sourceEntryId??v.id,seq:v.journalSeq}),!p||!n||!(v.kind==="user"&&(v.provisional===!0||v.local===!0))&&v.sourceEntryId===p.entryId&&v.journalSeq===p.seq&&v.journalGeneration===n)return v;o=!0;let k={...v,sourceEntryId:p.entryId,journalSeq:p.seq,journalGeneration:n};if(k.kind==="user"){const{provisional:M,local:P,...W}=k;k=W}return k});_h(a,v=>v.journalGeneration===n&&er(v.journalSeq))&&(o=!0);const l=new Map,d=new Map(a.map(v=>[v.id,v])),u=kh(d,v=>v!==void 0&&v.journalGeneration===n&&er(v.journalSeq)?v.journalSeq:void 0),f=v=>u(v)!==void 0,h=i?vh(a,u):void 0,_=(v,b)=>{const p=u(v);if(v.kind==="user"&&v.provisional===!0&&p===void 0)return[1,0,0,0,b];const A=v.kind==="supplement"?v.anchor:v.kind==="tool"?e.journalCallOwners?.get(v.toolCallId)??e.argsByCall.get(v.toolCallId)?.anchorId:void 0,k=typeof A=="string"?u(d.get(A)):void 0,M=k===void 0&&p===void 0?yh(v,d,u,h):void 0,P=p===void 0&&M===void 0?bh(v,d,f,u,l):void 0,W=k??p??M?.seq??P;if(W===void 0){const R=wh(v,d,h);return[1,R?.slot??b,R?-R.depth:0,0,b]}return[0,W,k!==void 0?1:p!==void 0?0:M!==void 0?M.slot:2,p??Number.MAX_SAFE_INTEGER,b]},y=a.map((v,b)=>({record:v,index:b,rank:_(v,b)}));return y.sort((v,b)=>{for(let p=0;p<v.rank.length;p++){const A=v.rank[p]-b.rank[p];if(A)return A}return 0}),!o&&y.every((v,b)=>v.index===b)?is(e,t):is(e,y.map(v=>v.record))}function L0(e,t){const n=e.journalGeneration,r=e.journalPositions,o=new Map;let i=!1;for(const p of t){p.sourcePrecedes!==void 0&&(i=!0);let k=[r?.get(p.sourceEntryId??p.id),r?.get(p.id)].filter(M=>M!==void 0).sort((M,P)=>P.seq-M.seq)[0];p.journalGeneration===n&&er(p.journalSeq)&&(!k||p.journalSeq>k.seq)&&(k={entryId:p.sourceEntryId??p.id,seq:p.journalSeq}),k&&o.set(p.id,k)}const a=p=>p===void 0?void 0:o.get(p.id)??r?.get(p.sourceEntryId??p.id)??r?.get(p.id);let c=!1;const l=t.slice();_h(l,p=>p.journalGeneration===n&&er(p.journalSeq))&&(c=!0);const u=new Map,f=new Map(l.map(p=>[p.id,p])),h=kh(f,p=>a(p)?.seq),_=p=>h(p)!==void 0,y=i?vh(l,h):void 0,v=(p,A)=>{const k=h(p);if(p.kind==="user"&&p.provisional===!0&&k===void 0)return[1,0,0,0,A];const M=p.kind==="supplement"?p.anchor:p.kind==="tool"?e.journalCallOwners?.get(p.toolCallId)??e.argsByCall.get(p.toolCallId)?.anchorId:void 0,P=typeof M=="string"?h(f.get(M)):void 0,W=P===void 0&&k===void 0?yh(p,f,h,y):void 0,R=k===void 0&&W===void 0?bh(p,f,_,h,u):void 0,m=P??k??W?.seq??R;if(m===void 0){const w=wh(p,f,y);return[1,w?.slot??A,w?-w.depth:0,0,A]}return[0,m,P!==void 0?1:k!==void 0?0:W!==void 0?W.slot:2,k??Number.MAX_SAFE_INTEGER,A]},b=l.map((p,A)=>({record:p,index:A,rank:v(p,A)}));return b.sort((p,A)=>{for(let k=0;k<p.rank.length;k++){const M=p.rank[k]-A.rank[k];if(M)return M}return 0}),!c&&b.every((p,A)=>p.index===A)?is(e,t):is(e,b.map(p=>p.record))}function Jt(e){const t=e.records.filter(o=>o.kind==="user"&&o.provisional===!0),n=e.records.filter(o=>o.journalGeneration!==e.journalGeneration||!er(o.journalSeq)),r=[...t,...n].map(o=>o.sourceEntryId??(o.kind==="tool"||o.kind==="supplement"?null:o.id));if(r.push(...ll(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let o=r.length-1;o>=0;o--){const i=r[o];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(o,1)}return[...new Set(r.filter(o=>typeof o=="string"&&o.length>0&&o.length<=128))]}function ll(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const o=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof o=="string"&&o.length>0&&o.length<=128&&t.add(o)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Eh(e,t){const n=e.journalPositions;return Jt(e).filter(r=>!n?.has(r)&&!t?.has(r))}const xt=e=>e.orderRevision??0;async function F0(e){const t=new Map,n=c=>{let l=t.get(c);return l||(l=new Set,t.set(c,l)),l},r=(c,l)=>l==="payload"?ll(c):l==="lookup"?Eh(c):Jt(c);let o=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),l=ic(c),d=l.revision,u=e.sweep?.(c,n);if(u?.kind==="none")return{kind:"complete",transcript:c};const f=u?.kind??"authority",h=Qv(r(c,f).filter(b=>!n(f).has(b)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),_=await e.read(h,f);if(!e.isCurrent()||xt(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(_,d,l),!e.isCurrent())return{kind:"stale"};const y=e.getTranscript(),v=e.page(_);if(v.journal_order_state==="ready"&&v.journal_generation===y.journalGeneration){v.journal_generation!==o&&(t.clear(),o=v.journal_generation);for(const A of h)n(f).add(A);if(y.orderNeedsReconcile){if(y.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const A=(v.source_retry_ids??[]).filter(k=>typeof k=="string"&&k.length>0&&k.length<=128);if(A.length>0&&h.length>1&&a===0){a++;for(const k of A)n("payload").delete(k);continue}}const b=e.sweep?.(y,n);if(b?.kind==="none")return{kind:"complete",transcript:y};const p=b?.kind??"authority";if(r(y,p).some(A=>!n(p).has(A)))continue;return{kind:"complete",transcript:y}}if(!y.orderNeedsReconcile||y.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function Ft(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const o=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof o=="string"&&o?o:e.id}function da(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function Ru(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function bj(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=da(i.action_count);if(a===null)continue;const c={actions:a,workedSeconds:Ru(i.worked_seconds),failed:da(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:da(i.cross_session_action_count),crossSessionWorkedSeconds:Ru(i.cross_session_worked_seconds)};n.set(i.run_key,c),c.openingUserId!==null&&n.set(c.openingUserId,c),c.closingAnswerId!==null&&n.set(c.closingAnswerId,c)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(Ft(i));const o=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:o?Ft(o):null}}}function U0(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const o=Math.round((n.ts??0)*1e3);return o>0?{id:n.id,tsMs:o}:null}function B0(e,t,n){const r=U0(e),o=e?.entries;if(r===null||!o||o.length===0)return!1;const i=Math.round((o[o.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,c]of t)if(!n.has(a)&&(c===null||!(c>r.tsMs)||!(c<i)))return!1;return!0}const H0=new Set(["completed","done","failed","cancelled","interrupted"]);function W0(e,t){const n=new Set;for(const o of t)o.kind==="custom"&&o.jobId&&n.add(o.jobId);const r=[];for(const o of e){const i=o.id==null?"":String(o.id);!i||n.has(i)||H0.has(String(o.status??""))&&r.push(i)}return r}function G0(e,t,n,r){let o=t,i=!1;for(const a of e){const c=a.changes??{};Array.isArray(c.jobs)?o=c.jobs:a.job_deltas&&(o=gh(o,a.job_deltas));const l=c.history_cursor;typeof l=="string"&&l!==""&&!r(l)&&(i=!0)}return i?W0(o,n):[]}const dl=new Set,Dn="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",ul=new RegExp(`[${Dn}]`),z0=new RegExp(`[${Dn}]+`),vj=new RegExp(`[${Dn}]+`,"g"),K0=new RegExp(`^[${Dn}]+|[${Dn}]+$`,"g"),V0=new RegExp(`^[${Dn}]+`),yj=new RegExp(`[^${Dn}]`);function nn(e){return e.replace(K0,"")}function Wo(e){return e.replace(V0,"")}function Ih(e,t){return t===0||ul.test(e[t-1])}function Ah(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&Ih(e,n)&&t.push(n);return t}function fl(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
1
|
+
import{r as x,j as U_,b as Sd,D as B_,l as Vc,m as Ep,n as Zc,o as H_}from"./index-CxNjWpOb.js";import{c as sn,t as g,a as W_}from"./messages-B7aIuFuF.js";import{P as G_,i as Yc,a as Xc,p as Ip}from"./roles-D1pcbxAx.js";const Ed=new Map,Id=new Map,Ad=new Map,Rd=new Map;function Jc(e){return e===void 0?"":JSON.stringify(e)}function Qc(e,t){const n=`${e}\0${Jc(t)}`;let r=Ed.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),Ed.set(n,r)),r}function z_(e,t){const n=`${e}\0${Jc(t)}`;let r=Id.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Id.set(n,r)),r}function pM(e,t,n){return Qc(n??sn(),t).format(e)}const hM={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};function mM(e,t,n){return Qc(n??sn(),t).format(e)}function K_(e,t,n){return Qc(n??sn(),t).format(e)}function V_(e,t,n){return z_(n??sn(),t).format(e)}function gM(e,t,n,r){const o=r??sn(),i=`${o}\0${Jc(n)}`;let a=Ad.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(o,n),Ad.set(i,a)),a.format(e,t)}const Z_={B:"byte",KB:"kilobyte",MB:"megabyte",GB:"gigabyte",TB:"terabyte",PB:"petabyte"},xd=new Map,Td=new Map;function Y_(e){return e.split("-")[0]?.toLowerCase()==="en"}function X_(e,t){if(e==="KiB"||e==="MiB"||e==="GiB"||Y_(t))return e;const n=`${t}\0${e}`;let r=xd.get(n);if(r===void 0){r=e;try{r=new Intl.NumberFormat(t,{style:"unit",unit:Z_[e],unitDisplay:"narrow"}).formatToParts(1).find(i=>i.type==="unit")?.value??e}catch{}xd.set(n,r)}return r}function J_(e){let t=Td.get(e);if(t===void 0){t=" ";try{t=new Intl.NumberFormat(e,{style:"unit",unit:"kilobyte",unitDisplay:"short"}).formatToParts(1).find(r=>r.type==="literal")?.value??" "}catch{}Td.set(e,t)}return t}function wo(e,t,n,r){const o=sn();return`${V_(e,{useGrouping:!1,...n},o)}${J_(o)}${X_(t,o)}`}function Ni(e,t){const n=sn();let r=Rd.get(n);return r===void 0&&(r=new Intl.ListFormat(n,{type:"conjunction",style:"narrow"}),Rd.set(n,r)),r.format(e)}const Q_={zh:";",ja:";",ur:"؛ ",ar:"؛ "};function _M(e,t){const n=sn().split("-")[0]?.toLowerCase();return e.join(Q_[n??""]??"; ")}var ni=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ir=typeof window>"u"||"Deno"in globalThis;function Tt(){}function q_(e,t){return typeof e=="function"?e(t):e}function Fa(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ap(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Pr(e,t){return typeof e=="function"?e(t):e}function Ht(e,t){return typeof e=="function"?e(t):e}function Cd(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:a,stale:c}=e;if(a){if(r){if(t.queryHash!==qc(a,t.options))return!1}else if(!xo(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||i&&!i(t))}function Od(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ro(t.options.mutationKey)!==Ro(i))return!1}else if(!xo(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function qc(e,t){return(t?.queryKeyHashFn||Ro)(e)}function Ro(e){return JSON.stringify(e,(t,n)=>Ba(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function xo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>xo(e[n],t[n])):!1}function Rp(e,t){if(e===t)return e;const n=Pd(e)&&Pd(t);if(n||Ba(e)&&Ba(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),a=i.length,c=n?[]:{};let l=0;for(let d=0;d<a;d++){const u=n?d:i[d];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(c[u]=void 0,l++):(c[u]=Rp(e[u],t[u]),c[u]===e[u]&&e[u]!==void 0&&l++)}return o===a&&l===o?e:c}return t}function Ua(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Pd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ba(e){if(!Md(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Md(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Md(e){return Object.prototype.toString.call(e)==="[object Object]"}function eb(e){return new Promise(t=>{setTimeout(t,e)})}function Ha(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Rp(e,t):t}function tb(e){return e}function nb(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function rb(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var el=Symbol();function xp(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===el?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ob=class extends ni{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!ir&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},tl=new ob,ib=class extends ni{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!ir&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},Vi=new ib;function Wa(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function sb(e){return Math.min(1e3*2**e,3e4)}function Tp(e){return(e??"online")==="online"?Vi.isOnline():!0}var Cp=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Zs(e){return e instanceof Cp}function Op(e){let t=!1,n=0,r=!1,o;const i=Wa(),a=v=>{r||(h(new Cp(v)),e.abort?.())},c=()=>{t=!0},l=()=>{t=!1},d=()=>tl.isFocused()&&(e.networkMode==="always"||Vi.isOnline())&&e.canRun(),u=()=>Tp(e.networkMode)&&e.canRun(),f=v=>{r||(r=!0,e.onSuccess?.(v),o?.(),i.resolve(v))},h=v=>{r||(r=!0,e.onError?.(v),o?.(),i.reject(v))},_=()=>new Promise(v=>{o=b=>{(r||d())&&v(b)},e.onPause?.()}).then(()=>{o=void 0,r||e.onContinue?.()}),y=()=>{if(r)return;let v;const b=n===0?e.initialPromise:void 0;try{v=b??e.fn()}catch(p){v=Promise.reject(p)}Promise.resolve(v).then(f).catch(p=>{if(r)return;const A=e.retry??(ir?0:3),k=e.retryDelay??sb,M=typeof k=="function"?k(n,p):k,P=A===!0||typeof A=="number"&&n<A||typeof A=="function"&&A(n,p);if(t||!P){h(p);return}n++,e.onFail?.(n,p),eb(M).then(()=>d()?void 0:_()).then(()=>{t?h(p):y()})})};return{promise:i,cancel:a,continue:()=>(o?.(),i),cancelRetry:c,continueRetry:l,canStart:u,start:()=>(u()?y():_().then(y),i)}}var ab=e=>setTimeout(e,0);function cb(){let e=[],t=0,n=c=>{c()},r=c=>{c()},o=ab;const i=c=>{t?e.push(c):o(()=>{n(c)})},a=()=>{const c=e;e=[],c.length&&o(()=>{r(()=>{c.forEach(l=>{n(l)})})})};return{batch:c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},batchCalls:c=>(...l)=>{i(()=>{c(...l)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{o=c}}}var ot=cb(),Pp=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fa(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ir?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},lb=class extends Pp{#t;#e;#n;#r;#o;#a;#s;constructor(e){super(),this.#s=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=db(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#o?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=Ha(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#o?.promise;return this.#o?.cancel(e),t?t.then(Tt).catch(Tt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Ht(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===el||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Ap(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#o?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#o?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#o&&(this.#s?this.#o.cancel({revert:!0}):this.#o.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#o)return this.#o.continueRetry(),this.#o.promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,r=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},o=()=>{const c=xp(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#s=!1,this.options.persister?this.options.persister(c,l,this):c(l)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:o};r(i),this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#i({type:"fetch",meta:i.fetchOptions?.meta});const a=c=>{Zs(c)&&c.silent||this.#i({type:"error",error:c}),Zs(c)||(this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this)),this.scheduleGc()};return this.#o=Op({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:c=>{if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(l){a(l);return}this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,l)=>{this.#i({type:"failed",failureCount:c,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#o.start()}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Mp(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return Zs(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),ot.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function Mp(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Tp(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function db(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var ub=class extends ni{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,o=t.queryHash??qc(r,t);let i=this.get(o);return i||(i=new lb({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ot.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Cd(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Cd(e,n)):t}notify(e){ot.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ot.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ot.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},fb=class extends Pp{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||pb(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=Op({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,o)=>{this.#r({type:"failed",failureCount:r,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const o=await this.options.onMutate?.(e);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ot.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function pb(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var hb=class extends ni{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new fb({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=pi(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=pi(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=pi(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(o=>o.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=pi(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ot.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Od(t,n))}findAll(e={}){return this.getAll().filter(t=>Od(e,t))}notify(e){ot.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ot.batch(()=>Promise.all(e.map(t=>t.continue().catch(Tt))))}};function pi(e){return e.options.scope?.id}function jd(e){return{onFetch:(t,n)=>{const r=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const f=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},h=xp(t.options,t.fetchOptions),_=async(y,v,b)=>{if(u)return Promise.reject();if(v==null&&y.pages.length)return Promise.resolve(y);const p={client:t.client,queryKey:t.queryKey,pageParam:v,direction:b?"backward":"forward",meta:t.options.meta};f(p);const A=await h(p),{maxPages:k}=t.options,M=b?rb:nb;return{pages:M(y.pages,A,k),pageParams:M(y.pageParams,v,k)}};if(o&&i.length){const y=o==="backward",v=y?jp:Ga,b={pages:i,pageParams:a},p=v(r,b);c=await _(b,p,y)}else{const y=e??i.length;do{const v=l===0?a[0]??r.initialPageParam:Ga(r,c);if(l>0&&v==null)break;c=await _(c,v),l++}while(l<y)}return c};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function Ga(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function jp(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function bM(e,t){return t?Ga(e,t)!=null:!1}function vM(e,t){return!t||!e.getPreviousPageParam?!1:jp(e,t)!=null}var mb=class{#t;#e;#n;#r;#o;#a;#s;#i;constructor(e={}){this.#t=e.queryCache||new ub,this.#e=e.mutationCache||new hb,this.#n=e.defaultOptions||{},this.#r=new Map,this.#o=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#s=tl.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=Vi.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#s?.(),this.#s=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Pr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#t.get(r.queryHash)?.state.data,a=q_(t,i);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ot.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;ot.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return ot.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ot.batch(()=>this.#t.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Tt).catch(Tt)}invalidateQueries(e,t={}){return ot.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ot.batch(()=>this.#t.findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Tt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Tt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(Pr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Tt).catch(Tt)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Tt).catch(Tt)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Vi.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Ro(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{xo(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#o.set(Ro(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(r=>{xo(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=qc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===el&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},gb=class extends ni{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#s=Wa(),this.options.experimental_prefetchInRender||this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#o;#a;#s;#i;#m;#f;#p;#l;#d;#c;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),$d(this.#e,this.options)?this.#u():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return za(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return za(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ht(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#k(),this.#e.setOptions(this.options),t._defaulted&&!Ua(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Dd(this.#e,n,this.options,t)&&this.#u(),this.updateResult(),r&&(this.#e!==n||Ht(this.options.enabled,this.#e)!==Ht(t.enabled,this.#e)||Pr(this.options.staleTime,this.#e)!==Pr(t.staleTime,this.#e))&&this.#g();const o=this.#_();r&&(this.#e!==n||Ht(this.options.enabled,this.#e)!==Ht(t.enabled,this.#e)||o!==this.#c)&&this.#b(o)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return bb(this,n)&&(this.#r=n,this.#a=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#u(e){this.#k();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Tt)),t}#g(){this.#y();const e=Pr(this.options.staleTime,this.#e);if(ir||this.#r.isStale||!Fa(e))return;const n=Ap(this.#r.dataUpdatedAt,e)+1;this.#l=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#c=e,!(ir||Ht(this.options.enabled,this.#e)===!1||!Fa(this.#c)||this.#c===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||tl.isFocused())&&this.#u()},this.#c))}#v(){this.#g(),this.#b(this.#_())}#y(){this.#l&&(clearTimeout(this.#l),this.#l=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,t){const n=this.#e,r=this.options,o=this.#r,i=this.#o,a=this.#a,l=e!==n?e.state:this.#n,{state:d}=e;let u={...d},f=!1,h;if(t._optimisticResults){const m=this.hasListeners(),w=!m&&$d(e,t),S=m&&Dd(e,n,t,r);(w||S)&&(u={...u,...Mp(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:_,errorUpdatedAt:y,status:v}=u;h=u.data;let b=!1;if(t.placeholderData!==void 0&&h===void 0&&v==="pending"){let m;o?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(m=o.data,b=!0):m=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,m!==void 0&&(v="success",h=Ha(o?.data,m,t),f=!0)}if(t.select&&h!==void 0&&!b)if(o&&h===i?.data&&t.select===this.#m)h=this.#f;else try{this.#m=t.select,h=t.select(h),h=Ha(o?.data,h,t),this.#f=h,this.#i=null}catch(m){this.#i=m}this.#i&&(_=this.#i,h=this.#f,y=Date.now(),v="error");const p=u.fetchStatus==="fetching",A=v==="pending",k=v==="error",M=A&&p,P=h!==void 0,R={status:v,fetchStatus:u.fetchStatus,isPending:A,isSuccess:v==="success",isError:k,isInitialLoading:M,isLoading:M,data:h,dataUpdatedAt:u.dataUpdatedAt,error:_,errorUpdatedAt:y,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:p,isRefetching:p&&!A,isLoadingError:k&&!P,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:k&&P,isStale:nl(e,t),refetch:this.refetch,promise:this.#s};if(this.options.experimental_prefetchInRender){const m=T=>{R.status==="error"?T.reject(R.error):R.data!==void 0&&T.resolve(R.data)},w=()=>{const T=this.#s=R.promise=Wa();m(T)},S=this.#s;switch(S.status){case"pending":e.queryHash===n.queryHash&&m(S);break;case"fulfilled":(R.status==="error"||R.data!==S.value)&&w();break;case"rejected":(R.status!=="error"||R.error!==S.reason)&&w();break}}return R}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#a=this.options,this.#o.data!==void 0&&(this.#p=this.#e),Ua(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,o=typeof r=="function"?r():r;if(o==="all"||!o&&!this.#h.size)return!0;const i=new Set(o??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const c=a;return this.#r[c]!==e[c]&&i.has(c)})};this.#S({listeners:n()})}#k(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#S(e){ot.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function _b(e,t){return Ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function $d(e,t){return _b(e,t)||e.state.data!==void 0&&za(e,t,t.refetchOnMount)}function za(e,t,n){if(Ht(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&nl(e,t)}return!1}function Dd(e,t,n,r){return(e!==t||Ht(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&nl(e,n)}function nl(e,t){return Ht(t.enabled,e)!==!1&&e.isStaleByTime(Pr(t.staleTime,e))}function bb(e,t){return!Ua(e.getCurrentResult(),t)}var rl=x.createContext(void 0),vb=e=>{const t=x.useContext(rl);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},yM=({client:e,children:t})=>(x.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),U_.jsx(rl.Provider,{value:e,children:t})),$p=x.createContext(!1),yb=()=>x.useContext($p);$p.Provider;function wb(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kb=x.createContext(wb()),Sb=()=>x.useContext(kb);function Eb(e,t){return typeof e=="function"?e(...t):!!e}function Nd(){}var Ib=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ab=e=>{x.useEffect(()=>{e.clearReset()},[e])},Rb=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Eb(n,[e.error,r])),xb=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Tb=(e,t)=>e.isLoading&&e.isFetching&&!t,Cb=(e,t)=>e?.suspense&&t.isPending,Ld=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ob(e,t,n){const r=vb(n),o=yb(),i=Sb(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=o?"isRestoring":"optimistic",xb(a),Ib(a,i),Ab(i);const c=!r.getQueryCache().get(a.queryHash),[l]=x.useState(()=>new t(r,a)),d=l.getOptimisticResult(a),u=!o&&e.subscribed!==!1;if(x.useSyncExternalStore(x.useCallback(f=>{const h=u?l.subscribe(ot.batchCalls(f)):Nd;return l.updateResult(),h},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),x.useEffect(()=>{l.setOptions(a)},[a,l]),Cb(a,d))throw Ld(a,l,i);if(Rb({result:d,errorResetBoundary:i,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw d.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!ir&&Tb(d,o)&&(c?Ld(a,l,i):r.getQueryCache().get(a.queryHash)?.promise)?.catch(Nd).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?d:l.trackResult(d)}function Dp(e,t){return Ob(e,gb,t)}const Pb=()=>{const e=x.useContext(rl)??null,t=x.useMemo(()=>new mb({defaultOptions:{queries:{enabled:!1,retry:!1,gcTime:0}}}),[]);return x.useEffect(()=>{if(!e)return()=>t.clear()},[e,t]),x.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])};function wM(e){return e!=="detached"&&e!=="wedged"}function Np(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function kM(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=Np(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}var ve;(function(e){e.assertEqual=o=>o;function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{const i={};for(const a of o)i[a]=a;return i},e.getValidEnumValues=o=>{const i=e.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),a={};for(const c of i)a[c]=o[c];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const i=[];for(const a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(const a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(ve||(ve={}));var Ka;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ka||(Ka={}));const B=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),un=e=>{switch(typeof e){case"undefined":return B.undefined;case"string":return B.string;case"number":return isNaN(e)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(e)?B.array:e===null?B.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?B.promise:typeof Map<"u"&&e instanceof Map?B.map:typeof Set<"u"&&e instanceof Set?B.set:typeof Date<"u"&&e instanceof Date?B.date:B.object;default:return B.unknown}},j=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Mb=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class kt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},o=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){const d=a.path[l];l===a.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(a))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return o(this),r}static assert(t){if(!(t instanceof kt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const o of this.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}kt.create=e=>new kt(e);const Br=(e,t)=>{let n;switch(e.code){case j.invalid_type:e.received===B.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case j.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ve.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:n=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case j.invalid_union:n="Invalid input";break;case j.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case j.invalid_enum_value:n=`Invalid enum value. Expected ${ve.joinValues(e.options)}, received '${e.received}'`;break;case j.invalid_arguments:n="Invalid function arguments";break;case j.invalid_return_type:n="Invalid function return type";break;case j.invalid_date:n="Invalid date";break;case j.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ve.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case j.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case j.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case j.custom:n="Invalid input";break;case j.invalid_intersection_types:n="Intersection results could not be merged";break;case j.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case j.not_finite:n="Number must be finite";break;default:n=t.defaultError,ve.assertNever(e)}return{message:n}};let Lp=Br;function jb(e){Lp=e}function Zi(){return Lp}const Yi=e=>{const{data:t,path:n,errorMaps:r,issueData:o}=e,i=[...n,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let c="";const l=r.filter(d=>!!d).slice().reverse();for(const d of l)c=d(a,{data:t,defaultError:c}).message;return{...o,path:i,message:c}},$b=[];function L(e,t){const n=Zi(),r=Yi({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Br?void 0:Br].filter(o=>!!o)});e.common.issues.push(r)}class ut{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const o of n){if(o.status==="aborted")return ee;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const o of n){const i=await o.key,a=await o.value;r.push({key:i,value:a})}return ut.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const o of n){const{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return ee;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const ee=Object.freeze({status:"aborted"}),Rr=e=>({status:"dirty",value:e}),ft=e=>({status:"valid",value:e}),Va=e=>e.status==="aborted",Za=e=>e.status==="dirty",sr=e=>e.status==="valid",To=e=>typeof Promise<"u"&&e instanceof Promise;function Xi(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function Fp(e,t,n,r,o){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var K;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(K||(K={}));var ho,mo;class rn{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Fd=(e,t)=>{if(sr(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new kt(e.common.issues);return this._error=n,this._error}}};function ce(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,c)=>{var l,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:c.defaultError}},description:o}}class ue{get description(){return this._def.description}_getType(t){return un(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:un(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ut,ctx:{common:t.parent.common,data:t.data,parsedType:un(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(To(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const o={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)},i=this._parseSync({data:t,path:o.path,parent:o});return Fd(o,i)}"~validate"(t){var n,r;const o={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:o});return sr(i)?{value:i.value}:{issues:o.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),o.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:o}).then(i=>sr(i)?{value:i.value}:{issues:o.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:un(t)},o=this._parse({data:t,path:r.path,parent:r}),i=await(To(o)?o:Promise.resolve(o));return Fd(r,i)}refine(t,n){const r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{const a=t(o),c=()=>i.addIssue({code:j.custom,...r(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Vt({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return tn.create(this,this._def)}nullable(){return $n.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return zt.create(this)}promise(){return Wr.create(this,this._def)}or(t){return Mo.create([this,t],this._def)}and(t){return jo.create(this,t,this._def)}transform(t){return new Vt({...ce(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Fo({...ce(this._def),innerType:this,defaultValue:n,typeName:q.ZodDefault})}brand(){return new ol({typeName:q.ZodBranded,type:this,...ce(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Uo({...ce(this._def),innerType:this,catchValue:n,typeName:q.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return ri.create(this,t)}readonly(){return Bo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Db=/^c[^\s-]{8,}$/i,Nb=/^[0-9a-z]+$/,Lb=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fb=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ub=/^[a-z0-9_-]{21}$/i,Bb=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Wb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ys;const zb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Kb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Vb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Zb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Up="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Jb=new RegExp(`^${Up}$`);function Bp(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Qb(e){return new RegExp(`^${Bp(e)}$`)}function Hp(e){let t=`${Up}T${Bp(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function qb(e,t){return!!((t==="v4"||!t)&&zb.test(e)||(t==="v6"||!t)&&Vb.test(e))}function ev(e,t){if(!Bb.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||!o.typ||!o.alg||t&&o.alg!==t)}catch{return!1}}function tv(e,t){return!!((t==="v4"||!t)&&Kb.test(e)||(t==="v6"||!t)&&Zb.test(e))}class Gt extends ue{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==B.string){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.string,received:i.parsedType}),ee}const r=new ut;let o;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,c=t.data.length<i.value;(a||c)&&(o=this._getOrReturnCtx(t,o),a?L(o,{code:j.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&L(o,{code:j.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Wb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"email",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ys||(Ys=new RegExp(Gb,"u")),Ys.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"emoji",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Fb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"uuid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ub.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"nanoid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Db.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Nb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid2",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Lb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ulid",code:j.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),L(o,{validation:"url",code:j.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"regex",code:j.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Hp(i).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Jb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Qb(i).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:j.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Hb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"duration",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?qb(t.data,i.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ip",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?ev(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"jwt",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?tv(t.data,i.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cidr",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Yb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64",code:j.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Xb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64url",code:j.invalid_string,message:i.message}),r.dirty()):ve.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:j.invalid_string,...K.errToObj(r)})}_addCheck(t){return new Gt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...K.errToObj(t)})}url(t){return this._addCheck({kind:"url",...K.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...K.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...K.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...K.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...K.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...K.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...K.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...K.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...K.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...K.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...K.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...K.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...K.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...K.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...K.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...K.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...K.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...K.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...K.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...K.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...K.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...K.errToObj(n)})}nonempty(t){return this.min(1,K.errToObj(t))}trim(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Gt.create=e=>{var t;return new Gt({checks:[],typeName:q.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...ce(e)})};function nv(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,i=parseInt(e.toFixed(o).replace(".","")),a=parseInt(t.toFixed(o).replace(".",""));return i%a/Math.pow(10,o)}class Pn extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==B.number){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.number,received:i.parsedType}),ee}let r;const o=new ut;for(const i of this._def.checks)i.kind==="int"?ve.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),L(r,{code:j.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?nv(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_finite,message:i.message}),o.dirty()):ve.assertNever(i);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,K.toString(n))}gt(t,n){return this.setLimit("min",t,!1,K.toString(n))}lte(t,n){return this.setLimit("max",t,!0,K.toString(n))}lt(t,n){return this.setLimit("max",t,!1,K.toString(n))}setLimit(t,n,r,o){return new Pn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(o)}]})}_addCheck(t){return new Pn({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:K.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:K.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ve.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Pn.create=e=>new Pn({checks:[],typeName:q.ZodNumber,coerce:e?.coerce||!1,...ce(e)});class Mn extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==B.bigint)return this._getInvalidInput(t);let r;const o=new ut;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),L(r,{code:j.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):ve.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return L(n,{code:j.invalid_type,expected:B.bigint,received:n.parsedType}),ee}gte(t,n){return this.setLimit("min",t,!0,K.toString(n))}gt(t,n){return this.setLimit("min",t,!1,K.toString(n))}lte(t,n){return this.setLimit("max",t,!0,K.toString(n))}lt(t,n){return this.setLimit("max",t,!1,K.toString(n))}setLimit(t,n,r,o){return new Mn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(o)}]})}_addCheck(t){return new Mn({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Mn.create=e=>{var t;return new Mn({checks:[],typeName:q.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...ce(e)})};class Co extends ue{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==B.boolean){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.boolean,received:r.parsedType}),ee}return ft(t.data)}}Co.create=e=>new Co({typeName:q.ZodBoolean,coerce:e?.coerce||!1,...ce(e)});class ar extends ue{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==B.date){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_type,expected:B.date,received:i.parsedType}),ee}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return L(i,{code:j.invalid_date}),ee}const r=new ut;let o;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:j.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):ve.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ar({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:K.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:K.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}ar.create=e=>new ar({checks:[],coerce:e?.coerce||!1,typeName:q.ZodDate,...ce(e)});class Ji extends ue{_parse(t){if(this._getType(t)!==B.symbol){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.symbol,received:r.parsedType}),ee}return ft(t.data)}}Ji.create=e=>new Ji({typeName:q.ZodSymbol,...ce(e)});class Oo extends ue{_parse(t){if(this._getType(t)!==B.undefined){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.undefined,received:r.parsedType}),ee}return ft(t.data)}}Oo.create=e=>new Oo({typeName:q.ZodUndefined,...ce(e)});class Po extends ue{_parse(t){if(this._getType(t)!==B.null){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.null,received:r.parsedType}),ee}return ft(t.data)}}Po.create=e=>new Po({typeName:q.ZodNull,...ce(e)});class Hr extends ue{constructor(){super(...arguments),this._any=!0}_parse(t){return ft(t.data)}}Hr.create=e=>new Hr({typeName:q.ZodAny,...ce(e)});class Jn extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ft(t.data)}}Jn.create=e=>new Jn({typeName:q.ZodUnknown,...ce(e)});class gn extends ue{_parse(t){const n=this._getOrReturnCtx(t);return L(n,{code:j.invalid_type,expected:B.never,received:n.parsedType}),ee}}gn.create=e=>new gn({typeName:q.ZodNever,...ce(e)});class Qi extends ue{_parse(t){if(this._getType(t)!==B.undefined){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.void,received:r.parsedType}),ee}return ft(t.data)}}Qi.create=e=>new Qi({typeName:q.ZodVoid,...ce(e)});class zt extends ue{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==B.array)return L(n,{code:j.invalid_type,expected:B.array,received:n.parsedType}),ee;if(o.exactLength!==null){const a=n.data.length>o.exactLength.value,c=n.data.length<o.exactLength.value;(a||c)&&(L(n,{code:a?j.too_big:j.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(L(n,{code:j.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(L(n,{code:j.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>o.type._parseAsync(new rn(n,a,n.path,c)))).then(a=>ut.mergeArray(r,a));const i=[...n.data].map((a,c)=>o.type._parseSync(new rn(n,a,n.path,c)));return ut.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new zt({...this._def,minLength:{value:t,message:K.toString(n)}})}max(t,n){return new zt({...this._def,maxLength:{value:t,message:K.toString(n)}})}length(t,n){return new zt({...this._def,exactLength:{value:t,message:K.toString(n)}})}nonempty(t){return this.min(1,t)}}zt.create=(e,t)=>new zt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...ce(t)});function wr(e){if(e instanceof He){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=tn.create(wr(r))}return new He({...e._def,shape:()=>t})}else return e instanceof zt?new zt({...e._def,type:wr(e.element)}):e instanceof tn?tn.create(wr(e.unwrap())):e instanceof $n?$n.create(wr(e.unwrap())):e instanceof on?on.create(e.items.map(t=>wr(t))):e}class He extends ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ve.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==B.object){const d=this._getOrReturnCtx(t);return L(d,{code:j.invalid_type,expected:B.object,received:d.parsedType}),ee}const{status:r,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof gn&&this._def.unknownKeys==="strip"))for(const d in o.data)a.includes(d)||c.push(d);const l=[];for(const d of a){const u=i[d],f=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new rn(o,f,o.path,d)),alwaysSet:d in o.data})}if(this._def.catchall instanceof gn){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of c)l.push({key:{status:"valid",value:u},value:{status:"valid",value:o.data[u]}});else if(d==="strict")c.length>0&&(L(o,{code:j.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of c){const f=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new rn(o,f,o.path,u)),alwaysSet:u in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of l){const f=await u.key,h=await u.value;d.push({key:f,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>ut.mergeObjectSync(r,d)):ut.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return K.errToObj,new He({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var o,i,a,c;const l=(a=(i=(o=this._def).errorMap)===null||i===void 0?void 0:i.call(o,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(c=K.errToObj(t).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new He({...this._def,unknownKeys:"strip"})}passthrough(){return new He({...this._def,unknownKeys:"passthrough"})}extend(t){return new He({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new He({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:q.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new He({...this._def,catchall:t})}pick(t){const n={};return ve.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new He({...this._def,shape:()=>n})}omit(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new He({...this._def,shape:()=>n})}deepPartial(){return wr(this)}partial(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{const o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}),new He({...this._def,shape:()=>n})}required(t){const n={};return ve.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof tn;)i=i._def.innerType;n[r]=i}}),new He({...this._def,shape:()=>n})}keyof(){return Wp(ve.objectKeys(this.shape))}}He.create=(e,t)=>new He({shape:()=>e,unknownKeys:"strip",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});He.strictCreate=(e,t)=>new He({shape:()=>e,unknownKeys:"strict",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});He.lazycreate=(e,t)=>new He({shape:e,unknownKeys:"strip",catchall:gn.create(),typeName:q.ZodObject,...ce(t)});class Mo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function o(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;const a=i.map(c=>new kt(c.ctx.common.issues));return L(n,{code:j.invalid_union,unionErrors:a}),ee}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(o);{let i;const a=[];for(const l of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(l=>new kt(l));return L(n,{code:j.invalid_union,unionErrors:c}),ee}}get options(){return this._def.options}}Mo.create=(e,t)=>new Mo({options:e,typeName:q.ZodUnion,...ce(t)});const cn=e=>e instanceof Do?cn(e.schema):e instanceof Vt?cn(e.innerType()):e instanceof No?[e.value]:e instanceof jn?e.options:e instanceof Lo?ve.objectValues(e.enum):e instanceof Fo?cn(e._def.innerType):e instanceof Oo?[void 0]:e instanceof Po?[null]:e instanceof tn?[void 0,...cn(e.unwrap())]:e instanceof $n?[null,...cn(e.unwrap())]:e instanceof ol||e instanceof Bo?cn(e.unwrap()):e instanceof Uo?cn(e._def.innerType):[];class ws extends ue{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.object)return L(n,{code:j.invalid_type,expected:B.object,received:n.parsedType}),ee;const r=this.discriminator,o=n.data[r],i=this.optionsMap.get(o);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(L(n,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const o=new Map;for(const i of n){const a=cn(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of a){if(o.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);o.set(c,i)}}return new ws({typeName:q.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:o,...ce(r)})}}function Ya(e,t){const n=un(e),r=un(t);if(e===t)return{valid:!0,data:e};if(n===B.object&&r===B.object){const o=ve.objectKeys(t),i=ve.objectKeys(e).filter(c=>o.indexOf(c)!==-1),a={...e,...t};for(const c of i){const l=Ya(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===B.array&&r===B.array){if(e.length!==t.length)return{valid:!1};const o=[];for(let i=0;i<e.length;i++){const a=e[i],c=t[i],l=Ya(a,c);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===B.date&&r===B.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class jo extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=(i,a)=>{if(Va(i)||Va(a))return ee;const c=Ya(i.value,a.value);return c.valid?((Za(i)||Za(a))&&n.dirty(),{status:n.value,value:c.data}):(L(r,{code:j.invalid_intersection_types}),ee)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}jo.create=(e,t,n)=>new jo({left:e,right:t,typeName:q.ZodIntersection,...ce(n)});class on extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.array)return L(r,{code:j.invalid_type,expected:B.array,received:r.parsedType}),ee;if(r.data.length<this._def.items.length)return L(r,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&r.data.length>this._def.items.length&&(L(r,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new rn(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>ut.mergeArray(n,a)):ut.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new on({...this._def,rest:t})}}on.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new on({items:e,typeName:q.ZodTuple,rest:null,...ce(t)})};class $o extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.object)return L(r,{code:j.invalid_type,expected:B.object,received:r.parsedType}),ee;const o=[],i=this._def.keyType,a=this._def.valueType;for(const c in r.data)o.push({key:i._parse(new rn(r,c,r.path,c)),value:a._parse(new rn(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?ut.mergeObjectAsync(n,o):ut.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ue?new $o({keyType:t,valueType:n,typeName:q.ZodRecord,...ce(r)}):new $o({keyType:Gt.create(),valueType:t,typeName:q.ZodRecord,...ce(n)})}}class qi extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.map)return L(r,{code:j.invalid_type,expected:B.map,received:r.parsedType}),ee;const o=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],d)=>({key:o._parse(new rn(r,c,r.path,[d,"key"])),value:i._parse(new rn(r,l,r.path,[d,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of a){const d=await l.key,u=await l.value;if(d.status==="aborted"||u.status==="aborted")return ee;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}})}else{const c=new Map;for(const l of a){const d=l.key,u=l.value;if(d.status==="aborted"||u.status==="aborted")return ee;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}}}}qi.create=(e,t,n)=>new qi({valueType:t,keyType:e,typeName:q.ZodMap,...ce(n)});class cr extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==B.set)return L(r,{code:j.invalid_type,expected:B.set,received:r.parsedType}),ee;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(L(r,{code:j.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(L(r,{code:j.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const d=new Set;for(const u of l){if(u.status==="aborted")return ee;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const c=[...r.data.values()].map((l,d)=>i._parse(new rn(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,n){return new cr({...this._def,minSize:{value:t,message:K.toString(n)}})}max(t,n){return new cr({...this._def,maxSize:{value:t,message:K.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}cr.create=(e,t)=>new cr({valueType:e,minSize:null,maxSize:null,typeName:q.ZodSet,...ce(t)});class Mr extends ue{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.function)return L(n,{code:j.invalid_type,expected:B.function,received:n.parsedType}),ee;function r(c,l){return Yi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Zi(),Br].filter(d=>!!d),issueData:{code:j.invalid_arguments,argumentsError:l}})}function o(c,l){return Yi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Zi(),Br].filter(d=>!!d),issueData:{code:j.invalid_return_type,returnTypeError:l}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Wr){const c=this;return ft(async function(...l){const d=new kt([]),u=await c._def.args.parseAsync(l,i).catch(_=>{throw d.addIssue(r(l,_)),d}),f=await Reflect.apply(a,this,u);return await c._def.returns._def.type.parseAsync(f,i).catch(_=>{throw d.addIssue(o(f,_)),d})})}else{const c=this;return ft(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new kt([r(l,d.error)]);const u=Reflect.apply(a,this,d.data),f=c._def.returns.safeParse(u,i);if(!f.success)throw new kt([o(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Mr({...this._def,args:on.create(t).rest(Jn.create())})}returns(t){return new Mr({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Mr({args:t||on.create([]).rest(Jn.create()),returns:n||Jn.create(),typeName:q.ZodFunction,...ce(r)})}}class Do extends ue{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Do.create=(e,t)=>new Do({getter:e,typeName:q.ZodLazy,...ce(t)});class No extends ue{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return L(n,{received:n.data,code:j.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:t.data}}get value(){return this._def.value}}No.create=(e,t)=>new No({value:e,typeName:q.ZodLiteral,...ce(t)});function Wp(e,t){return new jn({values:e,typeName:q.ZodEnum,...ce(t)})}class jn extends ue{constructor(){super(...arguments),ho.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return L(n,{expected:ve.joinValues(r),received:n.parsedType,code:j.invalid_type}),ee}if(Xi(this,ho)||Fp(this,ho,new Set(this._def.values)),!Xi(this,ho).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return L(n,{received:n.data,code:j.invalid_enum_value,options:r}),ee}return ft(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return jn.create(t,{...this._def,...n})}exclude(t,n=this._def){return jn.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}ho=new WeakMap;jn.create=Wp;class Lo extends ue{constructor(){super(...arguments),mo.set(this,void 0)}_parse(t){const n=ve.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==B.string&&r.parsedType!==B.number){const o=ve.objectValues(n);return L(r,{expected:ve.joinValues(o),received:r.parsedType,code:j.invalid_type}),ee}if(Xi(this,mo)||Fp(this,mo,new Set(ve.getValidEnumValues(this._def.values))),!Xi(this,mo).has(t.data)){const o=ve.objectValues(n);return L(r,{received:r.data,code:j.invalid_enum_value,options:o}),ee}return ft(t.data)}get enum(){return this._def.values}}mo=new WeakMap;Lo.create=(e,t)=>new Lo({values:e,typeName:q.ZodNativeEnum,...ce(t)});class Wr extends ue{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==B.promise&&n.common.async===!1)return L(n,{code:j.invalid_type,expected:B.promise,received:n.parsedType}),ee;const r=n.parsedType===B.promise?n.data:Promise.resolve(n.data);return ft(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Wr.create=(e,t)=>new Wr({type:e,typeName:q.ZodPromise,...ce(t)});class Vt extends ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{L(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){const a=o.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return ee;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?ee:l.status==="dirty"||n.value==="dirty"?Rr(l.value):l});{if(n.value==="aborted")return ee;const c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?ee:c.status==="dirty"||n.value==="dirty"?Rr(c.value):c}}if(o.type==="refinement"){const a=c=>{const l=o.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?ee:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?ee:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(o.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!sr(a))return a;const c=o.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>sr(a)?Promise.resolve(o.transform(a.value,i)).then(c=>({status:n.value,value:c})):a);ve.assertNever(o)}}Vt.create=(e,t,n)=>new Vt({schema:e,typeName:q.ZodEffects,effect:t,...ce(n)});Vt.createWithPreprocess=(e,t,n)=>new Vt({schema:t,effect:{type:"preprocess",transform:e},typeName:q.ZodEffects,...ce(n)});class tn extends ue{_parse(t){return this._getType(t)===B.undefined?ft(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tn.create=(e,t)=>new tn({innerType:e,typeName:q.ZodOptional,...ce(t)});class $n extends ue{_parse(t){return this._getType(t)===B.null?ft(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}$n.create=(e,t)=>new $n({innerType:e,typeName:q.ZodNullable,...ce(t)});class Fo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===B.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Fo.create=(e,t)=>new Fo({innerType:e,typeName:q.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ce(t)});class Uo extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return To(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kt(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new kt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Uo.create=(e,t)=>new Uo({innerType:e,typeName:q.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ce(t)});class es extends ue{_parse(t){if(this._getType(t)!==B.nan){const r=this._getOrReturnCtx(t);return L(r,{code:j.invalid_type,expected:B.nan,received:r.parsedType}),ee}return{status:"valid",value:t.data}}}es.create=e=>new es({typeName:q.ZodNaN,...ce(e)});const rv=Symbol("zod_brand");class ol extends ue{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class ri extends ue{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ee:i.status==="dirty"?(n.dirty(),Rr(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?ee:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new ri({in:t,out:n,typeName:q.ZodPipeline})}}class Bo extends ue{_parse(t){const n=this._def.innerType._parse(t),r=o=>(sr(o)&&(o.value=Object.freeze(o.value)),o);return To(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}}Bo.create=(e,t)=>new Bo({innerType:e,typeName:q.ZodReadonly,...ce(t)});function Ud(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Gp(e,t={},n){return e?Hr.create().superRefine((r,o)=>{var i,a;const c=e(r);if(c instanceof Promise)return c.then(l=>{var d,u;if(!l){const f=Ud(t,r),h=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;o.addIssue({code:"custom",...f,fatal:h})}});if(!c){const l=Ud(t,r),d=(a=(i=l.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;o.addIssue({code:"custom",...l,fatal:d})}}):Hr.create()}const ov={object:He.lazycreate};var q;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(q||(q={}));const iv=(e,t={message:`Input not instance of ${e.name}`})=>Gp(n=>n instanceof e,t),zp=Gt.create,Kp=Pn.create,sv=es.create,av=Mn.create,Vp=Co.create,cv=ar.create,lv=Ji.create,dv=Oo.create,uv=Po.create,fv=Hr.create,pv=Jn.create,hv=gn.create,mv=Qi.create,gv=zt.create,_v=He.create,bv=He.strictCreate,vv=Mo.create,yv=ws.create,wv=jo.create,kv=on.create,Sv=$o.create,Ev=qi.create,Iv=cr.create,Av=Mr.create,Rv=Do.create,xv=No.create,Tv=jn.create,Cv=Lo.create,Ov=Wr.create,Bd=Vt.create,Pv=tn.create,Mv=$n.create,jv=Vt.createWithPreprocess,$v=ri.create,Dv=()=>zp().optional(),Nv=()=>Kp().optional(),Lv=()=>Vp().optional(),Fv={string:e=>Gt.create({...e,coerce:!0}),number:e=>Pn.create({...e,coerce:!0}),boolean:e=>Co.create({...e,coerce:!0}),bigint:e=>Mn.create({...e,coerce:!0}),date:e=>ar.create({...e,coerce:!0})},Uv=ee;var s=Object.freeze({__proto__:null,defaultErrorMap:Br,setErrorMap:jb,getErrorMap:Zi,makeIssue:Yi,EMPTY_PATH:$b,addIssueToContext:L,ParseStatus:ut,INVALID:ee,DIRTY:Rr,OK:ft,isAborted:Va,isDirty:Za,isValid:sr,isAsync:To,get util(){return ve},get objectUtil(){return Ka},ZodParsedType:B,getParsedType:un,ZodType:ue,datetimeRegex:Hp,ZodString:Gt,ZodNumber:Pn,ZodBigInt:Mn,ZodBoolean:Co,ZodDate:ar,ZodSymbol:Ji,ZodUndefined:Oo,ZodNull:Po,ZodAny:Hr,ZodUnknown:Jn,ZodNever:gn,ZodVoid:Qi,ZodArray:zt,ZodObject:He,ZodUnion:Mo,ZodDiscriminatedUnion:ws,ZodIntersection:jo,ZodTuple:on,ZodRecord:$o,ZodMap:qi,ZodSet:cr,ZodFunction:Mr,ZodLazy:Do,ZodLiteral:No,ZodEnum:jn,ZodNativeEnum:Lo,ZodPromise:Wr,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:tn,ZodNullable:$n,ZodDefault:Fo,ZodCatch:Uo,ZodNaN:es,BRAND:rv,ZodBranded:ol,ZodPipeline:ri,ZodReadonly:Bo,custom:Gp,Schema:ue,ZodSchema:ue,late:ov,get ZodFirstPartyTypeKind(){return q},coerce:Fv,any:fv,array:gv,bigint:av,boolean:Vp,date:cv,discriminatedUnion:yv,effect:Bd,enum:Tv,function:Av,instanceof:iv,intersection:wv,lazy:Rv,literal:xv,map:Ev,nan:sv,nativeEnum:Cv,never:hv,null:uv,nullable:Mv,number:Kp,object:_v,oboolean:Lv,onumber:Nv,optional:Pv,ostring:Dv,pipeline:$v,preprocess:jv,promise:Ov,record:Sv,set:Iv,strictObject:bv,string:zp,symbol:lv,transformer:Bd,tuple:kv,undefined:dv,union:vv,unknown:pv,void:mv,NEVER:Uv,ZodIssueCode:j,quotelessJson:Mb,ZodError:kt});const Hd=s.enum(["app_start","sign_in","window_focus","surface_open"]),Zp=s.object({id:s.string().min(1),state:s.enum(["active","paused","disabled"])}).passthrough(),Bv=s.object({tenant_id:s.string().min(1),tenant_name:s.string().optional(),eligible:s.boolean(),endpoint:Zp.nullable()}).passthrough(),Hv=s.object({code:s.string(),message:s.string(),details:s.record(s.unknown()).optional(),retry_after_seconds:s.number().optional()}).passthrough(),Wv=s.object({code:s.string().min(1),count:s.number().int().nonnegative(),session:s.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),Gv=s.object({in_force:s.boolean(),notice_pending:s.boolean().catch(!1)}).passthrough().optional().catch(void 0),SM=s.object({capability:s.number(),consent_account_guard:s.boolean().optional(),state:s.enum(["ready","signed_out","unavailable","update_required"]),account_id:s.string().nullable(),tenant_id:s.string().nullable(),surface_state:s.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:s.object({settings:s.boolean(),inbox:s.boolean(),account_door:s.boolean(),onboarding:s.boolean()}),update_required:s.boolean(),local:s.object({enabled:s.boolean(),onboarding:s.string(),session:s.string()}),status:s.object({tenants:s.array(Bv)}).passthrough().nullable(),consent:s.object({version:s.string().min(1).max(128),text:s.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:s.enum(["served","cached","embedded"])}).nullable(),error:Hv.nullable(),state_note:s.string().nullable().optional(),read_only:s.boolean().optional(),trial_ended:s.object({tenant_id:s.string().min(1),trial_ended_at:s.string().min(1)}).passthrough().nullable().optional().catch(null),delivery_hold:Wv,default_on:Gv}).passthrough(),zv=s.object({version:s.string().min(1),consented_at:s.string().min(1),consented_via:s.string().min(1),current:s.boolean()}).passthrough(),EM=s.object({endpoint:Zp.extend({tenant_id:s.string().min(1),label:s.string().optional(),consent:zv.nullable().optional(),created_at:s.string().optional(),updated_at:s.string().optional()}).nullable(),settings:s.object({tenant_id:s.string().min(1),eligible:s.boolean(),consent_version:s.string().optional(),consent_required:s.boolean()}).passthrough(),default_on:s.boolean().optional().catch(void 0),share_typing:s.boolean().optional().catch(void 0)}).passthrough(),Kv=s.object({kind:s.enum(["endpoint","account"]).optional(),endpoint_id:s.string().min(1).optional(),account_id:s.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),Wd=s.object({direction:s.enum(["send","receive"]),effect:s.enum(["allow","deny"]),target:Kv,id:s.string().optional()}).passthrough(),Gd=s.object({mode:s.enum(["class_default","listed_only"]),allow:s.number(),deny:s.number()}).passthrough(),IM=s.object({allowlist:s.object({tenant_id:s.string().min(1),entries:s.array(Wd)}).passthrough(),view:s.object({tenant_id:s.string().nullable(),entries:s.array(Wd),directions:s.object({send:Gd,receive:Gd}),class_default:s.literal("cos_cos"),cues:s.object({allow_entry_switches_direction_to_listed_only:s.boolean(),listed_only_affects:s.string(),removing_allow_does_not_stop_open_thread:s.boolean(),deny_stops_pair_both_directions:s.boolean()}).passthrough()}).passthrough()}).passthrough(),AM=s.object({onboarding:s.literal("seen")}).passthrough();function Vv(e){return e?.default_on?.in_force===!0}function RM(e,t){const n=Zv(e),r=t?.endpoint?.consent?.version;return n&&r&&n.version===r?n.text:null}function xM(e,t){return e?.surface_state==="C"&&t?.default_on===!0&&t.endpoint?.state==="active"&&e.default_on?.notice_pending===!0}function TM(e,t){if(!e||!t||Vv(e)||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function Zv(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const Yv=8,Xa=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh","notifications"],Ho=200,Xv=6*1024,Jv=512;function ts(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const o=[];for(const i of n){if(o.length===Jv)break;const c=new URLSearchParams({order_ids:i}).toString().length+1;if(r+c>Xv)break;e.append("order_ids",i),o.push(i),r+=c}return o}function Qv(e,t,n){return ts(new URLSearchParams(n),t,e)}const CM=3,qv=4096,OM=128,PM=/^[0-9a-f]{32}$/,ey=/^\.+$/,ty=new RegExp("\\p{Cf}","u"),ny=/[/\\:]/,I=s.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),zd=s.string().min(1).max(256).regex(/^[a-zA-Z0-9_-]+(?::[a-zA-Z0-9_-]+)?$/),ry=s.string().min(1).max(128),hi=s.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),mi=s.string().min(1).max(32768),Yp=/^[a-f0-9]{12}$/,F=s.string().regex(Yp),oy=["network-credentials"],iy=e=>Yp.test(e)||oy.includes(e),Ja=s.string().refine(iy,"not a notifications session id"),Xs=s.string().regex(/^[a-f0-9]{12}$/),Js=s.string().min(1).max(128),sy=s.string().min(1).max(4096),eo=s.string().min(1).max(128).regex(/^[A-Za-z0-9_.-]+$/),Qs=s.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),gi=s.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),Kd=s.string().regex(/^[a-f0-9]{32}$/),ay=/^(\/|[A-Za-z]:[\\/])/,qs=s.string().min(1).max(4096).regex(ay),Vd=/^[a-f0-9]{32}$/,de=s.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Zd=s.string().min(1).max(512).nullish(),gr=s.string().regex(/^[A-Za-z0-9_-]{1,128}$/),_r=s.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),cy=/^pp_[0-9a-f]{16}$/,ea=s.string().regex(cy),ly=["credential_finite_share","credential_inheritance"],xr=/^sha256:[0-9a-f]{64}$/,Yd={operation:s.enum(ly),requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr)},to=s.string().regex(/^la_[0-9a-f]{16}$/),no=s.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),Xd=s.object({data_b64:s.string().min(1).max(1e6),mime_type:s.enum(["image/png","image/jpeg","image/gif","image/webp"]),origin_path:s.string().max(4096).optional()}).strict(),dy=s.object({digest:s.string().regex(/^[0-9a-f]{32}$/),name:s.string().max(1024).optional(),mime_type:s.string().max(255).optional(),bytes:s.number().int().min(0).optional(),path:s.string().max(4096).optional()}).strict(),Jd=2e5,Qd=8,uy=256,fy=100,qd=16,py=256,hy=100,my=200,gy=1e6,_y=s.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),rt=s.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),_i=s.object({kind:s.enum(["agent","team"]),name:rt}).strict(),Xp=s.enum(["claude","codex","omp"]),by=s.record(s.string(),s.array(s.string().min(1).max(512)).max(5e3)),eu={sources:s.array(Xp).max(3).optional(),sessionIds:by.optional(),all:s.boolean().optional(),includeSubagents:s.boolean().optional(),includeClearedSegments:s.boolean().optional(),includeMemory:s.boolean().optional(),includeInstructions:s.boolean().optional(),maxSessions:s.number().int().min(1).max(5e3).optional()},ta=s.object({provider:s.string().min(1).max(128),model_id:s.string().min(1).max(512),reasoning_effort:s.string().min(1).max(64).nullable(),fast_mode:s.boolean().nullable().optional()}).strict(),tu=s.object({kind:s.enum(["role","specialist"]).optional(),description:s.string().max(8e3).optional(),instructions:s.string().max(8e3).optional(),tools:s.array(s.string().min(1).max(128)).max(256).optional(),effort:s.string().max(64).optional(),delegate:s.boolean().optional(),action_class:s.enum(["reactive","proactive"]).optional()}).strict(),nu=s.object({name:s.string().min(1).max(64).optional(),description:s.string().max(8e3).optional(),manager:rt.optional(),members:s.array(s.object({role:rt,count:s.number().int().min(1).max(16),kind:s.enum(["agent","team"]),tier:s.enum(["lo","med","hi"]).nullable().optional(),effort:_y.nullable().optional()}).strict()).max(128).optional(),instructions:s.string().max(8e3).optional(),project:s.string().max(8e3).optional()}).strict(),vy=s.record(s.array(s.string().max(1024)).max(100)),na=s.array(I).max(4).refine(e=>new Set(e).size===e.length,"Duplicate attachment"),yy=s.array(s.object({kind:s.enum(["human","agent"]),account_id:I,endpoint_id:I.optional()}).strict()).max(50).refine(e=>new Set(e.map(t=>`${t.kind}:${t.account_id}:${t.endpoint_id??""}`)).size===e.length,"Duplicate mention"),ru=s.enum(["minutes","hours","days"]);function wy(e){return!ey.test(e)}const MM=e=>Li.safeParse(e).success,Li=s.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(wy),ou=s.enum(["str","int","float","bool","list","dict"]),iu=s.string().max(16384),ky=2e3,su=s.string().min(1).max(ky),au=s.string().min(1).max(64),Sy=s.string().min(1).max(64),Ey=s.string().min(1).max(64),cu=s.object({is_active:s.boolean().nullish(),one_time:s.boolean().nullish(),start_time_utc:s.string().max(64).nullish(),end_time_utc:s.string().max(64).nullish()}).strict(),Iy=s.object({conversation_length:s.number().int().optional(),detail_length:s.number().int().optional(),max_learnings_history:s.number().int().optional(),hosting:s.string().max(256).optional(),model_name:s.string().max(1024).optional(),auto_save_conversation:s.boolean().optional()}).strict(),Qa=128,lu=2e3,du=8e3,uu=64,fu=64,ks=e=>[...e].length,qa=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,Ay=e=>e===9||e===10||e===11||e===12||e===13||e===133,Ry=e=>e<=31||e>=127&&e<=159,xy=e=>ty.test(String.fromCodePoint(e)),Ty=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,bi=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Jp=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&qa(t[n].codePointAt(0)??0);)n++;for(;r>n&&qa(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},Cy=e=>{let t="",n=!1;for(const r of e){if(qa(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function Oy(e){const t=Jp(e);if(!t)return"must not be empty";if(ks(t)>Qa)return`must be at most ${Qa} characters`;if(ny.test(t))return'must not contain "/", "\\" or ":"';if(bi(t,Ty))return"must not contain Unicode bidirectional override characters";if(bi(t,Ay))return"must not contain whitespace";if(bi(t,Ry))return"must not contain control characters";if(bi(t,xy))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function jM(e){return Cy(Jp(e).normalize("NFKC").toLowerCase())}function Py(e){return e.trim()?ks(e)>lu?`must be at most ${lu} characters`:null:"must not be empty"}function My(e){return e.trim()?ks(e)>du?`must be at most ${du} characters`:null:"must not be empty"}function jy(e){if(e.length>fu)return`must hold at most ${fu} items`;for(const t of e)if(!t.trim()||ks(t)>uu)return`must hold items of 1 to ${uu} characters`;return null}const $y=e=>Oy(e)===null,Dy=s.string().refine($y,{message:"That is not a name the hub can publish."}),Ny=s.string().refine(e=>My(e)===null,{message:"That instruction body cannot be published."}),Ly=s.string().refine(e=>Py(e)===null,{message:"That description cannot be published."}),Fy=s.array(s.string()).refine(e=>jy(e)===null,{message:"That tool list cannot be published."}),ra={requestId:de.optional(),subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional()},pu=s.object({name:Dy,description:Ly,instructions:Ny,kind:s.enum(["role","specialist"]),when_to_use:s.string(),tools:Fy,effort:s.string(),delegate:s.boolean(),version:s.string(),categories:s.array(s.string()),tags:s.array(s.string())}).partial().strict(),Uy=s.enum(["team","agent"]),By=s.string().min(1).max(64),Hy=s.string().min(1).max(256),Qp=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,oa=s.string().regex(Qp,{message:"Letters, digits, dot, underscore and dash; no spaces."}),Wy=["planning","active","qa","validation","done","paused","archived"],hu=s.enum(Wy),vi=s.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),mu=s.array(s.string().min(1).max(24)).max(8),Sn=s.string().min(1).max(64),Gy=1e3,gu=240,_u=80,zy=256,Ky=100,Vy=200,Zy=/^[a-z0-9][a-z0-9_-]{0,23}$/;function $M(e){return e?Qp.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function DM(e){return Zy.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const yi=s.enum(["agent","team","skill"]),ia=s.string().min(1).max(128).regex(/\S/),bu=s.enum(Xa),Yy=s.object({visible:s.array(bu).max(Xa.length),more:s.array(bu).max(Xa.length)}).strict(),fn=s.string().min(3).max(256).regex(/^(?:n_[a-z2-7]{4,32}|ask:[A-Za-z0-9_-]+:[A-Za-z0-9_-]+)$/),vu=s.object({selectionToken:s.string().min(1).max(512),reconcileIds:s.array(fn).max(500).optional(),excludedIds:s.array(fn).max(500).optional()}).strict(),Xy=s.object({operationToken:s.string().min(1).max(512),reconcileIds:s.array(fn).max(500).optional()}).strict(),yu=s.union([s.object({throughSeq:s.number().int().min(0).optional(),receipt:s.literal(!0).optional(),reconcileIds:s.array(fn).max(500).optional(),items:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).min(1).max(500)}).strict(),s.object({sessionId:Ja,throughSeq:s.number().int().min(0),observed:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).max(500)}).strict(),s.object({all:s.literal(!0),throughSeq:s.number().int().min(0),observed:s.array(s.object({id:fn,revision:s.number().int().min(1)}).strict()).max(500)}).strict()]),Jy={pointer:"pointerdown",key:"keydown",wheel:"wheel"},Qy=s.discriminatedUnion("op",[s.object({op:s.literal("capabilities")}).strict(),s.object({op:s.literal("runtimes.list")}).strict(),s.object({op:s.literal("profiles.list")}).strict(),s.object({op:s.literal("profiles.get"),name:rt}).strict(),s.object({op:s.literal("imports.sources")}).strict(),s.object({op:s.literal("imports.sessions"),source:Xp,includeSubagents:s.boolean().optional()}).strict(),s.object({op:s.literal("imports.preview"),...eu}).strict(),s.object({op:s.literal("imports.start"),...eu}).strict(),s.object({op:s.literal("imports.status"),jobId:s.string().min(1).max(128)}).strict(),s.object({op:s.literal("imports.cancel"),jobId:s.string().min(1).max(128)}).strict(),s.object({op:s.literal("profiles.update"),name:rt,requestId:de,fields:tu,expectedDefinitionRevision:Zd.optional()}).strict(),s.object({op:s.literal("profiles.install"),name:rt,requestId:de}).strict(),s.object({op:s.literal("profiles.create"),name:rt,requestId:de,fields:tu.extend({description:s.string().max(8e3),instructions:s.string().min(1).max(8e3)})}).strict(),s.object({op:s.literal("hub.updates")}).strict(),s.object({op:s.literal("hub.skillPull"),requestId:de,hubId:I,hubSource:s.string().min(1).max(2048),visibility:s.enum(["public","org"]),tenantId:I.nullable(),localAlias:rt,subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional(),dryRun:s.boolean().optional(),adoptionStrategy:s.enum(["merge","keep-local","take-hub"]).optional(),allowLlm:s.boolean().optional(),confirm:s.boolean().optional(),adoptionReceipt:s.string().min(16).max(128).optional()}).strict(),s.object({op:s.literal("hub.skillSubscribe"),requestId:de,hubId:I,hubSource:s.string().min(1).max(2048),visibility:s.enum(["public","org"]),tenantId:I.nullable(),localAlias:rt}).strict(),s.object({op:s.literal("hub.skillUnpull"),requestId:de,linkId:s.string().min(1).max(256)}).strict(),s.object({op:s.literal("hub.skillPublish"),requestId:de,dryRun:s.boolean(),sourceSkill:rt,localAlias:rt,visibility:s.enum(["public","org"]),tenantId:I.nullable(),subscribe:s.boolean(),autoPush:s.boolean(),confirmPublicEgress:s.boolean(),previewReceipt:s.string().min(1).max(4096).optional(),confirmPublish:s.literal(!0).optional()}).strict(),s.object({op:s.literal("hub.links"),kind:s.enum(["agent","team","skill"]).optional()}).strict(),s.object({op:s.literal("hub.policy"),requestId:de,linkId:s.string().min(1).max(256),expectedPolicyRevision:s.string().min(1).max(256),subscribe:s.boolean().optional(),autoPush:s.boolean().optional(),confirmPublicEgress:s.boolean().optional()}).strict(),s.object({op:s.literal("hub.check"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional()}).strict(),s.object({op:s.literal("hub.apply"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional(),prefer:s.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:s.boolean().optional(),dryRun:s.boolean().optional(),resolveSource:s.literal(!0).optional(),hubSource:s.string().min(1).max(2048).optional(),visibility:s.enum(["public","org"]).optional(),tenantId:s.string().min(1).max(128).nullable().optional()}).strict(),s.object({op:s.literal("hub.applyAll"),requestId:de,kind:yi.optional()}).strict(),s.object({op:s.literal("hub.retry"),requestId:de,kind:yi.optional(),name:rt.optional(),localId:ia.optional()}).strict(),s.object({op:s.literal("hub.push"),requestId:de,linkId:s.string().min(1).max(256),direction:s.literal("push"),dryRun:s.boolean(),previewReceipt:s.string().min(1).max(4096).optional(),confirmPublish:s.literal(!0).optional()}).strict(),s.object({op:s.literal("teams.list")}).strict(),s.object({op:s.literal("teams.get"),name:rt}).strict(),s.object({op:s.literal("teams.effective"),name:rt}).strict(),s.object({op:s.literal("teams.update"),name:rt,requestId:de,fields:nu,expectedDefinitionRevision:Zd.optional()}).strict(),s.object({op:s.literal("teams.create"),requestId:de,fields:nu.extend({name:s.string().min(1).max(64)})}).strict(),s.object({op:s.literal("sessions.list"),limit:s.number().int().min(1).max(500).optional(),include_archived:s.boolean().optional(),include_temporary:s.boolean().optional(),include_peers:s.boolean().optional(),scope_kind:Uy.optional(),scope_name:By.optional(),cursor:Hy.optional(),with_counts:s.boolean().optional(),sort:s.literal("activity").optional()}).strict(),s.object({op:s.literal("delegated_cleanup_notice.ack")}).strict(),s.object({op:s.literal("sessions.search"),q:s.string().min(1).max(uy),limit:s.number().int().min(1).max(500).optional(),include_archived:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.archive"),sessionId:F,archived:s.boolean()}).strict(),s.object({op:s.literal("sessions.temporary"),sessionId:F,temporary:s.boolean()}).strict(),s.object({op:s.literal("sessions.delete"),sessionId:F,confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.create"),requestId:de,cwd:s.string().min(1).max(4096).optional(),target:_i.optional(),purpose:s.literal("agents-config").optional(),model:ta.optional(),draftId:F.optional(),peer:gr.optional(),temporary:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.preview"),requestId:de,cwd:s.string().min(1).max(4096),target:_i.optional(),model:ta.optional()}).strict(),s.object({op:s.literal("sessions.draft"),requestId:de,cwd:s.string().min(1).max(4096),target:_i.optional(),model:ta.optional()}).strict(),s.object({op:s.literal("sessions.get"),sessionId:F,journalOrder:s.boolean().optional(),orderIds:s.array(s.string().min(1).max(128)).max(512).optional(),peerJournalSource:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.files"),sessionId:F,scope:s.enum(["family","self"]).optional(),kind:s.string().max(256).optional(),q:s.string().max(256).optional(),sort:s.enum(["recent","name","kind","modified","created","size"]).optional(),order:s.enum(["asc","desc"]).optional(),limit:s.number().int().min(1).max(200).optional(),cursor:s.string().max(8192).optional()}).strict(),s.object({op:s.literal("sessions.files.materialise"),sessionId:F,fileId:s.string().regex(/^[a-f0-9]{16}$/)}).strict(),s.object({op:s.literal("sessions.files.download"),sessionId:F,fileId:s.string().regex(/^[a-f0-9]{16}$/)}).strict(),s.object({op:s.literal("sessions.userAttachments"),sessionId:F}).strict(),s.object({op:s.literal("sessions.userAttachments.materialise"),sessionId:F,digest:s.string().regex(/^[a-f0-9]{32}$/)}).strict(),s.object({op:s.literal("sessions.history"),sessionId:F,beforeId:I.optional(),limit:s.number().int().min(1).max(500).optional(),openFrame:s.boolean().optional(),journalOrder:s.boolean().optional(),orderIds:s.array(s.string().min(1).max(128)).max(512).optional(),peerJournalSource:s.boolean().optional(),sourceRead:s.enum(["metadata","payload"]).optional(),expectedJournalGeneration:s.string().min(1).max(128).optional()}).strict(),s.object({op:s.literal("sessions.checkpoints"),sessionId:F}).strict(),s.object({op:s.literal("sessions.checkpoints.warm"),sessionId:F,ids:s.array(I).max(qd).optional(),limit:s.number().int().min(1).max(qd).optional()}).strict(),s.object({op:s.literal("sessions.find"),sessionId:F,q:s.string().min(1).max(py),limit:s.number().int().min(1).max(my).optional()}).strict(),s.object({op:s.literal("subagents.transcript"),sessionId:F,childId:F,beforeId:I.optional(),entryId:s.string().min(1).max(128).regex(/^[a-zA-Z0-9_:-]+$/).optional(),limit:s.number().int().min(1).max(500).optional()}).strict(),s.object({op:s.literal("sessions.diff"),sessionId:F,callId:zd,start:s.number().int().min(0).max(1e6),offset:s.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),limit:s.number().int().min(1).max(Ho)}).strict(),s.object({op:s.literal("subagents.diff"),sessionId:F,childId:F,callId:zd,start:s.number().int().min(0).max(1e6),offset:s.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),limit:s.number().int().min(1).max(Ho)}).strict(),s.object({op:s.literal("sessions.message"),sessionId:F,requestId:de,text:s.string().max(Jd),images:s.array(Xd).max(Qd).optional(),files:s.array(dy).max(Yv).optional(),mode:s.enum(["prompt","steer"]).optional(),inputMode:s.enum(["typed","dictated","mixed"]).optional(),inputPath:s.string().max(1024).optional()}).strict(),s.object({op:s.literal("sessions.command"),sessionId:F,requestId:de,command:s.string().regex(/^\/?[A-Za-z]+$/).max(64),args:s.string().max(Jd).optional(),images:s.array(Xd).max(Qd).optional()}).strict(),s.object({op:s.literal("sessions.move"),sessionId:F,requestId:de,cwd:s.string().min(1).max(4096)}).strict(),s.object({op:s.literal("settingsIntents.list"),sessionId:F.optional()}).strict(),s.object({op:s.literal("settingsIntents.submit"),sessionId:F,requestId:de,kind:s.enum(["model","effort","fast","cwd"]),value:s.union([s.string().min(1).max(4096),s.boolean()]),effort:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("settingsIntents.dismiss"),sessionId:F,kind:s.enum(["model","effort","fast","cwd"]),generation:s.number().int().nonnegative()}).strict(),s.object({op:s.literal("sessions.profileActionStatus"),sessionId:F,actionId:s.string().regex(/^prv_[A-Za-z0-9_-]{32}$/),receiptId:s.string().min(1).max(160),profileKind:s.enum(["agent","team"]),profileName:s.string().min(1).max(128),toolCallId:s.string().min(1).max(160)}).strict(),s.object({op:s.literal("sessions.answer"),sessionId:F,epoch:I.optional(),requestId:I.optional(),value:s.string().max(32768).optional(),approved:s.boolean().optional(),questionIndex:s.number().int().min(0).optional(),askId:I.optional(),answers:s.record(s.string(),s.array(s.string().max(32768))).optional(),decline:s.boolean().optional(),revise:s.boolean().optional(),dismiss:s.boolean().optional(),reason:s.enum(["answered_in_chat","moot"]).optional()}).strict(),s.object({op:s.literal("sessions.seen"),sessionId:F,completionToken:s.string().uuid()}).strict(),s.object({op:s.literal("attention.seen"),items:s.array(s.object({sessionId:F,completionToken:s.string().uuid()}).strict()).min(1).max(500)}).strict(),s.object({op:s.literal("sessions.notified"),sessionId:F,completionToken:s.string().uuid()}).strict(),s.object({op:s.literal("tags.list")}).strict(),s.object({op:s.literal("tags.replace"),tags:s.array(s.object({id:s.string().optional(),name:s.string()}).strict())}).strict(),s.object({op:s.literal("sessions.tags"),expected_revision:s.string().optional(),sessionId:F,tags:s.array(s.string()),primary:s.string().nullable()}).strict(),s.object({op:s.literal("sessions.pin"),sessionId:F,pinned:s.boolean()}).strict(),s.object({op:s.literal("sessions.watch"),sessionId:F,subscriptionId:s.string().regex(Vd),visible:s.boolean(),canNotify:s.boolean()}).strict(),s.object({op:s.literal("sessions.warm"),sessionId:F}).strict(),s.object({op:s.literal("sessions.interrupt"),sessionId:F,requestId:de}).strict(),s.object({op:s.literal("supplements.cancel"),sessionId:F,job:Xs,anchor:Js}).strict(),s.object({op:s.literal("supplements.restart"),sessionId:F,job:Xs,anchor:Js}).strict(),s.object({op:s.literal("supplements.steer"),sessionId:F,job:Xs,anchor:Js,text:s.string().min(1).max(500)}).strict(),s.object({op:s.literal("sessions.variables.list"),sessionId:F}).strict(),s.object({op:s.literal("sessions.variables.create"),sessionId:F,key:Li,value:iu,type:ou}).strict(),s.object({op:s.literal("sessions.variables.update"),sessionId:F,key:Li,value:iu,type:ou}).strict(),s.object({op:s.literal("sessions.variables.delete"),sessionId:F,key:Li}).strict(),s.object({op:s.literal("sessions.presence"),subscriptionId:s.string().regex(/^[a-f0-9]{1,64}$/),canNotify:s.boolean(),canNotifyKinds:s.array(s.enum(["complete","error"])).max(4),sessionId:s.string().regex(/^([a-f0-9]{12})?$/),window:s.object({exists:s.boolean(),focused:s.boolean(),visible:s.boolean(),minimized:s.boolean()}).strict()}).strict(),s.object({op:s.literal("legacy.models"),provider:s.string().max(128).optional(),sort:s.enum(["id","name","provider","recommended"]).optional(),direction:s.enum(["ascending","descending"]).optional()}).strict(),s.object({op:s.literal("legacy.models.providers")}).strict(),s.object({op:s.literal("auth.probe"),provider:I}).strict(),s.object({op:s.literal("legacy.agent.upload"),agentId:I}).strict(),s.object({op:s.literal("agent.publish"),agentId:I,document:pu.optional(),...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("agent.republish"),agentId:I,hubAgentId:I,expectedRemoteRevision:s.string().min(1).max(512).optional(),document:pu.optional(),...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("team.publish"),teamId:I,...ra,visibility:s.literal("org").optional(),tenantId:I.optional()}).strict(),s.object({op:s.literal("team.pull"),teamId:I,tenantId:I.optional()}).strict(),s.object({op:s.literal("agent.nameAvailability"),name:s.string().min(1).max(Qa)}).strict(),s.object({op:s.literal("legacy.agents.list"),page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(500).optional(),name:s.string().max(256).optional(),sort:s.string().max(64).optional(),direction:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("legacy.agent.get"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.history"),agentId:I,page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(500).optional()}).strict(),s.object({op:s.literal("legacy.jobs.list"),agentId:I.optional(),status:s.string().max(64).optional()}).strict(),s.object({op:s.literal("legacy.job.get"),jobId:I}).strict(),s.object({op:s.literal("legacy.schedules.list"),page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("legacy.agent.schedules.list"),agentId:I,page:s.number().int().min(1).optional(),perPage:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("legacy.agent.schedule.create"),agentId:I,schedule:cu.extend({prompt:s.string().max(64e3),interval:s.number().int().min(1),unit:ru})}).strict(),s.object({op:s.literal("legacy.schedule.get"),scheduleId:I}).strict(),s.object({op:s.literal("legacy.schedule.edit"),scheduleId:I,schedule:cu.extend({prompt:s.string().max(64e3).nullish(),interval:s.number().int().min(1).nullish(),unit:ru.nullish()})}).strict(),s.object({op:s.literal("legacy.schedule.remove"),scheduleId:I}).strict(),s.object({op:s.literal("legacy.agent.create"),agent:s.record(s.unknown())}).strict(),s.object({op:s.literal("legacy.agent.update"),agentId:I,update:s.record(s.unknown())}).strict(),s.object({op:s.literal("legacy.agent.delete"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.conversation.clear"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.systemPrompt.get"),agentId:I}).strict(),s.object({op:s.literal("legacy.agent.systemPrompt.update"),agentId:I,systemPrompt:s.string().max(gy)}).strict(),s.object({op:s.literal("legacy.agent.download"),agentId:I}).strict(),s.object({op:s.literal("legacy.job.cancel"),jobId:I}).strict(),s.object({op:s.literal("commands.list")}).strict(),s.object({op:s.literal("commands.entities"),sessionId:F,command:I,name:s.string().max(128).optional()}).strict(),s.object({op:s.literal("models.catalogue"),live:s.boolean().optional(),scope:s.enum(["usable","all"]).optional()}).strict(),s.object({op:s.literal("usage.get"),provider:I.optional(),live:s.boolean().optional(),refresh:s.boolean().optional()}).strict(),s.object({op:s.literal("usage.reset"),provider:I,credentialRef:ry.optional(),identity:s.string().min(1).max(256).optional(),redeemRequestId:s.string().uuid()}).strict(),s.object({op:s.literal("quota.notice"),provider:I.optional(),model:s.string().min(1).max(200).optional(),refresh:s.boolean().optional()}).strict(),s.object({op:s.literal("analytics.get"),sessionId:F.optional(),sinceMs:s.number().int().nonnegative().optional(),untilMs:s.number().int().nonnegative().optional(),days:s.number().int().min(1).max(366).optional()}).strict(),s.object({op:s.literal("analytics.models"),sessionId:F.optional(),sinceMs:s.number().int().nonnegative().optional(),untilMs:s.number().int().nonnegative().optional(),days:s.number().int().min(1).max(366).optional()}).strict(),s.object({op:s.literal("info.get")}).strict(),s.object({op:s.literal("sessions.report"),sessionId:F,recentLimit:s.number().int().min(0).max(50).optional()}).strict(),s.object({op:s.literal("skills.list"),sessionId:F.optional(),cwd:sy.optional(),name:eo.optional()}).strict(),s.object({op:s.literal("skills.create"),requestId:de,name:eo,copyFrom:eo}).strict(),s.object({op:s.literal("skills.update"),requestId:de,name:eo,expectedFingerprint:s.string().regex(/^[a-f0-9]{64}$/),files:s.array(s.object({path:s.string().min(1).max(240),content:s.string().max(1024*1024)}).strict()).min(1).max(64)}).strict(),s.object({op:s.literal("skills.remove"),requestId:de,name:eo,discardLocalChanges:s.boolean()}).strict(),s.object({op:s.literal("sessions.failovers"),sessionId:F}).strict(),s.object({op:s.literal("sessions.credential"),sessionId:F,action:s.enum(["list","store","forget"]),key:hi.optional(),value:mi.optional(),confirmed:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.fork"),sessionId:F,requestId:de,message:s.string().max(2e5).optional(),boundary:s.enum(["next_safe","at_entry"]).optional(),entryId:s.string().max(128).optional(),autoTag:s.boolean().optional()}).strict(),s.object({op:s.literal("sessions.stop"),requestId:de,targets:s.array(F).min(1).max(100),confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.aside"),sessionId:F,requestId:de,text:s.string().min(1).max(32768),asideId:de.optional(),subscriptionId:s.string().regex(Vd).optional()}).strict(),s.object({op:s.literal("sessions.adopt"),sessionId:F,requestId:de,asideId:de,confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("sessions.aside.get"),sessionId:F,asideId:de}).strict(),s.object({op:s.literal("sessions.aside.close"),sessionId:F,asideId:de}).strict(),s.object({op:s.literal("wakes.list"),limit:s.number().int().min(1).max(500).optional(),includeDormant:s.boolean().optional()}).strict(),s.object({op:s.literal("wakes.create"),requestId:de,sessionId:F.optional(),cwd:s.string().min(1).max(4096).optional(),target:_i.optional(),message:su,in:s.string().min(1).max(64).optional(),at:s.string().min(1).max(64).optional(),every:s.string().min(1).max(64).optional(),until:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).optional(),title:s.string().min(1).max(200).optional()}).strict(),s.object({op:s.literal("wakes.edit"),sessionId:F,wakeId:au,message:su.optional(),in:s.string().min(1).max(64).optional(),at:s.string().min(1).max(64).optional(),every:s.string().min(1).max(64).optional(),until:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).optional()}).strict(),s.object({op:s.literal("wakes.remove"),sessionId:F,wakeId:au}).strict(),s.object({op:s.literal("monitors.list"),limit:s.number().int().min(1).max(500).optional(),includeDormant:s.boolean().optional()}).strict(),s.object({op:s.literal("monitors.cancel"),sessionId:F,monitorId:Sy}).strict(),s.object({op:s.literal("jobs.cancel"),sessionId:F,jobId:Ey}).strict(),s.object({op:s.literal("mcp.list"),sessionId:F}).strict(),s.object({op:s.literal("mcp.credentials.store"),sessionId:F,name:s.string().min(1).max(256),values:s.record(s.string().min(1).max(128),s.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:s.array(s.string().min(1).max(128)).max(32)}).strict(),s.object({op:s.literal("mcp.control"),sessionId:F,control:s.object({action:s.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Qs.optional(),scope:s.enum(["global","project"]).optional(),command:s.string().min(1).max(4096).optional(),args:s.array(s.string().max(8192)).max(128).optional(),env:s.record(gi).optional(),url:s.string().max(4096).optional(),headers:s.record(gi).optional(),oauth:s.boolean().optional(),confirmed:s.boolean().optional(),operation_id:Kd.optional()}).strict()}).strict(),s.object({op:s.literal("mcp.catalog"),cwd:qs.optional(),sessionId:F.optional()}).strict(),s.object({op:s.literal("mcp.catalog.control"),cwd:qs.optional(),control:s.object({action:s.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Qs.optional(),scope:s.enum(["global","project"]).optional(),command:s.string().min(1).max(4096).optional(),args:s.array(s.string().max(8192)).max(128).optional(),env:s.record(gi).optional(),url:s.string().max(4096).optional(),headers:s.record(gi).optional(),confirmed:s.boolean().optional(),operation_id:Kd.optional()}).strict()}).strict(),s.object({op:s.literal("mcp.catalog.credentials"),header:s.string().min(1).max(128).optional(),cwd:qs.optional(),name:Qs,values:s.record(s.string().min(1).max(128),s.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:s.array(s.string().min(1).max(128)).max(32)}).strict(),s.object({op:s.literal("radient.request"),control:s.object({operation:s.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend","team_trial.eligibility","team_trial.start","team_trial.status"]),request_id:de.optional(),tenant_id:I.optional(),account_id:I.optional(),agent_id:I.optional(),comment_id:I.optional(),team_id:I.optional(),skill_id:I.optional(),query:s.record(s.union([s.string().max(1024),s.number().int()])).optional(),payload:s.record(s.unknown()).optional(),confirmed:s.boolean().optional()}).strict()}).strict(),s.object({op:s.literal("providers.list")}).strict(),s.object({op:s.literal("accounts.list")}).strict(),s.object({op:s.literal("accounts.remove"),accountId:s.number().int().positive(),confirmed:s.literal(!0)}).strict(),s.object({op:s.literal("tunnel.setup.read"),credentialId:s.number().int().positive().optional()}).strict(),s.object({op:s.literal("tunnel.setup.plan"),credentialId:s.number().int().positive().optional()}).strict(),s.object({op:s.literal("tunnel.setup.run"),credentialId:s.number().int().positive(),acceptMonthlyPrice:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("mobile.doctor")}).strict(),s.object({op:s.literal("auth.start"),provider:I}).strict(),s.object({op:s.literal("auth.status"),id:I}).strict(),s.object({op:s.literal("auth.input"),id:I,promptId:I,value:mi}).strict(),s.object({op:s.literal("auth.cancel"),id:I}).strict(),s.object({op:s.literal("auth.key"),provider:I,value:mi}).strict(),s.object({op:s.literal("auth.logout"),provider:I}).strict(),s.object({op:s.literal("agent_messages.status"),boundary:Hd}).strict(),s.object({op:s.literal("agent_messages.enable"),expected_account_id:I,tenant_id:I,state:s.literal("active"),consent_version:s.string().min(1).max(128),consented_via:s.literal("dialog")}).strict(),s.object({op:s.literal("agent_messages.settings"),tenant_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.settings.put"),expected_account_id:I,tenant_id:I.optional(),consent_version:s.string().min(1).max(128).optional(),consented_via:s.enum(["dialog","settings"]).optional(),label:s.string().min(1).max(128).optional(),state:s.enum(["active","paused","disabled"])}).strict(),s.object({op:s.literal("agent_messages.onboarding.dismiss")}).strict(),s.object({op:s.literal("agent_messages.allowlist.get"),tenant_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.allowlist.put"),expected_account_id:I,tenant_id:I.optional(),entries:s.array(s.object({direction:s.enum(["send","receive"]),effect:s.enum(["allow","deny"]),target:s.object({endpoint_id:I.optional(),account_id:I.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),s.object({op:s.literal("team_bridge.conversations.list"),scope:s.literal("account").optional(),tenant_id:I.optional(),limit:s.number().int().min(1).max(100).optional(),cursor:s.string().min(1).max(512).optional(),before:s.string().min(1).max(64).optional(),status:s.enum(["open","archived"]).optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.get"),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.create"),expected_account_id:I.optional(),tenant_id:I.optional(),kind:s.enum(["dm","group","channel"]),name:s.string().min(1).max(128).optional(),topic:s.string().min(1).max(512).optional(),visibility:s.enum(["private","tenant"]).optional(),agent_capable:s.boolean().optional(),members:s.array(s.object({account_id:I,kind:s.enum(["human","agent"]),endpoint_id:I.optional(),display_label:s.string().min(1).max(64)}).strict()).max(500)}).strict(),s.object({op:s.literal("team_bridge.conversations.lifecycle"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I,action:s.enum(["archive","unarchive","join","leave"])}).strict(),s.object({op:s.literal("team_bridge.conversations.join"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.leave"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.conversations.notify"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),notify:s.enum(["all","mention","mute"])}).strict(),s.object({op:s.literal("team_bridge.conversations.agent_notify"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),notify:s.enum(["all","mention","mute"])}).strict(),s.object({op:s.literal("team_bridge.conversations.members.add"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),members:s.array(s.object({account_id:I,kind:s.enum(["human","agent"]),endpoint_id:I.optional(),display_label:s.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),s.object({op:s.literal("team_bridge.conversations.members.remove"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I,account_id:I}).strict(),s.object({op:s.literal("team_bridge.conversations.delete"),expected_account_id:I.optional(),tenant_id:I.optional(),conversation_id:I}).strict(),s.object({op:s.literal("team_bridge.conversations.consent"),expected_account_id:I.optional(),conversation_id:I,account_id:I,decision:s.enum(["accept","decline","withdraw"]),consent_version:s.string().min(1).max(128).optional(),endpoint_id:I.optional(),tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.conversations"),expected_account_id:I,tenant_id:I,limit:s.number().int().min(1).max(100).optional(),cursor:s.string().min(1).optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.messages"),expected_account_id:I,tenant_id:I,conversation_id:I,limit:s.number().int().min(1).max(100).optional(),before_seq:s.number().int().nonnegative().optional()}).strict(),s.object({op:s.literal("team_bridge.owner_audit.replies"),expected_account_id:I,tenant_id:I,conversation_id:I,message_id:I,limit:s.number().int().min(1).max(100).optional(),after_seq:s.number().int().nonnegative().optional(),before_seq:s.number().int().positive().optional(),order:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("team_bridge.messages.list"),conversation_id:I,tenant_id:I.optional(),limit:s.number().int().min(1).max(100).optional(),before_seq:s.number().int().nonnegative().optional(),endpoint_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.typing.get"),conversation_id:I,tenant_id:I}).strict(),s.object({op:s.enum(["team_bridge.typing.set","team_bridge.typing.clear"]),conversation_id:I,tenant_id:I,expected_account_id:I,thread_root_id:I.optional()}).strict(),s.object({op:s.literal("agent_messages.settings.share_typing"),expected_account_id:I,share_typing:s.boolean()}).strict(),s.object({op:s.literal("team_bridge.reactions.toggle"),conversation_id:I,message_id:I,expected_account_id:I,tenant_id:I,emoji:s.string().min(1),active:s.boolean()}).strict(),s.object({op:s.literal("team_bridge.messages.send"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),client_ref:I,body:s.string(),agent_label:s.string().min(1).max(64).optional(),thread_root_id:I.optional(),attachment_ids:na.optional(),files:s.array(I).min(1).max(10).refine(e=>new Set(e).size===e.length,"Duplicate file").optional(),mentions:yy.optional()}).strict(),s.object({op:s.literal("team_bridge.messages.replies"),conversation_id:I,message_id:I,expected_account_id:I,tenant_id:I,limit:s.number().int().min(1).max(100).optional(),after_seq:s.number().int().nonnegative().optional(),before_seq:s.number().int().positive().optional(),order:s.enum(["asc","desc"]).optional()}).strict(),s.object({op:s.literal("team_bridge.scheduled.list"),tenant_id:I}).strict(),s.object({op:s.literal("team_bridge.scheduled.create"),tenant_id:I,conversation_id:I,client_ref:I,body:s.string(),send_at:s.string().datetime({offset:!0}),attachment_ids:na.optional(),thread_root_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.scheduled.update"),tenant_id:I,scheduled_id:I,body:s.string().optional(),send_at:s.string().datetime({offset:!0}).optional(),attachment_ids:na.optional(),expected_version:s.number().int().nonnegative().optional()}).strict(),s.object({op:s.literal("team_bridge.attachments.delete"),tenant_id:I,conversation_id:I,attachment_id:I,expected_account_id:I}).strict(),s.object({op:s.literal("team_bridge.scheduled.cancel"),tenant_id:I,scheduled_id:I}).strict(),s.object({op:s.literal("team_bridge.read"),expected_account_id:I.optional(),conversation_id:I,tenant_id:I.optional(),seq:s.number().int().nonnegative().optional(),muted:s.boolean().optional()}).strict(),s.object({op:s.literal("team_bridge.thread_read"),expected_account_id:I,conversation_id:I,message_id:I,tenant_id:I,seq:s.number().int().nonnegative()}).strict(),s.object({op:s.literal("team_bridge.unread"),scope:s.literal("account").optional(),tenant_id:I.optional()}).strict(),s.object({op:s.literal("team_bridge.directory"),tenant_id:I}).strict(),s.object({op:s.literal("team_bridge.status"),boundary:Hd.optional()}).strict(),s.object({op:s.literal("team_bridge.link_preview.resolve"),url:s.string().min(1).max(qv),index:s.number().int().nonnegative(),expectedAccountId:I}).strict(),s.object({op:s.literal("settings.list")}).strict(),s.object({op:s.literal("settings.edit"),key:hi,value:s.unknown().refine(e=>e!==void 0,"A setting value is required."),base:vy.optional()}).strict(),s.object({op:s.literal("settings.reset"),key:hi}).strict(),s.object({op:s.literal("tts.paths")}).strict(),s.object({op:s.literal("notification_sounds.list")}).strict(),s.object({op:s.literal("notification_sounds.rename"),id:s.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),name:s.string().min(1).max(200)}).strict(),s.object({op:s.literal("notification_sounds.remove"),id:s.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)}).strict(),s.object({op:s.literal("config.get")}).strict(),s.object({op:s.literal("config.update"),value:Iy}).strict(),s.object({op:s.literal("instructions.get")}).strict(),s.object({op:s.literal("instructions.update"),content:s.string().max(64e3)}).strict(),s.object({op:s.literal("credentials.list")}).strict(),s.object({op:s.literal("credentials.update"),key:hi,value:mi}).strict(),s.object({op:s.literal("peers.list")}).strict(),s.object({op:s.literal("networks.list")}).strict(),s.object({op:s.literal("networks.invite"),networkId:gr,role:s.enum(["read","drive","admin"]),deviceId:gr.optional()}).strict(),s.object({op:s.literal("networks.member.remove"),networkId:gr,deviceId:gr,confirm:s.string().min(1).max(256)}).strict(),s.object({op:s.literal("sessions.transfer"),sessionId:F,to:s.union([s.literal("local"),gr]),keep:s.boolean().optional(),waitS:s.number().min(0).max(300).optional(),requestId:de.optional()}).strict(),s.object({op:s.literal("profileProposals.list"),state:s.enum(["pending","all"]).optional()}).strict(),s.object({op:s.literal("profileProposals.get"),proposalId:ea}).strict(),s.object({op:s.literal("profileProposals.accept"),proposalId:ea,requestId:de,after:s.record(s.string().regex(/^[a-z][a-z0-9_]{0,63}$/),s.unknown()).optional()}).strict(),s.object({op:s.literal("profileProposals.reject"),proposalId:ea,requestId:de,note:s.string().max(2e3).optional()}).strict(),s.object({op:s.literal("approvals.list")}).strict(),s.object({op:s.literal("approvals.approve"),approvalId:_r}).strict(),s.object({op:s.literal("approvals.deny"),approvalId:_r}).strict(),...["approvals.approveOperation","approvals.applyOperation"].map(e=>s.object({op:s.literal(e),approvalId:_r,operation:s.enum(["profile_save","pair_phone"]),requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr)}).strict()),s.object({op:s.literal("approvals.pairAck"),approvalId:_r,requestDigest:s.string().regex(xr),disclosureDigest:s.string().regex(xr),code:s.string().min(1).max(32).optional()}).strict(),s.object({op:s.literal("devices.list")}).strict(),s.object({op:s.literal("devices.remove"),deviceId:s.string().regex(/^[A-Za-z0-9]{1,64}$/)}).strict(),s.object({op:s.literal("operator.setup.read")}).strict(),s.object({op:s.literal("operator.setup.run")}).strict(),s.object({op:s.literal("mobile.password")}).strict(),s.object({op:s.literal("approvals.approveCredential"),approvalId:_r,...Yd}).strict(),s.object({op:s.literal("approvals.applyCredential"),approvalId:_r,...Yd}).strict(),s.object({op:s.literal("asks.list")}).strict(),s.object({op:s.literal("projects.list")}).strict(),s.object({op:s.literal("projects.get"),key:Sn}).strict(),s.object({op:s.literal("projects.create"),name:oa,description:s.string().max(gu).optional(),status:hu.optional(),tags:mu.optional()}).strict(),s.object({op:s.literal("projects.update"),key:Sn,fields:s.object({name:oa.optional(),title:s.string().max(80).optional(),owner:s.string().max(80).optional(),team:s.string().max(80).optional(),description:s.string().max(gu).optional(),status:hu.optional(),progress:s.string().max(Gy).optional(),tags:mu.optional(),start_date:vi.optional(),target_date:vi.optional(),completed_at:vi.optional(),estimate:s.number().positive().max(1e3).optional(),estimate_unit:s.enum(["points","days"]).optional()}).strict(),force_done:s.boolean().optional()}).strict(),s.object({op:s.literal("projects.delete"),key:Sn,confirmed_name:oa}).strict(),s.object({op:s.literal("projects.link"),key:Sn,sessionId:F}).strict(),s.object({op:s.literal("projects.unlink"),key:Sn,sessionId:F}).strict(),s.object({op:s.literal("projects.milestone"),key:Sn,name:s.string().min(1).max(_u),targetDate:vi.optional(),completed:s.boolean().optional()}).strict(),s.object({op:s.literal("projects.milestone.remove"),key:Sn,name:s.string().min(1).max(_u)}).strict(),s.object({op:s.literal("projects.request_update"),key:Sn}).strict(),s.object({op:s.literal("projects.for_session"),sessionId:F}).strict(),s.object({op:s.literal("projects.search"),q:s.string().min(1).max(zy),limit:s.number().int().min(1).max(Vy).optional()}).strict(),s.object({op:s.literal("aida.status")}).strict(),s.object({op:s.literal("aida.control"),action:s.enum(["open","pause","resume","greet","status"])}).strict(),s.object({op:s.literal("code_requests.list"),sessionId:F}).strict(),s.object({op:s.literal("code_requests.refresh"),sessionId:F,keys:s.array(s.string().min(1).max(512)).max(256).optional(),force:s.boolean().optional()}).strict(),s.object({op:s.literal("static.sign"),route:s.enum(["images","videos","audio","html"]),path:s.string().min(1),ttlS:s.number().int().min(1).max(3600).optional()}).strict(),s.object({op:s.literal("library.list"),scope:s.enum(["final","all"]).optional(),q:s.string().max(512).optional(),category:s.string().min(1).max(64).optional(),kind:s.string().min(1).max(64).optional(),origin_group:s.enum(["generated","created","mentioned"]).optional(),origin:s.string().min(1).max(64).optional(),tag:s.string().min(1).max(128).optional(),tag_mode:s.enum(["all","any"]).optional(),highlighted:s.boolean().optional(),organized:s.boolean().optional(),favorite:s.boolean().optional(),session:s.string().min(1).max(12).optional(),session_id:s.string().min(1).max(512).optional(),sort:s.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:s.enum(["asc","desc"]).optional(),limit:s.number().int().min(1).max(200).optional(),cursor:s.string().max(512).optional()}).strict(),s.object({op:s.literal("library.get"),id:to}).strict(),s.object({op:s.literal("library.update"),id:to,fields:s.object({name:s.string().max(200).optional(),description:s.string().max(2e3).optional(),favorite:s.boolean().optional(),locked:s.boolean().optional(),archived:s.boolean().optional()}).strict()}).strict(),s.object({op:s.literal("library.tags")}).strict(),s.object({op:s.literal("library.tags.create"),name:s.string().trim().min(1).max(24),category:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("library.tags.update"),id:no,name:s.string().trim().min(1).max(24).optional(),category:s.string().min(1).max(64).optional()}).strict(),s.object({op:s.literal("library.tags.delete"),id:no}).strict(),s.object({op:s.literal("library.tags.merge"),id:no,into:no}).strict(),s.object({op:s.literal("library.tags.assign"),id:to,tags:s.array(no).max(64),primary:s.string().max(128).optional()}).strict(),s.object({op:s.literal("library.chat.link"),id:to,sessionId:F}).strict(),s.object({op:s.literal("library.chat.clear"),id:to}).strict(),s.object({op:s.literal("library.librarian"),action:s.enum(["status","open","pause","resume","run"]).optional()}).strict(),s.object({op:s.literal("sidebar_layout.get")}).strict(),s.object({op:s.literal("sidebar_layout.set"),layout:Yy}).strict(),s.object({op:s.literal("notifications.list"),preview:s.literal(!0).optional(),includeAskReads:s.boolean().optional(),countSessionIds:s.array(F).max(50).optional(),includeSessionCounts:s.literal(!0).optional(),kind:s.enum(["all","asks","updates"]).optional(),bulkPriority:s.enum(["any","high","normal_up"]).optional(),state:s.enum(["unread","all","dismissed"]).optional(),source:s.enum(["notify","ask"]).optional(),priority:s.enum(["high","normal","low"]).optional(),sessionId:Ja.optional(),throughSeq:s.number().int().min(0).optional(),cursor:s.string().min(1).max(64).optional(),limit:s.number().int().min(1).max(100).optional()}).strict(),s.object({op:s.literal("notifications.get"),id:fn}).strict(),s.object({op:s.literal("notifications.count")}).strict(),s.object({op:s.literal("notifications.read"),verb:s.enum(["read","unread","undo"]),target:s.union([yu,vu,Xy])}).strict(),s.object({op:s.literal("notifications.dismiss"),verb:s.enum(["dismiss","undismiss"]),target:s.union([yu,vu])}).strict(),s.object({op:s.literal("notifications.seen"),items:s.array(s.object({id:fn,revision:s.number().int().min(1),anchorId:s.string().min(1).max(256),visibleSinceMs:s.number().int().min(0)}).strict()).min(1).max(50),evidence:s.object({sessionId:Ja,inputKind:s.enum(["pointer","key","wheel"]),inputAtMs:s.number().int().min(0),visibleSinceMs:s.number().int().min(0)}).strict()}).strict()]);Qy.superRefine((e,t)=>{if(e.op==="usage.reset"&&!e.credentialRef&&!e.identity&&t.addIssue({code:s.ZodIssueCode.custom,message:"A usage reset must name an account: send `credentialRef` or `identity`.",path:["credentialRef"]}),e.op==="team_bridge.conversations.consent"&&e.decision==="withdraw"!=(e.consent_version===void 0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"accept and decline require consent_version; withdraw carries none",path:["consent_version"]}),(e.op==="notifications.read"||e.op==="notifications.dismiss")&&"items"in e.target&&!!e.target.receipt!=(e.target.throughSeq!==void 0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"Receipt writes require a sequence boundary",path:["target"]}),e.op==="notifications.read"&&e.verb==="undo"!="operationToken"in e.target&&t.addIssue({code:s.ZodIssueCode.custom,message:"Undo requires an operation token, and only undo accepts one",path:["target"]}),e.op==="team_bridge.messages.send"&&e.files){const n=e.attachment_ids??[];(n.length+e.files.length>10||e.files.some(r=>n.includes(r)))&&t.addIssue({code:s.ZodIssueCode.custom,message:"Invalid combined attachment set",path:["files"]})}if((e.op==="team_bridge.messages.send"||e.op==="team_bridge.scheduled.create"||e.op==="team_bridge.scheduled.update"&&e.body!==void 0)&&e.body?.trim()===""&&(e.attachment_ids?.length??0)===0&&!(e.op==="team_bridge.messages.send"&&e.files?.length)){t.addIssue({code:s.ZodIssueCode.custom,message:"A message needs text or an image",path:["body"]});return}if(e.op.startsWith("team_bridge.")&&"expected_account_id"in e&&e.expected_account_id&&(!("tenant_id"in e)||!e.tenant_id)){t.addIssue({code:s.ZodIssueCode.custom,path:["tenant_id"],message:"Guarded conversation writes require an explicit tenant"});return}if(e.op==="team_bridge.messages.send"&&e.thread_root_id!==void 0&&!e.expected_account_id){t.addIssue({code:s.ZodIssueCode.custom,path:["expected_account_id"],message:"Thread replies require the captured account"});return}if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:s.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:s.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.name!==void 0,r=e.localId!==void 0,o=e.op!=="hub.check";if(n&&r||o&&!n&&!r||r&&e.kind===void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"A hub action addresses one item by name or local id, never both",path:["localId"]});return}}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.localId!==void 0||e.prefer!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, addressed by name, with no preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:s.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:s.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){if(e.askId||t.addIssue({code:s.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.dismiss===!0){(e.answers!==void 0||e.decline===!0||e.revise===!0)&&t.addIssue({code:s.ZodIssueCode.custom,message:"A dismissal carries no answers, decline or revise",path:["dismiss"]});return}e.reason!==void 0?t.addIssue({code:s.ZodIssueCode.custom,message:"A reason applies to a dismissal",path:["reason"]}):e.decline!==!0&&!e.answers?t.addIssue({code:s.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:s.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:s.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:s.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:s.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:s.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:s.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]}),e.dismiss===!0&&t.addIssue({code:s.ZodIssueCode.custom,message:"dismiss applies to a queued ask",path:["dismiss"]}),e.reason!==void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:"reason applies to a queued ask",path:["reason"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:s.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:s.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:s.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const We={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed",serverUpdating:"transient.server-updating"},qp="service is preparing a safe reload; retry shortly",eh="serve_reloading";function qy(e,t){if(e!==503||t===null||typeof t!="object")return!1;const n=t.detail;return n===qp?!0:n!==null&&typeof n=="object"&&n.code===eh}function ew(e){return e!==null&&typeof e=="object"&&e.updating===!0}function tw(e){return e!==null&&typeof e=="object"&&e.update_stalled===!0}const nw={runtimeUnreachable:"runtime_unreachable"},Ss="runtime_busy",th="runtime_retiring";s.object({data:s.object({aside_id:s.string().optional(),status:s.union([s.enum(["adopted","queued"]),s.string()]).optional()}).passthrough()}).passthrough();const nh=s.object({name:s.string(),description:s.string().nullish(),source:s.string().nullish(),link_id:s.string().nullish(),editable:s.boolean().nullish(),installed:s.boolean().nullish(),fingerprint:s.string().nullish(),form:s.string().nullish()}).passthrough(),rw=s.object({path:s.string(),size:s.number().nullish(),preview:s.string().nullish(),preview_truncated:s.boolean().nullish()}).passthrough(),ow=nh.extend({body:s.string().nullish(),body_in_detail:s.boolean().nullish(),body_length:s.number().nullish(),body_bytes:s.number().nullish(),body_truncated:s.boolean().nullish(),files:s.array(rw).nullish(),files_total:s.number().nullish(),files_truncated:s.boolean().nullish(),publish_budget:s.object({limit:s.number(),total:s.number()}).passthrough().nullish()}).passthrough(),NM=s.object({skills:s.array(nh),scope:s.string().nullish(),detail:s.string().nullish(),skill_detail:ow.nullish(),warning_count:s.number().nullish(),version:s.string().nullish()}).passthrough(),LM=s.object({reset:s.object({outcome:s.union([s.enum(["reset","already_redeemed","no_credit","nothing_to_reset","failed","refused"]),s.string()]),windows_reset:s.number().int().nonnegative(),detail:s.string().default(""),refused:s.boolean()}).passthrough(),usage:s.object({reports:s.array(s.record(s.unknown())),source:s.string(),fetched_at:s.number()}).passthrough().nullish()}).passthrough(),FM="aside_adopt_refused",iw=["session_closed","open_tool_batch","turn_running"];function UM(e){if(typeof e!="object"||e===null)return;const t=e.reason;return iw.find(n=>n===t)}const sw={[We.noCredential]:"ui.common.errors.desktop_refusal.no_credential",[We.refused]:"ui.common.errors.desktop_refusal.refused",[We.planeClosed]:"ui.common.errors.desktop_refusal.plane_closed",[We.transportFailed]:"ui.common.errors.desktop_refusal.transport_failed",[We.serverUpdating]:"ui.common.errors.desktop_refusal.server_updating"},ec={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function Es(e){return e!==void 0&&Object.values(We).includes(e)}function aw(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return We.refused;if(t===503)return We.planeClosed}}const BM=s.object({step:s.string(),blocked_on:s.string(),configured:s.boolean(),ready:s.boolean(),verified:s.boolean(),url:s.string().nullable(),credential_id:s.number().int().positive().nullable(),identity_label:s.string().nullable(),credential_choices:s.array(s.object({id:s.number().int().positive(),identity_label:s.string().nullable().optional()}).passthrough()).default([]),quote:s.object({monthly_price_usd:s.string().nullable(),positive_balance:s.boolean(),eligible:s.boolean(),account_valid:s.boolean()}).passthrough().nullable(),receipts:s.array(s.object({step:s.string(),ok:s.boolean(),text:s.string()})).default([]),remedy:s.object({kind:s.string(),text:s.string(),command:s.string().nullable().optional(),url:s.string().nullable().optional()}).nullable(),source:s.string(),in_progress:s.boolean().default(!1),progress:s.array(s.string()).default([]),active_credential_id:s.number().int().positive().nullable().default(null),billing_outcome:s.string().optional(),reservation_outcome:s.string().optional(),failure_stage:s.string().optional(),transport:s.string().optional()}).passthrough();function HM(e){return e.transport!=="relay"?!1:e.blocked_on==="cloudflared"||e.remedy?.kind==="install_cloudflared"}const WM=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),cw=88e4,lw=11e5,dw=2e4,uw=9e4,fw=new Set(["analytics.get","analytics.models","sessions.report"]),pw=new Set(["usage.get"]),hw=new Set(["networks.list","peers.list"]),mw=new Set(["usage.reset"]),gw=new Set(["sessions.files.download"]),_w=new Set([...fw,...pw,...hw,...mw,...gw]),bw=90,vw=30,yw=300,ww=10,rh=15,kw=1e4;function Sw(e){const n=e.to==="local"||e.keep?yw:vw,r=Math.max(0,e.waitS??0);return(bw+n+ww+rh)*1e3+r*1e3}const Ew=18e4,sa=Ew+15e3,Iw=120,Aw=135e3,Rw=93e4,oh=(Iw+30+rh)*1e3,xw=6e4,Tw=5*oh,Cw=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function Ow(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return oh;case"hub.check":return xw;case"hub.applyAll":return Tw;default:return null}}function Pw(e){if(typeof e!="string"&&e.op==="sessions.transfer")return Sw(e)+kw;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve"||t==="approvals.approveCredential"||typeof e!="string"&&e.op==="approvals.approveOperation"&&e.operation==="pair_phone"||t==="devices.remove"||t==="operator.setup.run")return sa;if(t==="tunnel.setup.run")return Rw;if(t==="tunnel.setup.plan")return Aw;const n=Ow(t);return n!==null?n:_w.has(t)?uw:dw}const Mw=5e3;function ih(e){return Pw(e)+Mw}const il="deadline_exceeded",sh="foreground_required",ah="View these completions in the foreground before marking them read.",jw=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.owner_audit.conversations","team_bridge.owner_audit.messages","team_bridge.owner_audit.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","profileProposals.list","profileProposals.get","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","mobile.doctor","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.userAttachments","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","sessions.diff","subagents.diff","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","devices.list","operator.setup.read","mobile.password","usage.get"]),$w=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Dw(e,t){const n=Math.round(t/1e3),r=il;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"||e==="approvals.approveCredential"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:Cw.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:jw.has(e)?{code:r,message:$w.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const GM=cw,zM=lw;s.object({state:s.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:s.string(),kind:s.enum(["balance","subscription","radient","none"]),model_free:s.boolean(),title:s.string(),body:s.string(),actions:s.array(s.object({id:s.enum(["open_url","resend_verification","refresh"]),label:s.string(),url:s.string().nullable().optional()})),resets_at_ms:s.number().int().nullable().optional(),checked_at_ms:s.number().int(),age_ms:s.number().int().nullable().optional(),source:s.enum(["cached","live"])});function Nw(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function wu(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function aa(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function ca(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function ku(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function ro(e){const t=new URLSearchParams;return e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id),t.size?`?${t.toString()}`:""}function wi(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function Lw(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"profileProposals.list":return{path:`/v1/desktop/profile-proposals?state=${e.state??"pending"}`,method:"GET"};case"profileProposals.get":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}`,method:"GET"};case"profileProposals.accept":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}/accept`,method:"POST",body:{request_id:e.requestId,...e.after?{after:e.after}:{}}};case"profileProposals.reject":return{path:`/v1/desktop/profile-proposals/${encodeURIComponent(e.proposalId)}/reject`,method:"POST",body:{request_id:e.requestId,...e.note?{note:e.note}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"approvals.approveOperation":case"approvals.applyOperation":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/${e.op==="approvals.approveOperation"?"approve-operation":"apply-operation"}`,method:"POST",body:{operation:e.operation,request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest}};case"approvals.pairAck":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/pair-ack`,method:"POST",body:{request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest,...e.code!==void 0?{code:e.code}:{}}};case"devices.list":return{path:"/v1/desktop/devices",method:"GET"};case"devices.remove":return{path:`/v1/desktop/devices/${encodeURIComponent(e.deviceId)}`,method:"DELETE"};case"mobile.password":return{path:"/v1/desktop/mobile/password",method:"GET"};case"operator.setup.read":return{path:"/v1/desktop/operator/setup",method:"GET"};case"operator.setup.run":return{path:"/v1/desktop/operator/setup",method:"POST",body:{}};case"approvals.approveCredential":case"approvals.applyCredential":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/${e.op==="approvals.approveCredential"?"approve-credential":"apply-credential"}`,method:"POST",body:{operation:e.operation,request_digest:e.requestDigest,disclosure_digest:e.disclosureDigest}};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:ku(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:ku(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.adoptionStrategy!==void 0?{adoption_strategy:e.adoptionStrategy}:{},...e.allowLlm!==void 0?{allow_llm:e.allowLlm}:{},...e.confirm!==void 0?{confirm:e.confirm}:{},...e.adoptionReceipt!==void 0?{adoption_receipt:e.adoptionReceipt}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),e.include_temporary&&t.set("include_temporary","true"),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??fy)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.temporary":return{path:`/v1/desktop/sessions/${e.sessionId}/temporary`,method:"POST",body:{temporary:e.temporary}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{},...e.temporary?{temporary:!0}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),ts(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.files.download":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/download`,method:"POST"};case"sessions.userAttachments":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments`,method:"GET"};case"sessions.userAttachments.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments/${encodeURIComponent(e.digest)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1"),t.set("diff_bindings","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),ts(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??hy)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.entryId&&t.set("entry_id",e.entryId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.diff":case"subagents.diff":{const t=new URLSearchParams({start:String(e.start),offset:String(e.offset??0),limit:String(e.limit)}),n=encodeURIComponent(e.callId);return{path:`/v1/desktop/sessions/${e.op==="subagents.diff"?`${e.sessionId}/children/${e.childId}`:e.sessionId}/tool-calls/${n}/diff?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],...e.files?.length?{files:e.files}:{},mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.profileActionStatus":return{path:`/v1/desktop/sessions/${e.sessionId}/profile-action-status`,method:"POST",body:{action_id:e.actionId,receipt_id:e.receiptId,profile_kind:e.profileKind,profile_name:e.profileName,tool_call_id:e.toolCallId}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{},...e.dismiss===!0?{dismiss:!0,...e.reason!==void 0?{reason:e.reason}:{}}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"settingsIntents.list":return{path:e.sessionId?`/v1/desktop/settings-intents?session_id=${e.sessionId}`:"/v1/desktop/settings-intents",method:"GET"};case"settingsIntents.submit":return{path:`/v1/desktop/sessions/${e.sessionId}/settings-intents`,method:"POST",body:{request_id:e.requestId,kind:e.kind,value:e.value,...e.effort!==void 0?{effort:e.effort}:{}}};case"settingsIntents.dismiss":return{path:`/v1/desktop/sessions/${e.sessionId}/settings-intents/${e.kind}?generation=${e.generation}`,method:"DELETE"};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{ca(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...aa(e)}}}case"agent.republish":{ca(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...aa(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{ca(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:aa(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...Nw(e),message:e.message,...wu(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...wu(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/monitors?${t}`:"/v1/desktop/monitors",method:"GET"}}case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"usage.reset":{const t={provider:e.provider,redeem_request_id:e.redeemRequestId};return e.credentialRef&&(t.credential_ref=e.credentialRef),e.identity&&(t.identity=e.identity),{path:"/v1/desktop/usage/reset",method:"POST",body:t}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"skills.create":return{path:"/v1/desktop/skills",method:"POST",body:{request_id:e.requestId,name:e.name,copy_from:e.copyFrom}};case"skills.update":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"PUT",body:{request_id:e.requestId,expected_fingerprint:e.expectedFingerprint,files:e.files}};case"skills.remove":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"DELETE",body:{request_id:e.requestId,discard_local_changes:e.discardLocalChanges}};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"mobile.doctor":return{path:"/v1/desktop/mobile/doctor",method:"GET"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${wi(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.onboarding.dismiss":return{path:"/v1/desktop/team-bridge/onboarding/dismiss",method:"POST"};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${wi(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),e.status&&t.set("status",e.status),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${wi(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}${e.action==="join"?"":ro(e)}`,method:"POST",...e.action==="join"&&(e.tenant_id||e.expected_account_id)?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id||e.expected_account_id?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.leave":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/leave${ro(e)}`,method:"POST"};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.agent_notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/agent-notify`,method:"PUT",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${ro(e)}`,method:"DELETE"};case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}${ro(e)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,...e.consent_version?{consent_version:e.consent_version}:{},...e.endpoint_id?{endpoint_id:e.endpoint_id}:{}}};case"team_bridge.owner_audit.conversations":case"team_bridge.owner_audit.messages":case"team_bridge.owner_audit.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit));let n="/v1/desktop/team-bridge/owner-audit/conversations";return e.op==="team_bridge.owner_audit.conversations"?e.cursor!==void 0&&t.set("cursor",e.cursor):(n+=`/${encodeURIComponent(e.conversation_id)}/messages`,e.op==="team_bridge.owner_audit.messages"?e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)):(n+=`/${encodeURIComponent(e.message_id)}/replies`,e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.order!==void 0&&t.set("order",e.order))),{path:`${n}?${t}`,method:"GET"}}case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.typing.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing${wi(e.tenant_id)}`,method:"GET"};case"team_bridge.typing.set":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing`,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.typing.clear":{const t=new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id});return e.thread_root_id&&t.set("thread_root_id",e.thread_root_id),{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/typing?${t}`,method:"DELETE"}}case"agent_messages.settings.share_typing":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,share_typing:e.share_typing}};case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id}}:{path:`${t}${ro(e)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{},...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.files?.length?{files:e.files}:{},...e.mentions?.length?{mentions:e.mentions}:{}}};case"team_bridge.scheduled.list":return{path:`/v1/desktop/team-bridge/scheduled?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"GET"};case"team_bridge.scheduled.create":return{path:"/v1/desktop/team-bridge/scheduled",method:"POST",body:{tenant_id:e.tenant_id,conversation_id:e.conversation_id,client_ref:e.client_ref,body:e.body,send_at:e.send_at,...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.scheduled.update":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"PATCH",body:{...e.body===void 0?{}:{body:e.body},...e.send_at===void 0?{}:{send_at:e.send_at},...e.attachment_ids===void 0?{}:{attachment_ids:e.attachment_ids},...e.expected_version===void 0?{}:{expected_version:e.expected_version}}};case"team_bridge.attachments.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/attachments/${encodeURIComponent(e.attachment_id)}?${new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id})}`,method:"DELETE"};case"team_bridge.scheduled.cancel":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"DELETE"};case"team_bridge.messages.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.order!==void 0&&t.set("order",e.order);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.thread_read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/read`,method:"POST",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,seq:e.seq}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.link_preview.resolve":return{path:"/v1/desktop/team-bridge/link-preview/resolve",method:"POST",body:{url:e.url,index:e.index,expected_account_id:e.expectedAccountId}};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"notification_sounds.list":return{path:"/v1/notification-sounds",method:"GET"};case"notification_sounds.rename":return{path:`/v1/notification-sounds/${e.id}`,method:"PATCH",body:{name:e.name}};case"notification_sounds.remove":return{path:`/v1/notification-sounds/${e.id}`,method:"DELETE"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.for_session":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/projects`,method:"GET"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??Ky)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}};case"notifications.list":{const t=new URLSearchParams;e.preview&&t.set("preview","true"),e.includeAskReads&&t.set("include_ask_reads","true"),e.includeSessionCounts&&t.set("include_session_counts","true");for(const n of e.countSessionIds??[])t.append("count_session_ids",n);return e.kind&&t.set("kind",e.kind),e.bulkPriority&&t.set("bulk_priority",e.bulkPriority),e.state&&t.set("state",e.state),e.source&&t.set("source",e.source),e.priority&&t.set("priority",e.priority),e.sessionId&&t.set("session_id",e.sessionId),e.cursor&&t.set("cursor",e.cursor),e.throughSeq!==void 0&&t.set("through_seq",String(e.throughSeq)),e.limit!==void 0&&t.set("limit",String(e.limit)),{path:`/v1/desktop/notifications${t.size?`?${t}`:""}`,method:"GET"}}case"notifications.get":return{path:`/v1/desktop/notifications/${encodeURIComponent(e.id)}`,method:"GET"};case"notifications.count":return{path:"/v1/desktop/notifications/count",method:"GET"};case"notifications.read":case"notifications.dismiss":return{path:"/v1/desktop/notifications",method:"PATCH",body:{op:e.verb,...Fw(e.target)}};case"notifications.seen":return{path:"/v1/desktop/notifications/seen",method:"POST",body:{items:e.items.map(t=>({id:t.id,revision:t.revision,anchor_id:t.anchorId,visible_since_ms:t.visibleSinceMs})),evidence:{surface:"desktop",session_id:e.evidence.sessionId,input_kind:Jy[e.evidence.inputKind],input_at_ms:e.evidence.inputAtMs,visible_since_ms:e.evidence.visibleSinceMs}}}}}function Fw(e){return"selectionToken"in e?{selection_token:e.selectionToken,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{},...e.excludedIds?{excluded_ids:e.excludedIds}:{}}:"operationToken"in e?{operation_token:e.operationToken,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{}}:"items"in e?{...e.receipt?{receipt:!0,through_seq:e.throughSeq,...e.reconcileIds?{reconcile_ids:e.reconcileIds}:{}}:{},ids:e.items.map(t=>({id:t.id,revision:t.revision}))}:"sessionId"in e?{session_id:e.sessionId,through_seq:e.throughSeq,observed:e.observed}:{all:!0,through_seq:e.throughSeq,observed:e.observed}}const KM=64,VM=64*1024*1024,ZM="superseded_completion_token",YM="store_busy",Uw="session_is_remote",Bw="owner_build_behind";function XM(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function Tr(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Hw(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const JM=e=>typeof e?.goal_status=="string",QM=e=>(e?.goal??"").trim().length>0;function Ww(e,t,n={}){return!e||e.epoch!==t.epoch?!0:t.seq>e.seq||n.allowEqual===!0&&t.seq===e.seq}function Gw(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const ko={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."};function zw(e){return e?e===ko.notPaired?"notPaired":e===ko.serverDown?"serverDown":e===ko.frameBudget?"frameTooLarge":"lost":"lost"}const Kw=/^[a-f0-9]{12}$/,Vw=/^[a-zA-Z0-9_-]{1,128}$/,Zw=()=>performance.timeOrigin+performance.now();function Yw(e){e&&(e.rendererEntryEpochMs=Zw())}function sl(e,t){e&&(e.delivery=t,e.deliveryAt=performance.now())}function Xw(e,t,n,r){const o=a=>a===void 0?"-":a.toFixed(3),i=(a,c)=>a===void 0||c===void 0?void 0:a-c;return["[snapshot-receipt]",`openToken=${t??"-"}`,`session=${Kw.test(e.sessionId)?e.sessionId:"?"}`,`streamId=${Vw.test(e.streamId)?e.streamId:"?"}`,"kind=snapshot",`chars=${e.chars}`,`mainRecordEpochMs=${o(e.mainRecordEpochMs)}`,`mainFoldMs=${o(e.mainFoldMs)}`,`mainObserverMs=${o(e.mainObserverMs)}`,`mainEmitMs=${o(e.mainEmitMs)}`,`mainSendEpochMs=${o(e.mainSendEpochMs)}`,`ipcApproxMs=${o(i(e.preloadReceiptEpochMs,e.mainSendEpochMs))}`,`preloadReceiptEpochMs=${o(e.preloadReceiptEpochMs)}`,`preloadReadyMs=${o(e.preloadReadyMs)}`,`bridgeApproxMs=${o(i(e.rendererEntryEpochMs,e.preloadReceiptEpochMs===void 0||e.preloadReadyMs===void 0?void 0:e.preloadReceiptEpochMs+e.preloadReadyMs))}`,`rendererEntryEpochMs=${o(e.rendererEntryEpochMs)}`,`delivery=${e.delivery??"-"}`,`bufferMs=${o(i(e.deliveryAt,e.bufferedAt))}`,`deliveryToParseMs=${o(i(n,e.deliveryAt))}`,`parseMs=${o(r-n)}`].join(" ")}const Su=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(r,o,c);return c},Jw=e=>e?Su(e):Su,Qw=e=>e;function qw(e,t=Qw){const n=Sd.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return Sd.useDebugValue(n),n}const Eu=e=>{const t=Jw(e),n=r=>qw(t,r);return Object.assign(n,t),n},oi=e=>e?Eu(e):Eu;function ch(e,t){let n;try{n=e()}catch{return}return{getItem:o=>{var i;const a=l=>l===null?null:JSON.parse(l,void 0),c=(i=n.getItem(o))!=null?i:null;return c instanceof Promise?c.then(a):a(c)},setItem:(o,i)=>n.setItem(o,JSON.stringify(i,void 0)),removeItem:o=>n.removeItem(o)}}const tc=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return tc(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return tc(r)(n)}}}},e0=(e,t)=>(n,r,o)=>{let i={storage:ch(()=>localStorage),partialize:v=>v,version:0,merge:(v,b)=>({...b,...v}),...t},a=!1;const c=new Set,l=new Set;let d=i.storage;if(!d)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...v)},r,o);const u=()=>{const v=i.partialize({...r()});return d.setItem(i.name,{state:v,version:i.version})},f=o.setState;o.setState=(v,b)=>{f(v,b),u()};const h=e((...v)=>{n(...v),u()},r,o);o.getInitialState=()=>h;let _;const y=()=>{var v,b;if(!d)return;a=!1,c.forEach(A=>{var k;return A((k=r())!=null?k:h)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(v=r())!=null?v:h))||void 0;return tc(d.getItem.bind(d))(i.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==i.version){if(i.migrate){const k=i.migrate(A.state,A.version);return k instanceof Promise?k.then(M=>[!0,M]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var k;const[M,P]=A;if(_=i.merge(P,(k=r())!=null?k:h),n(_,!0),M)return u()}).then(()=>{p?.(_,void 0),_=r(),a=!0,l.forEach(A=>A(_))}).catch(A=>{p?.(void 0,A)})};return o.persist={setOptions:v=>{i={...i,...v},v.storage&&(d=v.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>y(),hasHydrated:()=>a,onHydrate:v=>(c.add(v),()=>{c.delete(v)}),onFinishHydration:v=>(l.add(v),()=>{l.delete(v)})},i.skipHydration||y(),_||h},Is=e0,t0=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function n0(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,o)=>typeof r=="number"&&Number.isFinite(r)?r:o;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const lh=oi()(Is(e=>({notice:null,receive:t=>e(n=>t0(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:ch(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));function Qn(e){return g(sw[e])}let nc=null;function r0(e){if(e===null){nc=null;return}nc={openFrame:e.openFrame===!0,journalOrder:e.journalOrder===!0,peerJournalSource:e.peerJournalSource===!0}}function dh(){return nc}const Iu=()=>g("ui.common.errors.desktop_backend_offline"),o0=()=>g("ui.common.errors.desktop_backend_compatibility");async function uh(e){if(window.api?.desktop)try{return await i0(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ae?n:u0(n)?new _n(ah,sh):new Ae(null,Iu(),n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ae(null,Iu(),n)}if(!t.ok)throw new Ae(t.status,o0());return t.json()}function i0(e,t){const n=ih(t);let r;return Promise.race([e,new Promise((o,i)=>{r=setTimeout(()=>{const a=Dw(t.op,n);i(new Ae(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const fh="This server did not answer the request for its desktop controls.",s0=()=>g("ui.common.errors.desktop_refusal_placeholder");class Ae extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,o,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=o,this.retryAfterMs=i,this.detail=a}}class _n extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function al(e){return e instanceof Ae||e instanceof _n?e.code===We.serverUpdating?!0:e instanceof Ae&&ew(e.detail):!1}function qM(e){return e instanceof Ae&&tw(e.detail)}function ns(e,t){return al(e)?Qn(We.serverUpdating):e instanceof Ae||e instanceof _n?Es(e.code)?Qn(e.code):e.message===fh?s0():e.message:t}function a0(e,t,n,r){return r===eh&&t===503?We.serverUpdating:typeof r=="string"?r:n===qp&&t===503?We.serverUpdating:n===ec.noCredential?We.noCredential:n===ec.transportFailed?We.transportFailed:aw(Lw(e).path,t)}async function Ge(e){const t=await uh(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ae(t.status,r??fh,void 0,a0(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&c0(n?.result),n?.result}function c0(e){if(typeof e!="object"||e===null)return;const t=n0(e.delegated_cleanup_notice);t&&lh.getState().receive(t)}async function l0(){try{await Ge({op:"delegated_cleanup_notice.ack"})}catch{}}async function ej(){lh.getState().dismiss(),await l0()}function d0(e){return e instanceof Ae&&e.code===il}function tj(e){if(!(e instanceof Ae))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===Bw:e.code===Uw}function nj(e){return e instanceof _n&&e.code===sh}function u0(e){return e instanceof Error&&e.message.includes(ah)}async function rj(e){const t=await uh(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function oj(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Ge({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function f0(e,t,n){const r=b0(e);return r.record?(n?.("adopted"),Au(e.sessionId,"adopted","none",rc(e),null),w0(r.record,t)):(Kt&&pn(),n?.("requested"),Au(e.sessionId,"requested",r.refusal,rc(e),r.held),ph(e,t))}const p0=6e4,h0=512;function rc(e){return{openFrame:e.openFrame===!0,journalOrder:e.journalOrder===!0,peerJournalSource:e.peerJournalSource===!0}}let Kt=null,qn=null;function pn(){qn!==null&&(clearTimeout(qn),qn=null);const e=Kt;Kt=null,e&&(e.live=null,e.buffered=[],e.disposeTransport())}function m0(){return Kt?.sessionId??null}function g0(e){!e||Kt?.sessionId!==e||pn()}function _0(e,t){if(!e||Kt?.sessionId===e)return;pn();const n=dh(),r={openFrame:n?.openFrame===!0,journalOrder:n?.journalOrder===!0,peerJournalSource:n?.peerJournalSource===!0&&t?.remoteOwned===!0};let o=!1;const i={sessionId:e,negotiation:r,buffered:[],live:null,ended:!1,disposeTransport:()=>{}};if(i.disposeTransport=ph({sessionId:e,...r.openFrame?{openFrame:!0}:{},...r.journalOrder?{journalOrder:!0}:{},...r.peerJournalSource?{peerJournalSource:!0}:{}},c=>{if(i.live){sl(c.receipt,"live"),i.live(c);return}if(c.kind==="error"||c.kind==="end"){i.ended=!0,o=!0,pn();return}if(i.buffered.length>=h0){o=!0,pn();return}c.receipt&&(c.receipt.bufferedAt=performance.now()),i.buffered.push(c)}),o){i.disposeTransport();return}Kt=i;const a=setTimeout(()=>{Kt===i&&pn()},p0);typeof a.unref=="function"&&a.unref(),qn=a}function b0(e){const t=Kt;if(!t)return{record:null,refusal:"none",held:null};if(t.ended)return pn(),{record:null,refusal:"ended",held:t.negotiation};if(t.sessionId!==e.sessionId)return{record:null,refusal:"other-session",held:null};const n=rc(e);return e.epoch!==void 0||e.afterSeq!==void 0||(e.orderIds?.length??0)>0?(pn(),{record:null,refusal:"resuming",held:t.negotiation}):n.openFrame!==t.negotiation.openFrame||n.journalOrder!==t.negotiation.journalOrder||n.peerJournalSource!==t.negotiation.peerJournalSource?(pn(),{record:null,refusal:"negotiation",held:t.negotiation}):{record:t,refusal:null,held:t.negotiation}}const v0=/^[A-Za-z0-9_-]{1,80}$/,y0="[stream-prewarm]";function Au(e,t,n,r,o){if(t==="requested"&&n==="none")return;const i=v0.test(e)?e:"?",a=l=>[l.openFrame?"1":"0",l.journalOrder?"1":"0",l.peerJournalSource?"1":"0"].join(","),c=[y0,`session=${i}`,`decision=${t}`];t==="requested"&&(c.push(`why=${n}`,`asked=${a(r)}`),o&&c.push(`prewarm=${a(o)}`),n==="negotiation"&&c.push(`caps=${dh()?"recorded":"absent"}`)),console.warn(c.join(" "))}function w0(e,t){const n=e.buffered;e.buffered=[],e.live=t,qn!==null&&(clearTimeout(qn),qn=null),Kt===e&&(Kt=null);let r=!1;return queueMicrotask(()=>{if(!r)for(const o of n)sl(o.receipt,"replay"),t(o)}),()=>{r||(r=!0,e.live=null,e.disposeTransport())}}function ph(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,a=>{const c=a.receipt?{...a,receipt:{...a.receipt}}:a;Yw(c.receipt),sl(c.receipt,"direct"),t(c)});return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&(r.set("open_frame","1"),r.set("diff_bindings","1")),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),ts(r,"/__desktop/stream",e.orderIds??[]));const o=new EventSource(`/__desktop/stream?${r}`);return o.onmessage=i=>{t({kind:"data",data:i.data})},o.onerror=()=>{o.readyState===EventSource.CLOSED&&(t({kind:"error",detail:ko.ended}),o.close())},()=>{o.close(),t({kind:"end"})}}async function ij(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),o=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a,c;if(o.includes("application/json"))try{const l=await r.json();qy(r.status,l)&&(a=We.serverUpdating);const d=l?.detail;if(typeof d=="string")i=d;else if(typeof d=="object"&&d!==null){const u=d;typeof u.text=="string"&&u.text.trim()?i=u.text:typeof u.message=="string"&&u.message.trim()&&(i=u.message),typeof u.code=="string"&&a===void 0&&(a=u.code);const f=d.params;typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&Es(a)?a:i===ec.noCredential?We.noCredential:void 0,...e.op==="notification_sounds.upload"&&a!==void 0?{refusal:{code:a.slice(0,64),...c?{params:c}:{}}}:{}}}return o.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:o||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function sj(e){return e.kind==="error"?Es(e.code)?new _n(Qn(e.code),e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}function k0(e){if(al(e))return"updating";if(d0(e))return"deadline";const t=e instanceof Ae?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const hh={updating:"",unreachable:"",deadline:"",unauthorized:"",get outdated(){return g("ui.common.connection.backend.remedy_outdated")},unknown:""},Fi={get updating(){return Qn(We.serverUpdating)},get unreachable(){return g("ui.common.connection.backend.diagnosis_unreachable")},get deadline(){return g("ui.common.connection.backend.diagnosis_deadline")},get unauthorized(){return g("ui.common.connection.backend.diagnosis_unauthorized")},get outdated(){return g("ui.common.connection.backend.diagnosis_outdated")},unknown:""};function S0(e,t){const n=k0(t);return[e,Fi[n],hh[n]].filter(Boolean).join(" ")}const oc={get successor(){return g("ui.common.connection.backend.pairing_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.pairing_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.pairing_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.pairing_credential_refused")},get unpaired(){return g("ui.common.connection.backend.pairing_unpaired")}},E0={get successor(){return g("ui.common.connection.backend.pane_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.pane_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.pane_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.pane_credential_refused")},get unpaired(){return g("ui.common.connection.backend.pane_unpaired")}};function aj(e,t){return e!=="unpaired"?null:E0[t??"unpaired"]}function cj(e,t){return e!=="unpaired"?null:oc[t??"unpaired"]}function lj(e){const{kind:t,unpaired:n,answered:r,cause:o=null,servedByThisApp:i=!1}=e;return o==="pre-handshake"?i:o!==null||n?!1:r?i:t==="outdated"}function dj(e){const{kind:t,unpaired:n,missing:r,answered:o,cause:i=null}=e;if(i!==null)return oc[i];if(!o){if(t==="updating")return Fi.updating;if(t==="unreachable")return g("ui.common.connection.backend.compatibility_unreachable",{diagnosis:Fi.unreachable});if(t==="unauthorized")return g("ui.common.connection.backend.compatibility_unauthorized");if(t==="deadline")return g("ui.common.connection.backend.compatibility_deadline",{diagnosis:Fi.deadline});if(t==="outdated")return g("ui.common.connection.backend.compatibility_outdated",{remedy:hh.outdated})}return n?oc.unpaired:o?g("ui.common.connection.backend.compatibility_missing",{features:r.join(", ")}):g("ui.common.connection.backend.compatibility_unknown")}const I0=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function uj(e,t=null){return t!==null||!e?!0:I0.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function A0(e,t){return t instanceof Ae&&t.status===null?!1:e<1}function fj(e,t){return t instanceof Ae&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const R0={get successor(){return g("ui.common.connection.backend.card_successor")},get"governed-elsewhere"(){return g("ui.common.connection.backend.card_governed")},get"pre-handshake"(){return g("ui.common.connection.backend.card_pre_handshake")},get"credential-refused"(){return g("ui.common.connection.backend.card_credential_refused")},get unpaired(){return g("ui.common.connection.backend.card_unpaired")}};function pj(e,t,n){return e===null?{sentence:S0(t,n),remedy:!0}:{sentence:R0[e],remedy:Np(e)}}const mh={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],commandsFor:e=>["desktop","commands",e],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},x0=3e4,T0=15e3;function C0(e){return e?.desktop_available===!0}function hj(){const{client:e,provided:t}=Pb();return Dp({enabled:t,queryKey:mh.capabilities,queryFn:async()=>{try{const n=await Ge({op:"capabilities"});return r0(P0(n)),n}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>C0(n.state.data)?x0:T0,refetchIntervalInBackground:!0},e)}function O0(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function la(e,t,n=1){return O0(e,t,n)==="enabled"}function P0(e){return{openFrame:la(e,"open_frame"),journalOrder:la(e,"journal_order"),peerJournalSource:la(e,"peer_journal_source")}}function mj(e){return Dp({queryKey:mh.providers,queryFn:()=>Ge({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:A0})}let As=!1,rs=!1;const os=[];function gj(){typeof window>"u"||!window.__loDevDriver?.armed||(As=!0,rs=!1,os.length=0)}function M0(){return As}function j0(e){if(As)try{if(os.length>=256){rs=!0;return}os.push({carrier:e.carrier,sessionId:e.sessionId,epoch:typeof e.epoch=="string"?e.epoch:null,seq:typeof e.seq=="number"?e.seq:null,disposition:e.disposition})}catch{rs=!0}}function _j(){return{armed:As,fault:rs,receipts:os.map(e=>({...e}))}}const oo=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function gh(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const c=oo(a);return c===null||!n.has(c)});for(const a of t.upserted??[]){const c=oo(a);if(c===null){r.push(a);continue}const l=r.findIndex(d=>oo(d)===c);l===-1?r.push(a):r[l]=a}if(!t.order)return r;const o=new Map;for(const a of r){const c=oo(a);c!==null&&o.set(c,a)}const i=[];for(const a of t.order){const c=String(a),l=o.get(c);l&&(i.push(l),o.delete(c))}for(const a of r){const c=oo(a);c!==null&&o.has(c)?(i.push(a),o.delete(c)):c===null&&i.push(a)}return i}const ic=e=>({revision:xt(e),demand:e.orderDemand}),er=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Gr(e,t,n,r,o,i={}){let a=e;const c=t.journal_generation;if(t.reconcile===!0){const h=typeof c=="string"&&c.length>0?c:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===h?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:h,orderDemand:h!==void 0?{generation:h}:{}}}if(typeof c!="string"||c.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&o&&a.orderNeedsReconcile&&a.orderDemand===o.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),c!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===c?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:c,orderDemand:{generation:c}};let l=a.journalMode?a:{...a,journalMode:!0};if(c!==a.journalGeneration&&(l={...a,journalMode:!0,journalGeneration:c,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const h=(a.orderRevision??0)+1,_=new Map;for(const y of a.records){const v=y.sourceEntryId??(y.kind==="tool"||y.kind==="supplement"?null:y.id);typeof v=="string"&&v.length>0&&v.length<=128&&_.set(v,h)}l={...l,..._.size>0?{journalBodyOwed:_}:{},journalSourceVoid:void 0}}let d=l.journalPositions??new Map;const u=d,f=(h,_,y)=>{if(!er(y))return;const v=d.get(h);v&&v.seq>=y||(d===u&&(d=new Map(d)),d.set(h,{entryId:_,seq:y}))};for(const[h,_]of Object.entries(t.journal_ordinals??{}))f(h,h,_);for(const h of n)typeof h.id=="string"&&(f(h.id,h.id,h.journal_seq),h.role==="tool"&&typeof h.tool_call_id=="string"&&f(`tool:${h.tool_call_id}`,h.id,h.journal_seq),typeof h.anchor=="string"&&f(`supplement:${h.anchor}`,h.id,h.journal_seq));return d!==u&&(l={...l,journalPositions:d}),l}function cl(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const o=n,i=r;return t.tool_calls.forEach((a,c)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===o&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==c&&(r===i&&(r=new Map(r)),r.set(a.id,c)))}),n===o&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function _h(e,t){const n=new Set(e.map(i=>i.id));let r=!1,o;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){o=a;continue}if(a.sourcePrecedes!==void 0){if(a.sourceAdmissionAnchor!==void 0){const{sourceAdmissionAnchor:c,...l}=a;e[i]=l,r=!0}o=e[i];continue}!t(a)&&o&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:o.id},r=!0),o=e[i]}return r}function bh(e,t,n,r,o){const i=[],a=new Set;let c=e,l;for(;c!==void 0;){if(o.has(c.id)){l=o.get(c.id);break}if(n(c)){l=r(c);break}if(c.kind==="user"&&c.provisional===!0||a.has(c.id))break;a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor?t.get(c.sourceAdmissionAnchor):void 0}for(const d of i)o.set(d,l);return l}const $0=Number.MAX_SAFE_INTEGER;function D0(e,t){const n=new Map,r=new Map,o=new Map;for(const i of e){if(i.sourcePrecedes===void 0)continue;const a=t(i);if(a!==void 0)r.set(i.sourcePrecedes,a);else{const c=r.get(i.sourcePrecedes);c!==void 0&&n.set(i.id,{seq:c,slot:$0})}}for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.sourcePrecedes===void 0)continue;const c=t(a);if(c!==void 0)o.set(a.sourcePrecedes,c);else if(!n.has(a.id)){const l=o.get(a.sourcePrecedes);l!==void 0&&n.set(a.id,{seq:l,slot:-1})}}return n}function vh(e,t){return{floor:N0(e,t),position:new Map(e.map((n,r)=>[n.id,r])),page:D0(e,t)}}function yh(e,t,n,r){if(r===void 0||e.sourcePrecedes===void 0)return;const o=r.page.get(e.id);if(o!==void 0)return o;const i=new Set;let a=1,c=t.get(e.sourcePrecedes);for(;c!==void 0&&!i.has(c.id);){i.add(c.id);const l=n(c);if(l!==void 0)return{seq:l,slot:-a};const d=r.page.get(c.id);if(d!==void 0)return{seq:d.seq,slot:d.slot-a};a+=1,c=c.sourcePrecedes?t.get(c.sourcePrecedes):void 0}return r.floor===void 0?void 0:{seq:r.floor,slot:-a}}function wh(e,t,n){if(n===void 0||e.sourcePrecedes===void 0)return;const{position:r}=n,o=new Set;let i=1,a=t.get(e.sourcePrecedes);for(;a!==void 0&&!o.has(a.id);){if(a.sourcePrecedes===void 0){const c=r.get(a.id);return c===void 0?void 0:{slot:c,depth:i}}o.add(a.id),i+=1,a=t.get(a.sourcePrecedes)}}function N0(e,t){let n;for(const r of e){if(r.sourcePrecedes!==void 0)continue;const o=t(r);o!==void 0&&(n===void 0||o<n)&&(n=o)}return n}function kh(e,t){const n=new Map;return r=>{if(!r)return;const o=t(r);if(o===void 0)return;const i=[],a=new Set;let c=r,l=!0;for(;c;){if(n.has(c.id)){l=n.get(c.id)===!0;break}if(a.has(c.id)||t(c)===void 0){l=!1;break}a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor===void 0?void 0:e.get(c.sourceAdmissionAnchor)}for(const d of i)n.set(d,l);return l?o:void 0}}function is(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const o=new Map;t.forEach((a,c)=>{if(a.kind!=="tool")return;const l=n.get(a.toolCallId);if(l===void 0||!r.has(a.toolCallId))return;const d=o.get(l);d?d.push(c):o.set(l,[c])});let i=t;for(const a of o.values()){if(a.length<2)continue;const c=a.map(l=>t[l]).sort((l,d)=>(r.get(l.toolCallId)??0)-(r.get(d.toolCallId)??0));c.every((l,d)=>l===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((l,d)=>{i[l]=c[d]}))}return i}function Sh(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return L0(e,t);const n=e.journalGeneration,r=e.journalPositions;let o=!1,i=!1;const a=t.map(v=>{v.sourcePrecedes!==void 0&&(i=!0);let p=[r?.get(v.sourceEntryId??v.id),r?.get(v.id)].filter(M=>M!==void 0).sort((M,P)=>P.seq-M.seq)[0];if(v.journalGeneration===n&&er(v.journalSeq)&&(!p||v.journalSeq>p.seq)&&(p={entryId:v.sourceEntryId??v.id,seq:v.journalSeq}),!p||!n||!(v.kind==="user"&&(v.provisional===!0||v.local===!0))&&v.sourceEntryId===p.entryId&&v.journalSeq===p.seq&&v.journalGeneration===n)return v;o=!0;let k={...v,sourceEntryId:p.entryId,journalSeq:p.seq,journalGeneration:n};if(k.kind==="user"){const{provisional:M,local:P,...W}=k;k=W}return k});_h(a,v=>v.journalGeneration===n&&er(v.journalSeq))&&(o=!0);const l=new Map,d=new Map(a.map(v=>[v.id,v])),u=kh(d,v=>v!==void 0&&v.journalGeneration===n&&er(v.journalSeq)?v.journalSeq:void 0),f=v=>u(v)!==void 0,h=i?vh(a,u):void 0,_=(v,b)=>{const p=u(v);if(v.kind==="user"&&v.provisional===!0&&p===void 0)return[1,0,0,0,b];const A=v.kind==="supplement"?v.anchor:v.kind==="tool"?e.journalCallOwners?.get(v.toolCallId)??e.argsByCall.get(v.toolCallId)?.anchorId:void 0,k=typeof A=="string"?u(d.get(A)):void 0,M=k===void 0&&p===void 0?yh(v,d,u,h):void 0,P=p===void 0&&M===void 0?bh(v,d,f,u,l):void 0,W=k??p??M?.seq??P;if(W===void 0){const R=wh(v,d,h);return[1,R?.slot??b,R?-R.depth:0,0,b]}return[0,W,k!==void 0?1:p!==void 0?0:M!==void 0?M.slot:2,p??Number.MAX_SAFE_INTEGER,b]},y=a.map((v,b)=>({record:v,index:b,rank:_(v,b)}));return y.sort((v,b)=>{for(let p=0;p<v.rank.length;p++){const A=v.rank[p]-b.rank[p];if(A)return A}return 0}),!o&&y.every((v,b)=>v.index===b)?is(e,t):is(e,y.map(v=>v.record))}function L0(e,t){const n=e.journalGeneration,r=e.journalPositions,o=new Map;let i=!1;for(const p of t){p.sourcePrecedes!==void 0&&(i=!0);let k=[r?.get(p.sourceEntryId??p.id),r?.get(p.id)].filter(M=>M!==void 0).sort((M,P)=>P.seq-M.seq)[0];p.journalGeneration===n&&er(p.journalSeq)&&(!k||p.journalSeq>k.seq)&&(k={entryId:p.sourceEntryId??p.id,seq:p.journalSeq}),k&&o.set(p.id,k)}const a=p=>p===void 0?void 0:o.get(p.id)??r?.get(p.sourceEntryId??p.id)??r?.get(p.id);let c=!1;const l=t.slice();_h(l,p=>p.journalGeneration===n&&er(p.journalSeq))&&(c=!0);const u=new Map,f=new Map(l.map(p=>[p.id,p])),h=kh(f,p=>a(p)?.seq),_=p=>h(p)!==void 0,y=i?vh(l,h):void 0,v=(p,A)=>{const k=h(p);if(p.kind==="user"&&p.provisional===!0&&k===void 0)return[1,0,0,0,A];const M=p.kind==="supplement"?p.anchor:p.kind==="tool"?e.journalCallOwners?.get(p.toolCallId)??e.argsByCall.get(p.toolCallId)?.anchorId:void 0,P=typeof M=="string"?h(f.get(M)):void 0,W=P===void 0&&k===void 0?yh(p,f,h,y):void 0,R=k===void 0&&W===void 0?bh(p,f,_,h,u):void 0,m=P??k??W?.seq??R;if(m===void 0){const w=wh(p,f,y);return[1,w?.slot??A,w?-w.depth:0,0,A]}return[0,m,P!==void 0?1:k!==void 0?0:W!==void 0?W.slot:2,k??Number.MAX_SAFE_INTEGER,A]},b=l.map((p,A)=>({record:p,index:A,rank:v(p,A)}));return b.sort((p,A)=>{for(let k=0;k<p.rank.length;k++){const M=p.rank[k]-A.rank[k];if(M)return M}return 0}),!c&&b.every((p,A)=>p.index===A)?is(e,t):is(e,b.map(p=>p.record))}function Jt(e){const t=e.records.filter(o=>o.kind==="user"&&o.provisional===!0),n=e.records.filter(o=>o.journalGeneration!==e.journalGeneration||!er(o.journalSeq)),r=[...t,...n].map(o=>o.sourceEntryId??(o.kind==="tool"||o.kind==="supplement"?null:o.id));if(r.push(...ll(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let o=r.length-1;o>=0;o--){const i=r[o];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(o,1)}return[...new Set(r.filter(o=>typeof o=="string"&&o.length>0&&o.length<=128))]}function ll(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const o=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof o=="string"&&o.length>0&&o.length<=128&&t.add(o)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Eh(e,t){const n=e.journalPositions;return Jt(e).filter(r=>!n?.has(r)&&!t?.has(r))}const xt=e=>e.orderRevision??0;async function F0(e){const t=new Map,n=c=>{let l=t.get(c);return l||(l=new Set,t.set(c,l)),l},r=(c,l)=>l==="payload"?ll(c):l==="lookup"?Eh(c):Jt(c);let o=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),l=ic(c),d=l.revision,u=e.sweep?.(c,n);if(u?.kind==="none")return{kind:"complete",transcript:c};const f=u?.kind??"authority",h=Qv(r(c,f).filter(b=>!n(f).has(b)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),_=await e.read(h,f);if(!e.isCurrent()||xt(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(_,d,l),!e.isCurrent())return{kind:"stale"};const y=e.getTranscript(),v=e.page(_);if(v.journal_order_state==="ready"&&v.journal_generation===y.journalGeneration){v.journal_generation!==o&&(t.clear(),o=v.journal_generation);for(const A of h)n(f).add(A);if(y.orderNeedsReconcile){if(y.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const A=(v.source_retry_ids??[]).filter(k=>typeof k=="string"&&k.length>0&&k.length<=128);if(A.length>0&&h.length>1&&a===0){a++;for(const k of A)n("payload").delete(k);continue}}const b=e.sweep?.(y,n);if(b?.kind==="none")return{kind:"complete",transcript:y};const p=b?.kind??"authority";if(r(y,p).some(A=>!n(p).has(A)))continue;return{kind:"complete",transcript:y}}if(!y.orderNeedsReconcile||y.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function Ft(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const o=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof o=="string"&&o?o:e.id}function da(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function Ru(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function bj(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=da(i.action_count);if(a===null)continue;const c={actions:a,workedSeconds:Ru(i.worked_seconds),failed:da(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:da(i.cross_session_action_count),crossSessionWorkedSeconds:Ru(i.cross_session_worked_seconds)};n.set(i.run_key,c),c.openingUserId!==null&&n.set(c.openingUserId,c),c.closingAnswerId!==null&&n.set(c.closingAnswerId,c)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(Ft(i));const o=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:o?Ft(o):null}}}function U0(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const o=Math.round((n.ts??0)*1e3);return o>0?{id:n.id,tsMs:o}:null}function B0(e,t,n){const r=U0(e),o=e?.entries;if(r===null||!o||o.length===0)return!1;const i=Math.round((o[o.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,c]of t)if(!n.has(a)&&(c===null||!(c>r.tsMs)||!(c<i)))return!1;return!0}const H0=new Set(["completed","done","failed","cancelled","interrupted"]);function W0(e,t){const n=new Set;for(const o of t)o.kind==="custom"&&o.jobId&&n.add(o.jobId);const r=[];for(const o of e){const i=o.id==null?"":String(o.id);!i||n.has(i)||H0.has(String(o.status??""))&&r.push(i)}return r}function G0(e,t,n,r){let o=t,i=!1;for(const a of e){const c=a.changes??{};Array.isArray(c.jobs)?o=c.jobs:a.job_deltas&&(o=gh(o,a.job_deltas));const l=c.history_cursor;typeof l=="string"&&l!==""&&!r(l)&&(i=!0)}return i?W0(o,n):[]}const dl=new Set,Dn="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",ul=new RegExp(`[${Dn}]`),z0=new RegExp(`[${Dn}]+`),vj=new RegExp(`[${Dn}]+`,"g"),K0=new RegExp(`^[${Dn}]+|[${Dn}]+$`,"g"),V0=new RegExp(`^[${Dn}]+`),yj=new RegExp(`[^${Dn}]`);function nn(e){return e.replace(K0,"")}function Wo(e){return e.replace(V0,"")}function Ih(e,t){return t===0||ul.test(e[t-1])}function Ah(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&Ih(e,n)&&t.push(n);return t}function fl(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
2
2
|
`,n-1)+1,o=e.indexOf(`
|
|
3
3
|
`,n),i=o===-1?e.length:o;let a=e.slice(r,i);return a.endsWith("\r")&&(a=a.slice(0,-1)),{line:a,lineStart:r,column:n-r}}function Z0(e,t){if(t.size===0)return null;for(const n of Ah(e)){const r=e.slice(n+1),o=r.indexOf(" ");if(o!==-1&&t.has(r.slice(0,o).toLowerCase()))return n}return null}function pl(e,t,n){const r=Z0(e,n);let o=null;for(const i of Ah(e)){if(i===r)return t>i?i:o;i<=t&&(o=i)}return o}function Y0(e,t=null,n=dl){const{line:r,lineStart:o,column:i}=fl(e,t),a=pl(r,i,n);if(a===null)return null;let c=a+1;for(;c<r.length&&!ul.test(r[c]);)c++;return i>c?null:{start:o+a,query:r.slice(a+1,c),end:o+c}}function wj(e,t=null,n=dl){const{line:r,lineStart:o,column:i}=fl(e,t),a=pl(r,i,n);return a===null?null:{start:o+a,end:o+r.length}}function X0(e,t,n=null,r=dl){const{line:o,lineStart:i,column:a}=fl(e,n),c=r.size>0?r:new Set(t.map(_=>_.toLowerCase())),l=pl(o,a,c);if(l===null)return null;const d=o.slice(l+1),u=d.indexOf(" ");if(u===-1)return null;const f=d.slice(0,u);if(!t.some(_=>_.toLowerCase()===f.toLowerCase()))return null;const h=l+1+f.length;return a<=h?null:{value:d.slice(u+1),start:i+h+1,end:i+o.length,tokenStart:i+l}}function xu(e,t){return nn(e.slice(0,t))===""}function kj(e,t,n,r){const o=X0(e,r,t,n);if(o!==null&&xu(e,o.tokenStart))return"argument";const i=Y0(e,t,n);return i!==null&&xu(e,i.start)?"command":null}function Sj(e,t,n,r){let o=t,i=n;const a=c=>c>=0&&c<e.length&&`
|
|
4
4
|
`.includes(e[c]);return r===""?o>0&&a(o-1)?o-=1:a(i)&&(i+=1):o===0&&a(i)&&(i+=1),{text:`${e.slice(0,o)}${r}${e.slice(i)}`,caret:o+r.length}}const J0=1e3,Q0=900,q0=40,Rh=3;function ek(e,t){let n=0,r=-2,o=0;for(const i of e){const a=t.indexOf(i,o);if(a<0)return 0;n+=a===r+1?2:1,r=a,o=a+1}return n<=0?0:Math.max(1,Math.min(q0,n))}function xh(e,t){const n=e.toLowerCase(),r=t.toLowerCase();return n?n===r?J0:r.startsWith(n)?Q0:ek(n,r):0}function tk(e){const n=nn(e).split(z0).pop()??"";return n.startsWith("/")?n.slice(1):n}function nk(e,t){const n=tk(e),r=[];return t.forEach((o,i)=>{let a=0,c=o.name;for(const l of[o.name,...o.aliases]){const d=xh(n,l);d>a&&(a=d,c=l)}a>0&&r.push({score:a,index:i,name:c,command:o})}),r.sort((o,i)=>i.score-o.score||o.index-i.index),r.map(o=>({name:o.name,command:o.command}))}function Ej(e,t){if(!e)return t.map(i=>({name:i.name,command:i}));const n=nk(`/${e}`,t);if(e.length>=Rh)return n;const r=e.toLowerCase(),o=n.filter(({name:i})=>i.toLowerCase().startsWith(r));return o.length>0?o:n}function Tu(e,t){if(!e)return t.map(r=>({name:r.name,choice:r}));const n=[];return t.forEach((r,o)=>{const i=Math.max(0,...[r.name,...r.aliases??[]].map(a=>xh(e,a)));i>0&&n.push({score:i,order:o,choice:r})}),n.sort((r,o)=>o.score-r.score||r.order-o.order),n.map(r=>({name:r.choice.name,choice:r.choice}))}const Cu=/^-+/;function Ij(e,t,n,r,o){if(o)return!0;const i=nn(e).toLowerCase(),a=nn(t).toLowerCase();return i===a||i.length>0&&i.replace(Cu,"")===a.replace(Cu,"")?!0:!r&&n<=1}const rk=new RegExp("\\p{Ll}","u");function Th(e){for(const t of e)if(rk.test(t))return!0;return!1}function Aj(e,t,n){if(n){if(!e)return t.map(a=>({name:a.name,choice:a}));const r=Tu(e,t);if(e.length>=Rh)return r;const o=e.toLowerCase(),i=r.filter(a=>a.name.toLowerCase().startsWith(o));return i.length>0?i:r}return Th(e)?Tu(e,t).filter(r=>r.name.startsWith(e)):[]}const ok=/<skill name="([^"]*)" invocation="([^"]*)">/,ik=/[A-Za-z0-9]/,sk=/[A-Za-z0-9._-]/,ak=/[._-]/;function ck(e,t){if(t>=e.length||!ik.test(e[t]))return t;let n=t+1;for(;n<e.length&&sk.test(e[n]);)n++;return n}function lk(e){const t=[];let n=0;for(;n<e.length;){if(e[n]!=="$"||!Ih(e,n)){n+=1;continue}const r=ck(e,n+1);r>n+1&&t.push({start:n,end:r,name:e.slice(n+1,r)}),n+=Math.max(r-n,1)}return t}function dk(e,t,n,r,o,i){let a=n;for(;;){const c=e.slice(t+1,a);if(r.has(c))return{end:a,name:c};if(i||Th(c)){const l=o.get(c.toLowerCase());if(l!==void 0)return{end:a,name:l}}if(a>t+2&&ak.test(e[a-1])){a-=1;continue}return null}}function uk(e,t,n={}){return Ch(e,t,n.skipSpans??[],!0)}function Rj(e,t,n={}){return Ch(e,t,n.skipSpans??[],!1)}function Ch(e,t,n,r){const o=new Set(t),i=new Map;for(const l of t)i.has(l.toLowerCase())||i.set(l.toLowerCase(),l);const a=[],c=new Set;for(const l of lk(e)){if(n.some(([f,h])=>f<=l.start&&l.start<h))continue;const d=Wo(e.slice(0,l.start))==="",u=dk(e,l.start,l.end,o,i,d);u===null||r&&c.has(u.name)||(c.add(u.name),a.push({start:l.start,end:u.end,text:e.slice(l.start,u.end),name:u.name,leading:d}))}return a}const Cr="<operator-skills>",ss="</operator-skills>",go=`
|