@promptctl/cc-candybar 1.208.7 → 1.208.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +3 -3
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i}from"node:url";import{json as a}from"node:stream/consumers";import o from"node:os";import s,{basename as c,dirname as l,isAbsolute as u,join as d,resolve as f,sep as p}from"node:path";import m from"node:net";import h,{appendFileSync as g,closeSync as _,constants as v,existsSync as y,fstatSync as b,linkSync as x,mkdtempSync as S,openSync as C,readFileSync as w,readSync as T,rmSync as E,statSync as ee,unlinkSync as D,writeFileSync as te}from"node:fs";import{StringDecoder as O}from"node:string_decoder";import{inspect as k,parseArgs as ne,types as A}from"node:util";import{clearImmediate as re,setImmediate as ie}from"node:timers";import{spawn as ae,spawnSync as oe}from"node:child_process";import se,{createHash as ce,createHmac as le,randomBytes as ue,randomUUID as de,timingSafeEqual as fe}from"node:crypto";import pe from"node:v8";import{open as me,readFile as he,readdir as ge,stat as _e}from"node:fs/promises";import{get as ve}from"node:https";import{WriteStream as ye}from"node:tty";import{createInterface as be}from"node:readline";var xe=Object.create,Se=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,we=Object.getOwnPropertyNames,Te=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty,De=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Oe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=we(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ee.call(e,s)&&s!==n&&Se(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ce(t,s))||r.enumerable});return e},ke=(e,t,n)=>(n=e==null?{}:xe(Te(e)),Oe(t||!e||!e.__esModule?Se(n,`default`,{value:e,enumerable:!0}):n,e));let Ae=!1;const je=()=>Ae;function Me(e){Ae=e}function Ne(e){return je()?`[DEBUG] ${e()}\n`:``}function Pe(e,...t){je()&&console.error(`[DEBUG] ${e}`,...t)}function Fe(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Ie=(e,t)=>Pe(t),Le=`main`,Re=`CC_CANDYBAR_HOME`,ze=`CC_CANDYBAR_NAME`,Be=`CC_CANDYBAR_RUNTIME_DIR`,Ve=/^[a-z0-9][a-z0-9-]*$/;function He(e,t){if(!Ve.test(e))throw Error(`${t} must be lowercase letters, digits and dashes, starting with a letter or digit, got ${JSON.stringify(e)}`);if(e.length>32)throw Error(`${t} must be at most 32 characters, got ${e.length}: ${JSON.stringify(e)}`);return e}function Ue(e){let t=He(e,ze);if(t===`main`)throw Error(`${ze} may not be ${JSON.stringify(Le)}: that is the main renderer's name, which is what an unset ${Re} and ${ze} mean`);return t}function We(e){return e===`main`?Le:He(e,`a link's renderer name`)}function Ge(e){return e===`main`?`socket`:`${e}.sock`}function Ke(e,t){let n=e[t];return n&&n.length>0?n:void 0}function qe(){let e=process.getuid();return s.join(`/tmp`,`cc-candybar-${e}`)}function Je(e){let t=Ke(e.env,Be);if(t===void 0)return qe();if(!s.isAbsolute(t))throw Error(`${Be} must be an absolute path, got ${JSON.stringify(t)}`);return t}function Ye(e){let{env:t}=e,n=Ke(t,Re),r=Ke(t,ze),i=Ke(t,`CC_CANDYBAR_SOCKET`)??null,a=Je(e);if(n!==void 0&&r!==void 0){if(!s.isAbsolute(n))throw Error(`${Re} must be an absolute path, got ${JSON.stringify(n)}`);if(i!==null)throw Error(`CC_CANDYBAR_SOCKET is set beside ${Re} and ${ze}: a named renderer's socket is its name's, so unset it`);return{kind:`named`,name:Ue(r),runtime:a,root:n}}if(n!==void 0||r!==void 0){let[e,t]=n===void 0?[ze,Re]:[Re,ze];throw Error(`${e} is set without ${t}: a renderer's home is both, or neither for the main renderer`)}return{kind:`main`,name:Le,runtime:a,roots:{state:Ke(t,`XDG_STATE_HOME`)??s.join(e.home,`.local`,`state`),cache:Ke(t,`XDG_CACHE_HOME`)??s.join(e.home,`.cache`),config:Ke(t,`XDG_CONFIG_HOME`)??s.join(e.home,`.config`)},legacySocket:i}}const Xe=new Set([`ECONNREFUSED`,`ENOENT`,`ENOTSOCK`]),Ze=e=>({cause:Xe.has(e.code??``)?`unreachable`:`io_error`,message:e.message}),Qe={dial(e){let t=m.createConnection({path:e}),n=!1;return{settled:new Promise(e=>{let r=r=>{t.off(`connect`,i),n=!0,e({ok:!1,failure:Ze(r)})},i=()=>{t.off(`error`,r),n=!0,e({ok:!0,conn:t})};t.once(`error`,r),t.once(`connect`,i)}),abandon:()=>{n||(t.removeAllListeners(),t.destroy())}}}};function $e(e,t){return e+t}function et(e,t){return Math.round(t-e)}function tt(e,t){return et(t,e.monotonic())}const nt={now:()=>Date.now(),monotonic:()=>performance.now(),after:(e,t,n)=>{let r=setTimeout(t,e);return n?.unref&&r.unref(),()=>clearTimeout(r)},every:(e,t,n)=>{let r=setInterval(t,e);return n?.unref&&r.unref(),()=>clearInterval(r)},defer:e=>{let t=ie(e);return()=>re(t)}};function rt(e,t,n){return new Promise((r,i)=>{let a=()=>Object.assign(Error(`The operation was aborted`),{name:`AbortError`,code:`ABORT_ERR`,cause:n?.reason});if(n?.aborted){i(a());return}let o=()=>{s(),i(a())},s=e.after(t,()=>{n?.removeEventListener(`abort`,o),r()});n?.addEventListener(`abort`,o,{once:!0})})}function it(e,t){let n=new AbortController;return e.after(t,()=>n.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`)),{unref:!0}),n.signal}function at(e,t,n,r){return n<e.at+t?`held`:r===`request`&&!e.answered?`owed`:`over`}function ot(e,t){return!e.answered&&e.at===t.at&&e.text===t.text}const st=e=>e.getTime()/1e3,ct=e=>Math.round(e*1e3),lt=e=>new Date(ct(e)),ut=e=>st(new Date(e.now()));function dt(e,t){return A.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!y(t)?`working directory does not exist: ${t}`:e.message:String(e)}const ft={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3};function pt(e,t,n){let r=ft[t];if(r===void 0)return{allowed:!0};let i=e.get(t);if(i===void 0)return{allowed:!0};let a=n-i;return a>=r?{allowed:!0}:{allowed:!1,minIntervalMs:r,sinceLastMs:a}}function mt(e,t){return{...e.inherited,...t.envOverlay}}function ht(e){switch(e.reason){case`non-zero`:return`exited with code ${e.exitCode}`;case`signal`:return`killed by ${e.signal??`a signal`}`;case`timeout`:case`output-limit`:case`rate-limited`:case`pipe-error`:case`spawn-error`:return e.error??e.reason;default:return e.error===void 0?e.reason:`${e.reason}: ${e.error}`}}const gt=e=>{let t=[];for(let n of e){if(t.length===200)return`${t.join(``)}…`;t.push(n)}return e};function _t(e,t){if(e.reason===`output-limit`||e.reason===`pipe-error`)return``;let n=t.trim(),r=n.search(/[\r\n]/);if(r===-1)return gt(n);let i=Math.max(n.lastIndexOf(`
|
|
3
3
|
`),n.lastIndexOf(`\r`))+1;return`${gt(n.slice(0,r).trim())} … ${gt(n.slice(i).trim())}`}function vt(e,t=``){let n=_t(e,e.stderr);return`${ht(e)}${t}${n===``?``:`: ${n}`}`}const yt=({reason:e})=>({ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)});function bt(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${Math.round(n)}ms ago`}}function xt(e,t){let n=t.finally(()=>e.ending.delete(n));return e.ending.add(n),n}function St(e,t,n){let r=Ct(e,t,n);return r===null?(e.lastStartAt.set(t,e.scope.clock.monotonic()),null):(e.scope.stats?.onRefused(t),r)}function Ct(e,t,n){if(e.scope.signal.aborted)return yt(e.scope.signal);if(n?.aborted)return yt(n);let r=pt(e.lastStartAt,t,e.scope.clock.monotonic());return r.allowed?null:bt(t,r.minIntervalMs,r.sinceLastMs)}const wt=`\$1 == "+" { live[\$2] = 1; next } \$1 == "-" { delete live[\$2]; next } END { for (g in live) groups = groups " -" g; if (groups != "") system("kill -TERM" groups " 2>/dev/null; sleep ${250/1e3}; kill -KILL" groups " 2>/dev/null") }`;function Tt(e,t){t!==e.fault&&(e.fault=t,e.scope.observeWarnings({kind:`lifeline`,fault:t}))}function Et(e,t,n){e.lifeline?.process===t&&(e.lifeline=null,t.ref(),Tt(e,n))}const Dt=e=>`programs launched now would outlive their launcher if it died: its launch lifeline ${e}, and the next launch starts another`,Ot=e=>e===`cut`?`output cut at the ${Lt}-byte bound, so the program holding it now fails its writes`:`output failed to read`,kt=`a launched program's pipe outlived its launch: `;function At(e,t,n){let r=e.pipeEvent,i=new Map(r===null||r.answered?[]:r.counts),a=`${t}\0${n}`;i.set(a,(i.get(a)??0)+1),e.pipeEvent={text:`${kt}${[...i].map(([e,t])=>{let[n,r]=e.split(`\0`);return`${t}× ${r} ${Ot(n)}`}).join(`; `)}`,at:e.scope.now(),answered:!1,counts:i},e.scope.observeWarnings({kind:`launch-pipes`,text:`${kt}${n} ${Ot(t)}`})}function jt(e,t){let n=e.pipeEvent;n===null||!ot(n,t)||(e.pipeEvent={...n,answered:!0})}function Mt(e,t,n){let r=e.pipeEvent,i=r===null?`over`:at(r,60,t,n);return[...e.fault===null?[]:[{kind:`lifeline`,message:Dt(e.fault)}],...r===null||i===`over`?[]:[{kind:`launch-pipes`,message:r.text,event:r,hold:i}]]}function Nt(e){let{stats:t,clock:n}=e.scope;t?.onStart(`lifeline`);let r=n.monotonic(),i;try{i=e.spawner.spawn(`awk`,[wt],{stdio:[`pipe`,`ignore`,`ignore`],detached:!0})}catch(i){return t?.onEnd(`lifeline`,tt(n,r)),Tt(e,`did not start: ${dt(i,void 0)}`),null}t?.onEnd(`lifeline`,tt(n,r));let a=i.stdin;if(a==null)return i.once(`error`,t=>Tt(e,`did not start: ${t.message}`)),null;i.once(`spawn`,()=>{e.lifeline?.process===i&&Tt(e,null)}),i.once(`error`,t=>Et(e,i,`failed: ${t.message}`)),i.once(`exit`,(t,n)=>Et(e,i,`exited ${n??t}`)),a.on(`error`,t=>Et(e,i,`pipe failed: ${t.message}`)),xt(e,new Promise(e=>i.once(`close`,e))),i.unref(),a.unref();for(let t of e.liveGroups)a.write(`+ ${t}\n`);return{process:i,pipe:a}}function Pt(e,t){e.liveGroups.add(t),e.lifeline??=Nt(e),e.lifeline?.pipe.write(`+ ${t}\n`)}function Ft(e,t){e.liveGroups.delete(t),e.lifeline?.pipe.write(`- ${t}\n`)}function It(e){let t=e.lifeline;e.lifeline=null,t?.process.ref(),t?.pipe.end()}const Lt=16*1024*1024,Rt=`output exceeded ${Lt} bytes`,zt=e=>`timed out after ${e/1e3} s`;function Bt(e,t,n,r){let{stats:i}=e.scope,a=new O(`utf8`),o=``,s=0,c=0,l=r,u=`closed`;return n?.on(`error`,n=>{i?.onPipeError(t),l===null?At(e,`read-error`,t):l.failed(n)}),n?.on(`data`,r=>{if(l===null){if(c+=r.length,i?.onDrainRead(t,r.length),c<=16777216)return;u=`cut`,n.destroy(),At(e,`cut`,t);return}let d=Math.max(0,Lt-s);o+=a.write(r.subarray(0,d)),s+=r.length,s>16777216&&l.full()}),{take:()=>{if(l===null)return``;l=null;let e=o+a.end();return o=``,e},drain:()=>{n===null||n.destroyed||n.readableEnded||Vt(e,t,n,()=>u)}}}function Vt(e,t,n,r){let{stats:i}=e.scope;if(e.scope.signal.aborted){n.destroy();return}n.once(`close`,()=>{e.drains.delete(n),i?.onDrainClose(t,r())}),n.unref(),e.drains.add(n),i?.onDrainOpen(t)}const Ht=()=>`closed`;function Ut(e,t){e.on(`error`,()=>{}),e.end(t)}async function j(e,t){let{stats:n,clock:r}=e.scope,i=St(e,t.category,t.signal);if(i!==null)return i;let a=r.monotonic();return n?.onStart(t.category),new Promise(i=>{let{spawner:o}=e,s;try{s=o.spawn(t.bin,t.args??[],{cwd:t.cwd,env:mt(e.scope,t),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(e){n?.onEnd(t.category,tt(r,a)),i({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:dt(e,t.cwd)});return}let c=s.pid;c!==void 0&&Pt(e,c);let l=new Promise(e=>s.once(`exit`,e)),u=s.stdin;s.stdin=null;let d=null,f={full:()=>ee(`output-limit`),failed:e=>{d??=e.message,ee(`pipe-error`)}},p=Bt(e,t.category,s.stdout,f),m=Bt(e,t.category,s.stderr,f),h=()=>({stdout:p.take(),stderr:m.take()}),g=!1,_=null,v=null,y=null,b=null,x=()=>ee(`aborted`),S=()=>{t.signal?.removeEventListener(`abort`,x),e.inFlight.delete(x)},C=i=>{g||(g=!0,_?.(),v?.(),y?.(),S(),c!==void 0&&Ft(e,c),n?.onEnd(t.category,tt(r,a)),s.off(`close`,te),s.off(`error`,D),p.drain(),m.drain(),u!==null&&!u.destroyed&&!u.writableFinished&&Vt(e,t.category,u,Ht),i())},w=e=>C(()=>i(e)),T=(n,r)=>{try{o.signalGroup(n,r)}catch(n){e.unreaped.set(s,t.category),l.then(()=>e.unreaped.delete(s)),w({ok:!1,reason:`signal-refused`,...h(),exitCode:null,signal:null,error:n instanceof Error?n.message:String(n)})}},E=()=>te(s.exitCode,s.signalCode);if(c!==void 0){let e=t=>{if(!g){if(o.groupGone(c)){r.defer(E);return}y=r.after(t,()=>e(Math.min(t*2,1e3)))}};l.then(()=>r.defer(()=>e(25)))}let ee=e=>{if(b!==null)return;if((s.exitCode!==null||s.signalCode!==null)&&c!==void 0&&o.groupGone(c)){b=e===`timeout`?null:e,r.defer(E);return}b=e,_?.(),S();let t=s.pid;t!==void 0&&(v=r.after(250,()=>{T(t,`SIGKILL`),l.then(()=>r.defer(E))}),T(t,`SIGTERM`))},D=e=>{w({ok:!1,reason:`spawn-error`,...h(),exitCode:null,signal:null,error:dt(e,t.cwd)})};s.on(`error`,D);let te=(e,n)=>{if(b!==null){w({ok:!1,reason:b,...h(),exitCode:e,signal:n,...b===`timeout`?{error:zt(t.timeoutMs??0)}:b===`output-limit`?{error:Rt}:b===`pipe-error`?{error:`a pipe failed to read: ${d}`}:{}});return}if(e===0){w({ok:!0,...h(),exitCode:e});return}w({ok:!1,reason:n?`signal`:`non-zero`,...h(),exitCode:e,signal:n})};s.on(`close`,te),t.timeoutMs&&t.timeoutMs>0&&(_=r.after(t.timeoutMs,()=>ee(`timeout`))),t.signal?.addEventListener(`abort`,x,{once:!0}),e.inFlight.add(x),u!==null&&Ut(u,t.stdinInput)})}function Wt(e,t){let{stats:n,clock:r}=e.scope,i=St(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);try{let i=e.spawner.spawnSync(t.bin,t.args??[],{cwd:t.cwd,env:mt(e.scope,t),input:t.stdinInput,timeout:t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:void 0,stdio:[`pipe`,`pipe`,`pipe`],encoding:`utf8`});n?.onEnd(t.category,tt(r,a));let o=typeof i.stdout==`string`?i.stdout:``,s=typeof i.stderr==`string`?i.stderr:``,c=i.error?.code;if(i.error&&c!==`EPIPE`&&c!==`ECONNRESET`){let e=c===`ETIMEDOUT`?`timeout`:`spawn-error`;return{ok:!1,reason:e,stdout:o,stderr:s,exitCode:null,signal:i.signal??null,error:e===`timeout`?zt(t.timeoutMs??0):dt(i.error,t.cwd)}}return i.status===0?{ok:!0,stdout:o,stderr:s,exitCode:i.status}:{ok:!1,reason:i.signal?`signal`:`non-zero`,stdout:o,stderr:s,exitCode:i.status,signal:i.signal??null}}catch(e){return n?.onEnd(t.category,tt(r,a)),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:dt(e,t.cwd)}}}function Gt(e,t){let{stats:n,clock:r}=e.scope,i=St(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);let o=Kt(e,t);return n?.onEnd(t.category,tt(r,a)),o}function Kt(e,t){let n;try{n=e.spawner.spawn(t.bin,t.args??[],{cwd:t.cwd,env:mt(e.scope,t),detached:!0,stdio:`ignore`})}catch(e){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:dt(e,t.cwd)}}return n.once(`error`,()=>{}),n.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${t.bin}): no pid (binary not found or unexecutable)`}:(n.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}const qt=e=>e.kind===`exit`?`exit ${e.code}`:`timeout`;function Jt(e,t,n){let{stats:r,clock:i}=e.scope,a=St(e,t.category);if(a!==null)return{ok:!1,reason:a.reason,error:a.error};let o=i.monotonic();r?.onStart(t.category);let s;try{s=e.spawner.spawn(`/bin/sh`,[`-c`,`out=$1 err=$2 status=$3; shift 3; read go || exit 0; "$@" >"$out" 2>"$err" </dev/null; echo "exit $?" >"$status.$$" && ln "$status.$$" "$status"; rm -f "$status.$$"`,`sh`,n.stdout,n.stderr,n.status,t.bin,...t.args??[]],{cwd:t.cwd,env:mt(e.scope,t),detached:!0,stdio:[`pipe`,`ignore`,`ignore`]})}catch(e){return r?.onEnd(t.category,tt(i,o)),{ok:!1,reason:`spawn-error`,error:dt(e,t.cwd)}}r?.onEnd(t.category,tt(i,o)),s.once(`error`,()=>{});let c=s.pid,l=s.stdin;return l.on(`error`,()=>{}),c===void 0?(l.destroy(),{ok:!1,reason:`spawn-error`,error:`spawn(/bin/sh): no pid (shell not found or unexecutable)`}):(s.unref(),l.unref(),{ok:!0,pid:c,release:()=>l.end(`go
|
|
4
|
-
`),withdraw:()=>l.end()})}function Yt(e){let t;try{t=w(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function M(e,t,n,r,i){let a=`${r}.${process.pid}`;try{te(a,`${qt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{x(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{E(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function Xt(e,t,n){return Qt(e,t,n).launcher}function Zt(e,t,n){let{launcher:r,state:i}=Qt(e,t,n);return{...r,launchSync:e=>Wt(i,e)}}function Qt(e,t,n){let r={clock:t,launch:e=>xt(i,j(i,e)),launchDetachedSync:e=>Gt(i,e),launchJobSync:(e,t)=>Jt(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>M(n,t,e,r,i),launcherWarnings:(e,t)=>Mt(i,e,t),answeredPipeEvent:e=>jt(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&Et(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:Dt(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>st(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),It(i)},{once:!0}),{launcher:r,state:i}}function $t(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const en={spawn:(e,t,n)=>ae(e,t,n),spawnSync:(e,t,n)=>oe(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!$t(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},tn=(e,t)=>Xt(e,t,en),nn=(e,t)=>Zt(e,t,en);function rn(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=nt;return{host:e,home:an(e),launcher:nn({inherited:process.env},t),clock:t,dialer:Qe}}function an(e){try{return Ye(e)}catch(e){process.stderr.write(`cc-candybar: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}}const on=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function sn(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function cn(e){return on.test(e)?e:sn(e)}function ln(e){return`${e.dir===void 0?``:`cd ${cn(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${cn(t)} `).join(``)}${[e.program,...e.args].map(cn).join(` `)}`}const un=`cc-extra`;function dn(e){return s.join(s.dirname(e),un,`src`,`bun-attach.js`)}function fn(e){return s.join(s.dirname(e),`bun-graph.js`)}const pn=`attach-preload.cjs`;function mn(e){return s.join(s.dirname(e),pn)}function hn(e,t){return ln({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const gn=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function _n(e,t){return t.isSymbolicLink()?Buffer.from(h.readlinkSync(e)):h.readFileSync(e)}function vn(e,t,n=gn){return h.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=h.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?vn(e,r):[[s.relative(e,r).split(s.sep).join(`/`),_n(r,i)]]})}function yn(e){let t=se.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function bn(e){return yn(vn(e,e))}const xn=[`Cargo.toml`,`Cargo.lock`,`src`];function Sn(e){return yn(vn(e,e,e=>xn.includes(e)))}const Cn=e=>e.slice(0,7),wn=`1.208.7`;function Tn(e){let t=s.dirname(s.dirname(e));return h.existsSync(s.join(t,`src`))?t:null}function N(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:wn,digest:e}}function En(){return`2bd7e7478ec35609917997644d903218deb1cb1cc7c4b4a55502776c4996cd77`}function Dn(e){let t=JSON.parse(h.readFileSync(s.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${s.join(e,`package.json`)} has no version string`);return n}function On(e,t){try{let n=Tn(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=bn(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Dn(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function kn(e,t){try{return e.statSync(t).kind===`directory`?e.realpathSync(t):null}catch{return null}}function An(e,t){let n=kn(e,t),r=s.dirname(t);if(n!==null||r===t)return{dir:n??t,rest:[]};let i=An(e,r);return{dir:i.dir,rest:[...i.rest,s.basename(t)]}}function jn(e,t){let{dir:n,rest:r}=An(e,t);return s.join(n,...r)}const Mn=e=>e.isSymbolicLink()?`symlink`:e.isDirectory()?`directory`:e.isFile()?`file`:`other`,Nn=e=>({kind:Mn(e),size:Number(e.size),mtimeMs:Number(e.mtimeNs)/1e6,mode:Number(e.mode),dev:e.dev,ino:e.ino,birthtimeNs:e.birthtimeNs}),Pn={statSync:e=>Nn(h.statSync(e,{bigint:!0})),lstatSync:e=>Nn(h.lstatSync(e,{bigint:!0})),readlinkSync:e=>h.readlinkSync(e),realpathSync:e=>h.realpathSync.native(e),mkdirSync:e=>void h.mkdirSync(e,{recursive:!0}),opendirSync:e=>h.opendirSync(e).closeSync(),stat:async e=>Nn(await h.promises.stat(e,{bigint:!0})),readFile:e=>h.promises.readFile(e,`utf8`),writeFile:(e,t)=>h.promises.writeFile(e,t),readdir:async e=>(await h.promises.readdir(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:Mn(e)})),unlink:e=>h.promises.unlink(e),watch:(e,{recursive:t},n)=>{let r=h.watch(e,{persistent:!1,recursive:t},(e,t)=>n(e,t));return{close:()=>r.close(),onError:e=>void r.on(`error`,e)}}};function Fn(e){return e.kind===`main`?s.join(e.roots.state,`cc-candybar`):s.join(e.root,`state`)}function In(e){return e.kind===`main`?s.join(e.roots.cache,`cc-candybar`):s.join(e.root,`cache`)}function Ln(e){return e.kind===`main`?s.join(e.roots.config,`cc-candybar`):s.join(e.root,`config`)}function Rn(e){return Bn(e.kind===`main`?Ln(e):e.root)}const zn=e=>jn(Pn,e);function Bn(e){return{dir:e,onDisk:zn}}function Vn(e){return e.kind===`main`&&e.legacySocket!==null?e.legacySocket:s.join(e.runtime,Ge(e.name))}function Hn(e){return s.join(qe(),Ge(e))}function Un(e){return e.kind===`main`?{[Re]:``,[ze]:``,[Be]:e.runtime,XDG_STATE_HOME:e.roots.state,XDG_CACHE_HOME:e.roots.cache,XDG_CONFIG_HOME:e.roots.config,CC_CANDYBAR_SOCKET:e.legacySocket??``}:{[Re]:e.root,[ze]:e.name,[Be]:e.runtime,CC_CANDYBAR_SOCKET:``}}function Wn(e){h.mkdirSync(e,{recursive:!0,mode:448});let t=h.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=process.getuid();if(t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function Gn(e){Wn(s.dirname(e));for(let t of[e,Kn(e)])try{if(h.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Kn(e){return`${e}.lease`}function qn(e){return Kn(Vn(e))}function Jn(e){return s.join(Fn(e),`session-state.json`)}function Yn(e){return s.join(Fn(e),`settings-history.json`)}function Xn(e){return e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR||s.join(qe(),`daemons`)}function Zn(e){return s.join(Fn(e),`spawn.lock`)}function Qn(e){return s.join(Fn(e),`spawn.cooldown`)}function $n(e){return s.join(Fn(e),`spawn.backoff`)}function er(e){return s.join(Fn(e),`watch-probe`)}function tr(e){return s.join(Fn(e),`daemon.log`)}function nr(e){return s.join(Fn(e),`link-ids`)}function rr(e){return{socket:Vn(e),lease:qn(e),state:Fn(e),log:tr(e),sessionState:Jn(e),settingsHistory:Yn(e),storedRoot:Rn(e),watchProbe:er(e),spawnBackoff:$n(e),linkIds:nr(e)}}function ir(e){return Ke(e.env,`XDG_DATA_HOME`)??s.join(e.home,`.local`,`share`)}function ar(e,t){let{env:n}=e,r=`/usr/local/share:/usr/share`,i=process.platform===`darwin`?`${s.join(Ke(n,`HOMEBREW_PREFIX`)??`/opt/homebrew`,`share`)}:${r}`:r;return{homeDir:e.home,configDir:Ln(t),dataHome:ir(e),dataDirs:(Ke(n,`XDG_DATA_DIRS`)??i).split(`:`).filter(e=>e!==``)}}function or(e,t){return sr(e,t).at(-1)}function sr(e,t){let{hops:n,stopped:r}=cr(e,t);if(r!==null)throw r;return n}function cr(e,t){let n=[t];try{for(let t=0;t<ur;t++){let t=lr(e,n[n.length-1]);if(t===null)return{hops:n,stopped:null};n.push(t)}return{hops:n,stopped:Error(`${t}: more than ${ur} symbolic links`)}}catch(e){return{hops:n,stopped:e}}}function lr(e,t){try{return e.lstatSync(t).kind===`symlink`?s.resolve(e.realpathSync(s.dirname(t)),e.readlinkSync(t)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const ur=40;function dr(e,t,n){let r=or(Pn,e);h.mkdirSync(s.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??h.statSync(r,{throwIfNoEntry:!1})?.mode;try{let e=h.openSync(i,`w`,a);try{h.writeFileSync(e,t),h.fsyncSync(e)}finally{h.closeSync(e)}h.renameSync(i,r)}catch(e){throw h.rmSync(i,{force:!0}),e}}function fr(e,t,n,r,i){let a=e.dial(t),o=!1;return new Promise(e=>{let t=r.after(n,()=>{o=!0,a.abandon(),e({ok:!1,failure:{cause:`timeout`}})},i);a.settled.then(n=>{t(),o&&n.ok&&n.conn.destroy(),e(n)})})}const pr=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function mr(e){return Object.fromEntries(pr.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const hr=[`native`,`node`,`frames`];function gr(e,t){return{kind:e,bundle:t,source:null}}const _r=[`ansi`,`frame`],vr=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function yr(e){let t=Or(e.termCols),n=Or(e.termRows),r=kr(e.ssh),i=Er(e.tmux),a=Tr(e.configEnv),o=Tr(e.claudeConfigDir),s=wr(e.terminalEnv),c=Br(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{terminalEnv:s},...c!==void 0&&{client:c}}}function br(e,t){return vr.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function xr(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const Sr={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Cr(e){let t=Object.keys(Sr).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Sr[t](n.join(`, `))]});return t.length===0?null:t.join(`
|
|
4
|
+
`),withdraw:()=>l.end()})}function Yt(e){let t;try{t=w(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function M(e,t,n,r,i){let a=`${r}.${process.pid}`;try{te(a,`${qt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{x(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{E(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function Xt(e,t,n){return Qt(e,t,n).launcher}function Zt(e,t,n){let{launcher:r,state:i}=Qt(e,t,n);return{...r,launchSync:e=>Wt(i,e)}}function Qt(e,t,n){let r={clock:t,launch:e=>xt(i,j(i,e)),launchDetachedSync:e=>Gt(i,e),launchJobSync:(e,t)=>Jt(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>M(n,t,e,r,i),launcherWarnings:(e,t)=>Mt(i,e,t),answeredPipeEvent:e=>jt(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&Et(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:Dt(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>st(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),It(i)},{once:!0}),{launcher:r,state:i}}function $t(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const en={spawn:(e,t,n)=>ae(e,t,n),spawnSync:(e,t,n)=>oe(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!$t(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},tn=(e,t)=>Xt(e,t,en),nn=(e,t)=>Zt(e,t,en);function rn(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=nt;return{host:e,home:an(e),launcher:nn({inherited:process.env},t),clock:t,dialer:Qe}}function an(e){try{return Ye(e)}catch(e){process.stderr.write(`cc-candybar: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}}const on=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function sn(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function cn(e){return on.test(e)?e:sn(e)}function ln(e){return`${e.dir===void 0?``:`cd ${cn(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${cn(t)} `).join(``)}${[e.program,...e.args].map(cn).join(` `)}`}const un=`cc-extra`;function dn(e){return s.join(s.dirname(e),un,`src`,`bun-attach.js`)}function fn(e){return s.join(s.dirname(e),`bun-graph.js`)}const pn=`attach-preload.cjs`;function mn(e){return s.join(s.dirname(e),pn)}function hn(e,t){return ln({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const gn=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function _n(e,t){return t.isSymbolicLink()?Buffer.from(h.readlinkSync(e)):h.readFileSync(e)}function vn(e,t,n=gn){return h.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=h.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?vn(e,r):[[s.relative(e,r).split(s.sep).join(`/`),_n(r,i)]]})}function yn(e){let t=se.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function bn(e){return yn(vn(e,e))}const xn=[`Cargo.toml`,`Cargo.lock`,`src`];function Sn(e){return yn(vn(e,e,e=>xn.includes(e)))}const Cn=e=>e.slice(0,7),wn=`1.208.8`;function Tn(e){let t=s.dirname(s.dirname(e));return h.existsSync(s.join(t,`src`))?t:null}function N(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:wn,digest:e}}function En(){return`a73aaecc14c899306c96859ecb0e328c3b3458efbad2471315ba6de91b60170b`}function Dn(e){let t=JSON.parse(h.readFileSync(s.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${s.join(e,`package.json`)} has no version string`);return n}function On(e,t){try{let n=Tn(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=bn(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Dn(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function kn(e,t){try{return e.statSync(t).kind===`directory`?e.realpathSync(t):null}catch{return null}}function An(e,t){let n=kn(e,t),r=s.dirname(t);if(n!==null||r===t)return{dir:n??t,rest:[]};let i=An(e,r);return{dir:i.dir,rest:[...i.rest,s.basename(t)]}}function jn(e,t){let{dir:n,rest:r}=An(e,t);return s.join(n,...r)}const Mn=e=>e.isSymbolicLink()?`symlink`:e.isDirectory()?`directory`:e.isFile()?`file`:`other`,Nn=e=>({kind:Mn(e),size:Number(e.size),mtimeMs:Number(e.mtimeNs)/1e6,mode:Number(e.mode),dev:e.dev,ino:e.ino,birthtimeNs:e.birthtimeNs}),Pn={statSync:e=>Nn(h.statSync(e,{bigint:!0})),lstatSync:e=>Nn(h.lstatSync(e,{bigint:!0})),readlinkSync:e=>h.readlinkSync(e),realpathSync:e=>h.realpathSync.native(e),mkdirSync:e=>void h.mkdirSync(e,{recursive:!0}),opendirSync:e=>h.opendirSync(e).closeSync(),stat:async e=>Nn(await h.promises.stat(e,{bigint:!0})),readFile:e=>h.promises.readFile(e,`utf8`),writeFile:(e,t)=>h.promises.writeFile(e,t),readdir:async e=>(await h.promises.readdir(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:Mn(e)})),unlink:e=>h.promises.unlink(e),watch:(e,{recursive:t},n)=>{let r=h.watch(e,{persistent:!1,recursive:t},(e,t)=>n(e,t));return{close:()=>r.close(),onError:e=>void r.on(`error`,e)}}};function Fn(e){return e.kind===`main`?s.join(e.roots.state,`cc-candybar`):s.join(e.root,`state`)}function In(e){return e.kind===`main`?s.join(e.roots.cache,`cc-candybar`):s.join(e.root,`cache`)}function Ln(e){return e.kind===`main`?s.join(e.roots.config,`cc-candybar`):s.join(e.root,`config`)}function Rn(e){return Bn(e.kind===`main`?Ln(e):e.root)}const zn=e=>jn(Pn,e);function Bn(e){return{dir:e,onDisk:zn}}function Vn(e){return e.kind===`main`&&e.legacySocket!==null?e.legacySocket:s.join(e.runtime,Ge(e.name))}function Hn(e){return s.join(qe(),Ge(e))}function Un(e){return e.kind===`main`?{[Re]:``,[ze]:``,[Be]:e.runtime,XDG_STATE_HOME:e.roots.state,XDG_CACHE_HOME:e.roots.cache,XDG_CONFIG_HOME:e.roots.config,CC_CANDYBAR_SOCKET:e.legacySocket??``}:{[Re]:e.root,[ze]:e.name,[Be]:e.runtime,CC_CANDYBAR_SOCKET:``}}function Wn(e){h.mkdirSync(e,{recursive:!0,mode:448});let t=h.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=process.getuid();if(t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function Gn(e){Wn(s.dirname(e));for(let t of[e,Kn(e)])try{if(h.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Kn(e){return`${e}.lease`}function qn(e){return Kn(Vn(e))}function Jn(e){return s.join(Fn(e),`session-state.json`)}function Yn(e){return s.join(Fn(e),`settings-history.json`)}function Xn(e){return e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR||s.join(qe(),`daemons`)}function Zn(e){return s.join(Fn(e),`spawn.lock`)}function Qn(e){return s.join(Fn(e),`spawn.cooldown`)}function $n(e){return s.join(Fn(e),`spawn.backoff`)}function er(e){return s.join(Fn(e),`watch-probe`)}function tr(e){return s.join(Fn(e),`daemon.log`)}function nr(e){return s.join(Fn(e),`link-ids`)}function rr(e){return{socket:Vn(e),lease:qn(e),state:Fn(e),log:tr(e),sessionState:Jn(e),settingsHistory:Yn(e),storedRoot:Rn(e),watchProbe:er(e),spawnBackoff:$n(e),linkIds:nr(e)}}function ir(e){return Ke(e.env,`XDG_DATA_HOME`)??s.join(e.home,`.local`,`share`)}function ar(e,t){let{env:n}=e,r=`/usr/local/share:/usr/share`,i=process.platform===`darwin`?`${s.join(Ke(n,`HOMEBREW_PREFIX`)??`/opt/homebrew`,`share`)}:${r}`:r;return{homeDir:e.home,configDir:Ln(t),dataHome:ir(e),dataDirs:(Ke(n,`XDG_DATA_DIRS`)??i).split(`:`).filter(e=>e!==``)}}function or(e,t){return sr(e,t).at(-1)}function sr(e,t){let{hops:n,stopped:r}=cr(e,t);if(r!==null)throw r;return n}function cr(e,t){let n=[t];try{for(let t=0;t<ur;t++){let t=lr(e,n[n.length-1]);if(t===null)return{hops:n,stopped:null};n.push(t)}return{hops:n,stopped:Error(`${t}: more than ${ur} symbolic links`)}}catch(e){return{hops:n,stopped:e}}}function lr(e,t){try{return e.lstatSync(t).kind===`symlink`?s.resolve(e.realpathSync(s.dirname(t)),e.readlinkSync(t)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const ur=40;function dr(e,t,n){let r=or(Pn,e);h.mkdirSync(s.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??h.statSync(r,{throwIfNoEntry:!1})?.mode;try{let e=h.openSync(i,`w`,a);try{h.writeFileSync(e,t),h.fsyncSync(e)}finally{h.closeSync(e)}h.renameSync(i,r)}catch(e){throw h.rmSync(i,{force:!0}),e}}function fr(e,t,n,r,i){let a=e.dial(t),o=!1;return new Promise(e=>{let t=r.after(n,()=>{o=!0,a.abandon(),e({ok:!1,failure:{cause:`timeout`}})},i);a.settled.then(n=>{t(),o&&n.ok&&n.conn.destroy(),e(n)})})}const pr=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function mr(e){return Object.fromEntries(pr.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const hr=[`native`,`node`,`frames`];function gr(e,t){return{kind:e,bundle:t,source:null}}const _r=[`ansi`,`frame`],vr=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function yr(e){let t=Or(e.termCols),n=Or(e.termRows),r=kr(e.ssh),i=Er(e.tmux),a=Tr(e.configEnv),o=Tr(e.claudeConfigDir),s=wr(e.terminalEnv),c=Br(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{terminalEnv:s},...c!==void 0&&{client:c}}}function br(e,t){return vr.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function xr(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const Sr={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Cr(e){let t=Object.keys(Sr).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Sr[t](n.join(`, `))]});return t.length===0?null:t.join(`
|
|
5
5
|
`)}function wr(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=pr.filter(e=>t[e]!==void 0);return n.every(e=>typeof t[e]==`string`&&t[e]!==``)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function Tr(e){return typeof e==`string`&&s.isAbsolute(e)?e:void 0}function Er(e){if(e===null)return null;if(typeof e!=`object`)return;let{socket:t,pane:n,truecolor:r}=e;if(!(typeof t!=`string`||t===``)&&!(typeof n!=`string`||n===``)&&!(r!==null&&(typeof r!=`string`||r===``)))return{socket:t,pane:n,truecolor:r}}const Dr=1e4;function Or(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Dr?Dr:t}function kr(e){return typeof e==`boolean`?e:void 0}const Ar=new Set([...[],1]);function jr(e){return typeof e==`object`&&e&&e.kind===`url`?{kind:`url`,frame:e}:{kind:`request`,req:e}}const Mr=Math.floor((2**31-1)/1e3)-60;function Nr(e){return typeof e==`number`&&e>0&&e<=Mr?{ok:!0,seconds:e}:{ok:!1,problem:`is not a span of seconds above 0 and at most ${Mr}`}}var Pr=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}},Fr=class extends Error{constructor(e){super(e===`connect`?`CONNECT_TIMEOUT`:`TIMEOUT`),this.phase=e,this.name=`ClientTimeoutError`}};function Ir(e){return Lr(JSON.stringify(e))}function Lr(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Rr(e,t){let n=Buffer.alloc(0);return function(r){for(n=Buffer.concat([n,r]);n.length>=4;){let r=n.readUInt32BE(0);if(r>16777216){t(new Pr(`frame too large: ${r}`));return}if(n.length<4+r)return;let i=n.subarray(4,4+r);n=n.subarray(4+r);try{e(JSON.parse(i.toString(`utf8`)))}catch(e){let n=new Pr(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function zr(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=t=>{if(!o){o=!0,c(),e.off(`data`,l),e.off(`error`,u),e.off(`close`,d);try{t()}catch{}}},c=r.after(n-r.now(),()=>{s(()=>{e.destroy(),a(new Fr(`deadline`))})}),l=Rr(e=>s(()=>i(e)),e=>s(()=>a(e))),u=e=>s(()=>a(e)),d=()=>s(()=>a(Error(`socket closed before response`)));e.on(`data`,l),e.on(`error`,u),e.on(`close`,d),e.write(Ir(t))})}function Br(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Tr(n);return hr.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Vr(e,t,n,r){let i=await fr(e.dialer,Vn(e.home),n.connectMs,e.clock);return i.ok?Ur(i.conn,e.clock,t,n,r):Hr(i.failure)}function Hr(e){return e.cause===`timeout`?{kind:`busy`,phase:`connect`,message:new Fr(`connect`).message}:{kind:`transient`,cause:e.cause,message:e.message}}async function Ur(e,t,n,r,i){try{let a=t.now()+r.budgetMs,o=n(a),s=await zr(e,{v:3,...o},a,t);return Kr(o.kind,s,i)}catch(e){return qr(e)}finally{e.destroy()}}function Wr(e,t){return typeof e==`string`?e:t}function Gr(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Kr(e,t,n){let r=t;if(r.ok===!0){let r=n(t);return r===void 0?{kind:`permanent`,cause:`malformed_response`,message:`ok response without payload for "${e}" request`}:{kind:`ok`,value:r}}let i=Wr(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Gr(r.daemonV)};case`TIMEOUT`:return{kind:`busy`,phase:`deadline`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};case`SWITCHED_OFF`:return{kind:`permanent`,cause:`switched_off`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function qr(e){if(e instanceof Pr||e instanceof SyntaxError)return{kind:`permanent`,cause:`malformed_response`,message:e instanceof Error?e.message:String(e)};let t=e instanceof Error?e.message:String(e);return e instanceof Fr?{kind:`busy`,phase:e.phase,message:t}:{kind:`transient`,cause:`io_error`,message:t}}function Jr(e){if(e.kind===`busy`)return`daemon busy (${e.message})`;if(e.kind===`transient`)return`daemon unavailable (${e.cause}: ${e.message})\nHint: daemon may not be running. Run \`cc-candybar\` once to spawn it.`;switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`daemon protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:case`render_failed`:case`switched_off`:case`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}function Yr(e){return e===void 0?{kind:`unstated`}:typeof e==`number`&&Number.isSafeInteger(e)&&e>0?{kind:`stated`,at:e}:{kind:`refused`,problem:`request 'deadline' is not epoch milliseconds: ${JSON.stringify(e)}`}}function Xr(e,t,n){let r=e.kind===`stated`?n.monoMs+(e.at-n.epochMs):t+150-50,i=Math.min(r,t+200);return Math.round(i-60-n.monoMs)}const Zr={connectMs:50,budgetMs:150},Qr={connectMs:50,budgetMs:350};function $r(e){let t=e.output;return typeof t==`string`?t:void 0}function ei(e){return Kr(`render`,e,$r)}function ti(e,t,n,r,i,a=Zr){return Vr(e,e=>({kind:`render`,hookData:t,args:n,cwd:r,deadline:e,...i}),a,$r)}function ni(e,t,n){return Vr(e,()=>({kind:`pane-session`,socket:t,pane:n}),Qr,e=>`paneSession`in e?e.paneSession:void 0)}function ri(e,t){return Vr(e,()=>({kind:`click`,url:t}),Qr,$r)}const ii=5e3;async function ai(e){let t=[];for(let n of e){let e=await n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
|
|
6
6
|
`)}const oi=`/usr/bin/footprint`;function si(e,t,n){return t===`darwin`?[di(e,oi,[`-p`,String(n)]),di(e,`/usr/bin/vmmap`,[`--summary`,String(n)])]:t===`linux`?[fi(`/proc/self/smaps_rollup`),fi(`/proc/self/status`)]:[]}function ci(e,t,n){return t===`darwin`?li(n,t=>e.launch({bin:oi,args:t,timeoutMs:ii,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function li(e,t){return async n=>{let r=await t([`-p`,String(e),`--noCategories`,`-f`,`bytes`]);if(!r.ok)return{kind:`stand-in`,bytes:n,unread:`footprint ${vt(r)}`};let i=ui(r.stdout);return i===null?{kind:`stand-in`,bytes:n,unread:`footprint printed no phys_footprint line`}:{kind:`charged`,measure:`phys_footprint`,bytes:i}}}function ui(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function di(e,t,n){return{name:`${t} ${n.join(` `)}`,read:async()=>{let r=await e.launch({bin:t,args:[...n],timeoutMs:ii,category:`limits.memory-report`});return r.ok?r.stdout.trim().length>0?{kind:`text`,text:r.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:vt(r)}}}}function fi(e){return{name:e,read:async()=>{try{let t=h.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}const pi=`CC_CANDYBAR_RSS_LIMIT_MB`;function mi(e){let t=e[pi];if(t===void 0)return 1024;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${pi} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function hi(e){return mi(e)*2}const gi=1024*1024,P=e=>Math.round(e/gi);function _i(e){return mi(e)*gi}const vi={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function yi(e,t){return e>t}function bi(e,t){if(e.kind===`charged`)return e;let n=t.kind===`unmeasured`?0:t.charge.kind===`charged`?t.rss-t.charge.bytes:t.charge.gap;return{...e,bytes:e.bytes-n,gap:n}}const xi=.75;function Si(e,t){return e>t*xi}function Ci(e,t,n){let{prefix:r,suffix:i}=vi[t];return s.join(e,`${r}${n}${i}`)}function wi(e){for(let t of Object.keys(vi)){let{prefix:n,suffix:r}=vi[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Ti(e){let t=e.limitBytes??1024*gi,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null,o=!1,s;function c(){return a??=l().finally(()=>{a=null}),a}async function l(){if(r)return!0;let{rss:a,heapTotal:s}=e.memoryBytes(),c=bi(await e.memoryCharge(a),i),l={kind:`measured`,charge:c,rss:a,heapTotal:s};if(i=l,e.log(`info`,`memory ${Oi(l,t)}`),o||c.bytes<=t)return!1;r=!0,e.log(`warn`,`${Ei(c)} > limit ${P(t)} MB (rss ${P(a)} MB, v8 heap ${P(s)} MB); recording memory then shutting down`);let u=`${new Date(e.clock.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return await ki(e.log,`memory report`,async()=>{let t=Ci(e.snapshotDir,`memoryReport`,u),n=await e.captureMemoryReport();o||(e.writeMemoryReport(t,n),e.log(`info`,`memory report written: ${t}`))}),o?(e.log(`info`,`daemon closed during the breach: no snapshot, no exit`),!1):(await ki(e.log,`heap snapshot`,()=>{e.writeLogNow();let t=Ci(e.snapshotDir,`heapSnapshot`,u);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),await ki(e.log,`artifact rotation`,async()=>{for(let{artifacts:t}of Ai(e.listArtifacts()).slice(n))for(let n of Object.values(t))await ki(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0)}function u(){return i.kind===`measured`&&Si(i.charge.bytes,t)?`${Ei(i.charge)} approaching limit ${P(t)} MB (v8 heap ${P(i.heapTotal)} MB)`:null}function d(){let n;try{n={kind:`ok`,value:Ai(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function f(t=6e4){let n=async()=>{try{if(await c())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}o||(s=e.clock.after(t,()=>void n(),{unref:!0}))};n()}function p(){o=!0,s?.()}return{check:c,describeNextRestart:u,serving:d,arm:f,disarm:p}}function Ei(e){return e.kind===`charged`?`${e.measure} ${P(e.bytes)} MB`:`rss ${P(e.bytes+e.gap)} MB${e.gap===0?``:` less its last ${P(e.gap)} MB gap`} (standing in: ${e.unread})`}function Di(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function Oi({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)} gap=${P(e.gap)}MB`:``;return`measure=${Di(e)} charge=${P(e.bytes)}MB rss=${P(t)}MB heap=${P(n)}MB limit=${P(r)}MB${i}`}async function ki(e,t,n){try{await n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Ai(e){let t=new Map;for(let n of e){let e=s.basename(n),r=wi(e);if(r===null)continue;let{prefix:i,suffix:a}=vi[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(vi);return[...t].sort(([e],[t])=>yi(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function ji(e,t,n,r={}){let i=n.snapshotDir;return{clock:n.clock,pid:process.pid,snapshotDir:i,log:n.log,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:ci(n.launcher,process.platform,process.pid),captureMemoryReport:()=>ai(si(n.launcher,process.platform,process.pid)),writeMemoryReport:(e,t)=>h.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>pe.writeHeapSnapshot(e),writeLogNow:n.writeLogNow,listArtifacts:()=>{let e;try{e=h.readdirSync(i)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>wi(e)!==null).map(e=>s.join(i,e))},removeFile:e=>h.unlinkSync(e),shutdown:t,startedAtMs:e,...r}}function Mi(e,n={}){let{home:r,clock:i}=e;if(qi(r)!==null)return;let a=n.spawn??(()=>Yi(e)),o=Gi(r,i);if(o.kind===`contended`){let e=Pi(r,i);e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),Ni(r,i,a));return}if(o.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${o.reason}) — spawning unlocked\n`),Ni(r,i,a);return}try{Ni(r,i,a)}finally{eee()}}function Ni(e,t,n){Vi(e,t)&&Fi(n)}function Pi(e,t){try{let n=h.statSync(Zn(e));return t.now()-n.mtimeMs}catch{return null}}function Fi(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
|
|
7
7
|
`)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function Ii(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function Li(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function Ri(e){try{let t=h.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function zi(e,n){try{h.mkdirSync(s.dirname(e),{recursive:!0}),h.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function Bi(e){try{h.unlinkSync(e)}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function Vi(e,n){let r=Qn(e),i=$n(e),a=Ri(i),o=Ii(Hi(r,n),Li(a));return o.kind===`deny`?!1:(o.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${o.futureMs}ms in the future — ignoring and spawning\n`),Ui(r,n),zi(i,Math.min(a+1,5)),!0)}function Hi(e,t){try{return t.now()-h.statSync(e).mtimeMs}catch{return null}}function Ui(e,n){try{h.mkdirSync(s.dirname(e),{recursive:!0}),h.writeFileSync(e,`${t.pid} ${n.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let Wi=null;function Gi(e,n){let r=Zn(e);for(let e=0;e<2;e++){try{let e=h.openSync(r,`wx`,384);try{h.writeSync(e,JSON.stringify({pid:t.pid,ts:n.now()}))}catch{}return Wi={fd:e,path:r},{kind:`held`}}catch(e){let t=e.code;if(t!==`EEXIST`)return{kind:`error`,reason:`openSync(${r}): ${t??e.message}`}}if(!Ki(r,n))return{kind:`contended`};try{h.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Ki(e,t){try{let n=h.statSync(e);return t.now()-n.mtimeMs>1e4}catch{return!0}}function eee(){if(!Wi)return;let{fd:e,path:t}=Wi;Wi=null;try{h.closeSync(e)}catch{}try{h.unlinkSync(t)}catch{}}function qi(e){try{return h.mkdirSync(Fn(e),{recursive:!0}),null}catch(t){return`mkdir ${Fn(e)}: ${t.message}`}}function Ji(e,t){return[`--max-old-space-size=${hi(t)}`,e,`daemon`]}function Yi({host:e,launcher:n}){let r=t.execPath,i=t.argv[1];return i?n.launchDetachedSync({bin:r,args:Ji(i,e.env),category:`daemon-spawn`}).ok:!1}const Xi=`cc-candybar`,Zi=`CCCandybarURLHandler`,Qi=e=>e.startsWith(`${Xi}://`),$i=`closed`,ea=`open`,ta=`🍫`;function na(e,t,n){if(t===0)return`${e} needs a display (the clickable text)`;if(t!==1&&t!==n)return`${e} cycles ${n} members; bind one display per member (${n}) or one static display, got ${t}`}function ra(e,t,n,r){let i=na(e,t.length,n);if(i!==void 0)throw Error(i);return t.length===1?t[0]:t[r]}function ia(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function aa(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function oa(e,...t){return`{{ and ${[e,...t].map(sa).join(` `)} }}`}function sa(e){return`(eq .${e.variable} "${ia(e.member)}")`}function ca(e,t,n){return`{{ ${la(e,ua(t),ua(n))} }}`}function la(e,t,n){return`action "${e}" ${t} ${n}`}function ua(e){return`"${ia(e)}"`}function da(e,t){return{kind:`state`,key:e,default:t}}function fa(e,t){return{set:e,cycle:[$i,t]}}function pa(e){if(!(`set`in e&&`cycle`in e))return;let[t,n,...r]=e.cycle;return t===`closed`&&n!==void 0&&r.length===0?{key:e.set,member:n}:void 0}var ma=De(((e,t)=>{t.exports.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,t.exports.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,t.exports.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/})),ha=De(((e,t)=>{let n=ma();t.exports={isSpaceSeparator(e){return typeof e==`string`&&n.Space_Separator.test(e)},isIdStartChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`$`||e===`_`||n.ID_Start.test(e))},isIdContinueChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`$`||e===`_`||e===``||e===``||n.ID_Continue.test(e))},isDigit(e){return typeof e==`string`&&/[0-9]/.test(e)},isHexDigit(e){return typeof e==`string`&&/[0-9A-Fa-f]/.test(e)}}})),ga=De(((e,t)=>{let n=ha(),r,i,a,o,s,c,l,u,d;t.exports=function(e,t){r=String(e),i=`start`,a=[],o=0,s=1,c=0,l=void 0,u=void 0,d=void 0;do l=v(),ee[i]();while(l.type!==`eof`);return typeof t==`function`?f({"":d},``,t):d};function f(e,t,n){let r=e[t];if(typeof r==`object`&&r)if(Array.isArray(r))for(let e=0;e<r.length;e++){let t=String(e),i=f(r,t,n);i===void 0?delete r[t]:Object.defineProperty(r,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let e in r){let t=f(r,e,n);t===void 0?delete r[e]:Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let p,m,h,g,_;function v(){for(p=`default`,m=``,h=!1,g=1;;){_=y();let e=x[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
|
|
@@ -204,7 +204,7 @@ Config tooling:
|
|
|
204
204
|
`),...e]));return o.overflow=`ignore`,o.end=``,o}function TY(e,t){return{themePreview:{fn:(...n)=>{let[r,...i]=n;if(QA(`themePreview`,[`applyAction`],i),r!==void 0&&typeof r!=`string`)throw Error(`themePreview: applyAction must name a declared action, got ${JSON.stringify(r)}`);let{palette:a,decor:o}=vJ(e,`{{ themePreview }}`);return wY(r===void 0?a:vY(e,r,`themePreview`),o,{...nY(t,`{{ themePreview }}`).disclosure,depth:0},t.drawnAt(),aY(e))},argTypes:[`value`],arity:{kind:`variadic`},returnType:`T`}}}const EY=e=>e.slice(e.lastIndexOf(`.`)+1),DY=(e,t)=>{let n=new q(EY(e));return n.truncate(t,{marker:`…`}),n.plain};function OY(e,t){let n=e.map(e=>e.map(({name:e})=>rY(EY(e)))),r=e=>n.every(n=>n.reduce((t,n)=>t+Math.min(n,e)+2,0)<=t),i=Math.max(1,...n.flat());for(;i>1&&!r(i);)--i;return i}function kY(e,t,n,r){let i=OY(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new q(` ${DY(s,i)} `,{style:LJ($_(l,{kind:`bar`,decor:t,address:c},n))});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=q.fromFragments(a.flatMap((e,t)=>t===0?e:[new q(`
|
|
205
205
|
`),...e]));return o.overflow=`ignore`,o.end=``,o}const AY=`layoutPreview`;function jY(e,t){return{[AY]:{fn:()=>kY(yJ(e,`{{ layoutPreview }}`),vJ(e,`{{ layoutPreview }}`).decor,t.drawnAt(),aY(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function MY(e,t,n,r){let i=nY(r.activeSegment,`{{ menu }}`),a=r.action,o=WM(i.placementId,e,n.key),s=qM(o),c=UM(e),l=_J(a,`menu`).store,u=EJ(l,o)===c,d=EJ(l,`session.id`),f=u?$i:c,p=OJ(ra(`{{ menu "${e}" }}`,t,2,+!!u),US(a.links.to,[{verb:aS,args:[d,o,f,s,`0`]}]),!1);return i.drops.push(...u?(()=>{let t=r.activeSegment.drawnAt(),c=V_(i.palette,i.disclosure,t).plane,l=uY(a,e,`menu`);return dY(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,$i],[s,`0`]],onPick:n.closeOnPick},n.paged,a,WJ(i,n.distribution,vJ(a,`{{ menu }}`),l.paletteOf,t,c),RJ(i.palette,c,t))})():[]),p}const NY=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function PY(e,t){let n=t[t.length-1],r=NY(n)?n:void 0,i=r===void 0?t:t.slice(0,-1),a=i.findIndex(e=>typeof e!=`string`);if(a!==-1)throw Error(`{{ menu "${e}" }} display #${a+1} is not text (${JSON.stringify(i[a])}) — a menu binds its trigger text, then an optional trailing (dict …) of options`);return{displays:i,options:ZM(r??{})}}function FY(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=PY(t,n);return MY(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function IY(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=LY(t,n,r),c=[];for(let e=0;e<r;e++){let t=e<s,l=t&&o!==void 0?o(e*n/r):void 0;c.push(new q(t?i:a,{style:l===void 0?void 0:new W({color:l})}))}let l=q.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function LY(e,t,n){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.min(n,Math.max(0,Math.round(e/t*n)))}function RY(e){let t={fn:(()=>{let t=nY(e,`{{ bgOf }}`);if(t.bg===void 0)throw Error(`{{ bgOf }} is not available while segments.${t.segName}'s own "bg:" is being evaluated — the background is what that template computes. Reach for a palette color there instead, e.g. bg: '{{ darken (color "surface") 1 }}'.`);return t.bg.hex}),argTypes:[],arity:{kind:`exact`},returnType:`string`},n={fn:(()=>nY(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=nY(e,`{{ roleTextOn }}`);return VY(r,t,Cu(r,n)).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i={fn:((t,n)=>{let{palette:r}=nY(e,`{{ keptOn }}`),i=Cu(r,t),a=Cu(r,n),o=ll(Lu(i,H.TRUECOLOR),Lu(a,H.TRUECOLOR)),s=Math.min(A_,Math.max(o,3));return(Iu(i,e.drawnAt(),(e,t)=>ll(e,t(a))>=s)??i).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},a=NA(()=>nY(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),o={fn:((e,t,n,r,i,o,...s)=>{let c=o===void 0?void 0:[o,...HY(s)];return IY({value:e,max:t,width:n,filled:r,empty:i,colourAt:c===void 0?void 0:e=>String(a.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...a,bgOf:t,tint:n,roleTextOn:r,keptOn:i,gauge:o}}const zY={"#000000":[`darken-1`,`darken-2`,`darken-3`],"#ffffff":[`lighten-1`,`lighten-2`,`lighten-3`]},BY=Object.values(zY).flat();function VY(e,t,n){let r=Lu(n,H.TRUECOLOR),i=t=>{let n=Cu(e,t);return{colour:n,ratio:ll(Lu(n,H.TRUECOLOR),r)}},a=Pu(r).hex,o=zY[a];if(o===void 0)throw Error(`contrastFor named ${a} for ${n.hex}, which is neither pole`);let s=`text-${t}`,c=e=>`${t}-${e}`,l=new Map([s,t,...BY.map(c)].map(e=>[e,i(e)]));return([s,t,...o.map(c)].map(e=>l.get(e)).find(({ratio:e})=>e>=4.5)??[...l.values()].reduce((e,t)=>t.ratio>e.ratio?t:e)).colour}function HY(e){return e.flatMap(e=>{let t=e.indexOf(`:`),n=t<0?NaN:Number(e.slice(0,t));if(!Number.isFinite(n))throw Error(`{{ gauge }} stop "${e}" must be "<position>:<colour>", e.g. "80:error" or "80:#ff0000"`);return[n,e.slice(t+1)]})}const UY={input:`view`,state:`view`,template:`view`,time:`view`,shell:`view`,file:`view`,literal:`directory`,dropped:`directory`,source:`view`},WY=new WeakMap;function GY(e){let t=WY.get(e);return t===void 0&&(t=new Map([...LC(e)].map(([e,t])=>[e,UY[t.kind]])),WY.set(e,t)),t}function KY(e){let t=[],n=[];for(let r of e){if(!r.contains(`
|
|
206
206
|
`)){n.push(r);continue}let e=r.split(`
|
|
207
|
-
`);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function qY(e){let t=new Map;return e.map(e=>{let n=`${e.place}.${e.band}`,r=t.get(n)??0;return t.set(n,r+1),{line:e,row:`${n}#${r}`}})}const JY=e=>e.kind===`failed`?Qq:e;function YY(e,t){return t.kind===`shown`||t.kind===`failed`&&e.kind===`pending`?e:t}function XY(e,t){let n=[],r=[],i;for(let a of t)(a.band===`own`?n:r).push(a),i??=a.cells.find(t=>t.placement.id===e)?.placement.ground;return{drawing:i===void 0?null:{own:n,opened:r.length>0,ground:i},deeper:r}}function ZY(e){return{...e,cells:e.cells.map(iJ)}}function QY(e,t){let n=t.flatMap(e=>e.filter(e=>e.place===`above`)),r=t.map(e=>e.filter(e=>e.place===`flow`));return[...n,...$Y(e,r)]}function $Y(e,t){switch(e){case`vertical`:return t.flatMap(e=>e);case`horizontal`:return t.reduce((e,t)=>Math.max(e,t.length),0)===0?[]:[{cells:t.flatMap(e=>e[0]?.cells??[]),band:`own`,place:`flow`},...t.flatMap(e=>e.slice(1))]}}function eX(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:QY(e.direction,e.children.map((t,i)=>n(t,[...r,tX(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function tX(e,t){return e.steps[t]}function nX(e){if(e.kind===`segment`||e.unit===!0)return{width:1,reach:1};let t=rX(e);return{width:iX(t),reach:aX(t)}}function rX(e){let t=e.children.map(nX),n=n=>e.direction===`vertical`&&t.slice(0,n).some(({width:e})=>e>0);if(e.direction===`vertical`||e.unit===!0)return t.map((e,t)=>({start:0,span:e,ownLine:n(t)}));let r=0;return t.map((e,t)=>{let i=r;return r+=e.width,{start:i,span:e,ownLine:n(t)}})}const iX=e=>e.reduce((e,{span:t,ownLine:n})=>e+(n?0:t.width),0),aX=e=>e.reduce((e,{start:t,span:n})=>Math.max(e,t+n.reach),0);function oX(e,t){let n=rX(e);if(t?.axis===`cell`)return n.map(({start:e,span:n,ownLine:r})=>{let i=t.index+e;return r?{...t,index:i,lineStart:i,lineEnd:i+n.width-1}:{...t,index:i}});let r=Wv[e.direction],i=h_(e.distribution),[a,o,s]=r===`row`?[n.map((e,t)=>t),n.length,n.length-1]:[n.map(({start:e})=>e),aX(n),iX(n)-1];return a.map(e=>({index:e,count:o,distribution:i,axis:r,lineStart:0,lineEnd:s}))}const sX={compile(e,t){let n=oX(e,t.at);return{kind:`container`,direction:e.direction,when:t.when,steps:n,children:e.children.map((e,r)=>t.compileChild(e,Xv(t.path,r),n[r]))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),QY(e.direction,e.children.map((n,r)=>t.renderChild(n,JY(t.gate),tX(e,r))))}},cX={drop:e=>e.place,above:()=>`above`},lX={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},uX={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Gv(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(oa(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Zv(t.path),void 0),key:e.opens.ref.key,placement:e.opens.placement}},...e.lead!==void 0&&{lead:t.parse(e.lead,`lead`)},...e.trail!==void 0&&{trail:t.parse(e.trail,`trail`)}}},render:(e,t)=>t.placed(e.id,dX(e,t))};function dX(e,t){let n=t.lookupSegment(e.name);if(n===void 0)throw Error(`Layout segment "${e.name}" has no matching segment`);if(t.gate.kind===`hidden`)return[];let r=bj(t.scope,e.settings);if(t.gate.kind===`failed`)return _X(e,r,t,t.gate.message);try{let i=t.placement(e),a=YY(t.gate,i.gate());if(a.kind===`failed`)return _X(e,r,t,a.message);if(a.kind===`hidden`)return[];let o=i.bodyGate(),s=o.kind===`failed`&&a.kind===`pending`?a:o;if(s.kind===`failed`)return _X(e,r,t,s.message);let c=ux(e.settings.theme,t.palette),l={id:e.id,effect:e.settings.effect,ground:mP(c)},u=e=>({width:n.width??`auto`,justify:n.justify??`left`,truncate:n.truncate??`right`,baseStyle:e,padding:t.padding,placement:l}),d=s.kind===`shown`,f=a.kind===`pending`?a:s,p=f.kind===`pending`?fX(f.variable):pX(()=>i.evaluate(c,t.region)),m=p.kind===`drawn`?mX(p.segment,u):hX(e,r,t,p.variable,c,d,u);if(m===null)return[];let{styles:h,inline:g,drops:_}=m,v=e.opens,y=v===void 0?[]:t.renderBody(v.body,d?a:Qq,h.disclosure).map(e=>({...e,place:cX[v.placement](e)})),b=(e,t,n)=>sJ(mJ([e],t),{...u(t),width:`auto`,padding:n}),x=y.findIndex(e=>e.band===`own`),{lead:S,stays:C}=v!==void 0&&x!==-1?lX[v.placement](g,()=>b(t.closeDisclosure(v.key),h.close,t.padding)):{lead:[],stays:g},w=S.flatMap(e=>b(new q(` `.repeat(gX(rJ(e)))),h.trigger,0)),T=(e,t)=>e.band===`own`?t===x?S:w:[],E=y.map((e,t)=>({cells:[...T(e,t),...e.cells],band:`deeper`,place:e.place})),ee=[...C,..._];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...ee.flatMap(e=>e.cells),...y.flatMap(T)].flatMap(rJ)),[...ee,...E]}catch(n){return _X(e,r,t,n.message??String(n))}}const fX=e=>({kind:`waiting`,variable:e});function pX(e){try{return{kind:`drawn`,segment:e()}}catch(e){let t=ZC(e);if(t===void 0)throw e;return fX(t.variable)}}function mX(e,t){let{styles:n,fragments:r,lead:i,trail:a,drops:o,open:s}=e,c=s?n.trigger:n.closed,l=t(c);return{styles:n,inline:KY(mJ(r,c)).map((e,t)=>({cells:sJ(e,{...l,lead:t===0?mJ(i,c):[],trail:t===0?mJ(a,c):[]}),band:`own`,place:`flow`})),drops:o.map(e=>({cells:sJ(mJ([e],n.band),{...l,baseStyle:n.band}),band:`deeper`,place:`flow`}))}}function hX(e,t,n,r,i,a,o){n.waited(r);let s=n.lastDrawn(e.id);if(s?.kind===`hidden`)return null;let c=n.decorations(e,i),l=a?c.trigger:c.closed,u=mJ(vX(e.lead,e,t,n),l),d=mJ(vX(e.trail,e,t,n),l);return{styles:c,inline:(s===void 0||s.drawing.own.length===0?[[`auto`]]:s.drawing.own.map(e=>e.cells.map(e=>e.text.cellLength))).map((e,t)=>({cells:e.flatMap((e,n)=>{let r=t===0&&n===0;return sJ(mJ([new q(r?`…`:` `)],l),{...o(l),width:e,justify:`left`,truncate:`right`,lead:r?u:[],trail:r?d:[]})}),band:`own`,place:`flow`})),drops:[]}}function gX(e){return e.reduce((e,t)=>e+t.cellLength,0)}function _X(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:sJ([new q(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:mP(n.palette)},lead:vX(e.lead,e,t,n),trail:vX(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function vX(e,t,n,r){if(e===void 0)return[];try{return r.evaluateOnce(t,n,r.palette,e).fragments}catch(e){let n=ZC(e);return n===void 0?r.onSegmentError?.(t.id,e.message??String(e)):r.waited(n.variable),[]}}const yX={container:sX,segment:uX};function bX(e){return yX[e]}var xX=class{last=null;from(e){let{last:t}=this;return t!==null&&t.source.config===e.config&&t.source.preset===e.preset&&t.source.revision===e.revision&&t.source.width===e.width?t:null}begin(e,t){let n=new Map,r=new Map;return{placed:(e,r)=>{let{drawing:i}=t(e,r);return n.set(e,i===null?SX:{kind:`drew`,drawing:i}),r},rule:(e,t)=>r.set(e,t),commit:()=>{this.last={source:e,placements:n,rules:r}}}}};const SX={kind:`hidden`},CX={palette:`theme`,style:`style`,effect:`effect`},wX=ix.get(`colorCompatibility`),TX={width:0,chromeCols:0,padding:0,seamCols:0,preset:``};function EX(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,error:e}}}function DX(e){if(e.ok)return e.value;throw e.error}const OX=e=>({read:()=>e}),kX=jg({basePalette:Ag,palette:Ag,decor:K_});var AX=class{evaluated=0;memory=new xX;scope;binding;facts;look=X.observable.box(void 0,{deep:!1,equals:(e,t)=>e!==void 0&&t!==void 0&&kX(e,t)});layout;phase={ruling:!1};gates=new Map;placements=new Map;rules=new Map;slots=new Map;view;projected=void 0;drawnSlots=new Map;constructor(e,t,n,r){this.store=e,this.registry=t,this.source=n,this.view=X.observable.box(r,{deep:!1}),this.scope=vj(e),this.depth=e.derive(`drawn depth`,`computed`,()=>{let e=this.inputAt(wX);return e.kind===`found`&&typeof e.value==`string`&&Av(e.value)?e.value:`truecolor`});let i=(0,X.observable)(TX,void 0,{deep:!1});this.facts=i;let a=this.look,o=this.phase,s=()=>this.layout.read();this.binding={store:e,registry:t,get width(){return i.width},get chromeCols(){return i.chromeCols},get padding(){return i.padding},get seamCols(){return i.seamCols},get look(){return o.ruling?void 0:a.get()},get layout(){return o.ruling?void 0:s}},this.layout=this.derive(`layout`,n.layoutReadsInstant,()=>{let e=n.roots.get(i.preset),t=a.get().palette;return eX(e,e=>this.shown(e)).map(e=>e.flatMap(({name:e,address:n,settings:r})=>{let i=UR(e);return i===void 0?[]:[{name:i,address:n,palette:ux(r.theme,t)}]}))}),t.bindInputs({read:e=>this.inputAt(e),drawnAt:()=>jv(this.colorCompatibility())})}bind(e){(0,X.runInAction)(()=>this.view.set(e))}selections(){return this.view.get().selections()}draw(e,t){this.draws++,this.projected=t,this.drawnSlots.clear(),(0,X.runInAction)(()=>Object.assign(this.facts,e))}inputAt(e){let t=zM(e);return t===void 0?LM(e)===void 0?EM(this.view.get().payload(),e):EM(this.projected,e):TM(this.slotName(t))}depth;colorCompatibility(){return this.depth.read()}slot(e){let t=this.slots.get(e);if(t===void 0){let n,r=()=>{let t=this.selections()[CX[e]];if(t.kind===`decided`)return NX(t.name,null,null);let r=FX(this.source,e,t.source);if(this.source.instant.has(r.template))return{kind:`per-draw`,rule:r};let i=this.rule(r.template);switch(i.kind){case`named`:{let t=null;return n=IX(this.source,e,i.name,r.where,e=>{t=e}),NX(n,t,null)}case`pending`:return NX(n??_v[e],null,i.variable);case`failed`:return n=_v[e],NX(n,vv(r.where,e,`the rule failed — ${i.error}`),null)}},i;t=this.store.derive(`slot ${e}`,`computed`,()=>{let e=r();return(i===void 0||!PX(i,e))&&(i=e),i}),this.slots.set(e,t)}return t.read()}slotName(e){let t=this.slot(e);return t.kind===`settled`?t.name:this.drawnSlots.get(e)??_v[e]}drawnSlot(e,t){this.drawnSlots.set(e,t)}draws=0;publishLook(e){(0,X.runInAction)(()=>this.look.set(e))}gate(e){let{when:t}=e;if(t===void 0)return eJ(t,this.scope);let n=this.gates.get(e);return n===void 0&&(n=this.derive(`when`,this.readsInstant(t),()=>eY(this.source.activeSegment,()=>eJ(t,this.scope))),this.gates.set(e,n)),n.read()}placement(e){let t=this.placements.get(e);return t===void 0&&(t=new LX(this,e),this.placements.set(e,t)),t}rule(e){let t=this.rules.get(e);return t===void 0&&(t=this.derive(`rule`,this.readsInstant(e),()=>{this.phase.ruling=!0;let t=this.source.runtime.bound===this.binding?null:bJ(this.source.runtime,this.binding);try{return{kind:`named`,name:e.evaluate(this.scope).map(e=>e.plain).join(``)}}catch(e){let t=ZC(e);return t===void 0?{kind:`failed`,error:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}finally{t?.[Symbol.dispose](),this.phase.ruling=!1}}),this.rules.set(e,t)),t.read()}readsInstant(...e){return e.some(e=>e!==void 0&&this.source.instant.has(e))}derive(e,t,n){let r=()=>(this.evaluated++,n());return this.store.derive(`part ${e}`,t?`projection`:`computed`,t?this.oncePerDraw(r):r)}oncePerDraw(e){let t=null;return()=>(t?.draw!==this.draws&&(t={draw:this.draws,answer:EX(e)}),DX(t.answer))}shown(e){let t=this.gate(e);return e.kind===`container`?t.kind===`shown`||t.kind===`pending`:UR(e.name)===void 0||t.kind===`hidden`?!1:t.kind===`failed`?!0:this.placement(e).gate().kind!==`hidden`}};function jX(e,t,n,r){let i=e.views.get(t);if(i!==void 0)return i.bind(r),i;let a=new AX(t,n,e,r);return e.views.set(t,a),a}function MX(e,t){let n=e.views.get(t);if(n===void 0)throw Error(`a store was drawn before its view was bound (bindView): its inputs have no source`);return n}const NX=(e,t,n)=>({kind:`settled`,name:e,warning:t,waited:n}),PX=(e,t)=>e.kind===`settled`?t.kind===`settled`&&e.name===t.name&&e.warning===t.warning&&e.waited===t.waited:t.kind===`per-draw`&&e.rule===t.rule;function FX(e,t,n){let r=e.globalExpressions.get(t)?.get(n);if(r===void 0)throw Error(`the ${t} rule ${JSON.stringify(n)} reached the view but no compiled template exists — the compile and the resolution disagree about isExpression`);return r}function IX(e,t,n,r,i){switch(t){case`palette`:return mx(n,r,i).name;case`style`:return mv(n,e.styles).name;case`effect`:return wv(n).name}}var LX=class{where=RX(jg({palette:Ag,region:W_}));ground=RX(jg({colours:BX,bodyOpen:Ag}));opened=RX(jg({colours:BX,open:Ag}));ownGate;open;colours;body;affixes;constructor(e,t){let n=e.source.segments[t.name],r=e.source.activeSegment,i=bj(e.scope,t.settings),{when:a,bg:o,fg:s,template:c}=n,{lead:l,trail:u}=t,d=t.opens?.open;this.ownGate=a===void 0?OX($q):e.derive(`${t.id} when`,e.readsInstant(a),()=>eY(r,()=>eJ(a,i))),this.open=d===void 0?OX(Qq):e.derive(`${t.id} body gate`,e.readsInstant(d),()=>eY(r,()=>eJ(d,e.scope))),this.colours=e.derive(`${t.id} colours`,e.readsInstant(o,s),()=>{let{palette:n,region:a}=this.where.get();return UX(r,t,n,a,e.registry.drawnAt(),o,s,i)}),this.body=e.derive(`${t.id} body`,e.readsInstant(c),()=>{let{colours:e,bodyOpen:n}=this.ground.get();return WX(r,t,e,c,n,i)}),this.affixes=l===void 0&&u===void 0?OX(KX):e.derive(`${t.id} affixes`,e.readsInstant(l,u),()=>{let{colours:e,open:n}=this.opened.get();return GX(r,t,e,n,l,u,i)})}gate(){return this.ownGate.read()}bodyGate(){return this.open.read()}evaluate(e,t){this.where.set({palette:e,region:t});let n=this.colours.read();this.ground.set({colours:n,bodyOpen:this.open.read().kind===`shown`});let r=this.body.read();return this.opened.set({colours:n,open:r.open}),JX(n,r,this.affixes.read())}};function RX(e){let t=X.observable.box(void 0,{deep:!1,equals:(t,n)=>t!==void 0&&n!==void 0&&e(t,n)});return{set:e=>(0,X.runInAction)(()=>t.set(e)),get:()=>t.get()}}const zX=(e,t)=>e.hex===t.hex,BX=jg({palette:Ag,drawnAt:Ag,tint:zX,text:zX,bg:zX,disclosure:q_});function VX(e,t){return{segName:e.name,placementId:e.id,palette:t.palette,disclosure:t.disclosure,tint:t.tint,text:t.text}}const HX=e=>V_(e.palette,e.disclosure,e.drawnAt);function UX(e,t,n,r,i,a,o,s){let c={palette:n,drawnAt:i,...$_(n,r,i)};return $J(e,VX(t,c),e=>{let t=Vte(e,i,a,o,s);return{...c,bg:e.bg,style:t}})}function WX(e,t,n,r,i,a){return $J(e,VX(t,n),e=>(e.bg=i?HX(n).state:n.bg,{fragments:r.evaluate(a),drops:e.drops,open:e.drops.length>0||i}))}function GX(e,t,n,r,i,a,o){return $J(e,VX(t,n),e=>(e.bg=r?HX(n).state:n.bg,{lead:i?.evaluate(o)??[],trail:a?.evaluate(o)??[],drops:e.drops}))}const KX={lead:[],trail:[],drops:[]};function qX(e){let{palette:t,drawnAt:n,disclosure:r}=e;return{closed:e.style,get trigger(){return IJ(t,HX(e).state,n)},get band(){return IJ(t,HX(e).plane,n)},get close(){return zJ(t,HX(e).state,n)},disclosure:r}}function JX(e,t,n){return{styles:qX(e),fragments:t.fragments,lead:n.lead,trail:n.trail,drops:[...t.drops,...n.drops],open:t.open}}function YX(e,t,n,r,i,a,o){let s=UX(e,t,n,r,i,void 0,void 0,o);return JX(s,WX(e,t,s,a,!1,o),KX)}function XX(e,t,n,r,i){return qX(UX(e,t,n,r,i,void 0,void 0,{}))}function ZX(e,t){return{payload:()=>e,selections:()=>t}}function QX(e){if(`ttl`in e)return{kind:`ttl`,durationMs:xM(e.ttl)};if(`watch_file`in e)return{kind:`watch_file`,path:e.watch_file};if(`depends_on`in e)return{kind:`depends_on`,varNames:e.depends_on};if(`key`in e)return{kind:`key`,template:e.key};if(`never`in e)return{kind:`never`};throw Error(`Unknown CacheDecl discriminator — loader invariant violated: ${JSON.stringify(e)}`)}function $X(e,t){switch(ey(e)){case`json`:return{kind:`json`,default:t};case`regex`:return{kind:`regex`,regex:new RegExp(e.regex),default:t};case`text`:return{kind:`text`,default:t}}}function eZ(e,t,n,r,i){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`dropped`:e.declareFailedDocument(t,n.reason);break;case`source`:e.declareSourceDocument(t);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default,i);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:QX(n.cache),parse:$X(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:QX(n.cache),parse:$X(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{type:n.type??`string`,varDefault:n.default,derivation:i});break;case`time`:e.declareTime(t,{format:n.layout,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function tZ(e,t,n,r=zw.EMPTY){let i=r;for(let[r,a]of Object.entries(t))try{i=e.parse(`{{ define "${r}" }}${a}{{ end }}`,i).defines()}catch(e){throw Error(`Template parse error in ${n}.${r}: ${e.message}`,{cause:e})}return i}function nZ(e,t,n){let{compiled:r,loadWarnings:i}=iZ(e,t,n.cwd,rZ(n.links),cZ);return{...r,loadWarnings:i}}const rZ=e=>(t,n)=>lZ(n,e);function iZ(e,t,n,r,i=cZ){let a=aZ(e),o=oZ(a);return{compiled:r(o,a),compileKey:o,loadWarnings:sZ(e,t,n,i)}}function aZ(e){let{variables:t,...n}=e,r=new Map;for(let[e,n]of ax)n in t&&r.set(e,n);for(let[t,n]of sy(e))r.has(n.key)||r.set(n.key,t);return{config:n,stateReads:[...r].sort(([e],[t])=>e<t?-1:1),projections:[...AG(e)].sort(([e],[t])=>e<t?-1:1)}}function oZ(e){return ce(`sha256`).update(JSON.stringify(e)).digest(`hex`)}function sZ(e,t,n,r){let i=GY(e),a=AG(e),o=[];for(let[s,c]of LC(e))if(r.has(i.get(s)))try{eZ(t,s,c,n,a.has(s)?`projection`:`computed`)}catch(e){o.push(`Variable "${s}": ${e.message??String(e)}`)}return o}const cZ=new Set([`directory`,`view`]);function lZ({config:e,stateReads:t,projections:n},r){let i={bound:void 0,compiled:new Map,links:r},a=()=>_J(i,`drawnAt`).registry.drawnAt(),o=ZJ(a),s={action:i,activeSegment:o},c=Object.keys(e.styles),l=Ax(e.presets),u=MR(e),d=[e=>bY(i,o,e.now)],f=_j({extraFuncs:{...PJ(i),...yY(i),...fY(i,o),...hY(i),...TY(i,o),...jY(i,o),...FY(s),...RY(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},clockFuncs:d,drawnAt:a}),p=tZ(f,e.helpers,`helpers`),m=new Map,h=e=>{let t=f.parse(e,p);return m.set(t,e),t},g=new Map,_=e=>{let t=g.get(e);if(t!==void 0)return t;let n=h(e);return g.set(e,n),n},v=new Map(t);i.compiled=xJ(h,e.actions,v,u);let y=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=n.partials===void 0?p:tZ(f,n.partials,`segments.${t}.partials`,p),r=t=>{let n=f.parse(t,e);return m.set(n,t),n},i=(e,i,a=n.partials===void 0?_:r)=>{try{return a(e)}catch(e){throw Error(`Template parse error in segments.${t}.${i}: ${e.message}`,{cause:e})}};y[t]={when:n.when===void 0?void 0:i(n.when,`when`),template:i(n.template,`template`,r),bg:n.bg===void 0?void 0:i(n.bg,`bg`,r),fg:n.fg===void 0?void 0:i(n.fg,`fg`,r)}}let b=(e,t,n)=>{try{return _(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},x=t=>{let n=dy(e.segments[t.name]),r=Object.create(null);for(let[e,a]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>_y(t,e,a,t=>String(_J(i,`setting ${e}`).store.read(t.variable)))});return Object.freeze(r)},S=(e,t,n)=>{let r={path:t,at:n,when:e.when===void 0?void 0:b(e.when,t,`when`),parse:(e,n)=>b(e,t,n),compileChild:S,placementSettings:x};return bX(e.kind).compile(e,r)},C=new Map;for(let t of l){let{node:n,path:r}=Nx(e,t);C.set(t,S(n,r,void 0))}let w=new Map(lv.map(e=>[e,new Map]));for(let{at:t,slot:n,rule:r}of MG(e)){let e=t.join(`.`),i=w.get(n),a=i.get(r);i.set(r,a===void 0?{where:e,template:fZ(h,e,r)}:{where:`${a.where}, ${e}`,template:a.template})}let T=new Set(n.map(([e])=>e)),E={reads:CG({names:T,helpers:e.helpers,actions:e.actions}),projections:new Map(n),clock:gj(d)},ee=FG(E),D=[...C.values()].flatMap(dZ(y)).some(e=>ee(m.get(e))),te=D?new Set([...E.clock,AY]):E.clock,O=FG({...E,clock:te}),k=new Set([...m].flatMap(([e,t])=>O(t)?[e]:[]));for(let[t,n]of Object.entries(e.segments)){if(n.partials===void 0)continue;let r=FG({reads:CG({names:T,helpers:{...e.helpers,...n.partials},actions:e.actions}),projections:E.projections,clock:te});for(let e of SH){let n=y[t][e];n!==void 0&&r(m.get(n))&&k.add(n)}}return{segments:y,roots:C,activeSegment:o,menuRuntime:s,links:r,globalExpressions:w,instant:k,layoutReadsInstant:D,styles:e.styles,runtime:i,views:new WeakMap}}function uZ(e){return Object.entries(e.segments).flatMap(([t,n])=>[n.when,n.bg,n.fg,n.template].some(t=>t!==void 0&&e.instant.has(t))?[t]:[])}const dZ=e=>t=>{let n=[];return eX(t,e=>(n.push(e),!0)),n.flatMap(t=>[...t.when===void 0?[]:[t.when],...t.kind===`segment`&&e[t.name].when!==void 0?[e[t.name].when]:[]])};function fZ(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}const pZ=e=>{throw Error(`a slot settled on a name its domain refuses: ${e}`)};function mZ(e,t,n,r,i){let a=hZ(e,t,n.rule(t.template),r,i);return i.settled(e,a),a}function hZ(e,t,n,r,i){switch(n.kind){case`named`:return n.name;case`pending`:return i.waited(n.variable),i.held(e)??_v[e];case`failed`:return r({kind:`rule`,slot:e,message:vv(t.where,e,`the rule failed — ${n.error}`)}),_v[e]}}function gZ(e){return _Z(e).filter(e=>!e.name.startsWith(Yx)).map(e=>e.id)}function _Z(e){return e.kind===`container`?e.children.flatMap(_Z):[e,...e.opens===void 0?[]:_Z(e.opens.body)]}function vZ(e,t,n,r,i,a){let o={...r,term:{cols:i.width},colorCompatibility:{effective:i.colorCompatibility}};return jX(e,t,n,ZX(o,a)),o}function yZ(e,t,n,r,i,a,o,s,c){try{var l=lo();let{perSegmentSink:u,onSegmentError:d,onRenderWarning:f}=s??{},p=e=>f?.(e),m=c.effects??new LP(``),h=m.clockAt(a,bv[c.animationSpeed]),g=l.u(oj(a,h.timeline)),_=MX(t,n),v={...o,colorCompatibility:_.colorCompatibility()};_.draw({width:v.width,chromeCols:rF(v),padding:v.padding,seamCols:iF(v),preset:c.preset},i);let y=_.evaluated;l.u(bJ(t.menuRuntime.action,_.binding));let{preset:b,transitions:x}=c,S={variation:$g[c.variation],shade:Wg[c.shade]},C={config:e,preset:b,revision:r.stateRevision(),width:v.width},w=_.memory.begin(C,XY),T=_.memory.from(C),E=new Set,ee={held:e=>T?.rules.get(e),waited:e=>E.add(e),settled:w.rule},D=new Map,te=e=>{let n=_.slot(e);if(D.set(e,n.kind===`settled`?`kept`:`per-draw`),n.kind===`settled`)return n.warning!==null&&p({kind:`rule`,slot:e,message:n.warning}),n.waited!==null&&E.add(n.waited),n.name;let r=IX(t,e,mZ(e,n.rule,_,p,ee),n.rule.where,t=>p({kind:`rule`,slot:e,message:t}));return _.drawnSlot(e,r),r},{theme:O,style:k,effect:ne}=_.selections(),A=O.kind===`decided`?O:mx(te(`palette`),``,pZ),re=k.kind===`decided`?k:mv(te(`style`),e.styles),ie=ne.kind===`decided`?ne:wv(te(`effect`)),ae=A.value,oe=fx(ae,re.value);_.publishLook({basePalette:ae,palette:oe,decor:S});let se=oe.get(`warning`),ce=c.idleSince===void 0?null:{idleSince:c.idleSince,timeoutS:c.menuTimeout,fill:se,text:j_(oe,se,r.drawnAt())},le=m.motion(ie.value,h,{transitions:x,source:C,last:T,returned:XY,hold:ZY},ce);u?.clear();let ue=t=>e.segments[t],de=(e,i,a)=>{let o=i.kind===`hidden`?i:YY(i,_.gate(e)),s=o.kind===`failed`?{...o,report:()=>{let t=`when over ${gZ(e).join(`, `)||`no placement`}`;p({kind:`when`,where:t,error:o.message,message:`${t}: ${o.message} — what it gates is hidden`})}}:o,c={scope:_.scope,palette:oe,gate:s,padding:v.padding,region:a,perSegmentSink:u,onSegmentError:d,placement:e=>_.placement(e),evaluateOnce:(e,n,i,o)=>YX(t.activeSegment,e,i,a,r.drawnAt(),o,n),lookupSegment:ue,renderChild:(e,t,n)=>de(e,t,Z_(a,n)),renderBody:(e,t,n)=>de(e,t,Q_(n)),closeDisclosure:e=>FJ(t.links.to,n,e),placed:(e,t)=>w.placed(e,le.placed(e,t)),lastDrawn:e=>T?.placements.get(e),waited:e=>E.add(e),decorations:(e,n)=>XX(t.activeSegment,e,n,a,r.drawnAt())};return bX(e.kind).render(e,c)},fe=t.roots.get(b);if(fe===void 0)throw Error(`Preset "${b}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${kx}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let pe=qY(de(fe,$q,X_(S))).map(({line:e,row:t})=>{let n=fJ(e.cells,v),r=e.band===`deeper`?`menu`:`bar`;return{kind:r,cellBreaks:n.length-e.cells.length,...sF(n.map(e=>e.owner),v,le.row(t,r,n))}});le.drawn(),w.commit();let me=()=>pe.some(e=>e.kind===`menu`)||_.selections().effect.kind===`expression`||x||_Z(fe).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`),he=Math.min(g.heard(),...pe.map(e=>e.nextChange)),ge=Number.isFinite(he)?`moves`:me()?`can-move`:`still`;for(let[e,t]of r.cachePolicyFaults())p({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{frame:{depth:v.colorCompatibility,rows:pe.flatMap(({kind:e,lines:t})=>t.map(t=>({kind:e,runs:t}))),nextChange:he,motion:ge,pending:[...E].sort()},evaluated:_.evaluated-y,cellBreaks:pe.reduce((e,t)=>e+t.cellBreaks,0),rules:D}}catch(e){l.e=e}finally{l.d()}}function bZ(e){return qq(e.effective(),e.payload().tmux!==void 0)}function xZ(e,t,n,r,i,a,o,s){let{drawing:c,feeds:l,diagnostics:u}=t,{source:d}=e,f=d.effective(),p=d.payload().term.cols,m=yZ(e.state.config,e.state.compiled,e.store,e.registry,{diagnostics:OU(u),drawing:c,feeds:l,today:Iq(d.facts().builtins.today,n)},n,cq(f,p),{perSegmentSink:e.lastRenderCellsBySegment,onRenderWarning:s},{...f,effects:r,idleSince:i}),h=bZ(d),g={width:p,rows:AU(d.hints().termRows,c.by===`feed`?fb.flatMap(e=>{let t=db[e].rows;return h[e]&&t!==null?[t]:[]}):[]),colorCompatibility:m.frame.depth},_=kU(a,u);return{...m,body:_===null?m.frame:WP(m.frame,jU(u,_,o,e.sessionId,c.by,g)),viewing:_,geometry:g}}const SZ={moving:1e3/30,still:1e3},CZ=[`data`,`state`,`reload`,`visibility`];function wZ(e){return fb.filter(t=>e[t].subscribers>0).map(t=>{let{subscribers:n,fps:r,shown:i}=e[t];return`${t}:${n}sub/${r}fps/${i?`shown`:`offscreen`}`}).join(`,`)||`-`}function TZ(e,t){let n=e.filter(e=>e>t-1&&e<=t);e.splice(0,e.length,...n,t)}const EZ=(e,t)=>db[t].handsOff?e.resp:e.statusline,DZ=e=>Math.round(1e3/e);var OZ=class{requests=new Map;feeds=new Map;stopWatching=null;drawn=0;pushed=0;refused=0;lookups=0;found=0;constructor(e){this.deps=e}note(e,t,n){let r=this.requests.get(e);if(r!==void 0&&r.order>n)return;this.requests.delete(e),this.requests.set(e,{req:t,order:n});for(let e of this.requests.keys()){if(this.requests.size<=256)break;this.feeds.has(e)||this.requests.delete(e)}let i=this.feeds.get(e);i!==void 0&&i.noted++}subscribe(e,t){let n=this.deps.lanes(e);if(n!==null&&!n[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e)??this.open(e),i={lane:this.laneOf(r,t.lane),sent:null};return r.followers.set(t,i),this.send(t,i),this.hasten(r),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.followers.size} view=${n===null?`N`:`Y`}`),()=>this.unsubscribe(r,t)}laneOf(e,t){let n=e.lanes.get(t);if(n!==void 0)return n;let r=this.deps.encoders[t](),i={rate:[],encode:r,out:e.last===null?null:r(e.last.bar,EZ(e.last.answers,t))};return e.lanes.set(t,i),i}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e,t){let n=this.feeds.get(e);n!==void 0&&(n.woke[t]++,n.phase.kind!==`drawing`&&(n.wokeSince??=this.deps.clock.monotonic()),this.hasten(n)||n.coalesced++)}wakeWhere(e,t){for(let{sessionId:n,req:r}of this.watched())t(r)&&this.wake(n,e)}newestWhere(e){let t=null;for(let[n,{req:r,order:i}]of this.requests)e(r)&&(t===null||i>t.order)&&(t={sessionId:n,order:i});return this.lookups++,t!==null&&this.found++,t?.sessionId??null}latest(e){return this.requests.get(e)?.req??null}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e,t){let n=this.feeds.get(e);if(n===void 0)return yb;let r=t-1,i=this.shown(n);return vb(e=>{let a=n.lanes.get(e)?.rate;if(a===void 0)return gb;let o=0;for(let t of n.followers.keys())t.lane===e&&o++;let s=0;for(let e of a)e>r&&e<=t&&s++;return{subscribers:o,fps:s,shown:i}})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.followers.size;return{feeds:this.feeds.size,subscribers:e,drawn:this.drawn,pushed:this.pushed,refused:this.refused,lookups:this.lookups,found:this.found}}open(e){let t=this.deps.clock.monotonic(),n={sessionId:e,followers:new Map,lanes:new Map,unwatch:this.deps.watch(e,()=>this.wake(e,`state`)),unpin:this.deps.pin(e),phase:{kind:`waiting`},lastStart:-1/0,last:null,since:t,drawn:0,noted:0,noView:0,moving:0,unseen:0,failed:0,pushed:0,drawMs:0,evaluated:0,cellBreaks:0,woke:{data:0,state:0,reload:0,visibility:0},wokeSince:null,wakeToFrameLast:null,wakeToFrameMax:0,coalesced:0,summarizedAt:t,refreshesAtOpen:this.deps.refreshes()};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),n}close(){for(let e of[...this.feeds.values()])for(let t of[...e.followers.keys()])this.unsubscribe(e,t)}unsubscribe(e,t){if(e.followers.delete(t)){if([...e.followers.keys()].some(e=>e.lane===t.lane)||e.lanes.delete(t.lane),e.followers.size>0){this.hasten(e);return}e.phase.kind===`due`&&e.phase.clear(),e.unwatch(),e.unpin(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)}}draw(e,t){e.phase={kind:`drawing`};let n=e.wokeSince;e.wokeSince=null;let r=this.deps.clock.monotonic(),i=this.deps.instant(),a=Math.min(Math.max(t,i),i+.002),o=r+(a-i)*1e3;try{this.step(e,n,r,o,a)}catch(t){if(e.lastStart=o,this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${k(t)}`),this.feeds.get(e.sessionId)!==e)return;this.schedule(e,null,a)}}step(e,t,n,r,i){let a=this.deps.render(e.sessionId,DZ(this.spacingOf(e)),i);if(a===null){e.noView++,e.phase={kind:`waiting`};return}e.lastStart=r;let o=this.deps.clock.monotonic();t!==null&&(e.wakeToFrameLast=o-t,e.wakeToFrameMax=Math.max(e.wakeToFrameMax,o-t)),this.drawn++,e.drawn++,e.drawMs+=o-n,e.evaluated+=a.evaluated,e.cellBreaks+=a.cellBreaks,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,a),this.push(e,a,i),this.feeds.get(e.sessionId)===e&&(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),this.schedule(e,a,i)))}schedule(e,t,n){let{moving:r,still:i}=this.deps.periods,a=((t?.bar.nextChange??1/0)-n)*1e3,o=Math.min(Math.max(a,r),i),s=this.shown(e);o<i&&s&&e.moving++,o<i&&!s&&e.unseen++;let c=s?o:i;this.arm(e,n+c/1e3,this.deps.instant())}spacingOf(e){return this.shown(e)?this.deps.periods.moving:this.deps.periods.still}hasten(e){let{phase:t}=e;if(t.kind===`drawing`)return!1;let n=this.deps.clock.monotonic(),r=Math.max(n,e.lastStart+this.spacingOf(e));if(t.kind===`due`&&t.at<=r)return!1;let i=this.deps.instant();return this.arm(e,i+(r-n)/1e3,i),!0}arm(e,t,n){let r=Math.max(0,(t-n)*1e3);this.setTimer(e,t,this.deps.clock.monotonic()+r,r)}setTimer(e,t,n,r){e.phase.kind===`due`&&e.phase.clear(),e.phase={kind:`due`,at:n,clear:this.deps.clock.after(r,()=>this.fire(e,t,n))}}fire(e,t,n){let r=n-this.deps.clock.monotonic();r>0?this.setTimer(e,t,n,r):this.draw(e,t)}shown(e){let t=this.requests.get(e.sessionId);return t===void 0||this.deps.shown(t.req)}countFailure(e,t){t.failure!==null&&e.failed++}push(e,t,n){let r=this.deps.lanes(e.sessionId);if(r!==null)for(let t of[...e.followers.keys()])r[t.lane]||(this.unsubscribe(e,t),this.refuse(e.sessionId,t));if(e.followers.size===0)return;t.delivered();let i={resp:JSON.stringify(t.resp),statusline:JSON.stringify(t.statusline)},a=[...e.lanes].map(([e,n])=>({held:n,out:n.encode(t.bar,EZ(i,e))}));if(!(e.last?.answers.resp===i.resp&&e.last.answers.statusline===i.statusline&&a.every(({held:e,out:t})=>e.out?.json===t.json))){e.last={bar:t.bar,answers:i},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let{held:e,out:t}of a)e.out?.json!==t.json&&TZ(e.rate,n),e.out=t;for(let[t,n]of e.followers)this.send(t,n)}}send(e,t){let{out:n}=t.lane;n===null||t.sent===n.json||(e.frame(n),t.sent=n.json)}refuse(e,t){this.refused++,this.deps.log(`info`,`feed sid=${JSON.stringify(e)} refused lane=${t.lane} switched-off`),t.refused({ok:!1,error:hN(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.clock.monotonic(),r=this.deps.refreshes(),i=(n-e.since)/1e3,a=i===0?`-`:`${(e.drawn/i).toFixed(1)}fps`,o=$j.map(t=>`${t}:${r[t]-e.refreshesAtOpen[t]}`).join(`,`);this.deps.log(`info`,`feed sid=${JSON.stringify(e.sessionId)} ${t} subscribers=${e.followers.size} lanes=${[...e.followers.keys()].map(e=>e.lane).join(`,`)||`-`} for=${Math.round(i)}s drawn=${e.drawn} noted=${e.noted} noView=${e.noView} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} ceiling=${DZ(this.spacingOf(e))}fps achieved=${a} evaluated=${e.evaluated} cellBreaks=${e.cellBreaks} woke=${CZ.map(t=>`${t}:${e.woke[t]}`).join(`,`)} wakeToFrame=${e.wakeToFrameLast===null?`-`:`last:${e.wakeToFrameLast.toFixed(1)}ms,max:${e.wakeToFrameMax.toFixed(1)}ms`} coalesced=${e.coalesced} daemonRefreshed=${o} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};const kZ=`click.error`;function AZ(e,t,n,r){let i=MZ(e,t).filter(e=>at(e,5,r,`request`)!==`over`);IZ(e,t,{newest:{text:n,at:r,answered:!1},earlier:i})}function jZ(e,t,n){let r=LZ(e,t);if(r===null)return;let i=e=>n.some(t=>ot(e,t))?{...e,answered:!0}:e,a={newest:i(r.newest),earlier:r.earlier.map(i)};a.newest===r.newest&&a.earlier.every((e,t)=>e===r.earlier[t])||IZ(e,t,a)}function MZ(e,t){let n=LZ(e,t);return n===null?[]:[...n.earlier,n.newest]}function NZ(e,t,n,r){return MZ(e,t).map(e=>({error:e,hold:at(e,5,n,r)}))}const PZ=e=>e.flatMap(({error:e,hold:t})=>t===`over`?[]:[e]),FZ=e=>PZ(e).filter(e=>!e.answered);function IZ(e,t,{newest:n,earlier:r}){e.set(t,kZ,JSON.stringify({...n,earlier:r}))}function LZ(e,t){let n=e.get(t,kZ);if(n===null)return null;let r;try{r=JSON.parse(n)}catch{return null}let i=RZ(r);if(i===null)return null;let{earlier:a}=r;return{newest:i,earlier:Array.isArray(a)?a.flatMap(e=>{let t=RZ(e);return t===null?[]:[t]}):[]}}function RZ(e){if(typeof e!=`object`||!e)return null;let{text:t,at:n,answered:r}=e;return typeof t==`string`&&typeof n==`number`&&(r===void 0||typeof r==`boolean`)?{text:t,at:n,answered:r===!0}:null}function zZ(e,t){return fb.filter(n=>e[n]&&db[n].handsOff&&t.has(n))}function BZ(e,t,n){return{severity:gU,lines:[[_U(`[⟲ claude]`,US(e,[{verb:gS,args:[t,...n.map(e=>db[e].switch.setting)]}]))]]}}function VZ(e,t){for(let n of Object.entries(t))e.push(n)}const HZ={ok:`info`,"bad-request":`warn`,threw:`error`,closing:`info`,abandoned:`info`};function UZ(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,k(e.error)]];case`closing`:return[[`closing`,e.error.message]];case`abandoned`:return[[`abandoned`,`1`]]}}function WZ(e,t,n,r){let i=[...t,[`took`,`${r}ms`],[`outcome`,n.kind],...UZ(n)];return{level:HZ[n.kind],line:GZ(e,i)}}const GZ=(e,t)=>`${e}${t.map(([e,t])=>` ${e}=${z(t)}`).join(``)}`;function KZ(e,t,n){if(t.kind===`pending`)return oo(t.why);if(e!==void 0&&e.kind!==`pending`){let{at:n,...r}=e;if((0,X.compareStructural)(r,t))return e}return{...t,at:n}}const qZ=new Set([`hook_event_name`,`session_id`,`session_name`,`transcript_path`,`cwd`,`model`,`workspace`,`version`,`output_style`,`cost`,`context_window`,`exceeds_200k_tokens`,`effort`,`thinking`,`rate_limits`,`vim`,`agent`,`worktree`]),JZ=[[`session_id`,`string`],[`transcript_path`,`string`],[`cwd`,`string`],[`model`,`object`],[`model.id`,`string`],[`model.display_name`,`string`],[`workspace`,`object`],[`workspace.current_dir`,`string`],[`workspace.project_dir`,`string`]],YZ=[[`workspace.added_dirs`,`string-list`]];function XZ(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of JZ){let i=$Z(n,e);if(i==null)t.missingRequired.push(e);else{let n=ZZ(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of YZ){let i=$Z(n,e),a=i===void 0?r:QZ(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))qZ.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function ZZ(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function QZ(e){return Array.isArray(e)&&e.every(e=>ZZ(e)===`string`)?`string-list`:ZZ(e)}function $Z(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function eQ(e){let t=typeof e==`string`?e===``?`is empty`:e===`.`||e===`..`?`is ${JSON.stringify(e)}, which names a folder, not a session`:/[/\\\0]/.test(e)?`contains a path separator or NUL: ${JSON.stringify(e)}`:Buffer.byteLength(e,`utf8`)>250?`is longer than 250 bytes`:null:`is not a string: ${JSON.stringify(e)??String(e)}`;return t===null?{ok:!0,id:e}:{ok:!1,problem:t}}function tQ(e){let t=eQ(e);if(!t.ok)throw Error(`session id ${t.problem}`);return t.id}function nQ(e,t){let n=Object.keys(e.history);return e.revision===t.revision&&e.back===t.back&&n.every(n=>e.history[n]===t.history[n])&&rQ(e.values,t.values)}new Set(oq);function rQ(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function iQ(e){return{hookData:e.hookData,cwd:e.cwd,hints:e.hints}}function aQ(e){let t=e.kind===`recording`?{kind:e.kind,v:7,session:e.session,home:e.home}:e.kind===`facts`?{kind:e.kind,at:e.at,facts:e.facts}:e.kind===`draw`?{kind:e.kind,at:e.at,drawing:e.drawing,feeds:e.feeds,state:{...e.state,idleSince:e.state.idleSince??null},diagnostics:e.diagnostics}:e.kind===`state`?{kind:e.kind,state:e.state}:e.kind===`turn`?{kind:e.kind,held:e.held,at:e.document.at,facts:e.document.facts,...iQ(e.request),state:e.state}:{kind:e.kind,...e.kind===`request`&&{at:e.at},...iQ(e.request)};return`${JSON.stringify(t)}\n`}function oQ(e,t){let n=new Map,r=!1,i=e=>{for(let t of e.watching)t();e.watching.clear()},a=(e,t,r)=>{let a=n.get(e);a===void 0||!a.delete(t)||(a.size===0&&n.delete(e),i(t),t.sink.end(r))},o=(e,n,r)=>{if(!(r.kind===`declared`&&r.request===n.declaration))try{n.sink.write(r),r.kind===`facts`&&(n.document=r.facts),r.kind===`turn`&&(n.document=r.document.facts),(r.kind===`state`||r.kind===`draw`||r.kind===`turn`)&&(n.state=r.state),(r.kind===`request`||r.kind===`declared`||r.kind===`turn`)&&(n.declaration=r.request)}catch(r){t(`error`,`recording sid=${JSON.stringify(e)}: ${k(r)}`),a(e,n,{kind:`failed`,error:r})}},s=(e,t,n)=>o(e,t,n),c=(e,t,r,i)=>{if(i.facts===t.document)return;let a=r.source.state();(t.state===null||!nQ(t.state,a))&&s(e,t,{kind:`state`,state:a}),n.get(e)?.has(t)&&o(e,t,{kind:`facts`,...i})},l=(e,t,n)=>{let r=n.source.held();t.turn?.view===n&&t.turn.held===r||(t.turn={view:n,held:r},s(e,t,{kind:`turn`,held:r,...n.source.turn()}))},u=(t,r,i,{view:a,state:o,drawing:u,feeds:d,diagnostics:f})=>{let p=e.sessionView(t),m={at:i,drawing:u,feeds:d,state:o,diagnostics:f},h=[()=>l(t,r,a),()=>c(t,r,a,a.followed.stamped()),()=>s(t,r,{kind:`declared`,request:a.facts()}),()=>s(t,r,{kind:`draw`,...m}),...p===null?[]:[()=>l(t,r,p)]];for(let e of h)n.get(t)?.has(r)&&e()},d=(t,r)=>{let i=e.sessionView(t);if(i===null)return;let a=(e,i)=>{if(!n.get(t)?.has(r))return;let a=(0,X.reaction)(e,i,{fireImmediately:!0});n.get(t)?.has(r)?r.watching.add(a):a()};a(()=>i.source.held(),()=>l(t,r,i)),a(()=>i.followed.stamped(),e=>c(t,r,i,e))};return{record(t,i){if(r)throw Error(`the daemon is closing: it records nothing more`);let o=e.sessionView(t);if(o===null)throw Error(`no view of session ${JSON.stringify(t)} is open in this daemon: it has not drawn a bar here since the daemon started, or its view closed while it was idle`);let c={sink:i,watching:new Set,document:null,declaration:null,state:null,turn:null},l=n.get(t)??new Set;return n.set(t,l.add(c)),s(t,c,{kind:`recording`,session:t,home:o.source.home()}),l.has(c)&&d(t,c),()=>a(t,c,{kind:`stopped`})},moved(e){for(let t of n.get(e)??[])i(t),d(e,t)},arrived(e,t){let r=new Set;for(let i of n.get(e)??[])s(e,i,{kind:`request`,...t}),r.add(i);return{at:t.at,noted:r}},drew(e,{at:t,noted:r},i){let a=[...n.get(e)??[]].filter(e=>r.has(e));if(a.length===0)return;let o=i();for(let n of a)u(e,n,t,o)},fed(e,t,r){let i=[...n.get(e)??[]];if(i.length===0)return;let a=r();for(let n of i)u(e,n,t,a)},close(){r=!0;for(let[e,t]of n)for(let n of t)a(e,n,{kind:`closed`})}}}function sQ(e,t){let n=null,r=oQ({sessionView:e=>{if(n===null)throw Error(`a recorder read its cache before the cache was built`);return n.sessionView(e)}},t);return n=e({onSessionViewMoved:e=>r.moved(e)}),{cache:n,recorder:r}}function cQ(e,t,n){let r=e.arrived(t.sessionId,{at:n,request:t.facts()});return{...t.settle(n),arrival:r}}const lQ=(e,t)=>({view:e,state:{...e.source.state(),idleSince:t.idleSince},...t.handed});function uQ(e,t,n,r){let i=r();return e.drew(t.sessionId,n,()=>lQ(t,i)),i}function dQ(e,t,n,r){let i=r();return e.fed(t.sessionId,n,()=>lQ(t,i)),i}var fQ=class extends Error{name=`RecordingFailed`};function pQ(e,t,n,r,i,a){return new Promise((o,s)=>{let c;try{c=C(r,`wx`,384)}catch(e){s(Error(e.code===`EEXIST`?`${r} already exists: a recording writes a new file`:`${r} cannot be created: ${String(e)}`));return}let l=0,u={request:0,feed:0},d=()=>{},f=t.after(i*1e3,()=>d()),p=()=>d(),m={write:e=>{g(c,aQ(e)),l++,e.kind===`draw`&&u[e.drawing.by]++},end:e=>{f(),a.removeEventListener(`abort`,p);let t=e.kind===`failed`?e.error:null;try{_(c),u.request+u.feed===0&&D(r)}catch(e){t??=e}t===null?o({path:r,lines:l,answers:u.request,frames:u.feed,daemonClosed:e.kind===`closed`}):s(new fQ(`writing ${r}: ${String(t)}`))}};a.addEventListener(`abort`,p,{once:!0});try{d=e.record(n,m)}catch(e){a.removeEventListener(`abort`,p),f(),_(c),D(r),s(e)}})}const mQ=()=>{},hQ=e=>({ok:!1,error:e instanceof Error?e.message:k(e),code:`RENDER_FAILED`,daemonV:3}),gQ={ansi:e=>({ok:!0,output:dne(e)}),frame:e=>({ok:!0,frame:e})};function _Q(e,t,n,r){let{clock:i,frameFeeds:a}=e,o=i.monotonic(),s=[[`sid`,t]];try{try{var c=lo();let i=c.u(wQ(e,t,r,s));if(i===null)return null;let{drawn:o,evaluated:l,cellBreaks:u,delivered:d,lanes:f}=dQ(e.recorder,i.view,r,()=>EQ(e,i,{by:`feed`,fps:n})),p=gQ.ansi(o.body),m=MQ(e.links.to,t,o,zZ(f,a.following(t)));return{bar:o.body,resp:p,statusline:m===o.body?p:gQ.ansi(m),evaluated:l,cellBreaks:u,delivered:d,failure:null}}catch(e){c.e=e}finally{c.d()}}catch(e){let{level:t,line:n}=WZ(`render`,s,{kind:`threw`,error:e},tt(i,o)),r=hQ(e);return{bar:ane(r.error),resp:r,statusline:r,evaluated:0,cellBreaks:0,delivered:mQ,failure:{level:t,line:`frame ${n}`}}}}function vQ(e,t,n){let{sessionState:r}=e;return Xq(n.config,e=>r.get(t,e),e=>n.authoredRoots.has(e))}function yQ(e,t){try{var n=lo();let{renderCache:r}=e,i=n.u(r.holdView(t));return i===null?null:qq(i.view.source.effective(),mc(i.view.facts().hints.tmux))}catch(e){n.e=e}finally{n.d()}}function bQ(e,t,n){let r=e.frameFeeds.latest(n);return xQ(e,t,n,r===null||mc(r.hints.tmux))}function xQ(e,t,n,r){try{var i=lo();return qq(vQ(e,n,i.u(e.renderCache.hold(t.projectDir,t.cwd,t.target.path)).state),r)}catch(e){i.e=e}finally{i.d()}}function SQ(e,t,n,r){VZ(n,{renderer:r,at:t.toFixed(3)});let i=e.hints,a=br(e,i),o=xr(a);return VZ(n,{termCols:String(i.termCols??`?`),termRows:String(i.termRows??`?`),refused:a.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:i.client?.kind??`unreported`,rateLimits:e.rateLimits}),o}function CQ(e,t,n,r){let{renderCache:i}=e,a=t.hookData.workspace?.current_dir??t.cwd,o={...t,hookData:{...t.hookData,...a!==void 0&&s.isAbsolute(a)&&{location:uc(a)}}},c=SQ(o,n,r,e.rendererName);VZ(r,{encoding:o.encoding});let l=o.requested;return TQ(i.holdSession(l.projectDir,l.cwd,l.target.path,o),o,c,n,r)}function wQ(e,t,n,r){let{renderCache:i}=e,a=i.holdView(t);if(a===null){let e=i.openFailure(t);if(e!==null)throw e.error;return null}let o=a.view.facts(),s;try{s=SQ(o,n,r,e.rendererName)}catch(e){throw a[Symbol.dispose](),e}return TQ(a,o,s,n,r)}function TQ(e,t,n,r,i){try{let{entry:a,state:o,view:s}=e,{sessionId:c}=t;return{req:t,at:r,facts:i,sessionId:c,entry:a,state:o,view:s,hintsError:n,[Symbol.dispose]:()=>e[Symbol.dispose]()}}catch(t){throw e[Symbol.dispose](),t}}function EQ(e,t,n){let{sessionState:r,frameFeeds:i,renderCache:a,updateWatch:o,linkIds:s,links:c,fileEvents:l,renderWarnings:u,payloadProviders:d,effectSessions:f,menuIdle:p,launcher:m}=e,{req:h,at:g,facts:_,sessionId:v,entry:y,state:b,view:x,hintsError:S}=t,C=x.source.payload(),w=x.source.effective(),T=x.source.failure(),E=bZ(x.source);VZ(_,{lanes:fb.filter(e=>E[e]).join(`,`)||`-`}),VZ(_,{width:String(C.term.cols)});let ee=NZ(r,v,g,n.by),D=o.notice({to:c.to,sessionId:v,dismissed:r.get(v,Nz),enabled:w.updateNotice}),te=WU(y.repos,v,c),O=(e,t)=>({about:e,text:t,copy:t}),k=e=>O(e??``,e),ne=[k(Cr(h.refusedArgs)),k(S),O(`load`,y.lastError),O(`update-act`,o.error()),O(`link-ids`,s.error()),...b.dropped.map(e=>({about:`dropped\0${e.file}`,text:e.message,copy:e.prompt})),...PZ(ee).map(e=>O(`click\0${e.at}\0${e.text}`,e.text))].flatMap(({about:e,text:t,copy:n})=>e&&t&&n?[{about:e,text:t,copy:n}]:[]),A=y.watch===null?null:Dj(`config watch`,y.watch,null),re=m.launcherWarnings(g,n.by),ie=re.find(e=>e.kind===`launch-pipes`),ae=ie?.event??null,oe=[...Ac(l.delivery()),...re,...A===null?[]:[{kind:`config-watch`,message:A}],...y.lastWarning===null?[]:[{kind:`load`,message:y.lastWarning}],...T===null?[]:[{kind:`facts`,message:T.cause===`inputs`?`the bar is held on the last turn taken: ${T.reason}`:`the bar is drawn from the last facts that were read; the next could not be stamped: ${T.reason}`}]],se={config:b.config},ce=vU(c.to,v,n.by,ne,[...D,...te],[...oe.map(e=>({about:e.kind,message:e.message})),...u.ofSession(v,n.by,se).map(e=>({about:`${e.kind}\0${e.message}`,message:e.message}))].map(e=>({about:e.about,text:e.message,copy:e.message}))),le=x.source.facts(),ue={drawing:n,feeds:i.feedsOf(v,g),diagnostics:ce},de=so(C.metrics)?void 0:C.metrics;VZ(_,jq(le.sources)),VZ(_,Mq(le.runs)),VZ(_,{factsSeq:String(le.seq),prompts:String(de?.messageCount??`-`),nonPrompts:String(de?.nonPrompts??`-`),pr:dq(C.git),feeds:wZ(ue.feeds)});let fe=[],pe=f.of(v),{body:me,viewing:he,geometry:ge,evaluated:_e,cellBreaks:ve,rules:ye,idleSince:be}=p.drawn(v,g,w.menuTimeout,e=>xZ(x,ue,g,pe,e,r.get(v,nS),c.to,e=>fe.push(e))),xe=bU(ce),Se=new Map(ce.map((e,t)=>[xe[t],e.copy])),Ce=()=>a.delivered(v,n.by,Se),we=p.since(v,g);VZ(_,{menuIdle:we===void 0?`-`:`${(g-we).toFixed(1)}s/${w.menuTimeout}s`});let Te=u.drawn(v,n.by,se,fe),Ee=d.gitProvider.getStats(),De=d.usageStore.getStats(),Oe=pe.lastFrame(),ke=Oe.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,Ae=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,je=e=>{switch(e.kind){case`rule`:return`rule:${e.slot}`;case`refresh`:return`refresh:${e.variable}`;case`file-events`:return`${e.kind}:${e.state}`;case`load`:case`facts`:case`config-watch`:case`lifeline`:case`launch-pipes`:case`when`:return e.kind}},Me=[...oe,...fe].map(je).join(`,`)||`-`;return VZ(_,{git:`${Ee.size}/${Ee.hits}h/${Ee.misses}m`,usage:`${De.size}/${De.hits}h/${De.misses}m`,effect:Oe.effect,effectT:Oe.t.toFixed(3),speed:`${Oe.speed}x`,effectRows:`${Oe.made}made/${Oe.reused}reused`,effectOwn:ke,fadeBasis:Oe.basis,stateRev:String(Oe.revision),fades:Ae(Oe.fades),leaves:Ae(Oe.leaves),motion:me.motion,evaluated:String(_e),cellBreaks:String(ve),pending:me.pending.join(`,`)||`-`,rules:[...ye].map(([e,t])=>`${e}:${t}`).join(`,`)||`-`,err:ne.length>0?`Y`:`N`,clickError:ee.map(({hold:e})=>e).join(`,`)||`-`,pipeEvent:ie?.hold??`-`,upd:String(D.length),ask:String(te.length),warn:Me,diag:String(ce.length),warnRecord:Te?`new`:`kept`,viewer:he===null?`-`:`${he.index}/${ce.length}p${he.page+1}`}),{drawn:{body:me,viewerOpen:he!==null,diagnostics:ce,geometry:ge},evaluated:_e,cellBreaks:ve,answersClick:FZ(ee),pipeShown:ae,delivered:Ce,lanes:E,idleSince:be,handed:ue}}function DQ(e,t){let{laneSetups:n,tmuxStatusLines:r}=e,i=xQ(e,t.requested,t.sessionId,mc(t.hints.tmux));return r.observe(t.sessionId,t.hints.tmux,i.tmuxStatus),n.noted(t.sessionId,i)}function OQ(e,t,n){return uQ(e.recorder,t.view,n,()=>EQ(e,t,mb))}function kQ(e){return{sessionId:e.hookData.session_id,hints:e.hints,origin:e.requested,transcript:e.hookData.transcript_path,answered:cF(e.hookData)}}function AQ(e,t,n,r){let{frameFeeds:i,laneSetups:a,tmuxStatusLines:o}=e,s=i.latest(t);return s!==null&&n.tmuxStatus!==r.tmuxStatus&&o.observe(t,s.hints.tmux,r.tmuxStatus),a.clicked(t,n,r)}async function jQ(e,t,n,r,i){try{var a=lo();let{clock:o,frameFeeds:s,log:c}=e,l=a.u(CQ(e,t,n,i)),u=cQ(e.recorder,l.view,n),d=o.monotonic(),f=r-d;VZ(i,{deadline:`${t.deadline.kind}:${Math.round(f)}ms`});let p=await Gj(e=>Promise.all([u.landed,l.view.registry.inFlight(e)]),f,e=>c(`error`,`render wait failed after its deadline sid=${JSON.stringify(l.sessionId)}: ${k(e)}`),o.after),m=o.monotonic();VZ(i,{waited:`${Math.round(m-d)}ms`,ended:p,refreshed:yq(u.refreshed)});let{drawn:h,answersClick:g,pipeShown:_,delivered:v,lanes:y}=OQ(e,l,u.arrival),b=t.sessionId,x=zZ(y,s.following(b)),S=lF(t.hints.client??null)===`statusline`,C=gQ[t.encoding](S?MQ(e.links.to,b,h,x):h.body);return VZ(i,{handoff:(S?x:[]).join(`,`)||`-`,drew:`${tt(o,m)}ms`}),{resp:C,motion:h.body.motion,answersClick:g,pipeShown:_,delivered:v}}catch(e){a.e=e}finally{a.d()}}function MQ(e,t,n,r){let[i,...a]=r;return i===void 0||n.viewerOpen?n.body:WP(n.body,MU(BZ(e,t,[i,...a]),n.diagnostics,e,t,n.geometry))}const NQ=/^─{20,}/,PQ=/^❯(\s|$)/,FQ=/›\s*stashed$/;function IQ(e){let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>NQ.test(e)?[t]:[]).at(-2);return n===void 0||!PQ.test(t[n+1]??``)?null:{hint:t[n-1]??``,prompt:t[n+1]}}function LQ(e){if(e.inMode)return{kind:`in-mode`};let t=IQ(e);return t===null?{kind:`no-prompt`}:FQ.test(t.hint)?{kind:`stashed`}:{kind:`ready`}}function RQ(e){return/^❯\s*\S/u.test(IQ(e)?.prompt??``)}const zQ=/^\S+\s+\S[^…]*…\s+\((\d+[hms]\s*)+/u;function BQ(e){return e.screen.some(e=>zQ.test(e))}const VQ={"in-mode":`the Claude Code pane is in tmux copy mode — leave it (q) and click again`,stashed:`Claude Code is holding a stashed prompt (ctrl+s) — restore or send it, then click again`,"no-prompt":`Claude Code is not at its prompt (a dialog or picker is open) — close it and click again`};function HQ(e){return e===void 0?{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`}:e===null?{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only act in a tmux pane`}:{kind:`pane`,hint:e}}async function UQ(e,t,n){let r=LQ(await e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:VQ[r.kind]};let i=await e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}async function WQ(e,t,n,r,i){let a=await Us(e,t,n,r,i);if(a.kind===`failed`)throw Error(a.reason);return a}async function GQ(e,t){let n=await WQ(e,t,`claude-input.read`,[`display`,`-p`,`-t`,t.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,t.pane]);if(n.kind===`rate-limited`)throw Error(n.reason);let[r=``,...i]=n.stdout.split(`
|
|
207
|
+
`);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function qY(e){let t=new Map;return e.map(e=>{let n=`${e.place}.${e.band}`,r=t.get(n)??0;return t.set(n,r+1),{line:e,row:`${n}#${r}`}})}const JY=e=>e.kind===`failed`?Qq:e;function YY(e,t){return t.kind===`shown`||t.kind===`failed`&&e.kind===`pending`?e:t}function XY(e,t){let n=[],r=[],i;for(let a of t)(a.band===`own`?n:r).push(a),i??=a.cells.find(t=>t.placement.id===e)?.placement.ground;return{drawing:i===void 0?null:{own:n,opened:r.length>0,ground:i},deeper:r}}function ZY(e){return{...e,cells:e.cells.map(iJ)}}function QY(e,t){let n=t.flatMap(e=>e.filter(e=>e.place===`above`)),r=t.map(e=>e.filter(e=>e.place===`flow`));return[...n,...$Y(e,r)]}function $Y(e,t){switch(e){case`vertical`:return t.flatMap(e=>e);case`horizontal`:return t.reduce((e,t)=>Math.max(e,t.length),0)===0?[]:[{cells:t.flatMap(e=>e[0]?.cells??[]),band:`own`,place:`flow`},...t.flatMap(e=>e.slice(1))]}}function eX(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:QY(e.direction,e.children.map((t,i)=>n(t,[...r,tX(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function tX(e,t){return e.steps[t]}function nX(e){if(e.kind===`segment`||e.unit===!0)return{width:1,reach:1};let t=rX(e);return{width:iX(t),reach:aX(t)}}function rX(e){let t=e.children.map(nX),n=n=>e.direction===`vertical`&&t.slice(0,n).some(({width:e})=>e>0);if(e.direction===`vertical`||e.unit===!0)return t.map((e,t)=>({start:0,span:e,ownLine:n(t)}));let r=0;return t.map((e,t)=>{let i=r;return r+=e.width,{start:i,span:e,ownLine:n(t)}})}const iX=e=>e.reduce((e,{span:t,ownLine:n})=>e+(n?0:t.width),0),aX=e=>e.reduce((e,{start:t,span:n})=>Math.max(e,t+n.reach),0);function oX(e,t){let n=rX(e);if(t?.axis===`cell`)return n.map(({start:e,span:n,ownLine:r})=>{let i=t.index+e;return r?{...t,index:i,lineStart:i,lineEnd:i+n.width-1}:{...t,index:i}});let r=Wv[e.direction],i=h_(e.distribution),[a,o,s]=r===`row`?[n.map((e,t)=>t),n.length,n.length-1]:[n.map(({start:e})=>e),aX(n),iX(n)-1];return a.map(e=>({index:e,count:o,distribution:i,axis:r,lineStart:0,lineEnd:s}))}const sX={compile(e,t){let n=oX(e,t.at);return{kind:`container`,direction:e.direction,when:t.when,steps:n,children:e.children.map((e,r)=>t.compileChild(e,Xv(t.path,r),n[r]))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),QY(e.direction,e.children.map((n,r)=>t.renderChild(n,JY(t.gate),tX(e,r))))}},cX={drop:e=>e.place,above:()=>`above`},lX={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},uX={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Gv(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(oa(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Zv(t.path),void 0),key:e.opens.ref.key,placement:e.opens.placement}},...e.lead!==void 0&&{lead:t.parse(e.lead,`lead`)},...e.trail!==void 0&&{trail:t.parse(e.trail,`trail`)}}},render:(e,t)=>t.placed(e.id,dX(e,t))};function dX(e,t){let n=t.lookupSegment(e.name);if(n===void 0)throw Error(`Layout segment "${e.name}" has no matching segment`);if(t.gate.kind===`hidden`)return[];let r=bj(t.scope,e.settings);if(t.gate.kind===`failed`)return _X(e,r,t,t.gate.message);try{let i=t.placement(e),a=YY(t.gate,i.gate());if(a.kind===`failed`)return _X(e,r,t,a.message);if(a.kind===`hidden`)return[];let o=i.bodyGate(),s=o.kind===`failed`&&a.kind===`pending`?a:o;if(s.kind===`failed`)return _X(e,r,t,s.message);let c=ux(e.settings.theme,t.palette),l={id:e.id,effect:e.settings.effect,ground:mP(c)},u=e=>({width:n.width??`auto`,justify:n.justify??`left`,truncate:n.truncate??`right`,baseStyle:e,padding:t.padding,placement:l}),d=s.kind===`shown`,f=a.kind===`pending`?a:s,p=f.kind===`pending`?fX(f.variable):pX(()=>i.evaluate(c,t.region)),m=p.kind===`drawn`?mX(p.segment,u):hX(e,r,t,p.variable,c,d,u);if(m===null)return[];let{styles:h,inline:g,drops:_}=m,v=e.opens,y=v===void 0?[]:t.renderBody(v.body,d?a:Qq,h.disclosure).map(e=>({...e,place:cX[v.placement](e)})),b=(e,t,n)=>sJ(mJ([e],t),{...u(t),width:`auto`,padding:n}),x=y.findIndex(e=>e.band===`own`),{lead:S,stays:C}=v!==void 0&&x!==-1?lX[v.placement](g,()=>b(t.closeDisclosure(v.key),h.close,t.padding)):{lead:[],stays:g},w=S.flatMap(e=>b(new q(` `.repeat(gX(rJ(e)))),h.trigger,0)),T=(e,t)=>e.band===`own`?t===x?S:w:[],E=y.map((e,t)=>({cells:[...T(e,t),...e.cells],band:`deeper`,place:e.place})),ee=[...C,..._];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...ee.flatMap(e=>e.cells),...y.flatMap(T)].flatMap(rJ)),[...ee,...E]}catch(n){return _X(e,r,t,n.message??String(n))}}const fX=e=>({kind:`waiting`,variable:e});function pX(e){try{return{kind:`drawn`,segment:e()}}catch(e){let t=ZC(e);if(t===void 0)throw e;return fX(t.variable)}}function mX(e,t){let{styles:n,fragments:r,lead:i,trail:a,drops:o,open:s}=e,c=s?n.trigger:n.closed,l=t(c);return{styles:n,inline:KY(mJ(r,c)).map((e,t)=>({cells:sJ(e,{...l,lead:t===0?mJ(i,c):[],trail:t===0?mJ(a,c):[]}),band:`own`,place:`flow`})),drops:o.map(e=>({cells:sJ(mJ([e],n.band),{...l,baseStyle:n.band}),band:`deeper`,place:`flow`}))}}function hX(e,t,n,r,i,a,o){n.waited(r);let s=n.lastDrawn(e.id);if(s?.kind===`hidden`)return null;let c=n.decorations(e,i),l=a?c.trigger:c.closed,u=mJ(vX(e.lead,e,t,n),l),d=mJ(vX(e.trail,e,t,n),l);return{styles:c,inline:(s===void 0||s.drawing.own.length===0?[[`auto`]]:s.drawing.own.map(e=>e.cells.map(e=>e.text.cellLength))).map((e,t)=>({cells:e.flatMap((e,n)=>{let r=t===0&&n===0;return sJ(mJ([new q(r?`…`:` `)],l),{...o(l),width:e,justify:`left`,truncate:`right`,lead:r?u:[],trail:r?d:[]})}),band:`own`,place:`flow`})),drops:[]}}function gX(e){return e.reduce((e,t)=>e+t.cellLength,0)}function _X(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:sJ([new q(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:mP(n.palette)},lead:vX(e.lead,e,t,n),trail:vX(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function vX(e,t,n,r){if(e===void 0)return[];try{return r.evaluateOnce(t,n,r.palette,e).fragments}catch(e){let n=ZC(e);return n===void 0?r.onSegmentError?.(t.id,e.message??String(e)):r.waited(n.variable),[]}}const yX={container:sX,segment:uX};function bX(e){return yX[e]}var xX=class{last=null;from(e){let{last:t}=this;return t!==null&&t.source.config===e.config&&t.source.preset===e.preset&&t.source.revision===e.revision&&t.source.width===e.width?t:null}begin(e,t){let n=new Map,r=new Map;return{placed:(e,r)=>{let{drawing:i}=t(e,r);return n.set(e,i===null?SX:{kind:`drew`,drawing:i}),r},rule:(e,t)=>r.set(e,t),commit:()=>{this.last={source:e,placements:n,rules:r}}}}};const SX={kind:`hidden`},CX={palette:`theme`,style:`style`,effect:`effect`},wX=ix.get(`colorCompatibility`),TX={width:0,chromeCols:0,padding:0,seamCols:0,preset:``};function EX(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,error:e}}}function DX(e){if(e.ok)return e.value;throw e.error}const OX=e=>({read:()=>e}),kX=jg({basePalette:Ag,palette:Ag,decor:K_});var AX=class{evaluated=0;memory=new xX;scope;binding;facts;look=X.observable.box(void 0,{deep:!1,equals:(e,t)=>e!==void 0&&t!==void 0&&kX(e,t)});layout;phase={ruling:!1};gates=new Map;placements=new Map;rules=new Map;slots=new Map;view;projected=void 0;drawnSlots=new Map;constructor(e,t,n,r){this.store=e,this.registry=t,this.source=n,this.view=X.observable.box(r,{deep:!1}),this.scope=vj(e),this.depth=e.derive(`drawn depth`,`computed`,()=>{let e=this.inputAt(wX);return e.kind===`found`&&typeof e.value==`string`&&Av(e.value)?e.value:`truecolor`});let i=(0,X.observable)(TX,void 0,{deep:!1});this.facts=i;let a=this.look,o=this.phase,s=()=>this.layout.read();this.binding={store:e,registry:t,get width(){return i.width},get chromeCols(){return i.chromeCols},get padding(){return i.padding},get seamCols(){return i.seamCols},get look(){return o.ruling?void 0:a.get()},get layout(){return o.ruling?void 0:s}},this.layout=this.derive(`layout`,n.layoutReadsInstant,()=>{let e=n.roots.get(i.preset),t=a.get().palette;return eX(e,e=>this.shown(e)).map(e=>e.flatMap(({name:e,address:n,settings:r})=>{let i=UR(e);return i===void 0?[]:[{name:i,address:n,palette:ux(r.theme,t)}]}))}),t.bindInputs({read:e=>this.inputAt(e),drawnAt:()=>jv(this.colorCompatibility())})}bind(e){(0,X.runInAction)(()=>this.view.set(e))}selections(){return this.view.get().selections()}draw(e,t){this.draws++,this.projected=t,this.drawnSlots.clear(),(0,X.runInAction)(()=>Object.assign(this.facts,e))}inputAt(e){let t=zM(e);return t===void 0?LM(e)===void 0?EM(this.view.get().payload(),e):EM(this.projected,e):TM(this.slotName(t))}depth;colorCompatibility(){return this.depth.read()}slot(e){let t=this.slots.get(e);if(t===void 0){let n,r=()=>{let t=this.selections()[CX[e]];if(t.kind===`decided`)return NX(t.name,null,null);let r=FX(this.source,e,t.source);if(this.source.instant.has(r.template))return{kind:`per-draw`,rule:r};let i=this.rule(r.template);switch(i.kind){case`named`:{let t=null;return n=IX(this.source,e,i.name,r.where,e=>{t=e}),NX(n,t,null)}case`pending`:return NX(n??_v[e],null,i.variable);case`failed`:return n=_v[e],NX(n,vv(r.where,e,`the rule failed — ${i.error}`),null)}},i;t=this.store.derive(`slot ${e}`,`computed`,()=>{let e=r();return(i===void 0||!PX(i,e))&&(i=e),i}),this.slots.set(e,t)}return t.read()}slotName(e){let t=this.slot(e);return t.kind===`settled`?t.name:this.drawnSlots.get(e)??_v[e]}drawnSlot(e,t){this.drawnSlots.set(e,t)}draws=0;publishLook(e){(0,X.runInAction)(()=>this.look.set(e))}gate(e){let{when:t}=e;if(t===void 0)return eJ(t,this.scope);let n=this.gates.get(e);return n===void 0&&(n=this.derive(`when`,this.readsInstant(t),()=>eY(this.source.activeSegment,()=>eJ(t,this.scope))),this.gates.set(e,n)),n.read()}placement(e){let t=this.placements.get(e);return t===void 0&&(t=new LX(this,e),this.placements.set(e,t)),t}rule(e){let t=this.rules.get(e);return t===void 0&&(t=this.derive(`rule`,this.readsInstant(e),()=>{this.phase.ruling=!0;let t=this.source.runtime.bound===this.binding?null:bJ(this.source.runtime,this.binding);try{return{kind:`named`,name:e.evaluate(this.scope).map(e=>e.plain).join(``)}}catch(e){let t=ZC(e);return t===void 0?{kind:`failed`,error:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}finally{t?.[Symbol.dispose](),this.phase.ruling=!1}}),this.rules.set(e,t)),t.read()}readsInstant(...e){return e.some(e=>e!==void 0&&this.source.instant.has(e))}derive(e,t,n){let r=()=>(this.evaluated++,n());return this.store.derive(`part ${e}`,t?`projection`:`computed`,t?this.oncePerDraw(r):r)}oncePerDraw(e){let t=null;return()=>(t?.draw!==this.draws&&(t={draw:this.draws,answer:EX(e)}),DX(t.answer))}shown(e){let t=this.gate(e);return e.kind===`container`?t.kind===`shown`||t.kind===`pending`:UR(e.name)===void 0||t.kind===`hidden`?!1:t.kind===`failed`?!0:this.placement(e).gate().kind!==`hidden`}};function jX(e,t,n,r){let i=e.views.get(t);if(i!==void 0)return i.bind(r),i;let a=new AX(t,n,e,r);return e.views.set(t,a),a}function MX(e,t){let n=e.views.get(t);if(n===void 0)throw Error(`a store was drawn before its view was bound (bindView): its inputs have no source`);return n}const NX=(e,t,n)=>({kind:`settled`,name:e,warning:t,waited:n}),PX=(e,t)=>e.kind===`settled`?t.kind===`settled`&&e.name===t.name&&e.warning===t.warning&&e.waited===t.waited:t.kind===`per-draw`&&e.rule===t.rule;function FX(e,t,n){let r=e.globalExpressions.get(t)?.get(n);if(r===void 0)throw Error(`the ${t} rule ${JSON.stringify(n)} reached the view but no compiled template exists — the compile and the resolution disagree about isExpression`);return r}function IX(e,t,n,r,i){switch(t){case`palette`:return mx(n,r,i).name;case`style`:return mv(n,e.styles).name;case`effect`:return wv(n).name}}var LX=class{where=RX(jg({palette:Ag,region:W_}));ground=RX(jg({colours:BX,bodyOpen:Ag}));opened=RX(jg({colours:BX,open:Ag}));ownGate;open;colours;body;affixes;constructor(e,t){let n=e.source.segments[t.name],r=e.source.activeSegment,i=bj(e.scope,t.settings),{when:a,bg:o,fg:s,template:c}=n,{lead:l,trail:u}=t,d=t.opens?.open;this.ownGate=a===void 0?OX($q):e.derive(`${t.id} when`,e.readsInstant(a),()=>eY(r,()=>eJ(a,i))),this.open=d===void 0?OX(Qq):e.derive(`${t.id} body gate`,e.readsInstant(d),()=>eY(r,()=>eJ(d,e.scope))),this.colours=e.derive(`${t.id} colours`,e.readsInstant(o,s),()=>{let{palette:n,region:a}=this.where.get();return UX(r,t,n,a,e.registry.drawnAt(),o,s,i)}),this.body=e.derive(`${t.id} body`,e.readsInstant(c),()=>{let{colours:e,bodyOpen:n}=this.ground.get();return WX(r,t,e,c,n,i)}),this.affixes=l===void 0&&u===void 0?OX(KX):e.derive(`${t.id} affixes`,e.readsInstant(l,u),()=>{let{colours:e,open:n}=this.opened.get();return GX(r,t,e,n,l,u,i)})}gate(){return this.ownGate.read()}bodyGate(){return this.open.read()}evaluate(e,t){this.where.set({palette:e,region:t});let n=this.colours.read();this.ground.set({colours:n,bodyOpen:this.open.read().kind===`shown`});let r=this.body.read();return this.opened.set({colours:n,open:r.open}),JX(n,r,this.affixes.read())}};function RX(e){let t=X.observable.box(void 0,{deep:!1,equals:(t,n)=>t!==void 0&&n!==void 0&&e(t,n)});return{set:e=>(0,X.runInAction)(()=>t.set(e)),get:()=>t.get()}}const zX=(e,t)=>e.hex===t.hex,BX=jg({palette:Ag,drawnAt:Ag,tint:zX,text:zX,bg:zX,disclosure:q_});function VX(e,t){return{segName:e.name,placementId:e.id,palette:t.palette,disclosure:t.disclosure,tint:t.tint,text:t.text}}const HX=e=>V_(e.palette,e.disclosure,e.drawnAt);function UX(e,t,n,r,i,a,o,s){let c={palette:n,drawnAt:i,...$_(n,r,i)};return $J(e,VX(t,c),e=>{let t=Vte(e,i,a,o,s);return{...c,bg:e.bg,style:t}})}function WX(e,t,n,r,i,a){return $J(e,VX(t,n),e=>(e.bg=i?HX(n).state:n.bg,{fragments:r.evaluate(a),drops:e.drops,open:e.drops.length>0||i}))}function GX(e,t,n,r,i,a,o){return $J(e,VX(t,n),e=>(e.bg=r?HX(n).state:n.bg,{lead:i?.evaluate(o)??[],trail:a?.evaluate(o)??[],drops:e.drops}))}const KX={lead:[],trail:[],drops:[]};function qX(e){let{palette:t,drawnAt:n,disclosure:r}=e;return{closed:e.style,get trigger(){return IJ(t,HX(e).state,n)},get band(){return IJ(t,HX(e).plane,n)},get close(){return zJ(t,HX(e).state,n)},disclosure:r}}function JX(e,t,n){return{styles:qX(e),fragments:t.fragments,lead:n.lead,trail:n.trail,drops:[...t.drops,...n.drops],open:t.open}}function YX(e,t,n,r,i,a,o){let s=UX(e,t,n,r,i,void 0,void 0,o);return JX(s,WX(e,t,s,a,!1,o),KX)}function XX(e,t,n,r,i){return qX(UX(e,t,n,r,i,void 0,void 0,{}))}function ZX(e,t){return{payload:()=>e,selections:()=>t}}function QX(e){if(`ttl`in e)return{kind:`ttl`,durationMs:xM(e.ttl)};if(`watch_file`in e)return{kind:`watch_file`,path:e.watch_file};if(`depends_on`in e)return{kind:`depends_on`,varNames:e.depends_on};if(`key`in e)return{kind:`key`,template:e.key};if(`never`in e)return{kind:`never`};throw Error(`Unknown CacheDecl discriminator — loader invariant violated: ${JSON.stringify(e)}`)}function $X(e,t){switch(ey(e)){case`json`:return{kind:`json`,default:t};case`regex`:return{kind:`regex`,regex:new RegExp(e.regex),default:t};case`text`:return{kind:`text`,default:t}}}function eZ(e,t,n,r,i){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`dropped`:e.declareFailedDocument(t,n.reason);break;case`source`:e.declareSourceDocument(t);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default,i);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:QX(n.cache),parse:$X(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:QX(n.cache),parse:$X(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{type:n.type??`string`,varDefault:n.default,derivation:i});break;case`time`:e.declareTime(t,{format:n.layout,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function tZ(e,t,n,r=zw.EMPTY){let i=r;for(let[r,a]of Object.entries(t))try{i=e.parse(`{{ define "${r}" }}${a}{{ end }}`,i).defines()}catch(e){throw Error(`Template parse error in ${n}.${r}: ${e.message}`,{cause:e})}return i}function nZ(e,t,n){let{compiled:r,loadWarnings:i}=iZ(e,t,n.cwd,rZ(n.links),cZ);return{...r,loadWarnings:i}}const rZ=e=>(t,n)=>lZ(n,e);function iZ(e,t,n,r,i=cZ){let a=aZ(e),o=oZ(a);return{compiled:r(o,a),compileKey:o,loadWarnings:sZ(e,t,n,i)}}function aZ(e){let{variables:t,...n}=e,r=new Map;for(let[e,n]of ax)n in t&&r.set(e,n);for(let[t,n]of sy(e))r.has(n.key)||r.set(n.key,t);return{config:n,stateReads:[...r].sort(([e],[t])=>e<t?-1:1),projections:[...AG(e)].sort(([e],[t])=>e<t?-1:1)}}function oZ(e){return ce(`sha256`).update(JSON.stringify(e)).digest(`hex`)}function sZ(e,t,n,r){let i=GY(e),a=AG(e),o=[];for(let[s,c]of LC(e))if(r.has(i.get(s)))try{eZ(t,s,c,n,a.has(s)?`projection`:`computed`)}catch(e){o.push(`Variable "${s}": ${e.message??String(e)}`)}return o}const cZ=new Set([`directory`,`view`]);function lZ({config:e,stateReads:t,projections:n},r){let i={bound:void 0,compiled:new Map,links:r},a=()=>_J(i,`drawnAt`).registry.drawnAt(),o=ZJ(a),s={action:i,activeSegment:o},c=Object.keys(e.styles),l=Ax(e.presets),u=MR(e),d=[e=>bY(i,o,e.now)],f=_j({extraFuncs:{...PJ(i),...yY(i),...fY(i,o),...hY(i),...TY(i,o),...jY(i,o),...FY(s),...RY(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},clockFuncs:d,drawnAt:a}),p=tZ(f,e.helpers,`helpers`),m=new Map,h=e=>{let t=f.parse(e,p);return m.set(t,e),t},g=new Map,_=e=>{let t=g.get(e);if(t!==void 0)return t;let n=h(e);return g.set(e,n),n},v=new Map(t);i.compiled=xJ(h,e.actions,v,u);let y=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=n.partials===void 0?p:tZ(f,n.partials,`segments.${t}.partials`,p),r=t=>{let n=f.parse(t,e);return m.set(n,t),n},i=(e,i,a=n.partials===void 0?_:r)=>{try{return a(e)}catch(e){throw Error(`Template parse error in segments.${t}.${i}: ${e.message}`,{cause:e})}};y[t]={when:n.when===void 0?void 0:i(n.when,`when`),template:i(n.template,`template`,r),bg:n.bg===void 0?void 0:i(n.bg,`bg`,r),fg:n.fg===void 0?void 0:i(n.fg,`fg`,r)}}let b=(e,t,n)=>{try{return _(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},x=t=>{let n=dy(e.segments[t.name]),r=Object.create(null);for(let[e,a]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>_y(t,e,a,t=>String(_J(i,`setting ${e}`).store.read(t.variable)))});return Object.freeze(r)},S=(e,t,n)=>{let r={path:t,at:n,when:e.when===void 0?void 0:b(e.when,t,`when`),parse:(e,n)=>b(e,t,n),compileChild:S,placementSettings:x};return bX(e.kind).compile(e,r)},C=new Map;for(let t of l){let{node:n,path:r}=Nx(e,t);C.set(t,S(n,r,void 0))}let w=new Map(lv.map(e=>[e,new Map]));for(let{at:t,slot:n,rule:r}of MG(e)){let e=t.join(`.`),i=w.get(n),a=i.get(r);i.set(r,a===void 0?{where:e,template:fZ(h,e,r)}:{where:`${a.where}, ${e}`,template:a.template})}let T=new Set(n.map(([e])=>e)),E={reads:CG({names:T,helpers:e.helpers,actions:e.actions}),projections:new Map(n),clock:gj(d)},ee=FG(E),D=[...C.values()].flatMap(dZ(y)).some(e=>ee(m.get(e))),te=D?new Set([...E.clock,AY]):E.clock,O=FG({...E,clock:te}),k=new Set([...m].flatMap(([e,t])=>O(t)?[e]:[]));for(let[t,n]of Object.entries(e.segments)){if(n.partials===void 0)continue;let r=FG({reads:CG({names:T,helpers:{...e.helpers,...n.partials},actions:e.actions}),projections:E.projections,clock:te});for(let e of SH){let n=y[t][e];n!==void 0&&r(m.get(n))&&k.add(n)}}return{segments:y,roots:C,activeSegment:o,menuRuntime:s,links:r,globalExpressions:w,instant:k,layoutReadsInstant:D,styles:e.styles,runtime:i,views:new WeakMap}}function uZ(e){return Object.entries(e.segments).flatMap(([t,n])=>[n.when,n.bg,n.fg,n.template].some(t=>t!==void 0&&e.instant.has(t))?[t]:[])}const dZ=e=>t=>{let n=[];return eX(t,e=>(n.push(e),!0)),n.flatMap(t=>[...t.when===void 0?[]:[t.when],...t.kind===`segment`&&e[t.name].when!==void 0?[e[t.name].when]:[]])};function fZ(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}const pZ=e=>{throw Error(`a slot settled on a name its domain refuses: ${e}`)};function mZ(e,t,n,r,i){let a=hZ(e,t,n.rule(t.template),r,i);return i.settled(e,a),a}function hZ(e,t,n,r,i){switch(n.kind){case`named`:return n.name;case`pending`:return i.waited(n.variable),i.held(e)??_v[e];case`failed`:return r({kind:`rule`,slot:e,message:vv(t.where,e,`the rule failed — ${n.error}`)}),_v[e]}}function gZ(e){return _Z(e).filter(e=>!e.name.startsWith(Yx)).map(e=>e.id)}function _Z(e){return e.kind===`container`?e.children.flatMap(_Z):[e,...e.opens===void 0?[]:_Z(e.opens.body)]}function vZ(e,t,n,r,i,a){let o={...r,term:{cols:i.width},colorCompatibility:{effective:i.colorCompatibility}};return jX(e,t,n,ZX(o,a)),o}function yZ(e,t,n,r,i,a,o,s,c){try{var l=lo();let{perSegmentSink:u,onSegmentError:d,onRenderWarning:f}=s??{},p=e=>f?.(e),m=c.effects??new LP(``),h=m.clockAt(a,bv[c.animationSpeed]),g=l.u(oj(a,h.timeline)),_=MX(t,n),v={...o,colorCompatibility:_.colorCompatibility()};_.draw({width:v.width,chromeCols:rF(v),padding:v.padding,seamCols:iF(v),preset:c.preset},i);let y=_.evaluated;l.u(bJ(t.menuRuntime.action,_.binding));let{preset:b,transitions:x}=c,S={variation:$g[c.variation],shade:Wg[c.shade]},C={config:e,preset:b,revision:r.stateRevision(),width:v.width},w=_.memory.begin(C,XY),T=_.memory.from(C),E=new Set,ee={held:e=>T?.rules.get(e),waited:e=>E.add(e),settled:w.rule},D=new Map,te=e=>{let n=_.slot(e);if(D.set(e,n.kind===`settled`?`kept`:`per-draw`),n.kind===`settled`)return n.warning!==null&&p({kind:`rule`,slot:e,message:n.warning}),n.waited!==null&&E.add(n.waited),n.name;let r=IX(t,e,mZ(e,n.rule,_,p,ee),n.rule.where,t=>p({kind:`rule`,slot:e,message:t}));return _.drawnSlot(e,r),r},{theme:O,style:k,effect:ne}=_.selections(),A=O.kind===`decided`?O:mx(te(`palette`),``,pZ),re=k.kind===`decided`?k:mv(te(`style`),e.styles),ie=ne.kind===`decided`?ne:wv(te(`effect`)),ae=A.value,oe=fx(ae,re.value);_.publishLook({basePalette:ae,palette:oe,decor:S});let se=oe.get(`warning`),ce=c.idleSince===void 0?null:{idleSince:c.idleSince,timeoutS:c.menuTimeout,fill:se,text:j_(oe,se,r.drawnAt())},le=m.motion(ie.value,h,{transitions:x,source:C,last:T,returned:XY,hold:ZY},ce);u?.clear();let ue=t=>e.segments[t],de=(e,i,a)=>{let o=i.kind===`hidden`?i:YY(i,_.gate(e)),s=o.kind===`failed`?{...o,report:()=>{let t=`when over ${gZ(e).join(`, `)||`no placement`}`;p({kind:`when`,where:t,error:o.message,message:`${t}: ${o.message} — what it gates is hidden`})}}:o,c={scope:_.scope,palette:oe,gate:s,padding:v.padding,region:a,perSegmentSink:u,onSegmentError:d,placement:e=>_.placement(e),evaluateOnce:(e,n,i,o)=>YX(t.activeSegment,e,i,a,r.drawnAt(),o,n),lookupSegment:ue,renderChild:(e,t,n)=>de(e,t,Z_(a,n)),renderBody:(e,t,n)=>de(e,t,Q_(n)),closeDisclosure:e=>FJ(t.links.to,n,e),placed:(e,t)=>w.placed(e,le.placed(e,t)),lastDrawn:e=>T?.placements.get(e),waited:e=>E.add(e),decorations:(e,n)=>XX(t.activeSegment,e,n,a,r.drawnAt())};return bX(e.kind).render(e,c)},fe=t.roots.get(b);if(fe===void 0)throw Error(`Preset "${b}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${kx}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let pe=qY(de(fe,$q,X_(S))).map(({line:e,row:t})=>{let n=fJ(e.cells,v),r=e.band===`deeper`?`menu`:`bar`;return{kind:r,cellBreaks:n.length-e.cells.length,...sF(n.map(e=>e.owner),v,le.row(t,r,n))}});le.drawn(),w.commit();let me=()=>pe.some(e=>e.kind===`menu`)||_.selections().effect.kind===`expression`||x||_Z(fe).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`),he=Math.min(g.heard(),...pe.map(e=>e.nextChange)),ge=Number.isFinite(he)?`moves`:me()?`can-move`:`still`;for(let[e,t]of r.cachePolicyFaults())p({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{frame:{depth:v.colorCompatibility,rows:pe.flatMap(({kind:e,lines:t})=>t.map(t=>({kind:e,runs:t}))),nextChange:he,motion:ge,pending:[...E].sort()},evaluated:_.evaluated-y,cellBreaks:pe.reduce((e,t)=>e+t.cellBreaks,0),rules:D}}catch(e){l.e=e}finally{l.d()}}function bZ(e){return qq(e.effective(),e.payload().tmux!==void 0)}function xZ(e,t,n,r,i,a,o,s){let{drawing:c,feeds:l,diagnostics:u}=t,{source:d}=e,f=d.effective(),p=d.payload().term.cols,m=yZ(e.state.config,e.state.compiled,e.store,e.registry,{diagnostics:OU(u),drawing:c,feeds:l,today:Iq(d.facts().builtins.today,n)},n,cq(f,p),{perSegmentSink:e.lastRenderCellsBySegment,onRenderWarning:s},{...f,effects:r,idleSince:i}),h=bZ(d),g={width:p,rows:AU(d.hints().termRows,c.by===`feed`?fb.flatMap(e=>{let t=db[e].rows;return h[e]&&t!==null?[t]:[]}):[]),colorCompatibility:m.frame.depth},_=kU(a,u);return{...m,body:_===null?m.frame:WP(m.frame,jU(u,_,o,e.sessionId,c.by,g)),viewing:_,geometry:g}}const SZ={moving:1e3/30,still:1e3},CZ=[`data`,`state`,`reload`,`visibility`];function wZ(e){return fb.filter(t=>e[t].subscribers>0).map(t=>{let{subscribers:n,fps:r,shown:i}=e[t];return`${t}:${n}sub/${r}fps/${i?`shown`:`offscreen`}`}).join(`,`)||`-`}function TZ(e,t){let n=e.filter(e=>e>t-1&&e<=t);e.splice(0,e.length,...n,t)}const EZ=(e,t)=>db[t].handsOff?e.resp:e.statusline,DZ=e=>Math.round(1e3/e);var OZ=class{requests=new Map;feeds=new Map;stopWatching=null;drawn=0;pushed=0;refused=0;lookups=0;found=0;constructor(e){this.deps=e}note(e,t,n){let r=this.requests.get(e);if(r!==void 0&&r.order>n)return;this.requests.delete(e),this.requests.set(e,{req:t,order:n});for(let e of this.requests.keys()){if(this.requests.size<=256)break;this.feeds.has(e)||this.requests.delete(e)}let i=this.feeds.get(e);i!==void 0&&i.noted++}subscribe(e,t){let n=this.deps.lanes(e);if(n!==null&&!n[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e)??this.open(e),i={lane:this.laneOf(r,t.lane),sent:null};return r.followers.set(t,i),this.send(t,i),this.hasten(r),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.followers.size} view=${n===null?`N`:`Y`}`),()=>this.unsubscribe(r,t)}laneOf(e,t){let n=e.lanes.get(t);if(n!==void 0)return n;let r=this.deps.encoders[t](),i={rate:[],encode:r,out:e.last===null?null:r(e.last.bar,EZ(e.last.answers,t))};return e.lanes.set(t,i),i}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e,t){let n=this.feeds.get(e);n!==void 0&&(n.woke[t]++,n.phase.kind!==`rendering`&&(n.wokeSince??=this.deps.clock.monotonic()),this.hasten(n)||n.coalesced++)}wakeWhere(e,t){for(let{sessionId:n,req:r}of this.watched())t(r)&&this.wake(n,e)}newestWhere(e){let t=null;for(let[n,{req:r,order:i}]of this.requests)e(r)&&(t===null||i>t.order)&&(t={sessionId:n,order:i});return this.lookups++,t!==null&&this.found++,t?.sessionId??null}latest(e){return this.requests.get(e)?.req??null}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e,t){let n=this.feeds.get(e);if(n===void 0)return yb;let r=t-1,i=this.shown(n);return vb(e=>{let a=n.lanes.get(e)?.rate;if(a===void 0)return gb;let o=0;for(let t of n.followers.keys())t.lane===e&&o++;let s=0;for(let e of a)e>r&&e<=t&&s++;return{subscribers:o,fps:s,shown:i}})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.followers.size;return{feeds:this.feeds.size,subscribers:e,drawn:this.drawn,pushed:this.pushed,refused:this.refused,lookups:this.lookups,found:this.found}}open(e){let t=this.deps.clock.monotonic(),n={sessionId:e,followers:new Map,lanes:new Map,unwatch:this.deps.watch(e,()=>this.wake(e,`state`)),unpin:this.deps.pin(e),phase:{kind:`waiting`},lastStart:-1/0,last:null,since:t,drawn:0,noted:0,noView:0,moving:0,unseen:0,failed:0,pushed:0,drawMs:0,evaluated:0,cellBreaks:0,woke:{data:0,state:0,reload:0,visibility:0},wokeSince:null,wakeToFrameLast:null,wakeToFrameMax:0,coalesced:0,summarizedAt:t,refreshesAtOpen:this.deps.refreshes()};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),n}close(){for(let e of[...this.feeds.values()])for(let t of[...e.followers.keys()])this.unsubscribe(e,t)}unsubscribe(e,t){if(e.followers.delete(t)){if([...e.followers.keys()].some(e=>e.lane===t.lane)||e.lanes.delete(t.lane),e.followers.size>0){this.hasten(e);return}e.phase.kind===`due`&&e.phase.clear(),e.unwatch(),e.unpin(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)}}draw(e,t){e.phase={kind:`rendering`};let n=e.wokeSince;e.wokeSince=null;let r=this.deps.clock.monotonic(),i=this.deps.instant(),a=Math.min(Math.max(t,i),i+.002),o=r+(a-i)*1e3;try{this.step(e,n,r,o,a)}catch(t){if(e.lastStart=o,this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${k(t)}`),this.feeds.get(e.sessionId)!==e)return;this.schedule(e,null,a)}}step(e,t,n,r,i){let a=this.deps.render(e.sessionId,DZ(this.spacingOf(e)),i);if(a===null){e.noView++,e.phase={kind:`waiting`};return}e.phase={kind:`pushing`},e.lastStart=r;let o=this.deps.clock.monotonic();t!==null&&(e.wakeToFrameLast=o-t,e.wakeToFrameMax=Math.max(e.wakeToFrameMax,o-t)),this.drawn++,e.drawn++,e.drawMs+=o-n,e.evaluated+=a.evaluated,e.cellBreaks+=a.cellBreaks,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,a),this.push(e,a,i),this.feeds.get(e.sessionId)===e&&(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),this.schedule(e,a,i)))}schedule(e,t,n){let{moving:r,still:i}=this.deps.periods,a=((t?.bar.nextChange??1/0)-n)*1e3,o=Math.min(Math.max(a,r),i),s=this.shown(e);o<i&&s&&e.moving++,o<i&&!s&&e.unseen++;let c=s?o:i;this.arm(e,n+c/1e3,this.deps.instant())}spacingOf(e){return this.shown(e)?this.deps.periods.moving:this.deps.periods.still}hasten(e){let{phase:t}=e;if(t.kind===`rendering`)return!1;let n=this.deps.clock.monotonic(),r=Math.max(n,e.lastStart+this.spacingOf(e)),i=this.deps.instant();return this.arm(e,i+(r-n)/1e3,i)}arm(e,t,n){let r=Math.max(0,(t-n)*1e3),i=this.deps.clock.monotonic()+r;return e.phase.kind===`due`&&e.phase.at<=i?!1:(this.setTimer(e,t,i,r),!0)}setTimer(e,t,n,r){e.phase.kind===`due`&&e.phase.clear(),e.phase={kind:`due`,at:n,clear:this.deps.clock.after(r,()=>this.fire(e,t,n))}}fire(e,t,n){let r=n-this.deps.clock.monotonic();r>0?this.setTimer(e,t,n,r):this.draw(e,t)}shown(e){let t=this.requests.get(e.sessionId);return t===void 0||this.deps.shown(t.req)}countFailure(e,t){t.failure!==null&&e.failed++}push(e,t,n){let r=this.deps.lanes(e.sessionId);if(r!==null)for(let t of[...e.followers.keys()])r[t.lane]||(this.unsubscribe(e,t),this.refuse(e.sessionId,t));if(e.followers.size===0)return;t.delivered();let i={resp:JSON.stringify(t.resp),statusline:JSON.stringify(t.statusline)},a=[...e.lanes].map(([e,n])=>({held:n,out:n.encode(t.bar,EZ(i,e))}));if(!(e.last?.answers.resp===i.resp&&e.last.answers.statusline===i.statusline&&a.every(({held:e,out:t})=>e.out?.json===t.json))){e.last={bar:t.bar,answers:i},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let{held:e,out:t}of a)e.out?.json!==t.json&&TZ(e.rate,n),e.out=t;for(let[t,n]of e.followers)this.send(t,n)}}send(e,t){let{out:n}=t.lane;n===null||t.sent===n.json||(e.frame(n),t.sent=n.json)}refuse(e,t){this.refused++,this.deps.log(`info`,`feed sid=${JSON.stringify(e)} refused lane=${t.lane} switched-off`),t.refused({ok:!1,error:hN(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.clock.monotonic(),r=this.deps.refreshes(),i=(n-e.since)/1e3,a=i===0?`-`:`${(e.drawn/i).toFixed(1)}fps`,o=$j.map(t=>`${t}:${r[t]-e.refreshesAtOpen[t]}`).join(`,`);this.deps.log(`info`,`feed sid=${JSON.stringify(e.sessionId)} ${t} subscribers=${e.followers.size} lanes=${[...e.followers.keys()].map(e=>e.lane).join(`,`)||`-`} for=${Math.round(i)}s drawn=${e.drawn} noted=${e.noted} noView=${e.noView} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} ceiling=${DZ(this.spacingOf(e))}fps achieved=${a} evaluated=${e.evaluated} cellBreaks=${e.cellBreaks} woke=${CZ.map(t=>`${t}:${e.woke[t]}`).join(`,`)} wakeToFrame=${e.wakeToFrameLast===null?`-`:`last:${e.wakeToFrameLast.toFixed(1)}ms,max:${e.wakeToFrameMax.toFixed(1)}ms`} coalesced=${e.coalesced} daemonRefreshed=${o} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};const kZ=`click.error`;function AZ(e,t,n,r){let i=MZ(e,t).filter(e=>at(e,5,r,`request`)!==`over`);IZ(e,t,{newest:{text:n,at:r,answered:!1},earlier:i})}function jZ(e,t,n){let r=LZ(e,t);if(r===null)return;let i=e=>n.some(t=>ot(e,t))?{...e,answered:!0}:e,a={newest:i(r.newest),earlier:r.earlier.map(i)};a.newest===r.newest&&a.earlier.every((e,t)=>e===r.earlier[t])||IZ(e,t,a)}function MZ(e,t){let n=LZ(e,t);return n===null?[]:[...n.earlier,n.newest]}function NZ(e,t,n,r){return MZ(e,t).map(e=>({error:e,hold:at(e,5,n,r)}))}const PZ=e=>e.flatMap(({error:e,hold:t})=>t===`over`?[]:[e]),FZ=e=>PZ(e).filter(e=>!e.answered);function IZ(e,t,{newest:n,earlier:r}){e.set(t,kZ,JSON.stringify({...n,earlier:r}))}function LZ(e,t){let n=e.get(t,kZ);if(n===null)return null;let r;try{r=JSON.parse(n)}catch{return null}let i=RZ(r);if(i===null)return null;let{earlier:a}=r;return{newest:i,earlier:Array.isArray(a)?a.flatMap(e=>{let t=RZ(e);return t===null?[]:[t]}):[]}}function RZ(e){if(typeof e!=`object`||!e)return null;let{text:t,at:n,answered:r}=e;return typeof t==`string`&&typeof n==`number`&&(r===void 0||typeof r==`boolean`)?{text:t,at:n,answered:r===!0}:null}function zZ(e,t){return fb.filter(n=>e[n]&&db[n].handsOff&&t.has(n))}function BZ(e,t,n){return{severity:gU,lines:[[_U(`[⟲ claude]`,US(e,[{verb:gS,args:[t,...n.map(e=>db[e].switch.setting)]}]))]]}}function VZ(e,t){for(let n of Object.entries(t))e.push(n)}const HZ={ok:`info`,"bad-request":`warn`,threw:`error`,closing:`info`,abandoned:`info`};function UZ(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,k(e.error)]];case`closing`:return[[`closing`,e.error.message]];case`abandoned`:return[[`abandoned`,`1`]]}}function WZ(e,t,n,r){let i=[...t,[`took`,`${r}ms`],[`outcome`,n.kind],...UZ(n)];return{level:HZ[n.kind],line:GZ(e,i)}}const GZ=(e,t)=>`${e}${t.map(([e,t])=>` ${e}=${z(t)}`).join(``)}`;function KZ(e,t,n){if(t.kind===`pending`)return oo(t.why);if(e!==void 0&&e.kind!==`pending`){let{at:n,...r}=e;if((0,X.compareStructural)(r,t))return e}return{...t,at:n}}const qZ=new Set([`hook_event_name`,`session_id`,`session_name`,`transcript_path`,`cwd`,`model`,`workspace`,`version`,`output_style`,`cost`,`context_window`,`exceeds_200k_tokens`,`effort`,`thinking`,`rate_limits`,`vim`,`agent`,`worktree`]),JZ=[[`session_id`,`string`],[`transcript_path`,`string`],[`cwd`,`string`],[`model`,`object`],[`model.id`,`string`],[`model.display_name`,`string`],[`workspace`,`object`],[`workspace.current_dir`,`string`],[`workspace.project_dir`,`string`]],YZ=[[`workspace.added_dirs`,`string-list`]];function XZ(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of JZ){let i=$Z(n,e);if(i==null)t.missingRequired.push(e);else{let n=ZZ(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of YZ){let i=$Z(n,e),a=i===void 0?r:QZ(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))qZ.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function ZZ(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function QZ(e){return Array.isArray(e)&&e.every(e=>ZZ(e)===`string`)?`string-list`:ZZ(e)}function $Z(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function eQ(e){let t=typeof e==`string`?e===``?`is empty`:e===`.`||e===`..`?`is ${JSON.stringify(e)}, which names a folder, not a session`:/[/\\\0]/.test(e)?`contains a path separator or NUL: ${JSON.stringify(e)}`:Buffer.byteLength(e,`utf8`)>250?`is longer than 250 bytes`:null:`is not a string: ${JSON.stringify(e)??String(e)}`;return t===null?{ok:!0,id:e}:{ok:!1,problem:t}}function tQ(e){let t=eQ(e);if(!t.ok)throw Error(`session id ${t.problem}`);return t.id}function nQ(e,t){let n=Object.keys(e.history);return e.revision===t.revision&&e.back===t.back&&n.every(n=>e.history[n]===t.history[n])&&rQ(e.values,t.values)}new Set(oq);function rQ(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function iQ(e){return{hookData:e.hookData,cwd:e.cwd,hints:e.hints}}function aQ(e){let t=e.kind===`recording`?{kind:e.kind,v:7,session:e.session,home:e.home}:e.kind===`facts`?{kind:e.kind,at:e.at,facts:e.facts}:e.kind===`draw`?{kind:e.kind,at:e.at,drawing:e.drawing,feeds:e.feeds,state:{...e.state,idleSince:e.state.idleSince??null},diagnostics:e.diagnostics}:e.kind===`state`?{kind:e.kind,state:e.state}:e.kind===`turn`?{kind:e.kind,held:e.held,at:e.document.at,facts:e.document.facts,...iQ(e.request),state:e.state}:{kind:e.kind,...e.kind===`request`&&{at:e.at},...iQ(e.request)};return`${JSON.stringify(t)}\n`}function oQ(e,t){let n=new Map,r=!1,i=e=>{for(let t of e.watching)t();e.watching.clear()},a=(e,t,r)=>{let a=n.get(e);a===void 0||!a.delete(t)||(a.size===0&&n.delete(e),i(t),t.sink.end(r))},o=(e,n,r)=>{if(!(r.kind===`declared`&&r.request===n.declaration))try{n.sink.write(r),r.kind===`facts`&&(n.document=r.facts),r.kind===`turn`&&(n.document=r.document.facts),(r.kind===`state`||r.kind===`draw`||r.kind===`turn`)&&(n.state=r.state),(r.kind===`request`||r.kind===`declared`||r.kind===`turn`)&&(n.declaration=r.request)}catch(r){t(`error`,`recording sid=${JSON.stringify(e)}: ${k(r)}`),a(e,n,{kind:`failed`,error:r})}},s=(e,t,n)=>o(e,t,n),c=(e,t,r,i)=>{if(i.facts===t.document)return;let a=r.source.state();(t.state===null||!nQ(t.state,a))&&s(e,t,{kind:`state`,state:a}),n.get(e)?.has(t)&&o(e,t,{kind:`facts`,...i})},l=(e,t,n)=>{let r=n.source.held();t.turn?.view===n&&t.turn.held===r||(t.turn={view:n,held:r},s(e,t,{kind:`turn`,held:r,...n.source.turn()}))},u=(t,r,i,{view:a,state:o,drawing:u,feeds:d,diagnostics:f})=>{let p=e.sessionView(t),m={at:i,drawing:u,feeds:d,state:o,diagnostics:f},h=[()=>l(t,r,a),()=>c(t,r,a,a.followed.stamped()),()=>s(t,r,{kind:`declared`,request:a.facts()}),()=>s(t,r,{kind:`draw`,...m}),...p===null?[]:[()=>l(t,r,p)]];for(let e of h)n.get(t)?.has(r)&&e()},d=(t,r)=>{let i=e.sessionView(t);if(i===null)return;let a=(e,i)=>{if(!n.get(t)?.has(r))return;let a=(0,X.reaction)(e,i,{fireImmediately:!0});n.get(t)?.has(r)?r.watching.add(a):a()};a(()=>i.source.held(),()=>l(t,r,i)),a(()=>i.followed.stamped(),e=>c(t,r,i,e))};return{record(t,i){if(r)throw Error(`the daemon is closing: it records nothing more`);let o=e.sessionView(t);if(o===null)throw Error(`no view of session ${JSON.stringify(t)} is open in this daemon: it has not drawn a bar here since the daemon started, or its view closed while it was idle`);let c={sink:i,watching:new Set,document:null,declaration:null,state:null,turn:null},l=n.get(t)??new Set;return n.set(t,l.add(c)),s(t,c,{kind:`recording`,session:t,home:o.source.home()}),l.has(c)&&d(t,c),()=>a(t,c,{kind:`stopped`})},moved(e){for(let t of n.get(e)??[])i(t),d(e,t)},arrived(e,t){let r=new Set;for(let i of n.get(e)??[])s(e,i,{kind:`request`,...t}),r.add(i);return{at:t.at,noted:r}},drew(e,{at:t,noted:r},i){let a=[...n.get(e)??[]].filter(e=>r.has(e));if(a.length===0)return;let o=i();for(let n of a)u(e,n,t,o)},fed(e,t,r){let i=[...n.get(e)??[]];if(i.length===0)return;let a=r();for(let n of i)u(e,n,t,a)},close(){r=!0;for(let[e,t]of n)for(let n of t)a(e,n,{kind:`closed`})}}}function sQ(e,t){let n=null,r=oQ({sessionView:e=>{if(n===null)throw Error(`a recorder read its cache before the cache was built`);return n.sessionView(e)}},t);return n=e({onSessionViewMoved:e=>r.moved(e)}),{cache:n,recorder:r}}function cQ(e,t,n){let r=e.arrived(t.sessionId,{at:n,request:t.facts()});return{...t.settle(n),arrival:r}}const lQ=(e,t)=>({view:e,state:{...e.source.state(),idleSince:t.idleSince},...t.handed});function uQ(e,t,n,r){let i=r();return e.drew(t.sessionId,n,()=>lQ(t,i)),i}function dQ(e,t,n,r){let i=r();return e.fed(t.sessionId,n,()=>lQ(t,i)),i}var fQ=class extends Error{name=`RecordingFailed`};function pQ(e,t,n,r,i,a){return new Promise((o,s)=>{let c;try{c=C(r,`wx`,384)}catch(e){s(Error(e.code===`EEXIST`?`${r} already exists: a recording writes a new file`:`${r} cannot be created: ${String(e)}`));return}let l=0,u={request:0,feed:0},d=()=>{},f=t.after(i*1e3,()=>d()),p=()=>d(),m={write:e=>{g(c,aQ(e)),l++,e.kind===`draw`&&u[e.drawing.by]++},end:e=>{f(),a.removeEventListener(`abort`,p);let t=e.kind===`failed`?e.error:null;try{_(c),u.request+u.feed===0&&D(r)}catch(e){t??=e}t===null?o({path:r,lines:l,answers:u.request,frames:u.feed,daemonClosed:e.kind===`closed`}):s(new fQ(`writing ${r}: ${String(t)}`))}};a.addEventListener(`abort`,p,{once:!0});try{d=e.record(n,m)}catch(e){a.removeEventListener(`abort`,p),f(),_(c),D(r),s(e)}})}const mQ=()=>{},hQ=e=>({ok:!1,error:e instanceof Error?e.message:k(e),code:`RENDER_FAILED`,daemonV:3}),gQ={ansi:e=>({ok:!0,output:dne(e)}),frame:e=>({ok:!0,frame:e})};function _Q(e,t,n,r){let{clock:i,frameFeeds:a}=e,o=i.monotonic(),s=[[`sid`,t]];try{try{var c=lo();let i=c.u(wQ(e,t,r,s));if(i===null)return null;let{drawn:o,evaluated:l,cellBreaks:u,delivered:d,lanes:f}=dQ(e.recorder,i.view,r,()=>EQ(e,i,{by:`feed`,fps:n})),p=gQ.ansi(o.body),m=MQ(e.links.to,t,o,zZ(f,a.following(t)));return{bar:o.body,resp:p,statusline:m===o.body?p:gQ.ansi(m),evaluated:l,cellBreaks:u,delivered:d,failure:null}}catch(e){c.e=e}finally{c.d()}}catch(e){let{level:t,line:n}=WZ(`render`,s,{kind:`threw`,error:e},tt(i,o)),r=hQ(e);return{bar:ane(r.error),resp:r,statusline:r,evaluated:0,cellBreaks:0,delivered:mQ,failure:{level:t,line:`frame ${n}`}}}}function vQ(e,t,n){let{sessionState:r}=e;return Xq(n.config,e=>r.get(t,e),e=>n.authoredRoots.has(e))}function yQ(e,t){try{var n=lo();let{renderCache:r}=e,i=n.u(r.holdView(t));return i===null?null:qq(i.view.source.effective(),mc(i.view.facts().hints.tmux))}catch(e){n.e=e}finally{n.d()}}function bQ(e,t,n){let r=e.frameFeeds.latest(n);return xQ(e,t,n,r===null||mc(r.hints.tmux))}function xQ(e,t,n,r){try{var i=lo();return qq(vQ(e,n,i.u(e.renderCache.hold(t.projectDir,t.cwd,t.target.path)).state),r)}catch(e){i.e=e}finally{i.d()}}function SQ(e,t,n,r){VZ(n,{renderer:r,at:t.toFixed(3)});let i=e.hints,a=br(e,i),o=xr(a);return VZ(n,{termCols:String(i.termCols??`?`),termRows:String(i.termRows??`?`),refused:a.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:i.client?.kind??`unreported`,rateLimits:e.rateLimits}),o}function CQ(e,t,n,r){let{renderCache:i}=e,a=t.hookData.workspace?.current_dir??t.cwd,o={...t,hookData:{...t.hookData,...a!==void 0&&s.isAbsolute(a)&&{location:uc(a)}}},c=SQ(o,n,r,e.rendererName);VZ(r,{encoding:o.encoding});let l=o.requested;return TQ(i.holdSession(l.projectDir,l.cwd,l.target.path,o),o,c,n,r)}function wQ(e,t,n,r){let{renderCache:i}=e,a=i.holdView(t);if(a===null){let e=i.openFailure(t);if(e!==null)throw e.error;return null}let o=a.view.facts(),s;try{s=SQ(o,n,r,e.rendererName)}catch(e){throw a[Symbol.dispose](),e}return TQ(a,o,s,n,r)}function TQ(e,t,n,r,i){try{let{entry:a,state:o,view:s}=e,{sessionId:c}=t;return{req:t,at:r,facts:i,sessionId:c,entry:a,state:o,view:s,hintsError:n,[Symbol.dispose]:()=>e[Symbol.dispose]()}}catch(t){throw e[Symbol.dispose](),t}}function EQ(e,t,n){let{sessionState:r,frameFeeds:i,renderCache:a,updateWatch:o,linkIds:s,links:c,fileEvents:l,renderWarnings:u,payloadProviders:d,effectSessions:f,menuIdle:p,launcher:m}=e,{req:h,at:g,facts:_,sessionId:v,entry:y,state:b,view:x,hintsError:S}=t,C=x.source.payload(),w=x.source.effective(),T=x.source.failure(),E=bZ(x.source);VZ(_,{lanes:fb.filter(e=>E[e]).join(`,`)||`-`}),VZ(_,{width:String(C.term.cols)});let ee=NZ(r,v,g,n.by),D=o.notice({to:c.to,sessionId:v,dismissed:r.get(v,Nz),enabled:w.updateNotice}),te=WU(y.repos,v,c),O=(e,t)=>({about:e,text:t,copy:t}),k=e=>O(e??``,e),ne=[k(Cr(h.refusedArgs)),k(S),O(`load`,y.lastError),O(`update-act`,o.error()),O(`link-ids`,s.error()),...b.dropped.map(e=>({about:`dropped\0${e.file}`,text:e.message,copy:e.prompt})),...PZ(ee).map(e=>O(`click\0${e.at}\0${e.text}`,e.text))].flatMap(({about:e,text:t,copy:n})=>e&&t&&n?[{about:e,text:t,copy:n}]:[]),A=y.watch===null?null:Dj(`config watch`,y.watch,null),re=m.launcherWarnings(g,n.by),ie=re.find(e=>e.kind===`launch-pipes`),ae=ie?.event??null,oe=[...Ac(l.delivery()),...re,...A===null?[]:[{kind:`config-watch`,message:A}],...y.lastWarning===null?[]:[{kind:`load`,message:y.lastWarning}],...T===null?[]:[{kind:`facts`,message:T.cause===`inputs`?`the bar is held on the last turn taken: ${T.reason}`:`the bar is drawn from the last facts that were read; the next could not be stamped: ${T.reason}`}]],se={config:b.config},ce=vU(c.to,v,n.by,ne,[...D,...te],[...oe.map(e=>({about:e.kind,message:e.message})),...u.ofSession(v,n.by,se).map(e=>({about:`${e.kind}\0${e.message}`,message:e.message}))].map(e=>({about:e.about,text:e.message,copy:e.message}))),le=x.source.facts(),ue={drawing:n,feeds:i.feedsOf(v,g),diagnostics:ce},de=so(C.metrics)?void 0:C.metrics;VZ(_,jq(le.sources)),VZ(_,Mq(le.runs)),VZ(_,{factsSeq:String(le.seq),prompts:String(de?.messageCount??`-`),nonPrompts:String(de?.nonPrompts??`-`),pr:dq(C.git),feeds:wZ(ue.feeds)});let fe=[],pe=f.of(v),{body:me,viewing:he,geometry:ge,evaluated:_e,cellBreaks:ve,rules:ye,idleSince:be}=p.drawn(v,g,w.menuTimeout,e=>xZ(x,ue,g,pe,e,r.get(v,nS),c.to,e=>fe.push(e))),xe=bU(ce),Se=new Map(ce.map((e,t)=>[xe[t],e.copy])),Ce=()=>a.delivered(v,n.by,Se),we=p.since(v,g);VZ(_,{menuIdle:we===void 0?`-`:`${(g-we).toFixed(1)}s/${w.menuTimeout}s`});let Te=u.drawn(v,n.by,se,fe),Ee=d.gitProvider.getStats(),De=d.usageStore.getStats(),Oe=pe.lastFrame(),ke=Oe.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,Ae=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,je=e=>{switch(e.kind){case`rule`:return`rule:${e.slot}`;case`refresh`:return`refresh:${e.variable}`;case`file-events`:return`${e.kind}:${e.state}`;case`load`:case`facts`:case`config-watch`:case`lifeline`:case`launch-pipes`:case`when`:return e.kind}},Me=[...oe,...fe].map(je).join(`,`)||`-`;return VZ(_,{git:`${Ee.size}/${Ee.hits}h/${Ee.misses}m`,usage:`${De.size}/${De.hits}h/${De.misses}m`,effect:Oe.effect,effectT:Oe.t.toFixed(3),speed:`${Oe.speed}x`,effectRows:`${Oe.made}made/${Oe.reused}reused`,effectOwn:ke,fadeBasis:Oe.basis,stateRev:String(Oe.revision),fades:Ae(Oe.fades),leaves:Ae(Oe.leaves),motion:me.motion,evaluated:String(_e),cellBreaks:String(ve),pending:me.pending.join(`,`)||`-`,rules:[...ye].map(([e,t])=>`${e}:${t}`).join(`,`)||`-`,err:ne.length>0?`Y`:`N`,clickError:ee.map(({hold:e})=>e).join(`,`)||`-`,pipeEvent:ie?.hold??`-`,upd:String(D.length),ask:String(te.length),warn:Me,diag:String(ce.length),warnRecord:Te?`new`:`kept`,viewer:he===null?`-`:`${he.index}/${ce.length}p${he.page+1}`}),{drawn:{body:me,viewerOpen:he!==null,diagnostics:ce,geometry:ge},evaluated:_e,cellBreaks:ve,answersClick:FZ(ee),pipeShown:ae,delivered:Ce,lanes:E,idleSince:be,handed:ue}}function DQ(e,t){let{laneSetups:n,tmuxStatusLines:r}=e,i=xQ(e,t.requested,t.sessionId,mc(t.hints.tmux));return r.observe(t.sessionId,t.hints.tmux,i.tmuxStatus),n.noted(t.sessionId,i)}function OQ(e,t,n){return uQ(e.recorder,t.view,n,()=>EQ(e,t,mb))}function kQ(e){return{sessionId:e.hookData.session_id,hints:e.hints,origin:e.requested,transcript:e.hookData.transcript_path,answered:cF(e.hookData)}}function AQ(e,t,n,r){let{frameFeeds:i,laneSetups:a,tmuxStatusLines:o}=e,s=i.latest(t);return s!==null&&n.tmuxStatus!==r.tmuxStatus&&o.observe(t,s.hints.tmux,r.tmuxStatus),a.clicked(t,n,r)}async function jQ(e,t,n,r,i){try{var a=lo();let{clock:o,frameFeeds:s,log:c}=e,l=a.u(CQ(e,t,n,i)),u=cQ(e.recorder,l.view,n),d=o.monotonic(),f=r-d;VZ(i,{deadline:`${t.deadline.kind}:${Math.round(f)}ms`});let p=await Gj(e=>Promise.all([u.landed,l.view.registry.inFlight(e)]),f,e=>c(`error`,`render wait failed after its deadline sid=${JSON.stringify(l.sessionId)}: ${k(e)}`),o.after),m=o.monotonic();VZ(i,{waited:`${Math.round(m-d)}ms`,ended:p,refreshed:yq(u.refreshed)});let{drawn:h,answersClick:g,pipeShown:_,delivered:v,lanes:y}=OQ(e,l,u.arrival),b=t.sessionId,x=zZ(y,s.following(b)),S=lF(t.hints.client??null)===`statusline`,C=gQ[t.encoding](S?MQ(e.links.to,b,h,x):h.body);return VZ(i,{handoff:(S?x:[]).join(`,`)||`-`,drew:`${tt(o,m)}ms`}),{resp:C,motion:h.body.motion,answersClick:g,pipeShown:_,delivered:v}}catch(e){a.e=e}finally{a.d()}}function MQ(e,t,n,r){let[i,...a]=r;return i===void 0||n.viewerOpen?n.body:WP(n.body,MU(BZ(e,t,[i,...a]),n.diagnostics,e,t,n.geometry))}const NQ=/^─{20,}/,PQ=/^❯(\s|$)/,FQ=/›\s*stashed$/;function IQ(e){let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>NQ.test(e)?[t]:[]).at(-2);return n===void 0||!PQ.test(t[n+1]??``)?null:{hint:t[n-1]??``,prompt:t[n+1]}}function LQ(e){if(e.inMode)return{kind:`in-mode`};let t=IQ(e);return t===null?{kind:`no-prompt`}:FQ.test(t.hint)?{kind:`stashed`}:{kind:`ready`}}function RQ(e){return/^❯\s*\S/u.test(IQ(e)?.prompt??``)}const zQ=/^\S+\s+\S[^…]*…\s+\((\d+[hms]\s*)+/u;function BQ(e){return e.screen.some(e=>zQ.test(e))}const VQ={"in-mode":`the Claude Code pane is in tmux copy mode — leave it (q) and click again`,stashed:`Claude Code is holding a stashed prompt (ctrl+s) — restore or send it, then click again`,"no-prompt":`Claude Code is not at its prompt (a dialog or picker is open) — close it and click again`};function HQ(e){return e===void 0?{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`}:e===null?{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only act in a tmux pane`}:{kind:`pane`,hint:e}}async function UQ(e,t,n){let r=LQ(await e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:VQ[r.kind]};let i=await e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}async function WQ(e,t,n,r,i){let a=await Us(e,t,n,r,i);if(a.kind===`failed`)throw Error(a.reason);return a}async function GQ(e,t){let n=await WQ(e,t,`claude-input.read`,[`display`,`-p`,`-t`,t.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,t.pane]);if(n.kind===`rate-limited`)throw Error(n.reason);let[r=``,...i]=n.stdout.split(`
|
|
208
208
|
`);return{inMode:r!==`0`,screen:i}}function KQ(e,t,n){return[`load-buffer`,`-b`,t,`-`,`;`,...n.length===0?[]:[`send-keys`,`-t`,e,...n,`;`],`paste-buffer`,`-p`,`-d`,`-b`,t,`-t`,e,`;`,`send-keys`,`-t`,e,`Enter`]}async function qQ(e,t,n){let r=await WQ(e,t,`claude-input.type`,KQ(t.pane,`cc-candybar-slash`,[`C-s`]),n);return r.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${r.reason})`}}function JQ(e){return{read:t=>GQ(e,t),type:(t,n)=>qQ(e,t,n)}}const YQ={launch:({what:e})=>`launch:${e}`,"type-slash":({line:e})=>`type-slash:${e}`,"apply-update":()=>`apply-update`,run:({run:e})=>`run:${e.action}`,"lane-setup":({lane:e,on:t})=>`lane-setup:${e}-${t?`on`:`off`}`,doctor:({step:e})=>`doctor:${e.kind}`};function XQ(e){let t=YQ[e.kind];return t(e)}const ZQ=`render-origin`,QQ=`client-hints`;function $Q(e,t){let n=e[t];switch(typeof n){case`boolean`:return n?Pv:Fv;case`number`:return String(n);case`string`:return n;default:return n.kind===`decided`?n.name:null}}const e$=Object.entries(ex),t$=new Set(nx.map(e=>e.sessionKey)),n$=()=>!1;function r$(e,t){return Xq(e,e=>t$.has(e)?t(e):null,n$)}const i$=[`preset`,`theme`];function a$(e,t,n){let r=new Set(i$.slice(0,n).map(e=>ex[e].sessionKey));return Xq(e,e=>r.has(e)?t(e):null,n$)}function o$(e,t){let n=Array.from({length:i$.length+1},(n,r)=>a$(e,t,r));return e=>{let t=i$.indexOf(e);return n[t===-1?i$.length:t]}}function s$(e,t,n,r){return e.flatMap(([e,i])=>{let a=$Q(t,e);return a===null||a===$Q(n(e),e)?[]:[{...i,value:a,target:r(i)}]})}function c$(e,t,n){return $Q(r$(e,t),n)}function l$(e,t){let n=r$(e,t);return s$(e$,n,o$(e,t),t=>u$(e,n.preset,t.configKey))}function u$(e,t,n){return n in(Mx(e.presets,t).globals??{})?YN(t,n):n}function d$(e,t,n){let r=jx(t(ex.preset.sessionKey),e.globals.preset,e.presets),i=XN(n);return{key:i?.scope===`globals`?u$(e,r,i.field):n,globals:Fx(e,r)}}function f$(e,t){let{preset:n}=r$(e,t);return h$(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:gy(a,s);return c===void 0||hy(c)===hy(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function p$(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return Ax(e.presets).flatMap(n=>{let i=h$(e,n);return[...new Set(i.filter(e=>r.has(e.key)).map(e=>e.id))].flatMap(e=>{let n=i.filter(t=>t.id===e);return py(Object.fromEntries(n.map(e=>[e.setting,e.decl])),Object.fromEntries(n.map(e=>{let n=r.get(e.key)??t(e.key),i=n===null?void 0:gy(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const m$=new WeakMap;function h$(e,t){let n=m$.get(e)??new Map;m$.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[...Yv(Nx(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=dy(e.segments[t.name])[n];return{id:r,setting:n,key:i,decl:a,saved:t.settings?.[n]??a.default}})),a=[...new Map(i.map(e=>[e.key,e])).values()];return n.set(t,a),a}function g$(e,t){let n=r$(e,t);return{from:n.preset,globals:Mx(e.presets,n.preset).globals??{},picks:s$(e$.filter(([e])=>e!==`preset`),n,o$(e,t),e=>e.configKey),placements:f$(e,t)}}function _$(e,t){return Xq({...e,globals:{palette:t},presets:{}},()=>null,n$)}function v$(e,t){let n=r$(e,t),r=$Q(n,`theme`);if(r===null)return{kind:`rule`};let i=_$(e,r),a=Fx(e,n.preset),o=Object.fromEntries(Yb.map(e=>[e,$Q(a[e]===void 0?n:i,e)]));return{kind:`look`,theme:r,look:o,differs:Yb.some(e=>o[e]!==$Q(i,e))}}function y$(e){return{sessionKeys:nx.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...DN(e)?QK.map(t=>YN(t,e)):[],...JN(e)?iv().map(t=>qN(t,e)):[]]}}function b$(e){return new Set(nx.map(e=>e.configKey).filter(t=>y$(t).fileKeys.some(t=>C$(e,S$(t)))))}function x$(e,t,n){let r=l$(e,n),i=new Set(r.map(e=>e.configKey)),a=ox(e=>i.has(ex[e].configKey)||t.has(ex[e].configKey)),o=v$(e,n);return{unsaved:r.length+f$(e,n).length,resettable:a,themeDefault:o.kind===`look`&&o.differs?{differs:!0,theme:o.theme}:{differs:!1}}}function S$(e){let t=XN(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return ZN(t)}function C$(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&C$(e[n],r)}function w$(e,t,n){let r=sx.get(n);if(r!==void 0)return c$(e,t,r);for(let[,t]of sy(e))if(t.key===n)return t.default??null;return null}function T$(e,t){let n=VN(e).get(t);return n===void 0?null:String(n)}const E$={inside:()=>[],defaultOf:()=>$i,menus:[]},D$=e=>`${e.key}\0${e.member}`;function O$(e){let t=new Map,n=n=>{let r=`${n.name}\0${Gv(n)}`,i=t.get(r);if(i!==void 0)return i;let a=e.segments[n.name]?.template,o=a===void 0?[]:sG(a,Gv(n));return t.set(r,o),o},r=e=>[...e.opens===void 0?[]:[e.opens.ref],...n(e)],i=new Map,a=new Map;for(let t of Object.values(e.variables))t.kind===`state`&&(t.default!==void 0&&i.set(t.key,t.default),t.within!==void 0&&a.set(t.key,t.within));let o=new Map,s=new Map,c=new Map,l=e=>{s.set(e.key,(s.get(e.key)??new Set).add(e.member))},u=(e,t)=>{let n=o.get(D$(e))??new Map;n.set(D$(t),t),o.set(D$(e),n)},d=(e,t)=>{if(e.kind===`container`){for(let n of e.children)d(n,t);return}for(let n of r(e)){l(n),c.set(D$(n),n);for(let e of t)u(e,n)}e.opens!==void 0&&d(e.opens.body,[...t,e.opens.ref])};for(let t of Ax(e.presets))d(Nx(e,t).node,[]);for(let t of Object.values(e.actions)){let e=pa(t);e!==void 0&&l(e)}for(let[e,t]of a)for(let n of s.get(e)??[])for(let r of t)u(r,{key:e,member:n});let f=new Map;return{inside:e=>{let t=f.get(D$(e));if(t!==void 0)return t;let n=new Map,r=e=>{for(let[t,i]of o.get(D$(e))??[])n.has(t)||(n.set(t,i),r(i))};r(e);let i=new Map;for(let{key:e,member:t}of n.values())i.set(e,(i.get(e)??new Set).add(t));let a=[...i].map(([e,t])=>({key:e,outside:new Set([...s.get(e)].filter(e=>!t.has(e)))}));return f.set(D$(e),a),a},menus:[...c.values()],defaultOf:e=>i.get(e)??`closed`}}const k$=new WeakMap;function A$(e){let t=k$.get(e);if(t!==void 0)return t;let n=O$(e);return k$.set(e,n),n}function j$(e,t,n){let r=new Set(n.map(e=>e.key)),i=n=>t(n)??e.defaultOf(n),a=new Set;for(let{key:t,value:o}of n){let n=i(t);if(n!==o)for(let o of e.inside({key:t,member:n})){let t=i(o.key);t!==e.defaultOf(o.key)&&!o.outside.has(t)&&!r.has(o.key)&&a.add(o.key)}}return[...a]}function M$(e,t){let n=({key:n,member:r})=>(t(n)??e.defaultOf(n))===r,r=(t,n)=>e.inside(n).some(({key:e,outside:n})=>e===t.key&&!n.has(t.member));return e.menus.filter(n).filter(t=>{let i=e.menus.filter(e=>e!==t&&r(t,e)),a=i.length>0&&e.defaultOf(t.key)===t.member;return!i.some(n)&&!a})}function N$(e,t,n){let r=(r,i,a)=>{let o=j$(t(r),t=>e.get(r,t),i);(0,X.runInAction)(()=>{a();for(let t of o)e.clear(r,t)}),o.length>0&&n(`close-nested: folded=${o.join(`,`)} (session=${r})`)},i=(t,n)=>r(t,n,()=>e.setBatch(t,n));return{get:(t,n)=>e.get(t,n),revision:t=>e.revision(t),values:t=>e.values(t),set:(e,t,n)=>i(e,[{key:t,value:n}]),setBatch:i,clear:(n,i)=>r(n,[{key:i,value:t(n).defaultOf(i)}],()=>e.clear(n,i))}}const P$=new Set([`1`,`true`]),F$=new Set([`0`,`false`,``]);function I$(e,t){let n=s1(e),r=n.scope===`segment-palette`?`string`:Qb(n.field);if(r===`string`)return JSON.stringify(t);if(r===`number`){let n=Number(t);if(!Number.isFinite(n))throw Error(`persistValueText: "${e}" expects a number, got "${t}"`);return String(n)}if(P$.has(t))return`true`;if(F$.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function L$(e){try{return h.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function R$(e,t,n){try{if(t===null){h.rmSync(or(Pn,e),{force:!0});return}dr(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function z$(e){return/^\s*$/.test(e)?null:Ca(e)}function B$(e,t){return e!==null&&Ta(e,t)!==void 0}function V$(e){if(e.kind===`segment`)return e.when===void 0?e.name:{seg:e.name,when:e.when};if(e.kind===`container`){let{kind:t,direction:n,children:r,...i}=e;return{[n===`horizontal`?`h`:`v`]:r.map(V$),...i}}return e}function H$(e){if(!vx(e))return V$(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,V$(t)])),...n}}const U$=YK,W$=U$.segments,G$=U$.presets,K$=U$.root;function q$(e,t,n,r){if(!B$(e,t)&&n===void 0)throw new R(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function J$(e,t){let n=ZN(t);return t.scope===`segment-palette`&&q$(e,[`segments`,t.segment],W$[t.segment],n.join(`.`)),n}function Y$(e){return Ca(Na(e))}function X$(){return Object.entries(K$.rows).map(([e,t])=>{let n=V$(t);return{path:[`root`],fragment:Y$({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function Z$(e,t){let n=e===null?void 0:Ta(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function Q$(e,t){if(t===void 0)return null;let n=H$(t);return{path:e,fragment:Y$(n),unit:{path:e,value:n}}}function $$(e,t){let n=[`presets`,t],r=[...n,`root`],i=G$[t];q$(e,n,i,r.join(`.`));let a=Z$(e,r)??Q$(r,i?.root);return a!==null&&$a(a.fragment)?a:null}function e1(e,t){let n=Qa(t.fragment);return n===null?new Map([[`#`,{path:t.path,unit:t.unit,node:t.fragment}]]):new Map([...e,...n.map(e=>[e.key,{path:[...t.path,`rows`,e.key],unit:t.unit,node:e.value}])])}function t1(e,t){return[...X$(),Z$(e,[`root`]),$$(e,t)].filter(e=>e!==null).reduce(e1,new Map)}function n1(e,t,n){for(let{node:r,...i}of t1(e,t).values())if(to(r,n))return i;throw new R(`${r1(e,t).join(`.`)} holds no placement "${n}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`)}function r1(e,t){return $$(e,t)?.path??[`root`]}function i1(e,t){return t.scope===`preset-root`?r1(e,t.preset):ZN(t)}function a1(e,{unit:t}){return t===null?e:Ka(e,t.path,Na(t.value),ja)}function o1(e){let t=XN(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function s1(e){let t=o1(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function c1(e,t,n,r,i){let a=y1(t,r),o,s=()=>(o??={chain:p1(t,n)}).chain;b1(t,s,a),i(t,s,a),R$(t.path,r,e.logger),e.record(t.path,n,r)}function l1(e,t,n){let r=f1(e,t(),n);if(r.length>0)throw new R(`refused: ${e.above.map(e=>e.path).join(`, `)} sets ${r.join(`, `)} over ${e.path}, so this click would change nothing on the bar — edit it there`)}const u1=()=>{};function d1(e,t){try{return t()}catch(t){throw!(t instanceof R)||e.above.length===0?t:new R(`${t.message} — or it is declared by ${e.above.map(e=>e.path).join(`, `)}, which the bar does not edit`)}}function f1(e,t,n){if(t===null)return[];let r=new Set(_1(g1(t),g1(n)));return _1(h1(e,t),h1(e,n)).filter(e=>!r.has(e))}function p1(e,t){try{return m1(e,t)}catch(e){if(e instanceof xy)return null;throw e}}function m1(e,t){return TK(e.locs,t===null?e.above:[nU(e.path),...e.above],ZK,{warned:()=>{}},{repo:e.repo,cwd:e.cwd},n=>n===e.path&&t!==null?t:h.readFileSync(n,`utf8`))}function h1(e,t){let[n]=t.layers;return n?.path===e.path?n.config:t.base}function g1(e){return e.layers.at(-1)?.config??e.base}function _1(e,t,n=``){return!v1(e)||!v1(t)?JSON.stringify(e)===JSON.stringify(t)?[]:[n]:[...new Set([...Object.keys(e),...Object.keys(t)])].flatMap(r=>_1(e[r],t[r],n===``?r:`${n}.${r}`))}function v1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y1(e,t){try{return m1(e,t)}catch(e){throw e instanceof xy?new R(`refused: the config file would not load after this click — ${e.message}`):e}}function b1(e,t,n){if(n.dropped.length===0)return;let r=t();if(r===null)return;let i=e=>e.dropped.flatMap(e=>e.issues.map(t=>({file:e.file,issue:t}))),a=new Set(i(r).map(({file:e,issue:t})=>`${e}\0${t.message}`)),o=i(n).filter(({file:e,issue:t})=>!a.has(`${e}\0${t.message}`));if(o.length>0)throw new R(`refused: this click would leave a placement of a segment nothing declares — ${o.map(({file:e,issue:t})=>new xy(e,[t]).message).join(`
|
|
209
209
|
`)}`)}function x1(e,t){let n=s1(t),r=z$(L$(e)??``),i=r===null?void 0:Ta(r,ZN(n));return i!==void 0&&`value`in i?i.value:void 0}function S1(e,t,n){C1(e,t,n,[])}function C1(e,t,n,r){let i=L$(t.path),a=n.reduce((e,[t,n])=>Ka(e,J$(z$(e),s1(t)),I$(t,n),ja),i??``);c1(e,t,i,d1(t,()=>w1(a,t.path,r,e=>e)),l1)}function w1(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=n1(z$(s),n,i),l=oee(a1(s,c),c.path,i,a,Na(o));if(l===null)throw new R(`${c.path.join(`.`)} in ${t} has no placement "${i}" — the bar you clicked is stale (it reloads on the next render)`);return l},e)}function T1(e,t,n){let r=z$(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of t1(r,t)){if(!to(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?Da(e,c):Na(s.value);if(a!==`#`)return Ka(e,[...i,`rows`,a],l,ja);if($$(r,t)!==null)throw new R(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return Ka(e,i,l,ja)}return e}function E1(e,t){return Ja(e,t,t[0]===`presets`&&t.length>2&&!$K(t[1])?2:0)}function D1(e,t,n){let r=n.map(o1),i=L$(t.path);if(i===null)return;let a=r.reduce((e,t)=>E1(e,i1(z$(e),t)),i);a!==i&&c1(e,t,i,a,u1)}function O1(e){let t=e===null?void 0:Ta(e,[`presets`]);return t?.kind===`object`?t.entries.map(e=>e.key):[]}function k1(e,t){let n=new Set([...QK,...O1(e),...t.above.flatMap(e=>Object.keys(va.default.parse(h.readFileSync(e.path,`utf8`)).presets??{}))].map(HM));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(HM(e)))}function A1(e,t,n,r,i,a){let o=L$(t.path),s=z$(o??``),c=k1(s,t),l=[`presets`,c],u=d1(t,()=>$$(s,n)),d=[...u===null?[]:[[[...l,`root`],u.unit===null?Da(o??``,u.fragment):Na(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],Na(r)]]],f=i.map(([e,t])=>{let n=YN(c,e);return[J$(s,s1(n)),I$(n,t)]}),p=[...d,...f].reduce((e,[t,n])=>Ka(e,t,n,ja),Ka(o??``,l,`{}`,ja));return c1(e,t,o,d1(t,()=>w1(p,t.path,a.map(e=>({...e,preset:c})),T1)),l1),c}function j1(e,t,n,r){let i=L$(t.path);c1(e,t,i,Ka(i??``,[`themeDefaults`,n],Na(r),ja),l1)}function M1(e,t,n){if($K(n))throw new R(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=L$(t.path),a=z$(i??``);if(i===null||a===null||Ta(a,r)===void 0)throw new R(`cannot delete preset "${n}": ${t.path} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=Ta(a,[`globals`,`preset`]);c1(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>E1(e,t),i),u1)}function rre(e,t,n,r){let i=o1(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=L$(t.path),o=r.op===`remove`?r.target:r.anchor,s=d1(t,()=>n1(z$(a??``),i.preset,o)),c=a1(a??``,s),{after:l,placed:u}=N1(c,s.path,r,()=>{let e=y1(t,c).config;return Ax(e.presets).map(t=>Nx(e,t).node)});if(l===null)throw new R(`${s.path.join(`.`)} in ${t.path} has no placement "${o}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`);return c1(e,t,a,l,l1),u}function N1(e,t,n,r){switch(n.op){case`remove`:return{after:iee(e,t,n.target),placed:null};case`insert`:{let i=rz(n.segment,n.anchor,r());return{after:aee(e,t,i,n.anchor,n.relation),placed:i}}}}const P1={inTurn:()=>`single-run`};function F1(e,t,n){let r=(r,i,a)=>{let o=i.filter(t).map(t=>({key:t,before:e.get(r,t)}));a();for(let{key:t,before:i}of o)n(r,t,i,e.get(r,t))};return{get:(t,n)=>e.get(t,n),revision:t=>e.revision(t),values:t=>e.values(t),set:(t,n,i)=>r(t,[n],()=>e.set(t,n,i)),setBatch:(t,n)=>r(t,n.map(e=>e.key),()=>e.setBatch(t,n)),clear:(t,n)=>r(t,[n],()=>e.clear(t,n))}}const I1={load:()=>({}),save:()=>{},flush:()=>{}};var L1=class{sessions;storage;head=0;atom=(0,X.createAtom)(`SessionState`);constructor(e,t=I1,n=256){this.turns=e,this.maxSessions=n,this.storage=t,this.sessions=new Map,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=new Map(Object.entries(this.storage.load()).filter(([,e])=>Object.keys(e).length>0).map(([e,t])=>[e,{values:new Map(Object.entries(t)),revision:++this.head}])),this.evictOldest(),this.persist()}get(e,t){this.atom.reportObserved();let n=this.sessions.get(e);return n?(this.touch(e,n),n.values.get(t)??null):null}revision(e){return this.atom.reportObserved(),this.sessions.get(e)?.revision??0}values(e){return this.atom.reportObserved(),Object.fromEntries(this.sessions.get(e)?.values??[])}observers(){return this.atom.observers_?.size??0}latestRevision(){return this.head}size(){return this.sessions.size}set(e,t,n){this.setBatch(e,[{key:t,value:n}])}setBatch(e,t){this.held(e),t.length!==0&&this.commit(e,e=>{t.some(({key:t,value:n})=>e.values.get(t)!==n)&&(e.revision=++this.head);for(let{key:n,value:r}of t)e.values.set(n,r)})}clear(e,t){this.held(e),this.commit(e,e=>{e.values.delete(t)&&(e.revision=++this.head)})}restore(e,t,n){this.held(e),(this.sessions.get(e)?.revision??0)!==n&&this.commit(e,e=>{e.values.clear();for(let[n,r]of Object.entries(t))e.values.set(n,r);e.revision=n,this.head=Math.max(this.head,n)})}commit(e,t){(0,X.runInAction)(()=>{let n=this.sessions.get(e)??{values:new Map,revision:0};t(n),n.values.size===0?this.sessions.delete(e):(this.touch(e,n),this.evictOldest()),this.persist(),this.atom.reportChanged()})}held(e){if(this.turns.inTurn()===null)throw Error(`session state: a write of ${JSON.stringify(e)} outside any turn`)}touch(e,t){this.sessions.delete(e),this.sessions.set(e,t)}evictOldest(){let e=this.sessions.size-this.maxSessions;if(!(e<=0)){for(let t of this.sessions.keys())if(this.sessions.delete(t),--e===0)break}}flush(){this.storage.flush()}close(){this.flush(),this.storage=I1}persist(){this.storage.save(this.serialize())}serialize(){let e=Object.create(null);for(let[t,{values:n}]of this.sessions)e[t]=Object.fromEntries(n);return e}};function R1(e){let t=new Map;return{dir:e.dir,onDisk:n=>{let r=t.get(n);if(r!==void 0)return r;let i=e.onDisk(n);return t.set(n,i),i}}}function z1(e,t){return U1(e.dir,t)??B1(e,t)}function B1(e,t){let n=e.onDisk(e.dir);for(let r of V1(t)){let i=H1(n,e.onDisk(r));if(i!==null)return s.join(i,s.relative(r,t))}return null}function V1(e){let t=s.dirname(e);return t===e?[]:[t,...V1(t)]}function H1(e,t){let n=s.relative(e,t);return n===`..`||n.startsWith(`..${s.sep}`)||s.isAbsolute(n)?null:n}function U1(e,t){let n=H1(e,t);return n===``?null:n}function W1(e,t){let n=z1(e,t);return n===null?{kind:`world`,path:t}:{kind:`home`,path:n}}var G1=class extends Error{};function K1(e,t){if(typeof t==`string`){if(!s.isAbsolute(t))throw new G1(`an older build's stored path ${JSON.stringify(t)} is not absolute`);return q1(e,t)}if(typeof t!=`object`||!t)throw new G1(`stored path is not an object: ${JSON.stringify(t)}`);let{kind:n,path:r}=t;if(typeof r!=`string`)throw new G1(`stored path has no path: ${JSON.stringify(t)}`);if(n===`home`){let t=s.join(e.dir,r);if(s.isAbsolute(r)||U1(e.dir,t)!==r)throw new G1(`stored home path ${JSON.stringify(r)} is not a plain path inside the home's root ${e.dir}`);return t}if(n===`world`){if(!s.isAbsolute(r))throw new G1(`stored world path ${JSON.stringify(r)} is not absolute`);if(U1(e.dir,r)!==null)throw new G1(`stored world path ${r} lies under the home's root ${e.dir}; a home's file is stored relative to it`);return q1(e,r)}throw new G1(`stored path has no kind of home or world: ${JSON.stringify(t)}`)}function q1(e,t){let n=z1(e,t);return n===null?t:s.join(e.dir,n)}const J1={load:()=>({}),save:()=>{}},Y1=new Set(nx.map(e=>e.sessionKey)),X1=e=>Y1.has(e)||e.startsWith(sP),Z1=8*1024*1024,Q1={past:[],future:[]},$1=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var e0=class{held=X.observable.map(void 0,{deep:!1});get state(){return this.held}set state(e){(0,X.runInAction)(()=>this.held.replace(e))}constructor(e,t,n=J1){this.sessionState=e,this.logger=t,this.storage=n,this.state=new Map(Object.entries(n.load()))}depth(e){let{past:t,future:n,savepoint:r}=this.state.get(e)??Q1;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}history(e){return this.state.get(e)??Q1}begin(){let e=new Map,t=!1,n=(n,r)=>{t=!0;let i=e.get(n)??new Map,a=i.get($1(r));i.set($1(r),a===void 0?r:{...r,before:a.before}),e.set(n,i)},r=new Map;return{sessionState:F1(this.sessionState,()=>!0,(e,i,a,o)=>{if(t=!0,!(!X1(i)&&i!==`edit.mode`)){if(i===`edit.mode`){let t=r.get(e);r.set(e,{before:t===void 0?a:t.before,after:o});return}n(e,{kind:`session`,key:i,before:a,after:o})}}),file:(e,t,r,i)=>n(e,{kind:`file`,file:t,before:r,after:i}),wrote:()=>{t=!0},written:()=>t,commit:()=>{let t=new Map(e),n=new Map(r);e.clear(),r.clear();for(let e of new Set([...t.keys(),...n.keys()])){let r=[...t.get(e)?.values()??[]].filter(e=>e.before!==e.after),i=this.history(e),a=r.length===0?i:c0(i,r),o=n.get(e),s=o===void 0?a:f0(a,o);s!==i&&this.put(e,s)}}}}undo(e){let t=this.history(e),n=t.past.at(-1);if(n===void 0)throw new R(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,u0(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new R(`rewind: edit mode has no savepoint — nothing to cancel`);let r=n.net.filter(t=>this.read(e,t)!==t.after),i=new Set(r.map($1)),a=n.net.filter(e=>!i.has($1(e))),o=r0(p0(d0(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new R(`rewind: ${r.map(h0).join(`, `)} changed since edit mode opened — kept as it is; everything else edit mode changed was put back`);return a}redo(e){let t=this.history(e),{past:n,future:r}=t,i=r.at(-1);if(i===void 0)throw new R(`redo: nothing to redo`);let a=[...n,i],o=r0(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...a0(t.savepoint,a.length-o.length,i)}),i}apply(e,t,n,r,i){let a=n===`before`?`after`:`before`,o=t.filter(t=>this.read(e,t)!==t[a]);if(o.length>0){let t=new Set(o.map($1)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:p0(n,t),future:p0(i,t),...a!==void 0&&{savepoint:{at:p0([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has($1(e))),below:p0(a.below,t)}}}),new R(`${r}: ${o.map(h0).join(`, `)} changed since that edit — refusing to overwrite it; this session's undo history no longer steps it`)}let s=[];try{for(let r of t)this.write(e,r,r[n]),s.push(r);this.put(e,i)}catch(t){try{for(let t of s.reverse())this.write(e,t,t[a])}catch(e){throw Error(`${t.message}; and putting the step back failed, so it is half-applied: ${e.message}`)}throw t}}read(e,t){return t.kind===`session`?this.sessionState.get(e,t.key):L$(t.file)}write(e,t,n){t.kind===`file`?R$(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){let n=new Map(this.state);for(n.delete(e),(t.past.length>0||t.future.length>0||t.savepoint!==void 0)&&n.set(e,t);n.size>32||t0(n)>Z1;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,n0(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${Z1} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function t0(e){let t=0;for(let{past:n,future:r,savepoint:i}of e.values())for(let e of[...n,...r,...i===void 0?[]:[i.net,...i.below]])for(let n of e)t+=(n.before?.length??0)+(n.after?.length??0);return t}function n0({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...a0(n,1,[])}:{past:e,future:t.slice(1),...a0(n,0,[])}}function r0(e){return e.slice(-50)}const i0=e=>e===lP.member;function a0(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:o0(e.net,n),below:e.below}}}function o0(e,t){let n=new Map(e.map(e=>[$1(e),e]));for(let e of t){let t=n.get($1(e));n.set($1(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const s0=e=>e.map(e=>({...e,before:e.after,after:e.before}));function c0(e,t){let n=[...e.past,t],r=r0(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...a0(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...l0(e.future,a),...i.below]},n.length-r.length,t)}}function l0(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function u0(e,t){return{past:e.past.slice(0,-1),future:r0([...e.future,t]),...a0(e.savepoint,0,s0(t))}}function d0(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...l0(r,t.at-i.length),...t.below]}function f0(e,t){if(i0(t.after)&&!i0(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!i0(t.after)&&i0(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function p0(e,t){return e.map(e=>e.filter(e=>!t.has($1(e)))).filter(e=>e.length>0)}function m0(e){return e.map(h0).join(`, `)}function h0(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function g0(e){if(typeof e!=`object`||!e)return!1;let t=e,n=e=>e===null||typeof e==`string`;return(t.kind===`session`&&typeof t.key==`string`||t.kind===`file`&&`file`in t)&&n(t.before)&&n(t.after)}function _0(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(g0))}function v0(e){if(typeof e!=`object`||!e)return!1;let t=e;return Number.isInteger(t.at)&&t.at>=0&&Array.isArray(t.net)&&t.net.every(g0)&&_0(t.below)}function y0(e){if(typeof e!=`object`||!e)return!1;let t=e;return _0(t.past)&&_0(t.future)&&(t.savepoint===void 0||v0(t.savepoint))}function b0(e,t){let n=e=>e.kind===`file`||X1(e.key)?!0:(t.add(e.key),!1),r=e=>e.map(e=>e.filter(n)).filter(e=>e.length>0),{savepoint:i}=e,a=r(e.past),o=r(e.future);return i===void 0?{past:a,future:o}:{past:a,future:o,savepoint:{at:r(e.past.slice(0,i.at)).length,net:i.net.filter(n),below:r(i.below)}}}function x0(e,t){let n=(e,n)=>e.map(e=>e.kind===`file`?{...e,file:t(e.file,n)}:e),r=(e,t)=>e.map((e,r)=>n(e,`${t} step ${r+1}`)),{past:i,future:a,savepoint:o}=e;return{past:r(i,`undo`),future:r(a,`redo`),...o!==void 0&&{savepoint:{at:o.at,net:n(o.net,`edit mode's change`),below:r(o.below,`edit mode's redo`)}}}}function S0(e,t,n){return{load:()=>{let r;try{r=h.readFileSync(e,`utf8`)}catch(e){let t=e.code;return t!==`ENOENT`&&n(`warn`,`settings-history read failed (${t}); starting empty`),{}}let i;try{i=JSON.parse(r)}catch{i=null}if(typeof i!=`object`||!i||Array.isArray(i)||!Object.values(i).every(y0))return n(`warn`,`settings-history load: unexpected shape, starting empty`),{};let a=R1(t),o;try{o=Object.entries(i).map(([e,t])=>[e,x0(t,(t,n)=>{try{return K1(a,t)}catch(t){throw t instanceof G1?new G1(`session ${e}'s ${n}: ${t.message}`):t}})])}catch(e){if(!(e instanceof G1))throw e;return n(`warn`,`settings-history load: ${e.message}; starting empty`),{}}let s=new Set,c=Object.fromEntries(o.map(([e,t])=>[e,b0(t,s)]));return s.size>0&&n(`warn`,`settings-history load: dropped the changes to ${[...s].map(e=>`"${e}"`).join(`, `)}, no longer a setting`),c},save:r=>{let i=R1(t),a=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,x0(t,e=>W1(i,e))]));try{h.mkdirSync(s.dirname(e),{recursive:!0}),dr(e,JSON.stringify(a),384)}catch(e){let t=`settings-history write failed — the change landed but is not undoable: ${e.message}`;throw n(`error`,t),Error(t)}}}}const C0=[`CLAUDE_CODE_SESSION_ID`,`CLAUDE_PROJECT_DIR`,`CLAUDE_CONFIG_DIR`,`TMUX`,`TMUX_PANE`];function w0(e){return{...Object.fromEntries(C0.map(e=>[e,void 0])),CLAUDE_CODE_SESSION_ID:e.sessionId,CLAUDE_PROJECT_DIR:e.projectDir,...e.claudeConfigDir!==void 0&&{CLAUDE_CONFIG_DIR:e.claudeConfigDir}}}const T0=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function E0(e){let t=e=>({kind:`failed`,reason:e});if(!T0(e))return t(`is not an object`);for(let[n,r]of Object.entries(e)){if(!T0(r))return t(`holds ${JSON.stringify(n)} as something other than its sightings`);for(let[e,n]of Object.entries(r))if(!SF.includes(n))return t(`marks ${JSON.stringify(e)} ${JSON.stringify(n)}, not ${SF.join(` or `)}`)}return{kind:`ok`,value:e}}function D0(e,t,n,r){return{...e,[t]:{...e[t],[n]:r}}}const O0=e=>dU(e,`doctor-marks.json`,{},E0),k0=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of terminals`},A0=(e,t)=>e.includes(t)?e:[...e,t],j0=e=>dU(e,`doctor-clicked-terminals.json`,[],k0);var M0=class extends Error{constructor(e){super(`the doctor looked at ${e} less than a second ago — click again`),this.name=`DoctorBusy`}};const N0=e=>e===void 0||e===``?{kind:`recent`}:{kind:`shell`,sessionId:e},P0=(e,t)=>t.filter(t=>e.kind===`recent`?t.ago<=300:t.sessionId===e.sessionId),F0=(e,t,n)=>{if(e.kind===`recent`)return n;let[r]=P0(e,t);return r===void 0?n:r.projectDir},I0=(e,t)=>P0(e,t).map(({role:e,frame:t,projectDir:n,claudeConfigDir:r})=>({role:e,frame:t,projectDir:n,claudeConfigDir:r}));function L0(e){let t=new Map;for(let n of e.split(`
|
|
210
210
|
`)){let e=/^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(n);if(e===null)continue;let r=Number(e[1]);t.set(r,{pid:r,ppid:Number(e[2]),command:e[3].trim()})}return t}function*R0(e,t){let n=new Set;for(let r=e.get(t);r!==void 0&&!n.has(r.pid);)n.add(r.pid),yield r,r=e.get(r.ppid)}const z0={pullRequests:e=>Object.keys(uq).some(t=>e.has(`git.${t}`)),rateLimits:e=>B0(e,`block`)||B0(e,`weekly`)};function B0(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function V0(e,t){let n=e.segments[t];return n?[...[n.template,n.when,n.bg,n.fg].flatMap(e=>e?[e]:[]),...Object.values(n.partials??{})]:[]}function H0(e,t,n){let r=EG(e),i=new Map(LC(e)),a=[...V0(e,t),...n].flatMap(e=>r.ofTemplate(e).flatMap(({reaches:e})=>e)),o=new Set,s=new Set;for(;a.length>0;){let e=a.pop();if(o.has(e))continue;o.add(e);let t=i.get(e),n=wG(e,t);n!==void 0&&s.add(n);for(let{reaches:e}of r.ofVariable(t))a.push(...e)}return s}function U0(e,t){let n=new Map;for(let r of Yv(Nx(e,t).node)){if(r.kind!==`segment`)continue;let e=n.get(r.name)??[];r.when&&e.push(r.when),n.set(r.name,e)}let r=[...n.keys()].filter(t=>oy(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,H0(e,t,n.get(t))])),a=e=>r.filter(t=>z0[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`)}}const W0=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function G0(e){if(typeof e==`string`)return W0.exec(e)?.[1]}function K0(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let{content:t,activeForm:r,status:i}=e,a=i===`in_progress`,o=a&&typeof r==`string`?r:t;typeof o==`string`&&n.push({text:o,active:a,done:i===`completed`})}return n}function q0(e){return typeof e==`string`?e:Array.isArray(e)?e.find(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`)?.text??``:``}function J0(e,t){let n=e.message?.content,r=[],i=[],a;if(Array.isArray(n))for(let e of n){if(typeof e!=`object`||!e)continue;let t=e;switch(t.type){case`tool_use`:{let{id:e,name:n}=t;if(typeof e!=`string`||typeof n!=`string`)break;r.push({id:e,name:n}),n===`TodoWrite`&&(a=K0(t.input)??a);break}case`tool_result`:{let e=t.tool_use_id;typeof e==`string`&&i.push(e);break}default:break}}let o=t===`prompt`?G0(q0(n)):void 0;if(!(r.length===0&&i.length===0&&a===void 0&&o===void 0))return{...r.length>0&&{started:r},...i.length>0&&{finished:i},...a!==void 0&&{todos:a},...o!==void 0&&{command:o}}}function Y0(e,t){return e===void 0?[d(t,`.config`,`claude`),d(t,`.claude`)].filter(e=>y(e)):[e]}async function X0(e){let t=[];for(let n of e){let e=d(n,`projects`),r=await Z0(ho(e,{withFileTypes:!0}));for(let n of r??[])n.isDirectory()&&t.push(d(e,n.name))}return t}async function Z0(e){try{return await e}catch(e){if(e.code===`ENOENT`)return;throw e}}async function Q0(e,t,n){let r=[],i=[],a=d(t,e,`subagents`);try{let t=(await ho(a)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let o of t){let t=d(a,o);if(n?.has(t)){r.push(t);continue}let s=await xo(t,void 0,void 0);if(s.kind!==`ok`){Pe(`Failed to check agent file ${t}`);continue}i=o2(i,t,s.value);let c=r2(So(s.value,e=>e.subarray(0,Math.max(0,e.indexOf(10))).toString(`utf-8`)));c.kind===`object`&&c.value.sessionId===e&&r.push(t)}}catch(e){Pe(`Failed to read subagents directory ${a}:`,e)}return{paths:r,longLines:i}}function $0(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(t2(t)===`tool_result`)return`tool-result`;let n=typeof e.origin==`object`&&e.origin!==null?e.origin.kind:void 0;if(n!==void 0&&n!==`human`)return`turn`;let r=q0(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||e2.test(r)?`claude-code`:`prompt`}const e2=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function t2(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}function n2(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=$0(e);return{timestamp:new Date(e.timestamp),type:typeof e.type==`string`?e.type:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n,role:typeof t.role==`string`?t.role:void 0,type:typeof t.type==`string`?t.type:void 0}:void 0,costUSD:typeof e.costUSD==`number`?e.costUSD:void 0,isSidechain:e.isSidechain===!0,userEntry:r,activity:J0(e,r),raw:{model:typeof e.model==`string`?e.model:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n}:void 0,requestId:typeof e.requestId==`string`?e.requestId:void 0}}}function r2(e){let t=e.trim();if(!t)return{kind:`blank`};try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?{kind:`object`,value:e}:{kind:`unparsed`,reason:`not a JSON object`}}catch(e){return{kind:`unparsed`,reason:String(e)}}}function i2(e){let t=r2(e);if(t.kind===`unparsed`)return Pe(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return n2(t.value)}catch(e){return Pe(`Failed to project JSONL line: ${e}`),null}}function a2(e){let t=[];for(let n of e.split(`
|
|
@@ -490,7 +490,7 @@ function run(argv) {
|
|
|
490
490
|
`)+1,a=0,o=0;for(let e of n.slice(r,i).split(`
|
|
491
491
|
`)){let t=r2(e);t.kind!==`blank`&&(a++,t.kind===`unparsed`&&o++)}return{lines:a,unparsed:o,whole:t}}function v4(e){let t=Eo(e,CF+1);return t.kind===`ok`?F(_4(t.value.buf,t.value.fromStart)):t}function y4(e,t){if(t.kind===`failed`)return t;let n=new Map;for(let{path:e,answered:r}of t.value)n.set(e,r||(n.get(e)??!1));return{kind:`ok`,value:[...n].map(([t,n])=>({path:t,answered:n,read:e.transcript(t)}))}}const b4={github:{loginHost:()=>`github.com`,args:e=>[`auth`,`token`,`--hostname`,e],nonZero:`logged-out`},gitlab:{loginHost:e=>e,args:()=>[`--version`],nonZero:`failed`}};async function x4(e,t){if(ec(t)===void 0)return{kind:`ok`,value:null};let n=dW(await e.launch({bin:`git`,args:[...uW],cwd:t,envOverlay:{GIT_OPTIONAL_LOCKS:`0`},timeoutMs:2e3,category:`doctor.forge`}));if(n.kind===`failed`)return n;let r=gW(n.value);if(r===null)return{kind:`ok`,value:null};let i=lW(r);if(i===null)return{kind:`ok`,value:null};let a=iW[i],o=b4[i],s=o.loginHost(cW(r)),c=await e.launch({bin:a,args:[...o.args(s)],cwd:t,timeoutMs:2e3,category:`doctor.forge`});return S4(a,s,o.nonZero,c)}function S4(e,t,n,r){let i=n=>({kind:`ok`,value:{cli:e,host:t,status:n}});return r.ok?i(`ready`):aW(r)?i(`missing`):r.reason===`non-zero`&&n===`logged-out`?i({loggedOut:tW(r.stderr)}):{kind:`failed`,reason:eW(e,r)}}function C4(e,t){let n={layers:e.layers,target:t,warnings:e.warning===null?[]:e.warning.split(`
|
|
492
492
|
`)};return e.error===null?{...n,kind:`loaded`,unused:e.unused}:{...n,kind:`failed`,error:e.error}}const w4=e=>t4(()=>Ro(e));function T4(e,t){let n=e=>JSON.stringify([e.managedDir,e.projectDir,e.userFile]),r=n(e),i=[],a=new Map;for(let o of t){let t={managedDir:e.managedDir,projectDir:o.projectDir,userFile:Ao(o.claudeConfigDir)},s=n(t);if(s===r)i.push(o);else{let e=a.get(s)??{at:t,bars:[]};e.bars.push(o),a.set(s,e)}}let o=(e,t)=>({at:e,sources:w4(e),bars:t.map(({role:e,frame:t})=>({role:e,frame:t}))});return{origin:o(e,i),elsewhere:[...a.values()].map(({at:e,bars:t})=>o(e,t))}}async function E4(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,client:await e.probeTmux(t)}}function D4(e,t){switch(e.kind){case`unreported`:return{kind:`unreported`};case`outside`:return t===void 0?{kind:`unreported`}:{kind:`seen`,identified:jne(t),tmuxClient:null};case`inside`:{if(e.client.kind===`failed`)return{kind:`unasked`,reason:e.client.reason};let t=e.client.value;return t===null?{kind:`unasked`,reason:`tmux has no client attached to the pane's session`}:{kind:`seen`,identified:Ane(t),tmuxClient:t}}}}async function O4(e,t,n,r){if(t.kind!==`seen`)return t;let{identified:i,tmuxClient:a}=t,o=n.terminalEnv;if(i.kind!==`known`)return i;let{name:s,version:c}=i.terminal;if(Tne(s))return{kind:`bundling`,name:s,version:c};if(!Ene(s))return{kind:`unread`,name:s,version:c};let{ITERM_PROFILE:l,...u}=o??{},d=a===null?{kind:`ok`,value:n.ssh===!0}:await e.remoteLogin(a.pid);return{kind:`configured`,name:s,version:c,font:d.kind===`failed`?{kind:`failed`,reason:`whether the terminal is remote could not be asked: ${d.reason}`}:d.value?{kind:`failed`,reason:`the terminal is on the far side of a remote login, so its font is on the machine it runs on`}:await e.fontInUse({name:s,version:c},a===null?o??{}:u,r)}}function k4(e){switch(e.via){case`link`:return{kind:`arrived`,delivery:e.delivery};case`tmux-status`:return{kind:`unprobed`,reason:"this run was asked from the tmux status line, whose clicks tmux runs rather than the URL handler — run `cc-candybar doctor` to probe the handler"}}}async function A4(e,t){let[n,...r]=e;return n===void 0?{kind:`unneeded`}:{kind:`needed`,segments:[n,...r],fact:await t()}}async function j4(e,t,n,r){return{pullRequests:await A4(t.pullRequests,()=>e.forge(n.cwd)),rateLimits:await A4(t.rateLimits,()=>r)}}function M4(e,t){let n=t.find(e=>e.role===`statusline`);return n===void 0?{kind:`failed`,reason:`the daemon holds no statusline render of session ${e} — none since it started, or dropped for newer sessions' renders, or only a frames display draws it, which reports no width — so no width a statusline client measured is known; run this again once the statusline has redrawn`}:{kind:`ok`,value:{columns:n.termCols,of:{kind:`session`,sessionId:e}}}}async function N4(e,t,n,r,i,a,o,s,c,l,u){let d=e.loadConfig(n),f=Xq(d.config,r,()=>!1),p=await E4(e,t.tmux),m=D4(p,t.terminalEnv),h=[...new Set([...gne(f),...aF(JSON.stringify(d.config))])].join(``),[g,_,v]=await Promise.all([h===``?{kind:`none`}:O4(e,m,t,h).then(e=>({kind:`glyphs`,glyphs:h,terminal:e})),e.daemons(),j4(e,U0(d.config,f.preset),n,a)]);return{tmux:p,width:l,terminal:m,nerdFont:g,marks:u.marks,clicked:u.clicked,daemon:{serving:i,processes:_,read:u.postMortemsRead},config:C4(d,n.target),sighted:s,frames:c.kind===`failed`?c:{kind:`read`},data:v,transcripts:y4(e,o),claudeSettings:T4({managedDir:e.managedSettingsDir,projectDir:n.projectDir,userFile:Ao(ko(t.claudeConfigDir,e.home))},c.kind===`ok`?c.value:[])}}function P4(e,t,n){switch(t.kind){case`claude-settings`:{let e=t.file.path;dr(e,Ka(No(e),t.path,JSON.stringify(t.value),Ma));let r=e=>({...e,sources:w4(e.at)}),{origin:i,elsewhere:a}=n.claudeSettings;return{kind:`ok`,value:{...n,claudeSettings:{origin:r(i),elsewhere:a.map(r)}}}}case`post-mortems-read`:{let r=e.postMortemsRead.update(e=>e.through===null||yi(t.through,e.through)?{through:t.through}:e);return r.kind===`failed`?r:{kind:`ok`,value:{...n,daemon:{...n.daemon,read:r}}}}default:return t}}const F4={entries:0,held:0,refreshes:{},failures:0,abandoned:0,lastMs:null},I4=16384;var L4=class e{startedAt;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;unknownHookFields=new Set;constructor(e){this.clock=e,this.startedAt=new Date(e.now())}firstSightOfUnknownHookField(e){let t=!this.unknownHookFields.has(e);return this.unknownHookFields.add(e),t}watchersOpened=0;watchersClosed=0;watchRefusals=0;watchErrors=0;dirWatchesOpened=0;dirWatchesClosed=0;subprocessTotal=0;subprocessInFlight=0;subprocessDraining=0;subprocessDrainedBytes=0;subprocessDrainsCut=0;subprocessPipeErrors=0;subprocessRefusals=new Map;subprocessCount=new Map;subprocessHistogram=new Map;subprocessHistogramRotator=new Map;rollingTimestamps=[];rollingHead=0;get subprocessRefused(){return this.subprocessRefusals}launchStats={onStart:e=>{this.subprocessTotal++,this.subprocessInFlight++,this.subprocessCount.set(e,(this.subprocessCount.get(e)??0)+1),this.recordRollingNow()},onEnd:(e,t)=>{this.subprocessInFlight=Math.max(0,this.subprocessInFlight-1),this.recordDuration(e,t)},onRefused:e=>{this.subprocessRefusals.set(e,(this.subprocessRefusals.get(e)??0)+1)},onDrainOpen:()=>{this.subprocessDraining++},onDrainRead:(e,t)=>{this.subprocessDrainedBytes+=t},onDrainClose:(e,t)=>{this.subprocessDraining--,t===`cut`&&this.subprocessDrainsCut++},onPipeError:()=>{this.subprocessPipeErrors++}};recordRollingNow(){let e=this.clock.monotonic();if(this.rollingTimestamps.length<I4){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%I4}recordDuration(e,t){let n=this.subprocessHistogram.get(e);if(n||(n=[],this.subprocessHistogram.set(e,n)),n.length<16){n.push(t);return}let r=(this.subprocessHistogramRotator.get(e)??0)%16;n[r]=t,this.subprocessHistogramRotator.set(e,r+1)}snapshotSubprocesses(){let e=this.clock.monotonic()-6e4,t=0;for(let n of this.rollingTimestamps)n>=e&&t++;let n={};for(let[e,t]of this.subprocessCount)t>0&&(n[e]=t);let r={},i={};for(let[e,t]of this.subprocessHistogram){if(t.length===0)continue;let n=[...t].sort((e,t)=>e-t),a=Math.floor(n.length*.5),o=Math.min(n.length-1,Math.floor(n.length*.99)),s=n[a],c=n[o];s!==void 0&&(r[e]=s),c!==void 0&&(i[e]=c)}return{total:this.subprocessTotal,inFlight:this.subprocessInFlight,lastMinute:t,byCategory:n,refused:Object.fromEntries(this.subprocessRefused),draining:this.subprocessDraining,drainedBytes:this.subprocessDrainedBytes,drainsCut:this.subprocessDrainsCut,pipeErrors:this.subprocessPipeErrors,p50DurationMs:r,p99DurationMs:i}}static referenceSnapshot(){return new e({now:()=>0,monotonic:()=>0}).snapshot({gitCache:{size:0,held:0,hits:0,misses:0,changes:0,watchers:0},usageCache:{size:0,hits:0,misses:0,sweeps:0},sources:{records:[],homes:{daemon:0,configDir:0,repo:0,directory:0,session:0,view:0,pane:0},held:{git:0,tmux:0,host:0,today:0,pluginStorage:0},pluginStorage:{folders:0,faults:{unusable:0,refused:0,error:0},lost:0}},fileEvents:{delivery:{kind:`delivering`,unreported:[],missedSince:null},stalls:0,catchUps:0,probes:0,probeFailures:0},sourceRuns:{shell:F4,file:F4,watches:0},transcriptReads:{reads:0,bytes:0,longLines:0,largestLine:0},renderCache:{size:0,held:0,retired:0,compiles:0,views:0,pinned:0,retiredViews:0,accountedBytes:0,budgetBytes:0},effectCache:{sessions:0,effects:0},menuIdle:{sessions:0,armed:0},journalTurns:{gathers:0},runs:{started:0,failed:0,timedOut:0,refused:0,running:0,queued:0},sessionState:{sessions:0,observers:0,revision:0},frameFeeds:{feeds:0,subscribers:0,drawn:0,pushed:0,refused:0,lookups:0,found:0},tmuxStatus:{sessions:0,layouts:0,writes:0,failedWrites:0},linkIds:{minted:0,reused:0,evicted:0,reservations:0,faults:0},watchersActive:0,dirWatchesActive:0,handlerProbes:[],clients:[],bundle:`/`,sourceDigest:null,daemon:{pid:0,memory:{kind:`unmeasured`},limit:0,postMortems:{kind:`ok`,value:[]}},doctorStores:{marks:{kind:`ok`,value:{}},clicked:{kind:`ok`,value:[]},postMortemsRead:{kind:`ok`,value:{through:null}}}})}snapshot(e){let t=process.memoryUsage();return{pid:process.pid,version:wn,sourceDigest:e.sourceDigest,protocolVersion:3,startedAt:this.startedAt.toISOString(),uptimeSec:Math.floor((this.clock.now()-this.startedAt.getTime())/1e3),rssBytes:t.rss,heapUsedBytes:t.heapUsed,heapTotalBytes:t.heapTotal,externalBytes:t.external,arrayBuffersBytes:t.arrayBuffers,requests:{total:this.requestsTotal,errored:this.requestsErrored,timedOut:this.requestsTimedOut,inFlight:this.inFlight},unknownHookFields:[...this.unknownHookFields],gitCache:e.gitCache,usageCache:e.usageCache,sources:e.sources,fileEvents:e.fileEvents,sourceRuns:e.sourceRuns,transcriptReads:e.transcriptReads,renderCache:e.renderCache,effectCache:e.effectCache,menuIdle:e.menuIdle,journalTurns:e.journalTurns,runs:e.runs,sessionState:e.sessionState,frameFeeds:e.frameFeeds,tmuxStatus:e.tmuxStatus,linkIds:e.linkIds,watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed,refused:this.watchRefusals,errors:this.watchErrors,dirs:{active:e.dirWatchesActive,opened:this.dirWatchesOpened,closed:this.dirWatchesClosed}},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null,handlerProbes:e.handlerProbes,clients:e.clients,bundle:e.bundle,daemon:e.daemon,doctorStores:e.doctorStores}}};const R4={connectMs:200,budgetMs:500};async function z4(e,t){return B4(await V4(e),t.includes(`--json`))}function B4(e,t){if(e.kind!==`ok`)return{stdout:``,stderr:`daemon-stats: ${Jr(e)}\n`,code:1};let n=t?JSON.stringify(e.value,null,2)+`
|
|
493
|
-
`:null,r=H4(e.value);return r===null?{stdout:n??$4(e.value),stderr:``,code:0}:{stdout:n??``,stderr:`daemon-stats: ${r}\n`,code:1}}function V4(e){return Vr(e,()=>({kind:`stats`}),R4,e=>`stats`in e?e.stats:void 0)}function H4(e,t=K4){let n=L4.referenceSnapshot(),r=q4(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let{theirs:i,mine:a}=W4(e);return`the daemon (${i}) reports no ${r.join(`, `)}; it is another build than this client (${a}), and restarts only when its own bundle changes`}function U4(e){return e.version===`1.208.
|
|
493
|
+
`:null,r=H4(e.value);return r===null?{stdout:n??$4(e.value),stderr:``,code:0}:{stdout:n??``,stderr:`daemon-stats: ${r}\n`,code:1}}function V4(e){return Vr(e,()=>({kind:`stats`}),R4,e=>`stats`in e?e.stats:void 0)}function H4(e,t=K4){let n=L4.referenceSnapshot(),r=q4(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let{theirs:i,mine:a}=W4(e);return`the daemon (${i}) reports no ${r.join(`, `)}; it is another build than this client (${a}), and restarts only when its own bundle changes`}function U4(e){return e.version===`1.208.8`&&G4(e)===En()?null:W4(e)}function W4(e){return{theirs:Y4(e.version,G4(e)),mine:Y4(wn,En())}}const G4=e=>e.sourceDigest??null,K4=Object.keys(L4.referenceSnapshot());function q4(e,t,n=``){if(Array.isArray(e))return Array.isArray(t)?[]:[n||`<snapshot>`];if(!J4(e))return[];if(!J4(t))return[n||`<snapshot>`];if(`kind`in e)return[];let r=[];for(let i of Object.keys(e)){let a=n===``?i:`${n}.${i}`;i in t?r.push(...q4(e[i],t[i],a)):r.push(a)}return r}function J4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y4(e,t){return`${e} [${t===null?`no digest`:Cn(t)}]`}function X4(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function Z4(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function Q4(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m${e%60}s`:`${Math.floor(e/3600)}h${Math.floor(e%3600/60)}m`}function $4(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` build ${Y4(e.version,e.sourceDigest)}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${Q4(e.uptimeSec)}`),t.push(` rss ${X4(e.rssBytes)}`),t.push(` heapUsed ${X4(e.heapUsedBytes)}`),t.push(` heapTotal ${X4(e.heapTotalBytes)}`),t.push(` external ${X4(e.externalBytes)}`),t.push(` arrayBuffers ${X4(e.arrayBuffersBytes)}`),t.push(``),t.push(`requests`),t.push(` total ${e.requests.total}`),t.push(` errored ${e.requests.errored}`),t.push(` timedOut ${e.requests.timedOut}`),t.push(` inFlight ${e.requests.inFlight}`),t.push(` unknownFields ${e.unknownHookFields.map(e=>JSON.stringify(e)).join(`, `)||`-`}`),t.push(``),t.push(`gitCache`),t.push(` size ${e.gitCache.size}`),t.push(` held ${e.gitCache.held}`),t.push(` hit rate ${Z4(e.gitCache.hits,e.gitCache.misses)} (${e.gitCache.hits} / ${e.gitCache.hits+e.gitCache.misses})`),t.push(` changes ${e.gitCache.changes}`),t.push(``),t.push(`usageCache`),t.push(` size ${e.usageCache.size}`),t.push(` hit rate ${Z4(e.usageCache.hits,e.usageCache.misses)} (${e.usageCache.hits} / ${e.usageCache.hits+e.usageCache.misses})`),t.push(` sweeps ${e.usageCache.sweeps}`),t.push(``),t.push(`sources`);for(let n of e.sources.records){let e=Object.entries(n.refreshes).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` ${`${n.scope}/${n.name}`.padEnd(24)} failures=${n.failures} last=${n.lastMs===null?`-`:`${n.lastMs}ms`} refreshes ${e}`)}let n=Object.entries(e.sources.homes).map(([e,t])=>`${e}:${t}`).join(` `),r=Object.entries(e.sources.held).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` homes ${n}`),t.push(` held ${r}`);let i=e.sources.pluginStorage,a=Object.entries(i.faults).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` plugin storage folders=${i.folders} lost=${i.lost} faults ${a}`),t.push(` fileEvents ${jc(e.fileEvents)}`);for(let n of[`shell`,`file`]){let r=e.sourceRuns[n];t.push(` runs.${n.padEnd(8)} entries=${r.entries} held=${r.held} failures=${r.failures} abandoned=${r.abandoned} last=${r.lastMs===null?`-`:`${r.lastMs}ms`}`)}t.push(` runs.watches ${e.sourceRuns.watches}`),t.push(``),t.push(`transcriptReads`),t.push(` reads ${e.transcriptReads.reads}`),t.push(` bytes ${X4(e.transcriptReads.bytes)}`),t.push(` long lines ${e.transcriptReads.longLines}`),t.push(` largest line ${X4(e.transcriptReads.largestLine)}`),t.push(``),t.push(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(` held ${e.renderCache.held}`),t.push(` retired ${e.renderCache.retired}`),t.push(` compiles ${e.renderCache.compiles}`),t.push(` views ${e.renderCache.views}`),t.push(` pinned ${e.renderCache.pinned}`),t.push(` retired views ${e.renderCache.retiredViews}`),t.push(` accounted ${X4(e.renderCache.accountedBytes)} / ${X4(e.renderCache.budgetBytes)}`),t.push(``),t.push(`effectCache`),t.push(` sessions ${e.effectCache.sessions}`),t.push(` effects ${e.effectCache.effects}`),t.push(``),t.push(`menuIdle`),t.push(` sessions ${e.menuIdle.sessions}`),t.push(` armed ${e.menuIdle.armed}`),t.push(``),t.push(`journalTurns`),t.push(` gathers ${e.journalTurns.gathers}`),t.push(``),t.push(`sessionState`),t.push(` sessions ${e.sessionState.sessions}`),t.push(` observers ${e.sessionState.observers}`),t.push(` revision ${e.sessionState.revision}`),t.push(``),t.push(`watchers`),t.push(` active ${e.watchers.active}`),t.push(` opened ${e.watchers.opened}`),t.push(` closed ${e.watchers.closed}`),t.push(` refused ${e.watchers.refused}`),t.push(` errors ${e.watchers.errors}`),t.push(` dirs ${e.watchers.dirs.active} open (${e.watchers.dirs.opened} opened, ${e.watchers.dirs.closed} closed)`),t.push(``),t.push(`subprocesses`),t.push(` total ${e.subprocesses.total}`),t.push(` inFlight ${e.subprocesses.inFlight}`),t.push(` lastMinute ${e.subprocesses.lastMinute}`),t.push(` draining ${e.subprocesses.draining} (${e.subprocesses.drainedBytes} bytes dropped, ${e.subprocesses.drainsCut} cut)`),t.push(` pipeErrors ${e.subprocesses.pipeErrors}`);let o=Object.entries(e.subprocesses.byCategory),s=Object.entries(e.subprocesses.refused).map(([e,t])=>[`${e} refused`,t]),c=[...o,...s].reduce((e,[t])=>Math.max(e,t.length),13);for(let[n,r]of o){let i=e.subprocesses.p50DurationMs[n],a=e.subprocesses.p99DurationMs[n],o=i!==void 0&&a!==void 0?` (p50 ${i}ms · p99 ${a}ms)`:``;t.push(` ${n.padEnd(c)} ${r}${o}`)}for(let[e,n]of s)t.push(` ${e.padEnd(c)} ${n}`);return e.nextRestartReason&&(t.push(``),t.push(`nextRestart ${e.nextRestartReason}`)),t.join(`
|
|
494
494
|
`)+`
|
|
495
495
|
`}const e3=e=>({kind:`ok`,value:e}),t3=e=>({kind:`failed`,reason:e});var n3=class{arrivals=[];arrive(e){this.arrivals=[...this.arrivals,e].slice(-16)}list(){return this.arrivals}};const r3=/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;function i3(e){return r3.test(e)?e:null}function a3(e,t){let n=e.opener(t);if(n.kind===`failed`)return n;if(n.value===null)return e3(null);let r=n.value;return e3({app:r,forwarder:e.exists(ss(r))})}async function o3(e,t){let n=e.monotonic()+5e3;for(;e.monotonic()<n;){await e.pause();let n=await e.daemon(),r=n.kind===`ok`?n.value.arrivals.find(e=>e.nonce===t):void 0;if(n.kind===`ok`&&r!==void 0)return{kind:`arrived`,delivery:r.delivery}}return null}async function s3(e){if(e.platform!==`darwin`)return{kind:`unsupported`};if(e.sockets.own!==e.sockets.handler)return{kind:`unprobed`,reason:`this shell's daemon is at ${e.sockets.own}; the URL handler delivers a link naming ${e.name} to ${e.sockets.handler}`};let t=await e.daemon();if(t.kind===`failed`)return{kind:`unprobed`,reason:`the daemon could not be asked whether a link arrives: ${t.reason}`};let n=e.nonce(),r=WS(e.name,n),i=e.open(r);return(i===null?await o3(e,n):null)??{kind:`lost`,unopened:i,opener:a3(e,r),otherBuild:t.value.otherBuild}}function c3(e,t,n,r){let i=e.launchSync({bin:n,args:[...r],category:t,timeoutMs:5e3});return i.ok?e3(i.stdout):t3(vt(i))}const l3=e=>`ObjC.import("AppKit");var u = $.NSWorkspace.sharedWorkspace.URLForApplicationToOpenURL($.NSURL.URLWithString(${JSON.stringify(e)}));u.isNil() ? "" : u.path.js`;async function u3(e){let t=await V4(e);if(t.kind!==`ok`)return t3(Jr(t).split(`
|
|
496
496
|
`).join(` — `));let n=H4(t.value,[`handlerProbes`]);if(n!==null)return t3(n);let r=[];for(let e of t.value.handlerProbes){let t=d3(e);if(t===null)return t3(`the daemon lists its probe arrivals without who delivered them, so it is from a build before the forwarder app — restart it to run the installed one`);r.push(t)}return e3({arrivals:r,otherBuild:U4(t.value)})}function d3(e){if(typeof e!=`object`||!e)return null;let{nonce:t,delivery:n}=e;if(typeof t!=`string`||typeof n!=`object`||!n)return null;let{kind:r,urlV:i}=n;return r===`cli`?{nonce:t,delivery:{kind:`cli`}}:r===`forwarder`&&typeof i==`number`?{nonce:t,delivery:{kind:`forwarder`,urlV:i}}:null}function f3(e,t){let{home:n,clock:r}=t;return{platform:process.platform,name:n.name,sockets:{own:Vn(n),handler:Hn(n.name)},monotonic:()=>r.monotonic(),nonce:de,daemon:()=>u3(t),open:t=>{let n=c3(e,`doctor.open`,`/usr/bin/open`,[`-g`,t]);return n.kind===`ok`?null:n.reason},pause:()=>rt(r,100),opener:t=>{let n=c3(e,`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,l3(t)]);if(n.kind===`failed`)return n;let r=n.value.trim();return e3(r===``?null:r)},exists:h.existsSync}}const p3=5e3;function m3(e,t,n){if(e.reason===`rate-limited`){n(`warn`,vt(e));return}throw e.reason===`aborted`?new Ks(t):Error(`${t} failed (${vt(e)})`)}async function h3(e,t,n,r,i,a){let o=S(s.join(a,`cc-candybar-handoff-`));try{let a={stdout:`/dev/null`,stderr:s.join(o,`stderr`),status:s.join(o,`status`)},c=e.launchJobSync(t,a);if(!c.ok){m3({...c,stdout:``,stderr:``,exitCode:null,signal:null},n,r);return}c.release();let l=e.clock.monotonic()+i;for(;;){let o=e.jobGroupAlive(c.pid),s=Yt(a.status);if(s!==null){if(s.kind===`exit`&&s.code===0)return;m3(s.kind===`exit`?{ok:!1,reason:`non-zero`,stdout:``,stderr:w(a.stderr,`utf8`),exitCode:s.code,signal:null}:{ok:!1,reason:`timeout`,stdout:``,stderr:``,exitCode:null,signal:null},n,r);return}if(!o)throw Error(`${n} failed (lost): the opener ended with no verdict`);if(e.clock.monotonic()>=l){r(`info`,`${t.category} handed off at ${i}ms, pid ${c.pid}`);return}await rt(e.clock,50)}}finally{E(o,{recursive:!0,force:!0,maxRetries:3})}}function g3(e,t){_3(t,{bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`},`pbcopy`)}function _3(e,t,n){e.effect({kind:`launch`,spec:t,what:n})}const v3=(e,[t=``],n)=>{g3(t,n)},y3=new Set([`request`,`feed`]);function b3(e){if(!y3.has(e))throw new R(`unknown renderer ${JSON.stringify(e)}`);return e}const x3=(e,t,n)=>{let[r=``,i=``]=t,a=n.diagnosticCopy(e,b3(r),i);if(a===void 0)throw new R(`that message is no longer listed in session ${e}'s diagnostics — open ⚠ again and copy from there`);g3(a,n)},S3=(e,[t=``],n)=>{_3(n,{bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,t],category:`click.open`},`open -a "Visual Studio Code"`)},C3=(e,t,n)=>{n.navigating.get(e,`toolbar-expanded`)?n.navigating.clear(e,`toolbar-expanded`):n.navigating.set(e,`toolbar-expanded`,`1`)},w3=(e,t,n)=>{let r=n.gates.state.gateFor(I3(n,e));if(t.length===0)throw new R(`set-state: <key>/<value> is required (have keys: ${r.listKeys().join(`, `)})`);if(t.length%2!=0)throw new R(`set-state: expected even-count <key>/<value> pairs, got ${t.length} segment(s) after session id (have keys: ${r.listKeys().join(`, `)})`);let i=[];for(let e=0;e<t.length;e+=2){let n=t[e],a=t[e+1];if(!n)throw new R(`set-state: empty key at pair ${e/2+1} (expected <sessionId>/<key>/<value>[/<key>/<value>...] segments)`);let o=r.validate(n,a);if(!o.ok)throw new R(`set-state: pair ${e/2+1}: ${o.reason}`);i.push({key:n,value:o.value})}O3(n,e,`set-state`,i),n.navigating.setBatch(e,i);let a=i.map(e=>`${e.key}=${e.value}`).join(` `);n.log(`info`,`set-state: ${a} (session=${e})`)},T3=/^-?\d+$/;function E3(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const D3=(e,t,n)=>{let[r=``,i=``]=t;if(!r)throw new R(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!T3.test(i))throw new R(`step-state: delta must be an integer, got "${i}"`);let a=parseInt(i,10),o=I3(n,e),s=n.gates.state.gateFor(o),c=s.rangeParamsFor(r);if(!c)throw new R(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${s.listKeys().join(`, `)})`);let l=n.sessionState.get(e,r),u=l&&T3.test(l)?k3(c,parseInt(l,10)):A3(`step-state`,r,c,w$(o,t=>n.sessionState.get(e,t),r)),d=E3(u,a,c.min,c.max),f=s.validate(r,String(d));if(!f.ok)throw new R(`step-state: ${f.reason}`);O3(n,e,`step-state`,[{key:r,value:f.value}]),n.navigating.set(e,r,f.value),n.log(`info`,`step-state: ${r} ${u}→${f.value} (by ${a}, session=${e})`)};function O3(e,t,n,r){let i=r.filter(e=>e.key.startsWith(sP));if(i.length===0)return;let a=p$(I3(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new R(`${n}: refused — ${a.join(`; `)}`)}function k3(e,t){return Math.max(e.min,Math.min(e.max,t))}function A3(e,t,n,r){if(r===null)return n.min;if(!T3.test(r))throw new R(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return k3(n,parseInt(r,10))}function j3(e,t){return t===null?{source:`search`}:e===`argument`||e===`environment`?{source:e,path:t}:{source:`unknown`,path:t}}function M3(e,t){let n;try{n=JSON.parse(e)}catch{throw new R(`render origin is not JSON: ${e}`)}if(typeof n!=`object`||!n)throw new R(`render origin is not an object: ${e}`);let{projectDir:r,cwd:i,configFile:a,source:o}=n;if(typeof r!=`string`||typeof i!=`string`||a===void 0)throw new R(`render origin has the wrong shape: ${e}`);let s;try{s=a===null?null:K1(t,a)}catch(e){throw e instanceof G1?new R(`render origin: ${e.message}`):e}return{projectDir:r,cwd:i,target:j3(o,s)}}function N3(e,t){let n=P3(e,t);if(n===null)throw new R(`session ${t} has not rendered yet — no config to act on`);return n}function P3(e,t){let n=e.sessionState.get(t,ZQ);return n===null?null:M3(n,e.storedRoot)}function F3(e,t,n){let r=P3(e,t);if(r===null)return;let{path:i}=z3(e,r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function I3(e,t){return e.configFor(N3(e,t))}function L3(e,t){let n=P3(e,t);if(n===null)return null;let r=()=>e.lanes.of(n,t);return{sessionId:t,before:r(),read:r}}function R3(e,t){let n=P3(e,t);return n===null?E$:A$(e.configFor(n))}function z3(e,t){return sU(e.locations,VU(e.stateDir).read(),t.projectDir,t.cwd,t.target.path)}function B3(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.log}}const V3=(e,t,n)=>{let[r=``,i=``]=t,a=N3(n,e),o=n.configFor(a),s=n.gates.config.gateFor(o);if(!r)throw new R(`set-config: <key>/<value> is required (have keys: ${s.listKeys().join(`, `)})`);let c=s.validate(r,i);if(!c.ok)throw new R(`set-config: ${c.reason}`);let l=z3(n,a),u=d$(o,t=>n.sessionState.get(e,t),r);S1(B3(n,e),l,[[u.key,c.value]]),n.reloadConfig(a),n.log(`info`,`set-config: ${u.key}=${c.value} → ${l.path} (session=${e})`)},H3=(e,t,n)=>{let[r=``,i=``]=t;if(!r)throw new R(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!T3.test(i))throw new R(`step-config: delta must be an integer, got "${i}"`);let a=parseInt(i,10),o=N3(n,e),s=n.configFor(o),c=n.gates.config.gateFor(s),l=c.rangeParamsFor(r);if(!l)throw new R(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${c.listKeys().join(`, `)})`);let u=z3(n,o),d=d$(s,t=>n.sessionState.get(e,t),r),f=x1(u.path,d.key),p=typeof f==`number`?k3(l,f):A3(`step-config`,r,l,T$(d.globals,r)),m=E3(p,a,l.min,l.max),h=c.validate(r,String(m));if(!h.ok)throw new R(`step-config: ${h.reason}`);S1(B3(n,e),u,[[d.key,h.value]]),n.reloadConfig(o),n.log(`info`,`step-config: ${d.key} ${p}→${h.value} (by ${a}) → ${u.path} (session=${e})`)},U3=(e,t,n)=>{let r=N3(n,e),i=n.configFor(r),a=t=>n.sessionState.get(e,t),o=l$(i,a),s=f$(i,a);if(o.length+s.length===0){n.log(`info`,`save: nothing unsaved (session=${e})`);return}let c=n.gates.state.gateFor(i),l=o.map(e=>{let t=c.validate(e.sessionKey,e.value);if(!t.ok)throw new R(`save: ${t.reason}`);return[e.target,t.value]});G3(`save`,c,s);let u=z3(n,r);C1(B3(n,e),u,l,s),n.reloadConfig(r);for(let t of[...o.map(e=>e.sessionKey),...s.map(e=>e.key)])n.sessionState.clear(e,t);n.log(`info`,`save: ${[...l.map(([e,t])=>`${e}=${t}`),...s.map(W3)].join(` `)} → ${u.path} (session=${e})`)},W3=e=>`${e.preset}/${e.id}.settings.${e.setting}=${hy(e.value)}`;function G3(e,t,n){for(let r of n){let n=t.validate(r.key,hy(r.value));if(!n.ok)throw new R(`${e}: ${n.reason}`)}}const K3=(e,t,n)=>{let r=N3(n,e),i=n.configFor(r),a=g$(i,t=>n.sessionState.get(e,t)),o=n.gates.state.gateFor(i),s=a.picks.map(e=>{let t=o.validate(e.sessionKey,e.value);if(!t.ok)throw new R(`save-preset: ${t.reason}`);return[e.configKey,t.value]});G3(`save-preset`,o,a.placements);let c=z3(n,r),l=A1(B3(n,e),c,a.from,a.globals,s,a.placements);n.reloadConfig(r);for(let t of[...nx.map(e=>e.sessionKey),...a.placements.map(e=>e.key)])n.sessionState.clear(e,t);n.sessionState.set(e,ex.preset.sessionKey,l),n.log(`info`,`save-preset: ${[`${l} from=${a.from}`,...s.map(([e,t])=>`${e}=${t}`),...a.placements.map(W3)].join(` `)} → ${c.path} (session=${e})`)},q3=(e,t,n)=>{let r=N3(n,e),i=v$(n.configFor(r),t=>n.sessionState.get(e,t));if(i.kind===`rule`)throw new R(`save-theme-default: the theme is chosen by a rule (globals.palette), so there is no name to save as a theme's default — pick one in the menu first`);let a=z3(n,r);j1(B3(n,e),a,i.theme,i.look),n.reloadConfig(r);let o=new Set(l$(n.configFor(r),t=>n.sessionState.get(e,t)).map(e=>e.sessionKey)),s=Yb.map(e=>ex[e].sessionKey).filter(e=>!o.has(e));for(let t of s)n.sessionState.clear(e,t);n.log(`info`,`save-theme-default: ${i.theme} ${Yb.map(e=>`${e}=${i.look[e]}`).join(` `)} → ${a.path} (session=${e})`)},J3=(e,t,n)=>{let[r=``]=t;if(!r)throw new R(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let i=N3(n,e),a=z3(n,i);M1(B3(n,e),a,r),n.reloadConfig(i);let o=ex.preset.sessionKey;n.sessionState.get(e,o)===r&&n.sessionState.clear(e,o),n.log(`info`,`delete-preset: ${r} ← ${a.path} (session=${e})`)},Y3=(e,t,n)=>{let r=t,i=N3(n,e),a=n.gates.config.gateFor(n.configFor(i)).listKeys(),o=r.length===0?[``]:r.filter(e=>!a.includes(e));if(o.length>0)throw new R(`reset-config: unknown config key "${o.join(`", "`)}" (have: ${a.join(`, `)})`);let s=z3(n,i),c=r.map(y$),l=c.flatMap(e=>e.fileKeys),u=c.flatMap(e=>e.sessionKeys);D1(B3(n,e),s,l),n.reloadConfig(i);for(let t of u)n.sessionState.clear(e,t);n.log(`info`,`reset-config: ${[...l,...u.map(e=>`session:${e}`)].join(` `)} ← ${s.path} (session=${e})`)};function X3(e,t){let n=(e,t)=>[...Yv(Nx(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(Ax(t.presets).flatMap(e=>n(t,e).map(t=>cP(HM(e),Gv(t)))));return Ax(e.presets).flatMap(t=>n(e,t).map(e=>({member:cP(HM(t),Gv(e)),node:e})).filter(({member:e})=>!r.has(e)))}function Z3(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[iP]:[]])}const Q3=(e,t,n)=>{let[r=``,i=``]=t,a=N3(n,e),o=n.configFor(a),s=n.gates.config.gateFor(o);if(!r)throw new R(`apply-layout-op: <key>/<op> is required (have: ${s.listKeys().join(`, `)})`);let c=s.validate(r,i);if(!c.ok)throw new R(`apply-layout-op: ${c.reason}`);let l=nz(c.value);if(l===null)throw new R(`apply-layout-op: "${c.value}" is not a layout op token`);let u=z3(n,a),d=rre(B3(n,e),u,r,l);n.reloadConfig(a);let f=Z3(X3(o,n.configFor(a)),n.sessionState.get(e,iP)).filter(t=>n.sessionState.get(e,t)!==null);for(let t of f)n.sessionState.clear(e,t);n.log(`info`,`apply-layout-op: ${r} ${c.value} → ${u.path} placed=${JSON.stringify(d)} released=${JSON.stringify(f)} (session=${e})`)},$3=(e,t,n)=>{n.journal.commit();let r=n.history.undo(e);n.journal.wrote(),F3(n,e,r),n.log(`info`,`undo: restored ${m0(r)} (session=${e})`)},e6=(e,t,n)=>{let{step:r,discarded:i}=n.navigation.back(e,n.sessionState,n.gates.state.gateFor(I3(n,e))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);n.log(`info`,`back: ${a} discarded=${i} (session=${e})`)},t6=(e,t,n)=>{n.journal.commit(),n.journal.wrote();let r=n.history.rewind(e);F3(n,e,r),n.log(`info`,`rewind: put back ${m0(r)||`nothing`} as edit mode found it (session=${e})`)},n6=(e,t,n)=>{n.journal.commit();let r=n.history.redo(e);n.journal.wrote(),F3(n,e,r),n.log(`info`,`redo: re-applied ${m0(r)} (session=${e})`)},r6=(e,t,n)=>{n.effect({kind:`apply-update`})};function i6(e,t){let n=e.sessionState.get(t,QQ);if(n===null)throw new R(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new R(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new R(`client hints record is not an object: ${n}`);return yr(r)}function a6(e,t,n){let r=ZF(n);e.sessionState.setBatch(t,mI(r)),e.log(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${tI(n.config)} ${fI(n.nerdFont,n.marks)} ${nI(n.terminal,n.clicked)} ${rI(n.terminal,n.width)} ${iI(n.install)} ${oI(n.daemon)} ${sI(n.data)} ${dI(n.transcripts)} ${cI(n.frames,n.claudeSettings)} ${uI(n.claudeSettings.origin.sources)} (session=${t})`)}function o6(e,t,n){e.effect({kind:`doctor`,session:t,step:n,arrival:e.arrival})}function s6(e,t){let n=e=>{throw Error(`doctor: the gather ${e}; a gather writes nothing`)};return{get:(n,r)=>{let i=e.get(n,r);return t.set(JSON.stringify([n,r]),{what:r,value:i,again:e=>e.get(n,r)}),i},values:()=>n(`read every key; a gather reads keys by name`),revision:t=>e.revision(t),set:(e,t)=>n(`set ${t}`),setBatch:()=>n(`wrote a batch`),clear:(e,t)=>n(`cleared ${t}`)}}function c6(e,t,n){for(let{what:t,value:r,again:i}of n.reads)if(i(e.sessionState)!==r)return t;let r=e.doctor.loadConfig(N3(e,t));return r.config===n.load.config&&r.error===n.load.error&&r.warning===n.load.warning?null:`config`}function l6(e,t){let{tmux:n,claudeConfigDir:r,terminalEnv:i,ssh:a}=i6({sessionState:e},t);return{tmux:n,claudeConfigDir:r,terminalEnv:i,ssh:a}}async function u6(e,t,n,r){let i=new Map,a={...e,sessionState:s6(e.sessionState,i)},o=e=>JSON.stringify(l6(e,t)),s=l6(e.sessionState,t);i.set(`hints`,{what:QQ,value:JSON.stringify(s),again:o});let c=r.loadConfig(N3(a,t)),l={kind:`clicked`,sessionId:t,via:n.via},u=e.clients.ofSession(t,e.now()),d;try{d=await N4({...r,loadConfig:()=>c},s,N3(a,t),e=>a.sessionState.get(t,e),{kind:`ok`,value:e.serving()},{kind:`ok`,value:u.map(e=>e.rateLimits)},{kind:`ok`,value:u.map(e=>e.transcript)},l,{kind:`ok`,value:I0(l,u)},M4(t,u),a4(e.doctorStores))}catch(e){throw e instanceof M0?new R(e.message):e}return{facts:d,install:r4(r.install,e.bundle,u.map(e=>e.client)),stamp:{load:c,reads:[...i.values()]}}}async function d6(e,t){let n=o4(e.doctor),r=t.session;return e.journalTurns.gathering(async()=>{let i=await u6(e,r,t.arrival,n);return c6(e,r,i.stamp)===null?i:u6(e,r,t.arrival,n)})}function f6(e,t,n,{facts:r,install:i}){let a=a4(e.doctorStores),o={...r,marks:a.marks,clicked:a.clicked,daemon:{...r.daemon,read:a.postMortemsRead}};return{...o,urlHandler:k4(n),install:i,clicked:p6(e,n,o)}}function p6(e,t,{terminal:n,clicked:r}){let i=n.kind===`seen`?vF(n.identified):null;if(i===null||t.via!==`link`)return r;try{return e.doctorStores.clicked.update(e=>A0(e,i))}catch(t){return e.log(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(i)}: ${t instanceof Error?t.message:String(t)}`),r}}const m6={run:(e,t,n,r)=>a6(e,t,r),fix:(e,t,{check:n},r)=>{let i=n.probe(r);if(i.ok||i.fix===void 0)throw new R(`doctor-fix: ${n.label} — ${i.ok?`nothing to fix`:i.reason}`);let a=P4(e.doctorStores,i.fix,r);if(a.kind===`failed`)throw new R(`doctor-fix: ${n.label} — ${a.reason}`);e.log(`info`,`doctor-fix: ${n.name} → ${Lne(i.fix)} (session=${t})`),a6(e,t,a.value)},mark:(e,t,{check:n,mark:r},i)=>{let a=n.probe(i);if(a.ok||a.sighting===void 0)throw new R(`doctor-mark: ${n.label} — ${a.ok?`nothing to mark`:`shows nothing to look at`}`);let o=e.doctorStores.marks.update(e=>D0(e,n.name,a.sighting.id,r));if(o.kind===`failed`)throw new R(`doctor-mark: ${o.reason}`);e.log(`info`,`doctor-mark: ${n.name} ${r} on ${a.sighting.id} (session=${t})`),a6(e,t,{...i,marks:o})}};function h6(e,t,n){let r=t.session,i=c6(e,r,n.stamp);if(i!==null)throw new R(`doctor: the session's ${i} changed during the doctor's probes — click again`);g6(e,r,t.step,f6(e,r,t.arrival,n))}function g6(e,t,n,r){let i=m6[n.kind];i(e,t,n,r)}const _6=(e,t,n)=>{o6(n,e,{kind:`run`})},v6=(e,t)=>{if(!e.ok)throw new R(`probe: ${e.problem}`);let n=e.value;if(t.arrival.via!==`link`)throw new R(`probe: a probe arrives only as a link`);let{delivery:r}=t.arrival;t.probes.arrive({nonce:n,delivery:r}),t.log(`info`,`probe: arrived nonce=${n} delivery=${r.kind}`)},y6=(e,t,n)=>{let[r=``]=t,i=QF(r);if(i===void 0)throw new R(`doctor-fix: unknown check "${r}"`);o6(n,e,{kind:`fix`,check:i})},b6=(e,t,n)=>{let[r=``,i=``]=t,a=QF(r);if(a===void 0)throw new R(`doctor-mark: unknown check "${r}"`);if(!SF.includes(i))throw new R(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${SF.join(` or `)}`);o6(n,e,{kind:`mark`,check:a,mark:i})},x6=(e,t,n)=>{let[r=``]=t,i=Object.values(n.configFor(N3(n,e)).actions).filter(e=>`slash`in e),a=i.find(e=>e.slash===r);if(a===void 0)throw new R(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(i.map(e=>e.slash))].join(`, `)||`none`})`);let o=HQ(i6(n,e).tmux);if(o.kind===`refused`)throw new R(`${r} was not typed: ${o.reason}`);n.effect({kind:`type-slash`,pane:o.hint,line:a.slash})};function S6(e,[t=``,n=``,r=``],i){let a=N3(i,e),o=i.configFor(a).actions,s=Object.hasOwn(o,t)?o[t]:void 0;if(s===void 0||!(`run`in s))throw new R(`"${t}" is not a run action this session's config declares`);let c=Ux(s);if(!i.links.signer.verify({sessionId:e,action:t,declaration:c,evaluated:n},r))throw new R(`the link's signature does not match what it carries: it was not drawn by this daemon, or its action has been edited since it was drawn`);let l;try{l=JSON.parse(n)}catch{throw new R(`run ${t}: what the link carries is not JSON`)}let[u,...d]=l.run;if(u===void 0||u===``)throw new R(`run ${t}: the program evaluated to nothing`);let f=i.sourcesFor(a);return{sessionId:e,action:t,argv:[u,...d],envOverlay:{...w0({sessionId:e,projectDir:a.projectDir,claudeConfigDir:i6(i,e).claudeConfigDir}),...l.env},cwd:s.cwd??i.locations.homeDir,refreshes:s.refreshes.map(e=>({name:e,storage:f.get(e)}))}}const C6=new Map([[sS,v3,[1,1]],[cS,S3,[1,1]],[aS,w3,[0,1/0]],[oS,D3,[2,2]],[uS,V3,[2,2]],[dS,H3,[2,2]],[gS,Y3,[0,1/0]],[fS,U3,[0,0]],[pS,K3,[0,0]],[mS,q3,[0,0]],[hS,J3,[1,1]],[_S,Q3,[2,2]],[vS,$3,[0,0]],[yS,n6,[0,0]],[bS,e6,[0,0]],[xS,t6,[0,0]],[lS,C3,[0,0]],[SS,r6,[0,0]],[CS,_6,[0,0]],[wS,y6,[1,1]],[TS,b6,[2,2]],[kS,x6,[1,1]],[`run`,(e,t,n)=>{let r=S6(e,t,n);n.effect({kind:`run`,id:n.runs.superseded(r),run:r})},[3,3]],[AS,(e,t,n)=>{let[r=``,i=``,a=``]=t,o=i;if(!n.links.signer.verify(UU(e,r,o),a))throw new R(`the answer's signature does not match what it carries: it was not drawn by this daemon`);let s=HU(VU(n.stateDir),r,o);if(s.kind===`failed`)throw Error(`${r} was not ${o}: ${s.reason}`);n.journal.wrote();let{superseded:c,absent:l,unchecked:u}=s.value;n.log(`info`,`repo-config: ${r} ${o} superseded=${c.join(`,`)||`-`} absent=${l.join(`,`)||`-`} unchecked=${u.length===0?`-`:JSON.stringify(u)} (session=${e})`),n.reloadConfig(N3(n,e))},[3,3]],[jS,x3,[2,2]]].map(([e,t,n])=>[e,{handler:t,takes:n}]));new Set(C6.keys());function w6(e,t,n){let[r=``,...i]=n.split(`/`);return{verb:e,leaf:t,session:T6(r),args:Js(()=>i.map(decodeURIComponent))}}function T6(e){let t=Js(()=>decodeURIComponent(e));return t.ok?eQ(t.value):{ok:!1,problem:`has ${t.problem}`}}function E6({verb:e,value:t}){let n=C6.get(e);return n===void 0?{verb:e,leaf:n}:w6(e,n,t)}function D6(e){return e.find(e=>e.leaf!==void 0)?.session??null}function O6(e){let t=Js(()=>decodeURIComponent(e));if(!t.ok)return t;let n=i3(t.value);return n===null?{ok:!1,problem:`the value is not a probe nonce`}:{ok:!0,value:n}}const k6={[iS]:e=>{let t=JS(KS(e)).map(E6);return{kind:iS,effects:t,session:D6(t)}},[ES]:e=>({kind:ES,nonce:O6(e)})};function A6(e,t){return OS(e)?k6[e](t):null}function j6(e){return e.kind===`dispatch`&&e.session?.ok?e.session.id:null}function M6({verb:e,leaf:t,session:n,args:r},i,a){let o=[];try{if(!n.ok)throw new R(`session id ${n.problem}`);if(!i?.ok)throw new R(`its click's own session is refused, so no step of it runs`);if(i.id!==n.id)throw new R(`names session ${n.id}, not the session its click is in`);if(!r.ok)throw new R(r.problem);let[e,s]=t.takes;if(r.value.length<e||r.value.length>s)throw new R(`reads ${e===s?e:`${e} to ${s}`} after its session, and the link carries ${r.value.length}`);t.handler(n.id,r.value,{...a,effect:e=>void o.push(e)})}catch(t){throw t instanceof R&&N6.get(e)?.(a,{sid:i?.ok?i.id:`-`,args:r.ok?r.value:[],reason:t.message}),t}for(let e of o)a.effect(e)}const N6=new Map([[`run`,(e,{sid:t,args:[n],reason:r})=>e.runs.refused(t,n||`-`,r)]]);function P6(e,t,n){let r=[],i=!1;for(let a of e){if(a.leaf===void 0){r.push(`unknown effect verb "${a.verb}"`);continue}try{M6(a,t,n)}catch(e){e instanceof R||(i=!0),r.push(`${a.verb}: ${e instanceof Error?e.message:String(e)}`)}}if(r.length>0){t?.ok&&AZ(n.sessionState,t.id,r.join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptctl/cc-candybar",
|
|
3
|
-
"version": "1.208.
|
|
3
|
+
"version": "1.208.8",
|
|
4
4
|
"description": "Statusline renderer for Claude Code — a JSON5-configurable DSL with daemon-cached data sources, byte-clean palette-aware composition, and OSC8 click verbs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
"yaml": "^2.9.1"
|
|
111
111
|
},
|
|
112
112
|
"optionalDependencies": {
|
|
113
|
-
"@promptctl/cc-candybar-darwin-arm64": "1.208.
|
|
114
|
-
"@promptctl/cc-candybar-darwin-x64": "1.208.
|
|
115
|
-
"@promptctl/cc-candybar-linux-arm64": "1.208.
|
|
116
|
-
"@promptctl/cc-candybar-linux-x64": "1.208.
|
|
113
|
+
"@promptctl/cc-candybar-darwin-arm64": "1.208.8",
|
|
114
|
+
"@promptctl/cc-candybar-darwin-x64": "1.208.8",
|
|
115
|
+
"@promptctl/cc-candybar-linux-arm64": "1.208.8",
|
|
116
|
+
"@promptctl/cc-candybar-linux-x64": "1.208.8"
|
|
117
117
|
}
|
|
118
118
|
}
|