salidium 0.4.0 → 0.5.0

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.
@@ -0,0 +1,78 @@
1
+ import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,n,t as r}from"./react-runtime-DfSeidf4.js";import{n as i,t as a}from"./ui-runtime-C1c-P_PN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var o;function s(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var c=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},l=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(o=globalThis).__zod_globalConfig??(o.__zod_globalConfig={});var u=globalThis.__zod_globalConfig;function d(e){return e&&Object.assign(u,e),u}function f(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function p(e,t){return typeof t==`bigint`?t.toString():t}function m(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function h(e){return e==null}function g(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var v=Symbol(`evaluating`);function y(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==v)return r===void 0&&(r=v,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function b(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function x(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function S(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=m(()=>{if(u.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function re(e){if(ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return ne(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ie(e){return re(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ae=new Set([`string`,`number`,`symbol`]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function se(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ce(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return se(e,x(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return b(this,`shape`,e),e},checks:[]}))}function de(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return se(e,x(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return b(this,`shape`,r),r},checks:[]}))}function fe(e,t){if(!re(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return b(this,`shape`,n),n}}))}function pe(e,t){if(!re(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return b(this,`shape`,n),n}}))}function me(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return b(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function he(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return se(t,x(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return b(this,`shape`,i),i},checks:[]}))}function ge(e,t,n){return se(t,x(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return b(this,`shape`,i),i}}))}function _e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ve(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ye(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function be(e){return typeof e==`string`?e:e?.message}function xe(e,t,n){let r=e.message?e.message:be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Se(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ce(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var we=(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,p,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Te=s(`$ZodError`,we),Ee=s(`$ZodError`,we,{Parent:Error});function De(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Oe(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var T=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new c;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>xe(e,a,d())));throw te(t,i?.callee),t}return o.value},ke=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>xe(e,a,d())));throw te(t,i?.callee),t}return o.value},Ae=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new c;return a.issues.length?{success:!1,error:new(e??Te)(a.issues.map(e=>xe(e,i,d())))}:{success:!0,data:a.value}},je=Ae(Ee),Me=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>xe(e,i,d())))}:{success:!0,data:a.value}},Ne=Me(Ee),Pe=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return T(e)(t,n,i)},Fe=e=>(t,n,r)=>T(e)(t,n,r),Ie=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ke(e)(t,n,i)},Le=e=>async(t,n,r)=>ke(e)(t,n,r),Re=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ae(e)(t,n,i)},ze=e=>(t,n,r)=>Ae(e)(t,n,r),Be=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Me(e)(t,n,i)},Ve=e=>async(t,n,r)=>Me(e)(t,n,r),He=/^[cC][0-9a-z]{6,}$/,Ue=/^[0-9a-z]+$/,We=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ge=/^[0-9a-vA-V]{20}$/,Ke=/^[A-Za-z0-9]{27}$/,qe=/^[a-zA-Z0-9_-]{21}$/,Je=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ye=/^([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})$/,Xe=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ze=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Qe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function $e(){return new RegExp(Qe,`u`)}var et=/^(?:(?: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])$/,tt=/^(([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}|:))$/,nt=/^((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])$/,rt=/^(([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])$/,it=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,at=/^[A-Za-z0-9_-]*$/,ot=/^https?$/,st=/^\+[1-9]\d{6,14}$/,ct=`(?:(?:\\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])))`,lt=RegExp(`^${ct}$`);function ut(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function dt(e){return RegExp(`^${ut(e)}$`)}function ft(e){let t=ut({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ct}T(?:${r})$`)}var pt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},mt=/^-?\d+$/,ht=/^-?\d+(?:\.\d+)?$/,gt=/^(?:true|false)$/i,_t=/^null$/i,vt=/^[^A-Z]*$/,yt=/^[^a-z]*$/,bt=s(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),xt={number:`number`,bigint:`bigint`,object:`date`},St=s(`$ZodCheckLessThan`,(e,t)=>{bt.init(e,t);let n=xt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin: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})}}),Ct=s(`$ZodCheckGreaterThan`,(e,t)=>{bt.init(e,t);let n=xt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin: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})}}),wt=s(`$ZodCheckMultipleOf`,(e,t)=>{bt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):_(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})}}),Tt=s(`$ZodCheckNumberFormat`,(e,t)=>{bt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=le[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=mt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Et=s(`$ZodCheckMaxLength`,(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Se(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Dt=s(`$ZodCheckMinLength`,(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Se(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ot=s(`$ZodCheckLengthEquals`,(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Se(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),kt=s(`$ZodCheckStringFormat`,(e,t)=>{var n,r;bt.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),At=s(`$ZodCheckRegex`,(e,t)=>{kt.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})}}),jt=s(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=vt,kt.init(e,t)}),Mt=s(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=yt,kt.init(e,t)}),Nt=s(`$ZodCheckIncludes`,(e,t)=>{bt.init(e,t);let n=oe(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Pt=s(`$ZodCheckStartsWith`,(e,t)=>{bt.init(e,t);let n=RegExp(`^${oe(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ft=s(`$ZodCheckEndsWith`,(e,t)=>{bt.init(e,t);let n=RegExp(`.*${oe(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),It=s(`$ZodCheckOverwrite`,(e,t)=>{bt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Lt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
+ `))}},Rt={major:4,minor:4,patch:3},E=s(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Rt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=_e(e),i;for(let a of t){if(a._zod.def.when){if(ve(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new c;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=_e(e,t))});else{if(e.issues.length===t)continue;r||=_e(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(_e(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new c;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new c;return o.then(e=>t(e,r,a))}return t(o,r,a)}}y(e,`~standard`,()=>({validate:t=>{try{let n=je(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ne(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),zt=s(`$ZodString`,(e,t)=>{E.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??pt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),D=s(`$ZodStringFormat`,(e,t)=>{kt.init(e,t),zt.init(e,t)}),Bt=s(`$ZodGUID`,(e,t)=>{t.pattern??=Ye,D.init(e,t)}),Vt=s(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Xe(e)}else t.pattern??=Xe();D.init(e,t)}),Ht=s(`$ZodEmail`,(e,t)=>{t.pattern??=Ze,D.init(e,t)}),Ut=s(`$ZodURL`,(e,t)=>{D.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===ot.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);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})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Wt=s(`$ZodEmoji`,(e,t)=>{t.pattern??=$e(),D.init(e,t)}),Gt=s(`$ZodNanoID`,(e,t)=>{t.pattern??=qe,D.init(e,t)}),Kt=s(`$ZodCUID`,(e,t)=>{t.pattern??=He,D.init(e,t)}),qt=s(`$ZodCUID2`,(e,t)=>{t.pattern??=Ue,D.init(e,t)}),Jt=s(`$ZodULID`,(e,t)=>{t.pattern??=We,D.init(e,t)}),Yt=s(`$ZodXID`,(e,t)=>{t.pattern??=Ge,D.init(e,t)}),Xt=s(`$ZodKSUID`,(e,t)=>{t.pattern??=Ke,D.init(e,t)}),Zt=s(`$ZodISODateTime`,(e,t)=>{t.pattern??=ft(t),D.init(e,t)}),Qt=s(`$ZodISODate`,(e,t)=>{t.pattern??=lt,D.init(e,t)}),$t=s(`$ZodISOTime`,(e,t)=>{t.pattern??=dt(t),D.init(e,t)}),en=s(`$ZodISODuration`,(e,t)=>{t.pattern??=Je,D.init(e,t)}),tn=s(`$ZodIPv4`,(e,t)=>{t.pattern??=et,D.init(e,t),e._zod.bag.format=`ipv4`}),nn=s(`$ZodIPv6`,(e,t)=>{t.pattern??=tt,D.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})}}}),rn=s(`$ZodCIDRv4`,(e,t)=>{t.pattern??=nt,D.init(e,t)}),an=s(`$ZodCIDRv6`,(e,t)=>{t.pattern??=rt,D.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function on(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var sn=s(`$ZodBase64`,(e,t)=>{t.pattern??=it,D.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{on(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function cn(e){if(!at.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return on(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var ln=s(`$ZodBase64URL`,(e,t)=>{t.pattern??=at,D.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{cn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),un=s(`$ZodE164`,(e,t)=>{t.pattern??=st,D.init(e,t)});function dn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var fn=s(`$ZodJWT`,(e,t)=>{D.init(e,t),e._zod.check=n=>{dn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),pn=s(`$ZodNumber`,(e,t)=>{E.init(e,t),e._zod.pattern=e._zod.bag.pattern??ht,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),mn=s(`$ZodNumberFormat`,(e,t)=>{Tt.init(e,t),pn.init(e,t)}),hn=s(`$ZodBoolean`,(e,t)=>{E.init(e,t),e._zod.pattern=gt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),gn=s(`$ZodNull`,(e,t)=>{E.init(e,t),e._zod.pattern=_t,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),_n=s(`$ZodUnknown`,(e,t)=>{E.init(e,t),e._zod.parse=e=>e}),vn=s(`$ZodNever`,(e,t)=>{E.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function yn(e,t,n){e.issues.length&&t.issues.push(...ye(n,e.issues)),t.value[n]=e.value}var bn=s(`$ZodArray`,(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>yn(t,n,e))):yn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function xn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ye(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Sn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ce(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Cn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>xn(e,n,i,t,u,d))):xn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var wn=s(`$ZodObject`,(e,t)=>{if(E.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=m(()=>Sn(t));y(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ne,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>xn(n,t,e,s,r,i))):xn(a,t,e,s,r,i)}return i?Cn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Tn=s(`$ZodObjectJIT`,(e,t)=>{wn.init(e,t);let n=e._zod.parse,r=m(()=>Sn(t)),i=e=>{let t=new Lt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=S(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=S(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
+ if (${n}.issues.length) {
5
+ if (${o} in input) {
6
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${n}.value === undefined) {
14
+ if (${o} in input) {
15
+ newResult[${o}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${o}] = ${n}.value;
19
+ }
20
+
21
+ `):c?t.write(`
22
+ if (${n}.issues.length) {
23
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
26
+ })));
27
+ }
28
+
29
+ if (${n}.value === undefined) {
30
+ if (${o} in input) {
31
+ newResult[${o}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${o}] = ${n}.value;
35
+ }
36
+
37
+ `):t.write(`
38
+ const ${n}_present = ${o} in input;
39
+ if (${n}.issues.length) {
40
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
41
+ ...iss,
42
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
43
+ })));
44
+ }
45
+ if (!${n}_present && !${n}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${o}]
51
+ });
52
+ }
53
+
54
+ if (${n}_present) {
55
+ if (${n}.value === undefined) {
56
+ newResult[${o}] = undefined;
57
+ } else {
58
+ newResult[${o}] = ${n}.value;
59
+ }
60
+ }
61
+
62
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ne,s=!u.jitless,c=s&&C.value,l=t.catchall,d;e._zod.parse=(u,f)=>{d??=r.value;let p=u.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),u=a(u,f),l?Cn([],p,u,f,d,e):u):n(u,f):(u.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),u)}});function En(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!_e(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>xe(e,r,d())))}),t)}var Dn=s(`$ZodUnion`,(e,t)=>{E.init(e,t),y(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),y(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),y(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),y(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>g(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>En(t,r,e,i)):En(o,r,e,i)}}),On=s(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Dn.init(e,t);let n=e._zod.parse;y(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=m(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ne(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),kn=s(`$ZodIntersection`,(e,t)=>{E.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>jn(e,t,n)):jn(e,i,a)}});function An(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(re(e)&&re(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=An(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=An(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function jn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),_e(e))return e;let o=An(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Mn=s(`$ZodRecord`,(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!re(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>xe(e,r,d())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ye(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ye(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ht.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xe(e,r,d())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ye(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ye(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Nn=s(`$ZodEnum`,(e,t)=>{E.init(e,t);let n=f(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?oe(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Pn=s(`$ZodLiteral`,(e,t)=>{if(E.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?oe(e):e?oe(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Fn=s(`$ZodTransform`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new l(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new c;return n.value=i,n.fallback=!0,n}});function In(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ln=s(`$ZodOptional`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,y(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),y(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${g(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>In(e,r)):In(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Rn=s(`$ZodExactOptional`,(e,t)=>{Ln.init(e,t),y(e._zod,`values`,()=>t.innerType._zod.values),y(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),zn=s(`$ZodNullable`,(e,t)=>{E.init(e,t),y(e._zod,`optin`,()=>t.innerType._zod.optin),y(e._zod,`optout`,()=>t.innerType._zod.optout),y(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${g(e.source)}|null)$`):void 0}),y(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Bn=s(`$ZodDefault`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,y(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Vn(e,t)):Vn(r,t)}});function Vn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hn=s(`$ZodPrefault`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,y(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Un=s(`$ZodNonOptional`,(e,t)=>{E.init(e,t),y(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Wn(t,e)):Wn(i,e)}});function Wn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Gn=s(`$ZodCatch`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,y(e._zod,`optout`,()=>t.innerType._zod.optout),y(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>xe(e,n,d()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>xe(e,n,d()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Kn=s(`$ZodPipe`,(e,t)=>{E.init(e,t),y(e._zod,`values`,()=>t.in._zod.values),y(e._zod,`optin`,()=>t.in._zod.optin),y(e._zod,`optout`,()=>t.out._zod.optout),y(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>qn(e,t.in,n)):qn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>qn(e,t.out,n)):qn(r,t.out,n)}});function qn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Jn=s(`$ZodReadonly`,(e,t)=>{E.init(e,t),y(e._zod,`propValues`,()=>t.innerType._zod.propValues),y(e._zod,`values`,()=>t.innerType._zod.values),y(e._zod,`optin`,()=>t.innerType?._zod?.optin),y(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Yn):Yn(r)}});function Yn(e){return e.value=Object.freeze(e.value),e}var Xn=s(`$ZodCustom`,(e,t)=>{bt.init(e,t),E.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Zn(t,n,r,e));Zn(i,n,r,e)}});function Zn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ce(e))}}var Qn,$n=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function er(){return new $n}(Qn=globalThis).__zod_globalRegistry??(Qn.__zod_globalRegistry=er());var tr=globalThis.__zod_globalRegistry;function nr(e,t){return new e({type:`string`,...w(t)})}function rr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...w(t)})}function ir(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...w(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...w(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...w(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...w(t)})}function cr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...w(t)})}function lr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...w(t)})}function ur(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...w(t)})}function dr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...w(t)})}function fr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...w(t)})}function pr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...w(t)})}function mr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...w(t)})}function hr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...w(t)})}function gr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...w(t)})}function _r(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...w(t)})}function vr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...w(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...w(t)})}function br(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...w(t)})}function xr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...w(t)})}function Sr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...w(t)})}function Cr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...w(t)})}function wr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...w(t)})}function Tr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...w(t)})}function Er(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...w(t)})}function Dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...w(t)})}function Or(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...w(t)})}function kr(e,t){return new e({type:`number`,checks:[],...w(t)})}function Ar(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...w(t)})}function jr(e,t){return new e({type:`boolean`,...w(t)})}function Mr(e,t){return new e({type:`null`,...w(t)})}function Nr(e){return new e({type:`unknown`})}function Pr(e,t){return new e({type:`never`,...w(t)})}function Fr(e,t){return new St({check:`less_than`,...w(t),value:e,inclusive:!1})}function Ir(e,t){return new St({check:`less_than`,...w(t),value:e,inclusive:!0})}function Lr(e,t){return new Ct({check:`greater_than`,...w(t),value:e,inclusive:!1})}function Rr(e,t){return new Ct({check:`greater_than`,...w(t),value:e,inclusive:!0})}function zr(e,t){return new wt({check:`multiple_of`,...w(t),value:e})}function Br(e,t){return new Et({check:`max_length`,...w(t),maximum:e})}function Vr(e,t){return new Dt({check:`min_length`,...w(t),minimum:e})}function Hr(e,t){return new Ot({check:`length_equals`,...w(t),length:e})}function Ur(e,t){return new At({check:`string_format`,format:`regex`,...w(t),pattern:e})}function Wr(e){return new jt({check:`string_format`,format:`lowercase`,...w(e)})}function Gr(e){return new Mt({check:`string_format`,format:`uppercase`,...w(e)})}function Kr(e,t){return new Nt({check:`string_format`,format:`includes`,...w(t),includes:e})}function qr(e,t){return new Pt({check:`string_format`,format:`starts_with`,...w(t),prefix:e})}function Jr(e,t){return new Ft({check:`string_format`,format:`ends_with`,...w(t),suffix:e})}function Yr(e){return new It({check:`overwrite`,tx:e})}function Xr(e){return Yr(t=>t.normalize(e))}function Zr(){return Yr(e=>e.trim())}function Qr(){return Yr(e=>e.toLowerCase())}function $r(){return Yr(e=>e.toUpperCase())}function ei(){return Yr(e=>ee(e))}function ti(e,t,n){return new e({type:`array`,element:t,...w(n)})}function ni(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}function ri(e,t){let n=ii(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ce(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ce(r))}},e(t.value,t)),t);return n}function ii(e,t){let n=new bt({check:`custom`,...w(t)});return n._zod.check=e,n}function ai(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??tr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function O(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,O(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&k(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function oi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function si(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:li(t,`input`,e.processors),output:li(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k(r.element,n);if(r.type===`set`)return k(r.valueType,n);if(r.type===`lazy`)return k(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 k(r.innerType,n);if(r.type===`intersection`)return k(r.left,n)||k(r.right,n);if(r.type===`record`||r.type===`map`)return k(r.keyType,n)||k(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:k(r.in,n)||k(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k(e,n))return!0;return!!(r.rest&&k(r.rest,n))}return!1}var ci=(e,t={})=>n=>{let r=ai({...n,processors:t});return O(e,r),oi(r,e),si(r,e)},li=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ai({...i??{},target:a,io:t,processors:n});return O(e,o),oi(o,e),si(o,e)},ui={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},di=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ui[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},fi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},pi=(e,t,n,r)=>{n.type=`boolean`},mi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},hi=(e,t,n,r)=>{n.not={}},gi=(e,t,n,r)=>{let i=e._zod.def,a=f(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},_i=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},vi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},yi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},bi=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=O(a.element,t,{...r,path:[...r.path,`items`]})},xi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=O(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=O(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Si=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>O(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ci=(e,t,n,r)=>{let i=e._zod.def,a=O(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=O(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},wi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=O(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=O(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=O(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ti=(e,t,n,r)=>{let i=e._zod.def,a=O(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ei=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Di=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Oi=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ki=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ai=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;O(o,t,r);let s=t.seen.get(e);s.ref=o},ji=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Mi=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ni=s(`ZodISODateTime`,(e,t)=>{Zt.init(e,t),M.init(e,t)});function Pi(e){return Tr(Ni,e)}var Fi=s(`ZodISODate`,(e,t)=>{Qt.init(e,t),M.init(e,t)});function Ii(e){return Er(Fi,e)}var Li=s(`ZodISOTime`,(e,t)=>{$t.init(e,t),M.init(e,t)});function Ri(e){return Dr(Li,e)}var zi=s(`ZodISODuration`,(e,t)=>{en.init(e,t),M.init(e,t)});function Bi(e){return Or(zi,e)}var Vi=s(`ZodError`,(e,t)=>{Te.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Oe(e,t)},flatten:{value:t=>De(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,p,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,p,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Hi=T(Vi),Ui=ke(Vi),Wi=Ae(Vi),Gi=Me(Vi),Ki=Pe(Vi),qi=Fe(Vi),Ji=Ie(Vi),Yi=Le(Vi),Xi=Re(Vi),Zi=ze(Vi),Qi=Be(Vi),$i=Ve(Vi),ea=new WeakMap;function ta(e,t,n){let r=Object.getPrototypeOf(e),i=ea.get(r);if(i||(i=new Set,ea.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var A=s(`ZodType`,(e,t)=>(E.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:li(e,`input`),output:li(e,`output`)}}),e.toJSONSchema=ci(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Hi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Wi(e,t,n),e.parseAsync=async(t,n)=>Ui(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Gi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ki(e,t,n),e.decode=(t,n)=>qi(e,t,n),e.encodeAsync=async(t,n)=>Ji(e,t,n),e.decodeAsync=async(t,n)=>Yi(e,t,n),e.safeEncode=(t,n)=>Xi(e,t,n),e.safeDecode=(t,n)=>Zi(e,t,n),e.safeEncodeAsync=async(t,n)=>Qi(e,t,n),e.safeDecodeAsync=async(t,n)=>$i(e,t,n),ta(e,`ZodType`,{check(...e){let t=this.def;return this.clone(x(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return se(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(po(e,t))},superRefine(e,t){return this.check(mo(e,t))},overwrite(e){return this.check(Yr(e))},optional(){return Ja(this)},exactOptional(){return Xa(this)},nullable(){return Qa(this)},nullish(){return Ja(Qa(this))},nonoptional(e){return io(this,e)},array(){return F(this)},or(e){return Ia([this,e])},and(e){return Ba(this,e)},transform(e){return co(this,Ka(e))},default(e){return eo(this,e)},prefault(e){return no(this,e)},catch(e){return oo(this,e)},pipe(e){return co(this,e)},readonly(){return uo(this)},describe(e){let t=this.clone();return tr.add(t,{description:e}),t},meta(...e){if(e.length===0)return tr.get(this);let t=this.clone();return tr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return tr.get(e)?.description},configurable:!0}),e)),na=s(`_ZodString`,(e,t)=>{zt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ta(e,`_ZodString`,{regex(...e){return this.check(Ur(...e))},includes(...e){return this.check(Kr(...e))},startsWith(...e){return this.check(qr(...e))},endsWith(...e){return this.check(Jr(...e))},min(...e){return this.check(Vr(...e))},max(...e){return this.check(Br(...e))},length(...e){return this.check(Hr(...e))},nonempty(...e){return this.check(Vr(1,...e))},lowercase(e){return this.check(Wr(e))},uppercase(e){return this.check(Gr(e))},trim(){return this.check(Zr())},normalize(...e){return this.check(Xr(...e))},toLowerCase(){return this.check(Qr())},toUpperCase(){return this.check($r())},slugify(){return this.check(ei())}})}),ra=s(`ZodString`,(e,t)=>{zt.init(e,t),na.init(e,t),e.email=t=>e.check(rr(ia,t)),e.url=t=>e.check(lr(sa,t)),e.jwt=t=>e.check(wr(Sa,t)),e.emoji=t=>e.check(ur(ca,t)),e.guid=t=>e.check(ir(aa,t)),e.uuid=t=>e.check(ar(oa,t)),e.uuidv4=t=>e.check(or(oa,t)),e.uuidv6=t=>e.check(sr(oa,t)),e.uuidv7=t=>e.check(cr(oa,t)),e.nanoid=t=>e.check(dr(la,t)),e.guid=t=>e.check(ir(aa,t)),e.cuid=t=>e.check(fr(ua,t)),e.cuid2=t=>e.check(pr(da,t)),e.ulid=t=>e.check(mr(fa,t)),e.base64=t=>e.check(xr(ya,t)),e.base64url=t=>e.check(Sr(ba,t)),e.xid=t=>e.check(hr(pa,t)),e.ksuid=t=>e.check(gr(ma,t)),e.ipv4=t=>e.check(_r(ha,t)),e.ipv6=t=>e.check(vr(ga,t)),e.cidrv4=t=>e.check(yr(_a,t)),e.cidrv6=t=>e.check(br(va,t)),e.e164=t=>e.check(Cr(xa,t)),e.datetime=t=>e.check(Pi(t)),e.date=t=>e.check(Ii(t)),e.time=t=>e.check(Ri(t)),e.duration=t=>e.check(Bi(t))});function j(e){return nr(ra,e)}var M=s(`ZodStringFormat`,(e,t)=>{D.init(e,t),na.init(e,t)}),ia=s(`ZodEmail`,(e,t)=>{Ht.init(e,t),M.init(e,t)}),aa=s(`ZodGUID`,(e,t)=>{Bt.init(e,t),M.init(e,t)}),oa=s(`ZodUUID`,(e,t)=>{Vt.init(e,t),M.init(e,t)}),sa=s(`ZodURL`,(e,t)=>{Ut.init(e,t),M.init(e,t)}),ca=s(`ZodEmoji`,(e,t)=>{Wt.init(e,t),M.init(e,t)}),la=s(`ZodNanoID`,(e,t)=>{Gt.init(e,t),M.init(e,t)}),ua=s(`ZodCUID`,(e,t)=>{Kt.init(e,t),M.init(e,t)}),da=s(`ZodCUID2`,(e,t)=>{qt.init(e,t),M.init(e,t)}),fa=s(`ZodULID`,(e,t)=>{Jt.init(e,t),M.init(e,t)}),pa=s(`ZodXID`,(e,t)=>{Yt.init(e,t),M.init(e,t)}),ma=s(`ZodKSUID`,(e,t)=>{Xt.init(e,t),M.init(e,t)}),ha=s(`ZodIPv4`,(e,t)=>{tn.init(e,t),M.init(e,t)}),ga=s(`ZodIPv6`,(e,t)=>{nn.init(e,t),M.init(e,t)}),_a=s(`ZodCIDRv4`,(e,t)=>{rn.init(e,t),M.init(e,t)}),va=s(`ZodCIDRv6`,(e,t)=>{an.init(e,t),M.init(e,t)}),ya=s(`ZodBase64`,(e,t)=>{sn.init(e,t),M.init(e,t)}),ba=s(`ZodBase64URL`,(e,t)=>{ln.init(e,t),M.init(e,t)}),xa=s(`ZodE164`,(e,t)=>{un.init(e,t),M.init(e,t)}),Sa=s(`ZodJWT`,(e,t)=>{fn.init(e,t),M.init(e,t)}),Ca=s(`ZodNumber`,(e,t)=>{pn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),ta(e,`ZodNumber`,{gt(e,t){return this.check(Lr(e,t))},gte(e,t){return this.check(Rr(e,t))},min(e,t){return this.check(Rr(e,t))},lt(e,t){return this.check(Fr(e,t))},lte(e,t){return this.check(Ir(e,t))},max(e,t){return this.check(Ir(e,t))},int(e){return this.check(Ta(e))},safe(e){return this.check(Ta(e))},positive(e){return this.check(Lr(0,e))},nonnegative(e){return this.check(Rr(0,e))},negative(e){return this.check(Fr(0,e))},nonpositive(e){return this.check(Ir(0,e))},multipleOf(e,t){return this.check(zr(e,t))},step(e,t){return this.check(zr(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function N(e){return kr(Ca,e)}var wa=s(`ZodNumberFormat`,(e,t)=>{mn.init(e,t),Ca.init(e,t)});function Ta(e){return Ar(wa,e)}var Ea=s(`ZodBoolean`,(e,t)=>{hn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r)});function P(e){return jr(Ea,e)}var Da=s(`ZodNull`,(e,t)=>{gn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r)});function Oa(e){return Mr(Da,e)}var ka=s(`ZodUnknown`,(e,t)=>{_n.init(e,t),A.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Aa(){return Nr(ka)}var ja=s(`ZodNever`,(e,t)=>{vn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function Ma(e){return Pr(ja,e)}var Na=s(`ZodArray`,(e,t)=>{bn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),e.element=t.element,ta(e,`ZodArray`,{min(e,t){return this.check(Vr(e,t))},nonempty(e){return this.check(Vr(1,e))},max(e,t){return this.check(Br(e,t))},length(e,t){return this.check(Hr(e,t))},unwrap(){return this.element}})});function F(e,t){return ti(Na,e,t)}var Pa=s(`ZodObject`,(e,t)=>{Tn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),y(e,`shape`,()=>t.shape),ta(e,`ZodObject`,{keyof(){return L(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Aa()})},loose(){return this.clone({...this._zod.def,catchall:Aa()})},strict(){return this.clone({...this._zod.def,catchall:Ma()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return fe(this,e)},safeExtend(e){return pe(this,e)},merge(e){return me(this,e)},pick(e){return ue(this,e)},omit(e){return de(this,e)},partial(...e){return he(qa,this,e[0])},required(...e){return ge(ro,this,e[0])}})});function I(e,t){return new Pa({type:`object`,shape:e??{},...w(t)})}var Fa=s(`ZodUnion`,(e,t)=>{Dn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.options=t.options});function Ia(e,t){return new Fa({type:`union`,options:e,...w(t)})}var La=s(`ZodDiscriminatedUnion`,(e,t)=>{Fa.init(e,t),On.init(e,t)});function Ra(e,t,n){return new La({type:`union`,options:t,discriminator:e,...w(n)})}var za=s(`ZodIntersection`,(e,t)=>{kn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r)});function Ba(e,t){return new za({type:`intersection`,left:e,right:t})}var Va=s(`ZodRecord`,(e,t)=>{Mn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ha(e,t,n){return!t||!t._zod?new Va({type:`record`,keyType:j(),valueType:e,...w(t)}):new Va({type:`record`,keyType:e,valueType:t,...w(n)})}var Ua=s(`ZodEnum`,(e,t)=>{Nn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ua({...t,checks:[],...w(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ua({...t,checks:[],...w(r),entries:i})}});function L(e,t){return new Ua({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...w(t)})}var Wa=s(`ZodLiteral`,(e,t)=>{Pn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function R(e,t){return new Wa({type:`literal`,values:Array.isArray(e)?e:[e],...w(t)})}var Ga=s(`ZodTransform`,(e,t)=>{Fn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new l(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ce(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ce(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ka(e){return new Ga({type:`transform`,transform:e})}var qa=s(`ZodOptional`,(e,t)=>{Ln.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ja(e){return new qa({type:`optional`,innerType:e})}var Ya=s(`ZodExactOptional`,(e,t)=>{Rn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xa(e){return new Ya({type:`optional`,innerType:e})}var Za=s(`ZodNullable`,(e,t)=>{zn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qa(e){return new Za({type:`nullable`,innerType:e})}var $a=s(`ZodDefault`,(e,t)=>{Bn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eo(e,t){return new $a({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var to=s(`ZodPrefault`,(e,t)=>{Hn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function no(e,t){return new to({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var ro=s(`ZodNonOptional`,(e,t)=>{Un.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function io(e,t){return new ro({type:`nonoptional`,innerType:e,...w(t)})}var ao=s(`ZodCatch`,(e,t)=>{Gn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oo(e,t){return new ao({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var so=s(`ZodPipe`,(e,t)=>{Kn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.in=t.in,e.out=t.out});function co(e,t){return new so({type:`pipe`,in:e,out:t})}var lo=s(`ZodReadonly`,(e,t)=>{Jn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uo(e){return new lo({type:`readonly`,innerType:e})}var fo=s(`ZodCustom`,(e,t)=>{Xn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r)});function po(e,t={}){return ni(fo,e,t)}function mo(e,t){return ri(e,t)}var z=e(t(),1),ho=n(),go=L([`observed`,`reported`,`inferred`,`planned`,`explained`]),_o=Ia([L([`claude-code`,`codex`]),j().regex(/^[a-z][a-z0-9-]{0,62}\/[a-z][a-z0-9-]{0,62}$/,`extension provider id must be a lowercase owner/name namespace`)]),vo=I({provider:_o,channel:L([`hook`,`transcript`,`rollout`,`app-server`,`salidium`]),version:j().optional(),ref:I({path:j().optional(),line:N().int().nonnegative().optional(),recordId:j().optional(),recordHash:j().regex(/^sha256:[0-9a-f]{64}$/).optional()}).optional()}),yo=L([`explicit`,`inferred-success`,`inferred-failure`,`unknown`]),bo=I({code:N().int().optional(),observation:yo}),B=Pi({offset:!1,precision:3}),xo=L([`status`,`what`,`why`,`how`,`verified`,`left`,`review`]),So=I({sessionId:j(),seq:N().int().nonnegative(),ordinal:N().int().nonnegative(),ts:B,facet:xo,summary:j(),epistemic:go,refs:F(j()),detail:Ha(j(),Aa()).optional()});L([`command`,`fileEdit`,`fileWrite`,`fileRead`,`search`,`webFetch`,`webSearch`,`subagent`,`plan`,`question`,`mcp`,`other`]);var Co=Ra(`kind`,[I({kind:R(`command`),command:j(),description:j().optional(),cwd:j().optional(),background:P().optional()}),I({kind:L([`fileEdit`,`fileWrite`,`fileRead`]),path:j()}),I({kind:R(`search`),query:j(),path:j().optional()}),I({kind:L([`webFetch`,`webSearch`]),target:j()}),I({kind:R(`subagent`),description:j().optional(),agentType:j().optional(),background:P().optional()}),I({kind:R(`plan`)}),I({kind:R(`question`),questions:F(j())}),I({kind:R(`mcp`),server:j(),tool:j(),pathArgs:F(j().max(1e3)).max(32).optional(),pathArgsTruncated:P().optional(),argsExcerpt:j().optional()}),I({kind:R(`other`),summary:j().optional()})]),wo=I({oldStart:N().int(),oldLines:N().int(),newStart:N().int(),newLines:N().int(),lines:F(j())}),To=L([`add`,`update`,`delete`,`move`]),Eo=I({path:j(),change:To,movedFrom:j().optional(),hunks:F(wo).optional(),linesAdded:N().int().nonnegative(),linesRemoved:N().int().nonnegative(),applied:P(),userModifiedBefore:P().optional()}),Do=I({commit:I({sha:j(),kind:j().optional()}).optional(),push:I({branch:j().optional()}).optional(),branch:I({ref:j().optional(),action:j().optional()}).optional(),pr:I({number:N().int().optional(),url:j().optional(),action:j().optional()}).optional()}),Oo=Ra(`kind`,[I({kind:R(`command`),exit:bo,outputExcerpt:j(),outputChars:N().int().nonnegative(),truncated:P(),interrupted:P().optional(),timedOut:P().optional(),gitOperation:Do.optional()}),I({kind:R(`fileChanges`),changes:F(Eo)}),I({kind:R(`fileRead`),path:j(),suppressed:P().optional()}),I({kind:R(`subagent`),agentId:j().optional(),status:L([`completed`,`launched`,`failed`,`unknown`]),summaryExcerpt:j().optional(),toolCalls:N().int().optional(),durationMs:N().int().optional()}),I({kind:R(`generic`),excerpt:j().optional()})]),ko=L([`pending`,`in_progress`,`completed`,`cancelled`]),Ao=I({id:j(),text:j(),status:ko,activeForm:j().optional()}),V=I({id:j(),sessionId:j(),ts:B,tsSource:L([`provider`,`ingest`]),agentId:j().optional(),turnId:j().optional(),source:vo,redactions:N().int().nonnegative().optional()}),jo=V.extend({kind:R(`session.started`),cwd:j(),model:j().optional(),entrypoint:j().optional(),gitBranch:j().optional(),reason:j().optional(),title:j().optional(),transcriptPath:j().optional()}),Mo=V.extend({kind:R(`session.updated`),model:j().optional(),title:j().optional(),gitBranch:j().optional(),cwd:j().optional()}),No=V.extend({kind:R(`session.ended`),reason:j().optional()}),Po=V.extend({kind:R(`turn.started`),prompt:j(),promptTruncated:P().optional()}),Fo=V.extend({kind:R(`turn.ended`),lastMessage:j().optional(),outcome:L([`completed`,`interrupted`,`failed`]),error:j().optional()}),Io=V.extend({kind:R(`agent.message`),text:j(),truncated:P().optional(),phase:L([`commentary`,`final`]).optional(),messageId:j().optional()}),Lo=V.extend({kind:R(`agent.thinking`),chars:N().int().nonnegative()}),Ro=V.extend({kind:R(`agent.usage`),messageId:j(),model:j().max(120).optional(),inputTokens:N().int().nonnegative(),outputTokens:N().int().nonnegative(),cacheReadTokens:N().int().nonnegative(),cacheWriteTokens:N().int().nonnegative()}),zo=V.extend({kind:R(`tool.called`),callId:j(),toolName:j(),input:Co,title:j()}),Bo=V.extend({kind:R(`tool.completed`),callId:j(),toolName:j(),result:Oo,isError:P(),durationMs:N().int().nonnegative().optional()}),Vo=L([`error`,`rejected`,`denied`,`interrupted`,`timeout`]),Ho=V.extend({kind:R(`tool.failed`),callId:j(),toolName:j(),errorExcerpt:j(),cause:Vo,exit:bo.optional(),interrupted:P().optional(),durationMs:N().int().nonnegative().optional()}),Uo=V.extend({kind:R(`subagent.started`),subagentId:j(),agentType:j().optional(),description:j().optional(),transcriptPath:j().optional(),parentCallId:j().optional()}),Wo=V.extend({kind:R(`subagent.ended`),subagentId:j(),lastMessage:j().optional()}),Go=V.extend({kind:R(`plan.updated`),mode:L([`replace`,`merge`]),items:F(Ao),explanation:j().optional()}),Ko=V.extend({kind:R(`compaction`),trigger:j().optional(),summaryExcerpt:j().optional()}),qo=V.extend({kind:R(`permission.requested`),toolName:j(),summary:j()}),Jo=V.extend({kind:R(`notification`),notificationType:j().optional(),message:j()}),Yo=V.extend({kind:R(`git.snapshot`),repoRoot:j(),head:j().optional(),branch:j().optional(),dirty:F(I({path:j(),status:j()})),dirtyTruncated:P().optional()}),Xo=V.extend({kind:R(`ingest.warning`),code:L([`malformed-record`,`unsupported-record`,`truncated-record`,`source-gap`]),detail:j().optional()}),Zo=j().max(200).refine(e=>e.trim().split(/\s+/).filter(Boolean).length<=6,`diagram steps contain at most six words`),Qo=V.extend({kind:R(`salidium.explanation`),basedOnSeq:N().int().nonnegative(),model:j().max(120),what:I({summary:j().max(600),currently:j().max(600).nullable()}),why:I({summary:j().max(600),lanes:F(I({title:j().max(100),steps:F(Zo).min(1).max(4)})).max(3).refine(e=>e.length===0||e.length>=2,`lanes are empty or converging`).default([]),chain:F(Zo).min(1).max(6)}),how:I({summary:j().max(600),root:j().max(200).nullable().default(null),steps:F(Zo).min(1).max(6)}),approachChange:I({from:j().max(200),fromSteps:F(Zo).min(2).max(4),why:j().max(600),to:j().max(200),toSteps:F(Zo).min(2).max(4)}).nullable()}),$o=Ra(`kind`,[jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Qo]),es=I({seq:N().int().nonnegative()}),ts=Ia([R(`forever`),R(30),R(90),R(365)]),ns=L([`summary`,`expanded`]);I({history:I({days:N().int().min(0).max(2**53-1)}).strict(),retention:I({days:ts}).strict(),git:I({enabled:P()}).strict(),providers:I({enabled:F(_o).max(32)}).strict(),explainer:I({cadence:L([`off`,`session`,`turn`]),backend:L([`auto`,`claude`,`codex`]),model:j().trim().min(1).max(120).nullable()}).strict(),health:I({sampleIntervalSeconds:N().int().min(5).max(300),historyMinutes:N().int().min(15).max(1440)}).strict(),alerts:I({queueAgeMinutes:N().int().min(1).max(10080),queueGrowthFiles:N().int().min(1).max(1e6),databaseSizeBytes:N().int().min(1048576).max(2**53-1),cooldownMinutes:N().int().min(1).max(10080),nativeNotifications:P()}).strict(),ui:I({operationsDetail:ns}).strict()}).strict(),I({version:R(1),revision:N().int().nonnegative(),updatedAt:B,migratedFrom:L([`settings-v0`,`sqlite-retention`]).optional(),settings:I({history:I({days:N().int().min(0).max(2**53-1).optional()}).strict().optional(),retention:I({days:ts.optional()}).strict().optional(),git:I({enabled:P().optional()}).strict().optional(),providers:I({enabled:F(_o).max(32).optional()}).strict().optional(),explainer:I({cadence:L([`off`,`session`,`turn`]).optional(),backend:L([`auto`,`claude`,`codex`]).optional(),model:j().trim().min(1).max(120).nullable().optional()}).strict().optional(),health:I({sampleIntervalSeconds:N().int().min(5).max(300).optional(),historyMinutes:N().int().min(15).max(1440).optional()}).strict().optional(),alerts:I({queueAgeMinutes:N().int().min(1).max(10080).optional(),queueGrowthFiles:N().int().min(1).max(1e6).optional(),databaseSizeBytes:N().int().min(1048576).max(2**53-1).optional(),cooldownMinutes:N().int().min(1).max(10080).optional(),nativeNotifications:P().optional()}).strict().optional(),ui:I({operationsDetail:ns.optional()}).strict().optional()}).strict()}).strict().shape.settings.refine(e=>Object.keys(e).length>0,`at least one setting is required`);var rs=L([`default`,`stored`,`environment`]);function H(e){return I({value:e,source:rs,environment:j().optional()}).strict()}var is=I({contractVersion:R(1),schemaVersion:R(1),revision:N().int().nonnegative(),observedAt:B,restartRequired:F(j()),values:I({history:I({days:H(N().int().min(0).max(2**53-1))}).strict(),retention:I({days:H(ts)}).strict(),git:I({enabled:H(P())}).strict(),providers:I({enabled:H(F(_o).max(32))}).strict(),explainer:I({cadence:H(L([`off`,`session`,`turn`])),backend:H(L([`auto`,`claude`,`codex`])),model:H(j().trim().min(1).max(120).nullable())}).strict(),health:I({sampleIntervalSeconds:H(N().int().min(5).max(300)),historyMinutes:H(N().int().min(15).max(1440))}).strict(),alerts:I({queueAgeMinutes:H(N().int().min(1).max(10080)),queueGrowthFiles:H(N().int().min(1).max(1e6)),databaseSizeBytes:H(N().int().min(1048576).max(2**53-1)),cooldownMinutes:H(N().int().min(1).max(10080)),nativeNotifications:H(P())}).strict(),ui:I({operationsDetail:H(ns)}).strict()}).strict()}).strict(),as=L([`exact`,`unavailable`]),os=I({availability:as,files:N().int().nonnegative().nullable(),bytes:N().int().nonnegative().nullable(),oldestAt:B.nullable(),reason:j().optional()}).strict(),ss=I({availability:as,databaseBytes:N().int().nonnegative().nullable(),walBytes:N().int().nonnegative().nullable(),totalBytes:N().int().nonnegative().nullable(),schemaVersion:N().int().nonnegative().nullable(),layoutVersion:N().int().nonnegative().nullable(),integrity:L([`ok`,`failed`,`not-checked`,`unavailable`]),retention:ts.nullable(),lastIngestAt:B.nullable()}).strict(),cs=I({key:L([`sessions`,`checkpoints`,`provenance`,`structure`,`reusable`]),bytes:N().int().nonnegative()}).strict(),ls=I({path:j(),sessions:N().int().nonnegative(),bytes:N().int().nonnegative()}).strict(),us=I({contractVersion:R(1),state:L([`absent`,`running`,`ready`,`failed`]),computedAt:B.nullable(),elapsedMs:N().int().nonnegative().nullable(),fileBytes:N().int().nonnegative().nullable(),sessions:N().int().nonnegative().nullable(),parts:F(cs),projects:F(ls),projectsOmitted:N().int().nonnegative(),failure:j().max(500).nullable()}).strict(),ds=L([`idle`,`pause`,`drain`,`checkpoint`,`optimize`,`verify`,`resume`,`completed`,`failure`,`recovery`]),fs=I({version:R(1),operationId:j().min(1),kind:L([`queue-drain`,`storage-optimize`,`retention-compact`]),phase:ds,startedAt:B,updatedAt:B,progress:N().min(0).max(1).nullable(),message:j().max(500),resumedFrom:ds.optional(),failure:j().max(1e3).optional()}).strict(),ps=I({value:N().finite(),unit:L([`files/minute`,`bytes/minute`,`seconds`]),sampleWindowSeconds:N().positive(),samples:N().int().min(2),basis:R(`derived`)}).strict(),ms=I({id:_o,name:j().min(1),detected:P(),configuration:L([`configured`,`not-configured`,`partial`,`invalid`,`unavailable`]),trust:L([`trusted`,`untrusted`,`modified`,`managed`,`unknown`,`not-applicable`])}).strict(),hs=I({active:N().int().nonnegative(),recovered:N().int().nonnegative(),omitted:N().int().nonnegative(),latestFingerprint:j().nullable(),activeEpisodes:F(I({reason:j(),provider:j().nullable(),event:j().nullable(),pressure:j().nullable(),firstDroppedAt:B.nullable(),recoveredAt:B.nullable(),exactCount:Oa()})),recoveredEpisodes:F(I({reason:j(),provider:j().nullable(),event:j().nullable(),pressure:j().nullable(),firstDroppedAt:B.nullable(),recoveredAt:B.nullable(),exactCount:Oa()}))}).strict(),gs=I({contractVersion:R(1),observedAt:B,overall:L([`healthy`,`attention`,`critical`]),daemon:I({state:L([`running`,`unresponsive`,`stopped`]),pid:N().int().positive().nullable(),startedAt:B.nullable(),version:j().nullable()}).strict(),collection:I({state:L([`active`,`paused`]),pausedAt:B.nullable(),pauseExpiresAt:B.nullable(),pauseReason:L([`manual`,`stop`]).nullable()}).strict(),queue:os,store:ss,gaps:hs,maintenance:fs.nullable(),hooks:F(ms),estimates:I({queueVelocity:ps.nullable(),drainRate:ps.nullable(),storageGrowth:ps.nullable(),timeToEmpty:ps.nullable()}).strict(),history:I({retentionMinutes:N().int().positive(),retainedSamples:N().int().nonnegative()}).strict()}).strict(),_s=L([`queue-age`,`queue-growth`,`database-size`,`collection-gap`,`daemon-health`,`maintenance-failure`,`hook-trust-change`]),vs=I({id:j().min(1),deduplicationKey:j().min(1),kind:_s,severity:L([`notice`,`warning`,`critical`]),state:L([`active`,`acknowledged`,`recovered`]),title:j().min(1).max(160),detail:j().min(1).max(500),recoveryTitle:j().min(1).max(160).optional(),recoveryDetail:j().min(1).max(500).optional(),firstSeenAt:B,lastSeenAt:B,lastTransitionAt:B,acknowledgedAt:B.nullable(),recoveredAt:B.nullable(),notificationEligible:P()}).strict(),ys=I({contractVersion:R(1),observedAt:B,active:F(vs),recent:F(vs)}).strict(),bs=I({contractVersion:R(1),config:is,health:gs,alerts:ys}).strict(),xs=I({id:j().min(1),provider:j().nullable(),state:L([`ready`,`processing`,`legacy`,`quarantined`]),bytes:N().int().nonnegative(),queuedAt:B}).strict();I({contractVersion:R(1),observedAt:B,totalFiles:N().int().nonnegative().nullable(),totalBytes:N().int().nonnegative().nullable(),entries:F(xs),entriesTruncated:P(),exactTotals:P()}).strict();var Ss=I({name:j().min(1),description:j().min(1),maximumBytes:N().int().nonnegative(),redactions:F(j())}).strict();I({contractVersion:R(1),bundleSchemaVersion:R(1),createdAt:B,privacy:R(`redacted-local-diagnostics`),excludes:F(j()),entries:F(Ss)}).strict();var Cs=L([`working`,`idle`,`waiting`,`ended`,`unknown`]),ws=L([`generating`,`generated`,`disabled`,`unavailable`,`failed`]),Ts=I({id:j(),provider:_o,providerSessionId:j(),cwd:j(),repoRoot:j().optional(),title:j().optional(),model:j().optional(),entrypoint:j().optional(),internal:P().optional(),explanationStatus:ws.optional(),status:Cs,startedAt:B.optional(),lastEventAt:B.optional(),endedAt:B.optional(),latestSeq:N().int().nonnegative(),counts:I({turns:N().int().nonnegative(),toolCalls:N().int().nonnegative(),filesChanged:N().int().nonnegative(),linesAdded:N().int().nonnegative(),linesRemoved:N().int().nonnegative(),reviewOpen:N().int().nonnegative(),remaining:N().int().nonnegative()}),lastVerification:I({outcome:L([`pass`,`fail`,`partial`,`unknown`]),at:B,epistemic:go}).optional()});I({sessions:F(Ts),matched:N().int().nonnegative(),total:N().int().nonnegative(),query:j()});var Es=Ba($o,es);I({summary:Ts,state:Aa(),reducerVersion:j(),seq:N().int().nonnegative(),changes:F(So)});var Ds=Ra(`type`,[I({type:R(`event`),event:Es}),I({type:R(`changes`),changes:F(So)}),I({type:R(`session`),summary:Ts}),I({type:R(`sessionRemoved`),id:j()}),I({type:R(`heartbeat`),at:B})]),Os=I({error:R(`resnapshot-required`),reason:L([`backlog-exceeded`,`history-gap`,`cursor-ahead`]),sessionId:j(),after:N().int().min(-1),latestSeq:N().int().min(-1)});I({name:R(`salidium`),version:j(),pid:N().int(),startedAt:B,home:j(),providers:F(I({id:_o,displayName:j().min(1).optional(),hooksInstalled:P(),hookStatus:L([`configured`,`not-configured`,`partial`,`invalid`]).optional(),hookTrust:L([`trusted`,`untrusted`,`modified`,`managed`,`unknown`,`not-applicable`]).optional(),sourcesWatched:N().int().nonnegative()}))});var ks=I({reason:j(),provider:j().nullable(),event:j().nullable(),pressure:j().nullable(),firstDroppedAt:B.nullable(),recoveredAt:B.nullable(),exactCount:Oa()}),As=I({observedAt:B,state:L([`active`,`paused`]),pause:I({pausedAt:B,expiresAt:B,reason:L([`manual`,`stop`])}).nullable(),queue:I({files:N().int().nonnegative(),bytes:N().int().nonnegative(),oldestAt:B.nullable()}),store:I({bytes:N().int().nonnegative().nullable(),retention:Ia([R(`forever`),R(30),R(90),R(365)]).nullable(),lastIngestAt:B.nullable()}),health:L([`healthy`,`attention`,`runaway`]),gaps:I({active:F(ks),recovered:F(ks),omittedEpisodes:N().int().nonnegative()})});I({action:L([`pause`,`resume`]),reason:L([`manual`,`stop`]).optional()});var js=L([`off`,`session`,`turn`]),Ms=L([`auto`,`claude`,`codex`]),Ns=I({backend:L([`claude`,`codex`]).nullable(),model:j().min(1).max(120).nullable()}),Ps=j().trim().min(1).max(120).refine(e=>Array.from(e).every(e=>{let t=e.charCodeAt(0);return t>=32&&t!==127}),`model names cannot contain control characters`),Fs=I({messages:N().int().nonnegative(),inputTokens:N().int().nonnegative(),outputTokens:N().int().nonnegative(),cacheReadTokens:N().int().nonnegative(),cacheWriteTokens:N().int().nonnegative()});I({cadence:js,backend:Ms,model:Ps.nullable(),envOff:P(),backendLocked:P(),modelLocked:P(),activeBackend:Ms.nullable(),activeModel:Ps.nullable(),availableBackends:F(L([`claude`,`codex`])),routes:I({claudeCode:Ns,codex:Ns}),usageStatus:L([`ready`,`preparing`]).optional(),usage:Fs.optional()}),I({cadence:js.optional(),backend:Ms.optional(),model:Ps.nullable().optional()}).strict().refine(e=>Object.keys(e).length>0,`at least one setting is required`);var Is=I({guidance:j().trim().max(800)}).strict(),Ls=I({version:R(2),enabled:P(),revision:j().min(1).max(80),profile:Is}).strict().refine(e=>(e.revision!==`none`||!e.enabled&&e.profile.guidance===``)&&(!e.enabled||e.profile.guidance!==``),`enabled personalization requires guidance; the none revision is reserved for the disabled empty profile`);I({enabled:P(),profile:Is}).strict().refine(e=>!e.enabled||e.profile.guidance!==``,`enabled personalization requires guidance`);var Rs=Qo.pick({basedOnSeq:!0,model:!0,what:!0,why:!0,how:!0,approachChange:!0}).extend({generatedAt:B,profileRevision:j().min(1).max(80),analogies:I({why:j().max(300).nullable(),how:j().max(300).nullable()})}).strict(),zs=class{token;onUnauthorized;constructor(e,t={}){this.token=e,this.onUnauthorized=t.onUnauthorized}headers(){return{Authorization:`Bearer ${this.token}`}}async get(e,t){let n;try{n=await fetch(e,{headers:this.headers(),signal:t})}catch(e){throw t?.aborted?e:new U(`daemon unreachable${e instanceof Error&&e.message?` (${e.message})`:``}`,0)}if(n.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!n.ok)throw new U(`request failed: ${n.status}`,n.status);return await n.json()}info(){return this.get(`/api/info`)}collectionStatus(){return this.get(`/api/collection`).then(e=>As.parse(e))}operations(){return this.get(`/api/operations`).then(e=>bs.parse(e))}async setOperationalConfig(e,t){let n=await fetch(`/api/operations/config`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`,"If-Match":String(t)},body:JSON.stringify(e)});if(n.status===401&&this.onUnauthorized?.(),!n.ok)throw new U(`request failed: ${n.status}`,n.status);return is.parse(await n.json())}async resetOperationalConfig(e,t){let n=e?`?key=${encodeURIComponent(e)}`:``,r=await fetch(`/api/operations/config${n}`,{method:`DELETE`,headers:{...this.headers(),"If-Match":String(t)}});if(r.status===401&&this.onUnauthorized?.(),!r.ok)throw new U(`request failed: ${r.status}`,r.status);return is.parse(await r.json())}async drainQueue(){let e=await fetch(`/api/operations/maintenance/drain`,{method:`POST`,headers:this.headers()});if(e.status===401&&this.onUnauthorized?.(),!e.ok)throw new U(`request failed: ${e.status}`,e.status);return await e.json()}async acknowledgeAlert(e){let t=await fetch(`/api/operations/alerts/${encodeURIComponent(e)}/acknowledge`,{method:`POST`,headers:this.headers()});if(t.status===401&&this.onUnauthorized?.(),!t.ok)throw new U(`request failed: ${t.status}`,t.status);return ys.parse(await t.json())}async setCollection(e){let t=await fetch(`/api/collection`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`},body:JSON.stringify({action:e,reason:`manual`})});if(t.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!t.ok)throw new U(`request failed: ${t.status}`,t.status);return As.parse(await t.json())}async disconnectHooks(e){let t=await fetch(`/api/collection/hooks/${encodeURIComponent(e)}`,{method:`DELETE`,headers:this.headers()});if(t.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!t.ok)throw new U(`request failed: ${t.status}`,t.status);return As.parse(await t.json())}explainerSettings(){return this.get(`/api/settings/explainer`)}async setExplainerSettings(e){let t=await fetch(`/api/settings/explainer`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`},body:JSON.stringify(e)});if(t.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!t.ok)throw new U(`request failed: ${t.status}`,t.status);return await t.json()}async personalizationSettings(){return Ls.parse(await this.get(`/api/settings/personalization`))}async setPersonalizationSettings(e,t){let n=await fetch(`/api/settings/personalization`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`,"If-Match":t},body:JSON.stringify(e)});if(n.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!n.ok)throw new U(`request failed: ${n.status}`,n.status);return Ls.parse(await n.json())}async deletePersonalizationSettings(e){let t=await fetch(`/api/settings/personalization`,{method:`DELETE`,headers:{...this.headers(),"If-Match":e}});if(t.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!t.ok)throw new U(`request failed: ${t.status}`,t.status);return Ls.parse(await t.json())}async personalizedPresentation(e){let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/personalized-presentation`,{method:`POST`,headers:this.headers()});if(t.status===401)throw this.onUnauthorized?.(),new U(`unauthorized`,401);if(!t.ok)throw new U(`request failed: ${t.status}`,t.status);return Rs.parse(await t.json())}sessions(){return this.get(`/api/sessions`)}searchSessions(e,t={}){let n=e.trim(),r=new URLSearchParams;return n&&r.set(`q`,n),t.limit!==void 0&&r.set(`limit`,String(t.limit)),this.get(`/api/sessions/search?${r}`,t.signal)}snapshot(e){return this.get(`/api/sessions/${encodeURIComponent(e)}/snapshot?changes=400`)}stateAt(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/state?at=${t}`)}stateAtTime(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/state?atTime=${encodeURIComponent(t)}`)}changes(e,t=-1,n){let r=n===void 0?``:`&until=${n}`;return this.get(`/api/sessions/${encodeURIComponent(e)}/changes?after=${t}${r}`)}events(e,t,n,r=5e3){let i=n===void 0?``:`&until=${n}`;return this.get(`/api/sessions/${encodeURIComponent(e)}/events?after=${t}${i}&limit=${r}`)}raw(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/raw/${encodeURIComponent(t)}`)}async forget(e){await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:this.headers()})}stream(e,t,n,r){let i=!1,a,o=0;return(async()=>{for(;!i;){n(o===0?`connecting`:`reconnecting`);try{let i=typeof e==`function`?e():e,s=``,c=e=>{s+=e;let n=s.indexOf(`
65
+
66
+ `);for(;n!==-1;){let e=s.slice(0,n);s=s.slice(n+2);for(let n of e.split(`
67
+ `))if(n.startsWith(`data: `))try{let e=Ds.safeParse(JSON.parse(n.slice(6)));e.success&&t(e.data)}catch{}n=s.indexOf(`
68
+
69
+ `)}};if(Bs()){let e=await Hs(i,this.token,c,()=>{n(`open`),o=0},e=>{a=e});if(e.status===409&&Os.safeParse(Vs(e.body)).success){n(`closed`),r?.();return}if(e.status===401)throw new U(`unauthorized`,401);if(e.status!==0&&(e.status<200||e.status>=300))throw new U(`stream failed: ${e.status}`,e.status)}else{let e=new AbortController;a=()=>e.abort();let t=await fetch(i,{headers:this.headers(),signal:e.signal});if(t.status===409&&Os.safeParse(await t.json()).success){n(`closed`),r?.();return}if(!t.ok||!t.body)throw new U(`stream failed: ${t.status}`,t.status);n(`open`),o=0;let s=t.body.getReader(),l=new TextDecoder;for(;;){let{value:e,done:t}=await s.read();if(t)break;c(l.decode(e,{stream:!0}))}}}catch(e){if(i)break;if(e instanceof U&&e.status===401){n(`closed`),this.onUnauthorized?.();return}}if(i)break;o++,await new Promise(e=>setTimeout(e,Math.min(15e3,500*2**Math.min(o,5))))}n(`closed`)})(),()=>{i=!0,a?.()}}};function Bs(){let e=typeof navigator>`u`?``:navigator.userAgent;return/AppleWebKit/i.test(e)&&!/(?:Chrome|Chromium|Edg|OPR)\//i.test(e)&&typeof XMLHttpRequest<`u`}function Vs(e){try{return JSON.parse(e)}catch{return}}function Hs(e,t,n,r,i){return new Promise((a,o)=>{let s=new XMLHttpRequest,c=0,l=!1,u=()=>{l||s.status!==200||(l=!0,r())},d=()=>{u(),!(s.status!==200||s.responseText.length<=c)&&(n(s.responseText.slice(c)),c=s.responseText.length)};s.open(`GET`,e),s.setRequestHeader(`Authorization`,`Bearer ${t}`),s.onreadystatechange=()=>{s.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&u(),s.readyState===XMLHttpRequest.LOADING&&d()},s.onprogress=d,s.onload=()=>{d(),a({status:s.status,body:s.responseText})},s.onerror=()=>o(Error(`stream failed`)),s.onabort=()=>a({status:0,body:``}),i(()=>s.abort()),s.send()})}var U=class extends Error{status;constructor(e,t){super(e),this.status=t}},Us=`salidium.token`;function Ws(){let e=window.location.hash,t=/token=([0-9a-f]+)/.exec(e);if(t?.[1]){sessionStorage.setItem(Us,t[1]);let n=e.replace(/[#&]?token=[0-9a-f]+/,``).replace(/^#&/,`#`);return history.replaceState(null,``,`${window.location.pathname}${n===`#`?``:n}`),t[1]}return sessionStorage.getItem(Us)??void 0}function Gs(e){sessionStorage.setItem(Us,e)}function Ks(e){let t=e.trim(),n=/token=([0-9a-f]+)/.exec(t);return n?.[1]?n[1]:/^[0-9a-f]{16,}$/.test(t)?t:void 0}function qs(){sessionStorage.removeItem(Us)}var W=r(),Js=64,Ys=44;function Xs({size:e=24,className:t,decorative:n=!1,label:r=`Salidium`}){return(0,W.jsxs)(`svg`,{className:t,viewBox:`0 0 ${Js} ${Ys}`,width:e*Js/Ys,height:e,role:n?void 0:`img`,"aria-hidden":n||void 0,"aria-label":n?void 0:r,focusable:`false`,children:[(0,W.jsx)(`path`,{fill:`currentColor`,d:`M12 1.1C17.2-.2 21.6.1 26.1 2.6l9.1 5c5.4 3 6.6 7.8 3 11.9l-2.7 2.9c-1.4 1.5-1 3.9.8 5.2l3.5 2.8c3.2 2.5 3.9 6.7 1.3 9.8-1.5 1.8-3.6 2.7-6.3 2.7H14.1c-4.3 0-7.3-2.1-9-6L.9 27.1c-1.2-2.7-.9-5.8.1-8.5L5.3 7.3C6.5 4.2 8.8 2 12 1.1Z`}),(0,W.jsx)(`path`,{fill:`currentColor`,d:`M46.3 14.1c1.8-1.4 4.2-1.6 6.2-.4l5.6 3.3c3.1 1.8 4.8 4.7 5.3 8.4l.6 9.4c.3 4.6-2.1 8.1-6.5 8.1h-7.1c-4.1 0-6.6-3.1-6.2-7 .4-3.2-.8-5.8-3.4-7.7-2.7-2-3.1-5.5-1.3-8.1l6.8-6Z`})]})}function Zs({markSize:e=24,className:t}){let n=[`brand-lockup`,t].filter(Boolean).join(` `);return(0,W.jsxs)(`span`,{className:n,children:[(0,W.jsx)(Xs,{size:e,className:`brand-lockup-mark`,decorative:!0}),(0,W.jsx)(`span`,{className:`brand-lockup-name`,children:`Salidium`})]})}var Qs=/(^|\n)\s*(```|~~~)/,$s=/^(?:[\w-]+\{"|[[{]"|<\/?[a-z][\w-]*[\s>/])/i,ec=/^(?:[a-z]+:\/\/\S+|[~./]?[\w./@-]+\.[a-z0-9]{1,6}(?::\d+)?|[$>][^\n]*)$/i;function tc(e){let t=e.trim(),n=(t.split(`
70
+ `,1)[0]??``).trim();return{heading:/^#{1,6}\s/.test(n),wholeBold:/^\*\*[\s\S]+\*\*$/.test(t)&&!/\*\*[\s\S]*\*\*[\s\S]*\*\*/.test(t.slice(2,-2)),fence:Qs.test(t),listItem:/^(?:[-*+]\s|\d{1,3}[.)]\s)/.test(n),quote:/^>\s?/.test(n),table:/^\|/.test(n),artifact:$s.test(t)||ec.test(n)}}function nc(e){return e.heading||e.wholeBold||e.fence||e.table||e.artifact}function rc(e){return e.replace(/(?:^|\n)[ \t]*(```|~~~)[^\n]*\n[\s\S]*?\n[ \t]*\1[^\n]*(?=\n|$)/g,` `).replace(/(?:^|\n)[ \t]*(```|~~~)[\s\S]*$/g,` `).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\[[^\]]*\]/g,`$1`).replace(/<((?:https?|mailto):[^>\s]+)>/g,`$1`).split(`
71
+ `).map(e=>e.replace(/^\s{0,3}#{1,6}\s+/,``).replace(/^\s{0,3}>\s?/,``).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/,``).replace(/^\s*([-*_])(?:\s*\1){2,}\s*$/,``)).join(`
72
+ `).replace(/``([^`]|`(?!`))+``/g,e=>e.slice(2,-2)).replace(/`([^`\n]+)`/g,`$1`).replace(/`/g,``).replace(/~~(?=\S)([\s\S]*?\S)~~/g,`$1`).replace(/\*\*\*(?=\S)([\s\S]*?\S)\*\*\*/g,`$1`).replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g,`$1`).replace(/(?<![\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g,`$1`).replace(/(?<![\w_])__(?=\S)([\s\S]*?\S)__(?![\w_])/g,`$1`).replace(/(?<![\w_])_(?=\S)([^_\n]*?\S)_(?![\w_])/g,`$1`).replace(/\\([\\`*_{}[\]()#+\-.!>~|])/g,`$1`).replace(/\s+/g,` `).trim()}var ic=.9,ac=.75,oc=.4,sc={kind:`other`,confidence:0,rule:`none`},cc=400,lc=16,uc=/\?\s*$/,dc=/^(should|do you|would you|which|can you|could you|shall|is it ok|are you|want me|shall i|any preference)\b/i;function fc(e){let t=e.split(`
73
+ `).map(e=>e.trim()).filter(Boolean),n=yc(t[0]??``),r=t[t.length-1]??``;return uc.test(r)||dc.test(n)}function pc(e){return(e.match(/[.!?](?:\s|$)/g)??[]).length}function mc(e){return/:\s*$/.test(e)}var hc=/\b(if|unless|whether|would|could|should|might|maybe|perhaps|want me to|i'?d rather|in case|to see if|to make sure|so that|once|until|before)\b[^.\n]{0,40}$/i;function gc(e,t){return hc.test(e.slice(Math.max(0,t-60),t))}var _c=/`[^`\n]+`|\[[^\]]+\]\([^)\s]+\)|\b[\w@./-]+\.(?:ts|tsx|js|jsx|mjs|cjs|css|scss|json|jsonl|md|rs|swift|py|go|rb|java|kt|sql|sh|toml|yml|yaml|html|astro)\b(?::\d+)?/;function vc(e){return _c.test(e)}function yc(e){return e.replace(/[\u2018\u2019\u02BC]/g,`'`).replace(/[\u201C\u201D]/g,`"`)}var bc=140,xc=/^(?:todo\b|next steps?\b|still\s+(?:need|needs|to do|left)\b|not yet\b|not done\b|left to do\b|follow-?ups?\b|out of scope\b|remaining\b|i(?:'ve| have)? ?ha?ve ?n'?t\b|ha ?ve ?n'?t\b|did ?n'?t get to\b)/i;function Sc(e){let t=yc(e.trim());return!(t.length===0||t.length>bc||!xc.test(t)||mc(t)||/\*\*|^#{1,6}\s|```/.test(t)||pc(t)>1)}function Cc(e){if(Sc(e))return{kind:`remaining`,confidence:ic,rule:`task-lead`};if(/\b(remaining|still need|not yet|left to do|follow-?up|todo)\b/i.test(e))return{kind:`remaining`,confidence:oc,rule:`task-word-in-body`}}var wc=/\b(?:all\s+)?(tests?|checks?|suites?|specs?|build|builds|typecheck|typechecks|lint|compile)\s+(?:are\s+|is\s+|now\s+|still\s+|all\s+)?(pass|passes|passed|passing|green|succeeds|succeeded|clean|fail|fails|failed|failing|red)\b/i,Tc=/\b(not|n't|never|should|will|would|until|once|need to|needs to|make sure|to see if|whether|if)\b[^.\n]{0,40}$/i,Ec=/(?:tests?|checks?|cases?|cells?|specs?|suites?|assertions?|examples?|green)/,Dc=RegExp(`(?:${Ec.source}\\b[^.\\n]{0,16}(?<![\\d.])\\d{1,6}\\s*/\\s*\\d{1,6}(?![\\d.])|(?<![\\d.])\\d{1,6}\\s*/\\s*\\d{1,6}(?![\\d.])[^.\\n]{0,16}\\b${Ec.source})`,`i`),Oc=/\b\d{1,6}\s+(green|passing|failing|red)\b/i;function kc(e){let t=wc.exec(e);if(t&&!Tc.test(e.slice(Math.max(0,t.index-60),t.index)))return{kind:`verification`,confidence:ic,rule:`runner-outcome`};let n=Oc.exec(e);if(n&&!gc(e,n.index))return{kind:`verification`,confidence:ac,rule:`count-with-outcome`};let r=Dc.exec(e);if(r&&!gc(e,r.index))return{kind:`verification`,confidence:ac,rule:`ratio-beside-check-noun`};if(t)return{kind:`verification`,confidence:oc,rule:`runner-outcome-hedged`}}var Ac=/^(?:(?:so|ok|okay|right|good|and|but|well)[,:]?\s+)?/i,jc=/^(?:now|next|then|first|finally|after that)[,:]?\s+/i,Mc=/^(?:i'?ll|i will|let me|let's|i'?m going to|i'?m about to|i'?m now|i am going to|going to|i plan to|my plan is|the plan is|approach:)\b/i,Nc=/^(?:adding|removing|deleting|dropping|fixing|updating|rewriting|writing|wiring|building|measuring|checking|testing|verifying|extracting|switching|replacing|moving|making|reproducing|implementing|refactoring|migrating|renaming|splitting|merging|porting|wrapping|converting|restoring|reverting|generating|instrumenting|profiling|benchmarking)\b/i;function Pc(e){let t=e.slice((Ac.exec(e)?.[0]??``).length),n=jc.exec(t)?.[0],r=n?t.slice(n.length):t;if(Mc.test(r))return{kind:`approach`,confidence:ic,rule:`intent-modal-lead`};if(n&&Nc.test(r))return{kind:`approach`,confidence:ac,rule:`sequenced-step-lead`};if(Nc.test(r))return{kind:`approach`,confidence:oc,rule:`bare-gerund`};if(mc(e))return{kind:`approach`,confidence:oc,rule:`announces-list`}}var Fc=/^(?:(?:so|ok|okay|and|but|well)[,:]?\s+)?(?:found it|found that|found|i found|i'?ve found|discovered|i discovered|turns out|it turns out|the (?:root )?cause (?:is|was)|the (?:issue|problem|bug|defect|fault|regression) (?:is|was|turned out)|root cause:|cause:|the real (?:cause|problem|issue|reason|bug)|confirmed:)\b/i,Ic=/\b(?:(?:is|was|were|are)\s+(?:wrong|broken|stale|missing|empty|null|undefined|the problem|the cause)|(?:does ?n'?t|do ?n'?t|did ?n'?t|is ?n'?t|are ?n'?t|was ?n'?t|were ?n'?t|ca ?n'?t|could ?n'?t|never|no longer|not actually)\s+\w+)/i;function Lc(e){if(Fc.test(e))return{kind:`discovery`,confidence:ic,rule:`finding-lead`};let t=Ic.exec(e);if(t)return{kind:`discovery`,confidence:oc,rule:!gc(e,t.index)&&vc(e)&&pc(e)<=2?`defect-with-referent`:`defect-uncorroborated`};if(/\b(found|discovered|turns out|actually|noticed|the real \w+)\b/i.test(e))return{kind:`discovery`,confidence:oc,rule:`finding-word-in-body`}}var Rc=/^(?:summary|in summary|to summari[sz]e|here'?s what|what i did|what changed|done\b|completed\b|finished\b|all done\b)/i;function zc(e,t){if(t===`final`&&Rc.test(e))return{kind:`summary`,confidence:ic,rule:`summary-lead`}}function Bc(e,t=`commentary`){if(nc(tc(e)))return{kind:`other`,confidence:0,rule:`not-narration`};let n=Uc(rc(e));if(n.length<lc||n.length>cc)return{kind:`other`,confidence:0,rule:n.length<lc?`too-short`:`too-long`};let r=yc(n),i=[Cc(r),kc(r),zc(r,t),Lc(r),Pc(r)].filter(e=>e!==void 0),a=sc;for(let e of i)e.confidence>a.confidence&&(a=e);return Vc(a)?a:{kind:`other`,confidence:a.confidence,rule:a.rule}}function Vc(e){return e.confidence>=.7&&e.kind!==`other`}function Hc(e){let t=e.replace(/```[\s\S]*?```/g,` `).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/gm,``).replace(/^(\s*(?:\*\*|__))\s*\d{1,3}[.)]\s+/gm,`$1`),n=[];for(let e of t.split(/\n{2,}|\n(?=[A-Z\d#>*-])/)){let t=e.trim();if(t){if(t.length<=240){n.push(t);continue}for(let e of t.split(/(?<=[.!?:])\s+(?=[A-Z\d])/)){let t=e.trim();t&&n.push(t)}}}return n}function Uc(e,t=200){let n=Wc(e);if(n.length<=t)return n;let r=n.slice(0,t),i=r.lastIndexOf(` `);return`${Wc((i>t*.6?r.slice(0,i):r).trimEnd())}…`}function Wc(e){return e.replace(/^(?:`|\*{1,3}|_{1,3})+\s*/,``).replace(/\s*(?:`|\*{1,3}|_{1,3})+$/,``)}function Gc(e,t,n=5){let r=[],i=new Set,a;if(fc(e.trim())){let t=Uc(rc(Kc(e)));t&&r.push({kind:`question`,text:t,confidence:ic,rule:`question`})}for(let o of Hc(e)){let e=Bc(o,t),s=Uc(rc(o));if(!s||e.rule===`not-narration`||fc(s))continue;if(!Vc(e)){(!a||e.confidence>a.confidence)&&(a={kind:e.kind,text:s,confidence:e.confidence,rule:e.rule});continue}let c=`${e.kind}:${s}`;if(!i.has(c)&&(i.add(c),r.push({kind:e.kind,text:s,confidence:e.confidence,rule:e.rule}),r.length>=n))break}return r.length>0?r:a?[a]:[]}function Kc(e){let t=e.split(`
74
+ `).map(e=>e.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e--){let n=t[e]??``;if(/\?\s*$/.test(n))return n}return t[0]??``}function qc(e,t=160){for(let n of e.split(`
75
+ `)){let e=rc(n);if(e.length!==0)return e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e}return``}function Jc(e){return e<1e3?`${e} B`:e<1e6?`${(e/1e3).toFixed(1)} KB`:e<1e9?`${(e/1e6).toFixed(1)} MB`:`${(e/1e9).toFixed(2)} GB`}var Yc=[{runner:`vitest`,method:`test`,pattern:/^vitest(\s|$)/},{runner:`jest`,method:`test`,pattern:/^jest(\s|$)/},{runner:`playwright`,method:`test`,pattern:/^playwright\s+test(\s|$)/},{runner:`mocha`,method:`test`,pattern:/^mocha(\s|$)/},{runner:`pytest`,method:`test`,pattern:/^(pytest|py\.test)(\s|$)/},{runner:`cargo`,method:`test`,pattern:/^cargo\s+(nextest\s+run|test)(\s|$)/},{runner:`go`,method:`test`,pattern:/^go\s+test(\s|$)/},{runner:`xcodebuild`,method:`test`,pattern:/^xcodebuild\b.*\stest(-without-building)?(\s|$)/},{runner:`swift`,method:`test`,pattern:/^swift\s+test(\s|$)/},{runner:`dotnet`,method:`test`,pattern:/^dotnet\s+test(\s|$)/},{runner:`rspec`,method:`test`,pattern:/^rspec(\s|$)/},{runner:`phpunit`,method:`test`,pattern:/^phpunit(\s|$)/},{runner:`mix`,method:`test`,pattern:/^mix\s+test(\s|$)/},{runner:`gradle`,method:`test`,pattern:/^gradlew?\s+(:[\w-]+:)?test(\s|$)/},{runner:`maven`,method:`test`,pattern:/^mvn\s+(-[^\s]+\s+)*(test|verify)(\s|$)/},{runner:`node-test`,method:`test`,pattern:/^node\s+(--[^\s]+\s+)*--test(\s|$)/},{runner:`tsc`,method:`typecheck`,pattern:/^tsc(\s|$)/},{runner:`mypy`,method:`typecheck`,pattern:/^mypy(\s|$)/},{runner:`pyright`,method:`typecheck`,pattern:/^pyright(\s|$)/},{runner:`eslint`,method:`lint`,pattern:/^eslint(\s|$)/},{runner:`biome`,method:`lint`,pattern:/^biome\s+(check|lint|ci)(\s|$)/},{runner:`ruff`,method:`lint`,pattern:/^ruff\s+(check|format\s+--check)(\s|$)/},{runner:`clippy`,method:`lint`,pattern:/^cargo\s+clippy(\s|$)/},{runner:`golangci-lint`,method:`lint`,pattern:/^golangci-lint\s+run(\s|$)/},{runner:`cargo-build`,method:`build`,pattern:/^cargo\s+(build|check)(\s|$)/},{runner:`go-build`,method:`build`,pattern:/^go\s+(build|vet)(\s|$)/},{runner:`xcodebuild`,method:`build`,pattern:/^xcodebuild(\s|$)/},{runner:`swift-build`,method:`build`,pattern:/^swift\s+build(\s|$)/},{runner:`vite-build`,method:`build`,pattern:/^vite\s+build(\s|$)/},{runner:`make`,method:`build`,pattern:/^make(\s|$)/},{runner:`npm-script`,method:`test`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?test(:[\w-]+)?(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`typecheck`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?(typecheck|type-check|tsc)(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`lint`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?lint(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`build`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?build(\s|$)/,scopeUnknown:!0}],Xc=/(^|\s)(--watch(=\S+)?|-w|--watchAll)(\s|$)/,Zc=/(^|\s)(-k|-t|--grep|-g|--filter|-run|--only-testing|--testNamePattern|--testPathPattern|-x|--bail)(\s|=)/,Qc=new Set(`run.test.lint.build.typecheck.type-check.start.dev.exec.dlx.x.add.install.i.remove.rm.update.up.create.init.publish.link.why.ls.list.outdated.audit.view.info.config.cache.store.setup.env.patch`.split(`.`));function $c(e){let t=[];for(let n of al(e)){let e=n.real.trim();if(!e)continue;let r=e.split(/\s+/);for(;r.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(r[0]??``);)r.shift();if(r.length===0||r[0]===`cd`)continue;for(let e=0;e<3;e++){let e=r[0]??``,t=r[1]??``;if(e===`npx`||e===`bunx`||e===`yarn`){if(e===`yarn`&&(Qc.has(t)||t.startsWith(`-`)||!t))break;r.shift(),r[0]?.startsWith(`-`)&&r.shift();continue}if((e===`pnpm`||e===`npm`||e===`bun`)&&(t===`exec`||t===`dlx`||t===`x`)){r.splice(0,2);continue}if(e===`pnpm`&&t&&!Qc.has(t)&&!t.startsWith(`-`)){r.shift();continue}if((e===`python`||e===`python3`)&&t===`-m`){r.splice(0,2);continue}if(e===`bundle`&&t===`exec`||(e===`poetry`||e===`uv`||e===`pipenv`)&&t===`run`){r.splice(0,2);continue}break}if(r.length===0)continue;let i=r[0]??``,a=i.slice(i.lastIndexOf(`/`)+1);t.push([a,...r.slice(1)].join(` `))}return t}function el(e){return e.split(/\s+/).slice(1).some(e=>!e.startsWith(`-`)&&/\.(test|spec)\.[cm]?[jt]sx?$|\/|\.py$|\.rs$|\.go$|_test\b/.test(e))}function tl(e){for(let t of $c(e))for(let e of Yc){if(!e.pattern.test(t))continue;let n=Xc.test(t),r=e.scopeUnknown?`unknown`:`full`;return!e.scopeUnknown&&(Zc.test(t)||el(t))&&(r=`partial`),{method:e.method,runner:e.runner,scope:r,watch:n}}}var nl=[{id:`rm-rf`,pattern:/(^|\s)rm\s+(-[a-zA-Z]*r[a-zA-Z]*f|-[a-zA-Z]*f[a-zA-Z]*r)\b/,summary:`Recursive force delete`},{id:`git-force-push`,pattern:/(^|\s)git\s+push\b[^|;&]*(\s--force\b|\s-f\b|\s--force-with-lease\b)/,summary:`Force push`},{id:`git-reset-hard`,pattern:/(^|\s)git\s+reset\s+--hard\b/,summary:`Hard reset`},{id:`git-clean`,pattern:/(^|\s)git\s+clean\s+-[a-zA-Z]*f/,summary:`git clean -f`},{id:`git-checkout-discard`,pattern:/(^|\s)git\s+(checkout|restore)\s+(--\s+)?\.(\s|$)/,summary:`Discard working tree changes`},{id:`drop-table`,pattern:/\bdrop\s+(table|database|schema)\b/i,summary:`DROP TABLE/DATABASE`},{id:`no-verify`,pattern:/(^|\s)git\s+(commit|push)\b[^|;&]*\s--no-verify\b/,summary:`Skipped git hooks (--no-verify)`},{id:`chmod-777`,pattern:/(^|\s)chmod\s+(-R\s+)?777\b/,summary:`chmod 777`},{id:`sudo`,pattern:/(^|\s)sudo\s/,summary:`sudo`}];function rl(e){let t=e=>e.replace(/[^\n]/g,` `);return e.replace(/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1[\s\S]*?^[ \t]*\2[ \t]*$/gm,t).replace(/'[^']*'/g,t).replace(/"[^"]*"/g,t)}var il=/&&|\|\||;|\||\n/g;function al(e){let t=rl(e),n=[],r=0;il.lastIndex=0;for(let i=il.exec(t);i;i=il.exec(t))n.push({real:e.slice(r,i.index),masked:t.slice(r,i.index)}),r=i.index+i[0].length;return n.push({real:e.slice(r),masked:t.slice(r)}),n}function ol(e){let t=al(e);for(let e of nl){let n=t.find(t=>e.pattern.test(t.masked));if(n)return{id:e.id,summary:e.summary,segment:n.real.trim()}}}var sl=String.raw`(?:(?:-C\s+\S+|-c\s+\S+|--[\w-]+(?:=\S+)?|-\w)\s+)*`,cl=new RegExp(String.raw`(^|\s)git\s+${sl}commit\b`),ll=new RegExp(String.raw`(^|\s)git\s+${sl}push\b`);function ul(e){if(ll.test(e))return`push`;if(cl.test(e))return`commit`}var dl=/\x1b\[[0-9;?]*[ -/]*[@-~]/g;function fl(e){return e.replace(dl,``)}function G(e){if(e===void 0)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function K(e,t){let n,r,i=new RegExp(e.source,e.flags.includes(`g`)?e.flags:`${e.flags}g`);for(;(n=i.exec(t))!==null;)r=n;return r}function pl(e){let t={};for(let n of e.matchAll(/(\d+)\s+(failed|passed|skipped|todo|pending|expected fail|flaky)/g)){let e=Number(n[1]);switch(n[2]){case`failed`:t.failed=(t.failed??0)+e;break;case`passed`:t.passed=(t.passed??0)+e;break;default:t.skipped=(t.skipped??0)+e}}return t}function ml(e,t){let n=!1,r={pass:0,fail:0};for(let i of t.matchAll(e))n=!0,i[1]===`pass`?r.pass+=G(i[2])??0:r.fail+=G(i[2])??0;return n?r:void 0}function hl(e){return e?(e.failed??0)>0?`fail`:(e.passed??0)>0?`pass`:`unknown`:`unknown`}var gl={vitest:e=>{let t=K(/^\s*Tests\s+(.+?)\s*\((\d+)\)\s*$/m,e),n=K(/^\s*Test Files\s+(.+?)\s*\((\d+)\)\s*$/m,e),r=t??n;if(!r)return/No test files found/i.test(e)?{runner:`vitest`,outcome:`unknown`,rule:`vitest.none`}:void 0;let i=pl(r[1]??``);return i.total=G(r[2]),{runner:`vitest`,outcome:hl(i),counts:i,rule:`vitest.summary`}},jest:e=>{let t=K(/^Tests:\s+(.+?),\s*(\d+)\s+total\s*$/m,e);if(!t)return;let n=pl(t[1]??``);return n.total=G(t[2]),{runner:`jest`,outcome:hl(n),counts:n,rule:`jest.summary`}},pytest:e=>{let t=K(/^=+\s+(.+?)\s+in\s+[\d.]+s(?:\s+\([^)]*\))?\s+=+\s*$/m,e);if(!t)return/no tests ran/i.test(e)?{runner:`pytest`,outcome:`unknown`,rule:`pytest.none`}:void 0;let n={};for(let e of(t[1]??``).matchAll(/(\d+)\s+(failed|passed|skipped|deselected|xfailed|xpassed|errors?|warnings?)/g)){let t=Number(e[1]),r=e[2]??``;r===`failed`||r.startsWith(`error`)?n.failed=(n.failed??0)+t:r===`passed`||r===`xpassed`?n.passed=(n.passed??0)+t:(r===`skipped`||r===`xfailed`||r===`deselected`)&&(n.skipped=(n.skipped??0)+t)}return n.total=(n.passed??0)+(n.failed??0)+(n.skipped??0),{runner:`pytest`,outcome:hl(n),counts:n,rule:`pytest.summary`}},cargo:e=>{let t=[...e.matchAll(/^test result: (ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored/gm)];if(t.length===0)return/^error(\[E\d+\])?:/m.test(e)?{runner:`cargo`,outcome:`fail`,rule:`cargo.compile-error`}:void 0;let n={passed:0,failed:0,skipped:0},r=!1;for(let e of t)e[1]===`FAILED`&&(r=!0),n.passed=(n.passed??0)+Number(e[2]),n.failed=(n.failed??0)+Number(e[3]),n.skipped=(n.skipped??0)+Number(e[4]);return n.total=(n.passed??0)+(n.failed??0)+(n.skipped??0),{runner:`cargo`,outcome:r||(n.failed??0)>0?`fail`:`pass`,counts:n,rule:`cargo.summary`}},go:e=>{let t=[...e.matchAll(/^(ok|FAIL|\?)\s+(\S+)/gm)];if(t.length===0)return;let n=[...e.matchAll(/^\s*--- (PASS|FAIL|SKIP): /gm)],r={};return n.length>0&&(r.passed=n.filter(e=>e[1]===`PASS`).length,r.failed=n.filter(e=>e[1]===`FAIL`).length,r.skipped=n.filter(e=>e[1]===`SKIP`).length,r.total=n.length),{runner:`go`,outcome:t.some(e=>e[1]===`FAIL`)||/\[build failed\]/.test(e)?`fail`:`pass`,counts:n.length?r:void 0,rule:`go.package-lines`}},xcodebuild:e=>{let t=K(/\*\* (TEST|BUILD) (SUCCEEDED|FAILED|EXECUTE FAILED) \*\*/,e),n=K(/Executed (\d+) tests?, with (?:(\d+) tests? skipped and )?(\d+) failures?/,e);if(!t&&!n)return;let r=n?{total:G(n[1]),skipped:G(n[2])??0,failed:G(n[3]),passed:(G(n[1])??0)-(G(n[3])??0)-(G(n[2])??0)}:void 0;return{runner:`xcodebuild`,outcome:t?t[2]===`SUCCEEDED`?`pass`:`fail`:hl(r),counts:r,rule:`xcodebuild.marker`}},swift:e=>{let t=K(/Test run with (\d+) tests?(?: in \d+ suites?)? (passed|failed) after [\d.]+ seconds(?: with (\d+) issues?)?/,e),n=K(/Executed (\d+) tests?, with (?:(\d+) tests? skipped and )?(\d+) failures?/,e);if(!t&&!n)return/^error:/m.test(e)||/Compiling.*\n.*error:/.test(e)?{runner:`swift`,outcome:`fail`,rule:`swift.compile-error`}:void 0;let r={},i=`unknown`;if(t){r.total=(r.total??0)+(G(t[1])??0);let e=G(t[3])??0;r.failed=(r.failed??0)+(t[2]===`failed`?Math.max(1,e):0),i=t[2]===`passed`?`pass`:`fail`}n&&(r.total=(r.total??0)+(G(n[1])??0),r.failed=(r.failed??0)+(G(n[3])??0),r.skipped=(r.skipped??0)+(G(n[2])??0),(G(n[3])??0)>0?i=`fail`:i===`unknown`&&(i=`pass`));let a=(r.total??0)-(r.failed??0)-(r.skipped??0);return a>=0&&(r.passed=a),{runner:`swift`,outcome:i,counts:r,rule:`swift.summary`}},playwright:e=>{let t=K(/^\s*(\d+) passed(?: \([^)]*\))?\s*$/m,e),n=K(/^\s*(\d+) failed\s*$/m,e),r=K(/^\s*(\d+) skipped\s*$/m,e),i=K(/^\s*(\d+) flaky\s*$/m,e);if(!t&&!n)return;let a={passed:G(t?.[1])??0,failed:G(n?.[1])??0,skipped:(G(r?.[1])??0)+(G(i?.[1])??0)};return a.total=(a.passed??0)+(a.failed??0)+(a.skipped??0),{runner:`playwright`,outcome:hl(a),counts:a,rule:`playwright.summary`}},mocha:e=>{let t=K(/^\s*(\d+) passing/m,e),n=K(/^\s*(\d+) failing/m,e),r=K(/^\s*(\d+) pending/m,e);if(!t&&!n)return;let i={passed:G(t?.[1])??0,failed:G(n?.[1])??0,skipped:G(r?.[1])??0};return i.total=(i.passed??0)+(i.failed??0)+(i.skipped??0),{runner:`mocha`,outcome:hl(i),counts:i,rule:`mocha.summary`}},"node-test":e=>{let t=ml(/^# (pass|fail) (\d+)$/gm,e),n=ml(/^ℹ (pass|fail) (\d+)$/gm,e),r=n??t;if(!r)return;let i={passed:r.pass,failed:r.fail};return i.total=r.pass+r.fail,{runner:`node-test`,outcome:hl(i),counts:i,rule:n?`node-test.spec`:`node-test.tap`}},astro:e=>{let t=K(/^Result \(\d+ files?\):[ \t]*\n-[ \t]*(\d+) errors?/m,e);if(t){let e=G(t[1])??0;return{runner:`astro`,outcome:e>0?`fail`:`pass`,counts:{failed:e},rule:`astro.check`}}if(/\[build\] Complete!/.test(e))return{runner:`astro`,outcome:`pass`,rule:`astro.build`}},dotnet:e=>{let t=K(/(Passed|Failed)!\s+-\s+Failed:\s+(\d+),\s+Passed:\s+(\d+),\s+Skipped:\s+(\d+),\s+Total:\s+(\d+)/,e);if(!t)return;let n={failed:G(t[2]),passed:G(t[3]),skipped:G(t[4]),total:G(t[5])};return{runner:`dotnet`,outcome:hl(n),counts:n,rule:`dotnet.summary`}},rspec:e=>{let t=K(/^(\d+) examples?, (\d+) failures?(?:, (\d+) pending)?/m,e);if(!t)return;let n={total:G(t[1]),failed:G(t[2]),skipped:G(t[3])??0};return n.passed=(n.total??0)-(n.failed??0)-(n.skipped??0),{runner:`rspec`,outcome:hl(n),counts:n,rule:`rspec.summary`}},mix:e=>{let t=K(/^(\d+) tests?, (\d+) failures?/m,e);if(!t)return;let n={total:G(t[1]),failed:G(t[2])};return n.passed=(n.total??0)-(n.failed??0),{runner:`mix`,outcome:hl(n),counts:n,rule:`mix.summary`}},phpunit:e=>{let t=K(/^OK \((\d+) tests?, \d+ assertions?\)/m,e);if(t)return{runner:`phpunit`,outcome:`pass`,counts:{total:G(t[1]),passed:G(t[1]),failed:0},rule:`phpunit.ok`};let n=K(/^Tests: (\d+), Assertions: \d+(?:, Failures: (\d+))?(?:, Errors: (\d+))?/m,e);if(!n)return;let r=(G(n[2])??0)+(G(n[3])??0);return{runner:`phpunit`,outcome:r>0?`fail`:`pass`,counts:{total:G(n[1]),failed:r,passed:(G(n[1])??0)-r},rule:`phpunit.summary`}},tsc:e=>{let t=K(/Found (\d+) errors?/,e);if(t)return{runner:`tsc`,outcome:Number(t[1])>0?`fail`:`pass`,counts:{failed:G(t[1])},rule:`tsc.found`};if(/error TS\d+:/.test(e))return{runner:`tsc`,outcome:`fail`,counts:{failed:(e.match(/error TS\d+:/g)??[]).length},rule:`tsc.errors`}},eslint:e=>{let t=K(/✖ (\d+) problems? \((\d+) errors?, (\d+) warnings?\)/,e);if(t)return{runner:`eslint`,outcome:Number(t[2])>0?`fail`:`pass`,counts:{failed:G(t[2])},rule:`eslint.summary`}},biome:e=>{let t=K(/Found (\d+) errors?/,e);if(t)return{runner:`biome`,outcome:Number(t[1])>0?`fail`:`pass`,counts:{failed:G(t[1])},rule:`biome.errors`};if(/Checked \d+ files? in/.test(e))return{runner:`biome`,outcome:`pass`,rule:`biome.checked`}}},_l={"npm-script":[`vitest`,`jest`,`playwright`,`mocha`,`node-test`,`tsc`,`eslint`,`biome`,`pytest`,`astro`],ruff:[],mypy:[],pyright:[],clippy:[`cargo`],"cargo-build":[`cargo`],"go-build":[`go`],"swift-build":[`swift`],"vite-build":[],make:[`vitest`,`jest`,`pytest`,`cargo`,`go`],gradle:[],maven:[],"golangci-lint":[]},vl={vitest:`test`,jest:`test`,playwright:`test`,mocha:`test`,"node-test":`test`,pytest:`test`,cargo:`test`,go:`test`,swift:`test`,dotnet:`test`,rspec:`test`,mix:`test`,phpunit:`test`,xcodebuild:`build`,astro:`build`,tsc:`typecheck`,eslint:`lint`,biome:`lint`};function yl(e,t,n){let r=fl(t),i=gl[e];if(i){let e=i(r);if(e)return e}let a=_l[e]??[],o=n===void 0?a:[...a.filter(e=>vl[e]===n),...a.filter(e=>vl[e]!==n)];for(let e of o){let t=gl[e]?.(r);if(t)return t}}Object.keys(gl);function bl(e,t){if(e.input.kind!==`command`)return;let n=tl(e.input.command);if(!n||n.watch||e.input.background)return;let r=e.result?.kind===`command`?e.result:void 0,i=e.exit??r?.exit??{observation:`unknown`},a=r?.outputExcerpt??e.errorExcerpt??``,o=yl(n.runner,a,n.method),s=(o?vl[o.runner]:void 0)??n.method,c=[];r?.truncated&&c.push(`output-truncated`),n.scope===`partial`&&c.push(`scope-partial`),o||c.push(`no-summary-parsed`);let l=`unknown`,u=`inferred`,d=i.observation===`inferred-failure`||i.observation===`explicit`&&(i.code??0)!==0,f=i.observation===`inferred-success`||i.observation===`explicit`&&i.code===0;o&&o.outcome!==`unknown`?(l=o.outcome,o.outcome===`pass`&&d?(l=`partial`,c.push(`exit-summary-mismatch`)):o.outcome===`fail`&&f&&c.push(`exit-masked`),u=i.observation===`explicit`?`observed`:`inferred`):d?(l=`fail`,u=i.observation===`explicit`?`observed`:`inferred`):f?(l=`pass`,u=i.observation===`explicit`?`observed`:`inferred`,i.observation!==`explicit`&&c.push(`exit-inferred`)):l=`unknown`,e.status===`running`&&(l=`unknown`),(r?.interrupted||r?.timedOut)&&(l=`unknown`,c.push(r.interrupted?`interrupted`:`timed-out`));let p=l===`fail`||l===`partial`?xl(a,800):void 0;return{id:e.callId,callId:e.callId,turnId:e.turnId,at:e.endedAt??e.startedAt,seq:t,command:e.input.command,runner:o?.runner??n.runner,method:s,outcome:l,counts:o?.counts,scope:n.scope,exit:i,outcomeEpistemic:u,caveats:c,failureExcerpt:p,stale:!1}}function xl(e,t){return e.length<=t?e:e.slice(e.length-t)}var Sl=class{ordinal=0;changes=[];sessionId;event;constructor(e,t){this.sessionId=e,this.event=t}add(e,t,n,r,i){this.changes.push({sessionId:this.sessionId,seq:this.event.seq,ordinal:this.ordinal++,ts:this.event.ts,facet:e,summary:q(t,160),epistemic:n,refs:i??[this.event.id],...r?{detail:r}:{}})}};function q(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function Cl(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function wl(e){return e.slice(0,7)}function Tl(e){if(e.endedAt)return`ended`;if(e.waiting)return`waiting`;let t=e.turns[e.turns.length-1];return t&&!t.endedAt||e.running.length>0?`working`:t||e.startedAt?`idle`:`unknown`}function El(e,t,n,r){if(e.review.some(e=>e.id===r.id&&e.resolvedSeq===void 0))return;let i=r.instance?`${r.label}: ${r.instance}`:r.label;e.review.push({...r,summary:i,refs:r.refs??[t.id],createdSeq:t.seq,createdAt:t.ts,epistemic:r.epistemic??`inferred`}),n.changes.some(e=>e.facet===`review`&&e.summary===q(i,160))||n.add(`review`,i,r.epistemic??`inferred`,{rule:r.rule,severity:r.severity})}function Dl(e,t,n){for(let r of e.review)r.resolvedSeq===void 0&&n(r)&&(r.resolvedSeq=t.seq)}var Ol=/\b(?:all\s+)?(tests?|checks?|build|typecheck|lint)\s+(?:are\s+|is\s+|now\s+|still\s+)?(pass|passes|passed|passing|green|succeeds|succeeded|clean)\b/i,kl=/\b(not|n't|never|should|will|would|until|once|need to|needs to|make sure|to see if|whether|if)\b[^.\n]{0,40}$/i;function Al(e){let t=Ol.exec(e);if(!t)return!1;let n=e.slice(Math.max(0,t.index-60),t.index);return!kl.test(n)}function jl(e,t,n){let r=e.verifications[e.verifications.length-1];if(!(!r||r.seq!==t.seq)){if(r.outcome===`fail`)El(e,t,n,{id:`verification-failed:${r.method}`,rule:`verification-failed`,severity:`high`,label:Nl(r),epistemic:r.outcomeEpistemic});else if(r.outcome===`pass`&&r.scope!==`partial`){let n=r.method!==`lint`;Dl(e,t,e=>e.id===`verification-failed:${r.method}`||n&&e.rule===`changes-unverified`)}}}function Ml(e,t,n){switch(t.kind){case`permission.requested`:El(e,t,n,{id:`waiting:permission:${t.seq}`,rule:`waiting-permission`,severity:`high`,label:`Waiting for your permission`,instance:t.summary,epistemic:`observed`});break;case`notification`:e.waiting?.kind===`input`&&e.waiting.seq===t.seq&&El(e,t,n,{id:`waiting:input:${t.seq}`,rule:`waiting-input`,severity:`high`,label:`Agent needs input`,instance:q(t.message,120),epistemic:`observed`});break;case`tool.called`:if(t.input.kind===`question`&&El(e,t,n,{id:`waiting:question:${t.callId}`,rule:`waiting-question`,severity:`high`,label:`Asked you a question`,instance:q(t.input.questions[0]??`a question`,120),epistemic:`observed`}),t.input.kind===`command`){let r=ol(t.input.command);r&&El(e,t,n,{id:`destructive:${t.callId}`,rule:`destructive:${r.id}`,severity:r.id===`sudo`?`info`:`medium`,label:r.summary,instance:q(r.segment,100),epistemic:`observed`})}jl(e,t,n),Dl(e,t,e=>e.rule===`waiting-permission`||e.rule===`waiting-input`);break;case`tool.completed`:case`tool.failed`:if(Dl(e,t,e=>e.rule===`waiting-permission`||e.rule===`waiting-input`||e.id===`waiting:question:${t.callId}`),jl(e,t,n),t.kind===`tool.completed`&&t.result.kind===`command`&&!t.isError&&!t.result.gitOperation?.push){let r=e.activities[t.callId];r?.input.kind===`command`&&ul(r.input.command)===`push`&&El(e,t,n,{id:`push:${t.callId}`,rule:`git-push`,severity:`low`,label:`Pushed to remote`,epistemic:`inferred`})}t.kind===`tool.completed`&&t.result.kind===`command`&&t.result.gitOperation?.push&&El(e,t,n,{id:`push:${t.callId}`,rule:`git-push`,severity:`low`,label:`Pushed${t.result.gitOperation.push.branch?` ${t.result.gitOperation.push.branch}`:` to remote`}`,epistemic:`observed`});break;case`turn.started`:Dl(e,t,e=>e.rule.startsWith(`waiting-`));break;case`turn.ended`:{Dl(e,t,e=>e.rule.startsWith(`waiting-`));let r=e.turns.find(n=>n.id===(t.turnId??e.turns[e.turns.length-1]?.id));if(t.outcome===`failed`&&El(e,t,n,{id:`turn-failed:${t.seq}`,rule:`turn-failed`,severity:`high`,label:`Turn failed`,instance:q(t.error??`error`,120),epistemic:`observed`}),r){let i=[...e.verifications].filter(e=>e.outcome===`pass`&&e.scope!==`partial`&&e.method!==`lint`).sort((e,t)=>e.at.localeCompare(t.at)).pop(),a=Object.values(e.files).filter(e=>!i||e.lastChangedAt>i.at);if(r.filesTouched.length>0&&a.length>0){let r=i?`low`:`medium`,o=i?`${a.length} file${a.length===1?``:`s`} changed since the last passing check`:`${a.length} file${a.length===1?``:`s`} changed with no passing check observed`,s=e.review.find(e=>e.rule===`changes-unverified`&&e.resolvedSeq===void 0);s?(s.label=o,s.summary=o,s.severity=r,s.detail=a.map(e=>e.path).slice(0,50).join(`
76
+ `)):El(e,t,n,{id:`changes-unverified:${t.seq}`,rule:`changes-unverified`,severity:r,label:o,detail:a.map(e=>e.path).slice(0,50).join(`
77
+ `)})}t.lastMessage&&Al(t.lastMessage)&&(e.verifications.some(e=>e.turnId===r.id&&e.outcome===`pass`)||El(e,t,n,{id:`claim-without-evidence:${r.id}`,rule:`claim-without-evidence`,severity:`medium`,label:`Agent reports checks passing, but no passing check was observed this turn`,detail:q(t.lastMessage,300)}))}break}}}function Nl(e){let t=e.runner?` (${e.runner})`:``;return e.method===`test`?e.counts?.failed?`${e.counts.failed} test${e.counts.failed===1?``:`s`} failing${t}`:`Tests failing${t}`:`${e.method===`typecheck`?`Typecheck`:e.method===`lint`?`Lint`:e.method===`build`?`Build`:`Check`} failing${t}${e.counts?.failed?` (${e.counts.failed} errors)`:``}`}function Pl(e,t){if(t.seq<=e.latestSeq)return[];let n=new Sl(e.sessionId,t);switch(e.latestSeq=t.seq,e.revision+=1,e.lastEventAt=xu(e.lastEventAt,t.ts),t.redactions&&(e.counters.redactions+=t.redactions),t.kind){case`session.started`:Il(e,t,n);break;case`session.updated`:t.model&&(e.model=t.model),t.title&&(e.title=t.title),t.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&(e.cwd=t.cwd);break;case`session.ended`:e.endedAt=t.ts,n.add(`status`,`Session ended`,`observed`);break;case`turn.started`:Vl(e,t,n);break;case`turn.ended`:Hl(e,t,n);break;case`agent.message`:Ul(e,t,n);break;case`agent.thinking`:break;case`agent.usage`:Gl(e,t);break;case`tool.called`:Zl(e,t,n);break;case`tool.completed`:eu(e,t,n);break;case`tool.failed`:mu(e,t,n);break;case`subagent.started`:e.subagents[t.subagentId]={id:t.subagentId,agentType:t.agentType,description:t.description,startedAt:t.ts,toolCalls:0,eventId:t.id},n.add(`how`,`Delegated to ${t.agentType??`subagent`}: ${t.description??t.subagentId}`,`observed`);break;case`subagent.ended`:{let r=e.subagents[t.subagentId];r&&(r.endedAt=t.ts,r.lastMessage=t.lastMessage?q(rc(t.lastMessage),600):void 0,r.lastMessage&&(r.eventId=t.id)),n.add(`how`,`Subagent finished: ${r?.description??t.subagentId}`,`observed`);break}case`plan.updated`:vu(e,t,n);break;case`compaction`:{let r=e.lastCompactionAt?Date.parse(e.lastCompactionAt):NaN,i=Date.parse(t.ts);if(!Number.isNaN(r)&&!Number.isNaN(i)&&Math.abs(i-r)<6e4)break;e.lastCompactionAt=t.ts,e.counters.compactions+=1,n.add(`status`,`Context compacted`,`observed`);break}case`permission.requested`:e.waiting={kind:`permission`,since:t.ts,summary:t.summary,seq:t.seq};break;case`notification`:(t.notificationType===`idle_prompt`||t.notificationType===`agent_needs_input`)&&(e.waiting={kind:`input`,since:t.ts,summary:t.message,seq:t.seq});break;case`git.snapshot`:yu(e,t,n);break;case`ingest.warning`:e.counters.ingestWarnings+=1;break;case`salidium.explanation`:e.explained={basedOnSeq:t.basedOnSeq,model:t.model,at:t.ts,what:t.what,why:{...t.why,lanes:t.why.lanes??[]},how:{...t.how,root:t.how.root??null},approachChange:t.approachChange?{...t.approachChange,fromSteps:t.approachChange.fromSteps??[],toSteps:t.approachChange.toSteps??[]}:null},n.add(`what`,t.what.summary,`explained`,{model:t.model})}Ml(e,t,n);let r=e.status;return e.status=Tl(e),e.status!==r&&(e.statusSince=t.ts),n.changes}var Fl=/\.salidium[/\\]explainer$/;function Il(e,t,n){Fl.test(t.cwd)&&(e.internal=!0);let r=t.reason===`resume`;if((!e.startedAt||!r)&&(e.startedAt=e.startedAt??t.ts),t.cwd&&(e.cwd=t.cwd),t.model&&(e.model=t.model),t.entrypoint&&(e.entrypoint=t.entrypoint),t.gitBranch&&(e.gitBranch=t.gitBranch),t.title&&(e.title=t.title),t.transcriptPath&&(e.transcriptPath=t.transcriptPath),t.reason===`compact`||t.reason===`clear`)return;let i=Cl(e.cwd||``)||e.cwd;r?n.add(`status`,`Session resumed in ${i}`,`observed`,{model:e.model,reason:t.reason}):e.startLogged||(e.startLogged=!0,n.add(`status`,`Session started in ${i}`,`observed`,{model:e.model,reason:t.reason}))}function Ll(e){let t=e.turns[e.turns.length-1];return t&&!t.endedAt?t:void 0}function Rl(e,t){return t.turnId?e.turns.find(e=>e.id===t.turnId)||zl(e,t.turnId,``,t.ts,t.seq):e.turns.find(e=>e.startedAt<=t.ts&&(!e.endedAt||t.ts<=e.endedAt))??Ll(e)??e.turns[e.turns.length-1]}function zl(e,t,n,r,i){let a=Ll(e);if(a&&a.id!==t&&a.activityIds.length===0&&a.prompt===``)return a.id=t,a.prompt=n,a;a&&a.id!==t&&Bl(a,r,i,`interrupted`,!0);let o={id:t,index:e.turns.length,prompt:n,startedAt:r,activityIds:[],filesTouched:[],verificationIds:[],startSeq:i};return e.turns.push(o),e.counters.turns=e.turns.length,o}function Bl(e,t,n,r,i=!1){e.endedAt||(e.endedAt=t,e.endSeq=n,e.outcome=r,e.endInferred=i)}function Vl(e,t,n){t.prompt?.includes(`[salidium-explainer]`)&&(e.internal=!0);let r=t.turnId??`turn-${e.turns.length+1}`,i=e.turns.find(e=>e.id===r);if(i){if(i.prompt)return;i.prompt=t.prompt,i.startedAt=t.ts,i.startSeq=t.seq,e.waiting=void 0;let r=qc(t.prompt,140);n.add(`why`,r?`Asked: ${r}`:`New request`,`reported`,{author:`user`,turn:i.index});return}let a=zl(e,r,t.prompt,t.ts,t.seq);e.waiting=void 0;let o=qc(t.prompt,140);n.add(`why`,o?`Asked: ${o}`:`New request`,`reported`,{author:`user`,turn:a.index})}function Hl(e,t,n){let r=t.turnId?e.turns.find(e=>e.id===t.turnId):Ll(e);if(!r&&t.turnId&&(r=zl(e,t.turnId,``,t.ts,t.seq)),!r)return;if(r.endedAt&&!r.endInferred){t.lastMessage&&!r.lastMessage&&(r.lastMessage=t.lastMessage,Wl(e,t,t.lastMessage,`final`,n,r));return}r.endInferred=!1,r.endedAt=t.ts,r.endSeq=t.seq,r.outcome=t.outcome,r.lastMessage=t.lastMessage,r.error=t.error,e.waiting=void 0;for(let n of e.running){let i=e.activities[n];i&&i.turnId===r.id&&(i.status=`unknown`,i.endedAt=t.ts)}if(e.running=e.running.filter(t=>e.activities[t]?.turnId!==r.id),t.outcome===`failed`){e.issues.push({id:`turn-failed:${r.id}`,kind:`turnFailed`,summary:t.error??`Turn failed`,seq:t.seq,ts:t.ts}),n.add(`status`,`Turn failed: ${q(t.error??`error`,120)}`,`observed`);return}if(t.outcome===`interrupted`){e.issues.push({id:`interrupted:${r.id}`,kind:`interrupted`,summary:`Turn interrupted`,seq:t.seq,ts:t.ts}),n.add(`status`,`Turn interrupted`,`observed`);return}let i=t.lastMessage?qc(t.lastMessage,140):``;n.add(`status`,i?`Turn complete: ${i}`:`Turn complete`,i?`reported`:`observed`,{turn:r.index}),t.lastMessage&&Wl(e,t,t.lastMessage,`final`,n,r)}function Ul(e,t,n){let r=t.text.trim();if(!r)return;let i=Rl(e,t),a=t.phase??`commentary`;i&&!i.headline&&!t.agentId&&(i.headline=qc(r,140)),Wl(e,t,r,a,n,i)}function Wl(e,t,n,r,i,a){let o=Gc(n,r),s=a!==void 0&&e.claims.filter(e=>e.turnId===a.id&&!e.agentId).length===0;for(let[n,c]of o.entries()){let o={id:n===0?t.id:`${t.id}::${n}`,eventId:t.id,seq:t.seq,ts:t.ts,turnId:a?.id,agentId:t.agentId,kind:c.kind,text:c.text,confidence:c.confidence,rule:c.rule,phase:r,epistemic:`reported`};if(!e.claims.some(e=>e.text===o.text&&e.turnId===o.turnId)&&(e.claims.push(o),!t.agentId))switch(o.kind){case`discovery`:i.add(`why`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`approach`:i.add(`how`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`verification`:i.add(`verified`,`Agent says: ${o.text}`,`reported`,{claim:o.kind,rule:o.rule});break;case`remaining`:i.add(`left`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`question`:r===`final`&&(e.waiting={kind:`question`,since:t.ts,summary:o.text,seq:t.seq},i.add(`review`,`Agent asks: ${o.text}`,`reported`,{claim:o.kind,rule:o.rule}));break;case`summary`:r===`final`&&i.add(`what`,o.text,`reported`,{claim:o.kind});break;default:s&&n===0&&i.add(`status`,o.text,`reported`,{claim:o.kind,rule:o.rule})}}}function Gl(e,t){let n=e.usage,r=t.agentId??`main`,i=n.lastByLane[r];i?.messageId===t.messageId?(n.inputTokens-=i.inputTokens,n.outputTokens-=i.outputTokens,n.cacheReadTokens-=i.cacheReadTokens,n.cacheWriteTokens-=i.cacheWriteTokens):n.messages+=1,n.inputTokens+=t.inputTokens,n.outputTokens+=t.outputTokens,n.cacheReadTokens+=t.cacheReadTokens,n.cacheWriteTokens+=t.cacheWriteTokens,n.lastByLane[r]={messageId:t.messageId,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens}}function Kl(e){switch(e.source.channel){case`transcript`:case`rollout`:return 3;case`app-server`:return 2;case`hook`:return 1;case`salidium`:return 0}}function ql(e){return(e.input.kind===`other`?0:100)+Kl(e)}function Jl(e){let t=100;switch(e.result.kind){case`command`:t=e.result.exit.observation===`explicit`?500:e.result.exit.observation===`unknown`?300:400;break;case`fileChanges`:{let n=e.result.changes.filter(e=>e.applied);t=300+(n.some(e=>e.linesAdded+e.linesRemoved>0)?100:0)+(n.some(e=>!!e.hunks?.length)?50:0);break}case`fileRead`:t=300;break;case`subagent`:t=e.result.status===`completed`?400:300;break;case`generic`:t=e.result.excerpt?200:100}return t*10+Kl(e)}function Yl(e){return(e.exit?.observation===`explicit`?500:e.exit?.observation===`unknown`?300:e.exit?400:200)*10+Kl(e)}function Xl(e,t){e.eventIds.includes(t)||e.eventIds.push(t),e.eventIds.sort((e,t)=>e.localeCompare(t))}function Zl(e,t,n){let r=e.activities[t.callId];if(r){Ql(e,r,t,n);return}let i=Rl(e,t),a={callId:t.callId,turnId:i?.id,agentId:t.agentId,toolName:t.toolName,kind:t.input.kind,title:q(t.title,200),input:t.input.kind===`command`&&t.input.command.length>1200?{...t.input,command:`${t.input.command.slice(0,1200)}…`}:t.input,startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:ql(t),eventIds:[t.id]};e.activities[t.callId]=a,e.activityOrder.push(t.callId),e.running.push(t.callId),e.counters.toolCalls+=1,t.input.kind===`command`&&(e.counters.commands+=1),i?.activityIds.push(t.callId);let o=t.agentId?e.subagents[t.agentId]:void 0;if(o&&(o.toolCalls+=1),t.input.kind===`question`){let n=t.input.questions[0]??`question`;e.waiting={kind:`question`,since:t.ts,summary:n,seq:t.seq}}}function Ql(e,t,n,r){let i=t.input.kind===`other`&&t.seqCompleted!==void 0,a=ql(n);if(Xl(t,n.id),t.input.kind!==`other`&&a<=(t.callFidelity??-1))return;let o=t.input.kind,s=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,c=Rl(e,n);s&&c&&s.id!==c.id&&(s.activityIds=s.activityIds.filter(e=>e!==t.callId)),c&&!c.activityIds.includes(t.callId)&&c.activityIds.push(t.callId),t.turnId=c?.id??t.turnId,t.agentId=n.agentId??t.agentId,t.toolName=n.toolName,t.kind=n.input.kind,t.title=q(n.title,200),t.input=n.input.kind===`command`&&n.input.command.length>1200?{...n.input,command:`${n.input.command.slice(0,1200)}…`}:n.input,t.startedAt=n.ts,!t.resultDurationExplicit&&t.endedAt&&(t.durationMs=bu(n.ts,t.endedAt)),t.seqCalled=n.seq,t.callFidelity=a,o!==`command`&&n.input.kind===`command`&&(e.counters.commands+=1),o===`command`&&n.input.kind!==`command`&&--e.counters.commands;let l=n.agentId?e.subagents[n.agentId]:void 0;if(l&&i&&(l.toolCalls+=1),n.input.kind===`command`&&t.status!==`running`){if(t.result?.kind===`command`){du(e,t,{...n,id:t.eventIds.find(e=>e!==n.id)??n.id,kind:`tool.completed`,callId:t.callId,toolName:t.toolName,result:t.result,isError:t.isError,durationMs:t.durationMs},r,c),t.result=su(t.result);return}if(t.isError&&t.status===`failed`){for(let n=e.issues.length-1;n>=0;n--)e.issues[n]?.callId===t.callId&&e.issues[n]?.kind===`toolError`&&e.issues.splice(n,1);_u(e,t,{...n,id:t.eventIds.find(e=>e!==n.id)??n.id,kind:`tool.failed`,callId:t.callId,toolName:t.toolName,errorExcerpt:t.errorExcerpt??``,cause:t.failureCause??`error`,exit:t.exit,interrupted:t.failureCause===`interrupted`||void 0,durationMs:t.durationMs},r)}}}function $l(e,t,n){let r=e.activities[t];if(r)return r.status===`running`?(r.endedAt=n.ts,r.seqCompleted=n.seq,Xl(r,n.id),e.running=e.running.filter(e=>e!==t),e.waiting&&(e.waiting.kind===`permission`||e.waiting.kind===`input`)&&(e.waiting=void 0),r):r}function eu(e,t,n){let r=e.activities[t.callId];if(!r){let n=Rl(e,t);r={callId:t.callId,turnId:n?.id,agentId:t.agentId,toolName:t.toolName,kind:cu(t),title:t.toolName,input:{kind:`other`,summary:t.toolName},startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:0,eventIds:[]},e.activities[t.callId]=r,e.activityOrder.push(t.callId),e.counters.toolCalls+=1,n?.activityIds.push(t.callId),e.running.push(t.callId)}if(r.status!==`running`){tu(e,r,t,n);return}$l(e,t.callId,t),r.status=t.isError?`failed`:`completed`,r.isError=t.isError,r.result=t.result,r.resultFidelity=Jl(t),r.resultDurationExplicit=t.durationMs!==void 0,r.durationMs=t.durationMs??r.durationMs??bu(r.startedAt,t.ts),t.result.kind===`command`&&(r.exit=t.result.exit),t.isError&&(e.counters.toolFailures+=1),r.kind===`question`&&e.waiting?.kind===`question`&&(e.waiting=void 0);let i=r.turnId?e.turns.find(e=>e.id===r.turnId):void 0;switch(t.result.kind){case`fileChanges`:for(let a of t.result.changes)lu(e,r,a,t,n,i);break;case`command`:du(e,r,t,n,i);break;case`subagent`:{let n=t.result.agentId?e.subagents[t.result.agentId]:void 0;n&&(n.endedAt=n.endedAt??t.ts,n.lastMessage=n.lastMessage??t.result.summaryExcerpt)}}r.result=r.input.kind===`other`&&t.result.kind===`command`?t.result:su(t.result)}function tu(e,t,n,r){if(t.sourceConflict){Xl(t,n.id);return}let i=Jl(n);Xl(t,n.id);let a=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;if(n.result.kind===`command`&&t.result?.kind===`command`){if(ru(nu(t.result.exit,t.isError),nu(n.result.exit,n.isError))){au(e,t,n,r);return}if(i<=(t.resultFidelity??-1))return;t.exit=n.result.exit,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??bu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i;let o={...t,result:n.result,exit:n.result.exit},s=e.verifications.findIndex(e=>e.callId===t.callId),c=s>=0?e.verifications[s]:void 0;c&&(e.verifications.splice(s,1),a&&(a.verificationIds=a.verificationIds.filter(e=>e!==c.id)));let l=bl(o,n.seq);l&&fu(e,t,l,n,r,a,c===void 0||c.outcome!==l.outcome),t.result=su(n.result);return}if(n.result.kind===`fileChanges`&&t.result?.kind===`fileChanges`){if(i<=(t.resultFidelity??-1))return;for(let i of n.result.changes){let o=t.result.changes.find(e=>e.path===i.path);if(!o){lu(e,t,i,n,r,a);continue}let s=o.linesAdded+o.linesRemoved,c=i.linesAdded+i.linesRemoved,l=e.files[i.path];l&&(l.linesAdded+=i.linesAdded-o.linesAdded,l.linesRemoved+=i.linesRemoved-o.linesRemoved,e.counters.linesAdded+=i.linesAdded-o.linesAdded,e.counters.linesRemoved+=i.linesRemoved-o.linesRemoved,l.lastHunks=i.hunks?.slice(0,20),l.lastChangedAt=n.ts,l.lastChangeSeq=n.seq,l.lastAgentId=n.agentId,s===0&&c>0&&r.add(`what`,`${ou(i.change)} ${Cl(i.path)} (+${i.linesAdded} −${i.linesRemoved})`,`observed`,{path:i.path,change:i.change,linesAdded:i.linesAdded,linesRemoved:i.linesRemoved,agentId:n.agentId}))}t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??bu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.result=su(n.result);return}i<=(t.resultFidelity??-1)||(t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??bu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.result=su(n.result))}function nu(e,t){return t||e?.observation===`inferred-failure`?`fail`:e?.observation===`inferred-success`?`pass`:e?.observation===`explicit`?e.code===0?`pass`:`fail`:`unknown`}function ru(e,t){return e===`pass`&&t===`fail`||e===`fail`&&t===`pass`}function iu(e){return e.cause===`timeout`||e.cause===`interrupted`||e.cause===`rejected`||e.cause===`denied`?`unknown`:`fail`}function au(e,t,n,r){let i=[...new Set([...t.eventIds,n.id])].sort(),a=n.kind===`tool.failed`||n.isError,o=t.status===`failed`||t.isError;a&&!o&&(e.counters.toolFailures+=1);let s=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,c=e.verifications.find(e=>e.callId===t.callId);e.verifications=e.verifications.filter(e=>e.callId!==t.callId),s&&(s.verificationIds=s.verificationIds.filter(e=>e!==t.callId)),e.issues=e.issues.filter(e=>e.callId!==t.callId),e.review=e.review.filter(e=>!(e.rule===`verification-failed`&&e.refs.some(e=>i.includes(e))));let l=t.endedAt&&t.endedAt>n.ts?t.endedAt:n.ts,u=n.durationMs??bu(t.startedAt,n.ts)??0;t.endedAt=l,t.durationMs=Math.max(t.durationMs??0,u),t.seqCompleted=n.seq,t.eventIds=i,t.status=`unknown`,t.sourceConflict=!0,t.isError=!1,t.errorExcerpt=void 0,t.failureCause=void 0,t.exit={observation:`unknown`},t.result={kind:`command`,exit:{observation:`unknown`},outputExcerpt:``,outputChars:0,truncated:!1},e.running=e.running.filter(e=>e!==t.callId);let d=bl(t,n.seq);d?fu(e,t,{...d,outcome:`unknown`,counts:void 0,exit:{observation:`unknown`},outcomeEpistemic:`observed`,caveats:[...new Set([...d.caveats,`source-conflict`])],failureExcerpt:void 0},n,r,s):c&&t.input.kind===`command`&&fu(e,t,{...c,at:l,seq:n.seq,outcome:`unknown`,counts:void 0,exit:{observation:`unknown`},outcomeEpistemic:`observed`,caveats:[...new Set([...c.caveats,`source-conflict`])],failureExcerpt:void 0},n,r,s);let f=`source-conflict:${t.callId}`;if(!e.review.some(e=>e.id===f&&e.resolvedSeq===void 0)){let a=`Conflicting tool results`,o=q(t.input.kind===`command`?t.input.command:t.title,120);e.review.push({id:f,rule:`source-conflict`,severity:`high`,label:a,instance:o,summary:`${a}: ${o}`,detail:`The provider records disagree about whether this call succeeded.`,refs:i,createdSeq:n.seq,createdAt:l,epistemic:`observed`}),r.add(`review`,`${a}: ${o}`,`observed`,{rule:`source-conflict`,severity:`high`})}}function ou(e){return e===`add`?`Created`:e===`delete`?`Deleted`:e===`move`?`Moved`:`Changed`}function su(e){switch(e.kind){case`command`:return{...e,outputExcerpt:q(e.outputExcerpt,240)};case`fileChanges`:return{...e,changes:e.changes.map(e=>({...e,hunks:void 0}))};case`subagent`:return{...e,summaryExcerpt:e.summaryExcerpt?q(e.summaryExcerpt,400):void 0};case`generic`:return{...e,excerpt:e.excerpt?q(e.excerpt,240):void 0};default:return e}}function cu(e){switch(e.result.kind){case`command`:return`command`;case`fileChanges`:return`fileEdit`;case`fileRead`:return`fileRead`;case`subagent`:return`subagent`;default:return`other`}}function lu(e,t,n,r,i,a){if(!n.applied){e.issues.push({id:`patch:${r.id}:${n.path}`,kind:`patchFailed`,summary:`Patch not applied: ${Cl(n.path)}`,seq:r.seq,ts:r.ts,callId:t.callId}),i.add(`review`,`Patch not applied: ${Cl(n.path)}`,`observed`);return}let o=e.files[n.path],s=o??{path:n.path,changeCount:0,linesAdded:0,linesRemoved:0,kinds:[],firstChangedAt:r.ts,lastChangedAt:r.ts,lastChangeSeq:r.seq,lastCallId:t.callId,turnIds:[]};o||(e.files[n.path]=s,e.counters.filesChanged+=1),s.changeCount+=1,s.linesAdded+=n.linesAdded,s.linesRemoved+=n.linesRemoved,s.kinds.includes(n.change)||s.kinds.push(n.change),s.lastChangedAt=r.ts>s.lastChangedAt?r.ts:s.lastChangedAt,s.lastChangeSeq=r.seq,s.lastCallId=t.callId,s.lastAgentId=r.agentId,n.hunks&&(s.lastHunks=n.hunks.slice(0,20)),n.userModifiedBefore&&(s.userModifiedBefore=!0),a&&!s.turnIds.includes(a.id)&&s.turnIds.push(a.id),a&&!a.filesTouched.includes(n.path)&&a.filesTouched.push(n.path),e.counters.linesAdded+=n.linesAdded,e.counters.linesRemoved+=n.linesRemoved;for(let t of e.verifications)t.at<=r.ts&&(t.stale=!0);let c=ou(n.change),l=n.change===`delete`?``:` (+${n.linesAdded} −${n.linesRemoved})`;n.change===`update`&&n.linesAdded+n.linesRemoved===0&&!n.hunks||i.add(`what`,`${c} ${Cl(n.path)}${l}`,`observed`,{path:n.path,change:n.change,linesAdded:n.linesAdded,linesRemoved:n.linesRemoved,agentId:r.agentId}),n.userModifiedBefore&&i.add(`review`,`You had edited ${Cl(n.path)} before the agent changed it`,`observed`,{path:n.path,rule:`user-modified`})}var uu=/^\s*(ls|cat|head|tail|grep|rg|find|fd|pwd|which|echo|wc|tree|stat|file|du|df|env|printenv|git\s+(status|log|diff|show|blame|branch|remote|rev-parse|ls-files)|sed\s+-n|awk|jq|less|more|type|node\s+-e|python3?\s+-c|open|curl\s+-s)\b/;function du(e,t,n,r,i){if(t.input.kind!==`command`||n.result.kind!==`command`)return;let a=t.input.command,o=n.result;if(o.gitOperation)e.git.operations.push({op:o.gitOperation,at:n.ts,callId:t.callId}),o.gitOperation.commit&&(e.git.commits.push({sha:o.gitOperation.commit.sha,at:n.ts,callId:t.callId,kind:o.gitOperation.commit.kind}),e.git.head=o.gitOperation.commit.sha,r.add(`what`,`Committed ${wl(o.gitOperation.commit.sha)}`,`observed`,{sha:o.gitOperation.commit.sha})),o.gitOperation.push&&e.git.pushes.push({branch:o.gitOperation.push.branch,at:n.ts,callId:t.callId});else{let i=ul(a);if(i===`commit`&&!n.isError){let i=/\[[^\]]*\s([0-9a-f]{7,40})\]/.exec(o.outputExcerpt)?.[1];e.git.commits.push({sha:i??``,at:n.ts,callId:t.callId}),i&&(e.git.head=i),r.add(`what`,i?`Committed ${wl(i)}`:`Committed`,i?`observed`:`inferred`,{sha:i})}else i===`push`&&!n.isError&&e.git.pushes.push({at:n.ts,callId:t.callId})}let s=bl(t,n.seq);if(s){fu(e,t,s,n,r,i);return}if(n.isError){e.issues.push({id:`command:${n.id}`,kind:`commandFailed`,summary:`Command failed: ${q(a,100)}`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`Command failed: ${q(a,100)}`,`observed`,{exit:o.exit});return}!uu.test(a)&&(t.durationMs??0)>=3e4&&r.add(`what`,`Ran ${q(a,110)} (${Math.round((t.durationMs??0)/1e3)}s)`,`observed`)}function fu(e,t,n,r,i,a,o=!0){if(e.verifications.push(n),a?.verificationIds.push(n.id),o&&i.add(`verified`,pu(n),n.outcomeEpistemic,{outcome:n.outcome,runner:n.runner,method:n.method,counts:n.counts,caveats:n.caveats}),n.outcome===`fail`)e.issues.push({id:`verification:${n.id}`,kind:`commandFailed`,summary:pu(n),seq:r.seq,ts:r.ts,callId:t.callId});else if(n.outcome===`pass`&&n.scope!==`partial`)for(let t of e.issues)t.kind===`commandFailed`&&t.resolvedSeq===void 0&&t.id.startsWith(`verification:`)&&(t.resolvedSeq=r.seq)}function pu(e){let t=e.runner?` (${e.runner})`:``,n=e.counts,r=e.scope===`partial`?` [subset]`:``;if(e.method===`test`){if(e.outcome===`pass`){if(n?.total!==void 0&&n.total>0){let e=n.skipped?`, ${n.skipped} skipped`:``;return`${n.passed??0}/${n.total} tests passed${e}${t}${r}`}return`Tests passed${t}${r}${e.caveats?.includes(`exit-inferred`)?` (exit inferred)`:``}`}return e.outcome===`fail`?n?.failed!==void 0&&n.failed>0?`${n.failed} of ${n.total??`?`} tests failed${t}${r}`:`Tests failed${t}${r}`:e.outcome===`partial`?`Tests passed but command failed${t}`:`Test run result unknown${t}`}let i=e.method===`typecheck`?`Typecheck`:e.method===`lint`?`Lint`:e.method===`build`?`Build`:`Check`;return e.outcome===`pass`?`${i} passed${t}`:e.outcome===`fail`?`${i} failed${t}${n?.failed?` (${n.failed} error${n.failed===1?``:`s`})`:``}`:e.outcome===`partial`?`${i} partially passed${t}`:`${i} result unknown${t}`}function mu(e,t,n){hu(e,t,n);let r=e.activities[t.callId];r&&(r.errorExcerpt=r.errorExcerpt===void 0?void 0:q(r.errorExcerpt,400),r.result?.kind===`command`&&(r.result={...r.result,outputExcerpt:q(r.result.outputExcerpt,240)}))}function hu(e,t,n){let r=e.activities[t.callId];if(!r){let n=Rl(e,t);r={callId:t.callId,turnId:n?.id,agentId:t.agentId,toolName:t.toolName,kind:`other`,title:t.toolName,input:{kind:`other`,summary:t.toolName},startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:0,eventIds:[]},e.activities[t.callId]=r,e.activityOrder.push(t.callId),e.counters.toolCalls+=1,n?.activityIds.push(t.callId),e.running.push(t.callId)}if(r.sourceConflict){Xl(r,t.id);return}if(r.status!==`running`){r.result?.kind===`command`&&ru(nu(r.result.exit,r.isError),iu(t))?au(e,r,t,n):gu(e,r,t,n);return}if($l(e,t.callId,t),r.status=`failed`,r.isError=!0,r.errorExcerpt=t.errorExcerpt,r.failureCause=t.cause,r.resultFidelity=Yl(t),r.resultDurationExplicit=t.durationMs!==void 0,r.durationMs=t.durationMs??bu(r.startedAt,t.ts),t.exit&&(r.exit=t.exit),t.cause===`rejected`||t.cause===`denied`){r.status=`unknown`,e.waiting?.kind===`question`&&r.kind===`question`&&(e.waiting=void 0),n.add(`review`,`${t.cause===`rejected`?`You rejected`:`Denied`}: ${r.title}`,`observed`,{cause:t.cause});return}e.counters.toolFailures+=1,_u(e,r,t,n)}function gu(e,t,n,r){let i=Yl(n);if(Xl(t,n.id),i<=(t.resultFidelity??-1))return;let a=new Set(t.eventIds),o=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;e.verifications=e.verifications.filter(e=>e.callId!==t.callId),o&&(o.verificationIds=o.verificationIds.filter(e=>e!==t.callId)),e.issues=e.issues.filter(e=>e.callId!==t.callId),e.review=e.review.filter(e=>!(e.rule===`verification-failed`&&e.refs.some(e=>a.has(e)))),t.endedAt=n.ts,t.seqCompleted=n.seq,t.status=n.cause===`rejected`||n.cause===`denied`?`unknown`:`failed`,t.isError=!0,t.errorExcerpt=n.errorExcerpt,t.failureCause=n.cause,t.exit=n.exit,t.result=void 0,t.durationMs=n.durationMs??bu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,_u(e,t,n,r)}function _u(e,t,n,r){if(t.kind===`command`&&t.input.kind===`command`){let i=n.cause===`timeout`||n.cause===`interrupted`;t.result||={kind:`command`,exit:i?{observation:`unknown`}:n.exit??{observation:`inferred-failure`},outputExcerpt:n.errorExcerpt,outputChars:n.errorExcerpt.length,truncated:!1,interrupted:n.interrupted||n.cause===`interrupted`||void 0,timedOut:n.cause===`timeout`||void 0},i&&(t.exit={observation:`unknown`});let a=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,o=bl(t,n.seq);if(o){fu(e,t,o,n,r,a);return}if(n.interrupted){r.add(`what`,`Interrupted: ${q(t.input.command,100)}`,`observed`);return}e.issues.push({id:`command:${n.id}`,kind:`commandFailed`,summary:`Command failed: ${q(t.input.command,100)}`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`Command failed: ${q(t.input.command,100)}`,`observed`,{exit:n.exit});return}e.issues.push({id:`tool:${n.id}`,kind:`toolError`,summary:`${t.title} failed`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`${t.title} failed`,`observed`)}function vu(e,t,n){let r=e.plan.items,i;if(t.mode===`replace`)i=t.items.map(e=>({...e}));else{let e=new Map(r.map(e=>[e.id,{...e}]));for(let n of t.items){let t=e.get(n.id);e.set(n.id,t?{...t,status:n.status,text:n.text||t.text,activeForm:n.activeForm??t.activeForm}:{...n})}i=[...e.values()].filter(e=>e.status!==`cancelled`||r.some(t=>t.id===e.id))}e.plan={items:i,updatedAt:t.ts,updatedSeq:t.seq,explanation:t.explanation??e.plan.explanation};let a=i.filter(e=>e.status===`completed`).length,o=i.find(e=>e.status===`in_progress`),s=i.filter(e=>e.status===`pending`||e.status===`in_progress`).length,c=i.filter(e=>e.status===`completed`&&r.find(t=>t.id===e.id)?.status!==`completed`),l=r.length===0&&i.length>0;l&&n.add(`how`,`Plan: ${i.length} steps (${i.slice(0,3).map(e=>e.text).join(`; `)})`,`planned`,{items:i.length});for(let e of c)n.add(`left`,`Done: ${e.text}`,`reported`,{itemId:e.id,done:a,total:i.length});o&&(l||r.find(e=>e.id===o.id)?.status!==`in_progress`)&&n.add(`how`,`Now: ${o.activeForm??o.text}`,`planned`,{itemId:o.id}),t.explanation&&n.add(`why`,`Plan changed: ${t.explanation}`,`reported`);let u=JSON.stringify(r)!==JSON.stringify(i);!l&&c.length===0&&!o&&u&&n.add(`left`,s>0?`${s} of ${i.length} steps remaining`:`All plan steps completed`,`planned`,{pending:s,total:i.length})}function yu(e,t,n){let r=e.git.head;if(e.git.head=t.head??e.git.head,e.git.branch=t.branch??e.git.branch,e.git.dirtyCount=t.dirty.length+ +!!t.dirtyTruncated,e.git.snapshotAt=t.ts,e.repoRoot||=t.repoRoot,t.head&&r&&t.head!==r){let i=e.git.commits.find(e=>e.sha&&(t.head?.startsWith(e.sha)||e.sha.startsWith(t.head??``)));i?i.sha.length<t.head.length&&(i.sha=t.head):(e.git.headMoves.push({from:r,to:t.head,at:t.ts}),n.add(`what`,`HEAD moved to ${wl(t.head)}`,`observed`,{sha:t.head,branch:t.branch}))}}function bu(e,t){let n=Date.parse(e),r=Date.parse(t);if(!(Number.isNaN(n)||Number.isNaN(r)||r<n))return r-n}function xu(e,t){return e?t>e?t:e:t}function Su(e,t){if(e.status===`working`&&e.lastEventAt){let n=t-Date.parse(e.lastEventAt);if(Number.isFinite(n)&&n>9e5)return`idle`}return e.status}function Cu(e,t=Date.now()){let n=Su(e,t),r=e.verifications.map(t=>Nu(e,t)),i=r[r.length-1],a=Object.values(e.files).sort((e,t)=>t.lastChangeSeq-e.lastChangeSeq),o=[...e.verifications].filter(e=>e.outcome===`pass`&&e.scope!==`partial`&&e.method!==`lint`).sort((e,t)=>e.at.localeCompare(t.at)).pop(),s=e.review.filter(e=>e.resolvedSeq===void 0),c=s.filter(e=>e.severity!==`info`),l=s.slice().sort((e,t)=>wu(t.severity)-wu(e.severity)||t.createdSeq-e.createdSeq).map(Pu),u=zu(e),d=[...e.running].reverse().map(t=>e.activities[t]).find(e=>e&&!e.agentId&&t-Date.parse(e.startedAt)<6e5),f={status:n,statusSince:n===e.status?e.statusSince:e.lastEventAt,activeTitle:n===`working`?d?.title:void 0,activeSince:n===`working`?d?.startedAt:void 0,model:e.model,turns:e.turns.length,filesChanged:e.counters.filesChanged,linesAdded:e.counters.linesAdded,linesRemoved:e.counters.linesRemoved,commits:e.git.commits.length,latestVerification:i,reviewOpen:c.length,remaining:u.items.length,waiting:e.waiting?{kind:e.waiting.kind,summary:e.waiting.summary,since:e.waiting.since}:void 0},p=e.turns[e.turns.length-1],m=e=>e.kinds.includes(`delete`)?`-`:e.kinds.includes(`add`)&&e.kinds.length===1?`+`:`~`,h=ku(e,d,p,a,n)[0];return{strip:f,explained:e.explained,verdict:Du(e,n,d,o,c.length,a),report:{whatNow:h,editing:d&&(d.kind===`fileEdit`||d.kind===`fileWrite`)?d.title:a[0]?.path,ask:p?.prompt?{text:q(p.prompt,300),epistemic:`reported`,refs:[],at:p.startedAt,author:`user`}:void 0,plan:e.plan.items.map(e=>({text:e.text,status:e.status})),files:a.map(e=>({path:e.path,mark:m(e)})),runtimeMs:e.startedAt?Math.max(0,(e.lastEventAt?Date.parse(e.lastEventAt):t)-Date.parse(e.startedAt)):void 0},review:{glance:c.length===0?s.length===0?`Nothing needs you`:`Nothing needs you · ${s.length} noted`:`${c.length} item${c.length===1?``:`s`} need attention`,items:l,groups:Fu(l),resolvedCount:e.review.length-s.length},changes:{glance:Au(e),files:a.map(t=>Iu(e,t,o)),commands:e.activityOrder.map(t=>e.activities[t]).filter(e=>!!(e&&e.kind===`command`&&e.input.kind===`command`)).map(t=>Ru(e,t)),commits:e.git.commits.map(e=>({sha:e.sha,at:e.at,callId:e.callId}))},verified:{glance:ju(e,i),runs:r.slice().reverse(),summary:Mu(r),unverifiedFiles:a.filter(e=>!o||e.lastChangedAt>o.at).map(e=>e.path),claims:e.claims.filter(e=>e.kind===`verification`).map(e=>Ou(e))},left:u,turns:e.turns.map(t=>Bu(e,t,r)),subagents:Object.values(e.subagents).map(e=>({...e})),ingest:{warnings:e.counters.ingestWarnings,redactions:e.counters.redactions,compactions:e.counters.compactions},usage:e.usage.messages>0?{messages:e.usage.messages,inputTokens:e.usage.inputTokens,outputTokens:e.usage.outputTokens,cacheReadTokens:e.usage.cacheReadTokens,cacheWriteTokens:e.usage.cacheWriteTokens}:void 0}}function wu(e){return e===`high`?3:e===`medium`?2:+(e===`low`)}function Tu(e){return e.verifications.filter(t=>t.outcome===`fail`&&!e.verifications.some(e=>e.at>=t.at&&e.seq!==t.seq&&e.method===t.method&&e.outcome===`pass`&&e.scope!==`partial`))}function Eu(e,t){return t===void 0?e.length:e.filter(e=>e.lastChangedAt>t).length}function Du(e,t,n,r,i,a){let o=e.counters.filesChanged,s=e=>`${e} file${e===1?``:`s`}`;if(t===`waiting`&&e.waiting)return{headline:`Waiting for you`,tone:`attention`,epistemic:`observed`,because:e.waiting.summary,at:e.waiting.since,refs:[]};let c=Tu(e).pop();if(c){let e=Eu(a,c.at);return{headline:pu(c),tone:`fail`,epistemic:c.outcomeEpistemic,because:e>0?`${s(e)} changed after this check, so it may be out of date.`:c.caveats.includes(`exit-inferred`)?`Read from the output; the command reported no exit code.`:void 0,at:c.at,refs:[c.callId]}}if(t===`working`&&n)return{headline:n.title,tone:`working`,epistemic:`observed`,because:o>0?`${Au(e)} so far.`:void 0,at:n.startedAt,refs:[n.callId]};let l=Eu(a,r?.at);return o>0&&l>0?{headline:`${s(o)} changed, unverified`,tone:`attention`,epistemic:`observed`,because:r?`${s(l)} changed after the last passing check (${pu(r)}).`:`No passing test, build or typecheck run was observed in this session.`,at:r?.at,refs:r?[r.callId]:[]}:r?{headline:pu(r),tone:`pass`,epistemic:r.outcomeEpistemic,because:r.caveats.includes(`exit-inferred`)?`Read from the output; the command reported no exit code.`:o>0?`Ran after the last of ${s(o)} changed.`:void 0,at:r.at,refs:[r.callId]}:i>0?{headline:`${i} thing${i===1?``:`s`} need${i===1?`s`:``} you`,tone:`attention`,epistemic:`inferred`,refs:[]}:o>0?{headline:`${s(o)} changed`,tone:`neutral`,epistemic:`observed`,because:`No checks were observed in this session.`,refs:[]}:{headline:e.turns.length===0?`Nothing recorded yet`:`No files changed`,tone:`neutral`,epistemic:`observed`,refs:[]}}function Ou(e){return{text:e.text,epistemic:`reported`,refs:[e.id],at:e.ts,author:e.agentId?`subagent`:`agent`}}function ku(e,t,n,r,i){let a=[];if(i===`working`&&n){let t=[...e.claims].reverse().find(e=>e.turnId===n.id&&!e.agentId&&e.kind!==`question`);t?a.push({text:t.text,epistemic:`reported`,refs:[t.id],at:t.ts,author:`agent`}):n.headline?a.push({text:n.headline,epistemic:`reported`,refs:[],at:n.startedAt,author:`agent`}):a.push({text:`Working on: ${q(n.prompt,140)}`,epistemic:`reported`,refs:[],at:n.startedAt,author:`user`})}else if(n?.lastMessage){let t=e.claims.filter(e=>e.turnId===n.id&&e.phase===`final`&&e.kind===`summary`).pop();a.push({text:t?.text??qc(n.lastMessage,300),epistemic:`reported`,refs:t?[t.id]:[],at:n.endedAt,author:`agent`})}else n?.headline&&a.push({text:n.headline,epistemic:`reported`,refs:[],at:n.startedAt,author:`agent`});let o=r.slice(0,6);t===void 0&&o.length>0&&a.push({text:`Recently: ${o.map(e=>Cl(e.path)).join(`, `)}`,epistemic:`observed`,refs:o.map(e=>e.lastCallId)});let s=e.git.commits;return s.length>0&&a.push({text:`${s.length} commit${s.length===1?``:`s`}: ${s.map(e=>wl(e.sha||`???????`)).join(`, `)}`,epistemic:`observed`,refs:s.map(e=>e.callId??``).filter(Boolean)}),a}function Au(e){let t=e.counters,n=[];return n.push(t.filesChanged===0?`No files changed`:`${t.filesChanged} file${t.filesChanged===1?``:`s`} changed (+${t.linesAdded} −${t.linesRemoved})`),t.commands>0&&n.push(`${t.commands} command${t.commands===1?``:`s`}`),e.git.commits.length>0&&n.push(`${e.git.commits.length} commit${e.git.commits.length===1?``:`s`}`),n.join(` · `)}function ju(e,t){return t?`${t.label}${t.stale?` (before latest changes)`:``}`:e.counters.filesChanged>0?`No checks observed`:`No checks yet`}function Mu(e){let t=new Map;for(let n of e){let e=t.get(n.method);if(n.outcome===`unknown`){e?e.outcome===`unknown`?t.set(n.method,{...n,laterUnreadable:0}):e.laterUnreadable+=1:t.set(n.method,{...n,laterUnreadable:0});continue}t.set(n.method,{...n,laterUnreadable:0})}return[...t.values()]}function Nu(e,t){let n=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;return{id:t.id,callId:t.callId,at:t.at,label:pu(t),method:t.method,runner:t.runner,outcome:t.outcome,counts:t.counts,scope:t.scope,exit:t.exit,epistemic:t.outcomeEpistemic,caveats:t.caveats,stale:t.stale,command:t.command,failureExcerpt:t.failureExcerpt,turnIndex:n?.index}}function Pu(e){return{id:e.id,rule:e.rule,severity:e.severity,label:e.label,instance:e.instance,summary:e.summary,detail:e.detail,refs:e.refs,createdAt:e.createdAt,epistemic:e.epistemic}}function Fu(e){let t=new Map;for(let n of e){let e=t.get(n.rule);if(!e){t.set(n.rule,{rule:n.rule,label:n.label,severity:n.severity,occurrences:1,items:[{...n,repeats:1}],createdAt:n.createdAt});continue}e.occurrences++,wu(n.severity)>wu(e.severity)&&(e.severity=n.severity),n.createdAt>e.createdAt&&(e.createdAt=n.createdAt);let r=n.instance??n.label,i=e.items.find(e=>(e.instance??e.label)===r);i?i.repeats++:e.items.push({...n,repeats:1})}return[...t.values()]}function Iu(e,t,n){let r=t.turnIds.map(t=>e.turns.find(e=>e.id===t)?.index).filter(e=>e!==void 0),i=t.turnIds[t.turnIds.length-1],a=i?Lu(e,i,t):void 0;return{path:t.path,changeCount:t.changeCount,linesAdded:t.linesAdded,linesRemoved:t.linesRemoved,kinds:t.kinds,lastChangedAt:t.lastChangedAt,lastCallId:t.lastCallId,verifiedAfter:n!==void 0&&n.at>t.lastChangedAt,verifiedBy:n!==void 0&&n.at>t.lastChangedAt?pu(n):void 0,turnIndexes:r,reason:a}}function Lu(e,t,n){let r=n.lastAgentId,i=e.claims.filter(e=>(r?e.agentId===r:e.turnId===t&&!e.agentId)&&e.ts<=n.lastChangedAt&&(e.kind===`approach`||e.kind===`discovery`||e.kind===`status`)).sort((e,t)=>e.ts.localeCompare(t.ts)),a=Cl(n.path).replace(/\.[^.]+$/,``),o=[...i].reverse().find(e=>a.length>2&&e.text.includes(a))??i[i.length-1];if(o)return{text:o.text,epistemic:`reported`,refs:[o.id],at:o.ts,author:r?`subagent`:`agent`};if(r){let t=e.subagents[r];if(t?.description)return{text:`Subagent: ${t.description}`,epistemic:`observed`,refs:[],at:t.startedAt,author:`subagent`}}}function Ru(e,t){let n=t.input.kind===`command`?t.input:void 0,r=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;return{callId:t.callId,command:n?.command??t.title,description:n?.description,at:t.startedAt,status:t.status,exit:t.exit,durationMs:t.durationMs,isVerification:e.verifications.some(e=>e.callId===t.callId),turnIndex:r?.index,agentId:t.agentId}}function zu(e){let t=[];for(let n of e.plan.items)(n.status===`pending`||n.status===`in_progress`)&&t.push({id:`plan:${n.id}`,text:n.text,status:n.status,epistemic:`planned`,source:`plan`,refs:[]});let n=Tu(e),r=new Set;for(let e of n)r.has(e.method)||(r.add(e.method),t.push({id:`verification:${e.id}`,text:pu(e),status:`failing`,epistemic:e.outcomeEpistemic,source:`verification`,refs:[e.callId]}));let i=e.turns[e.turns.length-1],a=e.claims.filter(e=>e.kind===`remaining`&&!e.agentId&&(!i||e.turnId===i.id));for(let e of a.slice(-5))t.push({id:`claim:${e.id}`,text:e.text,status:`reported`,epistemic:`reported`,source:`agent`,refs:[e.id]});let o=e.plan.items.filter(e=>e.status===`pending`||e.status===`in_progress`).length,s=[];return e.plan.items.length>0&&s.push(o===0?`All plan steps done`:`${o} of ${e.plan.items.length} steps remaining`),n.length>0&&s.push(`${n.length} failing check${n.length===1?``:`s`}`),a.length>0&&s.push(`${a.length} item${a.length===1?``:`s`} agent says remain`),{glance:s.length?s.join(` · `):t.length===0?`Nothing recorded as remaining`:`${t.length} remaining`,items:t,planExplanation:e.plan.explanation}}function Bu(e,t,n){let r=t.activityIds.map(t=>e.activities[t]).filter(e=>!!e),i=0,a=0;for(let e of r)if(e.result?.kind===`fileChanges`)for(let t of e.result.changes)i+=t.linesAdded,a+=t.linesRemoved;return{id:t.id,index:t.index,prompt:q(t.prompt,120),headline:t.headline,startedAt:t.startedAt,endedAt:t.endedAt,outcome:t.outcome,lastMessage:t.lastMessage,activityCount:r.length,files:t.filesTouched,linesAdded:i,linesRemoved:a,verifications:n.filter(e=>t.verificationIds.includes(e.id)),activities:r.map(e=>({callId:e.callId,kind:e.kind,title:e.title,toolName:e.toolName,startedAt:e.startedAt,durationMs:e.durationMs,status:e.status,agentId:e.agentId,isVerification:t.verificationIds.includes(e.callId),exit:e.exit,eventIds:e.eventIds})),claims:e.claims.filter(e=>e.turnId===t.id).map(Ou)}}var Vu=`(?![A-Za-z0-9._~+/=-])`;[{id:`aws-access-key`,label:`AWS_KEY`,pattern:/\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\b/g,group:1,entropy:3,keywords:[`akia`,`asia`,`abia`,`acca`,`a3t`]},{id:`aws-secret-key`,label:`AWS_SECRET`,pattern:/(?:aws|secret)[\w.-]{0,24}?(?:secret|access)[\w.-]{0,16}?\s*[:=]\s*['"]?([A-Za-z0-9/+=]{40})\b/gi,group:1,entropy:3.5,keywords:[`aws`,`secret`]},{id:`github-token`,label:`GITHUB_TOKEN`,pattern:/\b((?:ghp|gho|ghu|ghs|ghr)_[0-9a-zA-Z_]{20,255}|github_pat_[0-9a-zA-Z_]{22,255})\b/g,group:1,keywords:[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`]},{id:`gitlab-token`,label:`GITLAB_TOKEN`,pattern:/\b(glpat-[0-9a-zA-Z_-]{20,300})\b/g,group:1,keywords:[`glpat-`]},{id:`openai-key`,label:`OPENAI_KEY`,pattern:new RegExp(String.raw`\b(sk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,}T3BlbkFJ[A-Za-z0-9_-]{20,}|sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20})${Vu}`,`g`),group:1,keywords:[`t3blbkfj`]},{id:`anthropic-key`,label:`ANTHROPIC_KEY`,pattern:new RegExp(String.raw`\b(sk-ant-(?:api|admin)\d{2}-[a-zA-Z0-9_-]{80,}AA)${Vu}`,`g`),group:1,keywords:[`sk-ant-`]},{id:`slack-token`,label:`SLACK_TOKEN`,pattern:/\b(xox[abpers]-[0-9]{8,13}-[0-9A-Za-z-]{8,})\b/g,group:1,keywords:[`xox`]},{id:`slack-webhook`,label:`SLACK_WEBHOOK`,pattern:/(https?:\/\/hooks\.slack\.com\/(?:services|workflows|triggers)\/[A-Za-z0-9+/]{20,})/g,group:1,keywords:[`hooks.slack.com`]},{id:`stripe-key`,label:`STRIPE_KEY`,pattern:new RegExp(String.raw`\b((?:sk|rk)_(?:test|live|prod)_[a-zA-Z0-9]{10,99})${Vu}`,`g`),group:1,keywords:[`sk_test`,`sk_live`,`sk_prod`,`rk_test`,`rk_live`,`rk_prod`]},{id:`google-api-key`,label:`GOOGLE_KEY`,pattern:new RegExp(String.raw`\b(AIza[\w-]{35})${Vu}`,`g`),group:1,entropy:4,keywords:[`aiza`]},{id:`npm-token`,label:`NPM_TOKEN`,pattern:new RegExp(String.raw`\b(npm_[a-zA-Z0-9]{36})${Vu}`,`g`),group:1,keywords:[`npm_`]},{id:`pypi-token`,label:`PYPI_TOKEN`,pattern:/\b(pypi-AgEIcHlwaS5vcmc[\w-]{50,1000})\b/g,group:1,keywords:[`pypi-ageichlwas5vcmc`]},{id:`huggingface-token`,label:`HF_TOKEN`,pattern:new RegExp(String.raw`\b(hf_[a-zA-Z]{34})${Vu}`,`g`),group:1,keywords:[`hf_`]},{id:`sendgrid-key`,label:`SENDGRID_KEY`,pattern:new RegExp(String.raw`\b(SG\.[a-zA-Z0-9=_.-]{66})${Vu}`,`g`),group:1,keywords:[`sg.`]},{id:`digitalocean-token`,label:`DO_TOKEN`,pattern:/\b(dop_v1_[a-f0-9]{64})\b/g,group:1,keywords:[`dop_v1_`]},{id:`vault-token`,label:`VAULT_TOKEN`,pattern:/\b(hvs\.[\w-]{90,120})\b/g,group:1,keywords:[`hvs.`]},{id:`jwt`,label:`JWT`,pattern:new RegExp(String.raw`\b(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9/\\_-]{17,}\.[a-zA-Z0-9/\\_-]{10,}={0,2})${Vu}`,`g`),group:1,entropy:3,keywords:[`ey`]},{id:`private-key`,label:`PRIVATE_KEY`,pattern:/(-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,4000}?-----END[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----)/g,group:1,keywords:[`-----begin`]},{id:`bearer-header`,label:`BEARER_TOKEN`,pattern:/(?:authorization|x-api-key)\s*[:=]\s*(?:bearer\s+|token\s+|basic\s+)?['"]?([A-Za-z0-9._~+/=-]{16,})/gi,group:1,entropy:3,keywords:[`authorization`,`x-api-key`]},{id:`url-credentials`,label:`URL_PASSWORD`,pattern:/\b[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:([^@\s/]{3,})@/gi,group:1,keywords:[`://`]},{id:`generic-secret`,label:`SECRET`,pattern:/(?:^|[\s"'`{(,])(?:[\w.-]{0,30}?(?:passw(?:or)?d|secret|token|api[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token))[\w.-]{0,10}\s*(?:=|:|=>|:=)\s*["'`]?([A-Za-z0-9_+/=.~!#$%^&*-]{12,200})/gi,group:1,entropy:3.5,keywords:[`password`,`passwd`,`secret`,`token`,`api_key`,`api-key`,`apikey`,`access_key`,`accesskey`,`private_key`,`client_secret`,`auth_token`]}].map(e=>e.id);var Hu=[`status`,`what`,`why`,`how`,`verified`,`left`,`review`],Uu=`salidium.detail`,Wu=`salidium.sidebar`,Gu=`salidium.theme`,Ku=`salidium.stats`,qu=`salidium.ingest`,Ju=`salidium.rewind`,Yu=`salidium.sideFolds`,Xu=`Nothing recorded`;function Zu(){let e=localStorage.getItem(Yu);if(e===null)return[Xu];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Qu(e){e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}function $u(){let e=localStorage.getItem(Gu);return e===`light`||e===`dark`?e:`system`}function ed(){let e=localStorage.getItem(Uu);return e===`1`?1:e===`2`?2:0}Qu($u());function td(e,t){return e.ts.localeCompare(t.ts)||e.seq-t.seq||e.ordinal-t.ordinal}var nd=0,J=0;function rd(e){return e instanceof Error?e.message:String(e)}function id(e,t){let n={...e};for(let e of t){if(e.internal||e.title?.includes(`[salidium-explainer]`)){delete n[e.id];continue}n[e.id]=e}return n}function ad(e){return Object.values(e).sort((e,t)=>(t.lastEventAt??t.startedAt??``).localeCompare(e.lastEventAt??e.startedAt??``)).map(e=>e.id)}function od(e){let t=e.health;return{observedAt:t.observedAt,state:t.collection.state,pause:t.collection.pausedAt&&t.collection.pauseExpiresAt&&t.collection.pauseReason?{pausedAt:t.collection.pausedAt,expiresAt:t.collection.pauseExpiresAt,reason:t.collection.pauseReason}:null,queue:{files:t.queue.files??0,bytes:t.queue.bytes??0,oldestAt:t.queue.oldestAt},store:{bytes:t.store.totalBytes,retention:t.store.retention,lastIngestAt:t.store.lastIngestAt},health:t.overall===`critical`?`runaway`:t.overall===`attention`?`attention`:`healthy`,gaps:{active:t.gaps.activeEpisodes,recovered:t.gaps.recoveredEpisodes,omittedEpisodes:t.gaps.omitted}}}var Y=i((e,t)=>({api:void 0,detail:ed(),panel:void 0,sidebarOpen:localStorage.getItem(Wu)!==`0`,statsOpen:localStorage.getItem(Ku)===`1`,ingestOpen:localStorage.getItem(qu)===`1`,rewindOpen:localStorage.getItem(Ju)===`1`,sessionQuery:``,sessionSearch:void 0,folded:Zu(),historyMode:`off`,historyKinds:[...Hu],theme:$u(),sessions:{},sessionOrder:[],sessionsLoaded:!1,listConnection:`connecting`,selectedId:void 0,live:{},liveErrors:{},rawOpen:void 0,explainer:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalization:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{},daemonError:void 0,authRejected:!1,openPanel:t=>e({panel:t}),closePanel:()=>e({panel:void 0}),setToken:n=>{nd++,J++,e({api:new zs(n,{onUnauthorized:()=>t().unauthorized()}),authRejected:!1,daemonError:void 0,personalization:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})},unauthorized:()=>{t().api&&(nd++,J++,qs(),e({api:void 0,authRejected:!0,live:{},liveErrors:{},rawOpen:void 0,explainer:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalization:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}}))},setDetail:t=>{localStorage.setItem(Uu,String(t)),e({detail:t})},loadExplainer:()=>{let n=t().api;n&&n.explainerSettings().then(t=>e({explainer:t}),()=>{})},loadCollection:()=>{let n=t().api;if(!n||t().operationsPending)return;let r=++J;t().operations||e({collectionLoading:!0,collectionError:void 0}),Promise.all([n.operations(),n.info()]).then(([i,a])=>{r===J&&n===t().api&&e({operations:i,collection:od(i),collectionInfo:a,collectionLoading:!1,collectionError:void 0})},i=>{r===J&&n===t().api&&e({collectionLoading:!1,collectionError:rd(i)})})},setCollection:async n=>{let r=t().api;if(!r){e({operationsActionError:`daemon is not connected`});return}if(t().operationsPending)throw Error(`another operations action is still running`);let i=++J;e({operationsPending:`collection`,operationsActionError:void 0});try{let a=await r.setCollection(n),o=await r.operations();i===J&&r===t().api&&e({collection:a,operations:o,operationsPending:void 0})}catch(n){i===J&&r===t().api&&e({operationsPending:void 0,operationsActionError:rd(n)})}},setOperationalConfig:async n=>{let r=t().api,i=t().operations;if(!r||!i)throw Error(`operational configuration is not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let a=++J;e({operationsPending:`policy`,operationsActionError:void 0});try{let o=await r.setOperationalConfig(n,i.config.revision);a===J&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,config:o}:e.operations,operationsPending:void 0}))}catch(n){throw a===J&&r===t().api&&e({operationsPending:void 0,operationsActionError:rd(n)}),n}},resetOperationalConfig:async n=>{let r=t().api,i=t().operations;if(!r||!i)throw Error(`operational configuration is not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let a=++J;e({operationsPending:`reset`,operationsActionError:void 0});try{let o=await r.resetOperationalConfig(n,i.config.revision);a===J&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,config:o}:e.operations,operationsPending:void 0}))}catch(n){throw a===J&&r===t().api&&e({operationsPending:void 0,operationsActionError:rd(n)}),n}},drainQueue:async()=>{let n=t().api;if(!n)throw Error(`daemon is not connected`);if(t().operationsPending)throw Error(`another operations action is still running`);let r=++J;e({operationsPending:`drain`,operationsActionError:void 0});try{await n.drainQueue();let i=await n.operations();r===J&&n===t().api&&e({operations:i,collection:od(i),operationsPending:void 0})}catch(i){throw r===J&&n===t().api&&e({operationsPending:void 0,operationsActionError:rd(i)}),i}},acknowledgeAlert:async n=>{let r=t().api;if(!r||!t().operations)throw Error(`operations are not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let i=++J;e({operationsPending:`alert`,operationsActionError:void 0});try{let a=await r.acknowledgeAlert(n);i===J&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,alerts:a}:e.operations,operationsPending:void 0}))}catch(n){throw i===J&&r===t().api&&e({operationsPending:void 0,operationsActionError:rd(n)}),n}},disconnectHooks:async n=>{let r=t().api;if(!r){e({operationsActionError:`daemon is not connected`});return}if(t().operationsPending)throw Error(`another operations action is still running`);let i=++J;e({operationsPending:`disconnect`,operationsActionError:void 0});try{let a=await r.disconnectHooks(n),o=await r.info(),s=await r.operations();i===J&&r===t().api&&e({collection:a,operations:s,collectionInfo:o,operationsPending:void 0})}catch(n){i===J&&r===t().api&&e({operationsPending:void 0,operationsActionError:rd(n)})}},loadPersonalization:()=>{let n=t().api;if(!n)return;let r=++nd;e({personalizationLoading:!0,personalizationLoadError:void 0}),n.personalizationSettings().then(i=>{if(r!==nd||n!==t().api)return;let a=t().personalization;e({personalization:i,personalizationLoading:!1,personalizationLoadError:void 0,...a&&a.revision!==i.revision?{personalized:{}}:{}})},()=>{r===nd&&n===t().api&&e({personalizationLoading:!1,personalizationLoadError:`Could not load saved terms.`})})},setExplainerSettings:n=>{let r=t().api;if(!r)return;let i=t().explainer;i&&e({explainer:{...i,...n}}),r.setExplainerSettings(n).then(t=>e({explainer:t}),()=>e({explainer:i}))},savePersonalization:async n=>{let r=t().api,i=t().personalization;if(!r||!i)throw Error(`personalization is not loaded`);nd++;try{e({personalization:await r.setPersonalizationSettings(n,i.revision),personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})}catch(e){throw e instanceof Error&&`status`in e&&e.status===409&&t().loadPersonalization(),e}},deletePersonalization:async()=>{let n=t().api,r=t().personalization;if(!n||!r)throw Error(`personalization is not loaded`);nd++;try{e({personalization:await n.deletePersonalizationSettings(r.revision),personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})}catch(e){throw e instanceof Error&&`status`in e&&e.status===409&&t().loadPersonalization(),e}},personalizeSession:async n=>{let r=t().api;if(!r)throw Error(`daemon is not connected`);let i=await r.personalizedPresentation(n),a=t().personalization,o=t().live[n]?.state.explained;if(!a||i.profileRevision!==a.revision||i.basedOnSeq!==o?.basedOnSeq)throw Error(`the explanation changed while personalization was running`);e(e=>({personalized:{...e.personalized,[n]:i}}))},setTheme:t=>{localStorage.setItem(Gu,t),Qu(t),e({theme:t})},toggleSidebar:()=>e(e=>{let t=!e.sidebarOpen;return localStorage.setItem(Wu,t?`1`:`0`),{sidebarOpen:t}}),toggleRewind:()=>e(e=>{let t=!e.rewindOpen;return localStorage.setItem(Ju,t?`1`:`0`),{rewindOpen:t}}),toggleStats:()=>e(e=>{let t=!e.statsOpen;return localStorage.setItem(Ku,t?`1`:`0`),t&&localStorage.setItem(qu,`0`),{statsOpen:t,...t?{ingestOpen:!1}:{}}}),toggleIngest:()=>e(e=>{let t=!e.ingestOpen;return localStorage.setItem(qu,t?`1`:`0`),t&&localStorage.setItem(Ku,`0`),{ingestOpen:t,...t?{statsOpen:!1}:{}}}),setSessionQuery:t=>e({sessionQuery:t}),toggleFold:t=>e(e=>{let n=e.folded.includes(t)?e.folded.filter(e=>e!==t):[...e.folded,t];return localStorage.setItem(Yu,JSON.stringify(n)),{folded:n}}),setHistoryMode:t=>e({historyMode:t}),setHistoryKinds:t=>e({historyKinds:t.length===0?[...Hu]:t}),upsertSessions:t=>e(e=>{let n=id(e.sessions,t);return{sessions:n,sessionOrder:ad(n),sessionsLoaded:!0}}),setSessionSearch:t=>e(e=>{if(t.query!==e.sessionQuery.trim())return{};let n=id(e.sessions,t.sessions);return{sessions:n,sessionOrder:ad(n),sessionSearch:{query:t.query,ids:t.query?t.sessions.map(e=>e.id):void 0,matched:t.matched,total:t.total}}}),removeSession:t=>e(e=>{let n={...e.sessions};delete n[t];let r={...e.live};return delete r[t],{sessions:n,sessionOrder:ad(n),live:r,selectedId:e.selectedId===t?void 0:e.selectedId}}),select:t=>e({selectedId:t,rawOpen:void 0}),setListConnection:t=>e(e=>({listConnection:t,daemonError:t===`open`?void 0:t===`reconnecting`||t===`closed`?{message:`connection to the daemon was lost`,unreachable:!0}:e.daemonError})),setDaemonError:t=>e({daemonError:t}),setLiveError:(t,n)=>e(e=>e.liveErrors[t]===n?{}:{liveErrors:{...e.liveErrors,[t]:n}}),initLive:(t,n,r)=>e(e=>({live:{...e.live,[t]:{state:n,revision:1,changes:[...r].sort(td),connection:`connecting`,lastSeenSeq:e.live[t]?.lastSeenSeq??n.latestSeq}},liveErrors:e.liveErrors[t]?{...e.liveErrors,[t]:void 0}:e.liveErrors})),applyEvents:(n,r,i)=>{let a=t().live[n];if(!a)return;let o=0;for(let e of r){let t=Pl(a.state,e);t.length&&a.changes.push(...t),o++}if(o>0&&i.length===0&&a.changes.sort(td),i.length){let e=new Set(a.changes.map(e=>`${e.seq}:${e.ordinal}`));for(let t of i)e.has(`${t.seq}:${t.ordinal}`)||a.changes.push(t);a.changes.sort(td)}(o!==0||i.length!==0)&&e(e=>({live:{...e.live,[n]:{...a,revision:a.revision+1}}}))},setLiveConnection:(t,n,r)=>e(e=>{let i=e.live[t];return i?{live:{...e.live,[t]:{...i,connection:n,error:r}}}:{}}),setScrub:(t,n)=>e(e=>{let r=e.live[t];return r?{live:{...e.live,[t]:{...r,scrub:n}}}:{}}),markSeen:t=>e(e=>{let n=e.live[t];return n?{live:{...e.live,[t]:{...n,lastSeenSeq:n.state.latestSeq}}}:{}}),openRaw:(t,n)=>e({rawOpen:{sessionId:t,eventId:n}}),closeRaw:()=>e({rawOpen:void 0})})),sd={copy:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`8`,height:`8`,rx:`1.8`}),(0,W.jsx)(`path`,{d:`M10.5 2.5H4.2A1.7 1.7 0 0 0 2.5 4.2v6.3`})]}),check:(0,W.jsx)(`path`,{d:`M3 8.4l3.4 3.2L13 4.8`}),edit:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`m3 11.8.6-2.8 6.8-6.8 2.4 2.4L6 11.4Z`}),(0,W.jsx)(`path`,{d:`m9.2 3.4 2.4 2.4M3 13h10`})]}),trash:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3.5 4.5h9M6 4.5V3h4v1.5M5 6.5l.5 6h5l.5-6`}),(0,W.jsx)(`path`,{d:`M7 7v3.5M9 7v3.5`})]}),panel:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`2`}),(0,W.jsx)(`path`,{d:`M6.5 3v10`})]}),history:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,W.jsx)(`path`,{d:`M8 5v3.2l2 1.4`})]}),sliders:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M2 5h8M12.5 5H14M2 11h2.5M7 11h7`}),(0,W.jsx)(`circle`,{cx:`11`,cy:`5`,r:`1.5`}),(0,W.jsx)(`circle`,{cx:`5.5`,cy:`11`,r:`1.5`})]}),sun:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`}),(0,W.jsx)(`path`,{d:`M8 1.5v1.2M8 13.3v1.2M2.4 2.4l.9.9M12.7 12.7l.9.9M1.5 8h1.2M13.3 8h1.2M2.4 13.6l.9-.9M12.7 3.3l.9-.9`})]}),moon:(0,W.jsx)(`path`,{d:`M13 9.6A5.6 5.6 0 0 1 6.4 3a5.6 5.6 0 1 0 6.6 6.6Z`}),auto:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,W.jsx)(`path`,{d:`M8 2.5a5.5 5.5 0 0 1 0 11Z`,fill:`currentColor`,stroke:`none`})]}),latest:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3 3.5 8 8l-5 4.5`}),(0,W.jsx)(`path`,{d:`M12.5 3v10`})]}),record:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3.5 2.5h6L12.5 5.5v8h-9Z`}),(0,W.jsx)(`path`,{d:`M5.5 7.5h5M5.5 10h3.5`})]}),filter:(0,W.jsx)(`path`,{d:`M2 3.5h12l-4.6 5.2v4.1l-2.8 1.7V8.7Z`}),help:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M5.9 6.2a2.2 2.2 0 1 1 2.9 2.1c-.6.2-1 .7-1 1.3v.4`}),(0,W.jsx)(`path`,{d:`M7.8 12.4h.4`})]}),search:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`7.2`,cy:`7.2`,r:`4.2`}),(0,W.jsx)(`path`,{d:`M10.3 10.3 13.5 13.5`})]}),reset:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M2.6 8a5.4 5.4 0 1 0 1.7-3.9`}),(0,W.jsx)(`path`,{d:`M2.3 3.2v3.1h3.1`})]}),table:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,W.jsx)(`path`,{d:`M2 6.5h12M6.5 6.5v6.5`})]}),stats:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M2.5 13.5h11`}),(0,W.jsx)(`path`,{d:`M4.5 11V7M8 11V3.5M11.5 11V8.5`})]}),storage:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3 3.5h5M3 6.5h5M3 9.5h5`}),(0,W.jsx)(`path`,{d:`m9.5 6.5 2 2 2-2M11.5 3v5.5`}),(0,W.jsx)(`path`,{d:`M8.5 12.5h5`})]}),outbound:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M8 3.5H3.5v9h9V8`}),(0,W.jsx)(`path`,{d:`M10 2.5h3.5V6`}),(0,W.jsx)(`path`,{d:`M13.5 2.5 8.5 7.5`})]}),close:(0,W.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`}),prev:(0,W.jsx)(`path`,{d:`M10 3.5 5.5 8l4.5 4.5`}),next:(0,W.jsx)(`path`,{d:`M6 3.5 10.5 8 6 12.5`}),save:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M8 2.5v7.5`}),(0,W.jsx)(`path`,{d:`M4.8 7.2 8 10.4l3.2-3.2`}),(0,W.jsx)(`path`,{d:`M3 12.5h10`})]}),flag:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M4 14.5V2.5`}),(0,W.jsx)(`path`,{d:`M4 3.2h7.6l-1.6 2.9 1.6 2.9H4`})]})};function X({name:e}){return(0,W.jsx)(`svg`,{className:`ico`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:sd[e]})}function Z({label:e,size:t=`sm`,block:n=!1,className:r=``}){return(0,W.jsxs)(`span`,{className:`loading is-${t} ${n?`is-block`:``} ${r}`.trim(),role:`status`,children:[(0,W.jsx)(cd,{}),(0,W.jsx)(`span`,{className:`loading-label shimmer`,children:e})]})}function cd(){return(0,W.jsxs)(`svg`,{className:`orb`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,W.jsx)(`circle`,{className:`orb-dot`,cx:`8`,cy:`3.2`,r:`1.9`,fill:`currentColor`}),(0,W.jsx)(`circle`,{className:`orb-dot`,cx:`12.2`,cy:`10.4`,r:`1.9`,fill:`currentColor`}),(0,W.jsx)(`circle`,{className:`orb-dot`,cx:`3.8`,cy:`10.4`,r:`1.9`,fill:`currentColor`})]})}function Q({icon:e,label:t,on:n,controls:r,expanded:i,buttonRef:a,disabled:o,title:s,onClick:c}){return(0,W.jsxs)(`button`,{ref:a,type:`button`,className:`btn ${t?``:`btn-icon`} ${n?`is-on`:``}`,onClick:c,"aria-pressed":r?void 0:n,"aria-expanded":r?i??n:void 0,"aria-controls":r,disabled:o,title:s,children:[(0,W.jsx)(X,{name:e}),t&&(0,W.jsx)(`span`,{children:t}),!t&&(0,W.jsx)(`span`,{className:`sr-only`,children:s})]})}var ld=`https://salidium.com/docs`;function ud({icon:e,label:t,href:n,title:r}){return(0,W.jsxs)(`a`,{className:`btn`,href:n,target:`_blank`,rel:`noreferrer`,title:r,children:[(0,W.jsx)(X,{name:e}),(0,W.jsx)(`span`,{children:t})]})}function dd(e,t){let n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t()},i=e=>{e.key===`Escape`&&t()};return document.addEventListener(`pointerdown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,r),document.removeEventListener(`keydown`,i)}},[e,t]),n}var fd=[{value:`system`,icon:`auto`,label:`Match the system`},{value:`light`,icon:`sun`,label:`Light`},{value:`dark`,icon:`moon`,label:`Dark`}];function pd(){let e=Y(e=>e.theme),t=Y(e=>e.setTheme),n=Math.max(0,fd.findIndex(t=>t.value===e)),r=fd[n],i=fd[(n+1)%fd.length];return(0,W.jsx)(Q,{icon:r.icon,title:`Theme: ${r.label}. Switch to ${i.label.toLowerCase()}.`,onClick:()=>t(i.value)})}function md({label:e,id:t,children:n}){let[r,i]=(0,z.useState)(!1);return(0,W.jsxs)(`div`,{className:`disclosure`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`disclosure-toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-controls":`disc-${t}`,children:[(0,W.jsx)(`span`,{className:`chev ${r?`is-open`:``}`,"aria-hidden":`true`,children:`›`}),e]}),(0,W.jsx)(`div`,{className:`disclosure-body ${r?`is-open`:``}`,id:`disc-${t}`,children:(0,W.jsx)(`div`,{children:n})})]})}function hd({status:e}){return e===`connecting`?(0,W.jsx)(`span`,{className:`conn conn-warn`,title:`Opening the connection to the daemon`,children:(0,W.jsx)(Z,{label:`Connecting`})}):e===`reconnecting`?(0,W.jsx)(`span`,{className:`conn conn-warn`,title:`Lost contact with the daemon; retrying`,children:(0,W.jsx)(Z,{label:`Reconnecting`})}):e===`closed`?(0,W.jsxs)(`span`,{className:`conn conn-bad`,title:`Not receiving updates; the daemon may have stopped`,children:[(0,W.jsx)(`span`,{className:`conn-mark`,"aria-hidden":`true`}),`Disconnected`]}):null}function gd(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function _d(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<5)return`just now`;if(r<60)return`${r}s ago`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}function vd(e){if(e===void 0)return``;if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(+(e<1e4))}s`;let t=Math.floor(e/6e4);if(t<60)return`${t}m ${Math.round(e%6e4/1e3)}s`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function yd(e,t){let n=wd(e),r=t?wd(t).replace(/\/$/,``):void 0;return r&&n.startsWith(`${r}/`)&&(n=n.slice(r.length+1)),n}function bd(e){return e.replace(/[A-Za-z]:[\\/]Users[\\/][^\\/\s'"]+/g,`~`).replace(/\/(?:Users|home)\/[^/\s'"]+/g,`~`)}function xd(e){let t=e.map(wd),n=t[0];if(!n||e.length<2)return``;let r=n.split(`/`),i=r.length-1;for(let e of t){let t=e.split(`/`),n=0;for(;n<i&&n<t.length-1&&t[n]===r[n];)n++;if(i=n,i===0)return``}return`${r.slice(0,i).join(`/`)}/`}function Sd(e){let t=wd(e),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function Cd(e){let t=wd(e),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):``}function wd(e){return e.replaceAll(`\\`,`/`)}var Td=`/api/operations/storage`,Ed={sessions:`Recorded sessions`,checkpoints:`Replay checkpoints`,provenance:`Provenance records`,structure:`Indexes and internal structure`,reusable:`Reusable space`},Dd=[`sessions`,`checkpoints`,`provenance`,`structure`,`reusable`];function Od(e){if(e===`checkpoints`)return`Derived state that makes replay fast. Storage optimization rebuilds it.`;if(e===`structure`)return`The remainder after the named parts, measured by difference rather than counted.`;if(e===`reusable`)return(0,W.jsxs)(W.Fragment,{children:[`Pages already deleted inside the file. With the daemon stopped,`,` `,(0,W.jsx)(`code`,{children:`salidium retention compact`}),` returns them to the disk.`]})}function kd(e){let t=e.split(/[\\/]/).filter(Boolean);return t.length>2?t.slice(-2).join(`/`):e}function Ad(){let e=Ws();return e?{Authorization:`Bearer ${e}`}:{}}function jd(e){return e instanceof Error?e.message:String(e)}function Md({composition:e}){let t=new Map(e.parts.map(e=>[e.key,e.bytes])),n=Dd.map(e=>({key:e,bytes:t.get(e)??0})),r=n.reduce((e,t)=>e+t.bytes,0),i=e.fileBytes&&e.fileBytes>0?e.fileBytes:r,a=e=>i>0?e/i*100:0,o=e=>{let t=a(e);return t>0&&t<1?`under 1%`:`${Math.round(t)}%`};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`composition-total`,children:[(0,W.jsx)(`strong`,{className:`num`,children:Jc(i)}),e.sessions===null?null:(0,W.jsxs)(`small`,{children:[e.sessions.toLocaleString(),` session`,e.sessions===1?``:`s`]})]}),i>0&&(0,W.jsx)(`div`,{className:`composition-bar`,"aria-hidden":`true`,children:n.filter(e=>e.bytes>0).map(e=>(0,W.jsx)(`span`,{className:`composition-part is-${e.key}`,style:{width:`${a(e.bytes)}%`}},e.key))}),(0,W.jsxs)(`p`,{className:`sr-only`,children:[Jc(i),` in total:`,` `,n.map(e=>`${Ed[e.key]} ${Jc(e.bytes)}, ${o(e.bytes)}`).join(`; `),`.`]}),(0,W.jsx)(`ul`,{className:`composition-legend`,children:n.map(e=>{let t=Od(e.key);return(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`composition-swatch is-${e.key}`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`composition-legend-label`,children:Ed[e.key]}),(0,W.jsx)(`span`,{className:`composition-legend-bytes`,children:Jc(e.bytes)}),t&&(0,W.jsx)(`small`,{className:`composition-legend-note`,children:t})]},e.key)})})]})}function Nd({composition:e}){if(e.projects.length===0)return null;let t=Math.max(1,...e.projects.map(e=>e.bytes));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{className:`composition-subtitle`,children:`Projects`}),(0,W.jsx)(`p`,{className:`composition-note`,children:`Bars compare each project with the largest one listed.`}),(0,W.jsx)(`ol`,{className:`composition-projects`,children:e.projects.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`composition-project-name mono`,title:e.path||void 0,children:(0,W.jsx)(`bdi`,{children:e.path?kd(e.path):`No project recorded`})}),(0,W.jsx)(`span`,{className:`composition-project-bytes num`,children:Jc(e.bytes)}),(0,W.jsx)(`span`,{className:`composition-project-bar`,"aria-hidden":`true`,children:(0,W.jsx)(`span`,{style:{width:`${e.bytes/t*100}%`}})}),(0,W.jsxs)(`span`,{className:`composition-project-count num`,children:[e.sessions.toLocaleString(),` session`,e.sessions===1?``:`s`]})]},e.path))}),e.projectsOmitted>0&&(0,W.jsxs)(`p`,{className:`composition-omitted`,children:[e.projectsOmitted.toLocaleString(),` more project`,e.projectsOmitted===1?``:`s`,` not listed`]})]})}function Pd({now:e}){let t=Y(e=>e.api),n=Y(e=>e.unauthorized),[r,i]=(0,z.useState)(),[a,o]=(0,z.useState)(),[s,c]=(0,z.useState)(!0),[l,u]=(0,z.useState)(!1),d=(0,z.useRef)(0),f=(0,z.useCallback)(async()=>{let e=++d.current;try{let t=await fetch(Td,{headers:Ad()});if(t.status===401){n();return}if(e!==d.current)return;if(t.status===404){c(!1);return}if(!t.ok)throw Error(`request failed: ${t.status}`);let r=us.parse(await t.json());if(e!==d.current)return;i(r),o(void 0)}catch(t){e===d.current&&o(jd(t))}},[n]),p=(0,z.useCallback)(async()=>{let e=++d.current;u(!0),o(void 0);try{let t=await fetch(Td,{method:`POST`,headers:Ad()});if(t.status===401){n();return}if(!t.ok)throw Error(`request failed: ${t.status}`);let r=us.parse(await t.json());if(e!==d.current)return;i(r)}catch(t){e===d.current&&o(jd(t))}finally{u(!1)}},[n]);(0,z.useEffect)(()=>{t&&f()},[t,f]);let m=r?.state===`running`;if((0,z.useEffect)(()=>{if(!t||!m)return;let e=setInterval(()=>void f(),1500);return()=>clearInterval(e)},[t,m,f]),!s||!r&&!a)return null;let h=r?.state??`absent`,g=l||m,_=h===`ready`?`Measure again`:h===`failed`?`Try again`:m?`Measuring…`:`Analyze storage`,v=h===`ready`?`Measured ${_d(r?.computedAt??void 0,e)}`.trim():m?`Measuring`:h===`failed`?`Did not finish`:`Not measured`;return(0,W.jsxs)(`section`,{className:`is-section is-composition`,"aria-labelledby":`is-composition-title`,children:[(0,W.jsxs)(`div`,{className:`operations-section-head`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`is-composition-title`,children:`What is using this space`}),(0,W.jsx)(`span`,{children:v})]}),h===`absent`&&(0,W.jsx)(`p`,{className:`composition-note`,children:`Nothing has been measured yet. Measuring reads every stored event and reports how much of this store is your recorded sessions, how much is the machinery that serves them, and how much is space the file can give back.`}),m&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`operations-action-status`,children:(0,W.jsx)(Z,{label:`Measuring the store`})}),(0,W.jsx)(`p`,{className:`composition-note`,children:`This reads every stored event and takes several seconds on a large store. Collection keeps running while it works.`})]}),h===`failed`&&(0,W.jsxs)(`p`,{className:`is-action-error`,role:`alert`,children:[`Measurement did not finish. `,r?.failure??`No reason was reported.`]}),h===`ready`&&r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Md,{composition:r}),(0,W.jsx)(Nd,{composition:r}),(0,W.jsxs)(`p`,{className:`composition-note`,children:[`A measurement, not a live reading. It was taken`,` `,_d(r.computedAt??void 0,e)||`at an unrecorded time`,r.elapsedMs===null?``:` and took ${vd(r.elapsedMs)}`,`; the store has kept changing since.`]})]}),a&&(0,W.jsxs)(`p`,{className:`is-action-error`,role:`alert`,children:[`Storage measurement unavailable. `,a]}),(0,W.jsx)(`div`,{className:`operations-actions`,children:(0,W.jsx)(`button`,{type:`button`,className:`btn`,disabled:g,onClick:()=>void p(),children:_})})]})}function Fd(e){return e===null?`Unavailable`:Jc(e)}function Id(e){return e===`critical`?`Critical`:e===`attention`?`Needs attention`:`Healthy`}function Ld(e){return e===`exact`?`measured`:`unavailable`}function Rd(e){return e===`failure`?`Did not finish`:e===`recovery`?`Recovering`:e===`completed`?`Finished`:`Running`}function zd(e){return e.state===`recovered`?`Over`:e.state===`acknowledged`?`Acknowledged`:e.severity===`critical`?`Needs attention now`:e.severity===`warning`?`Worth a look`:`For information`}function Bd(e){return e===null?`Unavailable`:e===`forever`?`Kept forever`:`Kept ${e} days`}function Vd(e){return!e||e.value<=0?``:`about ${Jc(e.value*60*24)} a day at this rate`}function Hd(e,t){if(e===null)return``;let n=Jc(t);if(e>=t)return`past its ${n} warning mark`;let r=Jc(t-e);return r===n?`warns at ${n}`:`${r} below its ${n} warning mark`}function Ud(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Wd(e){return e.hookStatus===`configured`?`Connected`:e.hookStatus===`partial`?`Incomplete`:e.hookStatus===`invalid`?`Needs repair`:`Not connected`}function Gd(e){if(e.id===`codex`&&e.hookStatus!==`not-configured`)return e.hookTrust===`trusted`?`Approved`:e.hookTrust===`managed`?`Managed`:e.hookTrust===`untrusted`?`Approval required`:e.hookTrust===`modified`?`Changed since approval`:`Trust unavailable here`}function Kd(e){return e===`policy`?`Saving local policy`:e===`reset`?`Restoring shipped defaults`:e===`drain`?`Draining one batch`:e===`alert`?`Acknowledging alert`:e===`disconnect`?`Disconnecting provider`:`Updating collection`}function qd(e,t,n=`Needs two measurements`){if(!e)return n;let r=t===`storage`?Jc(Math.abs(e.value)):Math.abs(e.value).toFixed(1);return`${/^[0.]+(?: B)?$/.test(r)?``:e.value>0?`+`:`−`}${r}${t===`storage`?`/min`:` files/min`}`}function Jd({overview:e,now:t}){let{health:n}=e,r=Vd(n.estimates.storageGrowth),i=n.estimates.queueVelocity===null?`Needs two measurements`:`Not shrinking`,a=Hd(n.store.totalBytes,e.config.values.alerts.databaseSizeBytes.value),o=!n.estimates.queueVelocity||n.estimates.queueVelocity.value===0?`steady`:n.estimates.queueVelocity.value<0?`draining`:`growing`;return(0,W.jsxs)(`section`,{className:`is-section operations-readout`,"aria-labelledby":`is-readout`,children:[(0,W.jsxs)(`div`,{className:`operations-section-head`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`is-readout`,children:`Current readout`}),(0,W.jsx)(`span`,{className:`operations-health is-${n.overall}`,children:Id(n.overall)})]}),(0,W.jsxs)(`dl`,{className:`is-readout`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[`Collection `,(0,W.jsx)(`small`,{className:`measure-kind`,children:`measured`})]}),(0,W.jsxs)(`dd`,{children:[n.collection.state===`active`?`Active`:`Paused`,n.collection.pauseExpiresAt&&(0,W.jsxs)(`small`,{children:[`until `,Ud(n.collection.pauseExpiresAt)]})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[`Waiting to be stored`,` `,(0,W.jsx)(`small`,{className:`measure-kind`,children:Ld(n.queue.availability)})]}),(0,W.jsxs)(`dd`,{children:[n.queue.files===null?`Unavailable`:`${n.queue.files.toLocaleString()} files`,(0,W.jsx)(`small`,{children:Fd(n.queue.bytes)})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[`Oldest waiting `,(0,W.jsx)(`small`,{className:`measure-kind`,children:`measured`})]}),(0,W.jsx)(`dd`,{children:n.queue.oldestAt?_d(n.queue.oldestAt,t):`None`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[`On this Mac`,` `,(0,W.jsx)(`small`,{className:`measure-kind`,children:Ld(n.store.availability)})]}),(0,W.jsxs)(`dd`,{children:[Fd(n.store.totalBytes),(0,W.jsxs)(`small`,{children:[Bd(n.store.retention),a?` · ${a}`:``]})]})]})]}),(0,W.jsxs)(`div`,{className:`operations-velocity is-${o}`,children:[(0,W.jsx)(`span`,{className:`operations-velocity-line`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Queue velocity`}),(0,W.jsx)(`span`,{children:qd(n.estimates.queueVelocity,`queue`)}),(0,W.jsxs)(`small`,{children:[n.estimates.queueVelocity?`${o} · `:``,`estimate`,n.estimates.queueVelocity?` · ${n.estimates.queueVelocity.samples} samples / ${Math.round(n.estimates.queueVelocity.sampleWindowSeconds)}s`:``]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Drain rate`}),(0,W.jsx)(`span`,{children:qd(n.estimates.drainRate,`queue`,i)}),(0,W.jsx)(`small`,{children:`estimate`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Storage growth`}),(0,W.jsx)(`span`,{children:qd(n.estimates.storageGrowth,`storage`)}),(0,W.jsx)(`small`,{children:r||`estimate`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Time to empty`}),(0,W.jsx)(`span`,{children:n.estimates.timeToEmpty?`${Math.max(1,Math.round(n.estimates.timeToEmpty.value/60))} min`:n.queue.files===0?`Already empty`:i}),(0,W.jsx)(`small`,{children:`estimate`})]})]}),(0,W.jsxs)(`p`,{className:`operations-retention-note`,children:[`Health history keeps `,n.history.retentionMinutes,` minutes locally ·`,` `,n.history.retainedSamples,` samples retained`]})]})}function Yd({health:e,info:t,now:n}){let r=window.location.port||(window.location.protocol===`https:`?`443`:`80`);return(0,W.jsxs)(`section`,{className:`is-section operations-runtime`,"aria-labelledby":`operations-runtime-title`,children:[(0,W.jsxs)(`div`,{className:`operations-section-head`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`operations-runtime-title`,children:`Where it runs`}),(0,W.jsx)(`span`,{children:`Local only`})]}),(0,W.jsxs)(`dl`,{className:`is-readout`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Background service`}),(0,W.jsxs)(`dd`,{children:[e.daemon.pid?`PID ${e.daemon.pid}`:`Unavailable`,e.daemon.startedAt&&(0,W.jsxs)(`small`,{children:[`started `,_d(e.daemon.startedAt,n)]})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Listening on`}),(0,W.jsxs)(`dd`,{children:[`127.0.0.1:`,r,(0,W.jsx)(`small`,{children:`this computer only`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`State stored in`}),(0,W.jsx)(`dd`,{className:`operations-runtime-path`,title:t?.home,children:(0,W.jsx)(`bdi`,{children:t?.home??`Unavailable`})})]})]}),(0,W.jsxs)(`p`,{className:`operations-runtime-note`,children:[`This tab is a control panel, not the service. Closing it does not stop collection. Reopen with `,(0,W.jsx)(`code`,{children:`salidium open`}),`; monitor without a window using`,` `,(0,W.jsx)(`code`,{children:`salidium status --watch`}),`. On macOS, `,(0,W.jsx)(`code`,{children:`salidium service install`}),` also starts it at login, recovers crashes, and adds a menu-bar control.`]})]})}function Xd({overview:e,info:t}){let n=Y(e=>e.setCollection),r=Y(e=>e.drainQueue),i=Y(e=>e.disconnectHooks),a=Y(e=>e.operationsPending),[o,s]=(0,z.useState)(),{health:c}=e;return(0,W.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`is-controls`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`is-controls`,children:`Collection controls`}),(0,W.jsxs)(`div`,{className:`operations-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn`,disabled:a!==void 0,onClick:()=>void n(c.collection.state===`active`?`pause`:`resume`),children:c.collection.state===`active`?`Pause collection`:`Resume collection`}),(0,W.jsx)(`button`,{type:`button`,className:`btn`,disabled:a!==void 0||c.collection.state===`paused`||c.queue.files===0,onClick:()=>void r().catch(()=>{}),children:`Drain one batch`})]}),(0,W.jsx)(`small`,{className:`operations-control-help`,children:`Pausing stops new observations for up to 24 hours. Draining makes one bounded batch durable; it never deletes work that failed to persist.`}),c.maintenance&&(0,W.jsxs)(`div`,{className:`maintenance-state is-${c.maintenance.phase}`,role:c.maintenance.phase===`failure`?`alert`:`status`,"aria-live":c.maintenance.phase===`failure`?`assertive`:`polite`,children:[(0,W.jsxs)(`span`,{children:[Rd(c.maintenance.phase),c.maintenance.progress===null?``:` · ${Math.round(c.maintenance.progress*100)}%`]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:c.maintenance.message}),c.maintenance.failure&&(0,W.jsx)(`small`,{children:c.maintenance.failure}),c.maintenance.progress!==null&&(0,W.jsx)(`progress`,{"aria-label":`Maintenance progress`,value:c.maintenance.progress,max:1})]})]}),(0,W.jsx)(`div`,{className:`is-providers`,children:(t?.providers??[]).map(e=>{let t=e.hookStatus===`configured`||e.hookStatus===`partial`,n=o===e.id;return(0,W.jsxs)(`div`,{className:`is-provider`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.displayName??e.id}),(0,W.jsx)(`span`,{children:Wd(e)}),Gd(e)&&(0,W.jsx)(`small`,{children:Gd(e)})]}),t&&(0,W.jsx)(`button`,{type:`button`,className:n?`btn is-confirm`:`btn`,disabled:a!==void 0,onBlur:()=>s(void 0),onClick:()=>{if(!n){s(e.id);return}s(void 0),i(e.id)},children:n?`Disconnect ${e.displayName??e.id}?`:`Disconnect`})]},e.id)})})]})}function Zd({source:e,environment:t}){return(0,W.jsx)(`small`,{className:`setting-source`,children:e===`environment`?`Locked by ${t}`:e})}function Qd({config:e}){let t=Y(e=>e.setOperationalConfig),n=Y(e=>e.resetOperationalConfig),r=Y(e=>e.operationsPending),[i,a]=(0,z.useState)(e.values.ui.operationsDetail.value===`expanded`),o=e=>void t(e).catch(()=>{}),s=e=>e===`environment`,c=r!==void 0,l=e.values.retention.days.value,[u,d]=(0,z.useState)(),f=e=>e===`forever`?1/0:e,p=e=>f(e)<f(l);return(0,z.useEffect)(()=>{a(e.values.ui.operationsDetail.value===`expanded`)},[e.values.ui.operationsDetail.value]),(0,W.jsxs)(`section`,{className:`is-section operations-policy`,"aria-labelledby":`operations-policy-title`,children:[(0,W.jsxs)(`button`,{className:`operations-fold`,type:`button`,"aria-expanded":i,"aria-controls":`operations-policy-settings`,disabled:c,onClick:()=>{let n=!i;a(n),t({ui:{operationsDetail:n?`expanded`:`summary`}}).catch(()=>{a(e.values.ui.operationsDetail.value===`expanded`)})},children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{id:`operations-policy-title`,children:`Local policy`}),(0,W.jsx)(`small`,{children:`Safe preferences only`})]}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:i?`−`:`+`})]}),i&&(0,W.jsxs)(`div`,{className:`operations-settings`,id:`operations-policy-settings`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`span`,{children:[`Keep session history`,(0,W.jsx)(Zd,{...e.values.retention.days})]}),(0,W.jsxs)(`select`,{value:u??l,disabled:c||s(e.values.retention.days.source),onChange:e=>{let t=e.target.value===`forever`?`forever`:Number(e.target.value);p(t)?d(t):(d(void 0),o({retention:{days:t}}))},children:[(0,W.jsx)(`option`,{value:`forever`,children:`Forever`}),(0,W.jsx)(`option`,{value:`30`,children:`30 days`}),(0,W.jsx)(`option`,{value:`90`,children:`90 days`}),(0,W.jsx)(`option`,{value:`365`,children:`365 days`})]})]}),u!==void 0&&(0,W.jsxs)(`div`,{className:`operations-retention-confirm`,role:`alert`,children:[(0,W.jsxs)(`p`,{children:[`Keeping `,u,` days permanently deletes every unpinned session with no activity in the last `,u,` days, and all of its events. This cannot be undone.`]}),(0,W.jsx)(`button`,{type:`button`,className:`btn is-confirm`,disabled:c,onClick:()=>{let e=u;d(void 0),o({retention:{days:e}})},children:`Delete older sessions`}),(0,W.jsxs)(`button`,{type:`button`,className:`btn`,disabled:c,onClick:()=>d(void 0),children:[`Keep `,Bd(l).toLowerCase()]})]}),(0,W.jsxs)(`label`,{className:`operations-notification`,children:[(0,W.jsxs)(`span`,{children:[`Native desktop notifications`,(0,W.jsx)(Zd,{...e.values.alerts.nativeNotifications}),(0,W.jsx)(`small`,{className:`setting-help`,children:`Alert metadata only; never session content.`})]}),(0,W.jsx)(`input`,{type:`checkbox`,checked:e.values.alerts.nativeNotifications.value,disabled:c||s(e.values.alerts.nativeNotifications.source),onChange:e=>o({alerts:{nativeNotifications:e.target.checked}})})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`span`,{children:[`Warn when queue age reaches`,(0,W.jsx)(Zd,{...e.values.alerts.queueAgeMinutes})]}),(0,W.jsxs)(`select`,{value:e.values.alerts.queueAgeMinutes.value,disabled:c||s(e.values.alerts.queueAgeMinutes.source),onChange:e=>o({alerts:{queueAgeMinutes:Number(e.target.value)}}),children:[(0,W.jsx)(`option`,{value:`5`,children:`5 minutes`}),(0,W.jsx)(`option`,{value:`10`,children:`10 minutes`}),(0,W.jsx)(`option`,{value:`30`,children:`30 minutes`}),(0,W.jsx)(`option`,{value:`60`,children:`1 hour`})]})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`span`,{children:[`Warn when storage reaches`,(0,W.jsx)(Zd,{...e.values.alerts.databaseSizeBytes})]}),(0,W.jsx)(`select`,{value:e.values.alerts.databaseSizeBytes.value,disabled:c||s(e.values.alerts.databaseSizeBytes.source),onChange:e=>o({alerts:{databaseSizeBytes:Number(e.target.value)}}),children:[1,5,10,20].map(e=>(0,W.jsxs)(`option`,{value:e*1e3*1e3*1e3,children:[e,` GB`]},e))})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`span`,{children:[`Alert cooldown`,(0,W.jsx)(Zd,{...e.values.alerts.cooldownMinutes})]}),(0,W.jsxs)(`select`,{value:e.values.alerts.cooldownMinutes.value,disabled:c||s(e.values.alerts.cooldownMinutes.source),onChange:e=>o({alerts:{cooldownMinutes:Number(e.target.value)}}),children:[(0,W.jsx)(`option`,{value:`5`,children:`5 minutes`}),(0,W.jsx)(`option`,{value:`30`,children:`30 minutes`}),(0,W.jsx)(`option`,{value:`60`,children:`1 hour`}),(0,W.jsx)(`option`,{value:`240`,children:`4 hours`})]})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`span`,{children:[`Keep health history`,(0,W.jsx)(Zd,{...e.values.health.historyMinutes})]}),(0,W.jsxs)(`select`,{value:e.values.health.historyMinutes.value,disabled:c||s(e.values.health.historyMinutes.source),onChange:e=>o({health:{historyMinutes:Number(e.target.value)}}),children:[(0,W.jsx)(`option`,{value:`15`,children:`15 minutes`}),(0,W.jsx)(`option`,{value:`60`,children:`1 hour`}),(0,W.jsx)(`option`,{value:`360`,children:`6 hours`}),(0,W.jsx)(`option`,{value:`1440`,children:`24 hours`})]})]}),(0,W.jsxs)(`fieldset`,{disabled:c||s(e.values.providers.enabled.source),children:[(0,W.jsx)(`legend`,{children:`Providers after restart`}),[`claude-code`,`codex`].map(t=>{let n=e.values.providers.enabled.value.includes(t);return(0,W.jsxs)(`label`,{className:`operations-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>o({providers:{enabled:n?e.values.providers.enabled.value.filter(e=>e!==t):[...e.values.providers.enabled.value,t]}})}),t===`claude-code`?`Claude Code`:`Codex`]},t)})]}),e.restartRequired.length>0&&(0,W.jsxs)(`p`,{className:`operations-restart`,role:`status`,children:[`Restart Salidium to apply `,e.restartRequired.join(`, `),`.`]}),(0,W.jsx)(`button`,{type:`button`,className:`btn operations-reset`,disabled:c,onClick:()=>void n().catch(()=>{}),children:`Restore shipped defaults`}),(0,W.jsx)(`p`,{className:`operations-policy-note`,children:`Relay reserves, payload ceilings, trust bypasses, SQLite pages, and compression limits are safety invariants and are not customizable here.`})]})]})}function $d({alerts:e}){let t=Y(e=>e.acknowledgeAlert),n=Y(e=>e.operationsPending),r=new Set(e.active.map(e=>e.id)),i=e.recent.filter(e=>e.state===`recovered`&&!r.has(e.id)),a=(e,r)=>(0,W.jsxs)(`li`,{className:`is-${e.severity} ${e.state===`recovered`?`is-recovered`:``}`,"aria-live":e.severity===`critical`&&e.state===`active`?`assertive`:void 0,"aria-atomic":e.severity===`critical`&&e.state===`active`||void 0,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.state===`recovered`?e.recoveryTitle??e.title:e.title}),(0,W.jsx)(`span`,{children:e.state===`recovered`?e.recoveryDetail??e.detail:e.detail}),(0,W.jsx)(`small`,{children:zd(e)})]}),r&&e.state===`active`&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,disabled:n!==void 0,onClick:()=>void t(e.id).catch(()=>{}),children:n===`alert`?`Acknowledging…`:`Acknowledge`})]},e.id);return(0,W.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`operations-alerts-title`,children:[(0,W.jsxs)(`div`,{className:`operations-section-head`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`operations-alerts-title`,children:`Local alerts`}),(0,W.jsxs)(`span`,{children:[e.active.length,` active`]})]}),(0,W.jsxs)(`div`,{"aria-live":`polite`,"aria-relevant":`additions text`,children:[e.active.length===0?(0,W.jsx)(`p`,{className:`is-empty`,children:`Nothing needs attention`}):(0,W.jsx)(`ol`,{className:`operations-alerts`,children:e.active.map(e=>a(e,!0))}),i.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{className:`operations-alerts-subtitle`,children:`Recently resolved`}),(0,W.jsx)(`ol`,{className:`operations-alerts is-recent`,children:i.map(e=>a(e,!1))})]})]})]})}function ef({health:e,now:t}){let n=[...e.gaps.activeEpisodes.map(e=>({...e,active:!0})),...e.gaps.recoveredEpisodes.slice(-10).reverse().map(e=>({...e,active:!1}))];return(0,W.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`is-ledger`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`is-ledger`,children:`Collection ledger`}),n.length===0?(0,W.jsx)(`p`,{className:`is-empty`,children:`No collection gaps observed`}):(0,W.jsx)(`ol`,{className:`is-ledger`,children:n.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:e.active?`is-gap-mark is-active`:`is-gap-mark`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.reason===`collection-stopped`?`Stopped interval`:e.reason===`collection-paused`?`Paused interval`:e.reason===`collection-pause-marker-invalid`?`Unreadable pause recovered`:e.active?`Gap active`:`Gap recovered`}),(0,W.jsxs)(`span`,{children:[e.reason.startsWith(`collection-`)?`Hook-only evidence may be absent`:e.event??`Multiple event types`,` `,`· count unavailable`]}),(0,W.jsx)(`small`,{children:e.firstDroppedAt?`first observed ${_d(e.firstDroppedAt,t)}`:`start time unavailable`})]})]},JSON.stringify(e)))}),e.gaps.omitted>0&&(0,W.jsxs)(`p`,{className:`is-omitted`,children:[e.gaps.omitted.toLocaleString(),` older episode`,e.gaps.omitted===1?``:`s`,` omitted`]})]})}function tf({onClose:e,returnFocusRef:t}){let n=Y(e=>e.api),r=Y(e=>e.operations),i=Y(e=>e.collectionInfo),a=Y(e=>e.collectionLoading),o=Y(e=>e.collectionError),s=Y(e=>e.operationsPending),c=Y(e=>e.operationsActionError),l=Y(e=>e.loadCollection),[u,d]=(0,z.useState)(()=>Date.now()),f=(0,z.useRef)(null),p=(0,z.useRef)(null);return(0,z.useLayoutEffect)(()=>{let e=f.current;return p.current?.focus(),()=>{e?.contains(document.activeElement)&&requestAnimationFrame(()=>t.current?.focus())}},[t]),(0,z.useEffect)(()=>{if(!n)return;l();let e=setInterval(()=>{d(Date.now()),l()},5e3);return()=>clearInterval(e)},[n,l]),(0,W.jsxs)(`aside`,{className:`inspector models-usage ingest-storage`,id:`ingest-storage-inspector`,"aria-label":`Ingest & Storage`,ref:f,children:[(0,W.jsxs)(`div`,{className:`inspector-head`,children:[(0,W.jsx)(Q,{icon:`panel`,title:`Hide Ingest & Storage`,buttonRef:p,onClick:()=>{e(),requestAnimationFrame(()=>t.current?.focus())}}),(0,W.jsx)(`span`,{className:`inspector-title`,children:`Local operations`})]}),(0,W.jsxs)(`div`,{className:`models-usage-body scroll-fade`,children:[!r&&a&&(0,W.jsx)(Z,{label:`Reading local health`,block:!0}),o&&(0,W.jsxs)(`p`,{className:`is-load-error`,role:`alert`,children:[r?`Health refresh failed; showing the last readout.`:`Operations readout unavailable.`,` `,o]}),c&&(0,W.jsxs)(`p`,{className:`is-action-error`,role:`alert`,children:[`Action not completed. `,c]}),s&&(0,W.jsx)(`div`,{className:`operations-action-status`,children:(0,W.jsx)(Z,{label:Kd(s)})}),r&&(0,W.jsxs)(`div`,{className:`is-body`,children:[(0,W.jsx)(Jd,{overview:r,now:u}),(0,W.jsx)(Pd,{now:u}),(0,W.jsx)(Yd,{health:r.health,info:i,now:u}),(0,W.jsx)($d,{alerts:r.alerts}),(0,W.jsx)(Xd,{overview:r,info:i}),(0,W.jsx)(Qd,{config:r.config}),(0,W.jsx)(ef,{health:r.health,now:u})]})]})]})}async function nf(e){if(!navigator.clipboard)return`refused`;try{return await navigator.clipboard.writeText(e),`copied`}catch{return`refused`}}function rf(e){if(!e)return;let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function af(e){let t=e.source.version?` ${e.source.version}`:``;return{title:of(e),meta:`seq ${e.seq} · ${e.source.provider} ${e.source.channel}${t}`,facts:ff(e),origin:_f(e)}}function of(e){switch(e.kind){case`session.started`:return`Session started`;case`session.updated`:return`Session details changed`;case`session.ended`:return`Session ended`;case`turn.started`:return`Turn started`;case`turn.ended`:return`Turn ended`;case`agent.message`:return e.phase===`final`?`The agent’s answer`:`The agent said`;case`agent.thinking`:return`The agent thought`;case`agent.usage`:return`What one model call used`;case`tool.called`:return sf[e.input.kind];case`tool.completed`:return cf[e.result.kind];case`tool.failed`:return e.cause===`rejected`||e.cause===`denied`?`Tool stopped`:`Tool failed`;case`subagent.started`:return`Subagent started`;case`subagent.ended`:return`Subagent finished`;case`plan.updated`:return`Plan updated`;case`compaction`:return`Context compacted`;case`permission.requested`:return`Permission asked for`;case`notification`:return`Notification`;case`git.snapshot`:return`Repository snapshot`;case`ingest.warning`:return`A record could not be read`;case`salidium.explanation`:return`Generated explanation`;default:return`Record`}}var sf={command:`Command run`,fileEdit:`File edited`,fileWrite:`File written`,fileRead:`File read`,search:`Search`,webFetch:`Page fetched`,webSearch:`Web search`,subagent:`Subagent launched`,plan:`Plan written`,question:`Question asked`,mcp:`MCP tool called`,other:`Tool called`},cf={command:`Command finished`,fileChanges:`Files changed`,fileRead:`File read`,subagent:`Subagent reported`,generic:`Tool finished`};function lf(e){let t=e.code===void 0?``:String(e.code);switch(e.observation){case`explicit`:return{value:t===``?`reported, no code`:t};case`inferred-success`:return{value:t===``?`success`:t,note:`inferred, not reported`};case`inferred-failure`:return{value:t===``?`failure`:t,note:`inferred, not reported`};default:return{value:`unknown`,note:`the record does not say`}}}function uf(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function df(e){return e.toLocaleString()}function ff(e){switch(e.kind){case`tool.called`:return[...hf(e),{label:`Tool`,value:e.toolName,mono:!0}];case`tool.completed`:return[...gf(e),{label:`Tool`,value:e.toolName,mono:!0},...e.durationMs===void 0?[]:[{label:`Took`,value:`${e.durationMs} ms`,mono:!0}]];case`tool.failed`:{let t=e.exit?lf(e.exit):void 0;return[{label:`Error`,value:e.errorExcerpt,mono:!0,block:!0,copy:!0},{label:`Cause`,value:pf[e.cause]},...t?[{label:`Exit`,value:t.value,mono:!0,note:t.note}]:[],{label:`Tool`,value:e.toolName,mono:!0},...e.durationMs===void 0?[]:[{label:`Took`,value:`${e.durationMs} ms`,mono:!0}]]}case`agent.message`:return[{label:`Said`,value:e.text,block:!0,copy:!0,note:e.truncated?`cut short by the excerpt limit`:void 0},...e.phase?[{label:`Phase`,value:e.phase}]:[]];case`agent.thinking`:return[{label:`Length`,value:uf(e.chars,`character`),mono:!0,note:`the reasoning itself is neither stored nor shown`}];case`agent.usage`:return[{label:`Input tokens`,value:df(e.inputTokens),mono:!0},{label:`Output tokens`,value:df(e.outputTokens),mono:!0},{label:`Cache read tokens`,value:df(e.cacheReadTokens),mono:!0},{label:`Cache write tokens`,value:df(e.cacheWriteTokens),mono:!0},...$(`Model`,e.model,!0),{label:`Response`,value:e.messageId,mono:!0,copy:!0,note:`one API response; its other records repeat these same figures`}];case`turn.started`:return[{label:`Asked`,value:e.prompt,block:!0,copy:!0,note:e.promptTruncated?`cut short by the excerpt limit`:void 0}];case`turn.ended`:return[{label:`Outcome`,value:e.outcome},...e.error?[{label:`Error`,value:e.error,mono:!0,block:!0}]:[],...e.lastMessage?[{label:`Last message`,value:e.lastMessage,block:!0,copy:!0}]:[]];case`session.started`:return[{label:`Working in`,value:e.cwd,mono:!0,copy:!0},...$(`Title`,e.title),...$(`Model`,e.model,!0),...$(`Branch`,e.gitBranch,!0),...$(`Started by`,e.entrypoint),...$(`Reason`,e.reason),...$(`Transcript`,e.transcriptPath,!0,!0)];case`session.updated`:return[...$(`Title`,e.title),...$(`Model`,e.model,!0),...$(`Branch`,e.gitBranch,!0),...$(`Working in`,e.cwd,!0,!0)];case`session.ended`:return[...$(`Reason`,e.reason)];case`subagent.started`:return[...$(`Task`,e.description),...$(`Kind`,e.agentType,!0),{label:`Lane`,value:e.subagentId,mono:!0},...$(`From call`,e.parentCallId,!0),...$(`Transcript`,e.transcriptPath,!0,!0)];case`subagent.ended`:return[{label:`Lane`,value:e.subagentId,mono:!0},...e.lastMessage?[{label:`Reported`,value:e.lastMessage,block:!0,copy:!0}]:[]];case`plan.updated`:{let t=e.items.filter(e=>e.status===`completed`).length,n=e.items.filter(e=>e.status===`in_progress`).length;return[{label:`Plan`,value:`${uf(e.items.length,`item`)} · ${t} done · ${n} in progress`},...e.items.map(e=>({label:mf[e.status],value:e.text})),...$(`Why`,e.explanation),{label:`Kind`,value:e.mode===`replace`?`the whole plan`:`an update to it`}]}case`compaction`:return[...$(`Trigger`,e.trigger),...e.summaryExcerpt?[{label:`Kept`,value:e.summaryExcerpt,block:!0,copy:!0}]:[]];case`permission.requested`:return[{label:`Asked`,value:e.summary,block:!0},{label:`Tool`,value:e.toolName,mono:!0}];case`notification`:return[{label:`Message`,value:e.message,block:!0},...$(`Kind`,e.notificationType)];case`git.snapshot`:return[{label:`Repository`,value:e.repoRoot,mono:!0,copy:!0},...$(`Head`,e.head,!0,!0),...$(`Branch`,e.branch,!0),{label:`Dirty`,value:e.dirty.length===0?`nothing uncommitted`:uf(e.dirty.length,`path`),note:e.dirtyTruncated?`the list is capped, so there may be more`:void 0},...e.dirty.map(e=>({label:e.status.trim()===``?`unchanged`:e.status.trim(),value:e.path,mono:!0}))];case`ingest.warning`:return[{label:`Problem`,value:e.code},...$(`Detail`,e.detail,!0,!1,!0)];case`salidium.explanation`:return[{label:`Summary`,value:e.what.summary,block:!0,note:`generated, not observed`},...$(`Currently`,e.what.currently??void 0),{label:`Generated by`,value:e.model,mono:!0},{label:`From records up to`,value:`seq ${e.basedOnSeq}`,mono:!0}];default:return[]}}var pf={error:`the tool itself failed`,rejected:`a human declined it`,denied:`policy refused it`,interrupted:`it was interrupted`,timeout:`it ran out of time`},mf={completed:`done`,in_progress:`doing`,pending:`to do`,cancelled:`dropped`};function $(e,t,n=!1,r=!1,i=!1){return t===void 0||t===``?[]:[{label:e,value:t,mono:n,copy:r,block:i}]}function hf(e){let t=e.input;switch(t.kind){case`command`:return[{label:`Command`,value:t.command,mono:!0,block:!0,copy:!0},...$(`Why`,t.description),...$(`In`,t.cwd,!0,!0),...t.background?[{label:`Runs`,value:`in the background`}]:[]];case`fileEdit`:case`fileWrite`:case`fileRead`:return[{label:`File`,value:t.path,mono:!0,copy:!0}];case`search`:return[{label:`Query`,value:t.query,mono:!0,copy:!0},...$(`In`,t.path,!0,!0)];case`webFetch`:case`webSearch`:return[{label:`Target`,value:t.target,mono:!0,copy:!0}];case`subagent`:return[...$(`Task`,t.description),...$(`Kind`,t.agentType,!0)];case`question`:return[{label:`Asked`,value:t.questions.join(`
78
+ `),block:!0,copy:!0}];case`mcp`:return[{label:`Tool`,value:`${t.server}/${t.tool}`,mono:!0,copy:!0},...$(`Arguments`,t.argsExcerpt,!0,!0,!0)];case`plan`:return[{label:`Wrote`,value:e.title}];default:return[...$(`Summary`,t.summary)]}}function gf(e){let t=e.result;switch(t.kind){case`command`:{let e=lf(t.exit),n=t.gitOperation;return[{label:`Exit`,value:e.value,mono:!0,note:e.note},...t.outputExcerpt?[{label:`Output`,value:t.outputExcerpt,mono:!0,block:!0,copy:!0,note:t.truncated?`excerpt of ${uf(t.outputChars,`character`)}`:uf(t.outputChars,`character`)}]:[{label:`Output`,value:`none recorded`}],...t.interrupted?[{label:`Interrupted`,value:`yes`}]:[],...t.timedOut?[{label:`Timed out`,value:`yes`}]:[],...n?.commit?[{label:`Commit`,value:n.commit.sha,mono:!0,copy:!0}]:[],...n?.push?[{label:`Pushed`,value:n.push.branch??`yes`,mono:!0}]:[],...n?.pr?.number===void 0?[]:[{label:`Pull request`,value:`#${n.pr.number}`,mono:!0}]]}case`fileChanges`:{let e=t.changes.reduce((e,t)=>e+t.linesAdded,0),n=t.changes.reduce((e,t)=>e+t.linesRemoved,0);return[{label:`Changed`,value:`${uf(t.changes.length,`file`)} · +${e} −${n}`},...t.changes.map(e=>({label:e.change,value:`${e.path} +${e.linesAdded} −${e.linesRemoved}`,mono:!0,note:e.applied?void 0:`not applied`}))]}case`fileRead`:return[{label:`File`,value:t.path,mono:!0,copy:!0},...t.suppressed?[{label:`Contents`,value:`withheld: this path holds credentials`}]:[]];case`subagent`:return[{label:`Status`,value:t.status},...t.summaryExcerpt?[{label:`Reported`,value:t.summaryExcerpt,block:!0,copy:!0}]:[],...t.toolCalls===void 0?[]:[{label:`Tool calls`,value:String(t.toolCalls),mono:!0}],...t.durationMs===void 0?[]:[{label:`Ran for`,value:`${t.durationMs} ms`,mono:!0}],...$(`Lane`,t.agentId,!0)];default:return t.excerpt?[{label:`Result`,value:t.excerpt,mono:!0,block:!0,copy:!0}]:[{label:`Result`,value:`nothing recorded`}]}}function _f(e){return[{label:`When`,value:e.ts,mono:!0,note:e.tsSource===`ingest`?`when Salidium received it, not when it happened`:void 0},...$(`Lane`,e.agentId,!0),...$(`Turn`,e.turnId,!0),...e.redactions?[{label:`Redacted`,value:uf(e.redactions,`credential-shaped string`),note:`removed at ingest, before anything was stored`}]:[],{label:`Id`,value:e.id,mono:!0,copy:!0}]}var vf=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,yf=[];function bf(e){return Array.from(e.querySelectorAll(vf)).filter(e=>!e.closest(`[hidden], [inert], [aria-hidden="true"]`)&&e.getClientRects().length>0)}function xf({active:e,containerRef:t,onClose:n,initialFocus:r,restoreFocus:i,shouldRestoreFocus:a}){let o=(0,z.useRef)(e),s=(0,z.useRef)(n),c=(0,z.useRef)(r),l=(0,z.useRef)(i),u=(0,z.useRef)(a),d=(0,z.useRef)(null);o.current=e,s.current=n,c.current=r,l.current=i,u.current=a,(0,z.useEffect)(()=>{if(e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(vf):null;t&&(d.current=t)};return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e]),(0,z.useEffect)(()=>{if(!e)return;let n=t.current;if(!n)return;let r=Symbol(`modal`),i=d.current;d.current=null;let a=i?.isConnected===!0?i:document.activeElement instanceof HTMLElement?document.activeElement:null;yf.push(r);let f=()=>c.current?.(n)??bf(n)[0]??n,p=requestAnimationFrame(()=>f().focus()),m=e=>{if(yf.at(-1)!==r)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),s.current();return}if(e.key!==`Tab`)return;let t=bf(n),i=t[0],a=t.at(-1);if(!i||!a){e.preventDefault(),n.focus();return}let o=document.activeElement;!(o instanceof Node)||!n.contains(o)?(e.preventDefault(),(e.shiftKey?a:i).focus()):e.shiftKey&&(o===i||o===n)?(e.preventDefault(),a.focus()):!e.shiftKey&&o===a&&(e.preventDefault(),i.focus())},h=e=>{yf.at(-1)!==r||n.contains(e.target)||f().focus()};return document.addEventListener(`keydown`,m,!0),document.addEventListener(`focusin`,h,!0),()=>{cancelAnimationFrame(p),document.removeEventListener(`keydown`,m,!0),document.removeEventListener(`focusin`,h,!0);let e=yf.lastIndexOf(r);e>=0&&yf.splice(e,1),!(o.current||u.current?.()===!1)&&requestAnimationFrame(()=>{let e=l.current?.()??a;e?.isConnected&&e.focus()})}},[e,t])}var Sf=900;function Cf(){return(0,z.useCallback)(e=>{if(!e)return;let t=0,n,r=()=>{t=0;let n=e.scrollTop>1,r=e.scrollTop+e.clientHeight<e.scrollHeight-1;e.dataset.fade=n&&r?`both`:n?`top`:r?`bottom`:`none`},i=()=>{t||=requestAnimationFrame(r)},a=()=>{e.dataset.scrolling=`true`,n&&clearTimeout(n),n=setTimeout(()=>{delete e.dataset.scrolling},Sf),i()};r(),e.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(i);o.observe(e);for(let t of e.children)o.observe(t);let s=new MutationObserver(i);return s.observe(e,{childList:!0,subtree:!0}),()=>{e.removeEventListener(`scroll`,a),o.disconnect(),s.disconnect(),t&&cancelAnimationFrame(t),n&&clearTimeout(n)}},[])}function wf(){let e=Y(e=>e.api),t=Y(e=>e.rawOpen),n=Y(e=>e.closeRaw),r=Y(e=>e.openRaw),[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(),[c,l]=(0,z.useState)(`event`),[u,d]=(0,z.useState)({}),f=(0,z.useRef)(null),p=Cf(),m=(0,z.useCallback)(()=>{!e||!t||(a(void 0),s(void 0),d({}),e.raw(t.sessionId,t.eventId).then(a,e=>s(e instanceof Error?e.message:String(e))))},[e,t]);(0,z.useEffect)(m,[m]);let h=t?.sessionId,g=i?.event.seq;(0,z.useEffect)(()=>{if(!e||h===void 0||g===void 0)return;let t=!0;return e.events(h,g-2,g+1,3).then(e=>{t&&d({prev:e.find(e=>e.seq===g-1)?.id,next:e.find(e=>e.seq===g+1)?.id})},()=>{}),()=>{t=!1}},[e,h,g]);let _=(0,z.useCallback)(e=>{e&&h&&r(h,e)},[r,h]);if(xf({active:t!==void 0,containerRef:f,onClose:n,initialFocus:e=>e.querySelector(`[data-modal-initial]`)}),(0,z.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key===`ArrowLeft`||e.key===`ArrowRight`){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),_(e.key===`ArrowLeft`?u.prev:u.next);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,_,u]),!t)return null;let v=i?af(i.event):void 0;return(0,W.jsxs)(`div`,{className:`drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`drawer-title`,ref:f,tabIndex:-1,children:[(0,W.jsxs)(`div`,{className:`drawer-head`,children:[(0,W.jsx)(`h2`,{className:`drawer-title`,id:`drawer-title`,children:v?v.title:`Source record`}),(0,W.jsxs)(`div`,{className:`drawer-acts`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>_(u.prev),disabled:!u.prev,title:`The record before this one (←)`,children:[(0,W.jsx)(X,{name:`prev`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`The record before this one`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>_(u.next),disabled:!u.next,title:`The record after this one (→)`,children:[(0,W.jsx)(X,{name:`next`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`The record after this one`})]}),i&&(0,W.jsx)(Df,{data:i}),(0,W.jsx)(`span`,{className:`toolbar-sep`,"aria-hidden":`true`}),(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:n,title:`Close (Escape)`,"data-modal-initial":`true`,children:[(0,W.jsx)(X,{name:`close`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,W.jsxs)(`div`,{className:`drawer-panes`,children:[(0,W.jsx)(`button`,{type:`button`,"aria-pressed":c===`event`,className:`btn ${c===`event`?`is-on`:``}`,onClick:()=>l(`event`),title:`What Salidium derived and stored`,children:`Salidium event`}),(0,W.jsx)(`button`,{type:`button`,"aria-pressed":c===`raw`,className:`btn ${c===`raw`?`is-on`:``}`,onClick:()=>l(`raw`),title:`The original line from the agent's own file`,children:`Provider record`}),v&&(0,W.jsx)(`span`,{className:`drawer-id mono`,children:v.meta})]}),(0,W.jsxs)(`div`,{className:`drawer-body scroll-fade`,ref:p,children:[o&&(0,W.jsxs)(`div`,{className:`bad`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`bad-title`,children:`Could not load this record`}),(0,W.jsx)(`p`,{className:`mono`,children:o}),(0,W.jsx)(`button`,{type:`button`,className:`btn btn-accent`,onClick:m,children:`Try again`})]}),!i&&!o&&(0,W.jsx)(`div`,{className:`muted`,role:`status`,children:(0,W.jsx)(Z,{label:`Loading the record`})}),i&&v&&c===`event`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Tf,{facts:v.facts}),(0,W.jsx)(`h3`,{className:`drawer-sub`,children:`How we know`}),(0,W.jsx)(Tf,{facts:v.origin}),(0,W.jsxs)(`details`,{className:`drawer-full`,children:[(0,W.jsx)(`summary`,{children:`Everything Salidium stored, as it is stored`}),(0,W.jsx)(`pre`,{className:`mono`,children:JSON.stringify(i.event,null,2)})]})]}),i&&c===`raw`&&(0,W.jsxs)(W.Fragment,{children:[i.path!==void 0&&(0,W.jsx)(Tf,{facts:[{label:`Line`,value:`${i.path}:${(i.line??0)+1}`,mono:!0,copy:!0}]}),i.raw===null||i.raw===void 0?(0,W.jsx)(`p`,{className:`muted`,children:i.reason??`No raw record.`}):(0,W.jsx)(`pre`,{className:`mono drawer-raw`,children:typeof i.raw==`string`?i.raw:JSON.stringify(i.raw,null,2)})]})]})]})}function Tf({facts:e}){if(e.length===0)return null;let t=new Map,n=e.map(e=>{let n=`${e.label}\u0000${e.value}`,r=(t.get(n)??0)+1;return t.set(n,r),{fact:e,key:r===1?n:`${n}\u0000${r}`}});return(0,W.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,W.jsx)(Ef,{fact:e.fact},e.key))})}function Ef({fact:e}){let[t,n]=(0,z.useState)(`idle`),r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(t===`idle`)return;let e=setTimeout(()=>n(`idle`),2400);return()=>clearTimeout(e)},[t]),(0,W.jsxs)(`div`,{className:`fact ${e.block?`is-block`:``}`,children:[(0,W.jsx)(`dt`,{className:`fact-label`,children:e.label}),(0,W.jsxs)(`dd`,{className:`fact-value`,children:[(0,W.jsx)(`span`,{className:e.mono?`mono`:void 0,ref:r,children:e.value}),e.note&&(0,W.jsx)(`span`,{className:`fact-note`,children:e.note}),e.copy&&(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon fact-copy`,onClick:()=>{nf(e.value).then(e=>{if(e===`copied`)return n(`copied`);rf(r.current),n(`selected`)})},title:t===`copied`?`Copied`:t===`selected`?`This window cannot reach the clipboard, so it is selected instead`:`Copy the ${e.label.toLowerCase()}`,children:[(0,W.jsx)(X,{name:t===`copied`?`check`:`copy`}),(0,W.jsxs)(`span`,{className:`sr-only`,children:[`Copy the `,e.label.toLowerCase()]})]})]})]})}function Df({data:e}){return(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>{let t=JSON.stringify({event:e.event,provider:{path:e.path,line:e.line,record:e.raw,reason:e.reason}},null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`salidium-${e.event.seq}-${e.event.kind}.json`,r.click(),URL.revokeObjectURL(n)},title:`Save both records as a JSON file`,children:[(0,W.jsx)(X,{name:`save`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Save both records as a JSON file`})]})}function Of(e){switch(e){case`working`:return{glyph:`●`,label:`Working`,cls:`st-working`};case`waiting`:return{glyph:`◐`,label:`Waiting for you`,cls:`st-waiting`};case`idle`:return{glyph:`○`,label:`Idle`,cls:`st-idle`};case`ended`:return{glyph:`◌`,label:`Ended`,cls:`st-ended`};default:return{glyph:`·`,label:`Unknown`,cls:`st-unknown`}}}var kf=[`working`,`waiting`,`idle`,`ended`];function Af(){let[e,t]=(0,z.useState)(!1),n=dd(e,()=>t(!1));return(0,W.jsxs)(`div`,{className:`pop`,ref:n,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon ${e?`is-on`:``}`,onClick:()=>t(e=>!e),"aria-expanded":e,title:`What the marks on a row mean`,children:[(0,W.jsx)(X,{name:`help`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`What the marks on a row mean`})]}),(0,W.jsxs)(`div`,{className:`pop-panel is-narrow marks-key arrives ${e?`is-open`:``}`,children:[(0,W.jsx)(`div`,{className:`pop-head`,children:(0,W.jsx)(`span`,{children:`On a row`})}),(0,W.jsxs)(`dl`,{children:[kf.map(e=>{let t=Of(e);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`status-dot ${t.cls}`,"aria-hidden":`true`,children:t.glyph}),(0,W.jsx)(`dd`,{children:t.label.toLowerCase()})]},e)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{"aria-hidden":`true`,children:(0,W.jsxs)(`span`,{className:`attn-badge num is-live`,children:[(0,W.jsx)(X,{name:`flag`}),`1`]})}),(0,W.jsx)(`dd`,{children:`to review`})]})]})]})]})}var jf=18e5;function Mf(e,t){if(e.status===`waiting`)return!0;if(e.counts.reviewOpen===0||e.status===`ended`)return!1;if(e.status===`working`)return!0;let n=Date.parse(e.lastEventAt??``);return Number.isFinite(n)&&t-n<jf}function Nf(e){return!e.title&&e.counts.turns===0&&e.counts.toolCalls===0&&e.counts.filesChanged===0}function Pf(e){return`${e.title??``} ${e.repoRoot??``} ${e.cwd??``} ${e.providerSessionId}`.toLowerCase()}function Ff(e){let t=e.toLowerCase().split(/\s+/).filter(Boolean);return t.length===0?()=>!0:e=>{let n=Pf(e);return t.every(e=>n.includes(e))}}var If=150;function Lf({now:e}){let t=Y(e=>e.sessionOrder),n=Y(e=>e.sessions),r=Y(e=>e.selectedId),i=Y(e=>e.sessionsLoaded),a=Y(e=>e.select),o=Y(e=>e.sessionQuery),s=Y(e=>e.setSessionQuery),c=Y(e=>e.api),l=Y(e=>e.sessionSearch),u=Y(e=>e.setSessionSearch),d=Cf(),f=o.trim();if((0,z.useEffect)(()=>{if(!c)return;let e=new AbortController,t=setTimeout(()=>{c.searchSessions(f,{limit:f?void 0:0,signal:e.signal}).then(u,()=>{})},If);return()=>{clearTimeout(t),e.abort()}},[c,f,u]),!i)return(0,W.jsx)(`div`,{className:`side-empty`,children:(0,W.jsx)(Z,{label:`Loading sessions`})});if(t.length===0)return(0,W.jsxs)(`div`,{className:`side-empty`,children:[(0,W.jsx)(`p`,{children:`No agent sessions yet.`}),(0,W.jsx)(`p`,{className:`muted`,children:`Start a Claude Code or Codex session and it will appear here within a second. Sessions from the last few days are read in when the daemon starts.`})]});let p=l?.query===f?l:void 0,m=p?.ids?p.ids.map(e=>n[e]).filter(e=>!!e):t.map(e=>n[e]).filter(e=>!!e).filter(Ff(f)),h=m.filter(Nf),g=m.filter(e=>!Nf(e)),_=[[`Needs you`,g.filter(t=>Mf(t,e))],[`Working`,g.filter(t=>!Mf(t,e)&&t.status===`working`)],[`Recent`,g.filter(t=>!Mf(t,e)&&t.status!==`working`)]],v=f.length>0,y=l?.total,b=p?.matched,x=b!==void 0&&b>0&&y!==void 0?y-b:0,S=b!==void 0&&b>m.length;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Rf,{query:o,setQuery:s}),(0,W.jsxs)(`div`,{className:`side-scroll scroll-fade`,ref:d,children:[_.map(([t,n])=>n.length===0?null:(0,W.jsx)(zf,{title:t,count:n.length,filtering:v,children:(0,W.jsx)(`ul`,{className:`session-list`,"aria-label":t,children:n.map(t=>(0,W.jsx)(Bf,{s:t,selected:t.id===r,now:e,onSelect:()=>a(t.id)},t.id))})},t)),h.length>0&&(0,W.jsx)(zf,{title:`Nothing recorded`,count:h.length,filtering:v,title2:`Sessions that started and ended without running a turn`,children:(0,W.jsx)(`ul`,{className:`session-list is-quiet`,"aria-label":`Sessions with nothing recorded`,children:[...h].sort((e,t)=>(t.lastEventAt??t.startedAt??``).localeCompare(e.lastEventAt??e.startedAt??``)).map(t=>(0,W.jsx)(Bf,{s:t,selected:t.id===r,now:e,onSelect:()=>a(t.id)},t.id))})}),!v&&y!==void 0&&y>m.length&&(0,W.jsxs)(`p`,{className:`side-hidden`,children:[m.length,` of `,y,` sessions`]}),v&&b===0&&y!==void 0&&(0,W.jsxs)(`p`,{className:`side-none`,children:[`Nothing matches `,(0,W.jsx)(`strong`,{children:o}),`.`,(0,W.jsxs)(`span`,{className:`muted`,children:[` `,y,` searched by name, repo and id.`]})]}),v&&S&&(0,W.jsxs)(`p`,{className:`side-hidden`,children:[`Showing the newest `,m.length,` of `,b,` matches`]}),v&&x>0&&(0,W.jsxs)(`p`,{className:`side-hidden`,children:[x,` `,x===1?`session`:`sessions`,` hidden by the filter`]})]})]})}function Rf({query:e,setQuery:t}){return(0,W.jsxs)(`div`,{className:`side-find`,children:[(0,W.jsx)(`span`,{className:`side-find-mark`,"aria-hidden":`true`,children:(0,W.jsx)(X,{name:`search`})}),(0,W.jsx)(`input`,{className:`field side-find-field`,type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Find a session`,"aria-label":`Find a session by name, repo or id`,spellCheck:!1,autoComplete:`off`}),e!==``&&(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon side-find-clear`,onClick:()=>t(``),title:`Clear the filter`,children:[(0,W.jsx)(X,{name:`close`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Clear the filter`})]})]})}function zf({title:e,count:t,filtering:n,title2:r,children:i}){let a=Y(t=>t.folded.includes(e)),o=Y(e=>e.toggleFold),s=n||!a;return(0,W.jsxs)(`section`,{className:`side-section`,children:[(0,W.jsx)(`h2`,{className:`side-section-h`,children:(0,W.jsxs)(`button`,{type:`button`,className:`side-section-head is-toggle`,onClick:()=>o(e),"aria-expanded":s,title:r??(s?`Fold ${e} away`:`Show ${e}`),children:[(0,W.jsx)(`span`,{className:`chev ${s?`is-open`:``}`,"aria-hidden":`true`,children:`›`}),(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`span`,{className:`num`,children:t})]})}),s&&i]})}function Bf({s:e,selected:t,now:n,onSelect:r}){let i=Of(e.status),a=Mf(e,n),o=Sd(e.repoRoot||e.cwd),s=e.title||(Nf(e)?e.providerSessionId.slice(0,8):o)||`unnamed`,c=s!==o,l=[s,c&&`in ${o}`,i.label,e.counts.reviewOpen>0&&`${e.counts.reviewOpen} to review`].filter(Boolean).join(`, `);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,className:`session-row ${t?`is-selected`:``} ${a?`has-attn`:``}`,onClick:r,"aria-current":t?`true`:void 0,"aria-label":l,title:c?`${s} (${o})`:s,children:[(0,W.jsx)(`span`,{className:`status-dot ${i.cls}`,"aria-hidden":`true`,children:i.glyph}),(0,W.jsx)(`span`,{className:`session-title`,children:s}),(0,W.jsx)(`span`,{className:`session-when`,title:`Last activity`,children:_d(e.lastEventAt??e.startedAt,n)}),e.counts.reviewOpen>0&&(0,W.jsxs)(`span`,{className:`attn-badge num ${a?`is-live`:``}`,title:a?`${e.counts.reviewOpen} to review, needs you now`:`${e.counts.reviewOpen} flagged during this session; it is no longer running`,children:[(0,W.jsx)(X,{name:`flag`}),e.counts.reviewOpen]})]})})}function Vf(e,t){return t<e?`duplicate`:t>e?`resnapshot`:`accept`}function Hf(e){return e instanceof U&&e.status===404?{kind:`not-found`,message:`Session not found`}:e instanceof U&&e.status===0?{kind:`unreachable`,message:e.message}:{kind:`failed`,message:e instanceof Error?e.message:String(e)}}function Uf(e,t=0){let n=Y(e=>e.api);(0,z.useEffect)(()=>{if(!n||!e)return;let t=!1,r=0,i,a=[],o=[],s,c=()=>{s=void 0;let t=a,n=o;a=[],o=[],(t.length||n.length)&&Y.getState().applyEvents(e,t,n)},l=()=>{a=[],o=[],s!==void 0&&cancelAnimationFrame(s),s=void 0},u=async()=>{let d=++r;i?.(),i=void 0,l();try{let l=await n.snapshot(e);if(t||d!==r)return;let f=Y.getState();f.initLive(e,l.state,l.changes),f.setDaemonError(void 0),n.changes(e).then(n=>{!t&&d===r&&n.length>l.changes.length&&Y.getState().applyEvents(e,[],n)},()=>void 0);let p=l.seq,m=l.seq+1;i=n.stream(()=>`/api/sessions/${encodeURIComponent(e)}/stream?after=${p}`,e=>{if(!(t||d!==r)){if(e.type===`event`){let t=e.event,n=Vf(m,t.seq);if(n===`duplicate`)return;if(n===`resnapshot`){u();return}m+=1,p=t.seq,a.push(t)}else if(e.type===`changes`)o.push(...e.changes);else return;s===void 0&&(s=requestAnimationFrame(c))}},n=>{!t&&d===r&&Y.getState().setLiveConnection(e,n)},()=>{!t&&d===r&&u()})}catch(n){if(t||d!==r||n instanceof U&&n.status===401)return;Y.getState().setLiveError(e,Hf(n))}};return u(),()=>{t=!0,r+=1,i?.(),l()}},[n,e,t])}function Wf(){let e=Y(e=>e.api);(0,z.useEffect)(()=>{if(!e)return;let t=!1;e.sessions().then(e=>{if(t)return;let n=Y.getState();n.upsertSessions(e),n.setDaemonError(void 0)},e=>{t||e instanceof U&&e.status===401||Y.getState().setDaemonError({message:e instanceof Error?e.message:String(e),unreachable:e instanceof U&&e.status===0})});let n=e.stream(`/api/stream`,e=>{e.type===`session`&&Y.getState().upsertSessions([e.summary]),e.type===`sessionRemoved`&&Y.getState().removeSession(e.id)},e=>Y.getState().setListConnection(e));return()=>{t=!0,n()}},[e])}var Gf={off:{label:`Local only`,detail:`No model calls`},session:{label:`When done`,detail:`One model call after the session ends`},turn:{label:`Each reply`,detail:`One model call after every agent reply`}};function Kf(e){if(e)return e.envOff?`off`:e.cadence}function qf(e){let t=Kf(e);return t?Gf[t]:void 0}function Jf(e){return e===`claude-code`?`Claude Code`:e===`codex`?`Codex`:e}function Yf(e,t,n=new Date().toISOString()){return{format:`salidium.session-report`,version:1,exportedAt:n,session:e,report:t}}function Xf(e){return`salidium-${e.normalize(`NFKD`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``).toLowerCase().slice(0,64)||`session`}.json`}function Zf(e,t){let n=new Blob([`${JSON.stringify(Yf(e,t),null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=Xf(e.title),i.click(),URL.revokeObjectURL(r)}function Qf(e){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null);return(0,z.useLayoutEffect)(()=>{if(!t||!r)return;let e=()=>t.style.setProperty(`--foot-space`,`${r.getBoundingClientRect().height}px`);e();let n=new ResizeObserver(e);return n.observe(r),()=>n.disconnect()},[t,r,e]),[n,i]}function $f(e){let[t,n]=(0,z.useState)(e);return e&&!t&&n(!0),t||e}var ep={status:`status`,what:`what changed`,why:`why`,how:`how`,verified:`checks`,left:`left to do`,review:`needs review`};function tp(){let e=Y(e=>e.historyKinds),t=Y(e=>e.setHistoryKinds),[n,r]=(0,z.useState)(!1),i=dd(n,()=>r(!1)),a=new Set(e),o=a.size===Hu.length,s=n=>t(a.has(n)?e.filter(e=>e!==n):[...e,n]);return(0,W.jsxs)(`div`,{className:`pop`,ref:i,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn ${n?`is-on`:``}`,onClick:()=>r(e=>!e),"aria-expanded":n,title:`Choose which kinds of change to show`,children:[(0,W.jsx)(X,{name:`filter`}),(0,W.jsx)(`span`,{children:`Filter`}),(0,W.jsx)(`span`,{className:`btn-pill`,children:o?`All`:`${a.size}/${Hu.length}`})]}),(0,W.jsxs)(`div`,{className:`pop-panel is-left is-narrow arrives ${n?`is-open`:``}`,children:[(0,W.jsxs)(`div`,{className:`pop-head`,children:[(0,W.jsx)(`span`,{children:`Show`}),!o&&(0,W.jsxs)(`button`,{type:`button`,className:`pop-help`,onClick:()=>t([...Hu]),title:`Show every kind again`,children:[(0,W.jsx)(X,{name:`reset`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Show every kind again`})]})]}),(0,W.jsxs)(`fieldset`,{className:`opts`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Kinds of change to show`}),Hu.map(e=>(0,W.jsxs)(`label`,{className:`opt is-tight ${a.has(e)?`is-on`:``}`,children:[(0,W.jsx)(`input`,{className:`sr-only`,type:`checkbox`,checked:a.has(e),onChange:()=>s(e)}),(0,W.jsx)(`span`,{className:`opt-swatch facet-${e}`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`opt-name`,children:ep[e]})]},e))]})]})]})}function np(e){return`ep-${e}`}function rp({changes:e,scrubTs:t,focusSeq:n,onScrub:r,onLive:i,onClose:o,onRef:s}){let c=Y(e=>e.historyKinds),l=Y(e=>e.setHistoryMode),u=(0,z.useRef)(null),d=Cf(),f=(0,z.useCallback)(e=>(u.current=e,d(e)),[d]),[p,m]=(0,z.useState)(n!==void 0);(0,z.useEffect)(()=>m(n!==void 0),[n]);let h=p&&n!==void 0,g=(0,z.useMemo)(()=>new Set(c),[c]),_=(0,z.useMemo)(()=>e.filter(e=>g.has(e.facet)&&(!h||e.seq>n)),[e,g,h,n]),v=a({count:_.length,getScrollElement:()=>u.current,estimateSize:()=>52,overscan:12,useFlushSync:!1,anchorTo:`end`,followOnAppend:!0}),[y,b]=(0,z.useState)(!0),x=v.getTotalSize();return(0,z.useEffect)(()=>{y&&t===void 0&&_.length>0&&x>0&&v.scrollToIndex(_.length-1,{align:`end`})},[_.length,y,t,v,x]),(0,W.jsxs)(`aside`,{className:`inspector history`,"aria-label":`History`,children:[(0,W.jsxs)(`div`,{className:`inspector-head`,children:[(0,W.jsx)(Q,{icon:`panel`,title:`Hide history (h)`,onClick:o}),(0,W.jsx)(tp,{}),(0,W.jsx)(Q,{icon:`table`,title:`Open the history as a table across the page`,onClick:()=>l(`table`)}),(0,W.jsxs)(`span`,{className:`inspector-title`,children:[h?`Since you looked`:`History`,` `,(0,W.jsx)(`span`,{className:`num`,children:_.length})]})]}),(t!==void 0||h)&&(0,W.jsxs)(`div`,{className:`history-scope`,children:[t!==void 0&&(0,W.jsx)(Q,{icon:`latest`,label:`Back to live`,title:`Stop showing a past moment`,onClick:i}),h&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>m(!1),children:`Show all history`})]}),(0,W.jsxs)(`div`,{className:`history-list scroll-fade`,ref:f,onScroll:()=>{let e=u.current;e&&b(e.scrollTop+e.clientHeight>=e.scrollHeight-40)},children:[_.length===0&&(0,W.jsx)(`div`,{className:`side-empty muted`,children:`No history yet.`}),(0,W.jsx)(`div`,{style:{height:x,position:`relative`},children:v.getVirtualItems().map(e=>{let n=_[e.index];if(!n)return null;let i=t!==void 0&&n.ts===t,a=t!==void 0&&n.ts>t;return(0,W.jsxs)(`div`,{"data-index":e.index,ref:v.measureElement,className:`hist-item facet-${n.facet} ${i?`is-scrub`:``} ${a?`is-future`:``}`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:[(0,W.jsxs)(`button`,{type:`button`,className:`hist-main`,onClick:()=>r(n.ts,n.seq),title:`Show the session as of this moment`,children:[(0,W.jsxs)(`span`,{className:`hist-meta`,children:[(0,W.jsx)(`span`,{className:`hist-dot`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`hist-facet`,children:ep[n.facet]}),n.epistemic!==`observed`&&(0,W.jsx)(`span`,{className:`hist-prov ${np(n.epistemic)}`,title:n.epistemic===`explained`?`Generated by a model, not observed`:n.epistemic===`reported`?`The agent said so; Salidium did not see it`:`Worked out by Salidium rather than seen directly`,children:n.epistemic}),(0,W.jsx)(`span`,{className:`hist-time mono`,children:gd(n.ts)})]}),(0,W.jsx)(`span`,{className:`hist-text`,children:n.summary})]}),n.refs[0]&&(0,W.jsx)(`button`,{type:`button`,className:`link hist-record`,onClick:()=>s(n.refs[0]??``),title:`Open the raw record this came from`,children:`record`})]},`${n.seq}:${n.ordinal}`)})})]})]})}function ip(e){return e+1}function ap(e){return e+2}function op({changes:e,scrubTs:t,onScrub:n,onLive:r,onRef:i}){let o=Y(e=>e.historyKinds),s=Y(e=>e.setHistoryMode),c=(0,z.useRef)(null),l=Cf(),u=(0,z.useCallback)(e=>(c.current=e,l(e)),[l]),d=(0,z.useMemo)(()=>new Set(o),[o]),f=(0,z.useMemo)(()=>e.filter(e=>d.has(e.facet)),[e,d]),p=a({count:f.length,getScrollElement:()=>c.current,estimateSize:()=>40,overscan:16,useFlushSync:!1});return(0,W.jsxs)(`div`,{className:`htab`,children:[(0,W.jsxs)(`header`,{className:`htab-head`,children:[(0,W.jsxs)(`h1`,{className:`htab-title`,children:[`History `,(0,W.jsx)(`span`,{className:`num`,children:f.length})]}),(0,W.jsxs)(`div`,{className:`toolbar htab-tools`,children:[(0,W.jsx)(tp,{}),t!==void 0&&(0,W.jsx)(Q,{icon:`latest`,label:`Back to live`,title:`Stop showing a past moment`,onClick:r}),(0,W.jsx)(Q,{icon:`panel`,label:`Show beside`,title:`Move the history back into the side rail`,onClick:()=>s(`rail`)})]})]}),(0,W.jsxs)(`div`,{className:`htab-grid`,role:`table`,"aria-label":`History`,"aria-rowcount":ip(f.length),children:[(0,W.jsxs)(`div`,{className:`htab-row is-head`,role:`row`,"aria-rowindex":1,children:[(0,W.jsx)(`span`,{role:`columnheader`,children:`When`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`Kind`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`Change`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`How we know`}),(0,W.jsx)(`span`,{role:`columnheader`,children:(0,W.jsx)(`span`,{className:`sr-only`,children:`Record`})})]}),(0,W.jsx)(`div`,{className:`htab-scroll scroll-fade`,ref:u,children:(0,W.jsx)(`div`,{style:{height:p.getTotalSize(),position:`relative`},children:p.getVirtualItems().map(e=>{let r=f[e.index];if(!r)return null;let a=t!==void 0&&r.ts===t,o=t!==void 0&&r.ts>t;return(0,W.jsxs)(`div`,{"data-index":e.index,ref:p.measureElement,role:`row`,"aria-rowindex":ap(e.index),className:`htab-row facet-${r.facet} ${a?`is-scrub`:``} ${o?`is-future`:``}`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:[(0,W.jsx)(`span`,{role:`cell`,children:(0,W.jsx)(`button`,{type:`button`,className:`htab-when mono`,onClick:()=>n(r.ts,r.seq),title:`Show the session as of this moment`,children:gd(r.ts)})}),(0,W.jsxs)(`span`,{role:`cell`,className:`htab-kind`,children:[(0,W.jsx)(`span`,{className:`hist-dot`,"aria-hidden":`true`}),ep[r.facet]]}),(0,W.jsx)(`span`,{role:`cell`,className:`htab-text`,children:r.summary}),(0,W.jsx)(`span`,{role:`cell`,className:`htab-prov`,children:r.epistemic===`observed`?``:r.epistemic}),(0,W.jsx)(`span`,{role:`cell`,children:r.refs[0]&&(0,W.jsxs)(`button`,{type:`button`,className:`tag-ev`,onClick:()=>i(r.refs[0]??``),title:`Open the raw record this came from`,children:[(0,W.jsx)(X,{name:`record`}),`record`]})})]},`${r.seq}:${r.ordinal}`)})})})]}),f.length===0&&(0,W.jsx)(`p`,{className:`rp-empty`,children:`No history yet.`})]})}function sp({id:e,title:t,children:n,sections:r}){let i=Y(e=>e.panel)===e,a=Y(e=>e.closePanel),o=(0,z.useRef)(null),[s,c]=(0,z.useState)(),l=r?.some(e=>e.key===s)?s:r?.[0]?.key,u=r?.find(e=>e.key===l)??r?.[0];xf({active:i,containerRef:o,onClose:a});let d=$f(i);return(0,z.useEffect)(()=>{i&&l!==s&&c(l)},[i,l,s]),d?(0,W.jsxs)(`div`,{className:`panel-scrim arrives ${i?`is-open`:``}`,inert:!i,children:[(0,W.jsx)(`div`,{className:`panel-backdrop`,"aria-hidden":`true`,onClick:a}),(0,W.jsxs)(`div`,{className:`panel-card panel-card-${e}`,ref:o,role:`dialog`,"aria-modal":`true`,"aria-label":t,tabIndex:-1,children:[(0,W.jsxs)(`div`,{className:`panel-head`,children:[(0,W.jsx)(`h2`,{className:`panel-title`,children:t}),(0,W.jsx)(`button`,{type:`button`,className:`panel-close`,onClick:a,title:`Close (Esc)`,children:(0,W.jsx)(X,{name:`close`})})]}),r&&r.length>0?(0,W.jsxs)(`div`,{className:`panel-split`,children:[(0,W.jsx)(`nav`,{className:`panel-rail`,"aria-label":`${t} sections`,children:r.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`panel-rail-item ${e.key===l?`is-on`:``}`,"aria-current":e.key===l?`true`:void 0,onClick:()=>c(e.key),children:[(0,W.jsx)(`span`,{className:`panel-rail-label`,children:e.label}),e.count!==void 0&&(0,W.jsx)(`span`,{className:`panel-rail-count num`,children:e.count})]},e.key))}),(0,W.jsx)(`div`,{className:`panel-body`,children:u?.render()})]}):(0,W.jsx)(`div`,{className:`panel-body`,children:n})]})]}):null}var cp=`Codex CLI default (not pinned)`;function lp(e){return e===cp?`Automatic`:e??`Unavailable`}function up(e){return e===cp}var dp={pass:`✓`,fail:`✕`,partial:`◐`,unknown:`?`};function fp(e){return dp[e]??`?`}function pp(e,t){let n=(0,z.useRef)(null),[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let t=n.current;if(!t||e)return;let r=()=>i(t.scrollHeight-t.clientHeight>1);r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[e,t]),[n,r]}function mp({steps:e,terminal:t=`accent`}){return e.length===0?null:(0,W.jsx)(`ol`,{className:`fd-chain end-${t}`,children:e.map((e,t)=>(0,W.jsx)(`li`,{className:`fd-node`,children:e},`${t}:${e}`))})}function hp({lanes:e,trunk:t}){return(0,W.jsxs)(`div`,{className:`fd-converge`,children:[(0,W.jsx)(`div`,{className:`fd-lanes`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(e=>(0,W.jsxs)(`div`,{className:`fd-lane`,children:[(0,W.jsx)(`p`,{className:`fd-lane-title`,children:e.title}),(0,W.jsx)(`ol`,{className:`fd-lane-steps`,children:e.steps.map((e,t)=>(0,W.jsx)(`li`,{children:e},`${t}:${e}`))})]},e.title))}),t.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gp,{count:e.length}),(0,W.jsx)(mp,{steps:t})]})]})}function gp({count:e,fanOut:t=!1}){return(0,W.jsxs)(`div`,{className:`fd-junction ${t?`is-fan`:``}`,style:{"--lanes":e},"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{className:`fd-trunk`}),(0,W.jsx)(`span`,{className:`fd-bus`}),(0,W.jsx)(`div`,{className:`fd-stems`,children:Array.from({length:e},(e,t)=>(0,W.jsx)(`span`,{},t))})]})}function _p({root:e,steps:t}){return t.length===0?null:e?(0,W.jsxs)(`div`,{className:`fd-tree has-root`,children:[(0,W.jsx)(`p`,{className:`fd-root mono`,children:e}),(0,W.jsx)(gp,{count:t.length,fanOut:!0}),(0,W.jsx)(vp,{steps:t})]}):(0,W.jsx)(`div`,{className:`fd-tree`,children:(0,W.jsx)(vp,{steps:t})})}function vp({steps:e}){return(0,W.jsx)(`ul`,{className:`fd-branches`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((e,t)=>(0,W.jsx)(`li`,{className:`fd-node`,children:e},`${t}:${e}`))})}function yp({from:e,fromSteps:t,to:n,toSteps:r,why:i}){return(0,W.jsxs)(`div`,{className:`fd-ba`,children:[(0,W.jsxs)(`div`,{className:`fd-ba-side is-was`,children:[(0,W.jsx)(`p`,{className:`fd-ba-label`,children:`Was`}),(0,W.jsx)(`p`,{className:`fd-ba-head`,children:e}),(0,W.jsx)(mp,{steps:t,terminal:`bad`})]}),i&&(0,W.jsxs)(`p`,{className:`fd-ba-why`,children:[(0,W.jsx)(`span`,{className:`fd-ba-pivot`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:i})]}),(0,W.jsxs)(`div`,{className:`fd-ba-side is-now`,children:[(0,W.jsx)(`p`,{className:`fd-ba-label`,children:`Now`}),(0,W.jsx)(`p`,{className:`fd-ba-head`,children:n}),(0,W.jsx)(mp,{steps:r,terminal:`good`})]})]})}function bp({marks:e}){let t=[];return e.junction&&t.push([`fd-key-junction`,`where separate paths meet`]),e.outcome&&t.push([`fd-key-outcome`,`abandoned, and adopted`]),t.length===0?null:(0,W.jsx)(`ul`,{className:`fd-legend`,children:t.map(([e,t])=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`fd-key ${e}`,"aria-hidden":`true`}),t]},e))})}function xp({sessionId:e,hasCurrentPresentation:t,onDone:n}){let r=Y(e=>e.personalization),i=Y(e=>e.personalizationLoading),a=Y(e=>e.personalizationLoadError),o=Y(e=>e.explainer),s=Y(e=>e.loadPersonalization),c=Y(e=>e.savePersonalization),l=Y(e=>e.deletePersonalization),u=Y(e=>e.personalizeSession),[d,f]=(0,z.useState)(),p=(0,z.useRef)(null),[m,h]=(0,z.useState)(`idle`);if((0,z.useEffect)(()=>s(),[s]),(0,z.useEffect)(()=>p.current?.focus(),[]),(0,z.useEffect)(()=>{r&&d===void 0&&f(r.profile.guidance)},[d,r]),!r||d===void 0)return a?(0,W.jsxs)(`div`,{className:`ex-personalize mu-load-error`,role:`alert`,children:[(0,W.jsx)(`span`,{children:a}),(0,W.jsxs)(`button`,{className:`btn mu-retry`,type:`button`,onClick:s,children:[(0,W.jsx)(X,{name:`reset`}),`Retry`]})]}):(0,W.jsx)(Z,{label:i?`Loading personalization settings`:`Waiting for Salidium`,block:!0});let g=r.profile.guidance,_=d.trim(),v=r.revision!==`none`&&g!==``,y=r.enabled&&v,b=_!==g,x=Kf(o),S=o===void 0,ee=!!(x&&x!==`off`&&o?.activeBackend),te=m===`saving`||m===`generating`||m===`clearing`,ne=b||!y,C=t&&!b,re=b?{icon:`edit`,label:`Unsaved changes`,state:`dirty`}:v?{icon:`check`,label:`Saved on this machine`,state:`saved`}:{icon:`close`,label:`Not saved`,state:`empty`};return(0,W.jsxs)(`form`,{id:`personalization-composer`,className:`ex-personalize`,onSubmit:async t=>{if(t.preventDefault(),!(!_||te)){if(ne)try{h(`saving`),await c({enabled:!0,profile:{guidance:_}})}catch{h(`save-error`);return}if(ee)try{h(`generating`),await u(e),h(`personalized`),n?.()}catch{h(`generation-error`)}else h(`saved`)}},children:[(0,W.jsx)(`label`,{className:`mu-guidance-label`,htmlFor:`personalization-guidance`,children:`Terms and examples`}),(0,W.jsx)(`span`,{className:`sr-only`,id:`personalization-boundary`,children:ee?`Personalizing sends this note and the generated explanation to the selected explanation agent. Evidence and transcripts stay local.`:`Saving keeps this note on this machine.`}),(0,W.jsxs)(`div`,{className:`mu-composer`,children:[(0,W.jsx)(`input`,{id:`personalization-guidance`,ref:p,className:`mu-guidance`,type:`text`,value:d,onChange:e=>{f(e.target.value),h(`idle`)},"aria-describedby":`personalization-boundary`,maxLength:800,placeholder:`Use kitchen examples…`}),(0,W.jsx)(`button`,{className:`btn btn-accent`,type:`submit`,disabled:!_||te||S||(ee?C:!ne),title:ee?t?`Replaces this report's current personalized version`:`Creates one personalized version of this report`:`Saves this note on this machine`,children:m===`saving`||m===`generating`||S?(0,W.jsx)(Z,{label:m===`saving`?`Saving`:m===`generating`?`Applying`:`Loading model settings`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{name:C?`check`:ee?`sliders`:`save`}),ee?C?`Applied`:`Apply`:`Save terms`]})})]}),(0,W.jsxs)(`div`,{className:`mu-meta`,children:[(0,W.jsxs)(`p`,{className:`mu-save-state is-${re.state}`,role:`status`,children:[(0,W.jsx)(X,{name:re.icon}),re.label]}),v&&(0,W.jsx)(`button`,{className:`btn mu-clear`,type:`button`,disabled:te,onClick:async()=>{h(`clearing`);try{await l(),f(``),h(`cleared`)}catch{h(`clear-error`)}},children:m===`clearing`?(0,W.jsx)(Z,{label:`Deleting`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{name:`trash`}),`Delete saved terms`]})})]}),(0,W.jsx)(`p`,{className:`mu-status`,role:`status`,children:m===`save-error`?`Not saved. Try again.`:m===`generation-error`?`Saved, but this report was not updated. Try again.`:m===`clear-error`?`Not cleared. Try again.`:``})]})}var Sp={fileEdit:`edit`,fileWrite:`edit`,fileRead:`read`,search:`read`,command:`run`,subagent:`delegate`,webFetch:`look`,webSearch:`look`,mcp:`look`,plan:`plan`,question:`plan`,other:`run`},Cp=4,wp={edit:e=>`edited ${e} ${e===1?`file`:`files`}`,read:e=>`read ${e} ${e===1?`file`:`files`}`,run:e=>`ran ${e} ${e===1?`command`:`commands`}`,delegate:e=>`delegated to ${e} ${e===1?`subagent`:`subagents`}`,look:e=>`${e} ${e===1?`lookup`:`lookups`}`,plan:e=>`planned (${e})`},Tp={edit:`±`,read:`⋯`,run:`$`,delegate:`⇢`,look:`@`,plan:`☰`};function Ep(e){let t=e.split(/\s+/).find(e=>e.includes(`/`)||/\.[a-z0-9]+$/i.test(e));return t?Sd(t):void 0}var Dp=new Set([`edit`]);function Op(e,t){let n=new Map(e.verifications.map(e=>[e.callId,e])),r=new Map(t.filter(e=>e.callId).map(e=>[e.callId,e])),i=[],a,o=[],s=()=>{if(!a)return;let e=[...new Set(a.items.map(e=>Ep(e.title)).filter(Boolean))],t=a.bucket===`edit`&&e.length===1?`edited ${e[0]}${a.items.length>1?` (${a.items.length}\u00d7)`:``}`:wp[a.bucket](e.length||a.items.length);i.push({kind:`work`,bucket:a.bucket,label:t,detail:e.length>1?e.slice(0,3).join(`, `):void 0,at:a.items[0]?.startedAt??``,refs:a.items.map(e=>e.callId),quiet:!1}),a=void 0},c=()=>{if(o.length===0)return;let e=new Map;for(let t of o){let n=Sp[t.kind];e.set(n,(e.get(n)??0)+1)}i.push({kind:`work`,bucket:`read`,label:[...e.entries()].map(([e,t])=>wp[e](t)).join(`, `),at:o[0]?.startedAt??``,refs:o.map(e=>e.callId),quiet:!0}),o=[]},l=()=>{s(),c()};for(let t of e.activities){let e=n.get(t.callId);if(e){l(),i.push({kind:`check`,row:e});continue}let u=r.get(t.callId);if(u){l(),i.push({kind:`commit`,sha:u.sha,at:u.at,callId:u.callId});continue}let d=Sp[t.kind];Dp.has(d)?a&&a.bucket===d&&o.length<Cp?(o=[],a.items.push(t)):(s(),c(),a={bucket:d,items:[t]}):o.push(t)}l();let u=i.map(e=>e.kind===`check`).lastIndexOf(!0);return i.slice(u+1).some(e=>e.kind===`work`&&e.bucket===`edit`)&&i.push({kind:`gap`,label:`nothing checked these edits`}),i}var kp=6;function Ap({turns:e,commits:t,onRef:n}){let[r,i]=(0,z.useState)(kp);if(e.length===0)return null;let a=e.length>r?e.slice(e.length-r):e,o=e.length-a.length;return(0,W.jsxs)(`section`,{className:`viz`,"aria-label":`What the agent did, in order`,children:[(0,W.jsxs)(`h3`,{className:`viz-title`,children:[`What happened `,(0,W.jsxs)(`span`,{className:`viz-count num`,children:[e.length,` turns`]})]}),o>0&&(0,W.jsxs)(`button`,{type:`button`,className:`flow-more`,onClick:()=>i(e=>e+kp),children:[`show `,Math.min(kp,o),` earlier `,o===1?`turn`:`turns`]}),(0,W.jsx)(`ol`,{className:`flow`,children:a.map((e,r)=>(0,W.jsx)(jp,{turn:e,commits:t,onRef:n,defaultOpen:r===a.length-1},e.id))})]})}function jp({turn:e,commits:t,onRef:n,defaultOpen:r}){let[i,a]=(0,z.useState)(r),o=Op(e,t),s=o.filter(e=>e.kind===`check`),c=s.filter(e=>e.kind===`check`&&e.row.outcome===`fail`).length,l=s.filter(e=>e.kind===`check`&&e.row.outcome===`pass`).length,u=o.some(e=>e.kind===`gap`);return(0,W.jsxs)(`li`,{className:`flow-turn ${i?`is-open`:``}`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flow-ask`,onClick:()=>a(e=>!e),"aria-expanded":i,children:[(0,W.jsx)(`span`,{className:`flow-ask-n num`,children:e.index+1}),(0,W.jsx)(`span`,{className:`flow-ask-text`,children:e.prompt||`(prompt not recorded)`}),(0,W.jsxs)(`span`,{className:`flow-sum`,children:[u&&(0,W.jsx)(`span`,{className:`flow-chip flow-sum-gap`,children:`unchecked`}),c>0?(0,W.jsxs)(`span`,{className:`flow-chip flow-sum-bad`,children:[(0,W.jsx)(`span`,{className:`num`,children:c}),` failed`]}):l>0&&(0,W.jsxs)(`span`,{className:`flow-chip flow-sum-ok`,children:[(0,W.jsx)(`span`,{className:`num`,children:l}),` passed`]})]}),(0,W.jsx)(`span`,{className:`flow-ask-caret`,"aria-hidden":`true`,children:`›`})]}),i&&(0,W.jsx)(`ol`,{className:`flow-steps`,children:o.map((e,t)=>(0,W.jsx)(Mp,{step:e,onRef:n},t))})]})}function Mp({step:e,onRef:t}){if(e.kind===`gap`)return(0,W.jsxs)(`li`,{className:`flow-step is-gap`,children:[(0,W.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:`!`}),(0,W.jsx)(`span`,{className:`flow-label`,children:e.label})]});if(e.kind===`check`){let n=e.row,r=fp(n.outcome);return(0,W.jsxs)(`li`,{className:`flow-step is-check v-${n.outcome}`,children:[(0,W.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:r}),(0,W.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>t(n.callId),children:[n.label,n.epistemic===`inferred`&&(0,W.jsx)(`span`,{className:`flow-derived`,children:`derived`})]}),(0,W.jsx)(`span`,{className:`flow-at mono`,children:gd(n.at)})]})}return e.kind===`commit`?(0,W.jsxs)(`li`,{className:`flow-step is-commit`,children:[(0,W.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:`◆`}),(0,W.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>e.callId&&t(e.callId),children:[`committed `,(0,W.jsx)(`span`,{className:`mono`,children:e.sha.slice(0,7)})]}),(0,W.jsx)(`span`,{className:`flow-at mono`,children:gd(e.at)})]}):(0,W.jsxs)(`li`,{className:`flow-step is-${e.bucket} ${e.quiet?`is-quiet`:``}`,children:[(0,W.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:Tp[e.bucket]}),(0,W.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>e.refs[0]&&t(e.refs[0]),children:[e.label,e.detail&&(0,W.jsx)(`span`,{className:`flow-detail mono`,children:e.detail})]}),(0,W.jsx)(`span`,{className:`flow-at mono`,children:gd(e.at)})]})}function Np({files:e,cwd:t,limit:n=10,onOpen:r}){if(e.length===0)return null;let i=[...e].sort((e,t)=>t.linesAdded+t.linesRemoved-(e.linesAdded+e.linesRemoved)).slice(0,n),a=Math.max(1,...i.map(e=>e.linesAdded+e.linesRemoved)),o=e.length-i.length,s=xd(i.map(e=>e.path));return(0,W.jsxs)(`section`,{className:`viz`,"aria-label":`Churn for ${e.length} changed files`,children:[(0,W.jsxs)(`h3`,{className:`viz-title`,children:[`Changed `,(0,W.jsx)(`span`,{className:`viz-count num`,children:e.length})]}),s&&(0,W.jsx)(`p`,{className:`viz-root mono`,title:s,children:(0,W.jsx)(`bdi`,{children:bd(s)})}),(0,W.jsx)(`ul`,{className:`churn`,children:i.map(e=>{let n=e.linesAdded+e.linesRemoved;return(0,W.jsxs)(`li`,{className:`churn-row`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`churn-main`,onClick:()=>r(e),children:[(0,W.jsxs)(`span`,{className:`churn-name mono`,title:e.path,children:[Sd(e.path),(0,W.jsx)(`span`,{className:`churn-dir`,children:Cd(s?e.path.slice(s.length):yd(e.path,t))})]}),(0,W.jsxs)(`span`,{className:`churn-bar`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{className:`churn-add`,style:{width:`${e.linesAdded/a*100}%`}}),(0,W.jsx)(`span`,{className:`churn-del`,style:{width:`${e.linesRemoved/a*100}%`}})]}),(0,W.jsxs)(`span`,{className:`churn-num num`,children:[(0,W.jsxs)(`span`,{className:`add`,children:[`+`,e.linesAdded]}),(0,W.jsxs)(`span`,{className:`del`,children:[`−`,e.linesRemoved]})]}),!e.verifiedAfter&&(0,W.jsx)(`span`,{className:`churn-flag`,title:`No passing check ran after this edit`,children:`?`})]}),(0,W.jsxs)(`span`,{className:`sr-only`,children:[yd(e.path,t),`: `,n,` lines changed`,e.verifiedAfter?``:`, unchecked since`]})]},e.path)})}),o>0&&(0,W.jsxs)(`p`,{className:`viz-foot`,children:[o,` smaller changes not shown`]})]})}function Pp({runs:e,onOpen:t}){if(e.length===0)return null;let n=[...new Set(e.map(e=>e.method))],r=e=>e===`pass`?`passing`:e===`fail`?`failing`:e===`partial`?`partial`:`unknown`;return(0,W.jsxs)(`section`,{className:`viz checks`,"aria-label":`${e.length} checks across ${n.length} kinds`,children:[(0,W.jsx)(`ul`,{className:`checks-rows`,children:n.map(n=>{let i=e.filter(e=>e.method===n).sort((e,t)=>e.at.localeCompare(t.at)),a=i[i.length-1];if(!a)return null;let o=i.filter(e=>e.outcome===`fail`).length;return(0,W.jsxs)(`li`,{className:`checks-row`,children:[(0,W.jsx)(`span`,{className:`checks-method`,children:n}),(0,W.jsxs)(`span`,{className:`checks-now v-${a.outcome}`,children:[(0,W.jsx)(`span`,{className:`checks-now-mark`,"aria-hidden":`true`,children:fp(a.outcome)}),r(a.outcome),a.counts?.total!==void 0&&(0,W.jsxs)(`span`,{className:`checks-counts num`,children:[a.counts.passed??0,`/`,a.counts.total]})]}),(0,W.jsx)(`span`,{className:`checks-strip`,children:i.map(e=>(0,W.jsx)(`button`,{type:`button`,className:`checks-tick v-${e.outcome} ${e.epistemic===`inferred`?`is-derived`:``}`,onClick:()=>t(e),title:`${gd(e.at)}, ${e.label}${e.epistemic===`inferred`?` (worked out, not observed)`:``}`,children:(0,W.jsxs)(`span`,{className:`sr-only`,children:[gd(e.at),` `,e.outcome]})},e.id))}),(0,W.jsx)(`span`,{className:`checks-runs`,children:i.length===1?`ran once`:`${i.length} runs${o>0?`, ${o} failed`:``}`}),(0,W.jsx)(`span`,{className:`checks-when`,children:gd(a.at)})]},n)})}),(0,W.jsx)(`p`,{className:`checks-key`,children:`Oldest first. A hollow mark is one Salidium worked out rather than read. Open any run for its record.`})]})}function Fp({files:e,failing:t,onOpen:n}){if(e.length===0)return null;let r=e.slice(0,120),i=e.filter(e=>e.verifiedAfter).length,a=e.length-i,o=t.length>0;return(0,W.jsxs)(`section`,{className:`viz cov`,"aria-label":`Which changed files a passing check ran after`,children:[(0,W.jsxs)(`p`,{className:`cov-lead`,children:[(0,W.jsxs)(`strong`,{className:`num`,children:[i,` of `,e.length]}),` `,`changed `,e.length===1?`file has`:`files have`,` had a passing check since it was last edited.`]}),o&&(0,W.jsxs)(`p`,{className:`cov-held`,children:[t.join(` and `),` `,t.length===1?`is`:`are`,` still failing.`]}),(0,W.jsx)(`p`,{className:`cov-scope`,children:`A filled square is one file, not the project. A full grid does not mean the project is green.`}),(0,W.jsx)(`ul`,{className:`cov-grid`,children:r.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{type:`button`,className:`cov-cell ${e.verifiedAfter?`is-covered`:`is-stale`}`,onClick:()=>n?.(e),title:`${e.path}: ${e.verifiedAfter?e.verifiedBy??`checked after the last edit`:`changed after the last passing check`}`,children:(0,W.jsxs)(`span`,{className:`sr-only`,children:[e.path,`:`,` `,e.verifiedAfter?`checked since last edit`:`not checked since last edit`]})})},e.path))}),e.length>120&&(0,W.jsxs)(`p`,{className:`cov-more`,children:[`…and `,e.length-120,` more.`]}),(0,W.jsxs)(`ul`,{className:`cov-key`,children:[(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`cov-cell is-covered`,"aria-hidden":`true`}),` checked since last edit`,(0,W.jsx)(`span`,{className:`num cov-key-n`,children:i})]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`cov-cell is-stale`,"aria-hidden":`true`}),` changed since the last check`,(0,W.jsx)(`span`,{className:`num cov-key-n`,children:a})]})]})]})}function Ip({ex:e,sessionId:t,personalized:n=!1,analogies:r,hasAlternate:i=!1,onToggleVersion:a,personalizerOpen:o,onClosePersonalizer:s,personalizationNote:c,hasCurrentPresentation:l=!1}){let u=e.approachChange,d=e.why.lanes.length>1,f=e.why.chain.length>0||e.why.lanes.length>0,p={junction:d,outcome:!!u};return(0,W.jsxs)(`section`,{className:`ex`,"aria-label":`Generated explanation`,children:[(0,W.jsx)(`p`,{className:`ex-what`,children:e.what.summary}),e.what.currently&&(0,W.jsxs)(`p`,{className:`ex-now`,children:[(0,W.jsx)(`span`,{className:`ex-now-key`,children:`Now`}),e.what.currently]}),i&&a&&(0,W.jsxs)(`div`,{className:`ex-version-row`,children:[c&&(0,W.jsxs)(`span`,{className:`ex-version-note`,title:c,children:[(0,W.jsx)(X,{name:`sliders`}),(0,W.jsx)(`span`,{children:`Saved:`}),c]}),(0,W.jsxs)(`fieldset`,{className:`ex-version-switch`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Explanation version`}),(0,W.jsxs)(`button`,{type:`button`,className:`btn ex-version-button ${n?``:`is-on`}`,"aria-pressed":!n,onClick:n?a:void 0,children:[(0,W.jsx)(X,{name:`record`}),`Original`]}),(0,W.jsxs)(`button`,{type:`button`,className:`btn ex-version-button ${n?`is-on`:``}`,"aria-pressed":n,onClick:n?void 0:a,children:[(0,W.jsx)(X,{name:`check`}),`Personalized`]})]})]}),o&&(0,W.jsx)(xp,{sessionId:t,hasCurrentPresentation:l,onDone:s}),f&&(0,W.jsxs)(`section`,{className:`ex-block`,id:`sec-why`,"data-diagram-tone":`why`,children:[(0,W.jsx)(Rp,{title:`Why`,summary:e.why.summary}),r?.why&&(0,W.jsx)(Lp,{children:r.why}),d?(0,W.jsx)(hp,{lanes:e.why.lanes,trunk:e.why.chain}):(0,W.jsx)(mp,{steps:e.why.chain})]}),e.how.steps.length>0&&(0,W.jsxs)(`section`,{className:`ex-block`,id:`sec-how`,"data-diagram-tone":`how`,children:[(0,W.jsx)(Rp,{title:`How`,summary:e.how.summary}),r?.how&&(0,W.jsx)(Lp,{children:r.how}),(0,W.jsx)(_p,{root:e.how.root,steps:e.how.steps})]}),u&&(0,W.jsxs)(`section`,{className:`ex-block`,id:`sec-approach`,"data-diagram-tone":`approach`,children:[(0,W.jsx)(Rp,{title:`Approach changed`}),(0,W.jsx)(yp,{from:u.from,fromSteps:u.fromSteps,to:u.to,toSteps:u.toSteps,why:u.why})]}),(0,W.jsxs)(`footer`,{className:`ex-foot`,children:[(0,W.jsx)(bp,{marks:p}),(0,W.jsx)(`div`,{className:`ex-attribution`,children:(0,W.jsxs)(`p`,{className:`ex-mark`,children:[n?`Personalized`:`Generated`,` by`,` `,up(e.model)?`Codex`:e.model]})})]})]})}function Lp({children:e}){return(0,W.jsxs)(`p`,{className:`ex-analogy`,children:[(0,W.jsx)(`span`,{children:`In your terms`}),e]})}function Rp({title:e,summary:t}){return(0,W.jsxs)(`header`,{className:`ex-head`,children:[(0,W.jsx)(`h2`,{className:`ex-title`,children:e}),t&&(0,W.jsx)(`p`,{className:`ex-summary`,children:t})]})}function zp({view:e,onRef:t}){let n=[...new Set(e.left.items.filter(e=>e.source===`verification`&&e.status===`failing`).map(e=>e.text.replace(/\s.*$/,``).toLowerCase()))];return(0,W.jsx)(Fp,{files:e.changes.files,failing:n,onOpen:e=>t(e.lastCallId)})}function Bp({view:e,onRef:t}){return(0,W.jsx)(Pp,{runs:e.verified.runs,onOpen:e=>t(e.callId)})}function Vp({view:e,cwd:t,onRef:n}){return(0,W.jsx)(Np,{files:e.changes.files,cwd:t,limit:20,onOpen:e=>n(e.lastCallId)})}function Hp({view:e,onRef:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ap,{turns:e.turns,commits:e.changes.commits,onRef:t}),(0,W.jsx)(Yp,{subagents:e.subagents,onRef:t})]})}function Up({which:e,view:t,onRef:n}){return(0,W.jsx)(Jp,{view:t,detail:2,onRef:n,only:e})}var Wp={pass:`passed`,fail:`failed`,partial:`partial`,unknown:`unknown`},Gp={"exit-inferred":`exit code not reported, read from the output`,"exit-masked":`exit code hidden by a pipe`,"output-truncated":`output was truncated`,"no-summary-parsed":`no summary line found in the output`,"exit-summary-mismatch":`the output says passed and the exit code says failed`};function Kp(e){return e.filter(e=>e!==`scope-partial`).map(e=>Gp[e]??e).join(` · `)}var qp=6;function Jp({view:e,detail:t,onRef:n,only:r}){let i=e.verified.summary,a=e.review.groups.filter(e=>e.severity!==`info`),o=e=>t>1?e:e.slice(0,qp),s=e=>t>1||e<=qp?null:(0,W.jsxs)(`li`,{className:`rp-none`,children:[`…`,e-qp,` more, under Records`]}),c=e=>r===void 0||r===e;return(0,W.jsxs)(`div`,{className:`rp-cols${r?` is-single`:``}`,children:[c(`checks`)&&(0,W.jsxs)(`div`,{className:`rp-block`,id:`sec-verified`,children:[(0,W.jsx)(`h3`,{className:`rp-title`,children:`Verified`}),i.length===0?(0,W.jsx)(`p`,{className:`rp-none`,children:`No checks observed.`}):(0,W.jsx)(`ul`,{className:`rp-status`,children:i.map(e=>{let r=Kp(e.caveats);return(0,W.jsxs)(`li`,{className:`v-${e.outcome}`,children:[(0,W.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:fp(e.outcome)}),(0,W.jsxs)(`button`,{type:`button`,className:`rp-status-label`,onClick:()=>n(e.callId),children:[e.method,(0,W.jsx)(`span`,{className:`sr-only`,children:Wp[e.outcome]??e.outcome}),e.counts?.total!==void 0&&(0,W.jsxs)(`span`,{className:`mono rp-counts`,children:[e.counts.passed??0,`/`,e.counts.total]})]}),e.scope===`partial`&&(0,W.jsx)(`span`,{className:`rp-subset`,children:`subset`}),e.laterUnreadable>0&&(0,W.jsx)(`span`,{className:`rp-stale`,title:`${e.laterUnreadable} later ${e.laterUnreadable===1?`run`:`runs`} of ${e.method} produced no readable outcome`,children:`not the latest run`}),r&&(0,W.jsx)(`span`,{className:`rp-caveat`,children:r}),t>1&&e.epistemic===`inferred`&&(0,W.jsx)(`span`,{className:`rp-derived`,children:`derived`})]},e.id)})})]}),c(`left`)&&(0,W.jsxs)(`div`,{className:`rp-block`,id:`sec-left`,children:[(0,W.jsx)(`h3`,{className:`rp-title`,children:`Left`}),e.left.items.length===0?(0,W.jsx)(`p`,{className:`rp-none`,children:`Nothing recorded.`}):(0,W.jsxs)(`ul`,{className:`rp-status`,children:[o(e.left.items).map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:e.status===`failing`?`✕`:e.status===`in_progress`?`▸`:`○`}),(0,W.jsx)(`span`,{children:e.text})]},e.id)),s(e.left.items.length)]})]}),c(`review`)&&(0,W.jsxs)(`div`,{className:`rp-block`,id:`sec-review`,children:[(0,W.jsx)(`h3`,{className:`rp-title`,children:`Review`}),a.length===0?(0,W.jsx)(`p`,{className:`rp-none`,children:`Nothing needs you.`}):(0,W.jsxs)(`ul`,{className:`rp-status`,children:[o(a).map(e=>(0,W.jsx)(Zp,{group:e,onRef:n},e.rule)),s(a.length)]})]})]})}function Yp({subagents:e,onRef:t}){if(e.length===0)return null;let n=e.filter(e=>e.lastMessage).length;return(0,W.jsx)(md,{label:`Delegated to ${e.length} ${e.length===1?`agent`:`agents`}${n>0?`, ${n} reported back`:``}`,id:`subagents`,children:(0,W.jsx)(`ul`,{className:`rows`,children:e.map(e=>(0,W.jsx)(Xp,{agent:e,onRef:t},e.id))})})}function Xp({agent:e,onRef:t}){let[n,r]=(0,z.useState)(!1),i=e.lastMessage??``,[a,o]=pp(n,i);return(0,W.jsxs)(`li`,{className:`row row-flat is-quote`,children:[(0,W.jsx)(`span`,{className:`attrib`,children:e.description??e.agentType??e.id}),i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{ref:a,className:`rp-statement-body${n?` is-open`:``}`,children:i}),(o||n)&&(0,W.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>r(!n),children:n?`less`:`more`})]}):(0,W.jsx)(`span`,{className:`muted`,children:e.endedAt?`ended without reporting`:`still running`}),e.eventId&&(0,W.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>t(e.eventId),"aria-label":`Open the record for ${e.description??e.agentType??e.id}`,children:`record`})]})}function Zp({group:e,onRef:t}){let[n,r]=(0,z.useState)(!1),i=e.items[0];return e.occurrences===1&&i?(0,W.jsxs)(`li`,{className:`is-attn`,children:[(0,W.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:`⚠`}),(0,W.jsx)(`span`,{children:i.summary}),i.refs[0]&&(0,W.jsx)(`button`,{type:`button`,className:`link rp-ev`,onClick:()=>t(i.refs[0]),children:`record`})]}):(0,W.jsxs)(`li`,{className:`is-attn rp-group`,children:[(0,W.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:`⚠`}),(0,W.jsxs)(`div`,{className:`rp-group-body`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`rp-group-head`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,W.jsx)(`span`,{className:`rp-group-label`,children:e.label}),(0,W.jsxs)(`span`,{className:`rp-group-count num`,children:[e.occurrences,e.items.length<e.occurrences&&(0,W.jsxs)(`span`,{className:`rp-group-distinct`,children:[` · `,e.items.length,` distinct`]})]})]}),n&&(0,W.jsx)(`ul`,{className:`rp-group-items`,children:e.items.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`mono`,title:e.instance??e.label,children:bd(e.instance??e.label)}),e.repeats>1&&(0,W.jsxs)(`span`,{className:`rp-group-repeats num`,children:[`×`,e.repeats]}),e.refs[0]&&(0,W.jsx)(`button`,{type:`button`,className:`link rp-ev`,onClick:()=>t(e.refs[0]),children:`record`})]},e.id))})]})]})}function Qp({verdict:e,strip:t,onOpen:n}){let r=[e.because,t.waiting?.summary,e.epistemic===`inferred`&&!e.because?`Worked out, not observed.`:void 0].filter(Boolean).join(` `);return(0,W.jsxs)(`div`,{className:`masthead-badges`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`tag is-open`,"data-tone":e.tone,onClick:()=>n(`checks`),title:`Open the checks this verdict was read from`,children:[(0,W.jsx)(`span`,{className:`tag-strong`,children:e.headline}),r&&(0,W.jsx)(`span`,{className:`tag-note`,children:r})]}),t.reviewOpen>0&&(0,W.jsxs)(`button`,{type:`button`,className:`tag is-open`,"data-tone":`attention`,onClick:()=>n(`review`),title:`Things Salidium flagged for a human: failing checks, waiting prompts, destructive commands, claims with no evidence`,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`to review`}),(0,W.jsx)(`span`,{className:`num tag-strong`,children:t.reviewOpen})]}),t.remaining>0&&(0,W.jsxs)(`button`,{type:`button`,className:`tag is-open`,onClick:()=>n(`left`),title:`Work the agent recorded as not yet finished`,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`unfinished`}),(0,W.jsx)(`span`,{className:`num tag-strong`,children:t.remaining})]})]})}var $p=[{value:`off`,name:Gf.off.label},{value:`session`,name:Gf.session.label},{value:`turn`,name:Gf.turn.label}],em=[{value:`auto`,name:`Same as coding`},{value:`claude`,name:`Claude`},{value:`codex`,name:`Codex`}],tm=[{model:`gpt-5.6-sol`,detail:`Highest capability`},{model:`gpt-5.6-terra`,detail:`Balanced`},{model:`gpt-5.6-luna`,detail:`Lightweight`}];function nm(e){return e===`claude`?`Claude Code`:e===`codex`?`Codex`:`Unavailable`}function rm({label:e,model:t,detail:n,exact:r=!0}){return(0,W.jsxs)(`div`,{className:`mu-model-row`,children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsxs)(`dd`,{children:[(0,W.jsx)(`strong`,{className:r?`mono`:void 0,children:t??`Unavailable`}),n&&(0,W.jsx)(`span`,{children:n})]})]})}function im(e){return{name:lp(e),automatic:up(e)}}function am({legend:e,value:t,options:n,disabled:r,onChange:i}){return(0,W.jsxs)(`fieldset`,{className:`mu-choice`,"data-choice":e,children:[(0,W.jsx)(`legend`,{children:e}),(0,W.jsx)(`div`,{className:`mu-choice-set`,children:n.map(e=>(0,W.jsx)(`button`,{type:`button`,className:e.value===t?`is-on`:void 0,"aria-pressed":e.value===t,"data-value":e.value,disabled:r,onClick:()=>i(e.value),children:e.name},e.value))})]})}function om({label:e,scope:t,usage:n,preparing:r=!1}){return(0,W.jsxs)(`div`,{className:`mu-usage-ledger`,children:[(0,W.jsxs)(`div`,{className:`mu-usage-head`,children:[(0,W.jsxs)(`span`,{children:[e,t&&(0,W.jsx)(`small`,{children:t})]}),(0,W.jsx)(`strong`,{children:r?(0,W.jsx)(Z,{label:`Preparing token history`}):n?`${n.messages.toLocaleString()} responses`:`No token data`})]}),n&&(0,W.jsxs)(`dl`,{className:`mu-usage-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Input`}),(0,W.jsx)(`dd`,{children:n.inputTokens.toLocaleString()})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Output`}),(0,W.jsx)(`dd`,{children:n.outputTokens.toLocaleString()})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Cache reused`}),(0,W.jsx)(`dd`,{children:n.cacheReadTokens.toLocaleString()})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Cache stored`}),(0,W.jsx)(`dd`,{children:n.cacheWriteTokens.toLocaleString()})]})]})]})}function sm({provider:e,workModel:t,sessionUsage:n,generatedModel:r}){let i=Y(e=>e.api),a=Y(e=>e.explainer),o=Y(e=>e.loadExplainer),s=Y(e=>e.setExplainerSettings),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),m=(0,z.useRef)(null);if((0,z.useEffect)(()=>{i&&o()},[i,o]),(0,z.useEffect)(()=>{if(!i||a?.usageStatus!==`preparing`)return;let e=window.setInterval(()=>void o(),2e3);return()=>window.clearInterval(e)},[i,a?.usageStatus,o]),(0,z.useEffect)(()=>l(a?.model??``),[a?.model]),(0,z.useEffect)(()=>{f&&m.current?.focus()},[f]),!a)return(0,W.jsx)(Z,{label:`Loading model settings`,block:!0});let h=e===`codex`?a.routes.codex:e===`claude-code`?a.routes.claudeCode:void 0,g=c.trim()!==(a.model??``),_=Kf(a)??`off`,v=Gf[_],y=_!==`off`,b=im(r??h?.model),x=im(h?.model),S=!!(r&&h?.model&&r!==h.model),ee=e===`codex`?`codex`:e===`claude-code`?`claude`:null,te=h?.backend??(a.backend===`auto`?null:a.backend),ne=h??(te===`claude`?a.routes.claudeCode:te===`codex`?a.routes.codex:void 0),C=[],re=new Set,ie=e=>{e.value&&re.has(e.value)||(e.value&&re.add(e.value),C.push(e))};if(te===`claude`&&!a.model&&ne?.model?ie({value:null,name:ne.model,detail:`Salidium default`}):ie({value:null,name:`Automatic`,detail:te?`${nm(te)} chooses`:`Uses the coding agent`}),t&&ee===te&&ie({value:t,name:t,detail:`Current coding model`}),te===`codex`)for(let e of tm)ie({value:e.model,name:e.model,detail:e.detail});return a.model&&ie({value:a.model,name:a.model,detail:`Current selection`}),(0,W.jsxs)(`div`,{className:`mu`,children:[(0,W.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-models`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`mu-models`,children:`Models`}),(0,W.jsx)(`dl`,{className:`mu-models`,children:e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(rm,{label:`Coding`,model:t}),y?(0,W.jsx)(rm,{label:`Explanation`,model:b.name,exact:!b.automatic,detail:b.automatic?`${nm(h?.backend??null)} chooses the model`:void 0}):(0,W.jsx)(rm,{label:`Explanation`,model:`Local only`,detail:`No model calls`,exact:!1}),y&&S&&(0,W.jsx)(rm,{label:`Next`,model:x.name,exact:!x.automatic})]}):y?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(rm,{label:`Claude`,model:a.routes.claudeCode.model}),(0,W.jsx)(rm,{label:`Codex`,model:im(a.routes.codex.model).name,exact:!1})]}):(0,W.jsx)(rm,{label:`Explanation`,model:`Local only`,detail:`No model calls`,exact:!1})})]}),(0,W.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-controls`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`mu-controls`,children:`Explanation`}),a.envOff&&(0,W.jsx)(`p`,{className:`explain-warning`,children:`Disabled by the daemon environment.`}),!a.envOff&&a.cadence!==`off`&&!a.routes.claudeCode.backend&&!a.routes.codex.backend&&(0,W.jsx)(`p`,{className:`explain-warning`,children:a.backendLocked?`The locked helper is unavailable.`:`No selected helper is installed.`}),(0,W.jsxs)(`div`,{className:`mu-control-stack`,children:[(0,W.jsx)(am,{legend:`Written Why + How`,value:a.cadence,options:$p,onChange:e=>s({cadence:e})}),(0,W.jsxs)(`p`,{className:`mu-cadence-note is-${_}`,children:[v.detail,`.`]}),y&&(0,W.jsx)(am,{legend:`Agent`,value:a.backend,options:em,disabled:a.backendLocked,onChange:e=>{e!==a.backend&&(l(``),p(!1),s({backend:e,model:null}))}})]}),y&&u?(0,W.jsxs)(`div`,{className:`mu-model-picker`,children:[(0,W.jsxs)(`div`,{className:`mu-model-picker-head`,children:[(0,W.jsx)(`span`,{children:`Model`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{p(!1),d(!1)},children:`Done`})]}),(0,W.jsxs)(`ul`,{className:`mu-model-options`,"aria-label":`Explanation model choices`,children:[C.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,className:`mu-model-option`,"aria-current":e.value===(a.model??null)?`true`:void 0,disabled:a.modelLocked,onClick:()=>{l(e.value??``),s({model:e.value}),p(!1)},children:[(0,W.jsx)(`span`,{className:`mono`,children:e.name}),(0,W.jsx)(`small`,{children:e.detail})]})},e.value??`automatic`)),(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,className:`mu-model-option`,"aria-expanded":f,disabled:a.modelLocked,onClick:()=>{l(a.model??``),p(!0)},children:[(0,W.jsx)(`span`,{children:`Other model…`}),(0,W.jsx)(`small`,{children:`Enter a model name`})]})})]}),f&&(0,W.jsxs)(`form`,{className:`mu-model-control`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(s({model:t}),p(!1))},children:[(0,W.jsx)(`label`,{htmlFor:`explainer-model`,children:`Model name`}),(0,W.jsxs)(`div`,{className:`mu-model-input`,children:[(0,W.jsx)(`input`,{ref:m,id:`explainer-model`,className:`field mono`,value:c,onChange:e=>l(e.target.value),placeholder:te===`claude`?`claude-…`:`gpt-…`,maxLength:120,disabled:a.modelLocked}),(0,W.jsx)(`button`,{className:`btn btn-accent`,type:`submit`,disabled:a.modelLocked||!g||!c.trim(),children:`Use`}),(0,W.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>{l(a.model??``),p(!1)},children:`Cancel`})]})]}),(a.backendLocked||a.modelLocked)&&(0,W.jsx)(`span`,{className:`explain-lock`,children:`Locked by the daemon environment.`})]}):y?(0,W.jsx)(`button`,{type:`button`,className:`mu-exact-trigger`,"aria-expanded":`false`,onClick:()=>d(!0),children:a.model?`Change model…`:`Choose a model…`}):null]}),(0,W.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-usage`,children:[(0,W.jsx)(`h3`,{className:`mu-title`,id:`mu-usage`,children:`Usage`}),(0,W.jsxs)(`div`,{className:`mu-usage-list`,children:[e&&(0,W.jsx)(om,{label:`Session`,usage:n}),(0,W.jsx)(om,{label:`Explanations`,scope:`all runs`,usage:a.usage,preparing:a.usageStatus===`preparing`})]})]})]})}var cm=8,lm=`live`;function um(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];a!==void 0&&a.ts<=t?n=i+1:r=i}return n-1}var dm=16,fm=(e,t=0)=>`calc(${dm/2+t}px + (100% - ${dm}px) * ${e})`;function pm({startedAt:e,endedAt:t,changes:n,checks:r,commits:i,scrubTs:a,onScrub:o,onLive:s}){let[c,l]=(0,z.useState)(),u=(0,z.useRef)(void 0);(0,z.useEffect)(()=>()=>clearTimeout(u.current),[]);let d=(0,z.useRef)(null),[f,p]=(0,z.useState)(0);(0,z.useLayoutEffect)(()=>{let e=d.current;if(!e)return;p(e.getBoundingClientRect().width);let t=new ResizeObserver(([t])=>p(t?.contentRect.width??e.getBoundingClientRect().width));return t.observe(e),()=>t.disconnect()},[]);let m=(0,z.useMemo)(()=>{let e=[],t=-1;for(let r of n){t=Math.max(t,r.seq);let n=e[e.length-1];n!==void 0&&n.ts===r.ts?n.seq=t:e.push({ts:r.ts,seq:t})}return e},[n,n.length]),h=(0,z.useMemo)(()=>{let e=new Map,t=(t,n)=>{let r=um(m,t);if(r<0)return;let i=e.get(r)??{fail:!1,pass:!1,commit:!1,n:0};i[n]=!0,i.n+=1,e.set(r,i)};for(let e of r)e.outcome===`pass`?t(e.at,`pass`):e.outcome===`fail`&&t(e.at,`fail`);for(let e of i)t(e.at,`commit`);let n=Math.max(0,f-dm),a=n>0&&m.length>0?n/m.length:0,o=a>0?Math.max(1,Math.ceil(cm/a)):1,s=[];for(let t of[...e.keys()].sort((e,t)=>e-t)){let n=e.get(t),r=s[s.length-1];if(r&&t-r.at<o){r.fail||=n.fail,r.pass||=n.pass,r.commit||=n.commit,r.n+=n.n;continue}s.push({at:t,...n})}return s.map(e=>({at:e.at,f:e.at/m.length,tone:e.fail?`fail`:e.pass?`pass`:`commit`,n:e.n}))},[r,i,m,f]);if(m.length===0)return null;let g=c??a,_=g===void 0||g===lm?m.length:Math.max(0,um(m,g)),v=m[_]?.ts,y=_/m.length,b=e=>{let t=m[e];l(t?t.ts:lm),clearTimeout(u.current),u.current=setTimeout(()=>{l(void 0),t?o(t.ts,t.seq):s()},90)};return(0,W.jsxs)(`section`,{className:`timeline`,"aria-label":`Session timeline`,children:[(0,W.jsxs)(`div`,{className:`tl-track`,ref:d,children:[(0,W.jsx)(`div`,{className:`tl-marks`,"aria-hidden":`true`,children:h.map(e=>(0,W.jsx)(`span`,{className:`tl-mark tl-${e.tone}`,style:{left:fm(e.f)},title:`${e.n} ${e.n===1?`event`:`events`} here`},e.at))}),_<m.length&&(0,W.jsx)(`div`,{className:`tl-future`,style:{left:fm(y)},"aria-hidden":`true`}),(0,W.jsx)(`div`,{className:`tl-stem`,style:{left:fm(y,-1)},"aria-hidden":`true`}),(0,W.jsx)(`input`,{className:`tl-range`,type:`range`,min:0,max:m.length,step:1,value:_,onChange:e=>b(Number(e.target.value)),"aria-label":`Show the session as it stood at a moment in time`,"aria-valuetext":v===void 0?t?`the whole session`:`now, following live`:`${gd(v)}, change ${_+1} of ${m.length}, later events hidden`})]}),(0,W.jsxs)(`div`,{className:`tl-legend`,children:[(0,W.jsx)(`span`,{className:`mono`,children:gd(e)}),(0,W.jsx)(`span`,{className:`tl-legend-mid`,children:_>=m.length?t?`whole session`:`following live`:(0,W.jsxs)(W.Fragment,{children:[`showing `,(0,W.jsx)(`strong`,{className:`mono`,children:gd(v)}),(0,W.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>b(m.length),children:`back to now`})]})}),(0,W.jsx)(`span`,{className:`mono`,children:t?gd(t):`now`})]})]})}function mm(){let[e,t]=(0,z.useState)(!1),n=dd(e,()=>t(!1));return(0,W.jsxs)(`div`,{className:`pop`,ref:n,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-float ${e?`is-on`:``}`,onClick:()=>t(e=>!e),"aria-expanded":e,title:`What the track shows`,children:[(0,W.jsx)(X,{name:`help`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`What the track shows`})]}),(0,W.jsxs)(`div`,{className:`pop-panel is-narrow is-up arrives ${e?`is-open`:``}`,children:[(0,W.jsx)(`div`,{className:`pop-head`,children:(0,W.jsx)(`span`,{children:`On the track`})}),(0,W.jsx)(`p`,{className:`pop-note`,children:`One step per change, not per minute. The clock is in the two end labels and in the readout while you drag.`}),(0,W.jsx)(`p`,{className:`pop-note`,children:`A mark is a check or a commit, red where a check failed. Marks too close to draw apart are merged, and a merged mark takes the worst outcome in it.`})]})]})}function hm({sessionId:e,now:t}){let[n,r]=(0,z.useState)(0);Uf(e,n);let i=Y(e=>e.api),a=Y(t=>t.live[e]),o=Y(t=>t.liveErrors[e]),s=Y(t=>t.sessions[e]),c=Y(e=>e.openRaw),l=Y(e=>e.setScrub),u=Y(e=>e.markSeen),d=Y(e=>e.openPanel),f=Y(e=>e.rewindOpen),p=Y(e=>e.toggleRewind),m=Y(e=>e.sidebarOpen),h=Y(e=>e.toggleSidebar),g=Y(e=>e.statsOpen),_=Y(e=>e.toggleStats),v=Y(e=>e.ingestOpen),y=Y(e=>e.toggleIngest),b=Y(e=>e.explainer),x=Y(e=>e.personalization),S=Y(t=>t.personalized[e]),ee=qf(b),te=Kf(b),ne=Y(e=>e.historyMode),C=Y(e=>e.setHistoryMode),[re,ie]=(0,z.useState)(void 0),[ae,oe]=(0,z.useState)(`personalized`),[se,w]=(0,z.useState)(!1),ce=(0,z.useRef)(null),le=Cf(),[ue,de]=Qf(`${f}`),fe=$f(f);(0,z.useEffect)(()=>{oe(`personalized`)},[S?.generatedAt,x?.revision,a?.state.explained?.basedOnSeq]),(0,z.useEffect)(()=>{a?.scrub?.seq!==void 0&&w(!1)},[a?.scrub?.seq]);let pe=a?.state,me=a?.scrub?.state,he=a?.revision??0,ge=a?.scrub?.seq,_e=(0,z.useMemo)(()=>pe?Cu(pe,t):void 0,[pe,he,t]),ve=(0,z.useMemo)(()=>me?Cu(me,t):void 0,[me,ge,t]),ye=(0,z.useCallback)(t=>{let n=Y.getState().live[e]?.state;if(!n)return;let r=t.includes(`#`)?t:n.activities[t]?.eventIds[0]??n.claims.find(e=>e.id===t)?.eventId??n.claims.find(e=>e.id===t)?.id;r&&c(e,r)},[c,e]),be=(0,z.useRef)(0),xe=(0,z.useCallback)((t,n)=>{let r=Y.getState().live[e];if(!i||!r)return;let a=++be.current;l(e,{ts:t,seq:n,state:r.scrub?.state??r.state,loading:!0}),i.stateAtTime(e,t).then(r=>{be.current===a&&l(e,{ts:t,seq:n,state:r.state,loading:!1})},()=>{be.current===a&&l(e,void 0)})},[i,e,l]),Se=(0,z.useCallback)(()=>{be.current++,l(e,void 0)},[e,l]),Ce=(0,z.useMemo)(()=>a?a.changes.filter(e=>e.seq>a.lastSeenSeq&&(e.facet===`what`||e.facet===`verified`||e.facet===`review`||e.facet===`left`)).length:0,[a]);(0,z.useEffect)(()=>()=>u(e),[e,u]);let we=(0,z.useCallback)(()=>{ie(Y.getState().live[e]?.lastSeenSeq),Y.getState().statsOpen&&_(),Y.getState().ingestOpen&&y(),C(`rail`),u(e)},[e,u,C,_,y]),Te=(0,z.useCallback)(()=>{Y.getState().historyMode===`off`?(Y.getState().statsOpen&&_(),Y.getState().ingestOpen&&y(),C(`rail`)):(ie(void 0),C(`off`))},[C,_,y]),Ee=(0,z.useCallback)(()=>{ie(void 0),C(`off`),_()},[C,_]),De=(0,z.useCallback)(()=>{ie(void 0),C(`off`),y()},[C,y]);if((0,z.useEffect)(()=>{let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||(e.key===`h`?Te():e.key===`l`&&ge!==void 0&&Se())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ge,Se,Te]),!a||!pe||!_e)return o?(0,W.jsx)(ym,{error:o,onRetry:()=>r(e=>e+1)}):(0,W.jsx)(`div`,{className:`main-empty`,children:(0,W.jsx)(`div`,{className:`muted`,role:`status`,children:(0,W.jsx)(Z,{label:`Loading session`,size:`md`})})});let Oe=me??pe,T=ve??_e,ke=T.changes.files.length>0||T.verified.runs.length>0||T.turns.length+T.subagents.length>0,Ae=Of(T.strip.status),je=_e.strip.status===`ended`?pe.lastEventAt:void 0,Me=T.explained,Ne=!!(Me&&x?.enabled&&S&&S.profileRevision===x.revision&&S.basedOnSeq===Me.basedOnSeq),Pe=Ne&&ae===`original`,Fe=Ne&&!Pe&&S?{basedOnSeq:S.basedOnSeq,model:S.model,at:S.generatedAt,what:S.what,why:S.why,how:S.how,approachChange:S.approachChange}:Me,Ie=Ne&&!Pe;return(0,W.jsxs)(`div`,{className:`session ${g||v||ne===`rail`?`has-inspector`:``} ${g?`has-models`:``}`,children:[(0,W.jsxs)(`div`,{className:`session-main`,ref:ue,children:[(0,W.jsxs)(`div`,{className:`session-actions`,children:[!m&&(0,W.jsx)(Q,{icon:`panel`,title:`Show the session list ([)`,onClick:h}),(0,W.jsxs)(`div`,{className:`toolbar session-actions-end`,children:[ge===void 0&&Ce>0&&(0,W.jsxs)(`button`,{type:`button`,className:`fresh`,onClick:we,title:`Changes since you last had this session open. Opens History filtered to them.`,children:[`Show `,Ce,` new`]}),ke&&(0,W.jsx)(Q,{icon:`table`,label:`Evidence`,title:`Coverage, checks over time, what changed, what happened when`,onClick:()=>d(`evidence`)}),(0,W.jsx)(Q,{icon:`save`,label:`Export`,title:`Save this report as JSON without raw provider records`,onClick:()=>Zf({id:e,provider:pe.provider,title:pe.title||s?.title||pe.cwd,cwd:pe.cwd,...pe.model?{model:pe.model}:{}},_e)}),(0,W.jsx)(Q,{icon:`latest`,label:`Rewind`,on:f,title:`Show the session as it stood at a moment in time`,onClick:p}),(0,W.jsx)(Q,{icon:`stats`,label:`Models & Usage`,on:g,title:`Show explanation timing, models and usage${ee?`. ${ee.label}: ${ee.detail}.`:``}`,onClick:Ee}),(0,W.jsx)(Q,{icon:`storage`,label:`Ingest & Storage`,on:v,controls:`ingest-storage-inspector`,expanded:v,buttonRef:ce,title:`Show collection state, queued observations, storage, and loss history`,onClick:De}),Me&&(0,W.jsx)(Q,{icon:Ne?`check`:`sliders`,label:Ne?`Personalized`:`Personalize`,on:se,controls:`personalization-composer`,expanded:se,disabled:ge!==void 0,title:ge===void 0?Ne?`Edit the saved terms applied to this report`:`Explain the generated report using terms and examples you know`:`Return to live before personalizing this report`,onClick:()=>w(e=>!e)}),(0,W.jsx)(Q,{icon:`history`,label:`History`,on:ne!==`off`,title:`Toggle history (h)`,onClick:Te}),(0,W.jsx)(ud,{icon:`outbound`,label:`Docs`,href:ld,title:`Open the Salidium documentation in a new tab`}),(0,W.jsx)(pd,{}),a.connection!==`open`&&a.connection!==`connecting`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`toolbar-sep`,"aria-hidden":`true`}),(0,W.jsx)(hd,{status:a.connection})]})]})]}),ne===`table`?(0,W.jsx)(op,{changes:a.changes,scrubTs:a.scrub?.ts,onScrub:xe,onLive:Se,onRef:ye}):(0,W.jsx)(`div`,{className:`session-content scroll-fade`,ref:le,children:(0,W.jsxs)(`article`,{className:`page`,children:[(0,W.jsxs)(`header`,{className:`masthead`,children:[(0,W.jsx)(Xs,{size:16,className:`masthead-mark`}),(0,W.jsx)(`h1`,{className:`masthead-title`,children:Oe.title||s?.title||Oe.cwd}),(0,W.jsxs)(`p`,{className:`masthead-meta`,children:[(0,W.jsxs)(`span`,{className:`tag is-status`,children:[(0,W.jsx)(`span`,{className:`status-dot ${Ae.cls}`,"aria-hidden":`true`,children:Ae.glyph}),Ae.label,T.strip.statusSince&&` ${_d(T.strip.statusSince,t)}`]}),(0,W.jsxs)(`span`,{className:`tag masthead-path`,title:Oe.cwd,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`in`}),(0,W.jsx)(`span`,{className:`mono`,children:bd(yd(Oe.cwd))})]}),Oe.gitBranch&&(0,W.jsxs)(`span`,{className:`tag`,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`branch`}),(0,W.jsx)(`span`,{className:`mono`,children:Oe.gitBranch})]}),(0,W.jsxs)(`span`,{className:`tag is-${Oe.provider}`,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`agent`}),Jf(Oe.provider)]}),Oe.model&&(0,W.jsxs)(`span`,{className:`tag`,children:[(0,W.jsx)(`span`,{className:`tag-key`,children:`model`}),(0,W.jsx)(`span`,{className:`mono`,children:Oe.model})]})]}),(0,W.jsx)(Qp,{verdict:T.verdict,strip:T.strip,onOpen:d})]}),ge!==void 0&&(0,W.jsxs)(`p`,{className:`scrub-note`,role:`status`,children:[`Showing this session as it stood at `,(0,W.jsx)(`strong`,{children:gd(a.scrub?.ts)}),`. Anything later is hidden. `,a.scrub?.loading&&(0,W.jsx)(Z,{label:`replaying`})]}),Fe?(0,W.jsx)(Ip,{ex:Fe,sessionId:e,personalized:Ie,analogies:Ie?S?.analogies:void 0,hasAlternate:Ne,onToggleVersion:Ne?()=>oe(Pe?`personalized`:`original`):void 0,personalizerOpen:se,onClosePersonalizer:()=>w(!1),personalizationNote:x?.profile.guidance,hasCurrentPresentation:Ne}):(0,W.jsx)(vm,{turns:T.turns.length,status:s?.explanationStatus,cadence:te})]})}),(0,W.jsx)(`div`,{className:`session-foot`,ref:de,children:fe&&(0,W.jsxs)(`div`,{className:`rewind arrives ${f?`is-open`:``}`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-float`,onClick:p,title:`Close the scrubber`,children:[(0,W.jsx)(X,{name:`close`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close the scrubber`})]}),(0,W.jsx)(pm,{startedAt:pe.startedAt,endedAt:je,now:t,changes:a.changes,checks:_e.verified.runs,commits:_e.changes.commits,scrubTs:a.scrub?.ts,onScrub:xe,onLive:Se}),(0,W.jsx)(mm,{})]})}),(0,W.jsx)(sp,{id:`checks`,title:`Verified`,children:(0,W.jsx)(Up,{which:`checks`,view:T,onRef:ye})}),(0,W.jsx)(sp,{id:`left`,title:`Left`,children:(0,W.jsx)(Up,{which:`left`,view:T,onRef:ye})}),(0,W.jsx)(sp,{id:`review`,title:`Needs you`,children:(0,W.jsx)(Up,{which:`review`,view:T,onRef:ye})}),(0,W.jsx)(gm,{view:T,cwd:Oe.cwd,onRef:ye})]}),g?(0,W.jsx)(_m,{view:T,provider:Oe.provider,generatedModel:T.explained?.model,onClose:_}):v?(0,W.jsx)(tf,{onClose:y,returnFocusRef:ce}):ne===`rail`?(0,W.jsx)(rp,{changes:a.changes,scrubTs:a.scrub?.ts,focusSeq:re,onScrub:xe,onLive:Se,onClose:Te,onRef:ye}):null]})}function gm({view:e,cwd:t,onRef:n}){let r=Y(e=>e.panel),i=Y(e=>e.closePanel),a=e.changes.files.length,o=e.verified.runs.length,s=e.turns.length+e.subagents.length,c=[];return a>0&&c.push({key:`coverage`,label:`Coverage`,count:a,render:()=>(0,W.jsx)(zp,{view:e,onRef:n})}),o>0&&c.push({key:`checks`,label:`Checks`,count:o,render:()=>(0,W.jsx)(Bp,{view:e,onRef:n})}),a>0&&c.push({key:`changed`,label:`Changed`,count:a,render:()=>(0,W.jsx)(Vp,{view:e,cwd:t,onRef:n})}),s>0&&c.push({key:`happened`,label:`What happened`,count:s,render:()=>(0,W.jsx)(Hp,{view:e,onRef:n})}),(0,z.useEffect)(()=>{r===`evidence`&&c.length===0&&i()},[r,c.length,i]),c.length===0?null:(0,W.jsx)(sp,{id:`evidence`,title:`Evidence`,sections:c})}function _m({view:e,provider:t,generatedModel:n,onClose:r}){return(0,W.jsxs)(`aside`,{className:`inspector models-usage`,"aria-label":`Models & Usage`,children:[(0,W.jsxs)(`div`,{className:`inspector-head`,children:[(0,W.jsx)(Q,{icon:`panel`,title:`Hide Models & Usage`,onClick:r}),(0,W.jsx)(`span`,{className:`inspector-title`,children:`Models & Usage`})]}),(0,W.jsx)(`div`,{className:`models-usage-body scroll-fade`,children:(0,W.jsx)(sm,{provider:t,workModel:e.strip.model,sessionUsage:e.usage,generatedModel:n})})]})}function vm({turns:e,status:t,cadence:n}){return e===0?(0,W.jsx)(`section`,{className:`ex-pending`,role:`status`,children:(0,W.jsx)(`p`,{children:`Nothing has happened in this session yet.`})}):t===`generating`?(0,W.jsxs)(`section`,{className:`ex-pending is-running`,role:`status`,children:[(0,W.jsx)(`p`,{className:`ex-pending-main`,children:(0,W.jsx)(Z,{label:`Reading the session`,size:`md`})}),(0,W.jsx)(`p`,{children:`Your selected agent is writing from a bounded, redacted summary of the session. It takes a few seconds, then the explanation is cached.`})]}):t===`disabled`?(0,W.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,W.jsx)(`p`,{className:`ex-pending-main`,children:`No model-written Why or How.`}),(0,W.jsx)(`p`,{children:`Local only makes no model calls. Change it in Models & Usage.`})]}):t===`unavailable`?(0,W.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,W.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation for this session.`}),(0,W.jsx)(`p`,{children:`No compatible Claude Code or Codex command is available, so nothing was sent. Observed facts are still available in Evidence.`})]}):t===`failed`?(0,W.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,W.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation for this session.`}),(0,W.jsx)(`p`,{children:`The selected agent was asked but returned no usable structured explanation. Observed facts are still available in Evidence; the next turn will try again.`})]}):(0,W.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,W.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation yet.`}),(0,W.jsx)(`p`,{children:n===`session`?`One is written after this session ends or goes quiet.`:n===`turn`?`One is written after the agent finishes its next reply.`:`Choose when to write one in Models & Usage.`})]})}function ym({error:e,onRetry:t}){let n=Y(e=>e.select);return(0,W.jsx)(`div`,{className:`main-empty`,children:(0,W.jsxs)(`div`,{className:`session-error`,role:`alert`,children:[e.kind===`not-found`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`session-error-title`,children:`This session is not in the store`}),(0,W.jsx)(`p`,{className:`muted`,children:`It may have been forgotten, or the daemon was restarted with a fresh store. Pick another session from the list.`})]}),e.kind===`unreachable`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`session-error-title`,children:`Cannot reach the Salidium daemon`}),(0,W.jsxs)(`p`,{className:`muted`,children:[e.message,`. Start it again with `,(0,W.jsx)(`code`,{children:`salidium`}),` in a terminal.`]})]}),e.kind===`failed`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`session-error-title`,children:`Could not load this session`}),(0,W.jsx)(`p`,{className:`muted mono`,children:e.message})]}),(0,W.jsxs)(`div`,{className:`session-error-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn btn-accent`,onClick:t,children:`Try again`}),e.kind===`not-found`&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n(void 0),children:`Back to sessions`})]})]})})}var bm=`salidium open`,xm=/Mac|iPhone|iPad/.test(navigator.platform??``)?`⌘C`:`Ctrl+C`;function Sm(){let[e,t]=(0,z.useState)(()=>Date.now());return(0,z.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),3e4);return()=>clearInterval(e)},[]),e}function Cm(){let[e,t]=(0,z.useState)(()=>window.matchMedia(`(max-width: 900px)`).matches);return(0,z.useEffect)(()=>{let e=window.matchMedia(`(max-width: 900px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function wm(){let e=Y(e=>e.api),t=Y(e=>e.setToken),n=Y(e=>e.authRejected),r=Y(e=>e.selectedId),i=Y(e=>e.select),a=Y(e=>e.sessionOrder),o=Y(e=>e.daemonError),s=a.length,c=Y(e=>e.listConnection),l=Y(e=>e.sidebarOpen),u=Y(e=>e.toggleSidebar),d=Y(e=>e.loadExplainer),f=Y(e=>e.loadPersonalization),p=(0,z.useRef)(null),m=(0,z.useRef)(null),h=Cm()&&l,g=Sm();return(0,z.useEffect)(()=>{let e=()=>{let e=Ws();e&&t(e)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[t]),(0,z.useEffect)(()=>{e&&(d(),f())},[e,d,f]),(0,z.useEffect)(()=>{if(!e)return;let t=()=>f(),n=()=>{document.visibilityState===`visible`&&t()};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,n)}},[e,f]),(0,z.useEffect)(()=>{let e=()=>{let e=/^#\/s\/(.+)$/.exec(window.location.hash);e?.[1]&&i(decodeURIComponent(e[1]))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[i]),(0,z.useEffect)(()=>{let e=r?`#/s/${encodeURIComponent(r)}`:``;window.location.hash!==e&&!/token=/.test(window.location.hash)&&history.replaceState(null,``,`${window.location.pathname}${e}`)},[r]),(0,z.useEffect)(()=>{!r&&a.length>0&&i(a[0])},[r,a,i]),(0,z.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&window.matchMedia(`(max-width: 900px)`).matches&&Y.getState().sidebarOpen){Y.getState().toggleSidebar();return}e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||e.key===`[`&&Y.getState().toggleSidebar()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),xf({active:h&&!!e,containerRef:p,onClose:u,initialFocus:e=>e.querySelector(`[data-modal-initial] button`)??e.querySelector(`button:not([disabled])`),restoreFocus:()=>m.current?.querySelector(`button`)??null,shouldRestoreFocus:()=>!Y.getState().sidebarOpen}),Wf(),e?(0,W.jsxs)(`div`,{className:`app ${l?``:`no-side`}`,children:[(0,W.jsx)(`div`,{className:`side-backdrop arrives ${l?`is-open`:``}`,"aria-hidden":`true`,onClick:u}),!l&&(0,W.jsx)(`div`,{className:`mobile-side-trigger`,ref:m,children:(0,W.jsx)(Q,{icon:`panel`,title:`Show the session list ([)`,onClick:u})}),(0,W.jsxs)(`aside`,{ref:p,className:`side arrives ${l?`is-open`:``}`,role:h?`dialog`:void 0,"aria-modal":h?`true`:void 0,"aria-labelledby":h?`session-list-title`:void 0,"aria-label":h?void 0:`Sessions`,tabIndex:h?-1:void 0,inert:!l,onClickCapture:e=>{window.matchMedia(`(max-width: 900px)`).matches&&e.target.closest(`.session-row`)&&u()},children:[(0,W.jsxs)(`div`,{className:`side-head`,children:[(0,W.jsx)(Xs,{size:22,className:`side-mark`,decorative:!0}),(0,W.jsx)(`span`,{className:`side-head-title`,id:`session-list-title`,children:`Salidium`}),(0,W.jsx)(hd,{status:c}),s>0&&(0,W.jsx)(Af,{}),(0,W.jsx)(`span`,{"data-modal-initial":`true`,children:(0,W.jsx)(Q,{icon:`panel`,title:`Hide the session list ([)`,onClick:u})})]}),(0,W.jsx)(Lf,{now:g}),o&&(0,W.jsxs)(`div`,{className:`side-error`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`side-error-title`,children:`The session list is not updating`}),(0,W.jsxs)(`p`,{children:[o.message,`.`,` `,o.unreachable?(0,W.jsxs)(W.Fragment,{children:[`Start the daemon again with `,(0,W.jsx)(`code`,{children:`salidium`}),` in a terminal.`]}):`It is reachable, so this is worth reporting rather than restarting.`]})]})]}),(0,W.jsx)(`main`,{className:`main`,inert:h,"aria-hidden":h||void 0,children:r?(0,W.jsx)(hm,{sessionId:r,now:g},r):s===0?(0,W.jsx)(Tm,{}):null}),(0,W.jsx)(`div`,{className:`raw-layer`,inert:h,"aria-hidden":h||void 0,children:(0,W.jsx)(wf,{})})]}):(0,W.jsx)(Em,{authRejected:n,onToken:t})}function Tm(){let e=Y(e=>e.statsOpen),t=Y(e=>e.toggleStats),n=Y(e=>e.ingestOpen),r=Y(e=>e.toggleIngest),i=qf(Y(e=>e.explainer)),a=(0,z.useRef)(null);return(0,W.jsxs)(`div`,{className:`first-run ${e||n?`has-inspector`:``}`,children:[(0,W.jsxs)(`div`,{className:`main-empty first-run-main`,children:[(0,W.jsxs)(`div`,{className:`toolbar first-run-actions`,children:[(0,W.jsx)(Q,{icon:`stats`,label:`Models & Usage`,on:e,title:`Show explanation timing, models and usage${i?`. ${i.label}: ${i.detail}.`:``}`,onClick:t}),(0,W.jsx)(Q,{icon:`storage`,label:`Ingest & Storage`,on:n,controls:`ingest-storage-inspector`,expanded:n,buttonRef:a,title:`Show collection state, queued observations, storage, and loss history`,onClick:r})]}),(0,W.jsxs)(`div`,{className:`main-empty-first`,children:[(0,W.jsx)(`p`,{children:`A report appears here when your agent runs.`}),(0,W.jsx)(`p`,{className:`muted`,children:`Start a run in Claude Code or Codex. Salidium reads the session it writes and turns it into what changed, what was checked, and what it flagged for a human.`}),(0,W.jsx)(`a`,{className:`link`,href:ld,target:`_blank`,rel:`noreferrer`,children:`Read the documentation`})]})]}),e?(0,W.jsxs)(`aside`,{className:`inspector models-usage`,"aria-label":`Models & Usage`,children:[(0,W.jsxs)(`div`,{className:`inspector-head`,children:[(0,W.jsx)(Q,{icon:`panel`,title:`Hide Models & Usage`,onClick:t}),(0,W.jsx)(`span`,{className:`inspector-title`,children:`Models & Usage`})]}),(0,W.jsx)(`div`,{className:`models-usage-body scroll-fade`,children:(0,W.jsx)(sm,{})})]}):n?(0,W.jsx)(tf,{onClose:r,returnFocusRef:a}):null]})}function Em({authRejected:e,onToken:t}){let[n,r]=(0,z.useState)(`idle`),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(n===`idle`)return;let e=setTimeout(()=>r(`idle`),2400);return()=>clearTimeout(e)},[n]),(0,W.jsx)(`div`,{className:`gate`,children:(0,W.jsxs)(`div`,{className:`gate-inner`,children:[(0,W.jsx)(`h1`,{className:`gate-mark`,children:(0,W.jsx)(Zs,{markSize:34})}),(0,W.jsx)(`p`,{className:`gate-lede`,role:e?`alert`:void 0,children:e?`The daemon restarted with a new token, so this page signed out.`:`This page needs the token your daemon is listening for.`}),(0,W.jsx)(`p`,{className:`gate-note`,children:`It is rotated every time the daemon starts, so it is never the same one twice.`}),(0,W.jsxs)(`div`,{className:`gate-cmd`,children:[(0,W.jsx)(`code`,{ref:c,children:bm}),(0,W.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>{let e=()=>{let e=c.current;if(e){let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}r(`selected`)};if(!navigator.clipboard)return e();navigator.clipboard.writeText(bm).then(()=>r(`copied`),e)},title:n===`copied`?`Copied`:`Copy the command`,children:[(0,W.jsx)(X,{name:n===`copied`?`check`:`copy`}),(0,W.jsx)(`span`,{className:`sr-only`,children:n===`copied`?`Copied`:`Copy the command`})]})]}),(0,W.jsx)(`p`,{className:`gate-hint`,role:n===`idle`?void 0:`status`,children:n===`copied`?`Copied. Run it in a terminal; it opens this page with the token attached.`:n===`selected`?`This window cannot reach the clipboard, so the command is selected. ${xm} to take it.`:`Run it in a terminal; it opens this page with the token attached.`}),(0,W.jsxs)(`form`,{className:`gate-paste`,onSubmit:e=>{if(e.preventDefault(),i.trim()===``){l.current?.focus();return}let n=Ks(i);if(!n){s(!0);return}s(!1),Gs(n),t(n)},children:[(0,W.jsx)(`input`,{ref:l,className:`field gate-field`,value:i,onChange:e=>{a(e.target.value),s(!1)},placeholder:`or paste the token, or the URL carrying it`,"aria-label":`Daemon token, or a URL containing it`,"aria-invalid":o||void 0,spellCheck:!1,autoComplete:`off`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-accent`,children:`Connect`})]}),o&&(0,W.jsxs)(`p`,{className:`gate-bad`,role:`alert`,children:[`That is not a token. It is a long run of hex, and the URL the command prints carries one after `,(0,W.jsx)(`code`,{children:`#token=`}),`.`]})]})})}var Dm=document.getElementById(`root`);Dm&&(0,ho.createRoot)(Dm).render((0,W.jsx)(z.StrictMode,{children:(0,W.jsx)(wm,{})}));