@richhardry/codor 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/node_modules/@codor/adapter-antigravity/package.json +2 -2
- package/node_modules/@codor/adapter-claude-code/package.json +2 -2
- package/node_modules/@codor/adapter-codex/package.json +2 -2
- package/node_modules/@codor/adapter-copilot/package.json +2 -2
- package/node_modules/@codor/adapter-cursor/package.json +2 -2
- package/node_modules/@codor/adapter-gemini/package.json +2 -2
- package/node_modules/@codor/adapter-opencode/package.json +2 -2
- package/node_modules/@codor/cli/dist/setup-ui.d.ts.map +1 -1
- package/node_modules/@codor/cli/dist/setup-ui.js +7 -3
- package/node_modules/@codor/cli/dist/setup-ui.js.map +1 -1
- package/node_modules/@codor/cli/dist/setup.d.ts +2 -2
- package/node_modules/@codor/cli/dist/setup.d.ts.map +1 -1
- package/node_modules/@codor/cli/dist/setup.js +47 -27
- package/node_modules/@codor/cli/dist/setup.js.map +1 -1
- package/node_modules/@codor/cli/dist/up.d.ts +2 -0
- package/node_modules/@codor/cli/dist/up.d.ts.map +1 -1
- package/node_modules/@codor/cli/dist/up.js +17 -2
- package/node_modules/@codor/cli/dist/up.js.map +1 -1
- package/node_modules/@codor/cli/package.json +3 -3
- package/node_modules/@codor/cli/runtime/web/assets/{LandingPage-BOmG5kSw.js → LandingPage-oLIz_H3H.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{LedgerPage-CecuTS8-.js → LedgerPage-CDSjXPp5.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/NoChannels-yL8IGs8_.js +11 -0
- package/node_modules/@codor/cli/runtime/web/assets/{PairingCodeInput-Cr6XDWx-.js → PairingCodeInput-Bh2hzFji.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{PairingPage-CQBWNA2L.js → PairingPage-CC8sVZit.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{SettingsPage-DGLbSXE7.js → SettingsPage-Cl3O3UCt.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{StartupUnavailable-DdQBHip_.js → StartupUnavailable-CHDoG9xu.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{arrow-left-BOpjMuRi.js → arrow-left-CFyShOnS.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{browser-BWQYNOsD.js → browser-BHgZ9Kl0.js} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/{index-DjwJakJC.css → index-BAZeDQCd.css} +1 -1
- package/node_modules/@codor/cli/runtime/web/assets/index-DWQr1Nx3.js +408 -0
- package/node_modules/@codor/cli/runtime/web/index.html +2 -2
- package/node_modules/@codor/cli/runtime/web/sw.js +1 -1
- package/node_modules/@codor/protocol/package.json +1 -1
- package/node_modules/@codor/switchboard/dist/adapter-registry.d.ts +45 -1
- package/node_modules/@codor/switchboard/dist/adapter-registry.d.ts.map +1 -1
- package/node_modules/@codor/switchboard/dist/adapter-registry.js +38 -11
- package/node_modules/@codor/switchboard/dist/adapter-registry.js.map +1 -1
- package/node_modules/@codor/switchboard/dist/daemon.d.ts +10 -0
- package/node_modules/@codor/switchboard/dist/daemon.d.ts.map +1 -1
- package/node_modules/@codor/switchboard/dist/daemon.js +55 -14
- package/node_modules/@codor/switchboard/dist/daemon.js.map +1 -1
- package/node_modules/@codor/switchboard/dist/server.d.ts.map +1 -1
- package/node_modules/@codor/switchboard/dist/server.js +11 -0
- package/node_modules/@codor/switchboard/dist/server.js.map +1 -1
- package/node_modules/@codor/switchboard/dist/store.d.ts +9 -0
- package/node_modules/@codor/switchboard/dist/store.d.ts.map +1 -1
- package/node_modules/@codor/switchboard/dist/store.js +16 -0
- package/node_modules/@codor/switchboard/dist/store.js.map +1 -1
- package/node_modules/@codor/switchboard/package.json +9 -9
- package/package.json +11 -11
- package/node_modules/@codor/cli/runtime/web/assets/NoChannels-CYiBXGQd.js +0 -11
- package/node_modules/@codor/cli/runtime/web/assets/index-Cxi54Xim.js +0 -408
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsPage-DGLbSXE7.js","assets/browser-BWQYNOsD.js","assets/react-C8w-UNLI.js","assets/qr-DpynCwP9.js","assets/arrow-left-BOpjMuRi.js","assets/sodium-DtsvMzX9.js","assets/LedgerPage-CecuTS8-.js","assets/graph-toBZHlC0.js","assets/PairingPage-CQBWNA2L.js","assets/PairingCodeInput-Cr6XDWx-.js","assets/LandingPage-BOmG5kSw.js","assets/StartupUnavailable-DdQBHip_.js","assets/NoChannels-CYiBXGQd.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var yl=Object.defineProperty;var kl=(e,t,n)=>t in e?yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var re=(e,t,n)=>kl(e,typeof t!="symbol"?t+"":t,n);import{r as Ko,g as wl,a as Xo}from"./react-C8w-UNLI.js";import{t as at}from"./sodium-DtsvMzX9.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();const Sl="modulepreload",jl=function(e){return"/"+e},xi={},Ot=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=a(n.map(d=>{if(d=jl(d),d in xi)return;xi[d]=!0;const u=d.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Sl,u||(f.as="script"),f.crossOrigin="",f.href=d,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var qr={exports:{}},_n={};/**
|
|
3
|
-
* @license React
|
|
4
|
-
* react-jsx-runtime.production.min.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var bi;function Nl(){if(bi)return _n;bi=1;var e=Ko(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(c,l,d){var u,h={},f=null,p=null;d!==void 0&&(f=""+d),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(p=l.ref);for(u in l)r.call(l,u)&&!i.hasOwnProperty(u)&&(h[u]=l[u]);if(c&&c.defaultProps)for(u in l=c.defaultProps,l)h[u]===void 0&&(h[u]=l[u]);return{$$typeof:t,type:c,key:f,ref:p,props:h,_owner:s.current}}return _n.Fragment=n,_n.jsx=a,_n.jsxs=a,_n}var _i;function Tl(){return _i||(_i=1,qr.exports=Nl()),qr.exports}var o=Tl(),x=Ko();const Vn=wl(x);var Gn={},vi;function El(){if(vi)return Gn;vi=1;var e=Xo();return Gn.createRoot=e.createRoot,Gn.hydrateRoot=e.hydrateRoot,Gn}var $l=El();const Qo="codor-theme";function Cl(e){return e==="system"||e==="dark"||e==="light"}function Rl(){try{const e=localStorage.getItem(Qo);return Cl(e)?e:"light"}catch{return"light"}}function ea(e=Rl()){e==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}function V_(e){try{localStorage.setItem(Qo,e)}catch{}ea(e)}const ta="codor-crypto-v1",$n="state",Al=new TextEncoder().encode("codor-auth-v1\0");let ks;const yi=new Map;function Et(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function sn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"="),n=atob(t);return Uint8Array.from(n,r=>r.charCodeAt(0))}function zl(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}function Il(e){const t=sn(e.server_nonce),n=sn(e.transcript_hash);if(t.length!==32||n.length!==32)throw new Error("device authentication challenge is malformed");return zl(Al,t,n)}function En(e){return ks=e,e}function Ll(e=""){return ks??e}function na(){return new Promise((e,t)=>{const n=indexedDB.open(ta,1);n.onupgradeneeded=()=>n.result.createObjectStore($n),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("IndexedDB open failed"))})}async function dn(e){const t=await na();try{return await new Promise((n,r)=>{const s=t.transaction($n).objectStore($n).get(e);s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error??new Error("IndexedDB read failed"))})}finally{t.close()}}async function Cn(e,t){const n=await na();try{await new Promise((r,s)=>{const i=n.transaction($n,"readwrite");i.objectStore($n).put(t,e),i.oncomplete=()=>r(),i.onerror=()=>s(i.error??new Error("IndexedDB write failed"))})}finally{n.close()}}async function ws(){await at.ready;let e=await dn("identity");if(!e){const t=at.crypto_sign_keypair(),n=at.crypto_box_keypair(),r=Et(t.publicKey);e={device_id:r,sign_public_key:r,sign_secret_key:Et(t.privateKey),encryption_public_key:Et(n.publicKey),encryption_secret_key:Et(n.privateKey)},await Cn("identity",e)}return Fl(e)}async function ra(e){await at.ready;const t=await oa();return at.crypto_box_seal_open(sn(e),sn(t.encryption_public_key),sn(t.encryption_secret_key))}async function sa(e,t){await Cn("peer:switchboard",{...e.switchboard,kind:"switchboard"});for(const n of e.room_keys)await Cn(`room:${n.room}`,{room:n.room,generation:n.generation,key:Et(await ra(n.sealed_key))});await ia({origin:new URL(t).origin,authority:"device"})}async function G_(e){const t=e.searchParams.get("endpoint"),n=e.searchParams.get("pairing_token"),r=e.searchParams.get("switchboard_sign_pub");if(!t||!n||!r)throw new Error("pairing link is incomplete");const s=await ws(),i=await fetch(`${t.replace(/\/$/,"")}/api/pairing/complete`,{method:"POST",headers:{authorization:`Pairing ${n}`,"content-type":"application/json"},body:JSON.stringify({...s,kind:"device",label:navigator.userAgent})});if(!i.ok)throw new Error(`pairing failed: ${String(i.status)}`);const a=await i.json();if(a.switchboard.sign_public_key!==r)throw new Error("Codor signing key does not match the pairing link");return await sa(a,t),a}function J_(e=window.location.origin){const t=new URL(e).origin,n=yi.get(t);if(n)return n;const r=(async()=>{const s=await fetch(`${t}/api/pairing/status`);if(!s.ok)throw new Error(`trusted pairing status failed: ${String(s.status)}`);if((await s.json()).trusted_enrollment!==!0)return!1;const a=await ws(),c=await fetch(`${t}/api/pairing/complete`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...a,kind:"device",label:navigator.userAgent})});if(!c.ok)throw new Error(`trusted pairing failed: ${String(c.status)}`);return await sa(await c.json(),t),!0})();return yi.set(t,r),r}async function Ol(e=window.location.origin){await at.ready;const t=await dn("peer:switchboard");if((t==null?void 0:t.kind)!=="switchboard")return;const n=await oa(),r=await fetch(`${e}/api/auth/challenge`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({device_id:n.device_id})});if(!r.ok)throw new Error(`device authentication failed: ${String(r.status)}`);const s=await r.json();if(s.switchboard_device_id!==t.device_id||!s.challenge)throw new Error("device authentication Codor identity mismatch");const i=s.challenge,a=Et(at.crypto_generichash(at.crypto_generichash_BYTES,new TextEncoder().encode(`codor-browser-session-v1\0${t.device_id}`),null));if(typeof i.challenge_id!="string"||i.challenge_id===""||typeof i.server_nonce!="string"||typeof i.transcript_hash!="string"||i.transcript_hash!==a||typeof i.expires_at!="string"||Date.parse(i.expires_at)<=Date.now())throw new Error("device authentication challenge is invalid");const c=Et(at.crypto_sign_detached(Il(i),sn(n.sign_secret_key))),l=await fetch(`${e}/api/auth/session`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({challenge_id:i.challenge_id,signature:c})});if(!l.ok)throw new Error(`device authentication failed: ${String(l.status)}`);const d=await l.json();if(typeof d.access_token!="string"||d.access_token===""||d.device_id!==n.device_id||typeof d.expires_at!="string"||Date.parse(d.expires_at)<=Date.now())throw new Error("device authentication session is invalid");return d.access_token}async function Pl(e=window.location.origin){const t=await dn("peer:switchboard");if((t==null?void 0:t.kind)==="switchboard")return await Ol(e)??"";const n=await Zl();return(n==null?void 0:n.origin)===e&&n.authority!=="device"&&typeof n.token=="string"?n.token:""}async function Ml(e){return dn(`room:${e}`)}async function Dl(e,t,n){if(await at.ready,e===""||!Number.isSafeInteger(t)||t<1)throw new Error("channel key metadata is invalid");if(n.length!==at.crypto_aead_xchacha20poly1305_ietf_KEYBYTES)throw new Error("channel key length is invalid");const r=await Ml(e);r&&r.generation>t||await Cn(`room:${e}`,{room:e,generation:t,key:Et(n)})}async function ia(e){if(e.origin===""||e.authority==="operator"&&(typeof e.token!="string"||e.token==="")||e.authority==="device"&&e.token!==void 0)throw new Error("browser access metadata is invalid");await Cn("access:switchboard",e)}async function Zl(){return dn("access:switchboard")}async function Y_(){ks="";for(const t of await navigator.serviceWorker.getRegistrations()){const n=await t.pushManager.getSubscription();n&&await n.unsubscribe(),await t.unregister()}for(const t of await caches.keys())await caches.delete(t);localStorage.clear();const e=typeof indexedDB.databases=="function"?await indexedDB.databases():[{name:ta}];await Promise.all(e.map(t=>t.name).filter(t=>typeof t=="string"&&t.startsWith("codor-")).map(t=>new Promise((n,r)=>{const s=indexedDB.deleteDatabase(t);s.onsuccess=()=>n(),s.onerror=()=>r(s.error??new Error("IndexedDB delete failed")),s.onblocked=()=>r(new Error("IndexedDB delete was blocked"))})))}function Fl(e){return{device_id:e.device_id,sign_public_key:e.sign_public_key,encryption_public_key:e.encryption_public_key}}async function oa(){await ws();const e=await dn("identity");if(!e)throw new Error("browser identity disappeared");return e}async function K_(e,t=window.location.origin){const n=new URL(t).origin,r=await fetch(`${n}/api/pairing/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})});if(!r.ok)throw new Error("pairing code not found");const s=await r.json(),i=new URL("/pair",s.endpoint);return i.searchParams.set("endpoint",s.endpoint),i.searchParams.set("pairing_token",s.pairing_token),i.searchParams.set("switchboard_sign_pub",s.switchboard_sign_pub),i}async function aa(e){try{const t=await e.json();if(typeof t.error=="string"&&t.error.trim()!=="")return new Error(t.error)}catch{}return new Error(`request failed: ${String(e.status)}`)}async function lt(e,t){const n=t.origin??window.location.origin,r=await fetch(`${n}${e}`,{headers:{authorization:`Bearer ${t.token}`}});if(!r.ok)throw await aa(r);return await r.json()}async function br(e,t,n,r){const s=r.origin??window.location.origin,i=await fetch(`${s}${e}`,{method:t,headers:{authorization:`Bearer ${r.token}`,...n!==void 0&&{"content-type":"application/json"}},...n!==void 0&&{body:JSON.stringify(n)}});if(!i.ok)throw await aa(i);if(i.status!==204)return await i.json()}async function Ul(e){const t=await lt("/api/adapters",e);return{adapters:t.adapters,discovering:t.discovering===!0}}async function ca(e){return(await lt("/api/rooms",e)).rooms}async function ql(e,t){const n=await br("/api/rooms","POST",e,t);if(n.room_key!==void 0){if(n.room_key.room!==n.room.id)throw new Error("created channel key does not match the created channel");const r=await ra(n.room_key.sealed_key);await Dl(n.room_key.room,n.room_key.generation,r)}return n.room}async function Bl(e,t,n){const r=new URLSearchParams;e!==void 0&&r.set("path",e),t&&r.set("hidden","1");const s=r.size===0?"":`?${r.toString()}`;return lt(`/api/local/dirs${s}`,n)}async function X_(e){return(await lt("/api/devices",e)).devices}async function Q_(e,t){return br("/api/pairing/offers","POST",{endpoint:e},t)}async function ev(e){return lt("/api/push/config",e)}async function tv(e,t,n){await br(`/api/devices/${encodeURIComponent(e)}/push-subscription`,"POST",{subscription:t},n)}async function nv(e,t){await br(`/api/devices/${encodeURIComponent(e)}`,"DELETE",void 0,t)}async function Hl(e,t){return(await lt(`/api/rooms/${encodeURIComponent(e)}/members`,t)).members}async function la(e,t,n){const r=new URLSearchParams;return t.before!==void 0&&r.set("before",String(t.before)),t.limit!==void 0&&r.set("limit",String(t.limit)),lt(`/api/rooms/${encodeURIComponent(e)}/messages?${r.toString()}`,n)}async function Wl(e,t,n){const r=new URLSearchParams({q:t});return(await lt(`/api/rooms/${encodeURIComponent(e)}/search?${r.toString()}`,n)).messages}async function ua(e,t,n){return(await lt(`/api/rooms/${encodeURIComponent(e)}/runs/${t}`,n)).events}async function rv(e,t,n){return(await lt(`/api/rooms/${encodeURIComponent(e)}/ledger/${encodeURIComponent(t)}`,n)).note}async function sv(e,t){return(await lt(`/api/rooms/${encodeURIComponent(e)}/ledger`,t)).graph}var ki;function v(e,t,n){function r(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);const d=a.prototype,u=Object.keys(d);for(let h=0;h<u.length;h++){const f=u[h];f in c||(c[f]=d[f].bind(c))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:e});function a(c){var l;const d=n!=null&&n.Parent?new i:this;r(d,c),(l=d._zod).deferred??(l.deferred=[]);for(const u of d._zod.deferred)u();return d}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:c=>{var l,d;return n!=null&&n.Parent&&c instanceof n.Parent?!0:(d=(l=c==null?void 0:c._zod)==null?void 0:l.traits)==null?void 0:d.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class on extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class da extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ki=globalThis).__zod_globalConfig??(ki.__zod_globalConfig={});const Ss=globalThis.__zod_globalConfig;function Dt(e){return Ss}function ha(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function es(e,t){return typeof t=="bigint"?t.toString():t}function _r(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function js(e){return e==null}function Ns(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Vl(e,t){const n=e/t,r=Math.round(n),s=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<s?0:n-r}const wi=Symbol("evaluating");function ne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==wi)return r===void 0&&(r=wi,r=n()),r},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function Bt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ct(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Si(e){return JSON.stringify(e)}function Gl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ma="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Jl=_r(()=>{var e;if(Ss.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function An(e){if(Rn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Rn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function fa(e){return An(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Yl=new Set(["string","number","symbol"]);function an(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rt(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Z(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Kl(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Xl={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ql(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Ct(e._zod.def,{get shape(){const a={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(a[c]=n.shape[c])}return Bt(this,"shape",a),a},checks:[]});return Rt(e,i)}function eu(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Ct(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete a[c]}return Bt(this,"shape",a),a},checks:[]});return Rt(e,i)}function tu(e,t){if(!An(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=Ct(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Bt(this,"shape",i),i}});return Rt(e,s)}function nu(e,t){if(!An(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ct(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Bt(this,"shape",r),r}});return Rt(e,n)}function ru(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ct(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Bt(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Rt(e,n)}function su(e,t,n){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=Ct(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(n)for(const d in n){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return Bt(this,"shape",l),l},checks:[]});return Rt(t,a)}function iu(e,t,n){const r=Ct(t._zod.def,{get shape(){const s=t._zod.def.shape,i={...s};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:s[a]}))}else for(const a in s)i[a]=new e({type:"nonoptional",innerType:s[a]});return Bt(this,"shape",i),i}});return Rt(t,r)}function rn(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function ou(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function pa(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Jn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Zt(e,t,n){var l,d,u,h,f,p;const r=e.message?e.message:Jn((u=(d=(l=e.inst)==null?void 0:l._zod.def)==null?void 0:d.error)==null?void 0:u.call(d,e))??Jn((h=t==null?void 0:t.error)==null?void 0:h.call(t,e))??Jn((f=n.customError)==null?void 0:f.call(n,e))??Jn((p=n.localeError)==null?void 0:p.call(n,e))??"Invalid input",{inst:s,continue:i,input:a,...c}=e;return c.path??(c.path=[]),c.message=r,t!=null&&t.reportInput&&(c.input=a),c}function Ts(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function zn(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const ga=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,es,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xa=v("$ZodError",ga),ba=v("$ZodError",ga,{Parent:Error});function au(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}function cu(e,t=n=>n.message){const n={_errors:[]},r=(s,i=[])=>{for(const a of s.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const c=[...i,...a.path];if(c.length===0)n._errors.push(t(a));else{let l=n,d=0;for(;d<c.length;){const u=c[d];d===c.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(t(a))):l[u]=l[u]||{_errors:[]},l=l[u],d++}}}};return r(e),n}const Es=e=>(t,n,r,s)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new on;if(a.issues.length){const c=new((s==null?void 0:s.Err)??e)(a.issues.map(l=>Zt(l,i,Dt())));throw ma(c,s==null?void 0:s.callee),c}return a.value},$s=e=>async(t,n,r,s)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new((s==null?void 0:s.Err)??e)(a.issues.map(l=>Zt(l,i,Dt())));throw ma(c,s==null?void 0:s.callee),c}return a.value},vr=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new on;return i.issues.length?{success:!1,error:new(e??xa)(i.issues.map(a=>Zt(a,s,Dt())))}:{success:!0,data:i.value}},lu=vr(ba),yr=e=>async(t,n,r)=>{const s=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>Zt(a,s,Dt())))}:{success:!0,data:i.value}},uu=yr(ba),du=e=>(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return Es(e)(t,n,s)},hu=e=>(t,n,r)=>Es(e)(t,n,r),mu=e=>async(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return $s(e)(t,n,s)},fu=e=>async(t,n,r)=>$s(e)(t,n,r),pu=e=>(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return vr(e)(t,n,s)},gu=e=>(t,n,r)=>vr(e)(t,n,r),xu=e=>async(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return yr(e)(t,n,s)},bu=e=>async(t,n,r)=>yr(e)(t,n,r),_u=/^[cC][0-9a-z]{6,}$/,vu=/^[0-9a-z]+$/,yu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ku=/^[0-9a-vA-V]{20}$/,wu=/^[A-Za-z0-9]{27}$/,Su=/^[a-zA-Z0-9_-]{21}$/,ju=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nu=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ji=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Tu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Eu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function $u(){return new RegExp(Eu,"u")}const Cu=/^(?:(?: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])$/,Ru=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Au=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Iu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_a=/^[A-Za-z0-9_-]*$/,Lu=/^https?$/,Ou=/^\+[1-9]\d{6,14}$/,va="(?:(?:\\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])))",Pu=new RegExp(`^${va}$`);function ya(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Mu(e){return new RegExp(`^${ya(e)}$`)}function Du(e){const t=ya({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${va}T(?:${r})$`)}const Zu=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Fu=/^-?\d+$/,Uu=/^-?\d+(?:\.\d+)?$/,qu=/^(?:true|false)$/i,Bu=/^[^A-Z]*$/,Hu=/^[^a-z]*$/,Be=v("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ka={number:"number",bigint:"bigint",object:"date"},wa=v("$ZodCheckLessThan",(e,t)=>{Be.init(e,t);const n=ka[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sa=v("$ZodCheckGreaterThan",(e,t)=>{Be.init(e,t);const n=ka[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,i=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wu=v("$ZodCheckMultipleOf",(e,t)=>{Be.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Vl(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Vu=v("$ZodCheckNumberFormat",(e,t)=>{var a;Be.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[s,i]=Xl[t.format];e._zod.onattach.push(c=>{const l=c._zod.bag;l.format=t.format,l.minimum=s,l.maximum=i,n&&(l.pattern=Fu)}),e._zod.check=c=>{const l=c.value;if(n){if(!Number.isInteger(l)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?c.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):c.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<s&&c.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),l>i&&c.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Gu=v("$ZodCheckMaxLength",(e,t)=>{var n;Be.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!js(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const s=r.value;if(s.length<=t.maximum)return;const a=Ts(s);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Ju=v("$ZodCheckMinLength",(e,t)=>{var n;Be.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!js(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const s=r.value;if(s.length>=t.minimum)return;const a=Ts(s);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Yu=v("$ZodCheckLengthEquals",(e,t)=>{var n;Be.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!js(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=r=>{const s=r.value,i=s.length;if(i===t.length)return;const a=Ts(s),c=i>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),kr=v("$ZodCheckStringFormat",(e,t)=>{var n,r;Be.init(e,t),e._zod.onattach.push(s=>{const i=s._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ku=v("$ZodCheckRegex",(e,t)=>{kr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xu=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Bu),kr.init(e,t)}),Qu=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Hu),kr.init(e,t)}),ed=v("$ZodCheckIncludes",(e,t)=>{Be.init(e,t);const n=an(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),td=v("$ZodCheckStartsWith",(e,t)=>{Be.init(e,t);const n=new RegExp(`^${an(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),nd=v("$ZodCheckEndsWith",(e,t)=>{Be.init(e,t);const n=new RegExp(`.*${an(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),rd=v("$ZodCheckOverwrite",(e,t)=>{Be.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sd{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
11
|
-
`).filter(a=>a),s=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.map(a=>a.slice(s)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,s.join(`
|
|
12
|
-
`))}}const id={major:4,minor:4,patch:3},ge=v("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=id;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const a of i._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const i=(c,l,d)=>{let u=rn(c),h;for(const f of l){if(f._zod.def.when){if(ou(c)||!f._zod.def.when(c))continue}else if(u)continue;const p=c.issues.length,g=f._zod.check(c);if(g instanceof Promise&&(d==null?void 0:d.async)===!1)throw new on;if(h||g instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await g,c.issues.length!==p&&(u||(u=rn(c,p)))});else{if(c.issues.length===p)continue;u||(u=rn(c,p))}}return h?h.then(()=>c):c},a=(c,l,d)=>{if(rn(c))return c.aborted=!0,c;const u=i(l,r,d);if(u instanceof Promise){if(d.async===!1)throw new on;return u.then(h=>e._zod.parse(h,d))}return e._zod.parse(u,d)};e._zod.run=(c,l)=>{if(l.skipChecks)return e._zod.parse(c,l);if(l.direction==="backward"){const u=e._zod.parse({value:c.value,issues:[]},{...l,skipChecks:!0});return u instanceof Promise?u.then(h=>a(h,c,l)):a(u,c,l)}const d=e._zod.parse(c,l);if(d instanceof Promise){if(l.async===!1)throw new on;return d.then(u=>i(u,r,l))}return i(d,r,l)}}ne(e,"~standard",()=>({validate:i=>{var a;try{const c=lu(e,i);return c.success?{value:c.data}:{issues:(a=c.error)==null?void 0:a.issues}}catch{return uu(e,i).then(l=>{var d;return l.success?{value:l.data}:{issues:(d=l.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),Cs=v("$ZodString",(e,t)=>{var n;ge.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Zu(e._zod.bag),e._zod.parse=(r,s)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ue=v("$ZodStringFormat",(e,t)=>{kr.init(e,t),Cs.init(e,t)}),od=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Nu),ue.init(e,t)}),ad=v("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ji(r))}else t.pattern??(t.pattern=ji());ue.init(e,t)}),cd=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Tu),ue.init(e,t)}),ld=v("$ZodURL",(e,t)=>{ue.init(e,t),e._zod.check=n=>{var r;try{const s=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===Lu.source&&!/^https?:\/\//i.test(s)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const i=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ud=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=$u()),ue.init(e,t)}),dd=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Su),ue.init(e,t)}),hd=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=_u),ue.init(e,t)}),md=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=vu),ue.init(e,t)}),fd=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=yu),ue.init(e,t)}),pd=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ku),ue.init(e,t)}),gd=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=wu),ue.init(e,t)}),xd=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Du(t)),ue.init(e,t)}),bd=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Pu),ue.init(e,t)}),_d=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Mu(t)),ue.init(e,t)}),vd=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ju),ue.init(e,t)}),yd=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Cu),ue.init(e,t),e._zod.bag.format="ipv4"}),kd=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ru),ue.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),wd=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Au),ue.init(e,t)}),Sd=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=zu),ue.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,i]=r;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ja(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const jd=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Iu),ue.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ja(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Nd(e){if(!_a.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ja(n)}const Td=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=_a),ue.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Nd(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ed=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ou),ue.init(e,t)});function $d(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Cd=v("$ZodJWT",(e,t)=>{ue.init(e,t),e._zod.check=n=>{$d(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Na=v("$ZodNumber",(e,t)=>{ge.init(e,t),e._zod.pattern=e._zod.bag.pattern??Uu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...i?{received:i}:{}}),n}}),Rd=v("$ZodNumberFormat",(e,t)=>{Vu.init(e,t),Na.init(e,t)}),Ad=v("$ZodBoolean",(e,t)=>{ge.init(e,t),e._zod.pattern=qu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),zd=v("$ZodUnknown",(e,t)=>{ge.init(e,t),e._zod.parse=n=>n}),Id=v("$ZodNever",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ni(e,t,n){e.issues.length&&t.issues.push(...pa(n,e.issues)),t.value[n]=e.value}const Ld=v("$ZodArray",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const i=[];for(let a=0;a<s.length;a++){const c=s[a],l=t.element._zod.run({value:c,issues:[]},r);l instanceof Promise?i.push(l.then(d=>Ni(d,n,a))):Ni(l,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function ar(e,t,n,r,s,i){const a=n in r;if(e.issues.length){if(s&&i&&!a)return;t.issues.push(...pa(n,e.issues))}if(!a&&!s){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function Ta(e){var r,s,i,a;const t=Object.keys(e.shape);for(const c of t)if(!((a=(i=(s=(r=e.shape)==null?void 0:r[c])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${c}": expected a Zod schema`);const n=Kl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ea(e,t,n,r,s,i){const a=[],c=s.keySet,l=s.catchall._zod,d=l.def.type,u=l.optin==="optional",h=l.optout==="optional";for(const f in t){if(f==="__proto__"||c.has(f))continue;if(d==="never"){a.push(f);continue}const p=l.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(g=>ar(g,n,f,t,u,h))):ar(p,n,f,t,u,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Od=v("$ZodObject",(e,t)=>{ge.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=_r(()=>Ta(t));ne(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const u=c[d]._zod;if(u.values){l[d]??(l[d]=new Set);for(const h of u.values)l[d].add(h)}}return l});const s=Rn,i=t.catchall;let a;e._zod.parse=(c,l)=>{a??(a=r.value);const d=c.value;if(!s(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const u=[],h=a.shape;for(const f of a.keys){const p=h[f],g=p._zod.optin==="optional",_=p._zod.optout==="optional",S=p._zod.run({value:d[f],issues:[]},l);S instanceof Promise?u.push(S.then(R=>ar(R,c,f,d,g,_))):ar(S,c,f,d,g,_)}return i?Ea(u,d,c,l,r.value,e):u.length?Promise.all(u).then(()=>c):c}}),Pd=v("$ZodObjectJIT",(e,t)=>{Od.init(e,t);const n=e._zod.parse,r=_r(()=>Ta(t)),s=f=>{var $,z;const p=new sd(["shape","payload","ctx"]),g=r.value,_=I=>{const k=Si(I);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};p.write("const input = payload.value;");const S=Object.create(null);let R=0;for(const I of g.keys)S[I]=`key_${R++}`;p.write("const newResult = {};");for(const I of g.keys){const k=S[I],E=Si(I),L=f[I],Q=(($=L==null?void 0:L._zod)==null?void 0:$.optin)==="optional",G=((z=L==null?void 0:L._zod)==null?void 0:z.optout)==="optional";p.write(`const ${k} = ${_(I)};`),Q&&G?p.write(`
|
|
13
|
-
if (${k}.issues.length) {
|
|
14
|
-
if (${E} in input) {
|
|
15
|
-
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
16
|
-
...iss,
|
|
17
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
18
|
-
})));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (${k}.value === undefined) {
|
|
23
|
-
if (${E} in input) {
|
|
24
|
-
newResult[${E}] = undefined;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
newResult[${E}] = ${k}.value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
`):Q?p.write(`
|
|
31
|
-
if (${k}.issues.length) {
|
|
32
|
-
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
33
|
-
...iss,
|
|
34
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
35
|
-
})));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (${k}.value === undefined) {
|
|
39
|
-
if (${E} in input) {
|
|
40
|
-
newResult[${E}] = undefined;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
newResult[${E}] = ${k}.value;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
`):p.write(`
|
|
47
|
-
const ${k}_present = ${E} in input;
|
|
48
|
-
if (${k}.issues.length) {
|
|
49
|
-
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
50
|
-
...iss,
|
|
51
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
52
|
-
})));
|
|
53
|
-
}
|
|
54
|
-
if (!${k}_present && !${k}.issues.length) {
|
|
55
|
-
payload.issues.push({
|
|
56
|
-
code: "invalid_type",
|
|
57
|
-
expected: "nonoptional",
|
|
58
|
-
input: undefined,
|
|
59
|
-
path: [${E}]
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (${k}_present) {
|
|
64
|
-
if (${k}.value === undefined) {
|
|
65
|
-
newResult[${E}] = undefined;
|
|
66
|
-
} else {
|
|
67
|
-
newResult[${E}] = ${k}.value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
`)}p.write("payload.value = newResult;"),p.write("return payload;");const A=p.compile();return(I,k)=>A(f,I,k)};let i;const a=Rn,c=!Ss.jitless,d=c&&Jl.value,u=t.catchall;let h;e._zod.parse=(f,p)=>{h??(h=r.value);const g=f.value;return a(g)?c&&d&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(i||(i=s(t.shape)),f=i(f,p),u?Ea([],g,f,p,h,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Ti(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const s=e.filter(i=>!rn(i));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>Zt(a,r,Dt())))}),t)}const $a=v("$ZodUnion",(e,t)=>{ge.init(e,t),ne(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>Ns(s.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,s)=>{if(n)return n(r,s);let i=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:r.value,issues:[]},s);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>Ti(c,r,e,s)):Ti(a,r,e,s)}}),Md=v("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$a.init(e,t);const n=e._zod.parse;ne(e._zod,"propValues",()=>{const s={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[c,l]of Object.entries(a)){s[c]||(s[c]=new Set);for(const d of l)s[c].add(d)}}return s});const r=_r(()=>{var a;const s=t.options,i=new Map;for(const c of s){const l=(a=c._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const d of l){if(i.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,c)}}return i});e._zod.parse=(s,i)=>{const a=s.value;if(!Rn(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const c=r.value.get(a==null?void 0:a[t.discriminator]);return c?c._zod.run(s,i):t.unionFallback||i.direction==="backward"?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),s)}}),Dd=v("$ZodIntersection",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,i=t.left._zod.run({value:s,issues:[]},r),a=t.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,d])=>Ei(n,l,d)):Ei(n,i,a)}});function ts(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(An(e)&&An(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),s={...e,...t};for(const i of r){const a=ts(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};s[i]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r],a=ts(s,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ei(e,t,n){const r=new Map;let s;for(const c of t.issues)if(c.code==="unrecognized_keys"){s??(s=c);for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(c);const i=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&s&&e.issues.push({...s,keys:i}),rn(e))return e;const a=ts(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const Zd=v("$ZodEnum",(e,t)=>{ge.init(e,t);const n=ha(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(s=>Yl.has(typeof s)).map(s=>typeof s=="string"?an(s):s.toString()).join("|")})$`),e._zod.parse=(s,i)=>{const a=s.value;return r.has(a)||s.issues.push({code:"invalid_value",values:n,input:a,inst:e}),s}}),Fd=v("$ZodLiteral",(e,t)=>{if(ge.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?an(r):r?an(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Ud=v("$ZodTransform",(e,t)=>{ge.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new da(e.constructor.name);const s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(n.value=a,n.fallback=!0,n));if(s instanceof Promise)throw new on;return n.value=s,n.fallback=!0,n}});function $i(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Ca=v("$ZodOptional",(e,t)=>{ge.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ns(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const s=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>$i(a,s)):$i(i,s)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),qd=v("$ZodExactOptional",(e,t)=>{Ca.init(e,t),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Bd=v("$ZodNullable",(e,t)=>{ge.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ns(n.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Hd=v("$ZodDefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Ci(i,t)):Ci(s,t)}});function Ci(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Wd=v("$ZodPrefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Vd=v("$ZodNonOptional",(e,t)=>{ge.init(e,t),ne(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Ri(i,e)):Ri(s,e)}});function Ri(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Gd=v("$ZodCatch",(e,t)=>{ge.init(e,t),e._zod.optin="optional",ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>Zt(a,r,Dt()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Zt(i,r,Dt()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Jd=v("$ZodPipe",(e,t)=>{ge.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>Yn(a,t.in,r)):Yn(i,t.in,r)}const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Yn(i,t.out,r)):Yn(s,t.out,r)}});function Yn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Yd=v("$ZodReadonly",(e,t)=>{ge.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ne(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Ai):Ai(s)}});function Ai(e){return e.value=Object.freeze(e.value),e}const Kd=v("$ZodCustom",(e,t)=>{Be.init(e,t),ge.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(i=>zi(i,n,r,e));zi(s,n,r,e)}});function zi(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(zn(s))}}var Ii;class Xd{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Qd(){return new Xd}(Ii=globalThis).__zod_globalRegistry??(Ii.__zod_globalRegistry=Qd());const jn=globalThis.__zod_globalRegistry;function eh(e,t){return new e({type:"string",...Z(t)})}function th(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Z(t)})}function Li(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Z(t)})}function nh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Z(t)})}function rh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Z(t)})}function sh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Z(t)})}function ih(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Z(t)})}function oh(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Z(t)})}function ah(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Z(t)})}function ch(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Z(t)})}function lh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Z(t)})}function uh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Z(t)})}function Ra(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Z(t)})}function dh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Z(t)})}function hh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Z(t)})}function mh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Z(t)})}function fh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Z(t)})}function ph(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Z(t)})}function gh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Z(t)})}function xh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Z(t)})}function bh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Z(t)})}function _h(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Z(t)})}function vh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Z(t)})}function yh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Z(t)})}function kh(e,t){return new e({type:"string",format:"date",check:"string_format",...Z(t)})}function wh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Z(t)})}function Sh(e,t){return new e({type:"string",format:"duration",check:"string_format",...Z(t)})}function jh(e,t){return new e({type:"number",checks:[],...Z(t)})}function Nh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Z(t)})}function Th(e,t){return new e({type:"boolean",...Z(t)})}function Eh(e){return new e({type:"unknown"})}function $h(e,t){return new e({type:"never",...Z(t)})}function Oi(e,t){return new wa({check:"less_than",...Z(t),value:e,inclusive:!1})}function Br(e,t){return new wa({check:"less_than",...Z(t),value:e,inclusive:!0})}function Pi(e,t){return new Sa({check:"greater_than",...Z(t),value:e,inclusive:!1})}function Hr(e,t){return new Sa({check:"greater_than",...Z(t),value:e,inclusive:!0})}function Mi(e,t){return new Wu({check:"multiple_of",...Z(t),value:e})}function Aa(e,t){return new Gu({check:"max_length",...Z(t),maximum:e})}function cr(e,t){return new Ju({check:"min_length",...Z(t),minimum:e})}function za(e,t){return new Yu({check:"length_equals",...Z(t),length:e})}function Ch(e,t){return new Ku({check:"string_format",format:"regex",...Z(t),pattern:e})}function Rh(e){return new Xu({check:"string_format",format:"lowercase",...Z(e)})}function Ah(e){return new Qu({check:"string_format",format:"uppercase",...Z(e)})}function zh(e,t){return new ed({check:"string_format",format:"includes",...Z(t),includes:e})}function Ih(e,t){return new td({check:"string_format",format:"starts_with",...Z(t),prefix:e})}function Lh(e,t){return new nd({check:"string_format",format:"ends_with",...Z(t),suffix:e})}function hn(e){return new rd({check:"overwrite",tx:e})}function Oh(e){return hn(t=>t.normalize(e))}function Ph(){return hn(e=>e.trim())}function Mh(){return hn(e=>e.toLowerCase())}function Dh(){return hn(e=>e.toUpperCase())}function Zh(){return hn(e=>Gl(e))}function Fh(e,t,n){return new e({type:"array",element:t,...Z(n)})}function Uh(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Z(n)})}function qh(e,t){const n=Bh(r=>(r.addIssue=s=>{if(typeof s=="string")r.issues.push(zn(s,r.value,n._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(zn(i))}},e(r.value,r)),t);return n}function Bh(e,t){const n=new Be({check:"custom",...Z(t)});return n._zod.check=e,n}function Ia(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??jn,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Te(e,t,n={path:[],schemaPath:[]}){var u,h;var r;const s=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const c=(h=(u=e._zod).toJSONSchema)==null?void 0:h.call(u);if(c)a.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{const g=a.schema,_=t.processors[s.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);_(e,t,g,f)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),Te(p,t,f),t.seen.get(p).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&Oe(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function La(e,t){var a,c,l,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const u of e.seen.entries()){const h=(a=e.metadataRegistry.get(u[0]))==null?void 0:a.id;if(h){const f=r.get(h);if(f&&f!==u[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(h,u[0])}}const s=u=>{var _;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(_=e.external.registry.get(u[0]))==null?void 0:_.id,R=e.external.uri??($=>$);if(S)return{ref:R(S)};const A=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=A,{defId:A,ref:`${R("__shared")}#/${h}/${A}`}}if(u[1]===n)return{ref:"#"};const p=`#/${h}/`,g=u[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:p+g}},i=u=>{if(u[1].schema.$ref)return;const h=u[1],{ref:f,defId:p}=s(u);h.def={...h.schema},p&&(h.defId=p);const g=h.schema;for(const _ in g)delete g[_];g.$ref=f};if(e.cycles==="throw")for(const u of e.seen.entries()){const h=u[1];if(h.cycle)throw new Error(`Cycle detected: #/${(c=h.cycle)==null?void 0:c.join("/")}/<root>
|
|
72
|
-
|
|
73
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const h=u[1];if(t===u[0]){i(u);continue}if(e.external){const p=(l=e.external.registry.get(u[0]))==null?void 0:l.id;if(t!==u[0]&&p){i(u);continue}}if((d=e.metadataRegistry.get(u[0]))==null?void 0:d.id){i(u);continue}if(h.cycle){i(u);continue}if(h.count>1&&e.reused==="ref"){i(u);continue}}}function Oa(e,t){var c,l,d,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=h=>{const f=e.seen.get(h);if(f.ref===null)return;const p=f.def??f.schema,g={...p},_=f.ref;if(f.ref=null,_){r(_);const R=e.seen.get(_),A=R.schema;if(A.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(A)):Object.assign(p,A),Object.assign(p,g),h._zod.parent===_)for(const z in p)z==="$ref"||z==="allOf"||z in g||delete p[z];if(A.$ref&&R.def)for(const z in p)z==="$ref"||z==="allOf"||z in R.def&&JSON.stringify(p[z])===JSON.stringify(R.def[z])&&delete p[z]}const S=h._zod.parent;if(S&&S!==_){r(S);const R=e.seen.get(S);if(R!=null&&R.schema.$ref&&(p.$ref=R.schema.$ref,R.def))for(const A in p)A==="$ref"||A==="allOf"||A in R.def&&JSON.stringify(p[A])===JSON.stringify(R.def[A])&&delete p[A]}e.override({zodSchema:h,jsonSchema:p,path:f.path??[]})};for(const h of[...e.seen.entries()].reverse())r(h[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const h=(l=e.external.registry.get(t))==null?void 0:l.id;if(!h)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(h)}Object.assign(s,n.def??n.schema);const i=(d=e.metadataRegistry.get(t))==null?void 0:d.id;i!==void 0&&s.id===i&&delete s.id;const a=((u=e.external)==null?void 0:u.defs)??{};for(const h of e.seen.entries()){const f=h[1];f.def&&f.defId&&(f.def.id===f.defId&&delete f.def.id,a[f.defId]=f.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?s.$defs=a:s.definitions=a);try{const h=JSON.parse(JSON.stringify(s));return Object.defineProperty(h,"~standard",{value:{...t["~standard"],jsonSchema:{input:lr(t,"input",e.processors),output:lr(t,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Oe(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,n);if(r.type==="set")return Oe(r.valueType,n);if(r.type==="lazy")return Oe(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,n);if(r.type==="intersection")return Oe(r.left,n)||Oe(r.right,n);if(r.type==="record"||r.type==="map")return Oe(r.keyType,n)||Oe(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Oe(r.in,n)||Oe(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Oe(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Oe(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Oe(s,n))return!0;return!!(r.rest&&Oe(r.rest,n))}return!1}const Hh=(e,t={})=>n=>{const r=Ia({...n,processors:t});return Te(e,r),La(r,e),Oa(r,e)},lr=(e,t,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},a=Ia({...s??{},target:i,io:t,processors:n});return Te(e,a),La(a,e),Oa(a,e)},Wh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vh=(e,t,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:a,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof a=="number"&&(s.maxLength=a),c&&(s.format=Wh[c]??c,s.format===""&&delete s.format,c==="time"&&delete s.format),d&&(s.contentEncoding=d),l&&l.size>0){const u=[...l];u.length===1?s.pattern=u[0].source:u.length>1&&(s.allOf=[...u.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Gh=(e,t,n,r)=>{const s=n,{minimum:i,maximum:a,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;typeof c=="string"&&c.includes("int")?s.type="integer":s.type="number";const h=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),f=typeof d=="number"&&d<=(a??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";h?p?(s.minimum=u,s.exclusiveMinimum=!0):s.exclusiveMinimum=u:typeof i=="number"&&(s.minimum=i),f?p?(s.maximum=d,s.exclusiveMaximum=!0):s.exclusiveMaximum=d:typeof a=="number"&&(s.maximum=a),typeof l=="number"&&(s.multipleOf=l)},Jh=(e,t,n,r)=>{n.type="boolean"},Yh=(e,t,n,r)=>{n.not={}},Kh=(e,t,n,r)=>{},Xh=(e,t,n,r)=>{const s=e._zod.def,i=ha(s.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},Qh=(e,t,n,r)=>{const s=e._zod.def,i=[];for(const a of s.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},em=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},tm=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},nm=(e,t,n,r)=>{const s=n,i=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(s.minItems=a),typeof c=="number"&&(s.maxItems=c),s.type="array",s.items=Te(i.element,t,{...r,path:[...r.path,"items"]})},rm=(e,t,n,r)=>{var d;const s=n,i=e._zod.def;s.type="object",s.properties={};const a=i.shape;for(const u in a)s.properties[u]=Te(a[u],t,{...r,path:[...r.path,"properties",u]});const c=new Set(Object.keys(a)),l=new Set([...c].filter(u=>{const h=i.shape[u]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((d=i.catchall)==null?void 0:d._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=Te(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},sm=(e,t,n,r)=>{const s=e._zod.def,i=s.inclusive===!1,a=s.options.map((c,l)=>Te(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=a:n.anyOf=a},im=(e,t,n,r)=>{const s=e._zod.def,i=Te(s.left,t,{...r,path:[...r.path,"allOf",0]}),a=Te(s.right,t,{...r,path:[...r.path,"allOf",1]}),c=d=>"allOf"in d&&Object.keys(d).length===1,l=[...c(i)?i.allOf:[i],...c(a)?a.allOf:[a]];n.allOf=l},om=(e,t,n,r)=>{const s=e._zod.def,i=Te(s.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},am=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},cm=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},lm=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},um=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType;let a;try{a=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},dm=(e,t,n,r)=>{const s=e._zod.def,i=s.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?s.out:s.in:s.out;Te(a,t,r);const c=t.seen.get(e);c.ref=a},hm=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.readOnly=!0},Pa=(e,t,n,r)=>{const s=e._zod.def;Te(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},mm=v("ZodISODateTime",(e,t)=>{xd.init(e,t),me.init(e,t)});function Ma(e){return yh(mm,e)}const fm=v("ZodISODate",(e,t)=>{bd.init(e,t),me.init(e,t)});function Da(e){return kh(fm,e)}const pm=v("ZodISOTime",(e,t)=>{_d.init(e,t),me.init(e,t)});function gm(e){return wh(pm,e)}const xm=v("ZodISODuration",(e,t)=>{vd.init(e,t),me.init(e,t)});function bm(e){return Sh(xm,e)}const _m=(e,t)=>{xa.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>cu(e,n)},flatten:{value:n=>au(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,es,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,es,2)}},isEmpty:{get(){return e.issues.length===0}}})},Je=v("ZodError",_m,{Parent:Error}),vm=Es(Je),ym=$s(Je),km=vr(Je),wm=yr(Je),Sm=du(Je),jm=hu(Je),Nm=mu(Je),Tm=fu(Je),Em=pu(Je),$m=gu(Je),Cm=xu(Je),Rm=bu(Je),Di=new WeakMap;function On(e,t,n){const r=Object.getPrototypeOf(e);let s=Di.get(r);if(s||(s=new Set,Di.set(r,s)),!s.has(t)){s.add(t);for(const i in n){const a=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const c=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}}const xe=v("ZodType",(e,t)=>(ge.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:lr(e,"input"),output:lr(e,"output")}}),e.toJSONSchema=Hh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>vm(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>km(e,n,r),e.parseAsync=async(n,r)=>ym(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>wm(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Sm(e,n,r),e.decode=(n,r)=>jm(e,n,r),e.encodeAsync=async(n,r)=>Nm(e,n,r),e.decodeAsync=async(n,r)=>Tm(e,n,r),e.safeEncode=(n,r)=>Em(e,n,r),e.safeDecode=(n,r)=>$m(e,n,r),e.safeEncodeAsync=async(n,r)=>Cm(e,n,r),e.safeDecodeAsync=async(n,r)=>Rm(e,n,r),On(e,"ZodType",{check(...n){const r=this.def;return this.clone(Ct(r,{checks:[...r.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Rt(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(jf(n,r))},superRefine(n,r){return this.check(Nf(n,r))},overwrite(n){return this.check(hn(n))},optional(){return Ui(this)},exactOptional(){return hf(this)},nullable(){return qi(this)},nullish(){return Ui(qi(this))},nonoptional(n){return bf(this,n)},array(){return we(this)},or(n){return rf([this,n])},and(n){return af(this,n)},transform(n){return Bi(this,uf(n))},default(n){return pf(this,n)},prefault(n){return xf(this,n)},catch(n){return vf(this,n)},pipe(n){return Bi(this,n)},readonly(){return wf(this)},describe(n){const r=this.clone();return jn.add(r,{description:n}),r},meta(...n){if(n.length===0)return jn.get(this);const r=this.clone();return jn.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=jn.get(e))==null?void 0:n.description},configurable:!0}),e)),Za=v("_ZodString",(e,t)=>{Cs.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,s,i)=>Vh(e,r,s);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,On(e,"_ZodString",{regex(...r){return this.check(Ch(...r))},includes(...r){return this.check(zh(...r))},startsWith(...r){return this.check(Ih(...r))},endsWith(...r){return this.check(Lh(...r))},min(...r){return this.check(cr(...r))},max(...r){return this.check(Aa(...r))},length(...r){return this.check(za(...r))},nonempty(...r){return this.check(cr(1,...r))},lowercase(r){return this.check(Rh(r))},uppercase(r){return this.check(Ah(r))},trim(){return this.check(Ph())},normalize(...r){return this.check(Oh(...r))},toLowerCase(){return this.check(Mh())},toUpperCase(){return this.check(Dh())},slugify(){return this.check(Zh())}})}),Am=v("ZodString",(e,t)=>{Cs.init(e,t),Za.init(e,t),e.email=n=>e.check(th(zm,n)),e.url=n=>e.check(oh(Im,n)),e.jwt=n=>e.check(vh(Jm,n)),e.emoji=n=>e.check(ah(Lm,n)),e.guid=n=>e.check(Li(Zi,n)),e.uuid=n=>e.check(nh(Kn,n)),e.uuidv4=n=>e.check(rh(Kn,n)),e.uuidv6=n=>e.check(sh(Kn,n)),e.uuidv7=n=>e.check(ih(Kn,n)),e.nanoid=n=>e.check(ch(Om,n)),e.guid=n=>e.check(Li(Zi,n)),e.cuid=n=>e.check(lh(Pm,n)),e.cuid2=n=>e.check(uh(Mm,n)),e.ulid=n=>e.check(Ra(Fa,n)),e.base64=n=>e.check(xh(Wm,n)),e.base64url=n=>e.check(bh(Vm,n)),e.xid=n=>e.check(dh(Zm,n)),e.ksuid=n=>e.check(hh(Fm,n)),e.ipv4=n=>e.check(mh(Um,n)),e.ipv6=n=>e.check(fh(qm,n)),e.cidrv4=n=>e.check(ph(Bm,n)),e.cidrv6=n=>e.check(gh(Hm,n)),e.e164=n=>e.check(_h(Gm,n)),e.datetime=n=>e.check(Ma(n)),e.date=n=>e.check(Da(n)),e.time=n=>e.check(gm(n)),e.duration=n=>e.check(bm(n))});function w(e){return eh(Am,e)}const me=v("ZodStringFormat",(e,t)=>{ue.init(e,t),Za.init(e,t)}),zm=v("ZodEmail",(e,t)=>{cd.init(e,t),me.init(e,t)}),Zi=v("ZodGUID",(e,t)=>{od.init(e,t),me.init(e,t)}),Kn=v("ZodUUID",(e,t)=>{ad.init(e,t),me.init(e,t)}),Im=v("ZodURL",(e,t)=>{ld.init(e,t),me.init(e,t)}),Lm=v("ZodEmoji",(e,t)=>{ud.init(e,t),me.init(e,t)}),Om=v("ZodNanoID",(e,t)=>{dd.init(e,t),me.init(e,t)}),Pm=v("ZodCUID",(e,t)=>{hd.init(e,t),me.init(e,t)}),Mm=v("ZodCUID2",(e,t)=>{md.init(e,t),me.init(e,t)}),Fa=v("ZodULID",(e,t)=>{fd.init(e,t),me.init(e,t)});function Dm(e){return Ra(Fa,e)}const Zm=v("ZodXID",(e,t)=>{pd.init(e,t),me.init(e,t)}),Fm=v("ZodKSUID",(e,t)=>{gd.init(e,t),me.init(e,t)}),Um=v("ZodIPv4",(e,t)=>{yd.init(e,t),me.init(e,t)}),qm=v("ZodIPv6",(e,t)=>{kd.init(e,t),me.init(e,t)}),Bm=v("ZodCIDRv4",(e,t)=>{wd.init(e,t),me.init(e,t)}),Hm=v("ZodCIDRv6",(e,t)=>{Sd.init(e,t),me.init(e,t)}),Wm=v("ZodBase64",(e,t)=>{jd.init(e,t),me.init(e,t)}),Vm=v("ZodBase64URL",(e,t)=>{Td.init(e,t),me.init(e,t)}),Gm=v("ZodE164",(e,t)=>{Ed.init(e,t),me.init(e,t)}),Jm=v("ZodJWT",(e,t)=>{Cd.init(e,t),me.init(e,t)}),Ua=v("ZodNumber",(e,t)=>{Na.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,s,i)=>Gh(e,r,s),On(e,"ZodNumber",{gt(r,s){return this.check(Pi(r,s))},gte(r,s){return this.check(Hr(r,s))},min(r,s){return this.check(Hr(r,s))},lt(r,s){return this.check(Oi(r,s))},lte(r,s){return this.check(Br(r,s))},max(r,s){return this.check(Br(r,s))},int(r){return this.check(Fi(r))},safe(r){return this.check(Fi(r))},positive(r){return this.check(Pi(0,r))},nonnegative(r){return this.check(Hr(0,r))},negative(r){return this.check(Oi(0,r))},nonpositive(r){return this.check(Br(0,r))},multipleOf(r,s){return this.check(Mi(r,s))},step(r,s){return this.check(Mi(r,s))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function F(e){return jh(Ua,e)}const Ym=v("ZodNumberFormat",(e,t)=>{Rd.init(e,t),Ua.init(e,t)});function Fi(e){return Nh(Ym,e)}const Km=v("ZodBoolean",(e,t)=>{Ad.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Jh(e,n,r)});function Me(e){return Th(Km,e)}const Xm=v("ZodUnknown",(e,t)=>{zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Kh()});function Ft(){return Eh(Xm)}const Qm=v("ZodNever",(e,t)=>{Id.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Yh(e,n,r)});function ef(e){return $h(Qm,e)}const tf=v("ZodArray",(e,t)=>{Ld.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>nm(e,n,r,s),e.element=t.element,On(e,"ZodArray",{min(n,r){return this.check(cr(n,r))},nonempty(n){return this.check(cr(1,n))},max(n,r){return this.check(Aa(n,r))},length(n,r){return this.check(za(n,r))},unwrap(){return this.element}})});function we(e,t){return Fh(tf,e,t)}const nf=v("ZodObject",(e,t)=>{Pd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>rm(e,n,r,s),ne(e,"shape",()=>t.shape),On(e,"ZodObject",{keyof(){return oe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Ft()})},loose(){return this.clone({...this._zod.def,catchall:Ft()})},strict(){return this.clone({...this._zod.def,catchall:ef()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return tu(this,n)},safeExtend(n){return nu(this,n)},merge(n){return ru(this,n)},pick(n){return Ql(this,n)},omit(n){return eu(this,n)},partial(...n){return su(Ba,this,n[0])},required(...n){return iu(Ha,this,n[0])}})});function j(e,t){const n={type:"object",shape:e??{},...Z(t)};return new nf(n)}const qa=v("ZodUnion",(e,t)=>{$a.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>sm(e,n,r,s),e.options=t.options});function rf(e,t){return new qa({type:"union",options:e,...Z(t)})}const sf=v("ZodDiscriminatedUnion",(e,t)=>{qa.init(e,t),Md.init(e,t)});function wr(e,t,n){return new sf({type:"union",options:t,discriminator:e,...Z(n)})}const of=v("ZodIntersection",(e,t)=>{Dd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>im(e,n,r,s)});function af(e,t){return new of({type:"intersection",left:e,right:t})}const ns=v("ZodEnum",(e,t)=>{Zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,s,i)=>Xh(e,r,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new ns({...t,checks:[],...Z(s),entries:i})},e.exclude=(r,s)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new ns({...t,checks:[],...Z(s),entries:i})}});function oe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ns({type:"enum",entries:n,...Z(t)})}const cf=v("ZodLiteral",(e,t)=>{Fd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Qh(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function O(e,t){return new cf({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}const lf=v("ZodTransform",(e,t)=>{Ud.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>tm(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new da(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(zn(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(zn(a))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=s,n.fallback=!0,n)}});function uf(e){return new lf({type:"transform",transform:e})}const Ba=v("ZodOptional",(e,t)=>{Ca.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Pa(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Ba({type:"optional",innerType:e})}const df=v("ZodExactOptional",(e,t)=>{qd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Pa(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function hf(e){return new df({type:"optional",innerType:e})}const mf=v("ZodNullable",(e,t)=>{Bd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>om(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function qi(e){return new mf({type:"nullable",innerType:e})}const ff=v("ZodDefault",(e,t)=>{Hd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>cm(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pf(e,t){return new ff({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():fa(t)}})}const gf=v("ZodPrefault",(e,t)=>{Wd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>lm(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function xf(e,t){return new gf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():fa(t)}})}const Ha=v("ZodNonOptional",(e,t)=>{Vd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>am(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function bf(e,t){return new Ha({type:"nonoptional",innerType:e,...Z(t)})}const _f=v("ZodCatch",(e,t)=>{Gd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>um(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vf(e,t){return new _f({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const yf=v("ZodPipe",(e,t)=>{Jd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>dm(e,n,r,s),e.in=t.in,e.out=t.out});function Bi(e,t){return new yf({type:"pipe",in:e,out:t})}const kf=v("ZodReadonly",(e,t)=>{Yd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>hm(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function wf(e){return new kf({type:"readonly",innerType:e})}const Sf=v("ZodCustom",(e,t)=>{Kd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(n,r,s)=>em(e,n)});function jf(e,t={}){return Uh(Sf,e,t)}function Nf(e,t){return qh(e,t)}const se=Dm(),Tf=/^[a-z0-9][a-z0-9-]{0,62}$/,je=w().regex(Tf);function Ef(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-").slice(0,63).replace(/-+$/g,"")||"channel"}const be=F().int().positive(),st=F().int().nonnegative(),pe=Ma(),Sr=oe(["read-only","workspace-write","full-access"]),Wa=["low","medium","high"],ur=oe([...Wa,"xhigh","max","ultra","ultracode"]),Rs=oe(["human","agent","extension","system","bridge"]),As=oe(["idle","running","queued","awaiting_input","paused","dead","unreachable","custody_uncertain"]),$f=oe(["owned","mirrored"]),Cf=oe(["owner","admin","member","observer"]),Rf=/^[a-z0-9][a-z0-9-]{1,30}$/,Va=["all","switchboard"],jr=w().regex(Rf),Mt=jr.refine(e=>!Va.includes(e),{message:"handle is reserved"});function Af(e){const n=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,31).replace(/-+$/g,""),r=n.length>=2?n:"agent";return Mt.safeParse(r).success?r:void 0}const rs=j({inputTokens:F().int().nonnegative().optional(),cachedInputTokens:F().int().nonnegative().optional(),outputTokens:F().int().nonnegative().optional(),totalCostUsd:F().nonnegative().optional(),contextWindowMaxTokens:F().int().positive().optional(),contextWindowUsedTokens:F().int().nonnegative().optional(),estimated:O(!0).optional()}).strict().superRefine((e,t)=>{e.contextWindowMaxTokens===void 0!=(e.contextWindowUsedTokens===void 0)&&t.addIssue({code:"custom",path:["contextWindowUsedTokens"],message:"context window maximum and used tokens must be reported together"})}),Ga=j({window:w().min(1),status:w().min(1).optional(),resets_at:pe.optional(),used_percent:F().min(0).max(100).optional()}).loose(),Hi=j({id:se,kind:Rs,handle:jr,display_name:w(),purpose:w().optional(),harness:w().min(1).optional(),session_ref:w().min(1).optional(),cwd:w().min(1).optional(),policy:w().min(1).optional(),model:w().min(1).optional(),thinking:ur.optional(),host:w().min(1).optional(),limits:we(Ga).optional(),lastUsage:rs.optional(),state:As.optional(),custody:$f.optional(),parent:se.optional(),role:Cf.optional(),conventions_sent:Me().default(!1),misaddressed:Me().default(!1),roster_stale:Me().default(!0),removed_ts:pe.optional(),waiting:j({peers:we(se).min(1),reason:oe(["reply","mention","any"]),since_ts:pe,until_ts:pe}).optional()}).superRefine((e,t)=>{e.kind!=="system"&&Va.includes(e.handle)&&t.addIssue({code:"custom",path:["handle"],message:`handle '${e.handle}' is reserved for the system member`}),e.kind==="human"&&e.role===void 0?t.addIssue({code:"custom",path:["role"],message:"human members require a role"}):e.kind!=="human"&&e.role!==void 0&&t.addIssue({code:"custom",path:["role"],message:"only human members may have a role"})}),zs=oe(["chat","run","ask","approval","system"]),zf=j({member_id:se,start:F().int().nonnegative(),end:F().int().positive()}).refine(e=>e.start<e.end,{message:"span end must be after start"}),If=j({platform:w().min(1),external_id:w().min(1),sender_name:w().min(1)}),ss=j({interaction_id:w().min(1),kind:oe(["ask","approval"]),prompt:w(),options:we(j({label:w().min(1),description:w().optional()})).optional(),multi:Me().optional(),tool:w().optional(),detail:w().optional()}),Ja=j({input_tokens:F().int().nonnegative(),output_tokens:F().int().nonnegative(),cost_usd:F().nonnegative().optional()}),Ya=oe(["running","completed","failed","interrupted"]),Lf=j({status:Ya,started_ts:pe,ended_ts:pe.optional(),stalled_since:pe.optional(),tool_calls:F().int().nonnegative(),usage:Ja.optional(),events_ref:w().min(1),final_text:w().optional(),model:w().min(1).optional(),estimated_cost_usd:F().nonnegative().optional(),output_mode:O("messages").optional(),result_message_id:be.optional(),error:w().min(1).optional()}),Of=j({id:w().min(1),name:w().min(1),mime:w().min(1),size:F().int().nonnegative()}),dr=j({id:be,room:je,author:se,kind:zs,body:w(),mentions:we(zf),refs:we(be),ledger_refs:we(w()),reply_to:be.optional(),run:Lf.optional(),run_parent_id:be.optional(),ask:ss.optional(),origin:If.optional(),ack:Me().optional(),pinned:Me().optional(),deleted:Me().optional(),attachments:we(Of).optional(),ts:pe,seq:st}),Pf=j({peers:we(jr).min(1),reason:oe(["reply","mention","any"]),since_ts:pe,until_ts:pe}).strict(),Mf=j({kind:oe(["tool","post"]),title:w().max(500),status:oe(["ok","error"]).optional(),duration_ms:F().nonnegative().optional(),ts:pe}).strict();j({member:j({handle:jr,state:As,waiting:Pf.optional()}).strict(),current_run:j({message_id:be,started_ts:pe,elapsed_ms:F().nonnegative(),tool_calls:F().int().nonnegative()}).strict().optional(),recent:we(Mf).max(5)}).strict();j({message_id:be,item_index:F().int().nonnegative(),kind:oe(["tool_call","tool_result"]),excerpt:w().max(240)}).strict();const Ka=e=>e.kind==="agent"&&e.removed_ts===void 0,Df=e=>Ka(e)&&e.state!=="dead";function Zf(e){if(e.latestFinalizedAgentId!==void 0){const n=e.members.find(r=>r.id===e.latestFinalizedAgentId&&Ka(r));if(n)return n}const t=e.members.filter(Df);if(e.startingAgentHandle!==void 0){const n=t.find(r=>r.handle===e.startingAgentHandle);if(n)return n}return t.length===1?t[0]:void 0}const Ff=oe(["pending","answered","acked","orphaned"]);j({id:w().min(1),room:je,member_id:se,message_id:be,native_id:w().min(1),kind:oe(["ask","approval"]),targets:we(se),state:Ff,answer:Ft().optional(),answered_by:se.optional(),answered_ts:pe.optional()});const Uf=oe(["queued","delivering","consumed","held"]),is=j({id:w().min(1),room:je,message_id:be,recipient:se,state:Uf,hop_count:F().int().nonnegative().optional(),attempt_count:F().int().nonnegative().default(0),batch_id:w().min(1).optional(),run_msg_id:be.optional(),read_ts:pe.optional(),interaction_resolved_ts:pe.optional(),group_id:w().min(1).optional(),group_round:F().int().positive().optional(),ts:pe}).superRefine((e,t)=>{e.group_id===void 0!=(e.group_round===void 0)&&t.addIssue({code:"custom",path:[e.group_id===void 0?"group_id":"group_round"],message:"group_id and group_round must be provided together"})}),qf=oe(["message","member","inbox","meter","room"]);j({room:je,seq:st,entity:qf,entity_id:w().min(1)});const Bf=j({turn_brake:F().int().positive().nullable().default(null),spend_brake_usd:F().positive().nullable().default(null),stall_minutes:F().int().positive().default(30),redaction_enabled:Me().default(!0),color:w().min(1).optional(),cwd:w().min(1).optional(),starting_agent_handle:Mt.optional(),bridged:Me().default(!1)}),Wi=j({id:je,name:w().min(1),created_ts:pe,config:Bf.prefault({})}),Hf=j({id:F().int().positive(),ts:pe,kind:zs,author_handle:w(),author_kind:Rs,preview:w().max(140)}),Wf=j({id:je,name:w().min(1),created_ts:pe,color:w().min(1).optional(),working:Me(),attention:Me(),latest:Hf.optional(),unread:F().int().nonnegative()}),Vf=j({delivery:is,author_id:se,author_handle:w(),author_kind:Rs,message_kind:zs,preview:w().max(140),ts:pe}),Gf=j({room:je,summary:Wf,latest_finalized_agent_id:se.optional(),active_runs:we(dr),interactions:we(dr),inbox:we(Vf)}),Jf=j({harness:w().min(1),handle:Mt,display_name:w().min(1).optional(),model:w().optional(),thinking:ur.optional(),policy:Sr.optional()});j({id:je.optional(),name:w().min(1),owner:j({handle:Mt,display_name:w()}),color:w().min(1).optional(),cwd:w().min(1).optional(),starting_agent:Jf.optional()});const Yf=j({room:je,day:Da(),turns:F().int().nonnegative(),cost_usd:F().nonnegative(),estimated_cost_usd:F().nonnegative().optional(),input_tokens:F().int().nonnegative(),output_tokens:F().int().nonnegative(),uncosted_tokens:F().int().nonnegative().optional()}),Kf=oe(["tool_call","tool_result","reasoning_summary","text_delta","commit","file_change"]),Xa=j({path:w().min(1),unified:w()}).loose(),Xf=j({media_type:w().min(1),data_b64:w()}).loose(),Qf=j({call_id:w().min(1),tool:w().min(1),title:w().min(1),detail:w().optional(),input:Ft().optional()}).loose(),ep=j({call_id:w().min(1),status:oe(["ok","error"]),output_text:w().optional(),diff:Xa.optional(),image:Xf.optional(),duration_ms:F().nonnegative().optional(),raw:Ft().optional()}).loose(),tp=j({text:w()}).loose(),np=j({text:w()}).loose(),rp=j({path:w().min(1),change:oe(["created","modified","deleted"]),diff:Xa.optional()}).loose(),sp=j({sha:w().optional(),message:w().optional()}).loose(),ip={tool_call:Qf,tool_result:ep,reasoning_summary:np,text_delta:tp,commit:sp,file_change:rp};function Kt(e,t){return ip[e].safeParse(t)}const Wr=w().min(1),op=j({type:O("compaction"),status:oe(["loading","completed"]),trigger:oe(["auto","manual"]).optional(),preTokens:F().nonnegative().optional()}).loose(),ap=wr("type",[j({type:O("run.started"),member:se,trigger_msg:be}),j({type:O("run.item"),item_type:Kf,payload:Ft(),output_message_id:be.optional(),ts:pe.optional()}),j({type:O("ask.raised"),card:ss}),j({type:O("approval.raised"),card:ss}),j({type:O("timeline"),item:op,output_message_id:be.optional()}),j({type:O("usage_updated"),usage:rs}),j({type:O("run.completed"),status:Ya.exclude(["running"]),final_text:w().optional(),output_message_id:be.optional(),error:w().min(1).optional(),usage:Ja.optional(),agent_usage:rs.optional()}),j({type:O("run.limits"),limits:we(Ga).min(1)}),j({type:O("member.state"),member:se,state:As}),j({type:O("extension.started"),parent:Wr,ext_member:Wr,description:w().min(1).optional(),agent_type:w().min(1).optional(),transcript_path:w().min(1).optional()}),j({type:O("extension.ended"),ext_member:Wr,summary:w().optional(),transcript_path:w().min(1).optional()})]),rr=2,cp=j({type:O("subscribe"),room:je,since_seq:st,hydrate_limit:F().int().positive().optional(),room_addressed:O(!0).optional(),browser_protocol:F().int().positive().optional(),client_kind:O("browser").optional()}),lp=j({type:O("post"),room:je,body:w(),reply_to:be.optional(),attachments:we(w().min(1)).max(8).optional(),awaiting_reply:Me().optional()}),up=j({type:O("list_rooms")}),dp=wr("act",[j({act:O("answer_interaction"),interaction_id:w().min(1),answer:Ft()}),j({act:O("redeliver"),delivery_id:w().min(1)}),j({act:O("release_hold"),delivery_id:w().min(1)}),j({act:O("mark_read"),delivery_id:w().min(1)}),j({act:O("mark_room_read"),through_seq:st}),j({act:O("join"),harness:w().min(1),handle:Mt,session_ref:w().min(1),cwd:w().min(1),policy:w().optional(),purpose:w().optional()}),j({act:O("adopt"),member_id:se}),j({act:O("attach_acquire"),member_id:se,cli_pid:F().int().positive()}),j({act:O("attach_child"),lease_id:w().min(1),child_pid:F().int().positive(),process_group_id:F().int().positive()}),j({act:O("attach_heartbeat"),lease_id:w().min(1)}),j({act:O("attach_complete"),lease_id:w().min(1)}),j({act:O("configure_room"),turn_brake:F().int().positive().nullable().optional(),spend_brake_usd:F().positive().nullable().optional(),stall_minutes:F().int().positive().optional()}),j({act:O("spawn"),harness:w().min(1),handle:Mt,cwd:w().min(1),model:w().optional(),policy:w().optional(),thinking:ur.optional(),purpose:w().optional()}),j({act:O("rename"),member_id:se,handle:Mt,display_name:w().optional()}),j({act:O("revive"),member_id:se}),j({act:O("kill"),member_id:se}),j({act:O("remove"),member_id:se}),j({act:O("pause"),member_id:se}),j({act:O("unpause"),member_id:se}),j({act:O("interrupt"),member_id:se}),j({act:O("compact_member"),member_id:se}),j({act:O("consume_delivery"),delivery_id:w().uuid()}),j({act:O("wait_begin"),reason:oe(["reply","mention","any"]),peers:we(se).min(1),until_ts:pe}),j({act:O("wait_end")}),j({act:O("configure"),member_id:se,model:w().min(1).nullable().optional(),thinking:ur.nullable().optional(),policy:Sr.optional()}),j({act:O("set_role"),member_id:se,role:oe(["owner","admin","member","observer"])}),j({act:O("pin_message"),message_id:be,pinned:Me()}),j({act:O("delete_message"),message_id:be}),j({act:O("retry_run"),message_id:be})]),hp=j({type:O("act"),room:je,act:dp}),mp=j({type:O("mirror_turn"),harness:w().min(1),session_ref:w().min(1),native_turn_id:w().min(1),body:w(),transcript_path:w().optional()}),fp=j({type:O("mirror_session_end"),harness:w().min(1),session_ref:w().min(1)});wr("type",[up,cp,lp,hp,mp,fp]);const pp=j({id:w().min(1),room:je,member_id:se,cli_pid:F().int().positive(),child_pid:F().int().positive().optional(),process_group_id:F().int().positive().optional(),heartbeat_ts:F().int().nonnegative()});wr("type",[j({type:O("upgrade_required"),minimum_browser_protocol:F().int().positive(),current_browser_protocol:F().int().positive()}),j({type:O("rooms"),rooms:we(Wi)}),j({type:O("self"),member_id:se,room:je.optional()}),j({type:O("attach_lease"),status:oe(["acquired","child_recorded","completed","uncertain"]),lease:pp.optional(),member:Hi}),j({type:O("mirror_ack"),native_turn_id:w().optional(),message_id:be.optional(),deduped:Me().optional(),adopted:Me().optional()}),j({type:O("message"),seq:st,message:dr}),j({type:O("member"),seq:st,member:Hi,room:je.optional()}),j({type:O("inbox"),seq:st,delivery:is}),j({type:O("consume_result"),delivery:is,message:dr}),j({type:O("meter"),seq:st,meter:Yf}),j({type:O("room"),seq:st,room:Wi}),j({type:O("room_support"),seq:st,support:Gf}),j({type:O("sync_complete"),seq:st,room:je.optional(),history_floor:be.optional()}),j({type:O("run_event"),room:je,message_id:be,event:ap,index:F().int().nonnegative().optional()}),j({type:O("error"),message:w(),ref:w().optional()})]);const Vi=e=>{let t;const n=new Set,r=(d,u)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const f=t;t=u??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(p=>p(t,f))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(r,s,c);return c},gp=(e=>e?Vi(e):Vi),xp=e=>e;function bp(e,t=xp){const n=Vn.useSyncExternalStore(e.subscribe,Vn.useCallback(()=>t(e.getState()),[e,t]),Vn.useCallback(()=>t(e.getInitialState()),[e,t]));return Vn.useDebugValue(n),n}const Gi=e=>{const t=gp(e),n=r=>bp(t,r);return Object.assign(n,t),n},Qa=(e=>e?Gi(e):Gi),Ji=20,_p=500;let rt;const vp=()=>({members:{},messages:{},inbox:{}});function yp(){rt=void 0}function ec(e,t,n){let r=e??{events:[],dropped_count:0};if(n!==void 0){if(r.events.length===0)r={...r,first_index:n};else if(r.first_index!==void 0){const a=r.first_index+r.events.length;if(n<a)return r;n>a&&(r={...r,events:[],first_index:n})}}const s=[...r.events,t],i=Math.max(0,s.length-_p);return{events:i===0?s:s.slice(i),dropped_count:r.dropped_count+i,...r.first_index!==void 0&&{first_index:r.first_index+i}}}Qa((e,t)=>({connected:!1,hydrated:!1,selfMemberId:void 0,room:void 0,seq:0,members:{},memberHistory:{},messages:{},inbox:{},meter:void 0,runEvents:{},latestFinalizedAgentId:void 0,historyCursor:void 0,errors:[],applyFrame:n=>{if(t().seq===0){if(n.type==="self"){rt=vp(),rt.selfMemberId=n.member_id;return}if(rt!==void 0)switch(n.type){case"room":rt.room=n.room;return;case"member":rt.members[n.member.id]=n.member;return;case"message":rt.messages[n.message.id]=n.message;return;case"inbox":rt.inbox[n.delivery.id]=n.delivery;return;case"meter":rt.meter=n.meter;return}}e(r=>{var i,a,c,l,d;const s="seq"in n?Math.max(r.seq,n.seq):r.seq;switch(n.type){case"self":return{selfMemberId:n.member_id};case"room":return{seq:s,room:n.room};case"sync_complete":{if(r.seq!==0)return{seq:s};const u=rt;rt=void 0;const h={...r.members,...u==null?void 0:u.members},f={...r.memberHistory};for(const E of Object.values((u==null?void 0:u.members)??{})){const L=E.state??"idle",Q=f[E.id]??[];((i=Q.at(-1))==null?void 0:i.state)!==L&&(f[E.id]=[...Q,{state:L,ts:new Date().toISOString()}].slice(-12))}const p={...r.messages,...u==null?void 0:u.messages},g={...r.inbox,...u==null?void 0:u.inbox};let _=r.latestFinalizedAgentId;for(const E of Object.values(p).sort((L,Q)=>L.id-Q.id))E.kind==="run"&&E.run!==void 0&&E.run.status!=="running"&&E.ack!==!0&&((a=h[E.author])==null?void 0:a.kind)==="agent"&&(_=E.author);const S={seq:s,hydrated:!0,members:h,memberHistory:f,inbox:g,latestFinalizedAgentId:_,...(u==null?void 0:u.selfMemberId)!==void 0&&{selfMemberId:u.selfMemberId},...(u==null?void 0:u.room)!==void 0&&{room:u.room},...(u==null?void 0:u.meter)!==void 0&&{meter:u.meter}};if(n.history_floor!==void 0)return{...S,messages:p,historyCursor:n.history_floor};const R=Object.values(p).sort((E,L)=>E.id-L.id);if(R.length<=Ji)return{...S,messages:p,historyCursor:(c=R[0])==null?void 0:c.id};const A=new Set;for(const E of Object.values(p))E.reply_to!==void 0&&A.add(E.reply_to);const $=E=>(E.kind==="ask"||E.kind==="approval")&&E.ask!==void 0&&(E.kind==="approval"?Object.values(g).some(L=>L.message_id===E.id&&L.state==="consumed"&&L.interaction_resolved_ts===void 0):!A.has(E.id)),z=R.slice(-Ji),I=new Map(z.map(E=>[E.id,E]));for(const E of R)$(E)&&I.set(E.id,E);const k=[...I.values()].sort((E,L)=>E.id-L.id);return{...S,messages:Object.fromEntries(k.map(E=>[E.id,E])),historyCursor:(l=z[0])==null?void 0:l.id}}case"member":{const u=n.member.state??"idle",h=r.memberHistory[n.member.id]??[],f=h.at(-1),p=(f==null?void 0:f.state)===u?h:[...h,{state:u,ts:new Date().toISOString()}].slice(-12);return{seq:s,members:{...r.members,[n.member.id]:n.member},memberHistory:{...r.memberHistory,[n.member.id]:p}}}case"message":{const u=n.message.kind==="run"&&n.message.run!==void 0&&n.message.run.status!=="running"&&n.message.ack!==!0&&((d=r.members[n.message.author])==null?void 0:d.kind)==="agent";return{seq:s,messages:{...r.messages,[n.message.id]:n.message},...u&&{latestFinalizedAgentId:n.message.author}}}case"inbox":return{seq:s,inbox:{...r.inbox,[n.delivery.id]:n.delivery}};case"meter":return{seq:s,meter:n.meter};case"run_event":return{runEvents:{...r.runEvents,[n.message_id]:ec(r.runEvents[n.message_id],n.event,n.index)}};case"error":return{errors:[...r.errors,n.message]};default:return{}}})},mergeHistoryPage:n=>e(r=>{const s=n.reduce((i,a)=>i===void 0?a.id:Math.min(i,a.id),void 0);return{messages:{...r.messages,...Object.fromEntries(n.map(i=>[i.id,i]))},...s!==void 0&&{historyCursor:r.historyCursor===void 0?s:Math.min(r.historyCursor,s)}}}),setConnected:n=>e({connected:n}),reset:()=>{yp(),e({hydrated:!1,room:void 0,selfMemberId:void 0,seq:0,members:{},memberHistory:{},messages:{},inbox:{},meter:void 0,runEvents:{},latestFinalizedAgentId:void 0,historyCursor:void 0,errors:[]})}}));const In=20,kp={},wp={},Sp={},jp={},Np={},Tp=[],tc={hydrated:!1,selfMemberId:void 0,room:void 0,seq:0,members:kp,memberHistory:Np,messages:wp,inbox:Sp,meter:void 0,runEvents:jp,support:void 0,historyCursor:void 0,errors:Tp},Xn=e=>({hydrated:!1,selfMemberId:void 0,room:e,seq:0,members:{},memberHistory:{},messages:{},inbox:{},meter:void 0,runEvents:{},support:void 0,historyCursor:void 0,errors:[]}),vn=new Map,Ep=()=>({members:{},messages:{},inbox:{}});function $p(e,t){switch(e.type){case"self":case"member":case"sync_complete":return e.room??t;case"message":return e.message.room;case"inbox":return e.delivery.room;case"consume_result":return e.message.room;case"meter":return e.meter.room;case"room":return e.room.id;case"room_support":return e.support.room;case"run_event":return e.room;default:return t}}function Yi(e,t){var s;const n=t.state??"idle",r=e[t.id]??[];return((s=r.at(-1))==null?void 0:s.state)===n?e:{...e,[t.id]:[...r,{state:n,ts:new Date().toISOString()}].slice(-12)}}function Cp(e,t){const n={...e,[t.id]:t},r=Object.values(n).sort((s,i)=>s.id-i.id);return r.length<=In?n:Object.fromEntries(r.slice(-In).map(s=>[s.id,s]))}const H=Qa((e,t)=>({connected:!1,activeRoom:"",rooms:{},roomList:[],applyFrame:(n,r)=>{if(n.type==="rooms"){e(c=>{const l={...c.rooms};for(const d of n.rooms)l[d.id]=l[d.id]===void 0?Xn(d):{...l[d.id],room:d};return{roomList:n.rooms,rooms:l}});return}const s=$p(n,r);if(s===void 0)return;const i=t().rooms[s]??tc;if(n.type==="self"&&!i.hydrated){const c=Ep();c.selfMemberId=n.member_id,vn.set(s,c);return}const a=vn.get(s);if(a!==void 0)switch(n.type){case"room":a.room=n.room;return;case"member":a.members[n.member.id]=n.member;return;case"message":a.messages[n.message.id]=n.message;return;case"inbox":a.inbox[n.delivery.id]=n.delivery;return;case"meter":a.meter=n.meter;return;case"room_support":a.support=n.support;return}e(c=>{var h,f;const l=c.rooms[s]??Xn(),d="seq"in n?Math.max(l.seq,n.seq):l.seq;let u=l;switch(n.type){case"self":u={...l,selfMemberId:n.member_id};break;case"room":u={...l,seq:d,room:n.room};break;case"sync_complete":{const p=vn.get(s);if(vn.delete(s),p===void 0){u={...l,seq:d,hydrated:!0};break}const g={...p.members,...l.members},_={...p.messages,...l.messages},S={...p.inbox,...l.inbox};let R=l.memberHistory;for(const A of Object.values(g))R=Yi(R,A);u={...l,hydrated:!0,seq:d,selfMemberId:p.selfMemberId,room:p.room??l.room,members:g,memberHistory:R,messages:_,inbox:S,meter:l.meter??p.meter,support:l.support??p.support,historyCursor:n.history_floor??((h=Object.values(_).sort((A,$)=>A.id-$.id)[0])==null?void 0:h.id)};break}case"member":u={...l,seq:d,members:{...l.members,[n.member.id]:n.member},memberHistory:Yi(l.memberHistory,n.member)};break;case"message":{const p=c.activeRoom===s?{...l.messages,[n.message.id]:n.message}:Cp(l.messages,n.message);u={...l,seq:d,messages:p,...c.activeRoom!==s&&{historyCursor:(f=Object.values(p).sort((g,_)=>g.id-_.id)[0])==null?void 0:f.id}};break}case"inbox":u={...l,seq:d,inbox:{...l.inbox,[n.delivery.id]:n.delivery}};break;case"consume_result":u={...l,messages:{...l.messages,[n.message.id]:n.message},inbox:{...l.inbox,[n.delivery.id]:n.delivery}};break;case"meter":u={...l,seq:d,meter:n.meter};break;case"room_support":u={...l,seq:d,support:n.support};break;case"run_event":if(c.activeRoom!==s)return{};u={...l,runEvents:{...l.runEvents,[n.message_id]:ec(l.runEvents[n.message_id],n.event,n.index)}};break;case"error":u={...l,errors:[...l.errors,n.message]};break;default:return{}}return{rooms:{...c.rooms,[s]:u}}})},mergeHistoryPage:(n,r)=>{e(s=>{const i=s.rooms[n]??Xn(),a=r.reduce((c,l)=>c===void 0?l.id:Math.min(c,l.id),void 0);return{rooms:{...s.rooms,[n]:{...i,messages:{...i.messages,...Object.fromEntries(r.map(c=>[c.id,c]))},...a!==void 0&&{historyCursor:i.historyCursor===void 0?a:Math.min(i.historyCursor,a)}}}}})},setActiveRoom:n=>{e(r=>{if(r.activeRoom===n)return{};const s={...r.rooms},i=s[r.activeRoom];return i!==void 0&&Object.keys(i.runEvents).length>0&&(s[r.activeRoom]={...i,runEvents:{}}),s[n]===void 0&&(s[n]=Xn()),{activeRoom:n,rooms:s}})},setConnected:n=>e({connected:n}),reset:()=>{vn.clear(),e({connected:!1,activeRoom:"",rooms:{},roomList:[]})}})),ie=(e,t)=>e.rooms[t]??tc,Rp=e=>Object.values(e).sort((t,n)=>t.id-n.id),Ap=(e,t)=>t!==void 0?e[t]:Object.values(e).find(n=>n.kind==="human"&&n.role==="owner"),zp=e=>Object.values(e).filter(t=>t.state==="held"),Ip=e=>{var t,n;return Zf({members:Object.values(e.members),latestFinalizedAgentId:(t=e.support)==null?void 0:t.latest_finalized_agent_id,startingAgentHandle:(n=e.room)==null?void 0:n.config.starting_agent_handle})};function nc(){const t=new URLSearchParams(window.location.search).get("room");return t===null||t===""?{}:{room:t}}async function os(){const e=new URL(window.location.href),t=e.searchParams.get("token")??"";if(t!==""){try{await ia({origin:window.location.origin,authority:"operator",token:t}),e.searchParams.delete("token"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}catch{}return En(t)}try{return En(await Pl(window.location.origin))}catch{return En("")}}const Lp=e=>x.useCallback(()=>Ll(e),[e]);function rc(){return H(e=>e.connected)}function sc(e){const t=rc(),[n,r]=x.useState([]);return x.useEffect(()=>{if(!t)return;let s=!0,i,a=10;const c=()=>{Ul({token:e()}).then(l=>{s&&(r(l.adapters),!(!l.discovering||a<=0)&&(a-=1,i=setTimeout(c,500)))}).catch(()=>{})};return c(),()=>{s=!1,i!==void 0&&clearTimeout(i)}},[t,e]),n}function Op(e,t){const n=rc(),[r,s]=x.useState({});return x.useEffect(()=>{if(!n)return;let i=!0;return Hl(e,{token:t()}).then(a=>{i&&s(Object.fromEntries(a.map(c=>[c.member.id,c])))}).catch(()=>{}),()=>{i=!1}},[n,e,t]),r}function Nr(){return x.useSyncExternalStore(e=>{const t=window.matchMedia("(max-width: 719px)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia("(max-width: 719px)").matches,()=>!1)}function Pp(){return x.useSyncExternalStore(e=>{const t=setInterval(e,6e4);return()=>clearInterval(t)},()=>Math.floor(Date.now()/6e4),()=>0)}let sr;function Ki(e){sr=e}async function ic(e){const t=await fetch("/api/rooms/summary?read_state=durable",{headers:{authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`summary failed: ${t.status}`);return(await t.json()).rooms}function Mp(e){const t=H(s=>s.rooms),[n,r]=x.useState(sr??[]);return x.useEffect(()=>{if(sr!==void 0){r(sr);return}let s=!0;return ic(e()).then(i=>{s&&r(i)}).catch(()=>ca({token:e()}).then(i=>{s&&r(i.map(a=>({id:a.id,name:a.name,created_ts:a.created_ts,color:a.config.color,working:!1,attention:!1,unread:0})))}).catch(()=>{})),()=>{s=!1}},[e]),x.useMemo(()=>{const s=new Map(n.map(i=>[i.id,i]));for(const i of Object.values(t))i.support!==void 0?s.set(i.support.room,i.support.summary):i.room!==void 0&&!s.has(i.room.id)&&s.set(i.room.id,{id:i.room.id,name:i.room.name,created_ts:i.room.created_ts,color:i.room.config.color,working:!1,attention:!1,unread:0});return[...s.values()]},[n,t])}const Is="codor:web-next:room";function Dp(e,t){var r;const n=s=>s!==void 0&&e.some(i=>i.id===s)?s:void 0;return n(t.explicit)??n(t.remembered)??((r=Zp(e)[0])==null?void 0:r.id)}function Zp(e){const t=n=>{var r;return Date.parse(((r=n.latest)==null?void 0:r.ts)??n.created_ts)||0};return[...e].sort((n,r)=>{if(n.working!==r.working)return n.working?-1:1;const s=t(r)-t(n);if(s!==0)return s;const i=(Date.parse(r.created_ts)||0)-(Date.parse(n.created_ts)||0);return i!==0?i:n.id.localeCompare(r.id)})}function Qn(){try{return window.localStorage.getItem(Is)??void 0}catch{return}}function hr(e){try{window.localStorage.setItem(Is,e)}catch{}}function Xi(){try{window.localStorage.removeItem(Is)}catch{}}async function Fp(e){try{const t=await ic(e);return Ki(t),t}catch{const n=(await ca({token:e})).map(r=>({id:r.id,name:r.name,created_ts:r.created_ts,color:r.config.color,working:!1,attention:!1,unread:0}));return Ki(n),n}}/**
|
|
74
|
-
* @license lucide-react v1.24.0 - ISC
|
|
75
|
-
*
|
|
76
|
-
* This source code is licensed under the ISC license.
|
|
77
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
78
|
-
*/const oc=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
|
79
|
-
* @license lucide-react v1.24.0 - ISC
|
|
80
|
-
*
|
|
81
|
-
* This source code is licensed under the ISC license.
|
|
82
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
83
|
-
*/const Up=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
84
|
-
* @license lucide-react v1.24.0 - ISC
|
|
85
|
-
*
|
|
86
|
-
* This source code is licensed under the ISC license.
|
|
87
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
88
|
-
*/const qp=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
|
|
89
|
-
* @license lucide-react v1.24.0 - ISC
|
|
90
|
-
*
|
|
91
|
-
* This source code is licensed under the ISC license.
|
|
92
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
93
|
-
*/const Qi=e=>{const t=qp(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
94
|
-
* @license lucide-react v1.24.0 - ISC
|
|
95
|
-
*
|
|
96
|
-
* This source code is licensed under the ISC license.
|
|
97
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
98
|
-
*/var Vr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
99
|
-
* @license lucide-react v1.24.0 - ISC
|
|
100
|
-
*
|
|
101
|
-
* This source code is licensed under the ISC license.
|
|
102
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
103
|
-
*/const Bp=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},Hp=x.createContext({}),Wp=()=>x.useContext(Hp),Vp=x.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:s="",children:i,iconNode:a,...c},l)=>{const{size:d=24,strokeWidth:u=2,absoluteStrokeWidth:h=!1,color:f="currentColor",className:p=""}=Wp()??{},g=r??h?Number(n??u)*24/Number(t??d):n??u;return x.createElement("svg",{ref:l,...Vr,width:t??d??Vr.width,height:t??d??Vr.height,stroke:e??f,strokeWidth:g,className:oc("lucide",p,s),...!i&&!Bp(c)&&{"aria-hidden":"true"},...c},[...a.map(([_,S])=>x.createElement(_,S)),...Array.isArray(i)?i:[i]])});/**
|
|
104
|
-
* @license lucide-react v1.24.0 - ISC
|
|
105
|
-
*
|
|
106
|
-
* This source code is licensed under the ISC license.
|
|
107
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
108
|
-
*/const V=(e,t)=>{const n=x.forwardRef(({className:r,...s},i)=>x.createElement(Vp,{ref:i,iconNode:t,className:oc(`lucide-${Up(Qi(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Qi(e),n};/**
|
|
109
|
-
* @license lucide-react v1.24.0 - ISC
|
|
110
|
-
*
|
|
111
|
-
* This source code is licensed under the ISC license.
|
|
112
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
113
|
-
*/const Gp=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Jp=V("arrow-down",Gp);/**
|
|
114
|
-
* @license lucide-react v1.24.0 - ISC
|
|
115
|
-
*
|
|
116
|
-
* This source code is licensed under the ISC license.
|
|
117
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
118
|
-
*/const Yp=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],as=V("arrow-up",Yp);/**
|
|
119
|
-
* @license lucide-react v1.24.0 - ISC
|
|
120
|
-
*
|
|
121
|
-
* This source code is licensed under the ISC license.
|
|
122
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
123
|
-
*/const Kp=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Xp=V("at-sign",Kp);/**
|
|
124
|
-
* @license lucide-react v1.24.0 - ISC
|
|
125
|
-
*
|
|
126
|
-
* This source code is licensed under the ISC license.
|
|
127
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
128
|
-
*/const Qp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],eg=V("ban",Qp);/**
|
|
129
|
-
* @license lucide-react v1.24.0 - ISC
|
|
130
|
-
*
|
|
131
|
-
* This source code is licensed under the ISC license.
|
|
132
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
133
|
-
*/const tg=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],tn=V("bot",tg);/**
|
|
134
|
-
* @license lucide-react v1.24.0 - ISC
|
|
135
|
-
*
|
|
136
|
-
* This source code is licensed under the ISC license.
|
|
137
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
138
|
-
*/const ng=[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]],rg=V("cat",ng);/**
|
|
139
|
-
* @license lucide-react v1.24.0 - ISC
|
|
140
|
-
*
|
|
141
|
-
* This source code is licensed under the ISC license.
|
|
142
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
143
|
-
*/const sg=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],ig=V("check-check",sg);/**
|
|
144
|
-
* @license lucide-react v1.24.0 - ISC
|
|
145
|
-
*
|
|
146
|
-
* This source code is licensed under the ISC license.
|
|
147
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
148
|
-
*/const og=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ls=V("check",og);/**
|
|
149
|
-
* @license lucide-react v1.24.0 - ISC
|
|
150
|
-
*
|
|
151
|
-
* This source code is licensed under the ISC license.
|
|
152
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
153
|
-
*/const ag=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],cg=V("chevron-left",ag);/**
|
|
154
|
-
* @license lucide-react v1.24.0 - ISC
|
|
155
|
-
*
|
|
156
|
-
* This source code is licensed under the ISC license.
|
|
157
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
158
|
-
*/const lg=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ac=V("chevron-right",lg);/**
|
|
159
|
-
* @license lucide-react v1.24.0 - ISC
|
|
160
|
-
*
|
|
161
|
-
* This source code is licensed under the ISC license.
|
|
162
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
163
|
-
*/const ug=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],dg=V("circle-pause",ug);/**
|
|
164
|
-
* @license lucide-react v1.24.0 - ISC
|
|
165
|
-
*
|
|
166
|
-
* This source code is licensed under the ISC license.
|
|
167
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
168
|
-
*/const hg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],mg=V("clock-3",hg);/**
|
|
169
|
-
* @license lucide-react v1.24.0 - ISC
|
|
170
|
-
*
|
|
171
|
-
* This source code is licensed under the ISC license.
|
|
172
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
173
|
-
*/const fg=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pg=V("copy",fg);/**
|
|
174
|
-
* @license lucide-react v1.24.0 - ISC
|
|
175
|
-
*
|
|
176
|
-
* This source code is licensed under the ISC license.
|
|
177
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
178
|
-
*/const gg=[["path",{d:"M14 9 9 4 4 9",key:"1af5af"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]],xg=V("corner-left-up",gg);/**
|
|
179
|
-
* @license lucide-react v1.24.0 - ISC
|
|
180
|
-
*
|
|
181
|
-
* This source code is licensed under the ISC license.
|
|
182
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
183
|
-
*/const bg=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],_g=V("cpu",bg);/**
|
|
184
|
-
* @license lucide-react v1.24.0 - ISC
|
|
185
|
-
*
|
|
186
|
-
* This source code is licensed under the ISC license.
|
|
187
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
188
|
-
*/const vg=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],cc=V("ellipsis-vertical",vg);/**
|
|
189
|
-
* @license lucide-react v1.24.0 - ISC
|
|
190
|
-
*
|
|
191
|
-
* This source code is licensed under the ISC license.
|
|
192
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
193
|
-
*/const yg=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],kg=V("folder-plus",yg);/**
|
|
194
|
-
* @license lucide-react v1.24.0 - ISC
|
|
195
|
-
*
|
|
196
|
-
* This source code is licensed under the ISC license.
|
|
197
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
198
|
-
*/const wg=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Sg=V("folder",wg);/**
|
|
199
|
-
* @license lucide-react v1.24.0 - ISC
|
|
200
|
-
*
|
|
201
|
-
* This source code is licensed under the ISC license.
|
|
202
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
203
|
-
*/const jg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ng=V("gauge",jg);/**
|
|
204
|
-
* @license lucide-react v1.24.0 - ISC
|
|
205
|
-
*
|
|
206
|
-
* This source code is licensed under the ISC license.
|
|
207
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
208
|
-
*/const Tg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Eg=V("globe",Tg);/**
|
|
209
|
-
* @license lucide-react v1.24.0 - ISC
|
|
210
|
-
*
|
|
211
|
-
* This source code is licensed under the ISC license.
|
|
212
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
213
|
-
*/const $g=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],Cg=V("inbox",$g);/**
|
|
214
|
-
* @license lucide-react v1.24.0 - ISC
|
|
215
|
-
*
|
|
216
|
-
* This source code is licensed under the ISC license.
|
|
217
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
218
|
-
*/const Rg=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pn=V("loader-circle",Rg);/**
|
|
219
|
-
* @license lucide-react v1.24.0 - ISC
|
|
220
|
-
*
|
|
221
|
-
* This source code is licensed under the ISC license.
|
|
222
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
223
|
-
*/const Ag=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],lc=V("lock",Ag);/**
|
|
224
|
-
* @license lucide-react v1.24.0 - ISC
|
|
225
|
-
*
|
|
226
|
-
* This source code is licensed under the ISC license.
|
|
227
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
228
|
-
*/const zg=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Ig=V("minimize-2",zg);/**
|
|
229
|
-
* @license lucide-react v1.24.0 - ISC
|
|
230
|
-
*
|
|
231
|
-
* This source code is licensed under the ISC license.
|
|
232
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
233
|
-
*/const Lg=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Og=V("monitor",Lg);/**
|
|
234
|
-
* @license lucide-react v1.24.0 - ISC
|
|
235
|
-
*
|
|
236
|
-
* This source code is licensed under the ISC license.
|
|
237
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
238
|
-
*/const Pg=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],cs=V("paperclip",Pg);/**
|
|
239
|
-
* @license lucide-react v1.24.0 - ISC
|
|
240
|
-
*
|
|
241
|
-
* This source code is licensed under the ISC license.
|
|
242
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
243
|
-
*/const Mg=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Dg=V("pencil-line",Mg);/**
|
|
244
|
-
* @license lucide-react v1.24.0 - ISC
|
|
245
|
-
*
|
|
246
|
-
* This source code is licensed under the ISC license.
|
|
247
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
248
|
-
*/const Zg=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Fg=V("pencil",Zg);/**
|
|
249
|
-
* @license lucide-react v1.24.0 - ISC
|
|
250
|
-
*
|
|
251
|
-
* This source code is licensed under the ISC license.
|
|
252
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
253
|
-
*/const Ug=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],uc=V("pin-off",Ug);/**
|
|
254
|
-
* @license lucide-react v1.24.0 - ISC
|
|
255
|
-
*
|
|
256
|
-
* This source code is licensed under the ISC license.
|
|
257
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
258
|
-
*/const qg=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Ln=V("pin",qg);/**
|
|
259
|
-
* @license lucide-react v1.24.0 - ISC
|
|
260
|
-
*
|
|
261
|
-
* This source code is licensed under the ISC license.
|
|
262
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
263
|
-
*/const Bg=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dc=V("plus",Bg);/**
|
|
264
|
-
* @license lucide-react v1.24.0 - ISC
|
|
265
|
-
*
|
|
266
|
-
* This source code is licensed under the ISC license.
|
|
267
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
268
|
-
*/const Hg=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],hc=V("quote",Hg);/**
|
|
269
|
-
* @license lucide-react v1.24.0 - ISC
|
|
270
|
-
*
|
|
271
|
-
* This source code is licensed under the ISC license.
|
|
272
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
273
|
-
*/const Wg=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],eo=V("refresh-cw",Wg);/**
|
|
274
|
-
* @license lucide-react v1.24.0 - ISC
|
|
275
|
-
*
|
|
276
|
-
* This source code is licensed under the ISC license.
|
|
277
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
278
|
-
*/const Vg=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],mc=V("rotate-ccw",Vg);/**
|
|
279
|
-
* @license lucide-react v1.24.0 - ISC
|
|
280
|
-
*
|
|
281
|
-
* This source code is licensed under the ISC license.
|
|
282
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
283
|
-
*/const Gg=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Jg=V("rotate-cw",Gg);/**
|
|
284
|
-
* @license lucide-react v1.24.0 - ISC
|
|
285
|
-
*
|
|
286
|
-
* This source code is licensed under the ISC license.
|
|
287
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
288
|
-
*/const Yg=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Kg=V("scissors",Yg);/**
|
|
289
|
-
* @license lucide-react v1.24.0 - ISC
|
|
290
|
-
*
|
|
291
|
-
* This source code is licensed under the ISC license.
|
|
292
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
293
|
-
*/const Xg=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Tr=V("search",Xg);/**
|
|
294
|
-
* @license lucide-react v1.24.0 - ISC
|
|
295
|
-
*
|
|
296
|
-
* This source code is licensed under the ISC license.
|
|
297
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
298
|
-
*/const Qg=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],fc=V("settings",Qg);/**
|
|
299
|
-
* @license lucide-react v1.24.0 - ISC
|
|
300
|
-
*
|
|
301
|
-
* This source code is licensed under the ISC license.
|
|
302
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
303
|
-
*/const ex=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],tx=V("share-2",ex);/**
|
|
304
|
-
* @license lucide-react v1.24.0 - ISC
|
|
305
|
-
*
|
|
306
|
-
* This source code is licensed under the ISC license.
|
|
307
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
308
|
-
*/const nx=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],rx=V("square-terminal",nx);/**
|
|
309
|
-
* @license lucide-react v1.24.0 - ISC
|
|
310
|
-
*
|
|
311
|
-
* This source code is licensed under the ISC license.
|
|
312
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
313
|
-
*/const sx=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pc=V("square",sx);/**
|
|
314
|
-
* @license lucide-react v1.24.0 - ISC
|
|
315
|
-
*
|
|
316
|
-
* This source code is licensed under the ISC license.
|
|
317
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
318
|
-
*/const ix=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ox=V("trash-2",ix);/**
|
|
319
|
-
* @license lucide-react v1.24.0 - ISC
|
|
320
|
-
*
|
|
321
|
-
* This source code is licensed under the ISC license.
|
|
322
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
323
|
-
*/const ax=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],cx=V("users",ax);/**
|
|
324
|
-
* @license lucide-react v1.24.0 - ISC
|
|
325
|
-
*
|
|
326
|
-
* This source code is licensed under the ISC license.
|
|
327
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
328
|
-
*/const lx=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$t=V("x",lx);/**
|
|
329
|
-
* @license lucide-react v1.24.0 - ISC
|
|
330
|
-
*
|
|
331
|
-
* This source code is licensed under the ISC license.
|
|
332
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
333
|
-
*/const ux=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],dx=V("zap",ux);let gc;const ls=new Set;function xc(e){gc=e;for(const t of ls)t()}const hx=e=>(ls.add(e),()=>ls.delete(e)),to=()=>gc;function mx(e){xc({minimum:e.minimum_browser_protocol,current:e.current_browser_protocol})}async function fx(e){const t=new URLSearchParams({browser_protocol:String(rr),client_kind:"browser"});try{const n=await fetch(`/api/client-compatibility?${t.toString()}`,{cache:"no-store",headers:{authorization:`Bearer ${e}`}});if(n.status!==426)return;const r=await n.json();xc({minimum:r.minimum_browser_protocol??rr+1,current:r.browser_protocol??rr})}catch{}}function px(){return new Promise(e=>{let t=!1,n;const r=()=>{t||(t=!0,navigator.serviceWorker.removeEventListener("controllerchange",r),n!==void 0&&window.clearTimeout(n),e())};navigator.serviceWorker.addEventListener("controllerchange",r),n=window.setTimeout(r,2e3)})}async function gx(){if("serviceWorker"in navigator){const t=await navigator.serviceWorker.getRegistration("/");if(t!==void 0){const n=px();await t.update().catch(()=>{}),await n}}const e=new URL(window.location.href);e.searchParams.set("_codor_update",String(Date.now())),window.location.replace(e.toString())}function xx(e){const t=x.useSyncExternalStore(hx,to,to),[n,r]=x.useState(!1);return t===void 0?e.children:o.jsx("main",{className:"nx-upgrade","data-testid":"upgrade-required",children:o.jsxs("section",{className:"nx-upgrade-card","aria-labelledby":"upgrade-title","aria-describedby":"upgrade-copy",children:[o.jsx("span",{className:"nx-upgrade-mark","aria-hidden":"true",children:o.jsx(eo,{size:24})}),o.jsx("p",{className:"nx-eyebrow",children:"Update required"}),o.jsx("h1",{id:"upgrade-title",children:"Codor has been updated"}),o.jsx("p",{id:"upgrade-copy",children:"This installed app is too old to read the current channel format safely. Refresh once to load the new version."}),o.jsx("button",{type:"button",className:"nx-btn is-primary nx-upgrade-action",disabled:n,onClick:()=>{r(!0),gx().catch(()=>r(!1))},children:n?o.jsxs(o.Fragment,{children:[o.jsx(Pn,{className:"nx-spin",size:16,"aria-hidden":"true"})," Updating…"]}):o.jsxs(o.Fragment,{children:[o.jsx(eo,{size:16,"aria-hidden":"true"})," Refresh Codor"]})}),o.jsxs("p",{className:"nx-upgrade-version",children:["App protocol ",t.current,"; server requires ",t.minimum,"."]})]})})}const no=new Set(["connected","disconnected"]),bx=2e4,_x=8e3;function vx(e){const t=window.location.origin.replace(/^http/,"ws"),n=e.socketFactory??(M=>new WebSocket(M));let r=e.room,s,i=new Set,a="disconnected",c=500,l,d,u,h=!1,f=e.token,p=0;H.getState().setActiveRoom(r);const g=()=>{l!==void 0&&clearTimeout(l),l=void 0},_=()=>{d!==void 0&&clearInterval(d),u!==void 0&&clearTimeout(u),d=void 0,u=void 0,h=!1},S=M=>{(s==null?void 0:s.readyState)===WebSocket.OPEN&&s.send(JSON.stringify(M))},R=M=>{i.has(M)||(s==null?void 0:s.readyState)!==WebSocket.OPEN||(i.add(M),S({type:"subscribe",room:M,since_seq:ie(H.getState(),M).seq,hydrate_limit:In,room_addressed:!0,browser_protocol:rr,client_kind:"browser"}))},A=M=>{if(M!==void 0){M.onopen=null,M.onmessage=null,M.onclose=null,M.onerror=null;try{M.close()}catch{}}},$=M=>{_(),d=setInterval(()=>{M!==p||a!=="connected"||document.visibilityState==="visible"&&(h||(h=!0,S({type:"list_rooms"}),u=setTimeout(()=>{M!==p||!h||(h=!1,k())},_x)))},bx)},z=()=>{if(a==="disposed")return;g(),_();const M=++p;A(s),i=new Set,s=n(`${t}/ws?token=${encodeURIComponent(f)}`);const Y=()=>M===p&&a!=="disposed";s.onopen=()=>{Y()&&(c=500,a="connected",H.getState().setConnected(!0),R(r),S({type:"list_rooms"}),$(M))},s.onmessage=$e=>{if(!Y())return;const Ce=JSON.parse($e.data);if(Ce.type==="upgrade_required"){a="parked-upgrade",_(),H.getState().setConnected(!1),mx(Ce),A(s),s=void 0;return}if(H.getState().applyFrame(Ce,r),Ce.type==="rooms"){h=!1,u!==void 0&&clearTimeout(u),u=void 0;for(const Re of Ce.rooms)R(Re.id)}},s.onclose=$e=>{if(!Y()||(_(),(a==="connected"||a==="disconnected")&&(a="disconnected"),H.getState().setConnected(!1),a!=="disconnected"))return;if($e.code===4403){a="parked-auth",En("");return}const Ce=()=>{!Y()||a!=="disconnected"||(g(),l=setTimeout(z,c),c=Math.min(c*2,1e4))};$e.code===4401&&e.refreshToken?e.refreshToken().then(Re=>{Y()&&(f=En(Re),Ce())},Ce):Ce()}};z();let I=!1;const k=()=>{!no.has(a)||I||(I=!0,queueMicrotask(()=>{var M;I=!1,no.has(a)&&(z(),(M=e.onResume)==null||M.call(e,r))}))},E=()=>{document.visibilityState==="visible"&&k()},L=M=>{M.persisted&&k()},Q=()=>{document.visibilityState==="visible"&&k()};window.addEventListener("visibilitychange",E),window.addEventListener("pageshow",L),window.addEventListener("online",Q);const G={room:()=>r,state:()=>a,post:(M,Y)=>{var $e;return S({type:"post",room:r,body:M,...(Y==null?void 0:Y.replyTo)!==void 0&&{reply_to:Y.replyTo},...($e=Y==null?void 0:Y.attachments)!=null&&$e.length?{attachments:Y.attachments}:{}})},act:M=>S({type:"act",room:r,act:M}),disconnect:()=>{a="parked-manual",g(),_(),p+=1,A(s),s=void 0,H.getState().setConnected(!1)},reconnect:()=>{a!=="parked-manual"&&a!=="disconnected"||(a="disconnected",z())},switchRoom:M=>{M!==r&&(r=M,H.getState().setActiveRoom(M),R(M))},dispose:()=>{a="disposed",g(),_(),H.getState().setConnected(!1),p+=1,window.removeEventListener("visibilitychange",E),window.removeEventListener("pageshow",L),window.removeEventListener("online",Q),A(s),s=void 0}};return window.__codor=G,G}const yx=4,kx=3;let cn="",bc=0;const Ge=new Map,us=new Set;function _c(){bc+=1;for(const e of us)e()}function wx(){return{active:0,queue:[],journals:new Map,inflight:new Map,wantTerminal:new Set,wantRefresh:new Set}}function vc(e){const t=Ge.get(e)??wx();for(Ge.delete(e),Ge.set(e,t);Ge.size>kx;){const n=Ge.keys().next().value;if(n===void 0)break;Ge.delete(n)}return t}function Sx(e){e!==cn&&(cn=e,vc(e),_c())}function mr(e,t){const n=e.queue.findIndex(s=>s.id===t.id);if(n===-1){e.queue.push(t);return}const r=e.queue[n];r.terminal=r.terminal||t.terminal,r.priority=r.priority||t.priority}function Os(e,t,n){if(!(e!==cn||Ge.get(e)!==t))for(;t.active<yx&&t.queue.length>0;){const r=t.queue.findIndex(i=>i.priority),s=t.queue.splice(r===-1?0:r,1)[0];t.active+=1,t.inflight.set(s.id,s.terminal),ua(e,s.id,{token:n()}).then(i=>{Ge.get(e)===t&&t.journals.set(s.id,{events:i,terminal:s.terminal})}).catch(()=>{Ge.get(e)===t&&t.journals.set(s.id,{events:[],terminal:s.terminal})}).finally(()=>{t.active-=1,Ge.get(e)===t&&(t.inflight.delete(s.id),t.wantTerminal.delete(s.id)?mr(t,{id:s.id,terminal:!0,priority:!1}):t.wantRefresh.delete(s.id)&&mr(t,{id:s.id,terminal:!1,priority:!1}),t.wantRefresh.delete(s.id),e===cn&&_c(),Os(e,t,n))})}}function yc(e,t,n,r){if(e!==cn)return;const s=vc(e),i=s.journals.get(n);if((i==null?void 0:i.terminal)===!0||i!==void 0&&!r.terminal)return;const a=s.inflight.get(n);if(a!==void 0){r.terminal&&!a&&s.wantTerminal.add(n);return}mr(s,{id:n,terminal:r.terminal,priority:r.priority===!0}),Os(e,s,t)}function jx(e,t){if(e!==cn)return;const n=Ge.get(e);if(n===void 0)return;const r=new Set;for(const[s,i]of n.journals)i.terminal||r.add(s);for(const[s,i]of n.inflight)i||r.add(s);for(const s of r){if(n.inflight.has(s)){n.wantRefresh.add(s);continue}mr(n,{id:s,terminal:!1,priority:!1})}Os(e,n,t)}function Ps(e,t){var n,r;return(r=(n=Ge.get(e))==null?void 0:n.journals.get(t))==null?void 0:r.events}function Nx(e){return us.add(e),()=>{us.delete(e)}}const ro=()=>bc;function kc(){return x.useSyncExternalStore(Nx,ro,ro)}function Tx(e){const t=["",...e.levels],n=t.length-1,r=Math.max(0,t.indexOf(e.value)),s=n===0?0:r/n,i=d=>d===""?"Default":d,a=`calc(8px + ${String(s*100)}% - ${String(s*16)}px)`,c=`calc(${String(s*100)}% - ${String(s*16)}px)`,l=s===0?"translateX(0)":s===1?"translateX(-100%)":"translateX(-50%)";return o.jsxs("div",{className:"nx-slider","data-testid":`${e.idPrefix}-thinking-slider`,children:[o.jsxs("div",{className:"nx-slider-rail",children:[o.jsx("div",{className:"nx-slider-fill",style:{width:c}}),o.jsx("div",{className:"nx-slider-ticks","aria-hidden":"true",children:t.map((d,u)=>o.jsx("span",{className:u<=r?"nx-slider-tick is-on":"nx-slider-tick","data-active":u===r},d===""?"default":d))}),o.jsx("span",{className:"nx-slider-knob",style:{left:a},"aria-hidden":"true"}),o.jsx("span",{className:"nx-slider-tip",style:{left:a,transform:l},"data-testid":`${e.idPrefix}-thinking-value`,children:i(t[r]??"")}),o.jsx("input",{type:"range",className:"nx-slider-input",min:0,max:n,step:1,value:r,disabled:e.disabled===!0||n===0,"aria-label":"Thinking effort","aria-valuetext":i(t[r]??""),"data-testid":`${e.idPrefix}-thinking-range`,onChange:d=>e.onChange(t[Number(d.target.value)]??"")})]}),o.jsxs("div",{className:"nx-slider-ends","aria-hidden":"true","data-testid":`${e.idPrefix}-thinking-ends`,children:[o.jsx("span",{children:i(t[0]??"")}),o.jsx("span",{children:i(t[n]??"")})]})]})}const so=31,Ex="[a-z0-9][a-z0-9\\-]{1,30}",$x=Sr.options,fr="read-only";function Ms(e){if(e===void 0||e.capabilities.thinking!==!0)return[];const t=e.capabilities.thinking_levels;return t!==void 0&&t.length>0?t:Wa}function Er(e,t){return Ms(e).includes(t)?t:void 0}const wc=e=>e!==void 0&&(e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\"));function Cx(e){return e.kind==="agent"&&e.removed_ts===void 0&&e.state!=="dead"&&e.state!=="unreachable"&&e.custody!=="mirrored"&&wc(e.cwd)}function Rx(e,t){var s;if(wc(e==null?void 0:e.config.cwd))return e.config.cwd;const n=t.filter(Cx).sort((i,a)=>i.id.localeCompare(a.id)),r=e==null?void 0:e.config.starting_agent_handle;if(r!==void 0){const i=n.find(a=>a.handle===r);if((i==null?void 0:i.cwd)!==void 0)return i.cwd}return((s=n[0])==null?void 0:s.cwd)??""}function Sc(e,t){const n=new Set(t.filter(s=>s.removed_ts===void 0).map(s=>s.handle)),r=e.slice(0,so);if(!n.has(r))return r;for(let s=2;s<1e3;s+=1){const i=`-${String(s)}`,a=r.slice(0,so-i.length)+i;if(!n.has(a))return a}return r}function Ax(e){const t=Sr.safeParse(e);return t.success?t.data:""}function zx(e){return e.find(t=>t.kind==="human"&&t.role==="owner")}function jc(e,t){return t!==void 0&&t.handle===e}const Ix=[{id:"coder",label:"Coder",blurb:"Writes and edits code",handle:"coder",purpose:"Implement the change we agree on, in small reviewable steps.",policy:"workspace-write",thinking:"medium"},{id:"reviewer",label:"Reviewer",blurb:"Reads and critiques",handle:"reviewer",purpose:"Review the diff for correctness and risk. Do not edit files.",policy:"read-only",thinking:"high"},{id:"planner",label:"Planner",blurb:"Breaks work down",handle:"planner",purpose:"Turn the goal into an ordered plan with checkable steps.",policy:"read-only",thinking:"high"},{id:"writer",label:"Writer",blurb:"Docs and prose",handle:"writer",purpose:"Write and revise documentation for this project.",policy:"workspace-write",thinking:"low"},{id:"tester",label:"Tester",blurb:"Runs and fixes tests",handle:"tester",purpose:"Run the suite, diagnose failures, and add missing coverage.",policy:"workspace-write",thinking:"medium"}];function Lx(e){const t=e.adapters.find(n=>n.id===e.config.harness);return{config:{...e.config,policy:e.preset.policy,thinking:Er(t,e.preset.thinking)??""},handle:Sc(e.preset.handle,e.members),purpose:e.preset.purpose}}function Ox(e,t,n){if(t===e.harness)return e;const r=n.find(a=>a.id===t),i=Ms(r).includes(e.thinking)?e.thinking:"";return{...e,harness:t,model:"",thinking:i}}function Nc(e,t){var n;return t.some(r=>r.id===e)?e:((n=t[0])==null?void 0:n.id)??""}const Px=/\b(handle|spawn|harness|agent|reserved)\b/i;function Mx(e,t){return t===""?!1:new RegExp(`(^|[^a-z0-9-])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}([^a-z0-9-]|$)`,"i").test(e)}function Dx(e,t){var r;if(Mx(e,t))return!0;const n=(r=/@([a-z0-9][a-z0-9-]*)/i.exec(e))==null?void 0:r[1];return n!==void 0&&n.toLowerCase()!==t.toLowerCase()?!1:Px.test(e)}function Zx(e){if(e.members.some(s=>s.handle===e.handle&&s.removed_ts===void 0))return{state:"arrived"};const r=e.freshErrors.filter(s=>Dx(s,e.handle)).at(-1);return r===void 0?{state:"pending"}:{state:"failed",message:r}}function Fx(e){return/starting agent|handle/i.test(e)}function Ux(e){var i;const t=Nc(e.config.harness,e.adapters),n=e.adapters.find(a=>a.id===t),r=Er(n,e.config.thinking),s=(i=e.purpose)==null?void 0:i.trim();return{harness:t,handle:Sc(e.handle.trim(),e.members),cwd:e.cwd.trim(),policy:e.config.policy===""?fr:e.config.policy,...e.config.model!==""&&{model:e.config.model},...r!==void 0&&{thinking:r},...s!==void 0&&s!==""&&{purpose:s}}}const Tc={"claude-code":{label:"Claude Code",mark:e=>o.jsx("svg",{viewBox:"0 0 94 94",width:e,height:e,fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M18.7657 62.4437L37.1822 52.1167L37.4857 51.2122L37.1822 50.7085H36.2715L33.1852 50.5208L22.6615 50.2391L13.5545 49.8636L4.70044 49.3942L2.47428 48.9248L0.399902 46.1553L0.602281 44.794L2.47428 43.5266L5.15579 43.7613L11.0754 44.1837L19.98 44.794L26.4055 45.1695L35.9679 46.1553H37.4857L37.6881 45.545L37.1822 45.1695L36.7774 44.794L27.5692 38.5508L17.6021 31.9791L12.3908 28.1769L9.60812 26.2524L8.19147 24.4686L7.58433 20.5256L10.1141 17.7091L13.5545 17.9438L14.4146 18.1785L17.9056 20.8542L25.343 26.6279L35.0572 33.7629L36.4739 34.9364L37.0443 34.5514L37.1316 34.2792L36.4739 33.1996L31.212 23.6706L25.596 13.9539L23.0663 9.91695L22.4086 7.52296C22.1538 6.51831 22.0038 5.68714 22.0038 4.65957L24.8877 0.716544L26.5067 0.200195L30.4025 0.716544L32.0215 2.12477L34.4501 7.66379L38.3458 16.3478L44.4172 28.1769L46.188 31.6975L47.1493 34.9364L47.5035 35.9222H48.1106V35.3589L48.6166 28.6933L49.5273 20.5256L50.438 10.0108L50.7415 7.05356L52.2088 3.48605L55.1433 1.56148L57.42 2.64112L59.292 5.31674L59.039 7.05356L57.926 14.2824L55.7504 25.5952L54.3337 33.1996H55.1433L56.1046 32.2138L59.9497 27.1442L66.3752 19.0704L69.2085 15.8784L72.5478 12.3579L74.6728 10.668H78.7203L81.6548 15.0804L80.3394 19.6337L76.1906 24.8911L72.7502 29.3504L67.8172 35.9595L64.7562 41.2734L65.0307 41.7118L65.7681 41.6489L76.8989 39.255L82.9197 38.1753L90.1041 36.9549L93.3422 38.457L93.6963 40.006L92.4315 43.151L84.7411 45.0287L75.7353 46.8594L62.3244 50.0164L62.1759 50.1358L62.3512 50.3958L68.399 50.9432L70.9794 51.084H77.3037L89.0922 51.9759L92.1785 53.9944L93.9999 56.4822L93.6963 58.4068L88.9404 60.8008L82.5655 59.2987L67.6401 55.7312L62.5301 54.4638H61.8217V54.8862L66.0717 59.064L73.9139 66.1051L83.6786 75.2116L84.1845 77.4648L82.9197 79.2485L81.6042 79.0608L73.0032 72.5829L69.6639 69.6726L62.1759 63.3356H61.67V63.9928L63.3902 66.5276L72.5478 80.2812L73.0032 84.5059L72.3454 85.8672L69.9675 86.7121L67.3871 86.2427L61.9735 78.6852L56.4587 70.2359L52.0064 62.6315L51.4687 62.971L48.8189 91.2654L47.6047 92.7206L44.7714 93.8002L42.3934 92.0164L41.1286 89.1061L42.3934 83.3324L43.9113 75.8219L45.1255 69.8604L46.2386 62.4437L46.9184 59.9661L46.8583 59.8003L46.3153 59.8916L40.7238 67.5603L32.2239 79.0608L25.4948 86.2427L23.8758 86.8999L21.0931 85.4447L21.3461 82.863L22.9145 80.5629L32.2239 68.7338L37.8399 61.3641L41.4594 57.1337L41.4242 56.5218L41.2244 56.5048L16.489 72.6299L12.0873 73.1932L10.1647 71.4094L10.4176 68.4991L11.3283 67.5603L18.7657 62.4437Z"})})},codex:{label:"Codex",mark:e=>o.jsx("svg",{viewBox:"166.30 166.30 383.40 383.40",width:e,height:e,fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M508.749 317.399C516.777 287.314 508.991 253.884 485.389 230.282C461.788 206.681 428.36 198.895 398.273 206.923C376.231 184.928 343.39 174.956 311.148 183.596C278.906 192.234 255.45 217.292 247.36 247.361C217.291 255.451 192.233 278.91 183.595 311.149C174.957 343.391 184.927 376.232 206.924 398.274C198.896 428.359 206.683 461.789 230.284 485.391C253.885 508.992 287.313 516.779 317.401 508.75C339.442 530.745 372.286 540.717 404.525 532.079C436.767 523.441 460.223 498.384 468.313 468.315C498.383 460.224 523.44 436.766 532.078 404.526C540.716 372.285 530.747 339.443 508.749 317.402V317.399ZM470.899 244.776C486.892 260.77 493.488 282.601 490.687 303.412L415.577 260.046C412.411 258.218 408.509 258.218 405.345 260.046L317.401 310.82V277.526C317.401 275.191 318.652 273.005 320.676 271.837L387.644 233.174C414.178 218.353 448.346 222.223 470.901 244.776H470.899ZM357.837 311.144L398.275 334.491V381.185L357.837 404.532L317.398 381.185V334.491L357.837 311.144ZM264.776 269.693C265.207 239.305 285.644 211.649 316.453 203.393C338.3 197.54 360.505 202.744 377.127 215.573L302.014 258.937C298.848 260.764 296.898 264.144 296.898 267.798V369.346L268.065 352.699C266.043 351.531 264.776 349.353 264.776 347.017V269.691V269.693ZM203.391 316.454C209.244 294.608 224.854 277.978 244.276 269.999V356.73C244.276 360.384 246.226 363.763 249.392 365.591L337.337 416.365L308.503 433.013C306.481 434.181 303.961 434.188 301.939 433.02L234.971 394.357C208.868 378.789 195.138 347.261 203.391 316.454ZM244.775 470.9C228.781 454.906 222.186 433.075 224.986 412.264L300.096 455.63C303.263 457.457 307.164 457.457 310.328 455.63L398.273 404.856V438.149C398.273 440.485 397.022 442.671 394.997 443.839L328.029 482.502C301.495 497.322 267.327 493.452 244.772 470.9H244.775ZM450.897 445.982C450.466 476.371 430.029 504.027 399.22 512.283C377.373 518.136 355.168 512.932 338.547 500.102L413.659 456.738C416.826 454.911 418.775 451.532 418.775 447.877V346.329L447.609 362.977C449.631 364.145 450.897 366.323 450.897 368.659V445.985V445.982ZM512.282 399.221C506.429 421.068 490.819 437.697 471.397 445.676V358.946C471.397 355.292 469.448 351.912 466.281 350.085L378.336 299.311L407.17 282.663C409.192 281.495 411.712 281.487 413.734 282.655L480.702 321.318C506.805 336.887 520.536 368.415 512.282 399.221Z"})})},gemini:{label:"Gemini",mark:e=>o.jsx("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M12 2c0 5.52-4.48 10-10 10 5.52 0 10 4.48 10 10 0-5.52 4.48-10 10-10-5.52 0-10-4.48-10-10Z"})})},antigravity:{label:"Antigravity",mark:e=>o.jsx(Ng,{width:e,height:e,"aria-hidden":"true"})},copilot:{label:"GitHub Copilot",mark:e=>o.jsx(rg,{width:e,height:e,"aria-hidden":"true"})},opencode:{label:"OpenCode",mark:e=>o.jsx("svg",{viewBox:"0 0 240 300",width:e,height:e,fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd","aria-hidden":"true",children:o.jsx("path",{d:"M180 60H60V240H180V60ZM240 300H0V0H240V300Z"})})},cursor:{label:"Cursor",mark:e=>o.jsx("svg",{viewBox:"0 0 466.73 532.09",width:e,height:e,fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})}};function Ec(e){var t;return((t=Tc[e])==null?void 0:t.label)??e}function qx(e,t=22){const n=Tc[e];return n!==void 0?n.mark(t):o.jsx(_g,{size:t,"aria-hidden":"true"})}const Bx={"read-only":{title:"Read only",icon:lc},"workspace-write":{title:"Edit",icon:Dg},"full-access":{title:"Full access",icon:dx}},Hx=8;function ln(e){const t=e.headingLevel===2?"h2":"h3";return o.jsxs("section",{className:"nx-sec",children:[o.jsxs("div",{className:"nx-sec-head",children:[o.jsx("span",{className:"nx-sec-n","aria-hidden":"true",children:e.n}),o.jsx(t,{className:"nx-sec-title",children:e.title}),o.jsx("span",{className:"nx-sec-rule","aria-hidden":"true"})]}),e.children]})}function Ds(e){const t=e.idPrefix??"agent";return o.jsx(o.Fragment,{children:o.jsxs("div",{className:"nx-field",children:[o.jsxs("span",{className:"nx-label",children:["Harness ",e.optional===!0&&o.jsx("span",{className:"nx-opt",children:"· optional"})]}),e.adapters.length===0&&e.allowNone!==!0?o.jsx("p",{className:"nx-note",role:"status",children:"Discovering harnesses…"}):o.jsxs("div",{className:"nx-harness-grid",role:"group","aria-label":"Harness",children:[e.allowNone===!0&&o.jsxs("button",{type:"button",className:"nx-harness","aria-pressed":e.config.harness==="","data-testid":`${t}-harness-none`,onClick:()=>{e.onChange({...e.config,harness:"",model:"",thinking:""})},children:[o.jsx(eg,{size:22,"aria-hidden":"true"}),o.jsx("span",{className:"nx-harness-name",children:"None"}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]}),e.adapters.map(n=>o.jsxs("button",{type:"button",className:"nx-harness","aria-pressed":n.id===e.config.harness,disabled:e.lockHarness===!0,"data-testid":`${t}-harness-${n.id}`,onClick:()=>{e.onChange(Ox(e.config,n.id,e.adapters))},children:[qx(n.id),o.jsx("span",{className:"nx-harness-name",children:Ec(n.id)}),n.capabilities.resume===!1&&o.jsx("span",{className:"nx-harness-sub",children:"ephemeral"}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]},n.id))]})]})})}function Wx(e){const t=e.idPrefix??"agent";return o.jsxs("div",{className:"nx-field",children:[o.jsxs("span",{className:"nx-label",children:["Preset ",o.jsx("span",{className:"nx-opt",children:"· optional"})]}),o.jsx("div",{className:"nx-tile-row",role:"group","aria-label":"Preset",children:Ix.map(n=>o.jsx("button",{type:"button",className:"nx-tile nx-preset","data-testid":`${t}-preset-${n.id}`,onClick:()=>{e.onApply(n)},children:n.label},n.id))})]})}function Zs(e){var g;const{adapters:t,config:n}=e,r=e.idPrefix??"agent",s=t.find(_=>_.id===n.harness),i=(s==null?void 0:s.models)??[],a=Ms(s),[c,l]=x.useState(""),d=_=>{e.onChange({...n,..._})},u=c.trim().toLowerCase(),h=u===""?i:i.filter(_=>_.toLowerCase().includes(u)),f=o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Model"}),i.length===0?o.jsxs(o.Fragment,{children:[o.jsx("input",{className:"nx-input",value:n.model,onChange:_=>{d({model:_.target.value})},placeholder:"harness default","aria-label":"Model","data-testid":`${r}-model-input`}),o.jsx("p",{className:"nx-note",children:"This harness did not report a model list."})]}):o.jsxs(o.Fragment,{children:[i.length>Hx&&o.jsx("input",{className:"nx-input",value:c,onChange:_=>{l(_.target.value)},placeholder:`Search ${String(i.length)} models…`,"aria-label":"Search models","data-testid":`${r}-model-search`}),o.jsxs("div",{className:"nx-list",role:"group","aria-label":"Model","data-testid":`${r}-model-list`,children:[o.jsxs("button",{type:"button","aria-pressed":n.model==="",className:"nx-list-row","data-testid":`${r}-model-default`,onClick:()=>{d({model:""})},children:[o.jsx("span",{children:"Default"}),o.jsx("span",{className:"nx-list-sub",children:"harness pick"}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]}),h.map(_=>o.jsxs("button",{type:"button","aria-pressed":n.model===_,className:"nx-list-row","data-testid":`${r}-model-${_}`,onClick:()=>{d({model:_})},children:[o.jsx("span",{className:"nx-mono",children:_}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]},_)),h.length===0&&o.jsx("p",{className:"nx-note",children:"No model matches that search."})]}),o.jsx("input",{className:"nx-input",value:n.model,onChange:_=>{d({model:_.target.value})},placeholder:"or type an exact model id","aria-label":"Custom model","data-testid":`${r}-model-custom`})]})]}),o.jsxs("div",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Thinking effort"}),a.length===0?o.jsx("p",{className:"nx-note","data-testid":`${r}-thinking-unsupported`,children:"Not supported by this harness."}):o.jsx(Tx,{levels:a,value:n.thinking,onChange:_=>{d({thinking:_})},idPrefix:r})]})]}),p=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"nx-perm-row",role:"group","aria-label":"Permissions",children:$x.map(_=>{var $;const S=Bx[_],R=(S==null?void 0:S.icon)??lc,A=($=s==null?void 0:s.capabilities.policies)==null?void 0:$[_];return o.jsxs("button",{type:"button",className:"nx-perm","aria-pressed":n.policy===_,"data-testid":`${r}-policy-${_}`,onClick:()=>{d({policy:_})},children:[o.jsx(R,{size:16,"aria-hidden":"true"}),o.jsx("span",{className:"nx-perm-title",children:(S==null?void 0:S.title)??_}),o.jsx("span",{className:A==null?"nx-perm-native is-deferred":"nx-perm-native",children:s===void 0?"":A??"not enforced"}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]},_)})}),s!==void 0&&n.policy!==""&&((g=s.capabilities.policies)==null?void 0:g[n.policy])===null&&o.jsxs("p",{className:"nx-note is-warn",role:"status","data-testid":`${r}-policy-deferred`,children:[Ec(s.id)," does not enforce this setting — it defers to however that harness is configured. Only Full access changes anything here."]}),(s==null?void 0:s.capabilities.approvals)==="spawn-time"&&o.jsx("p",{className:"nx-note",role:"status",children:"Approval policy is fixed when this harness starts; in-turn approval cards are unavailable."})]});return o.jsxs(o.Fragment,{children:[e.hideHarness!==!0&&o.jsx(Ds,{adapters:t,config:n,onChange:e.onChange,lockHarness:e.lockHarness,idPrefix:r}),e.embedded===!0?o.jsx("div",{className:"nx-agent-embedded-group",children:f}):o.jsx(ln,{n:e.behaviourSection,title:"Behaviour",children:f}),e.embedded===!0?o.jsx("div",{className:"nx-agent-embedded-group",children:p}):o.jsx(ln,{n:e.permissionsSection,title:"Permissions",children:p})]})}function $c(e){const[t,n]=x.useState(),[r,s]=x.useState(!1),[i,a]=x.useState(!1),c=(h,f=i,p=!1)=>{Bl(h,f,{token:e.token()}).then(g=>{n(g),s(!1)}).catch(()=>{p&&h!==void 0?c(void 0,f,!1):s(!0)})};if(x.useEffect(()=>{c(e.value===""?void 0:e.value,i,!0)},[]),r)return o.jsxs("div",{className:"nx-picker","data-testid":`${e.idPrefix}-folder-picker`,children:[o.jsxs("div",{className:"nx-picker-foot",children:[o.jsx("span",{className:"nx-note is-error",children:"Couldn’t list folders on this device."}),o.jsx("button",{type:"button",className:"nx-tile is-compact","data-testid":`${e.idPrefix}-folder-retry`,onClick:()=>{s(!1),c(void 0,i,!1)},children:"Retry"})]}),o.jsx("input",{className:"nx-input",value:e.value,onChange:h=>{e.onChange(h.target.value)},placeholder:"or type a path","aria-label":"Folder path","data-testid":`${e.idPrefix}-folder-typed`})]});if(t===void 0)return o.jsx("p",{className:"nx-note",children:"Loading folders…"});const l=t.path.split("/").filter(h=>h!==""),d=l.map((h,f)=>({name:h,path:`/${l.slice(0,f+1).join("/")}`})),u="this device";return o.jsxs("div",{className:"nx-picker","data-testid":`${e.idPrefix}-folder-picker`,children:[o.jsxs("div",{className:"nx-picker-bar",children:[o.jsxs("span",{className:"nx-host",title:String(u),children:[o.jsx(Og,{size:12,"aria-hidden":"true"}),String(u)]}),o.jsxs("nav",{className:"nx-crumbs","aria-label":"Folder path",children:[o.jsx("button",{type:"button","data-testid":`${e.idPrefix}-crumb-root`,onClick:()=>{c("/")},children:"~"}),d.map((h,f)=>o.jsx("button",{type:"button",className:f===d.length-1?"is-current":void 0,"data-testid":`${e.idPrefix}-crumb-${h.name}`,onClick:()=>{c(h.path)},children:h.name},h.path))]}),o.jsxs("span",{className:"nx-picker-tools",children:[t.parent!==null&&o.jsx("button",{type:"button","aria-label":"Up one folder","data-testid":`${e.idPrefix}-folder-up`,onClick:()=>{c(t.parent??void 0)},children:o.jsx(as,{size:14,"aria-hidden":"true"})}),o.jsx("button",{type:"button","aria-label":"Refresh","data-testid":`${e.idPrefix}-folder-refresh`,onClick:()=>{c(t.path)},children:o.jsx(Jg,{size:14,"aria-hidden":"true"})})]})]}),o.jsxs("ul",{className:"nx-picker-list",children:[t.parent!==null&&o.jsx("li",{children:o.jsxs("button",{type:"button",className:"nx-picker-row is-up","data-testid":`${e.idPrefix}-folder-parent`,onClick:()=>{c(t.parent??void 0)},children:[o.jsx(xg,{size:14,"aria-hidden":"true"}),o.jsx("span",{className:"nx-mono",children:".."})]})}),t.dirs.length===0&&o.jsx("li",{className:"nx-note",children:"no subfolders"}),t.dirs.map(h=>o.jsx("li",{children:o.jsxs("span",{className:"nx-picker-pair",children:[o.jsxs("button",{type:"button",className:"nx-picker-row","aria-pressed":e.value===h.path,"data-testid":`${e.idPrefix}-folder-${h.name}`,onClick:()=>{e.onChange(h.path)},children:[o.jsx(Sg,{size:14,"aria-hidden":"true"}),o.jsx("span",{className:"nx-mono",children:h.name}),o.jsx("span",{className:"nx-check","aria-hidden":"true"})]}),o.jsx("button",{type:"button",className:"nx-picker-open","aria-label":`Open ${h.name}`,"data-testid":`${e.idPrefix}-open-${h.name}`,onClick:()=>{c(h.path)},children:o.jsx(ac,{size:14,"aria-hidden":"true"})})]})},h.path))]}),o.jsxs("div",{className:"nx-picker-foot",children:[o.jsxs("label",{className:"nx-hidden-toggle",children:[o.jsx("input",{type:"checkbox",checked:i,"data-testid":`${e.idPrefix}-folder-hidden`,onChange:h=>{a(h.target.checked),c(t.path,h.target.checked)}}),"Hidden"]}),o.jsx("span",{className:"nx-picker-selected",children:e.value===""?o.jsx("span",{"data-testid":`${e.idPrefix}-folder-selected`,children:"No folder selected"}):o.jsxs(o.Fragment,{children:["Selected ",o.jsx("code",{"data-testid":`${e.idPrefix}-folder-selected`,children:e.value})]})})]}),o.jsx("input",{className:"nx-input",value:e.value,onChange:h=>{e.onChange(h.target.value)},placeholder:"or type a path","aria-label":"Folder path","data-testid":`${e.idPrefix}-folder-typed`})]})}const Vx={tool_call:"Tool call",tool_result:"Tool result",reasoning_summary:"Reasoning",text_delta:"Response",commit:"Commit",file_change:"File change"},Gx=e=>{if(e===void 0)return;const t=typeof e=="string"?e:JSON.stringify(e);if(!(t===void 0||t===""))return t.length>220?`${t.slice(0,217)}...`:t},Jx=e=>{const t=e.toLowerCase();return/bash|shell|terminal|command|exec/.test(t)?"terminal":/edit|write|patch|notebook/.test(t)?"edit":/grep|glob|search|find|read/.test(t)?"search":/web|browser|fetch|http/.test(t)?"web":"tool"};function Fs(e){let t=0,n=0;for(const r of e.split(`
|
|
334
|
-
`))r.startsWith("+++ ")||r.startsWith("--- ")||(r.startsWith("+")?t+=1:r.startsWith("-")&&(n+=1));return{added:t,removed:n}}const io=e=>{if(!e)return;const{added:t,removed:n}=Fs(e.unified);return`+${String(t)} -${String(n)}`},It=e=>{const t=e.event,n=t.type==="run.item"?t.item_type:void 0;return{id:`event-${String(e.index)}`,eventIndex:e.index,kind:"tool",icon:"generic",title:n?Vx[n]:"Run event",detail:t.type==="run.item"?Gx(t.payload):void 0,status:"info",event:t,ts:Yx(t)}},Yx=e=>e.type==="run.item"?e.ts:void 0;function Cc(e){const t=[],n=new Map;for(const r of e){const s=r.event;if(s.type!=="run.item")continue;if(s.item_type==="tool_call"){const a=Kt("tool_call",s.payload);if(!a.success){t.push(It(r));continue}n.set(a.data.call_id,t.length),t.push({id:`call-${a.data.call_id}`,eventIndex:r.index,kind:"tool",icon:Jx(a.data.tool),title:a.data.tool,detail:a.data.title,status:"running",event:s,ts:s.ts});continue}if(s.item_type==="tool_result"){const a=Kt("tool_result",s.payload);if(!a.success){t.push(It(r));continue}const c=n.get(a.data.call_id);if(c===void 0){t.push({...It(r),status:a.data.status,duration_ms:a.data.duration_ms,output_text:a.data.output_text,diff:a.data.diff,image:a.data.image});continue}const l=t[c];t[c]={...l,resultEventIndex:r.index,status:a.data.status,duration_ms:a.data.duration_ms,output_text:a.data.output_text,diff:a.data.diff,image:a.data.image,detail:[l.detail,io(a.data.diff)].filter(Boolean).join(" · "),event:s};continue}if(s.item_type==="text_delta"){const a=Kt("text_delta",s.payload);if(!a.success){t.push(It(r));continue}const c=t.at(-1);(c==null?void 0:c.kind)==="prose"&&c.icon==="text"?(c.text=`${c.text??""}${a.data.text}`,c.event=s):t.push({id:`text-${String(r.index)}`,eventIndex:r.index,kind:"prose",icon:"text",title:"Response",text:a.data.text,status:"info",event:s,ts:s.ts});continue}if(s.item_type==="reasoning_summary"){const a=Kt("reasoning_summary",s.payload);if(!a.success){t.push(It(r));continue}t.push({id:`reasoning-${String(r.index)}`,eventIndex:r.index,kind:"prose",icon:"reasoning",title:"Reasoning",text:a.data.text,status:"info",event:s,ts:s.ts});continue}if(s.item_type==="file_change"){const a=Kt("file_change",s.payload);if(!a.success){t.push(It(r));continue}const c=a.data.change==="created"?"Write":a.data.change==="deleted"?"Delete":"Edit";t.push({id:`file-${String(r.index)}`,eventIndex:r.index,kind:"tool",icon:"edit",title:c,detail:[a.data.path,io(a.data.diff)].filter(Boolean).join(" · "),status:"ok",diff:a.data.diff,event:s,ts:s.ts});continue}const i=Kt("commit",s.payload);if(!i.success){t.push(It(r));continue}t.push({id:`commit-${String(r.index)}`,eventIndex:r.index,kind:"tool",icon:"commit",title:"Commit",detail:i.data.message??i.data.sha??"Recorded",status:"ok",event:s,ts:s.ts})}return t}function Kx(e,t){const n=new Map;e==null||e.forEach((s,i)=>n.set(i,s));const r=t.first_index??t.dropped_count;return t.events.forEach((s,i)=>n.set(r+i,s)),[...n.entries()].sort(([s],[i])=>s-i).map(([s,i])=>({index:s,event:i}))}function Rc(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${String(n)}m${String(r).padStart(2,"0")}s`:`${String(r)}s`}const Xx=/(^|_|\b)(bash|sh|zsh|shell|exec|command|terminal)(\b|_|$)/i,Qx=/(read|glob|grep|search|list_director|ls|webfetch|web_fetch|fetch|view|cat)/i,eb=/(delete|remove|unlink|rm)/i;function oo(e,t=80){const n=[...e];if(n.length<=t)return e;const r=t-1,s=Math.ceil(r/2),i=Math.floor(r/2);return`${n.slice(0,s).join("")}…${n.slice(n.length-i).join("")}`}function ao(e){const t=e.trim().replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||t}function tb(e){return e.replace(/\s·\s\+\d+ -\d+$/,"")}function nb(e){var r,s;const t=e.title,n=tb(((r=e.detail)==null?void 0:r.trim())??"");if(Xx.test(t))return{icon:"terminal",label:oo(n||t),mono:!0};if((s=e.diff)!=null&&s.unified){const{added:i,removed:a}=Fs(e.diff.unified),c=ao(e.diff.path??n);return eb.test(t)?{icon:"edit",label:`Deleted ${c}`,mono:!0}:{icon:"edit",label:`+${String(i)} −${String(a)} ${c}`,mono:!0}}return Qx.test(t)?{icon:"search",label:`Explored ${ao(n||t)}`,mono:!1}:{icon:e.icon,label:n===""?t:`${t}: ${oo(n)}`,mono:!1}}const co=["indigo","green","violet"];function vt(e){if(e.kind==="human")return"user";let t=0;for(const n of e.handle)t=t*31+n.charCodeAt(0)>>>0;return co[t%co.length]??"indigo"}function rb(e){const t=e.replace(/^@/,""),n=t.split(/[\s_-]+/).filter(Boolean);return n.length>=2?`${n[0][0]??""}${n[1][0]??""}`:t.slice(0,2)}function sb(e,t=Date.now()){const n=Date.parse(e);if(!Number.isFinite(n))return"";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return"now";const s=Math.floor(r/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const a=Math.floor(i/24);return a===1?"yesterday":a<7?`${a}d`:new Date(n).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Ut(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}const ib=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});function un(e){return ib.format(e)}function ds(e){return`$${e.toFixed(e>0&&e<.01?4:2)}`}var ob=Xo();function ct(e){const t=e.size??34;return o.jsxs("span",{className:`nx-chip is-${e.accent}`,style:{width:t,height:t,fontSize:Math.round(t*.35)},title:e.title,"aria-hidden":"true",children:[rb(e.name),e.presence&&o.jsx("span",{className:`nx-presence is-${e.presence} on-${e.surface??"surface"}`})]})}function qe(e){const{variant:t="secondary",className:n,children:r,...s}=e;return o.jsx("button",{...s,className:`nx-btn is-${t} ${n??""}`,children:r})}function ke(e){const{icon:t,label:n,size:r="md",variant:s="outline",className:i,...a}=e;return o.jsx("button",{...a,"aria-label":n,title:a.title??n,className:`nx-iconbtn is-${s} is-${r} ${i??""}`,children:o.jsx(t,{"aria-hidden":"true",size:r==="sm"?15:17,strokeWidth:1.75})})}function Us(e){return o.jsx("span",{className:`nx-eyebrow ${e.className??""}`,children:e.children})}function Ac(e){return o.jsxs("span",{className:`nx-status is-${e.tone}`,children:[o.jsx("span",{className:"nx-status-dot","aria-hidden":"true"}),e.children]})}function ab(e){return o.jsx("div",{role:"tablist","aria-label":e.label,className:"nx-segmented",children:e.options.map(t=>o.jsx("button",{role:"tab","aria-selected":e.value===t.value,"data-testid":t.testid,className:"nx-segment",onClick:()=>e.onChange(t.value),children:t.label},t.value))})}function cb(e){return o.jsxs("span",{className:"nx-typing",role:"img","aria-label":e.label??"typing",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})}function yt(e){const t=x.useRef(null),n=x.useRef(e.onClose);return n.current=e.onClose,x.useEffect(()=>{var c,l;const r=document.activeElement,s=t.current,i=()=>[...(s==null?void 0:s.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'))??[]];(l=((c=e.initialFocus)==null?void 0:c.current)??i()[0]??s)==null||l.focus();const a=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),n.current();return}if(d.key!=="Tab"||!s)return;const u=i(),h=u[0],f=u.at(-1);!h||!f||(d.shiftKey&&document.activeElement===h?(d.preventDefault(),f.focus()):!d.shiftKey&&document.activeElement===f&&(d.preventDefault(),h.focus()))};return document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("keydown",a,!0),r==null||r.focus()}},[]),typeof document>"u"?null:ob.createPortal(o.jsx("div",{className:"nx-scrim",onPointerDown:r=>{r.target===r.currentTarget&&e.onClose()},children:o.jsx("div",{ref:t,role:e.alert?"alertdialog":"dialog","aria-modal":"true","aria-label":e.label,"data-testid":e.testid,tabIndex:-1,className:`nx-modal ${e.wide?"is-wide":""} ${e.structured?"is-structured":""}`,children:e.children})}),document.body)}function lo(e){return o.jsx("code",{className:"nx-code",children:e.children})}function lb(e){const t=e==null?void 0:e.contextWindowMaxTokens,n=e==null?void 0:e.contextWindowUsedTokens;if(!(t===void 0||n===void 0||!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<0))return n/t*100}function ub(e){return e>90?"red":e>=70?"amber":"normal"}function uo(e,t=0){return o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true",children:[o.jsx("circle",{className:"nx-context-meter-track",cx:"7",cy:"7",r:"6",fill:"none"}),!e&&o.jsx("circle",{className:"nx-context-meter-progress",cx:"7",cy:"7",r:"6",fill:"none",pathLength:"100",strokeDasharray:"100",strokeDashoffset:100-t})]})}const db=x.memo(function({usage:t,pending:n=!1,testId:r}){const s=lb(t);if(s===void 0)return n?o.jsx("span",{className:"nx-context-meter is-pending","data-testid":r,"aria-hidden":"true",children:uo(!0)}):null;const i=Math.max(0,Math.min(100,s)),a=Math.round(s),c=(t==null?void 0:t.contextWindowUsedTokens)??0,l=(t==null?void 0:t.contextWindowMaxTokens)??0,d=t==null?void 0:t.totalCostUsd,u=d!==void 0&&Number.isFinite(d)&&d>0?ds(d):void 0,h=(t==null?void 0:t.estimated)===!0,f=[`Context window · ${h?"≈ ":""}${a}% used`,`${un(c)} / ${un(l)} tokens`,...u===void 0?[]:[`Session cost: ${u}`]].join(" · ");return o.jsx("span",{className:`nx-context-meter is-${ub(i)}${h?" is-estimated":""}`,role:"img","aria-label":f,title:f,"data-testid":r,"data-percentage":a,children:uo(!1,i)})});async function hb(e,t,n){const r=n!==void 0?`?cwd=${encodeURIComponent(n)}`:"",s=await fetch(`/api/rooms/${encodeURIComponent(e)}/git-diff${r}`,{headers:{authorization:`Bearer ${t}`}});if(!s.ok)throw new Error(`git-diff request failed: ${String(s.status)}`);return s.json()}const mb={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"},fb=e=>mb[e];function pb(e){const t=e.split("/").filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join("/")}`}const hs=new Map,ms="nx-gitdiff:",gb=1440*60*1e3,xb=15e5,zc=(e,t)=>`${e}|${t??""}`;function ho(e,t){const n=zc(e,t),r=hs.get(n);if(r!==void 0)return r;try{const s=localStorage.getItem(ms+n);if(s===null)return;const i=JSON.parse(s);return typeof i.savedAt!="number"||Date.now()-i.savedAt>gb?void 0:(hs.set(n,i.state),i.state)}catch{return}}function bb(e,t,n){const r=zc(e,t);hs.set(r,n);try{const s=JSON.stringify({savedAt:Date.now(),state:n});s.length<=xb?localStorage.setItem(ms+r,s):localStorage.removeItem(ms+r)}catch{}}function Ic(e){const t=e.estimated_cost_usd??0,n=e.uncosted_tokens??0,r=(e.cost_usd>0?1:0)+(t>0?1:0)+(n>0?1:0)>1,s=[];return(e.cost_usd>0||t===0&&n===0)&&s.push(`${ds(e.cost_usd)}${r?" exact":""}`),t>0&&s.push(`~${ds(t)} est.`),n>0&&s.push(`${un(n)} unpriced tokens`),s.join(" + ")}const fs="nx-open-diff";function Gr(e){const[t,n]=x.useState("members"),[r,s]=x.useState(),i=x.useRef(0);return x.useEffect(()=>{const a=c=>{var d;const l=(d=c.detail)==null?void 0:d.path;l!==void 0&&(i.current+=1,n("diff"),s({path:l,nonce:i.current}))};return window.addEventListener(fs,a),()=>window.removeEventListener(fs,a)},[]),o.jsxs("aside",{className:"nx-context","aria-label":"Channel context",children:[o.jsx("div",{className:"nx-context-tabs",children:o.jsx(ab,{label:"Context",value:t,onChange:n,options:[{value:"members",label:"Members",testid:"context-tab-members"},{value:"diff",label:"Diff",testid:"context-tab-diff"},{value:"preview",label:"Preview",testid:"context-tab-preview"}]})}),t==="members"&&o.jsx(_b,{room:e.room,token:e.token,connection:e.connection}),t==="diff"&&o.jsx(Eb,{room:e.room,token:e.token,focus:r}),t==="preview"&&o.jsx(Cb,{room:e.room,token:e.token})]})}function _b(e){var A;const t=H($=>ie($,e.room).members),n=H($=>ie($,e.room).selfMemberId),r=Op(e.room,e.token),s=sc(e.token),[i,a]=x.useState(!1),[c,l]=x.useState(),[d,u]=x.useState(),h=H($=>ie($,e.room).errors),f=H($=>ie($,e.room).room),p=x.useRef(0),g=n!==void 0?(A=t[n])==null?void 0:A.role:void 0,_=g==="owner"||g==="admin",S=g==="owner"||g==="admin";x.useEffect(()=>{if(c===void 0)return;const $=Zx({handle:c,members:Object.values(t),freshErrors:h.slice(p.current)});$.state==="arrived"?(l(void 0),u(void 0),a(!1)):$.state==="failed"&&(u($.message),l(void 0))},[t,h,c]),x.useEffect(()=>{if(c===void 0)return;const $=setTimeout(()=>{u(`No response for @${c}. It may still be starting — check the roster before retrying.`),l(void 0)},2e4);return()=>{clearTimeout($)}},[c]);const R=x.useMemo(()=>{const $=Object.values(t).filter(k=>k.removed_ts===void 0&&(k.kind==="human"||k.kind==="agent")),z=$.filter(k=>k.kind==="human"),I=$.filter(k=>k.kind==="agent");return[...z,...I]},[t]);return o.jsxs("div",{className:"nx-members",children:[o.jsxs("div",{className:"nx-members-head",children:[o.jsx(Us,{children:"People & agents"}),o.jsx(ke,{icon:dc,label:"Spawn agent",size:"sm",variant:"quiet","data-testid":"spawn-agent",onClick:()=>a(!0)})]}),o.jsx("ul",{className:"nx-roster",children:R.map($=>o.jsx(vb,{member:$,detail:r[$.id],adapters:s,canStop:_,canManage:S,connection:e.connection,room:e.room},$.id))}),i&&o.jsx(jb,{adapters:s,token:e.token,roomId:e.room,room:f,members:R,pending:c!==void 0,failure:d,onClose:()=>{a(!1),l(void 0),u(void 0)},onSpawn:$=>{p.current=h.length,u(void 0),l($.handle),e.connection.act({act:"spawn",...$})}})]})}function vb(e){const{member:t,detail:n}=e,r=t.state==="running",[s,i]=x.useState(!1),[a,c]=x.useState(),[l,d]=x.useState(!1),[u,h]=x.useState(!1),f=x.useRef(null);x.useEffect(()=>{if(!s)return;const $=z=>{var I;(I=f.current)!=null&&I.contains(z.target)||i(!1)};return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[s]);const p=n==null?void 0:n.spend,g=p!==void 0?p.input_tokens+p.output_tokens:void 0,[_,S]=x.useState(!1),R=H($=>ie($,e.room).errors.length),A=x.useRef(null);return x.useEffect(()=>{const $=A.current;!_||$===null||(R>$.errors||t!==$.member)&&(A.current=null,S(!1))},[_,R,t]),o.jsxs("li",{className:"nx-member","data-testid":`member-${t.handle}`,children:[o.jsxs("div",{className:"nx-member-row",children:[o.jsx(ct,{name:t.handle,accent:vt(t),size:32}),o.jsxs("span",{className:"nx-member-id",children:[o.jsxs("strong",{children:["@",t.handle]}),o.jsx("span",{className:"nx-member-sub",children:t.kind==="human"?t.display_name:[t.harness,t.model,t.policy].filter(Boolean).join(" · ")||"agent"})]}),o.jsx("span",{className:"nx-member-state",children:t.kind==="human"?o.jsx(Us,{children:t.role??"human"}):o.jsx(kb,{state:t.state})}),t.kind==="agent"&&o.jsx(db,{usage:t.lastUsage,pending:t.state==="running",testId:`member-${t.handle}-context-window`}),t.kind==="agent"&&e.canManage&&o.jsx("button",{type:"button",className:"nx-member-compact","aria-label":`Compact @${t.handle}'s context`,"data-testid":`member-${t.handle}-compact`,disabled:t.state!=="idle"||_,title:r?"Stop the run first — compacting mid-turn would race the engine":t.state!=="idle"?`Only an idle agent can be compacted — @${t.handle} is ${t.state}`:_?"Compacting this agent’s engine session…":"Compact this agent’s engine session","data-compacting":_?"true":void 0,onClick:()=>{A.current={errors:R,member:t},S(!0),e.connection.act({act:"compact_member",member_id:t.id})},children:_?o.jsx(Pn,{size:13,className:"nx-spin","aria-hidden":"true"}):o.jsx(Ig,{size:13,"aria-hidden":"true"})}),t.kind==="agent"&&r&&e.canStop&&o.jsx("button",{type:"button",className:"nx-member-stop","aria-label":`Stop @${t.handle}`,"data-testid":`member-${t.handle}-stop`,title:"Stop this run (the agent stays alive)",onClick:()=>e.connection.act({act:"interrupt",member_id:t.id}),children:o.jsx(pc,{size:13,"aria-hidden":"true"})}),t.kind==="agent"&&e.canManage&&o.jsxs("div",{className:"nx-member-menu",ref:f,children:[o.jsx(ke,{icon:cc,label:`Actions for @${t.handle}`,size:"sm",variant:"quiet","data-testid":`member-${t.handle}-menu`,onClick:()=>i($=>!$)}),s&&o.jsxs("div",{className:"nx-menu",role:"menu","aria-label":`@${t.handle} actions`,children:[o.jsx("button",{role:"menuitem",onClick:()=>{i(!1),d(!0)},children:"Rename…"}),o.jsx("button",{role:"menuitem",onClick:()=>{i(!1),h(!0)},children:"Configure…"}),t.state==="dead"?o.jsx("button",{role:"menuitem","data-testid":`member-${t.handle}-revive`,onClick:()=>{i(!1),e.connection.act({act:"revive",member_id:t.id})},children:"Revive"}):o.jsx("button",{role:"menuitem",className:"is-danger",onClick:()=>{i(!1),c("kill")},children:"Kill…"}),o.jsx("button",{role:"menuitem",className:"is-danger",onClick:()=>{i(!1),c("remove")},children:"Remove…"})]})]})]}),t.kind==="agent"&&(p!==void 0||((n==null?void 0:n.queued_count)??0)>0)&&o.jsxs("p",{className:"nx-member-meter",children:[g!==void 0?`${un(g)} tokens`:"",p!==void 0?` · ${Ic(p)} · ${p.turns} turns`:"",((n==null?void 0:n.queued_count)??0)>0?` · ${n==null?void 0:n.queued_count} queued`:""]}),t.limits!==void 0&&t.limits.length>0&&o.jsx("p",{className:"nx-member-limits","data-testid":`member-${t.handle}-limits`,children:t.limits.map($=>$.used_percent!==void 0?o.jsx(yb,{limit:$},$.window):o.jsxs("span",{className:`nx-limit is-${$.status??"unknown"}`,children:[Lc($.window),": ",($.status??"reported").replace(/_/g," "),$.resets_at!==void 0?` · resets ${Ut($.resets_at)}`:""]},$.window))}),a!==void 0&&o.jsxs(yt,{label:a==="kill"?`Kill @${t.handle}?`:`Remove @${t.handle}?`,onClose:()=>c(void 0),alert:!0,testid:"member-confirm",children:[o.jsx("h2",{className:"nx-dialog-title",children:a==="kill"?`Kill @${t.handle}?`:`Remove @${t.handle}?`}),o.jsx("p",{className:"nx-dialog-body",children:a==="kill"?"The running session ends now; queued work stays queued and the agent can be revived later.":"The member leaves the roster. Queued work addressed to it is consumed."}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",onClick:()=>c(void 0),children:"Cancel"}),o.jsx(qe,{variant:"danger","data-testid":"member-confirm-go",onClick:()=>{e.connection.act(a==="kill"?{act:"kill",member_id:t.id}:{act:"remove",member_id:t.id}),c(void 0)},children:a==="kill"?"Kill session":"Remove member"})]})]}),l&&o.jsx(wb,{member:t,onClose:()=>d(!1),onRename:($,z)=>{e.connection.act({act:"rename",member_id:t.id,handle:$,...z!==""&&{display_name:z}}),d(!1)}}),u&&o.jsx(Sb,{member:t,adapters:e.adapters,onClose:()=>h(!1),onConfigure:$=>{e.connection.act({act:"configure",member_id:t.id,...$}),h(!1)}})]})}function Lc(e){return e==="five_hour"?"5h":e==="seven_day"||e==="weekly"?"weekly":e.replace(/_/g," ")}function yb(e){const t=Math.max(0,Math.round(100-(e.limit.used_percent??0))),n=t<15?"error":t<40?"warn":"ok";return o.jsxs("span",{className:`nx-gauge is-${n}`,title:e.limit.resets_at!==void 0?`resets ${Ut(e.limit.resets_at)}`:void 0,children:[o.jsx("span",{className:"nx-gauge-label",children:Lc(e.limit.window)}),o.jsx("span",{className:"nx-gauge-track","aria-hidden":"true",children:o.jsx("span",{className:"nx-gauge-fill",style:{width:`${t}%`}})}),o.jsxs("span",{className:"nx-gauge-value",children:[t,"% left"]})]})}function kb(e){const t=e.state==="running"||e.state==="queued"?"live":e.state==="dead"?"error":"neutral",n=e.state==="running"||e.state==="queued"?"Working":e.state==="dead"?"Dead":e.state==="awaiting_input"?"Waiting":"Idle";return o.jsx(Ac,{tone:t,children:n})}function wb(e){const[t,n]=x.useState(e.member.handle),[r,s]=x.useState(e.member.display_name);return o.jsxs(yt,{label:`Rename @${e.member.handle}`,onClose:e.onClose,testid:"rename-dialog",children:[o.jsxs("h2",{className:"nx-dialog-title",children:["Rename @",e.member.handle]}),o.jsxs("label",{className:"nx-field",children:["Handle",o.jsx("input",{value:t,onChange:i=>n(i.target.value),"data-testid":"rename-handle"})]}),o.jsxs("label",{className:"nx-field",children:["Display name",o.jsx("input",{value:r,onChange:i=>s(i.target.value)})]}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",type:"button",onClick:e.onClose,children:"Cancel"}),o.jsx(qe,{variant:"primary",disabled:t.trim()==="",onClick:()=>e.onRename(t.trim(),r.trim()),children:"Rename"})]})]})}function Sb(e){const[t,n]=x.useState({harness:e.member.harness??"",model:e.member.model??"",thinking:e.member.thinking??"",policy:Ax(e.member.policy)}),r=s=>{s.preventDefault();const i=e.adapters.find(a=>a.id===t.harness);e.onConfigure({model:t.model===""?null:t.model,thinking:Er(i,t.thinking)??null,...t.policy!==""&&{policy:t.policy}}),e.onClose()};return o.jsx(yt,{label:"Configure agent",onClose:e.onClose,testid:"configure-dialog",structured:!0,children:o.jsxs("form",{onSubmit:r,children:[o.jsxs("div",{className:"nx-dialog-head",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"nx-dialog-title",children:["Configure @",e.member.handle]}),o.jsx("p",{className:"nx-dialog-sub",children:"Applies to this agent's next turn."})]}),o.jsx("button",{type:"button",className:"nx-dialog-close","aria-label":"Close configure agent","data-testid":"configure-close",onClick:e.onClose,children:o.jsx($t,{size:16,"aria-hidden":"true"})})]}),o.jsx("div",{className:"nx-dialog-body",children:o.jsx(Zs,{adapters:e.adapters,config:t,onChange:n,lockHarness:!0,behaviourSection:1,permissionsSection:2,idPrefix:"configure"})}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",type:"button",onClick:e.onClose,children:"Cancel"}),o.jsx(qe,{variant:"primary",type:"submit","data-testid":"configure-go",children:"Save"})]})]})})}function jb(e){var z;const[t,n]=x.useState({harness:"",model:"",thinking:"",policy:fr}),[r,s]=x.useState(""),i=Rx(e.room,e.members),[a,c]=x.useState(i!==""),[l,d]=x.useState(i),u=a?i:l,[h,f]=x.useState(""),p=x.useRef(null),g=Nc(t.harness,e.adapters),_=zx(e.members),S=r.trim(),R=jc(S,_),A=g!==""&&S!==""&&u.trim()!==""&&!R&&!e.pending,$=I=>{I.preventDefault(),A&&e.onSpawn(Ux({config:{...t,harness:g},handle:S,cwd:u,purpose:h,adapters:e.adapters,members:e.members}))};return o.jsx(yt,{label:"Spawn agent",onClose:e.onClose,testid:"spawn-dialog",initialFocus:p,structured:!0,children:o.jsxs("form",{onSubmit:$,children:[o.jsxs("div",{className:"nx-dialog-head",children:[o.jsxs("div",{className:"nx-dialog-headings",children:[o.jsx("span",{className:"nx-dialog-icon","aria-hidden":"true",children:o.jsx(tn,{size:19})}),o.jsxs("div",{children:[o.jsx("h2",{className:"nx-dialog-title",children:"Spawn agent"}),o.jsxs("p",{className:"nx-dialog-sub",children:["Into ",o.jsxs("code",{className:"nx-mono",children:["#",((z=e.room)==null?void 0:z.name)??e.roomId]})]})]})]}),o.jsx("button",{type:"button",className:"nx-dialog-close","aria-label":"Close spawn agent","data-testid":"spawn-close",onClick:e.onClose,children:o.jsx($t,{size:16,"aria-hidden":"true"})})]}),o.jsxs("div",{className:"nx-dialog-body",children:[o.jsxs(ln,{n:1,title:"Identity",children:[o.jsx(Ds,{adapters:e.adapters,config:{...t,harness:g},onChange:n,idPrefix:"spawn"}),o.jsxs("label",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Handle"}),o.jsx("input",{ref:p,value:r,pattern:Ex,maxLength:31,onChange:I=>s(I.target.value),placeholder:"e.g. scout",required:!0,"data-testid":"spawn-handle"})]}),R&&o.jsxs("p",{className:"nx-field-error",role:"alert","data-testid":"spawn-owner-clash",children:["@",S," is already in use by the channel owner."]}),o.jsxs("div",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Working directory"}),o.jsxs("label",{className:"nx-switch-row",children:[o.jsx("input",{type:"checkbox",role:"switch",checked:a,onChange:I=>{c(I.target.checked)},"data-testid":"spawn-use-current-dir"}),o.jsx("span",{children:"Use current directory"})]}),a?i!==""&&o.jsxs("span",{className:"nx-field-note","data-testid":"spawn-inherited-cwd",children:["Inherits ",i]}):o.jsx($c,{token:e.token,value:l,onChange:d,idPrefix:"spawn"})]}),o.jsx(Wx,{idPrefix:"spawn",onApply:I=>{const k=Lx({preset:I,config:{...t,harness:g},adapters:e.adapters,members:e.members});n(k.config),s(k.handle),f(k.purpose)}})]}),o.jsx(Zs,{adapters:e.adapters,config:{...t,harness:g},onChange:n,hideHarness:!0,behaviourSection:2,permissionsSection:3,idPrefix:"spawn"}),o.jsx(ln,{n:4,title:"Purpose",children:o.jsxs("label",{className:"nx-field",children:[o.jsxs("span",{className:"nx-label",children:["Purpose ",o.jsx("span",{className:"nx-opt",children:"· optional"})]}),o.jsx("textarea",{value:h,rows:3,onChange:I=>f(I.target.value),placeholder:"What this agent should focus on…","data-testid":"spawn-purpose"})]})}),e.failure!==void 0&&o.jsx("p",{className:"nx-field-error",role:"alert","data-testid":"spawn-error",children:e.failure})]}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",type:"button",onClick:e.onClose,children:"Cancel"}),o.jsx(qe,{variant:"primary",type:"submit",disabled:!A,"data-testid":"spawn-go",children:e.pending?"Spawning…":"Spawn agent"})]})]})})}function Nb(e,t){const n=H(c=>ie(c,e).messages),[r,s]=x.useState([]),i=x.useRef(new Set),a=x.useRef(new Map);return x.useEffect(()=>{const c=Rp(n).filter(d=>d.kind==="run"&&d.run!==void 0&&d.run.status!=="running").slice(-20);let l=!1;return(async()=>{let d=!1;for(const h of c)if(!i.current.has(h.id)){i.current.add(h.id);try{const f=await ua(e,h.id,{token:t()});a.current.set(h.id,Cc(f.map((p,g)=>({index:g,event:p})))),d=!0}catch{}}if(!d||l)return;const u=[];for(const[h,f]of[...a.current.entries()].sort(([p],[g])=>p-g))for(const p of f)p.image!==void 0&&u.push({msgId:h,...p.image});s(u)})(),()=>{l=!0}},[n,e,t]),{images:r}}function Tb(e,t,n,r){const s=H(f=>ie(f,e).messages),i=x.useMemo(()=>Object.values(s).filter(f=>f.kind==="run"&&f.run!==void 0&&f.run.status!=="running").length,[s]),[a,c]=x.useState(()=>ho(e,n)),[l,d]=x.useState(!1),[u,h]=x.useState(!0);return x.useEffect(()=>{let f=!1;const p=ho(e,n);return c(p),d(!1),h(!0),hb(e,t(),n).then(g=>{f||(bb(e,n,g),c(g),h(!1))}).catch(()=>{f||(h(!1),p===void 0&&d(!0))}),()=>{f=!0}},[e,t,n,r,i]),{state:a,failed:l,refreshing:u}}function Eb(e){const[t,n]=x.useState(),[r,s]=x.useState(0),[i,a]=x.useState(),{state:c,failed:l,refreshing:d}=Tb(e.room,e.token,t,r);if(x.useEffect(()=>{e.focus!==void 0&&a(e.focus.path)},[e.focus]),l)return o.jsx(ir,{testid:"diff-error",children:"Couldn’t read the repository."});if(c===void 0)return o.jsx(ir,{testid:"diff-loading",children:d?"Reading the working tree…":"No repository."});const u=c.files,h=i!==void 0&&!u.some(p=>p.path===i),f=u.find(p=>p.path===i)??u[0];return o.jsxs("div",{className:"nx-diff",children:[d&&o.jsxs("span",{className:"nx-diff-refreshing","data-testid":"diff-refreshing",children:[o.jsx(Pn,{className:"nx-spin",size:12,"aria-hidden":"true"})," Refreshing…"]}),o.jsxs("div",{className:"nx-diff-toolbar",children:[c.cwds.length>1&&o.jsx("select",{className:"nx-diff-cwd","data-testid":"diff-cwd","aria-label":"Working directory",value:c.selected??"",onChange:p=>{n(p.target.value),a(void 0)},children:c.cwds.map(p=>o.jsx("option",{value:p,children:pb(p)},p))}),o.jsx("button",{type:"button",className:"nx-diff-refresh","data-testid":"diff-refresh",onClick:()=>s(p=>p+1),children:"Refresh"})]}),u.length===0&&!h&&o.jsx(ir,{testid:"diff-clean",children:"Working tree clean — no uncommitted changes."}),u.length>0&&o.jsx("ul",{className:"nx-diff-files","data-testid":"diff-files",children:u.map(p=>o.jsx("li",{children:o.jsxs("button",{className:`nx-diff-file ${p===f&&!h?"is-active":""}`,onClick:()=>a(p.path),children:[o.jsx("span",{className:`nx-diff-status is-${p.status}`,title:p.status,children:fb(p.status)}),o.jsx("span",{className:"nx-diff-path",children:p.path}),o.jsxs("span",{className:"nx-diff-stat",children:[o.jsxs("em",{className:"is-add",children:["+",p.additions]})," ",o.jsxs("em",{className:"is-del",children:["−",p.deletions]})]})]})},p.path))}),h?o.jsxs("p",{className:"nx-diff-note","data-testid":"diff-no-current",children:["No current changes for ",i,"."]}):f!==void 0&&o.jsx($b,{diff:{path:f.path,unified:f.diff}})]})}function $b(e){const t=x.useMemo(()=>e.diff.unified.split(`
|
|
335
|
-
`),[e.diff.unified]);return o.jsx("pre",{className:"nx-diff-view","data-testid":"diff-view",children:t.map((n,r)=>{const s=n.startsWith("@@")?"hunk":n.startsWith("+++")||n.startsWith("---")?"meta":n.startsWith("+")?"add":n.startsWith("-")?"del":"ctx";return o.jsx("span",{className:`nx-diff-line is-${s}`,children:n||" "},r)})})}function Cb(e){const{images:t}=Nb(e.room,e.token),n=t.at(-1);return n===void 0?o.jsx(ir,{testid:"preview-empty",children:"Nothing to preview yet — artifacts agents produce appear here."}):o.jsxs("div",{className:"nx-preview",children:[o.jsx("img",{src:`data:${n.media_type};base64,${n.data_b64}`,alt:`Artifact from turn #${n.msgId}`}),o.jsxs("p",{className:"nx-preview-meta",children:["from ",o.jsxs("a",{href:`#${n.msgId}`,children:["#",n.msgId]})]})]})}function ir(e){return o.jsxs("div",{className:"nx-context-empty","data-testid":e.testid,children:[o.jsx("div",{className:"nx-dotgrid","aria-hidden":"true"}),o.jsx("p",{children:e.children})]})}const mo=25*1024*1024,fo=8;async function Rb(e,t,n){const r=await fetch(`/api/rooms/${encodeURIComponent(e)}/attachments?name=${encodeURIComponent(n.name)}`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":n.type||"application/octet-stream"},body:n});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`upload failed (${String(r.status)})`)}return r.json()}const Ab=(e,t,n)=>`/api/rooms/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}?token=${encodeURIComponent(n)}`,zb=e=>/^image\/(png|jpe?g|gif|webp|avif)$/.test(e);function Oc(e){return e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Ib=8,po="nx-quote";function Lb(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1||r>0&&!/[\s(]/.test(n[r-1]??""))return;const s=n.slice(r+1);if(/^[a-z0-9_-]*$/i.test(s))return{start:r,query:s}}function go(e){const t=Nr(),n=H(T=>T.connected),r=H(T=>ie(T,e.room)),s=r.members,i=r.room,a=r.hydrated,[c,l]=x.useState(""),[d,u]=x.useState(),[h,f]=x.useState(),[p,g]=x.useState(),[_,S]=x.useState(0),[R,A]=x.useState([]),[$,z]=x.useState(!1),I=x.useRef(null),k=x.useRef(null),E=x.useRef(!1),L=x.useRef();x.useLayoutEffect(()=>{Re()},[c]),x.useLayoutEffect(()=>{const T=L.current;if(T===void 0)return;L.current=void 0;const B=I.current;B&&(B.setSelectionRange(T,T),B.focus(),ut())},[c]);const Q=x.useMemo(()=>Object.values(s).filter(T=>T.removed_ts===void 0&&T.kind!=="extension"),[s]),G=x.useMemo(()=>{if(!p)return[];const T=p.query.toLowerCase();return Q.filter(B=>B.handle.toLowerCase().startsWith(T)).slice(0,6)},[p,Q]),M=x.useMemo(()=>Ip(r),[r]);x.useEffect(()=>{if(E.current||M===void 0)return;const T=`@${M.handle} `;c!==T&&l(T)},[c,M]),x.useEffect(()=>{const T=B=>{var Ye;const U=B.detail,ae=typeof U=="string"?U:U.text;typeof U!="string"&&u(U.replyTo),E.current=!0,l(Ke=>`${Ke!==""&&!Ke.endsWith(`
|
|
336
|
-
`)?`${Ke}
|
|
337
|
-
`:Ke}${ae}
|
|
338
|
-
`),(Ye=I.current)==null||Ye.focus(),requestAnimationFrame(Re)};return window.addEventListener(po,T),()=>window.removeEventListener(po,T)},[]);const Y=n&&a&&!$&&(c.trim().length>0||R.length>0),$e=T=>{if(T.length===0)return;let B=T;B.some(ae=>ae.size>mo)&&(f("Files must be under 25 MB"),B=B.filter(ae=>ae.size<=mo));const U=fo-R.length;B.length>U&&(f(`Up to ${String(fo)} files per message`),B=B.slice(0,Math.max(0,U))),B.length!==0&&(z(!0),(async()=>{try{for(const ae of B){const Ye=await Rb(e.room,e.token(),ae);A(Ke=>[...Ke,Ye])}}catch(ae){f(ae instanceof Error?ae.message:"Upload failed")}finally{z(!1)}})())},Ce=T=>{A(B=>B.filter(U=>U.id!==T))},Re=()=>{const T=I.current;if(!T)return;T.style.height="auto";const B=getComputedStyle(T),U=parseFloat(B.lineHeight)||24,ae=parseFloat(B.paddingTop)+parseFloat(B.paddingBottom),Ye=Math.round(U*Ib+(Number.isFinite(ae)?ae:0));T.style.height=`${Math.min(T.scrollHeight,Ye)}px`},ut=()=>{const T=I.current;T&&(g(Lb(T.value,T.selectionStart??T.value.length)),S(0))},De=T=>{if(!p)return;E.current=!0;const B=I.current,U=(B==null?void 0:B.selectionStart)??c.length,ae=`${c.slice(0,p.start)}@${T.handle} ${c.slice(U)}`;l(ae),g(void 0),L.current=p.start+T.handle.length+2},kt=()=>{var U;const T=(((U=I.current)==null?void 0:U.value)??c).trim();if(!n||!a||$||T.length===0&&R.length===0)return;if(!Q.some(ae=>new RegExp(`@${ae.handle}\\b`,"i").test(T))&&Q.some(ae=>ae.kind==="agent")){f(M?`Say who this is for — try @${M.handle}`:"Say who this is for — mention someone with @");return}e.connection.post(T,{...d!==void 0&&{replyTo:d},...R.length>0&&{attachments:R.map(ae=>ae.id)}}),l(""),u(void 0),A([]),f(void 0),E.current=!1,g(void 0),requestAnimationFrame(Re)};return o.jsxs("footer",{className:"nx-composer",onDragOver:T=>{T.preventDefault()},onDrop:T=>{T.preventDefault(),$e(Array.from(T.dataTransfer.files))},children:[d!==void 0&&o.jsxs("p",{className:"nx-composer-reply","data-testid":"composer-reply",children:["Replying to #",d,o.jsx("button",{type:"button","aria-label":"Cancel reply",onClick:()=>u(void 0),children:o.jsx($t,{size:12,"aria-hidden":"true"})})]}),h!==void 0&&o.jsx("p",{className:"nx-composer-hint",role:"alert","data-testid":"composer-hint",children:h}),o.jsx("input",{ref:k,type:"file",multiple:!0,hidden:!0,"data-testid":"composer-file",onChange:T=>{$e(Array.from(T.target.files??[])),T.target.value=""}}),R.length>0&&o.jsx("ul",{className:"nx-attach-tray","data-testid":"attach-tray",children:R.map(T=>o.jsxs("li",{className:"nx-attach-chip","data-testid":`pending-${T.id}`,children:[o.jsx("span",{className:"nx-attach-name",children:T.name}),o.jsx("span",{className:"nx-attach-size",children:Oc(T.size)}),o.jsx("button",{type:"button",className:"nx-attach-remove","aria-label":`Remove ${T.name}`,"data-testid":`pending-${T.id}-remove`,onClick:()=>Ce(T.id),children:o.jsx($t,{size:13,"aria-hidden":"true"})})]},T.id))}),o.jsxs("div",{className:"nx-composer-bar",children:[p&&G.length>0&&o.jsx("ul",{className:"nx-mentions",role:"listbox","aria-label":"Mention someone","data-testid":"mention-popover",children:G.map((T,B)=>o.jsx("li",{role:"presentation",children:o.jsxs("button",{role:"option","aria-selected":B===_,className:`nx-mention ${B===_?"is-active":""}`,onMouseEnter:()=>S(B),onMouseDown:U=>{U.preventDefault(),De(T)},children:[o.jsx(ct,{name:T.handle,accent:vt(T),size:24}),o.jsxs("span",{className:"nx-mention-handle",children:["@",T.handle]}),o.jsx("span",{className:"nx-mention-kind",children:T.kind})]})},T.id))}),o.jsx("textarea",{ref:I,className:"nx-composer-input","data-testid":"composer-input",placeholder:n?`Message ${(i==null?void 0:i.name)??e.room}…`:"Reconnecting…","aria-label":"Message",rows:1,value:c,onBeforeInput:()=>{E.current=!0},onChange:T=>{E.current=!0,l(T.target.value),f(void 0),Re(),requestAnimationFrame(ut)},onClick:ut,onKeyDown:T=>{if(!(t&&T.key==="Enter")){if(p&&G.length>0){if(T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault(),S(B=>{const U=T.key==="ArrowDown"?1:-1;return(B+U+G.length)%G.length});return}if(T.key==="Enter"||T.key==="Tab"){T.preventDefault(),De(G[_]??G[0]);return}if(T.key==="Escape"){g(void 0);return}}T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),kt())}},onBlur:()=>g(void 0),onPaste:T=>{const B=Array.from(T.clipboardData.files);B.length>0&&(T.preventDefault(),$e(B))}}),t?o.jsxs("div",{className:"nx-composer-row2",children:[o.jsx(ke,{icon:cs,label:"Attach files",variant:"quiet","data-testid":"composer-attach",onClick:()=>{var T;return(T=k.current)==null?void 0:T.click()}}),o.jsx(ke,{icon:Xp,label:"Mention someone",variant:"quiet","data-testid":"composer-at",onClick:()=>{const T=I.current;if(!T)return;E.current=!0;const B=T.selectionStart??c.length,U=B===0||/\s/.test(c[B-1]??"")?"":" ";l(`${c.slice(0,B)}${U}@${c.slice(B)}`),L.current=B+U.length+1}}),o.jsx("span",{className:"nx-composer-spacer"}),o.jsx(ke,{icon:as,label:"Send message",variant:"solid",className:"nx-composer-send","data-testid":"composer-send",disabled:!Y,onClick:kt})]}):o.jsxs(o.Fragment,{children:[o.jsx(ke,{icon:cs,label:"Attach files",variant:"quiet",className:"nx-composer-attach","data-testid":"composer-attach",onClick:()=>{var T;return(T=k.current)==null?void 0:T.click()}}),o.jsx(ke,{icon:as,label:"Send message",variant:"solid",className:"nx-composer-send","data-testid":"composer-send",disabled:!Y,onClick:kt})]})]})]})}function Ob(e){const t=H(G=>G.activeRoom),n=H(G=>ie(G,t).members),r=H(G=>ie(G,t).selfMemberId),s=sc(e.token),[i,a]=x.useState(""),[c,l]=x.useState(""),[d,u]=x.useState({harness:"",model:"",thinking:"",policy:fr}),[h,f]=x.useState("codor"),[p,g]=x.useState(!1),[_,S]=x.useState(),[R,A]=x.useState(),$=Ap(n,r),z=d.harness,I=h.trim()===""?"Agent":h.trim(),k=x.useMemo(()=>Af(I),[I]),E=z!==""&&k!==void 0&&jc(k,$),L=i.trim()!==""&&c.trim()!==""&&$!==void 0&&!p&&!E&&(z===""||k!==void 0),Q=()=>{!L||$===void 0||(g(!0),S(void 0),A(void 0),ql({name:i.trim(),owner:{handle:$.handle,display_name:$.display_name},cwd:c.trim(),...z!==""&&k!==void 0&&{starting_agent:{harness:z,handle:k,display_name:I,policy:d.policy===""?fr:d.policy,...d.model!==""&&{model:d.model},...(()=>{const G=Er(s.find(M=>M.id===z),d.thinking);return G===void 0?{}:{thinking:G}})()}}},{token:e.token()}).then(G=>e.onCreated(G),G=>{const M=G instanceof Error?G.message:String(G);Fx(M)?A(M):S(M)}).finally(()=>g(!1)))};return o.jsx(yt,{label:"Create channel",onClose:e.onClose,testid:"create-channel-dialog",structured:!0,children:o.jsxs("form",{onSubmit:G=>{G.preventDefault(),Q()},children:[o.jsxs("div",{className:"nx-dialog-head",children:[o.jsxs("div",{className:"nx-dialog-headings",children:[o.jsx("span",{className:"nx-dialog-icon","aria-hidden":"true",children:o.jsx(kg,{size:19})}),o.jsxs("div",{children:[o.jsx("h2",{className:"nx-dialog-title",children:"Create channel"}),o.jsx("p",{className:"nx-dialog-sub",children:"A workspace for a task and its agents."})]})]}),o.jsx("button",{type:"button",className:"nx-dialog-close","aria-label":"Close create channel","data-testid":"create-close",onClick:e.onClose,children:o.jsx($t,{size:16,"aria-hidden":"true"})})]}),o.jsxs("div",{className:"nx-dialog-body",children:[o.jsxs(ln,{n:1,title:"Workspace",children:[o.jsxs("label",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Name"}),o.jsx("input",{value:i,required:!0,onChange:G=>a(G.target.value),placeholder:"e.g. Engineering","data-testid":"create-name"}),i.trim()!==""&&o.jsxs("span",{className:"nx-field-note",children:["id: ",o.jsx(lo,{children:Ef(i)})]})]}),o.jsxs("div",{className:"nx-field",children:[o.jsxs("span",{className:"nx-label",children:["Working folder ",o.jsx("span",{className:"nx-req",children:"· required"})]}),o.jsx($c,{token:e.token,value:c,onChange:l,idPrefix:"create"})]})]}),o.jsx(ln,{n:2,title:"Starting agent",children:o.jsxs("div",{className:"nx-agent-panel",children:[o.jsx(Ds,{adapters:s,config:d,onChange:u,allowNone:!0,optional:!0,idPrefix:"create"}),o.jsxs("label",{className:"nx-field",children:[o.jsx("span",{className:"nx-label",children:"Agent name"}),o.jsx("input",{value:h,disabled:z==="",onChange:G=>f(G.target.value),placeholder:"e.g. Scout","data-testid":"create-agent-name"}),z!==""&&R!==void 0&&o.jsx("span",{className:"nx-field-note is-error",role:"alert","data-testid":"create-agent-error",children:R}),z!==""&&h.trim()!==""&&(k!==void 0?o.jsxs("span",{className:"nx-field-note",children:["joins as ",o.jsxs(lo,{children:["@",k]})]}):o.jsx("span",{className:"nx-field-note is-error",children:"that name resolves to a reserved handle — pick another"})),E&&o.jsxs("span",{className:"nx-field-note is-error","data-testid":"create-owner-clash",children:["@",k," is already in use by the channel owner."]})]}),z!==""&&o.jsx(Zs,{adapters:s,config:d,onChange:u,hideHarness:!0,behaviourSection:3,permissionsSection:4,embedded:!0,idPrefix:"create"})]})}),_!==void 0&&o.jsx("p",{className:"nx-field-note is-error",role:"alert",children:_})]}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",type:"button",onClick:e.onClose,children:"Cancel"}),o.jsx(qe,{variant:"primary",type:"submit",disabled:!L,"data-testid":"create-go",children:p?"Creating…":"Create channel"})]})]})})}const Pb=[],ps="nx-jump-anchor";async function qs(e,t,n){const r=ie(H.getState(),e);for(let s=0;s<10&&ie(H.getState(),e).messages[t]===void 0;s++){const i=ie(H.getState(),e).historyCursor??r.historyCursor;if(i===void 0||i<=1)break;try{const a=await la(e,{before:i,limit:In},{token:n()});if(a.messages.length===0)break;H.getState().mergeHistoryPage(e,a.messages)}catch{break}}window.location.hash=`#${t}`;for(let s=0;s<30;s+=1){const i=document.getElementById(String(t));if(i!==null){i.scrollIntoView({block:"center"}),window.dispatchEvent(new CustomEvent(ps,{detail:{room:e,id:t}}));break}await new Promise(a=>requestAnimationFrame(()=>a()))}}function xo(e){const t=H(i=>ie(i,e.room).inbox),n=H(i=>ie(i,e.room).members),r=H(i=>ie(i,e.room).messages),s=x.useMemo(()=>zp(t),[t]);return s.length===0?null:o.jsx("div",{className:"nx-holds","data-testid":"hold-banner",children:s.map(i=>{const a=n[i.recipient],c=r[i.message_id];return o.jsxs("div",{className:"nx-hold",children:[o.jsx(dg,{size:16,"aria-hidden":"true"}),o.jsxs("span",{className:"nx-hold-text",children:["Held for ",o.jsxs("strong",{children:["@",(a==null?void 0:a.handle)??"…"]}),c!==void 0?` — “${(c.body.split(`
|
|
339
|
-
`,1)[0]??"").slice(0,80)}”`:""]}),o.jsxs("span",{className:"nx-hold-actions",children:[o.jsx(qe,{variant:"secondary","data-testid":`hold-${i.id}-release`,onClick:()=>e.connection.act({act:"release_hold",delivery_id:i.id}),children:"Release"}),o.jsx(qe,{variant:"quiet","data-testid":`hold-${i.id}-redeliver`,onClick:()=>e.connection.act({act:"redeliver",delivery_id:i.id}),children:"Redeliver"})]})]},i.id)})})}function Mb(e){const[t,n]=x.useState(!1),r=H(a=>ie(a,e.room).support),s=(r==null?void 0:r.inbox)??Pb,i=s.length;return o.jsxs("span",{className:"nx-inbox-wrap",children:[o.jsxs("span",{className:"nx-badge-anchor",children:[o.jsx(ke,{icon:Cg,label:`Inbox — ${i} unread`,"data-testid":"inbox-toggle",onClick:()=>n(a=>!a)}),i>0&&o.jsx("span",{className:"nx-badge","data-testid":"inbox-badge",children:i>99?"99+":i})]}),t&&o.jsx(Db,{rows:s,onClose:()=>n(!1),onMarkAllRead:()=>{for(const a of s)e.connection.act({act:"mark_read",delivery_id:a.delivery.id});n(!1)},onOpenRow:a=>{e.connection.act({act:"mark_read",delivery_id:a.delivery.id}),n(!1),qs(e.room,a.delivery.message_id,e.token)}})]})}function Db(e){const t=x.useRef(null);return x.useEffect(()=>{const n=s=>{var i;(i=t.current)!=null&&i.contains(s.target)||e.onClose()},r=s=>{s.key==="Escape"&&e.onClose()};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[]),o.jsxs("div",{ref:t,className:"nx-inbox",role:"dialog","aria-label":"Inbox","data-testid":"inbox-panel",children:[o.jsxs("header",{className:"nx-inbox-head",children:[o.jsx("strong",{children:"Needs you"}),e.rows.length>0&&o.jsx("button",{className:"nx-inbox-clear","data-testid":"inbox-mark-all",onClick:e.onMarkAllRead,children:"Mark all read"}),o.jsx(ke,{icon:$t,label:"Close inbox",size:"sm",variant:"quiet",onClick:e.onClose})]}),e.rows.length===0?o.jsx("p",{className:"nx-inbox-empty","data-testid":"inbox-empty",children:"Nothing needs you."}):o.jsx("ul",{className:"nx-inbox-list",children:e.rows.map(n=>o.jsx("li",{children:o.jsxs("button",{className:"nx-inbox-row","data-testid":`inbox-row-${n.delivery.id}`,onClick:()=>e.onOpenRow(n),children:[o.jsxs("strong",{children:["@",n.author_handle]}),o.jsx("span",{className:"nx-inbox-preview",children:n.preview||n.message_kind}),o.jsx("time",{children:Ut(n.ts)})]})},n.delivery.id))})]})}function Zb(e){const[t,n]=x.useState(""),[r,s]=x.useState(),[i,a]=x.useState(!1),c=H(d=>ie(d,e.room).members),l=x.useRef(null);return x.useEffect(()=>{const d=t.trim();if(d.length<2){s(void 0);return}a(!0);const u=setTimeout(()=>{Wl(e.room,d,{token:e.token()}).then(h=>s(h)).catch(()=>s([])).finally(()=>a(!1))},250);return()=>clearTimeout(u)},[t,e.room,e.token]),o.jsxs(yt,{label:"Search messages",onClose:e.onClose,testid:"search-overlay",initialFocus:l,children:[o.jsxs("div",{className:"nx-search-box",children:[o.jsx(Tr,{size:16,"aria-hidden":"true"}),o.jsx("input",{ref:l,"data-testid":"search-input",placeholder:"Search this channel…","aria-label":"Search this channel",value:t,onChange:d=>n(d.target.value)})]}),i&&o.jsx("p",{className:"nx-search-note",children:"Searching…"}),r!==void 0&&!i&&(r.length===0?o.jsx("p",{className:"nx-search-note","data-testid":"search-empty",children:"No matches."}):o.jsx("ul",{className:"nx-search-results","data-testid":"search-results",children:r.map(d=>{var u;return o.jsx("li",{children:o.jsxs("button",{className:"nx-search-row","data-testid":`search-hit-${d.id}`,onClick:()=>{e.onClose(),qs(e.room,d.id,e.token)},children:[o.jsxs("strong",{children:["@",((u=c[d.author])==null?void 0:u.handle)??"…"]}),o.jsx("span",{className:"nx-search-body",children:(d.body.split(`
|
|
340
|
-
`,1)[0]??"").slice(0,110)}),o.jsxs("span",{className:"nx-search-meta",children:["#",d.id," · ",Ut(d.ts)]})]})},d.id)})}))]})}function Fb({status:e,trigger:t,preTokens:n}){return e==="loading"?"Compacting…":t==="auto"?"Context automatically compacted":t==="manual"?"Context manually compacted":n!==void 0?`Context compacted (${un(n)} tokens)`:"Context compacted"}function Pc(e){const t=Fb(e);return o.jsxs("div",{className:`nx-compaction is-${e.status}`,role:"separator","aria-label":t,title:t,"data-testid":"compaction-marker","data-status":e.status,"data-trigger":e.trigger,"data-pre-tokens":e.preTokens,children:[o.jsx("span",{className:"nx-compaction-line","aria-hidden":"true"}),o.jsxs("span",{className:"nx-compaction-label","aria-hidden":"true",children:[e.status==="loading"?o.jsx(Pn,{className:"nx-spin",size:13}):o.jsx(Kg,{size:13}),o.jsx("span",{children:t})]}),o.jsx("span",{className:"nx-compaction-line","aria-hidden":"true"})]})}/*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */function bo(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ub(e){if(Array.isArray(e))return e}function qb(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,a,c=[],l=!0,d=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(l=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(u){d=!0,s=u}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function Bb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
341
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hb(e,t){return Ub(e)||qb(e,t)||Wb(e,t)||Bb()}function Wb(e,t){if(e){if(typeof e=="string")return bo(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bo(e,t):void 0}}const Mc=Object.entries,_o=Object.setPrototypeOf,Vb=Object.isFrozen,Gb=Object.getPrototypeOf,Jb=Object.getOwnPropertyDescriptor;let Ne=Object.freeze,Ee=Object.seal,nn=Object.create,Dc=typeof Reflect<"u"&&Reflect,gs=Dc.apply,xs=Dc.construct;Ne||(Ne=function(t){return t});Ee||(Ee=function(t){return t});gs||(gs=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return t.apply(n,s)});xs||(xs=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const Xt=_e(Array.prototype.forEach),Yb=_e(Array.prototype.lastIndexOf),vo=_e(Array.prototype.pop),Qt=_e(Array.prototype.push),Kb=_e(Array.prototype.splice),Tt=Array.isArray,Nn=_e(String.prototype.toLowerCase),Jr=_e(String.prototype.toString),yo=_e(String.prototype.match),yn=_e(String.prototype.replace),ko=_e(String.prototype.indexOf),Xb=_e(String.prototype.trim),Qb=_e(Number.prototype.toString),e0=_e(Boolean.prototype.toString),wo=typeof BigInt>"u"?null:_e(BigInt.prototype.toString),So=typeof Symbol>"u"?null:_e(Symbol.prototype.toString),ye=_e(Object.prototype.hasOwnProperty),kn=_e(Object.prototype.toString),ve=_e(RegExp.prototype.test),Lt=t0(TypeError);function _e(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return gs(e,t,r)}}function t0(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return xs(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nn;if(_o&&_o(e,null),!Tt(t))return e;let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const i=n(s);i!==s&&(Vb(t)||(t[r]=i),s=i)}e[s]=!0}return e}function n0(e){for(let t=0;t<e.length;t++)ye(e,t)||(e[t]=null);return e}function Pe(e){const t=nn(null);for(const r of Mc(e)){var n=Hb(r,2);const s=n[0],i=n[1];ye(e,s)&&(Tt(i)?t[s]=n0(i):i&&typeof i=="object"&&i.constructor===Object?t[s]=Pe(i):t[s]=i)}return t}function r0(e){switch(typeof e){case"string":return e;case"number":return Qb(e);case"boolean":return e0(e);case"bigint":return wo?wo(e):"0";case"symbol":return So?So(e):"Symbol()";case"undefined":return kn(e);case"function":case"object":{if(e===null)return kn(e);const t=e,n=pt(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:kn(r)}return kn(e)}default:return kn(e)}}function pt(e,t){for(;e!==null;){const r=Jb(e,t);if(r){if(r.get)return _e(r.get);if(typeof r.value=="function")return _e(r.value)}e=Gb(e)}function n(){return null}return n}function s0(e){try{return ve(e,""),!0}catch{return!1}}const jo=Ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Yr=Ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Kr=Ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),i0=Ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xr=Ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),o0=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),No=Ne(["#text"]),To=Ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Qr=Ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Eo=Ne(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),er=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),a0=Ee(/{{[\w\W]*|^[\w\W]*}}/g),c0=Ee(/<%[\w\W]*|^[\w\W]*%>/g),l0=Ee(/\${[\w\W]*/g),u0=Ee(/^data-[\-\w.\u00B7-\uFFFF]+$/),d0=Ee(/^aria-[\-\w]+$/),$o=Ee(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),h0=Ee(/^(?:\w+script|data):/i),m0=Ee(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),f0=Ee(/^html$/i),p0=Ee(/^[a-z][.\w]*(-[.\w]+)+$/i),Co=Ee(/<[/\w!]/g),Ro=Ee(/<[/\w]/g),g0=Ee(/<\/no(script|embed|frames)/i),x0=Ee(/\/>/i),Ve={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},b0=function(){return typeof window>"u"?null:window},_0=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Ao=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},jt=function(t,n,r,s){return ye(t,n)&&Tt(t[n])?K(s.base?Pe(s.base):{},t[n],s.transform):r};function Zc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:b0();const t=C=>Zc(C);if(t.version="3.4.12",t.removed=[],!e||!e.document||e.document.nodeType!==Ve.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,s=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,a=e.Node,c=e.Element,l=e.NodeFilter,d=e.NamedNodeMap;d===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const u=e.DOMParser,h=e.trustedTypes,f=c.prototype,p=pt(f,"cloneNode"),g=pt(f,"remove"),_=pt(f,"nextSibling"),S=pt(f,"childNodes"),R=pt(f,"parentNode"),A=pt(f,"shadowRoot"),$=pt(f,"attributes"),z=a&&a.prototype?pt(a.prototype,"nodeType"):null,I=a&&a.prototype?pt(a.prototype,"nodeName"):null;if(typeof i=="function"){const C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let k,E="",L,Q=!1,G=0;const M=function(){if(G>0)throw Lt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Y=function(m){M(),G++;try{return k.createHTML(m)}finally{G--}},$e=function(m){M(),G++;try{return k.createScriptURL(m)}finally{G--}},Ce=function(){return Q||(L=_0(h,s),Q=!0),L},Re=n,ut=Re.implementation,De=Re.createNodeIterator,kt=Re.createDocumentFragment,T=Re.getElementsByTagName,B=r.importNode;let U=Ao();t.isSupported=typeof Mc=="function"&&typeof R=="function"&&ut&&ut.createHTMLDocument!==void 0;const ae=a0,Ye=c0,Ke=l0,fn=u0,Dn=d0,Wt=h0,dt=m0,wt=p0;let Se=$o,ee=null;const xt=K({},[...jo,...Yr,...Kr,...Xr,...No]);let ce=null;const pn=K({},[...To,...Qr,...Eo,...er]);let le=Object.seal(nn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xe=null,At=null;const Ie=Object.seal(nn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let He=!0,We=!0,Zn=!1,gn=!0,Qe=!1,et=!0,y=!1,D=!1,J=null,de=null,Ze=!1,Fe=!1,bt=!1,_t=!1,ei=!0,ti=!1;const ni="user-content-";let Rr=!0,Ar=!1,Vt={},ht=null;const zr=K({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let ri=null;const si=K({},["audio","video","img","source","image","track"]);let Ir=null;const ii=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fn="http://www.w3.org/1998/Math/MathML",Un="http://www.w3.org/2000/svg",mt="http://www.w3.org/1999/xhtml";let Gt=mt,Lr=!1,Or=null;const il=K({},[Fn,Un,mt],Jr),oi=Ne(["mi","mo","mn","ms","mtext"]);let Pr=K({},oi);const ai=Ne(["annotation-xml"]);let Mr=K({},ai);const ol=K({},["title","style","font","a","script"]);let xn=null;const al=["application/xhtml+xml","text/html"],cl="text/html";let he=null,Jt=null;const ll=n.createElement("form"),ci=function(m){return m instanceof RegExp||m instanceof Function},Dr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Jt&&Jt===m)return;(!m||typeof m!="object")&&(m={}),m=Pe(m),xn=al.indexOf(m.PARSER_MEDIA_TYPE)===-1?cl:m.PARSER_MEDIA_TYPE,he=xn==="application/xhtml+xml"?Jr:Nn,ee=jt(m,"ALLOWED_TAGS",xt,{transform:he}),ce=jt(m,"ALLOWED_ATTR",pn,{transform:he}),Or=jt(m,"ALLOWED_NAMESPACES",il,{transform:Jr}),Ir=jt(m,"ADD_URI_SAFE_ATTR",ii,{transform:he,base:ii}),ri=jt(m,"ADD_DATA_URI_TAGS",si,{transform:he,base:si}),ht=jt(m,"FORBID_CONTENTS",zr,{transform:he}),Xe=jt(m,"FORBID_TAGS",Pe({}),{transform:he}),At=jt(m,"FORBID_ATTR",Pe({}),{transform:he}),Vt=ye(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?Pe(m.USE_PROFILES):m.USE_PROFILES:!1,He=m.ALLOW_ARIA_ATTR!==!1,We=m.ALLOW_DATA_ATTR!==!1,Zn=m.ALLOW_UNKNOWN_PROTOCOLS||!1,gn=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qe=m.SAFE_FOR_TEMPLATES||!1,et=m.SAFE_FOR_XML!==!1,y=m.WHOLE_DOCUMENT||!1,Fe=m.RETURN_DOM||!1,bt=m.RETURN_DOM_FRAGMENT||!1,_t=m.RETURN_TRUSTED_TYPE||!1,Ze=m.FORCE_BODY||!1,ei=m.SANITIZE_DOM!==!1,ti=m.SANITIZE_NAMED_PROPS||!1,Rr=m.KEEP_CONTENT!==!1,Ar=m.IN_PLACE||!1,Se=s0(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:$o,Gt=typeof m.NAMESPACE=="string"?m.NAMESPACE:mt,Pr=ye(m,"MATHML_TEXT_INTEGRATION_POINTS")&&m.MATHML_TEXT_INTEGRATION_POINTS&&typeof m.MATHML_TEXT_INTEGRATION_POINTS=="object"?Pe(m.MATHML_TEXT_INTEGRATION_POINTS):K({},oi),Mr=ye(m,"HTML_INTEGRATION_POINTS")&&m.HTML_INTEGRATION_POINTS&&typeof m.HTML_INTEGRATION_POINTS=="object"?Pe(m.HTML_INTEGRATION_POINTS):K({},ai);const b=ye(m,"CUSTOM_ELEMENT_HANDLING")&&m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING=="object"?Pe(m.CUSTOM_ELEMENT_HANDLING):nn(null);if(le=nn(null),ye(b,"tagNameCheck")&&ci(b.tagNameCheck)&&(le.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&ci(b.attributeNameCheck)&&(le.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),Ee(le),Qe&&(We=!1),bt&&(Fe=!0),Vt&&(ee=K({},No),ce=nn(null),Vt.html===!0&&(K(ee,jo),K(ce,To)),Vt.svg===!0&&(K(ee,Yr),K(ce,Qr),K(ce,er)),Vt.svgFilters===!0&&(K(ee,Kr),K(ce,Qr),K(ce,er)),Vt.mathMl===!0&&(K(ee,Xr),K(ce,Eo),K(ce,er))),Ie.tagCheck=null,Ie.attributeCheck=null,ye(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Ie.tagCheck=m.ADD_TAGS:Tt(m.ADD_TAGS)&&(ee===xt&&(ee=Pe(ee)),K(ee,m.ADD_TAGS,he))),ye(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Ie.attributeCheck=m.ADD_ATTR:Tt(m.ADD_ATTR)&&(ce===pn&&(ce=Pe(ce)),K(ce,m.ADD_ATTR,he))),ye(m,"ADD_URI_SAFE_ATTR")&&Tt(m.ADD_URI_SAFE_ATTR)&&K(Ir,m.ADD_URI_SAFE_ATTR,he),ye(m,"FORBID_CONTENTS")&&Tt(m.FORBID_CONTENTS)&&(ht===zr&&(ht=Pe(ht)),K(ht,m.FORBID_CONTENTS,he)),ye(m,"ADD_FORBID_CONTENTS")&&Tt(m.ADD_FORBID_CONTENTS)&&(ht===zr&&(ht=Pe(ht)),K(ht,m.ADD_FORBID_CONTENTS,he)),Rr&&(ee["#text"]=!0),y&&K(ee,["html","head","body"]),ee.table&&(K(ee,["tbody"]),delete Xe.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Lt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Lt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const N=k;k=m.TRUSTED_TYPES_POLICY;try{E=Y("")}catch(P){throw k=N,P}}else m.TRUSTED_TYPES_POLICY===null?(k=void 0,E=""):(k===void 0&&(k=Ce()),k&&typeof E=="string"&&(E=Y("")));Ne&&Ne(m),Jt=m},li=K({},[...Yr,...Kr,...i0]),ui=K({},[...Xr,...o0]),ul=function(m,b,N){return b.namespaceURI===mt?m==="svg":b.namespaceURI===Fn?m==="svg"&&(N==="annotation-xml"||Pr[N]):!!li[m]},dl=function(m,b,N){return b.namespaceURI===mt?m==="math":b.namespaceURI===Un?m==="math"&&Mr[N]:!!ui[m]},hl=function(m,b,N){return b.namespaceURI===Un&&!Mr[N]||b.namespaceURI===Fn&&!Pr[N]?!1:!ui[m]&&(ol[m]||!li[m])},ml=function(m){let b=R(m);(!b||!b.tagName)&&(b={namespaceURI:Gt,tagName:"template"});const N=Nn(m.tagName),P=Nn(b.tagName);return Or[m.namespaceURI]?m.namespaceURI===Un?ul(N,b,P):m.namespaceURI===Fn?dl(N,b,P):m.namespaceURI===mt?hl(N,b,P):!!(xn==="application/xhtml+xml"&&Or[m.namespaceURI]):!1},St=function(m){Qt(t.removed,{element:m});try{R(m).removeChild(m)}catch{if(g(m),!R(m))throw Lt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},qn=function(m){Zr(m);const b=S(m);if(b){const P=[];Xt(b,q=>{Qt(P,q)}),Xt(P,q=>{try{g(q)}catch{}})}const N=$(m);if(N)for(let P=N.length-1;P>=0;--P){const q=N[P],W=q&&q.name;if(typeof W=="string")try{m.removeAttribute(W)}catch{}}},zt=function(m,b){try{Qt(t.removed,{attribute:b.getAttributeNode(m),from:b})}catch{Qt(t.removed,{attribute:null,from:b})}if(b.removeAttribute(m),m==="is")if(Fe||bt)try{St(b)}catch{}else try{b.setAttribute(m,"")}catch{}},fl=function(m){const b=$(m);if(b)for(let N=b.length-1;N>=0;--N){const P=b[N],q=P&&P.name;if(!(typeof q!="string"||ce[he(q)]))try{m.removeAttribute(q)}catch{}}},Zr=function(m){const b=[m];for(;b.length>0;){const N=b.pop();(z?z(N):N.nodeType)===Ve.element&&fl(N);const q=S(N);if(q)for(let W=q.length-1;W>=0;--W)b.push(q[W])}},pl=function(m){if(!et)return;const b=[m];for(;b.length>0;){const N=b.pop(),P=z?z(N):N.nodeType;if(P===Ve.processingInstruction||P===Ve.comment&&ve(Ro,N.data)){try{g(N)}catch{}continue}if(P===Ve.element){const W=N,fe=he(I?I(N):N.nodeName);try{W.hasAttribute&&W.hasAttribute("patchsrc")&&W.removeAttribute("patchsrc"),W.hasAttribute&&W.hasAttribute("for")&&fe!=="label"&&fe!=="output"&&W.removeAttribute("for")}catch{}}const q=S(N);if(q)for(let W=q.length-1;W>=0;--W)b.push(q[W])}},di=function(m){let b=null,N=null;if(Ze)m="<remove></remove>"+m;else{const W=yo(m,/^[\r\n\t ]+/);N=W&&W[0]}xn==="application/xhtml+xml"&&Gt===mt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const P=k?Y(m):m;if(Gt===mt)try{b=new u().parseFromString(P,xn)}catch{}if(!b||!b.documentElement){b=ut.createDocument(Gt,"template",null);try{b.documentElement.innerHTML=Lr?E:P}catch{}}const q=b.body||b.documentElement;return m&&N&&q.insertBefore(n.createTextNode(N),q.childNodes[0]||null),Gt===mt?T.call(b,y?"html":"body")[0]:y?b.documentElement:q},hi=function(m){return De.call(m.ownerDocument||m,m,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Bn=function(m){return m=yn(m,ae," "),m=yn(m,Ye," "),m=yn(m,Ke," "),m},Fr=function(m){var b;m.normalize();const N=De.call(m.ownerDocument||m,m,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let P=N.nextNode();for(;P;)P.data=Bn(P.data),P=N.nextNode();const q=(b=m.querySelectorAll)===null||b===void 0?void 0:b.call(m,"template");q&&Xt(q,W=>{Yt(W.content)&&Fr(W.content)})},Hn=function(m){const b=I?I(m):null;return typeof b!="string"||he(b)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==$(m)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==z(m)||m.childNodes!==S(m)},Yt=function(m){if(!z||typeof m!="object"||m===null)return!1;try{return z(m)===Ve.documentFragment}catch{return!1}},bn=function(m){if(!z||typeof m!="object"||m===null)return!1;try{return typeof z(m)=="number"}catch{return!1}};function ft(C,m,b){C.length!==0&&Xt(C,N=>{N.call(t,m,b,Jt)})}const gl=function(m,b){return!!(et&&m.hasChildNodes()&&!bn(m.firstElementChild)&&ve(Co,m.textContent)&&ve(Co,m.innerHTML)||et&&m.namespaceURI===mt&&b==="style"&&bn(m.firstElementChild)||m.nodeType===Ve.processingInstruction||et&&m.nodeType===Ve.comment&&ve(Ro,m.data))},xl=function(m,b){if(!Xe[b]&&pi(b)&&(le.tagNameCheck instanceof RegExp&&ve(le.tagNameCheck,b)||le.tagNameCheck instanceof Function&&le.tagNameCheck(b)))return!1;if(Rr&&!ht[b]){const N=R(m),P=S(m);if(P&&N){const q=P.length;for(let W=q-1;W>=0;--W){const fe=Ar?P[W]:p(P[W],!0);N.insertBefore(fe,_(m))}}}return St(m),!0},mi=function(m,b){if(ft(U.beforeSanitizeElements,m,null),m!==b&&R(m)===null)return!0;if(Hn(m))return St(m),!0;const N=he(I?I(m):m.nodeName);if(ft(U.uponSanitizeElement,m,{tagName:N,allowedTags:ee}),m!==b&&R(m)===null)return!0;if(gl(m,N))return St(m),!0;if(Xe[N]||!(Ie.tagCheck instanceof Function&&Ie.tagCheck(N))&&!ee[N]){const q=xl(m,N);return q===!1&&ft(U.afterSanitizeElements,m,null),q}if((z?z(m):m.nodeType)===Ve.element&&!ml(m)||(N==="noscript"||N==="noembed"||N==="noframes")&&ve(g0,m.innerHTML))return St(m),!0;if(Qe&&m.nodeType===Ve.text){const q=Bn(m.textContent);m.textContent!==q&&(Qt(t.removed,{element:m.cloneNode()}),m.textContent=q)}return ft(U.afterSanitizeElements,m,null),!1},fi=function(m,b,N){if(At[b]||et&&b==="patchsrc"||et&&b==="for"&&m!=="label"&&m!=="output"||ei&&(b==="id"||b==="name")&&(N in n||N in ll))return!1;const P=ce[b]||Ie.attributeCheck instanceof Function&&Ie.attributeCheck(b,m);if(!(We&&ve(fn,b))){if(!(He&&ve(Dn,b))){if(P){if(!Ir[b]){if(!ve(Se,yn(N,dt,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&m!=="script"&&ko(N,"data:")===0&&ri[m])){if(!(Zn&&!ve(Wt,yn(N,dt,"")))){if(N)return!1}}}}}else if(!(pi(m)&&(le.tagNameCheck instanceof RegExp&&ve(le.tagNameCheck,m)||le.tagNameCheck instanceof Function&&le.tagNameCheck(m))&&(le.attributeNameCheck instanceof RegExp&&ve(le.attributeNameCheck,b)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(b,m))||b==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&ve(le.tagNameCheck,N)||le.tagNameCheck instanceof Function&&le.tagNameCheck(N))))return!1}}return!0},bl=K({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pi=function(m){return!bl[Nn(m)]&&ve(wt,m)},_l=function(m,b,N,P){if(k&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!N)switch(h.getAttributeType(m,b)){case"TrustedHTML":return Y(P);case"TrustedScriptURL":return $e(P)}return P},vl=function(m,b,N,P){try{N?m.setAttributeNS(N,b,P):m.setAttribute(b,P),Hn(m)?St(m):vo(t.removed)}catch{zt(b,m)}},gi=function(m){ft(U.beforeSanitizeAttributes,m,null);const b=m.attributes;if(!b||Hn(m))return;const N={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ce,forceKeepAttr:void 0};let P=b.length;const q=he(m.nodeName);for(;P--;){const W=b[P],fe=W.name,Ae=W.namespaceURI,tt=W.value,Ue=he(fe),nt=tt;let Le=fe==="value"?nt:Xb(nt);if(N.attrName=Ue,N.attrValue=Le,N.keepAttr=!0,N.forceKeepAttr=void 0,ft(U.uponSanitizeAttribute,m,N),Le=N.attrValue,ti&&(Ue==="id"||Ue==="name")&&ko(Le,ni)!==0&&(zt(fe,m),Le=ni+Le),et&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Le)){zt(fe,m);continue}if(Ue==="attributename"&&yo(Le,"href")){zt(fe,m);continue}if(!N.forceKeepAttr){if(!N.keepAttr){zt(fe,m);continue}if(!gn&&ve(x0,Le)){zt(fe,m);continue}if(Qe&&(Le=Bn(Le)),!fi(q,Ue,Le)){zt(fe,m);continue}Le=_l(q,Ue,Ae,Le),Le!==nt&&vl(m,fe,Ae,Le)}}ft(U.afterSanitizeAttributes,m,null)},Wn=function(m){let b=null;const N=hi(m);for(ft(U.beforeSanitizeShadowDOM,m,null);b=N.nextNode();)if(ft(U.uponSanitizeShadowNode,b,null),mi(b,m),gi(b),Yt(b.content)&&Wn(b.content),(z?z(b):b.nodeType)===Ve.element){const q=A(b);Yt(q)&&(Ur(q),Wn(q))}ft(U.afterSanitizeShadowDOM,m,null)},Ur=function(m){const b=[{node:m,shadow:null}];for(;b.length>0;){const N=b.pop();if(N.shadow){Wn(N.shadow);continue}const P=N.node,W=(z?z(P):P.nodeType)===Ve.element,fe=S(P);if(fe)for(let Ae=fe.length-1;Ae>=0;--Ae)b.push({node:fe[Ae],shadow:null});if(W){const Ae=I?I(P):null;if(typeof Ae=="string"&&he(Ae)==="template"){const tt=P.content;Yt(tt)&&b.push({node:tt,shadow:null})}}if(W){const Ae=A(P);Yt(Ae)&&b.push({node:null,shadow:Ae},{node:Ae,shadow:null})}}};return t.sanitize=function(C){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,N=null,P=null,q=null;if(Lr=!C,Lr&&(C="<!-->"),typeof C!="string"&&!bn(C)&&(C=r0(C),typeof C!="string"))throw Lt("dirty is not a string, aborting");if(!t.isSupported)return C;D?(ee=J,ce=de):Dr(m),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(ee=Pe(ee)),U.uponSanitizeAttribute.length>0&&(ce=Pe(ce)),t.removed=[];const W=Ar&&typeof C!="string"&&bn(C);if(W){pl(C);const Ue=I?I(C):C.nodeName;if(typeof Ue=="string"){const nt=he(Ue);if(!ee[nt]||Xe[nt])throw qn(C),Lt("root node is forbidden and cannot be sanitized in-place")}if(Hn(C))throw qn(C),Lt("root node is clobbered and cannot be sanitized in-place");try{Ur(C)}catch(nt){throw qn(C),nt}}else if(bn(C))b=di("<!---->"),N=b.ownerDocument.importNode(C,!0),N.nodeType===Ve.element&&N.nodeName==="BODY"||N.nodeName==="HTML"?b=N:b.appendChild(N),Ur(N);else{if(!Fe&&!Qe&&!y&&C.indexOf("<")===-1)return k&&_t?Y(C):C;if(b=di(C),!b)return Fe?null:_t?E:""}b&&Ze&&St(b.firstChild);const fe=W?C:b,Ae=hi(fe);try{for(;P=Ae.nextNode();)mi(P,fe),gi(P),Yt(P.content)&&Wn(P.content)}catch(Ue){throw W&&(qn(C),Xt(t.removed,nt=>{nt.element&&Zr(nt.element)})),Ue}if(W)return Xt(t.removed,Ue=>{Ue.element&&Zr(Ue.element)}),Qe&&Fr(C),C;if(Fe){if(Qe&&Fr(b),bt)for(q=kt.call(b.ownerDocument);b.firstChild;)q.appendChild(b.firstChild);else q=b;return(ce.shadowroot||ce.shadowrootmode)&&(q=B.call(r,q,!0)),q}let tt=y?b.outerHTML:b.innerHTML;return y&&ee["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ve(f0,b.ownerDocument.doctype.name)&&(tt="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
342
|
-
`+tt),Qe&&(tt=Bn(tt)),k&&_t?Y(tt):tt},t.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Dr(C),D=!0,J=ee,de=ce},t.clearConfig=function(){Jt=null,D=!1,J=null,de=null,k=L,E=""},t.isValidAttribute=function(C,m,b){Jt||Dr({});const N=he(C),P=he(m);return fi(N,P,b)},t.addHook=function(C,m){typeof m=="function"&&ye(U,C)&&Qt(U[C],m)},t.removeHook=function(C,m){if(ye(U,C)){if(m!==void 0){const b=Yb(U[C],m);return b===-1?void 0:Kb(U[C],b,1)[0]}return vo(U[C])}},t.removeHooks=function(C){ye(U,C)&&(U[C]=[])},t.removeAllHooks=function(){U=Ao()},t}var Fc=Zc();function Bs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ht=Bs();function Uc(e){Ht=e}var Pt={exec:()=>null};function en(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),s=t[r];return s||(s=e(r),t[r]=s),s}}function X(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(ze.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,t)};return r}var v0=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),ze={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:en(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:en(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:en(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:en(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:en(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:en(e=>new RegExp(`^ {0,${e}}>`))},y0=/^(?:[ \t]*(?:\n|$))+/,k0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,w0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,S0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,qc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Bc=X(qc).replace(/bull/g,Hs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),j0=X(qc).replace(/bull/g,Hs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ws=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,N0=/^[^\n]+/,Vs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,T0=X(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),E0=X(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hs).getRegex(),$r="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Gs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$0=X("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n+|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n+|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n+|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Gs).replace("tag",$r).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hc=e=>X(Ws).replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$r).getRegex(),C0=Hc(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),R0=Hc(/ {0,3}(?:[*+-]|\d{1,9}[.)])[ \t]+[^ \t\n]/),A0=X(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",R0).getRegex(),Js={blockquote:A0,code:k0,def:T0,fences:w0,heading:S0,hr:Mn,html:$0,lheading:Bc,list:E0,newline:y0,paragraph:C0,table:Pt,text:N0},zo=X("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$r).getRegex(),z0={...Js,lheading:j0,table:zo,paragraph:X(Ws).replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",zo).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$r).getRegex()},I0={...Js,html:X(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gs).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Pt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:X(Ws).replace("hr",Mn).replace("heading",` *#{1,6} *[^
|
|
343
|
-
]`).replace("lheading",Bc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},L0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,O0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wc=/^( {2,}|\\)\n(?!\s*$)/,P0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mn=/[\p{P}\p{S}]/u,Cr=/[\s\p{P}\p{S}]/u,Ys=/[^\s\p{P}\p{S}]/u,M0=X(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Cr).getRegex(),Vc=/(?!~)[\p{P}\p{S}]/u,D0=/(?!~)[\s\p{P}\p{S}]/u,Z0=/(?:[^\s\p{P}\p{S}]|~)/u,F0=X(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",v0?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Gc=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,U0=X(Gc,"u").replace(/punct/g,mn).getRegex(),q0=X(Gc,"u").replace(/punct/g,Vc).getRegex(),Jc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",B0=X(Jc,"gu").replace(/notPunctSpace/g,Ys).replace(/punctSpace/g,Cr).replace(/punct/g,mn).getRegex(),H0=X(Jc,"gu").replace(/notPunctSpace/g,Z0).replace(/punctSpace/g,D0).replace(/punct/g,Vc).getRegex(),W0=X("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ys).replace(/punctSpace/g,Cr).replace(/punct/g,mn).getRegex(),V0=X(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mn).getRegex(),G0="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",J0=X(G0,"gu").replace(/notPunctSpace/g,Ys).replace(/punctSpace/g,Cr).replace(/punct/g,mn).getRegex(),Y0=X(/\\(punct)/,"gu").replace(/punct/g,mn).getRegex(),K0=X(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),X0=X(Gs).replace("(?:-->|$)","-->").getRegex(),Q0=X("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",X0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,e_=X(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",pr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yc=X(/^!?\[(label)\]\[(ref)\]/).replace("label",pr).replace("ref",Vs).getRegex(),Kc=X(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vs).getRegex(),t_=X("reflink|nolink(?!\\()","g").replace("reflink",Yc).replace("nolink",Kc).getRegex(),Io=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ks={_backpedal:Pt,anyPunctuation:Y0,autolink:K0,blockSkip:F0,br:Wc,code:O0,del:Pt,delLDelim:Pt,delRDelim:Pt,emStrongLDelim:U0,emStrongRDelimAst:B0,emStrongRDelimUnd:W0,escape:L0,link:e_,nolink:Kc,punctuation:M0,reflink:Yc,reflinkSearch:t_,tag:Q0,text:P0,url:Pt},n_={...Ks,link:X(/^!?\[(label)\]\((.*?)\)/).replace("label",pr).getRegex(),reflink:X(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pr).getRegex()},bs={...Ks,emStrongRDelimAst:H0,emStrongLDelim:q0,delLDelim:V0,delRDelim:J0,url:X(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Io).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:X(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Io).getRegex()},r_={...bs,br:X(Wc).replace("{2,}","*").getRegex(),text:X(bs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tr={normal:Js,gfm:z0,pedantic:I0},wn={normal:Ks,gfm:bs,breaks:r_,pedantic:n_},s_={"&":"&","<":"<",">":">",'"':""","'":"'"},Lo=e=>s_[e];function gt(e,t){if(t){if(ze.escapeTest.test(e))return e.replace(ze.escapeReplace,Lo)}else if(ze.escapeTestNoEncode.test(e))return e.replace(ze.escapeReplaceNoEncode,Lo);return e}function Oo(e){try{e=encodeURI(e).replace(ze.percentDecode,"%")}catch{return null}return e}function Po(e,t){var i;let n=e.replace(ze.findPipe,(a,c,l)=>{let d=!1,u=c;for(;--u>=0&&l[u]==="\\";)d=!d;return d?"|":" |"}),r=n.split(ze.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(ze.slashPipe,"|");return r}function Nt(e,t,n){let r=e.length;if(r===0)return"";let s=0;for(;s<r&&e.charAt(r-s-1)===t;)s++;return e.slice(0,r-s)}function Mo(e){let t=e.split(`
|
|
344
|
-
`),n=t.length-1;for(;n>=0&&ze.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
345
|
-
`)}function i_(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function o_(e,t=0){let n=t,r="";for(let s of e)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function Do(e,t,n,r,s){let i=t.href,a=t.title||null,c=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:c,tokens:r.inlineTokens(c)};return r.state.inLink=!1,l}function a_(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let s=r[1];return t.split(`
|
|
346
|
-
`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[c]=a;return c.length>=s.length?i.slice(s.length):i}).join(`
|
|
347
|
-
`)}var gr=class{constructor(e){re(this,"options");re(this,"rules");re(this,"lexer");this.options=e||Ht}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Mo(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=a_(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Nt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Nt(t[0],`
|
|
348
|
-
`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Nt(t[0],`
|
|
349
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Nt(t[0],`
|
|
350
|
-
`).split(`
|
|
351
|
-
`),r="",s="",i=[];for(;n.length>0;){let a=!1,c=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))c.push(n[l]),a=!0;else if(!a)c.push(n[l]);else break;n=n.slice(l);let d=c.join(`
|
|
352
|
-
`),u=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
353
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
354
|
-
${d}`:d,s=s?`${s}
|
|
355
|
-
${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=h,n.length===0)break;let f=i.at(-1);if((f==null?void 0:f.type)==="code")break;if((f==null?void 0:f.type)==="blockquote"){let p=f,g=p.raw+`
|
|
356
|
-
`+n.join(`
|
|
357
|
-
`),_=this.blockquote(g);i[i.length-1]=_,r=r.substring(0,r.length-p.raw.length)+_.raw,s=s.substring(0,s.length-p.text.length)+_.text;break}else if((f==null?void 0:f.type)==="list"){let p=f,g=p.raw+`
|
|
358
|
-
`+n.join(`
|
|
359
|
-
`),_=this.list(g);i[i.length-1]=_,r=r.substring(0,r.length-f.raw.length)+_.raw,s=s.substring(0,s.length-p.raw.length)+_.raw,n=g.substring(i.at(-1).raw.length).split(`
|
|
360
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;e;){let l=!1,d="",u="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let h=o_(t[2].split(`
|
|
361
|
-
`,1)[0],t[1].length),f=e.split(`
|
|
362
|
-
`,1)[0],p=!h.trim(),g=0;if(this.options.pedantic?(g=2,u=h.trimStart()):p?g=t[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=h.slice(g),g+=t[1].length),p&&this.rules.other.blankLine.test(f)&&(d+=f+`
|
|
363
|
-
`,e=e.substring(f.length+1),l=!0),!l){let _=this.rules.other.nextBulletRegex(g),S=this.rules.other.hrRegex(g),R=this.rules.other.fencesBeginRegex(g),A=this.rules.other.headingBeginRegex(g),$=this.rules.other.htmlBeginRegex(g),z=this.rules.other.blockquoteBeginRegex(g);for(;e;){let I=e.split(`
|
|
364
|
-
`,1)[0],k;if(f=I,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),k=f):k=f.replace(this.rules.other.tabCharGlobal," "),R.test(f)||A.test(f)||$.test(f)||z.test(f)||_.test(f)||S.test(f))break;if(k.search(this.rules.other.nonSpaceChar)>=g||!f.trim())u+=`
|
|
365
|
-
`+k.slice(g);else{if(p||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(h)||A.test(h)||S.test(h))break;u+=`
|
|
366
|
-
`+f}p=!f.trim(),d+=I+`
|
|
367
|
-
`,e=e.substring(I.length+1),h=k.slice(g)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(a=!0)),s.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),s.raw+=d}let c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let l of s.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let d=l.tokens[0];if(l.task&&((d==null?void 0:d.type)==="text"||(d==null?void 0:d.type)==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),d.raw=d.raw.replace(this.rules.other.listReplaceTask,""),d.text=d.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=h.checked,s.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1);if(!s.loose){let u=l.tokens.filter(f=>f.type==="space"),h=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));s.loose=h}}if(s.loose)for(let l of s.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Mo(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Nt(t[0],`
|
|
368
|
-
`),href:r,title:s}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Po(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
369
|
-
`):[],i={type:"table",raw:Nt(t[0],`
|
|
370
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of s)i.rows.push(Po(c,i.header.length).map((l,d)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[d]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Nt(t[0],`
|
|
371
|
-
`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
372
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Nt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=i_(t[2],"()");if(i===-2)return;if(i>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Do(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Do(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,c=s,l=0,d=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(r=d.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){c+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){l+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+l);let u=[...r[0]][0].length,h=e.slice(0,s+r.index+u+a);if(Math.min(s,a)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let f=h.slice(2,-2);return{type:"strong",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,c=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+s);(r=l.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==s))continue;if(r[3]||r[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let d=[...r[0]][0].length,u=e.slice(0,s+r.index+d+a),h=u.slice(s,-s);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,s;if(t[2]==="@")r=t[0],s="mailto:"+r;else{let i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==t[0]);r=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},it=class _s{constructor(t){re(this,"tokens");re(this,"options");re(this,"state");re(this,"inlineQueue");re(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ht,this.options.tokenizer=this.options.tokenizer||new gr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ze,block:tr.normal,inline:wn.normal};this.options.pedantic?(n.block=tr.pedantic,n.inline=wn.pedantic):this.options.gfm&&(n.block=tr.gfm,this.options.breaks?n.inline=wn.breaks:n.inline=wn.gfm),this.tokenizer.rules=n}static get rules(){return{block:tr,inline:wn}}static lex(t,n){return new _s(n).lex(t)}static lexInline(t,n){return new _s(n).inlineTokens(t)}lex(t){t=t.replace(ze.carriageReturn,`
|
|
373
|
-
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,a,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(ze.tabCharGlobal," ").replace(ze.spaceLine,""));let s=1/0;for(;t;){if(t.length<s)s=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let l;if((a=(i=this.options.extensions)==null?void 0:i.block)!=null&&a.some(u=>(l=u.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.space(t)){t=t.substring(l.raw.length);let u=n.at(-1);l.raw.length===1&&u!==void 0?u.raw+=`
|
|
374
|
-
`:n.push(l);continue}if(l=this.tokenizer.code(t)){t=t.substring(l.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
375
|
-
`)?"":`
|
|
376
|
-
`)+l.raw,u.text+=`
|
|
377
|
-
`+l.text,this.inlineQueue.at(-1).src=u.text):n.push(l);continue}if(l=this.tokenizer.fences(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.heading(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.hr(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.blockquote(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.list(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.html(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.def(t)){t=t.substring(l.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
378
|
-
`)?"":`
|
|
379
|
-
`)+l.raw,u.text+=`
|
|
380
|
-
`+l.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title},n.push(l));continue}if(l=this.tokenizer.table(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.lheading(t)){t=t.substring(l.raw.length),n.push(l);continue}let d=t;if((c=this.options.extensions)!=null&&c.startBlock){let u=1/0,h=t.slice(1),f;this.options.extensions.startBlock.forEach(p=>{f=p.call({lexer:this},h),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(d=t.substring(0,u+1))}if(this.state.top&&(l=this.tokenizer.paragraph(d))){let u=n.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
381
|
-
`)?"":`
|
|
382
|
-
`)+l.raw,u.text+=`
|
|
383
|
-
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(l),r=d.length!==t.length,t=t.substring(l.raw.length);continue}if(l=this.tokenizer.text(t)){t=t.substring(l.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
384
|
-
`)?"":`
|
|
385
|
-
`)+l.raw,u.text+=`
|
|
386
|
-
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(l);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,u,h,f,p;this.tokenizer.lexer=this;let r=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let a=!1,c="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}a||(c=""),a=!1;let g;if((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.some(S=>(g=S.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let S=n.at(-1);g.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,c)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,c)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let _=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,R=t.slice(1),A;this.options.extensions.startInline.forEach($=>{A=$.call({lexer:this},R),typeof A=="number"&&A>=0&&(S=Math.min(S,A))}),S<1/0&&S>=0&&(_=t.substring(0,S+1))}if(g=this.tokenizer.inlineText(_)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},xr=class{constructor(e){re(this,"options");re(this,"parser");this.options=e||Ht}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(ze.notSpaceStart))==null?void 0:i[0],s=e.replace(ze.endingNewline,"")+`
|
|
387
|
-
`;return r?'<pre><code class="language-'+gt(r)+'">'+(n?s:gt(s,!0))+`</code></pre>
|
|
388
|
-
`:"<pre><code>"+(n?s:gt(s,!0))+`</code></pre>
|
|
389
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
390
|
-
${this.parser.parse(e)}</blockquote>
|
|
391
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
392
|
-
`}hr(e){return`<hr>
|
|
393
|
-
`}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let c=e.items[a];r+=this.listitem(c)}let s=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
394
|
-
`+r+"</"+s+`>
|
|
395
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
396
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
397
|
-
`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let r="";for(let s=0;s<e.rows.length;s++){let i=e.rows[s];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
398
|
-
<thead>
|
|
399
|
-
`+t+`</thead>
|
|
400
|
-
`+r+`</table>
|
|
401
|
-
`}tablerow({text:e}){return`<tr>
|
|
402
|
-
${e}</tr>
|
|
403
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
404
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${gt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=Oo(e);if(s===null)return r;e=s;let i='<a href="'+e+'"';return t&&(i+=' title="'+gt(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=Oo(e);if(s===null)return gt(n);e=s;let i=`<img src="${e}" alt="${gt(n)}"`;return t&&(i+=` title="${gt(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:gt(e.text)}},Xs=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ot=class vs{constructor(t){re(this,"options");re(this,"renderer");re(this,"textRenderer");this.options=t||Ht,this.options.renderer=this.options.renderer||new xr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xs}static parse(t,n){return new vs(n).parse(t)}static parseInline(t,n){return new vs(n).parseInline(t)}parse(t){var r,s;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let a=t[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[a.type]){let l=a,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=d||"";continue}}let c=a;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let l='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(t,n=this.renderer){var s,i;this.renderer.parser=this;let r="";for(let a=0;a<t.length;a++){let c=t[a];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[c.type]){let d=this.options.extensions.renderers[c.type].call({parser:this},c);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(c.type)){r+=d||"";continue}}let l=c;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let d='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}},nr,Tn=(nr=class{constructor(e){re(this,"options");re(this,"block");this.options=e||Ht}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?it.lex:it.lexInline}provideParser(e=this.block){return e?ot.parse:ot.parseInline}},re(nr,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),re(nr,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),nr),c_=class{constructor(...e){re(this,"defaults",Bs());re(this,"options",this.setOptions);re(this,"parse",this.parseMarkdown(!0));re(this,"parseInline",this.parseMarkdown(!1));re(this,"Parser",ot);re(this,"Renderer",xr);re(this,"TextRenderer",Xs);re(this,"Lexer",it);re(this,"Tokenizer",gr);re(this,"Hooks",Tn);this.use(...e)}walkTokens(e,t){var r,s;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let a=i;for(let c of a.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of a.rows)for(let l of c)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{let a=i;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(c=>{let l=a[c].flat(1/0);n=n.concat(this.walkTokens(l,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=t.renderers[s.name];i?t.renderers[s.name]=function(...a){let c=s.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[s.level];i?i.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),r.extensions=t),n.renderer){let s=this.defaults.renderer||new xr(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,c=n.renderer[a],l=s[a];s[a]=(...d)=>{let u=c.apply(s,d);return u===!1&&(u=l.apply(s,d)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new gr(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,c=n.tokenizer[a],l=s[a];s[a]=(...d)=>{let u=c.apply(s,d);return u===!1&&(u=l.apply(s,d)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Tn;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,c=n.hooks[a],l=s[a];Tn.passThroughHooks.has(i)?s[a]=d=>{if(this.defaults.async&&Tn.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await c.call(s,d);return l.call(s,h)})();let u=c.call(s,d);return l.call(s,u)}:s[a]=(...d)=>{if(this.defaults.async)return(async()=>{let h=await c.apply(s,d);return h===!1&&(h=await l.apply(s,d)),h})();let u=c.apply(s,d);return u===!1&&(u=l.apply(s,d)),u}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(a){let c=[];return c.push(i.call(this,a)),s&&(c=c.concat(s.call(this,a))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return it.lex(e,t??this.defaults)}parser(e,t){return ot.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,c=await(s.hooks?await s.hooks.provideLexer(e):e?it.lex:it.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser(e):e?ot.parse:ot.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(i);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer(e):e?it.lex:it.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let c=(s.hooks?s.hooks.provideParser(e):e?ot.parse:ot.parseInline)(a,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
405
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},qt=new c_;function te(e,t){return qt.parse(e,t)}te.options=te.setOptions=function(e){return qt.setOptions(e),te.defaults=qt.defaults,Uc(te.defaults),te};te.getDefaults=Bs;te.defaults=Ht;te.use=function(...e){return qt.use(...e),te.defaults=qt.defaults,Uc(te.defaults),te};te.walkTokens=function(e,t){return qt.walkTokens(e,t)};te.parseInline=qt.parseInline;te.Parser=ot;te.parser=ot.parse;te.Renderer=xr;te.TextRenderer=Xs;te.Lexer=it;te.lexer=it.lex;te.Tokenizer=gr;te.Hooks=Tn;te.parse=te;te.options;te.setOptions;te.use;te.walkTokens;te.parseInline;ot.parse;it.lex;te.use({gfm:!0,breaks:!0});const l_=["p","br","hr","h1","h2","h3","h4","h5","h6","strong","em","del","code","pre","ul","ol","li","blockquote","a"],u_=["href","title","start","target","rel"];Fc.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))});function d_(e){const t=te.parse(e,{async:!1});return Fc.sanitize(t,{ALLOWED_TAGS:l_,ALLOWED_ATTR:u_})}function h_(e,t,n){if(t.status==="completed"){const r=e.findIndex(i=>i.kind==="compaction"&&i.status==="loading"),s=r>=0?e[r]:void 0;if((s==null?void 0:s.kind)==="compaction"){const i={...s,status:"completed",trigger:t.trigger??s.trigger,preTokens:t.preTokens??s.preTokens};return[...e.slice(0,r),i,...e.slice(r+1)]}}return[...e,{kind:"compaction",id:`compaction-${String(n)}`,eventIndex:n,...t}]}function Zo(e){if(e.type!=="run.item")return;const t=e.payload;return typeof(t==null?void 0:t.call_id)=="string"?t.call_id:void 0}function m_(e){const t=new Map,n=[];for(const r of e){if(r.kind!=="row"){n.push(r);continue}const{row:s}=r;if(s.event.type==="run.item"&&s.event.item_type==="tool_call"){const i=Zo(s.event);i!==void 0&&t.set(i,n.length),n.push(r);continue}if(s.event.type==="run.item"&&s.event.item_type==="tool_result"){const i=Zo(s.event),a=i===void 0?void 0:t.get(i),c=a===void 0?void 0:n[a];if((c==null?void 0:c.kind)==="row"&&c.row.status==="running"){n[a]={kind:"row",row:{...c.row,resultEventIndex:s.eventIndex,status:s.status,duration_ms:s.duration_ms,output_text:s.output_text,diff:s.diff,image:s.image}};continue}}n.push(r)}return n}function Xc(e){let t=[],n=[];const r=()=>{n.length!==0&&(t=[...t,...Cc(n).map(s=>({kind:"row",row:s}))],n=[])};for(const s of e)s.event.type==="timeline"&&s.event.item.type==="compaction"?(r(),t=h_(t,s.event.item,s.index)):s.event.type==="run.item"&&n.push(s);return r(),m_(t)}function ys(e){var t,n,r;return e.kind==="run"&&((t=e.run)==null?void 0:t.status)==="running"?Number.POSITIVE_INFINITY:e.kind==="run"&&((n=e.run)==null?void 0:n.status)!=="running"?Date.parse(((r=e.run)==null?void 0:r.ended_ts)??e.ts):Date.parse(e.ts)}function Qc(e){const t=e.flatMap(n=>{var r;return[...((r=n.run)==null?void 0:r.output_mode)==="messages"?[n.id]:[],...n.run_parent_id!==void 0?[n.run_parent_id]:[]]});return t.length>0?Math.min(...t):void 0}function Fo(e){return[...e].sort((t,n)=>{var a,c;const r=t.kind==="run"&&((a=t.run)==null?void 0:a.status)==="running",s=n.kind==="run"&&((c=n.run)==null?void 0:c.status)==="running";if(r!==s)return r?1:-1;const i=r&&s?Date.parse(t.ts)-Date.parse(n.ts):ys(t)-ys(n);return i===0?t.id-n.id:i})}function f_(e){const t=Object.values(e),n=Qc(t);return n===void 0?Fo(t):[...Fo(t.filter(r=>r.id<n)),...t.filter(r=>r.id>=n).sort((r,s)=>r.id-s.id)]}const p_=2*6e4,g_=120,x_=80,b_=300,__=48,v_=3;function Uo(e){const t=e.getBoundingClientRect();let n;for(const r of e.querySelectorAll("[data-read-seq]")){const s=r.getBoundingClientRect();if(s.height<=0)continue;const i=Math.min(s.bottom,t.bottom)-Math.max(s.top,t.top),a=Math.min(__,s.height/2);if(i<a)continue;const c=Number(r.dataset.readSeq);Number.isSafeInteger(c)&&(n=n===void 0?c:Math.max(n,c))}return n}function el(e,t){if(!(t||e.deleted===!0||e.ack===!0)&&(e.kind==="chat"||e.kind==="run"&&e.run_parent_id!==void 0||e.kind==="run"&&e.run!==void 0&&e.run.status!=="running"))return e.seq}function y_(e,t,n){const r=new Set((n==null?void 0:n.map(s=>s.id))??[]);return e.filter(s=>{var a;if((s.kind==="ask"||s.kind==="approval")&&n!==void 0&&!r.has(s.id))return!1;const i=s.run_parent_id===void 0?s:t[s.run_parent_id];return(i==null?void 0:i.ack)!==!0||((a=i.run)==null?void 0:a.output_mode)!=="messages"?!0:s.id===(i.run.result_message_id??i.id)})}function qo(e){var gn,Qe,et;const t=H(y=>ie(y,e.room)),n=t.messages,r=t.members,s=t.selfMemberId,i=t.historyCursor,a=t.hydrated,c=t.support,l=H(y=>y.connected);x.useEffect(()=>Sx(e.room),[e.room]);const d=x.useRef(null),u=x.useRef(null),h=x.useRef(!0),f=x.useRef(0),p=x.useRef(0),[g,_]=x.useState(!1),[S,R]=x.useState(0),A=x.useRef(),[$,z]=x.useState(!1),[I,k]=x.useState(!0),E=x.useRef(!1),L=x.useRef(),Q=x.useRef(),G=t.inbox,M=x.useMemo(()=>f_(n),[n]),Y=x.useMemo(()=>y_(M,n,c==null?void 0:c.interactions),[n,M,c]),$e=x.useMemo(()=>(c==null?void 0:c.interactions.filter(y=>n[y.id]===void 0))??[],[n,c]),[Ce,Re]=x.useState([]);x.useEffect(()=>{let y=!0;return Re([]),fetch(`/api/rooms/${encodeURIComponent(e.room)}/messages?pinned=1`,{headers:{authorization:`Bearer ${e.token()}`}}).then(D=>D.ok?D.json():{messages:[]}).then(D=>{y&&Re(D.messages)}).catch(()=>{}),()=>{y=!1}},[e.room,e.token]);const ut=x.useMemo(()=>{const y=new Map;for(const D of Ce)y.set(D.id,D);for(const D of M)D.pinned===!0?y.set(D.id,D):y.delete(D.id);return[...y.values()].sort((D,J)=>D.id-J.id)},[Ce,M]),De=s!==void 0?(gn=r[s])==null?void 0:gn.role:void 0,kt=De==="owner"||De==="admin",T=De==="owner"||De==="admin",B=De==="owner"||De==="admin",U=De==="owner"||De==="admin",ae=s!==void 0?(Qe=r[s])==null?void 0:Qe.handle:void 0,Ye=x.useMemo(()=>[...new Set(Y.flatMap(y=>{var D;if(y.ack===!0)return[];if(y.run_parent_id!==void 0){const J=n[y.run_parent_id]??(c==null?void 0:c.active_runs.find(de=>de.id===y.run_parent_id));return((D=J==null?void 0:J.run)==null?void 0:D.status)==="running"?[]:[y.run_parent_id]}return y.kind==="run"&&y.run!==void 0&&y.run.status!=="running"?[y.id]:[]}))],[n,c,Y]),{segments:Ke,version:fn}=$_(e.room,e.token,Ye),Dn=x.useMemo(()=>Bo(Y,Ke),[Y,Ke]),Wt=x.useRef({room:e.room,ready:!1});Wt.current.room!==e.room&&(Wt.current={room:e.room,ready:!1});const dt=Ye.every(y=>Ps(e.room,y)!==void 0);a&&dt&&(Wt.current.ready=!0);const wt=a&&Wt.current.ready,Se=x.useCallback(()=>{Q.current!==void 0&&clearTimeout(Q.current),Q.current=void 0},[]),ee=x.useCallback(()=>{const y=L.current,D=d.current;if(y===void 0||!y.merged||y.room!==e.room||D===null)return;const J=document.getElementById(y.anchorId);if(J!==null&&D.contains(J)){const de=J.getBoundingClientRect().top-D.getBoundingClientRect().top;D.scrollTop+=de-y.anchorOffset}else D.scrollTop=y.fallbackTop+D.scrollHeight-y.fallbackHeight;f.current=D.scrollTop,p.current=0},[e.room]),xt=x.useCallback(()=>{Se(),Q.current=setTimeout(()=>{ee(),L.current=void 0,E.current=!1,Q.current=void 0,z(!1)},120)},[Se,ee]),ce=x.useMemo(()=>Object.values(r).filter(y=>y.kind==="agent"&&(y.state==="running"||y.state==="queued")).sort((y,D)=>y.state==="running"!=(D.state==="running")?y.state==="running"?-1:1:y.handle.localeCompare(D.handle)),[r]),pn=x.useMemo(()=>R_((c==null?void 0:c.active_runs)??[],Object.values(n)),[c,n]);x.useEffect(()=>{const y=Y.reduce((J,de)=>Math.max(J,de.id),0);if(h.current||A.current===void 0){A.current=y;return}const D=A.current;y>D&&(R(J=>J+Y.filter(de=>de.id>D).length),A.current=y)},[Y]);const le=(et=Y.at(-1))==null?void 0:et.id;x.useEffect(()=>{const y=d.current;y&&(h.current?(y.scrollTop=y.scrollHeight,f.current=y.scrollTop,_(!1)):_(!0))},[le]);const Xe=x.useRef(0),At=x.useRef(),Ie=x.useRef(),He=x.useCallback(()=>{Ie.current!==void 0&&clearTimeout(Ie.current),Ie.current=void 0,At.current=void 0},[]),We=x.useCallback(()=>{const y=d.current;if(!wt||!l||c===void 0||document.visibilityState!=="visible"||!document.hasFocus()||y===null){He();return}const D=Uo(y);if(D===void 0||D<=Xe.current){He();return}At.current===D&&Ie.current!==void 0||(He(),At.current=D,Ie.current=setTimeout(()=>{Ie.current=void 0,At.current=void 0;const J=d.current;J===null||document.visibilityState!=="visible"||!document.hasFocus()||Uo(J)!==D||D<=Xe.current||(Xe.current=D,e.connection.act({act:"mark_room_read",through_seq:D}))},b_))},[He,l,e.connection,c,wt]);x.useEffect(()=>(Xe.current=0,He(),Se(),h.current=!0,E.current=!1,L.current=void 0,z(!1),k(!0),()=>{Se(),E.current=!1,L.current=void 0}),[Se,He,e.room]),x.useEffect(()=>{l||(Xe.current=0,He())},[He,l]),x.useEffect(()=>{const y=()=>We();window.addEventListener("focus",y),document.addEventListener("visibilitychange",y);const D=requestAnimationFrame(We);return()=>{cancelAnimationFrame(D),He(),window.removeEventListener("focus",y),document.removeEventListener("visibilitychange",y)}},[He,We]),x.useEffect(()=>{const y=requestAnimationFrame(We);return()=>cancelAnimationFrame(y)},[Dn,fn,We]),x.useEffect(()=>{const y=d.current,D=u.current;if(!y||!D)return;let J;const de=new ResizeObserver(()=>{var Ze;if(((Ze=L.current)==null?void 0:Ze.merged)===!0){Se(),J!==void 0&&cancelAnimationFrame(J),J=requestAnimationFrame(()=>{ee(),dt&&xt()});return}h.current&&(J!==void 0&&cancelAnimationFrame(J),J=requestAnimationFrame(()=>{h.current&&(y.scrollTop=y.scrollHeight,f.current=y.scrollTop,_(!1),We())}))});return de.observe(D),()=>{de.disconnect(),J!==void 0&&cancelAnimationFrame(J)}},[Se,dt,We,ee,xt]),x.useEffect(()=>{const y=()=>{h.current=!1,_(!0)};return window.addEventListener("hashchange",y),()=>window.removeEventListener("hashchange",y)},[]),x.useEffect(()=>{const y=D=>{const J=D.detail,de=d.current,Ze=document.getElementById(String(J.id));if(J.room!==e.room||de===null||Ze===null||!de.contains(Ze))return;Se();const Fe=de.getBoundingClientRect();L.current={room:e.room,anchorId:Ze.id,anchorOffset:Ze.getBoundingClientRect().top-Fe.top,fallbackHeight:de.scrollHeight,fallbackTop:de.scrollTop,merged:!0},ee(),dt&&xt()};return window.addEventListener(ps,y),()=>window.removeEventListener(ps,y)},[Se,dt,e.room,ee,xt]),x.useLayoutEffect(()=>{const y=L.current;y===void 0||!y.merged||y.room!==e.room||(Se(),ee(),dt&&xt())},[Se,fn,dt,n,e.room,ee,xt]);const Zn=()=>{var de;const y=d.current;if(!y)return;const D=y.scrollHeight-y.scrollTop-y.clientHeight,J=f.current-y.scrollTop;if(f.current=y.scrollTop,J>0?p.current+=J:J<0&&(p.current=0),D<x_?(h.current=!0,R(0),requestAnimationFrame(We)):h.current&&p.current>=g_&&(h.current=!1),_(!h.current),We(),y.scrollTop<80&&!E.current&&I&&i!==void 0&&i>1){Se(),E.current=!0,z(!0),h.current=!1,_(!0);const Ze=y.getBoundingClientRect(),Fe=[...((de=u.current)==null?void 0:de.querySelectorAll(":scope > [id]"))??[]].find(_t=>_t.getBoundingClientRect().bottom>Ze.top),bt={room:e.room,anchorId:(Fe==null?void 0:Fe.id)??"",anchorOffset:Fe===void 0?0:Fe.getBoundingClientRect().top-Ze.top,fallbackHeight:y.scrollHeight,fallbackTop:y.scrollTop,merged:!1};L.current=bt,la(e.room,{before:i,limit:In},{token:e.token()}).then(_t=>{if(L.current===bt){if(_t.messages.length===0){k(!1),Se(),L.current=void 0,E.current=!1,z(!1);return}bt.merged=!0,H.getState().mergeHistoryPage(e.room,_t.messages)}}).catch(()=>{L.current===bt&&(Se(),L.current=void 0,E.current=!1,z(!1))})}};return o.jsxs("div",{className:"nx-transcript-wrap",children:[ut.length>0&&o.jsxs("div",{className:"nx-pinned-strip","data-testid":"pinned-strip",children:[o.jsx(Ln,{size:13,"aria-hidden":"true",className:"nx-pinned-mark"}),o.jsx("ul",{className:"nx-pinned-list",children:ut.map(y=>{var D;return o.jsx("li",{children:o.jsxs("button",{type:"button",className:"nx-pinned-item","data-testid":`pinned-${y.id}`,title:y.body,onClick:()=>void qs(e.room,y.id,e.token),children:[o.jsxs("span",{className:"nx-pinned-who",children:["@",((D=r[y.author])==null?void 0:D.handle)??"…"]}),o.jsx("span",{className:"nx-pinned-snippet",children:k_(y)})]})},y.id)})})]}),o.jsx("div",{ref:d,className:"nx-transcript","data-testid":"timeline","aria-busy":$,onScroll:Zn,tabIndex:0,children:o.jsxs("div",{ref:u,className:"nx-column",children:[!wt&&o.jsx(D_,{}),wt&&Y.length===0&&o.jsx("p",{className:"nx-empty","data-testid":"timeline-empty",children:"No messages yet — say something."}),wt&&Ho(Dn,{members:r,selfId:s,selfHandle:ae,inbox:G,room:e.room,token:e.token,connection:e.connection,canPin:kt,canDelete:B,canRetry:U}),wt&&$e.length>0&&o.jsxs("section",{className:"nx-action-tray","aria-label":"Needs your response","data-testid":"interaction-tray",children:[o.jsx("p",{className:"nx-action-tray-label",children:"Needs your response"}),Ho(Bo($e,new Map),{members:r,selfId:s,selfHandle:ae,inbox:G,room:e.room,token:e.token,connection:e.connection,canPin:kt,canDelete:B,canRetry:U})]}),ce.length>0&&o.jsx("div",{className:"nx-typing-bar","data-testid":"live-activity",children:ce.map(y=>o.jsxs("span",{className:"nx-typing-agent","data-testid":`typing-${y.handle}`,children:[o.jsx(ct,{name:y.handle,accent:vt(y),size:24}),o.jsx(cb,{label:`@${y.handle} is working`}),pn[y.id]!==void 0&&o.jsx(L_,{ts:pn[y.id]}),T&&y.state==="running"&&o.jsx("button",{type:"button",className:"nx-typing-stop","aria-label":`Stop @${y.handle}`,"data-testid":`typing-stop-${y.handle}`,title:"Stop this run (the agent stays alive)",onClick:()=>e.connection.act({act:"interrupt",member_id:y.id}),children:o.jsx(pc,{size:12,"aria-hidden":"true"})})]},y.id))})]})}),g&&o.jsxs("button",{className:`nx-jump ${S===0?"is-arrow":""}`,"aria-label":S===0?"Back to latest":void 0,onClick:()=>{const y=d.current;y&&(y.scrollTop=y.scrollHeight,f.current=y.scrollTop),h.current=!0,R(0),_(!1)},children:[o.jsx(Jp,{size:14,"aria-hidden":"true"}),S>0&&`${S} new message${S===1?"":"s"}`]})]})}function k_(e){const t=e.body.split(`
|
|
406
|
-
`).find(n=>n.trim()!=="")??"";return t.length>80?`${t.slice(0,79)}…`:t||"(no text)"}function w_(e){var c,l;const{message:t,author:n}=e,r=Nr(),s=e.viewerId!==void 0&&t.mentions.some(d=>d.member_id===e.viewerId);if(t.kind==="system")return o.jsx("p",{id:String(t.id),"data-testid":`msg-${t.id}`,className:"nx-system",children:t.body});const i=(n==null?void 0:n.handle)??"…";if(t.ack===!0)return o.jsxs("p",{id:String(t.id),"data-testid":`ack-${i}`,className:"nx-system nx-ack",children:[o.jsx(Ls,{size:13,"aria-hidden":"true"})," @",i," acknowledged"]});if(t.deleted===!0)return o.jsxs("article",{id:String(t.id),"data-testid":`msg-${t.id}`,className:`nx-turn is-deleted ${e.grouped?"is-grouped":""} ${e.mine?"is-mine":""}`,children:[!e.grouped&&!r&&o.jsx(ct,{name:i,accent:n?vt(n):"indigo",size:34}),o.jsxs("div",{className:"nx-turn-main",children:[!e.grouped&&o.jsxs("div",{className:"nx-turn-meta",children:[r&&o.jsx(ct,{name:i,accent:n?vt(n):"indigo",size:24}),o.jsxs("strong",{className:"nx-turn-author",children:["@",i]}),o.jsx("time",{className:"nx-turn-time",dateTime:t.ts,children:Ut(t.ts)}),o.jsx("span",{className:"nx-turn-spacer"}),o.jsxs("a",{className:"nx-permalink",href:`#${t.id}`,children:["#",t.id]})]}),o.jsx("p",{className:"nx-deleted","data-testid":`msg-${t.id}-deleted`,children:"[deleted]"})]})]});const a=()=>{const d=t.body.split(`
|
|
407
|
-
`,1)[0]??"";window.dispatchEvent(new CustomEvent("nx-quote",{detail:{text:`@${i} > ${d}`,replyTo:t.id}}))};return o.jsxs("article",{id:String(t.id),"data-testid":t.kind==="run"?`run-${t.id}`:`msg-${t.id}`,"data-read-seq":el(t,e.mine),"data-mentions-me":s?"true":void 0,className:`nx-turn ${e.grouped?"is-grouped":""} ${e.mine?"is-mine":""} ${t.pinned===!0?"is-pinned":""} ${s?"is-mentioned":""}`,children:[!e.grouped&&!r&&o.jsx(ct,{name:i,accent:n?vt(n):"indigo",size:34}),o.jsxs("div",{className:"nx-turn-main",children:[!e.grouped&&o.jsxs("div",{className:"nx-turn-meta",children:[r&&o.jsx(ct,{name:i,accent:n?vt(n):"indigo",size:24}),o.jsxs("strong",{className:"nx-turn-author",children:["@",i]}),t.origin!==void 0&&o.jsxs("span",{className:"nx-turn-origin",title:`via ${t.origin.platform}`,children:[t.origin.sender_name," · ",t.origin.platform]}),o.jsx("time",{className:"nx-turn-time",dateTime:t.ts,children:Ut(t.ts)}),t.pinned===!0&&o.jsx(Ln,{size:12,className:"nx-pin-glyph","aria-label":"Pinned","data-testid":`msg-${t.id}-pinned`}),(n==null?void 0:n.kind)==="human"&&o.jsx(N_,{message:t,deliveries:e.deliveries,members:e.members}),o.jsx("span",{className:"nx-turn-spacer"}),o.jsxs("a",{className:"nx-permalink",href:`#${t.id}`,children:["#",t.id]}),o.jsxs("span",{className:"nx-turn-actions",children:[o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":"Quote message","data-testid":`msg-${t.id}-quote`,onClick:a,children:o.jsx(hc,{size:14,"aria-hidden":"true"})}),t.kind!=="run"&&o.jsx(tl,{text:t.body,label:"Copy message",testId:`msg-${t.id}-copy`}),e.canPin&&o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":t.pinned===!0?"Unpin message":"Pin message","aria-pressed":t.pinned===!0,"data-testid":`msg-${t.id}-pin`,onClick:()=>e.connection.act({act:"pin_message",message_id:t.id,pinned:t.pinned!==!0}),children:t.pinned===!0?o.jsx(uc,{size:14,"aria-hidden":"true"}):o.jsx(Ln,{size:14,"aria-hidden":"true"})}),e.canDelete&&t.kind==="chat"&&o.jsx(j_,{messageId:t.id,connection:e.connection}),e.canRetry&&t.kind==="run"&&(((c=t.run)==null?void 0:c.status)==="failed"||((l=t.run)==null?void 0:l.status)==="interrupted")&&o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":"Retry run","data-testid":`run-${t.id}-retry`,onClick:()=>e.connection.act({act:"retry_run",message_id:t.id}),children:o.jsx(mc,{size:14,"aria-hidden":"true"})})]})]}),t.kind==="run"?o.jsx(z_,{message:t,room:e.room,token:e.token}):t.kind==="ask"||t.kind==="approval"?o.jsx(M_,{message:t,connection:e.connection}):o.jsx(Qs,{body:t.body,highlightHandle:s?e.viewerHandle:void 0}),t.attachments!==void 0&&t.attachments.length>0&&o.jsx(S_,{room:e.room,token:e.token,attachments:t.attachments})]})]})}function S_(e){return o.jsx("div",{className:"nx-attachments","data-testid":"message-attachments",children:e.attachments.map(t=>{const n=Ab(e.room,t.id,e.token());return zb(t.mime)?o.jsx("a",{className:"nx-attach-image",href:n,target:"_blank",rel:"noreferrer","data-testid":`attachment-${t.id}`,children:o.jsx("img",{src:n,alt:t.name,loading:"lazy"})},t.id):o.jsxs("a",{className:"nx-attach-download",href:n,download:t.name,"data-testid":`attachment-${t.id}`,children:[o.jsx(cs,{size:14,"aria-hidden":"true"}),o.jsx("span",{className:"nx-attach-name",children:t.name}),o.jsx("span",{className:"nx-attach-size",children:Oc(t.size)})]},t.id)})})}function tl(e){const[t,n]=x.useState(!1);return o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":e.label,"data-testid":e.testId,onClick:()=>{var r;(r=navigator.clipboard)==null||r.writeText(e.text).then(()=>{n(!0),setTimeout(()=>n(!1),1200)})},children:t?o.jsx(Ls,{size:14,"aria-hidden":"true"}):o.jsx(pg,{size:14,"aria-hidden":"true"})})}function j_(e){const[t,n]=x.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":"Delete message","data-testid":`msg-${e.messageId}-delete`,onClick:()=>n(!0),children:o.jsx(ox,{size:14,"aria-hidden":"true"})}),t&&o.jsxs(yt,{label:"Delete message?",onClose:()=>n(!1),alert:!0,testid:"delete-confirm",children:[o.jsx("h2",{className:"nx-dialog-title",children:"Delete this message?"}),o.jsx("p",{className:"nx-dialog-body",children:"The body is purged for everyone and cannot be restored; a “[deleted]” marker stays in its place."}),o.jsxs("div",{className:"nx-dialog-actions",children:[o.jsx(qe,{variant:"quiet",onClick:()=>n(!1),children:"Cancel"}),o.jsx(qe,{variant:"danger","data-testid":"delete-confirm-go",onClick:()=>{e.connection.act({act:"delete_message",message_id:e.messageId}),n(!1)},children:"Delete"})]})]})]})}function N_(e){const t=Object.values(e.deliveries).filter(r=>{var s;return r.message_id===e.message.id&&((s=e.members[r.recipient])==null?void 0:s.kind)==="agent"});if(t.length===0)return null;const n=t.every(r=>r.state==="delivering"||r.state==="consumed");return o.jsx("span",{className:`nx-seen ${n?"is-seen":""}`,title:n?"Delivered to its agents":"Waiting in the queue","data-testid":`msg-${e.message.id}-seen`,"data-seen":n,children:n?o.jsx(ig,{size:13,"aria-hidden":"true"}):o.jsx(mg,{size:12,"aria-hidden":"true"})})}function T_(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(^|[^\\w@/])@(${n})\\b`,"gi"),'$1<strong class="nx-mention-self">@$2</strong>')}function Qs(e){const t=x.useMemo(()=>{const n=d_(e.body);return e.highlightHandle===void 0?n:T_(n,e.highlightHandle)},[e.body,e.highlightHandle]);return o.jsx("div",{className:"nx-prose",dangerouslySetInnerHTML:{__html:t}})}function nl(e){const t=[];for(const n of e){if(n.kind==="compaction"){t.push({kind:"compaction",item:n});continue}const r=n.row,s=t.at(-1);r.icon==="reasoning"||r.event.type==="run.item"&&r.event.item_type==="reasoning_summary"||(r.kind==="tool"?(s==null?void 0:s.kind)==="tools"?s.rows.push(r):t.push({kind:"tools",rows:[r]}):t.push({kind:"prose",row:r}))}return t}function E_(e){var t;if(e.kind==="prose")return e.row.ts;if(e.kind==="tools")return(t=e.rows.find(n=>n.ts!==void 0))==null?void 0:t.ts}function $_(e,t,n){const r=kc(),s=n.join(",");x.useEffect(()=>{for(const c of n)yc(e,t,c,{terminal:!0})},[e,t,s]);const i=x.useRef(new Map);return{segments:x.useMemo(()=>{let c=i.current.get(e);for(c===void 0?c=new Map:i.current.delete(e),i.current.set(e,c);i.current.size>v_;){const d=i.current.keys().next().value;if(d===void 0)break;i.current.delete(d)}const l=new Map;for(const d of n){const u=Ps(e,d);if(u===void 0)continue;const h=c.get(d);if((h==null?void 0:h.events)===u){l.set(d,h.segments);continue}const f=nl(Xc(u.map((p,g)=>({index:g,event:p}))));c.set(d,{events:u,segments:f}),l.set(d,f)}return l},[e,s,r]),version:r}}function C_(e,t,n,r){return n&&r&&e.startsWith(t)?e.slice(t.length):""}function R_(e,t){var s,i;const n={},r=new Set;for(const a of e)((s=a.run)==null?void 0:s.status)==="running"&&(r.add(a.author),n[a.author]=a.run.started_ts??a.ts);for(const a of t){if(a.kind!=="run"||((i=a.run)==null?void 0:i.status)!=="running"||r.has(a.author))continue;const c=a.run.started_ts??a.ts,l=n[a.author];(l===void 0||c>l)&&(n[a.author]=c)}return n}function A_(e,t,n){const r=e.length>0?Math.max(...e):t;return{newestId:r,terminalOwnerId:n??r}}function z_(e){var I;const t=e.message.run_parent_id??e.message.id,n=H(k=>{var L;const E=ie(k,e.room);return E.messages[t]??((L=E.support)==null?void 0:L.active_runs.find(Q=>Q.id===t))}),r=H(k=>{const E=ie(k,e.room);return Object.values(E.messages).filter(L=>L.id===t||L.run_parent_id===t).map(L=>L.id).sort((L,Q)=>L-Q).join(",")}),s=(n==null?void 0:n.run)??e.message.run,i=e.message.run_parent_id!==void 0||(s==null?void 0:s.output_mode)==="messages",a=H(k=>ie(k,e.room).runEvents[t]),c=(s==null?void 0:s.status)==="running",l=t===e.message.id,d=kc();x.useEffect(()=>{yc(e.room,e.token,t,{terminal:!c,priority:c})},[e.room,e.token,t,c]);const u=Ps(e.room,t),h=x.useMemo(()=>{const k=Kx(u,a??{events:[],dropped_count:0}),E=i?k.filter(({event:L})=>((L.type==="run.item"||L.type==="timeline"||L.type==="run.completed"?L.output_message_id:void 0)??t)===e.message.id):k;return Xc(E)},[u,a==null?void 0:a.events.length,a==null?void 0:a.dropped_count,i,e.message.id,t,d]),f=x.useMemo(()=>nl(h),[h]),p=f.some(k=>k.kind==="prose"),g=i?e.message.body:((I=e.message.run)==null?void 0:I.final_text)??e.message.body,_=f.filter(k=>k.kind==="prose").map(k=>k.row.text??"").join(""),S=C_(g,_,i,p),R=l?s==null?void 0:s.error:void 0,A=x.useMemo(()=>{const k=(u??[]).find(M=>M.type==="run.completed"),E=r===""?[]:r.split(",").map(Number),{newestId:L,terminalOwnerId:Q}=A_(E,t,(s==null?void 0:s.result_message_id)??(k==null?void 0:k.output_message_id)),G=(s==null?void 0:s.status)??(k==null?void 0:k.status);return{newestId:L,terminalOwnerId:Q,status:G}},[u,r,t,s==null?void 0:s.status,s==null?void 0:s.result_message_id]),$=e.message.id===A.terminalOwnerId&&(A.status==="interrupted"||A.status==="failed"),z=c&&f.length===0&&g.length===0&&S.length===0;return o.jsxs("div",{className:`nx-run ${z?"is-evidence-free":""}`,...A.status!==void 0&&{"data-run-status":A.status},children:[f.map((k,E)=>{var L;return k.kind==="compaction"?o.jsx(Pc,{status:k.item.status,trigger:k.item.trigger,preTokens:k.item.preTokens},k.item.id):k.kind==="prose"?o.jsx(or,{messageId:e.message.id,blockId:k.row.eventIndex,text:k.row.text??""},k.row.eventIndex):o.jsx(rl,{rows:k.rows},`tools-${((L=k.rows[0])==null?void 0:L.eventIndex)??E}`)}),!c&&!p&&g.length>0&&o.jsx(or,{messageId:e.message.id,blockId:"final",text:g}),!c&&S.length>0&&o.jsx(or,{messageId:e.message.id,blockId:"final",text:S}),!c&&R!==void 0&&R!==""&&o.jsx("p",{className:"nx-field-note is-error",role:"alert","data-testid":"run-error",children:R}),!c&&$&&o.jsxs("p",{className:`nx-run-status is-${A.status??""}`,"data-testid":`run-${e.message.id}-status`,children:["run ",A.status]})]})}function Bo(e,t){const n=Qc(e),r=n===void 0?e:e.filter(c=>c.id<n),s=n===void 0?[]:e.filter(c=>c.id>=n).sort((c,l)=>c.id-l.id),i=[];return r.forEach((c,l)=>{const d=l*1e3,u=c.kind==="run"&&c.run!==void 0&&c.run.status!=="running",h=u?t.get(c.id):void 0;if(u&&h!==void 0&&h.some(f=>f.kind==="prose")){let f=Date.parse(c.run.ended_ts??c.ts);h.forEach((p,g)=>{const _=E_(p),S=_!==void 0?Date.parse(_):f;f=S,i.push({kind:"runseg",message:c,segment:p,isLast:g===h.length-1,ts:S,order:d+g})})}else i.push({kind:"turn",message:c,ts:ys(c),order:d})}),[...i.sort((c,l)=>c.ts-l.ts||c.order-l.order),...s.map((c,l)=>({kind:"turn",message:c,ts:Date.parse(c.ts),order:(r.length+l)*1e3}))]}function Ho(e,t){var c,l;const n=[],r=new Set;let s,i=Number.NEGATIVE_INFINITY,a=0;for(;a<e.length;){const d=e[a];if(d.kind==="runseg"){const u=d.message.id,h=[];let f=!1;for(;a<e.length;){const g=e[a];if((g==null?void 0:g.kind)!=="runseg"||g.message.id!==u)break;h.push(g.segment),f=g.isLast,i=g.ts,a+=1}const p=!r.has(u);r.add(u),n.push(o.jsx(I_,{message:d.message,author:t.members[d.message.author],segments:h,isLastStretch:f,anchored:p,mine:d.message.author===t.selfId,canPin:t.canPin,canRetry:t.canRetry,connection:t.connection},`run-${u}-${d.order}`)),s=d.message.author}else{const u=d.message,f=!(u.kind==="run"&&(((c=u.run)==null?void 0:c.status)==="failed"||((l=u.run)==null?void 0:l.status)==="interrupted"))&&s!==void 0&&s===u.author&&u.kind!=="system"&&Number.isFinite(d.ts)&&Number.isFinite(i)&&d.ts-i<p_;n.push(o.jsx(w_,{message:u,author:t.members[u.author],mine:u.author===t.selfId,grouped:f,room:t.room,token:t.token,connection:t.connection,deliveries:t.inbox,members:t.members,canPin:t.canPin,canDelete:t.canDelete,canRetry:t.canRetry,viewerId:t.selfId,viewerHandle:t.selfHandle},`turn-${u.id}`)),s=u.kind==="system"?void 0:u.author,i=d.ts,a+=1}}return n}function I_(e){var l,d;const{message:t,author:n}=e,r=Nr(),s=(n==null?void 0:n.handle)??"…",i=(l=t.run)==null?void 0:l.status,a=(d=t.run)==null?void 0:d.error,c=()=>{const u=t.body.split(`
|
|
408
|
-
`,1)[0]??"";window.dispatchEvent(new CustomEvent("nx-quote",{detail:{text:`@${s} > ${u}`,replyTo:t.id}}))};return o.jsxs("article",{id:e.anchored?String(t.id):void 0,"data-testid":`run-${t.id}`,"data-read-seq":el(t,e.mine),className:`nx-turn ${e.mine?"is-mine":""}`,children:[!r&&o.jsx(ct,{name:s,accent:n?vt(n):"indigo",size:34}),o.jsxs("div",{className:"nx-turn-main",children:[o.jsxs("div",{className:"nx-turn-meta",children:[r&&o.jsx(ct,{name:s,accent:n?vt(n):"indigo",size:24}),o.jsxs("strong",{className:"nx-turn-author",children:["@",s]}),o.jsx("time",{className:"nx-turn-time",dateTime:t.ts,children:Ut(t.ts)}),e.anchored&&t.pinned===!0&&o.jsx(Ln,{size:12,className:"nx-pin-glyph","aria-label":"Pinned","data-testid":`msg-${t.id}-pinned`}),o.jsx("span",{className:"nx-turn-spacer"}),o.jsxs("a",{className:"nx-permalink",href:`#${t.id}`,children:["#",t.id]}),e.anchored&&o.jsxs("span",{className:"nx-turn-actions",children:[o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":"Quote message","data-testid":`msg-${t.id}-quote`,onClick:c,children:o.jsx(hc,{size:14,"aria-hidden":"true"})}),e.canPin&&o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":t.pinned===!0?"Unpin message":"Pin message","aria-pressed":t.pinned===!0,"data-testid":`msg-${t.id}-pin`,onClick:()=>e.connection.act({act:"pin_message",message_id:t.id,pinned:t.pinned!==!0}),children:t.pinned===!0?o.jsx(uc,{size:14,"aria-hidden":"true"}):o.jsx(Ln,{size:14,"aria-hidden":"true"})}),e.canRetry&&(i==="failed"||i==="interrupted")&&o.jsx("button",{className:"nx-iconbtn is-quiet","aria-label":"Retry run","data-testid":`run-${t.id}-retry`,onClick:()=>e.connection.act({act:"retry_run",message_id:t.id}),children:o.jsx(mc,{size:14,"aria-hidden":"true"})})]})]}),o.jsxs("div",{className:"nx-run","data-run-status":i??"running",children:[e.segments.map((u,h)=>{var f;return u.kind==="compaction"?o.jsx(Pc,{status:u.item.status,trigger:u.item.trigger,preTokens:u.item.preTokens},u.item.id):u.kind==="prose"?o.jsx(or,{messageId:t.id,blockId:u.row.eventIndex,text:u.row.text??""},u.row.eventIndex):o.jsx(rl,{rows:u.rows},`tools-${((f=u.rows[0])==null?void 0:f.eventIndex)??h}`)}),e.isLastStretch&&a!==void 0&&a!==""&&o.jsx("p",{className:"nx-field-note is-error",role:"alert","data-testid":"run-error",children:a}),e.isLastStretch&&(i==="interrupted"||i==="failed")&&o.jsxs("p",{className:`nx-run-status is-${i}`,"data-testid":`run-${t.id}-status`,children:["run ",i]})]})]})]})}function or(e){return o.jsxs("div",{className:"nx-run-block","data-testid":`run-${e.messageId}-block-${e.blockId}`,children:[o.jsx(Qs,{body:e.text}),o.jsx("span",{className:"nx-run-block-actions",children:o.jsx(tl,{text:e.text,label:"Copy run block",testId:`run-${e.messageId}-block-${e.blockId}-copy`})})]})}function L_(e){const[,t]=x.useState(0);x.useEffect(()=>{const s=setInterval(()=>t(i=>i+1),1e3);return()=>clearInterval(s)},[]);const n=Math.max(0,Date.now()-Date.parse(e.ts)),r=Math.floor(n/1e3);return o.jsx("span",{className:"nx-typing-elapsed","data-testid":"typing-elapsed","data-elapsed-ms":String(n),"aria-hidden":"true",children:Rc(r*1e3)})}function rl(e){const[t,n]=x.useState(!1);if(e.rows.length===1)return o.jsx(Wo,{row:e.rows[0]});const r=e.rows.some(l=>l.status==="running"),s=e.rows.filter(l=>{var d;return((d=l.diff)==null?void 0:d.unified)!==void 0}),i=s.reduce((l,d)=>{const{added:u,removed:h}=Fs(d.diff.unified);return{added:l.added+u,removed:l.removed+h}},{added:0,removed:0}),a=e.rows.length===1?"tool":"tools",c=[r?`Running · ${e.rows.length} ${a} so far`:`Ran ${e.rows.length} ${a}`,s.length>0?`wrote ${s.length} file${s.length===1?"":"s"} +${i.added} −${i.removed}`:void 0].filter(Boolean).join(" · ");return o.jsxs("div",{className:"nx-batch","data-testid":"tool-batch",children:[o.jsxs("button",{className:`nx-batch-line ${r?"is-active":""}`,"aria-expanded":t,onClick:()=>n(l=>!l),children:[o.jsx(ac,{size:14,"aria-hidden":"true",className:t?"is-open":""}),c]}),t&&o.jsx("div",{className:"nx-batch-cards",children:e.rows.map(l=>o.jsx(Wo,{row:l},l.eventIndex))})]})}const O_={terminal:rx,edit:Fg,search:Tr,web:Eg,commit:tn,reasoning:tn,text:tn,tool:tn,generic:tn},P_=/^\+(\d+)\s−(\d+)\s(.*)$/;function Wo(e){var d;const[t,n]=x.useState(!1),r=nb(e.row),s=O_[r.icon],i=P_.exec(r.label),a=(d=e.row.diff)==null?void 0:d.path,c=()=>{window.dispatchEvent(new CustomEvent(fs,{detail:{path:a}}))},l=e.row.status==="running"?"Running…":e.row.status==="error"?"Failed":`Done${e.row.duration_ms!==void 0?` · ${Rc(e.row.duration_ms)}`:""}`;return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:`nx-tool is-${e.row.status}`,"data-row-kind":"tool","aria-label":a!==void 0?`Open diff for ${a}`:`Inspect ${e.row.title}`,onClick:a!==void 0?c:()=>n(!0),children:[o.jsx(s,{className:"nx-tool-icon",size:14,"aria-hidden":"true"}),o.jsx("span",{className:`nx-tool-label ${r.mono?"is-mono":""}`,children:i!==null?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"nx-stat-add",children:["+",i[1]]})," ",o.jsxs("span",{className:"nx-stat-del",children:["−",i[2]]})," ",i[3]]}):r.label}),o.jsx("span",{className:`nx-tool-mark is-${e.row.status}`,children:e.row.status==="running"?o.jsx(Pn,{className:"nx-spin",size:13,"aria-label":"running"}):e.row.status==="error"?o.jsx($t,{size:13,"aria-label":"failed"}):o.jsx(Ls,{size:13,"aria-label":"done"})})]}),t&&o.jsxs(yt,{label:`Tool: ${e.row.title}`,onClose:()=>n(!1),wide:!0,testid:"run-inspector",children:[o.jsxs("div",{className:"nx-inspect-head",children:[o.jsx("h2",{className:"nx-dialog-title",children:e.row.title}),o.jsx("span",{className:`nx-tool-status is-${e.row.status}`,children:l})]}),e.row.detail!==void 0&&o.jsx("p",{className:"nx-inspect-detail",children:e.row.detail}),e.row.event.type==="run.item"&&e.row.event.item_type==="tool_call"&&o.jsx("pre",{className:"nx-inspect-block",children:JSON.stringify(e.row.event.payload,null,2)}),e.row.output_text!==void 0&&e.row.output_text!==""&&o.jsx("pre",{className:"nx-inspect-block","data-testid":"inspector-output",children:e.row.output_text})]})]})}function M_(e){const t=e.message.ask,[n,r]=x.useState([]),[s,i]=x.useState(!1);if(!t)return o.jsx(Qs,{body:e.message.body});const a=c=>{e.connection.act({act:"answer_interaction",interaction_id:t.interaction_id,answer:c}),i(!0)};return o.jsxs("div",{className:"nx-ask","data-testid":`ask-${e.message.id}`,children:[o.jsxs("div",{className:"nx-ask-head",children:[o.jsx("span",{className:"nx-ask-kind",children:t.kind==="approval"?"Approval needed":"Question"}),t.tool!==void 0&&o.jsx("code",{className:"nx-code",children:t.tool})]}),o.jsx("p",{className:"nx-ask-prompt",children:t.prompt}),t.detail!==void 0&&o.jsx("pre",{className:"nx-ask-detail",children:t.detail}),t.options!==void 0&&t.options.length>0&&o.jsxs("div",{className:"nx-ask-options",children:[t.options.map(c=>o.jsx("button",{className:`nx-btn ${t.multi===!0&&n.includes(c.label)?"is-primary":""}`,disabled:s,title:c.description,"data-testid":`ask-${e.message.id}-${c.label}`,onClick:()=>{t.multi===!0?r(l=>l.includes(c.label)?l.filter(d=>d!==c.label):[...l,c.label]):a(c.label)},children:c.label},c.label)),t.multi===!0&&o.jsx("button",{className:"nx-btn is-primary",disabled:s||n.length===0,onClick:()=>a(n),children:"Send answer"})]}),s&&o.jsx("p",{className:"nx-ask-sent",children:"Answered — waiting for the agent…"})]})}function D_(){return o.jsx("div",{className:"nx-skeleton","aria-hidden":"true",children:[0,1,2].map(e=>o.jsxs("div",{className:"nx-skeleton-row",children:[o.jsx("span",{className:"nx-skeleton-chip"}),o.jsxs("span",{className:"nx-skeleton-lines",children:[o.jsx("span",{style:{width:"38%"}}),o.jsx("span",{style:{width:"86%"}}),o.jsx("span",{style:{width:"64%"}})]})]},e))})}function Z_(e){const t=Lp(e.token),[n,r]=x.useState(e.room),s=x.useRef(null);s.current===null&&(s.current=vx({room:e.room,token:e.token,refreshToken:e.refreshToken,onResume:g=>{jx(g,t)}}));const i=s.current,a=g=>{g!==n&&(i.switchRoom(g),r(g),hr(g),window.history.pushState(null,"",`/?room=${encodeURIComponent(g)}`))};x.useEffect(()=>()=>{var g;(g=s.current)==null||g.dispose()},[]),x.useEffect(()=>{const g=()=>{const _=nc().room;_!==void 0&&(i.switchRoom(_),r(_),hr(_))};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[]);const c=Nr(),[l,d]=x.useState("room"),[u,h]=x.useState(!1),[f,p]=x.useState(!1);return x.useEffect(()=>{if(!f)return;const g=window.matchMedia("(min-width: 720px) and (max-width: 1360px)"),_=()=>{g.matches||p(!1)};return g.addEventListener("change",_),_(),()=>g.removeEventListener("change",_)},[f]),c?o.jsxs("div",{className:"nx-app is-mobile","data-testid":"app","data-surface":l,children:[l==="channels"?o.jsx(Vo,{activeRoom:n,token:t,onSwitch:g=>{a(g),d("room")}}):o.jsx(Go,{room:n,connection:i,token:t,mobile:{onBack:()=>d("channels"),onContext:()=>h(!0)}}),u&&l==="room"&&o.jsxs("div",{className:"nx-mobile-context","data-testid":"mobile-context",children:[o.jsx("button",{className:"nx-mobile-context-close nx-btn",onClick:()=>h(!1),children:"Close"}),o.jsx(Gr,{room:n,token:t,connection:i})]})]}):o.jsxs("div",{className:"nx-app","data-testid":"app",children:[o.jsx(Vo,{activeRoom:n,token:t,onSwitch:a}),o.jsx(Go,{room:n,connection:i,token:t,onContext:()=>p(!0)}),o.jsx(Gr,{room:n,token:t,connection:i}),f&&o.jsx(yt,{label:"Channel context",testid:"responsive-context",onClose:()=>p(!1),children:o.jsxs("div",{className:"nx-responsive-context-shell",children:[o.jsxs("header",{className:"nx-responsive-context-head",children:[o.jsx("h2",{children:"Channel context"}),o.jsx(ke,{icon:$t,label:"Close channel context",variant:"quiet",onClick:()=>p(!1)})]}),o.jsx(Gr,{room:n,token:t,connection:i})]})})]})}function Vo(e){const[t,n]=x.useState(!1),r=Mp(e.token),s=H(p=>p.connected),i=H(p=>p.rooms),a=H(p=>ie(p,e.activeRoom)),c=a.room,l=a.members,d=a.selfMemberId;Pp();const u=d!==void 0?l[d]:void 0,h=x.useMemo(()=>Object.fromEntries(Object.entries(i).map(([p,g])=>[p,Object.values(g.members).filter(_=>_.kind==="agent"&&(_.state==="running"||_.state==="queued")).sort((_,S)=>_.handle.localeCompare(S.handle))])),[i]),f=x.useMemo(()=>{const p=r.length>0?[...r]:c!==void 0?[{id:c.id,name:c.name,created_ts:c.created_ts,working:!1,attention:!1,unread:0}]:[],g=_=>{var S;return Date.parse(((S=_.latest)==null?void 0:S.ts)??_.created_ts)||0};return p.sort((_,S)=>{var $,z;const R=((($=h[_.id])==null?void 0:$.length)??0)>0||_.working,A=(((z=h[S.id])==null?void 0:z.length)??0)>0||S.working;return R!==A?R?-1:1:g(S)-g(_)})},[r,c,h]);return o.jsxs("nav",{className:"nx-rail","aria-label":"Channels",children:[o.jsxs("div",{className:"nx-brand",children:[o.jsx("span",{className:"nx-brand-tile","aria-hidden":"true"}),o.jsx("strong",{children:"Codor"})]}),o.jsxs("div",{className:"nx-rail-search",children:[o.jsx(Tr,{size:15,"aria-hidden":"true"}),o.jsx("input",{type:"search",placeholder:"Search","aria-label":"Search channels"})]}),o.jsxs("div",{className:"nx-rail-label",children:[o.jsx(Us,{children:"Channels"}),o.jsx(ke,{icon:dc,label:"Create channel",size:"sm",variant:"quiet","data-testid":"create-room",onClick:()=>n(!0)})]}),o.jsx("ul",{className:"nx-rail-list",children:f.map(p=>{var I;const g=p.id===e.activeRoom,_=h[p.id]??[],S=_.length>0||p.working,R=_.length===1?`@${_[0].handle} is working…`:_.length>1?`${String(_.length)} agents are working…`:"working…",A=p.unread,$=(I=p.latest)==null?void 0:I.ts,z=F_(p);return o.jsx("li",{children:o.jsxs("a",{className:`nx-row ${g?"is-active":""}`,href:`/?room=${encodeURIComponent(p.id)}`,"aria-current":g?"page":void 0,"data-testid":`room-link-${p.id}`,onClick:k=>{k.metaKey||k.ctrlKey||k.shiftKey||(k.preventDefault(),e.onSwitch(p.id))},children:[o.jsx(ct,{name:p.name,accent:"indigo",size:38,presence:p.attention?"error":S?"live":g&&!s?"error":"idle",surface:g?"raised":"surface"}),o.jsxs("span",{className:"nx-row-main",children:[o.jsxs("span",{className:"nx-row-top",children:[o.jsx("span",{className:"nx-row-name",children:p.name}),$!==void 0&&o.jsx("time",{className:"nx-row-time",children:sb($)})]}),o.jsxs("span",{className:"nx-row-bottom",children:[S?o.jsxs("span",{className:"nx-row-working","data-testid":`room-working-${p.id}`,children:[o.jsxs("span",{className:"nx-typing","aria-hidden":"true",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]}),R]}):p.attention?o.jsx("span",{className:"nx-row-preview is-error",children:"agent needs attention"}):o.jsx("span",{className:"nx-row-preview",children:z}),A>0&&o.jsx("span",{className:"nx-unread","data-testid":`rail-unread-${p.id}`,children:A>99?"99+":A})]})]})]})},p.id)})}),o.jsxs("footer",{className:"nx-rail-footer",children:[o.jsx(ct,{name:(u==null?void 0:u.display_name)??(u==null?void 0:u.handle)??"You",accent:"user",size:32}),o.jsxs("span",{className:"nx-rail-id",children:[o.jsx("strong",{children:(u==null?void 0:u.display_name)??(u==null?void 0:u.handle)??"—"}),o.jsxs("span",{className:`nx-conn ${s?"is-live":"is-error"}`,"data-testid":"connection",title:s?"connected":"reconnecting",children:[o.jsx("span",{className:"nx-conn-dot","aria-hidden":"true"}),s?"Connected":"Reconnecting…"]})]}),o.jsx(ke,{icon:fc,label:"Settings",variant:"quiet",onClick:()=>{window.location.href=`/settings?room=${e.activeRoom}`}})]}),t&&o.jsx(Ob,{token:e.token,onClose:()=>n(!1),onCreated:p=>{n(!1),e.onSwitch(p.id)}})]})}function F_(e){if(!e.latest)return"No messages yet";const t=e.latest.author_handle===""?"…":`@${e.latest.author_handle}`,n=e.latest.preview!==""?e.latest.preview:e.latest.kind==="run"?"run in progress":"…";return`${t}: ${n}`}function Go(e){const t=H(l=>ie(l,e.room).room),n=H(l=>ie(l,e.room).meter),r=H(l=>l.connected),s=H(l=>Object.values(ie(l,e.room).members).filter(d=>d.removed_ts===void 0&&(d.kind==="human"||d.kind==="agent")).length),i=H(l=>{var d;return(d=Object.values(ie(l,e.room).members).find(u=>u.kind==="agent"&&(u.state==="running"||u.state==="queued")))==null?void 0:d.handle}),[a,c]=x.useState(!1);return e.mobile?o.jsxs("main",{className:"nx-chat","data-testid":"room-view",children:[o.jsxs("header",{className:"nx-mobile-head",children:[o.jsx(ke,{icon:cg,label:"Back to channels","data-testid":"mobile-back",onClick:e.mobile.onBack}),o.jsxs("div",{className:"nx-mobile-title",children:[o.jsx("h1",{children:(t==null?void 0:t.name)??e.room}),o.jsx("span",{className:"nx-mobile-sub",children:i!==void 0?`@${i} is working…`:r?"live":"reconnecting…"})]}),o.jsx(ke,{icon:cc,label:"Channel details","data-testid":"mobile-kebab",onClick:e.mobile.onContext})]}),o.jsx(xo,{room:e.room,connection:e.connection}),o.jsx(qo,{room:e.room,token:e.token,connection:e.connection}),o.jsx(go,{room:e.room,token:e.token,connection:e.connection})]}):o.jsxs("main",{className:"nx-chat","data-testid":"room-view",children:[o.jsxs("header",{className:"nx-chat-header",children:[o.jsxs("div",{className:"nx-chat-id",children:[o.jsxs("div",{className:"nx-chat-title",children:[o.jsx("h1",{children:(t==null?void 0:t.name)??e.room}),o.jsx(Ac,{tone:r?"live":"error",children:r?"Live":"Offline"})]}),o.jsxs("p",{className:"nx-chat-stats","data-testid":"meter",children:[s," members · ",(n==null?void 0:n.turns)??0," turns · ",un(((n==null?void 0:n.input_tokens)??0)+((n==null?void 0:n.output_tokens)??0))," tokens · ",Ic(n??{cost_usd:0})," today"]})]}),o.jsxs("div",{className:"nx-chat-actions",children:[o.jsx(ke,{icon:cx,label:"Open members and context","data-testid":"responsive-context-trigger",className:"nx-context-trigger",onClick:e.onContext}),o.jsx(ke,{icon:Tr,label:"Search messages","data-testid":"toggle-message-search",onClick:()=>c(!0)}),o.jsx(Mb,{room:e.room,connection:e.connection,token:e.token}),o.jsx(ke,{icon:tx,label:"Open ledger graph",onClick:()=>{window.location.href=`/ledger?room=${e.room}`}}),o.jsx(ke,{icon:fc,label:"Channel settings","data-testid":"room-settings",onClick:()=>{window.location.href=`/settings?room=${e.room}`}})]})]}),o.jsx(xo,{room:e.room,connection:e.connection}),o.jsx(qo,{room:e.room,token:e.token,connection:e.connection}),o.jsx(go,{room:e.room,token:e.token,connection:e.connection}),a&&o.jsx(Zb,{room:e.room,token:e.token,onClose:()=>c(!1)})]})}ea();const sl=document.querySelector("#root");if(!sl)throw new Error("missing #root element");const U_=sl;function Jo(e,t){const n=new URL(window.location.href);n.searchParams.get("room")!==t&&(n.searchParams.set("room",t),window.history.replaceState(null,"",`${e}${n.search}${n.hash}`))}async function Yo(e,t,n){if(e==="/settings"){const{SettingsPage:r}=await Ot(async()=>{const{SettingsPage:s}=await import("./SettingsPage-DGLbSXE7.js");return{SettingsPage:s}},__vite__mapDeps([0,1,2,3,4,5]));return o.jsx(r,{room:t,token:n,refreshToken:os})}if(e==="/ledger"){const{LedgerPage:r}=await Ot(async()=>{const{LedgerPage:s}=await import("./LedgerPage-CecuTS8-.js");return{LedgerPage:s}},__vite__mapDeps([6,4,7,2,5]));return o.jsx(r,{room:t,token:n})}return o.jsx(Z_,{room:t,token:n,refreshToken:os})}async function q_(){const e=await os();e!==""&&await fx(e);const t=window.location.pathname,n=`${t}${window.location.search}${window.location.hash}`,r=await(async()=>{if(t==="/pair"){const{PairingPage:l}=await Ot(async()=>{const{PairingPage:d}=await import("./PairingPage-CQBWNA2L.js");return{PairingPage:d}},__vite__mapDeps([8,1,2,3,9,5]));return o.jsx(l,{})}if(e===""){if(t==="/"){const{LandingPage:d}=await Ot(async()=>{const{LandingPage:u}=await import("./LandingPage-BOmG5kSw.js");return{LandingPage:u}},__vite__mapDeps([10,9,2,5]));return o.jsx(d,{})}const{PairingPage:l}=await Ot(async()=>{const{PairingPage:d}=await import("./PairingPage-CQBWNA2L.js");return{PairingPage:d}},__vite__mapDeps([8,1,2,3,9,5]));return o.jsx(l,{autoPair:!0,returnTo:n})}const s=nc().room,i=await Fp(e).catch(()=>{});if(i===void 0){const l=s??Qn();if(l===void 0){const{StartupUnavailable:d}=await Ot(async()=>{const{StartupUnavailable:u}=await import("./StartupUnavailable-DdQBHip_.js");return{StartupUnavailable:u}},__vite__mapDeps([11,2,5]));return o.jsx(d,{})}return hr(l),Jo(t,l),Yo(t,l,e)}const a=Dp(i,{explicit:s,remembered:Qn()});if(a===void 0){Qn()!==void 0&&Xi();const{NoChannels:l}=await Ot(async()=>{const{NoChannels:d}=await import("./NoChannels-CYiBXGQd.js");return{NoChannels:d}},__vite__mapDeps([12,2,5]));return o.jsx(l,{token:e})}const c=Qn();return c!==void 0&&!i.some(l=>l.id===c)&&Xi(),hr(a),Jo(t,a),Yo(t,a,e)})();$l.createRoot(U_).render(o.jsx(x.StrictMode,{children:o.jsx(xx,{children:r})}))}const Sn=new URL(window.location.href);Sn.searchParams.has("_codor_update")&&(Sn.searchParams.delete("_codor_update"),window.history.replaceState(null,"",`${Sn.pathname}${Sn.search}${Sn.hash}`));q_();"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/",type:"module",updateViaCache:"none"}).catch(()=>{})});export{Af as A,qe as B,lo as C,fr as D,ln as E,Ef as F,$c as G,Ds as H,ke as I,Zs as J,kg as K,ql as L,Og as M,Er as N,Ul as O,ab as S,ox as T,$t as X,x as a,Ll as b,V as c,vx as d,Rl as e,ev as f,ws as g,ie as h,Ut as i,o as j,yt as k,nv as l,Q_ as m,Y_ as n,ea as o,X_ as p,sv as q,tv as r,V_ as s,rv as t,H as u,J_ as v,Ls as w,G_ as x,K_ as y,pg as z};
|